MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/netdata/usr/share/netdata/web/v3/npm.maplibre.994c572adb7df2585c06.chunk.js
/*! For license information please see npm.maplibre.994c572adb7df2585c06.chunk.js.LICENSE.txt */
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"6866bb78c87eb499c83445c224071f481cf2061d"};var t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="99b3f2fa-f2ef-4d1d-b6e4-ba8d2aa71d3d",e._sentryDebugIdIdentifier="sentry-dbid-99b3f2fa-f2ef-4d1d-b6e4-ba8d2aa71d3d")}catch(e){}}(),(globalThis.webpackChunkcloud_frontend=globalThis.webpackChunkcloud_frontend||[]).push([[2492],{49367(){},16443(e){e.exports=function(){"use strict";var e={},t={};function i(i,r,n){if(t[i]=n,"index"===i){var s="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);",o={};return t.shared(o),t.index(e,o),"undefined"!==typeof window&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([s],{type:"text/javascript"}))),e}}return i("shared",["exports"],function(e){function t(e,t,i,r){return new(i||(i=Promise))(function(n,s){function o(e){try{l(r.next(e))}catch(e){s(e)}}function a(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,a)}l((r=r.apply(e,t||[])).next())})}function i(e,t){this.x=e,this.y=t}function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,s;"function"==typeof SuppressedError&&SuppressedError,i.prototype={clone(){return new i(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround(e,t){const i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:i},i.convert=function(e){if(e instanceof i)return e;if(Array.isArray(e))return new i(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new i(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var o=function(){if(s)return n;function e(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r}return s=1,n=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)<t)return i;var s=this.sampleCurveDerivativeX(i);if(Math.abs(s)<1e-6)break;i-=n/s}var o=0,a=1;for(i=e,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-e)<t));r++)e>n?o=i:a=i,i=.5*(a-o)+o;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},n}(),a=r(o);let l,c;function h(){return null==l&&(l="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),l}function u(){if(null==c&&(c=!1,h())){const e=5,t=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(t){for(let r=0;r<e*e;r++){const i=4*r;t.fillStyle=`rgb(${i},${i+1},${i+2})`,t.fillRect(r%e,Math.floor(r/e),1,1)}const i=t.getImageData(0,0,e,e).data;for(let t=0;t<e*e*4;t++)if(t%4!=3&&i[t]!==t){c=!0;break}}}return c||!1}var d=1e-6,p="undefined"!=typeof Float32Array?Float32Array:Array;function f(){var e=new p(9);return p!=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 m(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 g(){var e=new p(3);return p!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function _(e){var t=e[0],i=e[1],r=e[2];return Math.sqrt(t*t+i*i+r*r)}function y(e,t,i){var r=new p(3);return r[0]=e,r[1]=t,r[2]=i,r}function x(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function v(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function b(e,t,i){var r=t[0],n=t[1],s=t[2],o=i[0],a=i[1],l=i[2];return e[0]=n*l-s*a,e[1]=s*o-r*l,e[2]=r*a-n*o,e}var w,T=_;function S(e,t,i){var r=t[0],n=t[1],s=t[2],o=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*s+i[12]*o,e[1]=i[1]*r+i[5]*n+i[9]*s+i[13]*o,e[2]=i[2]*r+i[6]*n+i[10]*s+i[14]*o,e[3]=i[3]*r+i[7]*n+i[11]*s+i[15]*o,e}function P(){var e=new p(4);return p!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function I(e,t,i,r){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",s=Math.PI/360;t*=s,r*=s,i*=s;var o=Math.sin(t),a=Math.cos(t),l=Math.sin(i),c=Math.cos(i),h=Math.sin(r),u=Math.cos(r);switch(n){case"xyz":e[0]=o*c*u+a*l*h,e[1]=a*l*u-o*c*h,e[2]=a*c*h+o*l*u,e[3]=a*c*u-o*l*h;break;case"xzy":e[0]=o*c*u-a*l*h,e[1]=a*l*u-o*c*h,e[2]=a*c*h+o*l*u,e[3]=a*c*u+o*l*h;break;case"yxz":e[0]=o*c*u+a*l*h,e[1]=a*l*u-o*c*h,e[2]=a*c*h-o*l*u,e[3]=a*c*u+o*l*h;break;case"yzx":e[0]=o*c*u+a*l*h,e[1]=a*l*u+o*c*h,e[2]=a*c*h-o*l*u,e[3]=a*c*u-o*l*h;break;case"zxy":e[0]=o*c*u-a*l*h,e[1]=a*l*u+o*c*h,e[2]=a*c*h+o*l*u,e[3]=a*c*u-o*l*h;break;case"zyx":e[0]=o*c*u-a*l*h,e[1]=a*l*u+o*c*h,e[2]=a*c*h-o*l*u,e[3]=a*c*u+o*l*h;break;default:throw new Error("Unknown angle order "+n)}return e}function M(){var e=new p(2);return p!=Float32Array&&(e[0]=0,e[1]=0),e}function E(e,t){var i=new p(2);return i[0]=e,i[1]=t,i}g(),w=new p(4),p!=Float32Array&&(w[0]=0,w[1]=0,w[2]=0,w[3]=0),g(),y(1,0,0),y(0,1,0),P(),P(),f(),M();const C=8192;function A(e,t,i){return t*(C/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}function D(e,t){return(e%t+t)%t}function z(e,t,i){return e*(1-i)+t*i}function k(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function R(e,t,i,r){const n=new a(e,t,i,r);return e=>n.solve(e)}const L=R(.25,.1,.25,1);function F(e,t,i){return Math.min(i,Math.max(t,e))}function B(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function O(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let V=1;function j(e,t,i){const r={};for(const n in e)r[n]=t.call(this,e[n],n,e);return r}function N(e,t,i){const r={};for(const n in e)t.call(this,e[n],n,e)&&(r[n]=e[n]);return r}function U(e){return Array.isArray(e)?e.map(U):"object"==typeof e&&e?j(e,U):e}const G={};function $(e){G[e]||("undefined"!=typeof console&&console.warn(e),G[e]=!0)}function Z(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function q(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let W=null;function X(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const H="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Y(e,i,r,n,s){return t(this,void 0,void 0,function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const t=new VideoFrame(e,{timestamp:0});try{const o=null==t?void 0:t.format;if(!o||!o.startsWith("BGR")&&!o.startsWith("RGB"))throw new Error(`Unrecognized format ${o}`);const a=o.startsWith("BGR"),l=new Uint8ClampedArray(n*s*4);if(yield t.copyTo(l,function(e,t,i,r,n){const s=4*Math.max(-t,0),o=(Math.max(0,i)-i)*r*4+s,a=4*r,l=Math.max(0,t),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(e.width,t+r)-l,height:Math.min(e.height,i+n)-c},layout:[{offset:o,stride:a}]}}(e,i,r,n,s)),a)for(let e=0;e<l.length;e+=4){const t=l[e];l[e]=l[e+2],l[e+2]=t}return l}finally{t.close()}})}let K,J;function Q(e,t,i,r){return e.addEventListener(t,i,r),{unsubscribe:()=>{e.removeEventListener(t,i,r)}}}function ee(e){return e*Math.PI/180}function te(e){return e/Math.PI*180}const ie={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},re={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},ne="AbortError";class se extends Error{constructor(e=ne){super(e instanceof Error?e.message:e),this.name=ne,e instanceof Error&&e.stack&&(this.stack=e.stack)}}function oe(e){return e.name===ne}const ae={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function le(e){return ae.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const ce="global-dispatcher";class he extends Error{constructor(e,t,i,r){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=r}}const ue=()=>q(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,de=function(e,i){if(/:\/\//.test(e.url)&&!/^https?:|^file:/.test(e.url)){const t=le(e.url);if(t)return t(e,i);if(q(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:ce},i)}if(!(/^file:/.test(r=e.url)||/^file:/.test(ue())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(e,i){return t(this,void 0,void 0,function*(){const t=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:ue(),referrerPolicy:e.referrerPolicy,signal:i.signal});let r,n;"json"!==e.type||t.headers.has("Accept")||t.headers.set("Accept","application/json");try{r=yield fetch(t)}catch(t){if(oe(t))throw t;throw new he(0,t.message,e.url,new Blob)}if(!r.ok){const t=yield r.blob();throw new he(r.status,r.statusText,e.url,t)}n="arrayBuffer"===e.type||"image"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text();const s=yield n;return i.signal.throwIfAborted(),{data:s,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires"),etag:r.headers.get("ETag")}})}(e,i);if(q(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:ce},i)}var r;return function(e,t){return new Promise((i,r)=>{var n;const s=new XMLHttpRequest;s.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(s.responseType="arraybuffer");for(const t in e.headers)s.setRequestHeader(t,e.headers[t]);"json"===e.type&&(s.responseType="text",(null===(n=e.headers)||void 0===n?void 0:n.Accept)||s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===e.credentials,s.onerror=()=>{r(new Error(s.statusText))},s.onload=()=>{if(!t.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let t=s.response;if("json"===e.type)try{t=JSON.parse(s.response)}catch(e){return void r(e)}i({data:t,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires"),etag:s.getResponseHeader("ETag")})}else{const t=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});r(new he(s.status,s.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{s.abort(),r(new se(t.signal.reason))}),s.send(e.body)})}(e,i)};function pe(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function fe(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function me(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class ge{constructor(e,t={}){O(this,t),this.type=e}}class _e extends ge{constructor(e,t={}){super("error",O({error:e},t))}}class ye{on(e,t){return this._listeners=this._listeners||{},fe(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return me(e,t,this._listeners),me(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},fe(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new ge(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const s of r)me(i,s,this._oneTimeListeners),s.call(this,e);const n=this._eventedParent;n&&(O(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof _e&&console.error(e.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}}var xe={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const ve=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function be(e,t){const i={};for(const r in e)"ref"!==r&&(i[r]=e[r]);return ve.forEach(e=>{e in t&&(i[e]=t[e])}),i}function we(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!we(e[i],t[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!we(e[i],t[i]))return!1;return!0}return e===t}function Te(e,t){e.push(t)}function Se(e,t,i){Te(i,{command:"addSource",args:[e,t[e]]})}function Pe(e,t,i){Te(t,{command:"removeSource",args:[e]}),i[e]=!0}function Ie(e,t,i,r){Pe(e,i,r),Se(e,t,i)}function Me(e,t,i){let r;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!we(e[i][r],t[i][r]))return!1;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!we(e[i][r],t[i][r]))return!1;return!0}function Ee(e,t,i,r,n,s){e=e||{},t=t||{};for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(we(e[o],t[o])||i.push({command:s,args:[r,o,t[o],n]}));for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&!Object.prototype.hasOwnProperty.call(e,o)&&(we(e[o],t[o])||i.push({command:s,args:[r,o,t[o],n]}))}function Ce(e){return e.id}function Ae(e,t){return e[t.id]=t,e}class De{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function ze(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}class ke extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class Re{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[i,r]of t)this.bindings[i]=r}concat(e){return new Re(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 Le={kind:"null"},Fe={kind:"number"},Be={kind:"string"},Oe={kind:"boolean"},Ve={kind:"color"},je={kind:"projectionDefinition"},Ne={kind:"object"},Ue={kind:"value"},Ge={kind:"collator"},$e={kind:"formatted"},Ze={kind:"padding"},qe={kind:"colorArray"},We={kind:"numberArray"},Xe={kind:"resolvedImage"},He={kind:"variableAnchorOffsetCollection"};function Ye(e,t){return{kind:"array",itemType:e,N:t}}function Ke(e){if("array"===e.kind){const t=Ke(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Je=[Le,Fe,Be,Oe,Ve,je,$e,Ne,Ye(Ue),Ze,We,qe,Xe,He];function Qe(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Qe(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 Je)if(!Qe(e,t))return null}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function et(e,t){return t.some(t=>t.kind===e.kind)}function tt(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 it(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const rt=.96422,nt=.82521,st=4/29,ot=6/29,at=3*ot*ot,lt=ot*ot*ot,ct=Math.PI/180,ht=180/Math.PI;function ut(e){return(e%=360)<0&&(e+=360),e}function dt([e,t,i,r]){let n,s;const o=ft((.2225045*(e=pt(e))+.7168786*(t=pt(t))+.0606169*(i=pt(i)))/1);e===t&&t===i?n=s=o:(n=ft((.4360747*e+.3850649*t+.1430804*i)/rt),s=ft((.0139322*e+.0971045*t+.7141733*i)/nt));const a=116*o-16;return[a<0?0:a,500*(n-o),200*(o-s),r]}function pt(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function ft(e){return e>lt?Math.pow(e,1/3):e/at+st}function mt([e,t,i,r]){let n=(e+16)/116,s=isNaN(t)?n:n+t/500,o=isNaN(i)?n:n-i/200;return n=1*_t(n),s=rt*_t(s),o=nt*_t(o),[gt(3.1338561*s-1.6168667*n-.4906146*o),gt(-.9787684*s+1.9161415*n+.033454*o),gt(.0719453*s-.2289914*n+1.4052427*o),r]}function gt(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function _t(e){return e>ot?e*e*e:at*(e-st)}const yt=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function xt(e,t){return yt(e,t)?e[t]:void 0}function vt(e){return parseInt(e.padEnd(2,e),16)/255}function bt(e,t){return wt(t?e/100:e,0,1)}function wt(e,t,i){return Math.min(Math.max(t,e),i)}function Tt(e){return!e.some(Number.isNaN)}const St={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Pt(e,t,i){return e+i*(t-e)}function It(e,t,i){return e.map((e,r)=>Pt(e,t[r],i))}class Mt{constructor(e,t,i,r=1,n=!0){this.r=e,this.g=t,this.b=i,this.a=r,n||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[e,t,i,r]))}static parse(e){if(e instanceof Mt)return e;if("string"!=typeof e)return;const t=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=xt(St,e);if(t){const[e,i,r]=t;return[e/255,i/255,r/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let i=1;return[vt(e.slice(i,i+=t)),vt(e.slice(i,i+=t)),vt(e.slice(i,i+=t)),vt(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){const[e,i,r,n,s,o,a,l,c,h,u,d]=t,p=[n||" ",a||" ",h].join("");if("  "===p||"  /"===p||",,"===p||",,,"===p){const e=[r,o,c].join(""),t="%%%"===e?100:""===e?255:0;if(t){const e=[wt(+i/t,0,1),wt(+s/t,0,1),wt(+l/t,0,1),u?bt(+u,d):1];if(Tt(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,r,n,s,o,a,l,c]=i,h=[r||" ",s||" ",a].join("");if("  "===h||"  /"===h||",,"===h||",,,"===h){const e=[+t,wt(+n,0,100),wt(+o,0,100),l?bt(+l,c):1];if(Tt(e))return function([e,t,i,r]){function n(r){const n=(r+e/30)%12,s=t*Math.min(i,1-i);return i-s*Math.max(-1,Math.min(n-3,9-n,1))}return e=ut(e),t/=100,i/=100,[n(0),n(8),n(4),r]}(e)}}}(e);return t?new Mt(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:r}=this,n=r||1/0;return this.overwriteGetter("rgb",[e/n,t/n,i/n,r])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,r,n]=dt(e),s=Math.sqrt(i*i+r*r);return[Math.round(1e4*s)?ut(Math.atan2(r,i)*ht):NaN,s,t,n]}(this.rgb))}get lab(){return this.overwriteGetter("lab",dt(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,r]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${r})`}static interpolate(e,t,i,r="rgb"){switch(r){case"rgb":{const[r,n,s,o]=It(e.rgb,t.rgb,i);return new Mt(r,n,s,o,!1)}case"hcl":{const[r,n,s,o]=e.hcl,[a,l,c,h]=t.hcl;let u,d;if(isNaN(r)||isNaN(a))isNaN(r)?isNaN(a)?u=NaN:(u=a,1!==s&&0!==s||(d=l)):(u=r,1!==c&&0!==c||(d=n));else{let e=a-r;a>r&&e>180?e-=360:a<r&&r-a>180&&(e+=360),u=r+i*e}const[p,f,m,g]=function([e,t,i,r]){return e=isNaN(e)?0:e*ct,mt([i,Math.cos(e)*t,Math.sin(e)*t,r])}([u,null!=d?d:Pt(n,l,i),Pt(s,c,i),Pt(o,h,i)]);return new Mt(p,f,m,g,!1)}case"lab":{const[r,n,s,o]=mt(It(e.lab,t.lab,i));return new Mt(r,n,s,o,!1)}}}}Mt.black=new Mt(0,0,0,1),Mt.white=new Mt(1,1,1,1),Mt.transparent=new Mt(0,0,0,0),Mt.red=new Mt(1,0,0,1);class Et{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Ct=["bottom","center","top"];class At{constructor(e,t,i,r,n,s){this.text=e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n,this.verticalAlign=s}}class Dt{constructor(e){this.sections=e}static fromString(e){return new Dt([new At(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Dt?e:Dt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}}class zt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof zt)return e;if("number"==typeof e)return new zt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new zt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new zt(It(e.values,t.values,i))}}class kt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof kt)return e;if("number"==typeof e)return new kt([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new kt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new kt(It(e.values,t.values,i))}}class Rt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Rt)return e;if("string"==typeof e){const t=Mt.parse(e);if(!t)return;return new Rt([t])}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=Mt.parse(i);if(!e)return;t.push(e)}return new Rt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,r="rgb"){const n=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let s=0;s<e.values.length;s++)n.push(Mt.interpolate(e.values[s],t.values[s],i,r));return new Rt(n)}}class Lt extends Error{constructor(e){super(e),this.name="RuntimeError"}toJSON(){return this.message}}const Ft=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Bt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Bt)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let t=0;t<e.length;t+=2){const i=e[t],r=e[t+1];if("string"!=typeof i||!Ft.has(i))return;if(!Array.isArray(r)||2!==r.length||"number"!=typeof r[0]||"number"!=typeof r[1])return}return new Bt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){const r=e.values,n=t.values;if(r.length!==n.length)throw new Lt(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${t.toString()}`);const s=[];for(let o=0;o<r.length;o+=2){if(r[o]!==n[o])throw new Lt(`Cannot interpolate values containing mismatched anchors. from[${o}]: ${r[o]}, to[${o}]: ${n[o]}`);s.push(r[o]);const[e,t]=r[o+1],[a,l]=n[o+1];s.push([Pt(e,a,i),Pt(t,l,i)])}return new Bt(s)}}class Ot{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Ot({name:e,available:!1}):null}}class Vt{constructor(e,t,i){this.from=e,this.to=t,this.transition=i}static interpolate(e,t,i){return new Vt(e,t,i)}static parse(e){return e instanceof Vt?e:Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]?new Vt(e[0],e[1],e[2]):"object"==typeof e&&"string"==typeof e.from&&"string"==typeof e.to&&"number"==typeof e.transition?new Vt(e.from,e.to,e.transition):"string"==typeof e?new Vt(e,e,1):void 0}}function jt(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Nt(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof Vt||e instanceof Mt||e instanceof Et||e instanceof Dt||e instanceof zt||e instanceof kt||e instanceof Rt||e instanceof Bt||e instanceof Ot)return!0;if(Array.isArray(e)){for(const t of e)if(!Nt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Nt(e[t]))return!1;return!0}return!1}function Ut(e){if(null===e)return Le;if("string"==typeof e)return Be;if("boolean"==typeof e)return Oe;if("number"==typeof e)return Fe;if(e instanceof Mt)return Ve;if(e instanceof Vt)return je;if(e instanceof Et)return Ge;if(e instanceof Dt)return $e;if(e instanceof zt)return Ze;if(e instanceof kt)return We;if(e instanceof Rt)return qe;if(e instanceof Bt)return He;if(e instanceof Ot)return Xe;if(Array.isArray(e)){const t=e.length;let i;for(const r of e){const e=Ut(r);if(i){if(i===e)continue;i=Ue;break}i=e}return Ye(i||Ue,t)}return Ne}function Gt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Mt||e instanceof Vt||e instanceof Dt||e instanceof zt||e instanceof kt||e instanceof Rt||e instanceof Bt||e instanceof Ot?e.toString():JSON.stringify(e)}class $t{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(!Nt(e[1]))return t.error("invalid value");const i=e[1];let r=Ut(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new $t(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Zt={string:Be,number:Fe,boolean:Oe,object:Ne};class qt{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 i,r=1;const n=e[0];if("array"===n){let n,s;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Zt)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=Zt[i],r++}else n=Ue;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],r++}i=Ye(n,s)}else{if(!Zt[n])throw new Error(`Types doesn't contain name = ${n}`);i=Zt[n]}const s=[];for(;r<e.length;r++){const i=t.parse(e[r],r,Ue);if(!i)return null;s.push(i)}return new qt(i,s)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!Qe(this.type,Ut(i)))return i;if(t===this.args.length-1)throw new Lt(`Expected value to be of type ${Ke(this.type)}, but found ${Ke(Ut(i))} instead.`)}throw new Error}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Wt={"to-boolean":Oe,"to-color":Ve,"to-number":Fe,"to-string":Be};class Xt{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 i=e[0];if(!Wt[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const r=Wt[i],n=[];for(let s=1;s<e.length;s++){const i=t.parse(e[s],s,Ue);if(!i)return null;n.push(i)}return new Xt(r,n)}evaluate(e){switch(this.type.kind){case"boolean":return Boolean(this.args[0].evaluate(e));case"color":{let t,i;for(const r of this.args){if(t=r.evaluate(e),i=null,t instanceof Mt)return t;if("string"==typeof t){const i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:jt(t[0],t[1],t[2],t[3]),!i))return new Mt(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Lt(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const r=zt.parse(t);if(r)return r}throw new Lt(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const r=kt.parse(t);if(r)return r}throw new Lt(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const r=Rt.parse(t);if(r)return r}throw new Lt(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const r=Bt.parse(t);if(r)return r}throw new Lt(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new Lt(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return Dt.fromString(Gt(this.args[0].evaluate(e)));case"resolvedImage":return Ot.fromString(Gt(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return Gt(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Ht=["Unknown","Point","LineString","Polygon"];class Yt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ht[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Mt.parse(e),this._parseColorCache.set(e,t)),t}}class Kt{constructor(e,t,i=[],r,n=new Re,s=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=n,this.errors=s,this.expectedType=r,this._isConstant=t}parse(e,t,i,r,n={}){return t?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(e,t){function i(e,t,i){return"assert"===i?new qt(t,[e]):"coerce"===i?new Xt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=e[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[r];if(n){let r=n.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,n=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(n.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(n.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(n.kind)||"colorArray"===e.kind&&["value","string","array"].includes(n.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(n.kind))r=i(r,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,n))return null}else r=i(r,e,t.typeAnnotation||"assert")}if(!(r instanceof $t)&&"resolvedImage"!==r.type.kind&&this._isConstant(r)){const t=new Yt;try{r=new $t(r.type,r.evaluate(t))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new Kt(this.registry,this._isConstant,r,t||null,n,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new ke(i,e))}checkSubtype(e,t){const i=Qe(e,t);return i&&this.error(i),i}}class Jt{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 i=[];for(let n=1;n<e.length-1;n+=2){const r=e[n];if("string"!=typeof r)return t.error(`Expected string, but found ${typeof r} instead.`,n);if(/[^a-zA-Z0-9_]/.test(r))return t.error("Variable names must contain only alphanumeric characters or '_'.",n);const s=t.parse(e[n+1],n+1);if(!s)return null;i.push([r,s])}const r=t.parse(e[e.length-1],e.length-1,t.expectedType,i);return r?new Jt(i,r):null}outputDefined(){return this.result.outputDefined()}}class Qt{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 i=e[1];return t.scope.has(i)?new Qt(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class ei{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Fe),r=t.parse(e[2],2,Ye(t.expectedType||Ue));return i&&r?new ei(r.type.itemType,i,r):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new Lt(`Array index out of bounds: ${t} < 0.`);if(t>=i.length)throw new Lt(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Lt(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ti{constructor(e,t){this.type=Oe,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ue),r=t.parse(e[2],2,Ue);return i&&r?et(i.type,[Oe,Be,Fe,Le,Ue])?new ti(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!tt(t,["boolean","string","number","null"]))throw new Lt(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Ut(t))} instead.`);if(!tt(i,["string","array"]))throw new Lt(`Expected second argument to be of type array or string, but found ${Ke(Ut(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ii{constructor(e,t,i){this.type=Fe,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ue),r=t.parse(e[2],2,Ue);if(!i||!r)return null;if(!et(i.type,[Oe,Be,Fe,Le,Ue]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Fe);return n?new ii(i,r,n):null}return new ii(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!tt(t,["boolean","string","number","null"]))throw new Lt(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Ut(t))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(e)),tt(i,["string"])){const e=i.indexOf(t,r);return-1===e?-1:[...i.slice(0,e)].length}if(tt(i,["array"]))return i.indexOf(t,r);throw new Lt(`Expected second argument to be of type array or string, but found ${Ke(Ut(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ri{constructor(e,t,i,r,n,s){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,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 i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},s=[];for(let l=2;l<e.length-1;l+=2){let o=e[l];const a=e[l+1];Array.isArray(o)||(o=[o]);const c=t.concat(l);if(0===o.length)return c.error("Expected at least one branch label.");for(const e of o){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Ut(e)))return null}else i=Ut(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=s.length}const h=t.parse(a,l,r);if(!h)return null;r=r||h.type,s.push(h)}const o=t.parse(e[1],1,Ue);if(!o)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==o.type.kind&&t.concat(1).checkSubtype(i,o.type)?null:new ri(i,r,o,n,s,a):null}evaluate(e){const t=this.input.evaluate(e);return(Ut(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class ni{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let s=1;s<e.length-1;s+=2){const n=t.parse(e[s],s,Oe);if(!n)return null;const o=t.parse(e[s+1],s+1,i);if(!o)return null;r.push([n,o]),i=i||o.type}const n=t.parse(e[e.length-1],e.length-1,i);if(!n)return null;if(!i)throw new Error("Can't infer output type");return new ni(i,r,n)}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every(([e,t])=>t.outputDefined())&&this.otherwise.outputDefined()}}class si{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ue),r=t.parse(e[2],2,Fe);if(!i||!r)return null;if(!et(i.type,[Ye(Ue),Be,Ue]))return t.error(`Expected first argument to be of type array or string, but found ${Ke(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Fe);return n?new si(i.type,i,r,n):null}return new si(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let r;if(this.endIndex&&(r=this.endIndex.evaluate(e)),tt(t,["string"]))return[...t].slice(i,r).join("");if(tt(t,["array"]))return t.slice(i,r);throw new Lt(`Expected first argument to be of type array or string, but found ${Ke(Ut(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function oi(e,t){const i=e.length-1;let r,n,s=0,o=i,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),r=e[a],n=e[a+1],r<=t){if(a===i||t<n)return a;s=a+1}else{if(!(r>t))throw new Lt("Input is not a number.");o=a-1}return 0}class ai{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[r,n]of i)this.labels.push(r),this.outputs.push(n)}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 i=t.parse(e[1],1,Fe);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let s=1;s<e.length;s+=2){const i=1===s?-1/0:e[s],o=e[s+1],a=s,l=s+1;if("number"!=typeof i)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=i)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(o,l,n);if(!c)return null;n=n||c.type,r.push([i,c])}return new ai(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[oi(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function li(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ci,hi,ui=function(){if(hi)return ci;function e(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r}return hi=1,ci=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)<t)return i;var s=this.sampleCurveDerivativeX(i);if(Math.abs(s)<1e-6)break;i-=n/s}var o=0,a=1;for(i=e,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-e)<t));r++)e>n?o=i:a=i,i=.5*(a-o)+o;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},ci}(),di=li(ui);class pi{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[s,o]of n)this.labels.push(s),this.outputs.push(o)}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=fi(t,e.base,i,r);else if("linear"===e.name)n=fi(t,1,i,r);else if("cubic-bezier"===e.name){const s=e.controlPoints;n=new di(s[0],s[1],s[2],s[3]).solve(fi(t,1,i,r))}return n}static parse(e,t){let[i,r,n,...s]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.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);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,Fe),!n)return null;const o=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==qe?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=Ve;for(let l=0;l<s.length;l+=2){const e=s[l],i=s[l+1],r=l+3,n=l+4;if("number"!=typeof e)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',r);if(o.length&&o[o.length-1][0]>=e)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(i,n,a);if(!c)return null;a=a||c.type,o.push([e,c])}return it(a,Fe)||it(a,je)||it(a,Ve)||it(a,Ze)||it(a,We)||it(a,qe)||it(a,He)||it(a,Ye(Fe))?new pi(a,i,r,n,o):t.error(`Type ${Ke(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const s=oi(t,r),o=pi.interpolationFactor(this.interpolation,r,t[s],t[s+1]),a=i[s].evaluate(e),l=i[s+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Pt(a,l,o);case"color":return Mt.interpolate(a,l,o);case"padding":return zt.interpolate(a,l,o);case"colorArray":return Rt.interpolate(a,l,o);case"numberArray":return kt.interpolate(a,l,o);case"variableAnchorOffsetCollection":return Bt.interpolate(a,l,o);case"array":return It(a,l,o);case"projectionDefinition":return Vt.interpolate(a,l,o)}case"interpolate-hcl":switch(this.type.kind){case"color":return Mt.interpolate(a,l,o,"hcl");case"colorArray":return Rt.interpolate(a,l,o,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Mt.interpolate(a,l,o,"lab");case"colorArray":return Rt.interpolate(a,l,o,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function fi(e,t,i,r){const n=r-i,s=e-i;return 0===n?0:1===t?s/n:(Math.pow(t,s)-1)/(Math.pow(t,n)-1)}const mi={color:Mt.interpolate,number:Pt,padding:zt.interpolate,numberArray:kt.interpolate,colorArray:Rt.interpolate,variableAnchorOffsetCollection:Bt.interpolate,array:It};class gi{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 i=null;const r=t.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const o of e.slice(1)){const e=t.parse(o,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,n.push(e)}if(!i)throw new Error("No output type");const s=r&&n.some(e=>Qe(r,e.type));return new gi(s?Ue:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args)if(r++,i=n.evaluate(e),i&&i instanceof Ot&&!i.available&&(t||(t=i.name),i=null,r===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function _i(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 yi(e,t,i,r){return 0===r.compare(t,i)}function xi(e,t,i){const r="=="!==e&&"!="!==e;return class n{constructor(e,t,i){this.type=Oe,this.lhs=e,this.rhs=t,this.collator=i,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 i=e[0];let s=t.parse(e[1],1,Ue);if(!s)return null;if(!_i(i,s.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ke(s.type)}'.`);let o=t.parse(e[2],2,Ue);if(!o)return null;if(!_i(i,o.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ke(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${Ke(s.type)}' and '${Ke(o.type)}'.`);r&&("value"===s.type.kind&&"value"!==o.type.kind?s=new qt(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new qt(s.type,[o])));let a=null;if(4===e.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,Ge),!a)return null}return new n(s,o,a)}evaluate(n){const s=this.lhs.evaluate(n),o=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=Ut(s),i=Ut(o);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Lt(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=Ut(s),i=Ut(o);if("string"!==e.kind||"string"!==i.kind)return t(n,s,o)}return this.collator?i(n,s,o,this.collator.evaluate(n)):t(n,s,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const vi=xi("==",function(e,t,i){return t===i},yi),bi=xi("!=",function(e,t,i){return t!==i},function(e,t,i,r){return!yi(0,t,i,r)}),wi=xi("<",function(e,t,i){return t<i},function(e,t,i,r){return r.compare(t,i)<0}),Ti=xi(">",function(e,t,i){return t>i},function(e,t,i,r){return r.compare(t,i)>0}),Si=xi("<=",function(e,t,i){return t<=i},function(e,t,i,r){return r.compare(t,i)<=0}),Pi=xi(">=",function(e,t,i){return t>=i},function(e,t,i,r){return r.compare(t,i)>=0});class Ii{constructor(e,t,i){this.type=Ge,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const r=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Oe);if(!r)return null;const n=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Oe);if(!n)return null;let s=null;return i.locale&&(s=t.parse(i.locale,1,Be),!s)?null:new Ii(r,n,s)}evaluate(e){return new Et(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Mi{constructor(e,t,i,r,n,s){this.type=Be,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=s}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Fe);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parse(r.locale,1,Be),!n))return null;let s=null;if(r.currency&&(s=t.parse(r.currency,1,Be),!s))return null;let o=null;if(r.unit&&(o=t.parse(r.unit,1,Be),!o))return null;if(s&&o)return t.error("NumberFormat options `currency` and `unit` are mutually exclusive");let a=null;if(r["min-fraction-digits"]&&(a=t.parse(r["min-fraction-digits"],1,Fe),!a))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,Fe),!l)?null:new Mi(i,n,s,o,a,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}}class Ei{constructor(e){this.type=$e,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let s=1;s<=e.length-1;++s){const i=e[s];if(n&&"object"==typeof i&&!Array.isArray(i)){n=!1;let e=null;if(i["font-scale"]&&(e=t.parse(i["font-scale"],1,Fe),!e))return null;let s=null;if(i["text-font"]&&(s=t.parse(i["text-font"],1,Ye(Be)),!s))return null;let o=null;if(i["text-color"]&&(o=t.parse(i["text-color"],1,Ve),!o))return null;let a=null;if(i["vertical-align"]){if("string"==typeof i["vertical-align"]&&!Ct.includes(i["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${i["vertical-align"]}' instead.`);if(a=t.parse(i["vertical-align"],1,Be),!a)return null}const l=r[r.length-1];l.scale=e,l.font=s,l.textColor=o,l.verticalAlign=a}else{const i=t.parse(e[s],1,Ue);if(!i)return null;const o=i.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:i,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Ei(r)}evaluate(e){return new Dt(this.sections.map(t=>{const i=t.content.evaluate(e);return Ut(i)===Xe?new At("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new At(Gt(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class Ci{constructor(e){this.type=Xe,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Be);return i?new Ci(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=Ot.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ai{constructor(e){this.type=Fe,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Ke(i.type)} instead.`):new Ai(i):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 Lt(`Expected value to be of type string or array, but found ${Ke(Ut(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Di=8192;function zi(e,t){const i=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(i*n*Di),Math.round(r*n*Di)]}function ki(e,t){const i=Math.pow(2,t.z);return[(n=(e[0]/Di+t.x)/i,360*n-180),(r=(e[1]/Di+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,n}function Ri(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Li(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Fi(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],s=e[0]-i[0],o=e[1]-i[1];return r*o-s*n==0&&r*s<=0&&n*o<=0}function Bi(e,t,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(s=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*s[0]&&!(!Gi(e,t,i,r)||!Gi(i,r,e,t));var n,s}function Oi(e,t,i){for(const r of i)for(let i=0;i<r.length-1;++i)if(Bi(e,t,r[i],r[i+1]))return!0;return!1}function Vi(e,t,i=!1){let r=!1;for(const a of t)for(let t=0;t<a.length-1;t++){if(Fi(e,a[t],a[t+1]))return i;(s=a[t])[1]>(n=e)[1]!=(o=a[t+1])[1]>n[1]&&n[0]<(o[0]-s[0])*(n[1]-s[1])/(o[1]-s[1])+s[0]&&(r=!r)}var n,s,o;return r}function ji(e,t){for(const i of t)if(Vi(e,i))return!0;return!1}function Ni(e,t){for(const i of e)if(!Vi(i,t))return!1;for(let i=0;i<e.length-1;++i)if(Oi(e[i],e[i+1],t))return!1;return!0}function Ui(e,t){for(const i of t)if(Ni(e,i))return!0;return!1}function Gi(e,t,i,r){const n=r[0]-i[0],s=r[1]-i[1],o=(e[0]-i[0])*s-n*(e[1]-i[1]),a=(t[0]-i[0])*s-n*(t[1]-i[1]);return o>0&&a<0||o<0&&a>0}function $i(e,t,i){const r=[];for(let n=0;n<e.length;n++){const s=[];for(let r=0;r<e[n].length;r++){const o=zi(e[n][r],i);Ri(t,o),s.push(o)}r.push(s)}return r}function Zi(e,t,i){const r=[];for(let n=0;n<e.length;n++){const s=$i(e[n],t,i);r.push(s)}return r}function qi(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}Ri(t,e)}function Wi(e,t,i,r){const n=Math.pow(2,r.z)*Di,s=[r.x*Di,r.y*Di],o=[];for(const a of e)for(const e of a){const r=[e.x+s[0],e.y+s[1]];qi(r,t,i,n),o.push(r)}return o}function Xi(e,t,i,r){const n=Math.pow(2,r.z)*Di,s=[r.x*Di,r.y*Di],o=[];for(const l of e){const e=[];for(const i of l){const r=[i.x+s[0],i.y+s[1]];Ri(t,r),e.push(r)}o.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of o)for(const r of e)qi(r,t,i,n)}var a;return o}class Hi{constructor(e,t){this.type=Oe,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(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:r}=i.geometry;"Polygon"===t&&e.push(r),"MultiPolygon"===t&&e.push(...r)}if(e.length)return new Hi(t,{type:"MultiPolygon",coordinates:e})}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Hi(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Hi(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if("Polygon"===t.type){const s=$i(t.coordinates,r,n),o=Wi(e.geometry(),i,r,n);if(!Li(i,r))return!1;for(const e of o)if(!Vi(e,s))return!1}if("MultiPolygon"===t.type){const s=Zi(t.coordinates,r,n),o=Wi(e.geometry(),i,r,n);if(!Li(i,r))return!1;for(const e of o)if(!ji(e,s))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if("Polygon"===t.type){const s=$i(t.coordinates,r,n),o=Xi(e.geometry(),i,r,n);if(!Li(i,r))return!1;for(const e of o)if(!Ni(e,s))return!1}if("MultiPolygon"===t.type){const s=Zi(t.coordinates,r,n),o=Xi(e.geometry(),i,r,n);if(!Li(i,r))return!1;for(const e of o)if(!Ui(e,s))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Yi=class{constructor(e=[],t=(e,t)=>e<t?-1:e>t?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}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:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(i(r,s)>=0)break;t[e]=s,e=n}t[e]=r}_down(e){const{data:t,compare:i}=this,r=this.length>>1,n=t[e];for(;e<r;){let r=1+(e<<1);const s=r+1;if(s<this.length&&i(t[s],t[r])<0&&(r=s),i(t[r],n)>=0)break;t[e]=t[r],e=r}t[e]=n}};function Ki(e,t,i=0,r=e.length-1,n=Qi){for(;r>i;){if(r-i>600){const s=r-i+1,o=t-i+1,a=Math.log(s),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);Ki(e,t,Math.max(i,Math.floor(t-o*l/s+c)),Math.min(r,Math.floor(t+(s-o)*l/s+c)),n)}const s=e[t];let o=i,a=r;for(Ji(e,i,t),n(e[r],s)>0&&Ji(e,i,r);o<a;){for(Ji(e,o,a),o++,a--;n(e[o],s)<0;)o++;for(;n(e[a],s)>0;)a--}0===n(e[i],s)?Ji(e,i,a):(a++,Ji(e,a,r)),a<=t&&(i=a+1),t<=a&&(r=a-1)}}function Ji(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function Qi(e,t){return e<t?-1:e>t?1:0}function er(e,t){if(e.length<=1)return[e];const i=[];let r,n;for(const s of e){const e=ir(s);0!==e&&(s.area=Math.abs(e),void 0===n&&(n=e<0),n===e<0?(r&&i.push(r),r=[s]):r.push(s))}if(r&&i.push(r),t>1)for(let s=0;s<i.length;s++)i[s].length<=t||(Ki(i[s],t,1,i[s].length-1,tr),i[s]=i[s].slice(0,t));return i}function tr(e,t){return t.area-e.area}function ir(e){let t=0;for(let i,r,n=0,s=e.length,o=s-1;n<s;o=n++)i=e[n],r=e[o],t+=(r.x-i.x)*(i.y+r.y);return t}const rr=1/298.257223563,nr=rr*(2-rr),sr=Math.PI/180;class or{constructor(e){const t=6378.137*sr*1e3,i=Math.cos(e*sr),r=1/(1-nr*(1-i*i)),n=Math.sqrt(r);this.kx=t*n*i,this.ky=t*n*r*(1-nr)}distance(e,t){const i=this.wrap(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+r*r)}pointOnLine(e,t){let i,r,n,s,o=1/0;for(let a=0;a<e.length-1;a++){let l=e[a][0],c=e[a][1],h=this.wrap(e[a+1][0]-l)*this.kx,u=(e[a+1][1]-c)*this.ky,d=0;0===h&&0===u||(d=(this.wrap(t[0]-l)*this.kx*h+(t[1]-c)*this.ky*u)/(h*h+u*u),d>1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=h/this.kx*d,c+=u/this.ky*d)),h=this.wrap(t[0]-l)*this.kx,u=(t[1]-c)*this.ky;const p=h*h+u*u;p<o&&(o=p,i=l,r=c,n=a,s=d)}return{point:[i,r],index:n,t:Math.max(0,Math.min(1,s))}}wrap(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}}function ar(e,t){return t[0]-e[0]}function lr(e){return e[1]-e[0]+1}function cr(e,t){return e[1]>=e[0]&&e[1]<t}function hr(e,t){if(e[0]>e[1])return[null,null];const i=lr(e);if(t){if(2===i)return[e,null];const t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(1===i)return[e,null];const r=Math.floor(i/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function ur(e,t){if(!cr(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)Ri(i,e[r]);return i}function dr(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)Ri(t,e);return t}function pr(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function fr(e,t,i){if(!pr(e)||!pr(t))return NaN;let r=0,n=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]<t[1]&&(n=t[1]-e[3]),i.distance([0,0],[r,n])}function mr(e,t,i){const r=i.pointOnLine(t,e);return i.distance(e,r.point)}function gr(e,t,i,r,n){const s=Math.min(mr(e,[i,r],n),mr(t,[i,r],n)),o=Math.min(mr(i,[e,t],n),mr(r,[e,t],n));return Math.min(s,o)}function _r(e,t,i,r,n){if(!cr(t,e.length)||!cr(r,i.length))return 1/0;let s=1/0;for(let o=t[0];o<t[1];++o){const t=e[o],a=e[o+1];for(let e=r[0];e<r[1];++e){const r=i[e],o=i[e+1];if(Bi(t,a,r,o))return 0;s=Math.min(s,gr(t,a,r,o,n))}}return s}function yr(e,t,i,r,n){if(!cr(t,e.length)||!cr(r,i.length))return NaN;let s=1/0;for(let o=t[0];o<=t[1];++o)for(let t=r[0];t<=r[1];++t)if(s=Math.min(s,n.distance(e[o],i[t])),0===s)return s;return s}function xr(e,t,i){if(Vi(e,t,!0))return 0;let r=1/0;for(const n of t){const t=n[0],s=n[n.length-1];if(t!==s&&(r=Math.min(r,mr(e,[s,t],i)),0===r))return r;const o=i.pointOnLine(n,e);if(r=Math.min(r,i.distance(e,o.point)),0===r)return r}return r}function vr(e,t,i,r){if(!cr(t,e.length))return NaN;for(let s=t[0];s<=t[1];++s)if(Vi(e[s],i,!0))return 0;let n=1/0;for(let s=t[0];s<t[1];++s){const t=e[s],o=e[s+1];for(const e of i)for(let i=0,s=e.length,a=s-1;i<s;a=i++){const s=e[a],l=e[i];if(Bi(t,o,s,l))return 0;n=Math.min(n,gr(t,o,s,l,r))}}return n}function br(e,t){for(const i of e)for(const e of i)if(Vi(e,t,!0))return!0;return!1}function wr(e,t,i,r=1/0){const n=dr(e),s=dr(t);if(r!==1/0&&fr(n,s,i)>=r)return r;if(Li(n,s)){if(br(e,t))return 0}else if(br(t,e))return 0;let o=1/0;for(const a of e)for(let e=0,r=a.length,n=r-1;e<r;n=e++){const r=a[n],s=a[e];for(const e of t)for(let t=0,n=e.length,a=n-1;t<n;a=t++){const n=e[a],l=e[t];if(Bi(r,s,n,l))return 0;o=Math.min(o,gr(r,s,n,l,i))}}return o}function Tr(e,t,i,r,n,s){if(!s)return;const o=fr(ur(r,s),n,i);o<t&&e.push([o,s,[0,0]])}function Sr(e,t,i,r,n,s,o){if(!s||!o)return;const a=fr(ur(r,s),ur(n,o),i);a<t&&e.push([a,s,o])}function Pr(e,t,i,r,n=1/0){let s=Math.min(r.distance(e[0],i[0][0]),n);if(0===s)return s;const o=new Yi([[0,[0,e.length-1],[0,0]]],ar),a=dr(i);for(;o.length>0;){const n=o.pop();if(n[0]>=s)continue;const l=n[1],c=t?50:100;if(lr(l)<=c){if(!cr(l,e.length))return NaN;if(t){const t=vr(e,l,i,r);if(isNaN(t)||0===t)return t;s=Math.min(s,t)}else for(let t=l[0];t<=l[1];++t){const n=xr(e[t],i,r);if(s=Math.min(s,n),0===s)return 0}}else{const i=hr(l,t);Tr(o,s,r,e,a,i[0]),Tr(o,s,r,e,a,i[1])}}return s}function Ir(e,t,i,r,n,s=1/0){let o=Math.min(s,n.distance(e[0],i[0]));if(0===o)return o;const a=new Yi([[0,[0,e.length-1],[0,i.length-1]]],ar);for(;a.length>0;){const s=a.pop();if(s[0]>=o)continue;const l=s[1],c=s[2],h=t?50:100,u=r?50:100;if(lr(l)<=h&&lr(c)<=u){if(!cr(l,e.length)&&cr(c,i.length))return NaN;let s;if(t&&r)s=_r(e,l,i,c,n),o=Math.min(o,s);else if(t&&!r){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(s=mr(i[e],t,n),o=Math.min(o,s),0===o)return o}else if(!t&&r){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(s=mr(e[i],t,n),o=Math.min(o,s),0===o)return o}else s=yr(e,l,i,c,n),o=Math.min(o,s)}else{const s=hr(l,t),h=hr(c,r);Sr(a,o,n,e,i,s[0],h[0]),Sr(a,o,n,e,i,s[0],h[1]),Sr(a,o,n,e,i,s[1],h[0]),Sr(a,o,n,e,i,s[1],h[1])}}return o}function Mr(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}class Er{constructor(e,t){this.type=Fe,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new Er(t,t.features.map(e=>Mr(e.geometry)).flat());if("Feature"===t.type)return new Er(t,Mr(t.geometry));if("type"in t&&"coordinates"in t)return new Er(t,Mr(t))}return t.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=e.geometry(),r=i.flat().map(t=>ki([t.x,t.y],e.canonical));if(0===i.length)return NaN;const n=new or(r[0][1]);let s=1/0;for(const o of t){switch(o.type){case"Point":s=Math.min(s,Ir(r,!1,[o.coordinates],!1,n,s));break;case"LineString":s=Math.min(s,Ir(r,!1,o.coordinates,!0,n,s));break;case"Polygon":s=Math.min(s,Pr(r,!1,o.coordinates,n,s))}if(0===s)return s}return s}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),r=i.flat().map(t=>ki([t.x,t.y],e.canonical));if(0===i.length)return NaN;const n=new or(r[0][1]);let s=1/0;for(const o of t){switch(o.type){case"Point":s=Math.min(s,Ir(r,!0,[o.coordinates],!1,n,s));break;case"LineString":s=Math.min(s,Ir(r,!0,o.coordinates,!0,n,s));break;case"Polygon":s=Math.min(s,Pr(r,!0,o.coordinates,n,s))}if(0===s)return s}return s}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const r=er(i,0).map(t=>t.map(t=>t.map(t=>ki([t.x,t.y],e.canonical)))),n=new or(r[0][0][0][1]);let s=1/0;for(const o of t)for(const e of r){switch(o.type){case"Point":s=Math.min(s,Pr([o.coordinates],!1,e,n,s));break;case"LineString":s=Math.min(s,Pr(o.coordinates,!0,e,n,s));break;case"Polygon":s=Math.min(s,wr(e,o.coordinates,n,s))}if(0===s)return s}return s}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Cr{constructor(e){this.type=Ue,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Cr(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?xt(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Ar={"==":vi,"!=":bi,">":Ti,"<":wi,">=":Pi,"<=":Si,array:qt,at:ei,boolean:qt,case:ni,coalesce:gi,collator:Ii,format:Ei,image:Ci,in:ti,"index-of":ii,interpolate:pi,"interpolate-hcl":pi,"interpolate-lab":pi,length:Ai,let:Jt,literal:$t,match:ri,number:qt,"number-format":Mi,object:qt,slice:si,step:ai,string:qt,"to-boolean":Xt,"to-color":Xt,"to-number":Xt,"to-string":Xt,var:Qt,within:Hi,distance:Er,"global-state":Cr};class Dr{constructor(e,t,i,r){this.name=e,this.type=t,this._evaluate=i,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],r=Dr.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,s=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=s.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[l,c]of o){a=new Kt(t.registry,Fr,t.path,null,t.scope);const r=[];let s=!1;for(let t=1;t<e.length;t++){const i=e[t],n=Array.isArray(l)?l[t-1]:l.type,o=a.parse(i,1+r.length,n);if(!o){s=!0;break}r.push(o)}if(!s)if(Array.isArray(l)&&l.length!==r.length)a.error(`Expected ${l.length} arguments, but found ${r.length} instead.`);else{for(let e=0;e<r.length;e++){const t=Array.isArray(l)?l[e]:l.type,i=r[e];a.concat(e+1).checkSubtype(t,i.type)}if(0===a.errors.length)return new Dr(i,n,c,r)}}if(1===o.length)t.errors.push(...a.errors);else{const i=(o.length?o:s).map(([e])=>{return t=e,Array.isArray(t)?`(${t.map(Ke).join(", ")})`:`(${Ke(t.type)}...)`;var t}).join(" | "),r=[];for(let n=1;n<e.length;n++){const i=t.parse(e[n],1+r.length);if(!i)return null;r.push(Ke(i.type))}t.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(e,t){Dr.definitions=t;for(const i in t)e[i]=Dr}}function zr(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const s=n?n.evaluate(e):1,o=jt(t,i,r,s);if(o)throw new Lt(o);return new Mt(t/255,i/255,r/255,s,!1)}function kr(e,t){return e in t}function Rr(e,t){const i=t[e];return void 0===i?null:i}function Lr(e){return{type:e}}function Fr(e){if(e instanceof Qt)return Fr(e.boundExpression);if(e instanceof Dr&&"error"===e.name)return!1;if(e instanceof Ii)return!1;if(e instanceof Hi)return!1;if(e instanceof Er)return!1;if(e instanceof Cr)return!1;const t=e instanceof Xt||e instanceof qt;let i=!0;return e.eachChild(e=>{i=t?i&&Fr(e):i&&e instanceof $t}),!!i&&Br(e)&&Vr(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Br(e){if(e instanceof Dr){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Hi)return!1;if(e instanceof Er)return!1;let t=!0;return e.eachChild(e=>{t&&!Br(e)&&(t=!1)}),t}function Or(e){if(e instanceof Dr&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!Or(e)&&(t=!1)}),t}function Vr(e,t){if(e instanceof Dr&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!Vr(e,t)&&(i=!1)}),i}function jr(e){return{result:"success",value:e}}function Nr(e){return{result:"error",value:e}}function Ur(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Gr(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function $r(e){return!!e.expression&&e.expression.interpolated}function Zr(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function qr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Ut(e)===Ne}function Wr(e){return e}function Xr(e,t){const i=e.stops&&"object"==typeof e.stops[0][0],r=i||!(i||void 0!==e.property),n=e.type||($r(t)?"exponential":"interval"),s=function(e){switch(e.type){case"color":return Mt.parse;case"padding":return zt.parse;case"numberArray":return kt.parse;case"colorArray":return Rt.parse;default:return null}}(t);if(s&&((e=ze({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],s(e[1])])),e.default=s(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==(o=e.colorSpace)&&"hcl"!==o&&"lab"!==o)throw new Error(`Unknown color space: "${e.colorSpace}"`);var o;const a=function(e){switch(e){case"exponential":return Jr;case"interval":return Kr;case"categorical":return Yr;case"identity":return Qr;default:throw new Error(`Unknown function type "${e}"`)}}(n);let l,c;if("categorical"===n){l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];c=typeof e.stops[0][0]}if(i){const i={},r=[];for(let t=0;t<e.stops.length;t++){const n=e.stops[t],s=n[0].zoom;void 0===i[s]&&(i[s]={zoom:s,type:e.type,property:e.property,default:e.default,stops:[]},r.push(s)),i[s].stops.push([n[0].value,n[1]])}const n=[];for(const e of r)n.push([i[e].zoom,Xr(i[e],t)]);const s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:pi.interpolationFactor.bind(void 0,s),zoomStops:n.map(e=>e[0]),evaluate:({zoom:i},r)=>Jr({stops:n,base:e.base},t,i).evaluate(i,r)}}if(r){const i="exponential"===n?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:pi.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>a(e,t,i,l,c)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?Hr(e.default,t.default):a(e,t,n,l,c)}}}function Hr(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Yr(e,t,i,r,n){return Hr(typeof i===n?r[i]:void 0,e.default,t.default)}function Kr(e,t,i){if("number"!==Zr(i))return Hr(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=oi(e.stops.map(e=>e[0]),i);return e.stops[n][1]}function Jr(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==Zr(i))return Hr(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const s=oi(e.stops.map(e=>e[0]),i),o=function(e,t,i,r){const n=r-i,s=e-i;return 0===n?0:1===t?s/n:(Math.pow(t,s)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[s][0],e.stops[s+1][0]),a=e.stops[s][1],l=e.stops[s+1][1],c=mi[t.type]||Wr;return"function"==typeof a.evaluate?{evaluate(...t){const i=a.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==r)return c(i,r,o,e.colorSpace)}}:c(a,l,o,e.colorSpace)}function Qr(e,t,i){switch(t.type){case"color":i=Mt.parse(i);break;case"formatted":i=Dt.fromString(i.toString());break;case"resolvedImage":i=Ot.fromString(i.toString());break;case"padding":i=zt.parse(i);break;case"colorArray":i=Rt.parse(i);break;case"numberArray":i=kt.parse(i);break;default:Zr(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0)}return Hr(i,e.default,t.default)}Dr.register(Ar,{error:[{kind:"error"},[Be],(e,[t])=>{throw new Lt(t.evaluate(e))}],typeof:[Be,[Ue],(e,[t])=>Ke(Ut(t.evaluate(e)))],"to-rgba":[Ye(Fe,4),[Ve],(e,[t])=>{const[i,r,n,s]=t.evaluate(e).rgb;return[255*i,255*r,255*n,s]}],rgb:[Ve,[Fe,Fe,Fe],zr],rgba:[Ve,[Fe,Fe,Fe,Fe],zr],has:{type:Oe,overloads:[[[Be],(e,[t])=>kr(t.evaluate(e),e.properties())],[[Be,Ne],(e,[t,i])=>kr(t.evaluate(e),i.evaluate(e))]]},get:{type:Ue,overloads:[[[Be],(e,[t])=>Rr(t.evaluate(e),e.properties())],[[Be,Ne],(e,[t,i])=>Rr(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Ue,[Be],(e,[t])=>Rr(t.evaluate(e),e.featureState||{})],properties:[Ne,[],e=>e.properties()],"geometry-type":[Be,[],e=>e.geometryType()],id:[Ue,[],e=>e.id()],zoom:[Fe,[],e=>e.globals.zoom],"heatmap-density":[Fe,[],e=>e.globals.heatmapDensity||0],elevation:[Fe,[],e=>e.globals.elevation||0],"line-progress":[Fe,[],e=>e.globals.lineProgress||0],accumulated:[Ue,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Fe,Lr(Fe),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[Fe,Lr(Fe),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:Fe,overloads:[[[Fe,Fe],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Fe],(e,[t])=>-t.evaluate(e)]]},"/":[Fe,[Fe,Fe],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Fe,[Fe,Fe],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Fe,[],()=>Math.LN2],pi:[Fe,[],()=>Math.PI],e:[Fe,[],()=>Math.E],"^":[Fe,[Fe,Fe],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Fe,[Fe],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Fe,[Fe],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Fe,[Fe],(e,[t])=>Math.log(t.evaluate(e))],log2:[Fe,[Fe],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Fe,[Fe],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Fe,[Fe],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Fe,[Fe],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Fe,[Fe],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Fe,[Fe],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Fe,[Fe],(e,[t])=>Math.atan(t.evaluate(e))],min:[Fe,Lr(Fe),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[Fe,Lr(Fe),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[Fe,[Fe],(e,[t])=>Math.abs(t.evaluate(e))],round:[Fe,[Fe],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Fe,[Fe],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Fe,[Fe],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Oe,[Be,Ue],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Oe,[Ue],(e,[t])=>e.id()===t.value],"filter-type-==":[Oe,[Be],(e,[t])=>e.geometryType()===t.value],"filter-<":[Oe,[Be,Ue],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[Oe,[Ue],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[Oe,[Be,Ue],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Oe,[Ue],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[Oe,[Be,Ue],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Oe,[Ue],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[Oe,[Be,Ue],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Oe,[Ue],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[Oe,[Ue],(e,[t])=>t.value in e.properties()],"filter-has-id":[Oe,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Oe,[Ye(Be)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Oe,[Ye(Ue)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Oe,[Be,Ye(Ue)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Oe,[Be,Ye(Ue)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Lr(Oe),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Lr(Oe),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Oe,[Oe],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Oe,[Be],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Be,[Be],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Be,[Be],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Be,Lr(Ue),(e,t)=>t.map(t=>Gt(t.evaluate(e))).join("")],split:[Ye(Be),[Be,Be],(e,[t,i])=>t.evaluate(e).split(i.evaluate(e))],join:[Be,[Ye(Be),Be],(e,[t,i])=>t.value.join(i.evaluate(e))],"resolved-locale":[Be,[Ge],(e,[t])=>t.evaluate(e).resolvedLocale()]});class en{constructor(e,t,i){this.expression=e,this._warningHistory={},this._evaluator=new Yt,this._defaultValue=t?function(e){if("color"===e.type&&qr(e.default))return new Mt(0,0,0,0);switch(e.type){case"color":return Mt.parse(e.default)||null;case"padding":return zt.parse(e.default)||null;case"numberArray":return kt.parse(e.default)||null;case"colorArray":return Rt.parse(e.default)||null;case"variableAnchorOffsetCollection":return Bt.parse(e.default)||null;case"projectionDefinition":return Vt.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,n,s){return this._globalState&&(e=hn(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,s){this._globalState&&(e=hn(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Lt(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function tn(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Ar}function rn(e,t,i){const r=new Kt(Ar,Fr,[],t?function(e){const t={color:Ve,string:Be,number:Fe,enum:Be,boolean:Oe,formatted:$e,padding:Ze,numberArray:We,colorArray:qe,projectionDefinition:je,resolvedImage:Xe,variableAnchorOffsetCollection:He};return"array"===e.type?Ye(t[e.value]||Ue,e.length):t[e.type]}(t):void 0),n=r.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?jr(new en(n,t,i)):Nr(r.errors)}class nn{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!Or(t.expression),this.globalStateRefs=cn(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,n,s){return this._globalState&&(e=hn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,s)}evaluate(e,t,i,r,n,s){return this._globalState&&(e=hn(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,n,s)}}class sn{constructor(e,t,i,r,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Or(t.expression),this.globalStateRefs=cn(t.expression),this.interpolationType=r,this._globalState=n}evaluateWithoutErrorHandling(e,t,i,r,n,s){return this._globalState&&(e=hn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,s)}evaluate(e,t,i,r,n,s){return this._globalState&&(e=hn(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,n,s)}interpolationFactor(e,t,i){return this.interpolationType?pi.interpolationFactor(this.interpolationType,e,t,i):0}}function on(e,t,i){const r=rn(e,t,i);if("error"===r.result)return r;const n=r.value.expression,s=Br(n);if(!s&&!Ur(t))return Nr([new ke("","data expressions not supported")]);const o=Vr(n,["zoom"]);if(!o&&!Gr(t))return Nr([new ke("","zoom expressions not supported")]);const a=ln(n);return a||o?a instanceof ke?Nr([a]):a instanceof pi&&!$r(t)?Nr([new ke("",'"interpolate" expressions cannot be used with this property')]):jr(a?new sn(s?"camera":"composite",r.value,a.labels,a instanceof pi?a.interpolation:void 0,i):new nn(s?"constant":"source",r.value,i)):Nr([new ke("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class an{constructor(e,t){this._parameters=e,this._specification=t,ze(this,Xr(this._parameters,this._specification))}static deserialize(e){return new an(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ln(e){let t=null;if(e instanceof Jt)t=ln(e.result);else if(e instanceof gi){for(const i of e.args)if(t=ln(i),t)break}else(e instanceof ai||e instanceof pi)&&e.input instanceof Dr&&"zoom"===e.input.name&&(t=e);return t instanceof ke||e.eachChild(e=>{const i=ln(e);i instanceof ke?t=i:!t&&i?t=new ke("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new ke("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function cn(e,t=new Set){return e instanceof Cr&&t.add(e.key),e.eachChild(e=>{cn(e,t)}),t}function hn(e,t){const{zoom:i,heatmapDensity:r,elevation:n,lineProgress:s,isSupportedScript:o,accumulated:a}=null!=e?e:{};return{zoom:i,heatmapDensity:r,elevation:n,lineProgress:s,isSupportedScript:o,accumulated:a,globalState:t}}function un(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(!un(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const dn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function pn(e,t){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};un(e)||(e=gn(e));const i=rn(e,dn,t);if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return{filter:(e,t,r)=>i.value.evaluate(e,t,{},r),needGeometry:mn(e),getGlobalStateRefs:()=>cn(i.value.expression)}}function fn(e,t){return e<t?-1:e>t?1:0}function mn(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t<e.length;t++)if(mn(e[t]))return!0;return!1}function gn(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?_n(e[1],e[2],"=="):"!="===t?vn(_n(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?_n(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(gn))):"all"===t?["all"].concat(e.slice(1).map(gn)):"none"===t?["all"].concat(e.slice(1).map(gn).map(vn)):"in"===t?yn(e[1],e.slice(2)):"!in"===t?vn(yn(e[1],e.slice(2))):"has"===t?xn(e[1]):"!has"!==t||vn(xn(e[1]));var i}function _n(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function yn(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(fn)]]:["filter-in-small",e,["literal",t]]}}function xn(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function vn(e){return["!",e]}function bn(e){const t=typeof e;if("number"===t||"boolean"===t||"string"===t||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${bn(i)},`;return`${t}]`}const i=Object.keys(e).sort();let r="{";for(let n=0;n<i.length;n++)r+=`${JSON.stringify(i[n])}:${bn(e[i[n]])},`;return`${r}}`}function wn(e){let t="";for(const i of ve)t+=`/${bn(e[i])}`;return t}function Tn(e){const t=e.value;return t?[new De(e.key,t,"constants have been deprecated as of v8")]:[]}function Sn(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Pn(e){if(Array.isArray(e))return e.map(Pn);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Pn(e[i]);return t}return Sn(e)}function In(e){const t=e.key,i=e.value,r=e.valueSpec||{},n=e.objectElementValidators||{},s=e.style,o=e.styleSpec,a=e.validateSpec;let l=[];const c=Zr(i);if("object"!==c)return[new De(t,i,`object expected, ${c} found`)];for(const h in i){const e=h.split(".")[0],c=xt(r,e)||r["*"];let u;if(xt(n,e))u=n[e];else if(xt(r,e)){if(void 0===i[h])continue;u=a}else if(n["*"])u=n["*"];else{if(!r["*"]){l.push(new De(t,i[h],`unknown property "${h}"`));continue}u=a}l=l.concat(u({key:(t?`${t}.`:t)+h,value:i[h],valueSpec:c,style:s,styleSpec:o,object:i,objectKey:h,validateSpec:a},i))}for(const h in r)n[h]||r[h].required&&void 0===r[h].default&&void 0===i[h]&&l.push(new De(t,i,`missing required property "${h}"`));return l}function Mn(e){const t=e.value,i=e.valueSpec,r=e.style,n=e.styleSpec,s=e.key,o=e.arrayElementValidator||e.validateSpec;if("array"!==Zr(t))return[new De(s,t,`array expected, ${Zr(t)} found`)];if(i.length&&t.length!==i.length)return[new De(s,t,`array length ${i.length} expected, length ${t.length} found`)];let a={type:i.value,values:i.values};n.$version<7&&(a.function=i.function),"object"===Zr(i.value)&&(a=i.value);let l=[];for(let c=0;c<t.length;c++)l=l.concat(o({array:t,arrayIndex:c,value:t[c],valueSpec:a,validateSpec:e.validateSpec,style:r,styleSpec:n,key:`${s}[${c}]`}));return l}function En(e){const t=e.key,i=e.value,r=e.valueSpec;let n=Zr(i);return"number"===n&&i!=i&&(n="NaN"),"number"!==n?[new De(t,i,`number expected, ${n} found`)]:"minimum"in r&&i<r.minimum?[new De(t,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new De(t,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function Cn(e){const t=e.valueSpec,i=Sn(e.value.type);let r,n,s,o={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Zr(e.value.stops)&&"array"===Zr(e.value.stops[0])&&"object"===Zr(e.value.stops[0][0]),h=In({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new De(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Mn({key:e.key,value:r,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:u})),"array"===Zr(r)&&0===r.length&&t.push(new De(e.key,r,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&h.push(new De(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||h.push(new De(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!$r(e.valueSpec)&&h.push(new De(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Ur(e.valueSpec)?h.push(new De(e.key,e.value,"property functions not supported")):a&&!Gr(e.valueSpec)&&h.push(new De(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||h.push(new De(e.key,e.value,'"property" property is required')),h;function u(e){let i=[];const r=e.value,a=e.key;if("array"!==Zr(r))return[new De(a,r,`array expected, ${Zr(r)} found`)];if(2!==r.length)return[new De(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Zr(r[0]))return[new De(a,r,`object expected, ${Zr(r[0])} found`)];if(void 0===r[0].zoom)return[new De(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new De(a,r,"object stop key must have value")];if(s&&s>Sn(r[0].zoom))return[new De(a,r[0].zoom,"stop zoom values must appear in ascending order")];Sn(r[0].zoom)!==s&&(s=Sn(r[0].zoom),n=void 0,o={}),i=i.concat(In({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:En,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:r[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},r));return tn(Pn(r[1]))?i.concat([new De(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:r[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,s){const a=Zr(e.value),l=Sn(e.value),c=null!==e.value?e.value:s;if(r){if(a!==r)return[new De(e.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new De(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return Ur(t)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new De(e.key,c,r)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==n&&l<n?[new De(e.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in o?[new De(e.key,c,"stop domain values must be unique")]:(o[l]=!0,[])):[new De(e.key,c,`integer expected, found ${l}`)]}}function An(e){const t=("property"===e.expressionContext?on:rn)(Pn(e.value),e.valueSpec);if("error"===t.result)return t.value.map(t=>new De(`${e.key}${t.key}`,e.value,t.message));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new De(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!Or(i))return[new De(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!Or(i))return[new De(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Vr(i,["zoom","feature-state"]))return[new De(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!Br(i))return[new De(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Dn(e){const t=e.key,i=e.value,r=Zr(i);return"string"!==r?[new De(t,i,`color expected, ${r} found`)]:Mt.parse(String(i))?[]:[new De(t,i,`color expected, "${i}" found`)]}function zn(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(Sn(i))&&n.push(new De(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Sn(i))&&n.push(new De(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function kn(e){return un(Pn(e.value))?An(ze({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Rn(e)}function Rn(e){const t=e.value,i=e.key;if("array"!==Zr(t))return[new De(i,t,`array expected, ${Zr(t)} found`)];const r=e.styleSpec;let n,s=[];if(t.length<1)return[new De(i,t,"filter array must have at least 1 element")];switch(s=s.concat(zn({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),Sn(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===Sn(t[1])&&s.push(new De(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&s.push(new De(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(n=Zr(t[1]),"string"!==n&&s.push(new De(`${i}[1]`,t[1],`string expected, ${n} found`)));for(let o=2;o<t.length;o++)n=Zr(t[o]),"$type"===Sn(t[1])?s=s.concat(zn({key:`${i}[${o}]`,value:t[o],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&s.push(new De(`${i}[${o}]`,t[o],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<t.length;r++)s=s.concat(Rn({key:`${i}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":n=Zr(t[1]),2!==t.length?s.push(new De(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):"string"!==n&&s.push(new De(`${i}[1]`,t[1],`string expected, ${n} found`))}return s}function Ln(e,t){const i=e.key,r=e.validateSpec,n=e.style,s=e.styleSpec,o=e.value,a=e.objectKey,l=s[`${t}_${e.layerType}`];if(!l)return[];const c=a.match(/^(.*)-transition$/);if("paint"===t&&c&&l[c[1]]&&l[c[1]].transition)return r({key:i,value:o,valueSpec:s.transition,style:n,styleSpec:s});const h=e.valueSpec||l[a];if(!h)return[new De(i,o,`unknown property "${a}"`)];let u;if("string"===Zr(o)&&Ur(h)&&!h.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new De(i,o,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const d=[];return"symbol"===e.layerType&&"text-font"===a&&qr(Pn(o))&&"identity"===Sn(o.type)&&d.push(new De(i,o,'"text-font" does not support identity functions')),d.concat(r({key:e.key,value:o,valueSpec:h,style:n,styleSpec:s,expressionContext:"property",propertyType:t,propertyKey:a}))}function Fn(e){return Ln(e,"paint")}function Bn(e){return Ln(e,"layout")}function On(e){var t,i;let r=[];const n=e.value,s=e.key,o=e.style,a=e.styleSpec;if("object"!==Zr(n))return[new De(s,n,`object expected, ${Zr(n)} found`)];n.type||n.ref||r.push(new De(s,n,'either "type" or "ref" is required'));let l=Sn(n.type);const c=Sn(n.ref);if(n.id){const t=Sn(n.id);for(let i=0;i<e.arrayIndex;i++){const e=o.layers[i];Sn(e.id)===t&&r.push(new De(s,n.id,`duplicate layer id "${n.id}", previously used at line ${e.id.__line__}`))}}if("ref"in n){let e;["type","source","source-layer","filter","layout"].forEach(e=>{e in n&&r.push(new De(s,n[e],`"${e}" is prohibited for ref layers`))}),o.layers.forEach(t=>{Sn(t.id)===c&&(e=t)}),e?e.ref?r.push(new De(s,n.ref,"ref cannot reference another ref layer")):l=Sn(e.type):r.push(new De(s,n.ref,`ref layer "${c}" not found`))}else if("background"!==l)if(n.source){const e=o.sources&&o.sources[n.source],t=e&&Sn(e.type);e?"vector"===t&&"raster"===l?r.push(new De(s,n.source,`layer "${n.id}" requires a raster source`)):"raster-dem"!==t&&"hillshade"===l||"raster-dem"!==t&&"color-relief"===l?r.push(new De(s,n.source,`layer "${n.id}" requires a raster-dem source`)):"raster"===t&&"raster"!==l?r.push(new De(s,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==t||n["source-layer"]?"raster-dem"===t&&"hillshade"!==l&&"color-relief"!==l?r.push(new De(s,n.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==l||!n.paint||!n.paint["line-gradient"]||"geojson"===t&&e.lineMetrics||r.push(new De(s,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new De(s,n,`layer "${n.id}" must specify a "source-layer"`)):r.push(new De(s,n.source,`source "${n.source}" not found`))}else r.push(new De(s,n,'missing required property "source"'));return"raster"===l&&(null===(t=n.paint)||void 0===t?void 0:t.resampling)&&(null===(i=n.paint)||void 0===i?void 0:i["raster-resampling"])&&r.push(new De(s,n.paint,`layer "${n.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),r=r.concat(In({key:s,value:n,valueSpec:a.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${s}.type`,value:n.type,valueSpec:a.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:n,objectKey:"type"}),filter:kn,layout:e=>In({layer:n,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Bn(ze({layerType:l},e))}}),paint:e=>In({layer:n,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Fn(ze({layerType:l},e))}})}})),r}function Vn(e){const t=e.value,i=e.key,r=Zr(t);return"string"!==r?[new De(i,t,`string expected, ${r} found`)]:[]}const jn={promoteId:function({key:e,value:t}){if("string"===Zr(t))return Vn({key:e,value:t});{const i=[];for(const r in t)i.push(...Vn({key:`${e}.${r}`,value:t[r]}));return i}}};function Nn(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style,s=e.validateSpec;if(!t.type)return[new De(i,t,'"type" is required')];const o=Sn(t.type);let a;switch(o){case"vector":case"raster":return a=In({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:jn,validateSpec:s}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",r=e.value,n=e.styleSpec,s=n.source_raster_dem,o=e.style;let a=[];const l=Zr(r);if(void 0===r)return a;if("object"!==l)return a.push(new De("source_raster_dem",r,`object expected, ${l} found`)),a;const c="custom"===Sn(r.encoding),h=["redFactor","greenFactor","blueFactor","baseShift"],u=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const d in r)!c&&h.includes(d)?a.push(new De(d,r[d],`In "${i}": "${d}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):s[d]?a=a.concat(e.validateSpec({key:d,value:r[d],valueSpec:s[d],validateSpec:e.validateSpec,style:o,styleSpec:n})):a.push(new De(d,r[d],`unknown property "${d}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:r,validateSpec:s}),a;case"geojson":if(a=In({key:i,value:t,valueSpec:r.source_geojson,style:n,styleSpec:r,validateSpec:s,objectElementValidators:jn}),t.cluster)for(const e in t.clusterProperties){const[r,n]=t.clusterProperties[e],s="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...An({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...An({key:`${i}.${e}.reduce`,value:s,expressionContext:"cluster-reduce"}))}return a;case"video":return In({key:i,value:t,valueSpec:r.source_video,style:n,validateSpec:s,styleSpec:r});case"image":return In({key:i,value:t,valueSpec:r.source_image,style:n,validateSpec:s,styleSpec:r});case"canvas":return[new De(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return zn({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Un(e){const t=e.value,i=e.styleSpec,r=i.light,n=e.style;let s=[];const o=Zr(t);if(void 0===t)return s;if("object"!==o)return s=s.concat([new De("light",t,`object expected, ${o} found`)]),s;for(const a in t){const o=a.match(/^(.*)-transition$/);s=s.concat(o&&r[o[1]]&&r[o[1]].transition?e.validateSpec({key:a,value:t[a],valueSpec:i.transition,validateSpec:e.validateSpec,style:n,styleSpec:i}):r[a]?e.validateSpec({key:a,value:t[a],valueSpec:r[a],validateSpec:e.validateSpec,style:n,styleSpec:i}):[new De(a,t[a],`unknown property "${a}"`)])}return s}function Gn(e){const t=e.value,i=e.styleSpec,r=i.sky,n=e.style,s=Zr(t);if(void 0===t)return[];if("object"!==s)return[new De("sky",t,`object expected, ${s} found`)];let o=[];for(const a in t)o=o.concat(r[a]?e.validateSpec({key:a,value:t[a],valueSpec:r[a],style:n,styleSpec:i}):[new De(a,t[a],`unknown property "${a}"`)]);return o}function $n(e){const t=e.value,i=e.styleSpec,r=i.terrain,n=e.style;let s=[];const o=Zr(t);if(void 0===t)return s;if("object"!==o)return s=s.concat([new De("terrain",t,`object expected, ${o} found`)]),s;for(const a in t)s=s.concat(r[a]?e.validateSpec({key:a,value:t[a],valueSpec:r[a],validateSpec:e.validateSpec,style:n,styleSpec:i}):[new De(a,t[a],`unknown property "${a}"`)]);return s}function Zn(e){let t=[];const i=e.value,r=e.key;if(Array.isArray(i)){const n=[],s=[];for(const o in i)i[o].id&&n.includes(i[o].id)&&t.push(new De(r,i,`all the sprites' ids must be unique, but ${i[o].id} is duplicated`)),n.push(i[o].id),i[o].url&&s.includes(i[o].url)&&t.push(new De(r,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),s.push(i[o].url),t=t.concat(In({key:`${r}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return Vn({key:r,value:i})}function qn(e){return Boolean(e)&&e.constructor===Object}function Wn(e){return qn(e.value)?[]:[new De(e.key,e.value,`object expected, ${Zr(e.value)} found`)]}const Xn={"*":()=>[],array:Mn,boolean:function(e){const t=e.value,i=e.key,r=Zr(t);return"boolean"!==r?[new De(i,t,`boolean expected, ${r} found`)]:[]},number:En,color:Dn,constants:Tn,enum:zn,filter:kn,function:Cn,layer:On,object:In,source:Nn,light:Un,sky:Gn,terrain:$n,projection:function(e){const t=e.value,i=e.styleSpec,r=i.projection,n=e.style,s=Zr(t);if(void 0===t)return[];if("object"!==s)return[new De("projection",t,`object expected, ${s} found`)];let o=[];for(const a in t)o=o.concat(r[a]?e.validateSpec({key:a,value:t[a],valueSpec:r[a],style:n,styleSpec:i}):[new De(a,t[a],`unknown property "${a}"`)]);return o},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const r=Zr(i);return"array"!==r||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(r)?[]:[new De(t,i,`projection expected, invalid type "${r}" found`)]:[new De(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:Vn,formatted:function(e){return 0===Vn(e).length?[]:An(e)},resolvedImage:function(e){return 0===Vn(e).length?[]:An(e)},padding:function(e){const t=e.key,i=e.value;if("array"===Zr(i)){if(i.length<1||i.length>4)return[new De(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const r={type:"number"};let n=[];for(let s=0;s<i.length;s++)n=n.concat(e.validateSpec({key:`${t}[${s}]`,value:i[s],validateSpec:e.validateSpec,valueSpec:r}));return n}return En({key:t,value:i,valueSpec:{}})},numberArray:function(e){const t=e.key,i=e.value;if("array"===Zr(i)){const r={type:"number"};if(i.length<1)return[new De(t,i,"array length at least 1 expected, length 0 found")];let n=[];for(let s=0;s<i.length;s++)n=n.concat(e.validateSpec({key:`${t}[${s}]`,value:i[s],validateSpec:e.validateSpec,valueSpec:r}));return n}return En({key:t,value:i,valueSpec:{}})},colorArray:function(e){const t=e.key,i=e.value;if("array"===Zr(i)){if(i.length<1)return[new De(t,i,"array length at least 1 expected, length 0 found")];let e=[];for(let r=0;r<i.length;r++)e=e.concat(Dn({key:`${t}[${r}]`,value:i[r]}));return e}return Dn({key:t,value:i})},variableAnchorOffsetCollection:function(e){const t=e.key,i=e.value,r=Zr(i),n=e.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new De(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let s=[];for(let o=0;o<i.length;o+=2)s=s.concat(zn({key:`${t}[${o}]`,value:i[o],valueSpec:n.layout_symbol["text-anchor"]})),s=s.concat(Mn({key:`${t}[${o+1}]`,value:i[o+1],valueSpec:{length:2,value:"number"},validateSpec:e.validateSpec,style:e.style,styleSpec:n}));return s},sprite:Zn,state:Wn,fontFaces:function(e){const t=e.key,i=e.value,r=e.validateSpec,n=e.styleSpec,s=e.style;if(!qn(i))return[new De(t,i,`object expected, ${Zr(i)} found`)];const o=[];for(const a in i){const e=i[a],l=Zr(e);if("string"===l)o.push(...Vn({key:`${t}.${a}`,value:e}));else if("array"===l){const i={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[l,c]of e.entries())o.push(...In({key:`${t}.${a}[${l}]`,value:c,valueSpec:i,styleSpec:n,style:s,validateSpec:r}))}else o.push(new De(`${t}.${a}`,e,`string or array expected, ${l} found`))}return o}};function Hn(e){const t=e.value,i=e.valueSpec,r=e.styleSpec;return e.validateSpec=Hn,i.expression&&qr(Sn(t))?Cn(e):i.expression&&tn(Pn(t))?An(e):i.type&&Xn[i.type]?Xn[i.type](e):In(ze({},e,{valueSpec:i.type?r[i.type]:i}))}function Yn(e){const t=e.value,i=e.key,r=Vn(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new De(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new De(i,t,'"glyphs" url must include a "{range}" token'))),r}function Kn(e,t=xe){let i=[];return i=i.concat(Hn({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,validateSpec:Hn,objectElementValidators:{glyphs:Yn,"*":()=>[]}})),e.constants&&(i=i.concat(Tn({key:"constants",value:e.constants}))),Qn(i)}function Jn(e){return function(t){return e(Object.assign({},t,{validateSpec:Hn}))}}function Qn(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function es(e){return function(...t){return Qn(e.apply(this,t))}}Kn.source=es(Jn(Nn)),Kn.sprite=es(Jn(Zn)),Kn.glyphs=es(Jn(Yn)),Kn.light=es(Jn(Un)),Kn.sky=es(Jn(Gn)),Kn.terrain=es(Jn($n)),Kn.state=es(Jn(Wn)),Kn.layer=es(Jn(On)),Kn.filter=es(Jn(kn)),Kn.paintProperty=es(Jn(Fn)),Kn.layoutProperty=es(Jn(Bn));const ts={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class is{constructor(e,t){this._globalState=t,this.setValue(e)}evaluate(){var e;return null!==(e=this._literalValue)&&void 0!==e?e:this._compiledValue.evaluate({})}setValue(e){if(null==e||"visible"===e||"none"===e)return this._literalValue="none"===e?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const t=rn(e,ts,this._globalState);if("error"===t.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(t.value.map(e=>`${e.key}: ${e.message}`).join(", "));this._literalValue=void 0,this._compiledValue=t.value,this._globalStateRefs=cn(t.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const rs=xe,ns=Kn,ss=ns.light,os=ns.sky,as=ns.paintProperty,ls=ns.layoutProperty;function cs(e,t){let i=!1;if(t&&t.length)for(const r of t)e.fire(new _e(new Error(r.message))),i=!0;return i}class hs{constructor(e,t,i){const r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(i=n[2]);for(let e=0;e<this.d*this.d;e++){const t=n[3+e],i=n[3+e+1];r.push(t===i?null:n.subarray(t,i))}const s=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],s),this.bboxes=n.subarray(s),this.insert=this._insertReadonly}else{this.d=t+2*i;for(let e=0;e<this.d*this.d;e++)r.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=i,this.scale=t/e,this.uid=0;const n=i/t*e;this.min=-n,this.max=e+n}insert(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(e,t,i,r,n,s){this.cells[n].push(s)}query(e,t,i,r,n){const s=this.min,o=this.max;if(e<=s&&t<=s&&o<=i&&o<=r&&!n)return[...this.keys];{const s=[];return this._forEachCell(e,t,i,r,this._queryCell,s,{},n),s}}_queryCell(e,t,i,r,n,s,o,a){const l=this.cells[n];if(null!==l){const n=this.keys,c=this.bboxes;for(let h=0;h<l.length;h++){const u=l[h];if(void 0===o[u]){const l=4*u;(a?a(c[l+0],c[l+1],c[l+2],c[l+3]):e<=c[l+2]&&t<=c[l+3]&&i>=c[l+0]&&r>=c[l+1])?(o[u]=!0,s.push(n[u])):o[u]=!1}}}}_forEachCell(e,t,i,r,n,s,o,a){const l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&n.call(this,e,t,i,r,c,s,o,a))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,t=3+this.cells.length+1+1;let i=0;for(let s=0;s<this.cells.length;s++)i+=this.cells[s].length;const r=new Int32Array(t+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let n=t;for(let s=0;s<e.length;s++){const t=e[s];r[3+s]=n,r.set(t,n),n+=t.length}return r[3+e.length]=n,r.set(this.keys,n),n+=this.keys.length,r[3+e.length+1]=n,r.set(this.bboxes,n),n+=this.bboxes.length,r.buffer}static serialize(e,t){const i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}}static deserialize(e){return new hs(e.buffer)}}const us={};function ds(e,t,i={}){if(us[e])throw new Error(`${e} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),us[e]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}ds("Object",Object),ds("Set",Set),ds("TransferableGridIndex",hs),ds("Color",Mt),ds("Error",Error),ds("AJAXError",he),ds("ResolvedImage",Ot),ds("StylePropertyFunction",an),ds("StyleExpression",en,{omit:["_evaluator"]}),ds("ZoomDependentExpression",sn),ds("ZoomConstantExpression",nn),ds("CompoundExpression",Dr,{omit:["_evaluate"]});for(const Um in Ar)Ar[Um]._classRegistryKey||ds(`Expression_${Um}`,Ar[Um]);function ps(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function fs(e){return e.$name||e.constructor._classRegistryKey}function ms(e){return!function(e){if(null===e||"object"!=typeof e)return!1;const t=fs(e);return!(!t||"Object"===t)}(e)&&(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof Blob||e instanceof Error||ps(e)||X(e)||ArrayBuffer.isView(e)||e instanceof ImageData)}function gs(e,t){if(ms(e))return(ps(e)||X(e))&&t&&t.push(e),ArrayBuffer.isView(e)&&t&&t.push(e.buffer),e instanceof ImageData&&t&&t.push(e.data.buffer),e;if(Array.isArray(e)){const i=[];for(const r of e)i.push(gs(r,t));return i}if("object"!=typeof e)throw new Error("can't serialize object of type "+typeof e);const i=fs(e);if(!i)throw new Error(`can't serialize object of unregistered class ${e.constructor.name}`);if(!us[i])throw new Error(`${i} is not registered.`);const{klass:r}=us[i],n=r.serialize?r.serialize(e,t):{};if(r.serialize){if(t&&n===t[t.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const r in e){if(!e.hasOwnProperty(r))continue;if(us[i].omit.indexOf(r)>=0)continue;const s=e[r];n[r]=us[i].shallow.indexOf(r)>=0?s:gs(s,t)}e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(n.$name=i),n}function _s(e){if(ms(e))return e;if(Array.isArray(e))return e.map(_s);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const t=fs(e)||"Object";if(!us[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=us[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const r=Object.create(i.prototype);for(const n of Object.keys(e)){if("$name"===n)continue;const i=e[n];r[n]=us[t].shallow.indexOf(n)>=0?i:_s(i)}return r}class ys{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=i,!0))}}function xs(e){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function vs(e){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))}function bs(e){return/\s/u.test(String.fromCodePoint(e))}function ws(e){for(const t of e)if(vs(t.codePointAt(0)))return!0;return!1}function Ts(e){for(const t of e)if(!Is(t.codePointAt(0)))return!1;return!0}function Ss(e){const t=e.map(e=>{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}}).filter(e=>e);return new RegExp(t.join("|"),"u")}const Ps=Ss(["Arab","Dupl","Mong","Ougr","Syrc"]);function Is(e){return!Ps.test(String.fromCodePoint(e))}function Ms(e){return!(vs(e)||(t=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(t))));var t}const Es=Ss(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Cs(e){return Es.test(String.fromCodePoint(e))}function As(e,t){return!(!t&&Cs(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function Ds(e){for(const t of e)if(Cs(t.codePointAt(0)))return!0;return!1}const zs=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(zs.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,i){return t(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const t=e.pluginURL,r=new Promise(e=>{this.loadScriptResolve=e});i(t);const n=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(yield Promise.race([r,n]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${t}`)})}};class ks{constructor(e,t){this.isSupportedScript=Rs,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new ys,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ys,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}function Rs(e){return function(e,t){for(const i of e)if(!As(i.codePointAt(0),t))return!1;return!0}(e,"loaded"===zs.getRTLTextPluginStatus())}const Ls="-transition";class Fs{constructor(e,t,i){this.property=e,this.value=t,this.expression=function(e,t,i){if(qr(e))return new an(e,t);if(tn(e)){const r=on(e,t,i);if("error"===r.result)throw new Error(r.value.map(e=>`${e.key}: ${e.message}`).join(", "));return r.value}{let i=e;return"color"===t.type&&"string"==typeof e?i=Mt.parse(e):"padding"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==t.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===t.type&&Array.isArray(e)?i=Bt.parse(e):"projectionDefinition"===t.type&&"string"==typeof e&&(i=Vt.parse(e)):i=Rt.parse(e):i=kt.parse(e):i=zt.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class Bs{constructor(e,t){this.property=e,this.value=new Fs(e,void 0,t)}transitioned(e,t){return new Vs(this.property,this.value,t,O({},e.transition,this.transition),e.now)}untransitioned(){return new Vs(this.property,this.value,null,{},0)}}class Os{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=t}getValue(e){return U(this._values[e].value.value)}setValue(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Bs(this._values[e].property,this._globalState)),this._values[e].value=new Fs(this._values[e].property,null===t?void 0:U(t),this._globalState)}getTransition(e){return U(this._values[e].transition)}setTransition(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Bs(this._values[e].property,this._globalState)),this._values[e].transition=U(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}${Ls}`]=r)}return e}transitioned(e,t){const i=new js(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new js(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Vs{constructor(e,t,i,r,n){this.property=e,this.value=t,this.begin=n+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),s=this.prior;if(s){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return s.possiblyEvaluate(e,t,i);{const o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(e,t,i),n,k(o))}}return n}}class js{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const r=new Gs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Ns{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._globalState=t}hasValue(e){return void 0!==this._values[e].value}getValue(e){return U(this._values[e].value)}setValue(e,t){this._values[e]=new Fs(this._values[e].property,null===t?void 0:U(t),this._globalState)}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){const r=new Gs(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}}class Us{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}}class Gs{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class $s{constructor(e){this.specification=e}possiblyEvaluate(e,t){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(t)}interpolate(e,t,i){const r=mi[this.specification.type];return r?r(e,t,i):e}}class Zs{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,r){return new Us(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)}:e.expression,t)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new Us(this,{kind:"constant",value:void 0},e.parameters);const r=mi[this.specification.type];if(r){const n=r(e.value.value,t.value.value,i);return new Us(this,{kind:"constant",value:n},e.parameters)}return e}evaluate(e,t,i,r,n,s){return"constant"===e.kind?e.value:e.evaluate(t,i,r,n,s)}}class qs extends Zs{possiblyEvaluate(e,t,i,r){if(void 0===e.value)return new Us(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r),s="resolvedImage"===e.property.specification.type&&"string"!=typeof n?n.name:n,o=this._calculate(s,s,s,t);return new Us(this,{kind:"constant",value:o},t)}if("camera"===e.expression.kind){const i=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new Us(this,{kind:"constant",value:i},t)}return new Us(this,e.expression,t)}evaluate(e,t,i,r,n,s){if("source"===e.kind){const o=e.evaluate(t,i,r,n,s);return this._calculate(o,o,o,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,r),e.evaluate({zoom:Math.floor(t.zoom)},i,r),e.evaluate({zoom:Math.floor(t.zoom)+1},i,r),t):e.value}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Ws{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){if(void 0!==e.value){if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r);return this._calculate(n,n,n,t)}return this._calculate(e.expression.evaluate(new ks(Math.floor(t.zoom-1),t)),e.expression.evaluate(new ks(Math.floor(t.zoom),t)),e.expression.evaluate(new ks(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Xs{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}}class Hs{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const i=e[t];i.specification.overridable&&this.overridableProperties.push(t);const r=this.defaultPropertyValues[t]=new Fs(i,void 0,void 0),n=this.defaultTransitionablePropertyValues[t]=new Bs(i,void 0);this.defaultTransitioningPropertyValues[t]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}}ds("DataDrivenProperty",Zs),ds("DataConstantProperty",$s),ds("CrossFadedDataDrivenProperty",qs),ds("CrossFadedProperty",Ws),ds("ColorRampProperty",Xs);class Ys extends ye{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(e,t){return new is(e,t)}(this.visibility,i),"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=pn(e.filter,i)),t.layout&&(this._unevaluatedLayout=new Ns(t.layout,i)),t.paint)){this._transitionablePaint=new Os(t.paint,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Gs(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=pn(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;for(const t of this._visibilityExpression.getGlobalStateRefs())e.add(t);if(this._unevaluatedLayout)for(const t in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[t];for(const t of i.getGlobalStateRefs())e.add(t)}for(const t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){var e;const t=new globalThis.Map;if(this._transitionablePaint)for(const i in this._transitionablePaint._values){const r=this._transitionablePaint._values[i].value;for(const n of r.getGlobalStateRefs()){const s=null!==(e=t.get(n))&&void 0!==e?e:[];s.push({name:i,value:r.value}),t.set(n,s)}}return t}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(e,t,i={}){if(null==t||!this._validate(ls,`layers.${this.id}.layout.${e}`,e,t,i))return"visibility"===e?(this.visibility=t,this._visibilityExpression.setValue(t),void this.recalculateVisibility()):void this._unevaluatedLayout.setValue(e,t)}getPaintProperty(e){return e.endsWith(Ls)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(as,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith(Ls))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const i=this._transitionablePaint._values[e],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),s=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const o=this._transitionablePaint._values[e].value;return o.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(e,s,o)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e=this.minzoom,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this._evaluatedVisibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),N(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,r,n={}){return(!n||!1!==n.validate)&&cs(this,e.call(ns,{key:t,layerType:this.type,objectKey:i,value:r,styleSpec:xe,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Us&&Ur(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}}let Ks;var Js={get paint(){return Ks=Ks||new Hs({"raster-opacity":new $s(xe.paint_raster["raster-opacity"]),"raster-hue-rotate":new $s(xe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new $s(xe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new $s(xe.paint_raster["raster-brightness-max"]),"raster-saturation":new $s(xe.paint_raster["raster-saturation"]),"raster-contrast":new $s(xe.paint_raster["raster-contrast"]),resampling:new $s(xe.paint_raster.resampling),"raster-resampling":new $s(xe.paint_raster["raster-resampling"]),"raster-fade-duration":new $s(xe.paint_raster["raster-fade-duration"])})}};class Qs extends Ys{constructor(e,t){super(e,Js,t)}}const eo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class to{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}}class io{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(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,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,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}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}}function ro(e,t=1){let i=0,r=0;return{members:e.map(e=>{const n=eo[e.type].BYTES_PER_ELEMENT,s=i=no(i,Math.max(t,n)),o=e.components||1;return r=Math.max(r,n),i+=n*o,{name:e.name,type:e.type,components:o,offset:s}}),size:no(i,Math.max(r,t)),alignment:t}}function no(e,t){return Math.ceil(e/t)*t}class so extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}so.prototype.bytesPerElement=4,ds("StructArrayLayout2i4",so);class oo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}oo.prototype.bytesPerElement=6,ds("StructArrayLayout3i6",oo);class ao extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,e}}ao.prototype.bytesPerElement=8,ds("StructArrayLayout4i8",ao);class lo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n,s)}emplace(e,t,i,r,n,s,o){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=s,this.int16[a+5]=o,e}}lo.prototype.bytesPerElement=12,ds("StructArrayLayout2i4i12",lo);class co extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n,s)}emplace(e,t,i,r,n,s,o){const a=4*e,l=8*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=n,this.uint8[l+6]=s,this.uint8[l+7]=o,e}}co.prototype.bytesPerElement=8,ds("StructArrayLayout2i4ub8",co);class ho extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}ho.prototype.bytesPerElement=8,ds("StructArrayLayout2f8",ho);class uo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,s,o,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,n,s,o,a,l,c)}emplace(e,t,i,r,n,s,o,a,l,c,h){const u=10*e;return this.uint16[u+0]=t,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=n,this.uint16[u+4]=s,this.uint16[u+5]=o,this.uint16[u+6]=a,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,e}}uo.prototype.bytesPerElement=20,ds("StructArrayLayout10ui20",uo);class po extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,s,o,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,n,s,o,a)}emplace(e,t,i,r,n,s,o,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=s,this.uint16[c+5]=o,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}po.prototype.bytesPerElement=16,ds("StructArrayLayout8ui16",po);class fo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,s,o,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,s,o,a,l,c,h,u)}emplace(e,t,i,r,n,s,o,a,l,c,h,u,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=s,this.uint16[p+5]=o,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,e}}fo.prototype.bytesPerElement=24,ds("StructArrayLayout4i4ui4i24",fo);class mo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}mo.prototype.bytesPerElement=12,ds("StructArrayLayout3f12",mo);class go extends io{_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}}go.prototype.bytesPerElement=4,ds("StructArrayLayout1ul4",go);class _o extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,s,o,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,r,n,s,o,a,l)}emplace(e,t,i,r,n,s,o,a,l,c){const h=10*e,u=5*e;return this.int16[h+0]=t,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=n,this.int16[h+4]=s,this.int16[h+5]=o,this.uint32[u+3]=a,this.uint16[h+8]=l,this.uint16[h+9]=c,e}}_o.prototype.bytesPerElement=20,ds("StructArrayLayout6i1ul2ui20",_o);class yo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n,s)}emplace(e,t,i,r,n,s,o){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=s,this.int16[a+5]=o,e}}yo.prototype.bytesPerElement=12,ds("StructArrayLayout2i2i2i12",yo);class xo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n)}emplace(e,t,i,r,n,s){const o=4*e,a=8*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.int16[a+6]=n,this.int16[a+7]=s,e}}xo.prototype.bytesPerElement=16,ds("StructArrayLayout2f1f2i16",xo);class vo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n,s)}emplace(e,t,i,r,n,s,o){const a=16*e,l=4*e,c=8*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=n,this.int16[c+6]=s,this.int16[c+7]=o,e}}vo.prototype.bytesPerElement=16,ds("StructArrayLayout2ub2f2i16",vo);class bo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}bo.prototype.bytesPerElement=6,ds("StructArrayLayout3ui6",bo);class wo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,s,o,a,l,c,h,u,d,p,f,m,g){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,r,n,s,o,a,l,c,h,u,d,p,f,m,g)}emplace(e,t,i,r,n,s,o,a,l,c,h,u,d,p,f,m,g,_){const y=24*e,x=12*e,v=48*e;return this.int16[y+0]=t,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=n,this.uint32[x+2]=s,this.uint32[x+3]=o,this.uint32[x+4]=a,this.uint16[y+10]=l,this.uint16[y+11]=c,this.uint16[y+12]=h,this.float32[x+7]=u,this.float32[x+8]=d,this.uint8[v+36]=p,this.uint8[v+37]=f,this.uint8[v+38]=m,this.uint32[x+10]=g,this.int16[y+22]=_,e}}wo.prototype.bytesPerElement=48,ds("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",wo);class To extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,s,o,a,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,S,P,I,M){const E=this.length;return this.resize(E+1),this.emplace(E,e,t,i,r,n,s,o,a,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,S,P,I,M)}emplace(e,t,i,r,n,s,o,a,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,S,P,I,M,E){const C=32*e,A=16*e;return this.int16[C+0]=t,this.int16[C+1]=i,this.int16[C+2]=r,this.int16[C+3]=n,this.int16[C+4]=s,this.int16[C+5]=o,this.int16[C+6]=a,this.int16[C+7]=l,this.uint16[C+8]=c,this.uint16[C+9]=h,this.uint16[C+10]=u,this.uint16[C+11]=d,this.uint16[C+12]=p,this.uint16[C+13]=f,this.uint16[C+14]=m,this.uint16[C+15]=g,this.uint16[C+16]=_,this.uint16[C+17]=y,this.uint16[C+18]=x,this.uint16[C+19]=v,this.uint16[C+20]=b,this.uint16[C+21]=w,this.uint16[C+22]=T,this.uint32[A+12]=S,this.float32[A+13]=P,this.float32[A+14]=I,this.uint16[C+30]=M,this.uint16[C+31]=E,e}}To.prototype.bytesPerElement=64,ds("StructArrayLayout8i15ui1ul2f2ui64",To);class So extends io{_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}}So.prototype.bytesPerElement=4,ds("StructArrayLayout1f4",So);class Po extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[6*e+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}Po.prototype.bytesPerElement=12,ds("StructArrayLayout1ui2f12",Po);class Io extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=4*e;return this.uint32[2*e+0]=t,this.uint16[n+2]=i,this.uint16[n+3]=r,e}}Io.prototype.bytesPerElement=8,ds("StructArrayLayout1ul2ui8",Io);class Mo extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}Mo.prototype.bytesPerElement=4,ds("StructArrayLayout2ui4",Mo);class Eo extends io{_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}}Eo.prototype.bytesPerElement=2,ds("StructArrayLayout1ui2",Eo);class Co extends io{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const s=4*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,e}}Co.prototype.bytesPerElement=16,ds("StructArrayLayout4f16",Co);class Ao extends to{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}Ao.prototype.size=20;class Do extends _o{get(e){return new Ao(this,e)}}ds("CollisionBoxArray",Do);class zo extends to{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}zo.prototype.size=48;class ko extends wo{get(e){return new zo(this,e)}}ds("PlacedSymbolArray",ko);class Ro extends to{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Ro.prototype.size=64;class Lo extends To{get(e){return new Ro(this,e)}}ds("SymbolInstanceArray",Lo);class Fo extends So{getoffsetX(e){return this.float32[1*e+0]}}ds("GlyphOffsetArray",Fo);class Bo extends oo{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}ds("SymbolLineVertexArray",Bo);class Oo extends to{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Oo.prototype.size=12;class Vo extends Po{get(e){return new Oo(this,e)}}ds("TextAnchorOffsetArray",Vo);class jo extends to{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]}}jo.prototype.size=8;class No extends Io{get(e){return new jo(this,e)}}ds("FeatureIndexArray",No);class Uo extends so{}class Go extends so{}class $o extends so{}class Zo extends lo{}class qo extends co{}class Wo extends ho{}class Xo extends uo{}class Ho extends po{}class Yo extends fo{}class Ko extends mo{}class Jo extends go{}class Qo extends yo{}class ea extends vo{}class ta extends bo{}class ia extends Mo{}const ra=ro([{name:"a_pos",components:2,type:"Int16"}],4),{members:na}=ra;class sa{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,i,r){const n=this.segments[this.segments.length-1];return e>sa.MAX_VERTEX_ARRAY_LENGTH&&$(`Max vertices per segment is ${sa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${sa.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+e>sa.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r?this.createNewSegment(t,i,r):n}createNewSegment(e,t,i){const r={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(r.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(e,t,i){return this.prepareSegment(0,e,t,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}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,i,r){return new sa([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function oa(e,t){return 256*(e=F(Math.floor(e),0,255))+F(Math.floor(t),0,255)}sa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ds("SegmentVector",sa);const aa=ro([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),la=ro([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var ca,ha,ua,da={exports:{}},pa={exports:{}},fa={exports:{}},ma=function(){if(ua)return da.exports;ua=1;var e=(ca||(ca=1,pa.exports=function(e,t){var i,r,n,s,o,a,l,c;for(r=e.length-(i=3&e.length),n=t,o=3432918353,a=461845907,c=0;c<r;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,n=27492+(65535&(s=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}),pa.exports),t=(ha||(ha=1,fa.exports=function(e,t){for(var i,r=e.length,n=t^r,s=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(s)|(255&e.charCodeAt(++s))<<8|(255&e.charCodeAt(++s))<<16|(255&e.charCodeAt(++s))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++s;switch(r){case 3:n^=(255&e.charCodeAt(s+2))<<16;case 2:n^=(255&e.charCodeAt(s+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(s)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}),fa.exports);return da.exports=e,da.exports.murmur3=e,da.exports.murmur2=t,da.exports}(),ga=r(ma);class _a{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(ya(e)),this.positions.push(t,i,r)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const t=ya(e);let i=0,r=this.ids.length-1;for(;i<r;){const e=i+r>>1;this.ids[e]>=t?r=e:i=e+1}const n=[];for(;this.ids[i]===t;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return xa(i,r,0,i.length-1),t&&t.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(e){const t=new _a;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function ya(e){const t=+e;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:ga(String(e))}function xa(e,t,i,r){for(;i<r;){const n=e[i+r>>1];let s=i-1,o=r+1;for(;;){do{s++}while(e[s]<n);do{o--}while(e[o]>n);if(s>=o)break;va(e,s,o),va(t,3*s,3*o),va(t,3*s+1,3*o+1),va(t,3*s+2,3*o+2)}o-i<r-o?(xa(e,t,i,o),i=o+1):(xa(e,t,o+1,r),r=o)}}function va(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}ds("FeaturePositionMap",_a);class ba{constructor(e,t){this.gl=e.gl,this.location=t}}class wa extends ba{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Ta extends ba{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class Sa extends ba{constructor(e,t){super(e,t),this.current=Mt.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const Pa=new Float32Array(16);function Ia(e){return[oa(255*e.r,255*e.g),oa(255*e.b,255*e.a)]}class Ma{constructor(e,t,i){this.value=e,this.uniformNames=t.map(e=>`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new Sa(e,t):new wa(e,t)}}class Ea{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,i,r){let n=null;"u_pattern_to"===r?n=this.patternTo:"u_pattern_from"===r?n=this.patternFrom:"u_dasharray_to"===r?n=this.dashTo:"u_dasharray_from"===r?n=this.dashFrom:"u_pixel_ratio_to"===r?n=this.pixelRatioTo:"u_pixel_ratio_from"===r&&(n=this.pixelRatioFrom),null!==n&&e.set(n)}getBinding(e,t,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new Ta(e,t):new wa(e,t)}}class Ca{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,i){const r=this.paintVertexArray.length,n=this.expression.evaluate(new ks(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,n)}updatePaintArray(e,t,i,r,n){const s=this.expression.evaluate(new ks(0,n),i,r);this._setPaintValue(e,t,s)}_setPaintValue(e,t,i){if("color"===this.type){const r=Ia(i);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){var t;(null===(t=this.paintVertexArray)||void 0===t?void 0:t.arrayBuffer.byteLength)&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Aa{constructor(e,t,i,r,n,s){this.expression=e,this.uniformNames=t.map(e=>`u_${e}_t`),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0})),this.paintVertexArray=new s}populatePaintArray(e,t,i){const r=this.expression.evaluate(new ks(this.zoom,i),t,{},i.canonical,[],i.formattedSection),n=this.expression.evaluate(new ks(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),s=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(s,e,r,n)}updatePaintArray(e,t,i,r,n){const s=this.expression.evaluate(new ks(this.zoom,n),i,r),o=this.expression.evaluate(new ks(this.zoom+1,n),i,r);this._setPaintValue(e,t,s,o)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=Ia(i),s=Ia(r);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n[0],n[1],s[0],s[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(e){var t;(null===(t=this.paintVertexArray)||void 0===t?void 0:t.arrayBuffer.byteLength)&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){const i=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=F(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,i){return new wa(e,t)}}class Da{constructor(e,t,i,r,n,s){this.expression=e,this.type=t,this.useIntegerZoom=i,this.zoom=r,this.layerId=s,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}populatePaintArray(e,t,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,this.getPositionIds(t),i)}updatePaintArray(e,t,i,r,n){this._setPaintValues(e,t,this.getPositionIds(i),n)}_setPaintValues(e,t,i,r){const n=this.getPositions(r);if(!n||!i)return;const s=n[i.min],o=n[i.mid],a=n[i.max];if(s&&o&&a)for(let l=e;l<t;l++)this.emplace(this.zoomInPaintVertexArray,l,o,s),this.emplace(this.zoomOutPaintVertexArray,l,o,a)}upload(e){var t,i;if((null===(t=this.zoomInPaintVertexArray)||void 0===t?void 0:t.arrayBuffer.byteLength)&&(null===(i=this.zoomOutPaintVertexArray)||void 0===i?void 0:i.arrayBuffer.byteLength)){const t=this.getVertexAttributes();this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,t,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,t,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class za extends Da{getPositions(e){return e.imagePositions}getPositionIds(e){return e.patterns&&e.patterns[this.layerId]}getVertexAttributes(){return aa.members}emplace(e,t,i,r){e.emplace(t,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],i.pixelRatio,r.pixelRatio)}}class ka extends Da{getPositions(e){return e.dashPositions}getPositionIds(e){return e.dashes&&e.dashes[this.layerId]}getVertexAttributes(){return la.members}emplace(e,t,i,r){e.emplace(t,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}}class Ra{constructor(e,t,i){this.binders={},this._buffers=[];const r=[];for(const n in e.paint._values){if(!i(n))continue;const s=e.paint.get(n);if(!(s instanceof Us&&Ur(s.property.specification)))continue;const o=Fa(n,e.type),a=s.value,l=s.property.specification.type,c=s.property.useIntegerZoom,h=s.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h;if("constant"===a.kind)this.binders[n]=u?new Ea(a.value,o):new Ma(a.value,o,l),r.push(`/u_${n}`);else if("source"===a.kind||u){const i=Ba(n,l,"source");this.binders[n]=u?"line-dasharray"===n?new ka(a,l,c,t,i,e.id):new za(a,l,c,t,i,e.id):new Ca(a,o,l,i),r.push(`/a_${n}`)}else{const e=Ba(n,l,"composite");this.binders[n]=new Aa(a,o,l,c,t,e),r.push(`/z_${n}`)}}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Ca||t instanceof Aa?t.maxValue:0}populatePaintArrays(e,t,i){for(const r in this.binders){const n=this.binders[r];(n instanceof Ca||n instanceof Aa||n instanceof Da)&&n.populatePaintArray(e,t,i)}}setConstantPatternPositions(e,t){for(const i in this.binders){const r=this.binders[i];r instanceof Ea&&r.setConstantPatternPositions(e,t)}}setConstantDashPositions(e,t){for(const i in this.binders){const r=this.binders[i];r instanceof Ea&&r.setConstantDashPositions(e,t)}}updatePaintArrays(e,t,i,r,n){let s=!1;for(const o in e){const a=t.getPositions(o);for(const t of a){const a=i.feature(t.index);for(const i in this.binders){const l=this.binders[i];if((l instanceof Ca||l instanceof Aa||l instanceof Da)&&!0===l.expression.isStateDependent){const c=r.paint.get(i);l.expression=c.value,l.updatePaintArray(t.start,t.end,a,e[o],n),s=!0}}}}return s}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof Ma||i instanceof Ea)&&e.push(...i.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Ca||i instanceof Aa)for(let t=0;t<i.paintVertexAttributes.length;t++)e.push(i.paintVertexAttributes[t].name);else if(i instanceof Da){const t=i.getVertexAttributes();for(const i of t)e.push(i.name)}}return e}getBinderUniforms(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Ma||i instanceof Ea||i instanceof Aa)for(const t of i.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof Ma||n instanceof Ea||n instanceof Aa)for(const s of n.uniformNames)if(t[s]){const o=n.getBinding(e,t[s],s);i.push({name:s,property:r,binding:o})}}return i}setUniforms(e,t,i,r){for(const{name:n,property:s,binding:o}of t)this.binders[s].setUniform(o,r,i.get(s),n)}updatePaintBuffers(e){this._buffers=[];for(const t in this.binders){const i=this.binders[t];if(e&&i instanceof Da){const t=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(i instanceof Ca||i instanceof Aa)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof Ca||i instanceof Aa||i instanceof Da)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof Ca||t instanceof Aa||t instanceof Da)&&t.destroy()}}}class La{constructor(e,t,i=()=>!0){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Ra(r,t,i);this.needsUpload=!1,this._featureMap=new _a,this._bufferOffset=0}populatePaintArrays(e,t,i,r){for(const n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r){for(const n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(e,this._featureMap,t,n,r)||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()}}function Fa(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function Ba(e,t,i){const r={color:{source:ho,composite:Co},number:{source:So,composite:ho}},n=function(e){return{"line-pattern":{source:Xo,composite:Xo},"fill-pattern":{source:Xo,composite:Xo},"fill-extrusion-pattern":{source:Xo,composite:Xo},"line-dasharray":{source:Ho,composite:Ho}}[e]}(e);return n&&n[i]||r[t][i]}ds("ConstantBinder",Ma),ds("CrossFadedConstantBinder",Ea),ds("SourceExpressionBinder",Ca),ds("CrossFadedPatternBinder",za),ds("CrossFadedDasharrayBinder",ka),ds("CompositeExpressionBinder",Aa),ds("ProgramConfiguration",Ra,{omit:["_buffers"]}),ds("ProgramConfigurationSet",La);const Oa=Math.pow(2,14)-1,Va=-Oa-1;function ja(e){const t=C/e.extent,i=e.loadGeometry();for(let r=0;r<i.length;r++){const e=i[r];for(let i=0;i<e.length;i++){const r=e[i],n=Math.round(r.x*t),s=Math.round(r.y*t);r.x=F(n,Va,Oa),r.y=F(s,Va,Oa),(n<r.x||n>r.x+1||s<r.y||s>r.y+1)&&$("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Na(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?ja(e):[]}}const Ua=-32768;function Ga(e,t,i,r,n){e.emplaceBack(Ua+8*t+r,Ua+8*i+n)}class $a{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Go,this.indexArray=new ta,this.segments=new sa,this.programConfigurations=new La(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){const r=this.layers[0],n=[];let s=null,o=!1,a="heatmap"===r.type;if("circle"===r.type){const e=r;s=e.layout.get("circle-sort-key"),o=!s.isConstant(),a=a||"map"===e.paint.get("circle-pitch-alignment")}const l=a?t.subdivisionGranularity.circle:1;for(const{feature:c,id:h,index:u,sourceLayerIndex:d}of e){const e=this.layers[0]._featureFilter.needGeometry,t=Na(c,e);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),t,i))continue;const r=o?s.evaluate(t,{},i):void 0,a={id:h,properties:c.properties,type:c.type,sourceLayerIndex:d,index:u,geometry:e?t.geometry:ja(c),patterns:{},sortKey:r};n.push(a)}o&&n.sort((e,t)=>e.sortKey-t.sortKey);for(const c of n){const{geometry:r,index:n,sourceLayerIndex:s}=c,o=e[n].feature;this.addFeature(c,r,n,i,l),t.featureIndex.insert(o,r,n,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,na),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,r,n=1){let s;switch(n){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${n}; valid values are 1, 3, 5, 7.`)}const o=s.length;for(const a of t)for(const t of a){const i=t.x,r=t.y;if(i<0||i>=C||r<0||r>=C)continue;const n=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,e.sortKey),a=n.vertexLength;for(let e=0;e<o;e++)for(let t=0;t<o;t++)Ga(this.layoutVertexArray,i,r,s[t],s[e]);for(let e=0;e<o-1;e++)for(let t=0;t<o-1;t++){const i=a+e*o+t,r=a+(e+1)*o+t;this.indexArray.emplaceBack(i,r+1,i+1),this.indexArray.emplaceBack(i,r,r+1)}n.vertexLength+=o*o,n.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:{},canonical:r})}}function Za(e,t){for(let i=0;i<e.length;i++)if(el(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(el(e,t[i]))return!0;return!!Ha(e,t)}function qa(e,t,i){return!!el(e,t)||!!Ka(t,e,i)}function Wa(e,t){if(1===e.length)return Qa(t,e[0]);for(let i=0;i<t.length;i++){const r=t[i];for(let t=0;t<r.length;t++)if(el(e,r[t]))return!0}for(let i=0;i<e.length;i++)if(Qa(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(Ha(e,t[i]))return!0;return!1}function Xa(e,t,i){if(e.length>1){if(Ha(e,t))return!0;for(let r=0;r<t.length;r++)if(Ka(t[r],e,i))return!0}for(let r=0;r<e.length;r++)if(Ka(e[r],t,i))return!0;return!1}function Ha(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++)if(Ya(r,n,t[e],t[e+1]))return!0}return!1}function Ya(e,t,i,r){return Z(e,i,r)!==Z(t,i,r)&&Z(e,t,i)!==Z(e,t,r)}function Ka(e,t,i){const r=i*i;if(1===t.length)return e.distSqr(t[0])<r;for(let n=1;n<t.length;n++)if(Ja(e,t[n-1],t[n])<r)return!0;return!1}function Ja(e,t,i){const r=t.distSqr(i);if(0===r)return e.distSqr(t);const n=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return e.distSqr(n<0?t:n>1?i:i.sub(t)._mult(n)._add(t))}function Qa(e,t){let i,r,n,s=!1;for(let o=0;o<e.length;o++){i=e[o];for(let e=0,o=i.length-1;e<i.length;o=e++)r=i[e],n=i[o],r.y>t.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(s=!s)}return s}function el(e,t){let i=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){const s=e[r],o=e[n];s.y>t.y!=o.y>t.y&&t.x<(o.x-s.x)*(t.y-s.y)/(o.y-s.y)+s.x&&(i=!i)}return i}function tl(e,t,i){const r=i[0],n=i[2];if(e.x<r.x&&t.x<r.x||e.x>n.x&&t.x>n.x||e.y<r.y&&t.y<r.y||e.y>n.y&&t.y>n.y)return!1;const s=Z(e,t,i[0]);return s!==Z(e,t,i[1])||s!==Z(e,t,i[2])||s!==Z(e,t,i[3])}function il(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function rl(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function nl(e,t,r,n,s){if(!t[0]&&!t[1])return e;const o=i.convert(t)._mult(s);"viewport"===r&&o._rotate(-n);const a=[];for(let i=0;i<e.length;i++)a.push(e[i].sub(o));return a}function sl(e){const t=[];for(let i=0;i<e.length;i++){const r=e[i],n=t.at(-1);(0===i||n&&!r.equals(n))&&t.push(r)}return t}function ol({queryGeometry:e,size:t},i){return qa(e,i,t)}function al({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:n},s){return qa(e,s,t*(i.projectTileCoordinates(s.x,s.y,r,n).signedDistanceFromCamera/i.cameraToCenterDistance))}function ll({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:n},s){const o=i.projectTileCoordinates(s.x,s.y,r,n).signedDistanceFromCamera,a=t*(i.cameraToCenterDistance/o);return qa(e,ul(s,i,r,n),a)}function cl({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:n},s){return qa(e,ul(s,i,r,n),t)}function hl({queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:n,pitchAlignment:s="map",pitchScale:o="map"},a){const l="map"===s?"map"===o?ol:al:"map"===o?ll:cl,c={queryGeometry:e,size:t,transform:i,unwrappedTileID:r,getElevation:n};for(const h of a)for(const e of h)if(l(c,e))return!0;return!1}function ul(e,t,r,n){const s=t.projectTileCoordinates(e.x,e.y,r,n).point;return new i((.5*s.x+.5)*t.width,(.5*-s.y+.5)*t.height)}let dl,pl;ds("CircleBucket",$a,{omit:["layers"]});var fl={get paint(){return pl=pl||new Hs({"circle-radius":new Zs(xe.paint_circle["circle-radius"]),"circle-color":new Zs(xe.paint_circle["circle-color"]),"circle-blur":new Zs(xe.paint_circle["circle-blur"]),"circle-opacity":new Zs(xe.paint_circle["circle-opacity"]),"circle-translate":new $s(xe.paint_circle["circle-translate"]),"circle-translate-anchor":new $s(xe.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new $s(xe.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new $s(xe.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Zs(xe.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Zs(xe.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Zs(xe.paint_circle["circle-stroke-opacity"])})},get layout(){return dl=dl||new Hs({"circle-sort-key":new Zs(xe.layout_circle["circle-sort-key"])})}};class ml extends Ys{constructor(e,t){super(e,fl,t)}createBucket(e){return new $a(e)}queryRadius(e){const t=e;return il("circle-radius",this,t)+il("circle-stroke-width",this,t)+rl(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:a}){const l=nl(e,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-n.bearingInRadians,s),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i),h=this.paint.get("circle-pitch-scale"),u=this.paint.get("circle-pitch-alignment");let d,p;return"map"===u?(d=l,p=c*s):(d=function(e,t,i,r){return e.map(e=>ul(e,t,i,r))}(l,n,o,a),p=c),hl({queryGeometry:d,size:p,transform:n,unwrappedTileID:o,getElevation:a,pitchAlignment:u,pitchScale:h},r)}}class gl extends $a{}let _l;ds("HeatmapBucket",gl,{omit:["layers"]});var yl={get paint(){return _l=_l||new Hs({"heatmap-radius":new Zs(xe.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Zs(xe.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new $s(xe.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Xs(xe.paint_heatmap["heatmap-color"]),"heatmap-opacity":new $s(xe.paint_heatmap["heatmap-opacity"])})}};function xl(e,{width:t,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*i*r)throw new RangeError(`mismatched image size. expected: ${n.length} but got: ${t*i*r}`)}else n=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=n,e}function vl(e,{width:t,height:i},r){if(t===e.width&&i===e.height)return;const n=xl({},{width:t,height:i},r);bl(e,n,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},r),e.width=t,e.height=i,e.data=n.data}function bl(e,t,i,r,n,s){if(0===n.width||0===n.height)return t;if(n.width>e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const o=e.data,a=t.data;if(o===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l<n.height;l++){const c=((i.y+l)*e.width+i.x)*s,h=((r.y+l)*t.width+r.x)*s;for(let e=0;e<n.width*s;e++)a[h+e]=o[c+e]}return t}class wl{constructor(e,t){xl(this,e,1,t)}resize(e){vl(this,e,1)}clone(){return new wl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){bl(e,t,i,r,n,1)}}class Tl{constructor(e,t){xl(this,e,4,t)}resize(e){vl(this,e,4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Tl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){bl(e,t,i,r,n,4)}setPixel(e,t,i){const r=4*(e*this.width+t);this.data[r+0]=Math.round(255*i.r/i.a),this.data[r+1]=Math.round(255*i.g/i.a),this.data[r+2]=Math.round(255*i.b/i.a),this.data[r+3]=Math.round(255*i.a)}}function Sl(e){const t=new Uint8Array(e.length);for(let i=0;i<e.length;i+=4){const r=e[i+3];t[i+0]=Math.round(e[i+0]*r/255),t[i+1]=Math.round(e[i+1]*r/255),t[i+2]=Math.round(e[i+2]*r/255),t[i+3]=r}return t}function Pl(e){const t={},i=e.resolution||256,r=e.clips?e.clips.length:1,n=e.image||new Tl({width:i,height:r});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const s=(r,s,o)=>{t[e.evaluationKey]=o;const a=e.expression.evaluate(t);n.setPixel(r/4/i,s/4,a)};if(e.clips)for(let o=0,a=0;o<r;++o,a+=4*i)for(let t=0,r=0;t<i;t++,r+=4){const n=t/(i-1),{start:l,end:c}=e.clips[o];s(a,r,l*(1-n)+c*n)}else for(let o=0,a=0;o<i;o++,a+=4)s(0,a,o/(i-1));return n}ds("AlphaImage",wl),ds("RGBAImage",Tl);const Il="big-fb";class Ml extends Ys{createBucket(e){return new gl(e)}constructor(e,t){super(e,yl,t),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Pl({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Il)&&this.heatmapFbos.delete(Il)}queryRadius(e){return il("heatmap-radius",this,e)}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:a}){return hl({queryGeometry:e,size:this.paint.get("heatmap-radius").evaluate(t,i)*s,transform:n,unwrappedTileID:o,getElevation:a},r)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}}let El;var Cl={get paint(){return El=El||new Hs({"hillshade-illumination-direction":new $s(xe.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new $s(xe.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new $s(xe.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new $s(xe.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new $s(xe.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new $s(xe.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new $s(xe.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new $s(xe.paint_hillshade["hillshade-method"]),resampling:new $s(xe.paint_hillshade.resampling)})}};class Al extends Ys{constructor(e,t){super(e,Cl,t),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let e=this.paint.get("hillshade-illumination-direction").values,t=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,r=this.paint.get("hillshade-shadow-color").values;const n=Math.max(e.length,t.length,i.length,r.length);e=e.concat(Array(n-e.length).fill(e.at(-1))),t=t.concat(Array(n-t.length).fill(t.at(-1))),i=i.concat(Array(n-i.length).fill(i.at(-1))),r=r.concat(Array(n-r.length).fill(r.at(-1)));const s=t.map(ee);return{directionRadians:e.map(ee),altitudeRadians:s,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}}let Dl;var zl={get paint(){return Dl=Dl||new Hs({"color-relief-opacity":new $s(xe["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new Xs(xe["paint_color-relief"]["color-relief-color"]),resampling:new $s(xe["paint_color-relief"].resampling)})}};function kl(e){return"data"in e}class Rl{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this._ownedHandle=this.texture,this.update(t,r)}update(e,t,i){const{width:r,height:n}=e,s=!(this.size&&this.size[0]===r&&this.size[1]===n||i),{context:o}=this,{gl:a}=o;this.useMipmap=Boolean(t&&t.useMipmap),a.bindTexture(a.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);const l=this.format===a.RGBA&&(!t||!1!==t.premultiply);if(s)this.size=[r,n],kl(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(e,l,r,n,a)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._uploadDomImage(e,a));else{const{x:t,y:s}=i||{x:0,y:0};kl(e)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(e,l,t,s,r,n,a)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._updateDomImage(e,t,s,a))}this.useMipmap&&this.isSizePowerOfTwo()&&a.generateMipmap(a.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(e,t){t.texImage2D(t.TEXTURE_2D,0,this.format,this.format,t.UNSIGNED_BYTE,e)}_uploadRawData(e,t,i,r,n){let{data:s}=e;t&&s&&(s=Sl(s)),n.texImage2D(n.TEXTURE_2D,0,this.format,i,r,0,this.format,n.UNSIGNED_BYTE,s)}_updateDomImage(e,t,i,r){r.texSubImage2D(r.TEXTURE_2D,0,t,i,r.RGBA,r.UNSIGNED_BYTE,e)}_updateRawData(e,t,i,r,n,s,o){let{data:a}=e;t&&a&&(a=Sl(a)),o.texSubImage2D(o.TEXTURE_2D,0,i,r,n,s,o.RGBA,o.UNSIGNED_BYTE,a)}bind(e,t,i){const{context:r}=this,{gl:n}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),n.bindTexture(n.TEXTURE_2D,this.texture),i!==n.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=n.LINEAR),e!==this.filter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,i||e),this.filter=e),t!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrap=t)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}}class Ll{constructor(e,t,i,r=1,n=1,s=1,o=0){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&!["mapbox","terrarium","custom"].includes(i))return void $(`"${i}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=t.height;const a=this.dim=t.height-2;switch(this.data=new Uint32Array(t.data.buffer),i){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=r,this.greenFactor=n,this.blueFactor=s,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let l=0;l<a;l++)this.data[this._idx(-1,l)]=this.data[this._idx(0,l)],this.data[this._idx(a,l)]=this.data[this._idx(a-1,l)],this.data[this._idx(l,-1)]=this.data[this._idx(l,0)],this.data[this._idx(l,a)]=this.data[this._idx(l,a-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(a,-1)]=this.data[this._idx(a-1,0)],this.data[this._idx(-1,a)]=this.data[this._idx(0,a-1)],this.data[this._idx(a,a)]=this.data[this._idx(a-1,a-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let l=0;l<a;l++)for(let e=0;e<a;e++){const t=this.get(l,e);t>this.max&&(this.max=t),t<this.min&&(this.min=t)}}get(e,t){const i=new Uint8Array(this.data.buffer),r=4*this._idx(e,t);return this.unpack(i[r],i[r+1],i[r+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${e}, y: ${t}, dim: ${this.dim}`);return(t+1)*this.stride+(e+1)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return Fl(e,this.getUnpackVector())}getPixels(){return new Tl({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,s=i*this.dim,o=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:s=o-1;break;case 1:o=s+1}const a=-t*this.dim,l=-i*this.dim;for(let c=s;c<o;c++)for(let t=r;t<n;t++)this.data[this._idx(t,c)]=e.data[this._idx(t+a,c+l)]}}function Fl(e,t){const i=t[0],r=t[1],n=t[2],s=t[3],o=Math.min(i,r,n),a=Math.round((e+s)/o);return{r:Math.floor(a*o/i)%256,g:Math.floor(a*o/r)%256,b:Math.floor(a*o/n)%256}}ds("DEMData",Ll);class Bl extends Ys{constructor(e,t){super(e,zl,t)}_createColorRamp(e){const t={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof nn&&i._styleExpression.expression instanceof pi){this.colorRampExpression=i;const e=i._styleExpression.expression;t.elevationStops=e.labels,t.colorStops=[];for(const i of t.elevationStops)t.colorStops.push(e.evaluate({globals:{elevation:i}}))}if(t.elevationStops.length<1&&(t.elevationStops=[0],t.colorStops=[Mt.transparent]),t.elevationStops.length<2&&(t.elevationStops.push(t.elevationStops[0]+1),t.colorStops.push(t.colorStops[0])),t.elevationStops.length<=e)return t;const r={elevationStops:[],colorStops:[]},n=(t.elevationStops.length-1)/(e-1);for(let s=0;s<t.elevationStops.length-.5;s+=n)r.elevationStops.push(t.elevationStops[Math.round(s)]),r.colorStops.push(t.colorStops[Math.round(s)]);return $(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${e}, provided: ${t.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(e,t,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const r=this._createColorRamp(t),n=new Tl({width:r.colorStops.length,height:1}),s=new Tl({width:r.colorStops.length,height:1});for(let o=0;o<r.elevationStops.length;o++){const e=Fl(r.elevationStops[o],i);s.setPixel(0,o,new Mt(e.r/255,e.g/255,e.b/255,1)),n.setPixel(0,o,r.colorStops[o])}return this.colorRampTextures={elevationTexture:new Rl(e,s,e.gl.RGBA),colorTexture:new Rl(e,n,e.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}const Ol=ro([{name:"a_pos",components:2,type:"Int16"}],4),{members:Vl}=Ol;function jl(e,t,i){const r=i.patternDependencies;let n=!1;for(const s of t){const t=s.paint.get(`${e}-pattern`);t.isConstant()||(n=!0);const i=t.constantOr(null);i&&(n=!0,r[i.to]=!0,r[i.from]=!0)}return n}function Nl(e,t,i,r,n){const{zoom:s}=r,o=n.patternDependencies;for(const a of t){const t=a.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:s-1},i,{},n.availableImages),r=t.evaluate({zoom:s},i,{},n.availableImages),l=t.evaluate({zoom:s+1},i,{},n.availableImages);e=e&&e.name?e.name:e,r=r&&r.name?r.name:r,l=l&&l.name?l.name:l,o[e]=!0,o[r]=!0,o[l]=!0,i.patterns[a.id]={min:e,mid:r,max:l}}}return i}function Ul(e,t,i,r,n){let s;if(n===function(e,t,i,r){let n=0;for(let s=t,o=i-r;s<i;s+=r)n+=(e[o]-e[s])*(e[s+1]+e[o+1]),o=s;return n}(e,t,i,r)>0)for(let o=t;o<i;o+=r)s=hc(o/r|0,e[o],e[o+1],s);else for(let o=i-r;o>=t;o-=r)s=hc(o/r|0,e[o],e[o+1],s);return s&&nc(s,s.next)&&(uc(s),s=s.next),s}function Gl(e,t){if(!e)return e;t||(t=e);let i,r=e;do{if(i=!1,r.steiner||!nc(r,r.next)&&0!==rc(r.prev,r,r.next))r=r.next;else{if(uc(r),r=t=r.prev,r===r.next)break;i=!0}}while(i||r!==t);return t}function $l(e,t,i,r,n,s,o){if(!e)return;!o&&s&&function(e,t,i,r){let n=e;do{0===n.z&&(n.z=Jl(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){let t,i=1;do{let r,n=e;e=null;let s=null;for(t=0;n;){t++;let o=n,a=0;for(let e=0;e<i&&(a++,o=o.nextZ,o);e++);let l=i;for(;a>0||l>0&&o;)0!==a&&(0===l||!o||n.z<=o.z)?(r=n,n=n.nextZ,a--):(r=o,o=o.nextZ,l--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;n=o}s.nextZ=null,i*=2}while(t>1)}(n)}(e,r,n,s);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(s?ql(e,r,n,s):Zl(e))t.push(l.i,e.i,c.i),uc(e),e=c.next,a=c.next;else if((e=c)===a){o?1===o?$l(e=Wl(Gl(e),t),t,i,r,n,s,2):2===o&&Xl(e,t,i,r,n,s):$l(Gl(e),t,i,r,n,s,1);break}}}function Zl(e){const t=e.prev,i=e,r=e.next;if(rc(t,i,r)>=0)return!1;const n=t.x,s=i.x,o=r.x,a=t.y,l=i.y,c=r.y,h=Math.min(n,s,o),u=Math.min(a,l,c),d=Math.max(n,s,o),p=Math.max(a,l,c);let f=r.next;for(;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&tc(n,a,s,l,o,c,f.x,f.y)&&rc(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ql(e,t,i,r){const n=e.prev,s=e,o=e.next;if(rc(n,s,o)>=0)return!1;const a=n.x,l=s.x,c=o.x,h=n.y,u=s.y,d=o.y,p=Math.min(a,l,c),f=Math.min(h,u,d),m=Math.max(a,l,c),g=Math.max(h,u,d),_=Jl(p,f,t,i,r),y=Jl(m,g,t,i,r);let x=e.prevZ,v=e.nextZ;for(;x&&x.z>=_&&v&&v.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==n&&x!==o&&tc(a,h,l,u,c,d,x.x,x.y)&&rc(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==n&&v!==o&&tc(a,h,l,u,c,d,v.x,v.y)&&rc(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==n&&x!==o&&tc(a,h,l,u,c,d,x.x,x.y)&&rc(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==n&&v!==o&&tc(a,h,l,u,c,d,v.x,v.y)&&rc(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Wl(e,t){let i=e;do{const r=i.prev,n=i.next.next;!nc(r,n)&&sc(r,i,i.next,n)&&lc(r,n)&&lc(n,r)&&(t.push(r.i,i.i,n.i),uc(i),uc(i.next),i=e=n),i=i.next}while(i!==e);return Gl(i)}function Xl(e,t,i,r,n,s){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&ic(o,e)){let a=cc(o,e);return o=Gl(o,o.next),a=Gl(a,a.next),$l(o,t,i,r,n,s,0),void $l(a,t,i,r,n,s,0)}e=e.next}o=o.next}while(o!==e)}function Hl(e,t){let i=e.x-t.x;return 0===i&&(i=e.y-t.y,0===i)&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function Yl(e,t){const i=function(e,t){let i=t;const r=e.x,n=e.y;let s,o=-1/0;if(nc(e,i))return i;do{if(nc(e,i.next))return i.next;if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const e=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>o&&(o=e,s=i.x<i.next.x?i:i.next,e===r))return s}i=i.next}while(i!==t);if(!s)return null;const a=s,l=s.x,c=s.y;let h=1/0;i=s;do{if(r>=i.x&&i.x>=l&&r!==i.x&&ec(n<c?r:o,n,l,c,n<c?o:r,n,i.x,i.y)){const t=Math.abs(n-i.y)/(r-i.x);lc(i,e)&&(t<h||t===h&&(i.x>s.x||i.x===s.x&&Kl(s,i)))&&(s=i,h=t)}i=i.next}while(i!==a);return s}(e,t);if(!i)return t;const r=cc(i,e);return Gl(r,r.next),Gl(i,i.next)}function Kl(e,t){return rc(e.prev,e,t.prev)<0&&rc(t.next,e,e.next)<0}function Jl(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ql(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function ec(e,t,i,r,n,s,o,a){return(n-o)*(t-a)>=(e-o)*(s-a)&&(e-o)*(r-a)>=(i-o)*(t-a)&&(i-o)*(s-a)>=(n-o)*(r-a)}function tc(e,t,i,r,n,s,o,a){return!(e===o&&t===a)&&ec(e,t,i,r,n,s,o,a)}function ic(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&sc(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(lc(e,t)&&lc(t,e)&&function(e,t){let i=e,r=!1;const n=(e.x+t.x)/2,s=(e.y+t.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&n<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(rc(e.prev,e,t.prev)||rc(e,t.prev,t))||nc(e,t)&&rc(e.prev,e,e.next)>0&&rc(t.prev,t,t.next)>0)}function rc(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function nc(e,t){return e.x===t.x&&e.y===t.y}function sc(e,t,i,r){const n=ac(rc(e,t,i)),s=ac(rc(e,t,r)),o=ac(rc(i,r,e)),a=ac(rc(i,r,t));return n!==s&&o!==a||!(0!==n||!oc(e,i,t))||!(0!==s||!oc(e,r,t))||!(0!==o||!oc(i,e,r))||!(0!==a||!oc(i,t,r))}function oc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function ac(e){return e>0?1:e<0?-1:0}function lc(e,t){return rc(e.prev,e,e.next)<0?rc(e,t,e.next)>=0&&rc(e,e.prev,t)>=0:rc(e,t,e.prev)<0||rc(e,e.next,t)<0}function cc(e,t){const i=dc(e.i,e.x,e.y),r=dc(t.i,t.x,t.y),n=e.next,s=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function hc(e,t,i,r){const n=dc(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function uc(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 dc(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class pc{constructor(e,t){if(t>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<<e)),this._minGranularity,1)}}class fc{constructor(e){this.fill=e.fill,this.line=e.line,this.tile=e.tile,this.stencil=e.stencil,this.circle=e.circle}}fc.noSubdivision=new fc({fill:new pc(0,0),line:new pc(0,0),tile:new pc(0,0),stencil:new pc(0,0),circle:1}),ds("SubdivisionGranularityExpression",pc),ds("SubdivisionGranularitySetting",fc);const mc=-32768,gc=32767;class _c{constructor(e,t){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=e,this._granularityCellSize=C/e,this._canonical=t}_getKey(e,t){return(e+=32768)<<16|t+32768}_vertexToIndex(e,t){if(e<-32768||t<-32768||e>32767||t>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(e),r=0|Math.round(t),n=this._getKey(i,r);if(this._vertexDictionary.has(n))return this._vertexDictionary.get(n);const s=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,s),this._vertexBuffer.push(i,r),s}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){const i=[];for(let r=0;r<t.length;r+=3){const n=t[r],s=t[r+1],o=t[r+2],a=e[2*n],l=e[2*n+1];(e[2*s]-a)*(e[2*o+1]-l)-(e[2*s+1]-l)*(e[2*o]-a)>0?(i.push(n),i.push(o),i.push(s)):(i.push(n),i.push(s),i.push(o))}return i}(this._vertexBuffer,e);const t=[],i=e.length;for(let r=0;r<i;r+=3){const i=[e[r+0],e[r+1],e[r+2]],n=[this._vertexBuffer[2*e[r+0]+0],this._vertexBuffer[2*e[r+0]+1],this._vertexBuffer[2*e[r+1]+0],this._vertexBuffer[2*e[r+1]+1],this._vertexBuffer[2*e[r+2]+0],this._vertexBuffer[2*e[r+2]+1]];let s=1/0,o=1/0,a=-1/0,l=-1/0;for(let e=0;e<3;e++){const t=n[2*e],i=n[2*e+1];s=Math.min(s,t),a=Math.max(a,t),o=Math.min(o,i),l=Math.max(l,i)}if(s===a||o===l)continue;const c=Math.floor(s/this._granularityCellSize),h=Math.ceil(a/this._granularityCellSize),u=Math.floor(o/this._granularityCellSize),d=Math.ceil(l/this._granularityCellSize);if(c!==h||u!==d)for(let e=u;e<d;e++){const r=this._scanlineGenerateVertexRingForCellRow(e,n,i);vc(this._vertexBuffer,r,t)}else t.push(...i)}return t}_scanlineGenerateVertexRingForCellRow(e,t,i){const r=e*this._granularityCellSize,n=r+this._granularityCellSize,s=[];for(let o=0;o<3;o++){const e=t[2*o],a=t[2*o+1],l=t[2*(o+1)%6],c=t[(2*(o+1)+1)%6],h=t[2*(o+2)%6],u=t[(2*(o+2)+1)%6],d=l-e,p=c-a,f=0===d,m=0===p,g=(r-a)/p,_=(n-a)/p,y=Math.min(g,_),x=Math.max(g,_);if(!m&&(y>=1||x<=0)||m&&(a<r||a>n)){c>=r&&c<=n&&s.push(i[(o+1)%3]);continue}!m&&y>0&&s.push(this._vertexToIndex(e+d*y,a+p*y));const v=e+d*Math.max(y,0),b=e+d*Math.min(x,1);f||this._generateIntraEdgeVertices(s,e,a,l,c,v,b),!m&&x<1&&s.push(this._vertexToIndex(e+d*x,a+p*x)),(m||c>=r&&c<=n)&&s.push(i[(o+1)%3]),!m&&(c<=r||c>=n)&&this._generateInterEdgeVertices(s,e,a,l,c,h,u,b,r,n)}return s}_generateIntraEdgeVertices(e,t,i,r,n,s,o){const a=r-t,l=n-i,c=0===l,h=c?Math.min(t,r):Math.min(s,o),u=c?Math.max(t,r):Math.max(s,o),d=Math.floor(h/this._granularityCellSize)+1,p=Math.ceil(u/this._granularityCellSize)-1;if(c?t<r:s<o)for(let f=d;f<=p;f++){const r=f*this._granularityCellSize;e.push(this._vertexToIndex(r,i+l*(r-t)/a))}else for(let f=p;f>=d;f--){const r=f*this._granularityCellSize;e.push(this._vertexToIndex(r,i+l*(r-t)/a))}}_generateInterEdgeVertices(e,t,i,r,n,s,o,a,l,c){const h=n-i,u=s-r,d=o-n,p=(l-n)/d,f=(c-n)/d,m=Math.min(p,f),g=Math.max(p,f),_=r+u*m;let y=Math.floor(Math.min(_,a)/this._granularityCellSize)+1,x=Math.ceil(Math.max(_,a)/this._granularityCellSize)-1,v=a<_;const b=0===d;if(b&&(o===l||o===c))return;if(b||m>=1||g<=0){const e=i-o,r=s+(t-s)*Math.min((l-o)/e,(c-o)/e);y=Math.floor(Math.min(r,a)/this._granularityCellSize)+1,x=Math.ceil(Math.max(r,a)/this._granularityCellSize)-1,v=a<r}const w=h>0?c:l;if(v)for(let T=y;T<=x;T++)e.push(this._vertexToIndex(T*this._granularityCellSize,w));else for(let T=x;T>=y;T--)e.push(this._vertexToIndex(T*this._granularityCellSize,w))}_generateOutline(e){const t=[];for(const i of e){const e=xc(i,this._granularity,!0),r=this._pointArrayToIndices(e),n=[];for(let t=1;t<r.length;t++)n.push(r[t-1]),n.push(r[t]);t.push(n)}return t}_handlePoles(e){let t=!1,i=!1;this._canonical&&(0===this._canonical.y&&(t=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(t||i)&&this._fillPoles(e,t,i)}_ensureNoPoleVertices(){const e=this._vertexBuffer;for(let t=0;t<e.length;t+=2){const i=e[t+1];i===mc&&(e[t+1]=-32767),i===gc&&(e[t+1]=32766)}}_generatePoleQuad(e,t,i,r,n,s){r>n!=(s===mc)?(e.push(t),e.push(i),e.push(this._vertexToIndex(r,s)),e.push(i),e.push(this._vertexToIndex(n,s)),e.push(this._vertexToIndex(r,s))):(e.push(i),e.push(t),e.push(this._vertexToIndex(r,s)),e.push(this._vertexToIndex(n,s)),e.push(i),e.push(this._vertexToIndex(r,s)))}_fillPoles(e,t,i){const r=this._vertexBuffer,n=C,s=e.length;for(let o=2;o<s;o+=3){const s=e[o-2],a=e[o-1],l=e[o],c=r[2*s],h=r[2*s+1],u=r[2*a],d=r[2*a+1],p=r[2*l],f=r[2*l+1];t&&(0===h&&0===d&&this._generatePoleQuad(e,s,a,c,u,mc),0===d&&0===f&&this._generatePoleQuad(e,a,l,u,p,mc),0===f&&0===h&&this._generatePoleQuad(e,l,s,p,c,mc)),i&&(h===n&&d===n&&this._generatePoleQuad(e,s,a,c,u,gc),d===n&&f===n&&this._generatePoleQuad(e,a,l,u,p,gc),f===n&&h===n&&this._generatePoleQuad(e,l,s,p,c,gc))}}_initializeVertices(e){for(let t=0;t<e.length;t+=2)this._vertexToIndex(e[t],e[t+1])}subdividePolygonInternal(e,t){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:i,holeIndices:r}=function(e){const t=[],i=[];for(const r of e)if(0!==r.length){r!==e[0]&&t.push(i.length/2);for(let e=0;e<r.length;e++)i.push(r[e].x),i.push(r[e].y)}return{flattened:i,holeIndices:t}}(e);let n;this._initializeVertices(i);try{const e=function(e,t,i=2){const r=t&&t.length,n=r?t[0]*i:e.length;let s=Ul(e,0,n,i,!0);const o=[];if(!s||s.next===s.prev)return o;let a,l,c;if(r&&(s=function(e,t,i,r){const n=[];for(let s=0,o=t.length;s<o;s++){const i=Ul(e,t[s]*r,s<o-1?t[s+1]*r:e.length,r,!1);i===i.next&&(i.steiner=!0),n.push(Ql(i))}n.sort(Hl);for(let s=0;s<n.length;s++)i=Yl(n[s],i);return i}(e,t,s,i)),e.length>80*i){a=e[0],l=e[1];let t=a,r=l;for(let s=i;s<n;s+=i){const i=e[s],n=e[s+1];i<a&&(a=i),n<l&&(l=n),i>t&&(t=i),n>r&&(r=n)}c=Math.max(t-a,r-l),c=0!==c?32767/c:0}return $l(s,o,i,a,l,c,0),o}(i,r),t=this._convertIndices(i,e);n=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let s=[];return t&&(s=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(n),{verticesFlattened:this._vertexBuffer,indicesTriangles:n,indicesLineList:s}}_convertIndices(e,t){const i=[];for(let r=0;r<t.length;r++)i.push(this._vertexToIndex(e[2*t[r]],e[2*t[r]+1]));return i}_pointArrayToIndices(e){const t=[];for(let i=0;i<e.length;i++){const r=e[i];t.push(this._vertexToIndex(r.x,r.y))}return t}}function yc(e,t,i,r=!0){return new _c(i,t).subdividePolygonInternal(e,r)}function xc(e,t,r=!1){if(!e||e.length<1)return[];if(e.length<2)return[];const n=e[0],s=e[e.length-1],o=r&&(n.x!==s.x||n.y!==s.y);if(t<2)return o?[...e,e[0]]:[...e];const a=Math.floor(C/t),l=[];l.push(new i(e[0].x,e[0].y));const c=e.length,h=o?c:c-1;for(let u=0;u<h;u++){const t=e[u],r=u<c-1?e[u+1]:e[0],n=t.x,s=t.y,o=r.x,h=r.y,d=n!==o,p=s!==h;if(!d&&!p)continue;const f=o-n,m=h-s,g=Math.abs(f),_=Math.abs(m);let y=n,x=s;for(;;){const e=f>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,t=m>0?(Math.floor(x/a)+1)*a:(Math.ceil(x/a)-1)*a,r=Math.abs(y-e),n=Math.abs(x-t),s=Math.abs(y-o),c=Math.abs(x-h),u=d?r/g:Number.POSITIVE_INFINITY,v=p?n/_:Number.POSITIVE_INFINITY;if((s<=r||!d)&&(c<=n||!p))break;if(u<v&&d||!p){y=e,x+=m*u;const t=new i(y,Math.round(x));l[l.length-1].x===t.x&&l[l.length-1].y===t.y||l.push(t)}else{y+=f*v,x=t;const e=new i(Math.round(y),x);l[l.length-1].x===e.x&&l[l.length-1].y===e.y||l.push(e)}}const v=new i(o,h);l[l.length-1].x===v.x&&l[l.length-1].y===v.y||l.push(v)}return l}function vc(e,t,i){if(0===t.length)throw new Error("Subdivision vertex ring is empty.");let r=0,n=e[2*t[0]];for(let l=1;l<t.length;l++){const i=e[2*t[l]];i<n&&(n=i,r=l)}const s=t.length;let o=r,a=(o+1)%s;for(;;){const r=o-1>=0?o-1:s-1,n=(a+1)%s,l=e[2*t[r]],c=e[2*t[n]],h=e[2*t[o]],u=e[2*t[o]+1],d=e[2*t[a]+1];let p=!1;if(l<c)p=!0;else if(l>c)p=!1;else{const i=d-u,s=-(e[2*t[a]]-h),o=u<d?1:-1;((l-h)*i+(e[2*t[r]+1]-u)*s)*o>((c-h)*i+(e[2*t[n]+1]-u)*s)*o&&(p=!0)}if(p){const e=t[r],n=t[o],l=t[a];e!==n&&e!==l&&n!==l&&i.push(l,n,e),o--,o<0&&(o=s-1)}else{const e=t[n],r=t[o],l=t[a];e!==r&&e!==l&&r!==l&&i.push(l,r,e),a++,a>=s&&(a=0)}if(r===n)break}}function bc(e,t,i,r,n,s,o,a,l){const c=n.length/2,h=o&&a&&l;if(c<sa.MAX_VERTEX_ARRAY_LENGTH){const u=t.prepareSegment(c,i,r),d=u.vertexLength;for(let e=0;e<s.length;e+=3)r.emplaceBack(d+s[e],d+s[e+1],d+s[e+2]);let p,f;u.vertexLength+=c,u.primitiveLength+=s.length/3,h&&(f=o.prepareSegment(c,i,a),p=f.vertexLength,f.vertexLength+=c);for(let t=0;t<n.length;t+=2)e(n[t],n[t+1]);if(h)for(let e=0;e<l.length;e++){const t=l[e];for(let e=1;e<t.length;e+=2)a.emplaceBack(p+t[e-1],p+t[e]);f.primitiveLength+=t.length/2}}else!function(e,t,i,r,n,s){const o=[];for(let u=0;u<r.length/2;u++)o.push(-1);const a={count:0};let l=0,c=e.getOrCreateLatestSegment(t,i),h=c.vertexLength;for(let u=2;u<n.length;u+=3){const d=n[u-2],p=n[u-1],f=n[u];let m=o[d]<l,g=o[p]<l,_=o[f]<l;c.vertexLength+((m?1:0)+(g?1:0)+(_?1:0))>sa.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,m=!0,g=!0,_=!0,h=0);const y=wc(o,r,s,a,d,m,c),x=wc(o,r,s,a,p,g,c),v=wc(o,r,s,a,f,_,c);i.emplaceBack(h+y-l,h+x-l,h+v-l),c.primitiveLength++}}(t,i,r,n,s,e),h&&function(e,t,i,r,n,s){const o=[];for(let u=0;u<r.length/2;u++)o.push(-1);const a={count:0};let l=0,c=e.getOrCreateLatestSegment(t,i),h=c.vertexLength;for(let u=0;u<n.length;u++){const d=n[u];for(let p=1;p<n[u].length;p+=2){const n=d[p-1],u=d[p];let f=o[n]<l,m=o[u]<l;c.vertexLength+((f?1:0)+(m?1:0))>sa.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,f=!0,m=!0,h=0);const g=wc(o,r,s,a,n,f,c),_=wc(o,r,s,a,u,m,c);i.emplaceBack(h+g-l,h+_-l),c.primitiveLength++}}}(o,i,a,n,l,e),t.forceNewSegmentOnNextPrepare(),null==o||o.forceNewSegmentOnNextPrepare()}function wc(e,t,i,r,n,s,o){if(s){const s=r.count;return i(t[2*n],t[2*n+1]),e[n]=r.count,r.count++,o.vertexLength++,s}return e[n]}class Tc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new $o,this.indexArray=new ta,this.indexArray2=new ia,this.programConfigurations=new La(e.layers,e.zoom),this.segments=new sa,this.segments2=new sa,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=jl("fill",this.layers,t);const r=this.layers[0].layout.get("fill-sort-key"),n=!r.isConstant(),s=[];for(const{feature:o,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,h=Na(o,e);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),h,i))continue;const u=n?r.evaluate(h,{},i,t.availableImages):void 0,d={id:a,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:e?h.geometry:ja(o),patterns:{},sortKey:u};s.push(d)}n&&s.sort((e,t)=>e.sortKey-t.sortKey);for(const o of s){const{geometry:r,index:n,sourceLayerIndex:s}=o;if(this.hasDependencies){const e=Nl("fill",this.layers,o,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(o,r,n,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[n].feature,r,n,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e,t,i){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Vl),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,i,r,n,s){for(const o of er(t,500)){const e=yc(o,r,s.fill.getGranularityForZoomLevel(r.z)),t=this.layoutVertexArray;bc((e,i)=>{t.emplaceBack(e,i)},this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:n,canonical:r})}}let Sc,Pc;ds("FillBucket",Tc,{omit:["layers","patternFeatures"]});var Ic={get paint(){return Pc=Pc||new Hs({"fill-antialias":new $s(xe.paint_fill["fill-antialias"]),"fill-opacity":new Zs(xe.paint_fill["fill-opacity"]),"fill-color":new Zs(xe.paint_fill["fill-color"]),"fill-outline-color":new Zs(xe.paint_fill["fill-outline-color"]),"fill-translate":new $s(xe.paint_fill["fill-translate"]),"fill-translate-anchor":new $s(xe.paint_fill["fill-translate-anchor"]),"fill-pattern":new qs(xe.paint_fill["fill-pattern"])})},get layout(){return Sc=Sc||new Hs({"fill-sort-key":new Zs(xe.layout_fill["fill-sort-key"])})}};class Mc extends Ys{constructor(e,t){super(e,Ic,t)}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Tc(e)}queryRadius(){return rl(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:r}){return Wa(nl(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),t)}isTileClipped(){return!0}}const Ec=ro([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Cc=ro([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Ac}=Ec;class Dc{constructor(e,t,i,r,n){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=n,e.readFields(zc,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,r=[];let n,s=1,o=0,a=0,l=0;for(;e.pos<t;){if(o<=0){const t=e.readVarint();s=7&t,o=t>>3}if(o--,1===s||2===s)a+=e.readSVarint(),l+=e.readSVarint(),1===s&&(n&&r.push(n),n=[]),n&&n.push(new i(a,l));else{if(7!==s)throw new Error(`unknown command ${s}`);n&&n.push(n[0].clone())}}return n&&r.push(n),r}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,r=0,n=0,s=0,o=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos<t;){if(r<=0){const t=e.readVarint();i=7&t,r=t>>3}if(r--,1===i||2===i)n+=e.readSVarint(),s+=e.readSVarint(),n<o&&(o=n),n>a&&(a=n),s<l&&(l=s),s>c&&(c=s);else if(7!==i)throw new Error(`unknown command ${i}`)}return[o,l,a,c]}toGeoJSON(e,t,i){const r=this.extent*Math.pow(2,i),n=this.extent*e,s=this.extent*t,o=this.loadGeometry();function a(e){return[360*(e.x+n)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/r)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const i of o)e.push(i[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=o.map(l);c=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=kc(o),t=[];for(const i of e)t.push(i.map(l));c=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t}}}const h={type:"Feature",geometry:c,properties:this.properties};return null!=this.id&&(h.id=this.id),h}}function zc(e,t,i){1===e?t.id=i.readVarint():2===e?function(e,t){const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=t._keys[e.readVarint()],r=t._values[e.readVarint()];t.properties[i]=r}}(i,t):3===e?t.type=i.readVarint():4===e&&(t._geometry=i.pos)}function kc(e){const t=e.length;if(t<=1)return[e];const i=[];let r,n;for(let s=0;s<t;s++){const t=Rc(e[s]);0!==t&&(void 0===n&&(n=t<0),n===t<0?(r&&i.push(r),r=[e[s]]):r&&r.push(e[s]))}return r&&i.push(r),i}function Rc(e){let t=0;for(let i,r,n=0,s=e.length,o=s-1;n<s;o=n++)i=e[n],r=e[o],t+=(r.x-i.x)*(i.y+r.y);return t}Dc.types=["Unknown","Point","LineString","Polygon"];class Lc{constructor(e,t){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(Fc,this,t),this.length=this._features.length}feature(e){if(e<0||e>=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 Fc(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){let t=null;const i=e.readVarint()+e.pos;for(;e.pos<i;){const i=e.readVarint()>>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class Bc{constructor(e,t){this.layers=e.readFields(Oc,{},t)}}function Oc(e,t,i){if(3===e){const e=new Lc(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const Vc=Math.pow(2,13);function jc(e,t,i,r,n,s,o,a){e.emplaceBack(t,i,2*Math.floor(r*Vc)+o,n*Vc*2,s*Vc*2,Math.round(a))}class Nc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Zo,this.centroidVertexArray=new Uo,this.indexArray=new ta,this.programConfigurations=new La(e.layers,e.zoom),this.segments=new sa,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasDependencies=jl("fill-extrusion",this.layers,t);for(const{feature:r,id:n,index:s,sourceLayerIndex:o}of e){const e=this.layers[0]._featureFilter.needGeometry,a=Na(r,e);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),a,i))continue;const l={id:n,sourceLayerIndex:o,index:s,geometry:e?a.geometry:ja(r),properties:r.properties,type:r.type,patterns:{}};this.hasDependencies?this.features.push(Nl("fill-extrusion",this.layers,l,{zoom:this.zoom},t)):this.addFeature(l,l.geometry,s,i,{},t.subdivisionGranularity),t.featureIndex.insert(r,l.geometry,s,o,this.index,!0)}}addFeatures(e,t,i){for(const r of this.features){const{geometry:n}=r;this.addFeature(r,n,r.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ac),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Cc.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,r,n,s){for(const o of er(t,500)){const t={x:0,y:0,sampleCount:0},i=this.layoutVertexArray.length;this.processPolygon(t,r,e,o,s);const n=this.layoutVertexArray.length-i,a=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e<n;e++)this.centroidVertexArray.emplaceBack(a,l)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:n,canonical:r})}processPolygon(e,t,i,r,n){if(r.length<1)return;if($c(r[0]))return;for(const h of r)0!==h.length&&Uc(e,h);const s={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=n.fill.getGranularityForZoomLevel(t.z),a="Polygon"===Dc.types[i.type];for(const h of r){if(0===h.length)continue;if($c(h))continue;const e=xc(h,o,a);this._generateSideFaces(e,s)}if(!a)return;const l=yc(r,t,o,!1),c=this.layoutVertexArray;bc((e,t)=>{jc(c,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0;for(let r=1;r<e.length;r++){const n=e[r],s=e[r-1];if(Gc(n,s))continue;t.segment.vertexLength+4>sa.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const o=n.sub(s)._perp()._unit(),a=s.dist(n);i+a>32768&&(i=0),jc(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,0,i),jc(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,1,i),i+=a,jc(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,i),jc(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,i);const l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function Uc(e,t){for(let i=0;i<t.length;i++){const r=t[i];i===t.length-1&&t[0].x===r.x&&t[0].y===r.y||(e.x+=r.x,e.y+=r.y,e.sampleCount++)}}function Gc(e,t){return e.x===t.x&&(e.x<0||e.x>C)||e.y===t.y&&(e.y<0||e.y>C)}function $c(e){return e.every(e=>e.x<0)||e.every(e=>e.x>C)||e.every(e=>e.y<0)||e.every(e=>e.y>C)}let Zc;ds("FillExtrusionBucket",Nc,{omit:["layers","features"]});var qc={get paint(){return Zc=Zc||new Hs({"fill-extrusion-opacity":new $s(xe["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Zs(xe["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new $s(xe["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new $s(xe["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new qs(xe["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Zs(xe["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Zs(xe["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new $s(xe["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Wc extends Ys{constructor(e,t){super(e,qc,t)}createBucket(e){return new Nc(e)}queryRadius(){return rl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:n,transform:s,pixelsToTileUnits:o,pixelPosMatrix:a}){const l=nl(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-s.bearingInRadians,o),c=this.paint.get("fill-extrusion-height").evaluate(t,r),h=this.paint.get("fill-extrusion-base").evaluate(t,r),u=function(e,t){const r=[];for(const n of e){const e=[n.x,n.y,0,1];S(e,e,t),r.push(new i(e[0]/e[3],e[1]/e[3]))}return r}(l,a),d=function(e,t,r,n){const s=[],o=[],a=n[8]*t,l=n[9]*t,c=n[10]*t,h=n[11]*t,u=n[8]*r,d=n[9]*r,p=n[10]*r,f=n[11]*r;for(const m of e){const e=[],t=[];for(const r of m){const s=r.x,o=r.y,m=n[0]*s+n[4]*o+n[12],g=n[1]*s+n[5]*o+n[13],_=n[2]*s+n[6]*o+n[14],y=n[3]*s+n[7]*o+n[15],x=_+c,v=y+h,b=m+u,w=g+d,T=_+p,S=y+f,P=new i((m+a)/v,(g+l)/v);P.z=x/v,e.push(P);const I=new i(b/S,w/S);I.z=T/S,t.push(I)}s.push(e),o.push(t)}return[s,o]}(n,h,c,a);return function(e,t,i){let r=1/0;Wa(i,t)&&(r=Hc(i,t[0]));for(let n=0;n<t.length;n++){const s=t[n],o=e[n];for(let e=0;e<s.length-1;e++){const t=s[e],n=[t,s[e+1],o[e+1],o[e],t];Za(i,n)&&(r=Math.min(r,Hc(i,n)))}}return r!==1/0&&r}(d[0],d[1],u)}}function Xc(e,t){return e.x*t.x+e.y*t.y}function Hc(e,t){if(1===e.length){let i=0;const r=t[i++];let n;for(;!n||r.equals(n);)if(n=t[i++],!n)return 1/0;for(;i<t.length;i++){const s=t[i],o=e[0],a=n.sub(r),l=s.sub(r),c=o.sub(r),h=Xc(a,a),u=Xc(a,l),d=Xc(l,l),p=Xc(c,a),f=Xc(c,l),m=h*d-u*u,g=(d*p-u*f)/m,_=(h*f-u*p)/m,y=r.z*(1-g-_)+n.z*g+s.z*_;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}const Yc=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Kc{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=Yc[15&i];if(!n)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(e,2,1),[o]=new Uint32Array(e,4,1);return new Kc(o,s,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=Yc.indexOf(this.ArrayType),s=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-o%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+s+o+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Jc(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:o}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=o){for(let o=u;o<=h;o++){const a=s[2*o],c=s[2*o+1];a>=e&&a<=i&&c>=t&&c<=r&&l.push(n[o])}continue}const d=u+h>>1,p=s[2*d],f=s[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(u),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:s}=this,o=[0,r.length-1,0],a=[],l=i*i;for(;o.length;){const c=o.pop()||0,h=o.pop()||0,u=o.pop()||0;if(h-u<=s){for(let i=u;i<=h;i++)ih(n[2*i],n[2*i+1],e,t)<=l&&a.push(r[i]);continue}const d=u+h>>1,p=n[2*d],f=n[2*d+1];ih(p,f,e,t)<=l&&a.push(r[d]),(0===c?e-i<=p:t-i<=f)&&(o.push(u),o.push(d-1),o.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(o.push(d+1),o.push(h),o.push(1-c))}return a}}function Jc(e,t,i,r,n,s){if(n-r<=i)return;const o=r+n>>1;Qc(e,t,o,r,n,s),Jc(e,t,i,r,o-1,1-s),Jc(e,t,i,o+1,n,1-s)}function Qc(e,t,i,r,n,s){for(;n>r;){if(n-r>600){const o=n-r+1,a=i-r+1,l=Math.log(o),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(o-c)/o)*(a-o/2<0?-1:1);Qc(e,t,i,Math.max(r,Math.floor(i-a*c/o+h)),Math.min(n,Math.floor(i+(o-a)*c/o+h)),s)}const o=t[2*i+s];let a=r,l=n;for(eh(e,t,r,i),t[2*n+s]>o&&eh(e,t,r,n);a<l;){for(eh(e,t,a,l),a++,l--;t[2*a+s]<o;)a++;for(;t[2*l+s]>o;)l--}t[2*r+s]===o?eh(e,t,r,l):(l++,eh(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function eh(e,t,i,r){th(e,i,r),th(t,2*i,2*r),th(t,2*i+1,2*r+1)}function th(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function ih(e,t,i,r){const n=e-i,s=t-r;return n*n+s*s}function rh(e,t,i,r){let n=r;const s=t+(i-t>>1);let o,a=i-t;const l=e[t],c=e[t+1],h=e[i],u=e[i+1];for(let d=t+3;d<i;d+=3){const t=nh(e[d],e[d+1],l,c,h,u);if(t>n)o=d,n=t;else if(t===n){const e=Math.abs(d-s);e<a&&(o=d,a=e)}}n>r&&(o-t>3&&rh(e,t,o,r),e[o+2]=n,i-o>3&&rh(e,o,i,r))}function nh(e,t,i,r,n,s){let o=n-i,a=s-r;if(0!==o||0!==a){const l=((e-i)*o+(t-r)*a)/(o*o+a*a);l>1?(i=n,r=s):l>0&&(i+=o*l,r+=a*l)}return o=e-i,a=t-r,o*o+a*a}function sh(e,t,i,r){const n={type:t,geom:i},s={id:null==e?null:e,type:n.type,geometry:n.geom,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(n.type){case"Point":case"MultiPoint":case"LineString":oh(s,n.geom);break;case"Polygon":oh(s,n.geom[0]);break;case"MultiLineString":for(const e of n.geom)oh(s,e);break;case"MultiPolygon":for(const e of n.geom)oh(s,e[0])}return s}function oh(e,t){for(let i=0;i<t.length;i+=3)e.minX=Math.min(e.minX,t[i]),e.minY=Math.min(e.minY,t[i+1]),e.maxX=Math.max(e.maxX,t[i]),e.maxY=Math.max(e.maxY,t[i+1])}function ah(e,t){const i=[];switch(e.type){case"FeatureCollection":for(let r=0;r<e.features.length;r++)lh(i,e.features[r],t,r);break;case"Feature":lh(i,e,t);break;default:lh(i,{geometry:e,properties:void 0},t)}return i}function lh(e,t,i,r){if(!t.geometry)return;if("GeometryCollection"===t.geometry.type)return void function(e,t,i,r,n){for(const s of i.geometries)lh(e,{id:t.id,geometry:s,properties:t.properties},r,n)}(e,t,t.geometry,i,r);const n=t.geometry.coordinates;if(!n?.length)return;const s=function(e,t,i){return t.promoteId?e.properties?.[t.promoteId]:t.generateId?i||0:e.id}(t,i,r),o=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2);switch(t.geometry.type){case"Point":return void function(e,t,i,r){const n=[];n.push(uh(i.coordinates[0]),dh(i.coordinates[1]),0),e.push(sh(t,"Point",n,r))}(e,s,t.geometry,t.properties);case"MultiPoint":return void function(e,t,i,r){const n=[];for(const s of i.coordinates)n.push(uh(s[0]),dh(s[1]),0);e.push(sh(t,"MultiPoint",n,r))}(e,s,t.geometry,t.properties);case"LineString":return void function(e,t,i,r,n){const s=[];ch(i.coordinates,s,r,!1),e.push(sh(t,"LineString",s,n))}(e,s,t.geometry,o,t.properties);case"MultiLineString":return void function(e,t,i,r,n,s){if(n.lineMetrics)for(const o of i.coordinates){const i=[];ch(o,i,r,!1),e.push(sh(t,"LineString",i,s))}else{const n=[];hh(i.coordinates,n,r,!1),e.push(sh(t,"MultiLineString",n,s))}}(e,s,t.geometry,o,i,t.properties);case"Polygon":return void function(e,t,i,r,n){const s=[];hh(i.coordinates,s,r,!0),e.push(sh(t,"Polygon",s,n))}(e,s,t.geometry,o,t.properties);case"MultiPolygon":return void function(e,t,i,r,n){const s=[];for(const o of i.coordinates){const e=[];hh(o,e,r,!0),s.push(e)}e.push(sh(t,"MultiPolygon",s,n))}(e,s,t.geometry,o,t.properties);default:throw new Error("Input data is not a valid GeoJSON object.")}}function ch(e,t,i,r){let n,s,o=0;for(let l=0;l<e.length;l++){const i=uh(e[l][0]),a=dh(e[l][1]);t.push(i,a,0),l>0&&(o+=r?(n*a-i*s)/2:Math.sqrt(Math.pow(i-n,2)+Math.pow(a-s,2))),n=i,s=a}const a=t.length-3;t[2]=1,i>0&&rh(t,0,a,i),t[a+2]=1,t.size=Math.abs(o),t.start=0,t.end=t.size}function hh(e,t,i,r){for(let n=0;n<e.length;n++){const s=[];ch(e[n],s,i,r),t.push(s)}}function uh(e){return e/360+.5}function dh(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function ph(e){const t={type:"Feature",geometry:fh(e),properties:e.tags};return null!=e.id&&(t.id=e.id),t}function fh(e){const{type:t,geometry:i}=e;switch(t){case"Point":return{type:t,coordinates:gh(i[0],i[1])};case"MultiPoint":case"LineString":return{type:t,coordinates:mh(i)};case"MultiLineString":case"Polygon":return{type:t,coordinates:i.map(e=>mh(e))};case"MultiPolygon":return{type:t,coordinates:i.map(e=>e.map(e=>mh(e)))}}}function mh(e){const t=[];for(let i=0;i<e.length;i+=3)t.push(gh(e[i],e[i+1]));return t}function gh(e,t){return[_h(e),yh(t)]}function _h(e){return 360*(e-.5)}function yh(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var xh;function vh(e,t,i,r,n,s,o,a){if(r/=t,s>=(i/=t)&&o<r)return e;if(o<i||s>=r)return null;const l=[];for(const c of e){const e=n===xh.X?c.minX:c.minY,t=n===xh.X?c.maxX:c.maxY;if(e>=i&&t<r)l.push(c);else if(!(t<i||e>=r))switch(c.type){case"Point":case"MultiPoint":bh(c,l,i,r,n);continue;case"LineString":wh(c,l,i,r,n,a);continue;case"MultiLineString":Th(c,l,i,r,n);continue;case"Polygon":Sh(c,l,i,r,n);continue;case"MultiPolygon":Ph(c,l,i,r,n);continue}}return l.length?l:null}function bh(e,t,i,r,n){const s=[];(function(e,t,i,r,n){for(let s=0;s<e.length;s+=3){const o=e[s+n];o>=i&&o<=r&&Ch(t,e[s],e[s+1],e[s+2])}})(e.geometry,s,i,r,n),s.length&&t.push(sh(e.id,3===s.length?"Point":"MultiPoint",s,e.tags))}function wh(e,t,i,r,n,s){const o=[];if(Ih(e.geometry,o,i,r,n,!1,s.lineMetrics),o.length)if(s.lineMetrics)for(const a of o)t.push(sh(e.id,"LineString",a,e.tags));else t.push(o.length>1?sh(e.id,"MultiLineString",o,e.tags):sh(e.id,"LineString",o[0],e.tags))}function Th(e,t,i,r,n){const s=[];Eh(e.geometry,s,i,r,n,!1),s.length&&t.push(1!==s.length?sh(e.id,"MultiLineString",s,e.tags):sh(e.id,"LineString",s[0],e.tags))}function Sh(e,t,i,r,n){const s=[];Eh(e.geometry,s,i,r,n,!0),s.length&&t.push(sh(e.id,"Polygon",s,e.tags))}function Ph(e,t,i,r,n){const s=[];for(const o of e.geometry){const e=[];Eh(o,e,i,r,n,!0),e.length&&s.push(e)}s.length&&t.push(sh(e.id,"MultiPolygon",s,e.tags))}function Ih(e,t,i,r,n,s,o){let a=Mh(e);const l=n===xh.X?Ah:Dh;let c,h,u=e.start;for(let g=0;g<e.length-3;g+=3){const d=e[g],p=e[g+1],f=e[g+2],m=e[g+3],_=e[g+4],y=n===xh.X?d:p,x=n===xh.X?m:_;let v=!1;o&&(c=Math.sqrt(Math.pow(d-m,2)+Math.pow(p-_,2))),y<i?x>i&&(h=l(a,d,p,m,_,i),o&&(a.start=u+c*h)):y>r?x<r&&(h=l(a,d,p,m,_,r),o&&(a.start=u+c*h)):Ch(a,d,p,f),x<i&&y>=i&&(h=l(a,d,p,m,_,i),v=!0),x>r&&y<=r&&(h=l(a,d,p,m,_,r),v=!0),!s&&v&&(o&&(a.end=u+c*h),t.push(a),a=Mh(e)),o&&(u+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=n===xh.X?p:f;m>=i&&m<=r&&Ch(a,p,f,e[d+2]),d=a.length-3,s&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&Ch(a,a[0],a[1],a[2]),a.length&&t.push(a)}function Mh(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function Eh(e,t,i,r,n,s){for(const o of e)Ih(o,t,i,r,n,s,!1)}function Ch(e,t,i,r){e.push(t,i,r)}function Ah(e,t,i,r,n,s){const o=(s-t)/(r-t);return Ch(e,s,i+(n-i)*o,1),o}function Dh(e,t,i,r,n,s){const o=(s-i)/(n-i);return Ch(e,t+(r-t)*o,s,1),o}function zh(e,t){const i=t.buffer/t.extent;let r=e;const n=vh(e,1,-1-i,i,xh.X,-1,2,t),s=vh(e,1,1-i,2+i,xh.X,-1,2,t);return n||s?(r=vh(e,1,-i,1+i,xh.X,-1,2,t)||[],n&&(r=kh(n,1).concat(r)),s&&(r=r.concat(kh(s,-1))),r):r}function kh(e,t){const i=[];for(const r of e)switch(r.type){case"Point":case"MultiPoint":case"LineString":{const e=Rh(r.geometry,t);i.push(sh(r.id,r.type,e,r.tags));continue}case"MultiLineString":case"Polygon":{const e=[];for(const i of r.geometry)e.push(Rh(i,t));i.push(sh(r.id,r.type,e,r.tags));continue}case"MultiPolygon":{const e=[];for(const i of r.geometry){const r=[];for(const e of i)r.push(Rh(e,t));e.push(r)}i.push(sh(r.id,r.type,e,r.tags));continue}}return i}function Rh(e,t){const i=[];i.size=e.size,void 0!==e.start&&(i.start=e.start,i.end=e.end);for(let r=0;r<e.length;r+=3)i.push(e[r]+t,e[r+1],e[r+2]);return i}function Lh(e,t,i){const r=!!t.newGeometry,n=t.removeAllProperties||t.removeProperties?.length>0||t.addOrUpdateProperties?.length>0;if(r){const r=e[0];let s=ah({type:"FeatureCollection",features:[{type:"Feature",id:r.id,geometry:t.newGeometry,properties:n?Fh(r.tags,t):r.tags}]},i);return s=zh(s,i),s}if(n){const i=[];for(const r of e){const e={...r};e.tags=Fh(e.tags,t),i.push(e)}return i}return[]}function Fh(e,t){if(t.removeAllProperties)return{};const i={...e||{}};if(t.removeProperties)for(const r of t.removeProperties)delete i[r];if(t.addOrUpdateProperties)for(const{key:r,value:n}of t.addOrUpdateProperties)i[r]=n;return i}!function(e){e[e.X=0]="X",e[e.Y=1]="Y"}(xh||(xh={}));const Bh={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e};class Oh{constructor(e){this.options=Object.assign(Object.create(Bh),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[],this.points=[]}load(e){const t=[];for(const i of e){if(!i.geometry)continue;const[e,r]=i.geometry.coordinates,[n,s]=[uh(e),dh(r)];t.push({id:i.id,type:"Point",geometry:[n,s],tags:i.properties})}this.createIndex(t)}initialize(e){const t=[];for(const i of e)"Point"===i.type&&t.push(i);this.createIndex(t)}updateIndex(e,t,i){this.options=Object.assign(Object.create(Bh),i.clusterOptions),this.initialize(e)}createIndex(e){const{log:t,minZoom:i,maxZoom:r}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const s=[];for(let a=0;a<e.length;a++){const t=e[a];if(!t?.geometry)continue;let[i,r]=t.geometry;i=Math.fround(i),r=Math.fround(r),s.push(i,r,1/0,a,-1,1),this.options.reduce&&s.push(0)}let o=this.trees[r+1]=this.createTree(s);t&&console.timeEnd(n);for(let a=r;a>=i;a--){const e=Date.now();o=this.trees[a]=this.createTree(this.cluster(o,a)),t&&console.log("z%d: %d clusters in %dms",a,o.numItems,Date.now()-e)}t&&console.timeEnd("total time")}getClusters(e,t){return this.getClustersInternal(e,t).map(e=>ph(e))}getClustersInternal(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClustersInternal([i,r,180,s],t),o=this.getClustersInternal([-180,r,n,s],t);return e.concat(o)}const o=this.trees[this.limitZoom(t)],a=o.range(uh(i),dh(s),uh(n),dh(r)),l=o.flatData,c=[];for(const h of a){const e=this.stride*h;c.push(l[e+5]>1?Vh(l,e,this.clusterProps):this.points[l[e+3]])}return c}getChildren(e){const t=this.getOriginId(e),i=this.getOriginZoom(e),r=new Error("No cluster with the specified id: "+e),n=this.trees[i];if(!n)throw r;const s=n.flatData;if(t*this.stride>=s.length)throw r;const o=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(s[t*this.stride],s[t*this.stride+1],o),l=[];for(const c of a){const t=c*this.stride;s[t+4]===e&&l.push(s[t+5]>1?jh(s,t,this.clusterProps):ph(this.points[s[t+3]]))}if(0===l.length)throw r;return l}getLeaves(e,t,i){const r=[];return this.appendLeaves(r,e,t=t||10,i=i||0,0),r}getTile(e,t,i){const r=this.trees[this.limitZoom(e)];if(!r)return null;const n=Math.pow(2,e),{extent:s,radius:o}=this.options,a=o/s,l=(i-a)/n,c=(i+1+a)/n,h={transformed:!0,features:[],source:null,x:t,y:i,z:e};return this.addTileFeatures(r.range((t-a)/n,l,(t+1+a)/n,c),r.flatData,t,i,n,h),0===t&&this.addTileFeatures(r.range(1-a/n,l,1,c),r.flatData,n,i,n,h),t===n-1&&this.addTileFeatures(r.range(0,l,a/n,c),r.flatData,-1,i,n,h),h}getClusterExpansionZoom(e){return this.getOriginZoom(e)}appendLeaves(e,t,i,r,n){const s=this.getChildren(t);for(const o of s){const t=o.properties;if(t?.cluster?n+t.point_count<=r?n+=t.point_count:n=this.appendLeaves(e,t.cluster_id,i,r,n):n<r?n++:e.push(o),e.length===i)break}return n}createTree(e){const t=new Kc(e.length/this.stride|0,this.options.nodeSize,Float32Array);for(let i=0;i<e.length;i+=this.stride)t.add(e[i],e[i+1]);return t.finish(),t.flatData=e,t.data=null,t}addTileFeatures(e,t,i,r,n,s){for(const o of e){const e=o*this.stride,a=t[e+5]>1;let l,c,h;if(a)l=Nh(t,e,this.clusterProps),c=t[e],h=t[e+1];else{const i=this.points[t[e+3]];l=i.tags,[c,h]=i.geometry}const u={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(h*n-r))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(u.id=d),s.features.push(u)}}limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}cluster(e,t){const{radius:i,extent:r,reduce:n,minPoints:s}=this.options,o=i/(r*Math.pow(2,t)),a=e.flatData,l=[],c=this.stride;for(let h=0;h<a.length;h+=c){if(a[h+2]<=t)continue;a[h+2]=t;const i=a[h],r=a[h+1],u=e.within(a[h],a[h+1],o),d=a[h+5];let p=d;for(const e of u){const i=e*c;a[i+2]>t&&(p+=a[i+5])}if(p>d&&p>=s){let e,s=i*d,o=r*d,f=-1;const m=(h/c<<5)+(t+1)+this.points.length;for(const i of u){const r=i*c;if(a[r+2]<=t)continue;a[r+2]=t;const l=a[r+5];s+=a[r]*l,o+=a[r+1]*l,a[r+4]=m,n&&(e||(e=this.map(a,h,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this.map(a,r)))}a[h+4]=m,l.push(s/p,o/p,1/0,m,-1,p),n&&l.push(f)}else{for(let e=0;e<c;e++)l.push(a[h+e]);if(p>1)for(const e of u){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e<c;e++)l.push(a[i+e])}}}}return l}getOriginId(e){return e-this.points.length>>5}getOriginZoom(e){return(e-this.points.length)%32}map(e,t,i){if(e[t+5]>1){const r=this.clusterProps[e[t+6]];return i?Object.assign({},r):r}const r=this.points[e[t+3]].tags,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function Vh(e,t,i){return{id:e[t+3],type:"Point",tags:Nh(e,t,i),geometry:[e[t],e[t+1]]}}function jh(e,t,i){return{type:"Feature",id:e[t+3],properties:Nh(e,t,i),geometry:{type:"Point",coordinates:[_h(e[t]),yh(e[t+1])]}}}function Nh(e,t,i){const r=e[t+5],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,s=e[t+6],o=-1===s?{}:Object.assign({},i[s]);return Object.assign(o,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:n})}const Uh="geojsonvt_clip_start",Gh="geojsonvt_clip_end";function $h(e,t,i,r,n){const s=t===n.maxZoom?0:n.tolerance/((1<<t)*n.extent),o={transformed:!1,features:[],source:null,x:i,y:r,z:t,minX:2,minY:1,maxX:-1,maxY:0,numPoints:0,numSimplified:0,numFeatures:e.length};for(const a of e)Zh(o,a,s,n);return o}function Zh(e,t,i,r){switch(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),t.type){case"Point":case"MultiPoint":return void function(e,t){const i=[];for(let n=0;n<t.geometry.length;n+=3)i.push(t.geometry[n],t.geometry[n+1]),e.numPoints++,e.numSimplified++;if(!i.length)return;const r={type:1,tags:t.tags||null,geometry:i};null!==t.id&&(r.id=t.id),e.features.push(r)}(e,t);case"LineString":return void function(e,t,i,r){const n=[];if(qh(n,t.geometry,e,i,!1,!1),!n.length)return;let s=t.tags||null;if(r.lineMetrics){s={};for(const e in t.tags)s[e]=t.tags[e];s[Uh]=t.geometry.start/t.geometry.size,s[Gh]=t.geometry.end/t.geometry.size}const o={type:2,tags:s,geometry:n};null!==t.id&&(o.id=t.id),e.features.push(o)}(e,t,i,r);case"MultiLineString":case"Polygon":return void function(e,t,i){const r=[];for(let s=0;s<t.geometry.length;s++)qh(r,t.geometry[s],e,i,"Polygon"===t.type,0===s);if(!r.length)return;const n={type:"Polygon"===t.type?3:2,tags:t.tags||null,geometry:r};null!==t.id&&(n.id=t.id),e.features.push(n)}(e,t,i);case"MultiPolygon":return void function(e,t,i){const r=[];for(let s=0;s<t.geometry.length;s++){const n=t.geometry[s];for(let t=0;t<n.length;t++)qh(r,n[t],e,i,!0,0===t)}if(!r.length)return;const n={type:3,tags:t.tags||null,geometry:r};null!==t.id&&(n.id=t.id),e.features.push(n)}(e,t,i)}}function qh(e,t,i,r,n,s){const o=r*r;if(r>0&&t.size<(n?o:r))return void(i.numPoints+=t.length/3);const a=[];for(let l=0;l<t.length;l+=3)(0===r||t[l+2]>o)&&(i.numSimplified++,a.push(t[l],t[l+1])),i.numPoints++;n&&function(e,t){let i=0;for(let r=0,n=e.length,s=n-2;r<n;s=r,r+=2)i+=(e[r]-e[s])*(e[r+1]+e[s+1]);if(i>0===t)for(let r=0,n=e.length;r<n/2;r+=2){const t=e[r],i=e[r+1];e[r]=e[n-2-r],e[r+1]=e[n-1-r],e[n-2-r]=t,e[n-1-r]=i}}(a,s),e.push(a)}function Wh(e,t){if(e.transformed)return e;const i=1<<e.z,r=e.x,n=e.y;for(const s of e.features)1===s.type?Xh(s,t,i,r,n):Hh(s,t,i,r,n);return e.transformed=!0,e}function Xh(e,t,i,r,n){const s=e,o=e.geometry,a=[];for(let l=0;l<o.length;l+=2)a.push(Yh(o[l],o[l+1],t,i,r,n));return s.geometry=a,s}function Hh(e,t,i,r,n){const s=e,o=e.geometry,a=[];for(const l of o){const e=[];for(let s=0;s<l.length;s+=2)e.push(Yh(l[s],l[s+1],t,i,r,n));a.push(e)}return s.geometry=a,s}function Yh(e,t,i,r,n,s){return[Math.round(i*(e*r-n)),Math.round(i*(t*r-s))]}class Kh{constructor(e){this.options=e,this.stats={},this.total=0,this.tiles={},this.tileCoords=[],this.stats={},this.total=0}initialize(e){this.splitTile(e,0,0,0),this.options.debug&&(e.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}updateIndex(e,t,i){i.debug>1&&(console.log("invalidating tiles"),console.time("invalidating")),this.invalidateTiles(t),i.debug>1&&console.timeEnd("invalidating");const[r,n,s]=[0,0,0],o=$h(e,r,n,s,i);o.source=e;const a=Jh(r,n,s);if(this.tiles[a]=o,this.tileCoords.push({z:r,x:n,y:s,id:a}),i.debug){const e=`z${r}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}}getClusterExpansionZoom(e){return null}getChildren(e){return null}getLeaves(e,t,i){return null}getTile(e,t,i){const{extent:r,debug:n}=this.options,s=1<<e,o=Jh(e,t=t+s&s-1,i);if(this.tiles[o])return Wh(this.tiles[o],r);n>1&&console.log("drilling down to z%d-%d-%d",e,t,i);let a,l=e,c=t,h=i;for(;!a&&l>0;)l--,c>>=1,h>>=1,a=this.tiles[Jh(l,c,h)];return a?.source?(n>1&&(console.log("found parent tile z%d-%d-%d",l,c,h),console.time("drilling down")),this.splitTile(a.source,l,c,h,e,t,i),n>1&&console.timeEnd("drilling down"),this.tiles[o]?Wh(this.tiles[o],r):null):null}splitTile(e,t,i,r,n,s,o){const a=[e,t,i,r],l=this.options,c=l.debug;for(;a.length;){r=a.pop(),i=a.pop(),t=a.pop(),e=a.pop();const h=1<<t,u=Jh(t,i,r);let d=this.tiles[u];if(!d&&(c>1&&console.time("creation"),d=this.tiles[u]=$h(e,t,i,r,l),this.tileCoords.push({z:t,x:i,y:r,id:u}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,r,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==n){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===n)continue;if(null!=n){const e=n-t;if(i!==s>>e||r!==o>>e)continue}}if(d.source=null,!e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,y=null,x=null,v=null;const b=vh(e,h,i-p,i+m,xh.X,d.minX,d.maxX,l),w=vh(e,h,i+f,i+g,xh.X,d.minX,d.maxX,l);b&&(_=vh(b,h,r-p,r+m,xh.Y,d.minY,d.maxY,l),y=vh(b,h,r+f,r+g,xh.Y,d.minY,d.maxY,l)),w&&(x=vh(w,h,r-p,r+m,xh.Y,d.minY,d.maxY,l),v=vh(w,h,r+f,r+g,xh.Y,d.minY,d.maxY,l)),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*r),a.push(y||[],t+1,2*i,2*r+1),a.push(x||[],t+1,2*i+1,2*r),a.push(v||[],t+1,2*i+1,2*r+1)}}invalidateTiles(e){if(!e.length)return;const t=this.options,{debug:i}=t;let r=1/0,n=-1/0,s=1/0,o=-1/0;for(const c of e)r=Math.min(r,c.minX),n=Math.max(n,c.maxX),s=Math.min(s,c.minY),o=Math.max(o,c.maxY);const a=t.buffer/t.extent,l=new Set;for(const c in this.tiles){const t=this.tiles[c],h=1<<t.z,u=(t.x-a)/h,d=(t.x+1+a)/h,p=(t.y-a)/h,f=(t.y+1+a)/h;if(n<u||r>=d||o<p||s>=f)continue;let m=!1;for(const i of e)if(i.maxX>=u&&i.minX<d&&i.maxY>=p&&i.minY<f){m=!0;break}if(m){if(i){i>1&&console.log("invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t.z,t.x,t.y,t.numFeatures,t.numPoints,t.numSimplified);const e=`z${t.z}`;this.stats[e]=(this.stats[e]||0)-1,this.total--}delete this.tiles[c],l.add(c)}}l.size&&(this.tileCoords=this.tileCoords.filter(e=>!l.has(e.id)))}}function Jh(e,t,i){return 32*((1<<e)*i+t)+e}const Qh={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,cluster:!1,clusterOptions:Bh,debug:0},eu=ro([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:tu}=eu,iu=ro([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:ru}=iu,nu=Math.cos(Math.PI/180*37.5),su=Math.pow(2,14)/.5;class ou{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new qo,this.layoutVertexArray2=new Wo,this.indexArray=new ta,this.programConfigurations=new La(e.layers,e.zoom),this.segments=new sa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=jl("line",this.layers,t)||this.hasLineDasharray(this.layers);const r=this.layers[0].layout.get("line-sort-key"),n=!r.isConstant(),s=[];for(const{feature:o,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,t=Na(o,e);if(!this.layers[0]._featureFilter.filter(new ks(this.zoom),t,i))continue;const h=n?r.evaluate(t,{},i):void 0,u={id:a,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:e?t.geometry:ja(o),patterns:{},dashes:{},sortKey:h};s.push(u)}n&&s.sort((e,t)=>e.sortKey-t.sortKey);for(const o of s){const{geometry:r,index:n,sourceLayerIndex:s}=o;this.hasDependencies?(jl("line",this.layers,t)?Nl("line",this.layers,o,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,o,this.zoom,t),this.patternFeatures.push(o)):this.addFeature(o,r,n,i,{},{},t.subdivisionGranularity),t.featureIndex.insert(e[n].feature,r,n,s,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures(e,t,i,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,r,e.subdivisionGranularity)}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,ru)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,tu),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,Uh)&&Object.prototype.hasOwnProperty.call(e.properties,Gh))return{start:+e.properties[Uh],end:+e.properties[Gh]}}addFeature(e,t,i,r,n,s,o){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap"),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const d of t)this.addLine(d,e,l,c,h,u,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:n,dashPositions:s,canonical:r})}addLine(e,t,i,r,n,s,o,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=xc(e,o?a.line.getGranularityForZoomLevel(o.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const l="Polygon"===Dc.types[t.type];let c=e.length;for(;c>=2&&e[c-1].equals(e[c-2]);)c--;let h=0;for(;h<c-1&&e[h].equals(e[h+1]);)h++;if(c<(l?3:2))return;"bevel"===i&&(n=1.05);const u=this.overscaling<=16?122880/(512*this.overscaling):0,d=this.segments.prepareSegment(10*c,this.layoutVertexArray,this.indexArray);let p,f,m,g,_;this.e1=this.e2=-1,l&&(p=e[c-2],_=e[h].sub(p)._unit()._perp());for(let y=h;y<c;y++){if(m=y===c-1?l?e[h+1]:void 0:e[y+1],m&&e[y].equals(m))continue;_&&(g=_),p&&(f=p),p=e[y],_=m?m.sub(p)._unit()._perp():g,g=g||_;let t=g.add(_);0===t.x&&0===t.y||t._unit();const o=g.x*_.x+g.y*_.y,a=t.x*_.x+t.y*_.y,x=0!==a?1/a:1/0,v=2*Math.sqrt(2-2*a),b=a<nu&&f&&m,w=g.x*_.y-g.y*_.x>0;if(b&&y>h){const e=p.dist(f);if(e>2*u){const t=p.sub(p.sub(f)._mult(u/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,g,0,0,d),f=t}}const T=f&&m;let S=T?i:l?"butt":r;if(T&&"round"===S&&(x<s?S="miter":x<=2&&(S="fakeround")),"miter"===S&&x>n&&(S="bevel"),"bevel"===S&&(x>2&&(S="flipbevel"),x<n&&(S="miter")),f&&this.updateDistance(f,p),"miter"===S)t._mult(x),this.addCurrentVertex(p,t,0,0,d);else if("flipbevel"===S){if(x>100)t=_.mult(-1);else{const e=x*g.add(_).mag()/g.sub(_).mag();t._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(p,t,0,0,d),this.addCurrentVertex(p,t.mult(-1),0,0,d)}else if("bevel"===S||"fakeround"===S){const e=-Math.sqrt(x*x-1),t=w?e:0,i=w?0:e;if(f&&this.addCurrentVertex(p,g,t,i,d),"fakeround"===S){const e=Math.round(180*v/Math.PI/20);for(let t=1;t<e;t++){let i=t/e;if(.5!==i){const e=i-.5;i+=i*e*(i-1)*((1.0904+o*(o*(3.55645-1.43519*o)-3.2452))*e*e+(.848013+o*(.215638*o-1.06021)))}const r=_.sub(g)._mult(i)._add(g)._unit()._mult(w?-1:1);this.addHalfVertex(p,r.x,r.y,!1,w,0,d)}}m&&this.addCurrentVertex(p,_,-t,-i,d)}else if("butt"===S)this.addCurrentVertex(p,t,0,0,d);else if("square"===S){const e=f?1:-1;this.addCurrentVertex(p,t,e,e,d)}else"round"===S&&(f&&(this.addCurrentVertex(p,g,0,0,d),this.addCurrentVertex(p,g,1,1,d,!0)),m&&(this.addCurrentVertex(p,_,-1,-1,d,!0),this.addCurrentVertex(p,_,0,0,d)));if(b&&y<c-1){const e=p.dist(m);if(e>2*u){const t=p.add(m.sub(p)._mult(u/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,_,0,0,d),p=t}}}}addCurrentVertex(e,t,i,r,n,s=!1){const o=t.y*r-t.x,a=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,s,!1,i,n),this.addHalfVertex(e,o,a,s,!0,-r,n),this.distance>su/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,r,n,s))}addHalfVertex({x:e,y:t},i,r,n,s,o,a){const l=.5*(this.lineClips?this.scaledDistance*(su-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(s?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===o?0:o<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),s?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(const t of e){const e=t.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,r){for(const n of e){const e=n.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const s="round"===n.layout.get("line-cap"),o={dasharray:e.value.evaluate({zoom:i-1},t,{}),round:s},a={dasharray:e.value.evaluate({zoom:i},t,{}),round:s},l={dasharray:e.value.evaluate({zoom:i+1},t,{}),round:s},c=`${o.dasharray.join(",")},${o.round}`,h=`${a.dasharray.join(",")},${a.round}`,u=`${l.dasharray.join(",")},${l.round}`;r.dashDependencies[c]=o,r.dashDependencies[h]=a,r.dashDependencies[u]=l,t.dashes[n.id]={min:c,mid:h,max:u}}}}let au,lu;ds("LineBucket",ou,{omit:["layers","patternFeatures"]});var cu={get paint(){return lu=lu||new Hs({"line-opacity":new Zs(xe.paint_line["line-opacity"]),"line-color":new Zs(xe.paint_line["line-color"]),"line-translate":new $s(xe.paint_line["line-translate"]),"line-translate-anchor":new $s(xe.paint_line["line-translate-anchor"]),"line-width":new Zs(xe.paint_line["line-width"]),"line-gap-width":new Zs(xe.paint_line["line-gap-width"]),"line-offset":new Zs(xe.paint_line["line-offset"]),"line-blur":new Zs(xe.paint_line["line-blur"]),"line-dasharray":new qs(xe.paint_line["line-dasharray"]),"line-pattern":new qs(xe.paint_line["line-pattern"]),"line-gradient":new Xs(xe.paint_line["line-gradient"])})},get layout(){return au=au||new Hs({"line-cap":new $s(xe.layout_line["line-cap"]),"line-join":new Zs(xe.layout_line["line-join"]),"line-miter-limit":new $s(xe.layout_line["line-miter-limit"]),"line-round-limit":new $s(xe.layout_line["line-round-limit"]),"line-sort-key":new Zs(xe.layout_line["line-sort-key"])})}};class hu extends Zs{possiblyEvaluate(e,t){return t=new ks(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=O({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}let uu;class du extends Ys{constructor(e,t){super(e,cu,t),this.gradientVersion=0,uu||(uu=new hu(cu.paint.properties["line-width"].specification),uu.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof ai,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=uu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new ou(e)}queryRadius(e){const t=e,i=pu(il("line-width",this,t),il("line-gap-width",this,t)),r=il("line-offset",this,t);return i/2+Math.abs(r)+rl(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:n,transform:s,pixelsToTileUnits:o}){const a=nl(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-s.bearingInRadians,o),l=o/2*pu(this.paint.get("line-width").evaluate(t,r),this.paint.get("line-gap-width").evaluate(t,r)),c=this.paint.get("line-offset").evaluate(t,r);return c&&(n=function(e,t){const r=[];for(let n=0;n<e.length;n++){const s=sl(e[n]),o=[];for(let e=0;e<s.length;e++){const r=s[e],n=s[e-1],a=s[e+1],l=0===e?new i(0,0):r.sub(n)._unit()._perp(),c=e===s.length-1?new i(0,0):a.sub(r)._unit()._perp(),h=l._add(c)._unit(),u=h.x*c.x+h.y*c.y;0!==u&&h._mult(1/u),o.push(h._mult(t)._add(r))}r.push(o)}return r}(n,c*o)),function(e,t,i){for(let r=0;r<t.length;r++){const n=t[r];if(e.length>=3)for(let t=0;t<n.length;t++)if(el(e,n[t]))return!0;if(Xa(e,n,i))return!0}return!1}(a,n,l)}isTileClipped(){return!0}}function pu(e,t){return t>0?t+2*e:e}const fu=ro([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),mu=ro([{name:"a_projected_pos",components:3,type:"Float32"}],4);ro([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const gu=ro([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);ro([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const _u=ro([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),yu=ro([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function xu(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),zs.applyArabicShaping&&(e=zs.applyArabicShaping(e)),e}(e.text,t,i)}),e}ro([{name:"triangle",components:3,type:"Uint16"}]),ro([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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"}]),ro([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),ro([{type:"Float32",name:"offsetX"}]),ro([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),ro([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var vu=24;const bu={"!":"\ufe15","#":"\uff03",$:"\uff04","%":"\uff05","&":"\uff06","(":"\ufe35",")":"\ufe36","*":"\uff0a","+":"\uff0b",",":"\ufe10","-":"\ufe32",".":"\u30fb","/":"\uff0f",":":"\ufe13",";":"\ufe14","<":"\ufe3f","=":"\uff1d",">":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u22ef":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42"},wu={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Tu={40:!0};function Su(e,t,i,r,n,s){if("fontStack"in t){const r=i[t.fontStack],s=r&&r[e];return s?s.metrics.advance*t.scale+n:0}{const e=r[t.imageName];return e?e.displaySize[0]*t.scale*vu/s+n:0}}function Pu(e,t,i,r){const n=Math.pow(e-t,2);return r?e<t?n/2:2*n:n+Math.abs(i)*i}function Iu(e,t,i){let r=0;return 10===e&&(r-=1e4),i&&(r+=150),40!==e&&65288!==e||(r+=50),41!==t&&65289!==t||(r+=50),r}function Mu(e,t,i,r,n,s){let o=null,a=Pu(t,i,n,s);for(const l of r){const e=Pu(t-l.x,i,n,s)+l.badness;e<=a&&(o=l,a=e)}return{index:e,x:t,priorBreak:o,badness:a}}function Eu(e){return e?Eu(e.priorBreak).concat(e.index):[]}class Cu{constructor(e="",t=[],i=[]){this.text=e,this.sections=t,this.sectionIndex=i,this.imageSectionID=null}static fromFeature(e,t){const i=new Cu;for(let r=0;r<e.sections.length;r++){const n=e.sections[r];n.image?i.addImageSection(n):i.addTextSection(n,t)}return i}length(){return[...this.text].length}getSection(e){return this.sections[this.sectionIndex[e]]}getSectionIndex(e){return this.sectionIndex[e]}verticalizePunctuation(){this.text=function(e){let t="",i={premature:!0,value:void 0};const r=e[Symbol.iterator]();let n=r.next();const s=e[Symbol.iterator]();s.next();let o=s.next();for(;!n.done;)t+=!o.done&&Ms(o.value.codePointAt(0))&&!bu[o.value]||!i.premature&&Ms(i.value.codePointAt(0))&&!bu[i.value]||!bu[n.value]?n.value:bu[n.value],i={value:n.value,premature:!1},n=r.next(),o=s.next();return t}(this.text)}hasZeroWidthSpaces(){return this.text.includes("\u200b")}trim(){const e=this.text.match(/^\s*/),t=e?e[0].length:0,i=this.text.match(/\S\s*$/),r=i?i[0].length-1:0;this.text=this.text.substring(t,this.text.length-r),this.sectionIndex=this.sectionIndex.slice(t,this.sectionIndex.length-r)}substring(e,t){const i=[...this.text].slice(e,t).join(""),r=this.sectionIndex.slice(e,t);return new Cu(i,this.sections,r)}toCodeUnitIndex(e){return[...this.text].slice(0,e).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}getMaxImageSize(e){let t=0,i=0;for(let r=0;r<this.length();r++){const n=this.getSection(r);if("imageName"in n){const r=e[n.imageName];if(!r)continue;const s=r.displaySize;t=Math.max(t,s[0]),i=Math.max(i,s[1])}}return{maxImageWidth:t,maxImageHeight:i}}addTextSection(e,t){this.text+=e.text,this.sections.push({scale:e.scale||1,verticalAlign:e.verticalAlign||"bottom",fontStack:e.fontStack||t});const i=this.sections.length-1;this.sectionIndex.push(...[...e.text].map(()=>i))}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void $("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:t}),this.sectionIndex.push(this.sections.length-1)):$("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,i,r,n){const s=[],o=this.determineAverageLineWidth(e,t,i,r,n),a=this.hasZeroWidthSpaces();let l=0,c=0;const h=this.text[Symbol.iterator]();let u=h.next();const d=this.text[Symbol.iterator]();d.next();let p=d.next();const f=this.text[Symbol.iterator]();f.next(),f.next();let m=f.next();for(;!u.done;){const t=this.getSection(c),g=u.value.codePointAt(0);if(bs(g)||(l+=Su(g,t,i,r,e,n)),!p.done){const e=xs(g),i=p.value.codePointAt(0);(wu[g]||e||"imageName"in t||!m.done&&Tu[i])&&s.push(Mu(c+1,l,o,s,Iu(g,i,e&&a),!1))}c++,u=h.next(),p=d.next(),m=f.next()}return Eu(Mu(this.length(),l,o,s,0,!0))}determineAverageLineWidth(e,t,i,r,n){let s=0,o=0;for(const a of this.text){const t=this.getSection(o);s+=Su(a.codePointAt(0),t,i,r,e,n),o++}return s/Math.max(1,Math.ceil(s/t))}}const Au=4294967296,Du=1/Au,zu="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class ku{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos<i;){const i=this.readVarint(),r=i>>3,n=this.pos;this.type=7&i,e(r,t,this),this.pos===n&&this.skip(i)}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)*Au;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Au;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;let i,r;return r=t[this.pos++],i=127&r,r<128?i:(r=t[this.pos++],i|=(127&r)<<7,r<128?i:(r=t[this.pos++],i|=(127&r)<<14,r<128?i:(r=t[this.pos++],i|=(127&r)<<21,r<128?i:(r=t[this.pos],i|=(15&r)<<28,function(e,t,i){const r=i.buf;let n,s;if(s=r[i.pos++],n=(112&s)>>4,s<128)return Ru(e,n,t);if(s=r[i.pos++],n|=(127&s)<<3,s<128)return Ru(e,n,t);if(s=r[i.pos++],n|=(127&s)<<10,s<128)return Ru(e,n,t);if(s=r[i.pos++],n|=(127&s)<<17,s<128)return Ru(e,n,t);if(s=r[i.pos++],n|=(127&s)<<24,s<128)return Ru(e,n,t);if(s=r[i.pos++],n|=(1&s)<<31,s<128)return Ru(e,n,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}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&&zu?zu.decode(this.buf.subarray(t,e)):function(e,t,i){let r="",n=t;for(;n<i;){const t=e[n];let s,o,a,l=null,c=t>239?4:t>223?3:t>191?2:1;if(n+c>i)break;1===c?t<128&&(l=t):2===c?(s=e[n+1],128==(192&s)&&(l=(31&t)<<6|63&s,l<=127&&(l=null))):3===c?(s=e[n+1],o=e[n+2],128==(192&s)&&128==(192&o)&&(l=(15&t)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(s=e[n+1],o=e[n+2],a=e[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&t)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=c}return r}(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 i=this.readPackedEnd();for(;this.pos<i;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}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}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){const e=new Uint8Array(t);e.set(this.buf),this.buf=e,this.dataView=new DataView(e.buffer),this.length=t}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Du),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,-1&e,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*Du),!0),this.pos+=8}writeVarint(e){(e=+e||0)>268435455||e<0?function(e,t){let i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(i=~(-e%4294967296),r=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){const i=(7&e)<<4;t.buf[t.pos++]|=i|((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)))))}(r,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,i){for(let r,n,s=0;s<t.length;s++){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!n){r>56319||s+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&Lu(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}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);for(let i=0;i<t;i++)this.buf[this.pos++]=e[i]}writeRawMessage(e,t){this.pos++;const i=this.pos;e(t,this);const r=this.pos-i;r>=128&&Lu(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Fu,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Bu,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,ju,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Ou,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Vu,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Nu,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Uu,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Gu,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,$u,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)}}function Ru(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Lu(e,t,i){const r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(let n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n]}function Fu(e,t){for(let i=0;i<e.length;i++)t.writeVarint(e[i])}function Bu(e,t){for(let i=0;i<e.length;i++)t.writeSVarint(e[i])}function Ou(e,t){for(let i=0;i<e.length;i++)t.writeFloat(e[i])}function Vu(e,t){for(let i=0;i<e.length;i++)t.writeDouble(e[i])}function ju(e,t){for(let i=0;i<e.length;i++)t.writeBoolean(e[i])}function Nu(e,t){for(let i=0;i<e.length;i++)t.writeFixed32(e[i])}function Uu(e,t){for(let i=0;i<e.length;i++)t.writeSFixed32(e[i])}function Gu(e,t){for(let i=0;i<e.length;i++)t.writeFixed64(e[i])}function $u(e,t){for(let i=0;i<e.length;i++)t.writeSFixed64(e[i])}function Zu(e,t,i){1===e&&i.readMessage(qu,t)}function qu(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:s,left:o,top:a,advance:l}=i.readMessage(Wu,{});t.push({id:e,bitmap:new wl({width:n+6,height:s+6},r),metrics:{width:n,height:s,left:o,top:a,advance:l}})}}function Wu(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}function Xu(e){let t=0,i=0;for(const o of e)t+=o.w*o.h,i=Math.max(i,o.w);e.sort((e,t)=>t.h-e.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,s=0;for(const o of e)for(let e=r.length-1;e>=0;e--){const t=r[e];if(!(o.w>t.w||o.h>t.h)){if(o.x=t.x,o.y=t.y,s=Math.max(s,o.y+o.h),n=Math.max(n,o.x+o.w),o.w===t.w&&o.h===t.h){const t=r.pop();t&&e<r.length&&(r[e]=t)}else o.h===t.h?(t.x+=o.w,t.w-=o.w):o.w===t.w?(t.y+=o.h,t.h-=o.h):(r.push({x:t.x+o.w,y:t.y,w:t.w-o.w,h:o.h}),t.y+=o.h,t.h-=o.h);break}}return{w:n,h:s,fill:t/(n*s)||0}}class Hu{constructor(e,{pixelRatio:t,version:i,stretchX:r,stretchY:n,content:s,textFitWidth:o,textFitHeight:a}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=n,this.content=s,this.version=i,this.textFitWidth=o,this.textFitHeight=a}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Yu{constructor(e,t){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(e,i,n),this.addImages(t,r,n);const{w:s,h:o}=Xu(n),a=new Tl({width:s||1,height:o||1});for(const l in e){const t=e[l],r=i[l].paddedRect;Tl.copy(t.data,a,{x:0,y:0},{x:r.x+1,y:r.y+1},t.data)}for(const l in t){const e=t[l],i=r[l].paddedRect,n=i.x+1,s=i.y+1,o=e.data.width,c=e.data.height;Tl.copy(e.data,a,{x:0,y:0},{x:n,y:s},e.data),Tl.copy(e.data,a,{x:0,y:c-1},{x:n,y:s-1},{width:o,height:1}),Tl.copy(e.data,a,{x:0,y:0},{x:n,y:s+c},{width:o,height:1}),Tl.copy(e.data,a,{x:o-1,y:0},{x:n-1,y:s},{width:1,height:c}),Tl.copy(e.data,a,{x:0,y:0},{x:n+o,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(const r in e){const n=e[r],s={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(s),t[r]=new Hu(s,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in e.updatedImages)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t),this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl;i.update(t.data,void 0,{x:r,y:n})}}var Ku;function Ju(t,i,r,n,s,o,a,l,c,h,u,d,p,f,m){const g=Cu.fromFeature(t,s);let _;d===e.aw.vertical&&g.verticalizePunctuation();let y=g.determineLineBreaks(h,o,i,n,f);const{processBidirectionalText:x,processStyledBidirectionalText:v}=zs;if(x&&1===g.sections.length){_=[],y=y.map(e=>g.toCodeUnitIndex(e));const e=x(g.toString(),y);for(const t of e){const e=[...t].map(()=>0);_.push(new Cu(t,g.sections,e))}}else if(v){_=[],y=y.map(e=>g.toCodeUnitIndex(e));let e=0;const t=[];for(const r of g.text)t.push(...Array(r.length).fill(g.sectionIndex[e])),e++;const i=v(g.text,t,y);for(const r of i){const e=[];let t="";for(const i of r[0])e.push(r[1][t.length]),t+=i;_.push(new Cu(r[0],g.sections,e))}}else _=function(e,t){const i=[];let r=0;for(const n of t)i.push(e.substring(r,n)),r=n;return r<e.length()&&i.push(e.substring(r,e.length())),i}(g,y);const b=[],w={positionedLines:b,text:g.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:d,iconsInText:!1,verticalizable:!1};return function(e,t,i,r,n,s,o,a,l,c,h,u){let d=0,p=0,f=0,m=0;const g="right"===a?1:"left"===a?0:.5,_=vu/u;let y=0;for(const b of n){b.trim();const n=b.getMaxScale(),o={positionedGlyphs:[],lineOffset:0};e.positionedLines[y]=o;const a=o.positionedGlyphs;let u=0;if(!b.length()){p+=s,++y;continue}const x=ed(r,b,_);let v=0;for(const s of b.text){const o=b.getSection(v),f=s.codePointAt(0),m=id(l,h,f),g={glyph:f,imageName:null,x:d,y:p+-17,vertical:m,scale:1,fontStack:"",sectionIndex:b.getSectionIndex(v),metrics:null,rect:null};let y;if("fontStack"in o){if(y=rd(o,f,m,x,t,i),!y)continue;g.fontStack=o.fontStack}else{if(e.iconsInText=!0,o.scale*=_,y=nd(o,m,n,x,r),!y)continue;u=Math.max(u,y.imageOffset),g.imageName=o.imageName}const{rect:w,metrics:T,baselineOffset:S}=y;g.y+=S,g.scale=o.scale,g.metrics=T,g.rect=w,a.push(g),m?(e.verticalizable=!0,d+=("imageName"in o?T.advance:vu)*o.scale+c):d+=T.advance*o.scale+c,v++}0!==a.length&&(f=Math.max(d-c,f),sd(a,0,a.length-1,g)),d=0,o.lineOffset=Math.max(u,(n-1)*vu);const w=s*n+u;p+=w,m=Math.max(w,m),++y}const{horizontalAlign:x,verticalAlign:v}=Qu(o);(function(e,t,i,r,n,s,o,a,l){const c=(t-i)*n;let h=0;h=s!==o?-a*r- -17:-r*l*o+.5*o;for(const u of e)for(const e of u.positionedGlyphs)e.x+=c,e.y+=h})(e.positionedLines,g,x,v,f,m,s,p,n.length),e.top+=-v*p,e.bottom=e.top+p,e.left+=-x*f,e.right=e.left+f}(w,i,r,n,_,a,l,c,d,h,p,m),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return!1;return!0}(b)&&w}function Qu(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function ed(e,t,i){const r=t.getMaxScale()*vu,{maxImageWidth:n,maxImageHeight:s}=t.getMaxImageSize(e),o=Math.max(r,s*i);return{verticalLineContentWidth:Math.max(r,n*i),horizontalLineContentHeight:o}}function td(e){switch(e){case"top":return 0;case"center":return.5;default:return 1}}function id(t,i,r){return!(t===e.aw.horizontal||!i&&!vs(r)||i&&(bs(r)||(n=r,/\p{sc=Arab}/u.test(String.fromCodePoint(n)))));var n}function rd(e,t,i,r,n,s){const o=s[e.fontStack],a=function(e,t,i,r){if(e&&e.rect)return e;const n=t[i.fontStack],s=n&&n[r];return s?{rect:null,metrics:s.metrics}:null}(o&&o[t],n,e,t);if(null===a)return null;let l;if(i)l=r.verticalLineContentWidth-e.scale*vu;else{const t=td(e.verticalAlign);l=(r.horizontalLineContentHeight-e.scale*vu)*t}return{rect:a.rect,metrics:a.metrics,baselineOffset:l}}function nd(e,t,i,r,n){const s=n[e.imageName];if(!s)return null;const o=s.paddedRect,a=s.displaySize,l={width:a[0],height:a[1],left:1,top:-3,advance:t?a[1]:a[0]};let c;if(t)c=r.verticalLineContentWidth-a[1]*e.scale;else{const t=td(e.verticalAlign);c=(r.horizontalLineContentHeight-a[1]*e.scale)*t}return{rect:o,metrics:l,baselineOffset:c,imageOffset:(t?a[0]:a[1])*e.scale-vu*i}}function sd(e,t,i,r){if(0===r)return;const n=e[i],s=(e[i].x+n.metrics.advance*n.scale)*r;for(let o=t;o<=i;o++)e[o].x-=s}function od(e,t,i){const{horizontalAlign:r,verticalAlign:n}=Qu(i),s=t[0]-e.displaySize[0]*r,o=t[1]-e.displaySize[1]*n;return{image:e,top:o,bottom:o+e.displaySize[1],left:s,right:s+e.displaySize[0]}}function ad(e){var t,i;let r=e.left,n=e.top,s=e.right-r,o=e.bottom-n;const a=null!==(t=e.image.textFitWidth)&&void 0!==t?t:"stretchOrShrink",l=null!==(i=e.image.textFitHeight)&&void 0!==i?i:"stretchOrShrink",c=(e.image.content[2]-e.image.content[0])/(e.image.content[3]-e.image.content[1]);if("proportional"===l){if("stretchOnly"===a&&s/o<c||"proportional"===a){const e=Math.ceil(o*c);r*=e/s,s=e}}else if("proportional"===a&&"stretchOnly"===l&&0!==c&&s/o>c){const e=Math.ceil(s/c);n*=e/o,o=e}return{x1:r,y1:n,x2:r+s,y2:n+o}}function ld(e,t,i,r,n,s){const o=e.image;let a;if(o.content){const e=o.content,t=o.pixelRatio||1;a=[e[0]/t,e[1]/t,o.displaySize[0]-e[2]/t,o.displaySize[1]-e[3]/t]}const l=t.left*s,c=t.right*s;let h,u,d,p;"width"===i||"both"===i?(p=n[0]+l-r[3],u=n[0]+c+r[1]):(p=n[0]+(l+c-o.displaySize[0])/2,u=p+o.displaySize[0]);const f=t.top*s,m=t.bottom*s;return"height"===i||"both"===i?(h=n[1]+f-r[0],d=n[1]+m+r[2]):(h=n[1]+(f+m-o.displaySize[1])/2,d=h+o.displaySize[1]),{image:o,top:h,right:u,bottom:d,left:p,collisionPadding:a}}ds("ImagePosition",Hu),ds("ImageAtlas",Yu),e.aw=void 0,(Ku=e.aw||(e.aw={}))[Ku.none=0]="none",Ku[Ku.horizontal=1]="horizontal",Ku[Ku.vertical=2]="vertical",Ku[Ku.horizontalOnly=3]="horizontalOnly";const cd=128,hd=32640;function ud(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new ks(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;n<t.length&&t[n]<=e;)n++;n=Math.max(0,n-1);let s=n;for(;s<t.length&&t[s]<e+1;)s++;s=Math.min(t.length-1,s);const o=t[n],a=t[s];return"composite"===i.kind?{kind:"composite",minZoom:o,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:o,maxZoom:a,minSize:i.evaluate(new ks(o)),maxSize:i.evaluate(new ks(a)),interpolationType:r}}}function dd(e,t,i){let r="never";const n=e.get(t);return n?r=n:e.get(i)&&(r="always"),r}const pd=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function fd(e,t,i,r,n,s,o,a,l,c,h,u,d){const p=a?Math.min(hd,Math.round(a[0])):0,f=a?Math.min(hd,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),s,o,(p<<1)+(l?1:0),f,16*c,16*h,256*u,256*d)}function md(e,t,i){e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i)}function gd(e){for(const t of e.sections)if(Ds(t.text))return!0;return!1}class _d{constructor(e){this.layoutVertexArray=new Yo,this.indexArray=new ta,this.programConfigurations=e,this.segments=new sa,this.dynamicLayoutVertexArray=new Ko,this.opacityVertexArray=new Jo,this.hasVisibleVertices=!1,this.placedSymbolArray=new ko}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,fu.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,mu.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,pd,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}ds("SymbolBuffers",_d);class yd{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new sa,this.collisionVertexArray=new ea}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,gu.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}ds("CollisionBuffers",yd);class xd{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(e=>e.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ud(this.zoom,i["text-size"]),this.iconSizeData=ud(this.zoom,i["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),s=r.get("symbol-z-order");this.canOverlap="never"!==dd(r,"text-overlap","text-allow-overlap")||"never"!==dd(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==s&&!n.isConstant(),this.sortFeaturesByY=("viewport-y"===s||"auto"===s&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map(t=>e.aw[t])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=t.sourceID}createArrays(){this.text=new _d(new La(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new _d(new La(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Fo,this.lineVertexArray=new Bo,this.symbolInstances=new Lo,this.textAnchorOffsets=new Vo}calculateGlyphDependencies(e,t,i,r,n){for(const s of e)if(t[s.codePointAt(0)]=!0,(i||r)&&n){const e=bu[s];e&&(t[e.codePointAt(0)]=!0)}}populate(t,i,r){const n=this.layers[0],s=n.layout,o=s.get("text-font"),a=s.get("text-field"),l=s.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof Dt&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==o.value.kind||o.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=s.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const d=i.iconDependencies,p=i.glyphDependencies,f=i.availableImages,m=new ks(this.zoom);for(const{feature:g,id:_,index:y,sourceLayerIndex:x}of t){const t=n._featureFilter.needGeometry,i=Na(g,t);if(!n._featureFilter.filter(m,i,r))continue;let a,l;if(t||(i.geometry=ja(g)),c){const e=n.getValueAndResolveTokens("text-field",i,r,f),t=Dt.factory(e),s=this.hasRTLText=this.hasRTLText||gd(t);(!s||"unavailable"===zs.getRTLTextPluginStatus()||s&&zs.isParsed())&&(a=xu(t,n,i))}if(h){const e=n.getValueAndResolveTokens("icon-image",i,r,f);l=e instanceof Ot?e:Ot.fromString(e)}if(!a&&!l)continue;const v=this.sortFeaturesByKey?u.evaluate(i,{},r):void 0;if(this.features.push({id:_,text:a,icon:l,index:y,sourceLayerIndex:x,geometry:i.geometry,properties:g.properties,type:Dc.types[g.type],sortKey:v}),l&&(d[l.name]=!0),a){const t=o.evaluate(i,{},r).join(","),n="viewport"!==s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(e.aw.vertical)>=0;for(const e of a.sections)if(e.image)d[e.image.name]=!0;else{const i=ws(a.toString()),r=e.fontStack||t,s=p[r]=p[r]||{};this.calculateGlyphDependencies(e.text,s,n,this.allowVerticalPlacement,i)}}}"line"===s.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function s(t){r.push(e[t]),n++}function o(e,t,n){const s=i[e];return delete i[e],i[t]=s,r[s].geometry[0].pop(),r[s].geometry[0]=r[s].geometry[0].concat(n[0]),s}function a(e,i,n){const s=t[i];return delete t[i],t[e]=s,r[s].geometry[0].shift(),r[s].geometry[0]=n[0].concat(r[s].geometry[0]),s}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;c<e.length;c++){const h=e[c],u=h.geometry,d=h.text?h.text.toString():null;if(!d){s(c);continue}const p=l(d,u),f=l(d,u,!0);if(p in i&&f in t&&i[p]!==t[f]){const e=a(p,f,u),n=o(p,f,r[e].geometry);delete t[p],delete i[f],i[l(d,r[n].geometry,!0)]=n,r[e].geometry=null}else p in i?o(p,f,u):f in t?a(p,f,u):(s(c),t[p]=n-1,i[f]=n-1)}return r.filter(e=>e.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!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.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]);const n={};for(let s=e.segment+1;s<t.length;s++)n[s]={x:t[s].x,y:t[s].y,tileUnitDistanceFromAnchor:i},s<t.length-1&&(i+=t[s+1].dist(t[s]));for(let s=e.segment||0;s>=0;s--)n[s]={x:t[s].x,y:t[s].y,tileUnitDistanceFromAnchor:r},s>0&&(r+=t[s-1].dist(t[s]));for(let e=0;e<t.length;e++){const t=n[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,i,r,n,s,o,a,l,c,h,u,d){const p=t.indexArray,f=t.layoutVertexArray,m=t.segments.prepareSegment(4*i.length,f,p,this.canOverlap?o.sortKey:void 0),g=this.glyphOffsetArray.length,_=m.vertexLength,y=this.allowVerticalPlacement&&a===e.aw.vertical?Math.PI/2:0,x=o.text&&o.text.sections;for(let e=0;e<i.length;e++){const{tl:n,tr:s,bl:a,br:c,tex:h,pixelOffsetTL:u,pixelOffsetBR:g,minFontScaleX:_,minFontScaleY:v,glyphOffset:b,isSDF:w,sectionIndex:T}=i[e],S=m.vertexLength,P=b[1];fd(f,l.x,l.y,n.x,P+n.y,h.x,h.y,r,w,u.x,u.y,_,v),fd(f,l.x,l.y,s.x,P+s.y,h.x+h.w,h.y,r,w,g.x,u.y,_,v),fd(f,l.x,l.y,a.x,P+a.y,h.x,h.y+h.h,r,w,u.x,g.y,_,v),fd(f,l.x,l.y,c.x,P+c.y,h.x+h.w,h.y+h.h,r,w,g.x,g.y,_,v),md(t.dynamicLayoutVertexArray,l,y),p.emplaceBack(S,S+2,S+1),p.emplaceBack(S+1,S+2,S+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),e!==i.length-1&&T===i[e+1].sectionIndex||t.programConfigurations.populatePaintArrays(f.length,o,o.index,{imagePositions:{},canonical:d,formattedSection:x&&x[T]})}t.placedSymbolArray.emplaceBack(l.x,l.y,g,this.glyphOffsetArray.length-g,_,c,h,l.segment,r?r[0]:0,r?r[1]:0,n[0],n[1],a,0,!1,0,u)}_addCollisionDebugVertex(e,t,i,r,n,s){return t.emplaceBack(0,0),e.emplaceBack(i.x,i.y,r,n,Math.round(s.x),Math.round(s.y))}addCollisionDebugVertices(e,t,r,n,s,o,a){const l=s.segments.prepareSegment(4,s.layoutVertexArray,s.indexArray),c=l.vertexLength,h=s.layoutVertexArray,u=s.collisionVertexArray,d=a.anchorX,p=a.anchorY;this._addCollisionDebugVertex(h,u,o,d,p,new i(e,t)),this._addCollisionDebugVertex(h,u,o,d,p,new i(r,t)),this._addCollisionDebugVertex(h,u,o,d,p,new i(r,n)),this._addCollisionDebugVertex(h,u,o,d,p,new i(e,n)),l.vertexLength+=4;const f=s.indexArray;f.emplaceBack(c,c+1),f.emplaceBack(c+1,c+2),f.emplaceBack(c+2,c+3),f.emplaceBack(c+3,c),l.primitiveLength+=4}addDebugCollisionBoxes(e,t,i,r){for(let n=e;n<t;n++){const e=this.collisionBoxArray.get(n);this.addCollisionDebugVertices(e.x1,e.y1,e.x2,e.y2,r?this.textCollisionBox:this.iconCollisionBox,e.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new yd(Qo,_u.members,ia),this.iconCollisionBox=new yd(Qo,_u.members,ia);for(let e=0;e<this.symbolInstances.length;e++){const t=this.symbolInstances.get(e);this.addDebugCollisionBoxes(t.textBoxStartIndex,t.textBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.verticalTextBoxStartIndex,t.verticalTextBoxEndIndex,t,!0),this.addDebugCollisionBoxes(t.iconBoxStartIndex,t.iconBoxEndIndex,t,!1),this.addDebugCollisionBoxes(t.verticalIconBoxStartIndex,t.verticalIconBoxEndIndex,t,!1)}}_deserializeCollisionBoxesForSymbol(e,t,i,r,n,s,o,a,l){const c={};for(let h=t;h<i;h++){const t=e.get(h);c.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},c.textFeatureIndex=t.featureIndex;break}for(let h=r;h<n;h++){const t=e.get(h);c.verticalTextBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},c.verticalTextFeatureIndex=t.featureIndex;break}for(let h=s;h<o;h++){const t=e.get(h);c.iconBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},c.iconFeatureIndex=t.featureIndex;break}for(let h=a;h<l;h++){const t=e.get(h);c.verticalIconBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,anchorPointX:t.anchorPointX,anchorPointY:t.anchorPointY},c.verticalIconFeatureIndex=t.featureIndex;break}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let n=i.vertexStartIndex;n<r;n+=4)e.indexArray.emplaceBack(n,n+2,n+1),e.indexArray.emplaceBack(n+1,n+2,n+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),i=Math.cos(e),r=[],n=[],s=[];for(let o=0;o<this.symbolInstances.length;++o){s.push(o);const e=this.symbolInstances.get(o);r.push(0|Math.round(t*e.anchorX+i*e.anchorY)),n.push(e.featureIndex)}return s.sort((e,t)=>r[e]-r[t]||n[t]-n[e]),s}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){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),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let vd,bd;ds("SymbolBucket",xd,{omit:["layers","collisionBoxArray","features","compareText"]}),xd.MAX_GLYPHS=65535,xd.addDynamicAttributes=md;var wd={get paint(){return bd=bd||new Hs({"icon-opacity":new Zs(xe.paint_symbol["icon-opacity"]),"icon-color":new Zs(xe.paint_symbol["icon-color"]),"icon-halo-color":new Zs(xe.paint_symbol["icon-halo-color"]),"icon-halo-width":new Zs(xe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Zs(xe.paint_symbol["icon-halo-blur"]),"icon-translate":new $s(xe.paint_symbol["icon-translate"]),"icon-translate-anchor":new $s(xe.paint_symbol["icon-translate-anchor"]),"text-opacity":new Zs(xe.paint_symbol["text-opacity"]),"text-color":new Zs(xe.paint_symbol["text-color"],{runtimeType:Ve,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Zs(xe.paint_symbol["text-halo-color"]),"text-halo-width":new Zs(xe.paint_symbol["text-halo-width"]),"text-halo-blur":new Zs(xe.paint_symbol["text-halo-blur"]),"text-translate":new $s(xe.paint_symbol["text-translate"]),"text-translate-anchor":new $s(xe.paint_symbol["text-translate-anchor"])})},get layout(){return vd=vd||new Hs({"symbol-placement":new $s(xe.layout_symbol["symbol-placement"]),"symbol-spacing":new $s(xe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new $s(xe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Zs(xe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new $s(xe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new $s(xe.layout_symbol["icon-allow-overlap"]),"icon-overlap":new $s(xe.layout_symbol["icon-overlap"]),"icon-ignore-placement":new $s(xe.layout_symbol["icon-ignore-placement"]),"icon-optional":new $s(xe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new $s(xe.layout_symbol["icon-rotation-alignment"]),"icon-size":new Zs(xe.layout_symbol["icon-size"]),"icon-text-fit":new $s(xe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new $s(xe.layout_symbol["icon-text-fit-padding"]),"icon-image":new Zs(xe.layout_symbol["icon-image"]),"icon-rotate":new Zs(xe.layout_symbol["icon-rotate"]),"icon-padding":new Zs(xe.layout_symbol["icon-padding"]),"icon-keep-upright":new $s(xe.layout_symbol["icon-keep-upright"]),"icon-offset":new Zs(xe.layout_symbol["icon-offset"]),"icon-anchor":new Zs(xe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new $s(xe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new $s(xe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new $s(xe.layout_symbol["text-rotation-alignment"]),"text-field":new Zs(xe.layout_symbol["text-field"]),"text-font":new Zs(xe.layout_symbol["text-font"]),"text-size":new Zs(xe.layout_symbol["text-size"]),"text-max-width":new Zs(xe.layout_symbol["text-max-width"]),"text-line-height":new $s(xe.layout_symbol["text-line-height"]),"text-letter-spacing":new Zs(xe.layout_symbol["text-letter-spacing"]),"text-justify":new Zs(xe.layout_symbol["text-justify"]),"text-radial-offset":new Zs(xe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new $s(xe.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Zs(xe.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Zs(xe.layout_symbol["text-anchor"]),"text-max-angle":new $s(xe.layout_symbol["text-max-angle"]),"text-writing-mode":new $s(xe.layout_symbol["text-writing-mode"]),"text-rotate":new Zs(xe.layout_symbol["text-rotate"]),"text-padding":new $s(xe.layout_symbol["text-padding"]),"text-keep-upright":new $s(xe.layout_symbol["text-keep-upright"]),"text-transform":new Zs(xe.layout_symbol["text-transform"]),"text-offset":new Zs(xe.layout_symbol["text-offset"]),"text-allow-overlap":new $s(xe.layout_symbol["text-allow-overlap"]),"text-overlap":new $s(xe.layout_symbol["text-overlap"]),"text-ignore-placement":new $s(xe.layout_symbol["text-ignore-placement"]),"text-optional":new $s(xe.layout_symbol["text-optional"])})}};class Td{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Le,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}}ds("FormatSectionOverride",Td,{omit:["defaultValue"]});class Sd extends Ys{constructor(e,t){super(e,wd,t)}recalculate(e,t){if(super.recalculate(e,t),"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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const t=[];for(const i of e)t.indexOf(i)<0&&t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),s=this._unevaluatedLayout._values[e];return s.isDataDriven()||tn(s.value)||!n?n:function(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>e&&i in e?String(e[i]):"")}(t.properties,n)}createBucket(e){return new xd(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of wd.paint.overridableProperties){if(!Sd.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new Td(t),r=new en(i,t.property.specification);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new nn("source",r):new sn("composite",r,t.value.zoomStops),this.paint._values[e]=new Us(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&Sd.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=wd.paint.properties[t];let n=!1;const s=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Dt)s(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){const e=t=>{n||(t instanceof $t&&Ut(t.value)===$e?s(t.value.sections):t instanceof Ei?s(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}}let Pd;var Id={get paint(){return Pd=Pd||new Hs({"background-color":new $s(xe.paint_background["background-color"]),"background-pattern":new Ws(xe.paint_background["background-pattern"]),"background-opacity":new $s(xe.paint_background["background-opacity"])})}};class Md extends Ys{constructor(e,t){super(e,Id,t)}}class Ed extends Ys{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Cd{constructor(e){this._methodToThrottle=e,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){var e;this._triggered||(this._triggered=!0,null===(e=this._channel)||void 0===e||e.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Ad={once:!0},Dd=6371008.8;class zd{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 zd(B(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,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return Dd*Math.acos(Math.min(n,1))}static convert(e){if(e instanceof zd)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new zd(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new zd(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: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const kd=2*Math.PI*Dd;function Rd(e){return kd*Math.cos(e*Math.PI/180)}function Ld(e){return(180+e)/360}function Fd(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Bd(e,t){return e/Rd(t)}function Od(e){return 360*e-180}function Vd(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function jd(e,t){return e*Rd(Vd(t))}class Nd{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=zd.convert(e);return new Nd(Ld(i.lng),Fd(i.lat),Bd(t,i.lat))}toLngLat(){return new zd(Od(this.x),Vd(this.y))}toAltitude(){return jd(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/kd*(e=Vd(this.y),1/Math.cos(e*Math.PI/180));var e}}function Ud(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class Gd{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=Math.pow(2,e)||t<0||t>=Math.pow(2,e))}(e,t,i))throw new Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=qd(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){const r=(s=this.y,o=this.z,a=Ud(256*(n=this.x),256*(s=Math.pow(2,o)-s-1),o),l=Ud(256*(n+1),256*(s+1),o),a[0]+","+a[1]+","+l[0]+","+l[1]);var n,s,o,a,l;const c=function(e,t,i){let r,n="";for(let s=e;s>0;s--)r=1<<s-1,n+=(t&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,t>1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}isChildOf(e){const t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){const t=Math.pow(2,this.z);return new i((e.x*t-this.x)*C,(e.y*t-this.y)*C)}toString(){return`${this.z}/${this.x}/${this.y}`}}class $d{constructor(e,t){this.wrap=e,this.canonical=t,this.key=qd(e,t.z,t.z,t.x,t.y)}}class Zd{constructor(e,t,i,r,n){if(this.terrainRttPosMatrix32f=null,e<i)throw new Error(`overscaledZ should be >= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new Gd(i,+r,+n),this.key=qd(t,e,i,r,n)}clone(){return new Zd(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const t=this.canonical.z-e;return e>this.canonical.z?new Zd(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Zd(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-e;return e>this.canonical.z?qd(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):qd(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const t=this.canonical.z-e.canonical.z;return!(t<0)&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Zd(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Zd(t,this.wrap,t,i,r),new Zd(t,this.wrap,t,i+1,r),new Zd(t,this.wrap,t,i,r+1),new Zd(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Zd(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Zd(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new $d(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(e){return this.canonical.getTilePoint(new Nd(e.x-this.wrap,e.y))}normalizeCoordinates(e,t,i=8192){if(e>=0&&e<i&&t>=0&&t<i)return{tileID:this,x:e,y:t};const r=Math.floor(e/i),n=Math.floor(t/i),s=e-r*i,o=t-n*i,a=this.canonical.z,l=1<<a,c=this.canonical.y+n;if(c<0||c>=l)return null;let h=this.canonical.x+r,u=this.wrap;return h<0?(u-=Math.ceil(-h/l),h=(h%l+l)%l):h>=l&&(u+=Math.floor(h/l),h%=l),{tileID:new Zd(this.overscaledZ,u,a,h,c),x:s,y:o}}}function qd(e,t,i,r,n){(e*=2)<0&&(e=-1*e-1);const s=1<<i;return(s*s*e+s*n+r).toString(36)+i.toString(36)+t.toString(36)}ds("CanonicalTileID",Gd),ds("OverscaledTileID",Zd,{omit:["terrainRttPosMatrix32f"]});class Wd{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const t=new Wd;return t.extend(e(new i(this.minX,this.minY))),t.extend(e(new i(this.maxX,this.minY))),t.extend(e(new i(this.minX,this.maxY))),t.extend(e(new i(this.maxX,this.maxY))),t}static fromPoints(e){const t=new Wd;for(const i of e)t.extend(i);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Xd{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){if(e>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Hd{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._x=i,this._y=r,this._z=t,this.properties=e.properties,this.id=n}projectPoint(e,t,i,r){return[360*(e.x+t)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+i)/r)*Math.PI))-90]}projectLine(e,t,i,r){return e.map(e=>this.projectPoint(e,t,i,r))}get geometry(){if(this._geometry)return this._geometry;const e=this._vectorTileFeature,t=e.extent*Math.pow(2,this._z),i=e.extent*this._x,r=e.extent*this._y,n=e.loadGeometry();switch(e.type){case 1:{const e=[];for(const t of n)e.push(t[0]);const s=this.projectLine(e,i,r,t);this._geometry=1===e.length?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s};break}case 2:{const e=n.map(e=>this.projectLine(e,i,r,t));this._geometry=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=kc(n),s=[];for(const n of e)s.push(n.map(e=>this.projectLine(e,i,r,t)));this._geometry=1===s.length?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s};break}default:throw new Error(`unknown feature type: ${e.type}`)}return this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&"_x"!==t&&"_y"!==t&&"_z"!==t&&(e[t]=this[t]);return e}}class Yd{constructor(e,t,i){this._name=e,this.dataBuffer=t,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer?.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Kd extends Yd{}class Jd extends Kd{getValueFromBuffer(e){return this.dataBuffer[e]}}class Qd extends Kd{getValueFromBuffer(e){return this.dataBuffer[e]}}class ep extends Yd{constructor(e,t,i,r){super(e,t,r),this.delta=i}}class tp extends ep{constructor(e,t,i,r){super(e,Int32Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class ip extends Yd{constructor(e,t,i,r){super(e,r?Int32Array.of(t):Uint32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}}class rp{constructor(e,t,i,r,n=4096){this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=r,this._extent=n}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map(e=>[e.name,e]))),this.propertyVectorsMap.get(e)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const e=[],t=this.geometryVector.getGeometries();for(let i=0;i<this.numFeatures;i++){let r;if(this.idVector){const e=this.idVector.getValue(i);r=this.containsMaxSafeIntegerValues(this.idVector)&&null!==e?Number(e):e}const n={coordinates:t[i],type:this.geometryVector.geometryType(i)},s={};for(const e of this.propertyVectors){if(!e)continue;const t=e.name,r=e.getValue(i);null!==r&&(s[t]=r)}e.push({id:r,geometry:n,properties:s})}return e}containsMaxSafeIntegerValues(e){return e instanceof Jd||e instanceof ip||e instanceof tp||e instanceof Qd}}class np{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}increment(){return this.value++}add(e){this.value+=e}}var sp,op;!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(sp||(sp={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(op||(op={}));const ap=new Uint32Array(33);ap[0]=0;for(let Um=1;Um<=32;Um++)ap[Um]=32===Um?4294967295:4294967295>>>32-Um;const lp=ap,cp=256;function hp(e,t){return e-e%t}function up(e){const t=e>>>0;return((255&t)<<24|(65280&t)<<8|t>>>8&65280|t>>>24&255)>>>0}const dp=function(){if(!Number.isFinite(65536))return 65536;const e=hp(Math.floor(65536),cp);return 0===e?cp:e}(),pp=3*dp/cp+dp|0;function fp(){const e=new Uint8Array(pp);return{dataToBePacked:new Array(33),dataPointers:new Int32Array(33),byteContainer:e,byteContainerI32:new Int32Array(e.buffer,e.byteOffset,e.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function mp(e,t,i,r,n){switch(n){case 1:!function(e,t,i,r){let n=r,s=t;for(let o=0;o<8;o++){const t=e[s++]>>>0;i[n++]=t>>>0&1,i[n++]=t>>>1&1,i[n++]=t>>>2&1,i[n++]=t>>>3&1,i[n++]=t>>>4&1,i[n++]=t>>>5&1,i[n++]=t>>>6&1,i[n++]=t>>>7&1,i[n++]=t>>>8&1,i[n++]=t>>>9&1,i[n++]=t>>>10&1,i[n++]=t>>>11&1,i[n++]=t>>>12&1,i[n++]=t>>>13&1,i[n++]=t>>>14&1,i[n++]=t>>>15&1,i[n++]=t>>>16&1,i[n++]=t>>>17&1,i[n++]=t>>>18&1,i[n++]=t>>>19&1,i[n++]=t>>>20&1,i[n++]=t>>>21&1,i[n++]=t>>>22&1,i[n++]=t>>>23&1,i[n++]=t>>>24&1,i[n++]=t>>>25&1,i[n++]=t>>>26&1,i[n++]=t>>>27&1,i[n++]=t>>>28&1,i[n++]=t>>>29&1,i[n++]=t>>>30&1,i[n++]=t>>>31&1}}(e,t,i,r);break;case 2:!function(e,t,i,r){let n=r,s=t;for(let o=0;o<8;o++){const t=e[s++]>>>0,r=e[s++]>>>0;i[n++]=t>>>0&3,i[n++]=t>>>2&3,i[n++]=t>>>4&3,i[n++]=t>>>6&3,i[n++]=t>>>8&3,i[n++]=t>>>10&3,i[n++]=t>>>12&3,i[n++]=t>>>14&3,i[n++]=t>>>16&3,i[n++]=t>>>18&3,i[n++]=t>>>20&3,i[n++]=t>>>22&3,i[n++]=t>>>24&3,i[n++]=t>>>26&3,i[n++]=t>>>28&3,i[n++]=t>>>30&3,i[n++]=r>>>0&3,i[n++]=r>>>2&3,i[n++]=r>>>4&3,i[n++]=r>>>6&3,i[n++]=r>>>8&3,i[n++]=r>>>10&3,i[n++]=r>>>12&3,i[n++]=r>>>14&3,i[n++]=r>>>16&3,i[n++]=r>>>18&3,i[n++]=r>>>20&3,i[n++]=r>>>22&3,i[n++]=r>>>24&3,i[n++]=r>>>26&3,i[n++]=r>>>28&3,i[n++]=r>>>30&3}}(e,t,i,r);break;case 3:!function(e,t,i,r){let n=r,s=t;for(let o=0;o<8;o++){const t=e[s++]>>>0,r=e[s++]>>>0,o=e[s++]>>>0;i[n++]=t>>>0&7,i[n++]=t>>>3&7,i[n++]=t>>>6&7,i[n++]=t>>>9&7,i[n++]=t>>>12&7,i[n++]=t>>>15&7,i[n++]=t>>>18&7,i[n++]=t>>>21&7,i[n++]=t>>>24&7,i[n++]=t>>>27&7,i[n++]=7&(t>>>30|(1&r)<<2),i[n++]=r>>>1&7,i[n++]=r>>>4&7,i[n++]=r>>>7&7,i[n++]=r>>>10&7,i[n++]=r>>>13&7,i[n++]=r>>>16&7,i[n++]=r>>>19&7,i[n++]=r>>>22&7,i[n++]=r>>>25&7,i[n++]=r>>>28&7,i[n++]=7&(r>>>31|(3&o)<<1),i[n++]=o>>>2&7,i[n++]=o>>>5&7,i[n++]=o>>>8&7,i[n++]=o>>>11&7,i[n++]=o>>>14&7,i[n++]=o>>>17&7,i[n++]=o>>>20&7,i[n++]=o>>>23&7,i[n++]=o>>>26&7,i[n++]=o>>>29&7}}(e,t,i,r);break;case 4:!function(e,t,i,r){let n=r,s=t;for(let o=0;o<8;o++){const t=e[s++]>>>0,r=e[s++]>>>0,o=e[s++]>>>0,a=e[s++]>>>0;i[n++]=t>>>0&15,i[n++]=t>>>4&15,i[n++]=t>>>8&15,i[n++]=t>>>12&15,i[n++]=t>>>16&15,i[n++]=t>>>20&15,i[n++]=t>>>24&15,i[n++]=t>>>28&15,i[n++]=r>>>0&15,i[n++]=r>>>4&15,i[n++]=r>>>8&15,i[n++]=r>>>12&15,i[n++]=r>>>16&15,i[n++]=r>>>20&15,i[n++]=r>>>24&15,i[n++]=r>>>28&15,i[n++]=o>>>0&15,i[n++]=o>>>4&15,i[n++]=o>>>8&15,i[n++]=o>>>12&15,i[n++]=o>>>16&15,i[n++]=o>>>20&15,i[n++]=o>>>24&15,i[n++]=o>>>28&15,i[n++]=a>>>0&15,i[n++]=a>>>4&15,i[n++]=a>>>8&15,i[n++]=a>>>12&15,i[n++]=a>>>16&15,i[n++]=a>>>20&15,i[n++]=a>>>24&15,i[n++]=a>>>28&15}}(e,t,i,r);break;case 5:!function(e,t,i,r){let n=r,s=t;for(let o=0;o<8;o++){const t=e[s++]>>>0,r=e[s++]>>>0,o=e[s++]>>>0,a=e[s++]>>>0,l=e[s++]>>>0;i[n++]=t>>>0&31,i[n++]=t>>>5&31,i[n++]=t>>>10&31,i[n++]=t>>>15&31,i[n++]=t>>>20&31,i[n++]=t>>>25&31,i[n++]=31&(t>>>30|(7&r)<<2),i[n++]=r>>>3&31,i[n++]=r>>>8&31,i[n++]=r>>>13&31,i[n++]=r>>>18&31,i[n++]=r>>>23&31,i[n++]=31&(r>>>28|(1&o)<<4),i[n++]=o>>>1&31,i[n++]=o>>>6&31,i[n++]=o>>>11&31,i[n++]=o>>>16&31,i[n++]=o>>>21&31,i[n++]=o>>>26&31,i[n++]=31&(o>>>31|(15&a)<<1),i[n++]=a>>>4&31,i[n++]=a>>>9&31,i[n++]=a>>>14&31,i[n++]=a>>>19&31,i[n++]=a>>>24&31,i[n++]=31&(a>>>29|(3&l)<<3),i[n++]=l>>>2&31,i[n++]=l>>>7&31,i[n++]=l>>>12&31,i[n++]=l>>>17&31,i[n++]=l>>>22&31,i[n++]=l>>>27&31}}(e,t,i,r);break;case 6:!function(e,t,i,r){let n=r,s=t;for(let o=0;o<8;o++){const t=e[s++]>>>0,r=e[s++]>>>0,o=e[s++]>>>0,a=e[s++]>>>0,l=e[s++]>>>0,c=e[s++]>>>0;i[n++]=t>>>0&63,i[n++]=t>>>6&63,i[n++]=t>>>12&63,i[n++]=t>>>18&63,i[n++]=t>>>24&63,i[n++]=63&(t>>>30|(15&r)<<2),i[n++]=r>>>4&63,i[n++]=r>>>10&63,i[n++]=r>>>16&63,i[n++]=r>>>22&63,i[n++]=63&(r>>>28|(3&o)<<4),i[n++]=o>>>2&63,i[n++]=o>>>8&63,i[n++]=o>>>14&63,i[n++]=o>>>20&63,i[n++]=o>>>26&63,i[n++]=a>>>0&63,i[n++]=a>>>6&63,i[n++]=a>>>12&63,i[n++]=a>>>18&63,i[n++]=a>>>24&63,i[n++]=63&(a>>>30|(15&l)<<2),i[n++]=l>>>4&63,i[n++]=l>>>10&63,i[n++]=l>>>16&63,i[n++]=l>>>22&63,i[n++]=63&(l>>>28|(3&c)<<4),i[n++]=c>>>2&63,i[n++]=c>>>8&63,i[n++]=c>>>14&63,i[n++]=c>>>20&63,i[n++]=c>>>26&63}}(e,t,i,r);break;case 7:!function(e,t,i,r){let n=r,s=t;for(let o=0;o<8;o++){const t=e[s++]>>>0,r=e[s++]>>>0,o=e[s++]>>>0,a=e[s++]>>>0,l=e[s++]>>>0,c=e[s++]>>>0,h=e[s++]>>>0;i[n++]=t>>>0&127,i[n++]=t>>>7&127,i[n++]=t>>>14&127,i[n++]=t>>>21&127,i[n++]=127&(t>>>28|(7&r)<<4),i[n++]=r>>>3&127,i[n++]=r>>>10&127,i[n++]=r>>>17&127,i[n++]=r>>>24&127,i[n++]=127&(r>>>31|(63&o)<<1),i[n++]=o>>>6&127,i[n++]=o>>>13&127,i[n++]=o>>>20&127,i[n++]=127&(o>>>27|(3&a)<<5),i[n++]=a>>>2&127,i[n++]=a>>>9&127,i[n++]=a>>>16&127,i[n++]=a>>>23&127,i[n++]=127&(a>>>30|(31&l)<<2),i[n++]=l>>>5&127,i[n++]=l>>>12&127,i[n++]=l>>>19&127,i[n++]=127&(l>>>26|(1&c)<<6),i[n++]=c>>>1&127,i[n++]=c>>>8&127,i[n++]=c>>>15&127,i[n++]=c>>>22&127,i[n++]=127&(c>>>29|(15&h)<<3),i[n++]=h>>>4&127,i[n++]=h>>>11&127,i[n++]=h>>>18&127,i[n++]=h>>>25&127}}(e,t,i,r);break;case 8:!function(e,t,i,r){let n=r,s=t;for(let o=0;o<8;o++){const t=e[s++]>>>0,r=e[s++]>>>0,o=e[s++]>>>0,a=e[s++]>>>0,l=e[s++]>>>0,c=e[s++]>>>0,h=e[s++]>>>0,u=e[s++]>>>0;i[n++]=t>>>0&255,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=r>>>0&255,i[n++]=r>>>8&255,i[n++]=r>>>16&255,i[n++]=r>>>24&255,i[n++]=o>>>0&255,i[n++]=o>>>8&255,i[n++]=o>>>16&255,i[n++]=o>>>24&255,i[n++]=a>>>0&255,i[n++]=a>>>8&255,i[n++]=a>>>16&255,i[n++]=a>>>24&255,i[n++]=l>>>0&255,i[n++]=l>>>8&255,i[n++]=l>>>16&255,i[n++]=l>>>24&255,i[n++]=c>>>0&255,i[n++]=c>>>8&255,i[n++]=c>>>16&255,i[n++]=c>>>24&255,i[n++]=h>>>0&255,i[n++]=h>>>8&255,i[n++]=h>>>16&255,i[n++]=h>>>24&255,i[n++]=u>>>0&255,i[n++]=u>>>8&255,i[n++]=u>>>16&255,i[n++]=u>>>24&255}}(e,t,i,r);break;case 16:!function(e,t,i,r){let n=r,s=t;for(let o=0;o<128;o++){const t=e[s++]>>>0;i[n++]=65535&t,i[n++]=t>>>16&65535}}(e,t,i,r);break;default:!function(e,t,i,r,n){const s=lp[n]>>>0;let o=t,a=0,l=e[o]>>>0,c=r;for(let h=0;h<8;h++){for(let t=0;t<32;t++)if(a+n<=32)i[c+t]=l>>>a&s,a+=n,32===a&&(a=0,o++,31!==t&&(l=e[o]>>>0));else{const r=32-a,h=l>>>a;o++,l=e[o]>>>0;const u=n-r;i[c+t]=(h|(l&-1>>>32-u>>>0)<<r)&s,a=u}c+=32,a=0,h<7&&(l=e[o]>>>0)}}(e,t,i,r,n)}return t+(n<<3)|0}function gp(e,t,i,r){if(i+2>t)throw new Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${t})`);const n=e[i++],s=e[i++];if(n>32)throw new Error(`FastPFOR decode: invalid bitWidth=${n} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:n,exceptionCount:s,bytePosIn:i}}function _p(e,t,i,r,n,s,o,a,l){const{maxBits:c,exceptionBitWidth:h,bytePosIn:u}=function(e,t,i,r,n,s){if(i+1>t)throw new Error(`FastPFOR decode: exception header underflow at block=${s} (need 1 byte for maxBits, bytePos=${i}, byteSize=${t})`);const o=e[i++];if(o<r||o>32)throw new Error(`FastPFOR decode: invalid maxBits=${o} at block=${s} (bitWidth=${r}, expected ${r}..32)`);const a=o-r|0;if(a<1||a>32)throw new Error(`FastPFOR decode: invalid exceptionBitWidth=${a} at block=${s} (bitWidth=${r}, maxBits=${o})`);if(i+n>t)throw new Error(`FastPFOR decode: exception positions underflow at block=${s} (need=${n}, have=${t-i})`);return{maxBits:o,exceptionBitWidth:a,bytePosIn:i}}(n,s,o,i,r,l);if(o=u,1===h){const s=1<<i;for(let i=0;i<r;i=i+1|0)e[n[o++]+t|0]|=s;return o}const d=a.dataToBePacked[h];if(!d)throw new Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${h} (bitWidth=${i}, maxBits=${c}) at block ${l}`);const p=a.dataPointers;let f=0|p[h];const m=0|a.exceptionSizes[h];if(f+r>m)throw new Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${h} (ptr=${f}, need ${r}, size=${m}) at block ${l}`);for(let g=0;g<r;g=g+1|0){const r=n[o++],s=0|d[f++];e[r+t|0]|=s<<i}return p[h]=f,o}function yp(e,t,i,r,n,s){const o=0|i,a=0|e[o];if(a<=0||o+a>e.length-1)throw new Error(`FastPFOR decode: invalid whereMeta=${a} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${e.length})`);const l=o+1|0,c=o+a|0,h=e[c]>>>0,u=h+3>>>2,d=c+1,p=d+u;if(p>=e.length)throw new Error(`FastPFOR decode: invalid byteSize=${h} (metaInts=${u}, pageStart=${o}, packedEnd=${c}, byteContainerStart=${d}) causes bitmapPos=${p} out of bounds (encoded.length=${e.length})`);const f=function(e,t,i,r){r.byteContainer.length<i&&(r.byteContainer=new Uint8Array(2*i),r.byteContainerI32=void 0);const n=r.byteContainer,s=i>>>2;if(3&n.byteOffset)for(let a=0;a<s;a=a+1|0){const i=0|e[t+a|0],r=a<<2;n[r]=255&i,n[r+1|0]=i>>>8&255,n[r+2|0]=i>>>16&255,n[r+3|0]=i>>>24&255}else{let i=r.byteContainerI32;(!i||i.buffer!==n.buffer||i.byteOffset!==n.byteOffset||i.length<s)&&(i=r.byteContainerI32=new Int32Array(n.buffer,n.byteOffset,n.byteLength>>>2)),i.set(e.subarray(t,t+s))}const o=3&i;if(o>0){const i=0|e[t+s|0],r=s<<2;for(let e=0;e<o;e=e+1|0)n[r+e|0]=i>>>(e<<3)&255}return n}(e,d,h,s),m=h,g=function(e,t,i){const r=0|e[t++],n=i.dataToBePacked;for(let s=2;s<=32;s=s+1|0){if(!(r>>>s-1&1))continue;if(t>=e.length)throw new Error(`FastPFOR decode: truncated exception stream header (bitWidth=${s}, streamWordIndex=${t}, needWords=1, availableWords=${e.length-t}, encodedWords=${e.length})`);const o=e[t++]>>>0,a=hp(o+31,32),l=o*s+31>>>5;if(t+l>e.length)throw new Error(`FastPFOR decode: truncated exception stream (bitWidth=${s}, size=${o}, streamWordIndex=${t}, needWords=${l}, availableWords=${e.length-t}, encodedWords=${e.length})`);let c=n[s];(!c||c.length<a)&&(c=n[s]=new Uint32Array(a));let h=0;for(;h<o;h=h+32|0)xp(e,t,c,h,s),t=t+s|0;t=t-((h-o|0)*s>>>5)|0,i.exceptionSizes[s]=o}return t}(e,p,s);return s.dataPointers.fill(0),function(e,t,i,r,n,s,o,a,l,c){let h=0|i,u=0;for(let d=0;d<o;d=d+1|0){const t=gp(a,l,u,d);u=t.bytePosIn;const i=t.bitWidth,r=t.exceptionCount,o=s+d*cp|0;switch(i){case 0:n.fill(0,o,o+cp);break;case 32:for(let t=0;t<cp;t=t+1|0)n[o+t|0]=0|e[h+t|0];h=h+cp|0;break;default:h=mp(e,h,n,o,i)}r>0&&(u=_p(n,o,i,r,a,l,u,c,d))}if(h!==r)throw new Error(`FastPFOR decode: packed region mismatch (pageStart=${t}, packedStart=${i}, consumedPackedEnd=${h}, expectedPackedEnd=${r}, packedWords=${r-i}, encoded.length=${e.length})`)}(e,o,l,c,t,0|r,n/cp|0,f,m,s),g}function xp(e,t,i,r,n){switch(n){case 2:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0;i[n++]=s>>>0&3,i[n++]=s>>>2&3,i[n++]=s>>>4&3,i[n++]=s>>>6&3,i[n++]=s>>>8&3,i[n++]=s>>>10&3,i[n++]=s>>>12&3,i[n++]=s>>>14&3,i[n++]=s>>>16&3,i[n++]=s>>>18&3,i[n++]=s>>>20&3,i[n++]=s>>>22&3,i[n++]=s>>>24&3,i[n++]=s>>>26&3,i[n++]=s>>>28&3,i[n++]=s>>>30&3,i[n++]=o>>>0&3,i[n++]=o>>>2&3,i[n++]=o>>>4&3,i[n++]=o>>>6&3,i[n++]=o>>>8&3,i[n++]=o>>>10&3,i[n++]=o>>>12&3,i[n++]=o>>>14&3,i[n++]=o>>>16&3,i[n++]=o>>>18&3,i[n++]=o>>>20&3,i[n++]=o>>>22&3,i[n++]=o>>>24&3,i[n++]=o>>>26&3,i[n++]=o>>>28&3,i[n]=o>>>30&3}(e,t,i,r);case 3:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0;i[n++]=s>>>0&7,i[n++]=s>>>3&7,i[n++]=s>>>6&7,i[n++]=s>>>9&7,i[n++]=s>>>12&7,i[n++]=s>>>15&7,i[n++]=s>>>18&7,i[n++]=s>>>21&7,i[n++]=s>>>24&7,i[n++]=s>>>27&7,i[n++]=7&(s>>>30|(1&o)<<2),i[n++]=o>>>1&7,i[n++]=o>>>4&7,i[n++]=o>>>7&7,i[n++]=o>>>10&7,i[n++]=o>>>13&7,i[n++]=o>>>16&7,i[n++]=o>>>19&7,i[n++]=o>>>22&7,i[n++]=o>>>25&7,i[n++]=o>>>28&7,i[n++]=7&(o>>>31|(3&a)<<1),i[n++]=a>>>2&7,i[n++]=a>>>5&7,i[n++]=a>>>8&7,i[n++]=a>>>11&7,i[n++]=a>>>14&7,i[n++]=a>>>17&7,i[n++]=a>>>20&7,i[n++]=a>>>23&7,i[n++]=a>>>26&7,i[n]=a>>>29&7}(e,t,i,r);case 4:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0;i[n++]=s>>>0&15,i[n++]=s>>>4&15,i[n++]=s>>>8&15,i[n++]=s>>>12&15,i[n++]=s>>>16&15,i[n++]=s>>>20&15,i[n++]=s>>>24&15,i[n++]=s>>>28&15,i[n++]=o>>>0&15,i[n++]=o>>>4&15,i[n++]=o>>>8&15,i[n++]=o>>>12&15,i[n++]=o>>>16&15,i[n++]=o>>>20&15,i[n++]=o>>>24&15,i[n++]=o>>>28&15,i[n++]=a>>>0&15,i[n++]=a>>>4&15,i[n++]=a>>>8&15,i[n++]=a>>>12&15,i[n++]=a>>>16&15,i[n++]=a>>>20&15,i[n++]=a>>>24&15,i[n++]=a>>>28&15,i[n++]=l>>>0&15,i[n++]=l>>>4&15,i[n++]=l>>>8&15,i[n++]=l>>>12&15,i[n++]=l>>>16&15,i[n++]=l>>>20&15,i[n++]=l>>>24&15,i[n]=l>>>28&15}(e,t,i,r);case 5:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0;i[n++]=s>>>0&31,i[n++]=s>>>5&31,i[n++]=s>>>10&31,i[n++]=s>>>15&31,i[n++]=s>>>20&31,i[n++]=s>>>25&31,i[n++]=31&(s>>>30|(7&o)<<2),i[n++]=o>>>3&31,i[n++]=o>>>8&31,i[n++]=o>>>13&31,i[n++]=o>>>18&31,i[n++]=o>>>23&31,i[n++]=31&(o>>>28|(1&a)<<4),i[n++]=a>>>1&31,i[n++]=a>>>6&31,i[n++]=a>>>11&31,i[n++]=a>>>16&31,i[n++]=a>>>21&31,i[n++]=a>>>26&31,i[n++]=31&(a>>>31|(15&l)<<1),i[n++]=l>>>4&31,i[n++]=l>>>9&31,i[n++]=l>>>14&31,i[n++]=l>>>19&31,i[n++]=l>>>24&31,i[n++]=31&(l>>>29|(3&c)<<3),i[n++]=c>>>2&31,i[n++]=c>>>7&31,i[n++]=c>>>12&31,i[n++]=c>>>17&31,i[n++]=c>>>22&31,i[n]=c>>>27&31}(e,t,i,r);case 6:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0;i[n++]=s>>>0&63,i[n++]=s>>>6&63,i[n++]=s>>>12&63,i[n++]=s>>>18&63,i[n++]=s>>>24&63,i[n++]=63&(s>>>30|(15&o)<<2),i[n++]=o>>>4&63,i[n++]=o>>>10&63,i[n++]=o>>>16&63,i[n++]=o>>>22&63,i[n++]=63&(o>>>28|(3&a)<<4),i[n++]=a>>>2&63,i[n++]=a>>>8&63,i[n++]=a>>>14&63,i[n++]=a>>>20&63,i[n++]=a>>>26&63,i[n++]=l>>>0&63,i[n++]=l>>>6&63,i[n++]=l>>>12&63,i[n++]=l>>>18&63,i[n++]=l>>>24&63,i[n++]=63&(l>>>30|(15&c)<<2),i[n++]=c>>>4&63,i[n++]=c>>>10&63,i[n++]=c>>>16&63,i[n++]=c>>>22&63,i[n++]=63&(c>>>28|(3&h)<<4),i[n++]=h>>>2&63,i[n++]=h>>>8&63,i[n++]=h>>>14&63,i[n++]=h>>>20&63,i[n]=h>>>26&63}(e,t,i,r);case 7:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0;i[n++]=s>>>0&127,i[n++]=s>>>7&127,i[n++]=s>>>14&127,i[n++]=s>>>21&127,i[n++]=127&(s>>>28|(7&o)<<4),i[n++]=o>>>3&127,i[n++]=o>>>10&127,i[n++]=o>>>17&127,i[n++]=o>>>24&127,i[n++]=127&(o>>>31|(63&a)<<1),i[n++]=a>>>6&127,i[n++]=a>>>13&127,i[n++]=a>>>20&127,i[n++]=127&(a>>>27|(3&l)<<5),i[n++]=l>>>2&127,i[n++]=l>>>9&127,i[n++]=l>>>16&127,i[n++]=l>>>23&127,i[n++]=127&(l>>>30|(31&c)<<2),i[n++]=c>>>5&127,i[n++]=c>>>12&127,i[n++]=c>>>19&127,i[n++]=127&(c>>>26|(1&h)<<6),i[n++]=h>>>1&127,i[n++]=h>>>8&127,i[n++]=h>>>15&127,i[n++]=h>>>22&127,i[n++]=127&(h>>>29|(15&u)<<3),i[n++]=u>>>4&127,i[n++]=u>>>11&127,i[n++]=u>>>18&127,i[n]=u>>>25&127}(e,t,i,r);case 8:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0;i[n++]=s>>>0&255,i[n++]=s>>>8&255,i[n++]=s>>>16&255,i[n++]=s>>>24&255,i[n++]=o>>>0&255,i[n++]=o>>>8&255,i[n++]=o>>>16&255,i[n++]=o>>>24&255,i[n++]=a>>>0&255,i[n++]=a>>>8&255,i[n++]=a>>>16&255,i[n++]=a>>>24&255,i[n++]=l>>>0&255,i[n++]=l>>>8&255,i[n++]=l>>>16&255,i[n++]=l>>>24&255,i[n++]=c>>>0&255,i[n++]=c>>>8&255,i[n++]=c>>>16&255,i[n++]=c>>>24&255,i[n++]=h>>>0&255,i[n++]=h>>>8&255,i[n++]=h>>>16&255,i[n++]=h>>>24&255,i[n++]=u>>>0&255,i[n++]=u>>>8&255,i[n++]=u>>>16&255,i[n++]=u>>>24&255,i[n++]=d>>>0&255,i[n++]=d>>>8&255,i[n++]=d>>>16&255,i[n]=d>>>24&255}(e,t,i,r);case 9:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0;i[n++]=s>>>0&511,i[n++]=s>>>9&511,i[n++]=s>>>18&511,i[n++]=511&(s>>>27|(15&o)<<5),i[n++]=o>>>4&511,i[n++]=o>>>13&511,i[n++]=o>>>22&511,i[n++]=511&(o>>>31|(255&a)<<1),i[n++]=a>>>8&511,i[n++]=a>>>17&511,i[n++]=511&(a>>>26|(7&l)<<6),i[n++]=l>>>3&511,i[n++]=l>>>12&511,i[n++]=l>>>21&511,i[n++]=511&(l>>>30|(127&c)<<2),i[n++]=c>>>7&511,i[n++]=c>>>16&511,i[n++]=511&(c>>>25|(3&h)<<7),i[n++]=h>>>2&511,i[n++]=h>>>11&511,i[n++]=h>>>20&511,i[n++]=511&(h>>>29|(63&u)<<3),i[n++]=u>>>6&511,i[n++]=u>>>15&511,i[n++]=511&(u>>>24|(1&d)<<8),i[n++]=d>>>1&511,i[n++]=d>>>10&511,i[n++]=d>>>19&511,i[n++]=511&(d>>>28|(31&p)<<4),i[n++]=p>>>5&511,i[n++]=p>>>14&511,i[n]=p>>>23&511}(e,t,i,r);case 10:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0;i[n++]=s>>>0&1023,i[n++]=s>>>10&1023,i[n++]=s>>>20&1023,i[n++]=1023&(s>>>30|(255&o)<<2),i[n++]=o>>>8&1023,i[n++]=o>>>18&1023,i[n++]=1023&(o>>>28|(63&a)<<4),i[n++]=a>>>6&1023,i[n++]=a>>>16&1023,i[n++]=1023&(a>>>26|(15&l)<<6),i[n++]=l>>>4&1023,i[n++]=l>>>14&1023,i[n++]=1023&(l>>>24|(3&c)<<8),i[n++]=c>>>2&1023,i[n++]=c>>>12&1023,i[n++]=c>>>22&1023,i[n++]=h>>>0&1023,i[n++]=h>>>10&1023,i[n++]=h>>>20&1023,i[n++]=1023&(h>>>30|(255&u)<<2),i[n++]=u>>>8&1023,i[n++]=u>>>18&1023,i[n++]=1023&(u>>>28|(63&d)<<4),i[n++]=d>>>6&1023,i[n++]=d>>>16&1023,i[n++]=1023&(d>>>26|(15&p)<<6),i[n++]=p>>>4&1023,i[n++]=p>>>14&1023,i[n++]=1023&(p>>>24|(3&f)<<8),i[n++]=f>>>2&1023,i[n++]=f>>>12&1023,i[n]=f>>>22&1023}(e,t,i,r);case 11:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0;i[n++]=s>>>0&2047,i[n++]=s>>>11&2047,i[n++]=2047&(s>>>22|(1&o)<<10),i[n++]=o>>>1&2047,i[n++]=o>>>12&2047,i[n++]=2047&(o>>>23|(3&a)<<9),i[n++]=a>>>2&2047,i[n++]=a>>>13&2047,i[n++]=2047&(a>>>24|(7&l)<<8),i[n++]=l>>>3&2047,i[n++]=l>>>14&2047,i[n++]=2047&(l>>>25|(15&c)<<7),i[n++]=c>>>4&2047,i[n++]=c>>>15&2047,i[n++]=2047&(c>>>26|(31&h)<<6),i[n++]=h>>>5&2047,i[n++]=h>>>16&2047,i[n++]=2047&(h>>>27|(63&u)<<5),i[n++]=u>>>6&2047,i[n++]=u>>>17&2047,i[n++]=2047&(u>>>28|(127&d)<<4),i[n++]=d>>>7&2047,i[n++]=d>>>18&2047,i[n++]=2047&(d>>>29|(255&p)<<3),i[n++]=p>>>8&2047,i[n++]=p>>>19&2047,i[n++]=2047&(p>>>30|(511&f)<<2),i[n++]=f>>>9&2047,i[n++]=f>>>20&2047,i[n++]=2047&(f>>>31|(1023&m)<<1),i[n++]=m>>>10&2047,i[n]=m>>>21&2047}(e,t,i,r);case 12:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,g=e[t+11]>>>0;i[n++]=s>>>0&4095,i[n++]=s>>>12&4095,i[n++]=4095&(s>>>24|(15&o)<<8),i[n++]=o>>>4&4095,i[n++]=o>>>16&4095,i[n++]=4095&(o>>>28|(255&a)<<4),i[n++]=a>>>8&4095,i[n++]=a>>>20&4095,i[n++]=l>>>0&4095,i[n++]=l>>>12&4095,i[n++]=4095&(l>>>24|(15&c)<<8),i[n++]=c>>>4&4095,i[n++]=c>>>16&4095,i[n++]=4095&(c>>>28|(255&h)<<4),i[n++]=h>>>8&4095,i[n++]=h>>>20&4095,i[n++]=u>>>0&4095,i[n++]=u>>>12&4095,i[n++]=4095&(u>>>24|(15&d)<<8),i[n++]=d>>>4&4095,i[n++]=d>>>16&4095,i[n++]=4095&(d>>>28|(255&p)<<4),i[n++]=p>>>8&4095,i[n++]=p>>>20&4095,i[n++]=f>>>0&4095,i[n++]=f>>>12&4095,i[n++]=4095&(f>>>24|(15&m)<<8),i[n++]=m>>>4&4095,i[n++]=m>>>16&4095,i[n++]=4095&(m>>>28|(255&g)<<4),i[n++]=g>>>8&4095,i[n]=g>>>20&4095}(e,t,i,r);case 16:return void function(e,t,i,r){let n=r;const s=e[t]>>>0,o=e[t+1]>>>0,a=e[t+2]>>>0,l=e[t+3]>>>0,c=e[t+4]>>>0,h=e[t+5]>>>0,u=e[t+6]>>>0,d=e[t+7]>>>0,p=e[t+8]>>>0,f=e[t+9]>>>0,m=e[t+10]>>>0,g=e[t+11]>>>0,_=e[t+12]>>>0,y=e[t+13]>>>0,x=e[t+14]>>>0,v=e[t+15]>>>0;i[n++]=s>>>0&65535,i[n++]=s>>>16&65535,i[n++]=o>>>0&65535,i[n++]=o>>>16&65535,i[n++]=a>>>0&65535,i[n++]=a>>>16&65535,i[n++]=l>>>0&65535,i[n++]=l>>>16&65535,i[n++]=c>>>0&65535,i[n++]=c>>>16&65535,i[n++]=h>>>0&65535,i[n++]=h>>>16&65535,i[n++]=u>>>0&65535,i[n++]=u>>>16&65535,i[n++]=d>>>0&65535,i[n++]=d>>>16&65535,i[n++]=p>>>0&65535,i[n++]=p>>>16&65535,i[n++]=f>>>0&65535,i[n++]=f>>>16&65535,i[n++]=m>>>0&65535,i[n++]=m>>>16&65535,i[n++]=g>>>0&65535,i[n++]=g>>>16&65535,i[n++]=_>>>0&65535,i[n++]=_>>>16&65535,i[n++]=y>>>0&65535,i[n++]=y>>>16&65535,i[n++]=x>>>0&65535,i[n++]=x>>>16&65535,i[n++]=v>>>0&65535,i[n]=v>>>16&65535}(e,t,i,r);case 32:for(let n=0;n<32;n=n+1|0)i[r+n|0]=0|e[t+n|0];return}const s=lp[n]>>>0;let o=t,a=0,l=e[o]>>>0;for(let c=0;c<32;c++)if(a+n<=32)i[r+c]=l>>>a&s,a+=n,32===a&&(a=0,o++,31!==c&&(l=e[o]>>>0));else{const t=32-a,h=l>>>a;o++,l=e[o]>>>0,i[r+c]=(h|(l&lp[n-t]>>>0)<<t)&s,a=n-t}}function vp(e,t,i){const r=new Uint32Array(i);let n=0,s=t.get();for(let o=0;o<r.length;o++){let t=e[s++],i=127&t;t<128||(t=e[s++],i|=(127&t)<<7,t<128||(t=e[s++],i|=(127&t)<<14,t<128||(t=e[s++],i|=(127&t)<<21,t<128||(t=e[s++],i|=(15&t)<<28)))),r[n++]=i}return t.set(s),r}function bp(e,t,i){const r=new BigUint64Array(i);for(let n=0;n<r.length;n++)r[n]=wp(e,t);return r}function wp(e,t){let i=0n,r=0,n=t.get();for(;n<e.length;){const t=e[n++];if(i|=BigInt(127&t)<<BigInt(r),!(128&t))break;if(r+=7,r>=64)throw new Error("Varint too long")}return t.set(n),i}function Tp(e,t){let i,r;return r=e[t.get()],t.increment(),i=127&r,r<128?i:(r=e[t.get()],t.increment(),i|=(127&r)<<7,r<128?i:(r=e[t.get()],t.increment(),i|=(127&r)<<14,r<128?i:(r=e[t.get()],t.increment(),i|=(127&r)<<21,r<128?i:(r=e[t.get()],i|=(15&r)<<28,function(e,t,i){let r,n;if(n=t[i.get()],i.increment(),r=(112&n)>>4,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<3,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<10,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<17,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<24,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(1&n)<<31,n<128)return 4294967296*r+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(i,e,t)))))}function Sp(e){return e>>>1^-(1&e)}function Pp(e){return e>>1n^-(1n&e)}function Ip(e){return e%2==1?(e+1)/-2:e/2}function Mp(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=e[r]}const r=new Uint32Array(i);let n=0;for(let s=0;s<t;s++){const i=e[s];r.fill(e[s+t],n,n+i),n+=i}return r}function Ep(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=Number(e[r])}const r=new BigUint64Array(i);let n=0;for(let s=0;s<t;s++){const i=Number(e[s]);r.fill(e[s+t],n,n+i),n+=i}return r}function Cp(e,t,i){const r=new Float64Array(i);let n=0;for(let s=0;s<t;s++){const i=e[s];r.fill(e[s+t],n,n+i),n+=i}return r}function Ap(e){const t=new Int32Array(e.length);t[0]=Sp(e[0]);const i=e.length/4*4;let r=1;if(i>=4)for(;r<i-4;r+=4){const i=e[r+1],n=e[r+2],s=e[r+3];t[r]=Sp(e[r])+t[r-1],t[r+1]=Sp(i)+t[r],t[r+2]=Sp(n)+t[r+1],t[r+3]=Sp(s)+t[r+2]}for(;r!==e.length;++r)t[r]=Sp(e[r])+t[r-1];return t}function Dp(e){const t=new BigInt64Array(e.length);t[0]=Pp(e[0]);const i=e.length/4*4;let r=1;if(i>=4)for(;r<i-4;r+=4){const i=e[r+1],n=e[r+2],s=e[r+3];t[r]=Pp(e[r])+t[r-1],t[r+1]=Pp(i)+t[r],t[r+2]=Pp(n)+t[r+1],t[r+3]=Pp(s)+t[r+2]}for(;r!==t.length;++r)t[r]=Pp(e[r])+t[r-1];return t}function zp(e){const t=e.length/4*4;let i=1;if(t>=4)for(let r=e[0];i<t-4;i+=4)r=e[i]+=r,r=e[i+1]+=r,r=e[i+2]+=r,r=e[i+3]+=r;for(;i!==e.length;)e[i]+=e[i-1],++i}var kp,Rp,Lp,Fp,Bp,Op,Vp,jp;function Np(e,t){const i=function(e,t){const i=e[t.get()],r=Object.values(kp)[i>>4];let n=null;switch(r){case kp.DATA:n={dictionaryType:Object.values(Rp)[15&i]};break;case kp.OFFSET:n={offsetType:Object.values(Lp)[15&i]};break;case kp.LENGTH:n={lengthType:Object.values(Fp)[15&i]}}t.increment();const s=e[t.get()],o=Object.values(sp)[s>>5],a=Object.values(sp)[s>>2&7],l=Object.values(op)[3&s];t.increment();const c=vp(e,t,2),h=c[0];return{physicalStreamType:r,logicalStreamType:n,logicalLevelTechnique1:o,logicalLevelTechnique2:a,physicalLevelTechnique:l,numValues:h,byteLength:c[1],decompressedCount:h}}(e,t);return i.logicalLevelTechnique1===sp.MORTON?function(e,t,i){const r=vp(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:e.decompressedCount,numBits:r[0],coordinateShift:r[1]}}(i,e,t):sp.RLE!==i.logicalLevelTechnique1&&sp.RLE!==i.logicalLevelTechnique2||op.NONE===i.physicalLevelTechnique?i:function(e,t,i){const r=vp(t,i,2);return{physicalStreamType:e.physicalStreamType,logicalStreamType:e.logicalStreamType,logicalLevelTechnique1:e.logicalLevelTechnique1,logicalLevelTechnique2:e.logicalLevelTechnique2,physicalLevelTechnique:e.physicalLevelTechnique,numValues:e.numValues,byteLength:e.byteLength,decompressedCount:r[1],runs:r[0],numRleValues:r[1]}}(i,e,t)}!function(e){e.PRESENT="PRESENT",e.DATA="DATA",e.OFFSET="OFFSET",e.LENGTH="LENGTH"}(kp||(kp={})),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Rp||(Rp={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Lp||(Lp={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(Fp||(Fp={})),function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(Bp||(Bp={}));class Up{constructor(e,t){this.values=e,this._size=t}get(e){const t=Math.floor(e/8);return 1==(this.values[t]>>e%8&1)}set(e,t){const i=Math.floor(e/8);this.values[i]=this.values[i]|(t?1:0)<<e%8}getInt(e){const t=Math.floor(e/8);return this.values[t]>>e%8&1}size(){return this._size}getBuffer(){return this.values}}function Gp(e,t,i){if(!t)return e;const r=t.size(),n=new(0,e.constructor)(r);let s=0;for(let o=0;o<r;o++)n[o]=t.get(o)?e[s++]:i;return n}function $p(e,t,i,r,n){return function(e,t,i,r){let n;switch(t.logicalLevelTechnique1){case sp.DELTA:if(t.logicalLevelTechnique2===sp.RLE){const i=t;if(!r)return function(e,t,i){const r=new Int32Array(i);let n=0,s=0;for(let o=0;o<t;o++){const i=e[o],a=Sp(e[o+t]);for(let e=0;e<i;e++)s+=a,r[n++]=s}return r}(e,i.runs,i.numRleValues);n=Ap(e=Mp(e,i.runs,i.numRleValues))}else n=Ap(e);break;case sp.RLE:n=function(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=e[r]}const r=new Int32Array(i);let n=0;for(let s=0;s<t;s++){const i=e[s];let o=e[s+t];o=Sp(o),r.fill(o,n,n+i),n+=i}return r}(e,t.runs,t.numRleValues);break;case sp.MORTON:zp(e),n=new Int32Array(e);break;case sp.COMPONENTWISE_DELTA:n=function(e){if(e.length<2)return new Int32Array(e);const t=new Int32Array(e.length);t[0]=Sp(e[0]),t[1]=Sp(e[1]);const i=e.length/4*4;let r=2;if(i>=4)for(;r<i-4;r+=4){const i=e[r+1],n=e[r+2],s=e[r+3];t[r]=Sp(e[r])+t[r-2],t[r+1]=Sp(i)+t[r-1],t[r+2]=Sp(n)+t[r],t[r+3]=Sp(s)+t[r+1]}for(;r!==e.length;r+=2)t[r]=Sp(e[r])+t[r-2],t[r+1]=Sp(e[r+1])+t[r-1];return t}(e);break;case sp.NONE:n=function(e){const t=new Int32Array(e.length);for(let i=0;i<e.length;i++)t[i]=Sp(e[i]);return t}(e);break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?Gp(n,r,0):n}(Wp(e,t,i),i,0,n)}function Zp(e,t,i,r,n){return function(e,t,i,r){let n;switch(t.logicalLevelTechnique1){case sp.DELTA:n=function(e){const t=new Uint32Array(e.length);t[0]=Sp(e[0])>>>0;for(let i=1;i<e.length;i++)t[i]=t[i-1]+Sp(e[i])>>>0;return t}(t.logicalLevelTechnique2===sp.RLE?Mp(e,t.runs,t.numRleValues):e);break;case sp.RLE:n=Mp(e,t.runs,t.numRleValues);break;case sp.MORTON:zp(e),n=e;break;case sp.COMPONENTWISE_DELTA:n=function(e){if(e.length<2)return new Uint32Array(e);const t=new Uint32Array(e.length);t[0]=Sp(e[0])>>>0,t[1]=Sp(e[1])>>>0;for(let i=2;i<e.length;i+=2)t[i]=t[i-2]+Sp(e[i])>>>0,t[i+1]=t[i-1]+Sp(e[i+1])>>>0;return t}(e);break;case sp.NONE:n=e;break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return r?Gp(n,r,0):n}(Wp(e,t,i),i,0,n)}function qp(e,t,i){return function(e,t){if(t.logicalLevelTechnique1===sp.DELTA&&t.logicalLevelTechnique2===sp.NONE)return function(e){const t=new Int32Array(e.length+1);t[0]=0,t[1]=Sp(e[0]);let i=t[1];for(let r=2;r!==t.length;++r)i+=Sp(e[r-1]),t[r]=t[r-1]+i;return new Uint32Array(t)}(e);if(t.logicalLevelTechnique1===sp.RLE&&t.logicalLevelTechnique2===sp.NONE)return function(e,t,i){const r=new Uint32Array(i+1);r[0]=0;let n=1,s=r[0];for(let o=0;o<t;o++){const i=e[o],a=e[o+t];for(let e=n;e<n+i;e++)r[e]=a+s,s=r[e];n+=i}return r}(e,t.runs,t.numRleValues);if(t.logicalLevelTechnique1===sp.NONE&&t.logicalLevelTechnique2===sp.NONE){!function(e){let t=0;for(let i=0;i<e.length;i++)e[i]+=t,t=e[i]}(e);const i=new Uint32Array(t.numValues+1);return i[0]=0,i.set(e,1),i}if(t.logicalLevelTechnique1===sp.DELTA&&t.logicalLevelTechnique2===sp.RLE){const i=function(e,t,i){const r=new Int32Array(i+1);r[0]=0;let n=1,s=r[0];for(let o=0;o<t;o++){const i=e[o];let a=e[o+t];a=Sp(a);for(let e=n;e<n+i;e++)r[e]=a+s,s=r[e];n+=i}return r}(e,t.runs,t.numRleValues);return zp(i),new Uint32Array(i)}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")}(Wp(e,t,i),i)}function Wp(e,t,i){const r=i.physicalLevelTechnique;switch(r){case op.FAST_PFOR:return function(e,t,i,r){return function(e,t,i,r,n){const s=r.get();if(3&i)throw new Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${s} (encodedBytes.length=${e.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);const o=i>>>2,a=function(e,t){if(t<=e.encodedWords.length)return e.encodedWords;const i=new Uint32Array(Math.max(16,2*t));return e.encodedWords=i,i}(n,o);!function(e,t,i,r){if(t<0||i<0||t+i>e.length)throw new RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${t}, byteLength=${i}, bytes.length=${e.length})`);const n=Math.floor(i/4),s=i%4!=0,o=s?n+1:n;if(r.length<o)throw new RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${o}`);if(n>0){const i=e.byteOffset+t;if(3&i)for(let s=0;s<n;s++){const i=t+4*s;r[s]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]}else{const t=new Uint32Array(e.buffer,i,n);for(let e=0;e<n;e++)r[e]=0|up(t[e])}}if(s){const s=t+4*n,o=i-4*n;let a=0;for(let t=0;t<o;t++)a|=e[s+t]<<24-8*t;r[n]=0|a}}(e,s,i,a);const l=function(e,t,i){let r=0,n=0;const s=new Uint32Array(t),o=i??fp();if(e.length>0){const t=0|e[r];if(r=r+1|0,255&t)throw new Error(`FastPFOR decode: invalid alignedLength=${t} (expected multiple of 256)`);if(n+t>s.length)throw new Error(`FastPFOR decode: output buffer too small (outPos=${n}, alignedLength=${t}, out.length=${s.length})`);r=function(e,t,i,r,n,s){const o=r+hp(n,cp);let a=r,l=i;for(;a!==o;){const i=Math.min(dp,o-a);l=yp(e,t,l,a,i,s),a=a+i|0}return l}(e,s,r,n,t,o),n=n+t|0}return function(e,t,i,r,n,s){if(0===s)return t;let o=0,a=t;const l=t+i,c=n;let h=n;const u=n+s;let d=0,p=0;for(;a<l&&h<u;){const t=e[a]>>>o&255;if(o+=8,a+=o>>>5,o&=31,d|=(127&t)<<p,128&t)r[h++]=0|d,d=0,p=0;else if(p+=7,p>28)throw new Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${d}, decoded=${h-c}/${s}, inPos=${a}, inEnd=${l})`)}if(h!==u)throw new Error(`FastPFOR VByte: truncated stream (decoded=${h-c}, expected=${s}, consumedWords=${a-t}/${i}, vbyteStart=${t}, vbyteEnd=${l})`)}(e,r,e.length-r|0,s,n,t-n|0),s}(a.subarray(0,o),t,n.decoderWorkspace);return r.add(i),l}(e,t,i,r,function(e=16){if(e<0)throw new RangeError(`initialEncodedWordCapacity must be >= 0, got ${e}`);const t=Math.max(16,0|e);return{encodedWords:new Uint32Array(t),decoderWorkspace:fp()}}(i>>>2))}(e,i.numValues,i.byteLength,t);case op.VARINT:return vp(e,t,i.numValues);case op.NONE:{const r=t.get();t.add(i.byteLength);const n=e.subarray(r,t.get());return new Uint32Array(n)}default:throw new Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function Xp(e,t,i){const r=Wp(e,t,i);return 1===r.length?r[0]:function(e){return e[1]}(r)}function Hp(e,t,i){return function(e){if(2===e.length){const t=Sp(e[1]);return[t,t]}return[Sp(e[2]),Sp(e[3])]}(Wp(e,t,i))}function Yp(e,t,i){return function(e){if(2===e.length){const t=Pp(e[1]);return[t,t]}return[Pp(e[2]),Pp(e[3])]}(bp(e,t,i.numValues))}function Kp(e,t,i,r){return function(e,t,i){let r;switch(t.logicalLevelTechnique1){case sp.DELTA:r=function(e){const t=new BigUint64Array(e.length);t[0]=BigInt.asUintN(64,Pp(e[0]));for(let i=1;i<e.length;i++)t[i]=BigInt.asUintN(64,t[i-1]+Pp(e[i]));return t}(t.logicalLevelTechnique2===sp.RLE?Ep(e,t.runs,t.numRleValues):e);break;case sp.RLE:r=Ep(e,t.runs,t.numRleValues);break;case sp.NONE:r=e;break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?Gp(r,i,0n):r}(bp(e,t,i.numValues),i,r)}function Jp(e,t,i){const r=bp(e,t,i.numValues);return 1===r.length?r[0]:function(e){return e[1]}(r)}function Qp(e,t,i,r,n="int32"){const s=e.logicalLevelTechnique1;if(s===sp.RLE)return 1===e.runs?Bp.CONST:Bp.FLAT;if(s!==sp.DELTA||e.logicalLevelTechnique2!==sp.RLE)return 1===e.numValues?Bp.CONST:Bp.FLAT;const o=t instanceof Up?t.size():t;if(e.numRleValues!==o)return Bp.FLAT;if(1===e.runs)return Bp.SEQUENCE;if(2!==e.runs)return 1===e.numValues?Bp.CONST:Bp.FLAT;const a=r.get();if(e.physicalLevelTechnique===op.VARINT)return function(e,t,i){const r=new np(t.get());if("int64"===i){const t=bp(e,r,4);return 2n===t[2]&&2n===t[3]}const n=vp(e,r,4);return 2===n[2]&&2===n[3]}(i,r,n)?Bp.SEQUENCE:1===e.numValues?Bp.CONST:Bp.FLAT;const l=r.get(),c=new Int32Array(i.buffer,i.byteOffset+l,4);return r.set(a),2===c[2]&&2===c[3]?Bp.SEQUENCE:1===e.numValues?Bp.CONST:Bp.FLAT}class ef extends Kd{getValueFromBuffer(e){return this.dataBuffer[e]}}class tf extends ep{constructor(e,t,i,r){super(e,BigInt64Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}function rf(e,t,i){return{x:nf(e,t)-i,y:nf(e>>1,t)-i}}function nf(e,t){let i=0;for(let r=0;r<t;r++)i|=(e&1<<2*r)>>r;return i}function sf(e,t,r,n,s,o,a){return e===jp.MORTON?function(e,t,r,n,s,o){const a=new Array(s?n+1:n);for(let l=0;l<n;l++){const n=rf(e[t[r+l]],o.numBits,o.coordinateShift);a[l]=new i(n.x,n.y)}return s&&(a[a.length-1]=a[0]),a}(t,r,n,s,o,a):function(e,t,r,n,s){const o=new Array(s?n+1:n);for(let a=0;a<2*n;a+=2){const n=2*t[r+a/2];o[a/2]=new i(e[n],e[n+1])}return s&&(o[o.length-1]=o[0]),o}(t,r,n,s,o)}function of(e,t,r,n){const s=new Array(n?r+1:r);for(let o=0;o<2*r;o+=2)s[o/2]=new i(e[t+o],e[t+o+1]);return n&&(s[s.length-1]=s[0]),s}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(Op||(Op={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(Vp||(Vp={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(jp||(jp={}));class af{constructor(e,t,i,r,n){this._vertexBufferType=e,this._topologyVector=t,this._vertexOffsets=i,this._vertexBuffer=r,this._mortonSettings=n}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(e){const t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getVertex(e){if(this.vertexOffsets&&this.mortonSettings){const t=rf(this.vertexBuffer[this.vertexOffsets[e]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[t.x,t.y]}const t=this.vertexOffsets?2*this.vertexOffsets[e]:2*e;return[this.vertexBuffer[t],this.vertexBuffer[t+1]]}getGeometries(){return function(e){const t=new Array(e.numGeometries);let r=1,n=1,s=1,o=0,a=0,l=0;const c=e.mortonSettings,h=e.topologyVector,u=h.geometryOffsets,d=h.partOffsets,p=h.ringOffsets,f=e.vertexOffsets,m=!f||0===f.length,g=e.containsPolygonGeometry(),_=e.vertexBuffer;for(let y=0;y<e.numGeometries;y++)switch(e.geometryType(y)){case Op.POINT:{let h,g;if(m)h=_[a++],g=_[a++];else if(e.vertexBufferType===jp.MORTON){const e=rf(_[f[l++]],c.numBits,c.coordinateShift);h=e.x,g=e.y}else{const e=2*f[l++];h=_[e],g=_[e+1]}t[o++]=[[new i(h,g)]],u&&s++,d&&r++,p&&n++}break;case Op.MULTIPOINT:{const e=u[s]-u[s-1];s++;const c=new Array(e);if(m)for(let t=0;t<e;t++){const e=_[a++],r=_[a++];c[t]=new i(e,r)}else for(let t=0;t<e;t++){const e=2*f[l++];c[t]=new i(_[e],_[e+1])}t[o++]=c.map(e=>[e]),r+=e,n+=e}break;case Op.LINESTRING:{let i,h;g?(i=p[n]-p[n-1],n++):i=d[r]-d[r-1],r++,m?(h=of(_,a,i,!1),a+=2*i):(h=sf(e.vertexBufferType,_,f,l,i,!1,c),l+=i),t[o++]=[h],u&&s++}break;case Op.POLYGON:{const i=d[r]-d[r-1];r++;const h=new Array(i-1);let g,y=p[n]-p[n-1];if(n++,m){g=of(_,a,y,!0),a+=2*y;for(let e=0;e<h.length;e++)y=p[n]-p[n-1],n++,h[e]=of(_,a,y,!0),a+=2*y}else{g=sf(e.vertexBufferType,_,f,l,y,!0,c),l+=y;for(let t=0;t<h.length;t++)y=p[n]-p[n-1],n++,h[t]=sf(e.vertexBufferType,_,f,l,y,!0,c),l+=y}t[o++]=[g].concat(h),u&&s++}break;case Op.MULTILINESTRING:{const i=u[s]-u[s-1];s++;const h=new Array(i);for(let t=0;t<i;t++){let i;if(g?(i=p[n]-p[n-1],n++):i=d[r]-d[r-1],r++,m)h[t]=of(_,a,i,!1),a+=2*i;else{const r=sf(e.vertexBufferType,_,f,l,i,!1,c);h[t]=r,l+=i}}t[o++]=h}break;case Op.MULTIPOLYGON:{const i=u[s]-u[s-1];s++;const h=new Array(i);for(let t=0;t<i;t++){const i=d[r]-d[r-1];let s;r++;const o=new Array(i-1),u=p[n]-p[n-1];n++,m?(s=of(_,a,u,!0),a+=2*u):(s=sf(e.vertexBufferType,_,f,l,u,!0,c),l+=u);for(let t=0;t<o.length;t++){const i=p[n]-p[n-1];n++,m?(o[t]=of(_,a,i,!0),a+=2*i):(o[t]=sf(e.vertexBufferType,_,f,l,i,!0,c),l+=i)}h[t]=[s].concat(o)}t[o++]=h.flat()}break;default:throw new Error("The specified geometry type is currently not supported.")}return t}(this)}get mortonSettings(){return this._mortonSettings}}class lf extends af{constructor(e,t,i,r,n,s,o){super(i,r,n,s,o),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Op.POLYGON||this._geometryType===Op.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class cf extends af{constructor(e,t,i,r,n,s){super(e,i,r,n,s),this._geometryTypes=t}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let e=0;e<this.numGeometries;e++)if(this.geometryType(e)===Op.POLYGON||this.geometryType(e)===Op.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class hf{constructor(e,t,i,r){this._triangleOffsets=e,this._indexBuffer=t,this._vertexBuffer=i,this._topologyVector=r}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw new Error("Cannot convert GpuVector to coordinates without topology information");const e=new Array(this.numGeometries),t=this._topologyVector,r=t.partOffsets,n=t.ringOffsets,s=t.geometryOffsets;let o=0,a=1,l=1,c=1;for(let h=0;h<this.numGeometries;h++)switch(this.geometryType(h)){case Op.POLYGON:{const t=r[a]-r[a-1];a++;const u=[];for(let e=0;e<t;e++){const e=n[l]-n[l-1];l++;const t=[];for(let r=0;r<e;r++){const e=this._vertexBuffer[o++],r=this._vertexBuffer[o++];t.push(new i(e,r))}t.length>0&&t.push(t[0]),u.push(t)}e[h]=u,s&&c++}break;case Op.MULTIPOLYGON:{const t=s[c]-s[c-1];c++;const u=[];for(let e=0;e<t;e++){const e=r[a]-r[a-1];a++;for(let t=0;t<e;t++){const e=n[l]-n[l-1];l++;const t=[];for(let r=0;r<e;r++){const e=this._vertexBuffer[o++],r=this._vertexBuffer[o++];t.push(new i(e,r))}t.length>0&&t.push(t[0]),u.push(t)}}e[h]=u}}return e}[Symbol.iterator](){return null}}function uf(e,t,i,r,n,s){return new df(e,t,i,r,n,s)}class df extends hf{constructor(e,t,i,r,n,s){super(i,r,n,s),this._numGeometries=e,this._geometryType=t}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function pf(e,t,i,r,n){return new ff(e,t,i,r,n)}class ff extends hf{constructor(e,t,i,r,n){super(t,i,r,n),this._geometryTypes=e}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function mf(e,t,i,r,n){const s=Np(e,i);let o,a,l,c;if(Qp(s,r,e,i)===Bp.CONST){const n=Xp(e,i,s);let h,u,d,p;for(let r=0;r<t-1;r++){const t=Np(e,i);switch(t.physicalStreamType){case kp.LENGTH:switch(t.logicalStreamType.lengthType){case Fp.GEOMETRIES:h=qp(e,i,t);break;case Fp.PARTS:u=qp(e,i,t);break;case Fp.RINGS:d=qp(e,i,t);break;case Fp.TRIANGLES:p=qp(e,i,t)}break;case kp.OFFSET:switch(t.logicalStreamType.offsetType){case Lp.VERTEX:o=Zp(e,i,t);break;case Lp.INDEX:c=Zp(e,i,t)}break;case kp.DATA:Rp.VERTEX===t.logicalStreamType.dictionaryType?a=$p(e,i,t):(l={numBits:t.numBits,coordinateShift:t.coordinateShift},a=Zp(e,i,t))}}return c?void 0!==h||void 0!==u?uf(r,n,p,c,a,{geometryOffsets:h,partOffsets:u,ringOffsets:d}):uf(r,n,p,c,a):void 0===l?function(e,t,i,r,n){return new lf(e,t,jp.VEC_2,i,r,n)}(r,n,{geometryOffsets:h,partOffsets:u,ringOffsets:d},o,a):function(e,t,i,r,n,s){return new lf(e,t,jp.MORTON,i,r,n,s)}(r,n,{geometryOffsets:h,partOffsets:u,ringOffsets:d},o,a,l)}const h=Zp(e,i,s);let u,d,p,f,m,g,_;for(let y=0;y<t-1;y++){const t=Np(e,i);switch(t.physicalStreamType){case kp.LENGTH:switch(t.logicalStreamType.lengthType){case Fp.GEOMETRIES:u=Zp(e,i,t);break;case Fp.PARTS:d=Zp(e,i,t);break;case Fp.RINGS:p=Zp(e,i,t);break;case Fp.TRIANGLES:f=qp(e,i,t)}break;case kp.OFFSET:switch(t.logicalStreamType.offsetType){case Lp.VERTEX:o=Zp(e,i,t);break;case Lp.INDEX:c=Zp(e,i,t)}break;case kp.DATA:Rp.VERTEX===t.logicalStreamType.dictionaryType?a=$p(e,i,t):(l={numBits:t.numBits,coordinateShift:t.coordinateShift},a=Zp(e,i,t))}}return u?(m=gf(h,u,2),d&&p?(g=_f(h,m,d,!1),_=function(e,t,i,r){const n=new Uint32Array(i[i.length-1]+1);let s=0;n[0]=s;let o=1,a=1,l=0;for(let c=0;c<e.length;c++){const h=e[c],u=t[c+1]-t[c];if(0!==h&&3!==h)for(let e=0;e<u;e++){const e=i[o]-i[o-1];o++;for(let t=0;t<e;t++)s=n[a++]=s+r[l++]}else for(let e=0;e<u;e++)n[a++]=++s,o++}return n}(h,m,g,p)):d&&(g=function(e,t,i){const r=new Uint32Array(t[t.length-1]+1);let n=0;r[0]=n;let s=1,o=0;for(let a=0;a<e.length;a++){const l=e[a],c=t[a+1]-t[a];if(4===l||1===l)for(let e=0;e<c;e++)n=r[s++]=n+i[o++];else for(let e=0;e<c;e++)r[s++]=++n}return r}(h,m,d))):d&&p?(g=gf(h,d,1),_=_f(h,g,p,!0)):d&&(g=gf(h,d,0)),c&&!g?pf(h,f,c,a):c?pf(h,f,c,a,{geometryOffsets:m,partOffsets:g,ringOffsets:_}):void 0===l?function(e,t,i,r){return new cf(jp.VEC_2,e,t,i,r)}(h,{geometryOffsets:m,partOffsets:g,ringOffsets:_},o,a):function(e,t,i,r,n){return new cf(jp.MORTON,e,t,i,r,n)}(h,{geometryOffsets:m,partOffsets:g,ringOffsets:_},o,a,l)}function gf(e,t,i){const r=new Uint32Array(e.length+1);let n=0;r[0]=n;let s=0;for(let o=0;o<e.length;o++)n=r[o+1]=n+(e[o]>i?t[s++]:1);return r}function _f(e,t,i,r){const n=new Uint32Array(t[t.length-1]+1);let s=0;n[0]=s;let o=1,a=0;for(let l=0;l<e.length;l++){const c=e[l],h=t[l+1]-t[l];if(5===c||2===c||r&&(4===c||1===c))for(let e=0;e<h;e++)s=n[o++]=s+i[a++];else for(let e=0;e<h;e++)n[o++]=++s}return n}class yf extends Yd{constructor(e,t,i){super(e,t.getBuffer(),i),this.dataVector=t}getValueFromBuffer(e){return this.dataVector.get(e)}}class xf extends Kd{getValueFromBuffer(e){return this.dataBuffer[e]}}class vf extends Yd{constructor(e,t,i,r){super(e,r?BigInt64Array.of(t):BigUint64Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}}function bf(e,t,i,r,n){const s=function(e,t,i,r){const n=new Uint8Array(t);let s=0;const o=r.get()+i;for(;s<t&&!(r.get()>=o);){const i=e[r.increment()];if(i<=127){const o=i+3,a=e[r.increment()],l=Math.min(s+o,t);n.fill(a,s,l),s=l}else{const o=256-i;for(let i=0;i<o&&s<t;i++)n[s++]=e[r.increment()]}}return r.set(o),n}(e,Math.ceil(t/8),i,r);return n?function(e,t,i){if(!i)return e;const r=i.size(),n=new Up(e,t),s=new Up(new Uint8Array(Math.ceil(r/8)),r);let o=0;for(let a=0;a<r;a++){const e=!!i.get(a)&&n.get(o++);s.set(a,e)}return s.getBuffer()}(s,t,n):s}const wf=new TextDecoder;function Tf(e,t,i){return i-t>=12?wf.decode(e.subarray(t,i)):function(e,t,i){let r="",n=t;for(;n<i;){const t=e[n];let s,o,a,l=null,c=t>239?4:t>223?3:t>191?2:1;if(n+c>i)break;1===c?t<128&&(l=t):2===c?(s=e[n+1],128==(192&s)&&(l=(31&t)<<6|63&s,l<=127&&(l=null))):3===c?(s=e[n+1],o=e[n+2],128==(192&s)&&128==(192&o)&&(l=(15&t)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(s=e[n+1],o=e[n+2],a=e[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&t)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=c}return r}(e,t,i)}class Sf extends Yd{constructor(e,t,i,r){super(e,i,r),this.offsetBuffer=t}}class Pf extends Sf{constructor(e,t,i,r){super(e,t,i,r??t.length-1)}getValueFromBuffer(e){return Tf(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class If extends Sf{constructor(e,t,i,r,n){super(e,i,r,n??t.length),this.indexBuffer=t,this.indexBuffer=t}getValueFromBuffer(e){const t=this.indexBuffer[e];return Tf(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class Mf extends Sf{constructor(e,t,i,r,n,s,o){super(e,i,r,o),this.indexBuffer=t,this.symbolOffsetBuffer=n,this.symbolTableBuffer=s}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),this.decodedDictionary=function(e,t,i){const r=[],n=new Array(t.length).fill(0);for(let s=1;s<t.length;s++)n[s]=n[s-1]+t[s-1];for(let s=0;s<i.length;s++)if(255===i[s])r.push(i[++s]);else{const o=t[i[s]],a=n[i[s]];for(let t=0;t<o;t++)r.push(e[a+t])}return new Uint8Array(r)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const t=this.indexBuffer[e];return Tf(this.decodedDictionary,this.offsetBuffer[t],this.offsetBuffer[t+1])}offsetToLengthBuffer(e){const t=new Uint32Array(e.length-1);let i=e[0];for(let r=1;r<e.length;r++){const n=e[r];t[r-1]=n-i,i=n}return t}}function Ef(e,t,i,r,n,s){return"scalarType"===i.type?function(e,t,i,r,n,s){let o=null;if(0===e)return null;if(s.nullable){const e=Np(t,i),r=e.numValues,n=i.get(),s=bf(t,r,e.byteLength,i);i.set(n+e.byteLength),o=new Up(s,e.numValues)}const a=o??r;switch(n.physicalType){case 4:case 3:return function(e,t,i,r,n){const s=Np(e,t),o=Qp(s,n,e,t),a=3===r.physicalType;if(o===Bp.FLAT){const r=Cf(n)?n:void 0,o=a?$p(e,t,s,0,r):Zp(e,t,s,0,r);return new Jd(i.name,o,n)}if(o===Bp.SEQUENCE){const r=Hp(e,t,s);return new tp(i.name,r[0],r[1],s.numRleValues)}const l=a?function(e,t,i){const r=Wp(e,t,i);return 1===r.length?Sp(r[0]):function(e){return Sp(e[1])}(r)}(e,t,s):Xp(e,t,s);return new ip(i.name,l,n,a)}(t,i,s,n,a);case 9:return function(e,t,i,r,n){let s=null,o=null,a=null,l=null,c=null,h=n??null,u=null,d=null;for(let p=0;p<r;p++){const e=Np(t,i);switch(e.physicalStreamType){case kp.PRESENT:{const r=bf(t,e.numValues,e.byteLength,i),s=new Up(r,e.numValues);h=n??s;break}case kp.OFFSET:o=Zp(t,i,e,0,h);break;case kp.LENGTH:{const r=qp(t,i,e);Fp.DICTIONARY===e.logicalStreamType.lengthType?s=r:Fp.SYMBOL===e.logicalStreamType.lengthType?l=r:u=r;break}case kp.DATA:{const r=t.subarray(i.get(),i.get()+e.byteLength);i.add(e.byteLength);const n=e.logicalStreamType.dictionaryType;Rp.FSST===n?c=r:Rp.SINGLE===n||Rp.SHARED===n?a=r:Rp.NONE===n&&(d=r);break}}}return function(e,t,i,r,n,s,o){return t?new Mf(e,i,r,n,s,t,o):null}(e,c,o,s,a,l,h)??function(e,t,i,r,n){return t?n?new If(e,i,r,t,n):new If(e,i,r,t):null}(e,a,o,s,h)??function(e,t,i,r,n){if(!t||!i)return null;if(r)return n?new If(e,r,t,i,n):new If(e,r,t,i);if(n&&n.size()!==t.length-1){const r=new Uint32Array(n.size());let s=0;for(let e=0;e<n.size();e++)r[e]=n.get(e)?s++:0;return new If(e,r,t,i,n)}return n?new Pf(e,t,i,n):new Pf(e,t,i)}(e,u,d,o,h)}(s.name,t,i,s.nullable?e-1:e,o);case 0:return function(e,t,i,r,n){const s=Np(e,t),o=s.numValues,a=t.get(),l=Cf(n)?n:void 0,c=bf(e,o,s.byteLength,t,l);t.set(a+s.byteLength);const h=new Up(c,o);return new yf(i.name,h,n)}(t,i,s,0,a);case 6:case 5:return function(e,t,i,r,n){const s=Np(e,t),o=Qp(s,r,e,t,"int64"),a=5===n.physicalType;if(o===Bp.FLAT){const n=Cf(r)?r:void 0,o=a?function(e,t,i,r){return function(e,t,i){let r;switch(t.logicalLevelTechnique1){case sp.DELTA:if(t.logicalLevelTechnique2===sp.RLE){const n=t;if(!i)return function(e,t,i){const r=new BigInt64Array(i);let n=0,s=0n;for(let o=0;o<t;o++){const i=Number(e[o]),a=Pp(e[o+t]);for(let e=0;e<i;e++)s+=a,r[n++]=s}return r}(e,n.runs,n.numRleValues);r=Dp(e=Ep(e,n.runs,n.numRleValues))}else r=Dp(e);break;case sp.RLE:r=function(e,t,i){if(void 0===i){i=0;for(let r=0;r<t;r++)i+=Number(e[r])}const r=new BigInt64Array(i);let n=0;for(let s=0;s<t;s++){const i=Number(e[s]);let o=e[s+t];o=Pp(o),r.fill(o,n,n+i),n+=i}return r}(e,t.runs,t.numRleValues);break;case sp.NONE:r=function(e){const t=new BigInt64Array(e.length);for(let i=0;i<e.length;i++)t[i]=Pp(e[i]);return t}(e);break;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}return i?Gp(r,i,0n):r}(bp(e,t,i.numValues),i,r)}(e,t,s,n):Kp(e,t,s,n);return new ef(i.name,o,r)}if(o===Bp.SEQUENCE){const r=Yp(e,t,s);return new tf(i.name,r[0],r[1],s.numRleValues)}const l=a?function(e,t,i){const r=bp(e,t,i.numValues);return 1===r.length?Pp(r[0]):function(e){return Pp(e[1])}(r)}(e,t,s):Jp(e,t,s);return new vf(i.name,l,r,a)}(t,i,s,a,n);case 7:return function(e,t,i,r){const n=Np(e,t),s=Cf(r)?r:void 0,o=function(e,t,i,r){const n=t.get(),s=n+i*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(n,s)).buffer,a=new Float32Array(o);return t.set(s),r?Gp(a,r,0):a}(e,t,n.numValues,s);return new xf(i.name,o,r)}(t,i,s,a);case 8:return function(e,t,i,r){const n=Np(e,t),s=Cf(r)?r:void 0,o=function(e,t,i,r){const n=t.get(),s=n+i*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(e.subarray(n,s)).buffer,a=new Float64Array(o);return t.set(s),r?Gp(a,r,0):a}(e,t,n.numValues,s);return new Qd(i.name,o,r)}(t,i,s,a);default:throw new Error(`The specified data type for the field is currently not supported: ${n}`)}}(r,e,t,n,i.scalarType,i):0===r?null:function(e,t,i,r){let n=null,s=null,o=null,a=null,l=!1;for(;!l;){const i=Np(e,t);switch(i.physicalStreamType){case kp.LENGTH:Fp.DICTIONARY===i.logicalStreamType.lengthType?n=qp(e,t,i):o=qp(e,t,i);break;case kp.DATA:Rp.SINGLE===i.logicalStreamType.dictionaryType||Rp.SHARED===i.logicalStreamType.dictionaryType?(s=e.subarray(t.get(),t.get()+i.byteLength),l=!0):a=e.subarray(t.get(),t.get()+i.byteLength),t.add(i.byteLength)}}const c=i.complexType.children,h=[];let u=0;for(const d of c){const l=vp(e,t,1)[0];if(0===l)continue;const c=d.name?`${i.name}${d.name}`:i.name;if(2!==l||"scalarField"!==d.type||9!==d.scalarField.physicalType)throw new Error("Currently only optional string fields are implemented for a struct.");const p=Np(e,t),f=bf(e,p.numValues,p.byteLength,t),m=Np(e,t),g=Zp(e,t,m,0,m.decompressedCount!==r?new Up(f,p.numValues):void 0);h[u++]=a?new Mf(c,g,n,s,o,a,new Up(f,p.numValues)):new If(c,g,n,s,new Up(f,p.numValues))}return h}(e,t,i,n)}function Cf(e){return e instanceof Up}function Af(e){switch(e){case 0:case 1:case 2:case 3:{const t={};t.nullable=!!(1&e),t.columnScope=0;const i={type:"logicalType",logicalType:0};return i.longID=!!(2&e),t.scalarType=i,t.type="scalarType",t}case 4:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=t,e}case 30:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=t,e}default:return function(e){let t;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}const i={};i.nullable=!!(1&e),i.columnScope=0;const r={type:"physicalType"};return r.physicalType=t,i.type="scalarType",i.scalarType=r,i}(e)}}function Df(e){return e>=10}function zf(e){return 30===e}function kf(e){if("scalarType"===e.type){const t=e.scalarType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}if("logicalType"===t.type)return!1}else if("complexType"===e.type){const t=e.complexType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}function Rf(e){return"complexType"===e.type&&"physicalType"===e.complexType?.type&&0===e.complexType.physicalType}const Lf=new TextDecoder;function Ff(e,t){const i=vp(e,t,1)[0];if(0===i)return"";const r=t.get(),n=e.subarray(r,r+i);return t.add(i),Lf.decode(n)}function Bf(e,t){const i=vp(e,t,1)[0]>>>0;if(i<10||i>30)throw new Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT)`);const r=Af(i);if(Df(i)&&(r.name=Ff(e,t)),zf(i)){const i=vp(e,t,1)[0]>>>0;r.complexType.children=new Array(i);for(let n=0;n<i;n++)r.complexType.children[n]=Bf(e,t)}return function(e){return{name:e.name,nullable:e.nullable,scalarField:e.scalarType,complexField:e.complexType,type:"scalarType"===e.type?"scalarField":"complexField"}}(r)}function Of(e,t){const i=vp(e,t,1)[0]>>>0,r=Af(i);if(!r)throw new Error(`Unsupported column type code ${i}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(Df(i)?r.name=Ff(e,t):i>=0&&i<=3?r.name="id":4===i&&(r.name="geometry"),zf(i)){const i=vp(e,t,1)[0]>>>0,n=r.complexType;n.children=new Array(i);for(let r=0;r<i;r++)n.children[r]=Bf(e,t)}return r}function Vf(e,t){const i={featureTables:[]},r={};r.name=Ff(e,t);const n=vp(e,t,1)[0]>>>0,s=vp(e,t,1)[0]>>>0;r.columns=new Array(s);for(let o=0;o<s;o++)r.columns[o]=Of(e,t);return i.featureTables.push(r),[i,n]}function jf(e,t,i,r,n,s,o=!1){const a=t.scalarType;if(!a||"logicalType"!==a.type||0!==a.logicalType)throw new Error(`ID column must be a logical ID scalar type: ${r}`);const l=a.longID?6:4,c="number"==typeof s?void 0:s,h=Qp(n,s,e,i,6===l?"int64":"int32");if(4===l)switch(h){case Bp.FLAT:{const t=Zp(e,i,n,0,c);return new Jd(r,t,s)}case Bp.SEQUENCE:{const t=Hp(e,i,n);return new tp(r,t[0],t[1],n.numRleValues)}case Bp.CONST:{const t=Xp(e,i,n);return new ip(r,t,s,!1)}}switch(h){case Bp.FLAT:{if(o){const t=function(e,t,i){const r=function(e,t,i){const r=new Float64Array(i);for(let n=0;n<i;n++)r[n]=Tp(e,t);return r}(e,t,i.numValues);return function(e,t){switch(t.logicalLevelTechnique1){case sp.DELTA:return t.logicalLevelTechnique2===sp.RLE&&(e=Cp(e,t.runs,t.numRleValues)),function(e){e[0]=Ip(e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i<t-4;i+=4){const t=e[i+1],r=e[i+2],n=e[i+3];e[i]=Ip(e[i])+e[i-1],e[i+1]=Ip(t)+e[i],e[i+2]=Ip(r)+e[i+1],e[i+3]=Ip(n)+e[i+2]}for(;i!==e.length;++i)e[i]=Ip(e[i])+e[i-1]}(e),e;case sp.RLE:return function(e,t){return Cp(e,t.runs,t.numRleValues)}(e,t);case sp.NONE:return e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}(r,i)}(e,i,n);return new Qd(r,t,s)}const t=Kp(e,i,n,c);return new ef(r,t,s)}case Bp.SEQUENCE:{const t=Yp(e,i,n);return new tf(r,t[0],t[1],n.numRleValues)}case Bp.CONST:{const t=Jp(e,i,n);return new vf(r,t,s,!1)}}throw new Error("Vector type not supported for id column.")}class Nf{constructor(e,t){var i;switch(this._featureData=e,this.properties=this._featureData.properties||{},null===(i=this._featureData.geometry)||void 0===i?void 0:i.type){case Op.POINT:case Op.MULTIPOINT:this.type=1;break;case Op.LINESTRING:case Op.MULTILINESTRING:this.type=2;break;case Op.POLYGON:case Op.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=t,this.id=Number(this._featureData.id)}loadGeometry(){const e=[];for(const t of this._featureData.geometry.coordinates){const r=[];for(const e of t)r.push(new i(e.x,e.y));e.push(r)}return e}}class Uf{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new Nf(this.features[e],this.extent)}}class Gf{constructor(e){this.layers={};const t=function(e,t,i=!0){const r=new np(0),n=[];for(;r.get()<e.length;){const t=vp(e,r,1)[0]>>>0,o=r.get()+t;if(o>e.length)throw new Error(`Block overruns tile: ${o} > ${e.length}`);if(1!=vp(e,r,1)[0]>>>0){r.set(o);continue}const[a,l]=Vf(e,r),c=a.featureTables[0];let h=null,u=null;const d=[];let p=0;for(const n of c.columns){const t=n.name;if("scalarType"===(s=n).type&&"logicalType"===s.scalarType?.type&&0===s.scalarType.logicalType){let s=null;if(n.nullable){const t=Np(e,r),i=r.get(),n=bf(e,t.numValues,t.byteLength,r);r.set(i+t.byteLength),s=new Up(n,t.numValues)}const o=Np(e,r);p=s?s.size():o.decompressedCount,h=jf(e,n,r,t,o,s??p,i)}else if(Rf(n)){const t=vp(e,r,1)[0];if(0===p){const t=r.get();p=Np(e,r).decompressedCount,r.set(t)}u=mf(e,t,r,p)}else{const t=kf(n)?vp(e,r,1)[0]:1;if(0===t)continue;const i=Ef(e,r,n,t,p);if(i)if(Array.isArray(i))for(const e of i)d.push(e);else d.push(i)}}const f=new rp(c.name,u,h,d,l);n.push(f),r.set(o)}var s;return n}(new Uint8Array(e));this.layers=t.reduce((e,t)=>Object.assign(Object.assign({},e),{[t.name]:new Uf(t)}),{})}}class $f{constructor(e,t){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=t,"id"in e&&("string"==typeof e.id?this.id=parseInt(e.id,10):"number"!=typeof e.id||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],t=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const r of t){const t=[];for(const e of r)t.push(new i(e[0],e[1]));e.push(t)}return e}}const Zf="_geojsonTileLayer";function qf(e,t,i=""){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);const r={jsonPrefix:i,keys:[],values:[],keycache:{},valuecache:{}};for(let o=0;o<e.length;o++)r.feature=e.feature(o),t.writeMessage(2,Wf,r);const n=r.keys;for(const o of n)t.writeStringField(3,o);const s=r.values;for(const o of s)t.writeMessage(4,Jf,o)}function Wf(e,t){if(!e.feature)return;const i=e.feature;void 0!==i.id&&t.writeVarintField(1,i.id),t.writeMessage(2,Xf,e),t.writeVarintField(3,i.type),t.writeMessage(4,Kf,i)}function Xf(e,t){for(const i in e.feature?.properties){let r=e.feature.properties[i],n=e.keycache[i];if(null==r)continue;void 0===n&&(e.keys.push(i),n=e.keys.length-1,e.keycache[i]=n),t.writeVarint(n),"string"!=typeof r&&"boolean"!=typeof r&&"number"!=typeof r&&(r=e.jsonPrefix+JSON.stringify(r));const s=typeof r+":"+r;let o=e.valuecache[s];void 0===o&&(e.values.push(r),o=e.values.length-1,e.valuecache[s]=o),t.writeVarint(o)}}function Hf(e,t){return(t<<3)+(7&e)}function Yf(e){return e<<1^e>>31}function Kf(e,t){const i=e.loadGeometry(),r=e.type;let n=0,s=0;for(const o of i){let i=1;1===r&&(i=o.length),t.writeVarint(Hf(1,i));const a=3===r?o.length-1:o.length;for(let e=0;e<a;e++){1===e&&1!==r&&t.writeVarint(Hf(2,a-1));const i=o[e].x-n,l=o[e].y-s;t.writeVarint(Yf(i)),t.writeVarint(Yf(l)),n+=i,s+=l}3===e.type&&t.writeVarint(Hf(7,1))}}function Jf(e,t){const i=typeof e;"string"===i?t.writeStringField(1,e):"boolean"===i?t.writeBooleanField(7,e):"number"===i&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e))}class Qf{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new hs(C,16,0),this.grid3D=new hs(C,16,0),this.featureIndexArray=new No,this.promoteId=t}insert(e,t,i,r,n,s){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n);const a=s?this.grid3D:this.grid;for(let l=0;l<t.length;l++){const e=t[l],i=[1/0,1/0,-1/0,-1/0];for(let t=0;t<e.length;t++){const r=e[t];i[0]=Math.min(i[0],r.x),i[1]=Math.min(i[1],r.y),i[2]=Math.max(i[2],r.x),i[3]=Math.max(i[3],r.y)}i[0]<C&&i[1]<C&&i[2]>=0&&i[3]>=0&&a.insert(o,i[0],i[1],i[2],i[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Bc(new ku(this.rawTileData)).layers:new Gf(this.rawTileData).layers,this.sourceLayerCoder=new Xd(this.vtLayers?Object.keys(this.vtLayers).sort():[Zf])),this.vtLayers}query(e,t,r,n){this.loadVTLayers();const s=e.params,o=C/e.tileSize/e.scale,a=pn(s.filter,s.globalState),l=e.queryGeometry,c=e.queryPadding*o,h=Wd.fromPoints(l),u=this.grid.query(h.minX-c,h.minY-c,h.maxX+c,h.maxY+c),d=Wd.fromPoints(e.cameraQueryGeometry).expandBy(c),p=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,r,n,s)=>function(e,t,r,n,s){for(const i of e)if(t<=i.x&&r<=i.y&&n>=i.x&&s>=i.y)return!0;const o=[new i(t,r),new i(t,s),new i(n,s),new i(n,r)];if(e.length>2)for(const i of o)if(el(e,i))return!0;for(let i=0;i<e.length-1;i++)if(tl(e[i],e[i+1],o))return!0;return!1}(e.cameraQueryGeometry,t-c,r-c,n+c,s+c));for(const i of p)u.push(i);u.sort(tm);const f={};let m;for(let i=0;i<u.length;i++){const c=u[i];if(c===m)continue;m=c;const h=this.featureIndexArray.get(c);let d=null;this.loadMatchingFeature(f,h.bucketIndex,h.sourceLayerIndex,h.featureIndex,a,s.layers,s.availableImages,t,r,n,(t,i,r)=>(d||(d=ja(t)),i.queryIntersectsFeature({queryGeometry:l,feature:t,featureState:r,geometry:d,zoom:this.z,transform:e.transform,pixelsToTileUnits:o,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return f}loadMatchingFeature(e,t,i,r,n,s,o,a,l,c,h){const u=this.bucketLayerIDs[t];if(s&&!u.some(e=>s.has(e)))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(r);if(n.needGeometry){const e=Na(p,!0);if(!n.filter(new ks(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new ks(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(let m=0;m<u.length;m++){const t=u[m];if(s&&!s.has(t))continue;const i=a[t];if(!i)continue;let n={};f&&c&&(n=c.getState(i.sourceLayer||Zf,f));const d=O({},l[t]);d.paint=em(d.paint,i.paint,p,n,o),d.layout=em(d.layout,i.layout,p,n,o);const g=!h||h(p,i,n);if(!g)continue;const _=new Hd(p,this.z,this.x,this.y,f);_.layer=d;let y=e[t];void 0===y&&(y=e[t]=[]),y.push({featureIndex:r,feature:_,intersectionZ:g})}}lookupSymbolFeatures(e,t,i,r,n,s,o,a){const l={};this.loadVTLayers();const c=pn(n.filterSpec,n.globalState);for(const h of e)this.loadMatchingFeature(l,i,r,h,c,s,o,a,t);return l}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return!0;return!1}getId(e,t){var i;let r=e.id;return this.promoteId&&(r=e.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[t]],"boolean"==typeof r&&(r=Number(r)),void 0===r&&(null===(i=e.properties)||void 0===i?void 0:i.cluster)&&this.promoteId&&(r=Number(e.properties.cluster_id))),r}}function em(e,t,i,r,n){return j(e,(e,s)=>{const o=t instanceof Gs?t.get(s):null;return o&&o.evaluate?o.evaluate(i,r,n):o})}function tm(e,t){return t-e}function im(e,t,r,n,s){const o=[];for(let a=0;a<e.length;a++){const l=e[a];let c;for(let e=0;e<l.length-1;e++){let a=l[e],h=l[e+1];a.x<t&&h.x<t||(a.x<t?a=new i(t,a.y+(t-a.x)/(h.x-a.x)*(h.y-a.y))._round():h.x<t&&(h=new i(t,a.y+(t-a.x)/(h.x-a.x)*(h.y-a.y))._round()),a.y<r&&h.y<r||(a.y<r?a=new i(a.x+(r-a.y)/(h.y-a.y)*(h.x-a.x),r)._round():h.y<r&&(h=new i(a.x+(r-a.y)/(h.y-a.y)*(h.x-a.x),r)._round()),a.x>=n&&h.x>=n||(a.x>=n?a=new i(n,a.y+(n-a.x)/(h.x-a.x)*(h.y-a.y))._round():h.x>=n&&(h=new i(n,a.y+(n-a.x)/(h.x-a.x)*(h.y-a.y))._round()),a.y>=s&&h.y>=s||(a.y>=s?a=new i(a.x+(s-a.y)/(h.y-a.y)*(h.x-a.x),s)._round():h.y>=s&&(h=new i(a.x+(s-a.y)/(h.y-a.y)*(h.x-a.x),s)._round()),c&&a.equals(c[c.length-1])||(c=[a],o.push(c)),c.push(h)))))}}return o}function rm(e,t,i,r,n){switch(t){case 1:return function(e,t,i,r){const n=[];for(const s of e)for(const e of s){const s=0===r?e.x:e.y;s>=t&&s<=i&&n.push([e])}return n}(e,i,r,n);case 2:return sm(e,i,r,n,!1);case 3:return sm(e,i,r,n,!0)}return[]}function nm(e,t,r,n,s){const o=0===n?om:am;let a=[];const l=[];for(let i=0;i<e.length-1;i++){const c=e[i],h=e[i+1],u=0===n?c.x:c.y,d=0===n?h.x:h.y;let p=!1;u<t?d>t&&a.push(o(c,h,t)):u>r?d<r&&a.push(o(c,h,r)):a.push(c),d<t&&u>=t&&(a.push(o(c,h,t)),p=!0),d>r&&u<=r&&(a.push(o(c,h,r)),p=!0),!s&&p&&(l.push(a),a=[])}const c=e.length-1,h=0===n?e[c].x:e[c].y;return h>=t&&h<=r&&a.push(e[c]),s&&a.length>0&&!a[0].equals(a[a.length-1])&&a.push(new i(a[0].x,a[0].y)),a.length>0&&l.push(a),l}function sm(e,t,i,r,n){const s=[];for(const o of e){const e=nm(o,t,i,r,n);e.length>0&&s.push(...e)}return s}function om(e,t,r){return new i(r,e.y+(r-e.x)/(t.x-e.x)*(t.y-e.y))}function am(e,t,r){return new i(e.x+(r-e.y)/(t.y-e.y)*(t.x-e.x),r)}ds("FeatureIndex",Qf,{omit:["rawTileData","sourceLayerCoder"]});class lm extends i{constructor(e,t,i,r){super(e,t),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new lm(this.x,this.y,this.angle,this.segment)}}function cm(e,t,i,r,n){if(void 0===t.segment||0===i)return!0;let s=t,o=t.segment+1,a=0;for(;a>-i/2;){if(o--,o<0)return!1;a-=e[o].dist(s),s=e[o]}a+=e[o].dist(e[o+1]),o++;const l=[];let c=0;for(;a<i/2;){const t=e[o],i=e[o+1];if(!i)return!1;let s=e[o-1].angleTo(t)-t.angleTo(i);for(s=Math.abs((s+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:s}),c+=s;a-l[0].distance>r;)c-=l.shift().angleDelta;if(c>n)return!1;o++,a+=t.dist(i)}return!0}function hm(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function um(e,t,i){return e?.6*t*i:0}function dm(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function pm(e,t,i,r,n,s){const o=um(i,n,s),a=dm(i,r)*s;let l=0;const c=hm(e)/2;for(let h=0;h<e.length-1;h++){const i=e[h],r=e[h+1],n=i.dist(r);if(l+n>c){const s=(c-l)/n,u=mi.number(i.x,r.x,s),d=mi.number(i.y,r.y,s),p=new lm(u,d,r.angleTo(i),h);return p._round(),!o||cm(e,p,a,o,t)?p:void 0}l+=n}}function fm(e,t,i,r,n,s,o,a,l){const c=um(r,s,o),h=dm(r,n),u=h*o,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-u<t/4&&(t=u+t/4),mm(e,d?t/2*a%t:(h/2+2*s)*o*a%t,t,c,i,u,d,!1,l)}function mm(e,t,i,r,n,s,o,a,l){const c=s/2,h=hm(e);let u=0,d=t-i,p=[];for(let f=0;f<e.length-1;f++){const t=e[f],o=e[f+1],a=t.dist(o),m=o.angleTo(t);for(;d+i<u+a;){d+=i;const g=(d-u)/a,_=mi.number(t.x,o.x,g),y=mi.number(t.y,o.y,g);if(_>=0&&_<l&&y>=0&&y<l&&d-c>=0&&d+c<=h){const t=new lm(_,y,m,f);t._round(),r&&!cm(e,t,s,r,n)||p.push(t)}}u+=a}return a||p.length||o||(p=mm(e,u/2,i,r,n,s,o,!0,l)),p}function gm(e,t,r,n){const s=[],o=e.image,a=o.pixelRatio,l=o.paddedRect.w-2,c=o.paddedRect.h-2;let h={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const u=o.stretchX||[[0,l]],d=o.stretchY||[[0,c]],p=(e,t)=>e+t[1]-t[0],f=u.reduce(p,0),m=d.reduce(p,0),g=l-f,_=c-m;let y=0,x=f,v=0,b=m,w=0,T=g,S=0,P=_;if(o.content&&n){const t=o.content,i=t[2]-t[0],r=t[3]-t[1];(o.textFitWidth||o.textFitHeight)&&(h=ad(e)),y=_m(u,0,t[0]),v=_m(d,0,t[1]),x=_m(u,t[0],t[2]),b=_m(d,t[1],t[3]),w=t[0]-y,S=t[1]-v,T=i-x,P=r-b}const I=h.x1,M=h.y1,E=h.x2-I,C=h.y2-M,A=(e,n,s,l)=>{const c=xm(e.stretch-y,x,E,I),h=vm(e.fixed-w,T,e.stretch,f),u=xm(n.stretch-v,b,C,M),d=vm(n.fixed-S,P,n.stretch,m),p=xm(s.stretch-y,x,E,I),g=vm(s.fixed-w,T,s.stretch,f),_=xm(l.stretch-v,b,C,M),A=vm(l.fixed-S,P,l.stretch,m),D=new i(c,u),z=new i(p,u),k=new i(p,_),R=new i(c,_),L=new i(h/a,d/a),F=new i(g/a,A/a),B=t*Math.PI/180;if(B){const e=Math.sin(B),t=Math.cos(B),i=[t,-e,e,t];D._matMult(i),z._matMult(i),R._matMult(i),k._matMult(i)}const O=e.stretch+e.fixed,V=n.stretch+n.fixed;return{tl:D,tr:z,bl:R,br:k,tex:{x:o.paddedRect.x+1+O,y:o.paddedRect.y+1+V,w:s.stretch+s.fixed-O,h:l.stretch+l.fixed-V},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:F,minFontScaleX:T/a/E,minFontScaleY:P/a/C,isSDF:r}};if(n&&(o.stretchX||o.stretchY)){const e=ym(u,g,f),t=ym(d,_,m);for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++)s.push(A(r,t[e],n,t[e+1]))}}else s.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return s}function _m(e,t,i){let r=0;for(const n of e)r+=Math.max(t,Math.min(i,n[1]))-Math.max(t,Math.min(i,n[0]));return r}function ym(e,t,i){const r=[{fixed:-1,stretch:0}];for(const[n,s]of e){const e=r[r.length-1];r.push({fixed:n-e.stretch,stretch:e.stretch}),r.push({fixed:n-e.stretch,stretch:e.stretch+(s-n)})}return r.push({fixed:t+1,stretch:i}),r}function xm(e,t,i,r){return e/t*i+r}function vm(e,t,i,r){return e-t*i/r}ds("Anchor",lm);class bm{constructor(e,t,r,n,s,o,a,l,c,h){var u;if(this.boxStartIndex=e.length,c){let e=o.top,t=o.bottom;const i=o.collisionPadding;i&&(e-=i[1],t+=i[3]);let r=t-e;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{const c=(null===(u=o.image)||void 0===u?void 0:u.content)&&(o.image.textFitWidth||o.image.textFitHeight)?ad(o):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom};c.y1=c.y1*a-l[0],c.y2=c.y2*a+l[2],c.x1=c.x1*a-l[3],c.x2=c.x2*a+l[1];const d=o.collisionPadding;if(d&&(c.x1-=d[0]*a,c.y1-=d[1]*a,c.x2+=d[2]*a,c.y2+=d[3]*a),h){const e=new i(c.x1,c.y1),t=new i(c.x2,c.y1),r=new i(c.x1,c.y2),n=new i(c.x2,c.y2),s=h*Math.PI/180;e._rotate(s),t._rotate(s),r._rotate(s),n._rotate(s),c.x1=Math.min(e.x,t.x,r.x,n.x),c.x2=Math.max(e.x,t.x,r.x,n.x),c.y1=Math.min(e.y,t.y,r.y,n.y),c.y2=Math.max(e.y,t.y,r.y,n.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,r,n,s)}this.boxEndIndex=e.length}}class wm{constructor(e=[],t=(e,t)=>e<t?-1:e>t?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}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:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,s=t[n];if(i(r,s)>=0)break;t[e]=s,e=n}t[e]=r}_down(e){const{data:t,compare:i}=this,r=this.length>>1,n=t[e];for(;e<r;){let r=1+(e<<1);const s=r+1;if(s<this.length&&i(t[s],t[r])<0&&(r=s),i(t[r],n)>=0)break;t[e]=t[r],e=r}t[e]=n}}function Tm(e,t=1,r=!1){const n=Wd.fromPoints(e[0]),s=Math.min(n.width(),n.height());let o=s/2;const a=new wm([],Sm),{minX:l,minY:c,maxX:h,maxY:u}=n;if(0===s)return new i(l,c);for(let i=l;i<h;i+=s)for(let t=c;t<u;t+=s)a.push(new Pm(i+o,t+o,o,e));let d=function(e){let t=0,i=0,r=0;const n=e[0];for(let s=0,o=n.length,a=o-1;s<o;a=s++){const e=n[s],o=n[a],l=e.x*o.y-o.x*e.y;i+=(e.x+o.x)*l,r+=(e.y+o.y)*l,t+=3*l}return new Pm(i/t,r/t,0,e)}(e),p=a.length;for(;a.length;){const i=a.pop();(i.d>d.d||!d.d)&&(d=i,r&&console.log("found best %d after %d probes",Math.round(1e4*i.d)/1e4,p)),i.max-d.d<=t||(o=i.h/2,a.push(new Pm(i.p.x-o,i.p.y-o,o,e)),a.push(new Pm(i.p.x+o,i.p.y-o,o,e)),a.push(new Pm(i.p.x-o,i.p.y+o,o,e)),a.push(new Pm(i.p.x+o,i.p.y+o,o,e)),p+=4)}return r&&(console.log(`num probes: ${p}`),console.log(`best distance: ${d.d}`)),d.p}function Sm(e,t){return t.max-e.max}function Pm(e,t,r,n){this.p=new i(e,t),this.h=r,this.d=function(e,t){let i=!1,r=1/0;for(let n=0;n<t.length;n++){const s=t[n];for(let t=0,n=s.length,o=n-1;t<n;o=t++){const n=s[t],a=s[o];n.y>e.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,Ja(e,n,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}var Im;e.aM=void 0,(Im=e.aM||(e.aM={}))[Im.center=1]="center",Im[Im.left=2]="left",Im[Im.right=3]="right",Im[Im.top=4]="top",Im[Im.bottom=5]="bottom",Im[Im["top-left"]=6]="top-left",Im[Im["top-right"]=7]="top-right",Im[Im["bottom-left"]=8]="bottom-left",Im[Im["bottom-right"]=9]="bottom-right";const Mm=Number.POSITIVE_INFINITY;function Em(e,t){return t[1]!==Mm?function(e,t,i){let r=0,n=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}return[r,n]}(e,t[0],t[1]):function(e,t){let i=0,r=0;t<0&&(t=0);const n=t/Math.SQRT2;switch(e){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=t;break;case"right":i=-t}return[i,r]}(e,t[0])}function Cm(e,t,i){var r;const n=e.layout,s=null===(r=n.get("text-variable-anchor-offset"))||void 0===r?void 0:r.evaluate(t,{},i);if(s){const e=s.values,t=[];for(let i=0;i<e.length;i+=2){const r=t[i]=e[i],n=e[i+1].map(e=>e*vu);r.startsWith("top")?n[1]-=7:r.startsWith("bottom")&&(n[1]+=7),t[i+1]=n}return new Bt(t)}const o=n.get("text-variable-anchor");if(o){let r;r=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[n.get("text-radial-offset").evaluate(t,{},i)*vu,Mm]:n.get("text-offset").evaluate(t,{},i).map(e=>e*vu);const s=[];for(const e of o)s.push(e,Em(e,r));return new Bt(s)}return null}function Am(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 Dm(t,i,r,n,s,o,a,l,c,h,u,d){let p=o.textMaxSize.evaluate(i,{});void 0===p&&(p=a);const f=t.layers[0].layout,m=f.get("icon-offset").evaluate(i,{},u),g=km(r.horizontal),_=a/24,y=t.tilePixelRatio*_,x=t.tilePixelRatio*p/24,v=t.tilePixelRatio*l,b=t.tilePixelRatio*f.get("symbol-spacing"),w=f.get("text-padding")*t.tilePixelRatio,T=function(e,t,i,r=1){const n=e.get("icon-padding").evaluate(t,{},i),s=n&&n.values;return[s[0]*r,s[1]*r,s[2]*r,s[3]*r]}(f,i,u,t.tilePixelRatio),S=f.get("text-max-angle")/180*Math.PI,P="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),I="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),M=f.get("symbol-placement"),E=b/2,A=f.get("icon-text-fit");let D;n&&"none"!==A&&(t.allowVerticalPlacement&&r.vertical&&(D=ld(n,r.vertical,A,f.get("icon-text-fit-padding"),m,_)),g&&(n=ld(n,g,A,f.get("icon-text-fit-padding"),m,_)));const z=u?d.line.getGranularityForZoomLevel(u.z):1,k=(l,d)=>{d.x<0||d.x>=C||d.y<0||d.y>=C||function(t,i,r,n,s,o,a,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,S,P){const I=t.addToLineVertexArray(i,r);let M,E,C,A,D=0,z=0,k=0,R=0,L=-1,F=-1;const B={};let O=ga("");if(t.allowVerticalPlacement&&n.vertical){const e=l.layout.get("text-rotate").evaluate(b,{},S)+90;C=new bm(c,i,h,u,d,n.vertical,p,f,m,e),a&&(A=new bm(c,i,h,u,d,a,_,y,m,e))}if(s){const r=l.layout.get("icon-rotate").evaluate(b,{}),n="none"!==l.layout.get("icon-text-fit"),o=gm(s,r,T,n),p=a?gm(a,r,T,n):void 0;E=new bm(c,i,h,u,d,s,_,y,!1,r),D=4*o.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[cd*l.layout.get("icon-size").evaluate(b,{})],m[0]>hd&&$(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[cd*w.compositeIconSizes[0].evaluate(b,{},S),cd*w.compositeIconSizes[1].evaluate(b,{},S)],(m[0]>hd||m[1]>hd)&&$(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,o,m,v,x,b,e.aw.none,i,I.lineStartIndex,I.lineLength,-1,S),L=t.icon.placedSymbolArray.length-1,p&&(z=4*p.length,t.addSymbols(t.icon,p,m,v,x,b,e.aw.vertical,i,I.lineStartIndex,I.lineLength,-1,S),F=t.icon.placedSymbolArray.length-1)}const V=Object.keys(n.horizontal);for(const $ of V){const r=n.horizontal[$];if(!M){O=ga(r.text);const e=l.layout.get("text-rotate").evaluate(b,{},S);M=new bm(c,i,h,u,d,r,p,f,m,e)}const s=1===r.positionedLines.length;if(k+=zm(t,i,r,o,l,m,b,g,I,n.vertical?e.aw.horizontal:e.aw.horizontalOnly,s?V:[$],B,L,w,S),s)break}n.vertical&&(R+=zm(t,i,n.vertical,o,l,m,b,g,I,e.aw.vertical,["vertical"],B,F,w,S));const j=M?M.boxStartIndex:t.collisionBoxArray.length,N=M?M.boxEndIndex:t.collisionBoxArray.length,U=C?C.boxStartIndex:t.collisionBoxArray.length,G=C?C.boxEndIndex:t.collisionBoxArray.length,Z=E?E.boxStartIndex:t.collisionBoxArray.length,q=E?E.boxEndIndex:t.collisionBoxArray.length,W=A?A.boxStartIndex:t.collisionBoxArray.length,X=A?A.boxEndIndex:t.collisionBoxArray.length;let H=-1;const Y=(e,t)=>e&&e.circleDiameter?Math.max(e.circleDiameter,t):t;H=Y(M,H),H=Y(C,H),H=Y(E,H),H=Y(A,H);const K=H>-1?1:0;K&&(H*=P/vu),t.glyphOffsetArray.length>=xd.MAX_GLYPHS&&$("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,b.sortKey);const J=Cm(l,b,S),[Q,ee]=function(t,i){const r=t.length,n=null==i?void 0:i.values;if((null==n?void 0:n.length)>0)for(let s=0;s<n.length;s+=2){const i=n[s+1];t.emplaceBack(e.aM[n[s]],i[0],i[1])}return[r,t.length]}(t.textAnchorOffsets,J);t.symbolInstances.emplaceBack(i.x,i.y,B.right>=0?B.right:-1,B.center>=0?B.center:-1,B.left>=0?B.left:-1,B.vertical||-1,L,F,O,j,N,U,G,Z,q,W,X,h,k,R,D,z,K,0,p,H,Q,ee)}(t,d,l,r,n,s,D,t.layers[0],t.collisionBoxArray,i.index,i.sourceLayerIndex,t.index,y,[w,w,w,w],P,c,v,T,I,m,i,o,h,u,a)};if("line"===M)for(const e of im(i.geometry,0,0,C,C)){const i=xc(e,z),s=fm(i,b,S,r.vertical||g,n,24,x,t.overscaling,C);for(const e of s)g&&Rm(t,g.text,E,e)||k(i,e)}else if("line-center"===M){for(const e of i.geometry)if(e.length>1){const t=xc(e,z),i=pm(t,S,r.vertical||g,n,24,x);i&&k(t,i)}}else if("Polygon"===i.type)for(const e of er(i.geometry,0)){const t=Tm(e,16);k(xc(e[0],z,!0),new lm(t.x,t.y,0))}else if("LineString"===i.type)for(const e of i.geometry){const t=xc(e,z);k(t,new lm(t[0].x,t[0].y,0))}else if("Point"===i.type)for(const e of i.geometry)for(const t of e)k([t],new lm(t.x,t.y,0))}function zm(e,t,r,n,s,o,a,l,c,h,u,d,p,f,m){const g=function(e,t,r,n,s,o,a,l){const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=[];for(const u of t.positionedLines)for(const e of u.positionedGlyphs){if(!e.rect)continue;const n=e.rect||{};let o=4,d=!0,p=1,f=0;const m=(s||l)&&e.vertical,g=e.metrics.advance*e.scale/2;if(l&&t.verticalizable&&(f=u.lineOffset/2-(e.imageName?-(vu-e.metrics.width*e.scale)/2:(e.scale-1)*vu)),e.imageName){const t=a[e.imageName];d=t.sdf,p=t.pixelRatio,o=1/p}const _=s?[e.x+g,e.y]:[0,0];let y=s?[0,0]:[e.x+g+r[0],e.y+r[1]-f],x=[0,0];m&&(x=y,y=[0,0]);const v=e.metrics.isDoubleResolution?2:1,b=(e.metrics.left-o)*e.scale-g+y[0],w=(-e.metrics.top-o)*e.scale+y[1],T=b+n.w/v*e.scale/p,S=w+n.h/v*e.scale/p,P=new i(b,w),I=new i(T,w),M=new i(b,S),E=new i(T,S);if(m){const t=new i(-g,g- -17),r=-Math.PI/2,n=12-g,s=new i(22-n,-(e.imageName?n:0)),o=new i(...x);P._rotateAround(r,t)._add(s)._add(o),I._rotateAround(r,t)._add(s)._add(o),M._rotateAround(r,t)._add(s)._add(o),E._rotateAround(r,t)._add(s)._add(o)}if(c){const e=Math.sin(c),t=Math.cos(c),i=[t,-e,e,t];P._matMult(i),I._matMult(i),M._matMult(i),E._matMult(i)}const C=new i(0,0),A=new i(0,0);h.push({tl:P,tr:I,bl:M,br:E,tex:n,writingMode:t.writingMode,glyphOffset:_,sectionIndex:e.sectionIndex,isSDF:d,pixelOffsetTL:C,pixelOffsetBR:A,minFontScaleX:0,minFontScaleY:0})}return h}(0,r,l,s,o,a,n,e.allowVerticalPlacement),_=e.textSizeData;let y=null;"source"===_.kind?(y=[cd*s.layout.get("text-size").evaluate(a,{})],y[0]>hd&&$(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===_.kind&&(y=[cd*f.compositeTextSizes[0].evaluate(a,{},m),cd*f.compositeTextSizes[1].evaluate(a,{},m)],(y[0]>hd||y[1]>hd)&&$(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,y,l,o,a,h,t,c.lineStartIndex,c.lineLength,p,m);for(const i of u)d[i]=e.text.placedSymbolArray.length-1;return 4*g.length}function km(e){for(const t in e)return e[t];return null}function Rm(e,t,i,r){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])<i)return!0}else n[t]=[];return n[t].push(r),!1}var Lm;e.cF=void 0,(Lm=e.cF||(e.cF={})).create="create",Lm.load="load",Lm.fullLoad="fullLoad";let Fm=null,Bm=[];const Om=1e3/60,Vm="loadTime",jm="fullLoadTime",Nm={mark(e){performance.mark(e)},recordStartOfFrameAt(e){null!=Fm&&Bm.push(e-Fm),Fm=e},resetRuntimeMetrics(){Fm=null,Bm=[]},clearInitializationMetrics(){performance.clearMeasures(Vm),performance.clearMeasures(jm);for(const t in e.cF)performance.clearMarks(e.cF[t])},remove(){this.resetRuntimeMetrics(),this.clearInitializationMetrics()},getPerformanceMetrics(){performance.measure(Vm,e.cF.create,e.cF.load),performance.measure(jm,e.cF.create,e.cF.fullLoad);const t=performance.getEntriesByName(Vm)[0].duration,i=performance.getEntriesByName(jm)[0].duration,r=Bm.length;return{loadTimeMs:t,fullLoadTimeMs:i,averageFramesPerSecond:1/(Bm.reduce((e,t)=>e+t,0)/r/1e3),virtualDroppedFramesCount:Bm.filter(e=>e>Om).reduce((e,t)=>e+(t-Om)/Om,0),totalFramesCount:r}}};e.$=h,e.A=p,e.B=cs,e.C=ns,e.D=$s,e.E=ye,e.F=function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(i),y:e*Math.sin(t)*Math.sin(i),z:e*Math.cos(i)}},e.G=mi,e.H=ks,e.I=Hu,e.J=os,e.K=function(e){if(null==W){const t=e.navigator?e.navigator.userAgent:null;W=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return W},e.L=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Cd(()=>this.process()),this.subscription=Q(this.target,"message",e=>this.receive(e),!1),this.globalScope=q(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,r)=>{const n=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=t?Q(t.signal,"abort",()=>{null==s||s.unsubscribe(),delete this.resolveRejects[n];const t={id:n,type:"<cancel>",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)},Ad):null;this.resolveRejects[n]={resolve:e=>{null==s||s.unsubscribe(),i(e)},reject:e=>{null==s||s.unsubscribe(),r(e)}};const o=[],a=Object.assign(Object.assign({},e),{id:n,sourceMapId:this.mapId,origin:location.origin,data:gs(e.data,o)});this.target.postMessage(a,{transfer:o})})}receive(e){const t=e.data,i=t.id,r=["file://","resource://android","null"],n=[t.origin,location.origin],s=t.origin===location.origin,o=n.some(e=>r.includes(e));if((s||o)&&(!t.targetMapId||this.mapId===t.targetMapId)){if("<cancel>"===t.type){delete this.tasks[i];const e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if(q(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,i){return t(this,void 0,void 0,function*(){if("<response>"===i.type){const t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;return void(i.error?t.reject(_s(i.error)):t.resolve(_s(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const t=_s(i.data),r=new AbortController;this.abortControllers[e]=r;try{const n=yield this.messageHandlers[i.type](i.sourceMapId,t,r);this.completeTask(e,null,n)}catch(t){this.completeTask(e,t)}})}completeTask(e,t,i){const r=[];delete this.abortControllers[e];const n={id:e,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?gs(t):null,data:gs(i,r)};this.target.postMessage(n,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.M=ce,e.N=function(){var e=new p(16);return p!=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},e.O=function(e,t,i){var r,n,s,o,a,l,c,h,u,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(n=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=s,e[3]=o,e[4]=a,e[5]=l,e[6]=c,e[7]=h,e[8]=u,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+a*g+u*_+t[12],e[13]=n*m+l*g+d*_+t[13],e[14]=s*m+c*g+p*_+t[14],e[15]=o*m+h*g+f*_+t[15]),e},e.P=i,e.Q=function(e,t,i){var r=i[0],n=i[1],s=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,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},e.R=Tl,e.S=function(e,t,i){var r=t[0],n=t[1],s=t[2],o=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*a+b*u+w*m,e[1]=x*n+v*l+b*d+w*g,e[2]=x*s+v*c+b*p+w*_,e[3]=x*o+v*h+b*f+w*y,e[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*u+(w=i[7])*m,e[5]=x*n+v*l+b*d+w*g,e[6]=x*s+v*c+b*p+w*_,e[7]=x*o+v*h+b*f+w*y,e[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*u+(w=i[11])*m,e[9]=x*n+v*l+b*d+w*g,e[10]=x*s+v*c+b*p+w*_,e[11]=x*o+v*h+b*f+w*y,e[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*u+(w=i[15])*m,e[13]=x*n+v*l+b*d+w*g,e[14]=x*s+v*c+b*p+w*_,e[15]=x*o+v*h+b*f+w*y,e},e.T=Rl,e.U=function(e,t){const i={};for(let r=0;r<t.length;r++){const n=t[r];n in e&&(i[n]=e[n])}return i},e.V=zd,e.W=B,e.X=Fd,e.Y=Ld,e.Z=oe,e._=t,e.a=se,e.a$=function(e){var t=new p(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.a0=u,e.a1=Y,e.a2=Zd,e.a3=Od,e.a4=Vd,e.a5=C,e.a6=Nd,e.a7=Wd,e.a8=25,e.a9=Gd,e.aA=function(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)},e.aB=function(e){return e[0]=0,e[1]=0,e},e.aC=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},e.aD=md,e.aE=S,e.aF=function(e,t,r,n){const s=t.y-e.y,o=t.x-e.x,a=n.y-r.y,l=n.x-r.x,c=a*o-l*s;if(0===c)return null;const h=(l*(e.y-r.y)-a*(e.x-r.x))/c;return new i(e.x+h*o,e.y+h*s)},e.aG=im,e.aH=Za,e.aI=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const s of e)t=Math.min(t,s.x),i=Math.min(i,s.y),r=Math.max(r,s.x),n=Math.max(n,s.y);return[t,i,r,n]},e.aJ=vu,e.aK=A,e.aL=function(e,t,i,r,n=!1){if(!i[0]&&!i[1])return[0,0];const s=n?"map"===r?-e.bearingInRadians:0:"viewport"===r?e.bearingInRadians:0;if(s){const e=Math.sin(s),t=Math.cos(s);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}return[n?i[0]:A(t,i[0],e.zoom),n?i[1]:A(t,i[1],e.zoom)]},e.aN=dd,e.aO=Am,e.aP=Qu,e.aQ=e=>"symbol"===e.type,e.aR=Kc,e.aS=ro,e.aT=fc,e.aU=Uo,e.aV=sa,e.aW=ta,e.aX=te,e.aY=jd,e.aZ=v,e.a_=x,e.aa=e=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const r of e){const e=window.document.createElement("source");pe(r)||(t.crossOrigin="Anonymous"),e.src=r,t.appendChild(e)}})},e.ab=De,e.ac=function(){return V++},e.ad=Do,e.ae=xd,e.af=Zf,e.ag=pn,e.ah=Na,e.ai=Hd,e.aj=function(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,r,n)=>{const s=r||n;return t[i]=!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},e.ak=F,e.al=85.051129,e.am=ee,e.an=function(e){return Math.pow(2,e)},e.ao=m,e.ap=Bd,e.aq=function(e){return Math.log(e)/Math.LN2},e.ar=function(e){var t=e[0],i=e[1];return t*t+i*i},e.as=function(e){if(!e.length)return new Set;const t=Math.max(...e.map(e=>e.canonical.z));let i=1/0,r=-1/0,n=1/0,s=-1/0;const o=[];for(const l of e){const{x:e,y:a,z:c}=l.canonical,h=Math.pow(2,t-c),u=e*h,d=a*h;o.push({id:l,x:u,y:d}),u<i&&(i=u),u>r&&(r=u),d<n&&(n=d),d>s&&(s=d)}const a=new Set;for(const l of o)l.x!==i&&l.x!==r&&l.y!==n&&l.y!==s||a.add(l.id);return a},e.at=function(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x},e.au=class{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 r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout(()=>{this.remove(e,n)},i)),this.data[r].push(n),this.order.push(r),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,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.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 r of this.data[i])e(r.value)||t.push(r);for(const i of t)this.remove(i.value.tileID,i)}},e.av=function(e,t){let i=0,r=0;if("constant"===e.kind)r=e.layoutSize;else if("source"!==e.kind){const{interpolationType:n,minZoom:s,maxZoom:o}=e,a=n?F(pi.interpolationFactor(n,t,s,o),0,1):0;"camera"===e.kind?r=mi.number(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:r}},e.ax=function(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===e.kind?r/cd:"composite"===e.kind?mi.number(r/cd,n/cd,i):t},e.ay=function(e,t){var i=t[0],r=t[1],n=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],y=i*a-r*o,x=i*l-n*o,v=i*c-s*o,b=r*l-n*a,w=r*c-s*a,T=n*c-s*l,S=h*m-u*f,P=h*g-d*f,I=h*_-p*f,M=u*g-d*m,E=u*_-p*m,C=d*_-p*g,A=y*C-x*E+v*M+b*I-w*P+T*S;return A?(e[0]=(a*C-l*E+c*M)*(A=1/A),e[1]=(n*E-r*C-s*M)*A,e[2]=(m*T-g*w+_*b)*A,e[3]=(d*w-u*T-p*b)*A,e[4]=(l*I-o*C-c*P)*A,e[5]=(i*C-n*I+s*P)*A,e[6]=(g*v-f*T-_*x)*A,e[7]=(h*T-d*v+p*x)*A,e[8]=(o*E-a*I+c*S)*A,e[9]=(r*I-i*E-s*S)*A,e[10]=(f*w-m*v+_*y)*A,e[11]=(u*v-h*w-p*y)*A,e[12]=(a*P-o*M-l*S)*A,e[13]=(i*M-r*P+n*S)*A,e[14]=(m*x-f*b-g*y)*A,e[15]=(h*b-u*x+d*y)*A,e):null},e.az=M,e.b=X,e.b$=Ta,e.b0=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},e.b1=function(e,t){var i=t[0],r=t[1],n=t[2],s=i*i+r*r+n*n;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e},e.b2=b,e.b3=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.b4=function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e},e.b5=_,e.b6=function(e,t,i){const r=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===r?null:(-(e[0]*i[0]+e[1]*i[1]+e[2]*i[2])-i[3])/r},e.b7=T,e.b8=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e},e.b9=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]},e.bA=function(e,t,i){var r=i[0],n=i[1],s=i[2],o=i[3],a=t[0],l=t[1],c=t[2],h=n*c-s*l,u=s*a-r*c,d=r*l-n*a;return e[0]=a+o*(h+=h)+n*(d+=d)-s*(u+=u),e[1]=l+o*u+s*h-r*d,e[2]=c+o*d+r*u-n*h,e},e.bB=function(e,t,i){const r=(n=[e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((h=n[8])*(o=n[4])-(a=n[5])*(c=n[7]))+n[1]*(-h*(s=n[3])+a*(l=n[6]))+n[2]*(c*s-o*l);var n,s,o,a,l,c,h;if(0===r)return null;const u=b([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),d=b([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),p=b([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),f=v([],u,-e[3]);return x(f,f,v([],d,-t[3])),x(f,f,v([],p,-i[3])),v(f,f,1/r),f},e.bC=Dd,e.bD=function(){return new Float64Array(4)},e.bE=function(e,t,i,r){var n=[],s=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],s[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),s[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),s[2]=n[2],e[0]=s[0]+i[0],e[1]=s[1]+i[1],e[2]=s[2]+i[2],e},e.bF=function(e,t,i,r){var n=[],s=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],s[0]=n[0],s[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),s[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),e[0]=s[0]+i[0],e[1]=s[1]+i[1],e[2]=s[2]+i[2],e},e.bG=function(e,t,i,r){var n=[],s=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],s[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),s[1]=n[1],s[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),e[0]=s[0]+i[0],e[1]=s[1]+i[1],e[2]=s[2]+i[2],e},e.bH=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),s=t[0],o=t[1],a=t[2],l=t[3],c=t[8],h=t[9],u=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*n-c*r,e[1]=o*n-h*r,e[2]=a*n-u*r,e[3]=l*n-d*r,e[8]=s*r+c*n,e[9]=o*r+h*n,e[10]=a*r+u*n,e[11]=l*r+d*n,e},e.bI=function(e,t){const i=D(e,360),r=D(t,360),n=r-i,s=r>i?n-360:n+360;return Math.abs(n)<Math.abs(s)?n:s},e.bJ=function(e){return e[0]=0,e[1]=0,e[2]=0,e},e.bK=function(e,t,i,r){const n=Math.sqrt(e*e+t*t),s=Math.sqrt(i*i+r*r);e/=n,t/=n,i/=s,r/=s;const o=Math.acos(e*i+t*r);return-t*i+e*r>0?o:-o},e.bL=function(e,t){const i=D(e,2*Math.PI),r=D(t,2*Math.PI);return Math.min(Math.abs(i-r),Math.abs(i-r+2*Math.PI),Math.abs(i-r-2*Math.PI))},e.bM=function(){const e={},t=xe.$version;for(const i in xe.$root){const r=xe.$root[i];if(r.required){let n=null;n="version"===i?t:"array"===r.type?[]:{},null!=n&&(e[i]=n)}}return e},e.bN=ue,e.bO=ys,e.bP=function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],i[r]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==i){if("object"!=typeof i)return!1;if(Object.keys(t).length!==Object.keys(i).length)return!1;for(const r in t)if(!e(t[r],i[r]))return!1;return!0}return t===i},e.bQ=function(e){e=e.slice();const t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=be(e[i],t[e[i].ref]));return e},e.bR=function(e,t){if("custom"===e.type)return new Ed(e,t);switch(e.type){case"background":return new Md(e,t);case"circle":return new ml(e,t);case"color-relief":return new Bl(e,t);case"fill":return new Mc(e,t);case"fill-extrusion":return new Wc(e,t);case"heatmap":return new Ml(e,t);case"hillshade":return new Al(e,t);case"line":return new du(e,t);case"raster":return new Qs(e,t);case"symbol":return new Sd(e,t)}},e.bS=e=>"raster"===e.type,e.bT=U,e.bU=function(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!we(e.version,t.version))return[{command:"setStyle",args:[t]}];we(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),we(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),we(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),we(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),we(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),we(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),we(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),we(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),we(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),we(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),we(e.light,t.light)||i.push({command:"setLight",args:[t.light]}),we(e.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),we(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),we(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const r={},n=[];!function(e,t,i,r){let n;for(n in t=t||{},e=e||{})Object.prototype.hasOwnProperty.call(e,n)&&(Object.prototype.hasOwnProperty.call(t,n)||Pe(n,i,r));for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(Object.prototype.hasOwnProperty.call(e,n)?we(e[n],t[n])||("geojson"===e[n].type&&"geojson"===t[n].type&&Me(e,t,n)?Te(i,{command:"setGeoJSONSourceData",args:[n,t[n].data]}):Ie(n,t,i,r)):Se(n,t,i))}(e.sources,t.sources,n,r);const s=[];e.layers&&e.layers.forEach(e=>{"source"in e&&r[e.source]?i.push({command:"removeLayer",args:[e.id]}):s.push(e)}),i=i.concat(n),function(e,t,i){t=t||[];const r=(e=e||[]).map(Ce),n=t.map(Ce),s=e.reduce(Ae,{}),o=t.reduce(Ae,{}),a=r.slice(),l=Object.create(null);let c,h,u,d,p;for(let f=0,m=0;f<r.length;f++)c=r[f],Object.prototype.hasOwnProperty.call(o,c)?m++:(Te(i,{command:"removeLayer",args:[c]}),a.splice(a.indexOf(c,m),1));for(let f=0,m=0;f<n.length;f++)c=n[n.length-1-f],a[a.length-1-f]!==c&&(Object.prototype.hasOwnProperty.call(s,c)?(Te(i,{command:"removeLayer",args:[c]}),a.splice(a.lastIndexOf(c,a.length-m),1)):m++,d=a[a.length-f],Te(i,{command:"addLayer",args:[o[c],d]}),a.splice(a.length-f,0,c),l[c]=!0);for(let f=0;f<n.length;f++)if(c=n[f],h=s[c],u=o[c],!l[c]&&!we(h,u))if(we(h.source,u.source)&&we(h["source-layer"],u["source-layer"])&&we(h.type,u.type)){for(p in Ee(h.layout,u.layout,i,c,null,"setLayoutProperty"),Ee(h.paint,u.paint,i,c,null,"setPaintProperty"),we(h.filter,u.filter)||Te(i,{command:"setFilter",args:[c,u.filter]}),we(h.minzoom,u.minzoom)&&we(h.maxzoom,u.maxzoom)||Te(i,{command:"setLayerZoomRange",args:[c,u.minzoom,u.maxzoom]}),h)Object.prototype.hasOwnProperty.call(h,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?Ee(h[p],u[p],i,c,p.slice(6),"setPaintProperty"):we(h[p],u[p])||Te(i,{command:"setLayerProperty",args:[c,p,u[p]]}));for(p in u)Object.prototype.hasOwnProperty.call(u,p)&&!Object.prototype.hasOwnProperty.call(h,p)&&"layout"!==p&&"paint"!==p&&"filter"!==p&&"metadata"!==p&&"minzoom"!==p&&"maxzoom"!==p&&(0===p.indexOf("paint.")?Ee(h[p],u[p],i,c,p.slice(6),"setPaintProperty"):we(h[p],u[p])||Te(i,{command:"setLayerProperty",args:[c,p,u[p]]}))}else Te(i,{command:"removeLayer",args:[c]}),d=a[a.lastIndexOf(c)+1],Te(i,{command:"addLayer",args:[u,d]})}(s,t.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:"setStyle",args:[t]}]}return i},e.bV=function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},e.bW=j,e.bX=N,e.bY=class extends ba{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},e.bZ=Sa,e.b_=class extends ba{constructor(e,t){super(e,t),this.current=Pa}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.ba=$d,e.bb=qd,e.bc=function(e,t,i,r,n){var s=1/Math.tan(t/2);if(e[0]=s/i,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!=n&&n!==1/0){var o=1/(r-n);e[10]=(n+r)*o,e[14]=2*n*r*o}else e[10]=-1,e[14]=-2*r;return e},e.bd=function(e){var t=new p(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},e.be=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),s=t[0],o=t[1],a=t[2],l=t[3],c=t[4],h=t[5],u=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*n+c*r,e[1]=o*n+h*r,e[2]=a*n+u*r,e[3]=l*n+d*r,e[4]=c*n-s*r,e[5]=h*n-o*r,e[6]=u*n-a*r,e[7]=d*n-l*r,e},e.bf=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),s=t[4],o=t[5],a=t[6],l=t[7],c=t[8],h=t[9],u=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*n+c*r,e[5]=o*n+h*r,e[6]=a*n+u*r,e[7]=l*n+d*r,e[8]=c*n-s*r,e[9]=h*n-o*r,e[10]=u*n-a*r,e[11]=d*n-l*r,e},e.bg=function(){const e=new Float32Array(16);return m(e),e},e.bh=function(){const e=new Float64Array(16);return m(e),e},e.bi=function(){return new Float64Array(16)},e.bj=function(e,t,i){const r=new Float64Array(4);return I(r,e,t-90,i),r},e.bk=function(e,t,i,r){var n,s,o,a,l,c=t[0],h=t[1],u=t[2],p=t[3],f=i[0],m=i[1],g=i[2],_=i[3];return(s=c*f+h*m+u*g+p*_)<0&&(s=-s,f=-f,m=-m,g=-g,_=-_),1-s>d?(n=Math.acos(s),o=Math.sin(n),a=Math.sin((1-r)*n)/o,l=Math.sin(r*n)/o):(a=1-r,l=r),e[0]=a*c+l*f,e[1]=a*h+l*m,e[2]=a*u+l*g,e[3]=a*p+l*_,e},e.bl=function(e){const t=new Float64Array(9);var i,r,n,s,o,a,l,c,h,u,d,p,f,m,g,_,y,x;u=(n=(r=e)[0])*(l=n+n),d=(s=r[1])*l,f=(o=r[2])*l,m=o*(c=s+s),_=(a=r[3])*l,y=a*c,x=a*(h=o+o),(i=t)[0]=1-(p=s*c)-(g=o*h),i[3]=d-x,i[6]=f+y,i[1]=d+x,i[4]=1-u-g,i[7]=m-_,i[2]=f-y,i[5]=m+_,i[8]=1-u-p;const v=te(-Math.asin(F(t[2],-1,1)));let b,w;return Math.hypot(t[5],t[8])<.001?(b=0,w=-te(Math.atan2(t[3],t[4]))):(b=te(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),w=te(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:b,pitch:v+90,bearing:w}},e.bm=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bn=Mt,e.bo=wa,e.bp=mc,e.bq=gc,e.br=pc,e.bs=z,e.bt=k,e.bu=Vt,e.bv=function(e,t,i,r,n){return z(r,n,F((e-t)/(i-t),0,1))},e.bw=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e},e.bx=D,e.by=function(){return new Float64Array(3)},e.bz=I,e.c=ae,e.c$=class{constructor(e,t){this.layers={[Zf]:this},this.name=Zf,this.version=t?t.version:1,this.extent=t?t.extent:4096,this.length=e.length,this.features=e}feature(e){return new $f(this.features[e],this.extent)}},e.c0=class extends ba{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.c1=class extends ba{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.c2=f,e.c3=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.c4=function(e,t,i){var r=t[0],n=t[1],s=t[2];return e[0]=r*i[0]+n*i[3]+s*i[6],e[1]=r*i[1]+n*i[4]+s*i[7],e[2]=r*i[2]+n*i[5]+s*i[8],e},e.c5=function(e,t,i,r,n,s,o){var a=1/(t-i),l=1/(r-n),c=1/(s-o);return e[0]=-2*a,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*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(o+s)*c,e[15]=1,e},e.c6=class extends ba{constructor(e,t){super(e,t),this.current=new Array}set(e){if(e!=this.current){this.current=e;const t=new Float32Array(4*e.length);for(let i=0;i<e.length;i++)t[4*i]=e[i].r,t[4*i+1]=e[i].g,t[4*i+2]=e[i].b,t[4*i+3]=e[i].a;this.gl.uniform4fv(this.location,t)}}},e.c7=class extends ba{constructor(e,t){super(e,t),this.current=new Array}set(e){if(e!=this.current){this.current=e;const t=new Float32Array(e);this.gl.uniform1fv(this.location,t)}}},e.c8=class extends xo{},e.c9=yu,e.cA=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e},e.cB=function(e,t){const{x:i,y:r}=Nd.fromLngLat(t);return!(e<0||e>25||r<0||r>=1||i<0||i>=1)},e.cC=function(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},e.cD=class extends oo{},e.cE=Nm,e.cG=he,e.cH=function(e,t){ae.REGISTERED_PROTOCOLS[e]=t},e.cI=function(e){delete ae.REGISTERED_PROTOCOLS[e]},e.cJ=function(e,t){const i={};for(let n=0;n<e.length;n++){const r=t&&t[e[n].id]||wn(e[n]);t&&(t[e[n].id]=r);let s=i[r];s||(s=i[r]=[]),s.push(e[n])}const r=[];for(const n in i)r.push(i[n]);return r},e.cK=ds,e.cL=Xd,e.cM=Qf,e.cN=Yu,e.cO=function(t){var i;t.bucket.createArrays(),t.bucket.tilePixelRatio=C/(512*t.bucket.overscaling),t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;const r=t.bucket.layers[0],n=r.layout,s=r._unevaluatedLayout._values,o={layoutIconSize:s["icon-size"].possiblyEvaluate(new ks(t.bucket.zoom+1),t.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new ks(t.bucket.zoom+1),t.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new ks(18))};if("composite"===t.bucket.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.bucket.textSizeData;o.compositeTextSizes=[s["text-size"].possiblyEvaluate(new ks(e),t.canonical),s["text-size"].possiblyEvaluate(new ks(i),t.canonical)]}if("composite"===t.bucket.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.bucket.iconSizeData;o.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new ks(e),t.canonical),s["icon-size"].possiblyEvaluate(new ks(i),t.canonical)]}const a=n.get("text-line-height")*vu,l="viewport"!==n.get("text-rotation-alignment")&&"point"!==n.get("symbol-placement"),c=n.get("text-keep-upright"),h=n.get("text-size");for(const u of t.bucket.features){const s=n.get("text-font").evaluate(u,{},t.canonical).join(","),d=h.evaluate(u,{},t.canonical),p=o.layoutTextSize.evaluate(u,{},t.canonical),f=o.layoutIconSize.evaluate(u,{},t.canonical),m={horizontal:{},vertical:void 0},g=u.text;let _,y=[0,0];if(g){const i=g.toString(),o=n.get("text-letter-spacing").evaluate(u,{},t.canonical)*vu,h=Ts(i)?o:0,f=n.get("text-anchor").evaluate(u,{},t.canonical),_=Cm(r,u,t.canonical);if(!_){const e=n.get("text-radial-offset").evaluate(u,{},t.canonical);y=e?Em(f,[e*vu,Mm]):n.get("text-offset").evaluate(u,{},t.canonical).map(e=>e*vu)}let x=l?"center":n.get("text-justify").evaluate(u,{},t.canonical);const v="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(u,{},t.canonical)*vu:1/0,b=()=>{t.bucket.allowVerticalPlacement&&ws(i)&&(m.vertical=Ju(g,t.glyphMap,t.glyphPositions,t.imagePositions,s,v,a,f,"left",h,y,e.aw.vertical,!0,p,d))};if(!l&&_){const i=new Set;if("auto"===x)for(let e=0;e<_.values.length;e+=2)i.add(Am(_.values[e]));else i.add(x);let r=!1;for(const n of i)if(!m.horizontal[n])if(r)m.horizontal[n]=m.horizontal[0];else{const i=Ju(g,t.glyphMap,t.glyphPositions,t.imagePositions,s,v,a,"center",n,h,y,e.aw.horizontal,!1,p,d);i&&(m.horizontal[n]=i,r=1===i.positionedLines.length)}b()}else{"auto"===x&&(x=Am(f));const r=Ju(g,t.glyphMap,t.glyphPositions,t.imagePositions,s,v,a,f,x,h,y,e.aw.horizontal,!1,p,d);r&&(m.horizontal[x]=r),b(),ws(i)&&l&&c&&(m.vertical=Ju(g,t.glyphMap,t.glyphPositions,t.imagePositions,s,v,a,f,x,h,y,e.aw.vertical,!1,p,d))}}let x=!1;if(u.icon&&u.icon.name){const e=t.imageMap[u.icon.name];e&&(_=od(t.imagePositions[u.icon.name],n.get("icon-offset").evaluate(u,{},t.canonical),n.get("icon-anchor").evaluate(u,{},t.canonical)),x=!!e.sdf,void 0===t.bucket.sdfIcons?t.bucket.sdfIcons=x:t.bucket.sdfIcons!==x&&$("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.bucket.pixelRatio||0!==n.get("icon-rotate").constantOr(1))&&(t.bucket.iconsNeedLinear=!0))}const v=km(m.horizontal)||m.vertical;(i=t.bucket).iconsInText||(i.iconsInText=!!v&&v.iconsInText),(v||_)&&Dm(t.bucket,u,m,_,t.imageMap,o,p,f,y,x,t.canonical,t.subdivisionGranularity)}t.showCollisionBoxes&&t.bucket.generateCollisionDebugBuffers()},e.cP=Tc,e.cQ=Nc,e.cR=ou,e.cS=function(e,t=""){const i=new ku;return function(e,t,i=""){for(const r in e.layers)t.writeMessage(3,(e,t)=>qf(e,t,i),e.layers[r])}(e,i,t),i.finish()},e.cT=function(e,t,i,r,n,s){let o=rm(e,t,i,n,0);return o=rm(o,t,r,s,1),o},e.cU=class{constructor(e){this.maxEntries=e,this.map=new Map}get(e){const t=this.map.get(e);return void 0!==t&&(this.map.delete(e),this.map.set(e,t)),t}set(e,t){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}clear(){this.map.clear()}},e.cV=Bc,e.cW=ku,e.cX=Gf,e.cY=class{constructor(e){this.start=`${e}#start`,this.end=`${e}#end`,this.measure=e,performance.mark(this.start)}finish(){performance.mark(this.end);let e=performance.getEntriesByName(this.measure);return 0===e.length&&(performance.measure(this.measure,this.start,this.end),e=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),e}},e.cZ=function(e,i,r,n,s){return t(this,void 0,void 0,function*(){if(u())try{return yield Y(e,i,r,n,s)}catch(e){}return function(e,t,i,r,n){const s=e.width,o=e.height;K&&J||(K=new OffscreenCanvas(s,o),J=K.getContext("2d",{willReadFrequently:!0})),K.width=s,K.height=o,J.drawImage(e,0,0,s,o);const a=J.getImageData(t,i,r,n);return J.clearRect(0,0,s,o),a.data}(e,i,r,n,s)})},e.c_=Ll,e.ca=class extends bo{},e.cb=Il,e.cc=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},e.cd=Pl,e.ce=function(e,t,i){var r=t[0],n=t[1],s=t[2],o=i[3]*r+i[7]*n+i[11]*s+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*s+i[12])/(o=o||1),e[1]=(i[1]*r+i[5]*n+i[9]*s+i[13])/o,e[2]=(i[2]*r+i[6]*n+i[10]*s+i[14])/o,e},e.cf=class extends ao{},e.cg=class extends Eo{},e.ch=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.ci=function(e,t){var i=e[0],r=e[1],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],p=e[10],f=e[11],m=e[12],g=e[13],_=e[14],y=e[15],x=t[0],v=t[1],b=t[2],w=t[3],T=t[4],S=t[5],P=t[6],I=t[7],M=t[8],E=t[9],C=t[10],A=t[11],D=t[12],z=t[13],k=t[14],R=t[15];return Math.abs(i-x)<=d*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(r-v)<=d*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-b)<=d*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(s-w)<=d*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(o-T)<=d*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(a-S)<=d*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(l-P)<=d*Math.max(1,Math.abs(l),Math.abs(P))&&Math.abs(c-I)<=d*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(h-M)<=d*Math.max(1,Math.abs(h),Math.abs(M))&&Math.abs(u-E)<=d*Math.max(1,Math.abs(u),Math.abs(E))&&Math.abs(p-C)<=d*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(f-A)<=d*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(m-D)<=d*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(g-z)<=d*Math.max(1,Math.abs(g),Math.abs(z))&&Math.abs(_-k)<=d*Math.max(1,Math.abs(_),Math.abs(k))&&Math.abs(y-R)<=d*Math.max(1,Math.abs(y),Math.abs(R))},e.cj=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},e.ck=e=>"circle"===e.type,e.cl=e=>"heatmap"===e.type,e.cm=e=>"line"===e.type,e.cn=e=>"fill"===e.type,e.co=e=>"fill-extrusion"===e.type,e.cp=e=>"hillshade"===e.type,e.cq=e=>"color-relief"===e.type,e.cr=e=>"background"===e.type,e.cs=e=>"custom"===e.type,e.ct=R,e.cu=function(e,t,i){if(t<=0)return e;const r=1/t;return void 0===i||Math.abs(i)<1e-10?Math.round(e*r)/r:(i>0?Math.ceil(e*r-1e-9):Math.floor(e*r+1e-10))/r},e.cv=function(e,t,i){const r=E(t.x-i.x,t.y-i.y),n=E(e.x-i.x,e.y-i.y);var s,o;return te(Math.atan2(r[0]*n[1]-r[1]*n[0],(s=r)[0]*(o=n)[0]+s[1]*o[1]))},e.cw=L,e.cx=function(e,t){var i;if(!re[t])return!1;const r=null==e?void 0:e.target,n=(null===(i=null==r?void 0:r.ownerDocument)||void 0===i?void 0:i.defaultView)||window;return e instanceof n.MouseEvent||e instanceof n.WheelEvent},e.cy=function(e,t){return ie[t]&&"touches"in e},e.cz=function(e){return ie[e]||re[e]},e.d=pe,e.d0=rn,e.d1=class{get tiles(){return this.tileIndex?.tiles??{}}get stats(){return this.tileIndex.stats}get total(){return this.tileIndex.total}constructor(e,t){const i=(t=this.options=Object.assign({},Qh,t)).debug;if(i&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)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 r=ah(e,t);i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles")),r=zh(r,t),t.updateable&&(this.source=r),this.initializeIndex(r,t)}initializeIndex(e,t){this.tileIndex=t.cluster?new Oh(t.clusterOptions):new Kh(t),e.length&&this.tileIndex.initialize(e)}getTile(e,t,i){return t=+t,i=+i,(e=+e)<0||e>24?null:this.tileIndex.getTile(e,t,i)}updateData(e,t){const i=this.options;if(!i.updateable)throw new Error("to update tile geojson `updateable` option must be set to true");let{affected:r,source:n}=function(e,t,i){const r=function(e){return e?{removeAll:e.removeAll,remove:new Set(e.remove||[]),add:new Map(e.add?.map(e=>[e.id,e])),update:new Map(e.update?.map(e=>[e.id,e]))}:{remove:new Set,add:new Map,update:new Map}}(t);let n=[];if(r.removeAll&&(n=e,e=[]),r.remove.size||r.add.size){const t=[];for(const i of e)(r.remove.has(i.id)||r.add.has(i.id))&&t.push(i);if(t.length){n.push(...t);const i=new Set(t.map(e=>e.id));e=e.filter(e=>!i.has(e.id))}if(r.add.size){let t=ah({type:"FeatureCollection",features:Array.from(r.add.values())},i);t=zh(t,i),n.push(...t),e.push(...t)}}if(r.update.size)for(const[s,o]of r.update){const t=[],r=[];for(const i of e)i.id===s?t.push(i):r.push(i);if(!t.length)continue;const a=Lh(t,o,i);a.length&&(n.push(...t,...a),r.push(...a),e=r)}return{affected:n,source:e}}(this.source,e,i);t&&({affected:r,source:n}=this.filterUpdate(n,r,t)),r.length&&(this.source=n,this.tileIndex.updateIndex(n,r,i))}filterUpdate(e,t,i){const r=new Set;for(const n of e)null!=n.id&&(i(ph(n))||(t.push(n),r.add(n.id)));return{affected:t,source:e=e.filter(e=>!r.has(e.id))}}getData(){if(!this.options.updateable)throw new Error("to retrieve data the `updateable` option must be set to true");return{type:"FeatureCollection",features:this.source.map(e=>ph(e))}}updateClusterOptions(e,t){const i=this.options.cluster;this.options.cluster=e,this.options.clusterOptions=t,i!=e?this.initializeIndex(this.source,this.options):this.tileIndex.updateIndex(this.source,[],this.options)}getClusterExpansionZoom(e){return this.tileIndex.getClusterExpansionZoom(e)}getClusterChildren(e){return this.tileIndex.getChildren(e)}getClusterLeaves(e,t,i){return this.tileIndex.getLeaves(e,t,i)}},e.d2=zs,e.e=O,e.f=e=>t(void 0,void 0,void 0,function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(t)}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.`)}}),e.g=le,e.h=e=>new Promise((t,i)=>{const r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>{r.src=H})},r.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?URL.createObjectURL(n):H}),e.i=q,e.j=(e,t)=>de(O(e,{type:"json"}),t),e.k=_e,e.l=ge,e.m=de,e.n=(e,t)=>de(O(e,{type:"arrayBuffer"}),t),e.o=function(e){return new ku(e).readFields(Zu,[])},e.p=Xu,e.q=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},e.r=wl,e.s=Q,e.t=Hs,e.u=xe,e.v=rs,e.w=$,e.x=Os,e.y=ss,e.z=Ls}),i("worker",["./shared"],function(e){class t{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,i,r){for(const s of t){this._layerConfigs[s.id]=s;const t=this._layers[s.id]=e.bR(s,r);t._featureFilter=e.ag(t.filter,r),this.keyCache[s.id]&&delete this.keyCache[s.id]}for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=e.cJ(Object.values(this._layerConfigs),this.keyCache);for(const s of n){const t=s.map(e=>this._layers[e.id]),i=t[0];if(i.isHidden())continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||e.af;let a=n[o];a||(a=n[o]=[]),a.push(t)}}}class i{constructor(t){const i={},r=[];for(const e in t){const n=t[e],s=i[e]={};for(const e in n){const t=n[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};r.push(i),s[e]={rect:i,metrics:t.metrics}}}const{w:n,h:s}=e.p(r),o=new e.r({width:n||1,height:s||1});for(const a in t){const r=t[a];for(const t in r){const n=r[+t];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const s=i[a][t].rect;e.r.copy(n.bitmap,o,{x:0,y:0},{x:s.x+1,y:s.y+1},n.bitmap)}}this.image=o,this.positions=i}}e.cK("GlyphAtlas",i);class r{constructor(t){this.tileID=new e.a2(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[]}parse(t,r,s,o,a){return e._(this,void 0,void 0,function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.ad;const l=new e.cL(Object.keys(t.layers).sort()),c=new e.cM(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:s,subdivisionGranularity:a},d=r.familiesBySource[this.source];for(const i in d){const r=t.layers[i];if(!r)continue;1===r.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const o=l.encode(i),a=[];for(let e=0;e<r.length;e++){const t=r.feature(e),n=c.getId(t,i);a.push({feature:t,id:n,index:e,sourceLayerIndex:o})}for(const t of d[i]){const i=t[0];i.source!==this.source&&e.w(`layer.source = ${i.source} does not equal this.source = ${this.source}`),i.isHidden(this.zoom,!0)||(n(t,this.zoom,s),(h[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:o,sourceID:this.source})).populate(a,u,this.tileID.canonical),c.bucketLayerIDs.push(t.map(e=>e.id)))}}const p=e.bW(u.glyphDependencies,e=>Object.keys(e).map(Number));this.inFlightDependencies.forEach(e=>null==e?void 0:e.abort()),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(p).length){const e=new AbortController;this.inFlightDependencies.push(e),f=o.sendAsync({type:"GG",data:{stacks:p,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const m=Object.keys(u.iconDependencies);let g=Promise.resolve({});if(m.length){const e=new AbortController;this.inFlightDependencies.push(e),g=o.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},e)}const _=Object.keys(u.patternDependencies);let y=Promise.resolve({});if(_.length){const e=new AbortController;this.inFlightDependencies.push(e),y=o.sendAsync({type:"GI",data:{icons:_,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const x=u.dashDependencies;let v=Promise.resolve({});if(Object.keys(x).length){const e=new AbortController;this.inFlightDependencies.push(e),v=o.sendAsync({type:"GDA",data:{dashes:x}},e)}const[b,w,T,S]=yield Promise.all([f,g,y,v]),P=new i(b),I=new e.cN(w,T);for(const t in h){const i=h[t];i instanceof e.ae?(n(i.layers,this.zoom,s),e.cO({bucket:i,glyphMap:b,glyphPositions:P.positions,imageMap:w,imagePositions:I.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:u.subdivisionGranularity})):i.hasDependencies&&(i instanceof e.cP||i instanceof e.cQ||i instanceof e.cR)&&(n(i.layers,this.zoom,s),i.addFeatures(u,this.tileID.canonical,I.patternPositions,S))}return this.status="done",{buckets:Object.values(h).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:P.image,imageAtlas:I,dashPositions:S,glyphMap:this.returnDependencies?b:null,iconMap:this.returnDependencies?w:null,glyphPositions:this.returnDependencies?P.positions:null}})}}function n(t,i,r){const n=new e.H(i);for(const e of t)e.recalculate(n,r)}class s{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(e,t){this.loading[e]=t}finishLoading(e){delete this.loading[e]}abort(e){const t=this.loading[e];(null==t?void 0:t.abort)&&(t.abort.abort(),delete this.loading[e])}setParsing(e,t){this.parsing[e]=t}consumeParsing(e){const t=this.parsing[e];if(t)return delete this.parsing[e],t}clearParsing(e){delete this.parsing[e]}markLoaded(e,t){this.loaded[e]=t}getLoaded(e){const t=this.loaded[e];if(t)return t}removeLoaded(e){delete this.loaded[e]}clearLoaded(){this.loaded={}}}class o{constructor(e,t,i,r,n){this.type=e,this.properties=i||{},this.extent=n,this.pointsArray=t,this.id=r}loadGeometry(){return this.pointsArray.map(t=>t.map(t=>new e.P(t.x,t.y)))}}class a{constructor(e,t,i){this.version=2,this._myFeatures=e,this.name=t,this.length=e.length,this.extent=i}feature(e){return this._myFeatures[e]}}class l{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function c(t){let i=e.cS(t);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:t,rawData:i.buffer}}function h(t,i,r){const{extent:n}=t,s=Math.pow(2,r.z-i.z),l=(r.x-i.x*s)*n,c=(r.y-i.y*s)*n,h=[];for(let a=0;a<t.length;a++){const i=t.feature(a);let r=i.loadGeometry();for(const e of r)for(const t of e)t.x=t.x*s-l,t.y=t.y*s-c;const u=128;r=e.cT(r,i.type,-u,-u,n+u,n+u),0!==r.length&&h.push(new o(i.type,r,i.properties,i.id,n))}return new a(h,t.name,n)}class u{constructor(t,i,r){this.actor=t,this.layerIndex=i,this.availableImages=r,this.tileState=new s,this.overzoomedTileResultCache=new e.cU(1e3)}loadVectorTile(t,i){try{return{vectorTile:"mlt"!==t.encoding?new e.cV(new e.cW(i)):new e.cX(i),rawData:i}}catch(e){const n=new Uint8Array(i);let s=`Unable to parse the tile at ${t.request.url}, `;throw s+=31===n[0]&&139===n[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(s)}}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:i,overzoomParameters:n}=t;n&&(t.request=n.overzoomRequest);const s=this._startRequestTiming(t),o=new r(t);this.tileState.startLoading(i,o);const a=new AbortController;o.abort=a;try{const r=yield e.n(t.request,a);if(t.etag&&t.etag===r.etag)return this.tileState.finishLoading(i),this._getEtagUnmodifiedResult(r,s);const l=this.loadVectorTile(t,r.data);if(this.tileState.finishLoading(i),!l)return null;let{vectorTile:c,rawData:h}=l;n&&({vectorTile:c,rawData:h}=this._getOverzoomTile(t,c));const u=this._getExpiryData(r),d=this._finishRequestTiming(s);o.vectorTile=c,this.tileState.markLoaded(i,o);const p={rawData:h,cacheControl:u,resourceTiming:d};this.tileState.setParsing(i,p);try{return yield this._parseWorkerTile(o,t,p)}finally{this.tileState.clearParsing(i)}}catch(e){throw this.tileState.finishLoading(i),o.status="done",this.tileState.markLoaded(i,o),e}})}_getEtagUnmodifiedResult(t,i){const r=this._getExpiryData(t),n=this._finishRequestTiming(i);return e.e({etagUnmodified:!0},r,n)}_parseWorkerTile(t,i,r){return e._(this,void 0,void 0,function*(){let n=yield t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,i.subdivisionGranularity);if(r){const{rawData:t,cacheControl:s,resourceTiming:o}=r;n=e.e({rawTileData:t.slice(0),encoding:i.encoding},n,s,o)}return n})}_getExpiryData({expires:e,cacheControl:t,etag:i}){const r={};return e&&(r.expires=e),t&&(r.cacheControl=t),i&&(r.etag=i),r}_startRequestTiming(t){var i;if(null===(i=t.request)||void 0===i?void 0:i.collectResourceTiming)return new e.cY(t.request.url)}_finishRequestTiming(e){const t=null==e?void 0:e.finish();return t?{resourceTiming:JSON.parse(JSON.stringify(t))}:{}}_getOverzoomTile(e,t){const{tileID:i,source:r,overzoomParameters:n}=e,{maxZoomTileID:s}=n,o=`${s.key}_${i.key}`,a=this.overzoomedTileResultCache.get(o);if(a)return a;const u=new l,d=this.layerIndex.familiesBySource[r];for(const l in d){const e=t.layers[l];if(!e)continue;const r=h(e,s,i.canonical);r.length>0&&u.addLayer(r)}const p=c(u);return this.overzoomedTileResultCache.set(o,p),p}reloadTile(t){return e._(this,void 0,void 0,function*(){const e=t.uid,i=this.tileState.getLoaded(e);if(!i)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const r=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(i,t,r)}if("done"===i.status&&i.vectorTile)return yield this._parseWorkerTile(i,t)})}abortTile(t){return e._(this,void 0,void 0,function*(){this.tileState.abort(t.uid)})}removeTile(t){return e._(this,void 0,void 0,function*(){this.tileState.removeLoaded(t.uid)})}}class d{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:i,encoding:r,rawImageData:n,redFactor:s,greenFactor:o,blueFactor:a,baseShift:l}=t,c=n.width+2,h=n.height+2,u=e.b(n)?new e.R({width:c,height:h},yield e.cZ(n,-1,-1,c,h)):n,d=new e.c_(i,u,r,s,o,a,l);return this.loaded=this.loaded||{},this.loaded[i]=d,d})}removeTile(e){const t=this.loaded,i=e.uid;t&&t[i]&&delete t[i]}}class p{constructor(e,t,i,r=f){this.actor=e,this.layerIndex=t,this.availableImages=i,this.tileState=new s,this._createGeoJSONIndex=r}loadVectorTile(t){if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const{z:i,x:r,y:n}=t.tileID.canonical,s=this._geoJSONIndex.getTile(i,r,n);return s?c(new e.c$(s.features,{version:2,extent:e.a5})):null}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:e}=t,i=new r(t);i.abort=new AbortController;try{const r=this.loadVectorTile(t);if(!r)return null;const{vectorTile:n,rawData:s}=r;i.vectorTile=n,this.tileState.markLoaded(e,i);const o={rawData:s};this.tileState.setParsing(e,o);try{return yield this._parseWorkerTile(i,t,o)}finally{this.tileState.clearParsing(e)}}catch(t){throw i.status="done",this.tileState.markLoaded(e,i),t}})}_reloadLoadedTile(t){return e._(this,void 0,void 0,function*(){const e=t.uid,i=this.tileState.getLoaded(e);if(!i)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(i.showCollisionBoxes=t.showCollisionBoxes,"parsing"===i.status){const r=this.tileState.consumeParsing(e);return yield this._parseWorkerTile(i,t,r)}if("done"===i.status&&i.vectorTile)return yield this._parseWorkerTile(i,t)})}_parseWorkerTile(t,i,r){return e._(this,void 0,void 0,function*(){let n=yield t.parse(t.vectorTile,this.layerIndex,this.availableImages,this.actor,i.subdivisionGranularity);if(r){const{rawData:t}=r;n=e.e({rawTileData:t.slice(0),encoding:"mvt"},n)}return n})}abortTile(t){return e._(this,void 0,void 0,function*(){this.tileState.abort(t.uid)})}removeTile(t){return e._(this,void 0,void 0,function*(){this.tileState.removeLoaded(t.uid)})}loadData(t){return e._(this,void 0,void 0,function*(){var i;null===(i=this._pendingRequest)||void 0===i||i.abort();const r=this._startRequestTiming(t);this._pendingRequest=new AbortController;try{yield this.loadAndProcessGeoJSON(t,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();const e={};return t.request&&(e.data=t.data),this._finishRequestTiming(r,t,e),e}catch(t){if(delete this._pendingRequest,!e.Z(t))throw t;return{abandoned:!0}}})}_startRequestTiming(t){var i;if(null===(i=t.request)||void 0===i?void 0:i.collectResourceTiming)return new e.cY(t.request.url)}_finishRequestTiming(e,t,i){const r=null==e?void 0:e.finish();r&&(i.resourceTiming={[t.source]:JSON.parse(JSON.stringify(r))})}reloadTile(e){return this.tileState.getLoaded(e.uid)?this._reloadLoadedTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,i){return e._(this,void 0,void 0,function*(){var r;if(t.request&&(t.data=(yield e.j(t.request,i)).data),t.data)return t.data=this._filterGeoJSON(t.data,t.filter),void(this._geoJSONIndex=this._createGeoJSONIndex(t.data,t));if(t.dataDiff)return null!==(r=this._geoJSONIndex)&&void 0!==r||(this._geoJSONIndex=this._createGeoJSONIndex({type:"FeatureCollection",features:[]},t)),void this._geoJSONIndex.updateData(t.dataDiff,this._getFilterPredicate(t.filter));if(t.updateCluster&&this._geoJSONIndex.updateClusterOptions(t.geojsonVtOptions.cluster,m(t)),null==this._geoJSONIndex)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)})}_filterGeoJSON(e,t){if("FeatureCollection"!==e.type)return e;const i=this._getFilterPredicate(t);return i?{type:"FeatureCollection",features:e.features.filter(e=>i(e))}:e}_getFilterPredicate(t){if("boolean"!=typeof t&&!(null==t?void 0:t.length))return;const i=e.d0(t,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return e=>i.value.evaluate({zoom:0},e)}removeSource(t){return e._(this,void 0,void 0,function*(){var e;null===(e=this._pendingRequest)||void 0===e||e.abort()})}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getClusterChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getClusterLeaves(e.clusterId,e.limit,e.offset)}}function f(t,i){const r=e.e(i.geojsonVtOptions||{},{updateable:!0,clusterOptions:m(i)});return new e.d1(t,r)}function m({geojsonVtOptions:t,clusterProperties:i}){if(!i||!t.clusterOptions)return t.clusterOptions;const r={},n={},s={accumulated:null,zoom:0},o={properties:null},a=Object.keys(i);for(const l of a){const[t,s]=i[l],o=e.d0(s),a=e.d0("string"==typeof t?[t,["accumulated"],["get",l]]:t);r[l]=o.value,n[l]=a.value}return t.clusterOptions.map=e=>{o.properties=e;const t={};for(const i of a)t[i]=r[i].evaluate(s,o);return t},t.clusterOptions.reduce=(e,t)=>{o.properties=t;for(const i of a)s.accumulated=e[i],e[i]=n[i].evaluate(s,o)},t.clusterOptions}class g{constructor(t){this.self=t,this.actor=new e.L(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cH,this.self.removeProtocol=e.cI,this.self.registerRTLTextPlugin=t=>{e.d2.setMethods(t)},this.actor.registerMessageHandler("LDT",(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler("RDT",(t,i)=>e._(this,void 0,void 0,function*(){this._getDEMWorkerSource(t,i.source).removeTile(i)})),this.actor.registerMessageHandler("GCEZ",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterExpansionZoom(i)})),this.actor.registerMessageHandler("GCC",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterChildren(i)})),this.actor.registerMessageHandler("GCL",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterLeaves(i)})),this.actor.registerMessageHandler("LD",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler("LT",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler("RT",(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler("AT",(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler("RMT",(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler("RS",(t,i)=>e._(this,void 0,void 0,function*(){if(!this.workerSources[t]||!this.workerSources[t][i.type]||!this.workerSources[t][i.type][i.source])return;const e=this.workerSources[t][i.type][i.source];delete this.workerSources[t][i.type][i.source],void 0!==e.removeSource&&e.removeSource(i)})),this.actor.registerMessageHandler("RM",t=>e._(this,void 0,void 0,function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],this.globalStates.delete(t)})),this.actor.registerMessageHandler("SR",(t,i)=>e._(this,void 0,void 0,function*(){this.referrer=i})),this.actor.registerMessageHandler("SRPS",(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler("IS",(t,i)=>e._(this,void 0,void 0,function*(){this.self.importScripts(i)})),this.actor.registerMessageHandler("SI",(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler("UL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).update(i.layers,i.removedIds,this._getGlobalState(t))})),this.actor.registerMessageHandler("UGS",(t,i)=>e._(this,void 0,void 0,function*(){const e=this._getGlobalState(t);for(const t in i)e[t]=i[t]})),this.actor.registerMessageHandler("SL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).replace(i,this._getGlobalState(t))}))}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}_setImages(t,i){return e._(this,void 0,void 0,function*(){this.availableImages[t]=i;for(const e in this.workerSources[t]){const r=this.workerSources[t][e];for(const e in r)r[e].availableImages=i}})}_syncRTLPluginState(t,i){return e._(this,void 0,void 0,function*(){return yield e.d2.syncState(i,this.self.importScripts)})}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let i=this.layerIndexes[e];return i||(i=this.layerIndexes[e]=new t),i}_getWorkerSource(e,t,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][i]){const r={sendAsync:(t,i)=>(t.targetMapId=e,this.actor.sendAsync(t,i))};switch(t){case"vector":this.workerSources[e][t][i]=new u(r,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][i]=new p(r,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][i]=new this.externalWorkerSourceTypes[t](r,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][i]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new d),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new g(self)),g}),i("index",["exports","./shared"],function(e,t){var i="5.21.1";function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let n,s,o;const a={frame(e,i,r,n){const s=n||window,o=s.requestAnimationFrame(e=>{a(),i(e)}),{unsubscribe:a}=t.s(e.signal,"abort",()=>{a(),s.cancelAnimationFrame(o),r(new t.a(e.signal.reason))},!1)},frameAsync(e,t){return new Promise((i,r)=>{this.frame(e,i,r,t)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(n||(n=document.createElement("a")),n.href=e,n.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==o?o:!!matchMedia&&(null==s&&(s=matchMedia("(prefers-reduced-motion: reduce)")),s.matches)},set prefersReducedMotion(e){o=e}},l=new class{constructor(){this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:performance.now()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function c(){return l.getCurrentTime()}class h{static create(e,t,i){const r=window.document.createElement(e);return void 0!==t&&(r.className=t),i&&i.appendChild(r),r}static createNS(e,t){return window.document.createElementNS(e,t)}static disableDrag(){h.docStyle&&h.selectProp&&(h.userSelect=h.docStyle[h.selectProp],h.docStyle[h.selectProp]="none")}static enableDrag(){h.docStyle&&h.selectProp&&(h.docStyle[h.selectProp]=h.userSelect)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",h.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",h.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",h.suppressClickInternal,!0)},0)}static getScale(e){const t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,r){const n=i.boundingClientRect;return new t.P((r.clientX-n.left)/i.x-e.clientLeft,(r.clientY-n.top)/i.y-e.clientTop)}static mousePos(e,t){const i=h.getScale(e);return h.getPoint(e,i,t)}static touchPos(e,t){const i=[],r=h.getScale(e);for(let n=0;n<t.length;n++)i.push(h.getPoint(e,r,t[n]));return i}static sanitize(e){const t=(new DOMParser).parseFromString(e,"text/html").body||document.createElement("body"),i=t.querySelectorAll("script");for(const r of i)r.remove();return h.clean(t),t.innerHTML}static isPossiblyDangerous(e,t){const i=t.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!i.includes("javascript:")&&!i.includes("data:"))||!!e.startsWith("on")||void 0}static clean(e){const t=e.children;for(const i of t)h.removeAttributes(i),h.clean(i)}static removeAttributes(e){for(const{name:t,value:i}of e.attributes)h.isPossiblyDangerous(t,i)&&e.removeAttribute(t)}}var u;h.docStyle="undefined"!=typeof window&&window.document&&window.document.documentElement.style,h.selectProp=!h.docStyle||"userSelect"in h.docStyle?"userSelect":"webkitUserSelect",function(e){let i,r,n,s;e.resetRequestQueue=()=>{i=[],r=0,n=0,s={}},e.addThrottleControl=e=>{const t=n++;return s[t]=e,t},e.removeThrottleControl=e=>{delete s[e],a()},e.getImage=(e,r,n=!0)=>new Promise((s,o)=>{e.headers||(e.headers={}),e.headers.accept="image/webp,*/*",t.e(e,{type:"image"}),i.push({abortController:r,requestParameters:e,supportImageRefresh:n,state:"queued",onError:e=>{o(e)},onSuccess:e=>{s(e)}}),a()});const o=e=>t._(this,void 0,void 0,function*(){e.state="running";const{requestParameters:i,supportImageRefresh:n,onError:s,onSuccess:o,abortController:c}=e,h=!1===n&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce((e,t)=>e&&"accept"===t,!0));r++;const u=h?l(i,c):t.m(i,c);try{const i=yield u;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?o(i):i.data&&o({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(t){delete e.abortController,s(t)}finally{r--,a()}var d}),a=()=>{const e=(()=>{for(const e of Object.keys(s))if(s[e]())return!0;return!1})()?t.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t<e&&i.length>0;t++){const e=i.shift();e.abortController.signal.aborted?t--:o(e)}},l=(e,i)=>new Promise((r,n)=>{const s=new Image,o=e.url,a=e.credentials;a&&"include"===a?s.crossOrigin="use-credentials":(a&&"same-origin"===a||!t.d(o))&&(s.crossOrigin="anonymous"),i.signal.addEventListener("abort",()=>{s.src="",n(new t.a(i.signal.reason))}),s.fetchPriority="high",s.onload=()=>{s.onerror=s.onload=null,r({data:s})},s.onerror=()=>{s.onerror=s.onload=null,i.signal.aborted||n(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},s.src=o})}(u||(u={})),u.resetRequestQueue();class d{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function p(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:r,url:n}of e){const e=`${r}${n}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:r,url:n}))}}return t}function f(e,t,i){try{const r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function m(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class g extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,i){let r=!0;const n=i.data||i.spriteData;return this._validateStretch(i.stretchX,n&&n.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,n&&n.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){if(!e)return!0;if(4!==e.length)return!1;const i=t.spriteData,r=i&&i.width||t.data.width,n=i&&i.height||t.data.height;return!(e[0]<0||r<e[0]||e[1]<0||n<e[1]||e[2]<0||r<e[2]||e[3]<0||n<e[3]||e[2]<e[0]||e[3]<e[1])}updateImage(e,t,i=!0){const r=this.getImage(e);if(i&&(r.data.width!==t.data.width||r.data.height!==t.data.height))throw new Error(`size mismatch between old image (${r.data.width}x${r.data.height}) and new image (${t.data.width}x${t.data.height}).`);t.version=r.version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){const t=this.images[e];delete this.images[e],delete this.patterns[e],t.userImage&&t.userImage.onRemove&&t.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise((t,i)=>{let r=!0;if(!this.isLoaded())for(const n of e)this.images[n]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}_getImagesForIds(e){const i={};for(const r of e){let e=this.getImage(r);e||(this.fire(new t.l("styleimagemissing",{id:r})),e=this.getImage(r)),e?i[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${r}" 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.`)}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else{const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},n=new t.I(i,r);this.patterns[e]={bin:i,position:n}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.T(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.p(e),n=this.atlasImage;n.resize({width:i||1,height:r||1});for(const s in this.patterns){const{bin:e}=this.patterns[s],i=e.x+1,r=e.y+1,o=this.getImage(s).data,a=o.width,l=o.height;t.R.copy(o,n,{x:0,y:0},{x:i,y:r},{width:a,height:l}),t.R.copy(o,n,{x:0,y:l-1},{x:i,y:r-1},{width:a,height:1}),t.R.copy(o,n,{x:0,y:0},{x:i,y:r+l},{width:a,height:1}),t.R.copy(o,n,{x:a-1,y:0},{x:i-1,y:r},{width:1,height:l}),t.R.copy(o,n,{x:0,y:0},{x:i+a,y:r},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),m(e)&&this.updateImage(i,e)}}cloneImages(){const e={};for(const t in this.images){const i=this.images[t];e[t]=Object.assign(Object.assign({},i),{data:i.data?i.data.clone():null})}return e}}const _=1e20;function y(e,t,i,r,n,s,o,a,l){for(let c=t;c<t+r;c++)x(e,i*s+c,s,n,o,a,l);for(let c=i;c<i+n;c++)x(e,c*s+t,1,r,o,a,l)}function x(e,t,i,r,n,s,o){s[0]=0,o[0]=-_,o[1]=_,n[0]=e[t];for(let a=1,l=0,c=0;a<r;a++){n[a]=e[t+a*i];const r=a*a;do{const e=s[l];c=(n[a]-n[e]+r-e*e)/(a-e)/2}while(c<=o[l]&&--l>-1);l++,s[l]=a,o[l]=c,o[l+1]=_}for(let a=0,l=0;a<r;a++){for(;o[l+1]<a;)l++;const r=s[l],c=a-r;e[t+a*i]=n[r]+c*c}}const v=t.v.layout_symbol["text-font"].default.join(",");class b{constructor(e,t,i){this.requestManager=e,this.localIdeographFontFamily=t,this.entries={},this.lang=i}setURL(e){this.url=e}getGlyphs(e){return t._(this,void 0,void 0,function*(){const t=[];for(const n in e)for(const i of e[n])t.push(this._getAndCacheGlyphsPromise(n,i));const i=yield Promise.all(t),r={};for(const{stack:e,id:n,glyph:s}of i)r[e]||(r[e]={}),r[e][n]=s&&{id:s.id,bitmap:s.bitmap.clone(),metrics:s.metrics};return r})}_getAndCacheGlyphsPromise(e,i){return t._(this,void 0,void 0,function*(){let t=this.entries[e];t||(t=this.entries[e]={glyphs:{},requests:{},ranges:{}});let r=t.glyphs[i];return void 0!==r?{stack:e,id:i,glyph:r}:!this.url||this._charUsesLocalIdeographFontFamily(i)?(r=t.glyphs[i]=this._drawGlyph(t,e,i),{stack:e,id:i,glyph:r}):yield this._downloadAndCacheRangePromise(e,i)})}_downloadAndCacheRangePromise(e,i){return t._(this,void 0,void 0,function*(){const t=this.entries[e],r=Math.floor(i/256);if(t.ranges[r])return{stack:e,id:i,glyph:null};if(!t.requests[r]){const i=b.loadGlyphRange(e,r,this.url,this.requestManager);t.requests[r]=i}try{const n=yield t.requests[r];for(const e in n)t.glyphs[+e]=n[+e];return t.ranges[r]=!0,{stack:e,id:i,glyph:n[i]||null}}catch(n){const o=t.glyphs[i]=this._drawGlyph(t,e,i);return this._warnOnMissingGlyphRange(o,r,i,n),{stack:e,id:i,glyph:o}}})}_warnOnMissingGlyphRange(e,i,r,n){const s=256*i,o=s+255,a=r.toString(16).padStart(4,"0").toUpperCase();t.w(`Unable to load glyph range ${i}, ${s}-${o}. Rendering codepoint U+${a} locally instead. ${n}`)}_charUsesLocalIdeographFontFamily(e){return!!this.localIdeographFontFamily&&t.q(e)}_drawGlyph(e,i,r){const n=i===v&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(r),s=n?"ideographTinySDF":"tinySDF";e[s]||(e[s]=this._createTinySDF(n?this.localIdeographFontFamily:i));const o=e[s].draw(String.fromCodePoint(r)),a=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(r));return{id:r,bitmap:new t.r({width:o.width||60,height:o.height||60},o.data),metrics:{width:a?0:o.glyphWidth/2||24,height:o.glyphHeight/2||24,left:o.glyphLeft/2+.5||0,top:o.glyphTop/2-27.5||-8,advance:a?0:o.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(e){const t=e?e.split(","):[];t.push("sans-serif");const i=t.map(e=>/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(",");return new b.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:i,fontWeight:this._fontWeight(t[0]),fontStyle:this._fontStyle(t[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let i;for(const[r,n]of Object.entries(t))new RegExp(`\\b${r}\\b`,"i").test(e)&&(i=`${n}`);return i}destroy(){for(const e in this.entries){const t=this.entries[e];t.tinySDF&&(t.tinySDF=null),t.ideographTinySDF&&(t.ideographTinySDF=null),t.glyphs={},t.requests={},t.ranges={}}this.entries={}}}b.loadGlyphRange=function(e,i,r,n){return t._(this,void 0,void 0,function*(){const s=256*i,o=s+255,a=yield n.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${s}-${o}`),"Glyphs"),l=yield t.n(a,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${s}-${o}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c})},b.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:s="normal",fontStyle:o="normal",lang:a=null}={}){this.buffer=t,this.cutoff=r,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),h=this.ctx=c.getContext("2d",{willReadFrequently:!0});h.font=`${o} ${s} ${e}px ${n}`,h.textBaseline="alphabetic",h.textAlign="left",h.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){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:s}=this.ctx.measureText(e),o=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-n))),l=Math.min(this.size-this.buffer,o+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:o,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:x}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+o);const v=f.getImageData(m,m,a,l);x.fill(_,0,u),g.fill(0,0,u);for(let y=0;y<l;y++)for(let e=0;e<a;e++){const t=v.data[4*(y*a+e)+3]/255;if(0===t)continue;const i=(y+m)*c+e+m;if(1===t)x[i]=0,g[i]=_;else{const e=.5-t;x[i]=e>0?e*e:0,g[i]=e<0?e*e:0}}y(x,0,0,c,h,c,this.f,this.v,this.z),y(g,m,m,a,l,c,this.f,this.v,this.z);for(let _=0;_<u;_++){const e=Math.sqrt(x[_])-Math.sqrt(g[_]);d[_]=Math.round(255-255*(e/this.radius+this.cutoff))}return p}};class w{constructor(){this.specification=t.u.light.position}possiblyEvaluate(e,i){return t.F(e.expression.evaluate(i))}interpolate(e,i,r){return{x:t.G.number(e.x,i.x,r),y:t.G.number(e.y,i.y,r),z:t.G.number(e.z,i.z,r)}}}let T;class S extends t.E{constructor(e){super(),T=T||new t.t({anchor:new t.D(t.u.light.anchor),position:new w,color:new t.D(t.u.light.color),intensity:new t.D(t.u.light.intensity)}),this._transitionable=new t.x(T,void 0),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,i={}){if(!this._validate(t.y,e,i))for(const r in e){const i=e[r];r.endsWith(t.z)?this._transitionable.setTransition(r.slice(0,-t.z.length),i):this._transitionable.setValue(r,i)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,i,r){return(!r||!1!==r.validate)&&t.B(this,e.call(t.C,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.u}))}}const P=new t.t({"sky-color":new t.D(t.u.sky["sky-color"]),"horizon-color":new t.D(t.u.sky["horizon-color"]),"fog-color":new t.D(t.u.sky["fog-color"]),"fog-ground-blend":new t.D(t.u.sky["fog-ground-blend"]),"horizon-fog-blend":new t.D(t.u.sky["horizon-fog-blend"]),"sky-horizon-blend":new t.D(t.u.sky["sky-horizon-blend"]),"atmosphere-blend":new t.D(t.u.sky["atmosphere-blend"])});class I extends t.E{constructor(e){super(),this._transitionable=new t.x(P,void 0),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.H(0))}setSky(e,i={}){if(!this._validate(t.J,e,i)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const i in e){const r=e[i];i.endsWith(t.z)?this._transitionable.setTransition(i.slice(0,-t.z.length),r):this._transitionable.setValue(i,r)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,i,r={}){return!1!==(null==r?void 0:r.validate)&&t.B(this,e.call(t.C,t.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:t.u})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class M{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,t){const i=e.join(",")+String(t);return this.dashEntry[i]||(this.dashEntry[i]=this.addDash(e,t)),this.dashEntry[i]}getDashRanges(e,t,i){const r=[];let n=e.length%2==1?-e[e.length-1]*i:0,s=e[0]*i,o=!0;r.push({left:n,right:s,isDash:o,zeroLength:0===e[0]});let a=e[0];for(let l=1;l<e.length;l++){o=!o;const t=e[l];n=a*i,a+=t,s=a*i,r.push({left:n,right:s,isDash:o,zeroLength:0===t})}return r}addRoundDash(e,t,i){const r=t/2;for(let n=-i;n<=i;n++){const t=this.width*(this.nextRow+i+n);let s=0,o=e[s];for(let a=0;a<this.width;a++){a/o.right>1&&(o=e[++s]);const l=Math.abs(a-o.left),c=Math.abs(a-o.right),h=Math.min(l,c);let u;const d=n/i*(r+1);if(o.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e)}else u=r-Math.sqrt(h*h+d*d);this.data[t+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(e){for(let o=e.length-1;o>=0;--o){const t=e[o],i=e[o+1];t.zeroLength?e.splice(o,1):i&&i.isDash===t.isDash&&(i.left=t.left,e.splice(o,1))}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const r=this.width*this.nextRow;let n=0,s=e[n];for(let o=0;o<this.width;o++){o/s.right>1&&(s=e[++n]);const t=Math.abs(o-s.left),i=Math.abs(o-s.right),a=Math.min(t,i);this.data[r+o]=Math.max(0,Math.min(255,(s.isDash?a:-a)+128))}}addDash(e,i){const r=i?7:0,n=2*r+1;if(this.nextRow+n>this.height)return t.w("LineAtlas out of space"),null;let s=0;for(let t=0;t<e.length;t++)s+=e[t];if(0!==s){const t=this.width/s,n=this.getDashRanges(e,this.width,t);i?this.addRoundDash(n,t,r):this.addRegularDash(n)}const o={y:this.nextRow+r,height:2*r,width:s};return this.nextRow+=n,this.dirty=!0,o}bind(e){const t=e.gl;this.texture?(t.bindTexture(t.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,this.height,t.ALPHA,t.UNSIGNED_BYTE,this.data))):(this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.ALPHA,this.width,this.height,0,t.ALPHA,t.UNSIGNED_BYTE,this.data))}}const E="maplibre_preloaded_worker_pool";class C{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<C.workerCount;)this.workers.push(new Worker(t.c.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],0===this.numActive()&&(this.workers.forEach(e=>{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[E]}numActive(){return Object.keys(this.active).length}}const A=Math.floor(a.hardwareConcurrency/2);let D,z;function k(){return D||(D=new C),D}C.workerCount=t.K(globalThis)?Math.max(Math.min(A,3),1):1;class R{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let n=0;n<r.length;n++){const e=new t.L(r[n],i);e.name=`Worker ${n}`,this.actors.push(e)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,t){const i=[];for(const r of this.actors)i.push(r.sendAsync({type:e,data:t}));return Promise.all(i)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.actors.forEach(e=>{e.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t)}unregisterMessageHandler(e){for(const t of this.actors)t.unregisterMessageHandler(e)}}function L(){return z||(z=new R(k(),t.M),z.registerMessageHandler("GR",(e,i,r)=>t.m(i,r))),z}function F(e,i){const r=t.N();return t.O(r,r,[1,1,0]),t.Q(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.S(r,r,e.calculatePosMatrix(i.toUnwrapped())):r}function B(e,t,i,r,n,s,o){var a;const l=function(e,t,i){if(e)for(const r of e){const e=t[r];if(e&&e.source===i&&"fill-extrusion"===e.type)return!0}else for(const r in t){const e=t[r];if(e.source===i&&"fill-extrusion"===e.type)return!0}return!1}(null!==(a=null==n?void 0:n.layers)&&void 0!==a?a:null,t,e.id),c=s.maxPitchScaleFactor(),h=e.tilesIn(r,c,l);h.sort(O);const u=[];for(const d of h)u.push({wrappedTileID:d.tileID.wrapped().key,queryResults:d.tile.queryRenderedFeatures(t,i,e.getState(),d.queryGeometry,d.cameraQueryGeometry,d.scale,n,s,c,F(s,d.tileID),o?(e,t)=>o(d.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const r of e[i])V(r,t);return e}(function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,s=i[n]=i[n]||{};for(const i in e){const r=e[i],n=s[i]=s[i]||{},o=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,o.push(e))}}return t}(u),e)}function O(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function V(e,t){const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}function j(e,i,r,n){return t._(this,void 0,void 0,function*(){let s=e;if(e.url?s=(yield t.j(yield i.transformRequest(e.url,"Source"),r)).data:yield a.frameAsync(r,n),!s)return null;const o=t.U(t.e(s,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in s&&s.vector_layers&&(o.vectorLayerIds=s.vector_layers.map(e=>e.id)),o})}class N{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 t.V?new t.V(e.lng,e.lat):t.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.V?new t.V(e.lng,e.lat):t.V.convert(e),this}extend(e){const i=this._sw,r=this._ne;let n,s;if(e instanceof t.V)n=e,s=e;else{if(!(e instanceof N))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(N.convert(e)):this.extend(t.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.V.convert(e)):this;if(n=e._sw,s=e._ne,!n||!s)return this}return i||r?(i.lng=Math.min(n.lng,i.lng),i.lat=Math.min(n.lat,i.lat),r.lng=Math.max(s.lng,r.lng),r.lat=Math.max(s.lat,r.lat)):(this._sw=new t.V(n.lng,n.lat),this._ne=new t.V(s.lng,s.lat)),this}getCenter(){return new t.V((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 t.V(this.getWest(),this.getNorth())}getSouthEast(){return new t.V(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:i,lat:r}=t.V.convert(e);let n=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}intersects(e){if(!((e=N.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;const i=Math.abs(this.getEast()-this.getWest()),r=Math.abs(e.getEast()-e.getWest());if(i>=360||r>=360)return!0;const n=t.W(this.getWest(),-180,180),s=t.W(this.getEast(),-180,180),o=t.W(e.getWest(),-180,180),a=t.W(e.getEast(),-180,180),l=n>s,c=o>a;return!(!l||!c)||(l?a>=n||o<=s:c?s>=o||n<=a:o<=s&&a>=n)}static convert(e){return e instanceof N?e:e?new N(e):e}static fromLngLat(e,i=0){const r=360*i/40075017,n=r/Math.cos(Math.PI/180*e.lat);return new N(new t.V(e.lng-n,e.lat-r),new t.V(e.lng+n,e.lat+r))}adjustAntiMeridian(){const e=new t.V(this._sw.lng,this._sw.lat),i=new t.V(this._ne.lng,this._ne.lat);return new N(e,e.lng>i.lng?new t.V(i.lng+360,i.lat):i)}}class U{constructor(e,t,i){this.bounds=N.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.Y(this.bounds.getWest())*i),n=Math.floor(t.X(this.bounds.getNorth())*i),s=Math.ceil(t.Y(this.bounds.getEast())*i),o=Math.ceil(t.X(this.bounds.getSouth())*i);return e.x>=r&&e.x<s&&e.y>=n&&e.y<o}}class G extends t.E{constructor(e,i,r,n){if(super(),this.id=e,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.e(this,t.U(i,["url","scheme","tileSize","promoteId","encoding"])),this._options=t.e({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n)}load(){return t._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield j(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new U(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,t.Z(e)||this.fire(new t.k(e))}})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:yield this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:yield this._getOverzoomParameters(e),etag:e.etag};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,i)=>{e.reloadPromise={resolve:t,reject:i}})}else e.actor=this.dispatcher.getActor(),r="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t);const n={};return(null==t?void 0:t.etagUnmodified)&&(n.unmodified=!0),n}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}})}_getOverzoomParameters(e){return t._(this,void 0,void 0,function*(){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:yield this.map._requestManager.transformRequest(i,"Tile")}})}_afterTileLoadWorkerResponse(e,t){if((null==t?void 0:t.resourceTiming)&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.etag=null==t?void 0:t.etag,e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class $ extends t.E{constructor(e,i,r,n){super(),this.id=e,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.U(i,["url","scheme","tileSize"]))}load(){return t._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield j(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new U(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,t.Z(e)||this.fire(new t.k(e))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const r=yield u.getImage(yield this.map._requestManager.transformRequest(i,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(r&&r.data){this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&e.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});const i=this.map.painter.context,n=i.gl,s=r.data;e.texture=this.map.painter.getTileTexture(s.width),e.texture?e.texture.update(s,{useMipmap:!0}):(e.texture=new t.T(i,s,n.RGBA,{useMipmap:!0}),e.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class Z extends ${constructor(e,i,r,n){super(e,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=yield this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield u.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const n=t.b(r)&&t.$()?r:yield this.readImageNow(r),s={type:this.type,uid:e.uid,source:this.id,rawImageData:n,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(e.actor&&"expired"!==e.state&&"reloading"!==e.state)return;e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor());const o=yield e.actor.sendAsync({type:"LDT",data:s});e.dem=o,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}readImageNow(e){return t._(this,void 0,void 0,function*(){if("undefined"!=typeof VideoFrame&&t.a0()){const i=e.width+2,r=e.height+2;try{return new t.R({width:i,height:r},yield t.a1(e,-1,-1,i,r))}catch(e){}}return a.getImageData(e,1)})}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,s=0===i.x?e.wrap-1:e.wrap,o=(i.x+1+r)%r,a=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.a2(e.overscaledZ,s,i.z,n,i.y).key]={backfilled:!1},l[new t.a2(e.overscaledZ,a,i.z,o,i.y).key]={backfilled:!1},i.y>0&&(l[new t.a2(e.overscaledZ,s,i.z,n,i.y-1).key]={backfilled:!1},l[new t.a2(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.a2(e.overscaledZ,a,i.z,o,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new t.a2(e.overscaledZ,s,i.z,n,i.y+1).key]={backfilled:!1},l[new t.a2(e.overscaledZ,e.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new t.a2(e.overscaledZ,a,i.z,o,i.y+1).key]={backfilled:!1}),l}unloadTile(e){return t._(this,void 0,void 0,function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&(yield e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}}))})}}function q(e,t){return t?e.properties[t]:e.id}function W(e,t){const i={id:e.id};if(t.removeAllProperties&&(delete e.removeProperties,delete e.addOrUpdateProperties,delete t.removeProperties),t.removeProperties)for(const r of t.removeProperties){const t=e.addOrUpdateProperties.findIndex(e=>e.key===r);t>-1&&e.addOrUpdateProperties.splice(t,1)}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function X(e){var t,i;if(!e)return{};const r={};return r.removeAll=e.removeAll,r.remove=new Set(e.remove||[]),r.add=new Map(null===(t=e.add)||void 0===t?void 0:t.map(e=>[e.id,e])),r.update=new Map(null===(i=e.update)||void 0===i?void 0:i.map(e=>[e.id,e])),r}function H(e){return e&&0!==e.length?"number"==typeof e[0]?[e]:e.flatMap(e=>H(e)):[]}function Y(e){return"GeometryCollection"===e.type?e.geometries.flatMap(e=>Y(e)):H(e.coordinates)}function K(e){const t=new N;let i;switch(e.type){case"FeatureCollection":i=e.features.flatMap(e=>Y(e.geometry));break;case"Feature":i=Y(e.geometry);break;default:i=Y(e)}if(0===i.length)return t;for(let r=0;r<i.length;r++){const[e,n]=i[r];t.extend([e,n])}return t}class J extends t.E{constructor(e,i,r,n){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:i.data},this.actor=r.getActor(),this.setEventedParent(n),this._data="string"==typeof i.data?{url:i.data}:{geojson:i.data},this._options=t.e({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId,void 0!==i.clusterMaxZoom&&this.maxzoom<=i.clusterMaxZoom&&t.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${i.clusterMaxZoom}".`),this.workerOptions=t.e({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0!==i.buffer?i.buffer:128),tolerance:this._pixelsToTileUnits(void 0!==i.tolerance?i.tolerance:.375),extent:t.a5,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1,promoteId:"string"==typeof i.promoteId?i.promoteId:void 0,cluster:i.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(i.clusterMaxZoom),minPoints:Math.max(2,i.clusterMinPoints||2),extent:t.a5,radius:this._pixelsToTileUnits(i.clusterRadius||50),log:!1,generateId:i.generateId||!1}},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions)}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(e){return e*(t.a5/this.tileSize)}_getClusterMaxZoom(e){const i=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||void 0===e||t.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${i}"`),i}load(){return t._(this,void 0,void 0,function*(){yield this._updateWorkerData()})}onAdd(e){this.map=e,this.load()}setData(e,t){this._data="string"==typeof e?{url:e}:{geojson:e},this._pendingWorkerUpdate={data:e};const i=this._updateWorkerData();return t?i:this}updateData(e,t){this._pendingWorkerUpdate.diff=function(e,t){if(!e)return t||{};if(!t)return e||{};const i=X(e),r=X(t);!function(e,t){t.removeAll&&(e.add.clear(),e.update.clear(),e.remove.clear(),t.remove.clear());for(const i of t.remove)e.add.delete(i),e.update.delete(i);for(const[i,r]of t.update){const n=e.update.get(i);n&&(t.update.set(i,W(n,r)),e.update.delete(i))}}(i,r);const n={};if((i.removeAll||r.removeAll)&&(n.removeAll=!0),n.remove=new Set([...i.remove,...r.remove]),n.add=new Map([...i.add,...r.add]),n.update=new Map([...i.update,...r.update]),n.remove.size&&n.add.size)for(const s of n.add.keys())n.remove.delete(s);return function(e){const t={};return e.removeAll&&(t.removeAll=e.removeAll),e.remove&&(t.remove=Array.from(e.remove)),e.add&&(t.add=Array.from(e.add.values())),e.update&&(t.update=Array.from(e.update.values())),t}(n)}(this._pendingWorkerUpdate.diff,e);const i=this._updateWorkerData();return t?i:this}getData(){return t._(this,void 0,void 0,function*(){return this._data.url&&(yield this.once("data")),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}})}getBounds(){return t._(this,void 0,void 0,function*(){return K(yield this.getData())})}setClusterOptions(e){return this.workerOptions.geojsonVtOptions.cluster=e.cluster,void 0!==e.clusterRadius&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),void 0!==e.clusterMaxZoom&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,t,i){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:t,offset:i}})}_updateWorkerData(){return t._(this,void 0,void 0,function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void t.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:e,diff:i,updateCluster:r}=this._pendingWorkerUpdate,n=this._getLoadGeoJSONParameters(e,i,r);void 0!==e?this._pendingWorkerUpdate.data=void 0:i?this._pendingWorkerUpdate.diff=void 0:r&&(this._pendingWorkerUpdate.updateCluster=void 0),yield this._dispatchWorkerUpdate(n)})}_getLoadGeoJSONParameters(e,i,r){return t._(this,void 0,void 0,function*(){const n=t.e({type:this.type},this.workerOptions);return"string"==typeof e?(n.request=yield this.map._requestManager.transformRequest(a.resolveURL(e),"Source"),n.request.collectResourceTiming=this._collectResourceTiming,n):void 0!==e?(n.data=e,n):i?(n.dataDiff=i,n):r?(n.updateCluster=!0,n):void 0})}_dispatchWorkerUpdate(e){return t._(this,void 0,void 0,function*(){this._isUpdatingWorker=!0,this.fire(new t.l("dataloading",{dataType:"source"}));try{const i=yield e,r=yield this.actor.sendAsync({type:"LD",data:i});if(this._isUpdatingWorker=!1,this._removed||r.abandoned)return void this.fire(new t.l("dataabort",{dataType:"source"}));r.data&&(this._data={geojson:r.data});const n=this._applyDiffToSource(i.dataDiff),s=this._getShouldReloadTileOptions(n),o={dataType:"source"};this._applyResourceTiming(o,r),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"content",shouldReloadTileOptions:s})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}})}_applyResourceTiming(e,i){var r;if(!this._collectResourceTiming)return;const n=null===(r=i.resourceTiming)||void 0===r?void 0:r[this.id];if(!n)return;const s=n.slice(0);(null==s?void 0:s.length)&&t.e(e,{resourceTiming:s})}_applyDiffToSource(e){if(!e)return;const t="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const e=function(e,t){const i=new Map;if(null==e)return i;if(null==e.type)return i;if("Feature"===e.type){const r=q(e,t);if(null==r)return;return i.set(r,e),i}if("FeatureCollection"===e.type){const r=new Set;for(const n of e.features){const e=q(n,t);if(null==e)return;if(r.has(e))return;r.add(e),i.set(e,n)}return i}}(this._data.geojson,t);if(!e)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:e}}if(!this._data.updateable)return;const i=function(e,t,i){var r,n;const s=[];if(t.removeAll)e.clear();else if(t.remove)for(const o of t.remove){const t=e.get(o);t&&(s.push(t.geometry),e.delete(o))}if(t.add)for(const o of t.add){const t=q(o,i);if(null==t)continue;const r=e.get(t);r&&s.push(r.geometry),s.push(o.geometry),e.set(t,o)}if(t.update)for(const o of t.update){const t=e.get(o.id);if(!t)continue;const i=!!o.newGeometry,a=o.removeAllProperties||(null===(r=o.removeProperties)||void 0===r?void 0:r.length)>0||(null===(n=o.addOrUpdateProperties)||void 0===n?void 0:n.length)>0;if(!i&&!a)continue;s.push(t.geometry);const l=Object.assign({},t);if(e.set(o.id,l),i&&(s.push(o.newGeometry),l.geometry=o.newGeometry),a){if(l.properties=o.removeAllProperties?{}:Object.assign({},l.properties||{}),o.removeProperties)for(const e of o.removeProperties)delete l.properties[e];if(o.addOrUpdateProperties)for(const{key:e,value:t}of o.addOrUpdateProperties)l.properties[e]=t}}return s}(this._data.updateable,e,t);return e.removeAll||this._options.cluster?void 0:i}_getShouldReloadTileOptions(e){if(e)return{affectedBounds:e.filter(Boolean).map(e=>K(e))}}shouldReloadTile(e,{affectedBounds:i}){if("loading"===e.state)return!0;if("unloaded"===e.state)return!1;const{buffer:r,extent:n}=this.workerOptions.geojsonVtOptions,s=function({x:e,y:i,z:r},n=0){const s=t.a3((e-n)/Math.pow(2,r)),o=t.a4((i+1+n)/Math.pow(2,r)),a=t.a3((e+1+n)/Math.pow(2,r)),l=t.a4((i-n)/Math.pow(2,r));return new N([s,o],[a,l])}(e.tileID.canonical,r/n);for(const t of i)if(s.intersects(t))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};e.abortController=new AbortController;const r=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(r,this.map.painter,"RT"===t)})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return t.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class Q extends t.E{constructor(e,t,i,r){super(),this.flippedWindingOrder=!1,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.setEventedParent(r),this.options=t}load(e){return t._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield u.getImage(yield this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,t.Z(e)||this.fire(new t.k(e))}})}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const i=e.map(t.a6.fromLngLat);var r;return this.tileID=function(e){const i=t.a7.fromPoints(e),r=i.width(),n=i.height(),s=Math.max(r,n),o=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),a=Math.pow(2,o);return new t.a9(o,Math.floor((i.minX+i.maxX)/2*a),Math.floor((i.minY+i.maxY)/2*a))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(e=>this.tileID.getTilePoint(e)._round()),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new t.T(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:i,minY:r,maxX:n,maxY:s}=t.a7.fromPoints(e),o={};for(let a=0;a<=t.a8;a++){const e=Math.pow(2,a),t=Math.floor(i*e),l=Math.floor(r*e),c=Math.floor(n*e),h=Math.floor(s*e),u=(t%e+e)%e,d=c%e,p=Math.floor(t/e),f=Math.floor(c/e);o[a]={minWrap:p,maxWrap:f,minTileXWrapped:u,maxTileXWrapped:d,minTileY:l,maxTileY:h}}return o}}class ee extends Q{constructor(e,t,i,r){super(e,t,i,r),this._onPlayingHandler=()=>{var e;null===(e=this.map)||void 0===e||e.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=t}load(){return t._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push((yield this.map._requestManager.transformRequest(t,"Source")).url);try{const e=yield t.aa(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new t.k(e))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;e<i.start(0)||e>i.end(0)?this.fire(new t.k(new t.ab(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener("playing",this._onPlayingHandler),this.video.pause())}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.T(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class te extends Q{constructor(e,i,r,n){super(e,i,r,n),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 t.k(new t.ab(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.ab(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.ab(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.ab(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.k(new t.ab(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return t._(this,void 0,void 0,function*(){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 t.k(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(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new t.T(i,this.canvas,r.RGBA,{premultiply:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));let n=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.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}}const ie={},re=e=>{switch(e){case"geojson":return J;case"image":return Q;case"raster":return $;case"raster-dem":return Z;case"vector":return G;case"video":return ee;case"canvas":return te}return ie[e]},ne="RTLPluginLoaded";class se extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=L()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status="error",e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()})}_requestImport(){return t._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(ne))})}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let oe=null;function ae(){return oe||(oe=new se),oe}var le,ce;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(le||(le={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(ce||(ce={}));class he{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=t.ac(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=r}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=c(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,i,r){if(!0!==(null==e?void 0:e.etagUnmodified))if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestEncoding=e.encoding,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const r of e){const e=r.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.id]=r}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.ae){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.ae&&i.hasRTLText){this.hasRTLText=!0,ae().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new t.ad;else this.state="loaded"}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,n,s,o,a,l,c,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:n,scale:s,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:o,queryPadding:this.queryPadding*l,getElevation:h},e,t,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),s=i&&i.sourceLayer?i.sourceLayer:"",o=n[t.af]||n[s];if(!o)return;const a=t.ag(null==i?void 0:i.filter,null==i?void 0:i.globalState),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let d=0;d<o.length;d++){const i=o.feature(d);if(a.needGeometry){const e=t.ah(i,!0);if(!a.filter(new t.H(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!a.filter(new t.H(this.tileID.overscaledZ),i))continue;const n=r.getId(i,s),p=new t.ai(i,l,c,h,n);p.tile=u,e.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const i=this.expirationTime;if(e.cacheControl){const i=t.aj(e.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let t=!1;if(this.expirationTime>e)t=!1;else if(i)if(this.expirationTime<i)t=!0;else{const r=this.expirationTime-i;r?this.expirationTime=e+Math.max(r,3e4):t=!0}else t=!0;t?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,i){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(e).length)return;const r=this.latestFeatureIndex.loadVTLayers();for(const n in this.buckets){if(!i.style.hasLayer(n))continue;const s=this.buckets[n],o=s.layers[0].sourceLayer||t.af,a=r[o],l=e[o];if(!a||!l||0===Object.keys(l).length)continue;s.update(l,a,this.imageAtlas&&this.imageAtlas.patternPositions||{},this.dashPositions||{});const c=i&&i.style&&i.style.getLayer(n);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(s)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<c()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(e){this.symbolFadeHoldUntil=c()+e}setDependencies(e,t){const i={};for(const r of t)i[r]=!0;this.dependencies[e]=i}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return!0}return!1}}class ue{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(e,i,r){const n=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][n]=this.stateChanges[e][n]||{},t.e(this.stateChanges[e][n],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==n&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][n]){this.deletedStates[e][n]={};for(const t in this.state[e][n])r[t]||(this.deletedStates[e][n][t]=null)}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][n]&&null===this.deletedStates[e][n][t]&&delete this.deletedStates[e][n][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,i){const r=String(i),n=t.e({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return{};for(const e in t)delete n[e]}return n}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,i){const r={};for(const n in this.stateChanges){this.state[n]=this.state[n]||{};const e={};for(const i in this.stateChanges[n])this.state[n][i]||(this.state[n][i]={}),t.e(this.state[n][i],this.stateChanges[n][i]),e[i]=this.state[n][i];r[n]=e}for(const n in this.deletedStates){this.state[n]=this.state[n]||{};const e={};if(null===this.deletedStates[n])for(const t in this.state[n])e[t]={},this.state[n][t]={};else for(const t in this.deletedStates[n]){if(null===this.deletedStates[n][t])this.state[n][t]={};else for(const e of Object.keys(this.deletedStates[n][t]))delete this.state[n][t][e];e[t]=this.state[n][t]}r[n]=r[n]||{},t.e(r[n],e)}this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length&&(this.revision++,e.setFeatureState(r,i))}}const de=89.25;function pe(e,i){const r=t.ak(i.lat,-t.al,t.al);return new t.P(t.Y(i.lng)*e,t.X(r)*e)}function fe(e,i){return new t.a6(i.x/e,i.y/e).toLngLat()}function me(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.am(90-e.pitch)),Math.tan(t.am(de-e.pitch)))}function ge(e,i){const r=e.canonical,n=i/t.an(r.z),s=r.x+Math.pow(2,r.z)*e.wrap,o=t.ao(new Float64Array(16));return t.O(o,o,[s*n,r.y*n,0]),t.Q(o,o,[n/t.a5,n/t.a5,1]),o}function _e(e,i,r,n,s){const o=t.a6.fromLngLat(e,i),a=s*t.ap(1,e.lat),{x:l,y:c,z:h}=ye(r,n);return new t.a6(o.x+a*-l,o.y+a*-c,o.z+a*-h)}function ye(e,i){const r=t.am(e),n=t.am(i),s=Math.cos(-r),o=Math.sin(r);return{x:o*Math.sin(n),y:-o*Math.cos(n),z:s}}function xe(e,t,i){const r=t.intersectsFrustum(e);if(!i||0===r)return r;const n=t.intersectsPlane(i);return 0===n?0:2===r&&2===n?2:1}function ve(e,t,i){let r=0;const n=(i-t)/10;for(let s=0;s<10;s++)r+=n*Math.pow(Math.cos(t+(s+.5)/10*(i-t)),e);return r}function be(e,i){return function(r,n,s,o,a){const l=2*((e-1)/t.aq(Math.cos(t.am(de-a))/Math.cos(t.am(de)))-1),c=Math.acos(s/o),h=2*ve(l-1,0,t.am(a/2)),u=Math.min(t.am(de),c+t.am(a/2)),d=ve(l-1,Math.min(u,c-t.am(a/2)),u),p=Math.atan(n/s),f=Math.hypot(n,s);let m=r;return m+=t.aq(o/f/Math.max(.5,Math.cos(t.am(a/2)))),m+=l*t.aq(Math.cos(p))/2,m-=t.aq(Math.max(1,d/h/i))/2,m}}const we=be(9.314,3);function Te(e,i){const r=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.aq(e.tileSize/i.tileSize));return Math.max(0,r)}function Se(e,i){const r=e.getCameraFrustum(),n=e.getClippingPlane(),s=e.screenPointToMercatorCoordinate(e.getCameraPoint()),o=t.a6.fromLngLat(e.center,e.elevation);s.z=o.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const a=e.getCoveringTilesDetailsProvider(),l=a.allowVariableZoom(e,i),c=Te(e,i),h=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),u),p=Math.pow(2,d),f=[p*s.x,p*s.y,0],m=[p*o.x,p*o.y,0],g=Math.hypot(o.x-s.x,o.y-s.y),_=Math.abs(o.z-s.z),y=Math.hypot(g,_),x=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),v=[],b=[];if(e.renderWorldCopies&&a.allowWorldCopies())for(let t=1;t<=3;t++)v.push(x(-t)),v.push(x(t));for(v.push(x(0));v.length>0;){const p=v.pop(),g=p.x,x=p.y;let w=p.fullyVisible;const T={x:g,y:x,z:p.zoom},S=a.getTileBoundingVolume(T,p.wrap,e.elevation,i);if(!w){const e=xe(r,S,n);if(0===e)continue;w=2===e}const P=a.distanceToTile2d(s.x,s.y,T,S);let I=c;l&&(I=(i.calculateTileZoom||we)(e.zoom+t.aq(e.tileSize/i.tileSize),P,_,y,e.fov)),I=(i.roundZoom?Math.round:Math.floor)(I),I=Math.max(0,I);const M=Math.min(I,u);if(p.wrap=a.getWrap(o,T,p.wrap),p.zoom>=M){if(p.zoom<h)continue;const e=d-p.zoom,r=f[0]-.5-(g<<e),n=f[1]-.5-(x<<e),s=i.reparseOverscaled?Math.max(p.zoom,I):p.zoom;b.push({tileID:new t.a2(p.zoom===u?s:p.zoom,p.wrap,p.zoom,g,x),distanceSq:t.ar([m[0]-.5-g,m[1]-.5-x]),tileDistanceToCamera:Math.sqrt(r*r+n*n)})}else for(let e=0;e<4;e++)v.push({zoom:p.zoom+1,x:(g<<1)+e%2,y:(x<<1)+(e>>1),wrap:p.wrap,fullyVisible:w})}return b.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}const Pe=t.a7.fromPoints([new t.P(0,0),new t.P(t.a5,t.a5)]);function Ie(e){return"raster"===e||"image"===e||"video"===e}function Me(e,t,i,r,n,s,o){if(!t.hasData())return!1;const{tileID:a,fadingRole:l,fadingDirection:c,fadingParentID:h}=t;if(l===le.Base&&c===ce.Incoming&&h)return i[h.key]=h,!0;const u=Math.max(a.overscaledZ-n,s);for(let d=a.overscaledZ-1;d>=u;d--){const n=a.scaledTo(d),s=e.getLoadedTile(n);if(s)return t.setCrossFadeLogic({fadingRole:le.Base,fadingDirection:ce.Incoming,fadingParentID:s.tileID,fadeEndTime:r+o}),s.setCrossFadeLogic({fadingRole:le.Parent,fadingDirection:ce.Departing,fadeEndTime:r+o}),i[n.key]=n,!0}return!1}function Ee(e,t,i,r,n,s){if(!t.hasData())return!1;const o=t.tileID.children(n);let a=Ce(e,t,o,i,r,n,s);if(a)return!0;for(const l of o)Ce(e,t,l.children(n),i,r,n,s)&&(a=!0);return a}function Ce(e,t,i,r,n,s,o){if(i[0].overscaledZ>=s)return!1;let a=!1;for(const l of i){const i=e.getLoadedTile(l);if(!i)continue;const{fadingRole:s,fadingDirection:c,fadingParentID:h}=i;s===le.Base&&c===ce.Departing&&h||(i.setCrossFadeLogic({fadingRole:le.Base,fadingDirection:ce.Departing,fadingParentID:t.tileID,fadeEndTime:n+o}),t.setCrossFadeLogic({fadingRole:le.Parent,fadingDirection:ce.Incoming,fadeEndTime:n+o})),r[l.key]=l,a=!0}return a}function Ae(e,t,i,r){const n=e.tileID;return!!e.selfFading||!e.hasData()&&!!t.has(n)&&(e.setSelfFadeLogic(i+r),!0)}function De(e,t){var i;e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0;let r=t.tileID.canonical.x-e.tileID.canonical.x;const n=t.tileID.canonical.y-e.tileID.canonical.y,s=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===r&&0===n||Math.abs(n)>1||(Math.abs(r)>1&&(1===Math.abs(r+s)?r+=s:1===Math.abs(r-s)&&(r-=s)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,n),(null===(i=e.neighboringTiles)||void 0===i?void 0:i[o])&&(e.neighboringTiles[o].backfilled=!0)))}class ze{constructor(){this._tiles={}}handleWrapJump(e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t}setFeatureState(e,t){for(const i in this._tiles)this._tiles[i].setFeatureState(e,t)}getAllTiles(){return Object.values(this._tiles)}getAllIds(e=!1){return e?Object.values(this._tiles).map(e=>e.tileID).sort(t.at).map(e=>e.key):Object.keys(this._tiles)}getTileById(e){return this._tiles[e]}setTile(e,t){this._tiles[e]=t}deleteTileById(e){delete this._tiles[e]}getLoadedTile(e){const t=this.getTileById(e.key);return(null==t?void 0:t.hasData())?t:null}isIdRenderable(e,t=!1){var i;return null===(i=this.getTileById(e))||void 0===i?void 0:i.isRenderable(t)}getRenderableIds(e=0,i){const r=[];for(const t of this.getAllIds())this.isIdRenderable(t,i)&&r.push(this.getTileById(t));return i?r.sort((i,r)=>{const n=i.tileID,s=r.tileID,o=new t.P(n.canonical.x,n.canonical.y)._rotate(-e),a=new t.P(s.canonical.x,s.canonical.y)._rotate(-e);return n.overscaledZ-s.overscaledZ||a.y-o.y||a.x-o.x}).map(e=>e.tileID.key):r.map(e=>e.tileID).sort(t.at).map(e=>e.key)}}class ke extends t.E{constructor(e,i,r){super(),this.id=e,this.dispatcher=r,this.on("data",e=>this._dataHandler(e)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,i,r)=>{const n=new(re(t.type))(e,t,i,r);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return n})(e,i,r,this),this._inViewTiles=new ze,this._outOfViewCache=new t.au(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new ue,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){for(const t of this._inViewTiles.getAllTiles())t.unloadVectorData();this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e),this._inViewTiles=new ze}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}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,this.terrain)}_loadTile(e,i,r){return t._(this,void 0,void 0,function*(){try{const t=yield this._source.loadTile(e);this._tileLoaded(e,i,r,t)}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const t of this._inViewTiles.getAllTiles())t.upload(e),t.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(e){var t;return this._inViewTiles.getRenderableIds(null===(t=this.transform)||void 0===t?void 0:t.bearingInRadians,e)}hasRenderableParent(e){const t=e.overscaledZ-1;if(t>=this._source.minzoom){const i=this.getLoadedTile(e.scaledTo(t));if(i)return this._inViewTiles.isIdRenderable(i.tileID.key)}return!1}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const i of this._inViewTiles.getAllIds()){const r=this._inViewTiles.getTileById(i);t&&!this._source.shouldReloadTile(r,t)||(e?this._reloadTile(i,"expired"):"errored"!==r.state&&this._reloadTile(i,"reloading"))}}}_reloadTile(e,i){return t._(this,void 0,void 0,function*(){const t=this._inViewTiles.getTileById(e);t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i))})}_tileLoaded(e,i,r,n){e.timeAdded=c(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),(null==n?void 0:n.unmodified)||("raster-dem"===this.getSource().type&&e.dem&&function(e,t){var i,r;const n=t.getRenderableIds();for(const s of n){if(!e.neighboringTiles||!e.neighboringTiles[s])continue;const n=t.getTileById(s);e.neighboringTiles[s].backfilled||De(e,n),(null===(r=null===(i=n.neighboringTiles)||void 0===i?void 0:i[e.tileID.key])||void 0===r?void 0:r.backfilled)||De(n,e)}}(e,this._inViewTiles),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID})))}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._inViewTiles.getTileById(e)}_retainLoadedChildren(e,t){const i=this._getLoadedDescendents(t),r=new Set;for(const n of t){const t=i[n.key];if(!(null==t?void 0:t.length)){r.add(n);continue}const s=n.overscaledZ+ke.maxOverzooming,o=t.filter(e=>e.tileID.overscaledZ<=s);if(!o.length){r.add(n);continue}const a=Math.min(...o.map(e=>e.tileID.overscaledZ)),l=o.filter(e=>e.tileID.overscaledZ===a).map(e=>e.tileID);for(const i of l)e[i.key]=i;this._areDescendentsComplete(l,a,n.overscaledZ)||r.add(n)}return r}_getLoadedDescendents(e){var t;const i={};for(const r of this._inViewTiles.getAllTiles().filter(e=>e.hasData()))for(const n of e)r.tileID.isChildOf(n)&&(i[t=n.key]||(i[t]=[])).push(r);return i}_areDescendentsComplete(e,t,i){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:Math.pow(4,t-i)===e.length}getLoadedTile(e){return this._inViewTiles.getLoadedTile(e)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,n=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?t.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._outOfViewCache.setMaxSize(s)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);this._prevLng=e,t&&(this._inViewTiles.handleWrapJump(t),this._resetTileReloadTimers())}update(e,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new t.a2(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(r=Se(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter(e=>this._source.hasTile(e)))):r=[],this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));const n=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const s=Te(e,this._source),o=this._updateRetainedTiles(r,s),a=Ie(this._source.type);a&&this._rasterFadeDuration>0&&!i&&function(e,i,r,n,s,o,a){const l=c(),h=t.as(i);for(const t of i){const i=e.getTileById(t.key);i.fadingDirection!==ce.Departing&&0!==i.fadeOpacity||i.resetFadeLogic(),Me(e,i,r,l,n,s,a)||Ee(e,i,r,l,o,a)||Ae(i,h,l,a)||i.resetFadeLogic()}}(this._inViewTiles,r,o,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),a?this._cleanUpRasterTiles(o):this._cleanUpVectorTiles(o)}_cleanUpRasterTiles(e){for(const t of this._inViewTiles.getAllIds())e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(const t of this._inViewTiles.getAllIds()){const i=this._inViewTiles.getTileById(t);e[t]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(t):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){const t=[];for(const i of e)if(i.canonical.z>this._source.minzoom){const e=i.scaledTo(i.canonical.z-1);t.push(e);const r=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));t.push(r)}return e.concat(t)}releaseSymbolFadeTiles(){for(const e of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(e).holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){var i;const r=new Set;for(const l of e)this._addTile(l).hasData()||r.add(l);const n=e.reduce((e,t)=>(e[t.key]=t,e),{}),s=this._retainLoadedChildren(n,r),o={},a=Math.max(t-ke.maxUnderzooming,this._source.minzoom);for(const l of s){let e=this._inViewTiles.getTileById(l.key),t=null==e?void 0:e.wasRequested();for(let r=l.overscaledZ-1;r>=a;--r){const s=l.scaledTo(r);if(o[s.key])break;if(o[s.key]=!0,e=this.getTile(s),!e&&t&&(e=this._addTile(s)),e){const r=e.hasData();if((r||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||t)&&(n[s.key]=s),t=e.wasRequested(),r)break}}}return n}_addTile(e){let i=this._inViewTiles.getTileById(e.key);if(i)return i;i=this._outOfViewCache.getAndRemove(e),i&&(i.resetFadeLogic(),this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null));const r=i;return i||(i=new he(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._inViewTiles.setTile(e.key,i),r||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_clearTileReloadTimer(e){const t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e of this._inViewTiles.getAllIds()){const t=this._inViewTiles.getTileById(e);this._setTileReloadTimer(e,t)}}refreshTiles(e){for(const t of this._inViewTiles.getAllIds()){const i=this._inViewTiles.getTileById(t);(this._inViewTiles.isIdRenderable(t)||"errored"==i.state)&&e.some(e=>e.equals(i.tileID.canonical))&&this._reloadTile(t,"expired")}}_removeTile(e){const t=this._inViewTiles.getTileById(e);t&&(t.uses--,this._inViewTiles.deleteTileById(e),this._clearTileReloadTimer(e),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._outOfViewCache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e of this._inViewTiles.getAllIds())this._removeTile(e);this._outOfViewCache.reset()}tilesIn(e,i,r){const n=[],s=this.transform;if(!s)return n;const o=s.getCoveringTilesDetailsProvider().allowWorldCopies(),a=r?s.getCameraQueryGeometry(e):e,l=e=>s.screenPointToMercatorCoordinate(e,this.terrain),c=this.transformBbox(e,l,!o),h=this.transformBbox(a,l,!o),u=this.getIds(),d=t.a7.fromPoints(h);for(let p=0;p<u.length;p++){const e=this._inViewTiles.getTileById(u[p]);if(e.holdingForSymbolFade())continue;const r=o?[e.tileID]:[e.tileID.unwrapTo(-1),e.tileID.unwrapTo(0)],a=Math.pow(2,s.zoom-e.tileID.overscaledZ),l=i*e.queryPadding*t.a5/e.tileSize/a;for(const i of r){const r=d.map(e=>i.getTilePoint(new t.a6(e.x,e.y)));if(r.expandBy(l),r.intersects(Pe)){const t=c.map(e=>i.getTilePoint(e)),r=h.map(e=>i.getTilePoint(e));n.push({tile:e,tileID:o?i:i.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:r,scale:a})}}}return n}transformBbox(e,i,r){let n=e.map(i);if(r){const r=t.a7.fromPoints(e);r.shrinkBy(.001*Math.min(r.width(),r.height()));const s=r.map(i);t.a7.fromPoints(n).covers(s)||(n=n.map(e=>e.x>.5?new t.a6(e.x-1,e.y,e.z):e))}return n}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._inViewTiles.getTileById(e).tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){return!!this._source.hasTransition()||!(!Ie(this._source.type)||!function(e,t){if(t<=0)return!1;const i=c();for(const r of e.getAllTiles())if(r.fadeEndTime>=i)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration))}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,i,r){this._state.updateState(e=e||t.af,i,r)}removeFeatureState(e,i,r){this._state.removeFeatureState(e=e||t.af,i,r)}getFeatureState(e,i){return this._state.getState(e=e||t.af,i)}setDependencies(e,t,i){const r=this._inViewTiles.getTileById(e);r&&r.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(i).hasDependency(e,t)&&this._reloadTile(i,"reloading");this._outOfViewCache.filter(i=>!i.hasDependency(e,t))}areTilesLoaded(){for(const e of this._inViewTiles.getAllTiles())if("loaded"!==e.state&&"errored"!==e.state)return!1;return!0}}ke.maxUnderzooming=10,ke.maxOverzooming=3;class Re{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let i=1;i<this.points.length;i++)this._distances[i]=this._distances[i-1]+this.points[i].dist(this.points[i-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(1===this.points.length)return this.points[0];e=t.ak(e,0,1);let i=1,r=this._distances[i];const n=e*this.paddedLength+this.padding;for(;r<n&&i<this._distances.length;)r=this._distances[++i];const s=i-1,o=this._distances[s],a=r-o,l=a>0?(n-o)/a:0;return this.points[s].mult(1-l).add(this.points[i].mult(l))}}function Le(e,t){let i=!0;return"always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Fe{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let s=0;s<this.xCellCount*this.yCellCount;s++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,n,s){this.boxCells[n].push(s)}_insertCircleCell(e,t,i,r,n,s){this.circleCells[n].push(s)}_query(e,t,i,r,n,s,o){if(i<0||e>this.width||r<0||t>this.height)return[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return[{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e<this.boxKeys.length;e++)a.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];a.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}}else this._forEachCell(e,t,i,r,this._queryCell,a,{hitTest:n,overlapMode:s,seenUids:{box:{},circle:{}}},o);return a}query(e,t,i,r){return this._query(e,t,i,r,!1,null)}hitTest(e,t,i,r,n,s){return this._query(e,t,i,r,!0,n,s).length>0}hitTestCircle(e,t,i,r,n){const s=e-i,o=e+i,a=t-i,l=t+i;if(o<0||s>this.width||l<0||a>this.height)return!1;const c=[];return this._forEachCell(s,a,o,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),c.length>0}_queryCell(e,t,i,r,n,s,o,a){const{seenUids:l,hitTest:c,overlapMode:h}=o,u=this.boxCells[n];if(null!==u){const n=this.bboxes;for(const o of u)if(!l.box[o]){l.box[o]=!0;const u=4*o,d=this.boxKeys[o];if(e<=n[u+2]&&t<=n[u+3]&&i>=n[u+0]&&r>=n[u+1]&&(!a||a(d))&&(!c||!Le(h,d.overlapMode))&&(s.push({key:d,x1:n[u],y1:n[u+1],x2:n[u+2],y2:n[u+3]}),c))return!0}}const d=this.circleCells[n];if(null!==d){const n=this.circles;for(const o of d)if(!l.circle[o]){l.circle[o]=!0;const u=3*o,d=this.circleKeys[o];if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],e,t,i,r)&&(!a||a(d))&&(!c||!Le(h,d.overlapMode))){const e=n[u],t=n[u+1],i=n[u+2];if(s.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return!0}}}return!1}_queryCellCircle(e,t,i,r,n,s,o,a){const{circle:l,seenUids:c,overlapMode:h}=o,u=this.boxCells[n];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(r))&&!Le(h,r.overlapMode))return s.push(!0),!0}}const d=this.circleCells[n];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(r))&&!Le(h,r.overlapMode))return s.push(!0),!0}}}_forEachCell(e,t,i,r,n,s,o,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+d,s,o,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,s){const o=r-e,a=n-t,l=i+s;return l*l>o*o+a*a}_circleAndRectCollide(e,t,i,r,n,s,o){const a=(s-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return!1;const c=(o-n)/2,h=Math.abs(t-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,d=h-c;return u*u+d*d<=i*i}}function Be(e,i,n){const s=t.N();if(!e){const{vecSouth:e,vecEast:t}=Ve(i),n=r();n[0]=t[0],n[1]=t[1],n[2]=e[0],n[3]=e[1],o=n,(d=(l=(a=n)[0])*(u=a[3])-(h=a[2])*(c=a[1]))&&(o[0]=u*(d=1/d),o[1]=-c*d,o[2]=-h*d,o[3]=l*d),s[0]=n[0],s[1]=n[1],s[4]=n[2],s[5]=n[3]}var o,a,l,c,h,u,d;return t.Q(s,s,[1/n,1/n,1]),s}function Oe(e,i,r,n){if(e){const e=t.N();if(!i){const{vecSouth:t,vecEast:i}=Ve(r);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1]}return t.Q(e,e,[n,n,1]),e}return r.pixelsToClipSpaceMatrix}function Ve(e){const i=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),n=Math.cos(e.pitchInRadians),s=Math.cos(e.bearingInRadians),o=Math.sin(e.bearingInRadians),a=t.az();a[0]=-s*n*r-o*i,a[1]=-o*n*r+s*i;const l=t.aA(a);l<1e-9?t.aB(a):t.aC(a,a,1/l);const c=t.az();c[0]=s*n*i-o*r,c[1]=o*n*i+s*r;const h=t.aA(c);return h<1e-9?t.aB(c):t.aC(c,c,1/h),{vecEast:c,vecSouth:a}}function je(e,i,r,n){let s;n?(s=[e,i,n(e,i),1],t.aE(s,s,r)):(s=[e,i,0,1],rt(s,s,r));const o=s[3];return{point:new t.P(s[0]/o,s[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}function Ne(e,t){return.5+e/t*.5}function Ue(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Ge(e,i,r,n,s,o,a,l,c,h,u,d,p){const f=r?e.textSizeData:e.iconSizeData,m=t.av(f,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],_=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();const y=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let b=!1;for(let w=0;w<x.length;w++){const r=x.get(w);if(r.hidden||r.writingMode===t.aw.vertical&&!b){it(r.numGlyphs,_);continue}b=!1;const T=new t.P(r.anchorX,r.anchorY),S={getElevation:p,pitchedLabelPlaneMatrix:n,lineVertexArray:y,pitchWithMap:o,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:i.transform,tileAnchorPoint:T,unwrappedTileID:c,width:h,height:u,translation:d},P=Ke(r.anchorX,r.anchorY,S);if(!Ue(P.point,g)){it(r.numGlyphs,_);continue}const I=Ne(i.transform.cameraToCenterDistance,P.signedDistanceFromCamera),M=t.ax(f,m,r),E=o?M*i.transform.getPitchedTextCorrection(r.anchorX,r.anchorY,c)/I:M*I,C=qe({projectionContext:S,pitchedLabelPlaneMatrixInverse:s,symbol:r,fontSize:E,flip:!1,keepUpright:a,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:v,rotateToLine:l});b=C.useVertical,(C.notEnoughRoom||b||C.needsFlipping&&qe({projectionContext:S,pitchedLabelPlaneMatrixInverse:s,symbol:r,fontSize:E,flip:!0,keepUpright:a,glyphOffsetArray:e.glyphOffsetArray,dynamicLayoutVertexArray:_,aspectRatio:v,rotateToLine:l}).notEnoughRoom)&&it(r.numGlyphs,_)}r?e.text.dynamicLayoutVertexBuffer.updateData(_):e.icon.dynamicLayoutVertexBuffer.updateData(_)}function $e(e,t,i,r,n,s,o,a){const l=s.glyphStartIndex+s.numGlyphs,c=s.lineStartIndex,h=s.lineStartIndex+s.lineLength,u=t.getoffsetX(s.glyphStartIndex),d=t.getoffsetX(l-1),p=et(e*u,i,r,n,s.segment,c,h,a,o);if(!p)return null;const f=et(e*d,i,r,n,s.segment,c,h,a,o);return f?a.projectionCache.anyProjectionOccluded?null:{first:p,last:f}:null}function Ze(e,i,r,n){return e===t.aw.horizontal&&Math.abs(r.y-i.y)>Math.abs(r.x-i.x)*n?{useVertical:!0}:(e===t.aw.vertical?i.y<r.y:i.x>r.x)?{needsFlipping:!0}:null}function qe(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:n,fontSize:s,flip:o,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:h,rotateToLine:u}=e,d=s/24,p=n.lineOffsetX*d,f=n.lineOffsetY*d;let m;if(n.numGlyphs>1){const e=n.glyphStartIndex+n.numGlyphs,t=n.lineStartIndex,s=n.lineStartIndex+n.lineLength,c=$e(d,l,p,f,o,n,u,i);if(!c)return{notEnoughRoom:!0};const g=Ye(c.first.point.x,c.first.point.y,i,r),_=Ye(c.last.point.x,c.last.point.y,i,r);if(a&&!o){const e=Ze(n.writingMode,g,_,h);if(e)return e}m=[c.first];for(let r=n.glyphStartIndex+1;r<e-1;r++){const e=et(d*l.getoffsetX(r),p,f,o,n.segment,t,s,i,u);if(!e)return{notEnoughRoom:!0};m.push(e)}m.push(c.last)}else{if(a&&!o){const e=He(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,s=n.lineStartIndex+n.segment+1,o=new t.P(i.lineVertexArray.getx(s),i.lineVertexArray.gety(s)),a=He(o.x,o.y,i),l=a.signedDistanceFromCamera>0?a.point:We(i.tileAnchorPoint,o,e,1,i),c=Ye(e.x,e.y,i,r),u=Ye(l.x,l.y,i,r),d=Ze(n.writingMode,c,u,h);if(d)return d}const e=et(d*l.getoffsetX(n.glyphStartIndex),p,f,o,n.segment,n.lineStartIndex,n.lineStartIndex+n.lineLength,i,u);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[e]}for(const g of m)t.aD(c,g.point,g.angle);return{}}function We(e,t,i,r,n){const s=e.add(e.sub(t)._unit()),o=He(s.x,s.y,n).point,a=i.sub(o);return i.add(a._mult(r/a.mag()))}function Xe(e,i,r){const n=i.projectionCache;if(n.projections[e])return n.projections[e];const s=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),o=He(s.x,s.y,i);if(o.signedDistanceFromCamera>0)return n.projections[e]=o.point,n.anyProjectionOccluded=n.anyProjectionOccluded||o.isOccluded,o.point;const a=e-r.direction;return We(0===r.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),s,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function He(e,t,i){const r=e+i.translation[0],n=t+i.translation[1];let s;return i.pitchWithMap?(s=je(r,n,i.pitchedLabelPlaneMatrix,i.getElevation),s.isOccluded=!1):(s=i.transform.projectTileCoordinates(r,n,i.unwrappedTileID,i.getElevation),s.point.x=(.5*s.point.x+.5)*i.width,s.point.y=(.5*-s.point.y+.5)*i.height),s}function Ye(e,i,r,n){if(r.pitchWithMap){const s=[e,i,0,1];return t.aE(s,s,n),r.transform.projectTileCoordinates(s[0]/s[3],s[1]/s[3],r.unwrappedTileID,r.getElevation).point}return{x:e/r.width*2-1,y:1-i/r.height*2}}function Ke(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function Je(e,t,i){return e._unit()._perp()._mult(t*i)}function Qe(e,i,r,n,s,o,a,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const h=r.add(i);if(e+c.direction<n||e+c.direction>=s)return l.projectionCache.offsets[e]=h,h;const u=Xe(e+c.direction,l,c),d=Je(u.sub(r),a,c.direction),p=r.add(d),f=u.add(d);return l.projectionCache.offsets[e]=t.aF(o,h,p,f)||h,l.projectionCache.offsets[e]}function et(e,t,i,r,n,s,o,a,l){const c=r?e-t:e+t;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,p=h>0?s+n:s+n+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=He(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,g=d,_=d,y=0,x=0;const v=Math.abs(c),b=[];let w;for(;y+x<=v;){if(p+=h,p<s||p>=o)return null;y+=x,_=g,m=f;const e={absOffsetX:v,direction:h,distanceFromAnchor:y,previousVertex:_};if(g=Xe(p,a,e),0===i)b.push(_),w=g.sub(_);else{let t;const r=g.sub(_);t=0===r.mag()?Je(Xe(p+h,a,e).sub(g),i,h):Je(r,i,h),m||(m=_.add(t)),f=Qe(p,t,g,s,o,m,i,a,e),b.push(m),w=f.sub(m)}x=w.mag()}const T=w._mult((v-y)/x)._add(m||_),S=u+Math.atan2(g.y-_.y,g.x-_.x);return b.push(T),{point:T,angle:l?S:0,path:b}}const tt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function it(e,t){for(let i=0;i<e;i++){const e=t.length;t.resize(e+4),t.float32.set(tt,3*e)}}function rt(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const nt=100;class st{constructor(e,t=new Fe(e.width+200,e.height+200,25),i=new Fe(e.width+200,e.height+200,25)){this.transform=e,this.grid=t,this.ignoredGrid=i,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+nt,this.screenBottomBoundary=e.height+nt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,t,i,r,n,s,o,a,l,c,h,u){const d=this.projectAndGetPerspectiveRatio(e.anchorPointX+a[0],e.anchorPointY+a[1],n,c,u),p=i*d.perspectiveRatio;let f;if(s||o)f=this._projectCollisionBox(e,p,r,n,s,o,a,d,c,h,u);else{const t=d.x+(h?h.x*p:0),i=d.y+(h?h.y*p:0);f={allPointsOccluded:!1,box:[t+e.x1*p,i+e.y1*p,t+e.x2*p,i+e.y2*p]}}const[m,g,_,y]=f.box,x=s?f.allPointsOccluded:d.isOccluded;let v=x;return v||(v=d.perspectiveRatio<this.perspectiveRatioCutoff),v||(v=!this.isInsideGrid(m,g,_,y)),v||"always"!==t&&this.grid.hitTest(m,g,_,y,t,l)?{box:[m,g,_,y],placeable:!1,offscreen:!1,occluded:x}:{box:[m,g,_,y],placeable:!0,offscreen:this.isOffscreen(m,g,_,y),occluded:x}}placeCollisionCircles(e,i,r,n,s,o,a,l,c,h,u,d,p,f){const m=[],g=new t.P(i.anchorX,i.anchorY),_=this.getPerspectiveRatio(g.x,g.y,o,f),y=(c?s*this.transform.getPitchedTextCorrection(i.anchorX,i.anchorY,o)/_:s*_)/t.aJ,x={getElevation:f,pitchedLabelPlaneMatrix:a,lineVertexArray:r,pitchWithMap:c,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:g,unwrappedTileID:o,width:this.transform.width,height:this.transform.height,translation:p},v=$e(y,n,i.lineOffsetX*y,i.lineOffsetY*y,!1,i,!1,x);let b=!1,w=!1,T=!0;if(v){const i=.5*u*_+d,r=new t.P(-100,-100),n=new t.P(this.screenRightBoundary,this.screenBottomBoundary),s=new Re,o=v.first,a=v.last;let p=[];for(let e=o.path.length-1;e>=1;e--)p.push(o.path[e]);for(let e=1;e<a.path.length;e++)p.push(a.path[e]);const f=2.5*i;if(c){const e=this.projectPathToScreenSpace(p,x);p=e.some(e=>e.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let g=[];if(p.length>0){const e=p[0].clone(),i=p[0].clone();for(let t=1;t<p.length;t++)e.x=Math.min(e.x,p[t].x),e.y=Math.min(e.y,p[t].y),i.x=Math.max(i.x,p[t].x),i.y=Math.max(i.y,p[t].y);g=e.x>=r.x&&i.x<=n.x&&e.y>=r.y&&i.y<=n.y?[p]:i.x<r.x||e.x>n.x||i.y<r.y||e.y>n.y?[]:t.aG([p],r.x,r.y,n.x,n.y)}for(const t of g){s.reset(t,.25*i);let r=0;r=s.length<=.5*i?1:Math.ceil(s.paddedLength/f)+1;for(let t=0;t<r;t++){const n=t/Math.max(r-1,1),o=s.lerp(n),a=o.x+nt,c=o.y+nt;m.push(a,c,i,0);const u=a-i,d=c-i,p=a+i,f=c+i;if(T=T&&this.isOffscreen(u,d,p,f),w=w||this.isInsideGrid(u,d,p,f),"always"!==e&&this.grid.hitTestCircle(a,c,i,e,h)&&(b=!0,!l))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!l&&b||!w||_<this.perspectiveRatioCutoff?[]:m,offscreen:T,collisionDetected:b}}projectPathToScreenSpace(e,i){const r=function(e,i){const r=t.N();return t.ay(r,i.pitchedLabelPlaneMatrix),e.map(e=>{const t=je(e.x,e.y,r,i.getElevation),n=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return n.point.x=(.5*n.point.x+.5)*i.width,n.point.y=(.5*-n.point.y+.5)*i.height,n})}(e,i);return function(e){let t=0,i=0,r=0,n=0;for(let s=0;s<e.length;s++)e[s].isOccluded?(r=s+1,n=0):(n++,n>i&&(i=n,t=r));return e.slice(t,t+i)}(r)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[],r=new t.a7;for(const u of e){const e=new t.P(u.x+nt,u.y+nt);r.extend(e),i.push(e)}const{minX:n,minY:s,maxX:o,maxY:a}=r,l=this.grid.query(n,s,o,a).concat(this.ignoredGrid.query(n,s,o,a)),c={},h={};for(const u of l){const e=u.key;if(void 0===c[e.bucketInstanceId]&&(c[e.bucketInstanceId]={}),c[e.bucketInstanceId][e.featureIndex])continue;const r=[new t.P(u.x1,u.y1),new t.P(u.x2,u.y1),new t.P(u.x2,u.y2),new t.P(u.x1,u.y2)];t.aH(i,r)&&(c[e.bucketInstanceId][e.featureIndex]=!0,void 0===h[e.bucketInstanceId]&&(h[e.bucketInstanceId]=[]),h[e.bucketInstanceId].push(e.featureIndex))}return h}insertCollisionBox(e,t,i,r,n,s){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:n,collisionGroupID:s,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,n,s){const o=i?this.ignoredGrid:this.grid,a={bucketInstanceId:r,featureIndex:n,collisionGroupID:s,overlapMode:t};for(let l=0;l<e.length;l+=4)o.insertCircle(a,e[l],e[l+1],e[l+2])}projectAndGetPerspectiveRatio(e,i,r,n,s){if(s){let r;n?(r=[e,i,n(e,i),1],t.aE(r,r,s)):(r=[e,i,0,1],rt(r,r,s));const o=r[3];return{x:(r[0]/o+1)/2*this.transform.width+nt,y:(-r[1]/o+1)/2*this.transform.height+nt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/o*.5,isOccluded:!1,signedDistanceFromCamera:o}}{const t=this.transform.projectTileCoordinates(e,i,r,n);return{x:(t.point.x+1)/2*this.transform.width+nt,y:(1-t.point.y)/2*this.transform.height+nt,perspectiveRatio:.5+this.transform.cameraToCenterDistance/t.signedDistanceFromCamera*.5,isOccluded:t.isOccluded,signedDistanceFromCamera:t.signedDistanceFromCamera}}}getPerspectiveRatio(e,t,i,r){const n=this.transform.projectTileCoordinates(e,t,i,r);return.5+this.transform.cameraToCenterDistance/n.signedDistanceFromCamera*.5}isOffscreen(e,t,i,r){return i<nt||e>=this.screenRightBoundary||r<nt||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const e=t.ao([]);return t.O(e,e,[-100,-100,0]),e}_projectCollisionBox(e,i,r,n,s,o,a,l,c,h,u){let d=1,p=0,f=0,m=1;const g=e.anchorPointX+a[0],_=e.anchorPointY+a[1];if(o&&!s){const e=this.projectAndGetPerspectiveRatio(g+1,_,n,c,u),t=e.x-l.x,i=Math.atan((e.y-l.y)/t)+(t<0?Math.PI:0),r=Math.sin(i),s=Math.cos(i);d=s,p=r,f=-r,m=s}else if(!o&&s){const e=Ve(this.transform);d=e.vecEast[0],p=e.vecEast[1],f=e.vecSouth[0],m=e.vecSouth[1]}let y=l.x,x=l.y,v=i;s&&(y=g,x=_,v=Math.pow(2,-(this.transform.zoom-r.overscaledZ)),v*=this.transform.getPitchedTextCorrection(g,_,n),h||(v*=t.ak(.5+l.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),h&&(y+=d*h.x*v+f*h.y*v,x+=p*h.x*v+m*h.y*v);const b=e.x1*v,w=e.x2*v,T=(b+w)/2,S=e.y1*v,P=e.y2*v,I=(S+P)/2,M=[{offsetX:b,offsetY:S},{offsetX:T,offsetY:S},{offsetX:w,offsetY:S},{offsetX:w,offsetY:I},{offsetX:w,offsetY:P},{offsetX:T,offsetY:P},{offsetX:b,offsetY:P},{offsetX:b,offsetY:I}];let E=[];for(const{offsetX:A,offsetY:D}of M)E.push(new t.P(y+d*A+f*D,x+p*A+m*D));let C=!1;if(s){const e=E.map(e=>this.projectAndGetPerspectiveRatio(e.x,e.y,n,c,u));C=e.some(e=>!e.isOccluded),E=e.map(e=>new t.P(e.x,e.y))}else C=!0;return{box:t.aI(E),allPointsOccluded:!C}}}class ot{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class at{constructor(e,t,i,r,n){this.text=new ot(e?e.text:null,t,i,n),this.icon=new ot(e?e.icon:null,t,r,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class lt{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}}class ct{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class ht{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function ut(e,i,r,n,s){const{horizontalAlign:o,verticalAlign:a}=t.aP(e);return new t.P(-(o-.5)*i+n[0]*s,-(a-.5)*r+n[1]*s)}class dt{constructor(e,t,i,r,n){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new st(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new ht(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,i,r,n){const s=r.getBucket(i),o=r.latestFeatureIndex;if(!s||!o||i.id!==s.layerIds[0])return;const a=r.collisionBoxArray,l=s.layers[0].layout,c=s.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/t.a5,d=r.tileID.toUnwrapped(),p="map"===l.get("text-rotation-alignment"),f=t.aK(r,1,this.transform.zoom),m=t.aL(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),g=t.aL(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),_=Be(p,this.transform,f);this.retainedQueryData[s.bucketInstanceId]=new ct(s.bucketInstanceId,o,s.sourceLayerIndex,s.index,r.tileID);const y={bucket:s,layout:l,translationText:m,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:_,scale:h,textPixelRatio:u,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:t.av(s.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(s.sourceID)};if(n)for(const t of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:y})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:y})}attemptAnchorPlacement(e,i,r,n,s,o,a,l,c,h,u,d,p,f,m,g,_,y,x,v){const b=t.aM[e.textAnchor],w=[e.textOffset0,e.textOffset1],T=ut(b,r,n,w,s),S=this.collisionIndex.placeCollisionBox(i,d,l,c,h,a,o,g,u.predicate,x,T,v);if((!y||this.collisionIndex.placeCollisionBox(y,d,l,c,h,a,o,_,u.predicate,x,T,v).placeable)&&S.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:w,width:r,height:n,anchor:b,textBoxScale:s,prevAnchor:e},this.markUsedJustification(f,b,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:T,placedGlyphBoxes:S}}}placeLayerBucketPart(e,i,r){const{bucket:n,layout:s,translationText:o,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:p,collisionGroup:f}=e.parameters,m=s.get("text-optional"),g=s.get("icon-optional"),_=t.aN(s,"text-overlap","text-allow-overlap"),y="always"===_,x=t.aN(s,"icon-overlap","icon-allow-overlap"),v="always"===x,b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="none"!==s.get("icon-text-fit"),S="viewport-y"===s.get("symbol-z-order"),P=y&&(v||!n.hasIconData()||g),I=v&&(y||!n.hasTextData()||m);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d);const M=this.retainedQueryData[n.bucketInstanceId].tileID,E=this._getTerrainElevationFunc(M),C=this.transform.getFastPathSimpleProjectionMatrix(M),A=(e,d,v)=>{var S,A;if(i[e.crossTileID])return;if(u)return void(this.placements[e.crossTileID]=new lt(!1,!1,!1));let D=!1,z=!1,k=!0,R=null,L={box:null,placeable:!1,offscreen:null,occluded:!1},F={placeable:!1},B=null,O=null,V=null,j=0,N=0,U=0;d.textFeatureIndex?j=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(j=e.featureIndex),d.verticalTextFeatureIndex&&(N=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let r=t.aw.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(n,r,e))}return r},s=(i,r)=>{if(n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of n.writingModes)if(e===t.aw.vertical?(L=r(),F=L):L=i(),L&&L.placeable)break}else L=i()},c=e.textAnchorOffsetStartIndex,u=e.textAnchorOffsetEndIndex;if(u===c){const r=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,_,h,M,l,w,b,o,f.predicate,E,void 0,C);return r&&r.placeable&&(this.markUsedOrientation(n,i,e),this.placedOrientations[e.crossTileID]=i),r};s(()=>r(G,t.aw.horizontal),()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?r(i,t.aw.vertical):{box:null,offscreen:null}}),i(L&&L.placeable)}else{let p=t.aM[null===(A=null===(S=this.prevPlacement)||void 0===S?void 0:S.variableOffsets[e.crossTileID])||void 0===A?void 0:A.anchor];const m=(t,i,s)=>{const d=t.x2-t.x1,m=t.y2-t.y1,g=e.textBoxScale,y=T&&"never"===x?i:null;let v=null,S="never"===_?1:2,P="never";p&&S++;for(let r=0;r<S;r++){for(let i=c;i<u;i++){const r=n.textAnchorOffsets.get(i);if(p&&r.textAnchor!==p)continue;const c=this.attemptAnchorPlacement(r,t,d,m,g,b,w,h,M,l,f,P,e,n,s,o,a,y,E);if(c&&(v=c.placedGlyphBoxes,v&&v.placeable))return D=!0,R=c.shift,v}p?p=null:P=_}return r&&!v&&(v={box:this.collisionIndex.placeCollisionBox(G,"always",h,M,l,w,b,o,f.predicate,E,void 0,C).box,offscreen:!1,placeable:!1,occluded:!1}),v};s(()=>m(G,d.iconBox,t.aw.horizontal),()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&(!L||!L.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.aw.vertical):{box:null,occluded:!0,offscreen:null}}),L&&(D=L.placeable,k=L.offscreen);const g=i(L&&L.placeable);if(!D&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(n,t.anchor,e,g))}}}if(B=L,D=B&&B.placeable,k=B&&B.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const i=n.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),a=t.ax(n.textSizeData,p,i),h=s.get("text-padding");O=this.collisionIndex.placeCollisionCircles(_,i,n.lineVertexArray,n.glyphOffsetArray,a,l,c,r,w,f.predicate,e.collisionCircleDiameter,h,o,E),O.circles.length&&O.collisionDetected&&!r&&t.w("Collisions detected, but collision boxes are not shown"),D=y||O.circles.length>0&&!O.collisionDetected,k=k&&O.offscreen}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,x,h,M,l,w,b,a,f.predicate,E,T&&R?R:void 0,C);F&&F.placeable&&d.verticalIconBox?(V=e(d.verticalIconBox),z=V.placeable):(V=e(d.iconBox),z=V.placeable),k=k&&V.offscreen}const $=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Z=g||0===e.numIconVertices;$||Z?Z?$||(z=z&&D):D=z&&D:z=D=z&&D;const q=z&&V.placeable;if(D&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,_,s.get("text-ignore-placement"),n.bucketInstanceId,F&&F.placeable&&N?N:j,f.ID),q&&this.collisionIndex.insertCollisionBox(V.box,x,s.get("icon-ignore-placement"),n.bucketInstanceId,U,f.ID),O&&D&&this.collisionIndex.insertCollisionCircles(O.circles,_,s.get("text-ignore-placement"),n.bucketInstanceId,j,f.ID),r&&this.storeCollisionData(n.bucketInstanceId,v,d,B,V,O),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===n.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new lt((D||P)&&!(null==B?void 0:B.occluded),(z||I)&&!(null==V?void 0:V.occluded),k||n.justReloaded),i[e.crossTileID]=!0};if(S){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=n.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];A(n.symbolInstances.get(i),n.collisionArrays[i],i)}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)A(n.symbolInstances.get(t),n.collisionArrays[t],t);n.justReloaded=!1}storeCollisionData(e,t,i,r,n,s){if(i.textBox||i.iconBox){let s,o;this.collisionBoxArrays.has(e)?s=this.collisionBoxArrays.get(e):(s=new Map,this.collisionBoxArrays.set(e,s)),s.has(t)?o=s.get(t):(o={text:null,icon:null},s.set(t,o)),i.textBox&&(o.text=r.box),i.iconBox&&(o.icon=n.box)}if(s){let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=[]);for(let e=0;e<s.circles.length;e+=4)t.push(s.circles[e+0]-nt),t.push(s.circles[e+1]-nt),t.push(s.circles[e+2]),t.push(s.collisionDetected?1:0)}}markUsedJustification(e,i,r,n){let s;s=n===t.aw.vertical?r.verticalPlacedTextSymbolIndex:{left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex}[t.aO(i)];const o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(const t of o)t>=0&&(e.text.placedSymbolArray.get(t).crossTileID=s>=0&&t!==s?0:r.crossTileID)}markUsedOrientation(e,i,r){const n=i===t.aw.horizontal||i===t.aw.horizontalOnly?i:0,s=i===t.aw.vertical?i:0,o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of o)e.text.placedSymbolArray.get(t).placedOrientation=n;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=s)}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 r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},s=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(const a in this.placements){const e=this.placements[a],t=n[a];t?(this.opacities[a]=new at(t,r,e.text,e.icon),i=i||e.text!==t.text.placed||e.icon!==t.icon.placed):(this.opacities[a]=new at(null,r,e.text,e.icon,e.skipFade),i=i||e.text||e.icon)}for(const a in n){const e=n[a];if(!this.opacities[a]){const t=new at(e,r,!1,!1);t.isHidden()||(this.opacities[a]=t,i=i||e.text.placed||e.icon.placed)}}for(const a in s)this.variableOffsets[a]||!this.opacities[a]||this.opacities[a].isHidden()||(this.variableOffsets[a]=s[a]);for(const a in o)this.placedOrientations[a]||!this.opacities[a]||this.opacities[a].isHidden()||(this.placedOrientations[a]=o[a]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray)}}updateBucketOpacities(e,i,r,n){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const s=e.layers[0],o=s.layout,a=new at(null,0,!1,!1,!0),l=o.get("text-allow-overlap"),c=o.get("icon-allow-overlap"),h=s._unevaluatedLayout.hasValue("text-variable-anchor")||s._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===o.get("text-rotation-alignment"),d="map"===o.get("text-pitch-alignment"),p="none"!==o.get("icon-text-fit"),f=new at(null,0,l&&(c||!e.hasIconData()||o.get("icon-optional")),c&&(l||!e.hasTextData()||o.get("text-optional")),!0);!e.collisionArrays&&n&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(n);const m=(e,t,i)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(i);e.hasVisibleVertices=e.hasVisibleVertices||i!==wt},g=this.collisionBoxArrays.get(e.bucketInstanceId);for(let _=0;_<e.symbolInstances.length;_++){const i=e.symbolInstances.get(_),{numHorizontalGlyphVertices:n,numVerticalGlyphVertices:s,crossTileID:o}=i;let l=this.opacities[o];r[o]?l=a:l||(l=f,this.opacities[o]=l),r[o]=!0;const c=i.numIconVertices>0,y=this.placedOrientations[i.crossTileID],x=y===t.aw.vertical,v=y===t.aw.horizontal||y===t.aw.horizontalOnly;if(n>0||s>0){const t=bt(l.text);m(e.text,n,x?wt:t),m(e.text,s,v?wt:t);const r=l.text.isHidden();[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex].forEach(t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=r||x?1:0)}),i.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).hidden=r||v?1:0);const o=this.variableOffsets[i.crossTileID];o&&this.markUsedJustification(e,o.anchor,i,y);const a=this.placedOrientations[i.crossTileID];a&&(this.markUsedJustification(e,"left",i,a),this.markUsedOrientation(e,a,i))}if(c){const t=bt(l.icon),r=!(p&&i.verticalPlacedIconSymbolIndex&&x);i.placedIconSymbolIndex>=0&&(m(e.icon,i.numIconVertices,r?t:wt),e.icon.placedSymbolArray.get(i.placedIconSymbolIndex).hidden=l.icon.isHidden()),i.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,i.numVerticalIconVertices,r?wt:t),e.icon.placedSymbolArray.get(i.verticalPlacedIconSymbolIndex).hidden=l.icon.isHidden())}const b=g&&g.has(_)?g.get(_):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const i=e.collisionArrays[_];if(i){let r=new t.P(0,0);if(i.textBox||i.verticalTextBox){let t=!0;if(h){const e=this.variableOffsets[o];e?(r=ut(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),u&&r._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(i.textBox||i.verticalTextBox){let n;i.textBox&&(n=x),i.verticalTextBox&&(n=v),pt(e.textCollisionBox.collisionVertexArray,l.text.placed,!t||n,b.text,r.x,r.y)}}if(i.iconBox||i.verticalIconBox){const t=Boolean(!v&&i.verticalIconBox);let n;i.iconBox&&(n=t),i.verticalIconBox&&(n=!t),pt(e.iconCollisionBox.collisionVertexArray,l.icon.placed,n,b.icon,p?r.x:0,p?r.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.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 this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}}function pt(e,t,i,r,n,s){r&&0!==r.length||(r=[0,0,0,0]);const o=r[0]-nt,a=r[1]-nt,l=r[2]-nt,c=r[3]-nt;e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,a),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,l,a),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,l,c),e.emplaceBack(t?1:0,i?1:0,n||0,s||0,o,c)}const ft=Math.pow(2,25),mt=Math.pow(2,24),gt=Math.pow(2,17),_t=Math.pow(2,16),yt=Math.pow(2,9),xt=Math.pow(2,8),vt=Math.pow(2,1);function bt(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*ft+t*mt+i*gt+t*_t+i*yt+t*xt+i*vt+t}const wt=0;class Tt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,r,n){const s=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(s,r,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,s.sort((e,t)=>e.sortKey-t.sortKey));this._currentPartIndex<s.length;)if(t.placeLayerBucketPart(s[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,n())return!0;return!1}}class St{constructor(e,t,i,r,n,s,o,a){this.placement=new dt(e,t,s,o,a),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=n,this._done=!1}isDone(){return this._done}continuePlacement(e,i,r){const n=c(),s=()=>!this._forceFullPlacement&&c()-n>2;for(;this._currentPlacementIndex>=0;){const n=i[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if(t.aQ(n)&&n.layout&&(!n.minzoom||n.minzoom<=o)&&(!n.maxzoom||n.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new Tt(n)),this._inProgressLayer.continuePlacement(r[n.source],this.placement,this._showCollisionBoxes,n,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Pt=512/t.a5/2;class It{constructor(e,i,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};const n=new Map;for(let t=0;t<i.length;t++){const e=i.get(t),r=e.key,s=n.get(r);s?s.push(e):n.set(r,[e])}for(const[s,o]of n){const e={positions:o.map(e=>({x:Math.floor(e.anchorX*Pt),y:Math.floor(e.anchorY*Pt)})),crossTileIDs:o.map(e=>e.crossTileID)};if(e.positions.length>128){const i=new t.aR(e.positions.length,16,Uint16Array);for(const{x:t,y:r}of e.positions)i.add(t,r);i.finish(),delete e.positions,e.index=i}this._symbolsByKey[s]=e}}getScaledCoordinates(e,i){const{x:r,y:n,z:s}=this.tileID.canonical,{x:o,y:a,z:l}=i.canonical,c=Pt/Math.pow(2,l-s),h=(a*t.a5+e.anchorY)*c,u=n*t.a5*Pt;return{x:Math.floor((o*t.a5+e.anchorX)*c-r*t.a5*Pt),y:Math.floor(h-u)}}findMatches(e,t,i){const r=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z);for(let n=0;n<e.length;n++){const s=e.get(n);if(s.crossTileID)continue;const o=this._symbolsByKey[s.key];if(!o)continue;const a=this.getScaledCoordinates(s,t);if(o.index){const e=o.index.range(a.x-r,a.y-r,a.x+r,a.y+r).sort();for(const t of e){const e=o.crossTileIDs[t];if(!i[e]){i[e]=!0,s.crossTileID=e;break}}}else if(o.positions)for(let e=0;e<o.positions.length;e++){const t=o.positions[e],n=o.crossTileIDs[e];if(Math.abs(t.x-a.x)<=r&&Math.abs(t.y-a.y)<=r&&!i[n]){i[n]=!0,s.crossTileID=n;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}}class Mt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Et{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const i in this.indexes){const e=this.indexes[i],r={};for(const i in e){const n=e[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}this.indexes[i]=r}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 n=0;n<t.symbolInstances.length;n++)t.symbolInstances.get(n).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const r=this.usedCrossTileIDs[e.overscaledZ];for(const n in this.indexes){const i=this.indexes[n];if(Number(n)>e.overscaledZ)for(const n in i){const s=i[n];s.tileID.isChildOf(e)&&s.findMatches(t.symbolInstances,e,r)}else{const s=i[e.scaledTo(Number(n)).key];s&&s.findMatches(t.symbolInstances,e,r)}}for(let n=0;n<t.symbolInstances.length;n++){const e=t.symbolInstances.get(n);e.crossTileID||(e.crossTileID=i.generate(),r[e.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new It(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i of t.getCrossTileIDsLists())for(const t of i)delete this.usedCrossTileIDs[e][t]}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)e[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],t=!0)}return t}}class Ct{constructor(){this.layerIndexes={},this.crossTileIDs=new Mt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i){let r=this.layerIndexes[e.id];void 0===r&&(r=this.layerIndexes[e.id]=new Et);let n=!1;const s={};r.handleWrapJump(i);for(const o of t){const t=o.getBucket(e);t&&e.id===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),r.addBucket(o.tileID,t,this.crossTileIDs)&&(n=!0),s[t.bucketInstanceId]=!0)}return r.removeStaleBuckets(s)&&(n=!0),n}pruneUnusedLayers(e){const t={};e.forEach(e=>{t[e]=!0});for(const i in this.layerIndexes)t[i]||delete this.layerIndexes[i]}}var At="void main() {fragColor=vec4(1.0);}";const Dt={prelude:zt("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+      c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+    c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+    c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:zt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:zt("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:zt("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:zt("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:zt("in 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out 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\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:zt(At,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:zt("uniform 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);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.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 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:zt("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));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:zt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:zt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:zt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:zt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:zt(At,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:zt("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:zt("in vec2 v_pos;\n#ifdef GLOBE\nin 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);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout 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\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:zt("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:zt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:zt("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:zt("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:zt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);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((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 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=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:zt("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:zt("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:zt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:zt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:zt("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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 lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\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 lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:zt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\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 lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\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 lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:zt("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:zt("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:zt("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;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 vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:zt("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;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 vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:zt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:zt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:zt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:zt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:zt("#ifdef GL_ES\nprecision highp float;\n#endif\nin vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:zt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function zt(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),n=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=s?s.concat(n):n,a={};return{fragmentSource:e=e.replace(i,(e,t,i,r,n)=>(a[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n    ${i} ${r} ${n} = u_${n};\n#endif\n`)),vertexSource:t=t.replace(i,(e,t,i,r,n)=>{const s="float"===r?"vec2":"vec4",o=n.match(/color/)?"color":s;return a[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${s} a_${n};\nout ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n    ${n} = a_${n};\n#else\n    ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n    ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n    ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n    ${i} ${r} ${n} = a_${n};\n#else\n    ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n    ${i} ${r} ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n    ${i} ${r} ${n} = u_${n};\n#endif\n`}),staticAttributes:r,staticUniforms:o}}class kt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Rt=t.aS([{name:"a_pos",type:"Int16",components:2}]);const Lt="#define PROJECTION_MERCATOR",Ft="mercator";class Bt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Ft}get shaderDefine(){return Lt}get shaderPreludeCode(){return Dt.projectionMercator}get vertexShaderPreludeCode(){return Dt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aT.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,r,n,s){if(this._cachedMesh)return this._cachedMesh;const o=new t.aU;o.emplaceBack(0,0),o.emplaceBack(t.a5,0),o.emplaceBack(0,t.a5),o.emplaceBack(t.a5,t.a5);const a=e.createVertexBuffer(o,Rt.members),l=t.aV.simpleSegment(0,0,4,2),c=new t.aW;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const h=e.createIndexBuffer(c);return this._cachedMesh=new kt(a,h,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Ot{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.G.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.G.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.G.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.G.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.ak((this.left+e-this.right)/2,0,e),n=t.ak((this.top+i-this.bottom)/2,0,i);return new t.P(r,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Ot(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Vt(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function jt(e){return Math.max(0,Math.floor(e))}class Nt{constructor(e,i){var r;this.applyConstrain=(e,t)=>null!==this._constrainOverride?this._constrainOverride(e,t):this._callbacks.defaultConstrain(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==i?void 0:i.renderWorldCopies)||!!(null==i?void 0:i.renderWorldCopies),this._minZoom=(null==i?void 0:i.minZoom)||0,this._maxZoom=(null==i?void 0:i.maxZoom)||22,this._minPitch=null==(null==i?void 0:i.minPitch)?0:null==i?void 0:i.minPitch,this._maxPitch=null==(null==i?void 0:i.maxPitch)?60:null==i?void 0:i.maxPitch,this._constrainOverride=null!==(r=null==i?void 0:i.constrainOverride)&&void 0!==r?r:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=jt(this._zoom),this._scale=t.an(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ot,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,i,r){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=jt(this._zoom),this._scale=t.an(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Ot(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,i&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.W(e,-180,180)*Math.PI/180;var n,s,o,a,l,c,h,u,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),n=this._rotationMatrix,o=-this._bearingInRadians,a=(s=this._rotationMatrix)[0],l=s[1],c=s[2],h=s[3],u=Math.sin(o),d=Math.cos(o),n[0]=a*d+c*u,n[1]=l*d+h*u,n[2]=a*-u+c*d,n[3]=l*-u+h*d)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.ak(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aX(this._fovInRadians)}setFov(e){e=t.ak(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.am(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const i=this.applyConstrain(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.an(i),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new N([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-t.al,t.al])}getCameraQueryGeometry(e,i){if(1===i.length)return[i[0],e];{const{minX:r,minY:n,maxX:s,maxY:o}=t.a7.fromPoints(i).extend(e);return[new t.P(r,n),new t.P(s,n),new t.P(s,o),new t.P(r,o),new t.P(r,n)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ao(new Float64Array(16));t.Q(e,e,[this._width/2,-this._height/2,1]),t.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ao(new Float64Array(16)),t.Q(e,e,[1,-1,1]),t.O(e,e,[-1,-1,0]),t.Q(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,i,r,n){const s=void 0!==r?r:this.bearing,o=n=void 0!==n?n:this.pitch,{distanceToCenter:a,clampedElevation:l}=this._distanceToCenterFromAltElevationPitch(i,this.elevation,o),{x:c,y:h}=ye(o,s),u=t.a6.fromLngLat(e,i);let d,p,f=t.aY(1,u.y),m=0;do{if(m+=1,m>10)break;p=a/f,d=new t.a6(u.x+c*p,u.y+h*p),f=1/d.meterInMercatorCoordinateUnits()}while(Math.abs(a-p*f)>1e-12);return{center:d.toLngLat(),elevation:l,zoom:t.aq(this.height/2/Math.tan(this.fovInRadians/2)/p/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=1/this.worldSize,r=t.ap(1,this.center.lat)*this.worldSize,n=t.a6.fromLngLat(this.center,this.elevation),s=n.x/i,o=n.y/i,a=n.z/i,l=this.pitch,c=this.bearing,{x:h,y:u,z:d}=ye(l,c),p=this.cameraToCenterDistance,f=s+p*-h,m=o+p*-u,g=a+p*d,{distanceToCenter:_,clampedElevation:y}=this._distanceToCenterFromAltElevationPitch(g/r,e,l),x=_*r,v=new t.a6((f+h*x)*i,(m+u*x)*i,0).toLngLat(),b=t.ap(1,v.lat),w=t.aq(this.height/2/Math.tan(this.fovInRadians/2)/_/b/this.tileSize);this._elevation=y,this._center=v,this.setZoom(w)}_distanceToCenterFromAltElevationPitch(e,i,r){const n=-Math.cos(t.am(r)),s=e-i;let o,a=i;return n*s>=0||Math.abs(n)<.1?(o=1e4,a=e+o*n):o=-s/n,{distanceToCenter:o,clampedElevation:a}}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.ap(1,this.center.lat)*this.worldSize;return _e(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const i=e.canonical.z>=0?1<<e.canonical.z:Math.pow(2,e.canonical.z);return[e.canonical.x/i,e.canonical.y/i,1/i/t.a5,1/i/t.a5]}}class Ut{constructor(e,i){this.min=e,this.max=i,this.center=t.aZ([],t.a_([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],r=t.a$(this.min),n=t.a$(this.max);for(let t=0;t<i.length;t++)r[t]=i[t]?this.min[t]:this.center[t],n[t]=i[t]?this.center[t]:this.max[t];return n[2]=this.max[2],new Ut(r,n)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let t=!0;for(let i=0;i<e.planes.length;i++){const r=this.intersectsPlane(e.planes[i]);if(0===r)return 0;1===r&&(t=!1)}return t?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let t=e[3],i=e[3];for(let r=0;r<3;r++)e[r]>0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}}class Gt{distanceToTile2d(e,t,i,r){const n=r.distanceX([e,t]),s=r.distanceY([e,t]);return Math.hypot(n,s)}getWrap(e,t,i){return i}getTileBoundingVolume(e,i,r,n){var s,o;let a=0,l=0;if(null==n?void 0:n.terrain){const c=new t.a2(e.z,i,e.z,e.x,e.y),h=n.terrain.getMinMaxElevation(c);a=null!==(s=h.minElevation)&&void 0!==s?s:Math.min(0,r),l=null!==(o=h.maxElevation)&&void 0!==o?o:Math.max(0,r)}const c=1<<e.z;return new Ut([i+e.x/c,e.y/c,a],[i+(e.x+1)/c,(e.y+1)/c,l])}allowVariableZoom(e,i){const r=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,n=t.ak(78.5-r/2,0,60);return!!i.terrain||e.pitch>n}allowWorldCopies(){return!0}prepareNextFrame(){}}class $t{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(e,i=1,r=0,n,s){const o=s?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],a=Math.pow(2,r),l=[[-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=>function(e,i,r,n){const s=t.aE([],e,i),o=1/s[3]/r*n;return t.b4(s,s,[o,o,1/s[3],o])}(r,e,i,a));n&&function(e,i,r,n){const s=n?4:0,o=n?0:4;let a=0;const l=[],c=[];for(let d=0;d<4;d++){const i=t.b0([],e[d+o],e[d+s]),r=t.b5(i);t.aZ(i,i,1/r),l.push(r),c.push(i)}for(let d=0;d<4;d++){const i=t.b6(e[d+s],c[d],r);a=null!==i&&i>=0?Math.max(a,i):Math.max(a,l[d])}const h=function(e,i){const r=t.b0([],e[i[0]],e[i[1]]),n=t.b0([],e[i[2]],e[i[1]]),s=[0,0,0,0];return t.b1(s,t.b2([],r,n)),s[3]=-t.b3(s,e[i[0]]),s}(e,i),u=function(e,i){const r=t.b7(e),n=t.b8([],e,1/r),s=t.b0([],i,t.aZ([],n,t.b3(i,n))),o=t.b7(s);if(o>0){const e=Math.sqrt(1-n[3]*n[3]),r=t.aZ([],n,-n[3]),a=t.a_([],r,t.aZ([],s,e/o));return t.b9(i,a)}return null}(r,h);if(null!==u){const e=u/t.b3(c[0],h);a=Math.min(a,e)}for(let t=0;t<4;t++){const i=Math.min(a,l[t]);e[t+o]=[e[t+s][0]+c[t][0]*i,e[t+s][1]+c[t][1]*i,e[t+s][2]+c[t][2]*i,1]}}(l,o[0],n,s);const c=o.map(e=>{const i=t.b0([],l[e[0]],l[e[1]]),r=t.b0([],l[e[2]],l[e[1]]),n=t.b1([],t.b2([],i,r)),s=-t.b3(n,l[e[1]]);return n.concat(s)}),h=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],u=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const t of l)for(let e=0;e<3;e++)h[e]=Math.min(h[e],t[e]),u[e]=Math.max(u[e],t[e]);return new $t(l,c,new Ut(h,u))}}class Zt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,i)=>{i=t.ak(+i,this.minZoom,this.maxZoom);const r={center:new t.V(e.lng,e.lat),zoom:i};let n=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===n){const e=180-1e-10;n=[-e,e]}const s=this.tileSize*t.an(r.zoom);let o=0,a=s,l=0,c=s,h=0,u=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const e=this._helper._latRange;o=t.X(e[1])*s,a=t.X(e[0])*s,a-o<p&&(h=p/(a-o))}n&&(l=t.W(t.Y(n[0])*s,0,s),c=t.W(t.Y(n[1])*s,0,s),c<l&&(c+=s),c-l<d&&(u=d/(c-l)));const{x:f,y:m}=pe(s,e);let g,_;const y=Math.max(u||0,h||0);if(y){const e=new t.P(u?(c+l)/2:f,h?(a+o)/2:m);return r.center=fe(s,e).wrap(),r.zoom+=t.aq(y),r}if(this._helper._latRange){const e=p/2;m-e<o&&(_=o+e),m+e>a&&(_=a-e)}if(n){const e=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=t.W(f,e-s/2,e+s/2));const r=d/2;i-r<l&&(g=l+r),i+r>c&&(g=c-r)}if(void 0!==g||void 0!==_){const e=new t.P(null!=g?g:f,null!=_?_:m);r.center=fe(s,e).wrap()}return r},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Nt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Gt}clone(){const e=new Zt;return e.apply(this,!1),e}apply(e,t,i){this._helper.apply(e,t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.ba(0,e)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new t.P(0,0)),n=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),s=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),o=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),a=Math.floor(Math.min(r.x,n.x,s.x,o.x)),l=Math.floor(Math.max(r.x,n.x,s.x,o.x)),c=1;for(let h=a-c;h<=l+c;h++)0!==h&&i.push(new t.ba(h,e))}return i}getCameraFrustum(){return $t.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,i){const r=t.ap(this.elevation,this.center.lat),n=this.screenPointToMercatorCoordinateAtZ(i,r),s=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),o=t.a6.fromLngLat(e),a=new t.a6(o.x-(n.x-s.x),o.y-(n.y-s.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.a6.fromLngLat(e),i.getElevationForLngLat(e,this),this._pixelMatrix3D):this.coordinatePoint(t.a6.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const r=i||0,n=[e.x,e.y,0,1],s=[e.x,e.y,1,1];t.aE(n,n,this._pixelMatrixInverse),t.aE(s,s,this._pixelMatrixInverse);const o=n[3],a=s[3],l=n[1]/o,c=s[1]/a,h=n[2]/o,u=s[2]/a,d=h===u?0:(r-h)/(u-h);return new t.a6(t.G.number(n[0]/o,s[0]/a,d)/this.worldSize,t.G.number(l,c,d)/this.worldSize,r)}coordinatePoint(e,i=0,r=this._pixelMatrix){const n=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.aE(n,n,r),new t.P(n[0]/n[3],n[1]/n[3])}getBounds(){const e=Math.max(0,this._helper._height/2-me(this));return(new N).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-me(this)}calculatePosMatrix(e,i=!1,r){var n;const s=null!==(n=e.key)&&void 0!==n?n:t.bb(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),o=i?this._alignedPosMatrixCache:this._posMatrixCache;if(o.has(s)){const e=o.get(s);return r?e.f32:e.f64}const a=ge(e,this.worldSize);t.S(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return o.set(s,l),r?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const n=ge(e,this.worldSize);return t.S(n,this._fogMatrix,n),r.set(i,new Float32Array(n)),r.get(i)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}_calculateNearFarZIfNeeded(e,i,r){if(!this._helper.autoCalculateNearFarZ)return;const n=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),s=e-n*this._helper._pixelPerMeter/Math.cos(i),o=n<0?s:e,a=Math.PI/2+this.pitchInRadians,l=t.am(this.fov)*(Math.abs(Math.cos(t.am(this.roll)))*this.height+Math.abs(Math.sin(t.am(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*o/Math.sin(t.ak(Math.PI-a-l,.01,Math.PI-.01)),h=me(this),u=Math.atan(h/this._helper.cameraToCenterDistance),d=t.am(.75),p=u>d?2*u*(.5+r.y/(2*h)):d,f=Math.sin(p)*o/Math.sin(t.ak(Math.PI-a-p,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+o),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=pe(this.worldSize,this.center),r=i.x,n=i.y;this._helper._pixelPerMeter=t.ap(1,this.center.lat)*this.worldSize;const s=t.am(Math.min(this.pitch,de)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(s));let a;this._calculateNearFarZIfNeeded(o,s,e),a=new Float64Array(16),t.bc(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.ay(this._invProjMatrix,a),a[8]=2*-e.x/this._helper._width,a[9]=2*e.y/this._helper._height,this._projectionMatrix=t.bd(a),t.Q(a,a,[1,-1,1]),t.O(a,a,[0,0,-this._helper.cameraToCenterDistance]),t.be(a,a,-this.rollInRadians),t.bf(a,a,this.pitchInRadians),t.be(a,a,-this.bearingInRadians),t.O(a,a,[-r,-n,0]),this._mercatorMatrix=t.Q([],a,[this.worldSize,this.worldSize,this.worldSize]),t.Q(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),t.O(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=t.ay([],a);const l=[0,0,-1,1];t.aE(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.bc(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.be(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.bf(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.be(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.O(this._fogMatrix,this._fogMatrix,[-r,-n,0]),t.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);const c=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),p=r-Math.round(r)+u*c+d*h,f=n-Math.round(n)+u*h+d*c,m=new Float64Array(a);if(t.O(m,m,[p>.5?p-1:p,f>.5?f-1:f,0]),this._alignedProjMatrix=m,a=t.ay(new Float64Array(16),this._pixelMatrix),!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aE(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.ap(1,this.center.lat)*this.worldSize;return _e(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const r=t.a6.fromLngLat(e),n=[r.x*this.worldSize,r.y*this.worldSize,i,1];return t.aE(n,n,this._viewProjMatrix),n[2]/n[3]}getProjectionData(e){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:n}=e,s=this._helper.getMercatorTileCoordinates(i),o=i?this.calculatePosMatrix(i,r,!0):null;let a;return a=i&&i.terrainRttPosMatrix32f&&n?i.terrainRttPosMatrix32f:o||t.bg(),{mainMatrix:a,tileMercatorCoords:s,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.a$(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,r,n){const s=this.calculatePosMatrix(r);let o;n?(o=[e,i,n(e,i),1],t.aE(o,o,s)):(o=[e,i,0,1],rt(o,o,s));const a=o[3];return{point:new t.P(o[0]/a,o[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,i){const r=t.a6.fromLngLat(e,i),n=r.meterInMercatorCoordinateUnits(),s=t.bh();return t.O(s,s,[r.x,r.y,r.z]),t.be(s,s,Math.PI),t.bf(s,s,Math.PI/2),t.Q(s,s,[-n,n,n]),s}getProjectionDataForCustomLayer(e=!0){const i=new t.a2(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),n=ge(i,this.worldSize);t.S(n,this._viewProjMatrix,n),r.tileMercatorCoords=[0,0,1,1];const s=[t.a5,t.a5,this.worldSize/this._helper.pixelsPerMeter],o=t.bi();return t.Q(o,n,s),r.fallbackMatrix=o,r.mainMatrix=o,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function qt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Wt(e){if(e.useSlerp)if(e.k<1){const i=t.bj(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.bj(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),n=new Float64Array(4);t.bk(n,i,r,e.k);const s=t.bl(n);e.tr.setRoll(s.roll),e.tr.setPitch(s.pitch),e.tr.setBearing(s.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Xt(e,i,r,n,s){const o=s.padding,a=pe(s.worldSize,r.getNorthWest()),l=pe(s.worldSize,r.getNorthEast()),c=pe(s.worldSize,r.getSouthEast()),h=pe(s.worldSize,r.getSouthWest()),u=t.am(-n),d=a.rotate(u),p=l.rotate(u),f=c.rotate(u),m=h.rotate(u),g=new t.P(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),_=new t.P(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),y=g.sub(_),x=(s.width-(o.left+o.right+i.left+i.right))/y.x,v=(s.height-(o.top+o.bottom+i.top+i.bottom))/y.y;if(v<0||x<0)return void qt();const b=Math.min(t.aq(s.scale*Math.min(x,v)),e.maxZoom),w=t.P.convert(e.offset),T=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.am(n)),S=w.add(T).mult(s.scale/t.an(b));return{center:fe(s.worldSize,a.add(c).div(2).sub(S)),zoom:b,bearing:n}}class Ht{get useGlobeControls(){return!1}handlePanInertia(e,t){const i=e.mag(),r=Math.abs(me(t));return{easingOffset:e.mult(Math.min(.75*r/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around)}cameraForBoxAndBearing(e,t,i,r,n){return Xt(e,t,i,r,n)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.V.convert(i.center))}handleEaseTo(e,i){const r=e.zoom,n=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},o={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},a=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const h=a?+i.zoom:e.zoom;let u=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(u),{center:p,zoom:f}=e.applyConstrain(t.V.convert(i.center||d),null!=h?h:r);Vt(e,p);const m=pe(e.worldSize,d),g=pe(e.worldSize,p).sub(m),_=t.an(f-r);return c=f!==r,{easeFunc:a=>{if(c&&e.setZoom(t.G.number(r,f,a)),t.bm(s,o)||Wt({startEulerAngles:s,endEulerAngles:o,tr:e,k:a,useSlerp:s.roll!=o.roll}),l&&(e.interpolatePadding(n,i.padding,a),u=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else{const i=t.an(e.zoom-r),n=f>r?Math.min(2,_):Math.max(.5,_),s=Math.pow(n,1-a),o=fe(e.worldSize,m.add(g.mult(a*s)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?o.wrap():o,u)}},isZooming:c,elevationCenter:p}}handleFlyTo(e,i){const r=void 0!==i.zoom,n=e.zoom,s=e.applyConstrain(t.V.convert(i.center||i.locationAtOffset),r?+i.zoom:n),o=s.center,a=s.zoom;Vt(e,o);const l=pe(e.worldSize,i.locationAtOffset),c=pe(e.worldSize,o).sub(l),h=c.mag(),u=t.an(a-n);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,n,a),s=e.applyConstrain(o,r).zoom;d=t.an(s-n)}return{easeFunc:(i,r,s,h)=>{e.setZoom(1===i?a:n+t.aq(r));const u=1===i?o:fe(e.worldSize,l.add(c.mult(s)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?u.wrap():u,h)},scaleOfZoom:u,targetCenter:o,scaleOfMinZoom:d,pixelPathLength:h}}}class Yt{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}Yt.Replace=[1,0],Yt.disabled=new Yt(Yt.Replace,t.bn.transparent,[!1,!1,!1,!1]),Yt.unblended=new Yt(Yt.Replace,t.bn.transparent,[!0,!0,!0,!0]),Yt.alphaBlended=new Yt([1,771],t.bn.transparent,[!0,!0,!0,!0]);const Kt=2305;class Jt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Jt.disabled=new Jt(!1,1029,Kt),Jt.backCCW=new Jt(!0,1029,Kt),Jt.frontCCW=new Jt(!0,1028,Kt);class Qt{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}Qt.ReadOnly=!1,Qt.ReadWrite=!0,Qt.disabled=new Qt(519,Qt.ReadOnly,[0,1]);const ei=7680;class ti{constructor(e,t,i,r,n,s){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=s}}ti.disabled=new ti({func:519,mask:0},0,0,ei,ei,ei);const ii=new WeakMap;function ri(e){var t;if(ii.has(e))return ii.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return ii.set(e,i),i}}class ni{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const n=new t.aU;n.emplaceBack(-1,-1),n.emplaceBack(2,-1),n.emplaceBack(-1,2);const s=new t.aW;s.emplaceBack(0,1,2),this._fullscreenTriangle=new kt(i.createVertexBuffer(n,Rt.members),i.createIndexBuffer(s),t.aV.simpleSegment(0,0,n.length,s.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(o),ri(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,i){const r=this._cachedRenderContext.context,n=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.bn.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,n.TRIANGLES,Qt.disabled,ti.disabled,Yt.unblended,Jt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&ri(n)){n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.readBuffer(n.COLOR_ATTACHMENT0),n.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),n.bindBuffer(n.PIXEL_PACK_BUFFER,null);const e=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0);n.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&ri(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ni._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const si=t.a5/128;function oi(e,i){const r=void 0!==e.granularity?Math.max(e.granularity,1):1,n=r+(e.generateBorders?2:0),s=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),o=n+1,a=s+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,h=r+(e.generateBorders?1:0),u=r+(e.generateBorders||e.extendToSouthPole?1:0),d=o*a,p=n*s*6,f=o*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,g=new Int16Array(2*d);let _=0;for(let v=c;v<=u;v++)for(let i=l;i<=h;i++){let n=i/r*t.a5;-1===i&&(n=-si),i===r+1&&(n=t.a5+si);let s=v/r*t.a5;-1===v&&(s=e.extendToNorthPole?t.bp:-si),v===r+1&&(s=e.extendToSouthPole?t.bq:t.a5+si),g[_++]=n,g[_++]=s}const y=m?new Uint32Array(p):new Uint16Array(p);let x=0;for(let t=0;t<s;t++)for(let e=0;e<n;e++){const i=e+1+t*o,r=e+(t+1)*o,n=e+1+(t+1)*o;y[x++]=e+t*o,y[x++]=r,y[x++]=i,y[x++]=i,y[x++]=r,y[x++]=n}return{vertices:g.buffer.slice(0),indices:y.buffer.slice(0),uses32bitIndices:m}}const ai=new t.aT({fill:new t.br(128,2),line:new t.br(512,0),tile:new t.br(128,32),stencil:new t.br(128,1),circle:3});class li{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return Dt.projectionGlobe}get vertexShaderPreludeCode(){return Dt.projectionMercator.vertexSource}get subdivisionGranularity(){return ai}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||(this._errorMeasurement=new ni(e));const i=t.X(this._errorQueryLatitudeDegrees),r=2*Math.atan(Math.exp(Math.PI-i*Math.PI*2))-.5*Math.PI,n=this._errorMeasurement.updateErrorLoop(i,r),s=c();n!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=n,this._errorMeasurementLastChangeTime=s);const o=Math.min(Math.max((s-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=t.bs(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,t.bt(o))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,t,i,r,n){const s=("stencil"===n?ai.stencil:ai.tile).getGranularityForZoomLevel(t.z);return this._getMesh(e,{granularity:s,generateBorders:i,extendToNorthPole:0===t.y&&r,extendToSouthPole:t.y===(1<<t.z)-1&&r})}_getMesh(e,i){const r=this._getMeshKey(i);if(r in this._tileMeshCache)return this._tileMeshCache[r];const n=function(e,i){const r=oi(i,"16bit"),n=t.aU.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),s=t.aW.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new kt(e.createVertexBuffer(n,Rt.members),e.createIndexBuffer(s),t.aV.simpleSegment(0,0,n.length,s.length))}(e,i);return this._tileMeshCache[r]=n,n}recalculate(e){}hasTransition(){const e=c();let t=!1;return t=t||(e-this._errorMeasurementLastChangeTime)/1e3<.7,t=t||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,t}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}const ci=new t.t({type:new t.D(t.u.projection.type)});class hi extends t.E{constructor(e){super(),this._transitionable=new t.x(ci,void 0),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.H(0)),this._mercatorProjection=new Bt,this._verticalPerspectiveProjection=new li}get transitionState(){const e=this.properties.get("type");if("string"==typeof e&&"mercator"===e)return 0;if("string"==typeof e&&"vertical-perspective"===e)return 1;if(e instanceof t.bu){if("vertical-perspective"===e.from&&"mercator"===e.to)return 1-e.transition;if("mercator"===e.from&&"vertical-perspective"===e.to)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,i,r,n){return this.currentProjection.getMeshFromTileID(e,t,i,r,n)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function ui(e){const t=fi(e.worldSize,e.center.lat);return 2*Math.PI*t}function di(e,i,r,n,s){const o=1/(1<<s),a=i/t.a5*o+n*o,l=t.bx((e/t.a5*o+r*o)*Math.PI*2+Math.PI,2*Math.PI),c=2*Math.atan(Math.exp(Math.PI-a*Math.PI*2))-.5*Math.PI,h=Math.cos(c),u=new Float64Array(3);return u[0]=Math.sin(l)*h,u[1]=Math.sin(c),u[2]=Math.cos(l)*h,u}function pi(e){return function(e,t){const i=Math.cos(t),r=new Float64Array(3);return r[0]=Math.sin(e)*i,r[1]=Math.sin(t),r[2]=Math.cos(e)*i,r}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function fi(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function mi(e){const i=Math.asin(e[1])/Math.PI*180,r=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(r>1e-6){const n=e[0]/r,s=Math.acos(e[2]/r),o=(n>0?s:-s)/Math.PI*180;return new t.V(t.W(o,-180,180),i)}return new t.V(0,i)}function gi(e){return Math.cos(e*Math.PI/180)}function _i(e,i){const r=gi(e),n=gi(i);return t.aq(n/r)}function yi(e,i){const r=e.rotate(i.bearingInRadians),n=i.zoom+_i(i.center.lat,0),s=t.bs(1/gi(i.center.lat),1/gi(Math.min(Math.abs(i.center.lat),60)),t.bv(n,7,3,0,1)),o=360/ui({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.V(i.center.lng-r.x*o*s,t.ak(i.center.lat+r.y*o,-t.al,t.al))}function xi(e){const t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function vi(e,i,r,n){const s=e.lat+r*n;if(Math.abs(r)>1){const o=(Math.sign(e.lat+r)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,a=Math.abs(e.lat+r)*Math.PI/180,l=xi(o+n*(a-o)),c=xi(o),h=xi(a);return new t.V(e.lng+i*((l-c)/(h-c)),s)}return new t.V(e.lng+i*n,s)}class bi{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,r){const n=`${e.z}_${e.x}_${e.y}_${(null==r?void 0:r.terrain)?"t":""}`,s=this._cache.get(n);if(s)return s;const o=this._cachePrevious.get(n);if(o)return this._cache.set(n,o),o;const a=this._boundingVolumeFactory(e,t,i,r);return this._cache.set(n,a),this._hadAnyChanges=!0,a}}class wi{constructor(e,t,i,r){this.min=i,this.max=r,this.points=e,this.planes=t}static fromAabb(e,t){const i=[];for(let r=0;r<8;r++)i.push([1&~r?e[0]:t[0],1==(r>>1&1)?t[1]:e[1],1==(r>>2&1)?t[2]:e[2]]);return new wi(i,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,i,r){const n=t.bz([],r[0],r[1],r[2]),s=t.bA([],[i[0],0,0],n),o=t.bA([],[0,i[1],0],n),a=t.bA([],[0,0,i[2]],n),l=[...e],c=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){const r=e[i]+s[i]*(1&~t?-1:1)+o[i]*(1==(t>>1&1)?1:-1)+a[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],r),c[i]=Math.max(c[i],r)}const h=[];for(let u=0;u<8;u++){const i=[...e];t.a_(i,i,t.aZ([],s,1&~u?-1:1)),t.a_(i,i,t.aZ([],o,1==(u>>1&1)?1:-1)),t.a_(i,i,t.aZ([],a,1==(u>>2&1)?1:-1)),h.push(i)}return new wi(h,[[...s,-t.b3(s,h[0])],[...o,-t.b3(o,h[0])],[...a,-t.b3(a,h[0])],[-s[0],-s[1],-s[2],-t.b3(s,h[7])],[-o[0],-o[1],-o[2],-t.b3(o,h[7])],[-a[0],-a[1],-a[2],-t.b3(a,h[7])]],l,c)}intersectsFrustum(e){let t=!0;const i=this.points.length,r=this.planes.length,n=e.planes.length,s=e.points.length;for(let o=0;o<n;o++){const r=e.planes[o];let n=0;for(let e=0;e<i;e++){const t=this.points[e];r[0]*t[0]+r[1]*t[1]+r[2]*t[2]+r[3]>=0&&n++}if(0===n)return 0;n<i&&(t=!1)}if(t)return 2;for(let o=0;o<r;o++){const t=this.planes[o];let i=0;for(let r=0;r<s;r++){const n=e.points[r];t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]>=0&&i++}if(0===i)return 0}return 1}intersectsPlane(e){const t=this.points.length;let i=0;for(let r=0;r<t;r++){const t=this.points[r];e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0&&i++}return i===t?2:0===i?0:1}}function Ti(e,t,i){const r=e-t;return r<0?-r:Math.max(0,r-i)}function Si(e,t,i,r,n){const s=e-i;let o;return o=s<0?Math.min(-s,1+s-n):s>n?Math.min(Math.max(s-n,0),1-s):0,Math.max(o,Ti(t,r,n))}class Pi{constructor(){this._boundingVolumeCache=new bi(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,r){const n=1<<i.z,s=1/n,o=i.x/n,a=i.y/n;let l=2;return l=Math.min(l,Si(e,t,o,a,s)),l=Math.min(l,Si(e,t,o+.5,-a-s,s)),l=Math.min(l,Si(e,t,o+.5,2-a-s,s)),l}getWrap(e,t,i){const r=1<<t.z,n=1/r,s=t.x/r,o=Ti(e.x,s,n),a=Ti(e.x,s-1,n),l=Ti(e.x,s+1,n),c=Math.min(o,a,l);return c===l?1:c===a?-1:0}allowVariableZoom(e,t){return Te(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,r)}_computeTileBoundingVolume(e,i,r,n){var s,o;let a=0,l=0;if(null==n?void 0:n.terrain){const c=new t.a2(e.z,i,e.z,e.x,e.y),h=n.terrain.getMinMaxElevation(c);a=null!==(s=h.minElevation)&&void 0!==s?s:Math.min(0,r),l=null!==(o=h.maxElevation)&&void 0!==o?o:Math.max(0,r)}if(a/=t.bC,l/=t.bC,a+=1,l+=1,e.z<=0)return wi.fromAabb([-l,-l,-l],[l,l,l]);if(1===e.z)return wi.fromAabb([0===e.x?-l:0,0===e.y?0:-l,-l],[0===e.x?0:l,0===e.y?l:0,l]);{const i=[di(0,0,e.x,e.y,e.z),di(t.a5,0,e.x,e.y,e.z),di(t.a5,t.a5,e.x,e.y,e.z),di(0,t.a5,e.x,e.y,e.z)],r=[];for(const e of i)r.push(t.aZ([],e,l));if(l!==a)for(const e of i)r.push(t.aZ([],e,a));0===e.y&&r.push([0,1,0]),e.y===(1<<e.z)-1&&r.push([0,-1,0]);const n=[1,1,1],s=[-1,-1,-1];for(const e of r)for(let t=0;t<3;t++)n[t]=Math.min(n[t],e[t]),s[t]=Math.max(s[t],e[t]);const o=di(t.a5/2,t.a5/2,e.x,e.y,e.z),c=t.b2([],[0,1,0],o);t.b1(c,c);const h=t.b2([],o,c);t.b1(h,h);const u=t.b2([],i[2],i[1]);t.b1(u,u);const d=t.b2([],i[0],i[3]);t.b1(d,d),r.push(t.aZ([],o,l)),e.y>=(1<<e.z)/2&&r.push(t.aZ([],di(t.a5/2,0,e.x,e.y,e.z),l)),e.y<(1<<e.z)/2&&r.push(t.aZ([],di(t.a5/2,t.a5,e.x,e.y,e.z),l));const p=Ii(o,r),f=Ii(h,r),m=[-o[0],-o[1],-o[2],p.max],g=[o[0],o[1],o[2],-p.min],_=[-h[0],-h[1],-h[2],f.max],y=[h[0],h[1],h[2],-f.min],x=[...u,0],v=[...d,0],b=[];return 0===e.y?b.push(t.bB(v,x,m),t.bB(v,x,g)):b.push(t.bB(_,x,m),t.bB(_,x,g),t.bB(_,v,m),t.bB(_,v,g)),e.y===(1<<e.z)-1?b.push(t.bB(v,x,m),t.bB(v,x,g)):b.push(t.bB(y,x,m),t.bB(y,x,g),t.bB(y,v,m),t.bB(y,v,g)),new wi(b,[m,g,_,y,x,v],n,s)}}}function Ii(e,i){let r=1/0,n=-1/0;for(const s of i){const i=t.b3(e,s);r=Math.min(r,i),n=Math.max(n,i)}return{min:r,max:n}}class Mi{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t){this._helper.resize(e,t)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(e){this._cachedClippingPlane=t.bD(),this._projectionMatrix=t.bh(),this._globeViewProjMatrix32f=t.bg(),this._globeViewProjMatrixNoCorrection=t.bh(),this._globeViewProjMatrixNoCorrectionInverted=t.bh(),this._globeProjMatrixInverted=t.bh(),this._cameraPosition=t.by(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(e,i)=>{const r=t.ak(e.lat,-t.al,t.al),n=t.ak(+i,this.minZoom+_i(0,r),this.maxZoom);return{center:new t.V(e.lng,r),zoom:n}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Nt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Pi}clone(){const e=new Mi;return e.apply(this,!1),e}apply(e,t,i){this._globeLatitudeErrorCorrectionRadians=i||0,this._helper.apply(e,t)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.by();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,r=this.cameraToCenterDistance/e,n=Math.sin(i)*r,s=Math.cos(i)*r+1,o=1/Math.sqrt(n*n+s*s)*1;let a=-n,l=s;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const h=[0,a,l];t.bE(h,h,[0,0,0],-this.bearingInRadians),t.bF(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),t.bG(h,h,[0,0,0],this.center.lng*Math.PI/180);const u=1/t.b5(h);return t.aZ(h,h,u),[...h,-o*u]}isLocationOccluded(e){return!this.isSurfacePointVisible(pi(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,n=Math.cos(r),s=[Math.sin(i)*n,Math.sin(r),Math.cos(i)*n],o=[s[2],0,-s[0]],a=[0,0,0];t.b2(a,o,s),t.b1(o,o),t.b1(a,a);const l=[0,0,0];return t.b1(l,[o[0]*e[0]+a[0]*e[1]+s[0]*e[2],o[1]*e[0]+a[1]*e[1]+s[1]*e[2],o[2]*e[0]+a[2]*e[1]+s[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,r){const n=function(e,i,r){const n=1/(1<<r.z);return new t.a6(e/t.a5*n+r.x*n,i/t.a5*n+r.y*n)}(e,i,r.canonical),s=(o=n.y,[t.bx(n.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI]);var o;return this.getCircleRadiusCorrection()/Math.cos(s[1])}projectTileCoordinates(e,i,r,n){const s=r.canonical,o=di(e,i,s.x,s.y,s.z),a=1+(n?n(e,i):0)/t.bC,l=[o[0]*a,o[1]*a,o[2]*a,1];t.aE(l,l,this._globeViewProjMatrixNoCorrection);const c=this._cachedClippingPlane,h=c[0]*o[0]+c[1]*o[1]+c[2]*o[2]+c[3]<0;return{point:new t.P(l[0]/l[3],l[1]/l[3]),signedDistanceFromCamera:l[3],isOccluded:h}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const e=fi(this.worldSize,this.center.lat),i=t.bi(),r=t.bi();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),t.bc(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const n=this.centerOffset;i[8]=2*-n.x/this._helper._width,i[9]=2*n.y/this._helper._height,this._projectionMatrix=t.bd(i),this._globeProjMatrixInverted=t.bi(),t.ay(this._globeProjMatrixInverted,i),t.O(i,i,[0,0,-this.cameraToCenterDistance]),t.be(i,i,this.rollInRadians),t.bf(i,i,-this.pitchInRadians),t.be(i,i,this.bearingInRadians),t.O(i,i,[0,0,-e]);const s=t.by();s[0]=e,s[1]=e,s[2]=e,t.bf(r,i,this.center.lat*Math.PI/180),t.bH(r,r,-this.center.lng*Math.PI/180),t.Q(r,r,s),this._globeViewProjMatrixNoCorrection=r,t.bf(i,i,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),t.bH(i,i,-this.center.lng*Math.PI/180),t.Q(i,i,s),this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixNoCorrectionInverted=t.bi(),t.ay(this._globeViewProjMatrixNoCorrectionInverted,r);const o=t.by();this._cameraPosition=t.by(),this._cameraPosition[2]=this.cameraToCenterDistance/e,t.bE(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),t.bF(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),t.bE(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),t.a_(this._cameraPosition,this._cameraPosition,[0,0,1]),t.bF(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),t.bG(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);const a=t.bd(this._globeViewProjMatrixNoCorrectionInverted);t.Q(a,a,[1,1,-1]),this._cachedFrustum=$t.fromInvProjectionMatrix(a,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){t.w("calculateFogMatrix is not supported on globe projection.");const i=t.bi();return t.ao(i),i}getVisibleUnwrappedCoordinates(e){return[new t.ba(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&t.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,i){if(!this._globeViewProjMatrixNoCorrection)return 1;const r=pi(e);t.aZ(r,r,1+i/t.bC);const n=t.bD();return t.aE(n,[r[0],r[1],r[2],1],this._globeViewProjMatrixNoCorrection),n[2]/n[3]}populateCache(e){}getBounds(){const e=.5*this.width,i=.5*this.height,r=[new t.P(0,0),new t.P(e,0),new t.P(this.width,0),new t.P(this.width,i),new t.P(this.width,this.height),new t.P(e,this.height),new t.P(0,this.height),new t.P(0,i)],n=[];for(const t of r)n.push(this.unprojectScreenPoint(t));let s=0,o=0,a=0,l=0;const c=this.center;for(const u of n){const e=t.bI(c.lng,u.lng),i=t.bI(c.lat,u.lat);e<o&&(o=e),e>s&&(s=e),i<l&&(l=i),i>a&&(a=i)}const h=[c.lng+o,c.lat+l,c.lng+s,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new N(h)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,i){const r=pi(this.unprojectScreenPoint(i)),n=pi(e),s=t.by();t.bJ(s);const o=t.by();t.bG(o,r,s,-this.center.lng*Math.PI/180),t.bF(o,o,s,this.center.lat*Math.PI/180);const a=n[0]*n[0]+n[2]*n[2],l=o[0]*o[0];if(a<l)return;const c=Math.sqrt(a-l),h=-c,u=t.bK(n[0],n[2],o[0],c),d=t.bK(n[0],n[2],o[0],h),p=t.by();t.bG(p,n,s,-u);const f=t.bK(p[1],p[2],o[1],o[2]),m=t.by();t.bG(m,n,s,-d);const g=t.bK(m[1],m[2],o[1],o[2]),_=.5*Math.PI,y=f>=-_&&f<=_,x=g>=-_&&g<=_;let v,b;if(y&&x){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bL(u,e)+t.bL(f,i)<t.bL(d,e)+t.bL(g,i)?(v=u,b=f):(v=d,b=g)}else if(y)v=u,b=f;else{if(!x)return;v=d,b=g}const w=v/Math.PI*180,T=b/Math.PI*180,S=this.center.lat;this.setCenter(new t.V(w,t.ak(T,-90,90))),this.setZoom(this.zoom+_i(S,this.center.lat))}locationToScreenPoint(e,i){const r=pi(e);if(i){const n=i.getElevationForLngLatZoom(e,this._helper._tileZoom);t.aZ(r,r,1+n/t.bC)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(e){const i=t.bD();return t.aE(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],new t.P((.5*i[0]+.5)*this.width,(.5*-i[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,i){if(i){const t=i.pointCoordinate(e);if(t)return t}return t.a6.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}isPointOnMapSurface(e,t){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(i,r)}getRayDirectionFromPixel(e){const i=t.bD();i[0]=e.x/this.width*2-1,i[1]=-1*(e.y/this.height*2-1),i[2]=1,i[3]=1,t.aE(i,i,this._globeViewProjMatrixNoCorrectionInverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];const r=t.by();r[0]=i[0]-this._cameraPosition[0],r[1]=i[1]-this._cameraPosition[1],r[2]=i[2]-this._cameraPosition[2];const n=t.by();return t.b1(n,r),n}isSurfacePointVisible(e){const t=this._cachedClippingPlane;return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const i=t.bD();return t.aE(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const r=t.b3(e,i),n=t.by(),s=t.by();t.aZ(s,i,r),t.b0(n,e,s);const o=1-t.b3(n,n);if(o<0)return null;const a=t.b3(e,e)-1,l=-r+(r<0?1:-1)*Math.sqrt(o),c=a/l,h=l;return{tMin:Math.min(c,h),tMax:Math.max(c,h)}}unprojectScreenPoint(e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e),n=this.rayPlanetIntersection(i,r);if(n){const e=t.by();t.a_(e,i,[r[0]*n.tMin,r[1]*n.tMin,r[2]*n.tMin]);const s=t.by();return t.b1(s,e),mi(s)}const s=this._cachedClippingPlane,o=s[0]*r[0]+s[1]*r[1]+s[2]*r[2],a=-t.b9(s,i)/o,l=t.by();if(a>0)t.a_(l,i,[r[0]*a,r[1]*a,r[2]*a]);else{const e=t.by();t.a_(e,i,[2*r[0],2*r[1],2*r[2]]);const n=t.b9(this._cachedClippingPlane,e);t.b0(l,e,[this._cachedClippingPlane[0]*n,this._cachedClippingPlane[1]*n,this._cachedClippingPlane[2]*n])}const c=function(e){const i=t.by();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(s);return mi(function(e,i,r){const n=t.by();t.b0(n,r,e);const s=t.by();return t.bw(s,e,n,i/t.b7(n)),s}(c.center,c.radius,l))}getMatrixForModel(e,i){const r=t.V.convert(e),n=1/t.bC,s=t.bh();return t.bH(s,s,r.lng/180*Math.PI),t.bf(s,s,-r.lat/180*Math.PI),t.O(s,s,[0,0,1+i/t.bC]),t.bf(s,s,.5*Math.PI),t.Q(s,s,[n,n,n]),s}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.a2(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class Ei{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Nt({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new Zt,this._verticalPerspectiveTransform=new Mi}clone(){const e=new Ei;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this,!1),e}apply(e,t){this._helper.apply(e,t),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bs(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bs(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,r){const n=this._mercatorTransform.getPitchedTextCorrection(e,i,r),s=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,r);return t.bs(n,s,this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ci{get useGlobeControls(){return!0}handlePanInertia(e,i){const r=yi(e,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const r=e.around,n=i.screenPointToLocation(r);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const s=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const o=i.zoom-s;if(0===o)return;const a=t.bI(i.center.lng,n.lng),l=a/(Math.abs(a/180)+1),c=t.bI(i.center.lat,n.lat),h=i.getRayDirectionFromPixel(r),u=i.cameraPosition,d=-1*t.b3(u,h),p=t.by();t.a_(p,u,[h[0]*d,h[1]*d,h[2]*d]);const f=t.b5(p)-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=fi(i.worldSize,i.center.lat)/Math.min(i.width,i.height),_=t.bv(g,.9,.5,1,.25),y=(1-t.an(-o))*Math.min(m,_),x=i.center.lat,v=i.zoom,b=new t.V(i.center.lng+l*y,t.ak(i.center.lat+c*y,-t.al,t.al));i.setLocationAtPoint(n,r);const w=i.center,T=t.bv(Math.abs(a),45,85,0,1),S=t.bv(g,.75,.35,0,1),P=Math.pow(Math.max(T,S),.25),I=t.bI(w.lng,b.lng),M=t.bI(w.lat,b.lat);i.setCenter(new t.V(w.lng+I*P,w.lat+M*P).wrap()),i.setZoom(v+_i(x,i.center.lat))}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const r=t.center.lat,n=t.zoom;t.setCenter(yi(e.panDelta,t).wrap()),t.setZoom(n+_i(r,t.center.lat))}cameraForBoxAndBearing(e,i,r,n,s){const o=Xt(e,i,r,n,s),a=i.left/s.width*2-1,l=(s.width-i.right)/s.width*2-1,c=i.top/s.height*-2+1,h=(s.height-i.bottom)/s.height*-2+1,u=t.bI(r.getWest(),r.getEast())<0,d=u?r.getEast():r.getWest(),p=u?r.getWest():r.getEast(),f=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),g=d+.5*t.bI(d,p),_=f+.5*t.bI(f,m),y=s.clone();y.setCenter(o.center),y.setBearing(o.bearing),y.setPitch(0),y.setRoll(0),y.setZoom(o.zoom);const x=y.modelViewProjectionMatrix,v=[pi(r.getNorthWest()),pi(r.getNorthEast()),pi(r.getSouthWest()),pi(r.getSouthEast()),pi(new t.V(p,_)),pi(new t.V(d,_)),pi(new t.V(g,f)),pi(new t.V(g,m))],b=pi(o.center);let w=Number.POSITIVE_INFINITY;for(const t of v)a<0&&(w=Ci.getLesserNonNegativeNonNull(w,Ci.solveVectorScale(t,b,x,"x",a))),l>0&&(w=Ci.getLesserNonNegativeNonNull(w,Ci.solveVectorScale(t,b,x,"x",l))),c>0&&(w=Ci.getLesserNonNegativeNonNull(w,Ci.solveVectorScale(t,b,x,"y",c))),h<0&&(w=Ci.getLesserNonNegativeNonNull(w,Ci.solveVectorScale(t,b,x,"y",h)));if(Number.isFinite(w)&&0!==w)return o.zoom=y.zoom+t.aq(w),o;qt()}handleJumpToCenterZoom(e,i){const r=e.center.lat,n=e.applyConstrain(i.center?t.V.convert(i.center):e.center,e.zoom).center;e.setCenter(n.wrap());const s=void 0!==i.zoom?+i.zoom:e.zoom+_i(r,n.lat);e.zoom!==s&&e.setZoom(s)}handleEaseTo(e,i){const r=e.zoom,n=e.center,s=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let h=!1;const u=i.center?t.V.convert(i.center):n,d=e.applyConstrain(u,r).center;Vt(e,d);const p=e.clone();p.setCenter(d),p.setZoom(l?+i.zoom:r+_i(n.lat,u.lat)),p.setBearing(i.bearing);const f=new t.P(t.ak(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ak(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(d,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:r+_i(n.lat,m.lat),_=r+_i(n.lat,0),y=g+_i(m.lat,0),x=t.bI(n.lng,m.lng),v=t.bI(n.lat,m.lat),b=t.an(y-_);return h=g!==r,{easeFunc:r=>{if(t.bm(o,a)||Wt({startEulerAngles:o,endEulerAngles:a,tr:e,k:r,useSlerp:o.roll!=a.roll}),c&&e.interpolatePadding(s,i.padding,r),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else{const t=y>_?Math.min(2,b):Math.max(.5,b),i=Math.pow(t,1-r),s=vi(n,x,v,r*i);e.setCenter(s.wrap())}if(h){const i=t.G.number(_,y,r)+_i(0,e.center.lat);e.setZoom(i)}},isZooming:h,elevationCenter:m}}handleFlyTo(e,i){const r=void 0!==i.zoom,n=e.center,s=e.zoom,o=e.padding,a=!e.isPaddingEqual(i.padding),l=e.applyConstrain(t.V.convert(i.center||i.locationAtOffset),s).center,c=r?+i.zoom:e.zoom+_i(e.center.lat,l.lat),h=e.clone();h.setCenter(l),h.setZoom(c),h.setBearing(i.bearing);const u=new t.P(t.ak(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ak(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));h.setLocationAtPoint(l,u);const d=h.center;Vt(e,d);const p=function(e,i,r){const n=pi(i),s=pi(r),o=t.b3(n,s),a=Math.acos(o),l=ui(e);return a/(2*Math.PI)*l}(e,n,d),f=s+_i(n.lat,0),m=c+_i(d.lat,0),g=t.an(m-f);let _;if("number"==typeof i.minZoom){const r=+i.minZoom+_i(d.lat,0),n=Math.min(r,f,m)+_i(0,d.lat),s=e.applyConstrain(d,n).zoom+_i(d.lat,0);_=t.an(s-f)}const y=t.bI(n.lng,d.lng),x=t.bI(n.lat,d.lat);return{easeFunc:(r,s,l,h)=>{const u=vi(n,y,x,l);a&&e.interpolatePadding(o,i.padding,r);const p=1===r?d:u;e.setCenter(p.wrap());const m=f+t.aq(s);e.setZoom(1===r?c:m+_i(0,p.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,i,r,n){const s="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],o=[i[3],i[7],i[11],i[15]],a=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],l=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],c=t[0]*s[0]+t[1]*s[1]+t[2]*s[2],h=t[0]*o[0]+t[1]*o[1]+t[2]*o[2];return c+n*l===a+n*h||o[3]*(a-c)+s[3]*(h-l)+a*h==c*l?null:(c+s[3]-n*h-n*o[3])/(c-a-n*h+n*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&t<e?t:e}}class Ai{constructor(e){this._globe=e,this._mercatorCameraHelper=new Ht,this._verticalPerspectiveCameraHelper=new Ci}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){return this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,i){this.currentHelper.handleMapControlsPan(e,t,i)}cameraForBoxAndBearing(e,t,i,r,n){return this.currentHelper.cameraForBoxAndBearing(e,t,i,r,n)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}}const Di=(e,i)=>t.B(e,i&&i.filter(e=>"source.canvas"!==e.identifier)),zi=t.bM();class ki extends t.E{constructor(e,i={}){var r,n;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const t=this.tileManagers[e].getSource().type;"vector"!==t&&"geojson"!==t||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new R(k(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.dispatcher.registerMessageHandler("GDA",(e,t)=>this.getDashes(e,t)),this.imageManager=new g,this.imageManager.setEventedParent(this);const s=(null===(r=e._container)||void 0===r?void 0:r.lang)||"undefined"!=typeof document&&(null===(n=document.documentElement)||void 0===n?void 0:n.lang)||void 0;this.glyphManager=new b(e._requestManager,i.localIdeographFontFamily,s),this.lineAtlas=new M(256,512),this.crossTileSymbolIndex=new Ct,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",t.bN()),ae().on(ne,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.tileManagers[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const r in this._layers){const e=this._layers[r];e.source===i.id&&this._validateLayer(e)}})}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new t.bO,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,i){var r,n,s;this._checkLoaded();const o=null===i?null!==(s=null===(n=null===(r=this.stylesheet.state)||void 0===r?void 0:r[e])||void 0===n?void 0:n.default)&&void 0!==s?s:null:i;if(t.bP(o,this._globalState[e]))return this;this._globalState[e]=o,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const i=[];for(const r in e)!t.bP(this._globalState[r],e[r].default)&&(i.push(r),this._globalState[r]=e[r].default);this._applyGlobalStateChanges(i)}_applyGlobalStateChanges(e){if(0===e.length)return;const t=new Set,i={};for(const r of e){i[r]=this._globalState[r];for(const e in this._layers){const i=this._layers[e],n=i.getLayoutAffectingGlobalStateRefs(),s=i.getPaintAffectingGlobalStateRefs(),o=i.getVisibilityAffectingGlobalStateRefs();if(n.has(r)&&t.add(i.source),s.has(r))for(const{name:e,value:t}of s.get(r))this._updatePaintProperty(i,e,t);(null==o?void 0:o.has(r))&&(i.recalculateVisibility(),this._updateLayer(i))}}this.dispatcher.broadcast("UGS",i);for(const r in this.tileManagers)t.has(r)&&(this._reloadSource(r),this._changed=!0)}loadURL(e){return t._(this,arguments,void 0,function*(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const n=yield this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const s=this._loadStyleRequest;try{const e=yield t.j(n,this._loadStyleRequest);this._loadStyleRequest=null,this._load(e.data,i,r)}catch(e){this._loadStyleRequest=null,e&&!s.signal.aborted&&this.fire(new t.k(e))}})}loadJSON(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest,this.map._ownerWindow).then(()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,r)}).catch(()=>{})}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(zi,{validate:!1})}_load(e,i,r){var n,s;let o=i.transformStyle?i.transformStyle(r,e):e;if(!i.validate||!Di(this,t.C(o))){o=Object.assign({},o),this._loaded=!0,this.stylesheet=o;for(const e in o.sources)this.addSource(e,o.sources[e],{validate:!1});o.sprite?this._loadSprite(o.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(o.glyphs),this._createLayers(),this.light=new S(this.stylesheet.light),this._setProjectionInternal((null===(n=this.stylesheet.projection)||void 0===n?void 0:n.type)||"mercator"),this.sky=new I(this.stylesheet.sky),this.map.setTerrain(null!==(s=this.stylesheet.terrain)&&void 0!==s?s:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"))}}_createLayers(){var e,i,r;const n=t.bQ(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",n),this._order=n.map(e=>e.id),this._layers={},this._serializedLayers=null;for(const s of n){const e=t.bR(s,this._globalState);if(e.setEventedParent(this,{layer:{id:s.id}}),this._layers[s.id]=e,t.bS(e)&&this.tileManagers[e.source]){const t=null!==(r=null===(i=s.paint)||void 0===i?void 0:i["raster-fade-duration"])&&void 0!==r?r:e.paint.get("raster-fade-duration");this.tileManagers[e.source].setRasterFadeDuration(t)}}}_loadSprite(e,i=!1,r=void 0){this.imageManager.setLoaded(!1);const n=new AbortController;let s;this._spriteRequest=n,function(e,i,r,n){return t._(this,void 0,void 0,function*(){const s=p(e),o=r>1?"@2x":"",l={},c={};for(const{id:e,url:r}of s){const s=yield i.transformRequest(f(r,o,".json"),"SpriteJSON");l[e]=t.j(s,n);const a=yield i.transformRequest(f(r,o,".png"),"SpriteImage");c[e]=u.getImage(a,n)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,function*(){const t={};for(const r in e){t[r]={};const n=a.getImageCanvasContext((yield i[r]).data),s=(yield e[r]).data;for(const e in s){const{width:i,height:o,x:a,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=s[e];t[r][e]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:o,x:a,y:l,context:n}}}}return t})}(l,c)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter(t=>!(t in e)):[];for(const e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const n in e[t]){const r="default"===t?n:`${t}:${n}`;this._spritesImagesIds[t].push(r),r in this.imageManager.images?this.imageManager.updateImage(r,e[t][n],!1):this.imageManager.addImage(r,e[t][n]),i&&(this._changedImages[r]=!0)}}}).catch(e=>{this._spriteRequest=null,s=e,n.signal.aborted||this.fire(new t.k(s))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),r&&r(s)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}_validateLayer(e){const i=this.tileManagers[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const n=i.getSource();("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new t.k(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const r=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bT(r):r);const n=[];for(const s of e)if(r[s]){const e=i?t.bT(r[s]):r[s];n.push(e)}return n}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return!0;for(const r in this.tileManagers)if(this.tileManagers[r].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const r in this._updatedPaintProps)this._layers[r].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const r={};for(const t in this.tileManagers){const e=this.tileManagers[t];r[t]=e.used,e.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(const n in r){const e=this.tileManagers[n];!!r[n]!=!!e.used&&e.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:n}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,i={}){var r;this._checkLoaded();const n=this.serialize();if(e=i.transformStyle?i.transformStyle(n,e):e,(null===(r=i.validate)||void 0===r||r)&&Di(this,t.C(e)))return!1;(e=t.bT(e)).layers=t.bQ(e.layers);const s=t.bU(n,e),o=this._getOperationsToPerform(s);if(o.unimplemented.length>0)throw new Error(`Unimplemented: ${o.unimplemented.join(", ")}.`);if(0===o.operations.length)return!1;for(const t of o.operations)t();return this.stylesheet=e,this._serializedLayers=null,this.fire(new t.l("style.load",{style:this})),!0}_getOperationsToPerform(e){const t=[],i=[];for(const r of e)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,r.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,r.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,r.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,r.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,r.args));break;case"addSource":t.push(()=>this.addSource.apply(this,r.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,r.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,r.args));break;case"setLight":t.push(()=>this.setLight.apply(this,r.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,r.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,r.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,r.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,r.args));break;case"setSky":t.push(()=>this.setSky.apply(this,r.args));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,r.args));break;case"setTransition":t.push(()=>{});break;default:i.push(r.command)}return{operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.C.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=this.tileManagers[e]=new ke(e,i,this.dispatcher);n.style=this,n.setEventedParent(this,()=>({isSourceLoaded:n.loaded(),source:n.serialize(),sourceId:e})),n.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);for(const r in this._layers)if(this._layers[r].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${r}" is using it.`)));const i=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const i=this.tileManagers[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,i,r={}){this._checkLoaded();const n=e.id;if(this.getLayer(n))return void this.fire(new t.k(new Error(`Layer "${n}" already exists on this map.`)));let s;if("custom"===e.type){if(Di(this,t.bV(e)))return;s=t.bR(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(n,e.source),e=t.bT(e),e=t.e(e,{source:n})),this._validate(t.C.layer,`layers.${n}`,e,{arrayIndex:-1},r))return;s=t.bR(e,this._globalState),this._validateLayer(s),s.setEventedParent(this,{layer:{id:n}})}const o=i?this._order.indexOf(i):this._order.length;if(i&&-1===o)this.fire(new t.k(new Error(`Cannot add layer "${n}" before non-existing layer "${i}".`)));else{if(this._order.splice(o,0,n),this._layerOrderChanged=!0,this._layers[n]=s,this._removedLayers[n]&&s.source&&"custom"!==s.type){const e=this._removedLayers[n];delete this._removedLayers[n],e.type!==s.type?this._updatedSources[s.source]="clear":(this._updatedSources[s.source]="reload",this.tileManagers[s.source].pause())}this._updateLayer(s),s.onAdd&&s.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const n=i?this._order.indexOf(i):this._order.length;i&&-1===n?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(n,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const n=this.getLayer(e);n?n.minzoom===i&&n.maxzoom===r||(null!=i&&(n.minzoom=i),null!=r&&(n.maxzoom=r),this._updateLayer(n)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,r={}){this._checkLoaded();const n=this.getLayer(e);if(n){if(!t.bP(n.filter,i))return null==i?(n.setFilter(void 0),void this._updateLayer(n)):void(this._validate(t.C.filter,`layers.${n.id}.filter`,i,null,r)||(n.setFilter(t.bT(i)),this._updateLayer(n)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bT(this.getLayer(e).filter)}setLayoutProperty(e,i,r,n={}){this._checkLoaded();const s=this.getLayer(e);s?t.bP(s.getLayoutProperty(i),r)||(s.setLayoutProperty(i,r,n),this._updateLayer(s)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,r,n={}){this._checkLoaded();const s=this.getLayer(e);s?t.bP(s.getPaintProperty(i),r)||this._updatePaintProperty(s,i,r,n):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,i,r,n={}){e.setPaintProperty(i,r,n)&&this._updateLayer(e),t.bS(e)&&"raster-fade-duration"===i&&this.tileManagers[e.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const r=e.source,n=e.sourceLayer,s=this.tileManagers[r];if(void 0===s)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const o=s.getSource().type;"geojson"===o&&n?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==o||n?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),s.setFeatureState(n,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const r=e.source,n=this.tileManagers[r];if(void 0===n)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const s=n.getSource().type,o="vector"===s?e.sourceLayer:void 0;"vector"!==s||o?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):n.removeFeatureState(o,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this.tileManagers[i];if(void 0!==n)return"vector"!==n.getSource().type||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),n.getFeatureState(r,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bW(this.tileManagers,e=>e.serialize()),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,n=this.stylesheet;return t.bX({version:n.version,name:n.name,metadata:n.metadata,light:n.light,sky:n.sky,center:n.center,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,sprite:n.sprite,glyphs:n.glyphs,transition:n.transition,projection:n.projection,sources:e,layers:i,terrain:r},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let s=this._order.length-1;s>=0;s--){const n=this._order[s];if(t(n)){i[n]=s;for(const t of e){const e=t[n];if(e)for(const t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const n=[];for(let s=this._order.length-1;s>=0;s--){const o=this._order[s];if(t(o))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]<s)break;n.push(t),r.pop()}else for(const t of e){const e=t[o];if(e)for(const t of e)n.push(t.feature)}}return n}queryRenderedFeatures(e,i,r){i&&i.filter&&this._validate(t.C.filter,"queryRenderedFeatures.filter",i.filter,null,i);const n={};if(i&&i.layers){if(!(Array.isArray(i.layers)||i.layers instanceof Set))return this.fire(new t.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const e of i.layers){const i=this._layers[e];if(!i)return this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];n[i.source]=!0}}const s=[];i.availableImages=this._availableImages;const o=this._serializedAllLayers(),a=i.layers instanceof Set?i.layers:Array.isArray(i.layers)?new Set(i.layers):null,l=Object.assign(Object.assign({},i),{layers:a,globalState:this._globalState});for(const t in this.tileManagers)i.layers&&!n[t]||s.push(B(this.tileManagers[t],this._layers,o,e,l,r,this.map.terrain?(e,t,i)=>this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&s.push(function(e,t,i,r,n,s,o){const a={},l=s.queryRenderedSymbols(r),c=[];for(const h of Object.keys(l).map(Number))c.push(o[h]);c.sort(O);for(const h of c){const i=h.featureIndex.lookupSymbolFeatures(l[h.bucketInstanceId],t,h.bucketIndex,h.sourceLayerIndex,{filterSpec:n.filter,globalState:n.globalState},n.layers,n.availableImages,e);for(const e in i){const t=a[e]=a[e]||[],r=i[e];r.sort((e,t)=>{const i=h.featureSortOrder;if(i){const r=i.indexOf(e.featureIndex);return i.indexOf(t.featureIndex)-r}return t.featureIndex-e.featureIndex});for(const e of r)t.push(e)}}return function(e,t,i){for(const r in e)for(const n of e[r])V(n,i[t[r].source]);return e}(a,e,i)}(this._layers,o,this.tileManagers,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(s)}querySourceFeatures(e,i){(null==i?void 0:i.filter)&&this._validate(t.C.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.tileManagers[e];return r?function(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],n={};for(let s=0;s<i.length;s++){const e=i[s],o=e.tileID.canonical.key;n[o]||(n[o]=!0,e.querySourceFeatures(r,t))}return r}(r,i?Object.assign(Object.assign({},i),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(e,i={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const o in e)if(!t.bP(e[o],r[o])){n=!0;break}if(!n)return;const s={now:c(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,i),this.light.updateTransitions(s)}getProjection(){var e;return null===(e=this.stylesheet)||void 0===e?void 0:e.projection}setProjection(e){if(this._checkLoaded(),this.stylesheet.projection=e,this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(e.type)}getSky(){var e;return null===(e=this.stylesheet)||void 0===e?void 0:e.sky}setSky(e,i={}){this._checkLoaded();const r=this.getSky();let n=!1;if(!e&&!r)return;if(e&&!r)n=!0;else if(!e&&r)n=!0;else for(const o in e)if(!t.bP(e[o],r[o])){n=!0;break}if(!n)return;const s={now:c(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,i),this.sky.updateTransitions(s)}_setProjectionInternal(e){const i=function(e,i){const r={constrainOverride:i};if(Array.isArray(e)){const t=new hi({type:e});return{projection:t,transform:new Ei(r),cameraHelper:new Ai(t)}}switch(e){case"mercator":return{projection:new Bt,transform:new Zt(r),cameraHelper:new Ht};case"globe":{const e=new hi({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:e,transform:new Ei(r),cameraHelper:new Ai(e)}}case"vertical-perspective":return{projection:new li,transform:new Mi(r),cameraHelper:new Ci};default:return t.w(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Bt,transform:new Zt(r),cameraHelper:new Ht}}}(e,this.map.transformConstrain);this.projection=i.projection,this.map.migrateProjection(i.transform,i.cameraHelper);for(const t in this.tileManagers)this.tileManagers[t].reload()}_validate(e,i,r,n,s={}){return(!s||!1!==s.validate)&&Di(this,e.call(t.C,t.e({key:i,style:this.serialize(),value:r,styleSpec:t.u},n)))}_remove(e=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),ae().off(ne,this._rtlPluginLoaded);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this.tileManagers){const e=this.tileManagers[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.tileManagers[e].clearTiles()}_reloadSource(e){this.tileManagers[e].resume(),this.tileManagers[e].reload()}_updateSources(e){for(const t in this.tileManagers)this.tileManagers[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(const e in this.tileManagers)this._reloadSource(e)}_updatePlacement(e,t,i,r,n=!1){let s=!1,o=!1;const a={};for(const l of this._order){const t=this._layers[l];if("symbol"!==t.type)continue;if(!a[t.source]){const e=this.tileManagers[t.source];a[t.source]=e.getRenderableIds(!0).map(t=>e.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const i=this.crossTileSymbolIndex.addLayer(t,a[t.source],e.center.lng);s=s||i}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((n=n||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(c(),e.zoom))&&(this.pauseablePlacement=new St(e,this.map.terrain,this._order,n,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(c()),o=!0),s&&this.pauseablePlacement.placement.setStale()),o||s)for(const l of this._order){const e=this._layers[l];"symbol"===e.type&&this.placement.updateLayerOpacities(e,a[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(c())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e})}getGlyphs(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.C.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,i){return t._(this,void 0,void 0,function*(){const e={};for(const[t,r]of Object.entries(i.dashes))e[t]=this.lineAtlas.getDash(r.dasharray,r.round);return e})}addSprite(e,i,r={},n){this._checkLoaded();const s=[{id:e,url:i}],o=[...p(this.stylesheet.sprite),...s];this._validate(t.C.sprite,"sprite",o,null,r)||(this.stylesheet.sprite=o,this._loadSprite(s,!0,n))}removeSprite(e){this._checkLoaded();const i=p(this.stylesheet.sprite);if(i.find(t=>t.id===e)){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex(t=>t.id===e),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return p(this.stylesheet.sprite)}setSprite(e,i={},r){this._checkLoaded(),e&&this._validate(t.C.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const t=this.tileManagers[e];t.setEventedParent(null),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var Ri=t.aS([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Li{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,r,n,s,o,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let h=0;!c&&h<r.length;h++)this.boundPaintVertexBuffers[h]!==r[h]&&(c=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||c||this.boundIndexBuffer!==n||this.boundVertexOffset!==s||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==a||this.boundDynamicVertexBuffer3!==l?this.freshBind(t,i,r,n,s,o,a,l):(e.bindVertexArray.set(this.vao),o&&o.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind(),l&&l.bind())}freshBind(e,t,i,r,n,s,o,a){const l=e.numAttributes,c=this.context,h=c.gl;this.vao&&this.destroy(),this.vao=c.createVertexArray(),c.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=s,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=a,t.enableAttributes(h,e);for(const u of i)u.enableAttributes(h,e);s&&s.enableAttributes(h,e),o&&o.enableAttributes(h,e),a&&a.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,n);for(const u of i)u.bind(),u.setVertexAttribPointers(h,e,n);s&&(s.bind(),s.setVertexAttribPointers(h,e,n)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(h,e,n)),a&&(a.bind(),a.setVertexAttribPointers(h,e,n)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Fi=(e,i,r,n,s)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):t.bn.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:s?0:r?r.calculateFogBlendOpacity(n):0,u_horizon_color:r?r.properties.get("horizon-color"):t.bn.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:s?1:0}),Bi={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Oi(e){const t=[];for(let i=0;i<e.length;i++){if(null===e[i])continue;const r=e[i].split(" ");t.push(r.pop())}return t}class Vi{constructor(e,i,r,n,s,o,a,l,c=[]){const h=e.gl;this.program=h.createProgram();const u=Oi(i.staticAttributes),d=r?r.getBinderAttributes():[],p=u.concat(d),f=Dt.prelude.staticUniforms?Oi(Dt.prelude.staticUniforms):[],m=a.staticUniforms?Oi(a.staticUniforms):[],g=i.staticUniforms?Oi(i.staticUniforms):[],_=r?r.getBinderUniforms():[],y=f.concat(m).concat(g).concat(_),x=[];for(const t of y)x.indexOf(t)<0&&x.push(t);const v=r?r.defines():[];ri(h)&&v.unshift("#version 300 es"),s&&v.push("#define OVERDRAW_INSPECTOR;"),o&&v.push("#define TERRAIN3D;"),l&&v.push(l),c&&v.push(...c);let b=v.concat(Dt.prelude.fragmentSource,a.fragmentSource,i.fragmentSource).join("\n"),w=v.concat(Dt.prelude.vertexSource,a.vertexSource,i.vertexSource).join("\n");ri(h)||(b=function(e){return e.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(b),w=function(e){return e.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(w));const T=h.createShader(h.FRAGMENT_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);if(h.shaderSource(T,b),h.compileShader(T),!h.getShaderParameter(T,h.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${h.getShaderInfoLog(T)}`);h.attachShader(this.program,T);const S=h.createShader(h.VERTEX_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);if(h.shaderSource(S,w),h.compileShader(S),!h.getShaderParameter(S,h.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${h.getShaderInfoLog(S)}`);h.attachShader(this.program,S),this.attributes={};const P={};this.numAttributes=p.length;for(let t=0;t<this.numAttributes;t++)p[t]&&(h.bindAttribLocation(this.program,t,p[t]),this.attributes[p[t]]=t);if(h.linkProgram(this.program),!h.getProgramParameter(this.program,h.LINK_STATUS))throw new Error(`Program failed to link: ${h.getProgramInfoLog(this.program)}`);h.deleteShader(S),h.deleteShader(T);for(let t=0;t<x.length;t++){const e=x[t];if(e&&!P[e]){const t=h.getUniformLocation(this.program,e);t&&(P[e]=t)}}this.fixedUniforms=n(e,P),this.terrainUniforms=((e,i)=>({u_depth:new t.bY(e,i.u_depth),u_terrain:new t.bY(e,i.u_terrain),u_terrain_dim:new t.bo(e,i.u_terrain_dim),u_terrain_matrix:new t.b_(e,i.u_terrain_matrix),u_terrain_unpack:new t.b$(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.bo(e,i.u_terrain_exaggeration)}))(e,P),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.b_(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.b$(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.b$(e,i.u_projection_clipping_plane),u_projection_transition:new t.bo(e,i.u_projection_transition),u_projection_fallback_matrix:new t.b_(e,i.u_projection_fallback_matrix)}))(e,P),this.binderUniforms=r?r.getUniforms(e,P):[]}draw(e,t,i,r,n,s,o,a,l,c,h,u,d,p,f,m,g,_,y){const x=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(n),e.setCullFace(s),a){e.activeTexture.set(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,a.depthTexture),e.activeTexture.set(x.TEXTURE3),x.bindTexture(x.TEXTURE_2D,a.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(a[e])}if(l)for(const b in l)this.projectionUniforms[Bi[b]].set(l[b]);if(o)for(const b in this.fixedUniforms)this.fixedUniforms[b].set(o[b]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let v=0;switch(t){case x.LINES:v=2;break;case x.TRIANGLES:v=3;break;case x.LINE_STRIP:v=1}for(const b of d.get()){const i=b.vaos||(b.vaos={});(i[c]||(i[c]=new Li)).bind(e,this,h,m?m.getPaintVertexBuffers():[],u,b.vertexOffset,g,_,y),x.drawElements(t,b.primitiveLength*v,x.UNSIGNED_SHORT,b.primitiveOffset*v*2)}}}function ji(e,i,r){const n=1/t.aK(r,1,i.transform.tileZoom),s=Math.pow(2,r.tileID.overscaledZ),o=r.tileSize*Math.pow(2,i.transform.tileZoom)/s,a=o*(r.tileID.canonical.x+r.tileID.wrap*s),l=o*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[n,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const Ni=(e,i,r,n)=>{const s=e.style.light,o=s.properties.get("position"),a=[o.x,o.y,o.z],l=t.c2();"viewport"===s.properties.get("anchor")&&t.c3(l,e.transform.bearingInRadians),t.c4(a,a,l);const c=e.transform.transformLightDirection(a),h=s.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:s.properties.get("intensity"),u_lightcolor:[h.r,h.g,h.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:n}},Ui=(e,i,r,n,s,o,a)=>t.e(Ni(e,i,r,n),ji(o,e,a),{u_height_factor:-Math.pow(2,s.overscaledZ)/a.tileSize/8}),Gi=(e,i,r,n)=>t.e(ji(i,e,r),{u_fill_translate:n}),$i=(e,t)=>({u_world:e,u_fill_translate:t}),Zi=(e,i,r,n,s)=>t.e(Gi(e,i,r,s),{u_world:n}),qi=(e,i,r,n,s)=>{const o=e.transform;let a,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const e=t.aK(i,1,o.zoom);a=!0,l=[e,e],c=e/(t.a5*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*s}else a=!1,l=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:n}},Wi=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Xi=e=>({u_viewport_size:[e.width,e.height]}),Hi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Yi=(e,i,r,n)=>{const s=t.aK(e,1,i)/(t.a5*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*n;return{u_extrude_scale:t.aK(e,1,i),u_intensity:r,u_globe_extrude_scale:s}},Ki=(e,i,r,n)=>{const s=t.N();t.c5(s,0,e.width,e.height,0,0,1);const o=e.context.gl;return{u_matrix:s,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:r,u_color_ramp:n,u_opacity:i.paint.get("heatmap-opacity")}},Ji=(e,t,i)=>{const r=i.paint.get("hillshade-accent-color");let n;switch(i.paint.get("hillshade-method")){case"basic":n=4;break;case"combined":n=1;break;case"igor":n=2;break;case"multidirectional":n=3;break;default:n=0}const s=i.getIlluminationProperties();for(let o=0;o<s.directionRadians.length;o++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(s.directionRadians[o]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:er(0,t.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:s.altitudeRadians,u_azimuths:s.directionRadians,u_accent:r,u_method:n,u_highlights:s.highlightColor,u_shadows:s.shadowColor}},Qi=(e,i)=>{const r=i.stride,n=t.N();return t.c5(n,0,t.a5,-t.a5,0,0,1),t.O(n,n,[0,-t.a5,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function er(e,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new t.a6(0,n/r).toLngLat().lat,new t.a6(0,(n+1)/r).toLngLat().lat]}const tr=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),ir=(e,i,r,n)=>{const s=e.transform;return{u_translation:lr(e,i,r),u_ratio:n/t.aK(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},rr=(e,i,r,n,s)=>t.e(ir(e,i,r,n),{u_image:0,u_image_height:s}),nr=(e,i,r,n,s)=>{const o=e.transform,a=ar(i,o);return{u_translation:lr(e,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:n/t.aK(i,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[a,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},sr=(e,i,r,n,s)=>{const o=ar(i,e.transform);return t.e(ir(e,i,r,n),{u_tileratio:o,u_crossfade_from:s.fromScale,u_crossfade_to:s.toScale,u_image:0,u_mix:s.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},or=(e,i,r,n,s,o)=>{const a=ar(i,e.transform);return t.e(ir(e,i,r,n),{u_image:0,u_image_height:o,u_tileratio:a,u_crossfade_from:s.fromScale,u_crossfade_to:s.toScale,u_image_dash:1,u_mix:s.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function ar(e,i){return 1/t.aK(e,1,i.tileZoom)}function lr(e,i,r){return t.aL(e.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const cr=(e,t,i,r,n)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(o=r.paint.get("raster-saturation"),o>0?1-1/(1.001-o):-o),u_contrast_factor:(s=r.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:hr(r.paint.get("raster-hue-rotate")),u_coords_top:[n[0].x,n[0].y,n[1].x,n[1].y],u_coords_bottom:[n[3].x,n[3].y,n[2].x,n[2].y]};var s,o};function hr(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 ur=(e,t,i,r,n,s,o,a,l,c,h,u,d)=>{const p=o.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+h,u_pitch_with_map:+r,u_is_along_line:n,u_is_variable_anchor:s,u_texsize:u,u_texture:0,u_translation:c,u_pitched_scale:d}},dr=(e,i,r,n,s,o,a,l,c,h,u,d,p,f)=>{const m=a.transform;return t.e(ur(e,i,r,n,s,o,a,l,c,h,u,d,f),{u_gamma_scale:n?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:1})},pr=(e,i,r,n,s,o,a,l,c,h,u,d,p)=>t.e(dr(e,i,r,n,s,o,a,l,c,h,!0,u,0,p),{u_texsize_icon:d,u_texture_icon:1}),fr=(e,t)=>({u_opacity:e,u_color:t}),mr=(e,i,r,n,s)=>t.e(function(e,i,r,n){const s=r.imageManager.getPattern(e.from.toString()),o=r.imageManager.getPattern(e.to.toString()),{width:a,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,n.tileID.overscaledZ),h=n.tileSize*Math.pow(2,r.transform.tileZoom)/c,u=h*(n.tileID.canonical.x+n.tileID.wrap*c),d=h*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[a,l],u_mix:i.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.aK(n,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(r,s,i,n),{u_opacity:e}),gr=(e,t)=>{},_r={fillExtrusion:(e,i)=>({u_lightpos:new t.c0(e,i.u_lightpos),u_lightpos_globe:new t.c0(e,i.u_lightpos_globe),u_lightintensity:new t.bo(e,i.u_lightintensity),u_lightcolor:new t.c0(e,i.u_lightcolor),u_vertical_gradient:new t.bo(e,i.u_vertical_gradient),u_opacity:new t.bo(e,i.u_opacity),u_fill_translate:new t.c1(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.c0(e,i.u_lightpos),u_lightpos_globe:new t.c0(e,i.u_lightpos_globe),u_lightintensity:new t.bo(e,i.u_lightintensity),u_lightcolor:new t.c0(e,i.u_lightcolor),u_vertical_gradient:new t.bo(e,i.u_vertical_gradient),u_height_factor:new t.bo(e,i.u_height_factor),u_opacity:new t.bo(e,i.u_opacity),u_fill_translate:new t.c1(e,i.u_fill_translate),u_image:new t.bY(e,i.u_image),u_texsize:new t.c1(e,i.u_texsize),u_pixel_coord_upper:new t.c1(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c1(e,i.u_pixel_coord_lower),u_scale:new t.c0(e,i.u_scale),u_fade:new t.bo(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.c1(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bY(e,i.u_image),u_texsize:new t.c1(e,i.u_texsize),u_pixel_coord_upper:new t.c1(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c1(e,i.u_pixel_coord_lower),u_scale:new t.c0(e,i.u_scale),u_fade:new t.bo(e,i.u_fade),u_fill_translate:new t.c1(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.c1(e,i.u_world),u_fill_translate:new t.c1(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.c1(e,i.u_world),u_image:new t.bY(e,i.u_image),u_texsize:new t.c1(e,i.u_texsize),u_pixel_coord_upper:new t.c1(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c1(e,i.u_pixel_coord_lower),u_scale:new t.c0(e,i.u_scale),u_fade:new t.bo(e,i.u_fade),u_fill_translate:new t.c1(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.bo(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bY(e,i.u_scale_with_map),u_pitch_with_map:new t.bY(e,i.u_pitch_with_map),u_extrude_scale:new t.c1(e,i.u_extrude_scale),u_device_pixel_ratio:new t.bo(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.bo(e,i.u_globe_extrude_scale),u_translate:new t.c1(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.c1(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.c1(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.bZ(e,i.u_color),u_overlay:new t.bY(e,i.u_overlay),u_overlay_scale:new t.bo(e,i.u_overlay_scale)}),depth:gr,clippingMask:gr,heatmap:(e,i)=>({u_extrude_scale:new t.bo(e,i.u_extrude_scale),u_intensity:new t.bo(e,i.u_intensity),u_globe_extrude_scale:new t.bo(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.b_(e,i.u_matrix),u_world:new t.c1(e,i.u_world),u_image:new t.bY(e,i.u_image),u_color_ramp:new t.bY(e,i.u_color_ramp),u_opacity:new t.bo(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bY(e,i.u_image),u_latrange:new t.c1(e,i.u_latrange),u_exaggeration:new t.bo(e,i.u_exaggeration),u_altitudes:new t.c7(e,i.u_altitudes),u_azimuths:new t.c7(e,i.u_azimuths),u_accent:new t.bZ(e,i.u_accent),u_method:new t.bY(e,i.u_method),u_shadows:new t.c6(e,i.u_shadows),u_highlights:new t.c6(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.b_(e,i.u_matrix),u_image:new t.bY(e,i.u_image),u_dimension:new t.c1(e,i.u_dimension),u_zoom:new t.bo(e,i.u_zoom),u_unpack:new t.b$(e,i.u_unpack)}),colorRelief:(e,i)=>({u_image:new t.bY(e,i.u_image),u_unpack:new t.b$(e,i.u_unpack),u_dimension:new t.c1(e,i.u_dimension),u_elevation_stops:new t.bY(e,i.u_elevation_stops),u_color_stops:new t.bY(e,i.u_color_stops),u_color_ramp_size:new t.bY(e,i.u_color_ramp_size),u_opacity:new t.bo(e,i.u_opacity)}),line:(e,i)=>({u_translation:new t.c1(e,i.u_translation),u_ratio:new t.bo(e,i.u_ratio),u_device_pixel_ratio:new t.bo(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c1(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.c1(e,i.u_translation),u_ratio:new t.bo(e,i.u_ratio),u_device_pixel_ratio:new t.bo(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c1(e,i.u_units_to_pixels),u_image:new t.bY(e,i.u_image),u_image_height:new t.bo(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.c1(e,i.u_translation),u_texsize:new t.c1(e,i.u_texsize),u_ratio:new t.bo(e,i.u_ratio),u_device_pixel_ratio:new t.bo(e,i.u_device_pixel_ratio),u_image:new t.bY(e,i.u_image),u_units_to_pixels:new t.c1(e,i.u_units_to_pixels),u_scale:new t.c0(e,i.u_scale),u_fade:new t.bo(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.c1(e,i.u_translation),u_ratio:new t.bo(e,i.u_ratio),u_device_pixel_ratio:new t.bo(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c1(e,i.u_units_to_pixels),u_image:new t.bY(e,i.u_image),u_mix:new t.bo(e,i.u_mix),u_tileratio:new t.bo(e,i.u_tileratio),u_crossfade_from:new t.bo(e,i.u_crossfade_from),u_crossfade_to:new t.bo(e,i.u_crossfade_to),u_lineatlas_width:new t.bo(e,i.u_lineatlas_width),u_lineatlas_height:new t.bo(e,i.u_lineatlas_height)}),lineGradientSDF:(e,i)=>({u_translation:new t.c1(e,i.u_translation),u_ratio:new t.bo(e,i.u_ratio),u_device_pixel_ratio:new t.bo(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c1(e,i.u_units_to_pixels),u_image:new t.bY(e,i.u_image),u_image_height:new t.bo(e,i.u_image_height),u_tileratio:new t.bo(e,i.u_tileratio),u_crossfade_from:new t.bo(e,i.u_crossfade_from),u_crossfade_to:new t.bo(e,i.u_crossfade_to),u_image_dash:new t.bY(e,i.u_image_dash),u_mix:new t.bo(e,i.u_mix),u_lineatlas_width:new t.bo(e,i.u_lineatlas_width),u_lineatlas_height:new t.bo(e,i.u_lineatlas_height)}),raster:(e,i)=>({u_tl_parent:new t.c1(e,i.u_tl_parent),u_scale_parent:new t.bo(e,i.u_scale_parent),u_buffer_scale:new t.bo(e,i.u_buffer_scale),u_fade_t:new t.bo(e,i.u_fade_t),u_opacity:new t.bo(e,i.u_opacity),u_image0:new t.bY(e,i.u_image0),u_image1:new t.bY(e,i.u_image1),u_brightness_low:new t.bo(e,i.u_brightness_low),u_brightness_high:new t.bo(e,i.u_brightness_high),u_saturation_factor:new t.bo(e,i.u_saturation_factor),u_contrast_factor:new t.bo(e,i.u_contrast_factor),u_spin_weights:new t.c0(e,i.u_spin_weights),u_coords_top:new t.b$(e,i.u_coords_top),u_coords_bottom:new t.b$(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bY(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bY(e,i.u_is_size_feature_constant),u_size_t:new t.bo(e,i.u_size_t),u_size:new t.bo(e,i.u_size),u_camera_to_center_distance:new t.bo(e,i.u_camera_to_center_distance),u_pitch:new t.bo(e,i.u_pitch),u_rotate_symbol:new t.bY(e,i.u_rotate_symbol),u_aspect_ratio:new t.bo(e,i.u_aspect_ratio),u_fade_change:new t.bo(e,i.u_fade_change),u_label_plane_matrix:new t.b_(e,i.u_label_plane_matrix),u_coord_matrix:new t.b_(e,i.u_coord_matrix),u_is_text:new t.bY(e,i.u_is_text),u_pitch_with_map:new t.bY(e,i.u_pitch_with_map),u_is_along_line:new t.bY(e,i.u_is_along_line),u_is_variable_anchor:new t.bY(e,i.u_is_variable_anchor),u_texsize:new t.c1(e,i.u_texsize),u_texture:new t.bY(e,i.u_texture),u_translation:new t.c1(e,i.u_translation),u_pitched_scale:new t.bo(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bY(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bY(e,i.u_is_size_feature_constant),u_size_t:new t.bo(e,i.u_size_t),u_size:new t.bo(e,i.u_size),u_camera_to_center_distance:new t.bo(e,i.u_camera_to_center_distance),u_pitch:new t.bo(e,i.u_pitch),u_rotate_symbol:new t.bY(e,i.u_rotate_symbol),u_aspect_ratio:new t.bo(e,i.u_aspect_ratio),u_fade_change:new t.bo(e,i.u_fade_change),u_label_plane_matrix:new t.b_(e,i.u_label_plane_matrix),u_coord_matrix:new t.b_(e,i.u_coord_matrix),u_is_text:new t.bY(e,i.u_is_text),u_pitch_with_map:new t.bY(e,i.u_pitch_with_map),u_is_along_line:new t.bY(e,i.u_is_along_line),u_is_variable_anchor:new t.bY(e,i.u_is_variable_anchor),u_texsize:new t.c1(e,i.u_texsize),u_texture:new t.bY(e,i.u_texture),u_gamma_scale:new t.bo(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bo(e,i.u_device_pixel_ratio),u_is_halo:new t.bY(e,i.u_is_halo),u_translation:new t.c1(e,i.u_translation),u_pitched_scale:new t.bo(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bY(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bY(e,i.u_is_size_feature_constant),u_size_t:new t.bo(e,i.u_size_t),u_size:new t.bo(e,i.u_size),u_camera_to_center_distance:new t.bo(e,i.u_camera_to_center_distance),u_pitch:new t.bo(e,i.u_pitch),u_rotate_symbol:new t.bY(e,i.u_rotate_symbol),u_aspect_ratio:new t.bo(e,i.u_aspect_ratio),u_fade_change:new t.bo(e,i.u_fade_change),u_label_plane_matrix:new t.b_(e,i.u_label_plane_matrix),u_coord_matrix:new t.b_(e,i.u_coord_matrix),u_is_text:new t.bY(e,i.u_is_text),u_pitch_with_map:new t.bY(e,i.u_pitch_with_map),u_is_along_line:new t.bY(e,i.u_is_along_line),u_is_variable_anchor:new t.bY(e,i.u_is_variable_anchor),u_texsize:new t.c1(e,i.u_texsize),u_texsize_icon:new t.c1(e,i.u_texsize_icon),u_texture:new t.bY(e,i.u_texture),u_texture_icon:new t.bY(e,i.u_texture_icon),u_gamma_scale:new t.bo(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bo(e,i.u_device_pixel_ratio),u_is_halo:new t.bY(e,i.u_is_halo),u_translation:new t.c1(e,i.u_translation),u_pitched_scale:new t.bo(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.bo(e,i.u_opacity),u_color:new t.bZ(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.bo(e,i.u_opacity),u_image:new t.bY(e,i.u_image),u_pattern_tl_a:new t.c1(e,i.u_pattern_tl_a),u_pattern_br_a:new t.c1(e,i.u_pattern_br_a),u_pattern_tl_b:new t.c1(e,i.u_pattern_tl_b),u_pattern_br_b:new t.c1(e,i.u_pattern_br_b),u_texsize:new t.c1(e,i.u_texsize),u_mix:new t.bo(e,i.u_mix),u_pattern_size_a:new t.c1(e,i.u_pattern_size_a),u_pattern_size_b:new t.c1(e,i.u_pattern_size_b),u_scale_a:new t.bo(e,i.u_scale_a),u_scale_b:new t.bo(e,i.u_scale_b),u_pixel_coord_upper:new t.c1(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c1(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bo(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bY(e,i.u_texture),u_ele_delta:new t.bo(e,i.u_ele_delta),u_fog_matrix:new t.b_(e,i.u_fog_matrix),u_fog_color:new t.bZ(e,i.u_fog_color),u_fog_ground_blend:new t.bo(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bo(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.bZ(e,i.u_horizon_color),u_horizon_fog_blend:new t.bo(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.bo(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.bo(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bY(e,i.u_texture),u_terrain_coords_id:new t.bo(e,i.u_terrain_coords_id),u_ele_delta:new t.bo(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.bo(e,i.u_input),u_output_expected:new t.bo(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.c0(e,i.u_sun_pos),u_atmosphere_blend:new t.bo(e,i.u_atmosphere_blend),u_globe_position:new t.c0(e,i.u_globe_position),u_globe_radius:new t.bo(e,i.u_globe_radius),u_inv_proj_matrix:new t.b_(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.bZ(e,i.u_sky_color),u_horizon_color:new t.bZ(e,i.u_horizon_color),u_horizon:new t.c1(e,i.u_horizon),u_horizon_normal:new t.c1(e,i.u_horizon_normal),u_sky_horizon_blend:new t.bo(e,i.u_sky_horizon_blend),u_sky_blend:new t.bo(e,i.u_sky_blend)})};class yr{constructor(e,t,i){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||t.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");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)}}const xr={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class vr{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||t.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i<this.attributes.length;i++){const r=t.attributes[this.attributes[i].name];void 0!==r&&e.enableVertexAttribArray(r)}}setVertexAttribPointers(e,t,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],s=t.attributes[n.name];void 0!==s&&e.vertexAttribPointer(s,n.components,e[xr[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class br{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 wr extends br{getDefault(){return t.bn.transparent}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 Tr extends br{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Sr extends br{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class Pr extends br{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 Ir extends br{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Mr extends br{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Er extends br{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 Cr extends br{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 Ar extends br{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 Dr extends br{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 zr extends br{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 kr extends br{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class Rr extends br{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 Lr extends br{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class Fr extends br{getDefault(){return t.bn.transparent}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 Br extends br{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class Or extends br{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 Vr extends br{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class jr extends br{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Nr extends br{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Ur extends br{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Gr extends br{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 $r extends br{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 Zr extends br{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 qr extends br{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 Wr extends br{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 Xr extends br{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Hr extends br{getDefault(){return null}set(e){var t;if(e===this.current&&!this.dirty)return;const i=this.gl;ri(i)?i.bindVertexArray(e):null===(t=i.getExtension("OES_vertex_array_object"))||void 0===t||t.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Yr extends br{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 Kr extends br{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 Jr extends br{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 Qr extends br{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class en extends Qr{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,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class tn extends Qr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class rn extends Qr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}const nn="Framebuffer is not complete";class sn{constructor(e,t,i,r,n){this.context=e,this.width=t,this.height=i;const s=e.gl,o=this.framebuffer=s.createFramebuffer();if(this.colorAttachment=new en(e,o),r)this.depthAttachment=n?new rn(e,o):new tn(e,o);else if(n)throw new Error("Stencil cannot be set without depth");if(s.checkFramebufferStatus(s.FRAMEBUFFER)!==s.FRAMEBUFFER_COMPLETE)throw new Error(nn)}destroy(){const e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class on{constructor(e){var t,i;if(this.gl=e,this.clearColor=new wr(this),this.clearDepth=new Tr(this),this.clearStencil=new Sr(this),this.colorMask=new Pr(this),this.depthMask=new Ir(this),this.stencilMask=new Mr(this),this.stencilFunc=new Er(this),this.stencilOp=new Cr(this),this.stencilTest=new Ar(this),this.depthRange=new Dr(this),this.depthTest=new zr(this),this.depthFunc=new kr(this),this.blend=new Rr(this),this.blendFunc=new Lr(this),this.blendColor=new Fr(this),this.blendEquation=new Br(this),this.cullFace=new Or(this),this.cullFaceSide=new Vr(this),this.frontFace=new jr(this),this.program=new Nr(this),this.activeTexture=new Ur(this),this.viewport=new Gr(this),this.bindFramebuffer=new $r(this),this.bindRenderbuffer=new Zr(this),this.bindTexture=new qr(this),this.bindVertexBuffer=new Wr(this),this.bindElementBuffer=new Xr(this),this.bindVertexArray=new Hr(this),this.pixelStoreUnpack=new Yr(this),this.pixelStoreUnpackPremultiplyAlpha=new Kr(this),this.pixelStoreUnpackFlipY=new Jr(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),ri(e)){this.HALF_FLOAT=e.HALF_FLOAT;const r=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!==(t=e.RGBA16F)&&void 0!==t?t:null==r?void 0:r.RGBA16F_EXT,this.RGB16F=null!==(i=e.RGB16F)&&void 0!==i?i:null==r?void 0:r.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");const t=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==t?void 0:t.HALF_FLOAT_OES}}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.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t){return new yr(this,e,t)}createVertexBuffer(e,t,i){return new vr(this,e,t,i)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i,r){return new sn(this,e,t,i,r)}clear({color:e,depth:t,stencil:i}){const r=this.gl;let n=0;e&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!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(e){t.bP(e.blendFunction,Yt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){var e;return ri(this.gl)?this.gl.createVertexArray():null===(e=this.gl.getExtension("OES_vertex_array_object"))||void 0===e?void 0:e.createVertexArrayOES()}deleteVertexArray(e){var t;return ri(this.gl)?this.gl.deleteVertexArray(e):null===(t=this.gl.getExtension("OES_vertex_array_object"))||void 0===t?void 0:t.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let an;function ln(e,i,r,n,s){const o=e.context,a=e.transform,l=o.gl,c=e.useProgram("collisionBox"),h=[];let u=0,d=0;for(let t=0;t<n.length;t++){const p=n[t],f=i.getTile(p).getBucket(r);if(!f)continue;const m=s?f.textCollisionBox:f.iconCollisionBox,g=f.collisionCircleArray;g.length>0&&(h.push({circleArray:g,circleOffset:d,coord:p}),u+=g.length/4,d=u),m&&c.draw(o,l.LINES,Qt.disabled,ti.disabled,e.colorModeForRenderPass(),Jt.disabled,Wi(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(p),a.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer)}if(!s||!h.length)return;const p=e.useProgram("collisionCircle"),f=new t.c8;f.resize(4*u),f._trim();let m=0;for(const t of h)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,r=t.circleArray[i+0],n=t.circleArray[i+1],s=t.circleArray[i+2],o=t.circleArray[i+3];f.emplace(m++,r,n,s,o,0),f.emplace(m++,r,n,s,o,1),f.emplace(m++,r,n,s,o,2),f.emplace(m++,r,n,s,o,3)}(!an||an.length<2*u)&&(an=function(e){const i=2*e,r=new t.ca;r.resize(i),r._trim();for(let t=0;t<i;t++){const e=6*t;r.uint16[e+0]=4*t+0,r.uint16[e+1]=4*t+1,r.uint16[e+2]=4*t+2,r.uint16[e+3]=4*t+2,r.uint16[e+4]=4*t+3,r.uint16[e+5]=4*t+0}return r}(u));const g=o.createIndexBuffer(an,!0),_=o.createVertexBuffer(f,t.c9.members,!0);for(const y of h){const i=Xi(e.transform);p.draw(o,l.TRIANGLES,Qt.disabled,ti.disabled,e.colorModeForRenderPass(),Jt.disabled,i,e.style.map.terrain&&e.style.map.terrain.getTerrainData(y.coord),null,r.id,_,g,t.aV.simpleSegment(0,2*y.circleOffset,y.circleArray.length,y.circleArray.length/2),null,e.transform.zoom,null,null,null)}_.destroy(),g.destroy()}const cn=t.ao(new Float32Array(16));function hn(e,i,r,n,s,o){const{horizontalAlign:a,verticalAlign:l}=t.aP(e);return new t.P((-(a-.5)*i/s+n[0])*o,(-(l-.5)*r/s+n[1])*o)}function un(e,i,r,n,s,o){const a=i.tileAnchorPoint.add(new t.P(i.translation[0],i.translation[1]));if(i.pitchWithMap){let e=n.mult(o);r||(e=e.rotate(-s));const t=a.add(e);return je(t.x,t.y,i.pitchedLabelPlaneMatrix,i.getElevation).point}if(r){const t=He(i.tileAnchorPoint.x+1,i.tileAnchorPoint.y,i).point.sub(e),r=Math.atan(t.y/t.x)+(t.x<0?Math.PI:0);return e.add(n.rotate(r))}return e.add(n)}function dn(e,i,r,n,s,o,a,l,c,h,u,d){const p=e.text.placedSymbolArray,f=e.text.dynamicLayoutVertexArray,m=e.icon.dynamicLayoutVertexArray,g={};f.clear();for(let _=0;_<p.length;_++){const m=p.get(_),y=m.hidden||!m.crossTileID||e.allowVerticalPlacement&&!m.placedOrientation?null:n[m.crossTileID];if(y){const n=new t.P(m.anchorX,m.anchorY),p={getElevation:d,width:s.width,height:s.height,pitchedLabelPlaneMatrix:o,pitchWithMap:r,transform:s,tileAnchorPoint:n,translation:h,unwrappedTileID:u},_=r?Ke(n.x,n.y,p):He(n.x,n.y,p),x=Ne(s.cameraToCenterDistance,_.signedDistanceFromCamera);let v=t.ax(e.textSizeData,l,m)*x/t.aJ;r&&(v*=e.tilePixelRatio/a);const{width:b,height:w,anchor:T,textOffset:S,textBoxScale:P}=y,I=hn(T,b,w,S,P,v),M=s.getPitchedTextCorrection(n.x+h[0],n.y+h[1],u),E=un(_.point,p,i,I,-s.bearingInRadians,M),C=e.allowVerticalPlacement&&m.placedOrientation===t.aw.vertical?Math.PI/2:0;for(let e=0;e<m.numGlyphs;e++)t.aD(f,E,C);c&&m.associatedIconIndex>=0&&(g[m.associatedIconIndex]={shiftedAnchor:E,angle:C})}else it(m.numGlyphs,f)}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;e<i.length;e++){const r=i.get(e);if(r.hidden)it(r.numGlyphs,m);else{const i=g[e];if(i)for(let e=0;e<r.numGlyphs;e++)t.aD(m,i.shiftedAnchor,i.angle);else it(r.numGlyphs,m)}}e.icon.dynamicLayoutVertexBuffer.updateData(m)}e.text.dynamicLayoutVertexBuffer.updateData(f)}function pn(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function fn(e,i,r,n,s,o,a,l,c,h,u,d,p){const f=e.context,m=f.gl,g=e.transform,_="map"===l,y="map"===c,x="viewport"!==l&&"point"!==r.layout.get("symbol-placement"),v=_&&!y&&!x,b=!r.layout.get("symbol-sort-key").isConstant();let w=!1;const T=e.getDepthModeForSublayer(0,Qt.ReadOnly),S=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),P=[],I=g.getCircleRadiusCorrection();for(const M of n){const n=i.getTile(M),l=n.getBucket(r);if(!l)continue;const c=s?l.text:l.icon;if(!c||!c.segments.get().length||!c.hasVisibleVertices)continue;const u=c.programConfigurations.get(r.id),d=s||l.sdfIcons,f=s?l.textSizeData:l.iconSizeData,T=y||0!==g.pitch,E=e.useProgram(pn(d,s,l),u),C=t.av(f,g.zoom),A=e.style.map.terrain&&e.style.map.terrain.getTerrainData(M);let D,z,k,R,L=[0,0],F=null;if(s)z=n.glyphAtlasTexture,k=m.LINEAR,D=n.glyphAtlasTexture.size,l.iconsInText&&(L=n.imageAtlasTexture.size,F=n.imageAtlasTexture,R=T||e.options.rotating||e.options.zooming||"composite"===f.kind||"camera"===f.kind?m.LINEAR:m.NEAREST);else{const t=1!==r.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;z=n.imageAtlasTexture,k=d||e.options.rotating||e.options.zooming||t||T?m.LINEAR:m.NEAREST,D=n.imageAtlasTexture.size}const B=t.aK(n,1,e.transform.zoom),O=Be(_,e.transform,B),V=t.N();t.ay(V,O);const j=Oe(y,_,e.transform,B),N=t.aL(g,n,o,a),U=g.getProjectionData({overscaledTileID:M,applyGlobeMatrix:!p,applyTerrainMatrix:!0}),G=S&&l.hasTextData(),$="none"!==r.layout.get("icon-text-fit")&&G&&l.hasIconData();if(x){const t=e.style.map.terrain?(t,i)=>e.style.map.terrain.getElevation(M,t,i):null,i="map"===r.layout.get("text-rotation-alignment");Ge(l,e,s,O,V,y,h,i,M.toUnwrapped(),g.width,g.height,N,t)}const Z=s&&S||$,q=x||Z?cn:y?O:e.transform.clipSpaceToPixelsMatrix,W=d&&0!==r.paint.get(s?"text-halo-width":"icon-halo-width").constantOr(1);let X;X=d?l.iconsInText?pr(f.kind,C,v,y,x,Z,e,q,j,N,D,L,I):dr(f.kind,C,v,y,x,Z,e,q,j,N,s,D,0,I):ur(f.kind,C,v,y,x,Z,e,q,j,N,s,D,I);const H={program:E,buffers:c,uniformValues:X,projectionData:U,atlasTexture:z,atlasTextureIcon:F,atlasInterpolation:k,atlasInterpolationIcon:R,isSDF:d,hasHalo:W};if(b&&l.canOverlap){w=!0;const e=c.segments.get();for(const i of e)P.push({segments:new t.aV([i]),sortKey:i.sortKey,state:H,terrainData:A})}else P.push({segments:c.segments,sortKey:0,state:H,terrainData:A})}w&&P.sort((e,t)=>e.sortKey-t.sortKey);for(const t of P){const i=t.state;if(f.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,mn(i.buffers,t.segments,r,e,i.program,T,u,d,n,i.projectionData,t.terrainData)),n.u_is_halo=0}mn(i.buffers,t.segments,r,e,i.program,T,u,d,i.uniformValues,i.projectionData,t.terrainData)}}function mn(e,t,i,r,n,s,o,a,l,c,h){const u=r.context;n.draw(u,u.gl.TRIANGLES,s,o,a,Jt.backCCW,l,h,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function gn(e,i,r,n,s){const o=e.context,a=o.gl,l=ti.disabled,c=new Yt([a.ONE,a.ONE],t.bn.transparent,[!0,!0,!0,!0]),h=i.getBucket(r);if(!h)return;const u=n.key;let d=r.heatmapFbos.get(u);d||(d=yn(o,i.tileSize,i.tileSize),r.heatmapFbos.set(u,d)),o.bindFramebuffer.set(d.framebuffer),o.viewport.set([0,0,i.tileSize,i.tileSize]),o.clear({color:t.bn.transparent});const p=h.programConfigurations.get(r.id),f=e.useProgram("heatmap",p,!s),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(n);f.draw(o,a.TRIANGLES,Qt.disabled,l,c,Jt.disabled,Yi(i,e.transform.zoom,r.paint.get("heatmap-intensity"),1),g,m,r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,r.paint,e.transform.zoom,p)}function _n(e,t,i,r,n){const s=e.context,o=s.gl,a=e.transform;s.setColorMode(e.colorModeForRenderPass());const l=xn(s,t),c=i.key,h=t.heatmapFbos.get(c);if(!h)return;s.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,h.colorAttachment.get()),s.activeTexture.set(o.TEXTURE1),l.bind(o.LINEAR,o.CLAMP_TO_EDGE);const u=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:n,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(s,o.TRIANGLES,Qt.disabled,ti.disabled,e.colorModeForRenderPass(),Jt.disabled,Ki(e,t,0,1),null,u,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,a.zoom),h.destroy(),t.heatmapFbos.delete(c)}function yn(e,t,i){var r,n;const s=e.gl,o=s.createTexture();s.bindTexture(s.TEXTURE_2D,o),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR);const a=null!==(r=e.HALF_FLOAT)&&void 0!==r?r:s.UNSIGNED_BYTE,l=null!==(n=e.RGBA16F)&&void 0!==n?n:s.RGBA;s.texImage2D(s.TEXTURE_2D,0,l,t,i,0,s.RGBA,a,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(o),c}function xn(e,i){return i.colorRampTexture||(i.colorRampTexture=new t.T(e,i.colorRamp,e.gl.RGBA)),i.colorRampTexture}function vn(e,i,r,n,s,o,a,l){let c=256;if(s.stepInterpolant){const n=i.getSource().maxzoom,s=a.canonical.z===n?Math.ceil(1<<e.transform.maxZoom-a.canonical.z):1;c=t.ak(t.cc(o.maxLineLength/t.a5*1024*s),256,r.maxTextureSize)}return l.gradient=t.cd({expression:s.gradientExpression(),evaluationKey:"lineProgress",resolution:c,image:l.gradient||void 0,clips:o.lineClipsArray}),l.texture?l.texture.update(l.gradient):l.texture=new t.T(r,l.gradient,n.RGBA),l.version=s.gradientVersion,l.texture}function bn(e,t,i,r,n){e.activeTexture.set(t.TEXTURE0),i.imageAtlasTexture.bind(t.LINEAR,t.CLAMP_TO_EDGE),r.updatePaintBuffers(n)}function wn(e,t,i,r,n,s){(n||e.lineAtlas.dirty)&&(t.activeTexture.set(i.TEXTURE0),e.lineAtlas.bind(t)),r.updatePaintBuffers(s)}function Tn(e,t,i,r,n,s,o){const a=s.gradients[n.id];let l=a.texture;n.gradientVersion!==a.version&&(l=vn(e,t,i,r,n,s,o,a)),i.activeTexture.set(r.TEXTURE0),l.bind(n.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function Sn(e,t,i,r,n,s,o,a,l){const c=s.gradients[n.id];let h=c.texture;n.gradientVersion!==c.version&&(h=vn(e,t,i,r,n,s,o,c)),i.activeTexture.set(r.TEXTURE0),h.bind(n.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),e.lineAtlas.bind(i),a.updatePaintBuffers(l)}function Pn(e,t,i,r,n){if(!i||!r||!r.imageAtlas)return;const s=r.imageAtlas.patternPositions;let o=s[i.to.toString()],a=s[i.from.toString()];if(!o&&a&&(o=a),!a&&o&&(a=o),!o||!a){const e=n.getPaintProperty(t);o=s[e],a=s[e]}o&&a&&e.setConstantPatternPositions(o,a)}function In(e,i,r,n,s,o,a,l){const c=e.context.gl,h="fill-pattern",u=r.paint.get(h),d=u&&u.constantOr(1),p=r.getCrossfadeParameters();let f,m,g,_,y;const x=e.transform,v=r.paint.get("fill-translate"),b=r.paint.get("fill-translate-anchor");a?(m=d&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",f=c.LINES):(m=d?"fillPattern":"fill",f=c.TRIANGLES);const w=u.constantOr(null);for(const T of n){const n=i.getTile(T);if(d&&!n.patternsLoaded())continue;const u=n.getBucket(r);if(!u)continue;const S=u.programConfigurations.get(r.id),P=e.useProgram(m,S),I=e.style.map.terrain&&e.style.map.terrain.getTerrainData(T);d&&(e.context.activeTexture.set(c.TEXTURE0),n.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),S.updatePaintBuffers(p)),Pn(S,h,w,n,r);const M=x.getProjectionData({overscaledTileID:T,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),E=t.aL(x,n,v,b);if(a){_=u.indexBuffer2,y=u.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];g="fillOutlinePattern"===m&&d?Zi(e,p,n,t,E):$i(t,E)}else _=u.indexBuffer,y=u.segments,g=d?Gi(e,p,n,E):{u_fill_translate:E};const C=e.stencilModeForClipping(T);P.draw(e.context,f,s,C,o,Jt.backCCW,g,I,M,r.id,u.layoutVertexBuffer,_,y,r.paint,e.transform.zoom,S)}}function Mn(e,i,r,n,s,o,a,l){const c=e.context,h=c.gl,u="fill-extrusion-pattern",d=r.paint.get(u),p=d.constantOr(1),f=r.getCrossfadeParameters(),m=r.paint.get("fill-extrusion-opacity"),g=d.constantOr(null),_=e.transform;for(const y of n){const n=i.getTile(y),d=n.getBucket(r);if(!d)continue;const x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(y),v=d.programConfigurations.get(r.id),b=e.useProgram(p?"fillExtrusionPattern":"fillExtrusion",v);p&&(e.context.activeTexture.set(h.TEXTURE0),n.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),v.updatePaintBuffers(f));const w=_.getProjectionData({overscaledTileID:y,applyGlobeMatrix:!l,applyTerrainMatrix:!0});Pn(v,u,g,n,r);const T=t.aL(_,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),S=r.paint.get("fill-extrusion-vertical-gradient"),P=p?Ui(e,S,m,T,y,f,n):Ni(e,S,m,T);b.draw(c,c.gl.TRIANGLES,s,o,a,Jt.backCCW,P,x,w,r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,r.paint,e.transform.zoom,v,e.style.map.terrain&&d.centroidVertexBuffer)}}function En(e,t,i,r,n,s,o,a,l){var c;const h=e.style.projection,u=e.context,d=e.transform,p=u.gl,f=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=e.useProgram("hillshade",null,!1,f),g=!e.options.moving;for(const _ of r){const r=t.getTile(_),f=r.fbo;if(!f)continue;const y=h.getMeshFromTileID(u,_.canonical,a,!0,"raster"),x=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(_);u.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,f.colorAttachment.get());const v=d.getProjectionData({overscaledTileID:_,aligned:g,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(u,p.TRIANGLES,s,n[_.overscaledZ],o,Jt.backCCW,Ji(e,r,i),x,v,i.id,y.vertexBuffer,y.indexBuffer,y.segments)}}function Cn(e,i,r,n,s,o,a,l,c){var h;const u=e.style.projection,d=e.context,p=e.transform,f=d.gl,m=e.useProgram("colorRelief"),g=!e.options.moving,_="nearest"===r.paint.get("resampling")?f.NEAREST:f.LINEAR;let y=!0,x=0;for(const v of n){const n=i.getTile(v),b=n.dem;if(y){const e=f.getParameter(f.MAX_TEXTURE_SIZE),{elevationTexture:t,colorTexture:i}=r.getColorRampTextures(d,e,b.getUnpackVector());d.activeTexture.set(f.TEXTURE1),t.bind(f.NEAREST,f.CLAMP_TO_EDGE),d.activeTexture.set(f.TEXTURE4),i.bind(f.LINEAR,f.CLAMP_TO_EDGE),y=!1,x=t.size[0]}if(!b||!b.data)continue;const w=b.stride,T=b.getPixels();if(d.activeTexture.set(f.TEXTURE0),d.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||e.getTileTexture(w),n.demTexture){const e=n.demTexture;e.update(T,{premultiply:!1}),e.bind(_,f.CLAMP_TO_EDGE)}else n.demTexture=new t.T(d,T,f.RGBA,{premultiply:!1}),n.demTexture.bind(_,f.CLAMP_TO_EDGE);const S=u.getMeshFromTileID(d,v.canonical,l,!0,"raster"),P=null===(h=e.style.map.terrain)||void 0===h?void 0:h.getTerrainData(v),I=p.getProjectionData({overscaledTileID:v,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0});m.draw(d,f.TRIANGLES,o,s[v.overscaledZ],a,Jt.backCCW,tr(r,n.dem,x),P,I,r.id,S.vertexBuffer,S.indexBuffer,S.segments)}}const An=[new t.P(0,0),new t.P(t.a5,0),new t.P(t.a5,t.a5),new t.P(0,t.a5)];function Dn(e,t,i,r,n,s,o,a,l=!1,c=!1){const h=r[r.length-1].overscaledZ,u=e.context,d=u.gl,p=e.useProgram("raster"),f=e.transform,m=e.style.projection,g=e.colorModeForRenderPass(),_=!e.options.moving,y=i.paint.get("raster-opacity"),x="nearest"===i.paint.get("resampling")||"nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR,v=i.paint.get("raster-fade-duration"),b=!!e.style.map.terrain;for(const w of r){const r=e.getDepthModeForSublayer(w.overscaledZ-h,1===y?Qt.ReadWrite:Qt.ReadOnly,d.LESS),T=t.getTile(w);u.activeTexture.set(d.TEXTURE0),T.texture.bind(x,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),u.activeTexture.set(d.TEXTURE1);const{parentTile:S,parentScaleBy:P,parentTopLeft:I,fadeValues:M}=zn(T,t,v,b);T.fadeOpacity=M.tileOpacity,S?(S.fadeOpacity=M.parentTileOpacity,S.texture.bind(x,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST)):T.texture.bind(x,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),T.texture.useMipmap&&u.extTextureFilterAnisotropic&&e.transform.pitch>e.options.anisotropicFilterPitch&&d.texParameterf(d.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const E=e.style.map.terrain&&e.style.map.terrain.getTerrainData(w),C=f.getProjectionData({overscaledTileID:w,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),A=cr(I,P,M.fadeMix,i,a),D=m.getMeshFromTileID(u,w.canonical,s,o,"raster");p.draw(u,d.TRIANGLES,r,n?n[w.overscaledZ]:ti.disabled,g,l?Jt.frontCCW:Jt.backCCW,A,E,C,i.id,D.vertexBuffer,D.indexBuffer,D.segments)}}function zn(e,i,r,n){const s={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===r||n)return s;if(e.fadingParentID){const n=i.getLoadedTile(e.fadingParentID);if(!n)return s;const o=Math.pow(2,n.tileID.overscaledZ-e.tileID.overscaledZ),a=[e.tileID.canonical.x*o%1,e.tileID.canonical.y*o%1],l=function(e,i,r){const n=c(),s=(n-i.timeAdded)/r,o=e.fadingDirection===ce.Incoming,a=t.ak((n-e.timeAdded)/r,0,1),l=t.ak(1-s,0,1),h=o?a:l;return{tileOpacity:h,parentTileOpacity:o?l:a,fadeMix:{opacity:1,mix:1-h}}}(e,n,r);return{parentTile:n,parentScaleBy:o,parentTopLeft:a,fadeValues:l}}if(e.selfFading){const i=function(e,i){const r=(c()-e.timeAdded)/i,n=t.ak(r,0,1);return{tileOpacity:n,fadeMix:{opacity:n,mix:0}}}(e,r);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:i}}return s}const kn=new t.bn(1,0,0,1),Rn=new t.bn(0,1,0,1),Ln=new t.bn(0,0,1,1),Fn=new t.bn(1,0,1,1),Bn=new t.bn(0,1,1,1);function On(e,t,i,r){jn(e,0,t+i/2,e.transform.width,i,r)}function Vn(e,t,i,r){jn(e,t-i/2,0,i,e.transform.height,r)}function jn(e,t,i,r,n,s){const o=e.context,a=o.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,n*e.pixelRatio),o.clear({color:s}),a.disable(a.SCISSOR_TEST)}function Nn(e,i,r){const n=e.context,s=n.gl,o=e.useProgram("debug"),a=Qt.disabled,l=ti.disabled,c=e.colorModeForRenderPass(),h="$debug",u=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);n.activeTexture.set(s.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,p=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(r).tileSize,m=512/Math.min(f,512)*(r.overscaledZ/e.transform.zoom)*.5;let g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);const _=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(n,s.TRIANGLES,a,l,Yt.alphaBlended,Jt.disabled,Hi(t.bn.transparent,m),null,_,h,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),o.draw(n,s.LINE_STRIP,a,l,c,Jt.disabled,Hi(t.bn.red),u,_,h,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Un(e,t,i,r){const{isRenderingGlobe:n}=r,s=e.context,o=s.gl,a=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),h=e.useProgram("terrain");s.bindFramebuffer.set(null),s.viewport.set([0,0,e.width,e.height]);for(const u of i){const i=t.getTerrainMesh(u.tileID),r=e.renderToTexture.getTexture(u),d=t.getTerrainData(u.tileID);s.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,r.texture);const p=t.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(u.tileID.toUnwrapped()),m=Fi(p,f,e.style.sky,a.pitch,n),g=a.getProjectionData({overscaledTileID:u.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(s,o.TRIANGLES,c,ti.disabled,l,Jt.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Gn(e,i){if(!i.mesh){const r=new t.aU;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const n=new t.aW;n.emplaceBack(0,1,2),n.emplaceBack(0,2,3),i.mesh=new kt(e.createVertexBuffer(r,Rt.members),e.createIndexBuffer(n),t.aV.simpleSegment(0,0,r.length,n.length))}return i.mesh}class $n{constructor(e,i){this.context=new on(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.ao(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ke.maxOverzooming+ke.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Ct}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const r of this.style._order)this.style._layers[r].resize()}setup(){const e=this.context,i=new t.aU;i.emplaceBack(0,0),i.emplaceBack(t.a5,0),i.emplaceBack(0,t.a5),i.emplaceBack(t.a5,t.a5),this.tileExtentBuffer=e.createVertexBuffer(i,Rt.members),this.tileExtentSegments=t.aV.simpleSegment(0,0,4,2);const r=new t.aU;r.emplaceBack(0,0),r.emplaceBack(t.a5,0),r.emplaceBack(0,t.a5),r.emplaceBack(t.a5,t.a5),this.debugBuffer=e.createVertexBuffer(r,Rt.members),this.debugSegments=t.aV.simpleSegment(0,0,4,5);const n=new t.cf;n.emplaceBack(0,0,0,0),n.emplaceBack(t.a5,0,t.a5,0),n.emplaceBack(0,t.a5,0,t.a5),n.emplaceBack(t.a5,t.a5,t.a5,t.a5),this.rasterBoundsBuffer=e.createVertexBuffer(n,Ri.members),this.rasterBoundsSegments=t.aV.simpleSegment(0,0,4,2);const s=new t.aU;s.emplaceBack(0,0),s.emplaceBack(t.a5,0),s.emplaceBack(0,t.a5),s.emplaceBack(t.a5,t.a5),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(s,Rt.members),this.rasterBoundsSegmentsPosOnly=t.aV.simpleSegment(0,0,4,5);const o=new t.aU;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,Rt.members),this.viewportSegments=t.aV.simpleSegment(0,0,4,2);const a=new t.cg;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(a);const l=new t.aW;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new ti({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new kt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.N();t.c5(r,0,this.width,this.height,0,0,1),t.Q(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const n={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,Qt.disabled,this.stencilClearMode,Yt.disabled,Jt.disabled,null,null,n,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const r=this.context;r.setColorMode(Yt.disabled),r.setDepthMode(Qt.disabled);const n={};for(const s of t)n[s.key]=this.nextStencilID++;this._renderTileMasks(n,t,i,!0),this._renderTileMasks(n,t,i,!1),this._tileClippingMaskIDs=n}_renderTileMasks(e,t,i,r){const n=this.context,s=n.gl,o=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],h=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),u=o.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=a.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(n,s.TRIANGLES,Qt.disabled,new ti({func:s.ALWAYS,mask:0},t,255,s.KEEP,s.KEEP,s.REPLACE),Yt.disabled,i?Jt.disabled:Jt.backCCW,null,h,d,"$clipping",u.vertexBuffer,u.indexBuffer,u.segments)}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,r=this.transform,n=this.useProgram("depth"),s=this.getDepthModeFor3D(),o=Se(r,{tileSize:r.tileSize});for(const a of o){const o=this.style.map.terrain&&this.style.map.terrain.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(e,t.TRIANGLES,s,ti.disabled,Yt.disabled,Jt.backCCW,null,o,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new ti({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new ti({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;i<n;i++)e[i+r]=new ti({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=n,[e,i]}return[{[r]:ti.disabled},i]}stencilConfigForOverlapTwoPass(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(this.clearStencil(),n>1){const e={},s={};for(let i=0;i<n;i++)e[i+r]=new ti({func:t.GREATER,mask:255},n+1+i,255,t.KEEP,t.KEEP,t.REPLACE),s[i+r]=new ti({func:t.GREATER,mask:255},1+i,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*n+1,[e,s,i]}return this.nextStencilID=3,[{[r]:new ti({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new ti({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},i]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new Yt([e.CONSTANT_COLOR,e.ONE],new t.bn(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?Yt.unblended:Yt.alphaBlended}getDepthModeForSublayer(e,t,i){if(!this.opaquePassEnabledForLayer())return Qt.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Qt(i||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new Qt(this.context.gl.LEQUAL,Qt.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,i){var r,n;this.style=e,this.options=i,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(c()),this.imageManager.beginFrame();const s=this.style._order,o=this.style.tileManagers,a={},l={},h={},u={isRenderingToTexture:!1,isRenderingGlobe:(null===(r=e.projection)||void 0===r?void 0:r.transitionState)>0};for(const t in o){const e=o[t];e.used&&e.prepare(this.context),a[t]=e.getVisibleCoordinates(!1),l[t]=a[t].slice().reverse(),h[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<s.length;t++)if(this.style._layers[s[t]].is3D()){this.opaquePassCutoff=t;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const t of s){const e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=l[e.source];("custom"===e.type||i.length)&&this.renderLayer(this,o[e.source],e,i,u)}if(null===(n=this.style.projection)||void 0===n||n.updateGPUdependent({context:this.context,useProgram:e=>this.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.bn.black:t.bn.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,r=i.gl,n=((e,t,i)=>{const r=Math.cos(t.rollInRadians),n=Math.sin(t.rollInRadians),s=me(t),o=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-s*n)*i,(t.height/2+s*r)*i],u_horizon_normal:[-n,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:o}})(t,e.style.map.transform,e.pixelRatio),s=new Qt(r.LEQUAL,Qt.ReadWrite,[0,1]),o=ti.disabled,a=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=Gn(i,t);l.draw(i,r.TRIANGLES,s,o,a,Jt.disabled,n,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=s.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[s[this.currentLayer]],t=o[e.source],i=a[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,u)}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer<s.length;this.currentLayer++){const e=this.style._layers[s[this.currentLayer]],t=o[e.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(e,u))continue;this.opaquePassEnabledForLayer()||d||(d=!0,u.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const i=("symbol"===e.type?h:l)[e.source];this._renderTileClippingMasks(e,a[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,i,u)}if(u.isRenderingGlobe&&function(e,i,r){const n=e.context,s=n.gl,o=e.useProgram("atmosphere"),a=new Qt(s.LEQUAL,Qt.ReadOnly,[0,1]),l=e.transform,c=function(e,i){const r=e.properties.get("position"),n=[-r.x,-r.y,-r.z],s=t.ao(new Float64Array(16));return"map"===e.properties.get("anchor")&&(t.be(s,s,i.rollInRadians),t.bf(s,s,-i.pitchInRadians),t.be(s,s,i.bearingInRadians),t.bf(s,s,i.center.lat*Math.PI/180),t.bH(s,s,-i.center.lng*Math.PI/180)),t.ce(n,n,s),n}(r,e.transform),h=l.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),u=i.properties.get("atmosphere-blend")*h.projectionTransition;if(0===u)return;const d=fi(l.worldSize,l.center.lat),p=l.inverseProjectionMatrix,f=new Float64Array(4);f[3]=1,t.aE(f,f,l.modelViewProjectionMatrix),f[0]/=f[3],f[1]/=f[3],f[2]/=f[3],f[3]=1,t.aE(f,f,p),f[0]/=f[3],f[1]/=f[3],f[2]/=f[3],f[3]=1;const m=((e,t,i,r,n)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:n}))(c,u,[f[0],f[1],f[2]],d,p),g=Gn(n,i);o.draw(n,s.TRIANGLES,a,ti.disabled,Yt.alphaBlended,Jt.disabled,m,null,null,"atmosphere",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const r=Object.values(e._layers).flatMap(i=>i.source&&!i.isHidden(t)?[e.tileManagers[i.source]]:[]),n=r.filter(e=>"vector"===e.getSource().type),s=r.filter(e=>"vector"!==e.getSource().type),o=e=>{(!i||i.getSource().maxzoom<e.getSource().maxzoom)&&(i=e)};return n.forEach(e=>o(e)),i||s.forEach(e=>o(e)),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let r=0;r<i.length;r++)Nn(e,t,i[r])}(this,e,e.getVisibleCoordinates())}this.options.showPadding&&function(e){const t=e.transform.padding;On(e,e.transform.height-(t.top||0),3,kn),On(e,t.bottom||0,3,Rn),Vn(e,t.left||0,3,Ln),Vn(e,e.transform.width-(t.right||0),3,Fn);const i=e.transform.centerPoint;!function(e,t,i,r){jn(e,t-1,i-10,2,20,r),jn(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,Bn)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;const i=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix;let n=this.terrainFacilitator.dirty;n||(n=e?!t.ch(i,r):!t.ci(i,r)),n||(n=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),n&&(t.cj(i,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(e,i){const r=e.context,n=r.gl,s=e.transform,o=Yt.unblended,a=new Qt(n.LEQUAL,Qt.ReadWrite,[0,1]),l=i.tileManager.getRenderableTiles(),c=e.useProgram("terrainDepth");r.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.bn.transparent,depth:1});for(const t of l){const e=i.getTerrainMesh(t.tileID),l=i.getTerrainData(t.tileID),h=s.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),u={u_ele_delta:i.getMeshFrameDelta(s.zoom)};c.draw(r,n.TRIANGLES,a,ti.disabled,o,Jt.backCCW,u,l,h,"terrain",e.vertexBuffer,e.indexBuffer,e.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}(this,this.style.map.terrain),function(e,i){const r=e.context,n=r.gl,s=e.transform,o=Yt.unblended,a=new Qt(n.LEQUAL,Qt.ReadWrite,[0,1]),l=i.getCoordsTexture(),c=i.tileManager.getRenderableTiles(),h=e.useProgram("terrainCoords");r.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.bn.transparent,depth:1}),i.coordsIndex=[];for(const t of c){const e=i.getTerrainMesh(t.tileID),c=i.getTerrainData(t.tileID);r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,l.texture);const u={u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(s.zoom)},d=s.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});h.draw(r,n.TRIANGLES,a,ti.disabled,o,Jt.backCCW,u,c,d,"terrain",e.vertexBuffer,e.indexBuffer,e.segments),i.coordsIndex.push(t.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}(this,this.style.map.terrain))}renderLayer(e,i,r,n,s){r.isHidden(this.transform.zoom)||("background"===r.type||"custom"===r.type||(n||[]).length)&&(this.id=r.id,t.aQ(r)?function(e,i,r,n,s,o){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:a}=o,l=ti.disabled,c=e.colorModeForRenderPass();(r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(e,i,r,n,s,o,a,l,c){const h=i.transform,u=i.style.map.terrain,d="map"===s,p="map"===o;for(const f of e){const e=n.getTile(f),s=e.getBucket(r);if(!s||!s.text||!s.text.segments.get().length)continue;const o=t.av(s.textSizeData,h.zoom),m=t.aK(e,1,i.transform.zoom),g=Be(d,i.transform,m),_="none"!==r.layout.get("icon-text-fit")&&s.hasIconData();if(o){const i=Math.pow(2,h.zoom-e.tileID.overscaledZ),r=u?(e,t)=>u.getElevation(f,e,t):null;dn(s,d,p,c,h,g,i,o,_,t.aL(h,e,a,l),f.toUnwrapped(),r)}}}(n,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),s),0!==r.paint.get("icon-opacity").constantOr(1)&&fn(e,i,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,a),0!==r.paint.get("text-opacity").constantOr(1)&&fn(e,i,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,a),i.map.showCollisionBoxes&&(ln(e,i,r,n,!0),ln(e,i,r,n,!1))}(e,i,r,n,this.style.placement.variableOffsets,s):t.ck(r)?function(e,i,r,n,s){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:o}=s,a=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),h=!r.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const u=e.context,d=u.gl,p=e.transform,f=e.getDepthModeForSublayer(0,Qt.ReadOnly),m=ti.disabled,g=e.colorModeForRenderPass(),_=[],y=p.getCircleRadiusCorrection();for(let x=0;x<n.length;x++){const s=n[x],a=i.getTile(s),l=a.getBucket(r);if(!l)continue;const c=r.paint.get("circle-translate"),u=r.paint.get("circle-translate-anchor"),d=t.aL(p,a,c,u),f=l.programConfigurations.get(r.id),m=e.useProgram("circle",f),g=l.layoutVertexBuffer,v=l.indexBuffer,b=e.style.map.terrain&&e.style.map.terrain.getTerrainData(s),w={programConfiguration:f,program:m,layoutVertexBuffer:g,indexBuffer:v,uniformValues:qi(e,a,r,d,y),terrainData:b,projectionData:p.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!o,applyTerrainMatrix:!0})};if(h){const e=l.segments.get();for(const i of e)_.push({segments:new t.aV([i]),sortKey:i.sortKey,state:w})}else _.push({segments:l.segments,sortKey:0,state:w})}h&&_.sort((e,t)=>e.sortKey-t.sortKey);for(const t of _){const{programConfiguration:i,program:n,layoutVertexBuffer:s,indexBuffer:o,uniformValues:a,terrainData:l,projectionData:c}=t.state;n.draw(u,d.TRIANGLES,f,m,g,Jt.backCCW,a,l,c,r.id,s,o,t.segments,r.paint,e.transform.zoom,i)}}(e,i,r,n,s):t.cl(r)?function(e,i,r,n,s){if(0===r.paint.get("heatmap-opacity"))return;const o=e.context,{isRenderingToTexture:a,isRenderingGlobe:l}=s;if(e.style.map.terrain){for(const t of n){const n=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?gn(e,n,r,t,l):"translucent"===e.renderPass&&_n(e,r,t,a,l))}o.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,i,r,n){const s=e.context,o=s.gl,a=e.transform,l=ti.disabled,c=new Yt([o.ONE,o.ONE],t.bn.transparent,[!0,!0,!0,!0]);(function(e,i,r){const n=e.gl;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let s=r.heatmapFbos.get(t.cb);s?(n.bindTexture(n.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer)):(s=yn(e,i.width/4,i.height/4),r.heatmapFbos.set(t.cb,s))})(s,e,r),s.clear({color:t.bn.transparent});for(let t=0;t<n.length;t++){const h=n[t];if(i.hasRenderableParent(h))continue;const u=i.getTile(h),d=u.getBucket(r);if(!d)continue;const p=d.programConfigurations.get(r.id),f=e.useProgram("heatmap",p),m=a.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),g=a.getCircleRadiusCorrection();f.draw(s,o.TRIANGLES,Qt.disabled,l,c,Jt.backCCW,Yi(u,a.zoom,r.paint.get("heatmap-intensity"),g),null,m,r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,r.paint,a.zoom,p)}s.viewport.set([0,0,e.width,e.height])}(e,i,r,n):"translucent"===e.renderPass&&function(e,i){const r=e.context,n=r.gl;r.setColorMode(e.colorModeForRenderPass());const s=i.heatmapFbos.get(t.cb);s&&(r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,s.colorAttachment.get()),r.activeTexture.set(n.TEXTURE1),xn(r,i).bind(n.LINEAR,n.CLAMP_TO_EDGE),e.useProgram("heatmapTexture").draw(r,n.TRIANGLES,Qt.disabled,ti.disabled,e.colorModeForRenderPass(),Jt.disabled,Ki(e,i,0,1),null,null,i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom))}(e,r)}(e,i,r,n,s):t.cm(r)?function(e,t,i,r,n){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=n,o=i.paint.get("line-opacity"),a=i.paint.get("line-width");if(0===o.constantOr(1)||0===a.constantOr(1))return;const l=e.getDepthModeForSublayer(0,Qt.ReadOnly),c=e.colorModeForRenderPass(),h=i.paint.get("line-dasharray"),u=h.constantOr(1),d=i.paint.get("line-pattern"),p=d.constantOr(1),f=i.paint.get("line-gradient"),m=i.getCrossfadeParameters();let g;g=p?"linePattern":u&&f?"lineGradientSDF":u?"lineSDF":f?"lineGradient":"line";const _=e.context,y=_.gl,x=e.transform;let v=!0;for(const b of r){const r=t.getTile(b);if(p&&!r.patternsLoaded())continue;const n=r.getBucket(i);if(!n)continue;const o=n.programConfigurations.get(i.id),a=e.context.program.get(),w=e.useProgram(g,o),T=v||w.program!==a,S=e.style.map.terrain&&e.style.map.terrain.getTerrainData(b),P=d.constantOr(null),I=h&&h.constantOr(null);if(P&&r.imageAtlas){const e=r.imageAtlas,t=e.patternPositions[P.to.toString()],i=e.patternPositions[P.from.toString()];t&&i&&o.setConstantPatternPositions(t,i)}else if(I){const t="round"===i.layout.get("line-cap"),r=e.lineAtlas.getDash(I.to,t),n=e.lineAtlas.getDash(I.from,t);o.setConstantDashPositions(r,n)}const M=x.getProjectionData({overscaledTileID:b,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),E=x.getPixelScale();let C;p?(C=nr(e,r,i,E,m),bn(_,y,r,o,m)):u&&f?(C=or(e,r,i,E,m,n.lineClipsArray.length),Sn(e,t,_,y,i,n,b,o,m)):u?(C=sr(e,r,i,E,m),wn(e,_,y,o,T,m)):f?(C=rr(e,r,i,E,n.lineClipsArray.length),Tn(e,t,_,y,i,n,b)):C=ir(e,r,i,E);const A=e.stencilModeForClipping(b);w.draw(_,y.TRIANGLES,l,A,c,Jt.disabled,C,S,M,i.id,n.layoutVertexBuffer,n.indexBuffer,n.segments,i.paint,e.transform.zoom,o,n.layoutVertexBuffer2),v=!1}}(e,i,r,n,s):t.cn(r)?function(e,i,r,n,s){const o=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0===a.constantOr(1))return;const{isRenderingToTexture:l}=s,c=e.colorModeForRenderPass(),h=r.paint.get("fill-pattern"),u=e.opaquePassEnabledForLayer()&&!h.constantOr(1)&&1===o.constantOr(t.bn.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(e.renderPass===u){const t=e.getDepthModeForSublayer(1,"opaque"===e.renderPass?Qt.ReadWrite:Qt.ReadOnly);In(e,i,r,n,t,c,!1,l)}if("translucent"===e.renderPass&&r.paint.get("fill-antialias")){const t=e.getDepthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,Qt.ReadOnly);In(e,i,r,n,t,c,!0,l)}}(e,i,r,n,s):t.co(r)?function(e,t,i,r,n){const s=i.paint.get("fill-extrusion-opacity");if(0===s)return;const{isRenderingToTexture:o}=n;if("translucent"===e.renderPass){const n=new Qt(e.context.gl.LEQUAL,Qt.ReadWrite,e.depthRangeFor3D);if(1!==s||i.paint.get("fill-extrusion-pattern").constantOr(1))Mn(e,t,i,r,n,ti.disabled,Yt.disabled,o),Mn(e,t,i,r,n,e.stencilModeFor3D(),e.colorModeForRenderPass(),o);else{const s=e.colorModeForRenderPass();Mn(e,t,i,r,n,ti.disabled,s,o)}}}(e,i,r,n,s):t.cp(r)?function(e,i,r,n,s){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const{isRenderingToTexture:o}=s,a=e.context,l=e.style.projection.useSubdivision,c=e.getDepthModeForSublayer(0,Qt.ReadOnly),h=e.colorModeForRenderPass();if("offscreen"===e.renderPass)!function(e,i,r,n,s,o,a){const l=e.context,c=l.gl,h="nearest"===n.paint.get("resampling")?c.NEAREST:c.LINEAR;for(const u of r){const r=i.getTile(u),d=r.dem;if(!d||!d.data)continue;if(!r.needsHillshadePrepare)continue;const p=d.dim,f=d.stride,m=d.getPixels();if(l.activeTexture.set(c.TEXTURE1),l.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||e.getTileTexture(f),r.demTexture){const e=r.demTexture;e.update(m,{premultiply:!1}),e.bind(c.NEAREST,c.CLAMP_TO_EDGE)}else r.demTexture=new t.T(l,m,c.RGBA,{premultiply:!1}),r.demTexture.bind(c.NEAREST,c.CLAMP_TO_EDGE);l.activeTexture.set(c.TEXTURE0);let g=r.fbo;if(!g){const e=new t.T(l,{width:p,height:p,data:null},c.RGBA);e.bind(h,c.CLAMP_TO_EDGE),g=r.fbo=l.createFramebuffer(p,p,!0,!1),g.colorAttachment.set(e.texture)}l.bindFramebuffer.set(g.framebuffer),l.viewport.set([0,0,p,p]),e.useProgram("hillshadePrepare").draw(l,c.TRIANGLES,s,o,a,Jt.disabled,Qi(r.tileID,d),null,null,n.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),r.needsHillshadePrepare=!1}}(e,i,n,r,c,ti.disabled,h),a.viewport.set([0,0,e.width,e.height]);else if("translucent"===e.renderPass)if(l){const[t,s,a]=e.stencilConfigForOverlapTwoPass(n);En(e,i,r,a,t,c,h,!1,o),En(e,i,r,a,s,c,h,!0,o)}else{const[t,s]=e.getStencilConfigForOverlapAndUpdateStencilID(n);En(e,i,r,s,t,c,h,!1,o)}}(e,i,r,n,s):t.cq(r)?function(e,t,i,r,n){if("translucent"!==e.renderPass)return;if(!r.length)return;const{isRenderingToTexture:s}=n,o=e.style.projection.useSubdivision,a=e.getDepthModeForSublayer(0,Qt.ReadOnly),l=e.colorModeForRenderPass();if(o){const[n,o,c]=e.stencilConfigForOverlapTwoPass(r);Cn(e,t,i,c,n,a,l,!1,s),Cn(e,t,i,c,o,a,l,!0,s)}else{const[n,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);Cn(e,t,i,o,n,a,l,!1,s)}}(e,i,r,n,s):t.bS(r)?function(e,t,i,r,n){if("translucent"!==e.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!r.length)return;const{isRenderingToTexture:s}=n,o=t.getSource(),a=e.style.projection.useSubdivision;if(o instanceof Q)Dn(e,t,i,r,null,!1,!1,o.tileCoords,o.flippedWindingOrder,s);else if(a){const[n,o,a]=e.stencilConfigForOverlapTwoPass(r);Dn(e,t,i,a,n,!1,!0,An,!1,s),Dn(e,t,i,a,o,!0,!0,An,!1,s)}else{const[n,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);Dn(e,t,i,o,n,!1,!0,An,!1,s)}}(e,i,r,n,s):t.cr(r)?function(e,t,i,r,n){const s=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;const{isRenderingToTexture:a}=n,l=e.context,c=l.gl,h=e.style.projection,u=e.transform,d=u.tileSize,p=i.paint.get("background-pattern");if(e.isPatternMissing(p))return;const f=!p&&1===s.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==f)return;const m=ti.disabled,g=e.getDepthModeForSublayer(0,"opaque"===f?Qt.ReadWrite:Qt.ReadOnly),_=e.colorModeForRenderPass(),y=e.useProgram(p?"backgroundPattern":"background"),x=r||Se(u,{tileSize:d,terrain:e.style.map.terrain});p&&(l.activeTexture.set(c.TEXTURE0),e.imageManager.bind(e.context));const v=i.getCrossfadeParameters();for(const b of x){const t=u.getProjectionData({overscaledTileID:b,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),r=p?mr(o,e,p,{tileID:b,tileSize:d},v):fr(o,s),n=e.style.map.terrain&&e.style.map.terrain.getTerrainData(b),f=h.getMeshFromTileID(l,b.canonical,!1,!0,"raster");y.draw(l,c.TRIANGLES,g,m,_,Jt.backCCW,r,n,t,i.id,f.vertexBuffer,f.indexBuffer,f.segments)}}(e,0,r,n,s):t.cs(r)&&function(e,t,i,r){const{isRenderingGlobe:n}=r,s=e.context,o=i.implementation,a=e.style.projection,l=e.transform,c=l.getProjectionDataForCustomLayer(n),h={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:a.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${a.shaderPreludeCode.vertexSource}`,define:a.shaderDefine},defaultProjectionData:c},u=o.renderingMode?o.renderingMode:"2d";if("offscreen"===e.renderPass){const t=o.prerender;t&&(e.setCustomLayerDefaults(),s.setColorMode(e.colorModeForRenderPass()),t.call(o,s.gl,h),s.setDirty(),e.setBaseState())}else if("translucent"===e.renderPass){e.setCustomLayerDefaults(),s.setColorMode(e.colorModeForRenderPass()),s.setStencilMode(ti.disabled);const t="3d"===u?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,Qt.ReadOnly);s.setDepthMode(t),o.render(s.gl,h),s.setDirty(),e.setBaseState(),s.bindFramebuffer.set(null)}}(e,0,r,s))}saveTileTexture(e){const t=this._tileTextures[e.size[0]];t?t.length<$n.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?t.push(e):e.destroy():this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,r=[]){this.cache=this.cache||{};const n=!!this.style.map.terrain,s=this.style.projection,o=i?Dt.projectionMercator:s.shaderPreludeCode,a=i?Lt:s.shaderDefine,l=e+(t?t.cacheKey:"")+`/${i?Ft:s.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(n?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[l]||(this.cache[l]=new Vi(this.context,Dt[e],t,_r[e],this._showOverdrawInspector,n,o,a,r)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.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 t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,t;if(this._tileTextures){for(const e in this._tileTextures){const t=this._tileTextures[e];if(t)for(const e of t)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(t=this.tileExtentMesh.indexBuffer)||void 0===t||t.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const t=this.cache[e];t&&t.program&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Zn(e,t){let i,r=!1,n=null,s=null;const o=()=>{n=null,r&&(e.apply(s,i),n=setTimeout(o,t),r=!1)};return(...e)=>(r=!0,s=this,i=e,n||o(),n)}$n.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50;class qn{constructor(e){this._getCurrentHash=()=>{const e=window.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("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let n=window.location.href.replace(/(#.+)?$/,r);n=n.replace("&&","&"),window.history.replaceState(window.history.state,null,n)},this._updateHash=Zn(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),s=Math.round(t.lng*n)/n,o=Math.round(t.lat*n)/n,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${s}/${o}/${i}`:`${i}/${o}/${s}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map(i=>{const r=i.split("=")[0];return r===e?(t=!0,`${r}=${c}`):i}).filter(e=>e);return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.V(+e[2],+e[1])}catch(e){return!1}const i=+e[0],r=+(e[3]||0),n=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&n>=this._map.getMinPitch()&&n<=this._map.getMaxPitch()}}const Wn={linearity:.3,easing:t.ct(0,0,.3,1)},Xn=t.e({deceleration:2500,maxSpeed:1400},Wn),Hn=t.e({deceleration:20,maxSpeed:1400},Wn),Yn=t.e({deceleration:1e3,maxSpeed:360},Wn),Kn=t.e({deceleration:1e3,maxSpeed:90},Wn),Jn=t.e({deceleration:1e3,maxSpeed:360},Wn);class Qn{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:c(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=c();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,i.roll+=t.rollDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const s=ts(i.pan.mag(),r,t.e({},Xn,e||{})),o=i.pan.mult(s.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(o,this._map.transform);n.center=a.easingCenter,n.offset=a.easingOffset,es(n,s)}if(i.zoom){const e=ts(i.zoom,r,Hn),s=t.cu(this._map.transform.zoom+e.amount,this._map.getZoomSnap(),e.amount);n.zoom=s,es(n,e)}if(i.bearing){const e=ts(i.bearing,r,Yn);n.bearing=this._map.transform.bearing+t.ak(e.amount,-179,179),es(n,e)}if(i.pitch){const e=ts(i.pitch,r,Kn);n.pitch=this._map.transform.pitch+e.amount,es(n,e)}if(i.roll){const e=ts(i.roll,r,Jn);n.roll=this._map.transform.roll+t.ak(e.amount,-179,179),es(n,e)}if(n.zoom||n.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(n,{noMoveStart:!0})}}function es(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function ts(e,i,r){const{maxSpeed:n,linearity:s,deceleration:o}=r,a=t.ak(e*s/(i/1e3),-n,n),l=Math.abs(a)/(o*s);return{easing:r.easing,duration:1e3*l,amount:a*(l/2)}}class is extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,r,n={}){r=r instanceof MouseEvent?r:new MouseEvent(e,r);const s=h.mousePos(i.getCanvas(),r),o=i.unproject(s);super(e,t.e({point:s,lngLat:o,originalEvent:r},n)),this._defaultPrevented=!1,this.target=i}}class rs extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,i,r){const n="touchend"===e?r.changedTouches:r.touches,s=h.touchPos(i.getCanvasContainer(),n),o=s.map(e=>i.unproject(e)),a=s.reduce((e,t,i,r)=>e.add(t.div(r.length)),new t.P(0,0));super(e,{points:s,point:a,lngLats:o,lngLat:i.unproject(a),originalEvent:r}),this._defaultPrevented=!1}}class ns extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class ss{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new ns(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new is(e.type,this._map,e))}mouseup(e){this._map.fire(new is(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new is(e.type,this._map,e))}dblclick(e){return this._firePreventable(new is(e.type,this._map,e))}mouseover(e){this._map.fire(new is(e.type,this._map,e))}mouseout(e){this._map.fire(new is(e.type,this._map,e))}touchstart(e){return this._firePreventable(new rs(e.type,this._map,e))}touchmove(e){this._map.fire(new rs(e.type,this._map,e))}touchend(e){this._map.fire(new rs(e.type,this._map,e))}touchcancel(e){this._map.fire(new rs(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class os{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new is(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new is("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new is(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class as{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class ls{constructor(e,t){this._map=e,this._tr=new as(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1,t.boxZoom&&"object"==typeof t.boxZoom&&(this._boxZoomEnd=t.boxZoom.boxZoomEnd)}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&&(h.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=h.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));const n=Math.min(r.x,i.x),s=Math.max(r.x,i.x),o=Math.min(r.y,i.y),a=Math.max(r.y,i.y);this._box.style.transform=`translate(${n}px,${o}px)`,this._box.style.width=s-n+"px",this._box.style.height=a-o+"px"}mouseupWindow(e,i){if(!this._active)return;if(0!==e.button)return;const r=this._startPos,n=i;if(this.reset(),h.suppressClick(),r.x!==n.x||r.y!==n.y)return this._map.fire(new t.l("boxzoomend",{originalEvent:e})),this._boxZoomEnd?void this._boxZoomEnd(this._map,r,n,e):{cameraAnimation:e=>e.fitScreenCoordinates(r,n,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(this._box.remove(),this._box=null),h.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function cs(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}class hs{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=cs(r,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=cs(i,t);for(const n in this.touches){const e=r[n];(!e||e.dist(this.touches[n])>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 us{constructor(e){this.singleTap=new hs(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,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 r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class ds{constructor(e){this._tr=new as(e),this._zoomIn=new us({numTouches:1,numTaps:2}),this._zoomOut=new us({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,i,r){const n=this._zoomIn.touchend(e,i,r),s=this._zoomOut.touchend(e,i,r),o=this._tr;return n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:t.cu(o.zoom+1,i.getZoomSnap()),around:o.unproject(n)},{originalEvent:e})}):s?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:t.cu(o.zoom-1,i.getZoomSnap()),around:o.unproject(s)},{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}}class ps{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const r=Array.isArray(t)?t[0]:t;return!this._moved&&r.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(i,r))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&h.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const fs=0,ms=2,gs={[fs]:1,[ms]:2};class _s{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){this._eventButton=e.button}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(e,t){const i=gs[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton)}isValidEndEvent(e){return e.button===this._eventButton}}class ys{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return 1===e.targetTouches.length}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class xs{constructor(e=new _s({checkCorrectEvent:()=>!0}),t=new ys){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.startMove(e),e=>this.oneFingerTouchMoveStateManager.startMove(e))}endMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.endMove(e),e=>this.oneFingerTouchMoveStateManager.endMove(e))}isValidStartEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}}const vs=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class bs{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const n=cs(r,i),s=new t.P(0,0),o=new t.P(0,0);let a=0;for(const t in n){const e=n[t],i=this._touches[t];i&&(s._add(e),o._add(e.sub(i)),a++,n[t]=e)}if(this._touches=n,this._shouldBePrevented(a)||!o.mag())return;const l=o.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:s.div(a),panDelta:l}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ws{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}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){if(!this._firstTwoTouches)return;e.preventDefault();const[r,n]=this._firstTwoTouches,s=Ts(i,t,r),o=Ts(i,t,n);if(!s||!o)return;const a=this._aroundCenter?null:s.add(o).div(2);return this._move([s,o],a,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,s=Ts(i,t,r),o=Ts(i,t,n);s&&o||(this._active&&h.suppressClick(),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 Ts(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}function Ss(e,t){return Math.log(e/t)/Math.LN2}class Ps extends ws{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Ss(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Ss(this._distance,i),pinchAround:t}}}function Is(e,t){return 180*e.angleWith(t)/Math.PI}class Ms extends ws{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,i){const r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Is(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=Is(e,this._startVector);return Math.abs(i)<t}}function Es(e){return Math.abs(e.y)>Math.abs(e.x)}class Cs extends ws{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,Es(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=e[0].sub(this._lastPoints[0]),n=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const s=e.y>0==t.y>0;return Es(e)&&Es(t)&&s}}const As={panStep:100,bearingStep:15,pitchStep:10};class Ds{constructor(e){this._tr=new as(e);const t=As;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let i=0,r=0,n=0,s=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:i=1;break;case 189:case 109:case 173:i=-1;break;case 37:e.shiftKey?r=-1:(e.preventDefault(),s=-1);break;case 39:e.shiftKey?r=1:(e.preventDefault(),s=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,n=0),{cameraAnimation:a=>{const l=this._tr;a.easeTo({duration:300,easeId:"keyboardHandler",easing:zs,zoom:i?t.cu(l.zoom+i*(e.shiftKey?2:1),a.getZoomSnap()):l.zoom,bearing:l.bearing+r*this._bearingStep,pitch:l.pitch+n*this._pitchStep,offset:[-s*this._panStep,-o*this._panStep],center:l.center},{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}}function zs(e){return e*(2-e)}const ks=4.000244140625,Rs=1/450;class Ls{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new as(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Rs}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)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=c(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%ks==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_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 i=h.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.V.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>ks?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const n="number"!=typeof this._targetZoom?e.scale:t.an(this._targetZoom),s=e.applyConstrain(e.getCameraLngLat(),t.aq(n*r)).zoom,o=this._map.getZoomSnap();if("wheel"===this._type&&o>0){const i=t.cu(e.zoom,o);this._targetZoom=t.cu(s,o,s-i)}else this._targetZoom=s;"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,r=this._startZoom,n=this._easing;let s,o=!1;if("wheel"===this._type&&r&&n){const e=c()-this._lastWheelEventTime,a=Math.min((e+5)/200,1),l=n(a);s=t.G.number(r,i,l),a<1?this._frameId||(this._frameId=!0):o=!0}else s=i,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=s,{noInertia:!0,needsRenderFrame:!o,zoomDelta:s-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cw;if(this._prevEase){const e=this._prevEase,r=(c()-e.start)/e.duration,n=e.easing(r+.01)-e.easing(r),s=.27/Math.sqrt(n*n+1e-4)*.01,o=Math.sqrt(.0729-s*s);i=t.ct(s,o,.25,1)}return this._prevEase={start:c(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Fs{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 Bs{constructor(e){this._tr=new as(e),this.reset()}reset(){this._active=!1}dblclick(e,i){return e.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:t.cu(this._tr.zoom+(e.shiftKey?-1:1),r.getZoomSnap()),around:this._tr.unproject(i)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Os{constructor(){this._tap=new us({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const r=t[0],n=e.timeStamp-this._tapTime<500,s=this._tapPoint.dist(r)<30;n&&s?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(e,t,i)}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Vs{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("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class js{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Ns{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Us{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=h.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);const n=document.createElement("div");n.className="maplibregl-mobile-message",n.textContent=i,this._container.appendChild(n),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const Gs=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class $s extends t.l{}function Zs(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class qs{get _ownerDocument(){var e;return(null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||document}get _ownerWindow(){var e,t;return(null===(t=null===(e=this._el)||void 0===e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||window}constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===e.type?void 0:e,n={needsRenderFrame:!1},s={},o={};for(const{handlerName:c,handler:u,allowed:d}of this._handlers){if(!u.isEnabled())continue;let a;if(this._blockedByActive(o,d,c))u.reset();else if(u[i||e.type]){if(t.cx(e,i||e.type)){const t=h.mousePos(this._map.getCanvas(),e);a=u[i||e.type](e,t)}else if(t.cy(e,i||e.type)){const t=this._getMapTouches(e.touches),r=h.touchPos(this._map.getCanvas(),t);a=u[i||e.type](e,r,t)}else t.cz(i||e.type)||(a=u[i||e.type](e));this.mergeHandlerResult(n,s,a,c,r),a&&a.needsRenderFrame&&this._triggerRenderFrame()}(a||u.isActive())&&(o[c]=u)}const a={};for(const t in this._previousActiveHandlers)o[t]||(a[t]=r);this._previousActiveHandlers=o,(Object.keys(a).length||Zs(n))&&(this._changes.push([n,s,a]),this._triggerRenderFrame()),(Object.keys(o).length||Zs(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:l}=n;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Qn(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[t,n,s]of this._listeners)t.addEventListener(n,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,s)}destroy(){for(const[e,t,i]of this._listeners)e.removeEventListener(t,e===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new ss(i,e));const n=i.boxZoom=new ls(i,e);this._add("boxZoom",n),e.interactive&&e.boxZoom&&n.enable();const s=i.cooperativeGestures=new Us(i,e.cooperativeGestures);this._add("cooperativeGestures",s),e.cooperativeGestures&&s.enable();const o=new ds(i),a=new Bs(i);i.doubleClickZoom=new Fs(a,o),this._add("tapZoom",o),this._add("clickZoom",a),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const l=new Os;this._add("tapDragZoom",l);const c=i.touchPitch=new Cs(i);this._add("touchPitch",c),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const h=()=>i.project(i.getCenter()),u=function({enable:e,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:n=100,rotateDegreesPerPixelMoved:s=.8},o){const a=new _s({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button&&!e.ctrlKey});return new ps({clickTolerance:i,move:(e,i)=>{const a=o();if(r&&Math.abs(a.y-e.y)>n)return{bearingDelta:t.cv(new t.P(e.x,i.y),i,a)};let l=(i.x-e.x)*s;return r&&i.y<a.y&&(l=-l),{bearingDelta:l}},moveStateManager:a,enable:e,assignEvents:vs})}(e,h),d=function({enable:e,clickTolerance:t,pitchDegreesPerPixelMoved:i=-.5}){const r=new _s({checkCorrectEvent:e=>0===e.button&&e.ctrlKey||2===e.button});return new ps({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:r,enable:e,assignEvents:vs})}(e),p=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){const n=new _s({checkCorrectEvent:e=>2===e.button&&e.ctrlKey});return new ps({clickTolerance:t,move:(e,t)=>{const n=r();let s=(t.x-e.x)*i;return t.y<n.y&&(s=-s),{rollDelta:s}},moveStateManager:n,enable:e,assignEvents:vs})}(e,h);i.dragRotate=new js(e,u,d,p),this._add("mouseRotate",u,["mousePitch"]),this._add("mousePitch",d,["mouseRotate","mouseRoll"]),this._add("mouseRoll",p,["mousePitch"]),e.interactive&&e.dragRotate&&i.dragRotate.enable();const f=function({enable:e,clickTolerance:t}){const i=new _s({checkCorrectEvent:e=>0===e.button&&!e.ctrlKey});return new ps({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:vs})}(e),m=new bs(e,i);i.dragPan=new Vs(r,f,m),this._add("mousePan",f),this._add("touchPan",m,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const g=new Ms,_=new Ps;i.touchZoomRotate=new Ns(r,_,g,l),this._add("touchRotate",g,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new os(i));const y=i.scrollZoom=new Ls(i,()=>this._triggerRenderFrame());this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const x=i.keyboard=new Ds(i);this._add("keyboard",x),e.interactive&&e.keyboard&&i.keyboard.enable()}_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=[]}}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 Boolean(Gs(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return!0;return!1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,r,n,s){if(!r)return;t.e(e,r);const o={handlerName:n,originalEvent:r.originalEvent||s};void 0!==r.zoomDelta&&(i.zoom=o),void 0!==r.panDelta&&(i.drag=o),void 0!==r.rollDelta&&(i.roll=o),void 0!==r.pitchDelta&&(i.pitch=o),void 0!==r.bearingDelta&&(i.rotate=o)}_applyChanges(){const e={},i={},r={};for(const[n,s,o]of this._changes)n.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(n.panDelta)),n.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+n.pitchDelta),n.rollDelta&&(e.rollDelta=(e.rollDelta||0)+n.rollDelta),void 0!==n.around&&(e.around=n.around),void 0!==n.pinchAround&&(e.pinchAround=n.pinchAround),n.noInertia&&(e.noInertia=n.noInertia),t.e(i,s),t.e(r,o);this._updateMapTransform(e,i,r),this._changes=[]}_updateMapTransform(e,t,i){const r=this._map,n=r._getTransformForUpdate(),s=r.terrain;if(!(Zs(e)||s&&this._terrainMovement))return this._fireEvents(t,i,!0);r._stop(!0);let{panDelta:o,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:h,around:u,pinchAround:d}=e;void 0!==d&&(u=d),u=u||r.transform.centerPoint,s&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);const p={panDelta:o,zoomDelta:a,rollDelta:h,pitchDelta:c,bearingDelta:l,around:u};this._map.cameraHelper.useGlobeControls&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);const f=u.distSqr(n.centerPoint)<.01?n.center:n.screenPointToLocation(o?u.sub(o):u);this._handleMapControls({terrain:s,tr:n,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:o}),r._applyUpdatedTransform(n),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:n,panDelta:s}){const o=this._map.cameraHelper;if(o.handleMapControlsRollPitchBearingZoom(i,t),e)return o.useGlobeControls?(this._terrainMovement||!n.drag&&!n.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void o.handleMapControlsPan(i,t,r)):this._terrainMovement||!n.drag&&!n.zoom?void(n.drag&&this._terrainMovement&&s?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(s))):o.handleMapControlsPan(i,t,r)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void o.handleMapControlsPan(i,t,r));o.handleMapControlsPan(i,t,r)}_fireEvents(e,i,r){const n=Gs(this._eventsInProgress),s=Gs(e),o={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(o[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!n&&s&&this._fireEvent("movestart",s.originalEvent);for(const t in o)this._fireEvent(t,o[t]);s&&this._fireEvent("move",s.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const l={};let c;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],c=i[e]||r,l[`${t}end`]=c)}for(const t in l)this._fireEvent(t,l[t]);const h=Gs(this._eventsInProgress),u=(n||s)&&!h;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(r&&u){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&a.prefersReducedMotion?(this._map.fire(new t.l("moveend",{originalEvent:c})),i(this._map.getBearing())&&this._map.resetNorth()):(i(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:c})),this._updatingCamera=!1}}_fireEvent(e,i){this._map.fire(new t.l(e,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new $s("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Ws extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((c()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this._zoomSnap=i.zoomSnap,this.cameraHelper=t,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){e.apply(this.transform,!0),this.transform=e,this.cameraHelper=t}getCenter(){return new t.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,i,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.e({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,r){return this.easeTo(t.e({zoom:e},i),r)}zoomIn(e,i){return this.zoomTo(t.cu(this.getZoom()+1,this._zoomSnap),e,i),this}zoomOut(e,i){return this.zoomTo(t.cu(this.getZoom()-1,this._zoomSnap),e,i),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),this}getBearing(){return this.transform.bearing}setZoomSnap(e){return this._zoomSnap=e,this}getZoomSnap(){return this._zoomSnap}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,i,r){return this.easeTo(t.e({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=N.convert(e).adjustAntiMeridian();const i=t&&t.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),i,t)}_cameraForBoxAndBearing(e,i,r,n){const s={top:0,bottom:0,right:0,left:0};if("number"==typeof(n=t.e({padding:s,offset:[0,0],maxZoom:this.transform.maxZoom},n)).padding){const e=n.padding;n.padding={top:e,bottom:e,right:e,left:e}}const o=t.e(s,n.padding);n.padding=o;const a=this.transform,l=new N(e,i);return this.cameraHelper.cameraForBoxAndBearing(n,o,l,r,a)}fitBounds(e,t,i){return this._fitInternal(this.cameraForBounds(e,t),t,i)}fitScreenCoordinates(e,i,r,n,s){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(t.P.convert(e)),this.transform.screenPointToLocation(t.P.convert(i)),r,n),n,s)}_fitInternal(e,i,r){return e?(delete(i=t.e(e,i)).padding,i.linear?this.easeTo(i,r):this.flyTo(i,r)):this}jumpTo(e,i){this.stop();const r=this._getTransformForUpdate();let n=!1,s=!1,o=!1;const a=r.zoom;this.terrain&&r.setElevation(this.terrain.getElevationForLngLatZoom(e.center?t.V.convert(e.center):r.center,e.zoom||r.tileZoom)),this.cameraHelper.handleJumpToCenterZoom(r,e);const l=r.zoom!==a;return"elevation"in e&&r.elevation!==+e.elevation&&r.setElevation(+e.elevation),"bearing"in e&&r.bearing!==+e.bearing&&(n=!0,r.setBearing(+e.bearing)),"pitch"in e&&r.pitch!==+e.pitch&&(s=!0,r.setPitch(+e.pitch)),"roll"in e&&r.roll!==+e.roll&&(o=!0,r.setRoll(+e.roll)),null==e.padding||r.isPaddingEqual(e.padding)||r.setPadding(e.padding),this._applyUpdatedTransform(r),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)),l&&this.fire(new t.l("zoomstart",i)).fire(new t.l("zoom",i)).fire(new t.l("zoomend",i)),n&&this.fire(new t.l("rotatestart",i)).fire(new t.l("rotate",i)).fire(new t.l("rotateend",i)),s&&this.fire(new t.l("pitchstart",i)).fire(new t.l("pitch",i)).fire(new t.l("pitchend",i)),o&&this.fire(new t.l("rollstart",i)).fire(new t.l("roll",i)).fire(new t.l("rollend",i)),this.fire(new t.l("moveend",i))}calculateCameraOptionsFromTo(e,i,r,n=0){const s=t.a6.fromLngLat(e,i),o=t.a6.fromLngLat(r,n),a=o.x-s.x,l=o.y-s.y,c=o.z-s.z,h=Math.hypot(a,l,c);if(0===h)throw new Error("Can't calculate camera options with same From and To");const u=Math.hypot(a,l),d=t.aq(this.transform.cameraToCenterDistance/h/this.transform.tileSize),p=180*Math.atan2(a,-l)/Math.PI;let f=180*Math.acos(u/h)/Math.PI;return f=c<0?90-f:90+f,{center:o.toLngLat(),elevation:n,zoom:d,pitch:f,bearing:p}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,i,r,n){const s=this.transform.calculateCenterFromCameraLngLatAlt(e,t,i,r);return{center:s.center,elevation:s.elevation,zoom:s.zoom,bearing:i,pitch:r,roll:n}}easeTo(e,i){this._stop(!1,e.easeId),(!1===(e=t.e({offset:[0,0],duration:500,easing:t.cw},e)).animate||!e.essential&&a.prefersReducedMotion)&&(e.duration=0);const r=this._getTransformForUpdate(),n=this.getBearing(),s=r.pitch,o=r.roll,l="bearing"in e?this._normalizeBearing(e.bearing,n):n,c="pitch"in e?+e.pitch:s,h="roll"in e?this._normalizeBearing(e.roll,o):o,u="padding"in e?e.padding:r.padding,d=t.P.convert(e.offset);let p,f;e.around&&(p=t.V.convert(e.around),f=r.locationToScreenPoint(p));const m={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},g=this.cameraHelper.handleEaseTo(r,{bearing:l,pitch:c,roll:h,padding:u,around:p,aroundPoint:f,offsetAsPoint:d,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating=this._rotating||n!==l,this._pitching=this._pitching||c!==s,this._rolling=this._rolling||h!==o,this._padding=!r.isPaddingEqual(u),this._zooming=this._zooming||g.isZooming,this._easeId=e.easeId,this._prepareEase(i,e.noMoveStart,m),this.terrain&&this._prepareElevation(g.elevationCenter),this._ease(t=>{g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(i)},t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t)},e),this}_prepareEase(e,i,r={}){this._moving=!0,i||r.moving||this.fire(new t.l("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new t.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i}this.transform.setElevation(t.G.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(i<r){const i=this.calculateCameraOptionsFromTo(t,r,e.center,e.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}_applyUpdatedTransform(e){const t=[];if(t.push(e=>this._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&t.push(e=>this.transformCameraUpdate(e)),!t.length)return;const i=e.clone();for(const r of t){const e=i.clone(),{center:t,zoom:n,roll:s,pitch:o,bearing:a,elevation:l}=r(e);t&&e.setCenter(t),void 0!==l&&e.setElevation(l),void 0!==n&&e.setZoom(n),void 0!==s&&e.setRoll(s),void 0!==o&&e.setPitch(o),void 0!==a&&e.setBearing(a),i.apply(e,!1)}this.transform.apply(i,!1)}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,n=this._rotating,s=this._pitching,o=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.l("zoomend",e)),n&&this.fire(new t.l("rotateend",e)),s&&this.fire(new t.l("pitchend",e)),o&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e))}flyTo(e,i){if(!e.essential&&a.prefersReducedMotion){const r=t.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(r,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cw},e);const r=this._getTransformForUpdate(),n=r.bearing,s=r.pitch,o=r.roll,l=r.padding,c="bearing"in e?this._normalizeBearing(e.bearing,n):n,h="pitch"in e?+e.pitch:s,u="roll"in e?this._normalizeBearing(e.roll,o):o,d="padding"in e?e.padding:r.padding,p=t.P.convert(e.offset);let f=r.centerPoint.add(p);const m=r.screenPointToLocation(f),g=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:h,roll:u,padding:d,locationAtOffset:m,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let _=e.curve;const y=Math.max(r.width,r.height),x=y/g.scaleOfZoom,v=g.pixelPathLength;"number"==typeof g.scaleOfMinZoom&&(_=Math.sqrt(y/g.scaleOfMinZoom/v*2));const b=_*_;function w(e){const t=(x*x-y*y+(e?-1:1)*b*b*v*v)/(2*(e?x:y)*b*v);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return(Math.exp(e)-Math.exp(-e))/2}function S(e){return(Math.exp(e)+Math.exp(-e))/2}const P=w(!1);let I=function(e){return S(P)/S(P+_*e)},M=function(e){return y*((S(P)*(T(t=P+_*e)/S(t))-T(P))/b)/v;var t},E=(w(!0)-P)/_;if(Math.abs(v)<2e-6||!isFinite(E)){if(Math.abs(y-x)<1e-6)return this.easeTo(e,i);const t=x<y?-1:1;E=Math.abs(Math.log(x/y))/_,M=()=>0,I=e=>Math.exp(t*_*e)}return e.duration="duration"in e?+e.duration:1e3*E/("screenSpeed"in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=n!==c,this._pitching=h!==s,this._rolling=u!==o,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease(a=>{const m=a*E,_=1/I(m),y=M(m);this._rotating&&r.setBearing(t.G.number(n,c,a)),this._pitching&&r.setPitch(t.G.number(s,h,a)),this._rolling&&r.setRoll(t.G.number(o,u,a)),this._padding&&(r.interpolatePadding(l,d,a),f=r.centerPoint.add(p)),g.easeFunc(a,_,y,f),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(r),this._fireMoveEvents(i)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=c(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,i){e=t.W(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)<r&&(e-=360),Math.abs(e+360-i)<r&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLat(t.V.convert(e),this.transform):null}}const Xs={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Hs{constructor(e=Xs){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=h.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=h.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=h.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"!=typeof e?"":e)):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style.tileManagers;for(const r in t){const i=t[r];if(i.used||i.usedForTerrain){const t=i.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let r=i+1;r<e.length;r++)if(e[r].indexOf(t)>=0)return!1;return!0});const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=h.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Ys{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=h.create("div","maplibregl-ctrl");const t=h.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Ks{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 r of i)if(r.id===e)return void(r.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");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=[]}}var Js=t.aS([{name:"a_pos3d",type:"Int16",components:3}]);class Qs extends t.E{constructor(e){super(),this._lastTilesetChange=c(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,i){this.tileManager.update(e,i),this._renderableTilesKeys=[];const r={};for(const n of Se(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.tileManager._source.calculateTileZoom}))r[n.key]=!0,this._renderableTilesKeys.push(n.key),this._tiles[n.key]||(n.terrainRttPosMatrix32f=new Float64Array(16),t.c5(n.terrainRttPosMatrix32f,0,t.a5,t.a5,0,0,1),this._tiles[n.key]=new he(n,this.tileSize),this._lastTilesetChange=c());for(const t in this._tiles)r[t]||delete this._tiles[t]}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const r of this._renderableTilesKeys){const n=this._tiles[r].tileID,s=e.clone(),o=t.bi();if(n.canonical.equals(e.canonical))t.c5(o,0,t.a5,t.a5,0,0,1);else if(n.canonical.isChildOf(e.canonical)){const i=n.canonical.z-e.canonical.z,r=n.canonical.x-(n.canonical.x>>i<<i),s=n.canonical.y-(n.canonical.y>>i<<i),a=t.a5>>i;t.c5(o,0,a,a,0,0,1),t.O(o,o,[-r*a,-s*a,0])}else{if(!e.canonical.isChildOf(n.canonical))continue;{const i=e.canonical.z-n.canonical.z,r=e.canonical.x-(e.canonical.x>>i<<i),s=e.canonical.y-(e.canonical.y>>i<<i),a=t.a5>>i;t.c5(o,0,t.a5,t.a5,0,0,1),t.O(o,o,[r*a,s*a,0]),t.Q(o,o,[1/2**i,1/2**i,0])}}s.terrainRttPosMatrix32f=new Float32Array(o),i[r]=s}return i}_getTerrainCoordsForTileRanges(e,i){const r={};for(const n of this._renderableTilesKeys){const s=this._tiles[n].tileID;if(!this._isWithinTileRanges(s,i))continue;const o=e.clone(),a=t.bi();if(s.canonical.z===e.canonical.z){const i=e.canonical.x-s.canonical.x+e.wrap*(1<<e.canonical.z),r=e.canonical.y-s.canonical.y;t.c5(a,0,t.a5,t.a5,0,0,1),t.O(a,a,[i*t.a5,r*t.a5,0])}else if(s.canonical.z>e.canonical.z){const i=s.canonical.z-e.canonical.z,r=s.canonical.x-(s.canonical.x>>i<<i)+e.wrap*(1<<s.canonical.z),n=s.canonical.y-(s.canonical.y>>i<<i),o=e.canonical.x-(s.canonical.x>>i),l=e.canonical.y-(s.canonical.y>>i),c=t.a5>>i;t.c5(a,0,c,c,0,0,1),t.O(a,a,[-r*c+o*t.a5,-n*c+l*t.a5,0])}else{const i=e.canonical.z-s.canonical.z,r=e.canonical.x-(e.canonical.x>>i<<i)+e.wrap*(1<<e.canonical.z),n=e.canonical.y-(e.canonical.y>>i<<i),o=(e.canonical.x>>i)-s.canonical.x,l=(e.canonical.y>>i)-s.canonical.y,c=t.a5<<i;t.c5(a,0,c,c,0,0,1),t.O(a,a,[r*t.a5+o*c,n*t.a5+l*c,0])}o.terrainRttPosMatrix32f=new Float32Array(a),r[n]=o}return r}getSourceTile(e,t){const i=this.tileManager._source;let r=e.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(r).key);let n=this.findTileInCaches(this._sourceTileCache[e.key]);if(!(null==n?void 0:n.dem)&&t)for(;r>=i.minzoom&&!(null==n?void 0:n.dem);)n=this.findTileInCaches(e.scaledTo(r--).key);return n}findTileInCaches(e){let t=this.tileManager.getTileByID(e);return t||(t=this.tileManager._outOfViewCache.getByKey(e),t)}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){const i=t[e.canonical.z];return!!i&&(e.wrap>i.minWrap||e.wrap<i.maxWrap||e.canonical.x>=i.minTileXWrapped&&e.canonical.x<=i.maxTileXWrapped&&e.canonical.y>=i.minTileY&&e.canonical.y<=i.maxTileY)}}class eo{constructor(e,t,i){this._meshCache={},this.painter=e,this.tileManager=new Qs(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&(this._fbo.destroy(),this._fbo=null),this._fboCoordsTexture&&(this._fboCoordsTexture.destroy(),this._fboCoordsTexture=null),this._fboDepthTexture&&(this._fboDepthTexture.destroy(),this._fboDepthTexture=null),this._emptyDemTexture&&(this._emptyDemTexture.destroy(),this._emptyDemTexture=null),this._emptyDepthTexture&&(this._emptyDepthTexture.destroy(),this._emptyDepthTexture=null),this._coordsTexture&&(this._coordsTexture.destroy(),this._coordsTexture=null);for(const e in this._meshCache)this._meshCache[e].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(e,i,r,n=t.a5){var s;const o=e.normalizeCoordinates(i,r,n);if(!o)return 0;const a=this.getTerrainData(o.tileID),l=null===(s=a.tile)||void 0===s?void 0:s.dem;if(!l)return 0;const c=t.cA([],[o.x/n*t.a5,o.y/n*t.a5],a.u_terrain_matrix),h=[c[0]*l.dim,c[1]*l.dim],u=Math.floor(h[0]),d=Math.floor(h[1]),p=h[0]-u,f=h[1]-d;return l.get(u,d)*(1-p)*(1-f)+l.get(u+1,d)*p*(1-f)+l.get(u,d+1)*(1-p)*f+l.get(u+1,d+1)*p*f}getElevationForLngLatZoom(e,i){if(!t.cB(i,e.wrap()))return 0;const{tileID:r,mercatorX:n,mercatorY:s}=this._getOverscaledTileIDFromLngLatZoom(e,i);return this.getElevation(r,n%t.a5,s%t.a5,t.a5)}getElevationForLngLat(e,t){const i=Se(t,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let r=0;for(const n of i)n.canonical.z>r&&(r=Math.min(n.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(e,r)}getElevation(e,i,r,n=t.a5){return this.getDEMElevation(e,i,r,n)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const e=this.painter.context,i=new t.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new t.T(e,i,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new t.T(e,new t.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=t.ao([])}const i=this.tileManager.getSourceTile(e,!0);if(i&&i.dem&&(!i.demTexture||i.needsTerrainPrepare)){const e=this.painter.context;i.demTexture=this.painter.getTileTexture(i.dem.stride),i.demTexture?i.demTexture.update(i.dem.getPixels(),{premultiply:!1}):i.demTexture=new t.T(e,i.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),i.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),i.needsTerrainPrepare=!1}const r=i&&i.toString()+i.tileID.key+e.key;if(r&&!this._demMatrixCache[r]){const r=this.tileManager.getSource().maxzoom;let n=e.canonical.z-i.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=r?n=e.canonical.z-r:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const s=e.canonical.x-(e.canonical.x>>n<<n),o=e.canonical.y-(e.canonical.y>>n<<n),a=t.cC(new Float64Array(16),[1/(t.a5<<n),1/(t.a5<<n),0]);t.O(a,a,[s*t.a5,o*t.a5,0]),this._demMatrixCache[e.key]={matrix:a,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:i&&i.dem&&i.dem.dim||1,u_terrain_matrix:r?this._demMatrixCache[e.key].matrix:this._emptyDemMatrix,u_terrain_unpack:i&&i.dem&&i.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(i&&i.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:i}}getFramebuffer(e){const i=this.painter,r=i.width/devicePixelRatio,n=i.height/devicePixelRatio;return!this._fbo||this._fbo.width===r&&this._fbo.height===n||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new t.T(i.context,{width:r,height:n,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new t.T(i.context,{width:r,height:n,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=i.context.createFramebuffer(r,n,!0,!1),this._fbo.depthAttachment.set(i.context.createRenderbuffer(i.context.gl.DEPTH_COMPONENT16,r,n))),this._fbo.colorAttachment.set("coords"===e?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,s=0;t<this._coordsTextureSize;t++)for(let e=0;e<this._coordsTextureSize;e++,s+=4)i[s+0]=255&e,i[s+1]=255&t,i[s+2]=e>>8<<4|t>>8,i[s+3]=0;const r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),n=new t.T(e,r,e.gl.RGBA,{premultiply:!1});return n.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=n,n}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,n=r.gl,s=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),n.readPixels(s,a-o-1,1,1,n.RGBA,n.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.tileManager.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,p=(1<<u.tileID.canonical.z)*d;return new t.a6((u.tileID.canonical.x*d+l)/p+u.tileID.wrap,(u.tileID.canonical.y*d+c)/p,this.getElevation(u.tileID,l,c,d))}depthAtPoint(e){const t=new Uint8Array(4),i=this.painter.context,r=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),r.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,t),i.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){var i;const r=(null===(i=this.painter.style.projection)||void 0===i?void 0:i.transitionState)>0,n=r&&0===e.canonical.y,s=r&&e.canonical.y===(1<<e.canonical.z)-1,o=`m_${n?"n":""}_${s?"s":""}`;if(this._meshCache[o])return this._meshCache[o];const a=this.painter.context,l=new t.cD,c=new t.aW,h=this.meshSize,u=t.a5/h,d=h*h;for(let t=0;t<=h;t++)for(let e=0;e<=h;e++)l.emplaceBack(e*u,t*u,0);for(let t=0;t<d;t+=h+1)for(let e=0;e<h;e++)c.emplaceBack(e+t,h+e+t+1,h+e+t+2),c.emplaceBack(e+t,h+e+t+2,e+t+1);const p=l.length,f=p+(h+1),m=(h+1)*h,g=n?t.bp:0,_=n?0:1,y=s?t.bq:t.a5,x=s?0:1;for(let t=0;t<=h;t++)l.emplaceBack(t*u,g,_);for(let t=0;t<=h;t++)l.emplaceBack(t*u,y,x);for(let t=0;t<h;t++)c.emplaceBack(m+t,f+t,f+t+1),c.emplaceBack(m+t,f+t+1,m+t+1),c.emplaceBack(0+t,p+t+1,p+t),c.emplaceBack(0+t,0+t+1,p+t+1);const v=l.length,b=v+2*(h+1);for(const T of[0,1])for(let e=0;e<=h;e++)for(const i of[0,1])l.emplaceBack(T*t.a5,e*u,i);for(let t=0;t<2*h;t+=2)c.emplaceBack(v+t,v+t+1,v+t+3),c.emplaceBack(v+t,v+t+3,v+t+2),c.emplaceBack(b+t,b+t+3,b+t+1),c.emplaceBack(b+t,b+t+2,b+t+3);const w=new kt(a.createVertexBuffer(l,Js.members),a.createIndexBuffer(c),t.aV.simpleSegment(0,0,l.length,c.length));return this._meshCache[o]=w,w}getMeshFrameDelta(e){return 2*Math.PI*t.bC/Math.pow(2,Math.max(e,0))/5}getMinTileElevationForLngLatZoom(e,i){var r;if(!t.cB(i,e.wrap()))return 0;const{tileID:n}=this._getOverscaledTileIDFromLngLatZoom(e,i);return null!==(r=this.getMinMaxElevation(n).minElevation)&&void 0!==r?r:0}getMinMaxElevation(e){const t=this.getTerrainData(e).tile,i={minElevation:null,maxElevation:null};return t&&t.dem&&(i.minElevation=t.dem.min*this.exaggeration,i.maxElevation=t.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(e,i){const r=t.a6.fromLngLat(e.wrap()),n=(1<<i)*t.a5,s=r.x*n,o=r.y*n,a=Math.floor(s/t.a5),l=Math.floor(o/t.a5);return{tileID:new t.a2(i,0,i,a,l),mercatorX:s,mercatorY:o}}}class to{constructor(e,t,i){this._context=e,this._size=t,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){const i=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),r=new t.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return r.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),i.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),i.colorAttachment.set(r.texture),{id:e,fbo:i,texture:r,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(t=>e.id!==t),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some(e=>!e.inUse)}}const io={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class ro{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new to(e.context,30,t.tileManager.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){var i,r;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t)),this._coordsAscending={};for(const n in e.tileManagers){this._coordsAscending[n]={};const t=e.tileManagers[n].getVisibleCoordinates(),i=e.tileManagers[n].getSource(),r=i instanceof Q?i.terrainTileRanges:null;for(const e of t){const t=this.terrain.tileManager.getTerrainCoords(e,r);for(const e in t)this._coordsAscending[n][e]||(this._coordsAscending[n][e]=[]),this._coordsAscending[n][e].push(t[e])}}this._rttFingerprints={};for(const n of e._order){const t=e._layers[n],s=t.source;if(io[t.type]&&!this._rttFingerprints[s]){this._rttFingerprints[s]={};const t=null!==(r=null===(i=e.tileManagers[s])||void 0===i?void 0:i.getState().revision)&&void 0!==r?r:0;for(const e in this._coordsAscending[s])this._rttFingerprints[s][e]=`${this._coordsAscending[s][e].map(e=>e.key).sort().join()}#${t}`}}for(const n of this._renderableTiles)for(const e in this._rttFingerprints){const t=this._rttFingerprints[e][n.tileID.key];t&&t!==n.rttFingerprint[e]&&(n.rtt=[])}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return!1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),n=e.type,s=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(io[n]&&(this._prevType&&io[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if(io[this._prevType]||io[n]&&o){this._prevType=n;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const n of this._renderableTiles){if(this.pool.isFull()&&(Un(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(n),n.rtt[e]){const t=this.pool.getObjectForId(n.rtt[e].id);if(t.stamp===n.rtt[e].stamp){this.pool.useObject(t);continue}}const o=this.pool.getOrCreateFreeObject();this.pool.useObject(o),this.pool.stampObject(o),n.rtt[e]={id:o.id,stamp:o.stamp},s.context.bindFramebuffer.set(o.fbo.framebuffer),s.context.clear({color:t.bn.transparent,stencil:0}),s.currentStencilSource=void 0;for(let e=0;e<i.length;e++){const t=s.style._layers[i[e]],a=t.source?this._coordsAscending[t.source][n.tileID.key]:[n.tileID];s.context.viewport.set([0,0,o.fbo.width,o.fbo.height]),s._renderTileClippingMasks(t,a,!0),s.renderLayer(s,s.style.tileManagers[t.source],t,a,r),t.source&&(n.rttFingerprint[t.source]=this._rttFingerprints[t.source][n.tileID.key])}}return Un(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects(),io[n]}return!1}}const no={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Drag to rotate map, click to reset north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use \u2318 + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},so=i,oo={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Xs,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:t.c.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0,anisotropicFilterPitch:20};let ao=class extends Ws{get _ownerWindow(){var e,t;return(null===(t=null===(e=this._container)||void 0===e?void 0:e.ownerDocument)||void 0===t?void 0:t.defaultView)||window}constructor(e){var i,r;t.cE.mark(t.cF.create);const n=Object.assign(Object.assign(Object.assign({},oo),e),{canvasContextAttributes:Object.assign(Object.assign({},oo.canvasContextAttributes),e.canvasContextAttributes)});if(null!=n.minZoom&&null!=n.maxZoom&&n.minZoom>n.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=n.minPitch&&null!=n.maxPitch&&n.minPitch>n.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=n.minPitch&&n.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=n.maxPitch&&n.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const s=new Zt,o=new Ht;void 0!==n.minZoom&&s.setMinZoom(n.minZoom),void 0!==n.maxZoom&&s.setMaxZoom(n.maxZoom),void 0!==n.minPitch&&s.setMinPitch(n.minPitch),void 0!==n.maxPitch&&s.setMaxPitch(n.maxPitch),void 0!==n.renderWorldCopies&&s.setRenderWorldCopies(n.renderWorldCopies),null!==n.transformConstrain&&s.setConstrainOverride(n.transformConstrain),super(s,o,{bearingSnap:n.bearingSnap,zoomSnap:n.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ks,this._controls=[],this._mapId=t.ac(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{if(e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(const e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(const[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new t.l("webglcontextlost",{originalEvent:e}))}else this.fire(new t.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},n.canvasContextAttributes),this._trackResize=!0===n.trackResize,this._bearingSnap=n.bearingSnap,this._zoomSnap=n.zoomSnap,this._centerClampedToGround=n.centerClampedToGround,this._refreshExpiredTiles=!0===n.refreshExpiredTiles,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=!0===n.crossSourceCollisions,this._collectResourceTiming=!0===n.collectResourceTiming,this._locale=Object.assign(Object.assign({},no),n.locale),this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this._zoomLevelsToOverscale=n.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=n.transformCameraUpdate,this.transformConstrain=n.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===n.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(n.anisotropicFilterPitch),void 0!==n.reduceMotion&&(a.prefersReducedMotion=n.reduceMotion),this._imageQueueHandle=u.addThrottleControl(()=>this.isMoving()),this._requestManager=new d(n.transformRequest),this._container=this._resolveContainer(n.container),n.maxBounds&&this.setMaxBounds(n.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),"undefined"!=typeof window&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new qs(this,n),this._hash=n.hash&&new qn("string"==typeof n.hash&&n.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,roll:n.roll}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,t.e({},n.fitBoundsOptions,{duration:0}))));const l="string"==typeof n.style||!("globe"===(null===(r=null===(i=n.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,l),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style&&this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}),n.attributionControl&&this.addControl(new Hs("boolean"==typeof n.attributionControl?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new Ys,n.logoPosition),this.on("style.load",()=>{if(l||this._resizeTransform(),this.transform.unmodified){const e=t.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e))}),this.on("dataloading",e=>{this.fire(new t.l(`${e.dataType}dataloading`,e))}),this.on("dataabort",e=>{this.fire(new t.l("sourcedataabort",e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return Se(this.transform,e)}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this.transform)),super.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,i=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(i);const r=!this._moving;return r&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),r&&this.fire(new t.l("moveend",e)),this}_resizeInternal(e=!0){const[t,i]=this._containerDimensions(),r=this._getClampedPixelRatio(t,i);if(this._resizeCanvas(t,i,r),this.painter.resize(t,i,r),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const r=this._getClampedPixelRatio(t,i);this._resizeCanvas(t,i,r),this.painter.resize(t,i,r)}this._resizeTransform(e)}_resizeTransform(e=!0){var t;const[i,r]=this._containerDimensions();this.transform.resize(i,r,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,r,e)}_getClampedPixelRatio(e,t){const{0:i,1:r}=this._maxCanvasSize,n=this.getPixelRatio(),s=e*n,o=t*n;return Math.min(s>i?i/s:1,o>r?r/o:1)*n}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(N.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom){const i=this.transform.zoom,r=this._getTransformForUpdate();return r.setMinZoom(e),this._applyUpdatedTransform(r),this._update(),i!==this.transform.zoom&&this.fire(new t.l("zoomstart")).fire(new t.l("zoom")).fire(new t.l("zoomend")).fire(new t.l("movestart")).fire(new t.l("move")).fire(new t.l("moveend")),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom){const i=this.transform.zoom,r=this._getTransformForUpdate();return r.setMaxZoom(e),this._applyUpdatedTransform(r),this._update(),i!==this.transform.zoom&&this.fire(new t.l("zoomstart")).fire(new t.l("zoom")).fire(new t.l("zoomend")).fire(new t.l("movestart")).fire(new t.l("move")).fire(new t.l("moveend")),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch){const i=this.transform.pitch,r=this._getTransformForUpdate();return r.setMinPitch(e),this._applyUpdatedTransform(r),this._update(),i!==this.transform.pitch&&this.fire(new t.l("pitchstart")).fire(new t.l("pitch")).fire(new t.l("pitchend")).fire(new t.l("movestart")).fire(new t.l("move")).fire(new t.l("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?60:e)>180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch){const i=this.transform.pitch,r=this._getTransformForUpdate();return r.setMaxPitch(e),this._applyUpdatedTransform(r),this._update(),i!==this.transform.pitch&&this.fire(new t.l("pitchstart")).fire(new t.l("pitch")).fire(new t.l("pitchend")).fire(new t.l("movestart")).fire(new t.l("move")).fire(new t.l("moveend")),this}throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(e){if((e=null==e?20:e)>180)throw new Error("anisotropicFilterPitch must be less than or equal to 180");if(e<0)throw new Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=e,this._update()}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const n=n=>{const s=t.filter(e=>this.getLayer(e)),o=0!==s.length?this.queryRenderedFeatures(n.point,{layers:s}):[];o.length?r||(r=!0,i.call(this,new is(e,this,n.originalEvent,{features:o}))):r=!1};return{layers:t,listener:i,delegates:{mousemove:n,mouseout:()=>{r=!1}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=n=>{const s=t.filter(e=>this.getLayer(e));(0!==s.length?this.queryRenderedFeatures(n.point,{layers:s}):[]).length?r=!0:r&&(r=!1,i.call(this,new is(e,this,n.originalEvent)))},s=t=>{r&&(r=!1,i.call(this,new is(e,this,t.originalEvent)))};return{layers:t,listener:i,delegates:{mousemove:n,mouseout:s}}}{const r=e=>{const r=t.filter(e=>this.getLayer(e)),n=0!==r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];n.length&&(e.features=n,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const r=this._delegatedListeners[e];for(let n=0;n<r.length;n++){const e=r[n];if(e.listener===i&&e.layers.length===t.length&&e.layers.every(e=>t.includes(e))){for(const t in e.delegates)this.off(t,e.delegates[t]);return void r.splice(n,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const r="string"==typeof t?[t]:t,n=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,n);for(const s in n.delegates)this.on(s,n.delegates[s]);return{unsubscribe:()=>{this._removeDelegatedListener(e,r,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);const r="string"==typeof t?[t]:t,n=this._createDelegatedListener(e,r,i);for(const s in n.delegates){const t=n.delegates[s];n.delegates[s]=(...n)=>{this._removeDelegatedListener(e,r,i),t(...n)}}this._saveDelegatedListener(e,n);for(const s in n.delegates)this.once(s,n.delegates[s]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return[];let r;const n=e instanceof t.P||Array.isArray(e),s=n?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(n?{}:e)||{},s instanceof t.P||"number"==typeof s[0])r=[t.P.convert(s)];else{const e=t.P.convert(s[0]),i=t.P.convert(s[1]);r=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e]}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return!1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,r;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(e,t));const n=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new ki(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,n):this.style.loadJSON(e,t,n),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new ki(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){return t._(this,void 0,void 0,function*(){if("string"==typeof e){const r=e,n=yield this._requestManager.transformRequest(r,"Style");try{const e=yield t.j(n,new AbortController);this._updateDiff(e.data,i)}catch(e){e&&this.fire(new t.k(e))}}else"object"==typeof e&&this._updateDiff(e,i)})}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0)}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}.  Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.tileManagers[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.tileManagers[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const r in this.style._layers){const i=this.style._layers[r];"hillshade"===i.type&&i.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===i.type&&i.source===e.source&&t.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new eo(this.painter,i,e),this.painter.renderToTexture=new ro(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.tileManager.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(t.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;for(const t of Object.values(e))if(!t.areTilesLoaded())return!1;return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const r=this.getSource(i);if(!r)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=be(Math.max(1,e),Math.max(1,t))}else for(const r in this.style.tileManagers)this.style.tileManagers[r].getSource().calculateTileZoom=be(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const r=this.style.tileManagers[e];if(!r)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===i?r.reload(!0):r.refreshTiles(i.map(e=>new t.a9(e.z,e.x,e.y)))}addImage(e,i,r={}){const{pixelRatio:n=1,sdf:s=!1,stretchX:o,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(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`")));{const{width:r,height:a,data:d}=i,p=i;return this.style.addImage(e,{data:new t.R({width:r,height:a},new Uint8Array(d)),pixelRatio:n,stretchX:o,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:s,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{const{width:r,height:d,data:p}=a.getImageData(i);this.style.addImage(e,{data:new t.R({width:r,height:d},p),pixelRatio:n,stretchX:o,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:s,version:0})}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.k(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||t.b(i)?a.getImageData(i):i,{width:s,height:o,data:l}=n;if(void 0===s||void 0===o)return this.fire(new t.k(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.data.width||o!==r.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return r.data.replace(l,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return t._(this,void 0,void 0,function*(){return u.getImage(yield this._requestManager.transformRequest(e,"Image"),new AbortController)})}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupResizeObserver(){var e;let t=!1;const i=Zn(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50),r=null!==(e=this._ownerWindow.ResizeObserver)&&void 0!==e?e:ResizeObserver;this._resizeObserver=new r(e=>{t?i(e):t=!0}),this._resizeObserver.observe(this._container)}_resolveContainer(e){if("string"==typeof e){const t=document.getElementById(e);if(!t)throw new Error(`Container '${e}' not found.`);return t}if(e instanceof HTMLElement)return e;if(e&&"object"==typeof e&&1===e.nodeType)return e;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=h.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=h.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const n=this._controlContainer=h.create("div","maplibregl-control-container",e),s=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{s[e]=h.create("div",`maplibregl-ctrl-${e} `,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type)},{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new $n(i,this.transform)}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(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)}_render(e){var i,r,n,s,o;const a=this._idleTriggered?this._fadeDuration:0,l=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let h=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=c();this.style.zoomHistory.update(e,i);const r=new t.H(e,{now:i,fadeDuration:a,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(h=!0,this._crossFadingFactor=n),this.style.update(r)}const u=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==l;null===(n=this.style.projection)||void 0===n||n.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(s=this.style.projection)||void 0===s?void 0:s.transitionState,null===(o=this.style.projection)||void 0===o?void 0:o.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||u)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,a,this._crossSourceCollisions,u),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cE.mark(t.cF.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||h)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cE.mark(t.cF.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),u.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cE.remove(),this._removed=!0,this.fire(new t.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frame(this._frameRequest,e=>{t.cE.recordStartOfFrameAt(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!t.Z(e)&&!function(e){return e.message===nn}(e))throw e}},()=>{},this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=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,e?this.style._generateCollisionBoxes():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 version(){return so}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}};const lo={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class co{constructor(e,i,r=!1){this.mousedown=e=>{this.startMove(e,h.mousePos(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,h.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=h.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const n=new xs;this._rotatePitchHandler=new ps({clickTolerance:3,move:(e,n)=>{const s=i.getBoundingClientRect(),o=new t.P((s.bottom-s.top)/2,(s.right-s.left)/2);return{bearingDelta:t.cv(new t.P(e.x,n.y),n,o),pitchDelta:r?-.5*(n.y-e.y):void 0}},moveStateManager:n,enable:!0,assignEvents:()=>{}}),this.map=e,i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),h.disableDrag()}move(e,t){const i=this.map,{bearingDelta:r,pitchDelta:n}=this._rotatePitchHandler.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),n&&i.setPitch(i.getPitch()+n)}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}}let ho;function uo(e,i,r,n=!1){if(n||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const s=new t.V(e.lng,e.lat);if(e=new t.V(e.lng,e.lat),i){const n=new t.V(e.lng-360,e.lat),s=new t.V(e.lng+360,e.lat),o=r.locationToScreenPoint(e).distSqr(i);r.locationToScreenPoint(n).distSqr(i)<o?e=n:r.locationToScreenPoint(s).distSqr(i)<o&&(e=s)}for(;Math.abs(e.lng-r.center.lng)>180;){const t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e.lng!==s.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:s}const po={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%)"};function fo(e,t,i){const r=e.classList;for(const n in po)r.remove(`maplibregl-${i}-anchor-${n}`);r.add(`maplibregl-${i}-anchor-${t}`)}class mo extends t.E{constructor(e){if(super(),this._onClick=e=>{this.fire(new t.l("click",{originalEvent:e}))},this._onKeyPress=e=>{"Space"!==e.code&&"Enter"!==e.code||this.togglePopup()},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=uo(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),this._element.style.transform=`${po[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`,a.frameAsync(new AbortController,this._map._ownerWindow).then(()=>{this._updateOpacity(e&&"moveend"===e.type)}).catch(()=>{})},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div");const i=h.createNS("http://www.w3.org/2000/svg","svg"),r=41,n=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${n}px`),i.setAttributeNS(null,"viewBox",`0 0 ${n} ${r}`);const s=h.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"stroke","none"),s.setAttributeNS(null,"stroke-width","1"),s.setAttributeNS(null,"fill","none"),s.setAttributeNS(null,"fill-rule","evenodd");const o=h.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"fill-rule","nonzero");const a=h.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of l){const t=h.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),a.appendChild(t)}const c=h.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const u=h.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(u);const d=h.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=h.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(p);const f=h.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=h.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=h.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=h.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(_),o.appendChild(a),o.appendChild(c),o.appendChild(d),o.appendChild(f),o.appendChild(m),i.appendChild(o),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",n*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()}),fo(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),this._element.removeEventListener("click",this._onClick),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.V.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,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,r=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,r;const n=null===(i=this._map)||void 0===i?void 0:i.terrain,s=this._map.transform.isLocationOccluded(this._lngLat);if(!n||s){const e=s?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const o=this._map,a=o.terrain.depthAtPoint(this._pos),l=o.terrain.getElevationForLngLat(this._lngLat,o.transform);if(o.transform.lngLatToCameraDepth(this._lngLat,l)-a<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/o.transform.pixelsPerMeter,h=Math.sin(o.getPitch()*Math.PI/180)*c,u=o.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=o.transform.lngLatToCameraDepth(this._lngLat,l+h)-u>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const go={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let _o=0,yo=!1;const xo={maxWidth:100,unit:"metric"};function vo(e,t,i){const r=i&&i.maxWidth||100,n=e._container.clientHeight/2,s=e._container.clientWidth/2,o=e.unproject([s-r/2,n]),a=e.unproject([s+r/2,n]),l=Math.round(e.project(a).x-e.project(o).x),c=Math.min(r,l,e._container.clientWidth),h=o.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*h;i>5280?bo(t,c,i/5280,e._getUIString("ScaleControl.Miles")):bo(t,c,i,e._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?bo(t,c,h/1852,e._getUIString("ScaleControl.NauticalMiles")):h>=1e3?bo(t,c,h/1e3,e._getUIString("ScaleControl.Kilometers")):bo(t,c,h,e._getUIString("ScaleControl.Meters"))}function bo(e,t,i,r){const n=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}(i);e.style.width=t*(n/i)+"px",e.innerHTML=`${n}&nbsp;${r}`}const wo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},To=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function So(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return So(new t.P(0,0))}const Po=i;e.AJAXError=t.cG,e.EXTENT=t.a5,e.Event=t.l,e.Evented=t.E,e.LngLat=t.V,e.MercatorCoordinate=t.a6,e.Point=t.P,e.addProtocol=t.cH,e.config=t.c,e.removeProtocol=t.cI,e.AttributionControl=Hs,e.BoxZoomHandler=ls,e.CanvasSource=te,e.CooperativeGesturesHandler=Us,e.DoubleClickZoomHandler=Fs,e.DragPanHandler=Vs,e.DragRotateHandler=js,e.EdgeInsets=Ot,e.FullscreenControl=class extends t.E{constructor(e={}){var i;super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=null!==(i=e.pseudo)&&void 0!==i&&i,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=h.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);h.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=J,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const i=new t.V(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,n=this._map.getBearing(),s=t.e({bearing:n},this.options.fitBoundsOptions),o=N.fromLngLat(i,r);this._map.fitBounds(o,s,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const i=new t.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&yo)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=e=>{if(!this._map)return;const i=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")))},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=h.create("button","maplibregl-ctrl-geolocate",this._container),h.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=h.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new mo({element:this._dotElement}),this._circleElement=h.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new mo({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",this._onMoveStart)}},this.options=t.e({},go,e)}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,function*(e=!1){if(void 0!==ho&&!e)return ho;if(void 0===window.navigator.permissions)return ho=!!window.navigator.geolocation,ho;try{const e=yield window.navigator.permissions.query({name:"geolocation"});ho="denied"!==e.state}catch(e){ho=!!window.navigator.geolocation}return ho})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.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("movestart",this._onMoveStart),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,_o=0,yo=!1}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),r=e.distanceTo(i)/100,n=2*this._accuracy/r;this._circleElement.style.width=`${n.toFixed(2)}px`,this._circleElement.style.height=`${n.toFixed(2)}px`}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":_o--,yo=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),_o++,_o>1?(e={maximumAge:6e5,timeout:0},yo=!0):(e=this.options.positionOptions,yo=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=h.create("button","maplibregl-ctrl-globe",this._container),h.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},e.Hash=qn,e.ImageSource=Q,e.KeyboardHandler=Ds,e.LngLatBounds=N,e.LogoControl=Ys,e.Map=ao,e.MapLibreMap=ao,e.MapMouseEvent=is,e.MapTouchEvent=rs,e.MapWheelEvent=ns,e.Marker=mo,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i)},this.options=t.e({},lo,e),this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),h.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),h.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=h.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new co(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){const i=h.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=h.create("div","maplibregl-popup",this._map.getContainer()),this._tip=h.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}let t;if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=uo(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),e&&"point"in e&&e.point&&(t=e.point),this._trackPointer&&!t)return;const i=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationToScreenPoint(this._lngLat));let r=this.options.anchor;const n=So(this.options.offset);if(!r){const e=this._container.offsetWidth,t=this._container.offsetHeight,s=function(e){var t,i,r,n;return e?{top:null!==(t=e.top)&&void 0!==t?t:0,right:null!==(i=e.right)&&void 0!==i?i:0,bottom:null!==(r=e.bottom)&&void 0!==r?r:0,left:null!==(n=e.left)&&void 0!==n?n:0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);let o;o=i.y+n.bottom.y<t+s.top?["top"]:i.y>this._map.transform.height-t-s.bottom?["bottom"]:[],i.x<e/2+s.left?o.push("left"):i.x>this._map.transform.width-e/2-s.right&&o.push("right"),r=0===o.length?"bottom":o.join("-")}let s=i.add(n[r]);this.options.subpixelPositioning||(s=s.round()),this._container.style.transform=`${po[r]} translate(${s.x}px,${s.y}px)`,fo(this._container,r,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create(wo),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.V.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._update),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._update),this._map.on("drag",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-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 r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=h.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}setPadding(e){this.options.padding=e,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=h.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(To);e&&e.focus()}},e.RasterDEMTileSource=Z,e.RasterTileSource=$,e.ScaleControl=class{constructor(e){this._onMove=()=>{vo(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,vo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},xo),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}},e.ScrollZoomHandler=Ls,e.Style=ki,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=h.create("button","maplibregl-ctrl-terrain",this._container),h.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=Cs,e.TwoFingersTouchRotateHandler=Ms,e.TwoFingersTouchZoomHandler=Ps,e.TwoFingersTouchZoomRotateHandler=Ns,e.VectorTileSource=G,e.VideoSource=ee,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,function*(){if(re(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{ie[e]=t})(e,i)}),e.clearPrewarmedResources=function(){const e=D;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(E),D=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()"))},e.createTileMesh=oi,e.getMaxParallelImageRequests=function(){return t.c.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return ae().getRTLTextPluginStatus()},e.getVersion=function(){return Po},e.getWorkerCount=function(){return C.workerCount},e.getWorkerUrl=function(){return t.c.WORKER_URL},e.importScriptInWorkers=function(e){return L().broadcast("IS",e)},e.isTimeFrozen=function(){return l.isFrozen()},e.now=c,e.prewarm=function(){k().acquire(E)},e.restoreNow=function(){l.restoreNow()},e.setMaxParallelImageRequests=function(e){t.c.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setNow=function(e){l.setNow(e)},e.setRTLTextPlugin=function(e,t){return ae().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){C.workerCount=e},e.setWorkerUrl=function(e){t.c.WORKER_URL=e}}),e}()},43937(e,t,i){"use strict";i.d(t,{Ay:()=>r.T5,Wd:()=>r.Wd,kL:()=>r.kL,ov:()=>r.ov,pH:()=>r.pH,z0:()=>r.z0});var r=i(4795)}}]);