var HDmap=function(){"use strict";var pp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pu(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function Qg(a){if(a.__esModule)return a;var i=a.default;if(typeof i=="function"){var s=function l(){return this instanceof l?Reflect.construct(i,arguments,this.constructor):i.apply(this,arguments)};s.prototype=i.prototype}else s={};return Object.defineProperty(s,"__esModule",{value:!0}),Object.keys(a).forEach(function(l){var h=Object.getOwnPropertyDescriptor(a,l);Object.defineProperty(s,l,h.get?h:{enumerable:!0,get:function(){return a[l]}})}),s}var e_={exports:{}};(function(a,i){(function(s,l){a.exports=l()})(pp,function(){var s,l,h;function f(t,E){if(!s)s=E;else if(!l)l=E;else{var k="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+s+")(sharedChunk); ("+l+")(sharedChunk); self.onerror = null;",P={};s(P),h=E(P),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(h.workerUrl=window.URL.createObjectURL(new Blob([k],{type:"text/javascript"})))}}f(["exports"],function(t){var E=typeof self<"u"?self:{},k="2.15.0";let P;const R={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(P==null){const n=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{P=process.env.API_URL_REGEX!=null?new RegExp(process.env.API_URL_REGEX):n}catch{P=n}}return P},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!R.API_URL)return null;try{const n=new URL(R.API_URL);return n.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":n.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},F={supported:!1,testSupport:function(n){!J&&Z&&(he?ye(n):U=n)}};let U,Z,J=!1,he=!1;function ye(n){const e=n.createTexture();n.bindTexture(n.TEXTURE_2D,e);try{if(n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,Z),n.isContextLost())return;F.supported=!0}catch{}n.deleteTexture(e),J=!0}E.document&&(Z=E.document.createElement("img"),Z.onload=function(){U&&ye(U),U=null,he=!0},Z.onerror=function(){J=!0,U=null},Z.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const te="01";function ce(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var be=we;function we(n,e,r,u){this.cx=3*n,this.bx=3*(r-n)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(u-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=n,this.p1y=e,this.p2x=r,this.p2y=u}we.prototype={sampleCurveX:function(n){return((this.ax*n+this.bx)*n+this.cx)*n},sampleCurveY:function(n){return((this.ay*n+this.by)*n+this.cy)*n},sampleCurveDerivativeX:function(n){return(3*this.ax*n+2*this.bx)*n+this.cx},solveCurveX:function(n,e){if(e===void 0&&(e=1e-6),n<0)return 0;if(n>1)return 1;for(var r=n,u=0;u<8;u++){var m=this.sampleCurveX(r)-n;if(Math.abs(m)m?b=r:I=r,r=.5*(I-b)+b;return r},solve:function(n,e){return this.sampleCurveY(this.solveCurveX(n,e))}};var Ue=ce(be),ze=Ve;function Ve(n,e){this.x=n,this.y=e}Ve.prototype={clone:function(){return new Ve(this.x,this.y)},add:function(n){return this.clone()._add(n)},sub:function(n){return this.clone()._sub(n)},multByPoint:function(n){return this.clone()._multByPoint(n)},divByPoint:function(n){return this.clone()._divByPoint(n)},mult:function(n){return this.clone()._mult(n)},div:function(n){return this.clone()._div(n)},rotate:function(n){return this.clone()._rotate(n)},rotateAround:function(n,e){return this.clone()._rotateAround(n,e)},matMult:function(n){return this.clone()._matMult(n)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(n){return this.x===n.x&&this.y===n.y},dist:function(n){return Math.sqrt(this.distSqr(n))},distSqr:function(n){var e=n.x-this.x,r=n.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(n){return Math.atan2(this.y-n.y,this.x-n.x)},angleWith:function(n){return this.angleWithSep(n.x,n.y)},angleWithSep:function(n,e){return Math.atan2(this.x*e-this.y*n,this.x*n+this.y*e)},_matMult:function(n){var e=n[2]*this.x+n[3]*this.y;return this.x=n[0]*this.x+n[1]*this.y,this.y=e,this},_add:function(n){return this.x+=n.x,this.y+=n.y,this},_sub:function(n){return this.x-=n.x,this.y-=n.y,this},_mult:function(n){return this.x*=n,this.y*=n,this},_div:function(n){return this.x/=n,this.y/=n,this},_multByPoint:function(n){return this.x*=n.x,this.y*=n.y,this},_divByPoint:function(n){return this.x/=n.x,this.y/=n.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var n=this.y;return this.y=this.x,this.x=-n,this},_rotate:function(n){var e=Math.cos(n),r=Math.sin(n),u=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=u,this},_rotateAround:function(n,e){var r=Math.cos(n),u=Math.sin(n),m=e.y+u*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-u*(this.y-e.y),this.y=m,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Ve.convert=function(n){return n instanceof Ve?n:Array.isArray(n)?new Ve(n[0],n[1]):n};var Ie=ce(ze);const ft=Math.PI/180,lt=180/Math.PI;function Je(n){return n*ft}function At(n){return n*lt}const ut=[[0,0],[1,0],[1,1],[0,1]];function Nt(n){if(n<=0)return 0;if(n>=1)return 1;const e=n*n,r=e*n;return 4*(n<.5?r:3*(n-e)+r-.75)}function Lt(n,e,r,u){const m=new Ue(n,e,r,u);return function(y){return m.solve(y)}}const Yt=Lt(.25,.1,.25,1);function Mt(n,e,r){return Math.min(r,Math.max(e,n))}function Gt(n,e,r){return(r=Mt((r-n)/(e-n),0,1))*r*(3-2*r)}function tt(n,e,r){const u=r-e,m=((n-e)%u+u)%u+e;return m===e?r:m}function Bt(n,e,r){if(!n.length)return r(null,[]);let u=n.length;const m=new Array(n.length);let y=null;n.forEach((b,I)=>{e(b,(C,A)=>{C&&(y=C),m[I]=A,--u==0&&r(y,m)})})}function Zt(n){const e=[];for(const r in n)e.push(n[r]);return e}function Vt(n,...e){for(const r of e)for(const u in r)n[u]=r[u];return n}let St=1;function hn(){return St++}function rn(){return function n(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,n)}()}function Tn(n){return n<=1?1:Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function je(n){return!!n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(n)}function Kn(n,e){n.forEach(r=>{e[r]&&(e[r]=e[r].bind(e))})}function bn(n,e){return n.indexOf(e,n.length-e.length)!==-1}function gt(n,e,r){const u={};for(const m in n)u[m]=e.call(this,n[m],m,n);return u}function Me(n,e,r){const u={};for(const m in n)e.call(r||this,n[m],m,n)&&(u[m]=n[m]);return u}function Fn(n){return Array.isArray(n)?n.map(Fn):typeof n=="object"&&n?gt(n,Fn):n}const Si={};function yn(n){Si[n]||(typeof console<"u"&&console.warn(n),Si[n]=!0)}function _i(n,e,r){return(r.y-n.y)*(e.x-n.x)>(e.y-n.y)*(r.x-n.x)}function Yi(n){let e=0;for(let r,u,m=0,y=n.length,b=y-1;m@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,u,m,y)=>{const b=m||y;return e[u]=!b||b.toLowerCase(),""}),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e}let Wo=null;function zo(n){if(Wo==null){const e=n.navigator?n.navigator.userAgent:null;Wo=!!n.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Wo}function Fr(n){try{const e=E[n];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}}function bo(n,e){return[n[4*e],n[4*e+1],n[4*e+2],n[4*e+3]]}const an="mapbox-tiles";let lo=500,uo=50,Mr,tn;function as(){try{return E.caches}catch{}}function Ln(){as()&&!Mr&&(Mr=E.caches.open(an))}function sn(n){const e=n.indexOf("?");if(e<0)return n;const r=function(m){const y=m.indexOf("?");return y>0?m.slice(y+1).split("&"):[]}(n),u=r.filter(m=>{const y=m.split("=");return y[0]==="language"||y[0]==="worldview"});return u.length?`${n.slice(0,e)}?${u.join("&")}`:n.slice(0,e)}let ra=1/0;const vr={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(vr);class Yo extends Error{constructor(e,r,u){r===401&&Ge(u)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=r,this.url=u}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const nn=Hi()?()=>self.worker&&self.worker.referrer:()=>(E.location.protocol==="blob:"?E.parent:E).location.href,ls=function(n,e){if(!(/^file:/.test(r=n.url)||/^file:/.test(nn())&&!/^\w+:/.test(r))){if(E.fetch&&E.Request&&E.AbortController&&E.Request.prototype.hasOwnProperty("signal"))return function(u,m){const y=new E.AbortController,b=new E.Request(u.url,{method:u.method||"GET",body:u.body,credentials:u.credentials,headers:u.headers,referrer:nn(),referrerPolicy:u.referrerPolicy,signal:y.signal});let I=!1,C=!1;const A=(O=b.url).indexOf("sku=")>0&&Ge(O);var O;u.type==="json"&&b.headers.set("Accept","application/json");const B=($,W,K)=>{if(C)return;if($&&$.message!=="SecurityError"&&yn($.toString()),W&&K)return j(W);const re=Date.now();E.fetch(b).then(de=>{if(de.ok){const Te=A?de.clone():null;return j(de,Te,re)}return m(new Yo(de.statusText,de.status,u.url))}).catch(de=>{de.name!=="AbortError"&&m(new Error(`${de.message} ${u.url}`))})},j=($,W,K)=>{(u.type==="arrayBuffer"?$.arrayBuffer():u.type==="json"?$.json():$.text()).then(re=>{C||(W&&K&&function(de,Te,pe){if(Ln(),!Mr)return;const Ee={status:Te.status,statusText:Te.statusText,headers:new E.Headers};Te.headers.forEach((We,Ze)=>Ee.headers.set(Ze,We));const Ce=wt(Te.headers.get("Cache-Control")||"");if(Ce["no-store"])return;Ce["max-age"]&&Ee.headers.set("Expires",new Date(pe+1e3*Ce["max-age"]).toUTCString());const Se=Ee.headers.get("Expires");Se&&(new Date(Se).getTime()-pe<42e4||function(We,Ze){if(tn===void 0)try{new Response(new ReadableStream),tn=!0}catch{tn=!1}tn?Ze(We.body):We.blob().then(Ze)}(Te,We=>{const Ze=new E.Response(We,Ee);Ln(),Mr&&Mr.then(nt=>nt.put(sn(de.url),Ze)).catch(nt=>yn(nt.message))}))}(b,W,K),I=!0,m(null,re,$.headers.get("Cache-Control"),$.headers.get("Expires")))}).catch(re=>{C||m(new Error(re.message))})};return A?function($,W){if(Ln(),!Mr)return W(null);const K=sn($.url);Mr.then(re=>{re.match(K).then(de=>{const Te=function(pe){if(!pe)return!1;const Ee=new Date(pe.headers.get("Expires")||0),Ce=wt(pe.headers.get("Cache-Control")||"");return Ee>Date.now()&&!Ce["no-cache"]}(de);re.delete(K),Te&&re.put(K,de.clone()),W(null,de,Te)}).catch(W)}).catch(W)}(b,B):B(null,null),{cancel:()=>{C=!0,I||y.abort()}}}(n,e);if(Hi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",n,e,void 0,!0)}var r;return function(u,m){const y=new E.XMLHttpRequest;y.open(u.method||"GET",u.url,!0),u.type==="arrayBuffer"&&(y.responseType="arraybuffer");for(const b in u.headers)y.setRequestHeader(b,u.headers[b]);return u.type==="json"&&(y.responseType="text",y.setRequestHeader("Accept","application/json")),y.withCredentials=u.credentials==="include",y.onerror=()=>{m(new Error(y.statusText))},y.onload=()=>{if((y.status>=200&&y.status<300||y.status===0)&&y.response!==null){let b=y.response;if(u.type==="json")try{b=JSON.parse(y.response)}catch(I){return m(I)}m(null,b,y.getResponseHeader("Cache-Control"),y.getResponseHeader("Expires"))}else m(new Yo(y.statusText,y.status,u.url))},y.send(u.body),{cancel:()=>y.abort()}}(n,e)},zs=function(n,e){return ls(Vt(n,{type:"arrayBuffer"}),e)};function Os(n){const e=E.document.createElement("a");return e.href=n,e.protocol===E.document.location.protocol&&e.host===E.document.location.host}const xe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let ee,ne;ee=[],ne=0;const ve=function(n,e){if(F.supported&&(n.headers||(n.headers={}),n.headers.accept="image/webp,*/*"),ne>=R.MAX_PARALLEL_IMAGE_REQUESTS){const y={requestParameters:n,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return ee.push(y),y}ne++;let r=!1;const u=()=>{if(!r)for(r=!0,ne--;ee.length&&ne{u(),y?e(y):b&&(E.createImageBitmap?function(A,O){const B=new E.Blob([new Uint8Array(A)],{type:"image/png"});E.createImageBitmap(B).then(j=>{O(null,j)}).catch(j=>{O(new Error(`Could not load image because of ${j.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(b,(A,O)=>e(A,O,I,C)):function(A,O){const B=new E.Image,j=E.URL;B.onload=()=>{O(null,B),j.revokeObjectURL(B.src),B.onload=null,E.requestAnimationFrame(()=>{B.src=xe})},B.onerror=()=>O(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 $=new E.Blob([new Uint8Array(A)],{type:"image/png"});B.src=A.byteLength?j.createObjectURL($):xe}(b,(A,O)=>e(A,O,I,C)))});return{cancel:()=>{m.cancel(),u()}}},ke="NO_ACCESS_TOKEN";function De(n){return n.indexOf("mapbox:")===0}function Ge(n){return R.API_URL_REGEX.test(n)}function Fe(n){return R.API_CDN_URL_REGEX.test(n)}function me(n){return R.API_STYLE_REGEX.test(n)&&!Ye(n)}function Ye(n){return R.API_SPRITE_REGEX.test(n)}const xt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function It(n){const e=n.match(xt);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function _t(n){const e=n.params.length?`?${n.params.join("&")}`:"";return`${n.protocol}://${n.authority}${n.path}${e}`}const ln="mapbox.eventData";function wn(n){if(!n)return null;const e=n.split(".");if(!e||e.length!==3)return null;try{return JSON.parse(decodeURIComponent(E.atob(e[1]).split("").map(r=>"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class on{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const r=wn(R.ACCESS_TOKEN);let u="";return u=r&&r.u?E.btoa(encodeURIComponent(r.u).replace(/%([0-9A-F]{2})/g,(m,y)=>String.fromCharCode(+("0x"+y)))):R.ACCESS_TOKEN||"",e?`${ln}.${e}:${u}`:`${ln}:${u}`}fetchEventData(){const e=Fr("localStorage"),r=this.getStorageKey(),u=this.getStorageKey("uuid");if(e)try{const m=E.localStorage.getItem(r);m&&(this.eventData=JSON.parse(m));const y=E.localStorage.getItem(u);y&&(this.anonId=y)}catch{yn("Unable to read from LocalStorage")}}saveEventData(){const e=Fr("localStorage"),r=this.getStorageKey(),u=this.getStorageKey("uuid");if(e)try{E.localStorage.setItem(u,this.anonId),Object.keys(this.eventData).length>=1&&E.localStorage.setItem(r,JSON.stringify(this.eventData))}catch{yn("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,r,u,m){if(!R.EVENTS_URL)return;const y=It(R.EVENTS_URL);y.params.push(`access_token=${m||R.ACCESS_TOKEN||""}`);const b={event:this.type,created:new Date(e).toISOString()},I=r?Vt(b,r):b,C={url:_t(y),headers:{"Content-Type":"text/plain"},body:JSON.stringify([I])};this.pendingRequest=function(A,O){return ls(Vt(A,{method:"POST"}),O)}(C,A=>{this.pendingRequest=null,u(A),this.saveEventData(),this.processRequests(m)})}queueRequest(e,r){this.queue.push(e),this.processRequests(r)}}const En=new class extends on{constructor(n){super("appUserTurnstile"),this._customAccessToken=n}postTurnstileEvent(n,e){R.EVENTS_URL&&R.ACCESS_TOKEN&&Array.isArray(n)&&n.some(r=>De(r)||Ge(r))&&this.queueRequest(Date.now(),e)}processRequests(n){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=wn(R.ACCESS_TOKEN),r=e?e.u:R.ACCESS_TOKEN;let u=r!==this.eventData.tokenU;je(this.anonId)||(this.anonId=rn(),u=!0);const m=this.queue.shift();if(this.eventData.lastSuccess){const y=new Date(this.eventData.lastSuccess),b=new Date(m),I=(m-this.eventData.lastSuccess)/864e5;u=u||I>=1||I<-1||y.getDate()!==b.getDate()}else u=!0;u?this.postEvent(m,{sdkIdentifier:"mapbox-gl-js",sdkVersion:k,skuId:te,"enabled.telemetry":!1,userId:this.anonId},y=>{y||(this.eventData.lastSuccess=m,this.eventData.tokenU=r)},n):this.processRequests()}},Sn=En.postTurnstileEvent.bind(En),yi=new class extends on{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(n,e,r,u){this.skuToken=e,this.errorCb=u,R.EVENTS_URL&&(r||R.ACCESS_TOKEN?this.queueRequest({id:n,timestamp:Date.now()},r):this.errorCb(new Error(ke)))}processRequests(n){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),je(this.anonId)||(this.anonId=rn()),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:k,skuId:te,skuToken:this.skuToken,userId:this.anonId},u=>{u?this.errorCb(u):e&&(this.success[e]=!0)},n))}},ki=yi.postMapLoadEvent.bind(yi),hr=new class extends on{constructor(){super("gljs.performance")}postPerformanceEvent(n,e){R.EVENTS_URL&&(n||R.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},n)}processRequests(n){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:e,performanceData:r}=this.queue.shift(),u=function(m){const y=E.performance.getEntriesByType("resource"),b=E.performance.getEntriesByType("mark"),I=function(j){const $={};if(j){for(const W in j)if(W!=="other")for(const K of j[W]){const re=`${W}ResolveRangeMin`,de=`${W}ResolveRangeMax`,Te=`${W}RequestCount`,pe=`${W}RequestCachedCount`;$[re]=Math.min($[re]||1/0,K.startTime),$[de]=Math.max($[de]||-1/0,K.responseEnd);const Ee=Ce=>{$[Ce]===void 0&&($[Ce]=0),++$[Ce]};K.transferSize!==void 0&&K.transferSize===0&&Ee(pe),Ee(Te)}}return $}(function(j,$){const W={};if(j)for(const K of j){const re=$(K);W[re]===void 0&&(W[re]=[]),W[re].push(K)}return W}(y,oa)),C=E.devicePixelRatio,A=E.navigator.connection||E.navigator.mozConnection||E.navigator.webkitConnection,O={counters:[],metadata:[],attributes:[]},B=(j,$,W)=>{W!=null&&j.push({name:$,value:W.toString()})};for(const j in I)B(O.counters,j,I[j]);if(m.interactionRange[0]!==1/0&&m.interactionRange[1]!==-1/0&&(B(O.counters,"interactionRangeMin",m.interactionRange[0]),B(O.counters,"interactionRangeMax",m.interactionRange[1])),b)for(const j of Object.keys(Xr)){const $=Xr[j],W=b.find(K=>K.name===$);W&&B(O.counters,$,W.startTime)}return B(O.counters,"visibilityHidden",m.visibilityHidden),B(O.attributes,"style",function(j){if(j)for(const $ of j){const W=$.name.split("?")[0];if(me(W)){const K=W.split("/").slice(-2);if(K.length===2)return`mapbox://styles/${K[0]}/${K[1]}`}}}(y)),B(O.attributes,"terrainEnabled",m.terrainEnabled?"true":"false"),B(O.attributes,"fogEnabled",m.fogEnabled?"true":"false"),B(O.attributes,"projection",m.projection),B(O.attributes,"zoom",m.zoom),B(O.metadata,"devicePixelRatio",C),B(O.metadata,"connectionEffectiveType",A?A.effectiveType:void 0),B(O.metadata,"navigatorUserAgent",E.navigator.userAgent),B(O.metadata,"screenWidth",E.screen.width),B(O.metadata,"screenHeight",E.screen.height),B(O.metadata,"windowWidth",E.innerWidth),B(O.metadata,"windowHeight",E.innerHeight),B(O.metadata,"mapWidth",m.width/C),B(O.metadata,"mapHeight",m.height/C),B(O.metadata,"webglRenderer",m.renderer),B(O.metadata,"webglVendor",m.vendor),B(O.metadata,"sdkVersion",k),B(O.metadata,"sdkIdentifier","mapbox-gl-js"),O}(r);for(const m of u.metadata);for(const m of u.counters);for(const m of u.attributes);this.postEvent(e,u,()=>{},n)}},$n=hr.postPerformanceEvent.bind(hr),$r=new class extends on{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(n,e,r,u){if(!R.API_URL||!R.SESSION_PATH)return;const m=It(R.API_URL+R.SESSION_PATH);m.params.push(`sku=${e||""}`),m.params.push(`access_token=${u||R.ACCESS_TOKEN||""}`);const y={url:_t(m),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(b,I){return ls(Vt(b,{method:"GET"}),I)}(y,b=>{this.pendingRequest=null,r(b),this.saveEventData(),this.processRequests(u)})}getSessionAPI(n,e,r,u){this.skuToken=e,this.errorCb=u,R.SESSION_PATH&&R.API_URL&&(r||R.ACCESS_TOKEN?this.queueRequest({id:n,timestamp:Date.now()},r):this.errorCb(new Error(ke)))}processRequests(n){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||this.getSession(r,this.skuToken,u=>{u?this.errorCb(u):e&&(this.success[e]=!0)},n)}},Ci=$r.getSessionAPI.bind($r),Li=new Set,Xr={create:"create",load:"load",fullLoad:"fullLoad"},Pl={mark(n){E.performance.mark(n)},measure(n,e,r){E.performance.measure(n,e,r)}};function oa(n){const e=n.name.split("?")[0];return Fe(e)&&e.includes("mapbox-gl.js")?"javascript":Fe(e)&&e.includes("mapbox-gl.css")?"css":function(r){return R.API_FONTS_REGEX.test(r)}(e)?"fontRange":Ye(e)?"sprite":me(e)?"style":function(r){return R.API_TILEJSON_REGEX.test(r)}(e)?"tilejson":"other"}const On=E.performance;function Ri(n){const e=n?n.url.toString():void 0;return On.getEntriesByName(e)}let sa,Ll,us,Sr;const co={now:()=>us!==void 0?us:E.performance.now(),setNow(n){us=n},restoreNow(){us=void 0},frame(n){const e=E.requestAnimationFrame(n);return{cancel:()=>E.cancelAnimationFrame(e)}},getImageData(n,e=0){const{width:r,height:u}=n;Sr||(Sr=E.document.createElement("canvas"));const m=Sr.getContext("2d",{willReadFrequently:!0});if(!m)throw new Error("failed to create canvas 2d context");return(r>Sr.width||u>Sr.height)&&(Sr.width=r,Sr.height=u),m.clearRect(-e,-e,r+2*e,u+2*e),m.drawImage(n,0,0,r,u),m.getImageData(-e,-e,r+2*e,u+2*e)},resolveURL:n=>(sa||(sa=E.document.createElement("a")),sa.href=n,sa.href),get devicePixelRatio(){return E.devicePixelRatio},get prefersReducedMotion(){return!!E.matchMedia&&(Ll==null&&(Ll=E.matchMedia("(prefers-reduced-motion: reduce)")),Ll.matches)}};function aa(n,e,r){r[n]&&r[n].indexOf(e)!==-1||(r[n]=r[n]||[],r[n].push(e))}function Va(n,e,r){if(r&&r[n]){const u=r[n].indexOf(e);u!==-1&&r[n].splice(u,1)}}class cs{constructor(e,r={}){Vt(this,r),this.type=e}}class Fi extends cs{constructor(e,r={}){super("error",Vt({error:e},r))}}class wo{on(e,r){return this._listeners=this._listeners||{},aa(e,r,this._listeners),this}off(e,r){return Va(e,r,this._listeners),Va(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},aa(e,r,this._oneTimeListeners),this):new Promise(u=>this.once(e,u))}fire(e,r){typeof e=="string"&&(e=new cs(e,r||{}));const u=e.type;if(this.listens(u)){e.target=this;const m=this._listeners&&this._listeners[u]?this._listeners[u].slice():[];for(const I of m)I.call(this,e);const y=this._oneTimeListeners&&this._oneTimeListeners[u]?this._oneTimeListeners[u].slice():[];for(const I of y)Va(u,I,this._oneTimeListeners),I.call(this,e);const b=this._eventedParent;b&&(Vt(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),b.fire(e))}else e instanceof Fi&&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,r){return this._eventedParent=e,this._eventedParentData=r,this}}var Qe=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"requires":["fill-extrusion-edge-radius"],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function kr(n,...e){for(const r of e)for(const u in r)n[u]=r[u];return n}function Ti(n){return n instanceof Number||n instanceof String||n instanceof Boolean?n.valueOf():n}function Ki(n){if(Array.isArray(n))return n.map(Ki);if(n instanceof Object&&!(n instanceof Number||n instanceof String||n instanceof Boolean)){const e={};for(const r in n)e[r]=Ki(n[r]);return e}return Ti(n)}class Nu extends Error{constructor(e,r){super(r),this.message=r,this.key=e}}var Eo=Nu;class Ua{constructor(e,r=[]){this.parent=e,this.bindings={};for(const[u,m]of r)this.bindings[u]=m}concat(e){return new Ua(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)}}var Rl=Ua;const Oo={kind:"null"},Pt={kind:"number"},fn={kind:"string"},In={kind:"boolean"},Ji={kind:"color"},ho={kind:"object"},kn={kind:"value"},Vr={kind:"collator"},la={kind:"formatted"},Ho={kind:"resolvedImage"};function fr(n,e){return{kind:"array",itemType:n,N:e}}function li(n){if(n.kind==="array"){const e=li(n.itemType);return typeof n.N=="number"?`array<${e}, ${n.N}>`:n.itemType.kind==="value"?"array":`array<${e}>`}return n.kind}const Bu=[Oo,Pt,fn,In,Ji,la,ho,fr(kn),Ho];function To(n,e){if(e.kind==="error")return null;if(n.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!To(n.itemType,e.itemType))&&(typeof n.N!="number"||n.N===e.N))return null}else{if(n.kind===e.kind)return null;if(n.kind==="value"){for(const r of Bu)if(!To(r,e))return null}}return`Expected ${li(n)} but found ${li(e)} instead.`}function ua(n,e){return e.some(r=>r.kind===n.kind)}function hs(n,e){return e.some(r=>r==="null"?n===null:r==="array"?Array.isArray(n):r==="object"?n&&!Array.isArray(n)&&typeof n=="object":r===typeof n)}var mi,Ko={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function ca(n){return(n=Math.round(n))<0?0:n>255?255:n}function fs(n){return ca(n[n.length-1]==="%"?parseFloat(n)/100*255:parseInt(n))}function xr(n){return(e=n[n.length-1]==="%"?parseFloat(n)/100:parseFloat(n))<0?0:e>1?1:e;var e}function rr(n,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?n+(e-n)*r*6:2*r<1?e:3*r<2?n+(e-n)*(.6666666666666666-r)*6:n}try{mi={}.parseCSSColor=function(n){var e,r=n.replace(/ /g,"").toLowerCase();if(r in Ko)return Ko[r].slice();if(r[0]==="#")return r.length===4?(e=parseInt(r.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:r.length===7&&(e=parseInt(r.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var u=r.indexOf("("),m=r.indexOf(")");if(u!==-1&&m+1===r.length){var y=r.substr(0,u),b=r.substr(u+1,m-(u+1)).split(","),I=1;switch(y){case"rgba":if(b.length!==4)return null;I=xr(b.pop());case"rgb":return b.length!==3?null:[fs(b[0]),fs(b[1]),fs(b[2]),I];case"hsla":if(b.length!==4)return null;I=xr(b.pop());case"hsl":if(b.length!==3)return null;var C=(parseFloat(b[0])%360+360)%360/360,A=xr(b[1]),O=xr(b[2]),B=O<=.5?O*(A+1):O+A-O*A,j=2*O-B;return[ca(255*rr(j,B,C+.3333333333333333)),ca(255*rr(j,B,C)),ca(255*rr(j,B,C-.3333333333333333)),I];default:return null}}return null}}catch{}class or{constructor(e,r,u,m=1){this.r=e,this.g=r,this.b=u,this.a=m}static parse(e){if(!e)return;if(e instanceof or)return e;if(typeof e!="string")return;const r=mi(e);return r?new or(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){const[e,r,u,m]=this.toArray();return`rgba(${Math.round(e)},${Math.round(r)},${Math.round(u)},${m})`}toArray(){const{r:e,g:r,b:u,a:m}=this;return m===0?[0,0,0,0]:[255*e/m,255*r/m,255*u/m,m]}toArray01(){const{r:e,g:r,b:u,a:m}=this;return m===0?[0,0,0,0]:[e/m,r/m,u/m,m]}toArray01PremultipliedAlpha(){const{r:e,g:r,b:u,a:m}=this;return[e,r,u,m]}}or.black=new or(0,0,0,1),or.white=new or(1,1,1,1),or.transparent=new or(0,0,0,0),or.red=new or(1,0,0,1),or.blue=new or(0,0,1,1);var Ai=or;class Dl{constructor(e,r,u){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=u,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ja{constructor(e,r,u,m,y){this.text=e.normalize?e.normalize():e,this.image=r,this.scale=u,this.fontStack=m,this.textColor=y}}class sr{constructor(e){this.sections=e}static fromString(e){return new sr([new ja(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof sr?e:sr.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const r of this.sections){if(r.image){e.push(["image",r.image.name]);continue}e.push(r.text);const u={};r.fontStack&&(u["text-font"]=["literal",r.fontStack.split(",")]),r.scale&&(u["font-scale"]=r.scale),r.textColor&&(u["text-color"]=["rgba"].concat(r.textColor.toArray())),e.push(u)}return e}}class Wr{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Wr({name:e,available:!1}):null}serialize(){return["image",this.name]}}function zl(n,e,r,u){return typeof n=="number"&&n>=0&&n<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?u===void 0||typeof u=="number"&&u>=0&&u<=1?null:`Invalid rgba value [${[n,e,r,u].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof u=="number"?[n,e,r,u]:[n,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Vn(n){if(n===null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||n instanceof Ai||n instanceof Dl||n instanceof sr||n instanceof Wr)return!0;if(Array.isArray(n)){for(const e of n)if(!Vn(e))return!1;return!0}if(typeof n=="object"){for(const e in n)if(!Vn(n[e]))return!1;return!0}return!1}function Xn(n){if(n===null)return Oo;if(typeof n=="string")return fn;if(typeof n=="boolean")return In;if(typeof n=="number")return Pt;if(n instanceof Ai)return Ji;if(n instanceof Dl)return Vr;if(n instanceof sr)return la;if(n instanceof Wr)return Ho;if(Array.isArray(n)){const e=n.length;let r;for(const u of n){const m=Xn(u);if(r){if(r===m)continue;r=kn;break}r=m}return fr(r||kn,e)}return ho}function ds(n){const e=typeof n;return n===null?"":e==="string"||e==="number"||e==="boolean"?String(n):n instanceof Ai||n instanceof sr||n instanceof Wr?n.toString():JSON.stringify(n)}class Ga{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Vn(e[1]))return r.error("invalid value");const u=e[1];let m=Xn(u);const y=r.expectedType;return m.kind!=="array"||m.N!==0||!y||y.kind!=="array"||typeof y.N=="number"&&y.N!==0||(m=y),new Ga(m,u)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Ai?["rgba"].concat(this.value.toArray()):this.value instanceof sr?this.value.serialize():this.value}}var fo=Ga,Qi=class{constructor(n){this.name="ExpressionEvaluationError",this.message=n}toJSON(){return this.message}};const ar={string:fn,number:Pt,boolean:In,object:ho};class qa{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let u,m=1;const y=e[0];if(y==="array"){let I,C;if(e.length>2){const A=e[1];if(typeof A!="string"||!(A in ar)||A==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);I=ar[A],m++}else I=kn;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);C=e[2],m++}u=fr(I,C)}else u=ar[y];const b=[];for(;me.outputDefined())}serialize(){const e=this.type,r=[e.kind];if(e.kind==="array"){const u=e.itemType;if(u.kind==="string"||u.kind==="number"||u.kind==="boolean"){r.push(u.kind);const m=e.N;(typeof m=="number"||this.args.length>1)&&r.push(m)}}return r.concat(this.args.map(u=>u.serialize()))}}var po=qa;class No{constructor(e){this.type=la,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const u=e[1];if(!Array.isArray(u)&&typeof u=="object")return r.error("First argument must be an image or text section.");const m=[];let y=!1;for(let b=1;b<=e.length-1;++b){const I=e[b];if(y&&typeof I=="object"&&!Array.isArray(I)){y=!1;let C=null;if(I["font-scale"]&&(C=r.parse(I["font-scale"],1,Pt),!C))return null;let A=null;if(I["text-font"]&&(A=r.parse(I["text-font"],1,fr(fn)),!A))return null;let O=null;if(I["text-color"]&&(O=r.parse(I["text-color"],1,Ji),!O))return null;const B=m[m.length-1];B.scale=C,B.font=A,B.textColor=O}else{const C=r.parse(e[b],1,kn);if(!C)return null;const A=C.type.kind;if(A!=="string"&&A!=="value"&&A!=="null"&&A!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");y=!0,m.push({content:C,scale:null,font:null,textColor:null})}}return new No(m)}evaluate(e){return new sr(this.sections.map(r=>{const u=r.content.evaluate(e);return Xn(u)===Ho?new ja("",u,null,null,null):new ja(ds(u),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)}))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const r of this.sections){e.push(r.content.serialize());const u={};r.scale&&(u["font-scale"]=r.scale.serialize()),r.font&&(u["text-font"]=r.font.serialize()),r.textColor&&(u["text-color"]=r.textColor.serialize()),e.push(u)}return e}}class ha{constructor(e){this.type=Ho,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const u=r.parse(e[1],1,fn);return u?new ha(u):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),u=Wr.fromString(r);return u&&e.availableImages&&(u.available=e.availableImages.indexOf(r)>-1),u}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const nh={"to-boolean":In,"to-color":Ji,"to-number":Pt,"to-string":fn};class Za{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const u=e[0];if((u==="to-boolean"||u==="to-string")&&e.length!==2)return r.error("Expected one argument.");const m=nh[u],y=[];for(let b=1;b4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:zl(r[0],r[1],r[2],r[3]),!u))return new Ai(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Qi(u||`Could not parse color from value '${typeof r=="string"?r:String(JSON.stringify(r))}'`)}if(this.type.kind==="number"){let r=null;for(const u of this.args){if(r=u.evaluate(e),r===null)return 0;const m=Number(r);if(!isNaN(m))return m}throw new Qi(`Could not convert ${JSON.stringify(r)} to number.`)}return this.type.kind==="formatted"?sr.fromString(ds(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?Wr.fromString(ds(this.args[0].evaluate(e))):ds(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new No([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new ha(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild(r=>{e.push(r.serialize())}),e}}var Cr=Za;const Ur=["Unknown","Point","LineString","Polygon"];var Ol=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Ur[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const n=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:r,y:u}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*e-n[0])+this.featureDistanceData.bearing[1]*(u*e-n[1])}return 0}parseColor(n){let e=this._parseColorCache[n];return e||(e=this._parseColorCache[n]=Ai.parse(n)),e}};class er{constructor(e,r,u,m){this.name=e,this.type=r,this._evaluate=u,this.args=m}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,r){const u=e[0],m=er.definitions[u];if(!m)return r.error(`Unknown expression "${u}". If you wanted a literal array, use ["literal", [...]].`,0);const y=Array.isArray(m)?m[0]:m.type,b=Array.isArray(m)?[[m[1],m[2]]]:m.overloads,I=b.filter(([A])=>!Array.isArray(A)||A.length===e.length-1);let C=null;for(const[A,O]of I){C=new br(r.registry,r.path,null,r.scope);const B=[];let j=!1;for(let $=1;${return j=B,Array.isArray(j)?`(${j.map(li).join(", ")})`:`(${li(j.type)}...)`;var j}).join(" | "),O=[];for(let B=1;B=e[2]||n[1]<=e[1]||n[3]>=e[3])}function pa(n,e){const r=(180+n[0])/360,u=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n[1]*Math.PI/360)))/360,m=Math.pow(2,e.z);return[Math.round(r*m*Pr),Math.round(u*m*Pr)]}function go(n,e,r){const u=n[0]-e[0],m=n[1]-e[1],y=n[0]-r[0],b=n[1]-r[1];return u*b-y*m==0&&u*y<=0&&m*b<=0}function ma(n,e){let r=!1;for(let b=0,I=e.length;b(u=n)[1]!=(y=C[A+1])[1]>u[1]&&u[0]<(y[0]-m[0])*(u[1]-m[1])/(y[1]-m[1])+m[0]&&(r=!r)}}var u,m,y;return r}function Nl(n,e){for(let r=0;r0&&I<0||b<0&&I>0}function Ns(n,e,r){for(const A of r)for(let O=0;Or[2]){const m=.5*u;let y=n[0]-r[0]>m?-u:r[0]-n[0]>m?u:0;y===0&&(y=n[0]-r[2]>m?-u:r[2]-n[0]>m?u:0),n[0]+=y}da(e,n)}function Lr(n,e,r,u){const m=Math.pow(2,u.z)*Pr,y=[u.x*Pr,u.y*Pr],b=[];if(!n)return b;for(const I of n)for(const C of I){const A=[C.x+y[0],C.y+y[1]];Bo(A,e,r,m),b.push(A)}return b}function Vl(n,e,r,u){const m=Math.pow(2,u.z)*Pr,y=[u.x*Pr,u.y*Pr],b=[];if(!n)return b;for(const C of n){const A=[];for(const O of C){const B=[O.x+y[0],O.y+y[1]];da(e,B),A.push(B)}b.push(A)}if(e[2]-e[0]<=m/2){(I=e)[0]=I[1]=1/0,I[2]=I[3]=-1/0;for(const C of b)for(const A of C)Bo(A,e,r,m)}var I;return b}class ps{constructor(e,r){this.type=In,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Vn(e[1])){const u=e[1];if(u.type==="FeatureCollection")for(let m=0;m{e&&!Jo(r)&&(e=!1)}),e}function Io(n){if(n instanceof Ar&&n.name==="feature-state")return!1;let e=!0;return n.eachChild(r=>{e&&!Io(r)&&(e=!1)}),e}function Fo(n,e){if(n instanceof Ar&&e.indexOf(n.name)>=0)return!1;let r=!0;return n.eachChild(u=>{r&&!Fo(u,e)&&(r=!1)}),r}class ga{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const u=e[1];return r.scope.has(u)?new ga(u,r.scope.get(u)):r.error(`Unknown variable "${u}". Make sure "${u}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var Yr=ga;class Bs{constructor(e,r=[],u,m=new Rl,y=[]){this.registry=e,this.path=r,this.key=r.map(b=>`[${b}]`).join(""),this.scope=m,this.errors=y,this.expectedType=u}parse(e,r,u,m,y={}){return r?this.concat(r,u,m)._parse(e,y):this._parse(e,y)}_parse(e,r){function u(m,y,b){return b==="assert"?new po(y,[m]):b==="coerce"?new Cr(y,[m]):m}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const m=e[0];if(typeof m!="string")return this.error(`Expression name must be a string, but found ${typeof m} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const y=this.registry[m];if(y){let b=y.parse(e,this);if(!b)return null;if(this.expectedType){const I=this.expectedType,C=b.type;if(I.kind!=="string"&&I.kind!=="number"&&I.kind!=="boolean"&&I.kind!=="object"&&I.kind!=="array"||C.kind!=="value")if(I.kind!=="color"&&I.kind!=="formatted"&&I.kind!=="resolvedImage"||C.kind!=="value"&&C.kind!=="string"){if(this.checkSubtype(I,C))return null}else b=u(b,I,r.typeAnnotation||"coerce");else b=u(b,I,r.typeAnnotation||"assert")}if(!(b instanceof fo)&&b.type.kind!=="resolvedImage"&&ms(b)){const I=new Ol;try{b=new fo(b.type,b.evaluate(I))}catch(C){return this.error(C.message),null}}return b}return this.error(`Unknown expression "${m}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,u){const m=typeof e=="number"?this.path.concat(e):this.path,y=u?this.scope.concat(u):this.scope;return new Bs(this.registry,m,r||null,y,this.errors)}error(e,...r){const u=`${this.key}${r.map(m=>`[${m}]`).join("")}`;this.errors.push(new Eo(u,e))}checkSubtype(e,r){const u=To(e,r);return u&&this.error(u),u}}var br=Bs;function ms(n){if(n instanceof Yr)return ms(n.boundExpression);if(n instanceof Ar&&n.name==="error"||n instanceof fa||n instanceof $a)return!1;const e=n instanceof Cr||n instanceof po;let r=!0;return n.eachChild(u=>{r=e?r&&ms(u):r&&u instanceof fo}),!!r&&Jo(n)&&Fo(n,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function Xa(n,e){const r=n.length-1;let u,m,y=0,b=r,I=0;for(;y<=b;)if(I=Math.floor((y+b)/2),u=n[I],m=n[I+1],u<=e){if(I===r||ee))throw new Qi("Input is not a number.");b=I-1}return 0}class _a{constructor(e,r,u){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[m,y]of u)this.labels.push(m),this.outputs.push(y)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const u=r.parse(e[1],1,Pt);if(!u)return null;const m=[];let y=null;r.expectedType&&r.expectedType.kind!=="value"&&(y=r.expectedType);for(let b=1;b=I)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',A);const B=r.parse(C,O,y);if(!B)return null;y=y||B.type,m.push([I,B])}return new _a(y,u,m)}evaluate(e){const r=this.labels,u=this.outputs;if(r.length===1)return u[0].evaluate(e);const m=this.input.evaluate(e);if(m<=r[0])return u[0].evaluate(e);const y=r.length;return m>=r[y-1]?u[y-1].evaluate(e):u[Xa(r,m)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let r=0;r0&&e.push(this.labels[r]),e.push(this.outputs[r].serialize());return e}}var Wa=_a;function Nn(n,e,r){return n*(1-r)+e*r}var gs=Object.freeze({__proto__:null,array:function(n,e,r){return n.map((u,m)=>Nn(u,e[m],r))},color:function(n,e,r){return new Ai(Nn(n.r,e.r,r),Nn(n.g,e.g,r),Nn(n.b,e.b,r),Nn(n.a,e.a,r))},number:Nn});const Vu=.95047,Ul=1.08883,Uu=4/29,_s=6/29,jl=3*_s*_s,rh=_s*_s*_s,oh=Math.PI/180,sh=180/Math.PI;function Ya(n){return n>rh?Math.pow(n,.3333333333333333):n/jl+Uu}function Gl(n){return n>_s?n*n*n:jl*(n-Uu)}function Ha(n){return 255*(n<=.0031308?12.92*n:1.055*Math.pow(n,.4166666666666667)-.055)}function Ka(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function ju(n){const e=Ka(n.r),r=Ka(n.g),u=Ka(n.b),m=Ya((.4124564*e+.3575761*r+.1804375*u)/Vu),y=Ya((.2126729*e+.7151522*r+.072175*u)/1);return{l:116*y-16,a:500*(m-y),b:200*(y-Ya((.0193339*e+.119192*r+.9503041*u)/Ul)),alpha:n.a}}function Gu(n){let e=(n.l+16)/116,r=isNaN(n.a)?e:e+n.a/500,u=isNaN(n.b)?e:e-n.b/200;return e=1*Gl(e),r=Vu*Gl(r),u=Ul*Gl(u),new Ai(Ha(3.2404542*r-1.5371385*e-.4985314*u),Ha(-.969266*r+1.8760108*e+.041556*u),Ha(.0556434*r-.2040259*e+1.0572252*u),n.alpha)}function ah(n,e,r){const u=e-n;return n+r*(u>180||u<-180?u-360*Math.round(u/360):u)}const ya={forward:ju,reverse:Gu,interpolate:function(n,e,r){return{l:Nn(n.l,e.l,r),a:Nn(n.a,e.a,r),b:Nn(n.b,e.b,r),alpha:Nn(n.alpha,e.alpha,r)}}},Fs={forward:function(n){const{l:e,a:r,b:u}=ju(n),m=Math.atan2(u,r)*sh;return{h:m<0?m+360:m,c:Math.sqrt(r*r+u*u),l:e,alpha:n.a}},reverse:function(n){const e=n.h*oh,r=n.c;return Gu({l:n.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:n.alpha})},interpolate:function(n,e,r){return{h:ah(n.h,e.h,r),c:Nn(n.c,e.c,r),l:Nn(n.l,e.l,r),alpha:Nn(n.alpha,e.alpha,r)}}};var ql=Object.freeze({__proto__:null,hcl:Fs,lab:ya});class Vs{constructor(e,r,u,m,y){this.type=e,this.operator=r,this.interpolation=u,this.input=m,this.labels=[],this.outputs=[];for(const[b,I]of y)this.labels.push(b),this.outputs.push(I)}static interpolationFactor(e,r,u,m){let y=0;if(e.name==="exponential")y=Ja(r,e.base,u,m);else if(e.name==="linear")y=Ja(r,1,u,m);else if(e.name==="cubic-bezier"){const b=e.controlPoints;y=new Ue(b[0],b[1],b[2],b[3]).solve(Ja(r,1,u,m))}return y}static parse(e,r){let[u,m,y,...b]=e;if(!Array.isArray(m)||m.length===0)return r.error("Expected an interpolation type expression.",1);if(m[0]==="linear")m={name:"linear"};else if(m[0]==="exponential"){const A=m[1];if(typeof A!="number")return r.error("Exponential interpolation requires a numeric base.",1,1);m={name:"exponential",base:A}}else{if(m[0]!=="cubic-bezier")return r.error(`Unknown interpolation type ${String(m[0])}`,1,0);{const A=m.slice(1);if(A.length!==4||A.some(O=>typeof O!="number"||O<0||O>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);m={name:"cubic-bezier",controlPoints:A}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(y=r.parse(y,2,Pt),!y)return null;const I=[];let C=null;u==="interpolate-hcl"||u==="interpolate-lab"?C=Ji:r.expectedType&&r.expectedType.kind!=="value"&&(C=r.expectedType);for(let A=0;A=O)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',j);const W=r.parse(B,$,C);if(!W)return null;C=C||W.type,I.push([O,W])}return C.kind==="number"||C.kind==="color"||C.kind==="array"&&C.itemType.kind==="number"&&typeof C.N=="number"?new Vs(C,u,m,y,I):r.error(`Type ${li(C)} is not interpolatable.`)}evaluate(e){const r=this.labels,u=this.outputs;if(r.length===1)return u[0].evaluate(e);const m=this.input.evaluate(e);if(m<=r[0])return u[0].evaluate(e);const y=r.length;if(m>=r[y-1])return u[y-1].evaluate(e);const b=Xa(r,m),I=Vs.interpolationFactor(this.interpolation,m,r[b],r[b+1]),C=u[b].evaluate(e),A=u[b+1].evaluate(e);return this.operator==="interpolate"?gs[this.type.kind.toLowerCase()](C,A,I):this.operator==="interpolate-hcl"?Fs.reverse(Fs.interpolate(Fs.forward(C),Fs.forward(A),I)):ya.reverse(ya.interpolate(ya.forward(C),ya.forward(A),I))}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const r=[this.operator,e,this.input.serialize()];for(let u=0;uTo(m,I.type));return new Qa(b?kn:u,y)}evaluate(e){let r,u=null,m=0;for(const y of this.args){if(m++,u=y.evaluate(e),u&&u instanceof Wr&&!u.available&&(r||(r=u),u=null,m===this.args.length))return r;if(u!==null)break}return u}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(r=>{e.push(r.serialize())}),e}}var el=Qa;class Us{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const u=[];for(let y=1;y=u.length)throw new Qi(`Array index out of bounds: ${r} > ${u.length-1}.`);if(r!==Math.floor(r))throw new Qi(`Array index must be an integer, but found ${r} instead.`);return u[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Zu=tl;class Zl{constructor(e,r){this.type=In,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const u=r.parse(e[1],1,kn),m=r.parse(e[2],2,kn);return u&&m?ua(u.type,[In,fn,Pt,Oo,kn])?new Zl(u,m):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${li(u.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),u=this.haystack.evaluate(e);if(u==null)return!1;if(!hs(r,["boolean","string","number","null"]))throw new Qi(`Expected first argument to be of type boolean, string, number or null, but found ${li(Xn(r))} instead.`);if(!hs(u,["string","array"]))throw new Qi(`Expected second argument to be of type array or string, but found ${li(Xn(u))} instead.`);return u.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var nl=Zl;class Mo{constructor(e,r,u){this.type=Pt,this.needle=e,this.haystack=r,this.fromIndex=u}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const u=r.parse(e[1],1,kn),m=r.parse(e[2],2,kn);if(!u||!m)return null;if(!ua(u.type,[In,fn,Pt,Oo,kn]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${li(u.type)} instead`);if(e.length===4){const y=r.parse(e[3],3,Pt);return y?new Mo(u,m,y):null}return new Mo(u,m)}evaluate(e){const r=this.needle.evaluate(e),u=this.haystack.evaluate(e);if(!hs(r,["boolean","string","number","null"]))throw new Qi(`Expected first argument to be of type boolean, string, number or null, but found ${li(Xn(r))} instead.`);if(!hs(u,["string","array"]))throw new Qi(`Expected second argument to be of type array or string, but found ${li(Xn(u))} instead.`);if(this.fromIndex){const m=this.fromIndex.evaluate(e);return u.indexOf(r,m)}return u.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var $u=Mo;class il{constructor(e,r,u,m,y,b){this.inputType=e,this.type=r,this.input=u,this.cases=m,this.outputs=y,this.otherwise=b}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let u,m;r.expectedType&&r.expectedType.kind!=="value"&&(m=r.expectedType);const y={},b=[];for(let A=2;ANumber.MAX_SAFE_INTEGER)return j.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof W=="number"&&Math.floor(W)!==W)return j.error("Numeric branch labels must be integer values.");if(u){if(j.checkSubtype(u,Xn(W)))return null}else u=Xn(W);if(y[String(W)]!==void 0)return j.error("Branch labels must be unique.");y[String(W)]=b.length}const $=r.parse(B,A,m);if(!$)return null;m=m||$.type,b.push($)}const I=r.parse(e[1],1,kn);if(!I)return null;const C=r.parse(e[e.length-1],e.length-1,m);return C?I.type.kind!=="value"&&r.concat(1).checkSubtype(u,I.type)?null:new il(u,m,I,y,b,C):null}evaluate(e){const r=this.input.evaluate(e);return(Xn(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],r=Object.keys(this.cases).sort(),u=[],m={};for(const b of r){const I=m[this.cases[b]];I===void 0?(m[this.cases[b]]=u.length,u.push([this.cases[b],[b]])):u[I][1].push(b)}const y=b=>this.inputType.kind==="number"?Number(b):b;for(const[b,I]of u)e.push(I.length===1?y(I[0]):I.map(y)),e.push(this.outputs[b].serialize());return e.push(this.otherwise.serialize()),e}}var Hr=il;class Kr{constructor(e,r,u){this.type=e,this.branches=r,this.otherwise=u}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let u;r.expectedType&&r.expectedType.kind!=="value"&&(u=r.expectedType);const m=[];for(let b=1;br.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(r=>{e.push(r.serialize())}),e}}var M=Kr;class c{constructor(e,r,u,m){this.type=e,this.input=r,this.beginIndex=u,this.endIndex=m}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const u=r.parse(e[1],1,kn),m=r.parse(e[2],2,Pt);if(!u||!m)return null;if(!ua(u.type,[fr(kn),fn,kn]))return r.error(`Expected first argument to be of type array or string, but found ${li(u.type)} instead`);if(e.length===4){const y=r.parse(e[3],3,Pt);return y?new c(u.type,u,m,y):null}return new c(u.type,u,m)}evaluate(e){const r=this.input.evaluate(e),u=this.beginIndex.evaluate(e);if(!hs(r,["string","array"]))throw new Qi(`Expected first argument to be of type array or string, but found ${li(Xn(r))} instead.`);if(this.endIndex){const m=this.endIndex.evaluate(e);return r.slice(u,m)}return r.slice(u)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var p=c;function g(n,e){return n==="=="||n==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function w(n,e,r,u){return u.compare(e,r)===0}function L(n,e,r){const u=n!=="=="&&n!=="!=";return class _b{constructor(y,b,I){this.type=In,this.lhs=y,this.rhs=b,this.collator=I,this.hasUntypedArgument=y.type.kind==="value"||b.type.kind==="value"}static parse(y,b){if(y.length!==3&&y.length!==4)return b.error("Expected two or three arguments.");const I=y[0];let C=b.parse(y[1],1,kn);if(!C)return null;if(!g(I,C.type))return b.concat(1).error(`"${I}" comparisons are not supported for type '${li(C.type)}'.`);let A=b.parse(y[2],2,kn);if(!A)return null;if(!g(I,A.type))return b.concat(2).error(`"${I}" comparisons are not supported for type '${li(A.type)}'.`);if(C.type.kind!==A.type.kind&&C.type.kind!=="value"&&A.type.kind!=="value")return b.error(`Cannot compare types '${li(C.type)}' and '${li(A.type)}'.`);u&&(C.type.kind==="value"&&A.type.kind!=="value"?C=new po(A.type,[C]):C.type.kind!=="value"&&A.type.kind==="value"&&(A=new po(C.type,[A])));let O=null;if(y.length===4){if(C.type.kind!=="string"&&A.type.kind!=="string"&&C.type.kind!=="value"&&A.type.kind!=="value")return b.error("Cannot use collator to compare non-string types.");if(O=b.parse(y[3],3,Vr),!O)return null}return new _b(C,A,O)}evaluate(y){const b=this.lhs.evaluate(y),I=this.rhs.evaluate(y);if(u&&this.hasUntypedArgument){const C=Xn(b),A=Xn(I);if(C.kind!==A.kind||C.kind!=="string"&&C.kind!=="number")throw new Qi(`Expected arguments for "${n}" to be (string, string) or (number, number), but found (${C.kind}, ${A.kind}) instead.`)}if(this.collator&&!u&&this.hasUntypedArgument){const C=Xn(b),A=Xn(I);if(C.kind!=="string"||A.kind!=="string")return e(y,b,I)}return this.collator?r(y,b,I,this.collator.evaluate(y)):e(y,b,I)}eachChild(y){y(this.lhs),y(this.rhs),this.collator&&y(this.collator)}outputDefined(){return!0}serialize(){const y=[n];return this.eachChild(b=>{y.push(b.serialize())}),y}}}const V=L("==",function(n,e,r){return e===r},w),X=L("!=",function(n,e,r){return e!==r},function(n,e,r,u){return!w(0,e,r,u)}),Q=L("<",function(n,e,r){return e",function(n,e,r){return e>r},function(n,e,r,u){return u.compare(e,r)>0}),Le=L("<=",function(n,e,r){return e<=r},function(n,e,r,u){return u.compare(e,r)<=0}),Ne=L(">=",function(n,e,r){return e>=r},function(n,e,r,u){return u.compare(e,r)>=0});class rt{constructor(e,r,u,m,y,b){this.type=fn,this.number=e,this.locale=r,this.currency=u,this.unit=m,this.minFractionDigits=y,this.maxFractionDigits=b}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const u=r.parse(e[1],1,Pt);if(!u)return null;const m=e[2];if(typeof m!="object"||Array.isArray(m))return r.error("NumberFormat options argument must be an object.");let y=null;if(m.locale&&(y=r.parse(m.locale,1,fn),!y))return null;let b=null;if(m.currency&&(b=r.parse(m.currency,1,fn),!b))return null;let I=null;if(m.unit&&(I=r.parse(m.unit,1,fn),!I))return null;let C=null;if(m["min-fraction-digits"]&&(C=r.parse(m["min-fraction-digits"],1,Pt),!C))return null;let A=null;return m["max-fraction-digits"]&&(A=r.parse(m["max-fraction-digits"],1,Pt),!A)?null:new rt(u,y,b,I,C,A)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class kt{constructor(e){this.type=Pt,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const u=r.parse(e[1],1);return u?u.type.kind!=="array"&&u.type.kind!=="string"&&u.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${li(u.type)} instead.`):new kt(u):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new Qi(`Expected value to be of type string or array, but found ${li(Xn(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(r=>{e.push(r.serialize())}),e}}const Ct={"==":V,"!=":X,">":ae,"<":Q,">=":Ne,"<=":Le,array:po,at:Zu,boolean:po,case:M,coalesce:el,collator:fa,format:No,image:ha,in:nl,"index-of":$u,interpolate:_o,"interpolate-hcl":_o,"interpolate-lab":_o,length:kt,let:qu,literal:fo,match:Hr,number:po,"number-format":rt,object:po,slice:p,step:Wa,string:po,"to-boolean":Cr,"to-color":Cr,"to-number":Cr,"to-string":Cr,var:Yr,within:$a};function Qt(n,[e,r,u,m]){e=e.evaluate(n),r=r.evaluate(n),u=u.evaluate(n);const y=m?m.evaluate(n):1,b=zl(e,r,u,y);if(b)throw new Qi(b);return new Ai(e/255*y,r/255*y,u/255*y,y)}function Ht(n,e){return n in e}function dn(n,e){const r=e[n];return r===void 0?null:r}function Rn(n){return{type:n}}Ar.register(Ct,{error:[{kind:"error"},[fn],(n,[e])=>{throw new Qi(e.evaluate(n))}],typeof:[fn,[kn],(n,[e])=>li(Xn(e.evaluate(n)))],"to-rgba":[fr(Pt,4),[Ji],(n,[e])=>e.evaluate(n).toArray()],rgb:[Ji,[Pt,Pt,Pt],Qt],rgba:[Ji,[Pt,Pt,Pt,Pt],Qt],has:{type:In,overloads:[[[fn],(n,[e])=>Ht(e.evaluate(n),n.properties())],[[fn,ho],(n,[e,r])=>Ht(e.evaluate(n),r.evaluate(n))]]},get:{type:kn,overloads:[[[fn],(n,[e])=>dn(e.evaluate(n),n.properties())],[[fn,ho],(n,[e,r])=>dn(e.evaluate(n),r.evaluate(n))]]},"feature-state":[kn,[fn],(n,[e])=>dn(e.evaluate(n),n.featureState||{})],properties:[ho,[],n=>n.properties()],"geometry-type":[fn,[],n=>n.geometryType()],id:[kn,[],n=>n.id()],zoom:[Pt,[],n=>n.globals.zoom],pitch:[Pt,[],n=>n.globals.pitch||0],"distance-from-center":[Pt,[],n=>n.distanceFromCenter()],"heatmap-density":[Pt,[],n=>n.globals.heatmapDensity||0],"line-progress":[Pt,[],n=>n.globals.lineProgress||0],"sky-radial-progress":[Pt,[],n=>n.globals.skyRadialProgress||0],accumulated:[kn,[],n=>n.globals.accumulated===void 0?null:n.globals.accumulated],"+":[Pt,Rn(Pt),(n,e)=>{let r=0;for(const u of e)r+=u.evaluate(n);return r}],"*":[Pt,Rn(Pt),(n,e)=>{let r=1;for(const u of e)r*=u.evaluate(n);return r}],"-":{type:Pt,overloads:[[[Pt,Pt],(n,[e,r])=>e.evaluate(n)-r.evaluate(n)],[[Pt],(n,[e])=>-e.evaluate(n)]]},"/":[Pt,[Pt,Pt],(n,[e,r])=>e.evaluate(n)/r.evaluate(n)],"%":[Pt,[Pt,Pt],(n,[e,r])=>e.evaluate(n)%r.evaluate(n)],ln2:[Pt,[],()=>Math.LN2],pi:[Pt,[],()=>Math.PI],e:[Pt,[],()=>Math.E],"^":[Pt,[Pt,Pt],(n,[e,r])=>Math.pow(e.evaluate(n),r.evaluate(n))],sqrt:[Pt,[Pt],(n,[e])=>Math.sqrt(e.evaluate(n))],log10:[Pt,[Pt],(n,[e])=>Math.log(e.evaluate(n))/Math.LN10],ln:[Pt,[Pt],(n,[e])=>Math.log(e.evaluate(n))],log2:[Pt,[Pt],(n,[e])=>Math.log(e.evaluate(n))/Math.LN2],sin:[Pt,[Pt],(n,[e])=>Math.sin(e.evaluate(n))],cos:[Pt,[Pt],(n,[e])=>Math.cos(e.evaluate(n))],tan:[Pt,[Pt],(n,[e])=>Math.tan(e.evaluate(n))],asin:[Pt,[Pt],(n,[e])=>Math.asin(e.evaluate(n))],acos:[Pt,[Pt],(n,[e])=>Math.acos(e.evaluate(n))],atan:[Pt,[Pt],(n,[e])=>Math.atan(e.evaluate(n))],min:[Pt,Rn(Pt),(n,e)=>Math.min(...e.map(r=>r.evaluate(n)))],max:[Pt,Rn(Pt),(n,e)=>Math.max(...e.map(r=>r.evaluate(n)))],abs:[Pt,[Pt],(n,[e])=>Math.abs(e.evaluate(n))],round:[Pt,[Pt],(n,[e])=>{const r=e.evaluate(n);return r<0?-Math.round(-r):Math.round(r)}],floor:[Pt,[Pt],(n,[e])=>Math.floor(e.evaluate(n))],ceil:[Pt,[Pt],(n,[e])=>Math.ceil(e.evaluate(n))],"filter-==":[In,[fn,kn],(n,[e,r])=>n.properties()[e.value]===r.value],"filter-id-==":[In,[kn],(n,[e])=>n.id()===e.value],"filter-type-==":[In,[fn],(n,[e])=>n.geometryType()===e.value],"filter-<":[In,[fn,kn],(n,[e,r])=>{const u=n.properties()[e.value],m=r.value;return typeof u==typeof m&&u{const r=n.id(),u=e.value;return typeof r==typeof u&&r":[In,[fn,kn],(n,[e,r])=>{const u=n.properties()[e.value],m=r.value;return typeof u==typeof m&&u>m}],"filter-id->":[In,[kn],(n,[e])=>{const r=n.id(),u=e.value;return typeof r==typeof u&&r>u}],"filter-<=":[In,[fn,kn],(n,[e,r])=>{const u=n.properties()[e.value],m=r.value;return typeof u==typeof m&&u<=m}],"filter-id-<=":[In,[kn],(n,[e])=>{const r=n.id(),u=e.value;return typeof r==typeof u&&r<=u}],"filter->=":[In,[fn,kn],(n,[e,r])=>{const u=n.properties()[e.value],m=r.value;return typeof u==typeof m&&u>=m}],"filter-id->=":[In,[kn],(n,[e])=>{const r=n.id(),u=e.value;return typeof r==typeof u&&r>=u}],"filter-has":[In,[kn],(n,[e])=>e.value in n.properties()],"filter-has-id":[In,[],n=>n.id()!==null&&n.id()!==void 0],"filter-type-in":[In,[fr(fn)],(n,[e])=>e.value.indexOf(n.geometryType())>=0],"filter-id-in":[In,[fr(kn)],(n,[e])=>e.value.indexOf(n.id())>=0],"filter-in-small":[In,[fn,fr(kn)],(n,[e,r])=>r.value.indexOf(n.properties()[e.value])>=0],"filter-in-large":[In,[fn,fr(kn)],(n,[e,r])=>function(u,m,y,b){for(;y<=b;){const I=y+b>>1;if(m[I]===u)return!0;m[I]>u?b=I-1:y=I+1}return!1}(n.properties()[e.value],r.value,0,r.value.length-1)],all:{type:In,overloads:[[[In,In],(n,[e,r])=>e.evaluate(n)&&r.evaluate(n)],[Rn(In),(n,e)=>{for(const r of e)if(!r.evaluate(n))return!1;return!0}]]},any:{type:In,overloads:[[[In,In],(n,[e,r])=>e.evaluate(n)||r.evaluate(n)],[Rn(In),(n,e)=>{for(const r of e)if(r.evaluate(n))return!0;return!1}]]},"!":[In,[In],(n,[e])=>!e.evaluate(n)],"is-supported-script":[In,[fn],(n,[e])=>{const r=n.globals&&n.globals.isSupportedScript;return!r||r(e.evaluate(n))}],upcase:[fn,[fn],(n,[e])=>e.evaluate(n).toUpperCase()],downcase:[fn,[fn],(n,[e])=>e.evaluate(n).toLowerCase()],concat:[fn,Rn(kn),(n,e)=>e.map(r=>ds(r.evaluate(n))).join("")],"resolved-locale":[fn,[Vr],(n,[e])=>e.evaluate(n).resolvedLocale()]});var ui=Ct;function lr(n){return{result:"success",value:n}}function Vi(n){return{result:"error",value:n}}function dr(n){return n["property-type"]==="data-driven"}function Jr(n){return!!n.expression&&n.expression.parameters.indexOf("zoom")>-1}function So(n){return!!n.expression&&n.expression.interpolated}function Dn(n){return n instanceof Number?"number":n instanceof String?"string":n instanceof Boolean?"boolean":Array.isArray(n)?"array":n===null?"null":typeof n}function Vo(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function ys(n){return n}function va(n,e){const r=e.type==="color",u=n.stops&&typeof n.stops[0][0]=="object",m=u||!(u||n.property!==void 0),y=n.type||(So(e)?"exponential":"interval");if(r&&((n=kr({},n)).stops&&(n.stops=n.stops.map(A=>[A[0],Ai.parse(A[1])])),n.default=Ai.parse(n.default?n.default:e.default)),n.colorSpace&&n.colorSpace!=="rgb"&&!ql[n.colorSpace])throw new Error(`Unknown color space: ${n.colorSpace}`);let b,I,C;if(y==="exponential")b=xs;else if(y==="interval")b=js;else if(y==="categorical"){b=rl,I=Object.create(null);for(const A of n.stops)I[A[0]]=A[1];C=typeof n.stops[0][0]}else{if(y!=="identity")throw new Error(`Unknown function type "${y}"`);b=pd}if(u){const A={},O=[];for(let $=0;$$[0]),evaluate:({zoom:$},W)=>xs({stops:B,base:n.base},e,$).evaluate($,W)}}if(m){const A=y==="exponential"?{name:"exponential",base:n.base!==void 0?n.base:1}:null;return{kind:"camera",interpolationType:A,interpolationFactor:_o.interpolationFactor.bind(void 0,A),zoomStops:n.stops.map(O=>O[0]),evaluate:({zoom:O})=>b(n,e,O,I,C)}}return{kind:"source",evaluate(A,O){const B=O&&O.properties?O.properties[n.property]:void 0;return B===void 0?vs(n.default,e.default):b(n,e,B,I,C)}}}function vs(n,e,r){return n!==void 0?n:e!==void 0?e:r!==void 0?r:void 0}function rl(n,e,r,u,m){return vs(typeof r===m?u[r]:void 0,n.default,e.default)}function js(n,e,r){if(Dn(r)!=="number")return vs(n.default,e.default);const u=n.stops.length;if(u===1||r<=n.stops[0][0])return n.stops[0][1];if(r>=n.stops[u-1][0])return n.stops[u-1][1];const m=Xa(n.stops.map(y=>y[0]),r);return n.stops[m][1]}function xs(n,e,r){const u=n.base!==void 0?n.base:1;if(Dn(r)!=="number")return vs(n.default,e.default);const m=n.stops.length;if(m===1||r<=n.stops[0][0])return n.stops[0][1];if(r>=n.stops[m-1][0])return n.stops[m-1][1];const y=Xa(n.stops.map(O=>O[0]),r),b=function(O,B,j,$){const W=$-j,K=O-j;return W===0?0:B===1?K/W:(Math.pow(B,K)-1)/(Math.pow(B,W)-1)}(r,u,n.stops[y][0],n.stops[y+1][0]),I=n.stops[y][1],C=n.stops[y+1][1];let A=gs[e.type]||ys;if(n.colorSpace&&n.colorSpace!=="rgb"){const O=ql[n.colorSpace];A=(B,j)=>O.reverse(O.interpolate(O.forward(B),O.forward(j),b))}return typeof I.evaluate=="function"?{evaluate(...O){const B=I.evaluate.apply(void 0,O),j=C.evaluate.apply(void 0,O);if(B!==void 0&&j!==void 0)return A(B,j,b)}}:A(I,C,b)}function pd(n,e,r){return e.type==="color"?r=Ai.parse(r):e.type==="formatted"?r=sr.fromString(r.toString()):e.type==="resolvedImage"?r=Wr.fromString(r.toString()):Dn(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0),vs(r,n.default,e.default)}class Xu{constructor(e,r){this.expression=e,this._warningHistory={},this._evaluator=new Ol,this._defaultValue=r?function(u){return u.type==="color"&&(Vo(u.default)||Array.isArray(u.default))?new Ai(0,0,0,0):u.type==="color"?Ai.parse(u.default)||null:u.default===void 0?null:u.default}(r):null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,u,m,y,b,I,C){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=u,this._evaluator.canonical=m||null,this._evaluator.availableImages=y||null,this._evaluator.formattedSection=b,this._evaluator.featureTileCoord=I||null,this._evaluator.featureDistanceData=C||null,this.expression.evaluate(this._evaluator)}evaluate(e,r,u,m,y,b,I,C){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=u||null,this._evaluator.canonical=m||null,this._evaluator.availableImages=y||null,this._evaluator.formattedSection=b||null,this._evaluator.featureTileCoord=I||null,this._evaluator.featureDistanceData=C||null;try{const A=this.expression.evaluate(this._evaluator);if(A==null||typeof A=="number"&&A!=A)return this._defaultValue;if(this._enumValues&&!(A in this._enumValues))throw new Qi(`Expected value to be one of ${Object.keys(this._enumValues).map(O=>JSON.stringify(O)).join(", ")}, but found ${JSON.stringify(A)} instead.`);return A}catch(A){return this._warningHistory[A.message]||(this._warningHistory[A.message]=!0,typeof console<"u"&&console.warn(A.message)),this._defaultValue}}}function ol(n){return Array.isArray(n)&&n.length>0&&typeof n[0]=="string"&&n[0]in ui}function sl(n,e){const r=new br(ui,[],e?function(m){const y={color:Ji,string:fn,number:Pt,enum:fn,boolean:In,formatted:la,resolvedImage:Ho};return m.type==="array"?fr(y[m.value]||kn,m.length):y[m.type]}(e):void 0),u=r.parse(n,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return u?lr(new Xu(u,e)):Vi(r.errors)}class lh{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!Io(r.expression)}evaluateWithoutErrorHandling(e,r,u,m,y,b){return this._styleExpression.evaluateWithoutErrorHandling(e,r,u,m,y,b)}evaluate(e,r,u,m,y,b){return this._styleExpression.evaluate(e,r,u,m,y,b)}}class $l{constructor(e,r,u,m){this.kind=e,this.zoomStops=u,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!Io(r.expression),this.interpolationType=m}evaluateWithoutErrorHandling(e,r,u,m,y,b){return this._styleExpression.evaluateWithoutErrorHandling(e,r,u,m,y,b)}evaluate(e,r,u,m,y,b){return this._styleExpression.evaluate(e,r,u,m,y,b)}interpolationFactor(e,r,u){return this.interpolationType?_o.interpolationFactor(this.interpolationType,e,r,u):0}}function Xl(n,e){if((n=sl(n,e)).result==="error")return n;const r=n.value.expression,u=Jo(r);if(!u&&!dr(e))return Vi([new Eo("","data expressions not supported")]);const m=Fo(r,["zoom","pitch","distance-from-center"]);if(!m&&!Jr(e))return Vi([new Eo("","zoom expressions not supported")]);const y=Yu(r);return y||m?y instanceof Eo?Vi([y]):y instanceof _o&&!So(e)?Vi([new Eo("",'"interpolate" expressions cannot be used with this property')]):lr(y?new $l(u?"camera":"composite",n.value,y.labels,y instanceof _o?y.interpolation:void 0):new lh(u?"constant":"source",n.value)):Vi([new Eo("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Wu{constructor(e,r){this._parameters=e,this._specification=r,kr(this,va(this._parameters,this._specification))}static deserialize(e){return new Wu(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Yu(n){let e=null;if(n instanceof qu)e=Yu(n.result);else if(n instanceof el){for(const r of n.args)if(e=Yu(r),e)break}else(n instanceof Wa||n instanceof _o)&&n.input instanceof Ar&&n.input.name==="zoom"&&(e=n);return e instanceof Eo||n.eachChild(r=>{const u=Yu(r);u instanceof Eo?e=u:!e&&u?e=new Eo("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&u&&e!==u&&(e=new Eo("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}class Ot{constructor(e,r,u,m){this.message=(e?`${e}: `:"")+u,m&&(this.identifier=m),r!=null&&r.__line__&&(this.line=r.__line__)}}function Uo(n){const e=n.key,r=n.value,u=n.valueSpec||{},m=n.objectElementValidators||{},y=n.style,b=n.styleSpec;let I=[];const C=Dn(r);if(C!=="object")return[new Ot(e,r,`object expected, ${C} found`)];for(const A in r){const O=A.split(".")[0];let B;m[O]?B=m[O]:u[O]?B=Rr:m["*"]?B=m["*"]:u["*"]&&(B=Rr),B?I=I.concat(B({key:(e&&`${e}.`)+A,value:r[A],valueSpec:u[O]||u["*"],style:y,styleSpec:b,object:r,objectKey:A},r)):I.push(new Ot(e,r[A],`unknown property "${A}"`))}for(const A in u)m[A]||u[A].required&&u[A].default===void 0&&r[A]===void 0&&I.push(new Ot(e,r,`missing required property "${A}"`));return I}function md(n){const e=n.value,r=n.valueSpec,u=n.style,m=n.styleSpec,y=n.key,b=n.arrayElementValidator||Rr;if(Dn(e)!=="array")return[new Ot(y,e,`array expected, ${Dn(e)} found`)];if(r.length&&e.length!==r.length)return[new Ot(y,e,`array length ${r.length} expected, length ${e.length} found`)];if(r["min-length"]&&e.lengthy)return[new Ot(e,r,`${r} is greater than the maximum value ${y}`)]}return[]}function Yl(n){const e=n.valueSpec,r=Ti(n.value.type);let u,m,y,b={};const I=r!=="categorical"&&n.value.property===void 0,C=!I,A=Dn(n.value.stops)==="array"&&Dn(n.value.stops[0])==="array"&&Dn(n.value.stops[0][0])==="object",O=Uo({key:n.key,value:n.value,valueSpec:n.styleSpec.function,style:n.style,styleSpec:n.styleSpec,objectElementValidators:{stops:function($){if(r==="identity")return[new Ot($.key,$.value,'identity function may not have a "stops" property')];let W=[];const K=$.value;return W=W.concat(md({key:$.key,value:K,valueSpec:$.valueSpec,style:$.style,styleSpec:$.styleSpec,arrayElementValidator:B})),Dn(K)==="array"&&K.length===0&&W.push(new Ot($.key,K,"array must have at least one stop")),W},default:function($){return Rr({key:$.key,value:$.value,valueSpec:e,style:$.style,styleSpec:$.styleSpec})}}});return r==="identity"&&I&&O.push(new Ot(n.key,n.value,'missing required property "property"')),r==="identity"||n.value.stops||O.push(new Ot(n.key,n.value,'missing required property "stops"')),r==="exponential"&&n.valueSpec.expression&&!So(n.valueSpec)&&O.push(new Ot(n.key,n.value,"exponential functions not supported")),n.styleSpec.$version>=8&&(C&&!dr(n.valueSpec)?O.push(new Ot(n.key,n.value,"property functions not supported")):I&&!Jr(n.valueSpec)&&O.push(new Ot(n.key,n.value,"zoom functions not supported"))),r!=="categorical"&&!A||n.value.property!==void 0||O.push(new Ot(n.key,n.value,'"property" property is required')),O;function B($){let W=[];const K=$.value,re=$.key;if(Dn(K)!=="array")return[new Ot(re,K,`array expected, ${Dn(K)} found`)];if(K.length!==2)return[new Ot(re,K,`array length 2 expected, length ${K.length} found`)];if(A){if(Dn(K[0])!=="object")return[new Ot(re,K,`object expected, ${Dn(K[0])} found`)];if(K[0].zoom===void 0)return[new Ot(re,K,"object stop key must have zoom")];if(K[0].value===void 0)return[new Ot(re,K,"object stop key must have value")];const de=Ti(K[0].zoom);if(typeof de!="number")return[new Ot(re,K[0].zoom,"stop zoom values must be numbers")];if(y&&y>de)return[new Ot(re,K[0].zoom,"stop zoom values must appear in ascending order")];de!==y&&(y=de,m=void 0,b={}),W=W.concat(Uo({key:`${re}[0]`,value:K[0],valueSpec:{zoom:{}},style:$.style,styleSpec:$.styleSpec,objectElementValidators:{zoom:Wl,value:j}}))}else W=W.concat(j({key:`${re}[0]`,value:K[0],valueSpec:{},style:$.style,styleSpec:$.styleSpec},K));return ol(Ki(K[1]))?W.concat([new Ot(`${re}[1]`,K[1],"expressions are not allowed in function stops.")]):W.concat(Rr({key:`${re}[1]`,value:K[1],valueSpec:e,style:$.style,styleSpec:$.styleSpec}))}function j($,W){const K=Dn($.value),re=Ti($.value),de=$.value!==null?$.value:W;if(u){if(K!==u)return[new Ot($.key,de,`${K} stop domain type must match previous stop domain type ${u}`)]}else u=K;if(K!=="number"&&K!=="string"&&K!=="boolean"&&typeof re!="number"&&typeof re!="string"&&typeof re!="boolean")return[new Ot($.key,de,"stop domain value must be a number, string, or boolean")];if(K!=="number"&&r!=="categorical"){let Te=`number expected, ${K} found`;return dr(e)&&r===void 0&&(Te+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ot($.key,de,Te)]}return r!=="categorical"||K!=="number"||typeof re=="number"&&isFinite(re)&&Math.floor(re)===re?r!=="categorical"&&K==="number"&&typeof re=="number"&&typeof m=="number"&&m!==void 0&&renew Ot(`${n.key}${u.key}`,n.value,u.message));const r=e.value.expression||e.value._styleExpression.expression;if(n.expressionContext==="property"&&n.propertyKey==="text-font"&&!r.outputDefined())return[new Ot(n.key,n.value,`Invalid data expression for "${n.propertyKey}". Output values must be contained as literals within the expression.`)];if(n.expressionContext==="property"&&n.propertyType==="layout"&&!Io(r))return[new Ot(n.key,n.value,'"feature-state" data expressions are not supported with layout properties.')];if(n.expressionContext==="filter")return Hl(r,n);if(n.expressionContext&&n.expressionContext.indexOf("cluster")===0){if(!Fo(r,["zoom","feature-state"]))return[new Ot(n.key,n.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(n.expressionContext==="cluster-initial"&&!Jo(r))return[new Ot(n.key,n.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Hl(n,e){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const m of e.valueSpec.expression.parameters)r.delete(m);if(r.size===0)return[];const u=[];return n instanceof Ar&&r.has(n.name)?[new Ot(e.key,e.value,`["${n.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(n.eachChild(m=>{u.push(...Hl(m,e))}),u)}function Hu(n){const e=n.key,r=n.value,u=n.valueSpec,m=[];return Array.isArray(u.values)?u.values.indexOf(Ti(r))===-1&&m.push(new Ot(e,r,`expected one of [${u.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(u.values).indexOf(Ti(r))===-1&&m.push(new Ot(e,r,`expected one of [${Object.keys(u.values).join(", ")}], ${JSON.stringify(r)} found`)),m}function uh(n){if(n===!0||n===!1)return!0;if(!Array.isArray(n)||n.length===0)return!1;switch(n[0]){case"has":return n.length>=2&&n[1]!=="$id"&&n[1]!=="$type";case"in":return n.length>=3&&(typeof n[1]!="string"||Array.isArray(n[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return n.length!==3||Array.isArray(n[1])||Array.isArray(n[2]);case"any":case"all":for(const e of n.slice(1))if(!uh(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function Ku(n,e="fill"){if(n==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};uh(n)||(n=ll(n));const r=n;let u=!0;try{u=function(A){if(!al(A))return A;let O=Ki(A);return Ju(O),O=gd(O),O}(r)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(r,null,2)} `)}const m=Qe[`filter_${e}`],y=sl(u,m);let b=null;if(y.result==="error")throw new Error(y.value.map(A=>`${A.key}: ${A.message}`).join(", "));b=(A,O,B)=>y.value.evaluate(A,O,{},B);let I=null,C=null;if(u!==r){const A=sl(r,m);if(A.result==="error")throw new Error(A.value.map(O=>`${O.key}: ${O.message}`).join(", "));I=(O,B,j,$,W)=>A.value.evaluate(O,B,{},j,void 0,void 0,$,W),C=!Jo(A.value.expression)}return{filter:b,dynamicFilter:I||void 0,needGeometry:_d(u),needFeature:!!C}}function gd(n){if(!Array.isArray(n))return n;const e=function(r){if(ch.has(r[0])){for(let u=1;ugd(r))}function Ju(n){let e=!1;const r=[];if(n[0]==="case"){for(let u=1;u",">=","<","<=","to-boolean"]);function Dm(n,e){return ne?1:0}function _d(n){if(!Array.isArray(n))return!1;if(n[0]==="within")return!0;for(let e=1;e"||e==="<="||e===">="?hh(n[1],n[2],e):e==="any"?(r=n.slice(1),["any"].concat(r.map(ll))):e==="all"?["all"].concat(n.slice(1).map(ll)):e==="none"?["all"].concat(n.slice(1).map(ll).map(Qu)):e==="in"?fh(n[1],n.slice(2)):e==="!in"?Qu(fh(n[1],n.slice(2))):e==="has"?dh(n[1]):e==="!has"?Qu(dh(n[1])):e!=="within"||n;var r}function hh(n,e,r){switch(n){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,n,e]}}function fh(n,e){if(e.length===0)return!1;switch(n){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(r=>typeof r!=typeof e[0])?["filter-in-large",n,["literal",e.sort(Dm)]]:["filter-in-small",n,["literal",e]]}}function dh(n){switch(n){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",n]}}function Qu(n){return["!",n]}function Kl(n){return uh(Ki(n.value))?pr(kr({},n,{expressionContext:"filter",valueSpec:n.styleSpec[`filter_${n.layerType||"fill"}`]})):Jl(n)}function Jl(n){const e=n.value,r=n.key;if(Dn(e)!=="array")return[new Ot(r,e,`array expected, ${Dn(e)} found`)];const u=n.styleSpec;let m,y=[];if(e.length<1)return[new Ot(r,e,"filter array must have at least 1 element")];switch(y=y.concat(Hu({key:`${r}[0]`,value:e[0],valueSpec:u.filter_operator,style:n.style,styleSpec:n.styleSpec})),Ti(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Ti(e[1])==="$type"&&y.push(new Ot(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&y.push(new Ot(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(m=Dn(e[1]),m!=="string"&&y.push(new Ot(`${r}[1]`,e[1],`string expected, ${m} found`)));for(let b=2;b{A in r&&e.push(new Ot(u,r[A],`"${A}" is prohibited for ref layers`))}),m.layers.forEach(A=>{Ti(A.id)===I&&(C=A)}),C?C.ref?e.push(new Ot(u,r.ref,"ref cannot reference another ref layer")):b=Ti(C.type):typeof I=="string"&&e.push(new Ot(u,r.ref,`ref layer "${I}" not found`))}else if(b!=="background"&&b!=="sky")if(r.source){const C=m.sources&&m.sources[r.source],A=C&&Ti(C.type);C?A==="vector"&&b==="raster"?e.push(new Ot(u,r.source,`layer "${r.id}" requires a raster source`)):A==="raster"&&b!=="raster"?e.push(new Ot(u,r.source,`layer "${r.id}" requires a vector source`)):A!=="vector"||r["source-layer"]?A==="raster-dem"&&b!=="hillshade"?e.push(new Ot(u,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):b!=="line"||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||A==="geojson"&&C.lineMetrics||e.push(new Ot(u,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ot(u,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Ot(u,r.source,`source "${r.source}" not found`))}else e.push(new Ot(u,r,'missing required property "source"'));return e=e.concat(Uo({key:u,value:r,valueSpec:y.layer,style:n.style,styleSpec:n.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Rr({key:`${u}.type`,value:r.type,valueSpec:y.layer.type,style:n.style,styleSpec:n.styleSpec,object:r,objectKey:"type"}),filter:C=>Kl(kr({layerType:b},C)),layout:C=>Uo({layer:r,key:C.key,value:C.value,valueSpec:{},style:C.style,styleSpec:C.styleSpec,objectElementValidators:{"*":A=>mh(kr({layerType:b},A))}}),paint:C=>Uo({layer:r,key:C.key,value:C.value,valueSpec:{},style:C.style,styleSpec:C.styleSpec,objectElementValidators:{"*":A=>yd(kr({layerType:b},A))}})}})),e}function Gs(n){const e=n.value,r=n.key,u=Dn(e);return u!=="string"?[new Ot(r,e,`string expected, ${u} found`)]:[]}const xd={promoteId:function({key:n,value:e}){if(Dn(e)==="string")return Gs({key:n,value:e});{const r=[];for(const u in e)r.push(...Gs({key:`${n}.${u}`,value:e[u]}));return r}}};function bd(n){const e=n.value,r=n.key,u=n.styleSpec,m=n.style;if(!e.type)return[new Ot(r,e,'"type" is required')];const y=Ti(e.type);let b;switch(y){case"vector":case"raster":case"raster-dem":return b=Uo({key:r,value:e,valueSpec:u[`source_${y.replace("-","_")}`],style:n.style,styleSpec:u,objectElementValidators:xd}),b;case"geojson":if(b=Uo({key:r,value:e,valueSpec:u.source_geojson,style:m,styleSpec:u,objectElementValidators:xd}),e.cluster)for(const I in e.clusterProperties){const[C,A]=e.clusterProperties[I],O=typeof C=="string"?[C,["accumulated"],["get",I]]:C;b.push(...pr({key:`${r}.${I}.map`,value:A,expressionContext:"cluster-map"})),b.push(...pr({key:`${r}.${I}.reduce`,value:O,expressionContext:"cluster-reduce"}))}return b;case"video":return Uo({key:r,value:e,valueSpec:u.source_video,style:m,styleSpec:u});case"image":return Uo({key:r,value:e,valueSpec:u.source_image,style:m,styleSpec:u});case"canvas":return[new Ot(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Hu({key:`${r}.type`,value:e.type,valueSpec:{values:zm(u)},style:m,styleSpec:u})}}function zm(n){return n.source.reduce((e,r)=>{const u=n[r];return u.type.type==="enum"&&(e=e.concat(Object.keys(u.type.values))),e},[])}function wd(n){const e=n.value,r=n.styleSpec,u=r.light,m=n.style;let y=[];const b=Dn(e);if(e===void 0)return y;if(b!=="object")return y=y.concat([new Ot("light",e,`object expected, ${b} found`)]),y;for(const I in e){const C=I.match(/^(.*)-transition$/);y=y.concat(C&&u[C[1]]&&u[C[1]].transition?Rr({key:I,value:e[I],valueSpec:r.transition,style:m,styleSpec:r}):u[I]?Rr({key:I,value:e[I],valueSpec:u[I],style:m,styleSpec:r}):[new Ot(I,e[I],`unknown property "${I}"`)])}return y}function gh(n){const e=n.value,r=n.key,u=n.style,m=n.styleSpec,y=m.terrain;let b=[];const I=Dn(e);if(e===void 0)return b;if(I!=="object")return b=b.concat([new Ot("terrain",e,`object expected, ${I} found`)]),b;for(const C in e){const A=C.match(/^(.*)-transition$/);b=b.concat(A&&y[A[1]]&&y[A[1]].transition?Rr({key:C,value:e[C],valueSpec:m.transition,style:u,styleSpec:m}):y[C]?Rr({key:C,value:e[C],valueSpec:y[C],style:u,styleSpec:m}):[new Ot(C,e[C],`unknown property "${C}"`)])}if(e.source){const C=u.sources&&u.sources[e.source],A=C&&Ti(C.type);C?A!=="raster-dem"&&b.push(new Ot(r,e.source,`terrain cannot be used with a source of type ${String(A)}, it only be used with a "raster-dem" source type`)):b.push(new Ot(r,e.source,`source "${e.source}" not found`))}else b.push(new Ot(r,e,'terrain is missing required property "source"'));return b}function Ed(n){const e=n.value,r=n.style,u=n.styleSpec,m=u.fog;let y=[];const b=Dn(e);if(e===void 0)return y;if(b!=="object")return y=y.concat([new Ot("fog",e,`object expected, ${b} found`)]),y;for(const I in e){const C=I.match(/^(.*)-transition$/);y=y.concat(C&&m[C[1]]&&m[C[1]].transition?Rr({key:I,value:e[I],valueSpec:u.transition,style:r,styleSpec:u}):m[I]?Rr({key:I,value:e[I],valueSpec:m[I],style:r,styleSpec:u}):[new Ot(I,e[I],`unknown property "${I}"`)])}return y}const Td={"*":()=>[],array:md,boolean:function(n){const e=n.value,r=n.key,u=Dn(e);return u!=="boolean"?[new Ot(r,e,`boolean expected, ${u} found`)]:[]},number:Wl,color:function(n){const e=n.key,r=n.value,u=Dn(r);return u!=="string"?[new Ot(e,r,`color expected, ${u} found`)]:mi(r)===null?[new Ot(e,r,`color expected, "${r}" found`)]:[]},enum:Hu,filter:Kl,function:Yl,layer:vd,object:Uo,source:bd,light:wd,terrain:gh,fog:Ed,string:Gs,formatted:function(n){return Gs(n).length===0?[]:pr(n)},resolvedImage:function(n){return Gs(n).length===0?[]:pr(n)},projection:function(n){const e=n.value,r=n.styleSpec,u=r.projection,m=n.style;let y=[];const b=Dn(e);if(b==="object")for(const I in e)y=y.concat(Rr({key:I,value:e[I],valueSpec:u[I],style:m,styleSpec:r}));else b!=="string"&&(y=y.concat([new Ot("projection",e,`object or string expected, ${b} found`)]));return y}};function Rr(n){const e=n.value,r=n.valueSpec,u=n.styleSpec;return r.expression&&Vo(Ti(e))?Yl(n):r.expression&&ol(Ki(e))?pr(n):r.type&&Td[r.type]?Td[r.type](n):Uo(kr({},n,{valueSpec:r.type?u[r.type]:r}))}function Om(n){const e=n.value,r=n.key,u=Gs(n);return u.length||(e.indexOf("{fontstack}")===-1&&u.push(new Ot(r,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&u.push(new Ot(r,e,'"glyphs" url must include a "{range}" token'))),u}function Id(n,e=Qe){return ko(Rr({key:"",value:n,valueSpec:e.$root,styleSpec:e,style:n,objectElementValidators:{glyphs:Om,"*":()=>[]}}))}const Nm=n=>ko(yd(n)),Bm=n=>ko(mh(n));function ko(n){return n.slice().sort((e,r)=>e.line&&r.line?e.line-r.line:0)}function Md(n,e){let r=!1;if(e&&e.length)for(const u of e)n.fire(new Fi(new Error(u.message))),r=!0;return r}var Fm=Qo,jo=3;function Qo(n,e,r){var u=this.cells=[];if(n instanceof ArrayBuffer){this.arrayBuffer=n;var m=new Int32Array(this.arrayBuffer);n=m[0],this.d=(e=m[1])+2*(r=m[2]);for(var y=0;y=O[$+0]&&u>=O[$+1])?(b[j]=!0,y.push(A[j])):b[j]=!1}}},Qo.prototype._forEachCell=function(n,e,r,u,m,y,b,I){for(var C=this._convertToCellCoord(n),A=this._convertToCellCoord(e),O=this._convertToCellCoord(r),B=this._convertToCellCoord(u),j=C;j<=O;j++)for(var $=A;$<=B;$++){var W=this.d*$+j;if((!I||I(this._convertFromCellCoord(j),this._convertFromCellCoord($),this._convertFromCellCoord(j+1),this._convertFromCellCoord($+1)))&&m.call(this,n,e,r,u,W,y,b,I))return}},Qo.prototype._convertFromCellCoord=function(n){return(n-this.padding)/this.scale},Qo.prototype._convertToCellCoord=function(n){return Math.max(0,Math.min(this.d-1,Math.floor(n*this.scale)+this.padding))},Qo.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var n=this.cells,e=jo+this.cells.length+1+1,r=0,u=0;u=0||(m[y]=ul(n[y],e)));n instanceof Error&&(m.message=n.message)}if(m.$name)throw new Error("$name property is reserved for worker serialization logic.");return u!=="Object"&&(m.$name=u),m}throw new Error("can't serialize object of type "+typeof n)}function ba(n){if(n==null||typeof n=="boolean"||typeof n=="number"||typeof n=="string"||n instanceof Boolean||n instanceof Number||n instanceof String||n instanceof Date||n instanceof RegExp||_h(n)||yh(n)||ArrayBuffer.isView(n)||n instanceof E.ImageData)return n;if(Array.isArray(n))return n.map(ba);if(typeof n=="object"){const e=n.$name||"Object",{klass:r}=ec[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(n);const u=Object.create(r.prototype);for(const m of Object.keys(n))m!=="$name"&&(u[m]=ba(n[m]));return u}throw new Error("can't deserialize object of type "+typeof n)}const zt={"Latin-1 Supplement":n=>n>=128&&n<=255,Arabic:n=>n>=1536&&n<=1791,"Arabic Supplement":n=>n>=1872&&n<=1919,"Arabic Extended-A":n=>n>=2208&&n<=2303,"Hangul Jamo":n=>n>=4352&&n<=4607,"Unified Canadian Aboriginal Syllabics":n=>n>=5120&&n<=5759,Khmer:n=>n>=6016&&n<=6143,"Unified Canadian Aboriginal Syllabics Extended":n=>n>=6320&&n<=6399,"General Punctuation":n=>n>=8192&&n<=8303,"Letterlike Symbols":n=>n>=8448&&n<=8527,"Number Forms":n=>n>=8528&&n<=8591,"Miscellaneous Technical":n=>n>=8960&&n<=9215,"Control Pictures":n=>n>=9216&&n<=9279,"Optical Character Recognition":n=>n>=9280&&n<=9311,"Enclosed Alphanumerics":n=>n>=9312&&n<=9471,"Geometric Shapes":n=>n>=9632&&n<=9727,"Miscellaneous Symbols":n=>n>=9728&&n<=9983,"Miscellaneous Symbols and Arrows":n=>n>=11008&&n<=11263,"CJK Radicals Supplement":n=>n>=11904&&n<=12031,"Kangxi Radicals":n=>n>=12032&&n<=12255,"Ideographic Description Characters":n=>n>=12272&&n<=12287,"CJK Symbols and Punctuation":n=>n>=12288&&n<=12351,Hiragana:n=>n>=12352&&n<=12447,Katakana:n=>n>=12448&&n<=12543,Bopomofo:n=>n>=12544&&n<=12591,"Hangul Compatibility Jamo":n=>n>=12592&&n<=12687,Kanbun:n=>n>=12688&&n<=12703,"Bopomofo Extended":n=>n>=12704&&n<=12735,"CJK Strokes":n=>n>=12736&&n<=12783,"Katakana Phonetic Extensions":n=>n>=12784&&n<=12799,"Enclosed CJK Letters and Months":n=>n>=12800&&n<=13055,"CJK Compatibility":n=>n>=13056&&n<=13311,"CJK Unified Ideographs Extension A":n=>n>=13312&&n<=19903,"Yijing Hexagram Symbols":n=>n>=19904&&n<=19967,"CJK Unified Ideographs":n=>n>=19968&&n<=40959,"Yi Syllables":n=>n>=40960&&n<=42127,"Yi Radicals":n=>n>=42128&&n<=42191,"Hangul Jamo Extended-A":n=>n>=43360&&n<=43391,"Hangul Syllables":n=>n>=44032&&n<=55215,"Hangul Jamo Extended-B":n=>n>=55216&&n<=55295,"Private Use Area":n=>n>=57344&&n<=63743,"CJK Compatibility Ideographs":n=>n>=63744&&n<=64255,"Arabic Presentation Forms-A":n=>n>=64336&&n<=65023,"Vertical Forms":n=>n>=65040&&n<=65055,"CJK Compatibility Forms":n=>n>=65072&&n<=65103,"Small Form Variants":n=>n>=65104&&n<=65135,"Arabic Presentation Forms-B":n=>n>=65136&&n<=65279,"Halfwidth and Fullwidth Forms":n=>n>=65280&&n<=65519};function vh(n){for(const e of n)if(xh(e.charCodeAt(0)))return!0;return!1}function Vm(n){for(const e of n)if(!Sd(e.charCodeAt(0)))return!1;return!0}function Sd(n){return!(zt.Arabic(n)||zt["Arabic Supplement"](n)||zt["Arabic Extended-A"](n)||zt["Arabic Presentation Forms-A"](n)||zt["Arabic Presentation Forms-B"](n))}function xh(n){return!(n!==746&&n!==747&&(n<4352||!(zt["Bopomofo Extended"](n)||zt.Bopomofo(n)||zt["CJK Compatibility Forms"](n)&&!(n>=65097&&n<=65103)||zt["CJK Compatibility Ideographs"](n)||zt["CJK Compatibility"](n)||zt["CJK Radicals Supplement"](n)||zt["CJK Strokes"](n)||!(!zt["CJK Symbols and Punctuation"](n)||n>=12296&&n<=12305||n>=12308&&n<=12319||n===12336)||zt["CJK Unified Ideographs Extension A"](n)||zt["CJK Unified Ideographs"](n)||zt["Enclosed CJK Letters and Months"](n)||zt["Hangul Compatibility Jamo"](n)||zt["Hangul Jamo Extended-A"](n)||zt["Hangul Jamo Extended-B"](n)||zt["Hangul Jamo"](n)||zt["Hangul Syllables"](n)||zt.Hiragana(n)||zt["Ideographic Description Characters"](n)||zt.Kanbun(n)||zt["Kangxi Radicals"](n)||zt["Katakana Phonetic Extensions"](n)||zt.Katakana(n)&&n!==12540||!(!zt["Halfwidth and Fullwidth Forms"](n)||n===65288||n===65289||n===65293||n>=65306&&n<=65310||n===65339||n===65341||n===65343||n>=65371&&n<=65503||n===65507||n>=65512&&n<=65519)||!(!zt["Small Form Variants"](n)||n>=65112&&n<=65118||n>=65123&&n<=65126)||zt["Unified Canadian Aboriginal Syllabics"](n)||zt["Unified Canadian Aboriginal Syllabics Extended"](n)||zt["Vertical Forms"](n)||zt["Yijing Hexagram Symbols"](n)||zt["Yi Syllables"](n)||zt["Yi Radicals"](n))))}function kd(n){return!(xh(n)||function(e){return!!(zt["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||zt["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||zt["Letterlike Symbols"](e)||zt["Number Forms"](e)||zt["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||zt["Control Pictures"](e)&&e!==9251||zt["Optical Character Recognition"](e)||zt["Enclosed Alphanumerics"](e)||zt["Geometric Shapes"](e)||zt["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||zt["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||zt["CJK Symbols and Punctuation"](e)||zt.Katakana(e)||zt["Private Use Area"](e)||zt["CJK Compatibility Forms"](e)||zt["Small Form Variants"](e)||zt["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(n))}function Cd(n){return n>=1424&&n<=2303||zt["Arabic Presentation Forms-A"](n)||zt["Arabic Presentation Forms-B"](n)}function Um(n,e){return!(!e&&Cd(n)||n>=2304&&n<=3583||n>=3840&&n<=4255||zt.Khmer(n))}function jm(n){for(const e of n)if(Cd(e.charCodeAt(0)))return!0;return!1}const bh="deferred",wh="loading",Eh="loaded";let cl=null,_="unavailable",o=null;const d=function(n){n&&typeof n=="string"&&n.indexOf("NetworkError")>-1&&(_="error"),cl&&cl(n)};function v(){T.fire(new cs("pluginStateChange",{pluginStatus:_,pluginURL:o}))}const T=new wo,S=function(){return _},D=function(){if(_!==bh||!o)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_=wh,v(),o&&zs({url:o},n=>{n?d(n):(_=Eh,v())})},z={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_===Eh||z.applyArabicShaping!=null,isLoading:()=>_===wh,setState(n){_=n.pluginStatus,o=n.pluginURL},isParsed:()=>z.applyArabicShaping!=null&&z.processBidirectionalText!=null&&z.processStyledBidirectionalText!=null,getPluginURL:()=>o};class N{constructor(e,r){this.zoom=e,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.transition=r.transition,this.pitch=r.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(e){return function(r,u){for(const m of r)if(!Um(m.charCodeAt(0),u))return!1;return!0}(e,z.isLoaded())}}class q{constructor(e,r){this.property=e,this.value=r,this.expression=function(u,m){if(Vo(u))return new Wu(u,m);if(ol(u)){const y=Xl(u,m);if(y.result==="error")throw new Error(y.value.map(b=>`${b.key}: ${b.message}`).join(", "));return y.value}{let y=u;return typeof u=="string"&&m.type==="color"&&(y=Ai.parse(u)),{kind:"constant",evaluate:()=>y}}}(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,u){return this.property.possiblyEvaluate(this,e,r,u)}}class G{constructor(e){this.property=e,this.value=new q(e,void 0)}transitioned(e,r){return new ie(this.property,this.value,r,Vt({},e.transition,this.transition),e.now)}untransitioned(){return new ie(this.property,this.value,null,{},0)}}class Y{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return Fn(this._values[e].value.value)}setValue(e,r){this._values.hasOwnProperty(e)||(this._values[e]=new G(this._values[e].property)),this._values[e].value=new q(this._values[e].property,r===null?void 0:Fn(r))}getTransition(e){return Fn(this._values[e].transition)}setTransition(e,r){this._values.hasOwnProperty(e)||(this._values[e]=new G(this._values[e].property)),this._values[e].transition=Fn(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const u=this.getValue(r);u!==void 0&&(e[r]=u);const m=this.getTransition(r);m!==void 0&&(e[`${r}-transition`]=m)}return e}transitioned(e,r){const u=new se(this._properties);for(const m of Object.keys(this._values))u._values[m]=this._values[m].transitioned(e,r._values[m]);return u}untransitioned(){const e=new se(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class ie{constructor(e,r,u,m,y){const b=m.delay||0,I=m.duration||0;y=y||0,this.property=e,this.value=r,this.begin=y+b,this.end=this.begin+I,e.specification.transition&&(m.delay||m.duration)&&(this.prior=u)}possiblyEvaluate(e,r,u){const m=e.now||0,y=this.value.possiblyEvaluate(e,r,u),b=this.prior;if(b){if(m>this.end)return this.prior=null,y;if(this.value.isDataDriven())return this.prior=null,y;if(mthis.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Oe(n,e=1){let r=0,u=0;return{members:n.map(m=>{const y=Re[m.type].BYTES_PER_ELEMENT,b=r=Xe(r,Math.max(e,y)),I=m.components||1;return u=Math.max(u,y),r+=y*I,{name:m.name,type:m.type,components:I,offset:b}}),size:Xe(r,Math.max(u,e)),alignment:e}}function Xe(n,e){return Math.ceil(n/e)*e}class pt extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const u=this.length;return this.resize(u+1),this.emplace(u,e,r)}emplace(e,r,u){const m=2*e;return this.int16[m+0]=r,this.int16[m+1]=u,e}}pt.prototype.bytesPerElement=4,Ft(pt,"StructArrayLayout2i4");class qe extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,u){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,u)}emplace(e,r,u,m){const y=3*e;return this.int16[y+0]=r,this.int16[y+1]=u,this.int16[y+2]=m,e}}qe.prototype.bytesPerElement=6,Ft(qe,"StructArrayLayout3i6");class ot extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,u,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,u,m)}emplace(e,r,u,m,y){const b=4*e;return this.int16[b+0]=r,this.int16[b+1]=u,this.int16[b+2]=m,this.int16[b+3]=y,e}}ot.prototype.bytesPerElement=8,Ft(ot,"StructArrayLayout4i8");class He extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y,b,I){const C=this.length;return this.resize(C+1),this.emplace(C,e,r,u,m,y,b,I)}emplace(e,r,u,m,y,b,I,C){const A=6*e,O=12*e,B=3*e;return this.int16[A+0]=r,this.int16[A+1]=u,this.uint8[O+4]=m,this.uint8[O+5]=y,this.uint8[O+6]=b,this.uint8[O+7]=I,this.float32[B+2]=C,e}}He.prototype.bytesPerElement=12,Ft(He,"StructArrayLayout2i4ub1f12");class dt extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,u,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,u,m)}emplace(e,r,u,m,y){const b=4*e;return this.float32[b+0]=r,this.float32[b+1]=u,this.float32[b+2]=m,this.float32[b+3]=y,e}}dt.prototype.bytesPerElement=16,Ft(dt,"StructArrayLayout4f16");class $e extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y){const b=this.length;return this.resize(b+1),this.emplace(b,e,r,u,m,y)}emplace(e,r,u,m,y,b){const I=6*e,C=3*e;return this.uint16[I+0]=r,this.uint16[I+1]=u,this.uint16[I+2]=m,this.uint16[I+3]=y,this.float32[C+2]=b,e}}$e.prototype.bytesPerElement=12,Ft($e,"StructArrayLayout4ui1f12");class it extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,u,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,u,m)}emplace(e,r,u,m,y){const b=4*e;return this.uint16[b+0]=r,this.uint16[b+1]=u,this.uint16[b+2]=m,this.uint16[b+3]=y,e}}it.prototype.bytesPerElement=8,Ft(it,"StructArrayLayout4ui8");class yt extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y,b){const I=this.length;return this.resize(I+1),this.emplace(I,e,r,u,m,y,b)}emplace(e,r,u,m,y,b,I){const C=6*e;return this.int16[C+0]=r,this.int16[C+1]=u,this.int16[C+2]=m,this.int16[C+3]=y,this.int16[C+4]=b,this.int16[C+5]=I,e}}yt.prototype.bytesPerElement=12,Ft(yt,"StructArrayLayout6i12");class ct extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y,b,I,C,A,O,B,j){const $=this.length;return this.resize($+1),this.emplace($,e,r,u,m,y,b,I,C,A,O,B,j)}emplace(e,r,u,m,y,b,I,C,A,O,B,j,$){const W=12*e;return this.int16[W+0]=r,this.int16[W+1]=u,this.int16[W+2]=m,this.int16[W+3]=y,this.uint16[W+4]=b,this.uint16[W+5]=I,this.uint16[W+6]=C,this.uint16[W+7]=A,this.int16[W+8]=O,this.int16[W+9]=B,this.int16[W+10]=j,this.int16[W+11]=$,e}}ct.prototype.bytesPerElement=24,Ft(ct,"StructArrayLayout4i4ui4i24");class bt extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y,b){const I=this.length;return this.resize(I+1),this.emplace(I,e,r,u,m,y,b)}emplace(e,r,u,m,y,b,I){const C=10*e,A=5*e;return this.int16[C+0]=r,this.int16[C+1]=u,this.int16[C+2]=m,this.float32[A+2]=y,this.float32[A+3]=b,this.float32[A+4]=I,e}}bt.prototype.bytesPerElement=20,Ft(bt,"StructArrayLayout3i3f20");class $t extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}$t.prototype.bytesPerElement=4,Ft($t,"StructArrayLayout1ul4");class un extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y,b,I,C,A,O,B,j,$){const W=this.length;return this.resize(W+1),this.emplace(W,e,r,u,m,y,b,I,C,A,O,B,j,$)}emplace(e,r,u,m,y,b,I,C,A,O,B,j,$,W){const K=20*e,re=10*e;return this.int16[K+0]=r,this.int16[K+1]=u,this.int16[K+2]=m,this.int16[K+3]=y,this.int16[K+4]=b,this.float32[re+3]=I,this.float32[re+4]=C,this.float32[re+5]=A,this.float32[re+6]=O,this.int16[K+14]=B,this.uint32[re+8]=j,this.uint16[K+18]=$,this.uint16[K+19]=W,e}}un.prototype.bytesPerElement=40,Ft(un,"StructArrayLayout5i4f1i1ul2ui40");class Ut extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y,b,I){const C=this.length;return this.resize(C+1),this.emplace(C,e,r,u,m,y,b,I)}emplace(e,r,u,m,y,b,I,C){const A=8*e;return this.int16[A+0]=r,this.int16[A+1]=u,this.int16[A+2]=m,this.int16[A+4]=y,this.int16[A+5]=b,this.int16[A+6]=I,this.int16[A+7]=C,e}}Ut.prototype.bytesPerElement=16,Ft(Ut,"StructArrayLayout3i2i2i16");class Kt extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y){const b=this.length;return this.resize(b+1),this.emplace(b,e,r,u,m,y)}emplace(e,r,u,m,y,b){const I=4*e,C=8*e;return this.float32[I+0]=r,this.float32[I+1]=u,this.float32[I+2]=m,this.int16[C+6]=y,this.int16[C+7]=b,e}}Kt.prototype.bytesPerElement=16,Ft(Kt,"StructArrayLayout2f1f2i16");class An extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,u,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,u,m)}emplace(e,r,u,m,y){const b=12*e,I=3*e;return this.uint8[b+0]=r,this.uint8[b+1]=u,this.float32[I+1]=m,this.float32[I+2]=y,e}}An.prototype.bytesPerElement=12,Ft(An,"StructArrayLayout2ub2f12");class Cn extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,u){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,u)}emplace(e,r,u,m){const y=3*e;return this.float32[y+0]=r,this.float32[y+1]=u,this.float32[y+2]=m,e}}Cn.prototype.bytesPerElement=12,Ft(Cn,"StructArrayLayout3f12");class qt extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,u){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,u)}emplace(e,r,u,m){const y=3*e;return this.uint16[y+0]=r,this.uint16[y+1]=u,this.uint16[y+2]=m,e}}qt.prototype.bytesPerElement=6,Ft(qt,"StructArrayLayout3ui6");class Yn extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y,b,I,C,A,O,B,j,$,W,K,re,de,Te,pe,Ee,Ce){const Se=this.length;return this.resize(Se+1),this.emplace(Se,e,r,u,m,y,b,I,C,A,O,B,j,$,W,K,re,de,Te,pe,Ee,Ce)}emplace(e,r,u,m,y,b,I,C,A,O,B,j,$,W,K,re,de,Te,pe,Ee,Ce,Se){const We=30*e,Ze=15*e,nt=60*e;return this.int16[We+0]=r,this.int16[We+1]=u,this.int16[We+2]=m,this.float32[Ze+2]=y,this.float32[Ze+3]=b,this.uint16[We+8]=I,this.uint16[We+9]=C,this.uint32[Ze+5]=A,this.uint32[Ze+6]=O,this.uint32[Ze+7]=B,this.uint16[We+16]=j,this.uint16[We+17]=$,this.uint16[We+18]=W,this.float32[Ze+10]=K,this.float32[Ze+11]=re,this.uint8[nt+48]=de,this.uint8[nt+49]=Te,this.uint8[nt+50]=pe,this.uint32[Ze+13]=Ee,this.int16[We+28]=Ce,this.uint8[nt+58]=Se,e}}Yn.prototype.bytesPerElement=60,Ft(Yn,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class ei extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y,b,I,C,A,O,B,j,$,W,K,re,de,Te,pe,Ee,Ce,Se,We,Ze,nt,mt,Ke,st,at,ht){const Et=this.length;return this.resize(Et+1),this.emplace(Et,e,r,u,m,y,b,I,C,A,O,B,j,$,W,K,re,de,Te,pe,Ee,Ce,Se,We,Ze,nt,mt,Ke,st,at,ht)}emplace(e,r,u,m,y,b,I,C,A,O,B,j,$,W,K,re,de,Te,pe,Ee,Ce,Se,We,Ze,nt,mt,Ke,st,at,ht,Et){const et=38*e,Rt=19*e;return this.int16[et+0]=r,this.int16[et+1]=u,this.int16[et+2]=m,this.float32[Rt+2]=y,this.float32[Rt+3]=b,this.int16[et+8]=I,this.int16[et+9]=C,this.int16[et+10]=A,this.int16[et+11]=O,this.int16[et+12]=B,this.int16[et+13]=j,this.uint16[et+14]=$,this.uint16[et+15]=W,this.uint16[et+16]=K,this.uint16[et+17]=re,this.uint16[et+18]=de,this.uint16[et+19]=Te,this.uint16[et+20]=pe,this.uint16[et+21]=Ee,this.uint16[et+22]=Ce,this.uint16[et+23]=Se,this.uint16[et+24]=We,this.uint16[et+25]=Ze,this.uint16[et+26]=nt,this.uint16[et+27]=mt,this.uint16[et+28]=Ke,this.uint32[Rt+15]=st,this.float32[Rt+16]=at,this.float32[Rt+17]=ht,this.float32[Rt+18]=Et,e}}ei.prototype.bytesPerElement=76,Ft(ei,"StructArrayLayout3i2f6i15ui1ul3f76");class ti extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}ti.prototype.bytesPerElement=4,Ft(ti,"StructArrayLayout1f4");class ni extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,u,m,y){const b=this.length;return this.resize(b+1),this.emplace(b,e,r,u,m,y)}emplace(e,r,u,m,y,b){const I=5*e;return this.float32[I+0]=r,this.float32[I+1]=u,this.float32[I+2]=m,this.float32[I+3]=y,this.float32[I+4]=b,e}}ni.prototype.bytesPerElement=20,Ft(ni,"StructArrayLayout5f20");class Dr extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,u,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,u,m)}emplace(e,r,u,m,y){const b=6*e;return this.uint32[3*e+0]=r,this.uint16[b+2]=u,this.uint16[b+3]=m,this.uint16[b+4]=y,e}}Dr.prototype.bytesPerElement=12,Ft(Dr,"StructArrayLayout1ul3ui12");class mr extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const u=this.length;return this.resize(u+1),this.emplace(u,e,r)}emplace(e,r,u){const m=2*e;return this.uint16[m+0]=r,this.uint16[m+1]=u,e}}mr.prototype.bytesPerElement=4,Ft(mr,"StructArrayLayout2ui4");class Co extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}Co.prototype.bytesPerElement=2,Ft(Co,"StructArrayLayout1ui2");class es extends Be{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const u=this.length;return this.resize(u+1),this.emplace(u,e,r)}emplace(e,r,u){const m=2*e;return this.float32[m+0]=r,this.float32[m+1]=u,e}}es.prototype.bytesPerElement=8,Ft(es,"StructArrayLayout2f8");class wi extends Pe{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}wi.prototype.size=40;class ii extends un{get(e){return new wi(this,e)}}Ft(ii,"CollisionBoxArray");class Gn extends Pe{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}Gn.prototype.size=60;class Ui extends Yn{get(e){return new Gn(this,e)}}Ft(Ui,"PlacedSymbolArray");class jr extends Pe{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(e){this._structArray.uint32[this._pos4+15]=e}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}jr.prototype.size=76;class vi extends ei{get(e){return new jr(this,e)}}Ft(vi,"SymbolInstanceArray");class Qr extends ti{getoffsetX(e){return this.float32[1*e+0]}}Ft(Qr,"GlyphOffsetArray");class tc extends pt{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Ft(tc,"SymbolLineVertexArray");class wa extends Pe{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}wa.prototype.size=12;class Ql extends Dr{get(e){return new wa(this,e)}}Ft(Ql,"FeatureIndexArray");class bs extends mr{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Ft(bs,"FillExtrusionCentroidArray");const qs=Oe([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ea=Oe([{name:"a_dash",components:4,type:"Uint16"}]);var nc={exports:{}},eu={exports:{}};eu.exports=function(n,e){var r,u,m,y,b,I,C,A;for(u=n.length-(r=3&n.length),m=e,b=3432918353,I=461845907,A=0;A>>16)*b&65535)<<16)&4294967295)<<15|C>>>17))*I+(((C>>>16)*I&65535)<<16)&4294967295)<<13|m>>>19))+((5*(m>>>16)&65535)<<16)&4294967295))+((58964+(y>>>16)&65535)<<16);switch(C=0,r){case 3:C^=(255&n.charCodeAt(A+2))<<16;case 2:C^=(255&n.charCodeAt(A+1))<<8;case 1:m^=C=(65535&(C=(C=(65535&(C^=255&n.charCodeAt(A)))*b+(((C>>>16)*b&65535)<<16)&4294967295)<<15|C>>>17))*I+(((C>>>16)*I&65535)<<16)&4294967295}return m^=n.length,m=2246822507*(65535&(m^=m>>>16))+((2246822507*(m>>>16)&65535)<<16)&4294967295,m=3266489909*(65535&(m^=m>>>13))+((3266489909*(m>>>16)&65535)<<16)&4294967295,(m^=m>>>16)>>>0};var Th=eu.exports,Uv={exports:{}};Uv.exports=function(n,e){for(var r,u=n.length,m=e^u,y=0;u>=4;)r=1540483477*(65535&(r=255&n.charCodeAt(y)|(255&n.charCodeAt(++y))<<8|(255&n.charCodeAt(++y))<<16|(255&n.charCodeAt(++y))<<24))+((1540483477*(r>>>16)&65535)<<16),m=1540483477*(65535&m)+((1540483477*(m>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),u-=4,++y;switch(u){case 3:m^=(255&n.charCodeAt(y+2))<<16;case 2:m^=(255&n.charCodeAt(y+1))<<8;case 1:m=1540483477*(65535&(m^=255&n.charCodeAt(y)))+((1540483477*(m>>>16)&65535)<<16)}return m=1540483477*(65535&(m^=m>>>13))+((1540483477*(m>>>16)&65535)<<16),(m^=m>>>15)>>>0};var jv=Th,LS=Uv.exports;nc.exports=jv,nc.exports.murmur3=jv,nc.exports.murmur2=LS;var Gm=ce(nc.exports);class Ad{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,u,m){this.ids.push(Gv(e)),this.positions.push(r,u,m)}getPositions(e){const r=Gv(e);let u=0,m=this.ids.length-1;for(;u>1;this.ids[b]>=r?m=b:u=b+1}const y=[];for(;this.ids[u]===r;)y.push({index:this.positions[3*u],start:this.positions[3*u+1],end:this.positions[3*u+2]}),u++;return y}static serialize(e,r){const u=new Float64Array(e.ids),m=new Uint32Array(e.positions);return qm(u,m,0,u.length-1),r&&r.push(u.buffer,m.buffer),{ids:u,positions:m}}static deserialize(e){const r=new Ad;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function Gv(n){const e=+n;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:Gm(String(n))}function qm(n,e,r,u){for(;r>1];let y=r-1,b=u+1;for(;;){do y++;while(n[y]m);if(y>=b)break;Pd(n,y,b),Pd(e,3*y,3*b),Pd(e,3*y+1,3*b+1),Pd(e,3*y+2,3*b+2)}b-r`u_${m}`),this.type=u}setUniform(e,r,u,m,y){r.set(e,y,m.constantOr(this.value))}getBinding(e,r){return this.type==="color"?new Zv(e):new Ld(e)}}class ic{constructor(e,r){this.uniformNames=r.map(u=>`u_${u}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,r,u,m,y){const b=y==="u_pattern"||y==="u_dash"?this.pattern:y==="u_pixel_ratio"?this.pixelRatio:null;b&&r.set(e,y,b)}getBinding(e,r){return r==="u_pattern"||r==="u_dash"?new qv(e):new Ld(e)}}class Ia{constructor(e,r,u,m){this.expression=e,this.type=u,this.maxValue=0,this.paintVertexAttributes=r.map(y=>({name:`a_${y}`,type:"Float32",components:u==="color"?2:1,offset:0})),this.paintVertexArray=new m}populatePaintArray(e,r,u,m,y,b){const I=this.paintVertexArray.length,C=this.expression.evaluate(new N(0),r,{},y,m,b);this.paintVertexArray.resize(e),this._setPaintValue(I,e,C)}updatePaintArray(e,r,u,m,y){const b=this.expression.evaluate({zoom:0},u,m,void 0,y);this._setPaintValue(e,r,b)}_setPaintValue(e,r,u){if(this.type==="color"){const m=Zm(u);for(let y=e;y`u_${I}_t`),this.type=u,this.useIntegerZoom=m,this.zoom=y,this.maxValue=0,this.paintVertexAttributes=r.map(I=>({name:`a_${I}`,type:"Float32",components:u==="color"?4:2,offset:0})),this.paintVertexArray=new b}populatePaintArray(e,r,u,m,y,b){const I=this.expression.evaluate(new N(this.zoom),r,{},y,m,b),C=this.expression.evaluate(new N(this.zoom+1),r,{},y,m,b),A=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(A,e,I,C)}updatePaintArray(e,r,u,m,y){const b=this.expression.evaluate({zoom:this.zoom},u,m,void 0,y),I=this.expression.evaluate({zoom:this.zoom+1},u,m,void 0,y);this._setPaintValue(e,r,b,I)}_setPaintValue(e,r,u,m){if(this.type==="color"){const y=Zm(u),b=Zm(m);for(let I=e;I!0){this.binders={},this._buffers=[];const m=[];for(const y in e.paint._values){if(!u(y))continue;const b=e.paint.get(y);if(!(b instanceof le&&dr(b.property.specification)))continue;const I=NS(y,e.type),C=b.value,A=b.property.specification.type,O=!!b.property.useIntegerZoom,B=y==="line-dasharray"||y.endsWith("pattern"),j=y==="line-dasharray"&&e.layout.get("line-cap").value.kind!=="constant";if(C.kind!=="constant"||j)if(C.kind==="source"||j||B){const $=$v(y,A,"source");this.binders[y]=B?new hl(C,I,A,$,e.id):new Ia(C,I,A,$),m.push(`/a_${y}`)}else{const $=$v(y,A,"composite");this.binders[y]=new ws(C,I,A,O,r,$),m.push(`/z_${y}`)}else this.binders[y]=B?new ic(C.value,I):new Ih(C.value,I,A),m.push(`/u_${y}`)}this.cacheKey=m.sort().join("")}getMaxValue(e){const r=this.binders[e];return r instanceof Ia||r instanceof ws?r.maxValue:0}populatePaintArrays(e,r,u,m,y,b){for(const I in this.binders){const C=this.binders[I];(C instanceof Ia||C instanceof ws||C instanceof hl)&&C.populatePaintArray(e,r,u,m,y,b)}}setConstantPatternPositions(e){for(const r in this.binders){const u=this.binders[r];u instanceof ic&&u.setConstantPatternPositions(e)}}updatePaintArrays(e,r,u,m,y,b){let I=!1;for(const C in e){const A=r.getPositions(C);for(const O of A){const B=u.feature(O.index);for(const j in this.binders){const $=this.binders[j];if(($ instanceof Ia||$ instanceof ws||$ instanceof hl)&&$.expression.isStateDependent===!0){const W=m.paint.get(j);$.expression=W.value,$.updatePaintArray(O.start,O.end,B,e[C],y,b),I=!0}}}}return I}defines(){const e=[];for(const r in this.binders){const u=this.binders[r];(u instanceof Ih||u instanceof ic)&&e.push(...u.uniformNames.map(m=>`#define HAS_UNIFORM_${m}`))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const u=this.binders[r];if(u instanceof Ia||u instanceof ws||u instanceof hl)for(let m=0;m!0){this.programConfigurations={};for(const m of e)this.programConfigurations[m.id]=new fl(m,r,u);this.needsUpload=!1,this._featureMap=new Ad,this._bufferOffset=0}populatePaintArrays(e,r,u,m,y,b,I){for(const C in this.programConfigurations)this.programConfigurations[C].populatePaintArrays(e,r,m,y,b,I);r.id!==void 0&&this._featureMap.add(r.id,u,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,u,m,y){for(const b of u)this.needsUpload=this.programConfigurations[b.id].updatePaintArrays(e,this._featureMap,r,b,m,y)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const OS={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function NS(n,e){return OS[n]||[n.replace(`${e}-`,"").replace(/-/g,"_")]}const BS={"line-pattern":{source:$e,composite:$e},"fill-pattern":{source:$e,composite:$e},"fill-extrusion-pattern":{source:$e,composite:$e},"line-dasharray":{source:it,composite:it}},FS={color:{source:es,composite:dt},number:{source:ti,composite:es}};function $v(n,e,r){const u=BS[n];return u&&u[r]||FS[e][r]}Ft(Ih,"ConstantBinder"),Ft(ic,"PatternConstantBinder"),Ft(Ia,"SourceExpressionBinder"),Ft(hl,"PatternCompositeBinder"),Ft(ws,"CompositeExpressionBinder"),Ft(fl,"ProgramConfiguration",{omit:["_buffers"]}),Ft(tu,"ProgramConfigurationSet");const Xv="-transition";class Es extends wo{constructor(e,r){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&e.type!=="sky"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),r.layout&&(this._unevaluatedLayout=new ue(r.layout)),r.paint)){this._transitionablePaint=new Y(r.paint);for(const u in e.paint)this.setPaintProperty(u,e.paint[u],{validate:!1});for(const u in e.layout)this.setLayoutProperty(u,e.layout[u],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new fe(r.paint)}}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,u={}){r!=null&&this._validate(Bm,`layers.${this.id}.layout.${e}`,e,r,u)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return bn(e,Xv)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,u={}){if(r!=null&&this._validate(Nm,`layers.${this.id}.paint.${e}`,e,r,u))return!1;if(bn(e,Xv))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const m=this._transitionablePaint._values[e],y=m.value.isDataDriven(),b=m.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const I=this._transitionablePaint._values[e].value,C=I.isDataDriven(),A=bn(e,"pattern")||e==="line-dasharray";return C||y||A||this._handleOverridablePaintPropertyUpdate(e,b,I)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,r,u){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}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),Me(e,(r,u)=>!(r===void 0||u==="layout"&&!Object.keys(r).length||u==="paint"&&!Object.keys(r).length))}_validate(e,r,u,m,y={}){return(!y||y.validate!==!1)&&Md(this,e.call(Id,{key:r,layerType:this.type,objectKey:u,value:m,styleSpec:Qe,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof le&&dr(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Ku(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const VS=Oe([{name:"a_pos",components:2,type:"Int16"}],4),US=Oe([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class ji{constructor(e=[]){this.segments=e}prepareSegment(e,r,u,m){let y=this.segments[this.segments.length-1];return e>ji.MAX_VERTEX_ARRAY_LENGTH&&yn(`Max vertices per segment is ${ji.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!y||y.vertexLength+e>ji.MAX_VERTEX_ARRAY_LENGTH||y.sortKey!==m)&&(y={vertexOffset:r.length,primitiveOffset:u.length,vertexLength:0,primitiveLength:0},m!==void 0&&(y.sortKey=m),this.segments.push(y)),y}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,u,m){return new ji([{vertexOffset:e,primitiveOffset:r,vertexLength:u,primitiveLength:m,vaos:{},sortKey:0}])}}ji.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ft(ji,"SegmentVector");var Wt=8192;class dl{constructor(e,r){e&&(r?this.setSouthWest(e).setNorthEast(r):e.length===4?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 ri?new ri(e.lng,e.lat):ri.convert(e),this}setSouthWest(e){return this._sw=e instanceof ri?new ri(e.lng,e.lat):ri.convert(e),this}extend(e){const r=this._sw,u=this._ne;let m,y;if(e instanceof ri)m=e,y=e;else{if(!(e instanceof dl))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(dl.convert(e)):this.extend(ri.convert(e)):typeof e=="object"&&e!==null&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(ri.convert(e)):this;if(m=e._sw,y=e._ne,!m||!y)return this}return r||u?(r.lng=Math.min(m.lng,r.lng),r.lat=Math.min(m.lat,r.lat),u.lng=Math.max(y.lng,u.lng),u.lat=Math.max(y.lat,u.lat)):(this._sw=new ri(m.lng,m.lat),this._ne=new ri(y.lng,y.lat)),this}getCenter(){return new ri((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 ri(this.getWest(),this.getNorth())}getSouthEast(){return new ri(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:r,lat:u}=ri.convert(e);let m=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(m=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=u&&u<=this._ne.lat&&m}static convert(e){return!e||e instanceof dl?e:new dl(e)}}var Rd=1e-6,Ao=typeof Float32Array<"u"?Float32Array:Array;function Wv(){var n=new Ao(9);return Ao!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function Yv(n,e,r){var u=e[0],m=e[1],y=e[2],b=e[3],I=e[4],C=e[5],A=e[6],O=e[7],B=e[8],j=r[0],$=r[1],W=r[2],K=r[3],re=r[4],de=r[5],Te=r[6],pe=r[7],Ee=r[8];return n[0]=j*u+$*b+W*A,n[1]=j*m+$*I+W*O,n[2]=j*y+$*C+W*B,n[3]=K*u+re*b+de*A,n[4]=K*m+re*I+de*O,n[5]=K*y+re*C+de*B,n[6]=Te*u+pe*b+Ee*A,n[7]=Te*m+pe*I+Ee*O,n[8]=Te*y+pe*C+Ee*B,n}function Ts(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function $m(n,e){var r=e[0],u=e[1],m=e[2],y=e[3],b=e[4],I=e[5],C=e[6],A=e[7],O=e[8],B=e[9],j=e[10],$=e[11],W=e[12],K=e[13],re=e[14],de=e[15],Te=r*I-u*b,pe=r*C-m*b,Ee=r*A-y*b,Ce=u*C-m*I,Se=u*A-y*I,We=m*A-y*C,Ze=O*K-B*W,nt=O*re-j*W,mt=O*de-$*W,Ke=B*re-j*K,st=B*de-$*K,at=j*de-$*re,ht=Te*at-pe*st+Ee*Ke+Ce*mt-Se*nt+We*Ze;return ht?(n[0]=(I*at-C*st+A*Ke)*(ht=1/ht),n[1]=(m*st-u*at-y*Ke)*ht,n[2]=(K*We-re*Se+de*Ce)*ht,n[3]=(j*Se-B*We-$*Ce)*ht,n[4]=(C*mt-b*at-A*nt)*ht,n[5]=(r*at-m*mt+y*nt)*ht,n[6]=(re*Ee-W*We-de*pe)*ht,n[7]=(O*We-j*Ee+$*pe)*ht,n[8]=(b*st-I*mt+A*Ze)*ht,n[9]=(u*mt-r*st-y*Ze)*ht,n[10]=(W*Se-K*Ee+de*Te)*ht,n[11]=(B*Ee-O*Se-$*Te)*ht,n[12]=(I*nt-b*Ke-C*Ze)*ht,n[13]=(r*Ke-u*nt+m*Ze)*ht,n[14]=(K*pe-W*Ce-re*Te)*ht,n[15]=(O*Ce-B*pe+j*Te)*ht,n):null}function nu(n,e,r){var u=e[0],m=e[1],y=e[2],b=e[3],I=e[4],C=e[5],A=e[6],O=e[7],B=e[8],j=e[9],$=e[10],W=e[11],K=e[12],re=e[13],de=e[14],Te=e[15],pe=r[0],Ee=r[1],Ce=r[2],Se=r[3];return n[0]=pe*u+Ee*I+Ce*B+Se*K,n[1]=pe*m+Ee*C+Ce*j+Se*re,n[2]=pe*y+Ee*A+Ce*$+Se*de,n[3]=pe*b+Ee*O+Ce*W+Se*Te,n[4]=(pe=r[4])*u+(Ee=r[5])*I+(Ce=r[6])*B+(Se=r[7])*K,n[5]=pe*m+Ee*C+Ce*j+Se*re,n[6]=pe*y+Ee*A+Ce*$+Se*de,n[7]=pe*b+Ee*O+Ce*W+Se*Te,n[8]=(pe=r[8])*u+(Ee=r[9])*I+(Ce=r[10])*B+(Se=r[11])*K,n[9]=pe*m+Ee*C+Ce*j+Se*re,n[10]=pe*y+Ee*A+Ce*$+Se*de,n[11]=pe*b+Ee*O+Ce*W+Se*Te,n[12]=(pe=r[12])*u+(Ee=r[13])*I+(Ce=r[14])*B+(Se=r[15])*K,n[13]=pe*m+Ee*C+Ce*j+Se*re,n[14]=pe*y+Ee*A+Ce*$+Se*de,n[15]=pe*b+Ee*O+Ce*W+Se*Te,n}function Mh(n,e,r){var u,m,y,b,I,C,A,O,B,j,$,W,K=r[0],re=r[1],de=r[2];return e===n?(n[12]=e[0]*K+e[4]*re+e[8]*de+e[12],n[13]=e[1]*K+e[5]*re+e[9]*de+e[13],n[14]=e[2]*K+e[6]*re+e[10]*de+e[14],n[15]=e[3]*K+e[7]*re+e[11]*de+e[15]):(m=e[1],y=e[2],b=e[3],I=e[4],C=e[5],A=e[6],O=e[7],B=e[8],j=e[9],$=e[10],W=e[11],n[0]=u=e[0],n[1]=m,n[2]=y,n[3]=b,n[4]=I,n[5]=C,n[6]=A,n[7]=O,n[8]=B,n[9]=j,n[10]=$,n[11]=W,n[12]=u*K+I*re+B*de+e[12],n[13]=m*K+C*re+j*de+e[13],n[14]=y*K+A*re+$*de+e[14],n[15]=b*K+O*re+W*de+e[15]),n}function iu(n,e,r){var u=r[0],m=r[1],y=r[2];return n[0]=e[0]*u,n[1]=e[1]*u,n[2]=e[2]*u,n[3]=e[3]*u,n[4]=e[4]*m,n[5]=e[5]*m,n[6]=e[6]*m,n[7]=e[7]*m,n[8]=e[8]*y,n[9]=e[9]*y,n[10]=e[10]*y,n[11]=e[11]*y,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function Xm(n,e,r){var u=Math.sin(r),m=Math.cos(r),y=e[4],b=e[5],I=e[6],C=e[7],A=e[8],O=e[9],B=e[10],j=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=y*m+A*u,n[5]=b*m+O*u,n[6]=I*m+B*u,n[7]=C*m+j*u,n[8]=A*m-y*u,n[9]=O*m-b*u,n[10]=B*m-I*u,n[11]=j*m-C*u,n}function Dd(n,e,r){var u=Math.sin(r),m=Math.cos(r),y=e[0],b=e[1],I=e[2],C=e[3],A=e[8],O=e[9],B=e[10],j=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=y*m-A*u,n[1]=b*m-O*u,n[2]=I*m-B*u,n[3]=C*m-j*u,n[8]=y*u+A*m,n[9]=b*u+O*m,n[10]=I*u+B*m,n[11]=C*u+j*m,n}function Hv(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Kv(n,e,r){var u,m,y,b=r[0],I=r[1],C=r[2],A=Math.hypot(b,I,C);return A0&&(y=1/Math.sqrt(y)),n[0]=e[0]*y,n[1]=e[1]*y,n[2]=e[2]*y,n}function ts(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function Hm(n,e,r){var u=e[0],m=e[1],y=e[2],b=r[0],I=r[1],C=r[2];return n[0]=m*C-y*I,n[1]=y*b-u*C,n[2]=u*I-m*b,n}function zi(n,e,r){var u=e[0],m=e[1],y=e[2],b=r[3]*u+r[7]*m+r[11]*y+r[15];return n[0]=(r[0]*u+r[4]*m+r[8]*y+r[12])/(b=b||1),n[1]=(r[1]*u+r[5]*m+r[9]*y+r[13])/b,n[2]=(r[2]*u+r[6]*m+r[10]*y+r[14])/b,n}function ex(n,e,r){var u=r[0],m=r[1],y=r[2],b=e[0],I=e[1],C=e[2],A=m*C-y*I,O=y*b-u*C,B=u*I-m*b,j=m*B-y*O,$=y*A-u*B,W=u*O-m*A,K=2*r[3];return O*=K,B*=K,$*=2,W*=2,n[0]=b+(A*=K)+(j*=2),n[1]=I+O+$,n[2]=C+B+W,n}var Ph,Is=Ym,GS=Qv,qS=Sh;function tx(n,e,r){return n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n[3]=e[3]*r,n}function nx(n,e){var r=e[0],u=e[1],m=e[2],y=e[3],b=r*r+u*u+m*m+y*y;return b>0&&(b=1/Math.sqrt(b)),n[0]=r*b,n[1]=u*b,n[2]=m*b,n[3]=y*b,n}function ru(n,e,r){var u=e[0],m=e[1],y=e[2],b=e[3];return n[0]=r[0]*u+r[4]*m+r[8]*y+r[12]*b,n[1]=r[1]*u+r[5]*m+r[9]*y+r[13]*b,n[2]=r[2]*u+r[6]*m+r[10]*y+r[14]*b,n[3]=r[3]*u+r[7]*m+r[11]*y+r[15]*b,n}function ix(){var n=new Ao(4);return Ao!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function rx(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function ox(n,e,r){r*=.5;var u=e[0],m=e[1],y=e[2],b=e[3],I=Math.sin(r),C=Math.cos(r);return n[0]=u*C+b*I,n[1]=m*C+y*I,n[2]=y*C-m*I,n[3]=b*C-u*I,n}function sx(n,e,r){r*=.5;var u=e[0],m=e[1],y=e[2],b=e[3],I=Math.sin(r),C=Math.cos(r);return n[0]=u*C-y*I,n[1]=m*C+b*I,n[2]=y*C+u*I,n[3]=b*C-m*I,n}Wm(),Ph=new Ao(4),Ao!=Float32Array&&(Ph[0]=0,Ph[1]=0,Ph[2]=0,Ph[3]=0);var ZS=nx;Wm(),rc(1,0,0),rc(0,1,0),ix(),ix(),Wv();const $S=Oe([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:ax}=$S,lx=Oe([{name:"a_pos_3",components:3,type:"Int16"}]);var Lh=Oe([{name:"a_pos",type:"Int16",components:2}]);class Km{constructor(e,r){this.pos=e,this.dir=r}intersectsPlane(e,r,u){const m=ts(r,this.dir);if(Math.abs(m)<1e-6)return!1;const y=((e[0]-this.pos[0])*r[0]+(e[1]-this.pos[1])*r[1]+(e[2]-this.pos[2])*r[2])/m;return u[0]=this.pos[0]+this.dir[0]*y,u[1]=this.pos[1]+this.dir[1]*y,u[2]=this.pos[2]+this.dir[2]*y,!0}closestPointOnSphere(e,r,u){if(function($,W){var K=$[0],re=$[1],de=$[2],Te=W[0],pe=W[1],Ee=W[2];return Math.abs(K-Te)<=Rd*Math.max(1,Math.abs(K),Math.abs(Te))&&Math.abs(re-pe)<=Rd*Math.max(1,Math.abs(re),Math.abs(pe))&&Math.abs(de-Ee)<=Rd*Math.max(1,Math.abs(de),Math.abs(Ee))}(this.pos,e)||r===0)return u[0]=u[1]=u[2]=0,!1;const[m,y,b]=this.dir,I=this.pos[0]-e[0],C=this.pos[1]-e[1],A=this.pos[2]-e[2],O=m*m+y*y+b*b,B=2*(I*m+C*y+A*b),j=B*B-4*O*(I*I+C*C+A*A-r*r);if(j<0){const $=Math.max(-B/2,0),W=I+m*$,K=C+y*$,re=A+b*$,de=Math.hypot(W,K,re);return u[0]=W*r/de,u[1]=K*r/de,u[2]=re*r/de,!1}{const $=(-B-Math.sqrt(j))/(2*O);if($<0){const W=Math.hypot(I,C,A);return u[0]=I*r/W,u[1]=C*r/W,u[2]=A*r/W,!1}return u[0]=I+m*$,u[1]=C+y*$,u[2]=A+b*$,!0}}}class Jm{constructor(e,r,u,m,y){this.TL=e,this.TR=r,this.BR=u,this.BL=m,this.horizon=y}static fromInvProjectionMatrix(e,r,u){const m=[-1,1,1],y=[1,1,1],b=[1,-1,1],I=[-1,-1,1],C=zi(m,m,e),A=zi(y,y,e),O=zi(b,b,e),B=zi(I,I,e);return new Jm(C,A,O,B,r/u)}}class Qm{constructor(e,r){this.points=e,this.planes=r}static fromInvProjectionMatrix(e,r,u,m){const y=Math.pow(2,u),b=[[-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(C=>{const A=ru([],C,e),O=1/A[3]/r*y;return function(B,j,$){return B[0]=j[0]*$[0],B[1]=j[1]*$[1],B[2]=j[2]*$[2],B[3]=j[3]*$[3],B}(A,A,[O,O,m?1/A[3]:O,O])}),I=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(C=>{const A=eo([],Hm([],Is([],b[C[0]],b[C[1]]),Is([],b[C[2]],b[C[1]]))),O=-ts(A,b[C[1]]);return A.concat(O)});return new Qm(b,I)}}class to{static fromPoints(e){const r=[1/0,1/0,1/0],u=[-1/0,-1/0,-1/0];for(const m of e)kh(r,r,m),Ch(u,u,m);return new to(r,u)}static applyTransform(e,r){const u=e.getCorners();for(let m=0;m=0;if(b===0)return 0;b!==r.length&&(u=!1)}if(u)return 2;for(let m=0;m<3;m++){let y=Number.MAX_VALUE,b=-Number.MAX_VALUE;for(let I=0;Ithis.max[m]-this.min[m])return 0}return 1}}const eg=5,ux=6,Zs=Wt/Math.PI/2,XS=16383,ou=64,Rh=[ou,32,16],ns=-Zs,is=Zs,WS=[new to([ns,ns,ns],[is,is,is]),new to([ns,ns,ns],[0,0,is]),new to([0,ns,ns],[is,0,is]),new to([ns,0,ns],[0,is,is]),new to([0,0,ns],[is,is,is])];function zd(n){return n*Zs/Oh}function cx(n,e,r,u=!0){const m=Go([],n._camera.position,n.worldSize),y=[e,r,1,1];ru(y,y,n.pixelMatrixInverse),tx(y,y,1/y[3]);const b=eo([],Is([],y,m)),I=n.globeMatrix,C=[I[12],I[13],I[14]],A=Is([],C,m),O=Sh(A),B=eo([],A),j=n.worldSize/(2*Math.PI),$=ts(B,b),W=Math.asin(j/O);if(W1?null:function(u,m,y,b){const I=Math.sin(y);return u*(Math.sin((1-b)*y)/I)+m*(Math.sin(b*y)/I)}(n.a[e],n.b[e],n.angle,Mt(r,0,1))+n.center[e]}function $s(n){if(n.z<=1)return WS[n.z+2*n.y+n.x];const e=ng(Od(n));return to.fromPoints(e)}function su(n,e,r){return Go(n,n,1-r),Ah(n,n,e,r)}function hx(n,e){const r=ac(e.zoom);if(r===0)return $s(n);const u=Od(n),m=ng(u),y=Xs(u.getWest())*e.worldSize,b=Xs(u.getEast())*e.worldSize,I=Ws(u.getNorth())*e.worldSize,C=Ws(u.getSouth())*e.worldSize,A=[y,I,0],O=[b,I,0],B=[y,C,0],j=[b,C,0],$=$m([],e.globeMatrix);return zi(A,A,$),zi(O,O,$),zi(B,B,$),zi(j,j,$),m[0]=su(m[0],B,r),m[1]=su(m[1],j,r),m[2]=su(m[2],O,r),m[3]=su(m[3],A,r),to.fromPoints(m)}function fx(n,e,r){for(const u of n)zi(u,u,e),Go(u,u,r)}function HS(n,e,r){const u=e/n.worldSize,m=n.globeMatrix;if(r.z<=1){const Ze=$s(r).getCorners();return fx(Ze,m,u),to.fromPoints(Ze)}const y=Od(r),b=ng(y);fx(b,m,u);const I=Number.MAX_VALUE,C=[-I,-I,-I],A=[I,I,I];if(y.contains(n.center)){for(const mt of b)kh(A,A,mt),Ch(C,C,mt);C[2]=0;const Ze=n.point,nt=[Ze.x*u,Ze.y*u,0];return kh(A,A,nt),Ch(C,C,nt),new to(A,C)}const O=[m[12]*u,m[13]*u,m[14]*u],B=y.getCenter(),j=Mt(n.center.lat,-Or,Or),$=Mt(B.lat,-Or,Or),W=Xs(n.center.lng),K=Ws(j);let re=W-Xs(B.lng);const de=K-Ws($);re>.5?re-=1:re<-.5&&(re+=1);let Te=0;Math.abs(re)>Math.abs(de)?Te=re>=0?1:3:(Te=de>=0?0:2,Ah(O,O,[m[4]*u,m[5]*u,m[6]*u],-Math.sin(Je(de>=0?y.getSouth():y.getNorth()))*Zs));const pe=b[Te],Ee=b[(Te+1)%4],Ce=new YS(pe,Ee,O),Se=[tg(Ce,0)||pe[0],tg(Ce,1)||pe[1],tg(Ce,2)||pe[2]],We=ac(n.zoom);if(We>0){const Ze=function({x:mt,y:Ke,z:st},at,ht,Et,et){const Rt=1/(1<.5?Xt=-1:mn<-.5&&(Xt=1),jt=((jt+Xt)*at-(Et*=at))*ht+Et,Dt=((Dt+Xt)*at-Et)*ht+Et,pn=(pn*at-(et*=at))*ht+et,Tt=(Tt*at-et)*ht+et,[[jt,Tt,0],[Dt,Tt,0],[Dt,pn,0],[jt,pn,0]]}(r,e,n._pixelsPerMercatorPixel,W,K);for(let mt=0;mtMath.PI/2*1.01}const gx=Je(85),KS=Math.cos(gx),JS=Math.sin(gx),Oh=63710088e-1,_x=2*Math.PI*Oh;class pl{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new pl(tt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,u=this.lat*r,m=e.lat*r,y=Math.sin(u)*Math.sin(m)+Math.cos(u)*Math.cos(m)*Math.cos((e.lng-this.lng)*r);return Oh*Math.acos(Math.min(y,1))}toBounds(e=0){const r=360*e/40075017,u=r/Math.cos(Math.PI/180*this.lat);return new dl(new pl(this.lng-u,this.lat-r),new pl(this.lng+u,this.lat+r))}toEcef(e){const r=zd(e);return sc(this.lat,this.lng,Zs+r)}static convert(e){if(e instanceof pl)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new pl(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new pl(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}var ri=pl;function og(n){return _x*Math.cos(n*Math.PI/180)}function Xs(n){return(180+n)/360}function Ws(n){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n*Math.PI/360)))/360}function Ms(n,e){return n/og(e)}function qo(n){return 360*n-180}function zr(n){return 360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90}function yx(n,e){return n*og(zr(e))}const Or=85.051129;function vx(n){return 1/Math.cos(n*Math.PI/180)}class lc{constructor(e,r,u=0){this.x=+e,this.y=+r,this.z=+u}static fromLngLat(e,r=0){const u=ri.convert(e);return new lc(Xs(u.lng),Ws(u.lat),Ms(r,u.lat))}toLngLat(){return new ri(qo(this.x),zr(this.y))}toAltitude(){return yx(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/_x*vx(zr(this.y))}}function sg(n,e,r,u,m,y,b,I,C){const A=(e+u)/2,O=(r+m)/2,B=new Ie(A,O);I(B),function(j,$,W,K,re,de){const Te=W-re,pe=K-de;return Math.abs((K-$)*Te-(W-j)*pe)/Math.hypot(Te,pe)}(B.x,B.y,y.x,y.y,b.x,b.y)>=C?(sg(n,e,r,A,O,y,B,I,C),sg(n,A,O,u,m,B,b,I,C)):n.push(b)}function xx(n,e,r){let u=n[0],m=u.x,y=u.y;e(u);const b=[u];for(let I=1;In.x+1||un.y+1)&&yn("Geometry exceeds allowed extent, reduce your vector tile buffer size"),n}function Sa(n,e,r){const u=n.loadGeometry(),m=n.extent,y=Wt/m;if(e&&r&&r.projection.isReprojectedInTileSpace){const b=1<{const $=qo((e.x+j.x/m)/b),W=zr((e.y+j.y/m)/b),K=O.project($,W);j.x=(K.x*I-C)*m,j.y=(K.y*I-A)*m};for(let j=0;j=m||W.y<0||W.y>=m||(B(W),$.push(W));u[j]=$}}for(const b of u)for(const I of b)ek(I,y);return u}function au(n,e){return{type:n.type,id:n.id,properties:n.properties,geometry:e?Sa(n):[]}}function Bd(n,e,r,u,m){n.emplaceBack(2*e+(u+1)/2,2*r+(m+1)/2)}function Fd(n,e,r){n.emplaceBack(e.x,e.y,e.z,r[0]*16384,r[1]*16384,r[2]*16384)}class ug{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new pt,this.indexArray=new qt,this.segments=new ji,this.programConfigurations=new tu(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,u,m){const y=this.layers[0],b=[];let I=null;y.type==="circle"&&(I=y.layout.get("circle-sort-key"));for(const{feature:A,id:O,index:B,sourceLayerIndex:j}of e){const $=this.layers[0]._featureFilter.needGeometry,W=au(A,$);if(!this.layers[0]._featureFilter.filter(new N(this.zoom),W,u))continue;const K=I?I.evaluate(W,{},u):void 0,re={id:O,properties:A.properties,type:A.type,sourceLayerIndex:j,index:B,geometry:$?W.geometry:Sa(A,u,m),patterns:{},sortKey:K};b.push(re)}I&&b.sort((A,O)=>A.sortKey-O.sortKey);let C=null;m.projection.name==="globe"&&(this.globeExtVertexArray=new yt,C=m.projection);for(const A of b){const{geometry:O,index:B,sourceLayerIndex:j}=A,$=e[B].feature;this.addFeature(A,O,B,r.availableImages,u,C),r.featureIndex.insert($,O,B,j,this.index)}}update(e,r,u,m){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,u,m)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,VS.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,US.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,r,u,m,y,b){for(const I of r)for(const C of I){const A=C.x,O=C.y;if(A<0||A>=Wt||O<0||O>=Wt)continue;if(b){const $=b.projectTilePoint(A,O,y),W=b.upVector(y,A,O),K=this.globeExtVertexArray;Fd(K,$,W),Fd(K,$,W),Fd(K,$,W),Fd(K,$,W)}const B=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),j=B.vertexLength;Bd(this.layoutVertexArray,A,O,-1,-1),Bd(this.layoutVertexArray,A,O,1,-1),Bd(this.layoutVertexArray,A,O,1,1),Bd(this.layoutVertexArray,A,O,-1,1),this.indexArray.emplaceBack(j,j+1,j+2),this.indexArray.emplaceBack(j,j+2,j+3),B.vertexLength+=4,B.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,{},m,y)}}function wx(n,e){for(let r=0;r1){if(cg(n,e))return!0;for(let u=0;u1?r:r.sub(e)._mult(m)._add(e))}function Ix(n,e){let r,u,m,y=!1;for(let b=0;be.y!=m.y>e.y&&e.x<(m.x-u.x)*(e.y-u.y)/(m.y-u.y)+u.x&&(y=!y)}return y}function lu(n,e){let r=!1;for(let u=0,m=n.length-1;ue.y!=b.y>e.y&&e.x<(b.x-y.x)*(e.y-y.y)/(b.y-y.y)+y.x&&(r=!r)}return r}function Mx(n,e,r,u,m){for(const b of n)if(e<=b.x&&r<=b.y&&u>=b.x&&m>=b.y)return!0;const y=[new Ie(e,r),new Ie(e,m),new Ie(u,m),new Ie(u,r)];if(n.length>2){for(const b of y)if(lu(n,b))return!0}for(let b=0;bm.x&&e.x>m.x||n.ym.y&&e.y>m.y)return!1;const y=_i(n,e,r[0]);return y!==_i(n,e,r[1])||y!==_i(n,e,r[2])||y!==_i(n,e,r[3])}function uc(n,e,r){const u=e.paint.get(n).value;return u.kind==="constant"?u.value:r.programConfigurations.get(e.id).getMaxValue(n)}function Vd(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1])}function Sx(n,e,r,u,m){if(!e[0]&&!e[1])return n;const y=Ie.convert(e)._mult(m);r==="viewport"&&y._rotate(-u);const b=[];for(let I=0;I0){const pe=r.projection.upVector(A,$.x,$.y);K.x+=pe[0]*O*W,K.y+=pe[1]*O*W,K.z+=pe[2]*O*W}const re=y?$:ak(K.x,K.y,K.z,u),de=y?n.tilespaceRays.map(pe=>uk(pe,W)):n.queryGeometry.screenGeometry,Te=ru([],[K.x,K.y,K.z,1],u);if(!b&&y?C*=Te[3]/r.cameraToCenterDistance:b&&!y&&(C*=r.cameraToCenterDistance/Te[3]),y){const pe=zr((j.y/Wt+A.y)/(1<n.width||m.height>n.height||r.x>n.width-m.width||r.y>n.height-m.height)throw new RangeError("out of range source coordinates for image copy");if(m.width>e.width||m.height>e.height||u.x>e.width-m.width||u.y>e.height-m.height)throw new RangeError("out of range destination coordinates for image copy");const b=n.data,I=e.data;for(let C=0;C{e[n.evaluationKey]=C;const A=n.expression.evaluate(e);m.data[b+I+0]=Math.floor(255*A.r/A.a),m.data[b+I+1]=Math.floor(255*A.g/A.a),m.data[b+I+2]=Math.floor(255*A.b/A.a),m.data[b+I+3]=Math.floor(255*A.a)};if(n.clips)for(let b=0,I=0;b80*r){u=y=n[0],m=b=n[1];for(var W=r;Wy&&(y=I),C>b&&(b=C);A=(A=Math.max(y-u,b-m))!==0?32767/A:0}return Nh(j,$,r,u,m,A,0),$}function Dx(n,e,r,u,m){var y,b;if(m===_g(n,e,r,u)>0)for(y=e;y=e;y-=u)b=Nx(y,n[y],n[y+1],b);return b&&jd(b,b.next)&&(Fh(b),b=b.next),b}function uu(n,e){if(!n)return n;e||(e=n);var r,u=n;do if(r=!1,u.steiner||!jd(u,u.next)&&Gi(u.prev,u,u.next)!==0)u=u.next;else{if(Fh(u),(u=e=u.prev)===u.next)break;r=!0}while(r||u!==e);return e}function Nh(n,e,r,u,m,y,b){if(n){!b&&y&&function(O,B,j,$){var W=O;do W.z===0&&(W.z=mg(W.x,W.y,B,j,$)),W.prevZ=W.prev,W.nextZ=W.next,W=W.next;while(W!==O);W.prevZ.nextZ=null,W.prevZ=null,function(K){var re,de,Te,pe,Ee,Ce,Se,We,Ze=1;do{for(de=K,K=null,Ee=null,Ce=0;de;){for(Ce++,Te=de,Se=0,re=0;re0||We>0&&Te;)Se!==0&&(We===0||!Te||de.z<=Te.z)?(pe=de,de=de.nextZ,Se--):(pe=Te,Te=Te.nextZ,We--),Ee?Ee.nextZ=pe:K=pe,pe.prevZ=Ee,Ee=pe;de=Te}Ee.nextZ=null,Ze*=2}while(Ce>1)}(W)}(n,u,m,y);for(var I,C,A=n;n.prev!==n.next;)if(I=n.prev,C=n.next,y?mk(n,u,m,y):pk(n))e.push(I.i/r|0),e.push(n.i/r|0),e.push(C.i/r|0),Fh(n),n=C.next,A=C.next;else if((n=C)===A){b?b===1?Nh(n=gk(uu(n),e,r),e,r,u,m,y,2):b===2&&_k(n,e,r,u,m,y):Nh(uu(n),e,r,u,m,y,1);break}}}function pk(n){var e=n.prev,r=n,u=n.next;if(Gi(e,r,u)>=0)return!1;for(var m=e.x,y=r.x,b=u.x,I=e.y,C=r.y,A=u.y,O=my?m>b?m:b:y>b?y:b,$=I>C?I>A?I:A:C>A?C:A,W=u.next;W!==e;){if(W.x>=O&&W.x<=j&&W.y>=B&&W.y<=$&&cc(m,I,y,C,b,A,W.x,W.y)&&Gi(W.prev,W,W.next)>=0)return!1;W=W.next}return!0}function mk(n,e,r,u){var m=n.prev,y=n,b=n.next;if(Gi(m,y,b)>=0)return!1;for(var I=m.x,C=y.x,A=b.x,O=m.y,B=y.y,j=b.y,$=IC?I>A?I:A:C>A?C:A,re=O>B?O>j?O:j:B>j?B:j,de=mg($,W,e,r,u),Te=mg(K,re,e,r,u),pe=n.prevZ,Ee=n.nextZ;pe&&pe.z>=de&&Ee&&Ee.z<=Te;){if(pe.x>=$&&pe.x<=K&&pe.y>=W&&pe.y<=re&&pe!==m&&pe!==b&&cc(I,O,C,B,A,j,pe.x,pe.y)&&Gi(pe.prev,pe,pe.next)>=0||(pe=pe.prevZ,Ee.x>=$&&Ee.x<=K&&Ee.y>=W&&Ee.y<=re&&Ee!==m&&Ee!==b&&cc(I,O,C,B,A,j,Ee.x,Ee.y)&&Gi(Ee.prev,Ee,Ee.next)>=0))return!1;Ee=Ee.nextZ}for(;pe&&pe.z>=de;){if(pe.x>=$&&pe.x<=K&&pe.y>=W&&pe.y<=re&&pe!==m&&pe!==b&&cc(I,O,C,B,A,j,pe.x,pe.y)&&Gi(pe.prev,pe,pe.next)>=0)return!1;pe=pe.prevZ}for(;Ee&&Ee.z<=Te;){if(Ee.x>=$&&Ee.x<=K&&Ee.y>=W&&Ee.y<=re&&Ee!==m&&Ee!==b&&cc(I,O,C,B,A,j,Ee.x,Ee.y)&&Gi(Ee.prev,Ee,Ee.next)>=0)return!1;Ee=Ee.nextZ}return!0}function gk(n,e,r){var u=n;do{var m=u.prev,y=u.next.next;!jd(m,y)&&zx(m,u,u.next,y)&&Bh(m,y)&&Bh(y,m)&&(e.push(m.i/r|0),e.push(u.i/r|0),e.push(y.i/r|0),Fh(u),Fh(u.next),u=n=y),u=u.next}while(u!==n);return uu(u)}function _k(n,e,r,u,m,y){var b=n;do{for(var I=b.next.next;I!==b.prev;){if(b.i!==I.i&&wk(b,I)){var C=Ox(b,I);return b=uu(b,b.next),C=uu(C,C.next),Nh(b,e,r,u,m,y,0),void Nh(C,e,r,u,m,y,0)}I=I.next}b=b.next}while(b!==n)}function yk(n,e){return n.x-e.x}function vk(n,e){var r=function(m,y){var b,I=y,C=m.x,A=m.y,O=-1/0;do{if(A<=I.y&&A>=I.next.y&&I.next.y!==I.y){var B=I.x+(A-I.y)*(I.next.x-I.x)/(I.next.y-I.y);if(B<=C&&B>O&&(O=B,b=I.x=I.x&&I.x>=W&&C!==I.x&&cc(Ab.x||I.x===b.x&&xk(b,I)))&&(b=I,re=j)),I=I.next;while(I!==$);return b}(n,e);if(!r)return e;var u=Ox(r,n);return uu(u,u.next),uu(r,r.next)}function xk(n,e){return Gi(n.prev,n,e.prev)<0&&Gi(e.next,n,n.next)<0}function mg(n,e,r,u,m){return(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-r)*m|0)|n<<8))|n<<4))|n<<2))|n<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-u)*m|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function bk(n){var e=n,r=n;do(e.x=(n-b)*(y-I)&&(n-b)*(u-I)>=(r-b)*(e-I)&&(r-b)*(y-I)>=(m-b)*(u-I)}function wk(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!function(r,u){var m=r;do{if(m.i!==r.i&&m.next.i!==r.i&&m.i!==u.i&&m.next.i!==u.i&&zx(m,m.next,r,u))return!0;m=m.next}while(m!==r);return!1}(n,e)&&(Bh(n,e)&&Bh(e,n)&&function(r,u){var m=r,y=!1,b=(r.x+u.x)/2,I=(r.y+u.y)/2;do m.y>I!=m.next.y>I&&m.next.y!==m.y&&b<(m.next.x-m.x)*(I-m.y)/(m.next.y-m.y)+m.x&&(y=!y),m=m.next;while(m!==r);return y}(n,e)&&(Gi(n.prev,n,e.prev)||Gi(n,e.prev,e))||jd(n,e)&&Gi(n.prev,n,n.next)>0&&Gi(e.prev,e,e.next)>0)}function Gi(n,e,r){return(e.y-n.y)*(r.x-e.x)-(e.x-n.x)*(r.y-e.y)}function jd(n,e){return n.x===e.x&&n.y===e.y}function zx(n,e,r,u){var m=qd(Gi(n,e,r)),y=qd(Gi(n,e,u)),b=qd(Gi(r,u,n)),I=qd(Gi(r,u,e));return m!==y&&b!==I||!(m!==0||!Gd(n,r,e))||!(y!==0||!Gd(n,u,e))||!(b!==0||!Gd(r,n,u))||!(I!==0||!Gd(r,e,u))}function Gd(n,e,r){return e.x<=Math.max(n.x,r.x)&&e.x>=Math.min(n.x,r.x)&&e.y<=Math.max(n.y,r.y)&&e.y>=Math.min(n.y,r.y)}function qd(n){return n>0?1:n<0?-1:0}function Bh(n,e){return Gi(n.prev,n,n.next)<0?Gi(n,e,n.next)>=0&&Gi(n,n.prev,e)>=0:Gi(n,e,n.prev)<0||Gi(n,n.next,e)<0}function Ox(n,e){var r=new gg(n.i,n.x,n.y),u=new gg(e.i,e.x,e.y),m=n.next,y=e.prev;return n.next=e,e.prev=n,r.next=m,m.prev=r,u.next=r,r.prev=u,y.next=u,u.prev=y,u}function Nx(n,e,r,u){var m=new gg(n,e,r);return u?(m.next=u.next,m.prev=u,u.next.prev=m,u.next=m):(m.prev=m,m.next=m),m}function Fh(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function gg(n,e,r){this.i=n,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function _g(n,e,r,u){for(var m=0,y=e,b=r-u;y0&&r.holes.push(u+=n[m-1].length)}return r};var yg=ce(pg.exports);function Ek(n,e,r,u,m){Bx(n,e,r,u||n.length-1,m||Tk)}function Bx(n,e,r,u,m){for(;u>r;){if(u-r>600){var y=u-r+1,b=e-r+1,I=Math.log(y),C=.5*Math.exp(2*I/3),A=.5*Math.sqrt(I*C*(y-C)/y)*(b-y/2<0?-1:1);Bx(n,e,Math.max(r,Math.floor(e-b*C/y+A)),Math.min(u,Math.floor(e+(y-b)*C/y+A)),m)}var O=n[e],B=r,j=u;for(Vh(n,r,e),m(n[u],O)>0&&Vh(n,r,u);B0;)j--}m(n[r],O)===0?Vh(n,r,j):Vh(n,++j,u),j<=e&&(r=j+1),e<=j&&(u=j-1)}}function Vh(n,e,r){var u=n[e];n[e]=n[r],n[r]=u}function Tk(n,e){return ne?1:0}function vg(n,e){const r=n.length;if(r<=1)return[n];const u=[];let m,y;for(let b=0;b1)for(let b=0;br.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new pt,this.indexArray=new qt,this.indexArray2=new mr,this.programConfigurations=new tu(e.layers,e.zoom),this.segments=new ji,this.segments2=new ji,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id),this.projection=e.projection}populate(e,r,u,m){this.hasPattern=xg("fill",this.layers,r);const y=this.layers[0].layout.get("fill-sort-key"),b=[];for(const{feature:I,id:C,index:A,sourceLayerIndex:O}of e){const B=this.layers[0]._featureFilter.needGeometry,j=au(I,B);if(!this.layers[0]._featureFilter.filter(new N(this.zoom),j,u))continue;const $=y?y.evaluate(j,{},u,r.availableImages):void 0,W={id:C,properties:I.properties,type:I.type,sourceLayerIndex:O,index:A,geometry:B?j.geometry:Sa(I,u,m),patterns:{},sortKey:$};b.push(W)}y&&b.sort((I,C)=>I.sortKey-C.sortKey);for(const I of b){const{geometry:C,index:A,sourceLayerIndex:O}=I;if(this.hasPattern){const B=bg("fill",this.layers,I,this.zoom,r);this.patternFeatures.push(B)}else this.addFeature(I,C,A,u,{},r.availableImages);r.featureIndex.insert(e[A].feature,C,A,O,this.index)}}update(e,r,u,m){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,u,m)}addFeatures(e,r,u,m,y){for(const b of this.patternFeatures)this.addFeature(b,b.geometry,b.index,r,u,m)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,dk),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,r,u,m,y,b=[]){for(const I of vg(r,500)){let C=0;for(const W of I)C+=W.length;const A=this.segments.prepareSegment(C,this.layoutVertexArray,this.indexArray),O=A.vertexLength,B=[],j=[];for(const W of I){if(W.length===0)continue;W!==I[0]&&j.push(B.length/2);const K=this.segments2.prepareSegment(W.length,this.layoutVertexArray,this.indexArray2),re=K.vertexLength;this.layoutVertexArray.emplaceBack(W[0].x,W[0].y),this.indexArray2.emplaceBack(re+W.length-1,re),B.push(W[0].x),B.push(W[0].y);for(let de=1;de>3}if(m--,u===1||u===2)y+=n.readSVarint(),b+=n.readSVarint(),u===1&&(e&&I.push(e),e=[]),e.push(new Lk(y,b));else{if(u!==7)throw new Error("unknown command "+u);e&&e.push(e[0].clone())}}return e&&I.push(e),I},hc.prototype.bbox=function(){var n=this._pbf;n.pos=this._geometry;for(var e=n.readVarint()+n.pos,r=1,u=0,m=0,y=0,b=1/0,I=-1/0,C=1/0,A=-1/0;n.pos>3}if(u--,r===1||r===2)(m+=n.readSVarint())I&&(I=m),(y+=n.readSVarint())A&&(A=y);else if(r!==7)throw new Error("unknown command "+r)}return[b,C,I,A]},hc.prototype.toGeoJSON=function(n,e,r){var u,m,y=this.extent*Math.pow(2,r),b=this.extent*n,I=this.extent*e,C=this.loadGeometry(),A=hc.types[this.type];function O($){for(var W=0;W<$.length;W++){var K=$[W];$[W]=[360*(K.x+b)/y-180,360/Math.PI*Math.atan(Math.exp((180-360*(K.y+I)/y)*Math.PI/180))-90]}}switch(this.type){case 1:var B=[];for(u=0;u>3;m=b===1?u.readString():b===2?u.readFloat():b===3?u.readDouble():b===4?u.readVarint64():b===5?u.readVarint():b===6?u.readSVarint():b===7?u.readBoolean():null}return m}(r))}Ux.prototype.feature=function(n){if(n<0||n>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[n];var e=this._pbf.readVarint()+this._pbf.pos;return new zk(this._pbf,e,this.extent,this._keys,this._values)};var Nk=Vx;function Bk(n,e,r){if(n===3){var u=new Nk(r,r.readVarint()+r.pos);u.length&&(e[u.name]=u)}}var wg=$d.VectorTile=function(n,e){this.layers=n.readFields(Bk,{},e)},Xd=$d.VectorTileFeature=Fx;function Wd(n,e,r,u){const m=[],y=u===0?(b,I,C,A,O,B)=>{b.push(new Ie(B,C+(B-I)/(A-I)*(O-C)))}:(b,I,C,A,O,B)=>{b.push(new Ie(I+(B-C)/(O-C)*(A-I),B))};for(const b of n){const I=[];for(const C of b){if(C.length<=2)continue;const A=[];for(let j=0;je&&y(A,$,W,K,re,e):de>r?Te=e&&y(A,$,W,K,re,e),Te>r&&de<=r&&y(A,$,W,K,re,r)}let O=C[C.length-1];const B=u===0?O.x:O.y;B>=e&&B<=r&&A.push(O),A.length&&(O=A[A.length-1],A[0].x===O.x&&A[0].y===O.y||A.push(A[0]),I.push(A))}I.length&&m.push(I)}return m}$d.VectorTileLayer=Vx;const Fk=Xd.types,Vk=Math.pow(2,13);function Uh(n,e,r,u,m,y,b,I){n.emplaceBack((e<<1)+b,(r<<1)+y,(Math.floor(u*Vk)<<1)+m,Math.round(I))}function jh(n,e,r){n.emplaceBack(e.x,e.y,e.z,r[0]*16384,r[1]*16384,r[2]*16384)}class jx{constructor(){this.acc=new Ie(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new Ie(e.x,e.y),this.max=new Ie(e.x,e.y))}append(e,r){this.currentPolyCount.edges++,this.acc._add(e);const u=this.min,m=this.max;e.xm.x&&(m.x=e.x),e.ym.y&&(m.y=e.y),((e.x===0||e.x===Wt)&&e.x===r.x)!=((e.y===0||e.y===Wt)&&e.y===r.y)&&this.processBorderOverlap(e,r),r.x<0!=e.x<0&&this.addBorderIntersection(0,Nn(r.y,e.y,(0-r.x)/(e.x-r.x))),r.x>Wt!=e.x>Wt&&this.addBorderIntersection(1,Nn(r.y,e.y,(Wt-r.x)/(e.x-r.x))),r.y<0!=e.y<0&&this.addBorderIntersection(2,Nn(r.x,e.x,(0-r.y)/(e.y-r.y))),r.y>Wt!=e.y>Wt&&this.addBorderIntersection(3,Nn(r.x,e.x,(Wt-r.y)/(e.y-r.y)))}addBorderIntersection(e,r){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const u=this.borders[e];ru[1]&&(u[1]=r)}processBorderOverlap(e,r){if(e.x===r.x){if(e.y===r.y)return;const u=e.x===0?0:1;this.addBorderIntersection(u,r.y),this.addBorderIntersection(u,e.y)}else{const u=e.y===0?2:3;this.addBorderIntersection(u,r.x),this.addBorderIntersection(u,e.x)}}centroid(){const e=this.polyCount.reduce((r,u)=>r+u.edges,0);return e!==0?this.acc.div(e)._round():new Ie(0,0)}span(){return new Ie(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,r)=>e+ +(r[0]!==Number.MAX_VALUE),0)}}class Gh{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new ot,this.centroidVertexArray=new bs,this.indexArray=new qt,this.programConfigurations=new tu(e.layers,e.zoom),this.segments=new ji,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id),this.enableTerrain=e.enableTerrain}populate(e,r,u,m){this.features=[],this.hasPattern=xg("fill-extrusion",this.layers,r),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(y){const b=Math.exp(Math.PI*(1-y.y/(1<=0;de--){const Te=$[de];(Te.length===0||(W=Te[0]).every(pe=>pe.x<=0)||W.every(pe=>pe.x>=Wt)||W.every(pe=>pe.y<=0)||W.every(pe=>pe.y>=Wt))&&$.splice(de,1)}var W;let K;if(O)K=Yx($,C,m);else{K=[];for(const de of $)K.push({polygon:de,bounds:C})}const re=j?this.edgeRadius:0;for(const{polygon:de,bounds:Te}of K){let pe=0,Ee=0;for(const Se of de)j&&!Se[0].equals(Se[Se.length-1])&&Se.push(Se[0]),Ee+=j?Se.length-1:Se.length;const Ce=this.segments.prepareSegment((j?5:4)*Ee,this.layoutVertexArray,this.indexArray);if(j){const Se=[],We=[];pe=Ce.vertexLength;for(const nt of de){let mt,Ke;nt.length&&nt!==de[0]&&We.push(Se.length/2),mt=nt[1].sub(nt[0])._perp()._unit();for(let st=1;st4&&$x(Se[Se.length-2],Se[0],Se[1]),Ke=re?Uk(Se[Se.length-2],Se[0],Se[1],re):0;Ze=Se[1].sub(Se[0])._perp()._unit();let st=!0;for(let at=1,ht=0;at0?1:0,Tt=Et.dist(et);if(ht+Tt>32768&&(ht=0),re){nt=Rt.sub(et)._perp()._unit();let gn=qx(Et,et,Rt,Gx(Ze,nt),re);isNaN(gn)&&(gn=0);const en=et.sub(Et)._unit();Et=Et.add(en.mult(Ke))._round(),et=et.add(en.mult(-gn))._round(),Ke=gn,Ze=nt}const Xt=Ce.vertexLength,mn=Se.length>4&&$x(Et,et,Rt);let jn=Xx(ht,mt,st);if(Uh(this.layoutVertexArray,Et.x,Et.y,Dt,pn,0,0,jn),Uh(this.layoutVertexArray,Et.x,Et.y,Dt,pn,0,1,jn),ht+=Tt,jn=Xx(ht,mn,!st),mt=mn,Uh(this.layoutVertexArray,et.x,et.y,Dt,pn,0,0,jn),Uh(this.layoutVertexArray,et.x,et.y,Dt,pn,0,1,jn),Ce.vertexLength+=4,this.indexArray.emplaceBack(Xt+0,Xt+1,Xt+2),this.indexArray.emplaceBack(Xt+1,Xt+3,Xt+2),Ce.primitiveLength+=2,re){const gn=pe+(at===1?Se.length-2:at-2),en=at===1?pe:gn+1;if(this.indexArray.emplaceBack(Xt+1,gn,Xt+3),this.indexArray.emplaceBack(gn,en,Xt+3),Ce.primitiveLength+=2,We===void 0&&(We=Xt),!Zx(Rt,Se[at],Te)){const gi=at===Se.length-1?We:Ce.vertexLength;this.indexArray.emplaceBack(Xt+2,Xt+3,gi),this.indexArray.emplaceBack(Xt+3,gi+1,gi),this.indexArray.emplaceBack(Xt+3,en,gi+1),Ce.primitiveLength+=3}st=!st}if(O){const gn=this.layoutVertexExtArray,en=A.projectTilePoint(Et.x,Et.y,m),gi=A.projectTilePoint(et.x,et.y,m),vn=A.upVector(m,Et.x,Et.y),xn=A.upVector(m,et.x,et.y);jh(gn,en,vn),jh(gn,en,vn),jh(gn,gi,xn),jh(gn,gi,xn)}}j&&(pe+=Se.length-1)}}if(B&&B.polyCount.length>0){if(B.borders){B.vertexArrayOffset=this.centroidVertexArray.length;const de=B.borders,Te=this.featuresOnBorder.push(B)-1;for(let pe=0;pe<4;pe++)de[pe][0]!==Number.MAX_VALUE&&this.borders[pe].push(Te)}this.encodeCentroid(B.borders?void 0:B.centroid(),B)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,y,b,m)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((r,u)=>this.featuresOnBorder[r].borders[e][0]-this.featuresOnBorder[u].borders[e][0])}encodeCentroid(e,r,u=!0){let m,y;if(e)if(e.y!==0){const I=r.span()._mult(this.tileToMeter);m=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(I.x/10)),y=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(I.y/10))}else m=Math.ceil(7*(e.x+450)),y=0;else m=0,y=+u;let b=u?this.centroidVertexArray.length:r.vertexArrayOffset;for(const I of r.polyCount){u&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*I.edges+I.top);for(let C=0;Cr[1].x&&e.x>r[1].x||n.yr[1].y&&e.y>r[1].y}function $x(n,e,r){if(n.x<0||n.x>=Wt||e.x<0||e.x>=Wt||r.x<0||r.x>=Wt)return!1;const u=r.sub(e),m=u.perp(),y=n.sub(e);return(u.x*y.x+u.y*y.y)/Math.sqrt((u.x*u.x+u.y*u.y)*(y.x*y.x+y.y*y.y))>-.866&&m.x*y.x+m.y*y.y<0}function Xx(n,e,r){const u=e?2|n:-3&n;return r?1|u:-2&u}function Wx(){const n=Math.PI/32,e=Math.tan(n),r=Oh;return r*Math.sqrt(1+2*e*e)-r}function Yx(n,e,r){const u=1<{for(const Ze of Se)W.push({polygon:Ze,bounds:We})},re=Math.ceil(Math.log2(O)),de=Math.ceil(Math.log2(B)),Te=re-de,pe=[];for(let Se=0;Se0?0:1);for(let Se=0;SeWe+1?Ce.push({polygons:ht,bounds:et,depth:We+1}):K(ht,et)}if(Et.length){const et=[new Ie(Ze===0?at:nt.x,Ze===1?at:nt.y),mt];pe.length>We+1?Ce.push({polygons:Et,bounds:et,depth:We+1}):K(Et,et)}}return W}(n,e,Math.ceil((y-m)/11.25),Math.ceil((b-I)/11.25),1,(C,A,O)=>{if(C===0)return .5*(A+O);{const B=zr((r.y+A/Wt)/u);return(Ws(.5*(zr((r.y+O/Wt)/u)+B))*u-r.y)*Wt}})}Ft(Gh,"FillExtrusionBucket",{omit:["layers","features"]}),Ft(jx,"PartMetadata");const jk=new _e({"fill-extrusion-edge-radius":new H(Qe["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var Gk={paint:new _e({"fill-extrusion-opacity":new H(Qe["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new oe(Qe["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new H(Qe["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new H(Qe["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new oe(Qe["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new oe(Qe["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new oe(Qe["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new H(Qe["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new H(Qe["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new H(Qe["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-rounded-roof":new H(Qe["paint_fill-extrusion"]["fill-extrusion-rounded-roof"])}),layout:jk};function Hx(n,e,r){var u=2*Math.PI*6378137/256/Math.pow(2,r);return[n*u-2*Math.PI*6378137/2,e*u-2*Math.PI*6378137/2]}class Yd{constructor(e,r,u){this.z=e,this.x=r,this.y=u,this.key=qh(0,e,e,r,u)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r){const u=function(y,b,I){var C=Hx(256*y,256*(b=Math.pow(2,I)-b-1),I),A=Hx(256*(y+1),256*(b+1),I);return C[0]+","+C[1]+","+A[0]+","+A[1]}(this.x,this.y,this.z),m=function(y,b,I){let C,A="";for(let O=y;O>0;O--)C=1<this.canonical.z?new no(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new no(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r=!0){if(this.overscaledZ===e&&r)return this.key;if(e>this.canonical.z)return qh(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y);{const u=this.canonical.z-e;return qh(this.wrap*+r,e,e,this.canonical.x>>u,this.canonical.y>>u)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new no(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,u=2*this.canonical.x,m=2*this.canonical.y;return[new no(r,this.wrap,r,u,m),new no(r,this.wrap,r,u+1,m),new no(r,this.wrap,r,u,m+1),new no(r,this.wrap,r,u+1,m+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.yr.id),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new He,this.layoutVertexArray2=new dt,this.indexArray=new qt,this.programConfigurations=new tu(e.layers,e.zoom),this.segments=new ji,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,u,m){this.hasPattern=xg("line",this.layers,r);const y=this.layers[0].layout.get("line-sort-key"),b=[];for(const{feature:O,id:B,index:j,sourceLayerIndex:$}of e){const W=this.layers[0]._featureFilter.needGeometry,K=au(O,W);if(!this.layers[0]._featureFilter.filter(new N(this.zoom),K,u))continue;const re=y?y.evaluate(K,{},u):void 0,de={id:B,properties:O.properties,type:O.type,sourceLayerIndex:$,index:j,geometry:W?K.geometry:Sa(O,u,m),patterns:{},sortKey:re};b.push(de)}y&&b.sort((O,B)=>O.sortKey-B.sortKey);const{lineAtlas:I,featureIndex:C}=r,A=this.addConstantDashes(I);for(const O of b){const{geometry:B,index:j,sourceLayerIndex:$}=O;if(A&&this.addFeatureDashes(O,I),this.hasPattern){const W=bg("line",this.layers,O,this.zoom,r);this.patternFeatures.push(W)}else this.addFeature(O,B,j,u,I.positions,r.availableImages);C.insert(e[j].feature,B,j,$,this.index)}}addConstantDashes(e){let r=!1;for(const u of this.layers){const m=u.paint.get("line-dasharray").value,y=u.layout.get("line-cap").value;if(m.kind!=="constant"||y.kind!=="constant")r=!0;else{const b=y.value,I=m.value;if(!I)continue;e.addDash(I,b)}}return r}addFeatureDashes(e,r){const u=this.zoom;for(const m of this.layers){const y=m.paint.get("line-dasharray").value,b=m.layout.get("line-cap").value;if(y.kind==="constant"&&b.kind==="constant")continue;let I,C;if(y.kind==="constant"){if(I=y.value,!I)continue}else I=y.evaluate({zoom:u},e);C=b.kind==="constant"?b.value:b.evaluate({zoom:u},e),r.addDash(I,C),e.patterns[m.id]=r.getKey(I,C)}}update(e,r,u,m){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,u,m)}addFeatures(e,r,u,m,y){for(const b of this.patternFeatures)this.addFeature(b,b.geometry,b.index,r,u,m)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Xk)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Zk),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&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,u,m,y,b){const I=this.layers[0].layout,C=I.get("line-join").evaluate(e,{}),A=I.get("line-cap").evaluate(e,{}),O=I.get("line-miter-limit"),B=I.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const j of r)this.addLine(j,e,C,A,O,B);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,y,b,m)}addLine(e,r,u,m,y,b){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let de=0;de=2&&e[C-1].equals(e[C-2]);)C--;let A=0;for(;A0;if(We&&de>A){const Ke=j.dist($);if(Ke>2*O){const st=j.sub(j.sub($)._mult(O/Ke)._round());this.updateDistance($,st),this.addCurrentVertex(st,K,0,0,B),$=st}}const nt=$&&W;let mt=nt?u:I?"butt":m;if(nt&&mt==="round"&&(Cey&&(mt="bevel"),mt==="bevel"&&(Ce>2&&(mt="flipbevel"),Ce100)Te=re.mult(-1);else{const Ke=Ce*K.add(re).mag()/K.sub(re).mag();Te._perp()._mult(Ke*(Ze?-1:1))}this.addCurrentVertex(j,Te,0,0,B),this.addCurrentVertex(j,Te.mult(-1),0,0,B)}else if(mt==="bevel"||mt==="fakeround"){const Ke=-Math.sqrt(Ce*Ce-1),st=Ze?Ke:0,at=Ze?0:Ke;if($&&this.addCurrentVertex(j,K,st,at,B),mt==="fakeround"){const ht=Math.round(180*Se/Math.PI/20);for(let Et=1;Et2*O){const st=j.add(W.sub(j)._mult(O/Ke)._round());this.updateDistance(j,st),this.addCurrentVertex(st,re,0,0,B),j=st}}}}addCurrentVertex(e,r,u,m,y,b=!1){const I=r.y*m-r.x,C=-r.y-r.x*m;this.addHalfVertex(e,r.x+r.y*u,r.y-r.x*u,b,!1,u,y),this.addHalfVertex(e,I,C,b,!0,-m,y)}addHalfVertex({x:e,y:r},u,m,y,b,I,C){this.layoutVertexArray.emplaceBack((e<<1)+(y?1:0),(r<<1)+(b?1:0),Math.round(63*u)+128,Math.round(63*m)+128,1+(I===0?0:I<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const A=C.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,A),C.primitiveLength++),b?this.e2=A:this.e1=A}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}}Ft(Hd,"LineBucket",{omit:["layers","patternFeatures"]});const Hk=new _e({"line-cap":new oe(Qe.layout_line["line-cap"]),"line-join":new oe(Qe.layout_line["line-join"]),"line-miter-limit":new H(Qe.layout_line["line-miter-limit"]),"line-round-limit":new H(Qe.layout_line["line-round-limit"]),"line-sort-key":new oe(Qe.layout_line["line-sort-key"])});var e1={paint:new _e({"line-opacity":new oe(Qe.paint_line["line-opacity"]),"line-color":new oe(Qe.paint_line["line-color"]),"line-translate":new H(Qe.paint_line["line-translate"]),"line-translate-anchor":new H(Qe.paint_line["line-translate-anchor"]),"line-width":new oe(Qe.paint_line["line-width"]),"line-gap-width":new oe(Qe.paint_line["line-gap-width"]),"line-offset":new oe(Qe.paint_line["line-offset"]),"line-blur":new oe(Qe.paint_line["line-blur"]),"line-dasharray":new oe(Qe.paint_line["line-dasharray"]),"line-pattern":new oe(Qe.paint_line["line-pattern"]),"line-gradient":new ge(Qe.paint_line["line-gradient"]),"line-trim-offset":new H(Qe.paint_line["line-trim-offset"])}),layout:Hk};const t1=new class extends oe{possiblyEvaluate(n,e){return e=new N(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(n,e)}evaluate(n,e,r,u){return e=Vt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(n,e,r,u)}}(e1.paint.properties["line-width"].specification);function n1(n,e){return e>0?e+2*n:n}t1.useIntegerZoom=!0;const Kk=Oe([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Jk=Oe([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Qk=Oe([{name:"a_projected_pos",components:4,type:"Float32"}],4);Oe([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const eC=Oe([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),tC=Oe([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Oe([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const i1=Oe([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),nC=Oe([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Oe([{name:"triangle",components:3,type:"Uint16"}]),Oe([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Oe([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Oe([{type:"Float32",name:"offsetX"}]),Oe([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var wr=24;const Ss=128;function Eg(n,e){const{expression:r}=e;if(r.kind==="constant")return{kind:"constant",layoutSize:r.evaluate(new N(n+1))};if(r.kind==="source")return{kind:"source"};{const{zoomStops:u,interpolationType:m}=r;let y=0;for(;y{u.text=function(m,y,b){const I=y.layout.get("text-transform").evaluate(b,{});return I==="uppercase"?m=m.toLocaleUpperCase():I==="lowercase"&&(m=m.toLocaleLowerCase()),z.applyArabicShaping&&(m=z.applyArabicShaping(m)),m}(u.text,e,r)}),n}const $h={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function oC(n){return n==="︶"||n==="﹈"||n==="︸"||n==="﹄"||n==="﹂"||n==="︾"||n==="︼"||n==="︺"||n==="︘"||n==="﹀"||n==="︐"||n==="︓"||n==="︔"||n==="`"||n===" ̄"||n==="︑"||n==="︒"}function sC(n){return n==="︵"||n==="﹇"||n==="︷"||n==="﹃"||n==="﹁"||n==="︽"||n==="︻"||n==="︹"||n==="︗"||n==="︿"}var r1=ci,o1=function(n,e,r,u,m){var y,b,I=8*m-u-1,C=(1<>1,O=-7,B=m-1,j=-1,$=n[e+B];for(B+=j,y=$&(1<<-O)-1,$>>=-O,O+=I;O>0;y=256*y+n[e+B],B+=j,O-=8);for(b=y&(1<<-O)-1,y>>=-O,O+=u;O>0;b=256*b+n[e+B],B+=j,O-=8);if(y===0)y=1-A;else{if(y===C)return b?NaN:1/0*($?-1:1);b+=Math.pow(2,u),y-=A}return($?-1:1)*b*Math.pow(2,y-u)},s1=function(n,e,r,u,m,y){var b,I,C,A=8*y-m-1,O=(1<>1,j=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,$=0,W=1,K=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(I=isNaN(e)?1:0,b=O):(b=Math.floor(Math.log(e)/Math.LN2),e*(C=Math.pow(2,-b))<1&&(b--,C*=2),(e+=b+B>=1?j/C:j*Math.pow(2,1-B))*C>=2&&(b++,C/=2),b+B>=O?(I=0,b=O):b+B>=1?(I=(e*C-1)*Math.pow(2,m),b+=B):(I=e*Math.pow(2,B-1)*Math.pow(2,m),b=0));m>=8;n[r+$]=255&I,$+=W,I/=256,m-=8);for(b=b<0;n[r+$]=255&b,$+=W,b/=256,A-=8);n[r+$-W]|=128*K};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */function ci(n){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(n)?n:new Uint8Array(n||0),this.pos=0,this.type=0,this.length=this.buf.length}ci.Varint=0,ci.Fixed64=1,ci.Bytes=2,ci.Fixed32=5;var Tg=4294967296,a1=1/Tg,l1=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function Ca(n){return n.type===ci.Bytes?n.readVarint()+n.pos:n.pos+1}function pc(n,e,r){return r?4294967296*e+(n>>>0):4294967296*(e>>>0)+(n>>>0)}function u1(n,e,r){var u=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(u);for(var m=r.pos-1;m>=n;m--)r.buf[m+u]=r.buf[m]}function aC(n,e){for(var r=0;r>>8,n[r+2]=e>>>16,n[r+3]=e>>>24}function c1(n,e){return(n[e]|n[e+1]<<8|n[e+2]<<16)+(n[e+3]<<24)}ci.prototype={destroy:function(){this.buf=null},readFields:function(n,e,r){for(r=r||this.length;this.pos>3,y=this.pos;this.type=7&u,n(m,e,this),this.pos===y&&this.skip(u)}return e},readMessage:function(n,e){return this.readFields(n,e,this.readVarint()+this.pos)},readFixed32:function(){var n=Jd(this.buf,this.pos);return this.pos+=4,n},readSFixed32:function(){var n=c1(this.buf,this.pos);return this.pos+=4,n},readFixed64:function(){var n=Jd(this.buf,this.pos)+Jd(this.buf,this.pos+4)*Tg;return this.pos+=8,n},readSFixed64:function(){var n=Jd(this.buf,this.pos)+c1(this.buf,this.pos+4)*Tg;return this.pos+=8,n},readFloat:function(){var n=o1(this.buf,this.pos,!0,23,4);return this.pos+=4,n},readDouble:function(){var n=o1(this.buf,this.pos,!0,52,8);return this.pos+=8,n},readVarint:function(n){var e,r,u=this.buf;return e=127&(r=u[this.pos++]),r<128?e:(e|=(127&(r=u[this.pos++]))<<7,r<128?e:(e|=(127&(r=u[this.pos++]))<<14,r<128?e:(e|=(127&(r=u[this.pos++]))<<21,r<128?e:function(m,y,b){var I,C,A=b.buf;if(I=(112&(C=A[b.pos++]))>>4,C<128||(I|=(127&(C=A[b.pos++]))<<3,C<128)||(I|=(127&(C=A[b.pos++]))<<10,C<128)||(I|=(127&(C=A[b.pos++]))<<17,C<128)||(I|=(127&(C=A[b.pos++]))<<24,C<128)||(I|=(1&(C=A[b.pos++]))<<31,C<128))return pc(m,I,y);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=u[this.pos]))<<28,n,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var n=this.readVarint();return n%2==1?(n+1)/-2:n/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var n=this.readVarint()+this.pos,e=this.pos;return this.pos=n,n-e>=12&&l1?function(r,u,m){return l1.decode(r.subarray(u,m))}(this.buf,e,n):function(r,u,m){for(var y="",b=u;b239?4:O>223?3:O>191?2:1;if(b+j>m)break;j===1?O<128&&(B=O):j===2?(192&(I=r[b+1]))==128&&(B=(31&O)<<6|63&I)<=127&&(B=null):j===3?(C=r[b+2],(192&(I=r[b+1]))==128&&(192&C)==128&&((B=(15&O)<<12|(63&I)<<6|63&C)<=2047||B>=55296&&B<=57343)&&(B=null)):j===4&&(C=r[b+2],A=r[b+3],(192&(I=r[b+1]))==128&&(192&C)==128&&(192&A)==128&&((B=(15&O)<<18|(63&I)<<12|(63&C)<<6|63&A)<=65535||B>=1114112)&&(B=null)),B===null?(B=65533,j=1):B>65535&&(B-=65536,y+=String.fromCharCode(B>>>10&1023|55296),B=56320|1023&B),y+=String.fromCharCode(B),b+=j}return y}(this.buf,e,n)},readBytes:function(){var n=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,n);return this.pos=n,e},readPackedVarint:function(n,e){if(this.type!==ci.Bytes)return n.push(this.readVarint(e));var r=Ca(this);for(n=n||[];this.pos127;);else if(e===ci.Bytes)this.pos=this.readVarint()+this.pos;else if(e===ci.Fixed32)this.pos+=4;else{if(e!==ci.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(n,e){this.writeVarint(n<<3|e)},realloc:function(n){for(var e=this.length||16;e268435455||n<0?function(e,r){var u,m;if(e>=0?(u=e%4294967296|0,m=e/4294967296|0):(m=~(-e/4294967296),4294967295^(u=~(-e%4294967296))?u=u+1|0:(u=0,m=m+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(y,b,I){I.buf[I.pos++]=127&y|128,y>>>=7,I.buf[I.pos++]=127&y|128,y>>>=7,I.buf[I.pos++]=127&y|128,y>>>=7,I.buf[I.pos++]=127&y|128,I.buf[I.pos]=127&(y>>>=7)}(u,0,r),function(y,b){var I=(7&y)<<4;b.buf[b.pos++]|=I|((y>>>=3)?128:0),y&&(b.buf[b.pos++]=127&y|((y>>>=7)?128:0),y&&(b.buf[b.pos++]=127&y|((y>>>=7)?128:0),y&&(b.buf[b.pos++]=127&y|((y>>>=7)?128:0),y&&(b.buf[b.pos++]=127&y|((y>>>=7)?128:0),y&&(b.buf[b.pos++]=127&y)))))}(m,r)}(n,this):(this.realloc(4),this.buf[this.pos++]=127&n|(n>127?128:0),n<=127||(this.buf[this.pos++]=127&(n>>>=7)|(n>127?128:0),n<=127||(this.buf[this.pos++]=127&(n>>>=7)|(n>127?128:0),n<=127||(this.buf[this.pos++]=n>>>7&127))))},writeSVarint:function(n){this.writeVarint(n<0?2*-n-1:2*n)},writeBoolean:function(n){this.writeVarint(!!n)},writeString:function(n){n=String(n),this.realloc(4*n.length),this.pos++;var e=this.pos;this.pos=function(u,m,y){for(var b,I,C=0;C55295&&b<57344){if(!I){b>56319||C+1===m.length?(u[y++]=239,u[y++]=191,u[y++]=189):I=b;continue}if(b<56320){u[y++]=239,u[y++]=191,u[y++]=189,I=b;continue}b=I-55296<<10|b-56320|65536,I=null}else I&&(u[y++]=239,u[y++]=191,u[y++]=189,I=null);b<128?u[y++]=b:(b<2048?u[y++]=b>>6|192:(b<65536?u[y++]=b>>12|224:(u[y++]=b>>18|240,u[y++]=b>>12&63|128),u[y++]=b>>6&63|128),u[y++]=63&b|128)}return y}(this.buf,n,this.pos);var r=this.pos-e;r>=128&&u1(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(n){this.realloc(4),s1(this.buf,n,this.pos,!0,23,4),this.pos+=4},writeDouble:function(n){this.realloc(8),s1(this.buf,n,this.pos,!0,52,8),this.pos+=8},writeBytes:function(n){var e=n.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&u1(r,u,this),this.pos=r-1,this.writeVarint(u),this.pos+=u},writeMessage:function(n,e,r){this.writeTag(n,ci.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(n,e){e.length&&this.writeMessage(n,aC,e)},writePackedSVarint:function(n,e){e.length&&this.writeMessage(n,lC,e)},writePackedBoolean:function(n,e){e.length&&this.writeMessage(n,hC,e)},writePackedFloat:function(n,e){e.length&&this.writeMessage(n,uC,e)},writePackedDouble:function(n,e){e.length&&this.writeMessage(n,cC,e)},writePackedFixed32:function(n,e){e.length&&this.writeMessage(n,fC,e)},writePackedSFixed32:function(n,e){e.length&&this.writeMessage(n,dC,e)},writePackedFixed64:function(n,e){e.length&&this.writeMessage(n,pC,e)},writePackedSFixed64:function(n,e){e.length&&this.writeMessage(n,mC,e)},writeBytesField:function(n,e){this.writeTag(n,ci.Bytes),this.writeBytes(e)},writeFixed32Field:function(n,e){this.writeTag(n,ci.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(n,e){this.writeTag(n,ci.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(n,e){this.writeTag(n,ci.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(n,e){this.writeTag(n,ci.Fixed64),this.writeSFixed64(e)},writeVarintField:function(n,e){this.writeTag(n,ci.Varint),this.writeVarint(e)},writeSVarintField:function(n,e){this.writeTag(n,ci.Varint),this.writeSVarint(e)},writeStringField:function(n,e){this.writeTag(n,ci.Bytes),this.writeString(e)},writeFloatField:function(n,e){this.writeTag(n,ci.Fixed32),this.writeFloat(e)},writeDoubleField:function(n,e){this.writeTag(n,ci.Fixed64),this.writeDouble(e)},writeBooleanField:function(n,e){this.writeVarintField(n,!!e)}};var Qd=ce(r1);const Ig=3;function gC(n,e,r){e.glyphs=[],n===1&&r.readMessage(_C,e)}function _C(n,e,r){if(n===3){const{id:u,bitmap:m,width:y,height:b,left:I,top:C,advance:A}=r.readMessage(yC,{});e.glyphs.push({id:u,bitmap:new ka({width:y+2*Ig,height:b+2*Ig},m),metrics:{width:y,height:b,left:I,top:C,advance:A}})}else n===4?e.ascender=r.readSVarint():n===5&&(e.descender=r.readSVarint())}function yC(n,e,r){n===1?e.id=r.readVarint():n===2?e.bitmap=r.readBytes():n===3?e.width=r.readVarint():n===4?e.height=r.readVarint():n===5?e.left=r.readSVarint():n===6?e.top=r.readSVarint():n===7&&(e.advance=r.readVarint())}const h1=Ig;function Mg(n){let e=0,r=0;for(const b of n)e+=b.w*b.h,r=Math.max(r,b.w);n.sort((b,I)=>I.h-b.h);const u=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let m=0,y=0;for(const b of n)for(let I=u.length-1;I>=0;I--){const C=u[I];if(!(b.w>C.w||b.h>C.h)){if(b.x=C.x,b.y=C.y,y=Math.max(y,b.y+b.h),m=Math.max(m,b.x+b.w),b.w===C.w&&b.h===C.h){const A=u.pop();Ie.hasImage(u)),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const u in e.updatedImages)this.patchUpdatedImage(this.iconPositions[u],e.getImage(u),r),this.patchUpdatedImage(this.patternPositions[u],e.getImage(u),r)}patchUpdatedImage(e,r,u){if(!e||!r||e.version===r.version)return;e.version=r.version;const[m,y]=e.tl;u.update(r.data,void 0,{x:m,y})}}Ft(Sg,"ImagePosition"),Ft(f1,"ImageAtlas");const Zo={horizontal:1,vertical:2,horizontalOnly:3},d1=-17;class Xh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,r){const u=new Xh;return u.scale=e||1,u.fontStack=r,u}static forImage(e){const r=new Xh;return r.imageName=e,r}}class gc{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,r){const u=new gc;for(let m=0;m=0&&u>=e&&ep[this.text.charCodeAt(u)];u--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const u=new gc;return u.text=this.text.substring(e,r),u.sectionIndex=this.sectionIndex.slice(e,r),u.sections=this.sections,u}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(Xh.forText(e.scale,e.fontStack||r));const u=this.sections.length-1;for(let m=0;m=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function kg(n,e,r,u,m,y,b,I,C,A,O,B,j,$,W){const K=gc.fromFeature(n,m);B===Zo.vertical&&K.verticalizePunctuation(j);let re=[];const de=function(Se,We,Ze,nt,mt,Ke){if(!Se)return[];const st=[],at=function(Rt,jt,Dt,pn,Tt,Xt){let mn=0;for(let jn=0;jn=0;let Et=0;for(let Rt=0;Rt0&&As>si&&(si=As)}else{const ro=Ze[tr.fontStack];if(!ro)continue;ro[Pi]&&(di=ro[Pi]);const _r=We[tr.fontStack];if(!_r)continue;const As=_r.glyphs[Pi];if(!As)continue;if($i=As.metrics,Xi=Pi!==8203?wr:0,Xt){const Ec=_r.ascender!==void 0?Math.abs(_r.ascender):0,rf=_r.descender!==void 0?Math.abs(_r.descender):0,of=(Ec+rf)*qn;Ii-r/2;){if(b--,b<0)return!1;I-=n[b].dist(y),y=n[b]}I+=n[b].dist(n[b+1]),b++;const C=[];let A=0;for(;Iu;)A-=C.shift().angleDelta;if(A>m)return!1;b++,I+=O.dist(B)}return!0}function b1(n){let e=0;for(let r=0;rA){const W=(A-C)/$,K=Nn(B.x,j.x,W),re=Nn(B.y,j.y,W),de=new Aa(K,re,0,j.angleTo(B),O);return!b||x1(n,de,I,b,e)?de:void 0}C+=$}}function EC(n,e,r,u,m,y,b,I,C){const A=w1(u,y,b),O=E1(u,m),B=O*b,j=n[0].x===0||n[0].x===C||n[0].y===0||n[0].y===C;return e-B=0&&Ee=0&&Ce=0&&j+A<=O){const Se=new Aa(Ee,Ce,0,Te,W);Se._round(),u&&!x1(n,Se,y,u,m)||$.push(Se)}}B+=de}return I||$.length||b||($=T1(n,B/2,r,u,m,y,b,!0,C)),$}function I1(n,e,r,u,m){const y=[];for(let b=0;b=u&&B.x>=u||(O.x>=u?O=new Ie(u,O.y+(u-O.x)/(B.x-O.x)*(B.y-O.y))._round():B.x>=u&&(B=new Ie(u,O.y+(u-O.x)/(B.x-O.x)*(B.y-O.y))._round()),O.y>=m&&B.y>=m||(O.y>=m?O=new Ie(O.x+(m-O.y)/(B.y-O.y)*(B.x-O.x),m)._round():B.y>=m&&(B=new Ie(O.x+(m-O.y)/(B.y-O.y)*(B.x-O.x),m)._round()),C&&O.equals(C[C.length-1])||(C=[O],y.push(C)),C.push(B)))))}}return y}Ft(Aa,"Anchor");const Wh=1e20;function M1(n,e,r,u,m,y,b,I,C){for(let A=e;A-1);C++,y[C]=I,b[C]=A,b[C+1]=Wh}for(let I=0,C=0;I{let I=this.entries[m];I||(I=this.entries[m]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let C=I.glyphs[y];if(C!==void 0)return void b(null,{stack:m,id:y,glyph:C});if(C=this._tinySDF(I,m,y),C)return I.glyphs[y]=C,void b(null,{stack:m,id:y,glyph:C});const A=Math.floor(y/256);if(256*A>65535)return void b(new Error("glyphs > 65535 not supported"));if(I.ranges[A])return void b(null,{stack:m,id:y,glyph:C});let O=I.requests[A];O||(O=I.requests[A]=[],_c.loadGlyphRange(m,A,this.url,this.requestManager,(B,j)=>{if(j){I.ascender=j.ascender,I.descender=j.descender;for(const $ in j.glyphs)this._doesCharSupportLocalGlyph(+$)||(I.glyphs[+$]=j.glyphs[+$]);I.ranges[A]=!0}for(const $ of O)$(B,j);delete I.requests[A]})),O.push((B,j)=>{B?b(B):j&&b(null,{stack:m,id:y,glyph:j.glyphs[y]||null})})},(m,y)=>{if(m)r(m);else if(y){const b={};for(const{stack:I,id:C,glyph:A}of y)b[I]===void 0&&(b[I]={}),b[I].glyphs===void 0&&(b[I].glyphs={}),b[I].glyphs[C]=A&&{id:A.id,bitmap:A.bitmap.clone(),metrics:A.metrics},b[I].ascender=this.entries[I].ascender,b[I].descender=this.entries[I].descender;r(null,b)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Ag.none&&(this.localGlyphMode===Ag.all?!!this.localFontFamily:!!this.localFontFamily&&(zt["CJK Unified Ideographs"](e)||zt["Hangul Syllables"](e)||zt.Hiragana(e)||zt.Katakana(e)||zt["CJK Symbols and Punctuation"](e)))}_tinySDF(e,r,u){const m=this.localFontFamily;if(!m||!this._doesCharSupportLocalGlyph(u))return;let y=e.tinySDF;if(!y){let K="400";/bold/i.test(r)?K="900":/medium/i.test(r)?K="500":/light/i.test(r)&&(K="200"),y=e.tinySDF=new _c.TinySDF({fontFamily:m,fontWeight:K,fontSize:24*ks,buffer:3*ks,radius:8*ks}),y.fontWeight=K}if(this.localGlyphs[y.fontWeight][u])return this.localGlyphs[y.fontWeight][u];const b=String.fromCharCode(u),{data:I,width:C,height:A,glyphWidth:O,glyphHeight:B,glyphLeft:j,glyphTop:$,glyphAdvance:W}=y.draw(b);return this.localGlyphs[y.fontWeight][u]={id:u,bitmap:new ka({width:C,height:A},I),metrics:{width:O/ks,height:B/ks,left:j/ks,top:$/ks-27,advance:W/ks,localGlyph:!0}}}}_c.loadGlyphRange=function(n,e,r,u,m){const y=256*e,b=y+255,I=u.transformRequest(u.normalizeGlyphsURL(r).replace("{fontstack}",n).replace("{range}",`${y}-${b}`),vr.Glyphs);zs(I,(C,A)=>{if(C)m(C);else if(A){const O={},B=function(j){return new Qd(j).readFields(gC,{})}(A);for(const j of B.glyphs)O[j.id]=j;m(null,{glyphs:O,ascender:B.ascender,descender:B.descender})}})},_c.TinySDF=class{constructor({fontSize:n=24,buffer:e=3,radius:r=8,cutoff:u=.25,fontFamily:m="sans-serif",fontWeight:y="normal",fontStyle:b="normal"}={}){this.buffer=e,this.cutoff=u,this.radius=r;const I=this.size=n+4*e,C=this._createCanvas(I),A=this.ctx=C.getContext("2d",{willReadFrequently:!0});A.font=`${b} ${y} ${n}px ${m}`,A.textBaseline="alphabetic",A.textAlign="left",A.fillStyle="black",this.gridOuter=new Float64Array(I*I),this.gridInner=new Float64Array(I*I),this.f=new Float64Array(I),this.z=new Float64Array(I+1),this.v=new Uint16Array(I)}_createCanvas(n){const e=document.createElement("canvas");return e.width=e.height=n,e}draw(n){const{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:u,actualBoundingBoxLeft:m,actualBoundingBoxRight:y}=this.ctx.measureText(n),b=Math.ceil(r),I=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(y-m))),C=Math.min(this.size-this.buffer,b+Math.ceil(u)),A=I+2*this.buffer,O=C+2*this.buffer,B=Math.max(A*O,0),j=new Uint8ClampedArray(B),$={data:j,width:A,height:O,glyphWidth:I,glyphHeight:C,glyphTop:b,glyphLeft:0,glyphAdvance:e};if(I===0||C===0)return $;const{ctx:W,buffer:K,gridInner:re,gridOuter:de}=this;W.clearRect(K,K,I,C),W.fillText(n,K,K+b);const Te=W.getImageData(K,K,I,C);de.fill(Wh,0,B),re.fill(0,0,B);for(let pe=0;pe0?We*We:0,re[Se]=We<0?We*We:0}}M1(de,0,0,A,O,A,this.f,this.v,this.z),M1(re,K,K,I,C,A,this.f,this.v,this.z);for(let pe=0;peKe+st[1]-st[0],W=B.reduce($,0),K=j.reduce($,0),re=I-W,de=C-K;let Te=0,pe=W,Ee=0,Ce=K,Se=0,We=re,Ze=0,nt=de;if(y.content&&u){const Ke=y.content;Te=tp(B,0,Ke[0]),Ee=tp(j,0,Ke[1]),pe=tp(B,Ke[0],Ke[2]),Ce=tp(j,Ke[1],Ke[3]),Se=Ke[0]-Te,Ze=Ke[1]-Ee,We=Ke[2]-Ke[0]-pe,nt=Ke[3]-Ke[1]-Ce}const mt=(Ke,st,at,ht)=>{const Et=np(Ke.stretch-Te,pe,A,n.left),et=ip(Ke.fixed-Se,We,Ke.stretch,W),Rt=np(st.stretch-Ee,Ce,O,n.top),jt=ip(st.fixed-Ze,nt,st.stretch,K),Dt=np(at.stretch-Te,pe,A,n.left),pn=ip(at.fixed-Se,We,at.stretch,W),Tt=np(ht.stretch-Ee,Ce,O,n.top),Xt=ip(ht.fixed-Ze,nt,ht.stretch,K),mn=new Ie(Et,Rt),jn=new Ie(Dt,Rt),gn=new Ie(Dt,Tt),en=new Ie(Et,Tt),gi=new Ie(et/b,jt/b),vn=new Ie(pn/b,Xt/b),xn=e*Math.PI/180;if(xn){const fi=Math.sin(xn),si=Math.cos(xn),Ii=[si,-fi,fi,si];mn._matMult(Ii),jn._matMult(Ii),en._matMult(Ii),gn._matMult(Ii)}const oi=Ke.stretch+Ke.fixed,hi=st.stretch+st.fixed;return{tl:mn,tr:jn,bl:en,br:gn,tex:{x:y.paddedRect.x+yc+oi,y:y.paddedRect.y+yc+hi,w:at.stretch+at.fixed-oi,h:ht.stretch+ht.fixed-hi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:gi,pixelOffsetBR:vn,minFontScaleX:We/b/A,minFontScaleY:nt/b/O,isSDF:r}};if(u&&(y.stretchX||y.stretchY)){const Ke=C1(B,re,W),st=C1(j,de,K);for(let at=0;at0)for(let u=(this.length>>1)-1;u>=0;u--)this._down(u)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:u}=this,m=r[e];for(;e>0;){const y=e-1>>1,b=r[y];if(u(m,b)>=0)break;r[e]=b,e=y}r[e]=m}_down(e){const{data:r,compare:u}=this,m=this.length>>1,y=r[e];for(;e=0)break;r[e]=I,e=b}r[e]=y}}function MC(n,e){return ne?1:0}function SC(n,e=1,r=!1){let u=1/0,m=1/0,y=-1/0,b=-1/0;const I=n[0];for(let $=0;$y)&&(y=W.x),(!$||W.y>b)&&(b=W.y)}const C=Math.min(y-u,b-m);let A=C/2;const O=new IC([],kC);if(C===0)return new Ie(u,m);for(let $=u;$B.d||!B.d)&&(B=$,r&&console.log("found best %d after %d probes",Math.round(1e4*$.d)/1e4,j)),$.max-B.d<=e||(A=$.h/2,O.push(new vc($.p.x-A,$.p.y-A,A,n)),O.push(new vc($.p.x+A,$.p.y-A,A,n)),O.push(new vc($.p.x-A,$.p.y+A,A,n)),O.push(new vc($.p.x+A,$.p.y+A,A,n)),j+=4)}return r&&(console.log(`num probes: ${j}`),console.log(`best distance: ${B.d}`)),B.p}function kC(n,e){return e.max-n.max}class vc{constructor(e,r,u,m){this.p=new Ie(e,r),this.h=u,this.d=function(y,b){let I=!1,C=1/0;for(let A=0;Ay.y!=K.y>y.y&&y.x<(K.x-W.x)*(y.y-W.y)/(K.y-W.y)+W.x&&(I=!I),C=Math.min(C,Tx(y,W,K))}}return(I?1:-1)*Math.sqrt(C)}(this.p,m),this.max=this.d+this.h*Math.SQRT2}}const xc=7,Pg=Number.POSITIVE_INFINITY,CC=Math.sqrt(2);function A1(n,[e,r]){let u=0,m=0;if(r===Pg){e<0&&(e=0);const y=e/CC;switch(n){case"top-right":case"top-left":m=y-xc;break;case"bottom-right":case"bottom-left":m=-y+xc;break;case"bottom":m=-e+xc;break;case"top":m=e-xc}switch(n){case"top-right":case"bottom-right":u=-y;break;case"top-left":case"bottom-left":u=y;break;case"left":u=e;break;case"right":u=-e}}else{switch(e=Math.abs(e),r=Math.abs(r),n){case"top-right":case"top-left":case"top":m=r-xc;break;case"bottom-right":case"bottom-left":case"bottom":m=-r+xc}switch(n){case"top-right":case"bottom-right":case"right":u=-e;break;case"top-left":case"bottom-left":case"left":u=e}}return[u,m]}function AC(n,e,r,u,m,y,b,I,C,A){n.createArrays(),n.tilePixelRatio=Wt/(512*n.overscaling),n.compareText={},n.iconsNeedLinear=!1;const O=n.layers[0].layout,B=n.layers[0]._unevaluatedLayout._values,j={};if(n.textSizeData.kind==="composite"){const{minZoom:K,maxZoom:re}=n.textSizeData;j.compositeTextSizes=[B["text-size"].possiblyEvaluate(new N(K),I),B["text-size"].possiblyEvaluate(new N(re),I)]}if(n.iconSizeData.kind==="composite"){const{minZoom:K,maxZoom:re}=n.iconSizeData;j.compositeIconSizes=[B["icon-size"].possiblyEvaluate(new N(K),I),B["icon-size"].possiblyEvaluate(new N(re),I)]}j.layoutTextSize=B["text-size"].possiblyEvaluate(new N(C+1),I),j.layoutIconSize=B["icon-size"].possiblyEvaluate(new N(C+1),I),j.textMaxSize=B["text-size"].possiblyEvaluate(new N(18),I);const $=O.get("text-rotation-alignment")==="map"&&O.get("symbol-placement")!=="point",W=O.get("text-size");for(const K of n.features){const re=O.get("text-font").evaluate(K,{},I).join(","),de=W.evaluate(K,{},I),Te=j.layoutTextSize.evaluate(K,{},I),pe=(j.layoutIconSize.evaluate(K,{},I),{horizontal:{},vertical:void 0}),Ee=K.text;let Ce,Se=[0,0];if(Ee){const nt=Ee.toString(),mt=O.get("text-letter-spacing").evaluate(K,{},I)*wr,Ke=O.get("text-line-height").evaluate(K,{},I)*wr,st=Vm(nt)?mt:0,at=O.get("text-anchor").evaluate(K,{},I),ht=O.get("text-variable-anchor");if(!ht){const Dt=O.get("text-radial-offset").evaluate(K,{},I);Se=Dt?A1(at,[Dt*wr,Pg]):O.get("text-offset").evaluate(K,{},I).map(pn=>pn*wr)}let Et=$?"center":O.get("text-justify").evaluate(K,{},I);const et=O.get("symbol-placement")==="point",Rt=et?O.get("text-max-width").evaluate(K,{},I)*wr:1/0,jt=Dt=>{n.allowVerticalPlacement&&vh(nt)&&(pe.vertical=kg(Ee,e,r,m,re,Rt,Ke,at,Dt,st,Se,Zo.vertical,!0,Te,de))};if(!$&&ht){const Dt=Et==="auto"?ht.map(Tt=>Lg(Tt)):[Et];let pn=!1;for(let Tt=0;Tt=0||!vh(nt)){const Dt=kg(Ee,e,r,m,re,Rt,Ke,at,Et,st,Se,Zo.horizontal,!1,Te,de);Dt&&(pe.horizontal[Et]=Dt)}jt(et?"left":Et)}}let We=!1;if(K.icon&&K.icon.name){const nt=u[K.icon.name];nt&&(Ce=bC(m[K.icon.name],O.get("icon-offset").evaluate(K,{},I),O.get("icon-anchor").evaluate(K,{},I)),We=nt.sdf,n.sdfIcons===void 0?n.sdfIcons=nt.sdf:n.sdfIcons!==nt.sdf&&yn("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(nt.pixelRatio!==n.pixelRatio||O.get("icon-rotate").constantOr(1)!==0)&&(n.iconsNeedLinear=!0))}const Ze=L1(pe.horizontal)||pe.vertical;n.iconsInText||(n.iconsInText=!!Ze&&Ze.iconsInText),(Ze||Ce)&&PC(n,K,pe,Ce,u,j,Te,0,Se,We,b,I,A)}y&&n.generateCollisionDebugBuffers(C,n.collisionBoxArray)}function Lg(n){switch(n){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function PC(n,e,r,u,m,y,b,I,C,A,O,B,j){let $=y.textMaxSize.evaluate(e,{},B);$===void 0&&($=b);const W=n.layers[0].layout,K=W.get("icon-offset").evaluate(e,{},B),re=L1(r.horizontal)||r.vertical,de=j.name==="globe",Te=wr,pe=b/Te,Ee=n.tilePixelRatio*$/Te,Ce=(at=n.overscaling,n.zoom>18&&at>2&&(at>>=1),Math.max(Wt/(512*at),1)*W.get("symbol-spacing")),Se=W.get("text-padding")*n.tilePixelRatio,We=W.get("icon-padding")*n.tilePixelRatio,Ze=Je(W.get("text-max-angle")),nt=W.get("text-rotation-alignment")==="map"&&W.get("symbol-placement")!=="point",mt=W.get("icon-rotation-alignment")==="map"&&W.get("symbol-placement")!=="point",Ke=W.get("symbol-placement"),st=Ce/2;var at;const ht=W.get("icon-text-fit");let Et;u&&ht!=="none"&&(n.allowVerticalPlacement&&r.vertical&&(Et=v1(u,r.vertical,ht,W.get("icon-text-fit-padding"),K,pe)),re&&(u=v1(u,re,ht,W.get("icon-text-fit-padding"),K,pe)));const et=(Rt,jt,Dt)=>{if(jt.x<0||jt.x>=Wt||jt.y<0||jt.y>=Wt)return;let pn=null;if(de){const{x:Tt,y:Xt,z:mn}=j.projectTilePoint(jt.x,jt.y,Dt);pn={anchor:new Aa(Tt,Xt,mn,0,void 0),up:j.upVector(Dt,jt.x,jt.y)}}(function(Tt,Xt,mn,jn,gn,en,gi,vn,xn,oi,hi,fi,si,Ii,Di,qi,ai,tr,Zi,Pi,qn,$i,di,io,Xi){const Er=Tt.addToLineVertexArray(Xt,jn);let gr,ro,_r,As,Ec,rf,of,hb=0,fb=0,db=0,pb=0,Xg=-1,Wg=-1;const Js={};let mb=Gm("");const fu=mn?mn.anchor:Xt;let Yg=0,Hg=0;if(xn._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Yg,Hg]=xn.layout.get("text-offset").evaluate(qn,{},Xi).map(Lo=>Lo*wr):(Yg=xn.layout.get("text-radial-offset").evaluate(qn,{},Xi)*wr,Hg=Pg),Tt.allowVerticalPlacement&&gn.vertical){const Lo=gn.vertical;if(Di)rf=Rg(Lo),vn&&(of=Rg(vn));else{const Ro=xn.layout.get("text-rotate").evaluate(qn,{},Xi)+90;_r=rp(oi,fu,Xt,hi,fi,si,Lo,Ii,Ro,qi),vn&&(As=rp(oi,fu,Xt,hi,fi,si,vn,tr,Ro))}}if(en){const Lo=xn.layout.get("icon-rotate").evaluate(qn,{},Xi),Ro=xn.layout.get("icon-text-fit")!=="none",sf=k1(en,Lo,di,Ro),Jg=vn?k1(vn,Lo,di,Ro):void 0;ro=rp(oi,fu,Xt,hi,fi,si,en,tr,Lo),hb=4*sf.length;const gb=Tt.iconSizeData;let du=null;gb.kind==="source"?(du=[Ss*xn.layout.get("icon-size").evaluate(qn,{},Xi)],du[0]>ml&&yn(`${Tt.layerIds[0]}: Value for "icon-size" is >= ${Yh}. Reduce your "icon-size".`)):gb.kind==="composite"&&(du=[Ss*$i.compositeIconSizes[0].evaluate(qn,{},Xi),Ss*$i.compositeIconSizes[1].evaluate(qn,{},Xi)],(du[0]>ml||du[1]>ml)&&yn(`${Tt.layerIds[0]}: Value for "icon-size" is >= ${Yh}. Reduce your "icon-size".`)),Tt.addSymbols(Tt.icon,sf,du,Pi,Zi,qn,!1,mn,Xt,Er.lineStartIndex,Er.lineLength,-1,io,Xi),Xg=Tt.icon.placedSymbolArray.length-1,Jg&&(fb=4*Jg.length,Tt.addSymbols(Tt.icon,Jg,du,Pi,Zi,qn,Zo.vertical,mn,Xt,Er.lineStartIndex,Er.lineLength,-1,io,Xi),Wg=Tt.icon.placedSymbolArray.length-1)}for(const Lo in gn.horizontal){const Ro=gn.horizontal[Lo];gr||(mb=Gm(Ro.text),Di?Ec=Rg(Ro):gr=rp(oi,fu,Xt,hi,fi,si,Ro,Ii,xn.layout.get("text-rotate").evaluate(qn,{},Xi),qi));const sf=Ro.positionedLines.length===1;if(db+=P1(Tt,mn,Xt,Ro,gi,xn,Di,qn,qi,Er,gn.vertical?Zo.horizontal:Zo.horizontalOnly,sf?Object.keys(gn.horizontal):[Lo],Js,Xg,$i,io,Xi),sf)break}gn.vertical&&(pb+=P1(Tt,mn,Xt,gn.vertical,gi,xn,Di,qn,qi,Er,Zo.vertical,["vertical"],Js,Wg,$i,io,Xi));let bl=-1;const Kg=(Lo,Ro)=>Lo?Math.max(Lo,Ro):Ro;bl=Kg(Ec,bl),bl=Kg(rf,bl),bl=Kg(of,bl);const oA=bl>-1?1:0;Tt.glyphOffsetArray.length>=_l.MAX_GLYPHS&&yn("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),qn.sortKey!==void 0&&Tt.addToSortKeyRanges(Tt.symbolInstances.length,qn.sortKey),Tt.symbolInstances.emplaceBack(fu.x,fu.y,fu.z,Xt.x,Xt.y,Js.right>=0?Js.right:-1,Js.center>=0?Js.center:-1,Js.left>=0?Js.left:-1,Js.vertical>=0?Js.vertical:-1,Xg,Wg,mb,gr!==void 0?gr:Tt.collisionBoxArray.length,gr!==void 0?gr+1:Tt.collisionBoxArray.length,_r!==void 0?_r:Tt.collisionBoxArray.length,_r!==void 0?_r+1:Tt.collisionBoxArray.length,ro!==void 0?ro:Tt.collisionBoxArray.length,ro!==void 0?ro+1:Tt.collisionBoxArray.length,As||Tt.collisionBoxArray.length,As?As+1:Tt.collisionBoxArray.length,hi,db,pb,hb,fb,oA,0,Yg,Hg,bl)})(n,jt,pn,Rt,r,u,m,Et,n.layers[0],n.collisionBoxArray,e.index,e.sourceLayerIndex,n.index,Se,nt,C,0,We,mt,K,e,y,A,O,B)};if(Ke==="line")for(const Rt of I1(e.geometry,0,0,Wt,Wt)){const jt=EC(Rt,Ce,Ze,r.vertical||re,u,Te,Ee,n.overscaling,Wt);for(const Dt of jt)re&&LC(n,re.text,st,Dt)||et(Rt,Dt,B)}else if(Ke==="line-center"){for(const Rt of e.geometry)if(Rt.length>1){const jt=wC(Rt,Ze,r.vertical||re,u,Te,Ee);jt&&et(Rt,jt,B)}}else if(e.type==="Polygon")for(const Rt of vg(e.geometry,0)){const jt=SC(Rt,16);et(Rt[0],new Aa(jt.x,jt.y,0,0,void 0),B)}else if(e.type==="LineString")for(const Rt of e.geometry)et(Rt,new Aa(Rt[0].x,Rt[0].y,0,0,void 0),B);else if(e.type==="Point")for(const Rt of e.geometry)for(const jt of Rt)et([jt],new Aa(jt.x,jt.y,0,0,void 0),B)}const Yh=255,ml=Yh*Ss;function P1(n,e,r,u,m,y,b,I,C,A,O,B,j,$,W,K,re){const de=function(Ee,Ce,Se,We,Ze,nt,mt,Ke){const st=[];if(Ce.positionedLines.length===0)return st;const at=We.layout.get("text-rotate").evaluate(nt,{})*Math.PI/180,ht=function(Dt){const pn=Dt[0],Tt=Dt[1],Xt=pn*Tt;return Xt>0?[pn,-Tt]:Xt<0?[-pn,Tt]:pn===0?[Tt,pn]:[Tt,-pn]}(Se);let Et=Math.abs(Ce.top-Ce.bottom);for(const Dt of Ce.positionedLines)Et-=Dt.lineOffset;const et=Ce.positionedLines.length,Rt=Et/et;let jt=Ce.top-Se[1];for(let Dt=0;Dtml&&yn(`${n.layerIds[0]}: Value for "text-size" is >= ${Yh}. Reduce your "text-size".`)):Te.kind==="composite"&&(pe=[Ss*W.compositeTextSizes[0].evaluate(I,{},re),Ss*W.compositeTextSizes[1].evaluate(I,{},re)],(pe[0]>ml||pe[1]>ml)&&yn(`${n.layerIds[0]}: Value for "text-size" is >= ${Yh}. Reduce your "text-size".`)),n.addSymbols(n.text,de,pe,C,b,I,O,e,r,A.lineStartIndex,A.lineLength,$,K,re);for(const Ee of B)j[Ee]=n.text.placedSymbolArray.length-1;return 4*de.length}function L1(n){for(const e in n)return n[e];return null}function rp(n,e,r,u,m,y,b,I,C,A){let O=b.top,B=b.bottom,j=b.left,$=b.right;const W=b.collisionPadding;if(W&&(j-=W[0],O-=W[1],$+=W[2],B+=W[3]),C){const K=new Ie(j,O),re=new Ie($,O),de=new Ie(j,B),Te=new Ie($,B),pe=Je(C);let Ee=new Ie(0,0);A&&(Ee=new Ie(A[0],A[1])),K._rotateAround(pe,Ee),re._rotateAround(pe,Ee),de._rotateAround(pe,Ee),Te._rotateAround(pe,Ee),j=Math.min(K.x,re.x,de.x,Te.x),$=Math.max(K.x,re.x,de.x,Te.x),O=Math.min(K.y,re.y,de.y,Te.y),B=Math.max(K.y,re.y,de.y,Te.y)}return n.emplaceBack(e.x,e.y,e.z,r.x,r.y,j,O,$,B,I,u,m,y),n.length-1}function Rg(n){n.collisionPadding&&(n.top-=n.collisionPadding[1],n.bottom+=n.collisionPadding[3]);const e=n.bottom-n.top;return e>0?Math.max(10,e):null}function LC(n,e,r,u){const m=n.compareText;if(e in m){const y=m[e];for(let b=y.length-1;b>=0;b--)if(u.dist(y[b])pe&&(Ee(Se,ht,Ze,nt,st,at),Ee(ht,We,st,at,mt,Ke))}Ee(B,j,u,y,m,y),Ee(j,$,m,y,m,b),Ee($,W,m,b,u,b),Ee(W,B,u,b,u,y),K-=pe,re-=pe,de+=pe,Te+=pe;const Ce=1/Math.max(de-K,Te-re);return{scale:Ce,x:K*Ce,y:re*Ce,x2:de*Ce,y2:Te*Ce,projection:e}}const RC=Ts(new Float32Array(16));class gl{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,r){return{x:0,y:0,z:0}}unproject(e,r){return new ri(0,0)}projectTilePoint(e,r,u){return{x:e,y:r,z:0}}locationPoint(e,r,u=!0){return e._coordinatePoint(e.locationCoordinate(r),u)}pixelsPerMeter(e,r){return Ms(1,e)*r}pixelSpaceConversion(e,r,u){return 1}farthestPixelDistance(e){return R1(e,e.pixelsPerMeter)}pointCoordinate(e,r,u,m){const y=e.horizonLineFromTop(!1),b=new Ie(r,Math.max(y,u));return e.rayIntersectionCoordinate(e.pointRayIntersection(b,m))}pointCoordinate3D(e,r,u){const m=new Ie(r,u);if(e.elevation)return e.elevation.pointCoordinate(m);{const y=this.pointCoordinate(e,m.x,m.y,0);return[y.x,y.y,y.z]}}isPointAboveHorizon(e,r){if(e.elevation)return!this.pointCoordinate3D(e,r.x,r.y);const u=e.horizonLineFromTop();return r.y0?r<-bc+u&&(r=-bc+u):r>bc-u&&(r=bc-u);const b=y/Math.pow(sp(r),m);let I=b*Math.sin(m*e),C=y-b*Math.cos(m*e);return I=.5*(I/Math.PI+.5),C=.5*(C/Math.PI+.5),{x:I,y:this.southernCenter?C:1-C,z:0}}unproject(e,r){e=(2*e-.5)*Math.PI,this.southernCenter&&(r=1-r),r=(2*(1-r)-.5)*Math.PI;const{n:u,f:m}=this,y=m-r,b=Math.sign(y),I=Math.sign(u)*Math.sqrt(e*e+y*y);let C=Math.atan2(e,Math.abs(y))*b;y*u<0&&(C-=Math.PI*Math.sign(e)*b);const A=Mt(At(C/u)+this.center[0],-180,180),O=Mt(At(2*Math.atan(Math.pow(m/I,1/u))-bc),-Or,Or);return new ri(A,this.southernCenter?-O:O)}}class D1 extends gl{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,r){return{x:Xs(e),y:Ws(r),z:0}}unproject(e,r){const u=qo(e),m=zr(r);return new ri(u,m)}}const z1=Je(Or);class BC extends gl{project(e,r){const u=(r=Je(r))*r,m=u*u;return{x:.5*((e=Je(e))*(.8707-.131979*u+m*(m*(.003971*u-.001529*m)-.013791))/Math.PI+.5),y:1-.5*(r*(1.007226+u*(.015085+m*(.028874*u-.044475-.005916*m)))/Math.PI+1),z:0}}unproject(e,r){e=(2*e-.5)*Math.PI;let u=r=(2*(1-r)-1)*Math.PI,m=25,y=0,b=u*u;do{b=u*u;const A=b*b;y=(u*(1.007226+b*(.015085+A*(.028874*b-.044475-.005916*A)))-r)/(1.007226+b*(.045255+A*(.259866*b-.311325-.06507600000000001*A))),u=Mt(u-y,-z1,z1)}while(Math.abs(y)>1e-6&&--m>0);b=u*u;const I=Mt(At(e/(.8707+b*(b*(b*b*b*(.003971-.001529*b)-.013791)-.131979))),-180,180),C=At(u);return new ri(I,C)}}const O1=Je(Or);class FC extends gl{project(e,r){r=Je(r),e=Je(e);const u=Math.cos(r),m=2/Math.PI,y=Math.acos(u*Math.cos(e/2)),b=Math.sin(y)/y,I=.5*(e*m+2*u*Math.sin(e/2)/b)||0,C=.5*(r+Math.sin(r)/b)||0;return{x:.5*(I/Math.PI+.5),y:1-.5*(C/Math.PI+1),z:0}}unproject(e,r){let u=e=(2*e-.5)*Math.PI,m=r=(2*(1-r)-1)*Math.PI,y=25;const b=1e-6;let I=0,C=0;do{const A=Math.cos(m),O=Math.sin(m),B=2*O*A,j=O*O,$=A*A,W=Math.cos(u/2),K=Math.sin(u/2),re=2*W*K,de=K*K,Te=1-$*W*W,pe=Te?1/Te:0,Ee=Te?Math.acos(A*W)*Math.sqrt(1/Te):0,Ce=.5*(2*Ee*A*K+2*u/Math.PI)-e,Se=.5*(Ee*O+m)-r,We=.5*pe*($*de+Ee*A*W*j)+1/Math.PI,Ze=pe*(re*B/4-Ee*O*K),nt=.125*pe*(B*K-Ee*O*$*re),mt=.5*pe*(j*W+Ee*de*A)+.5,Ke=Ze*nt-mt*We;I=(Se*Ze-Ce*mt)/Ke,C=(Ce*nt-Se*We)/Ke,u=Mt(u-I,-Math.PI,Math.PI),m=Mt(m-C,-O1,O1)}while((Math.abs(I)>b||Math.abs(C)>b)&&--y>0);return new ri(At(u),At(m))}}class N1 extends gl{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Je(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,r){const{scale:u,cosPhi:m}=this;return{x:Je(e)*m*u+.5,y:-Math.sin(Je(r))/m*u+.5,z:0}}unproject(e,r){const{scale:u,cosPhi:m}=this,y=-(r-.5)/u,b=Mt(At((e-.5)/u)/m,-180,180),I=Math.asin(Mt(y*m,-1,1)),C=Mt(At(I),-Or,Or);return new ri(b,C)}}class VC extends D1{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,r,u){const m=Dh(e,r,u);return zi(m,m,zh($s(u))),{x:m[0],y:m[1],z:m[2]}}locationPoint(e,r){const u=sc(r.lat,r.lng),m=eo([],u),y=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(r),e._centerAltitude):e._centerAltitude;Ah(u,u,m,Ms(1,0)*Wt*y);const b=Ts(new Float64Array(16));return nu(b,e.pixelMatrix,e.globeMatrix),zi(u,u,b),new Ie(u[0],u[1])}pixelsPerMeter(e,r){return Ms(1,0)*r}pixelSpaceConversion(e,r,u){const m=Ms(1,e)*r,y=Nn(Ms(1,45)*r,m,u);return this.pixelsPerMeter(e,r)/y}createTileMatrix(e,r,u){const m=ig($s(u.canonical));return nu(new Float64Array(16),e.globeMatrix,m)}createInversionMatrix(e,r){const{center:u}=e,m=zh($s(r));return Dd(m,m,Je(u.lng)),Xm(m,m,Je(u.lat)),iu(m,m,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(m)}pointCoordinate(e,r,u,m){return cx(e,r,u,!0)||new lc(0,0)}pointCoordinate3D(e,r,u){const m=this.pointCoordinate(e,r,u,0);return[m.x,m.y,m.z]}isPointAboveHorizon(e,r){return!cx(e,r.x,r.y,!1)}farthestPixelDistance(e){const r=function(m,y){const b=m.cameraToCenterDistance,I=m._centerAltitude*y,C=m._camera,A=m._camera.forward(),O=Ma([],Go([],A,-b),[0,0,I]),B=m.worldSize/(2*Math.PI),j=[0,0,-B],$=m.width/m.height,W=Math.tan(m.fovAboveCenter),K=Go([],C.up(),W),re=Go([],C.right(),W*$),de=eo([],Ma([],Ma([],A,K),re)),Te=[];let pe;if(new Km(O,de).closestPointOnSphere(j,B,Te)){const Ee=Ma([],Te,j),Ce=Is([],Ee,O);pe=Math.cos(m.fovAboveCenter)*Sh(Ce)}else{const Ee=Is([],O,j),Ce=Is([],j,O);eo(Ce,Ce);const Se=Sh(Ee)-B;pe=Math.sqrt(Se*(Se+2*B));const We=Math.acos(pe/(B+Se))-Math.acos(ts(A,Ce));pe*=Math.cos(We)}return 1.01*pe}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),u=ac(e.zoom);if(u>0){const m=R1(e,Ms(1,e.center.lat)*e.worldSize),y=e.worldSize/(2*Math.PI),b=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Nn(r,m+y*(1-Math.cos(b)),Math.pow(u,10))}return r}upVector(e,r,u){return Dh(r,u,e,1)}upVectorScale(e){return{metersToTile:zd(Nd($s(e)))}}}function B1(n){const e=n.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(n.name){case"mercator":return new D1(n);case"equirectangular":return new OC(n);case"naturalEarth":return new BC(n);case"equalEarth":return new zC(n);case"winkelTripel":return new FC(n);case"albers":return r?new N1(n):new DC(n);case"lambertConformalConic":return r?new N1(n):new NC(n);case"globe":return new VC(n)}throw new Error(`Invalid projection name: ${n.name}`)}const UC=Xd.types,jC=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ap(n,e,r,u,m,y,b,I,C,A,O,B,j){const $=I?Math.min(ml,Math.round(I[0])):0,W=I?Math.min(ml,Math.round(I[1])):0;n.emplaceBack(e,r,Math.round(32*u),Math.round(32*m),y,b,($<<1)+(C?1:0),W,16*A,16*O,256*B,256*j)}function lp(n,e,r,u,m,y,b){n.emplaceBack(e,r,u,m,y,b)}function up(n,e,r,u,m){n.emplaceBack(e,r,u,m),n.emplaceBack(e,r,u,m),n.emplaceBack(e,r,u,m),n.emplaceBack(e,r,u,m)}function GC(n){for(const e of n.sections)if(jm(e.text))return!0;return!1}class Dg{constructor(e){this.layoutVertexArray=new ct,this.indexArray=new qt,this.programConfigurations=e,this.segments=new ji,this.dynamicLayoutVertexArray=new dt,this.opacityVertexArray=new $t,this.placedSymbolArray=new Ui,this.globeExtVertexArray=new bt}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,r,u,m){this.isEmpty()||(u&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Kk.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,r),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Qk.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,jC,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Jk.members,!0)),this.opacityVertexBuffer.itemSize=1),(u||m)&&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(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Ft(Dg,"SymbolBuffers");class zg{constructor(e,r,u){this.layoutVertexArray=new e,this.layoutAttributes=r,this.indexArray=new u,this.segments=new ji,this.collisionVertexArray=new An,this.collisionVertexArrayExt=new Cn}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,eC.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,tC.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Ft(zg,"CollisionBuffers");class _l{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(b=>b.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Ts([]),this.placementViewportMatrix=Ts([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Eg(this.zoom,r["text-size"]),this.iconSizeData=Eg(this.zoom,r["icon-size"]);const u=this.layers[0].layout,m=u.get("symbol-sort-key"),y=u.get("symbol-z-order");this.canOverlap=u.get("text-allow-overlap")||u.get("icon-allow-overlap")||u.get("text-ignore-placement")||u.get("icon-ignore-placement"),this.sortFeaturesByKey=y!=="viewport-y"&&m.constantOr(1)!==void 0,this.sortFeaturesByY=(y==="viewport-y"||y==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=u.get("text-writing-mode").map(b=>Zo[b]),this.stateDependentLayerIds=this.layers.filter(b=>b.isStateDependent()).map(b=>b.id),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new Dg(new tu(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Dg(new tu(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Qr,this.lineVertexArray=new tc,this.symbolInstances=new vi}calculateGlyphDependencies(e,r,u,m,y){for(let b=0;b0)&&(C.value.kind!=="constant"||C.value.value.length>0),j=O.value.kind!=="constant"||!!O.value.value||Object.keys(O.parameters).length>0,$=b.get("symbol-sort-key");if(this.features=[],!B&&!j)return;const W=r.iconDependencies,K=r.glyphDependencies,re=r.availableImages,de=new N(this.zoom);for(const{feature:Te,id:pe,index:Ee,sourceLayerIndex:Ce}of e){const Se=y._featureFilter.needGeometry,We=au(Te,Se);if(!y._featureFilter.filter(de,We,u))continue;if(Se||(We.geometry=Sa(Te,u,m)),I&&Te.type!==1&&u.z<=5){const Ke=We.geometry,st=.98078528056,at=(ht,Et)=>ts(Dh(ht.x,ht.y,u,1),Dh(Et.x,Et.y,u,1))=0;for(const at of Ze.sections)if(at.image)W[at.image.name]=!0;else{const ht=vh(Ze.toString()),Et=at.fontStack||Ke,et=K[Et]=K[Et]||{};this.calculateGlyphDependencies(at.text,et,st,this.allowVerticalPlacement,ht)}}}b.get("symbol-placement")==="line"&&(this.features=function(Te){const pe={},Ee={},Ce=[];let Se=0;function We(Ke){Ce.push(Te[Ke]),Se++}function Ze(Ke,st,at){const ht=Ee[Ke];return delete Ee[Ke],Ee[st]=ht,Ce[ht].geometry[0].pop(),Ce[ht].geometry[0]=Ce[ht].geometry[0].concat(at[0]),ht}function nt(Ke,st,at){const ht=pe[st];return delete pe[st],pe[Ke]=ht,Ce[ht].geometry[0].shift(),Ce[ht].geometry[0]=at[0].concat(Ce[ht].geometry[0]),ht}function mt(Ke,st,at){const ht=at?st[0][st[0].length-1]:st[0][0];return`${Ke}:${ht.x}:${ht.y}`}for(let Ke=0;KeKe.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((Te,pe)=>Te.sortKey-pe.sortKey)}update(e,r,u,m){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,u,m),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,u,m))}isEmpty(){return this.symbolInstances.length===0&&!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()}getProjection(){return this.projectionInstance||(this.projectionInstance=B1(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const u=this.lineVertexArray.length;if(e.segment!==void 0)for(const{x:m,y}of r)this.lineVertexArray.emplaceBack(m,y);return{lineStartIndex:u,lineLength:this.lineVertexArray.length-u}}addSymbols(e,r,u,m,y,b,I,C,A,O,B,j,$,W){const K=e.indexArray,re=e.layoutVertexArray,de=e.globeExtVertexArray,Te=e.segments.prepareSegment(4*r.length,re,K,this.canOverlap?b.sortKey:void 0),pe=this.glyphOffsetArray.length,Ee=Te.vertexLength,Ce=this.allowVerticalPlacement&&I===Zo.vertical?Math.PI/2:0,Se=b.text&&b.text.sections;for(let Ze=0;Ze=0?r.rightJustifiedTextSymbolIndex:r.centerJustifiedTextSymbolIndex>=0?r.centerJustifiedTextSymbolIndex:r.leftJustifiedTextSymbolIndex>=0?r.leftJustifiedTextSymbolIndex:r.verticalPlacedTextSymbolIndex>=0?r.verticalPlacedTextSymbolIndex:m),b=Kd(this.textSizeData,e,y)/wr;return this.tilePixelRatio*b}getSymbolInstanceIconSize(e,r,u){const m=this.icon.placedSymbolArray.get(u),y=Kd(this.iconSizeData,e,m);return this.tilePixelRatio*y}_commitDebugCollisionVertexUpdate(e,r,u){e.emplaceBack(r,-u,-u),e.emplaceBack(r,u,-u),e.emplaceBack(r,u,u),e.emplaceBack(r,-u,u)}_updateTextDebugCollisionBoxes(e,r,u,m,y,b){for(let I=m;I0}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,r){const u=e.placedSymbolArray.get(r),m=u.vertexStartIndex+4*u.numGlyphs;for(let y=u.vertexStartIndex;ym[I]-m[C]||y[C]-y[I]),b}addToSortKeyRanges(e,r){const u=this.sortKeyRanges[this.sortKeyRanges.length-1];u&&u.sortKey===r?u.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,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 r of this.symbolInstanceIndexes){const u=this.symbolInstances.get(r);this.featureSortOrder.push(u.featureIndex);const{rightJustifiedTextSymbolIndex:m,centerJustifiedTextSymbolIndex:y,leftJustifiedTextSymbolIndex:b,verticalPlacedTextSymbolIndex:I,placedIconSymbolIndex:C,verticalPlacedIconSymbolIndex:A}=u;m>=0&&this.addIndicesForPlacedSymbol(this.text,m),y>=0&&y!==m&&this.addIndicesForPlacedSymbol(this.text,y),b>=0&&b!==y&&b!==m&&this.addIndicesForPlacedSymbol(this.text,b),I>=0&&this.addIndicesForPlacedSymbol(this.text,I),C>=0&&this.addIndicesForPlacedSymbol(this.icon,C),A>=0&&this.addIndicesForPlacedSymbol(this.icon,A)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Ft(_l,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),_l.MAX_GLYPHS=65535,_l.addDynamicAttributes=up;const qC=new _e({"symbol-placement":new H(Qe.layout_symbol["symbol-placement"]),"symbol-spacing":new H(Qe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new H(Qe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new oe(Qe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new H(Qe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new H(Qe.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new H(Qe.layout_symbol["icon-ignore-placement"]),"icon-optional":new H(Qe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new H(Qe.layout_symbol["icon-rotation-alignment"]),"icon-size":new oe(Qe.layout_symbol["icon-size"]),"icon-text-fit":new H(Qe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new H(Qe.layout_symbol["icon-text-fit-padding"]),"icon-image":new oe(Qe.layout_symbol["icon-image"]),"icon-rotate":new oe(Qe.layout_symbol["icon-rotate"]),"icon-padding":new H(Qe.layout_symbol["icon-padding"]),"icon-keep-upright":new H(Qe.layout_symbol["icon-keep-upright"]),"icon-offset":new oe(Qe.layout_symbol["icon-offset"]),"icon-anchor":new oe(Qe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new H(Qe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new H(Qe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new H(Qe.layout_symbol["text-rotation-alignment"]),"text-field":new oe(Qe.layout_symbol["text-field"]),"text-font":new oe(Qe.layout_symbol["text-font"]),"text-size":new oe(Qe.layout_symbol["text-size"]),"text-max-width":new oe(Qe.layout_symbol["text-max-width"]),"text-line-height":new oe(Qe.layout_symbol["text-line-height"]),"text-letter-spacing":new oe(Qe.layout_symbol["text-letter-spacing"]),"text-justify":new oe(Qe.layout_symbol["text-justify"]),"text-radial-offset":new oe(Qe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new H(Qe.layout_symbol["text-variable-anchor"]),"text-anchor":new oe(Qe.layout_symbol["text-anchor"]),"text-max-angle":new H(Qe.layout_symbol["text-max-angle"]),"text-writing-mode":new H(Qe.layout_symbol["text-writing-mode"]),"text-rotate":new oe(Qe.layout_symbol["text-rotate"]),"text-padding":new H(Qe.layout_symbol["text-padding"]),"text-keep-upright":new H(Qe.layout_symbol["text-keep-upright"]),"text-transform":new oe(Qe.layout_symbol["text-transform"]),"text-offset":new oe(Qe.layout_symbol["text-offset"]),"text-allow-overlap":new H(Qe.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new H(Qe.layout_symbol["text-ignore-placement"]),"text-optional":new H(Qe.layout_symbol["text-optional"])});var Og={paint:new _e({"icon-opacity":new oe(Qe.paint_symbol["icon-opacity"]),"icon-color":new oe(Qe.paint_symbol["icon-color"]),"icon-halo-color":new oe(Qe.paint_symbol["icon-halo-color"]),"icon-halo-width":new oe(Qe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new oe(Qe.paint_symbol["icon-halo-blur"]),"icon-translate":new H(Qe.paint_symbol["icon-translate"]),"icon-translate-anchor":new H(Qe.paint_symbol["icon-translate-anchor"]),"text-opacity":new oe(Qe.paint_symbol["text-opacity"]),"text-color":new oe(Qe.paint_symbol["text-color"],{runtimeType:Ji,getOverride:n=>n.textColor,hasOverride:n=>!!n.textColor}),"text-halo-color":new oe(Qe.paint_symbol["text-halo-color"]),"text-halo-width":new oe(Qe.paint_symbol["text-halo-width"]),"text-halo-blur":new oe(Qe.paint_symbol["text-halo-blur"]),"text-translate":new H(Qe.paint_symbol["text-translate"]),"text-translate-anchor":new H(Qe.paint_symbol["text-translate-anchor"])}),layout:qC};class F1{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Oo,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.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}}Ft(F1,"FormatSectionOverride",{omit:["defaultValue"]});class cp extends Es{constructor(e){super(e,Og)}recalculate(e,r){super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const u=this.layout.get("text-writing-mode");if(u){const m=[];for(const y of u)m.indexOf(y)<0&&m.push(y);this.layout._values["text-writing-mode"]=m}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,r,u,m){const y=this.layout.get(e).evaluate(r,{},u,m),b=this._unevaluatedLayout._values[e];return b.isDataDriven()||ol(b.value)||!y?y:function(I,C){return C.replace(/{([^{}]+)}/g,(A,O)=>O in I?String(I[O]):"")}(r.properties,y)}createBucket(e){return new _l(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Og.paint.overridableProperties){if(!cp.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),u=new F1(r),m=new Xu(u,r.property.specification);let y=null;y=r.value.kind==="constant"||r.value.kind==="source"?new lh("source",m):new $l("composite",m,r.value.zoomStops,r.value._interpolationType),this.paint._values[e]=new le(r.property,y,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,u){return!(!this.layout||r.isDataDriven()||u.isDataDriven())&&cp.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const u=e.get("text-field"),m=Og.paint.properties[r];let y=!1;const b=I=>{for(const C of I)if(m.overrides&&m.overrides.hasOverride(C))return void(y=!0)};if(u.value.kind==="constant"&&u.value.value instanceof sr)b(u.value.value.sections);else if(u.value.kind==="source"){const I=A=>{y||(A instanceof fo&&Xn(A.value)===la?b(A.value.sections):A instanceof No?b(A.sections):A.eachChild(I))},C=u.value;C._styleExpression&&I(C._styleExpression.expression)}return y}getProgramConfiguration(e){return new fl(this,e)}}var ZC={paint:new _e({"background-color":new H(Qe.paint_background["background-color"]),"background-pattern":new H(Qe.paint_background["background-pattern"]),"background-opacity":new H(Qe.paint_background["background-opacity"])})},$C={paint:new _e({"raster-opacity":new H(Qe.paint_raster["raster-opacity"]),"raster-hue-rotate":new H(Qe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new H(Qe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new H(Qe.paint_raster["raster-brightness-max"]),"raster-saturation":new H(Qe.paint_raster["raster-saturation"]),"raster-contrast":new H(Qe.paint_raster["raster-contrast"]),"raster-resampling":new H(Qe.paint_raster["raster-resampling"]),"raster-fade-duration":new H(Qe.paint_raster["raster-fade-duration"])})};class XC extends Es{constructor(e){super(e,{}),this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isLayerDraped(){return this.implementation.renderToTile!==void 0}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var WC={paint:new _e({"sky-type":new H(Qe.paint_sky["sky-type"]),"sky-atmosphere-sun":new H(Qe.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new H(Qe.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new H(Qe.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new H(Qe.paint_sky["sky-gradient-radius"]),"sky-gradient":new ge(Qe.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new H(Qe.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new H(Qe.paint_sky["sky-atmosphere-color"]),"sky-opacity":new H(Qe.paint_sky["sky-opacity"])})};function Ng(n,e,r){const u=[0,0,1],m=rx([]);return sx(m,m,r?-Je(n)+Math.PI:Je(n)),ox(m,m,-Je(e)),ex(u,u,m),eo(u,u)}const YC={circle:class extends Es{constructor(n){super(n,sk)}createBucket(n){return new ug(n)}queryRadius(n){const e=n;return uc("circle-radius",this,e)+uc("circle-stroke-width",this,e)+Vd(this.paint.get("circle-translate"))}queryIntersectsFeature(n,e,r,u,m,y,b,I){const C=kx(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),y.angle,n.pixelToTileUnitsFactor),A=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r);return Cx(n,u,y,b,I,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",C,A)}getProgramIds(){return["circle"]}getProgramConfiguration(n){return new fl(this,n)}},heatmap:class extends Es{createBucket(n){return new Px(n)}constructor(n){super(n,ck),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(n){n==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=dg({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(n){return uc("heatmap-radius",this,n)}queryIntersectsFeature(n,e,r,u,m,y,b,I){const C=this.paint.get("heatmap-radius").evaluate(e,r);return Cx(n,u,y,b,I,!0,!0,new Ie(0,0),C)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(n){return new fl(this,n)}},hillshade:class extends Es{constructor(n){super(n,hk)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends Es{constructor(n){super(n,Sk)}getProgramIds(){const n=this.paint.get("fill-pattern"),e=n&&n.constantOr(1),r=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getProgramConfiguration(n){return new fl(this,n)}recalculate(n,e){super.recalculate(n,e);const r=this.paint._values["fill-outline-color"];r.value.kind==="constant"&&r.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(n){return new Zd(n)}queryRadius(){return Vd(this.paint.get("fill-translate"))}queryIntersectsFeature(n,e,r,u,m,y){return!n.queryGeometry.isAboveHorizon&&Ex(Sx(n.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),y.angle,n.pixelToTileUnitsFactor),u)}isTileClipped(){return!0}},"fill-extrusion":class extends Es{constructor(n){super(n,Gk)}createBucket(n){return new Gh(n)}queryRadius(){return Vd(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(n){return new fl(this,n)}queryIntersectsFeature(n,e,r,u,m,y,b,I,C){const A=kx(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),y.angle,n.pixelToTileUnitsFactor),O=this.paint.get("fill-extrusion-height").evaluate(e,r),B=this.paint.get("fill-extrusion-base").evaluate(e,r),j=[0,0],$=I&&y.elevation,W=y.elevation?y.elevation.exaggeration():1,K=n.tile.getBucket(this);if($&&K instanceof Gh){const Ee=K.centroidVertexArray,Ce=C+1;CeEe.polygon).flat());const re=$?I:null,[de,Te]=function(Ee,Ce,Se,We,Ze,nt,mt,Ke,st,at,ht){return Ee.projection.name==="globe"?function(Et,et,Rt,jt,Dt,pn,Tt,Xt,mn,jn,gn){const en=[],gi=[],vn=Et.projection.upVectorScale(gn,Et.center.lat,Et.worldSize).metersToTile,xn=[0,0,0,1],oi=[0,0,0,1],hi=(si,Ii,Di,qi)=>{si[0]=Ii,si[1]=Di,si[2]=qi,si[3]=1},fi=Wx();Rt>0&&(Rt+=fi),jt+=fi;for(const si of et){const Ii=[],Di=[];for(const qi of si){const ai=qi.x+Dt.x,tr=qi.y+Dt.y,Zi=Et.projection.projectTilePoint(ai,tr,gn),Pi=Et.projection.upVector(gn,qi.x,qi.y);let qn=Rt,$i=jt;if(Tt){const di=Qx(ai,tr,Rt,jt,Tt,Xt,mn,jn);qn+=di.base,$i+=di.top}Rt!==0?hi(xn,Zi.x+Pi[0]*vn*qn,Zi.y+Pi[1]*vn*qn,Zi.z+Pi[2]*vn*qn):hi(xn,Zi.x,Zi.y,Zi.z),hi(oi,Zi.x+Pi[0]*vn*$i,Zi.y+Pi[1]*vn*$i,Zi.z+Pi[2]*vn*$i),zi(xn,xn,pn),zi(oi,oi,pn),Ii.push(new fc(xn[0],xn[1],xn[2])),Di.push(new fc(oi[0],oi[1],oi[2]))}en.push(Ii),gi.push(Di)}return[en,gi]}(Ee,Ce,Se,We,Ze,nt,mt,Ke,st,at,ht):mt?function(Et,et,Rt,jt,Dt,pn,Tt,Xt,mn){const jn=[],gn=[],en=[0,0,0,1];for(const gi of Et){const vn=[],xn=[];for(const oi of gi){const hi=oi.x+jt.x,fi=oi.y+jt.y,si=Qx(hi,fi,et,Rt,pn,Tt,Xt,mn);en[0]=hi,en[1]=fi,en[2]=si.base,en[3]=1,ru(en,en,Dt),en[3]=Math.max(en[3],1e-5);const Ii=new fc(en[0]/en[3],en[1]/en[3],en[2]/en[3]);en[0]=hi,en[1]=fi,en[2]=si.top,en[3]=1,ru(en,en,Dt),en[3]=Math.max(en[3],1e-5);const Di=new fc(en[0]/en[3],en[1]/en[3],en[2]/en[3]);vn.push(Ii),xn.push(Di)}jn.push(vn),gn.push(xn)}return[jn,gn]}(Ce,Se,We,Ze,nt,mt,Ke,st,at):function(Et,et,Rt,jt,Dt){const pn=[],Tt=[],Xt=Dt[8]*et,mn=Dt[9]*et,jn=Dt[10]*et,gn=Dt[11]*et,en=Dt[8]*Rt,gi=Dt[9]*Rt,vn=Dt[10]*Rt,xn=Dt[11]*Rt;for(const oi of Et){const hi=[],fi=[];for(const si of oi){const Ii=si.x+jt.x,Di=si.y+jt.y,qi=Dt[0]*Ii+Dt[4]*Di+Dt[12],ai=Dt[1]*Ii+Dt[5]*Di+Dt[13],tr=Dt[2]*Ii+Dt[6]*Di+Dt[14],Zi=Dt[3]*Ii+Dt[7]*Di+Dt[15],Pi=qi+Xt,qn=ai+mn,$i=tr+jn,di=Math.max(Zi+gn,1e-5),io=qi+en,Xi=ai+gi,Er=tr+vn,gr=Math.max(Zi+xn,1e-5);hi.push(new fc(Pi/di,qn/di,$i/di)),fi.push(new fc(io/gr,Xi/gr,Er/gr))}pn.push(hi),Tt.push(fi)}return[pn,Tt]}(Ce,Se,We,Ze,nt)}(y,u,B,O,A,b,re,j,W,y.center.lat,n.tileID.canonical),pe=n.queryGeometry;return function(Ee,Ce,Se){let We=1/0;Ex(Se,Ce)&&(We=Jx(Se,Ce[0]));for(let Ze=0;Ze=3){for(let W=0;W<$.length;W++)if(lu(A,$[W]))return!0}if(nk(A,$,B))return!0}return!1}(b,u,I)}isTileClipped(){return!0}},symbol:cp,background:class extends Es{constructor(n){super(n,ZC)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends Es{constructor(n){super(n,$C)}getProgramIds(){return["raster"]}},sky:class extends Es{constructor(n){super(n,WC),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(n){n==="sky-gradient"?this._updateColorRamp():n!=="sky-atmosphere-sun"&&n!=="sky-atmosphere-halo-color"&&n!=="sky-atmosphere-color"&&n!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=dg({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(n){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=n.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(n,e){if(this.paint.get("sky-type")==="atmosphere"){const u=this.paint.get("sky-atmosphere-sun"),m=!u,y=n.style.light,b=y.properties.get("position");return m&&y.properties.get("anchor")==="viewport"&&yn("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),m?Ng(b.azimuthal,90-b.polar,e):Ng(u[0],90-u[1],e)}const r=this.paint.get("sky-gradient-center");return Ng(r[0],90-r[1],e)}is3D(){return!1}isSky(){return!0}markSkyboxValid(n){this._skyboxInvalidated=!1,this._lightPosition=n.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const n=this.paint.get("sky-type");return n==="atmosphere"?["skyboxCapture","skybox"]:n==="gradient"?["skyboxGradient"]:null}}};class ef{constructor(e,r,u,m){this.context=e,this.format=u,this.texture=e.gl.createTexture(),this.update(r,m)}update(e,r,u){const{width:m,height:y}=e,{context:b}=this,{gl:I}=b,{HTMLImageElement:C,HTMLCanvasElement:A,HTMLVideoElement:O,ImageData:B,ImageBitmap:j}=E;if(I.bindTexture(I.TEXTURE_2D,this.texture),b.pixelStoreUnpackFlipY.set(!1),b.pixelStoreUnpack.set(1),b.pixelStoreUnpackPremultiplyAlpha.set(this.format===I.RGBA&&(!r||r.premultiply!==!1)),u||this.size&&this.size[0]===m&&this.size[1]===y){const{x:$,y:W}=u||{x:0,y:0};e instanceof C||e instanceof A||e instanceof O||e instanceof B||j&&e instanceof j?I.texSubImage2D(I.TEXTURE_2D,0,$,W,I.RGBA,I.UNSIGNED_BYTE,e):I.texSubImage2D(I.TEXTURE_2D,0,$,W,m,y,I.RGBA,I.UNSIGNED_BYTE,e.data)}else this.size=[m,y],e instanceof C||e instanceof A||e instanceof O||e instanceof B||j&&e instanceof j?I.texImage2D(I.TEXTURE_2D,0,this.format,this.format,I.UNSIGNED_BYTE,e):I.texImage2D(I.TEXTURE_2D,0,this.format,m,y,0,this.format,I.UNSIGNED_BYTE,e.data);this.useMipmap=!!(r&&r.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&I.generateMipmap(I.TEXTURE_2D)}bind(e,r){const{context:u}=this,{gl:m}=u;m.bindTexture(m.TEXTURE_2D,this.texture),e!==this.filter&&(m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,e),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,this.useMipmap?e===m.NEAREST?m.NEAREST_MIPMAP_NEAREST:m.LINEAR_MIPMAP_NEAREST:e),this.filter=e),r!==this.wrap&&(m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,r),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,r),this.wrap=r)}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}}class HC{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class KC{constructor(){this.tasks={},this.taskQueue=[],Kn(["process"],this),this.invoker=new HC(this.process),this.nextId=0}add(e,r){const u=this.nextId++,m=function({type:y,isSymbolTile:b,zoom:I}){return I=I||0,y==="message"?0:y!=="maybePrepare"||b?y!=="parseTile"||b?y==="parseTile"&&b?300-I:y==="maybePrepare"&&b?400-I:500:200-I:100-I}(r);if(m===0){Hi();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[u]={fn:e,metadata:r,priority:m,id:u},this.taskQueue.push(u),this.invoker.trigger(),{cancel:()=>{delete this.tasks[u]}}}process(){Hi();try{if(this.taskQueue=this.taskQueue.filter(u=>!!this.tasks[u]),!this.taskQueue.length)return;const e=this.pick();if(e===null)return;const r=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!r)return;r.fn()}finally{}}pick(){let e=null,r=1/0;for(let m=0;m>=1)>1;){const A=r+m>>1,O=u+y>>1;1&e?(m=r,y=u,r=b,u=I):(r=m,u=y,m=b,y=I),b=A,I=O}const C=4*n;yl[C+0]=r,yl[C+1]=u,yl[C+2]=m,yl[C+3]=y}const Hs=new Uint16Array(2178),vl=new Uint8Array(1089),hp=new Uint16Array(1089);function j1(n){return n===0?-.03125:n===32?.03125:0}var G1=Oe([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const q1={type:2,extent:Wt,loadGeometry:()=>[[new Ie(0,0),new Ie(Wt+1,0),new Ie(Wt+1,Wt+1),new Ie(0,Wt+1),new Ie(0,0)]]};class Bg{constructor(e,r,u,m,y){this.tileID=e,this.uid=hn(),this.uses=0,this.tileSize=r,this.tileZoom=u,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=y,this.expiredRequestCount=0,this.state="loading",m&&m.transform&&(this.projection=m.transform.projection)}registerFadeDuration(e){const r=e+this.timeAdded;ry.getLayer(A)).filter(Boolean);if(C.length!==0){I.layers=C,I.stateDependentLayerIds&&(I.stateDependentLayers=I.stateDependentLayerIds.map(A=>C.filter(O=>O.id===A)[0]));for(const A of C)b[A.id]=I}}return b}(e.buckets,r.style),this.hasSymbolBuckets=!1;for(const m in this.buckets){const y=this.buckets[m];if(y instanceof _l){if(this.hasSymbolBuckets=!0,!u)break;y.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const m in this.buckets){const y=this.buckets[m];if(y instanceof _l&&y.hasRTLText){this.hasRTLText=!0,z.isLoading()||z.isLoaded()||S()!=="deferred"||D();break}}this.queryPadding=0;for(const m in this.buckets){const y=this.buckets[m];this.queryPadding=Math.max(this.queryPadding,r.style.getLayer(m).queryRadius(y))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new ii}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const u in this.buckets){const m=this.buckets[u];m.uploadPending()&&m.upload(e)}const r=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new ef(e,this.imageAtlas.image,r.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new ef(e,this.glyphAtlasImage,r.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new ef(e,this.lineAtlas.image,r.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,r,u,m,y,b,I,C){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:m,pixelPosMatrix:I,transform:b,params:y,tileTransform:this.tileTransform},e,r,u):{}}querySourceFeatures(e,r){const u=this.latestFeatureIndex;if(!u||!u.rawTileData)return;const m=u.loadVTLayers(),y=r?r.sourceLayer:"",b=m._geojsonTileLayer||m[y];if(!b)return;const I=Ku(r&&r.filter),{z:C,x:A,y:O}=this.tileID.canonical,B={z:C,x:A,y:O};for(let j=0;ju)m=!1;else if(r)if(this.expirationTime=0;re--){const de=4*re,Te=yl[de+0],pe=yl[de+1],Ee=yl[de+2],Ce=yl[de+3],Se=Te+Ee>>1,We=pe+Ce>>1,Ze=Se+We-pe,nt=We+Te-Se,mt=pe*Ys+Te,Ke=Ce*Ys+Ee,st=We*Ys+Se,at=Math.hypot((Hs[2*mt+0]+Hs[2*Ke+0])/2-Hs[2*st+0],(Hs[2*mt+1]+Hs[2*Ke+1])/2-Hs[2*st+1])>=16;vl[st]=vl[st]||(at?1:0),re<1022&&(vl[st]=vl[st]||vl[(pe+nt>>1)*Ys+(Te+Ze>>1)]||vl[(Ce+nt>>1)*Ys+(Ee+Ze>>1)])}const B=new ot,j=new qt;let $=0;function W(re,de){const Te=de*Ys+re;return hp[Te]===0&&(B.emplaceBack(Hs[2*Te+0],Hs[2*Te+1],re*Wt/rs,de*Wt/rs),hp[Te]=++$),hp[Te]-1}function K(re,de,Te,pe,Ee,Ce){const Se=re+Te>>1,We=de+pe>>1;if(Math.abs(re-Ee)+Math.abs(de-Ce)>1&&vl[We*Ys+Se])K(Ee,Ce,re,de,Se,We),K(Te,pe,Ee,Ce,Se,We);else{const Ze=W(re,de),nt=W(Te,pe),mt=W(Ee,Ce);j.emplaceBack(Ze,nt,mt)}}return K(0,0,rs,rs,rs,0),K(rs,rs,0,0,0,rs),{vertices:B,indices:j}}(this.tileID.canonical,r);m=b.vertices,y=b.indices}else{m=new ot,y=new qt;for(const{x:I,y:C}of u)m.emplaceBack(I,C,0,0);const b=yg(m.int16,void 0,4);for(let I=0;I0&&(I=$m(new Float64Array(16),r.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,m,r,y,I,b),this._makeGlobeTileDebugTextBuffer(e,m,r,y,I,b)}_globePoint(e,r,u,m,y,b,I){let C=Dh(e,r,u);if(b){const A=1<.5?$=-1:j<-.5&&($=1);let W=(e/Wt+u.x)/A+$,K=(r/Wt+u.y)/A;W=(W-O)*m._pixelsPerMercatorPixel+O,K=(K-B)*m._pixelsPerMercatorPixel+B;const re=[W*m.worldSize,K*m.worldSize,0];zi(re,re,b),C=su(C,re,I)}return zi(C,C,y)}_makeGlobeTileDebugBorderBuffer(e,r,u,m,y,b){const I=new pt,C=new Co,A=new qe,O=(j,$,W,K,re)=>{const de=(W-j)/(re-1),Te=(K-$)/(re-1),pe=I.length;for(let Ee=0;EeB*$+W;for(let $=0;$e[b])return null}else{const I=1/u[b];let C=(n[b]-r[b])*I,A=(e[b]-r[b])*I;if(C>A){const O=C;C=A,A=O}if(C>m&&(m=C),Ay)return null}return m}function X1(n,e,r,u,m,y,b,I,C,A,O){const B=u-n,j=m-e,$=y-r,W=b-n,K=I-e,re=C-r,de=O[1]*re-O[2]*K,Te=O[2]*W-O[0]*re,pe=O[0]*K-O[1]*W,Ee=B*de+j*Te+$*pe;if(Math.abs(Ee)<1e-15)return null;const Ce=1/Ee,Se=A[0]-n,We=A[1]-e,Ze=A[2]-r,nt=(Se*de+We*Te+Ze*pe)*Ce;if(nt<0||nt>1)return null;const mt=We*$-Ze*j,Ke=Ze*B-Se*$,st=Se*j-We*B,at=(O[0]*mt+O[1]*Ke+O[2]*st)*Ce;return at<0||nt+at>1?null:(W*mt+K*Ke+re*st)*Ce}function W1(n,e,r){return(n-e)/(r-e)}function Y1(n,e,r,u,m,y,b,I,C){const A=1<{const Te=re?1:0,pe=($+1)*K-Te,Ee=W*K,Ce=(W+1)*K-Te;de[0]=$*K,de[1]=Ee,de[2]=pe,de[3]=Ce};let B=new Z1(C);const j=[];for(let $=0;$=1;C/=2){const $=I[I.length-1];B=new Z1(C);for(let W=0;W0;){const{idx:W,t:K,nodex:re,nodey:de,depth:Te}=$.pop();if(this.leaves[W]){Y1(re,de,Te,e,r,u,m,B,j);const Ee=1<=et[2])return K}continue}let pe=0;for(let Ee=0;Ee=A[O[Ze]]&&(O.splice(Ze,0,Ee),We=!0);We||(O[pe]=Ee),pe++}}for(let Ee=0;Ee=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}static pack(e,r){const u=[0,0,0,0],m=fp.getUnpackVector(r);let y=Math.floor((e+m[3])/m[2]);return u[2]=y%256,y=Math.floor(y/256),u[1]=y%256,y=Math.floor(y/256),u[0]=y,u}getPixels(){return new Po({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,r,u){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let m=r*this.dim,y=r*this.dim+this.dim,b=u*this.dim,I=u*this.dim+this.dim;switch(r){case-1:m=y-1;break;case 1:y=m+1}switch(u){case-1:b=I-1;break;case 1:I=b+1}const C=-r*this.dim,A=-u*this.dim;for(let O=b;O{this.remove(e,y)},u)),this.data[m].push(y),this.order.push(m),this.order.length>this.max){const b=this._getAndRemoveByKey(this.order[0]);b&&this.onRemove(b)}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 r=this.data[e].shift();return r.timeout&&clearTimeout(r.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),r.value}getByKey(e){const r=this.data[e];return r?r[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,r){if(!this.has(e))return this;const u=e.wrapped().key,m=r===void 0?0:this.data[u].indexOf(r),y=this.data[u][m];return this.data[u].splice(m,1),y.timeout&&clearTimeout(y.timeout),this.data[u].length===0&&delete this.data[u],this.onRemove(y.value),this.order.splice(this.order.indexOf(u),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(e){const r=[];for(const u in this.data)for(const m of this.data[u])e(m.value)||r.push(m);for(const u of r)this.remove(u.value.tileID,u)}}class wc{constructor(e,r,u){this.func=e,this.mask=r,this.range=u}}wc.ReadOnly=!1,wc.ReadWrite=!0,wc.disabled=new wc(519,wc.ReadOnly,[0,1]);const Fg=7680;class Vg{constructor(e,r,u,m,y,b){this.test=e,this.ref=r,this.mask=u,this.fail=m,this.depthFail=y,this.pass=b}}Vg.disabled=new Vg({func:519,mask:0},0,0,Fg,Fg,Fg);class Ks{constructor(e,r,u){this.blendFunction=e,this.blendColor=r,this.mask=u}}Ks.Replace=[1,0],Ks.disabled=new Ks(Ks.Replace,Ai.transparent,[!1,!1,!1,!1]),Ks.unblended=new Ks(Ks.Replace,Ai.transparent,[!0,!0,!0,!0]),Ks.alphaBlended=new Ks([1,771],Ai.transparent,[!0,!0,!0,!0]);const Ug=1029,jg=2305;class Cs{constructor(e,r,u){this.enable=e,this.mode=r,this.frontFace=u}}Cs.disabled=new Cs(!1,Ug,jg),Cs.backCCW=new Cs(!0,Ug,jg),Cs.backCW=new Cs(!0,Ug,2304),Cs.frontCW=new Cs(!0,1028,2304),Cs.frontCCW=new Cs(!0,1028,jg);class hu extends wo{constructor(e,r,u){super(),this.id=e,this._onlySymbols=u,r.on("data",m=>{m.dataType==="source"&&m.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&m.dataType==="source"&&m.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new nA(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=r.minTileCacheSize,this._maxTileCacheSize=r.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new QC,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(e){this.map=e,this._minTileCacheSize=this._minTileCacheSize===void 0&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const e in this._tiles){const r=this._tiles[e];if(r.state!=="loaded"&&r.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,r){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,r)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const r in this._tiles){const u=this._tiles[r];u.upload(e),u.prepare(this.map.style.imageManager)}}getIds(){return Zt(this._tiles).map(e=>e.tileID).sort(Q1).map(e=>e.key)}getRenderableIds(e){const r=[];for(const u in this._tiles)this._isIdRenderable(+u,e)&&r.push(this._tiles[u]);return e?r.sort((u,m)=>{const y=u.tileID,b=m.tileID,I=new Ie(y.canonical.x,y.canonical.y)._rotate(this.transform.angle),C=new Ie(b.canonical.x,b.canonical.y)._rotate(this.transform.angle);return y.overscaledZ-b.overscaledZ||C.y-I.y||C.x-I.x}).map(u=>u.tileID.key):r.map(u=>u.tileID).sort(Q1).map(u=>u.key)}hasRenderableParent(e){const r=this.findLoadedParent(e,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(e,r){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(r||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(+e,"reloading")}}_reloadTile(e,r){const u=this._tiles[e];u&&(u.state!=="loading"&&(u.state=r),this._loadTile(u,this._tileLoaded.bind(this,u,e,r)))}_tileLoaded(e,r,u,m){if(m)if(e.state="errored",m.status!==404)this._source.fire(new Fi(m,{tile:e}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const y=this.map.painter.terrain;this.update(this.transform,y.getScaledDemTileSize(),!0),y.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=co.now(),u==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(r,e),this._source.type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new cs("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const r=this.getRenderableIds();for(let m=0;m1||(Math.abs(b)>1&&(Math.abs(b+C)===1?b+=C:Math.abs(b-C)===1&&(b-=C)),y.dem&&m.dem&&(m.dem.backfillBorder(y.dem,b,I),m.neighboringTiles&&m.neighboringTiles[A]&&(m.neighboringTiles[A].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,r,u,m){for(const y in this._tiles){let b=this._tiles[y];if(m[y]||!b.hasData()||b.tileID.overscaledZ<=r||b.tileID.overscaledZ>u)continue;let I=b.tileID;for(;b&&b.tileID.overscaledZ>r+1;){const A=b.tileID.scaledTo(b.tileID.overscaledZ-1);b=this._tiles[A.key],b&&b.hasData()&&(I=A)}let C=I;for(;C.overscaledZ>r;)if(C=C.scaledTo(C.overscaledZ-1),e[C.key]){m[I.key]=I;break}}}findLoadedParent(e,r){if(e.key in this._loadedParentTiles){const u=this._loadedParentTiles[e.key];return u&&u.tileID.overscaledZ>=r?u:null}for(let u=e.overscaledZ-1;u>=r;u--){const m=e.scaledTo(u),y=this._getLoadedTile(m);if(y)return y}}_getLoadedTile(e){const r=this._tiles[e.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,r){r=r||this._source.tileSize;const u=Math.ceil(e.width/r)+1,m=Math.ceil(e.height/r)+1,y=Math.floor(u*m*5),b=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,y):y,I=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,b):b;this._cache.setMaxSize(I)}handleWrapJump(e){const r=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,r){const u={};for(const m in this._tiles){const y=this._tiles[m];y.tileID=y.tileID.unwrapTo(y.tileID.wrap+r),u[y.tileID.key]=y}this._tiles=u;for(const m in this._timers)clearTimeout(this._timers[m]),delete this._timers[m];for(const m in this._tiles)this._setTileReloadTimer(+m,this._tiles[m])}}update(e,r,u){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!u)return;let m;this.updateCacheSize(e,r),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?m=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(I=>new no(I.canonical.z,I.wrap,I.canonical.z,I.canonical.x,I.canonical.y)):(m=e.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!u,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(m=m.filter(I=>this._source.hasTile(I)))):m=[];const y=this._updateRetainedTiles(m);if(eb(this._source.type)&&m.length!==0){const I={},C={},A=Object.keys(y);for(const B of A){const j=y[B],$=this._tiles[B];if(!$||$.fadeEndTime&&$.fadeEndTime<=co.now())continue;const W=this.findLoadedParent(j,Math.max(j.overscaledZ-hu.maxOverzooming,this._source.minzoom));W&&(this._addTile(W.tileID),I[W.tileID.key]=W.tileID),C[B]=j}const O=m[m.length-1].overscaledZ;for(const B in this._tiles){const j=this._tiles[B];if(y[B]||!j.hasData())continue;let $=j.tileID;for(;$.overscaledZ>O;){$=$.scaledTo($.overscaledZ-1);const W=this._tiles[$.key];if(W&&W.hasData()&&C[$.key]){y[B]=j.tileID;break}}}for(const B in I)y[B]||(this._coveredTiles[B]=!0,y[B]=I[B])}for(const I in y)this._tiles[I].clearFadeHold();const b=function(I,C){const A=[];for(const O in I)O in C||A.push(O);return A}(this._tiles,y);for(const I of b){const C=this._tiles[I];C.hasSymbolBuckets&&!C.holdingForFade()?C.setHoldDuration(this.map._fadeDuration):C.hasSymbolBuckets&&!C.symbolFadeFinished()||this._removeTile(+I)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const r={};if(e.length===0)return r;const u={},m=e.reduce((A,O)=>Math.min(A,O.overscaledZ),1/0),y=e[0].overscaledZ,b=Math.max(y-hu.maxOverzooming,this._source.minzoom),I=Math.max(y+hu.maxUnderzooming,this._source.minzoom),C={};for(const A of e){const O=this._addTile(A);r[A.key]=A,O.hasData()||m=this._source.maxzoom){const j=A.children(this._source.maxzoom)[0],$=this.getTile(j);if($&&$.hasData()){r[j.key]=j;continue}}else{const j=A.children(this._source.maxzoom);if(r[j[0].key]&&r[j[1].key]&&r[j[2].key]&&r[j[3].key])continue}let B=O.wasRequested();for(let j=A.overscaledZ-1;j>=b;--j){const $=A.scaledTo(j);if(u[$.key]||(u[$.key]=!0,O=this.getTile($),!O&&B&&(O=this._addTile($)),O&&(r[$.key]=$,B=O.wasRequested(),O.hasData())))break}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const r=[];let u,m=this._tiles[e].tileID;for(;m.overscaledZ>0;){if(m.key in this._loadedParentTiles){u=this._loadedParentTiles[m.key];break}r.push(m.key);const y=m.scaledTo(m.overscaledZ-1);if(u=this._getLoadedTile(y),u)break;m=y}for(const y of r)this._loadedParentTiles[y]=u}}_addTile(e){let r=this._tiles[e.key];if(r)return r;r=this._cache.getAndRemove(e),r&&(this._setTileReloadTimer(e.key,r),r.tileID=e,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,r)));const u=!!r;if(!u){const m=this.map?this.map.painter:null;r=new Bg(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,m,this._isRaster),this._loadTile(r,this._tileLoaded.bind(this,r,e.key,r.state))}return r?(r.uses++,this._tiles[e.key]=r,u||this._source.fire(new cs("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(e,r){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const u=r.getExpiryTimeout();u&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},u))}_removeTile(e){const r=this._tiles[e];r&&(r.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),r.uses>0||(r.hasData()&&r.state!=="reloading"?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,r,u){const m=[],y=this.transform;if(!y)return m;const b=y.projection.name==="globe",I=Xs(y.center.lng);for(const C in this._tiles){const A=this._tiles[C];if(u&&A.clearQueryDebugViz(),A.holdingForFade())continue;let O;if(b){const B=A.tileID.canonical;if(B.z===0){const j=[Math.abs(Mt(I,...tf(B,-1))-I),Math.abs(Mt(I,...tf(B,1))-I)];O=[0,2*j.indexOf(Math.min(...j))-1]}else{const j=[Math.abs(Mt(I,...tf(B,-1))-I),Math.abs(Mt(I,...tf(B,0))-I),Math.abs(Mt(I,...tf(B,1))-I)];O=[j.indexOf(Math.min(...j))-1]}}else O=[0];for(const B of O){const j=e.containsTile(A,y,r,B);j&&m.push(j)}}return m}getVisibleCoordinates(e){const r=this.getRenderableIds(e).map(u=>this._tiles[u].tileID);for(const u of r)u.projMatrix=this.transform.calculateProjMatrix(u.toUnwrapped());return r}hasTransition(){if(this._source.hasTransition())return!0;if(eb(this._source.type))for(const e in this._tiles){const r=this._tiles[e];if(r.fadeEndTime!==void 0&&r.fadeEndTime>=co.now())return!0}return!1}setFeatureState(e,r,u){this._state.updateState(e=e||"_geojsonTileLayer",r,u)}removeFeatureState(e,r,u){this._state.removeFeatureState(e=e||"_geojsonTileLayer",r,u)}getFeatureState(e,r){return this._state.getState(e=e||"_geojsonTileLayer",r)}setDependencies(e,r,u){const m=this._tiles[e];m&&m.setDependencies(r,u)}reloadTilesForDependencies(e,r){for(const u in this._tiles)this._tiles[u].hasDependency(e,r)&&this._reloadTile(+u,"reloading");this._cache.filter(u=>!u.hasDependency(e,r))}_preloadTiles(e,r){if(!this._sourceLoaded){const I=()=>{this._sourceLoaded&&(this._source.off("data",I),this._preloadTiles(e,r))};return void this._source.on("data",I)}const u=new Map,m=Array.isArray(e)?e:[e],y=this.map.painter.terrain,b=this.usedForTerrain&&y?y.getScaledDemTileSize():this._source.tileSize;for(const I of m){const C=I.coveringTiles({tileSize:b,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const A of C)u.set(A.key,A);this.usedForTerrain&&I.updateElevation(!1)}Bt(Array.from(u.values()),(I,C)=>{const A=new Bg(I,this._source.tileSize*I.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(A,O=>{this._source.type==="raster-dem"&&A.dem&&this._backfillDEM(A),C(O,A)})},r)}}function Q1(n,e){const r=Math.abs(2*n.wrap)-+(n.wrap<0),u=Math.abs(2*e.wrap)-+(e.wrap<0);return n.overscaledZ-e.overscaledZ||u-r||e.canonical.y-n.canonical.y||e.canonical.x-n.canonical.x}function eb(n){return n==="raster"||n==="image"||n==="video"||n==="custom"}function tf(n,e){const r=1<=0&&B[3]>=0&&C.insert(I,B[0],B[1],B[2],B[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new wg(new Qd(this.rawTileData)).layers,this.sourceLayerCoder=new V1(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,r,u,m){this.loadVTLayers();const y=e.params||{},b=Ku(y.filter),I=e.tileResult,C=e.transform,A=I.bufferedTilespaceBounds,O=this.grid.query(A.min.x,A.min.y,A.max.x,A.max.y,(W,K,re,de)=>Mx(I.bufferedTilespaceGeometry,W,K,re,de));O.sort(iA);let B=null;C.elevation&&O.length>0&&(B=dp.create(C.elevation,this.tileID));const j={};let $;for(let W=0;W(de||(de=Sa(Te,this.tileID.canonical,e.tileTransform)),pe.queryIntersectsFeature(I,Te,Ee,de,this.z,e.transform,e.pixelPosMatrix,B,Ce)))}return j}loadMatchingFeature(e,r,u,m,y,b,I,C,A){const{featureIndex:O,bucketIndex:B,sourceLayerIndex:j,layoutVertexArrayOffset:$}=r,W=this.bucketLayerIDs[B];if(m&&!function(Te,pe){for(let Ee=0;Ee=0)return!0;return!1}(m,W))return;const K=this.sourceLayerCoder.decode(j),re=this.vtLayers[K].feature(O);if(u.needGeometry){const Te=au(re,!0);if(!u.filter(new N(this.tileID.overscaledZ),Te,this.tileID.canonical))return}else if(!u.filter(new N(this.tileID.overscaledZ),re))return;const de=this.getId(re,K);for(let Te=0;Te{const I=e instanceof fe?e.get(b):null;return I&&I.evaluate?I.evaluate(r,u,m):I})}function iA(n,e){return e-n}Ft(tb,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class ib{constructor(e,r){this.width=e,this.height=r,this.nextRow=0,this.image=new ka({width:e,height:r}),this.positions={},this.uploaded=!1}getDash(e,r){const u=this.getKey(e,r);return this.positions[u]}trim(){const e=this.width,r=this.height=Tn(this.nextRow);this.image.resize({width:e,height:r})}getKey(e,r){return e.join(",")+r}getDashRanges(e,r,u){const m=[];let y=e.length%2==1?-e[e.length-1]*u:0,b=e[0]*u,I=!0;m.push({left:y,right:b,isDash:I,zeroLength:e[0]===0});let C=e[0];for(let A=1;A1&&(C=e[++I]);const O=Math.abs(A-C.left),B=Math.abs(A-C.right),j=Math.min(O,B);let $;const W=y/u*(m+1);if(C.isDash){const K=m-Math.abs(W);$=Math.sqrt(j*j+K*K)}else $=m-Math.sqrt(j*j+W*W);this.image.data[b+A]=Math.max(0,Math.min(255,$+128))}}}addRegularDash(e,r){for(let C=e.length-1;C>=0;--C){const A=e[C],O=e[C+1];A.zeroLength?e.splice(C,1):O&&O.isDash===A.isDash&&(O.left=A.left,e.splice(C,1))}const u=e[0],m=e[e.length-1];u.isDash===m.isDash&&(u.left=m.left-this.width,m.right=u.right+this.width);const y=this.width*this.nextRow;let b=0,I=e[b];for(let C=0;C1&&(I=e[++b]);const A=Math.abs(C-I.left),O=Math.abs(C-I.right),B=Math.min(A,O);this.image.data[y+C]=Math.max(0,Math.min(255,(I.isDash?B:-B)+r+128))}}addDash(e,r){const u=this.getKey(e,r);if(this.positions[u])return this.positions[u];const m=r==="round",y=m?7:0,b=2*y+1;if(this.nextRow+b>this.height)return yn("LineAtlas out of space"),null;e.length===0&&e.push(1);let I=0;for(let O=0;O=st.maxzoom||st.visibility!=="none"&&(Gg(Ke,this.zoom,u),(C[st.id]=st.createBucket({index:I.bucketLayerIDs.length,layers:Ke,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:nt,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:u})).populate(mt,O,this.tileID.canonical,this.tileTransform),I.bucketLayerIDs.push(Ke.map(at=>at.id)))}}let j,$,W,K;A.trim();const re={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},de=()=>{if(j)return y(j);if($&&W&&K){const Ce=new ob($),Se=new f1(W,K);for(const We in C){const Ze=C[We];Ze instanceof _l?(Gg(Ze.layers,this.zoom,u),AC(Ze,$,Ce.positions,W,Se.iconPositions,this.showCollisionBoxes,u,this.tileID.canonical,this.tileZoom,this.projection)):Ze.hasPattern&&(Ze instanceof Hd||Ze instanceof Zd||Ze instanceof Gh)&&(Gg(Ze.layers,this.zoom,u),Ze.addFeatures(O,this.tileID.canonical,Se.patternPositions,u,this.tileTransform))}this.status="done",y(null,{buckets:Zt(C).filter(We=>!We.isEmpty()),featureIndex:I,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Ce.image,lineAtlas:A,imageAtlas:Se,glyphMap:this.returnDependencies?$:null,iconMap:this.returnDependencies?W:null,glyphPositions:this.returnDependencies?Ce.positions:null})}},Te=gt(O.glyphDependencies,Ce=>Object.keys(Ce).map(Number));Object.keys(Te).length?m.send("getGlyphs",{uid:this.uid,stacks:Te},(Ce,Se)=>{j||(j=Ce,$=Se,de())},void 0,!1,re):$={};const pe=Object.keys(O.iconDependencies);pe.length?m.send("getImages",{icons:pe,source:this.source,tileID:this.tileID,type:"icons"},(Ce,Se)=>{j||(j=Ce,W=Se,de())},void 0,!1,re):W={};const Ee=Object.keys(O.patternDependencies);Ee.length?m.send("getImages",{icons:Ee,source:this.source,tileID:this.tileID,type:"patterns"},(Ce,Se)=>{j||(j=Ce,K=Se,de())},void 0,!1,re):K={},de()}}function Gg(n,e,r){const u=new N(e);for(const m of n)m.recalculate(u,r)}class sb{constructor(e){this.entries={},this.scheduler=e}request(e,r,u,m){const y=this.entries[e]=this.entries[e]||{callbacks:[]};if(y.result){const[b,I]=y.result;return this.scheduler?this.scheduler.add(()=>{m(b,I)},r):m(b,I),()=>{}}return y.callbacks.push(m),y.cancel||(y.cancel=u((b,I)=>{y.result=[b,I];for(const C of y.callbacks)this.scheduler?this.scheduler.add(()=>{C(b,I)},r):C(b,I);setTimeout(()=>delete this.entries[e],3e3)})),()=>{y.result||(y.callbacks=y.callbacks.filter(b=>b!==m),y.callbacks.length||(y.cancel(),delete this.entries[e]))}}}function ab(n,e,r){const u=JSON.stringify(n.request);return n.data&&(this.deduped.entries[u]={result:[null,n.data]}),this.deduped.request(u,{type:"parseTile",isSymbolTile:n.isSymbolTile,zoom:n.tileZoom},m=>{const y=zs(n.request,(b,I,C,A)=>{b?m(b):I&&m(null,{vectorTile:r?void 0:new wg(new Qd(I)),rawData:I,cacheControl:C,expires:A})});return()=>{y.cancel(),m()}},e)}const lb=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class qg{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[r,u]=new Uint8Array(e,0,2);if(r!==219)throw new Error("Data does not appear to be in a KDBush format.");const m=u>>4;if(m!==1)throw new Error(`Got v${m} data when expected v1.`);const y=lb[15&u];if(!y)throw new Error("Unrecognized array type.");const[b]=new Uint16Array(e,2,1),[I]=new Uint32Array(e,4,1);return new qg(I,b,y,e)}constructor(e,r=64,u=Float64Array,m){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=u,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const y=lb.indexOf(this.ArrayType),b=2*e*this.ArrayType.BYTES_PER_ELEMENT,I=e*this.IndexArrayType.BYTES_PER_ELEMENT,C=(8-I%8)%8;if(y<0)throw new Error(`Unexpected typed array class: ${u}.`);m&&m instanceof ArrayBuffer?(this.data=m,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+I+C,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+b+I+C),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+I+C,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+y]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const u=this._pos>>1;return this.ids[u]=u,this.coords[this._pos++]=e,this.coords[this._pos++]=r,u}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Zg(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,u,m){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:y,coords:b,nodeSize:I}=this,C=[0,y.length-1,0],A=[];for(;C.length;){const O=C.pop()||0,B=C.pop()||0,j=C.pop()||0;if(B-j<=I){for(let re=j;re<=B;re++){const de=b[2*re],Te=b[2*re+1];de>=e&&de<=u&&Te>=r&&Te<=m&&A.push(y[re])}continue}const $=j+B>>1,W=b[2*$],K=b[2*$+1];W>=e&&W<=u&&K>=r&&K<=m&&A.push(y[$]),(O===0?e<=W:r<=K)&&(C.push(j),C.push($-1),C.push(1-O)),(O===0?u>=W:m>=K)&&(C.push($+1),C.push(B),C.push(1-O))}return A}within(e,r,u){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:m,coords:y,nodeSize:b}=this,I=[0,m.length-1,0],C=[],A=u*u;for(;I.length;){const O=I.pop()||0,B=I.pop()||0,j=I.pop()||0;if(B-j<=b){for(let re=j;re<=B;re++)cb(y[2*re],y[2*re+1],e,r)<=A&&C.push(m[re]);continue}const $=j+B>>1,W=y[2*$],K=y[2*$+1];cb(W,K,e,r)<=A&&C.push(m[$]),(O===0?e-u<=W:r-u<=K)&&(I.push(j),I.push($-1),I.push(1-O)),(O===0?e+u>=W:r+u>=K)&&(I.push($+1),I.push(B),I.push(1-O))}return C}}function Zg(n,e,r,u,m,y){if(m-u<=r)return;const b=u+m>>1;ub(n,e,b,u,m,y),Zg(n,e,r,u,b-1,1-y),Zg(n,e,r,b+1,m,1-y)}function ub(n,e,r,u,m,y){for(;m>u;){if(m-u>600){const A=m-u+1,O=r-u+1,B=Math.log(A),j=.5*Math.exp(2*B/3),$=.5*Math.sqrt(B*j*(A-j)/A)*(O-A/2<0?-1:1);ub(n,e,r,Math.max(u,Math.floor(r-O*j/A+$)),Math.min(m,Math.floor(r+(A-O)*j/A+$)),y)}const b=e[2*r+y];let I=u,C=m;for(nf(n,e,u,r),e[2*m+y]>b&&nf(n,e,u,m);Ib;)C--}e[2*u+y]===b?nf(n,e,u,C):(C++,nf(n,e,C,m)),C<=r&&(u=C+1),r<=C&&(m=C-1)}}function nf(n,e,r,u){$g(n,r,u),$g(e,2*r,2*u),$g(e,2*r+1,2*u+1)}function $g(n,e,r){const u=n[e];n[e]=n[r],n[r]=u}function cb(n,e,r,u){const m=n-r,y=e-u;return m*m+y*y}t.ARRAY_TYPE=Ao,t.AUTH_ERR_MSG=ke,t.Aabb=to,t.Actor=class{constructor(n,e,r){this.target=n,this.parent=e,this.mapId=r,this.callbacks={},this.cancelCallbacks={},Kn(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=Hi()?n:E,this.scheduler=new KC}send(n,e,r,u,m=!1,y){const b=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=y,this.callbacks[b]=r);const I=zo(this.globalScope)?void 0:[];return this.target.postMessage({id:b,type:n,hasCallback:!!r,targetMapId:u,mustQueue:m,sourceMapId:this.mapId,data:ul(e,I)},I),{cancel:()=>{r&&delete this.callbacks[b],this.target.postMessage({id:b,type:"",targetMapId:u,sourceMapId:this.mapId})}}}receive(n){const e=n.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type===""){const u=this.cancelCallbacks[r];delete this.cancelCallbacks[r],u&&u.cancel()}else if(e.mustQueue||Hi()){const u=this.callbacks[r];this.cancelCallbacks[r]=this.scheduler.add(()=>this.processTask(r,e),u&&u.metadata||{type:"message"})}else this.processTask(r,e)}processTask(n,e){if(e.type===""){const r=this.callbacks[n];delete this.callbacks[n],r&&(e.error?r(ba(e.error)):r(null,ba(e.data)))}else{const r=zo(this.globalScope)?void 0:[],u=e.hasCallback?(y,b)=>{delete this.cancelCallbacks[n],this.target.postMessage({id:n,type:"",sourceMapId:this.mapId,error:y?ul(y):null,data:ul(b,r)},r)}:y=>{},m=ba(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,m,u);else if(this.parent.getWorkerSource){const y=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,y[0],m.source)[y[1]](m,u)}else u(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.CanonicalTileID=Yd,t.Color=Ai,t.ColorMode=Ks,t.CullFaceMode=Cs,t.DEMData=fp,t.DataConstantProperty=H,t.DedupedRequest=sb,t.DepthMode=wc,t.EXTENT=Wt,t.Elevation=class{isDataAvailableAtPoint(n){const e=this._source();if(this.isUsingMockSource()||!e||n.y<0||n.y>1)return!1;const r=e.getSource().maxzoom,u=1<1)return e;const m=u.getSource().maxzoom,y=1<{const y=this.getAtTileOffset(n,m.x,m.y),b=u.upVector(n.canonical,m.x,m.y);return Go(b,b,y*u.upVectorScale(n.canonical,e,r).metersToTile),b}}getForTilePoints(n,e,r,u){if(this.isUsingMockSource())return!1;const m=dp.create(this,n,u);return!!m&&(e.forEach(y=>{y[2]=this.exaggeration()*m.getElevationAt(y[0],y[1],r)}),!0)}getMinMaxForTile(n){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(n);if(!e||!e.dem)return null;const r=e.dem.tree,u=e.tileID,m=1<{let j=A===y-1?A-2:A===0?A:A-1;return j+=B?24575:0,[j,O]};for(let A=0;Athis._skuTokenExpiresAt}transformRequest(n,e){return this._transformRequestFn&&this._transformRequestFn(n,e)||{url:n}}normalizeStyleURL(n,e){if(!De(n))return n;const r=It(n);return r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeGlyphsURL(n,e){if(!De(n))return n;const r=It(n);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeSourceURL(n,e,r,u){if(!De(n))return n;const m=It(n);return m.path=`/v4/${m.authority}.json`,m.params.push("secure"),r&&m.params.push(`language=${r}`),u&&m.params.push(`worldview=${u}`),this._makeAPIURL(m,this._customAccessToken||e)}normalizeSpriteURL(n,e,r,u){const m=It(n);return De(n)?(m.path=`/styles/v1${m.path}/sprite${e}${r}`,this._makeAPIURL(m,this._customAccessToken||u)):(m.path+=`${e}${r}`,_t(m))}normalizeTileURL(n,e,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),n&&!De(n))return n;const u=It(n);u.path=u.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||r&&u.authority!=="raster"&&r===512?"@2x":""}${F.supported?".webp":"$1"}`),u.authority==="raster"?u.path=`/${R.RASTER_URL_PREFIX}${u.path}`:(u.path=u.path.replace(/^.+\/v4\//,"/"),u.path=`/${R.TILE_URL_VERSION}${u.path}`);const m=this._customAccessToken||function(y){for(const b of y){const I=b.match(/^access_token=(.*)$/);if(I)return I[1]}return null}(u.params)||R.ACCESS_TOKEN;return R.REQUIRE_ACCESS_TOKEN&&m&&this._skuToken&&u.params.push(`sku=${this._skuToken}`),this._makeAPIURL(u,m)}canonicalizeTileURL(n,e){const r=It(n);if(!r.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!r.path.match(/\.[\w]+$/))return n;let u="mapbox://";r.path.match(/^\/raster\/v1\//)?u+=`raster/${r.path.replace(`/${R.RASTER_URL_PREFIX}/`,"")}`:u+=`tiles/${r.path.replace(`/${R.TILE_URL_VERSION}/`,"")}`;let m=r.params;return e&&(m=m.filter(y=>!y.match(/^access_token=/))),m.length&&(u+=`?${m.join("&")}`),u}canonicalizeTileset(n,e){const r=!!e&&De(e),u=[];for(const m of n.tiles||[])Ge(m)?u.push(this.canonicalizeTileURL(m,r)):u.push(m);return u}_makeAPIURL(n,e){const r="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",u=It(R.API_URL);if(n.protocol=u.protocol,n.authority=u.authority,n.protocol==="http"){const m=n.params.indexOf("secure");m>=0&&n.params.splice(m,1)}if(u.path!=="/"&&(n.path=`${u.path}${n.path}`),!R.REQUIRE_ACCESS_TOKEN)return _t(n);if(e=e||R.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if(e[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return n.params=n.params.filter(m=>m.indexOf("access_token")===-1),n.params.push(`access_token=${e||""}`),_t(n)}},t.ResourceType=vr,t.SegmentVector=ji,t.SourceCache=hu,t.StencilMode=Vg,t.StructArrayLayout1ui2=Co,t.StructArrayLayout2f1f2i16=Kt,t.StructArrayLayout2i4=pt,t.StructArrayLayout2ui4=mr,t.StructArrayLayout3f12=Cn,t.StructArrayLayout3ui6=qt,t.StructArrayLayout4i8=ot,t.StructArrayLayout5f20=ni,t.Texture=ef,t.Tile=Bg,t.Transitionable=Y,t.Uniform1f=Ld,t.Uniform1i=class extends Ta{constructor(n){super(n),this.current=0}set(n,e,r){this.fetchUniformLocation(n,e)&&this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}},t.Uniform2f=class extends Ta{constructor(n){super(n),this.current=[0,0]}set(n,e,r){this.fetchUniformLocation(n,e)&&(r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1])))}},t.Uniform3f=class extends Ta{constructor(n){super(n),this.current=[0,0,0]}set(n,e,r){this.fetchUniformLocation(n,e)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2])))}},t.Uniform4f=qv,t.UniformColor=Zv,t.UniformMatrix2f=class extends Ta{constructor(n){super(n),this.current=zS}set(n,e,r){if(this.fetchUniformLocation(n,e)){for(let u=0;u<4;u++)if(r[u]!==this.current[u]){this.current=r,this.gl.uniformMatrix2fv(this.location,!1,r);break}}}},t.UniformMatrix3f=class extends Ta{constructor(n){super(n),this.current=DS}set(n,e,r){if(this.fetchUniformLocation(n,e)){for(let u=0;u<9;u++)if(r[u]!==this.current[u]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}}},t.UniformMatrix4f=class extends Ta{constructor(n){super(n),this.current=RS}set(n,e,r){if(this.fetchUniformLocation(n,e)){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let u=1;u<16;u++)if(r[u]!==this.current[u]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}}},t.UnwrappedTileID=Kx,t.ValidationError=Ot,t.VectorTileFeature=Xd,t.VectorTileWorkerSource=class extends wo{constructor(n,e,r,u,m){super(),this.actor=n,this.layerIndex=e,this.availableImages=r,this.loadVectorData=m||ab,this.loading={},this.loaded={},this.deduped=new sb(n.scheduler),this.isSpriteLoaded=u,this.scheduler=n.scheduler}loadTile(n,e){const r=n.uid,u=n&&n.request,m=u&&u.collectResourceTiming,y=this.loading[r]=new rA(n);y.abort=this.loadVectorData(n,(b,I)=>{const C=!this.loading[r];if(delete this.loading[r],C||b||!I)return y.status="done",C||(this.loaded[r]=y),e(b);const A=I.rawData,O={};I.expires&&(O.expires=I.expires),I.cacheControl&&(O.cacheControl=I.cacheControl),y.vectorTile=I.vectorTile||new wg(new Qd(A));const B=()=>{y.parse(y.vectorTile,this.layerIndex,this.availableImages,this.actor,(j,$)=>{if(j||!$)return e(j);const W={};if(m){const K=Ri(u);K.length>0&&(W.resourceTiming=JSON.parse(JSON.stringify(K)))}e(null,Vt({rawTileData:A.slice(0)},$,O,W))})};this.isSpriteLoaded?B():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(B,{type:"parseTile",isSymbolTile:n.isSymbolTile,zoom:n.tileZoom}):B()}),this.loaded=this.loaded||{},this.loaded[r]=y})}reloadTile(n,e){const r=this.loaded,u=n.uid,m=this;if(r&&r[u]){const y=r[u];y.showCollisionBoxes=n.showCollisionBoxes,y.enableTerrain=!!n.enableTerrain,y.projection=n.projection,y.tileTransform=cu(n.tileID.canonical,n.projection);const b=(I,C)=>{const A=y.reloadCallback;A&&(delete y.reloadCallback,y.parse(y.vectorTile,m.layerIndex,this.availableImages,m.actor,A)),e(I,C)};y.status==="parsing"?y.reloadCallback=b:y.status==="done"&&(y.vectorTile?y.parse(y.vectorTile,this.layerIndex,this.availableImages,this.actor,b):b())}}abortTile(n,e){const r=n.uid,u=this.loading[r];u&&(u.abort&&u.abort(),delete this.loading[r]),e()}removeTile(n,e){const r=this.loaded,u=n.uid;r&&r[u]&&delete r[u],e()}},t.WritingMode=Zo,t.ZoomDependentExpression=$l,t.add=Ma,t.addDynamicAttributes=up,t.adjoint=function(n,e){var r=e[0],u=e[1],m=e[2],y=e[3],b=e[4],I=e[5],C=e[6],A=e[7],O=e[8];return n[0]=b*O-I*A,n[1]=m*A-u*O,n[2]=u*I-m*b,n[3]=I*C-y*O,n[4]=r*O-m*C,n[5]=m*y-r*I,n[6]=y*A-b*C,n[7]=u*C-r*A,n[8]=r*b-u*y,n},t.asyncAll=Bt,t.bezier=Lt,t.bindAll=Kn,t.boundsAttributes=G1,t.bufferConvexPolygon=function(n,e){const r=[];for(let u=0;uuo&&(n.getActor().send("enforceCacheSizeLimit",lo),ra=0)},t.calculateGlobeLabelMatrix=function(n,e){const{x:r,y:u}=n.point,m=px(r,u,n.worldSize/n._pixelsPerMercatorPixel,0,0);return nu(m,m,ig($s(e)))},t.calculateGlobeMatrix=function(n){const{x:e,y:r}=n.point,{lng:u,lat:m}=n._center;return px(e,r,n.worldSize,u,m)},t.calculateGlobeMercatorMatrix=function(n){const e=n.pixelsPerMeter,r=e/Ms(1,n.center.lat),u=Ts(new Float64Array(16));return Mh(u,u,[n.point.x,n.point.y,0]),iu(u,u,[r,r,e]),Float32Array.from(u)},t.circumferenceAtLatitude=og,t.clamp=Mt,t.clearTileCache=function(n){if(!as())return;const e=E.caches.delete(an);n&&e.catch(n).then(()=>n())},t.clipLine=I1,t.clone=function(n){var e=new Ao(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e},t.clone$1=Fn,t.collisionCircleLayout=nC,t.config=R,t.conjugate=function(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=e[3],n},t.create=function(){var n=new Ao(16);return Ao!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n},t.create$1=Wv,t.createExpression=sl,t.createLayout=Oe,t.createStyleLayer=function(n){return n.type==="custom"?new XC(n):new YC[n.type](n)},t.cross=Hm,t.degToRad=Je,t.distance=function(n,e){return Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2])},t.div=function(n,e,r){return n[0]=e[0]/r[0],n[1]=e[1]/r[1],n[2]=e[2]/r[2],n},t.dot=ts,t.earthRadius=Oh,t.ease=Yt,t.easeCubicInOut=Nt,t.ecefToLatLng=function([n,e,r]){const u=Math.hypot(n,e,r),m=Math.atan2(n,r),y=.5*Math.PI-Math.acos(-e/u);return new ri(At(m),At(y))},t.emitValidationErrors=Md,t.endsWith=bn,t.enforceCacheSizeLimit=function(n){Ln(),Mr&&Mr.then(e=>{e.keys().then(r=>{for(let u=0;uy&&(u+=(n[m]-y)*(n[m]-y)),e[m]0){const W=180/u;Yv($,$,[W/A+1,0,0,0,W/O+1,0,-.5*W/B,.5*W/j,1])}return $[2]=C,$[5]=n.x,$[8]=n.y,$},t.getImage=ve,t.getJSON=function(n,e){return ls(Vt(n,{type:"json"}),e)},t.getLatitudinalLod=function(n){const e=Or-5;n=Mt(n,-e,e)/e*90;const r=Math.pow(Math.abs(Math.sin(Je(n))),3);return Math.round(r*(Rh.length-1))},t.getMapSessionAPI=Ci,t.getPerformanceMeasurement=Ri,t.getProjection=B1,t.getRTLTextPluginStatus=S,t.getReferrer=nn,t.getTilePoint=function(n,{x:e,y:r},u=0){return new Ie(((e-u)*n.scale-n.x)*Wt,(r*n.scale-n.y)*Wt)},t.getTileVec3=function(n,e,r=0){return rc(((e.x-r)*n.scale-n.x)*Wt,(e.y*n.scale-n.y)*Wt,yx(e.z,e.y))},t.getVideo=function(n,e){const r=E.document.createElement("video");r.muted=!0,r.onloadstart=function(){e(null,r)};for(let u=0;u{}}},t.globeCenterToScreenPoint=function(n){const e=[0,0,0],r=Ts(new Float64Array(16));return nu(r,n.pixelMatrix,n.globeMatrix),zi(e,e,r),new Ie(e[0],e[1])},t.globeDenormalizeECEF=ig,t.globeECEFOrigin=function(n,e){const r=[0,0,0];return zi(r,r,zh($s(e.canonical))),zi(r,r,n),r},t.globeMetersToEcef=zd,t.globeNormalizeECEF=zh,t.globePixelsToTileUnits=function(n,e){return Wt/(512*Math.pow(2,n))*Nd($s(e))},t.globePoleMatrixForTile=function(n,e,r){const u=Ts(new Float64Array(16)),m=(e/(1<0;return u===0&&!m&&!b&&y},t.identity=Ts,t.identity$1=rx,t.invert=$m,t.isFullscreen=function(){return!!E.document.fullscreenElement||!!E.document.webkitFullscreenElement},t.isLngLatBehindGlobe=rg,t.isMapAuthenticated=function(n){return Li.has(n)},t.isMapboxURL=De,t.isSafariWithAntialiasingBug=function(n){const e=n.navigator?n.navigator.userAgent:null;return!!zo(n)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.latFromMercatorY=zr,t.latLngToECEF=sc,t.len=qS,t.length=Sh,t.length$1=function(n){return Math.hypot(n[0],n[1],n[2],n[3])},t.lngFromMercatorX=qo,t.loadVectorTile=ab,t.makeRequest=ls,t.mapValue=function(n,e,r,u,m){return Mt((n-e)/(r-e)*(m-u)+u,u,m)},t.mercatorScale=vx,t.mercatorXfromLng=Xs,t.mercatorYfromLat=Ws,t.mercatorZfromAltitude=Ms,t.mul=jS,t.mul$1=GS,t.multiply=nu,t.multiply$1=Yv,t.multiply$2=Qv,t.nextPowerOfTwo=Tn,t.normalize=eo,t.normalize$1=ZS,t.normalize$2=nx,t.number=Nn,t.ortho=function(n,e,r,u,m,y,b){var I=1/(e-r),C=1/(u-m),A=1/(y-b);return n[0]=-2*I,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*C,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*A,n[11]=0,n[12]=(e+r)*I,n[13]=(m+u)*C,n[14]=(b+y)*A,n[15]=1,n},t.pbf=r1,t.perspective=function(n,e,r,u,m){var y,b=1/Math.tan(e/2);return n[0]=b/r,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=b,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,m!=null&&m!==1/0?(n[10]=(m+u)*(y=1/(u-m)),n[14]=2*m*u*y):(n[10]=-1,n[14]=-2*u),n},t.pick=function(n,e){const r={};for(let u=0;u0&&r[0]<=n.width&&r[1]>0&&r[1]<=n.height&&!rg(n,new ri(n.center.lat,90)),u[0]>0&&u[0]<=n.width&&u[1]>0&&u[1]<=n.height&&!rg(n,new ri(n.center.lat,-90))]},t.polygonContainsPoint=lu,t.polygonIntersectsBox=Mx,t.polygonIntersectsPolygon=wx,t.polygonizeBounds=function(n,e,r=0,u=!0){const m=new Ie(r,r),y=n.sub(m),b=e.add(m),I=[y,new Ie(b.x,y.y),b,new Ie(y.x,b.y)];return u&&I.push(y.clone()),I},t.posAttributes=Lh,t.postMapLoadEvent=ki,t.postPerformanceEvent=$n,t.postTurnstileEvent=Sn,t.potpack=Mg,t.prevPowerOfTwo=function(n){return n<=1?1:Math.pow(2,Math.floor(Math.log(n)/Math.LN2))},t.radToDeg=At,t.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.registerForPluginStateChange=function(n){return n({pluginStatus:_,pluginURL:o}),T.on("pluginStateChange",n),n},t.removeAuthState=function(n){Li.delete(n)},t.renderColorRamp=dg,t.resample=xx,t.rotateX=Xm,t.rotateX$1=ox,t.rotateY=Dd,t.rotateY$1=sx,t.rotateZ=function(n,e,r){var u=Math.sin(r),m=Math.cos(r),y=e[0],b=e[1],I=e[2],C=e[3],A=e[4],O=e[5],B=e[6],j=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=y*m+A*u,n[1]=b*m+O*u,n[2]=I*m+B*u,n[3]=C*m+j*u,n[4]=A*m-y*u,n[5]=O*m-b*u,n[6]=B*m-I*u,n[7]=j*m-C*u,n},t.rotateZ$1=function(n,e,r){r*=.5;var u=e[0],m=e[1],y=e[2],b=e[3],I=Math.sin(r),C=Math.cos(r);return n[0]=u*C+m*I,n[1]=m*C-u*I,n[2]=y*C+b*I,n[3]=b*C-y*I,n},t.scale=iu,t.scale$1=tx,t.scale$2=Go,t.scaleAndAdd=Ah,t.set=function(n,e,r,u){return n[0]=e,n[1]=r,n[2]=u,n},t.setCacheLimits=function(n,e){lo=n,uo=e},t.setColumn=function(n,e,r){n[4*e+0]=r[0],n[4*e+1]=r[1],n[4*e+2]=r[2],n[4*e+3]=r[3]},t.setRTLTextPlugin=function(n,e,r=!1){if(_===bh||_===wh||_===Eh)throw new Error("setRTLTextPlugin cannot be called multiple times.");o=co.resolveURL(n),_=bh,cl=e,v(),r||D()},t.smoothstep=Gt,t.spec=Qe,t.squaredLength=function(n){var e=n[0],r=n[1],u=n[2];return e*e+r*r+u*u},t.storeAuthState=function(n,e){e?Li.add(n):Li.delete(n)},t.sub=Is,t.subtract=Ym,t.symbolSize=iC,t.tileAABB=function(n,e,r,u,m,y,b,I,C){if(C.name==="globe")return HS(n,e,new Yd(r,u,m));const A=cu({z:r,x:u,y:m},C);return new to([(y+A.x/A.scale)*e,e*(A.y/A.scale),b],[(y+A.x2/A.scale)*e,e*(A.y2/A.scale),I])},t.tileCornersToBounds=Od,t.tileTransform=cu,t.transformMat3=function(n,e,r){var u=e[0],m=e[1],y=e[2];return n[0]=u*r[0]+m*r[3]+y*r[6],n[1]=u*r[1]+m*r[4]+y*r[7],n[2]=u*r[2]+m*r[5]+y*r[8],n},t.transformMat4=zi,t.transformMat4$1=ru,t.transformQuat=ex,t.transitionTileAABBinECEF=hx,t.translate=Mh,t.transpose=function(n,e){if(n===e){var r=e[1],u=e[2],m=e[5];n[1]=e[3],n[2]=e[6],n[3]=r,n[5]=e[7],n[6]=u,n[7]=m}else n[0]=e[0],n[1]=e[3],n[2]=e[6],n[3]=e[1],n[4]=e[4],n[5]=e[7],n[6]=e[2],n[7]=e[5],n[8]=e[8];return n},t.triggerPluginCompletionEvent=d,t.uniqueId=hn,t.updateGlobeVertexNormal=function(n,e,r,u,m){const y=5*e+2;n.float32[y+0]=r,n.float32[y+1]=u,n.float32[y+2]=m},t.validateCustomStyleLayer=function(n){const e=[],r=n.id;return r===void 0&&e.push({message:`layers.${r}: missing required property "id"`}),n.render===void 0&&e.push({message:`layers.${r}: missing required method "render"`}),n.renderingMode&&n.renderingMode!=="2d"&&n.renderingMode!=="3d"&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},t.validateFilter=n=>ko(Kl(n)),t.validateFog=n=>ko(Ed(n)),t.validateLayer=n=>ko(vd(n)),t.validateLight=n=>ko(wd(n)),t.validateSource=n=>ko(bd(n)),t.validateStyle=Id,t.validateTerrain=n=>ko(gh(n)),t.values=Zt,t.vectorTile=$d,t.version=k,t.warnOnce=yn,t.window=E,t.wrap=tt}),f(["./shared"],function(t){function E(xe){if(typeof xe=="number"||typeof xe=="boolean"||typeof xe=="string"||xe==null)return JSON.stringify(xe);if(Array.isArray(xe)){let ne="[";for(const ve of xe)ne+=`${E(ve)},`;return`${ne}]`}let ee="{";for(const ne of Object.keys(xe).sort())ee+=`${ne}:${E(xe[ne])},`;return`${ee}}`}function k(xe){let ee="";for(const ne of t.refProperties)ee+=`/${E(xe[ne])}`;return ee}class P{constructor(ee){this.keyCache={},ee&&this.replace(ee)}replace(ee){this._layerConfigs={},this._layers={},this.update(ee,[])}update(ee,ne){for(const ke of ee)this._layerConfigs[ke.id]=ke,(this._layers[ke.id]=t.createStyleLayer(ke)).compileFilter(),this.keyCache[ke.id]&&delete this.keyCache[ke.id];for(const ke of ne)delete this.keyCache[ke],delete this._layerConfigs[ke],delete this._layers[ke];this.familiesBySource={};const ve=function(ke,De){const Ge={};for(let me=0;methis._layers[It.id]),Ge=De[0];if(Ge.visibility==="none")continue;const Fe=Ge.source||"";let me=this.familiesBySource[Fe];me||(me=this.familiesBySource[Fe]={});const Ye=Ge.sourceLayer||"_geojsonTileLayer";let xt=me[Ye];xt||(xt=me[Ye]=[]),xt.push(De)}}}class R{loadTile(ee,ne){const{uid:ve,encoding:ke,rawImageData:De,padding:Ge,buildQuadTree:Fe}=ee,me=t.window.ImageBitmap&&De instanceof t.window.ImageBitmap?this.getImageData(De,Ge):De;ne(null,new t.DEMData(ve,me,ke,Ge<1,Fe))}getImageData(ee,ne){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(ee.width,ee.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=ee.width,this.offscreenCanvas.height=ee.height,this.offscreenCanvasContext.drawImage(ee,0,0,ee.width,ee.height);const ve=this.offscreenCanvasContext.getImageData(-ne,-ne,ee.width+2*ne,ee.height+2*ne);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),ve}}function F(xe,ee){if(xe.length!==0){U(xe[0],ee);for(var ne=1;ne=Math.abs(Fe)?ne-me+Fe:Fe-me+ne,ne=me}ne+ve>=0!=!!ee&&xe.reverse()}var Z=t.getDefaultExportFromCjs(function xe(ee,ne){var ve,ke=ee&&ee.type;if(ke==="FeatureCollection")for(ve=0;ve>31}function ut(xe,ee){for(var ne=xe.loadGeometry(),ve=xe.type,ke=0,De=0,Ge=ne.length,Fe=0;Fexe},Mt=Math.fround||(Gt=new Float32Array(1),xe=>(Gt[0]=+xe,Gt[0]));var Gt;const tt=3,Bt=5,Zt=6;class Vt{constructor(ee){this.options=Object.assign(Object.create(Yt),ee),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(ee){const{log:ne,minZoom:ve,maxZoom:ke}=this.options;ne&&console.time("total time");const De=`prepare ${ee.length} points`;ne&&console.time(De),this.points=ee;const Ge=[];for(let me=0;me=ve;me--){const Ye=+Date.now();Fe=this.trees[me]=this._createTree(this._cluster(Fe,me)),ne&&console.log("z%d: %d clusters in %dms",me,Fe.numItems,+Date.now()-Ye)}return ne&&console.timeEnd("total time"),this}getClusters(ee,ne){let ve=((ee[0]+180)%360+360)%360-180;const ke=Math.max(-90,Math.min(90,ee[1]));let De=ee[2]===180?180:((ee[2]+180)%360+360)%360-180;const Ge=Math.max(-90,Math.min(90,ee[3]));if(ee[2]-ee[0]>=360)ve=-180,De=180;else if(ve>De){const It=this.getClusters([ve,ke,180,Ge],ne),_t=this.getClusters([-180,ke,De,Ge],ne);return It.concat(_t)}const Fe=this.trees[this._limitZoom(ne)],me=Fe.range(rn(ve),Tn(Ge),rn(De),Tn(ke)),Ye=Fe.data,xt=[];for(const It of me){const _t=this.stride*It;xt.push(Ye[_t+Bt]>1?St(Ye,_t,this.clusterProps):this.points[Ye[_t+tt]])}return xt}getChildren(ee){const ne=this._getOriginId(ee),ve=this._getOriginZoom(ee),ke="No cluster with the specified id.",De=this.trees[ve];if(!De)throw new Error(ke);const Ge=De.data;if(ne*this.stride>=Ge.length)throw new Error(ke);const Fe=this.options.radius/(this.options.extent*Math.pow(2,ve-1)),me=De.within(Ge[ne*this.stride],Ge[ne*this.stride+1],Fe),Ye=[];for(const xt of me){const It=xt*this.stride;Ge[It+4]===ee&&Ye.push(Ge[It+Bt]>1?St(Ge,It,this.clusterProps):this.points[Ge[It+tt]])}if(Ye.length===0)throw new Error(ke);return Ye}getLeaves(ee,ne,ve){const ke=[];return this._appendLeaves(ke,ee,ne=ne||10,ve=ve||0,0),ke}getTile(ee,ne,ve){const ke=this.trees[this._limitZoom(ee)],De=Math.pow(2,ee),{extent:Ge,radius:Fe}=this.options,me=Fe/Ge,Ye=(ve-me)/De,xt=(ve+1+me)/De,It={features:[]};return this._addTileFeatures(ke.range((ne-me)/De,Ye,(ne+1+me)/De,xt),ke.data,ne,ve,De,It),ne===0&&this._addTileFeatures(ke.range(1-me/De,Ye,1,xt),ke.data,De,ve,De,It),ne===De-1&&this._addTileFeatures(ke.range(0,Ye,me/De,xt),ke.data,-1,ve,De,It),It.features.length?It:null}getClusterExpansionZoom(ee){let ne=this._getOriginZoom(ee)-1;for(;ne<=this.options.maxZoom;){const ve=this.getChildren(ee);if(ne++,ve.length!==1)break;ee=ve[0].properties.cluster_id}return ne}_appendLeaves(ee,ne,ve,ke,De){const Ge=this.getChildren(ne);for(const Fe of Ge){const me=Fe.properties;if(me&&me.cluster?De+me.point_count<=ke?De+=me.point_count:De=this._appendLeaves(ee,me.cluster_id,ve,ke,De):De1;let xt,It,_t;if(Ye)xt=hn(ne,me,this.clusterProps),It=ne[me],_t=ne[me+1];else{const on=this.points[ne[me+tt]];xt=on.properties;const[En,Sn]=on.geometry.coordinates;It=rn(En),_t=Tn(Sn)}const ln={type:1,geometry:[[Math.round(this.options.extent*(It*De-ve)),Math.round(this.options.extent*(_t*De-ke))]],tags:xt};let wn;wn=Ye||this.options.generateId?ne[me+tt]:this.points[ne[me+tt]].id,wn!==void 0&&(ln.id=wn),Ge.features.push(ln)}}_limitZoom(ee){return Math.max(this.options.minZoom,Math.min(Math.floor(+ee),this.options.maxZoom+1))}_cluster(ee,ne){const{radius:ve,extent:ke,reduce:De,minPoints:Ge}=this.options,Fe=ve/(ke*Math.pow(2,ne)),me=ee.data,Ye=[],xt=this.stride;for(let It=0;Itne&&(En+=me[yi+Bt])}if(En>on&&En>=Ge){let Sn,yi=_t*on,ki=ln*on,hr=-1;const $n=((It/xt|0)<<5)+(ne+1)+this.points.length;for(const $r of wn){const Ci=$r*xt;if(me[Ci+2]<=ne)continue;me[Ci+2]=ne;const Li=me[Ci+Bt];yi+=me[Ci]*Li,ki+=me[Ci+1]*Li,me[Ci+4]=$n,De&&(Sn||(Sn=this._map(me,It,!0),hr=this.clusterProps.length,this.clusterProps.push(Sn)),De(Sn,this._map(me,Ci)))}me[It+4]=$n,Ye.push(yi/En,ki/En,1/0,$n,-1,En),De&&Ye.push(hr)}else{for(let Sn=0;Sn1)for(const Sn of wn){const yi=Sn*xt;if(!(me[yi+2]<=ne)){me[yi+2]=ne;for(let ki=0;ki>5}_getOriginZoom(ee){return(ee-this.points.length)%32}_map(ee,ne,ve){if(ee[ne+Bt]>1){const Ge=this.clusterProps[ee[ne+Zt]];return ve?Object.assign({},Ge):Ge}const ke=this.points[ee[ne+tt]].properties,De=this.options.map(ke);return ve&&De===ke?Object.assign({},De):De}}function St(xe,ee,ne){return{type:"Feature",id:xe[ee+tt],properties:hn(xe,ee,ne),geometry:{type:"Point",coordinates:[(ve=xe[ee],360*(ve-.5)),je(xe[ee+1])]}};var ve}function hn(xe,ee,ne){const ve=xe[ee+Bt],ke=ve>=1e4?`${Math.round(ve/1e3)}k`:ve>=1e3?Math.round(ve/100)/10+"k":ve,De=xe[ee+Zt],Ge=De===-1?{}:Object.assign({},ne[De]);return Object.assign(Ge,{cluster:!0,cluster_id:xe[ee+tt],point_count:ve,point_count_abbreviated:ke})}function rn(xe){return xe/360+.5}function Tn(xe){const ee=Math.sin(xe*Math.PI/180),ne=.5-.25*Math.log((1+ee)/(1-ee))/Math.PI;return ne<0?0:ne>1?1:ne}function je(xe){const ee=(180-360*xe)*Math.PI/180;return 360*Math.atan(Math.exp(ee))/Math.PI-90}function Kn(xe,ee,ne,ve){for(var ke,De=ve,Ge=ne-ee>>1,Fe=ne-ee,me=xe[ee],Ye=xe[ee+1],xt=xe[ne],It=xe[ne+1],_t=ee+3;_tDe)ke=_t,De=ln;else if(ln===De){var wn=Math.abs(_t-Ge);wnve&&(ke-ee>3&&Kn(xe,ee,ke,ve),xe[ke+2]=De,ne-ke>3&&Kn(xe,ke,ne,ve))}function bn(xe,ee,ne,ve,ke,De){var Ge=ke-ne,Fe=De-ve;if(Ge!==0||Fe!==0){var me=((xe-ne)*Ge+(ee-ve)*Fe)/(Ge*Ge+Fe*Fe);me>1?(ne=ke,ve=De):me>0&&(ne+=Ge*me,ve+=Fe*me)}return(Ge=xe-ne)*Ge+(Fe=ee-ve)*Fe}function gt(xe,ee,ne,ve){var ke={id:xe===void 0?null:xe,type:ee,geometry:ne,tags:ve,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(De){var Ge=De.geometry,Fe=De.type;if(Fe==="Point"||Fe==="MultiPoint"||Fe==="LineString")Me(De,Ge);else if(Fe==="Polygon"||Fe==="MultiLineString")for(var me=0;me0&&(Ge+=ve?(ke*Ye-me*De)/2:Math.sqrt(Math.pow(me-ke,2)+Math.pow(Ye-De,2))),ke=me,De=Ye}var xt=ee.length-3;ee[2]=1,Kn(ee,0,xt,ne),ee[xt+2]=1,ee.size=Math.abs(Ge),ee.start=0,ee.end=ee.size}function _i(xe,ee,ne,ve){for(var ke=0;ke1?1:ne}function wt(xe,ee,ne,ve,ke,De,Ge,Fe){if(ve/=ee,De>=(ne/=ee)&&Ge=ve)return null;for(var me=[],Ye=0;Ye=ne&&wn=ve)){var on=[];if(_t==="Point"||_t==="MultiPoint")Wo(It,on,ne,ve,ke);else if(_t==="LineString")zo(It,on,ne,ve,ke,!1,Fe.lineMetrics);else if(_t==="MultiLineString")bo(It,on,ne,ve,ke,!1);else if(_t==="Polygon")bo(It,on,ne,ve,ke,!0);else if(_t==="MultiPolygon")for(var En=0;En=ne&&Ge<=ve&&(ee.push(xe[De]),ee.push(xe[De+1]),ee.push(xe[De+2]))}}function zo(xe,ee,ne,ve,ke,De,Ge){for(var Fe,me,Ye=Fr(xe),xt=ke===0?lo:uo,It=xe.start,_t=0;_tne&&(me=xt(Ye,ln,wn,En,Sn,ne),Ge&&(Ye.start=It+Fe*me)):yi>ve?ki=ne&&(me=xt(Ye,ln,wn,En,Sn,ne),hr=!0),ki>ve&&yi<=ve&&(me=xt(Ye,ln,wn,En,Sn,ve),hr=!0),!De&&hr&&(Ge&&(Ye.end=It+Fe*me),ee.push(Ye),Ye=Fr(xe)),Ge&&(It+=Fe)}var $n=xe.length-3;ln=xe[$n],wn=xe[$n+1],on=xe[$n+2],(yi=ke===0?ln:wn)>=ne&&yi<=ve&&an(Ye,ln,wn,on),$n=Ye.length-3,De&&$n>=3&&(Ye[$n]!==Ye[0]||Ye[$n+1]!==Ye[1])&&an(Ye,Ye[0],Ye[1],Ye[2]),Ye.length&&ee.push(Ye)}function Fr(xe){var ee=[];return ee.size=xe.size,ee.start=xe.start,ee.end=xe.end,ee}function bo(xe,ee,ne,ve,ke,De){for(var Ge=0;GeGe.maxX&&(Ge.maxX=xt),It>Ge.maxY&&(Ge.maxY=It)}return Ge}function ra(xe,ee,ne,ve){var ke=ee.geometry,De=ee.type,Ge=[];if(De==="Point"||De==="MultiPoint")for(var Fe=0;Fe0&&ee.size<(ke?Ge:ve))ne.numPoints+=ee.length/3;else{for(var Fe=[],me=0;meGe)&&(ne.numSimplified++,Fe.push(ee[me]),Fe.push(ee[me+1])),ne.numPoints++;ke&&function(Ye,xt){for(var It=0,_t=0,ln=Ye.length,wn=ln-2;_t0===xt)for(_t=0,ln=Ye.length;_t24)throw new Error("maxZoom should be in the 0-24 range");if(ee.promoteId&&ee.generateId)throw new Error("promoteId and generateId cannot be used together.");var ve=function(ke,De){var Ge=[];if(ke.type==="FeatureCollection")for(var Fe=0;Fe1&&console.time("creation"),_t=this.tiles[It]=sn(xe,ee,ne,ve,me),this.tileCoords.push({z:ee,x:ne,y:ve}),Ye)){Ye>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",ee,ne,ve,_t.numFeatures,_t.numPoints,_t.numSimplified),console.timeEnd("creation"));var ln="z"+ee;this.stats[ln]=(this.stats[ln]||0)+1,this.total++}if(_t.source=xe,ke){if(ee===me.maxZoom||ee===ke)continue;var wn=1<1&&console.time("clipping");var on,En,Sn,yi,ki,hr,$n=.5*me.buffer/me.extent,$r=.5-$n,Ci=.5+$n,Li=1+$n;on=En=Sn=yi=null,ki=wt(xe,xt,ne-$n,ne+Ci,0,_t.minX,_t.maxX,me),hr=wt(xe,xt,ne+$r,ne+Li,0,_t.minX,_t.maxX,me),xe=null,ki&&(on=wt(ki,xt,ve-$n,ve+Ci,1,_t.minY,_t.maxY,me),En=wt(ki,xt,ve+$r,ve+Li,1,_t.minY,_t.maxY,me),ki=null),hr&&(Sn=wt(hr,xt,ve-$n,ve+Ci,1,_t.minY,_t.maxY,me),yi=wt(hr,xt,ve+$r,ve+Li,1,_t.minY,_t.maxY,me),hr=null),Ye>1&&console.timeEnd("clipping"),Fe.push(on||[],ee+1,2*ne,2*ve),Fe.push(En||[],ee+1,2*ne,2*ve+1),Fe.push(Sn||[],ee+1,2*ne+1,2*ve),Fe.push(yi||[],ee+1,2*ne+1,2*ve+1)}}},Yo.prototype.getTile=function(xe,ee,ne){var ve=this.options,ke=ve.extent,De=ve.debug;if(xe<0||xe>24)return null;var Ge=1<1&&console.log("drilling down to z%d-%d-%d",xe,ee,ne);for(var me,Ye=xe,xt=ee,It=ne;!me&&Ye>0;)Ye--,xt=Math.floor(xt/2),It=Math.floor(It/2),me=this.tiles[nn(Ye,xt,It)];return me&&me.source?(De>1&&console.log("found parent tile z%d-%d-%d",Ye,xt,It),De>1&&console.time("drilling down"),this.splitTile(me.source,Ye,xt,It,xe,ee,ne),De>1&&console.timeEnd("drilling down"),this.tiles[Fe]?as(this.tiles[Fe],ke):null):null};class zs extends t.VectorTileWorkerSource{constructor(ee,ne,ve,ke,De){super(ee,ne,ve,ke,ls),De&&(this.loadGeoJSON=De)}loadData(ee,ne){const ve=ee&&ee.request,ke=ve&&ve.collectResourceTiming;this.loadGeoJSON(ee,(De,Ge)=>{if(De||!Ge)return ne(De);if(typeof Ge!="object")return ne(new Error(`Input data given to '${ee.source}' is not a valid GeoJSON object.`));{Z(Ge,!0);try{if(ee.filter){const me=t.createExpression(ee.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(me.result==="error")throw new Error(me.value.map(xt=>`${xt.key}: ${xt.message}`).join(", "));Ge={type:"FeatureCollection",features:Ge.features.filter(xt=>me.value.evaluate({zoom:0},xt))}}this._geoJSONIndex=ee.cluster?new Vt(function({superclusterOptions:me,clusterProperties:Ye}){if(!Ye||!me)return me;const xt={},It={},_t={accumulated:null,zoom:0},ln={properties:null},wn=Object.keys(Ye);for(const on of wn){const[En,Sn]=Ye[on],yi=t.createExpression(Sn),ki=t.createExpression(typeof En=="string"?[En,["accumulated"],["get",on]]:En);xt[on]=yi.value,It[on]=ki.value}return me.map=on=>{ln.properties=on;const En={};for(const Sn of wn)En[Sn]=xt[Sn].evaluate(_t,ln);return En},me.reduce=(on,En)=>{ln.properties=En;for(const Sn of wn)_t.accumulated=on[Sn],on[Sn]=It[Sn].evaluate(_t,ln)},me}(ee)).load(Ge.features):function(me,Ye){return new Yo(me,Ye)}(Ge,ee.geojsonVtOptions)}catch(me){return ne(me)}this.loaded={};const Fe={};if(ke){const me=t.getPerformanceMeasurement(ve);me&&(Fe.resourceTiming={},Fe.resourceTiming[ee.source]=JSON.parse(JSON.stringify(me)))}ne(null,Fe)}})}reloadTile(ee,ne){const ve=this.loaded;return ve&&ve[ee.uid]?super.reloadTile(ee,ne):this.loadTile(ee,ne)}loadGeoJSON(ee,ne){if(ee.request)t.getJSON(ee.request,ne);else{if(typeof ee.data!="string")return ne(new Error(`Input data given to '${ee.source}' is not a valid GeoJSON object.`));try{return ne(null,JSON.parse(ee.data))}catch{return ne(new Error(`Input data given to '${ee.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(ee,ne){try{ne(null,this._geoJSONIndex.getClusterExpansionZoom(ee.clusterId))}catch(ve){ne(ve)}}getClusterChildren(ee,ne){try{ne(null,this._geoJSONIndex.getChildren(ee.clusterId))}catch(ve){ne(ve)}}getClusterLeaves(ee,ne){try{ne(null,this._geoJSONIndex.getLeaves(ee.clusterId,ee.limit,ee.offset))}catch(ve){ne(ve)}}}class Os{constructor(ee){this.self=ee,this.actor=new t.Actor(ee,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=t.getProjection({name:"mercator"}),this.workerSourceTypes={vector:t.VectorTileWorkerSource,geojson:zs},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(ne,ve)=>{if(this.workerSourceTypes[ne])throw new Error(`Worker source with name "${ne}" already registered.`);this.workerSourceTypes[ne]=ve},this.self.registerRTLTextPlugin=ne=>{if(t.plugin.isParsed())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=ne.applyArabicShaping,t.plugin.processBidirectionalText=ne.processBidirectionalText,t.plugin.processStyledBidirectionalText=ne.processStyledBidirectionalText}}clearCaches(ee,ne,ve){delete this.layerIndexes[ee],delete this.availableImages[ee],delete this.workerSources[ee],delete this.demWorkerSources[ee],ve()}checkIfReady(ee,ne,ve){ve()}setReferrer(ee,ne){this.referrer=ne}spriteLoaded(ee,ne){this.isSpriteLoaded[ee]=ne;for(const ve in this.workerSources[ee]){const ke=this.workerSources[ee][ve];for(const De in ke)ke[De]instanceof t.VectorTileWorkerSource&&(ke[De].isSpriteLoaded=ne,ke[De].fire(new t.Event("isSpriteLoaded")))}}setImages(ee,ne,ve){this.availableImages[ee]=ne;for(const ke in this.workerSources[ee]){const De=this.workerSources[ee][ke];for(const Ge in De)De[Ge].availableImages=ne}ve()}enableTerrain(ee,ne,ve){this.terrain=ne,ve()}setProjection(ee,ne){this.projections[ee]=t.getProjection(ne)}setLayers(ee,ne,ve){this.getLayerIndex(ee).replace(ne),ve()}updateLayers(ee,ne,ve){this.getLayerIndex(ee).update(ne.layers,ne.removedIds),ve()}loadTile(ee,ne,ve){const ke=this.enableTerrain?t.extend({enableTerrain:this.terrain},ne):ne;ke.projection=this.projections[ee]||this.defaultProjection,this.getWorkerSource(ee,ne.type,ne.source).loadTile(ke,ve)}loadDEMTile(ee,ne,ve){const ke=this.enableTerrain?t.extend({buildQuadTree:this.terrain},ne):ne;this.getDEMWorkerSource(ee,ne.source).loadTile(ke,ve)}reloadTile(ee,ne,ve){const ke=this.enableTerrain?t.extend({enableTerrain:this.terrain},ne):ne;ke.projection=this.projections[ee]||this.defaultProjection,this.getWorkerSource(ee,ne.type,ne.source).reloadTile(ke,ve)}abortTile(ee,ne,ve){this.getWorkerSource(ee,ne.type,ne.source).abortTile(ne,ve)}removeTile(ee,ne,ve){this.getWorkerSource(ee,ne.type,ne.source).removeTile(ne,ve)}removeSource(ee,ne,ve){if(!this.workerSources[ee]||!this.workerSources[ee][ne.type]||!this.workerSources[ee][ne.type][ne.source])return;const ke=this.workerSources[ee][ne.type][ne.source];delete this.workerSources[ee][ne.type][ne.source],ke.removeSource!==void 0?ke.removeSource(ne,ve):ve()}loadWorkerSource(ee,ne,ve){try{this.self.importScripts(ne.url),ve()}catch(ke){ve(ke.toString())}}syncRTLPluginState(ee,ne,ve){try{t.plugin.setState(ne);const ke=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&ke!=null){this.self.importScripts(ke);const De=t.plugin.isParsed();ve(De?void 0:new Error(`RTL Text Plugin failed to import scripts from ${ke}`),De)}}catch(ke){ve(ke.toString())}}getAvailableImages(ee){let ne=this.availableImages[ee];return ne||(ne=[]),ne}getLayerIndex(ee){let ne=this.layerIndexes[ee];return ne||(ne=this.layerIndexes[ee]=new P),ne}getWorkerSource(ee,ne,ve){if(this.workerSources[ee]||(this.workerSources[ee]={}),this.workerSources[ee][ne]||(this.workerSources[ee][ne]={}),!this.workerSources[ee][ne][ve]){const ke={send:(De,Ge,Fe,me,Ye,xt)=>{this.actor.send(De,Ge,Fe,ee,Ye,xt)},scheduler:this.actor.scheduler};this.workerSources[ee][ne][ve]=new this.workerSourceTypes[ne](ke,this.getLayerIndex(ee),this.getAvailableImages(ee),this.isSpriteLoaded[ee])}return this.workerSources[ee][ne][ve]}getDEMWorkerSource(ee,ne){return this.demWorkerSources[ee]||(this.demWorkerSources[ee]={}),this.demWorkerSources[ee][ne]||(this.demWorkerSources[ee][ne]=new R),this.demWorkerSources[ee][ne]}enforceCacheSizeLimit(ee,ne){t.enforceCacheSizeLimit(ne)}getWorkerPerformanceMetrics(ee,ne,ve){ve(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new Os(self)),Os}),f(["./shared"],function(t){function E(_,o){if(Array.isArray(_)){if(!Array.isArray(o)||_.length!==o.length)return!1;for(let d=0;d<_.length;d++)if(!E(_[d],o[d]))return!1;return!0}if(typeof _=="object"&&_!==null&&o!==null){if(typeof o!="object"||Object.keys(_).length!==Object.keys(o).length)return!1;for(const d in _)if(!E(_[d],o[d]))return!1;return!0}return _===o}var k=P;function P(_){return!function(o){return typeof window>"u"||typeof document>"u"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var v,T,S=new Blob([""],{type:"text/javascript"}),D=URL.createObjectURL(S);try{T=new Worker(D),v=!0}catch{v=!1}return T&&T.terminate(),URL.revokeObjectURL(D),v}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var v=document.createElement("canvas");v.width=v.height=1;var T=v.getContext("2d");if(!T)return!1;var S=T.getImageData(0,0,1,1);return S&&S.width===v.width}()?(R[d=o&&o.failIfMajorPerformanceCaveat]===void 0&&(R[d]=function(v){var T,S=function(D){var z=document.createElement("canvas"),N=Object.create(P.webGLContextAttributes);return N.failIfMajorPerformanceCaveat=D,z.getContext("webgl",N)||z.getContext("experimental-webgl",N)}(v);if(!S)return!1;try{T=S.createShader(S.VERTEX_SHADER)}catch{return!1}return!(!T||S.isContextLost())&&(S.shaderSource(T,"void main() {}"),S.compileShader(T),S.getShaderParameter(T,S.COMPILE_STATUS)===!0)}(d)),R[d]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var d}(_)}var R={};function F(_,o,d){const v=t.window.document.createElement(_);return o!==void 0&&(v.className=o),d&&d.appendChild(v),v}function U(_,o,d){const v=t.window.document.createElementNS("http://www.w3.org/2000/svg",_);for(const T of Object.keys(o))v.setAttributeNS(null,T,o[T]);return d&&d.appendChild(v),v}P.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const Z=t.window.document&&t.window.document.documentElement.style,J=Z&&Z.userSelect!==void 0?"userSelect":"WebkitUserSelect";let he;function ye(){Z&&J&&(he=Z[J],Z[J]="none")}function te(){Z&&J&&(Z[J]=he)}function ce(_){_.preventDefault(),_.stopPropagation(),t.window.removeEventListener("click",ce,!0)}function be(){t.window.addEventListener("click",ce,!0),t.window.setTimeout(()=>{t.window.removeEventListener("click",ce,!0)},0)}function we(_,o){const d=_.getBoundingClientRect();return Ve(_,d,o)}function Ue(_,o){const d=_.getBoundingClientRect(),v=[];for(let T=0;T=0?0:_.button}function Ve(_,o,d){const v=_.offsetWidth===o.width?1:_.offsetWidth/o.width;return new t.Point((d.clientX-o.left)*v,(d.clientY-o.top)*v)}function Ie(_,o){var d=o[0],v=o[1],T=o[2],S=o[3],D=d*S-T*v;return D?(_[0]=S*(D=1/D),_[1]=-v*D,_[2]=-T*D,_[3]=d*D,_):null}function ft(_){const{userImage:o}=_;return!!(o&&o.render&&o.render())&&(_.data.replace(new Uint8Array(o.data.buffer)),!0)}class lt extends t.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(o){if(this.loaded!==o&&(this.loaded=o,o)){for(const{ids:d,callback:v}of this.requestors)this._notify(d,v);this.requestors=[]}}hasImage(o){return!!this.getImage(o)}getImage(o){return this.images[o]}addImage(o,d){this._validate(o,d)&&(this.images[o]=d)}_validate(o,d){let v=!0;return this._validateStretch(d.stretchX,d.data&&d.data.width)||(this.fire(new t.ErrorEvent(new Error(`Image "${o}" has invalid "stretchX" value`))),v=!1),this._validateStretch(d.stretchY,d.data&&d.data.height)||(this.fire(new t.ErrorEvent(new Error(`Image "${o}" has invalid "stretchY" value`))),v=!1),this._validateContent(d.content,d)||(this.fire(new t.ErrorEvent(new Error(`Image "${o}" has invalid "content" value`))),v=!1),v}_validateStretch(o,d){if(!o)return!0;let v=0;for(const T of o){if(T[0]{this.ready=!0})}broadcast(o,d,v){t.asyncAll(this.actors,(T,S)=>{T.send(o,d,S)},v=v||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(o=>{o.remove()}),this.actors=[],this.workerPool.release(this.id)}}function Bt(_,o,d){return o*(t.EXTENT/(_.tileSize*Math.pow(2,d-_.tileID.overscaledZ)))}tt.Actor=t.Actor;class Zt{constructor(o,d,v,T){this.screenBounds=o,this.cameraPoint=d,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=v,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,T)}static createFromScreenPoints(o,d){let v,T;if(o instanceof t.Point||typeof o[0]=="number"){const S=t.Point.convert(o);v=[S],T=d.isPointAboveHorizon(S)}else{const S=t.Point.convert(o[0]),D=t.Point.convert(o[1]);v=[S,D],T=t.polygonizeBounds(S,D).every(z=>d.isPointAboveHorizon(z))}return new Zt(v,d.getCameraPoint(),T,d)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(o){return t.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],o)}bufferedCameraGeometry(o){const d=this.screenBounds[0],v=this.screenBounds.length===1?this.screenBounds[0].add(new t.Point(1,1)):this.screenBounds[1],T=t.polygonizeBounds(d,v,0,!1);return this.cameraPoint.y>v.y&&(this.cameraPoint.x>d.x&&this.cameraPoint.x=v.x?T[2]=this.cameraPoint:this.cameraPoint.x<=d.x&&(T[3]=this.cameraPoint)),t.bufferConvexPolygon(T,o)}bufferedCameraGeometryGlobe(o){const d=this.screenBounds[0],v=this.screenBounds.length===1?this.screenBounds[0].add(new t.Point(1,1)):this.screenBounds[1],T=t.polygonizeBounds(d,v,o),S=this.cameraPoint.clone();switch(3*((S.y>d.y)+(S.y>v.y))+((S.x>d.x)+(S.x>v.x))){case 0:T[0]=S,T[4]=S.clone();break;case 1:T.splice(1,0,S);break;case 2:T[1]=S;break;case 3:T.splice(4,0,S);break;case 5:T.splice(2,0,S);break;case 6:T[3]=S;break;case 7:T.splice(3,0,S);break;case 8:T[2]=S}return T}containsTile(o,d,v,T=0){const S=o.queryPadding/d._pixelsPerMercatorPixel+1,D=v?this._bufferedCameraMercator(S,d):this._bufferedScreenMercator(S,d);let z=o.tileID.wrap+(D.unwrapped?T:0);const N=D.polygon.map(fe=>t.getTilePoint(o.tileTransform,fe,z));if(!t.polygonIntersectsBox(N,0,0,t.EXTENT,t.EXTENT))return;z=o.tileID.wrap+(this.screenGeometryMercator.unwrapped?T:0);const q=this.screenGeometryMercator.polygon.map(fe=>t.getTileVec3(o.tileTransform,fe,z)),G=q.map(fe=>new t.Point(fe[0],fe[1])),Y=d.getFreeCameraOptions().position||new t.MercatorCoordinate(0,0,0),ie=t.getTileVec3(o.tileTransform,Y,z),se=q.map(fe=>{const H=t.sub(fe,fe,ie);return t.normalize(H,H),new t.Ray(ie,H)}),ue=Bt(o,1,d.zoom)*d._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:G,tilespaceRays:se,bufferedTilespaceGeometry:N,bufferedTilespaceBounds:(le=t.getBounds(N),le.min.x=t.clamp(le.min.x,0,t.EXTENT),le.min.y=t.clamp(le.min.y,0,t.EXTENT),le.max.x=t.clamp(le.max.x,0,t.EXTENT),le.max.y=t.clamp(le.max.y,0,t.EXTENT),le),tile:o,tileID:o.tileID,pixelToTileUnitsFactor:ue};var le}_bufferedScreenMercator(o,d){const v=hn(o);if(this._screenRaycastCache[v])return this._screenRaycastCache[v];{let T;return T=d.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(o),d):{polygon:this.bufferedScreenGeometry(o).map(S=>d.pointCoordinate3D(S)),unwrapped:!0},this._screenRaycastCache[v]=T,T}}_bufferedCameraMercator(o,d){const v=hn(o);if(this._cameraRaycastCache[v])return this._cameraRaycastCache[v];{let T;return T=d.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(o),d):{polygon:this.bufferedCameraGeometry(o).map(S=>d.pointCoordinate3D(S)),unwrapped:!0},this._cameraRaycastCache[v]=T,T}}_projectAndResample(o,d){const v=function(S,D){const z=t.multiply([],D.pixelMatrix,D.globeMatrix),N=[0,-t.GLOBE_RADIUS,0,1],q=[0,t.GLOBE_RADIUS,0,1],G=[0,0,0,1];t.transformMat4$1(N,N,z),t.transformMat4$1(q,q,z),t.transformMat4$1(G,G,z);const Y=new t.Point(N[0]/N[3],N[1]/N[3]),ie=new t.Point(q[0]/q[3],q[1]/q[3]),se=t.polygonContainsPoint(S,Y)&&N[3]1?Vt(S.slice(0,fe),D):[],ge=fenew t.Point(St(Pe.x),Pe.y)),ge=ge.map(Pe=>new t.Point(St(Pe.x),Pe.y));const _e=[...oe];_e.length===0&&_e.push(ge[ge.length-1]);const Ae=t.number(_e[_e.length-1].y,(ge.length===0?oe[0]:ge[0]).y,H);let Re;return Re=se?[new t.Point(0,Ae),new t.Point(0,0),new t.Point(1,0),new t.Point(1,Ae)]:[new t.Point(1,Ae),new t.Point(1,1),new t.Point(0,1),new t.Point(0,Ae)],_e.push(...Re),ge.length===0?_e.push(oe[0]):_e.push(...ge),{polygon:_e.map(Pe=>new t.MercatorCoordinate(Pe.x,Pe.y)),unwrapped:!1}}(o,d);if(v)return v;const T=function(S,D){let z=!1,N=-1/0,q=0;for(let Y=0;YN&&(N=S[Y].x,q=Y);for(let Y=0;Y.5&&(se.x{Y.x-=1}),{polygon:S,unwrapped:z}}(Vt(o,d).map(S=>new t.Point(St(S.x),S.y)),d);return{polygon:T.polygon.map(S=>new t.MercatorCoordinate(S.x,S.y)),unwrapped:T.unwrapped}}}function Vt(_,o){return t.resample(_,d=>{const v=o.pointCoordinate3D(d);d.x=v.x,d.y=v.y},.00390625)}function St(_){return _<0?1+_%1:_%1}function hn(_){return 100*_|0}function rn(_,o,d,v,T){const S=function(D,z){if(D)return T(D);if(z){_.url&&z.tiles&&_.tiles&&delete _.tiles;const N=t.pick(t.extend(z,_),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);z.vector_layers&&(N.vectorLayers=z.vector_layers,N.vectorLayerIds=N.vectorLayers.map(q=>q.id)),N.tiles=o.canonicalizeTileset(N,_.url),T(null,N)}};return _.url?t.getJSON(o.transformRequest(o.normalizeSourceURL(_.url,null,d,v),t.ResourceType.Source),S):t.exported.frame(()=>S(null,_))}class Tn{constructor(o,d,v){this.bounds=t.LngLatBounds.convert(this.validateBounds(o)),this.minzoom=d||0,this.maxzoom=v||24}validateBounds(o){return Array.isArray(o)&&o.length===4?[Math.max(-180,o[0]),Math.max(-90,o[1]),Math.min(180,o[2]),Math.min(90,o[3])]:[-180,-90,180,90]}contains(o){const d=Math.pow(2,o.z),v=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*d),T=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*d),S=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*d),D=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*d);return o.x>=v&&o.x=T&&o.y{this._tileJSONRequest=null,this._loaded=!0,T?(d&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${d}`),v&&v.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${v}`),this.fire(new t.ErrorEvent(T))):S&&(t.extend(this,S),S.bounds&&(this.tileBounds=new Tn(S.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(S.tiles,this.map._requestManager._customAccessToken),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))),o&&o(T)})}loaded(){return this._loaded}hasTile(o){return!this.tileBounds||this.tileBounds.contains(o.canonical)}onAdd(o){this.map=o,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(o){return this._options.tiles=o,this.reload(),this}setUrl(o){return this.url=o,this._options.url=o,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return t.extend({},this._options)}loadTile(o,d){const v=this.map._requestManager.normalizeTileURL(o.tileID.canonical.url(this.tiles,this.scheme)),T={request:this.map._requestManager.transformRequest(v,t.ResourceType.Tile),data:void 0,uid:o.uid,tileID:o.tileID,tileZoom:o.tileZoom,zoom:o.tileID.overscaledZ,tileSize:this.tileSize*o.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:o.isSymbolTile};if(T.request.collectResourceTiming=this._collectResourceTiming,o.actor&&o.state!=="expired")o.state==="loading"?o.reloadCallback=d:o.request=o.actor.send("reloadTile",T,S.bind(this));else if(o.actor=this._tileWorkers[v]=this._tileWorkers[v]||this.dispatcher.getActor(),this.dispatcher.ready)o.request=o.actor.send("loadTile",T,S.bind(this),void 0,!0);else{const D=t.loadVectorTile.call({deduped:this._deduped},T,(z,N)=>{z||!N?S.call(this,z):(T.data={cacheControl:N.cacheControl,expires:N.expires,rawData:N.rawData.slice(0)},o.actor&&o.actor.send("loadTile",T,S.bind(this),void 0,!0))},!0);o.request={cancel:D}}function S(D,z){return delete o.request,o.aborted?d(null):D&&D.status!==404?d(D):(z&&z.resourceTiming&&(o.resourceTiming=z.resourceTiming),this.map._refreshExpiredTiles&&z&&o.setExpiryData(z),o.loadVectorData(z,this.map.painter),t.cacheEntryPossiblyAdded(this.dispatcher),d(null),void(o.reloadCallback&&(this.loadTile(o,o.reloadCallback),o.reloadCallback=null)))}}abortTile(o){o.request&&(o.request.cancel(),delete o.request),o.actor&&o.actor.send("abortTile",{uid:o.uid,type:this.type,source:this.id})}unloadTile(o){o.unloadVectorData(),o.actor&&o.actor.send("removeTile",{uid:o.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class _t extends t.Evented{constructor(o,d,v,T){super(),this.id=o,this.dispatcher=v,this.setEventedParent(T),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.extend({type:"raster"},d),t.extend(this,t.pick(d,["url","scheme","tileSize"]))}load(o){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=rn(this._options,this.map._requestManager,null,null,(d,v)=>{this._tileJSONRequest=null,this._loaded=!0,d?this.fire(new t.ErrorEvent(d)):v&&(t.extend(this,v),v.bounds&&(this.tileBounds=new Tn(v.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(v.tiles),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))),o&&o(d)})}loaded(){return this._loaded}onAdd(o){this.map=o,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(o){return this._options.tiles=o,this.reload(),this}setUrl(o){return this.url=o,this._options.url=o,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return t.extend({},this._options)}hasTile(o){return!this.tileBounds||this.tileBounds.contains(o.canonical)}loadTile(o,d){const v=t.exported.devicePixelRatio>=2,T=this.map._requestManager.normalizeTileURL(o.tileID.canonical.url(this.tiles,this.scheme),v,this.tileSize);o.request=t.getImage(this.map._requestManager.transformRequest(T,t.ResourceType.Tile),(S,D,z,N)=>(delete o.request,o.aborted?(o.state="unloaded",d(null)):S?(o.state="errored",d(S)):D?(this.map._refreshExpiredTiles&&o.setExpiryData({cacheControl:z,expires:N}),o.setTexture(D,this.map.painter),o.state="loaded",t.cacheEntryPossiblyAdded(this.dispatcher),void d(null)):d(null)))}static loadTileData(o,d,v){o.setTexture(d,v)}static unloadTileData(o,d){o.texture&&d.saveTileTexture(o.texture)}abortTile(o,d){o.request&&(o.request.cancel(),delete o.request),d()}unloadTile(o,d){o.texture&&this.map.painter.saveTileTexture(o.texture),d()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function ln(_,o,d,v,T,S,D,z){const N=[_,d,T,o,v,S,1,1,1],q=[D,z,1],G=t.adjoint([],N),[Y,ie,se]=t.transformMat3(q,q,t.transpose(G,G));return t.multiply$1(N,[Y,0,0,0,ie,0,0,0,se],N)}class wn extends t.Evented{constructor(o,d,v,T){super(),this.id=o,this.dispatcher=v,this.coordinates=d.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(T),this.options=d,this._dirty=!1}load(o,d){this._loaded=d||!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),(v,T)=>{if(this._imageRequest=null,this._loaded=!0,v)this.fire(new t.ErrorEvent(v));else if(T){const{HTMLImageElement:S}=t.window;this.image=T instanceof S?t.exported.getImageData(T):T,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,o&&(this.coordinates=o),this._finishLoading()}})}loaded(){return this._loaded}updateImage(o){return this.image&&o.url?(this._imageRequest&&o.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=o.url,this.load(o.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(o){this.map=o,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(o){this.coordinates=o,this._boundsArray=void 0;const d=o.map(t.MercatorCoordinate.fromLngLat);return this.tileID=function(v){let T=1/0,S=1/0,D=-1/0,z=-1/0;for(const Y of v)T=Math.min(T,Y.x),S=Math.min(S,Y.y),D=Math.max(D,Y.x),z=Math.max(z,Y.y);const N=Math.max(D-T,z-S),q=Math.max(0,Math.floor(-Math.log(N)/Math.LN2)),G=Math.pow(2,q);return new t.CanonicalTileID(q,Math.floor((T+D)/2*G),Math.floor((S+z)/2*G))}(d),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(o){for(const N in this.tiles){const q=this.tiles[N];q.state!=="loaded"&&(q.state="loaded",q.texture=this.texture)}if(this._boundsArray)return;const d=t.tileTransform(this.tileID,this.map.transform.projection),[v,T,S,D]=this.coordinates.map(N=>{const q=d.projection.project(N[0],N[1]);return t.getTilePoint(d,q)._round()});this.perspectiveTransform=function(N,q,G,Y,ie,se,ue,le,fe,H){const oe=ln(0,0,N,0,0,q,N,q),ge=ln(G,Y,ie,se,ue,le,fe,H);return t.multiply$1(ge,t.adjoint(oe,oe),ge),[ge[6]/ge[8]*N/t.EXTENT,ge[7]/ge[8]*q/t.EXTENT]}(this.width,this.height,v.x,v.y,T.x,T.y,D.x,D.y,S.x,S.y);const z=this._boundsArray=new t.StructArrayLayout4i8;z.emplaceBack(v.x,v.y,0,0),z.emplaceBack(T.x,T.y,t.EXTENT,0),z.emplaceBack(D.x,D.y,0,t.EXTENT),z.emplaceBack(S.x,S.y,t.EXTENT,t.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=o.createVertexBuffer(z,t.boundsAttributes.members),this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const o=this.map.painter.context,d=o.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new t.Texture(o,this.image,d.RGBA),this.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(o)}loadTile(o,d){this.tileID&&this.tileID.equals(o.tileID.canonical)?(this.tiles[String(o.tileID.wrap)]=o,o.buckets={},d(null)):(o.state="errored",d(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const on={vector:It,raster:_t,"raster-dem":class extends _t{constructor(_,o,d,v){super(_,o,d,v),this.type="raster-dem",this.maxzoom=22,this._options=t.extend({type:"raster-dem"},o),this.encoding=o.encoding||"mapbox"}loadTile(_,o){const d=this.map._requestManager.normalizeTileURL(_.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function v(T,S){T&&(_.state="errored",o(T)),S&&(_.dem=S,_.dem.onDeserialize(),_.needsHillshadePrepare=!0,_.needsDEMTextureUpload=!0,_.state="loaded",o(null))}_.request=t.getImage(this.map._requestManager.transformRequest(d,t.ResourceType.Tile),(function(T,S,D,z){if(delete _.request,_.aborted)_.state="unloaded",o(null);else if(T)_.state="errored",o(T);else if(S){this.map._refreshExpiredTiles&&_.setExpiryData({cacheControl:D,expires:z});const N=t.window.ImageBitmap&&S instanceof t.window.ImageBitmap&&(sn==null&&(sn=t.window.OffscreenCanvas&&new t.window.OffscreenCanvas(1,1).getContext("2d")&&typeof t.window.createImageBitmap=="function"),sn),q=1-(S.width-t.prevPowerOfTwo(S.width))/2;q<1||_.neighboringTiles||(_.neighboringTiles=this._getNeighboringTiles(_.tileID));const G=N?S:t.exported.getImageData(S,q),Y={uid:_.uid,coord:_.tileID,source:this.id,rawImageData:G,encoding:this.encoding,padding:q};_.actor&&_.state!=="expired"||(_.actor=this.dispatcher.getActor(),_.actor.send("loadDEMTile",Y,v.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(_){const o=_.canonical,d=Math.pow(2,o.z),v=(o.x-1+d)%d,T=o.x===0?_.wrap-1:_.wrap,S=(o.x+1+d)%d,D=o.x+1===d?_.wrap+1:_.wrap,z={};return z[new t.OverscaledTileID(_.overscaledZ,T,o.z,v,o.y).key]={backfilled:!1},z[new t.OverscaledTileID(_.overscaledZ,D,o.z,S,o.y).key]={backfilled:!1},o.y>0&&(z[new t.OverscaledTileID(_.overscaledZ,T,o.z,v,o.y-1).key]={backfilled:!1},z[new t.OverscaledTileID(_.overscaledZ,_.wrap,o.z,o.x,o.y-1).key]={backfilled:!1},z[new t.OverscaledTileID(_.overscaledZ,D,o.z,S,o.y-1).key]={backfilled:!1}),o.y+1{if(this._loaded=!0,this._pendingLoad=null,d)this.fire(new t.ErrorEvent(d));else{const T={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&v&&v.resourceTiming&&v.resourceTiming[this.id]&&(T.resourceTiming=v.resourceTiming[this.id]),this.fire(new t.Event("data",T)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(_,o){const d=_.actor?"reloadTile":"loadTile";_.actor=this.actor,_.request=this.actor.send(d,{type:this.type,uid:_.uid,tileID:_.tileID,tileZoom:_.tileZoom,zoom:_.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(v,T)=>(delete _.request,_.unloadVectorData(),_.aborted?o(null):v?o(v):(_.loadVectorData(T,this.map.painter,d==="reloadTile"),o(null))),void 0,d==="loadTile")}abortTile(_){_.request&&(_.request.cancel(),delete _.request),_.aborted=!0}unloadTile(_){_.unloadVectorData(),this.actor.send("removeTile",{uid:_.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return t.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends wn{constructor(_,o,d,v){super(_,o,d,v),this.roundZoom=!0,this.type="video",this.options=o}load(){this._loaded=!1;const _=this.options;this.urls=[];for(const o of _.urls)this.urls.push(this.map._requestManager.transformRequest(o,t.ResourceType.Source).url);t.getVideo(this.urls,(o,d)=>{this._loaded=!0,o?this.fire(new t.ErrorEvent(o)):d&&(this.video=d,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(_){if(this.video){const o=this.video.seekable;_o.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${o.start(0)} and ${o.end(0)}-second mark.`))):this.video.currentTime=_}}getVideo(){return this.video}onAdd(_){this.map||(this.map=_,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const _=this.map.painter.context,o=_.gl;this.texture?this.video.paused||(this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),o.texSubImage2D(o.TEXTURE_2D,0,0,0,o.RGBA,o.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(_,this.video,o.RGBA),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(_)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:wn,canvas:class extends wn{constructor(_,o,d,v){super(_,o,d,v),o.coordinates?Array.isArray(o.coordinates)&&o.coordinates.length===4&&!o.coordinates.some(T=>!Array.isArray(T)||T.length!==2||T.some(S=>typeof S!="number"))||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${_}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${_}`,null,'missing required property "coordinates"'))),o.animate&&typeof o.animate!="boolean"&&this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${_}`,null,'optional "animate" property must be a boolean value'))),o.canvas?typeof o.canvas=="string"||o.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${_}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${_}`,null,'missing required property "canvas"'))),this.options=o,this.animate=o.animate===void 0||o.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.window.HTMLCanvasElement?this.options.canvas:t.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(_){this.map=_,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let _=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,_=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,_=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const o=this.map.painter.context;this.texture?(_||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(o,this.canvas,o.gl.RGBA,{premultiply:!0}),this._prepareData(o)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const _ of[this.canvas.width,this.canvas.height])if(isNaN(_)||_<=0)return!0;return!1}},custom:class extends t.Evented{constructor(_,o,d,v){super(),this.id=_,this.type="custom",this._dataType="raster",this._dispatcher=d,this._implementation=o,this.setEventedParent(v),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new t.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new t.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Tn(this._implementation.bounds,this.minzoom,this.maxzoom)),o.update=this._update.bind(this),o.clearTiles=this._clearTiles.bind(this),o.coveringTiles=this._coveringTiles.bind(this),t.extend(this,t.pick(o,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return t.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(_){this._map=_,this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(_),this.load()}onRemove(_){this._implementation.onRemove&&this._implementation.onRemove(_)}hasTile(_){if(this._implementation.hasTile){const{x:o,y:d,z:v}=_.canonical;return this._implementation.hasTile({x:o,y:d,z:v})}return!this.tileBounds||this.tileBounds.contains(_.canonical)}loadTile(_,o){const{x:d,y:v,z:T}=_.tileID.canonical,S=new t.window.AbortController;_.request=Promise.resolve(this._implementation.loadTile({x:d,y:v,z:T},{signal:S.signal})).then((function(D){return delete _.request,_.aborted?(_.state="unloaded",o(null)):D===void 0?(_.state="errored",o(null)):D===null?(this.loadTileData(_,{width:this.tileSize,height:this.tileSize,data:null}),_.state="loaded",o(null)):function(z){return z instanceof t.window.ImageData||z instanceof t.window.HTMLCanvasElement||z instanceof t.window.ImageBitmap||z instanceof t.window.HTMLImageElement}(D)?(this.loadTileData(_,D),_.state="loaded",void o(null)):(_.state="errored",o(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(D=>{D.code!==20&&(_.state="errored",o(D))}),_.request.cancel=()=>S.abort()}loadTileData(_,o){_t.loadTileData(_,o,this._map.painter)}unloadTileData(_){_t.unloadTileData(_,this._map.painter)}unloadTile(_,o){if(this.unloadTileData(_),this._implementation.unloadTile){const{x:d,y:v,z:T}=_.tileID.canonical;this._implementation.unloadTile({x:d,y:v,z:T})}o()}abortTile(_,o){_.request&&_.request.cancel&&(_.request.cancel(),delete _.request),o()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(_=>({x:_.canonical.x,y:_.canonical.y,z:_.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}}},En=function(_,o,d,v){const T=new on[o.type](_,o,d,v);if(T.id!==_)throw new Error(`Expected Source id to be ${_} instead of ${T.id}`);return t.bindAll(["load","abort","unload","serialize","prepare"],T),T};function Sn(_,o){const d=t.identity([]);return t.scale(d,d,[.5*_.width,.5*-_.height,1]),t.translate(d,d,[1,-1,0]),t.multiply(d,d,_.calculateProjMatrix(o.toUnwrapped())),Float32Array.from(d)}function yi(_,o,d,v,T,S,D,z=!1){const N=_.tilesIn(v,D,z);N.sort(hr);const q=[];for(const Y of N)q.push({wrappedTileID:Y.tile.tileID.wrapped().key,queryResults:Y.tile.queryRenderedFeatures(o,d,_._state,Y,T,S,Sn(_.transform,Y.tile.tileID),z)});const G=function(Y){const ie={},se={};for(const ue of Y){const le=ue.queryResults,fe=ue.wrappedTileID,H=se[fe]=se[fe]||{};for(const oe in le){const ge=le[oe],_e=H[oe]=H[oe]||{},Ae=ie[oe]=ie[oe]||[];for(const Re of ge)_e[Re.featureIndex]||(_e[Re.featureIndex]=!0,Ae.push(Re))}}return ie}(q);for(const Y in G)G[Y].forEach(ie=>{const se=ie.feature,ue=se.layer;ue&&ue.type!=="background"&&ue.type!=="sky"&&(se.source=ue.source,ue["source-layer"]&&(se.sourceLayer=ue["source-layer"]),se.state=se.id!==void 0?_.getFeatureState(ue["source-layer"],se.id):{})});return G}function ki(_,o){const d=_.getRenderableIds().map(S=>_.getTileByID(S)),v=[],T={};for(let S=0;S{d.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[$r]}numActive(){return Object.keys(this.active).length}}let Li;function Xr(){return Li||(Li=new Ci),Li}function Pl(_,o){const d={};for(const v in _)v!=="ref"&&(d[v]=_[v]);return t.refProperties.forEach(v=>{v in o&&(d[v]=o[v])}),d}function oa(_){_=_.slice();const o=Object.create(null);for(let d=0;d<_.length;d++)o[_[d].id]=_[d];for(let d=0;d<_.length;d++)"ref"in _[d]&&(_[d]=Pl(_[d],o[_[d].ref]));return _}Ci.workerCount=2;const On={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function Ri(_,o,d){d.push({command:On.addSource,args:[_,o[_]]})}function sa(_,o,d){o.push({command:On.removeSource,args:[_]}),d[_]=!0}function Ll(_,o,d,v){sa(_,d,v),Ri(_,o,d)}function us(_,o,d){let v;for(v in _[d])if(_[d].hasOwnProperty(v)&&v!=="data"&&!E(_[d][v],o[d][v]))return!1;for(v in o[d])if(o[d].hasOwnProperty(v)&&v!=="data"&&!E(_[d][v],o[d][v]))return!1;return!0}function Sr(_,o,d,v,T,S){let D;for(D in o=o||{},_=_||{})_.hasOwnProperty(D)&&(E(_[D],o[D])||d.push({command:S,args:[v,D,o[D],T]}));for(D in o)o.hasOwnProperty(D)&&!_.hasOwnProperty(D)&&(E(_[D],o[D])||d.push({command:S,args:[v,D,o[D],T]}))}function co(_){return _.id}function aa(_,o){return _[o.id]=o,_}class Va{constructor(o,d){this.reset(o,d)}reset(o,d){this.points=o||[],this._distances=[0];for(let v=1;v0?(T-D)/z:0;return this.points[S].mult(1-N).add(this.points[d].mult(N))}}class cs{constructor(o,d,v){const T=this.boxCells=[],S=this.circleCells=[];this.xCellCount=Math.ceil(o/v),this.yCellCount=Math.ceil(d/v);for(let D=0;Dthis.width||T<0||d>this.height)return!S&&[];const z=[];if(o<=0&&d<=0&&this.width<=v&&this.height<=T){if(S)return!0;for(let N=0;N0:z}_queryCircle(o,d,v,T,S){const D=o-v,z=o+v,N=d-v,q=d+v;if(z<0||D>this.width||q<0||N>this.height)return!T&&[];const G=[];return this._forEachCell(D,N,z,q,this._queryCellCircle,G,{hitTest:T,circle:{x:o,y:d,radius:v},seenUids:{box:{},circle:{}}},S),T?G.length>0:G}query(o,d,v,T,S){return this._query(o,d,v,T,!1,S)}hitTest(o,d,v,T,S){return this._query(o,d,v,T,!0,S)}hitTestCircle(o,d,v,T){return this._queryCircle(o,d,v,!0,T)}_queryCell(o,d,v,T,S,D,z,N){const q=z.seenUids,G=this.boxCells[S];if(G!==null){const ie=this.bboxes;for(const se of G)if(!q.box[se]){q.box[se]=!0;const ue=4*se;if(o<=ie[ue+2]&&d<=ie[ue+3]&&v>=ie[ue+0]&&T>=ie[ue+1]&&(!N||N(this.boxKeys[se]))){if(z.hitTest)return D.push(!0),!0;D.push({key:this.boxKeys[se],x1:ie[ue],y1:ie[ue+1],x2:ie[ue+2],y2:ie[ue+3]})}}}const Y=this.circleCells[S];if(Y!==null){const ie=this.circles;for(const se of Y)if(!q.circle[se]){q.circle[se]=!0;const ue=3*se;if(this._circleAndRectCollide(ie[ue],ie[ue+1],ie[ue+2],o,d,v,T)&&(!N||N(this.circleKeys[se]))){if(z.hitTest)return D.push(!0),!0;{const le=ie[ue],fe=ie[ue+1],H=ie[ue+2];D.push({key:this.circleKeys[se],x1:le-H,y1:fe-H,x2:le+H,y2:fe+H})}}}}}_queryCellCircle(o,d,v,T,S,D,z,N){const q=z.circle,G=z.seenUids,Y=this.boxCells[S];if(Y!==null){const se=this.bboxes;for(const ue of Y)if(!G.box[ue]){G.box[ue]=!0;const le=4*ue;if(this._circleAndRectCollide(q.x,q.y,q.radius,se[le+0],se[le+1],se[le+2],se[le+3])&&(!N||N(this.boxKeys[ue])))return D.push(!0),!0}}const ie=this.circleCells[S];if(ie!==null){const se=this.circles;for(const ue of ie)if(!G.circle[ue]){G.circle[ue]=!0;const le=3*ue;if(this._circlesCollide(se[le],se[le+1],se[le+2],q.x,q.y,q.radius)&&(!N||N(this.circleKeys[ue])))return D.push(!0),!0}}}_forEachCell(o,d,v,T,S,D,z,N){const q=this._convertToXCellCoord(o),G=this._convertToYCellCoord(d),Y=this._convertToXCellCoord(v),ie=this._convertToYCellCoord(T);for(let se=q;se<=Y;se++)for(let ue=G;ue<=ie;ue++)if(S.call(this,o,d,v,T,this.xCellCount*ue+se,D,z,N))return}_convertToXCellCoord(o){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(o*this.xScale)))}_convertToYCellCoord(o){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(o*this.yScale)))}_circlesCollide(o,d,v,T,S,D){const z=T-o,N=S-d,q=v+D;return q*q>z*z+N*N}_circleAndRectCollide(o,d,v,T,S,D,z){const N=(D-T)/2,q=Math.abs(o-(T+N));if(q>N+v)return!1;const G=(z-S)/2,Y=Math.abs(d-(S+G));if(Y>G+v)return!1;if(q<=N||Y<=G)return!0;const ie=q-N,se=Y-G;return ie*ie+se*se<=v*v}}const Fi={unknown:0,flipRequired:1,flipNotRequired:2},wo=Math.tan(85*Math.PI/180);function Qe(_,o,d,v,T,S,D){const z=t.create();if(d)if(S.name==="globe"){const N=t.calculateGlobeLabelMatrix(T,o);t.multiply(z,z,N)}else{const N=Ie([],D);z[0]=N[0],z[1]=N[1],z[4]=N[2],z[5]=N[3],v||t.rotateZ(z,z,T.angle)}else t.multiply(z,T.labelPlaneMatrix,_);return z}function kr(_,o,d,v,T,S,D){const z=Qe(_,o,d,v,T,S,D);return S.name==="globe"&&d||(z[2]=z[6]=z[10]=z[14]=0),z}function Ti(_,o,d,v,T,S,D){if(d){if(S.name==="globe"){const z=Qe(_,o,d,v,T,S,D);return t.invert(z,z),t.multiply(z,_,z),z}{const z=t.clone(_),N=t.identity([]);return N[0]=D[0],N[1]=D[1],N[4]=D[2],N[5]=D[3],t.multiply(z,z,N),v||t.rotateZ(z,z,-T.angle),z}}return T.glCoordMatrix}function Ki(_,o,d,v){const T=[_,o,d,1];d?t.transformMat4$1(T,T,v):kn(T,T,v);const S=T[3];return T[0]/=S,T[1]/=S,T[2]/=S,T}function Nu(_,o){return Math.min(.5+_/o*.5,1.5)}function Eo(_,o){const d=_[0]/_[3],v=_[1]/_[3];return d>=-o[0]&&d<=o[0]&&v>=-o[1]&&v<=o[1]}function Ua(_,o,d,v,T,S,D,z,N,q){const G=d.transform,Y=v?_.textSizeData:_.iconSizeData,ie=t.evaluateSizeForZoom(Y,d.transform.zoom),se=G.projection.name==="globe",ue=[256/d.width*2+1,256/d.height*2+1],le=v?_.text.dynamicLayoutVertexArray:_.icon.dynamicLayoutVertexArray;le.clear();let fe=null;se&&(fe=v?_.text.globeExtVertexArray:_.icon.globeExtVertexArray);const H=_.lineVertexArray,oe=v?_.text.placedSymbolArray:_.icon.placedSymbolArray,ge=d.transform.width/d.transform.height;let _e,Ae=!1;for(let Re=0;ReMath.abs(d)?{useVertical:!0}:_===t.WritingMode.vertical?v>0?{needsFlipping:!0}:null:o!==Fi.unknown&&function(T,S){return T===0||Math.abs(S/T)>wo}(d,v)?o===Fi.flipRequired?{needsFlipping:!0}:null:d<0?{needsFlipping:!0}:null}function Pt(_,o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue,le,fe,H,oe){const ge=o/24,_e=_.lineOffsetX*ge,Ae=_.lineOffsetY*ge,{lineStartIndex:Re,glyphStartIndex:Pe,numGlyphs:Be,segment:Oe,writingMode:Xe,flipState:pt}=_,qe=Re+_.lineLength,ot=He=>{if(G){const[yt,ct,bt]=He.up,$t=q.length;t.updateGlobeVertexNormal(G,$t+0,yt,ct,bt),t.updateGlobeVertexNormal(G,$t+1,yt,ct,bt),t.updateGlobeVertexNormal(G,$t+2,yt,ct,bt),t.updateGlobeVertexNormal(G,$t+3,yt,ct,bt)}const[dt,$e,it]=He.point;t.addDynamicAttributes(q,dt,$e,it,He.angle)};if(Be>1){const He=Rl(ge,z,_e,Ae,d,Y,ie,_,N,S,se,le,!1,fe,H,oe);if(!He)return{notEnoughRoom:!0};if(v&&!d){let[dt,$e,it]=He.first.point,[yt,ct,bt]=He.last.point;[dt,$e]=Ki(dt,$e,it,D),[yt,ct]=Ki(yt,ct,bt,D);const $t=Oo(Xe,pt,(yt-dt)*ue,ct-$e);if(_.flipState=$t&&$t.needsFlipping?Fi.flipRequired:Fi.flipNotRequired,$t)return $t}ot(He.first);for(let dt=Pe+1;dt0?yt:In(ie,it,dt,1,T,void 0,fe,H.canonical),bt=Oo(Xe,pt,(ct[0]-dt[0])*ue,ct[1]-dt[1]);if(_.flipState=bt&&bt.needsFlipping?Fi.flipRequired:Fi.flipNotRequired,bt)return bt}const He=Ji(ge*z.getoffsetX(Pe),_e,Ae,d,Y,ie,Oe,Re,qe,N,S,se,le,!1,!1,fe,H,oe);if(!He)return{notEnoughRoom:!0};ot(He)}return{}}function fn(_,o,d,v,T){const{x:S,y:D,z}=v.projectTilePoint(_.x,_.y,o);if(!T)return Ki(S,D,z,d);const[N,q,G]=T(_);return Ki(S+N,D+q,z+G,d)}function In(_,o,d,v,T,S,D,z){const N=fn(_.sub(o)._unit()._add(_),z,T,D,S);return t.sub(N,d,N),t.normalize(N,N),t.scaleAndAdd(N,d,N,v)}function Ji(_,o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue,le,fe,H){const oe=v?_-o:_+o;let ge=oe>0?1:-1,_e=0;v&&(ge*=-1,_e=Math.PI),ge<0&&(_e+=Math.PI);let Ae=z+D+(ge>0?0:1)|0,Re=T,Pe=T,Be=0,Oe=0;const Xe=Math.abs(oe),pt=[],qe=[];let ot=S,He=ot;const dt=()=>In(He,ot,Pe,Xe-Be+1,G,ie,le,fe.canonical);for(;Be+Oe<=Xe;){if(Ae+=ge,Ae=N)return null;if(Pe=Re,He=ot,pt.push(Pe),se&&qe.push(He),ot=new t.Point(q.getx(Ae),q.gety(Ae)),Re=Y[Ae],!Re){const Kt=fn(ot,fe.canonical,G,le,ie);Re=Kt[3]>0?Y[Ae]=Kt:dt()}Be+=Oe,Oe=t.distance(Pe,Re)}ue&&ie&&(Y[Ae]&&(Re=dt(),Oe=t.distance(Pe,Re)),Y[Ae]=Re);const $e=(Xe-Be)/Oe,it=ot.sub(He)._mult($e)._add(He),yt=t.sub([],Re,Pe),ct=t.scaleAndAdd([],Pe,yt,$e);let bt=[0,0,1],$t=yt[0],un=yt[1];if(H&&(bt=le.upVector(fe.canonical,it.x,it.y),bt[0]!==0||bt[1]!==0||bt[2]!==1)){const Kt=[bt[2],0,-bt[0]],An=t.cross([],bt,Kt);t.normalize(Kt,Kt),t.normalize(An,An),$t=t.dot(yt,Kt),un=t.dot(yt,An)}if(d){const Kt=t.cross([],bt,yt);t.normalize(Kt,Kt),t.scaleAndAdd(ct,ct,Kt,d*ge)}const Ut=_e+Math.atan2(un,$t);return pt.push(ct),se&&qe.push(it),{point:ct,angle:Ut,path:pt,tilePath:qe,up:bt}}function ho(_,o){const d=o.length,v=d+4*_;o.resize(v),o.float32.fill(-1/0,4*d,4*v)}function kn(_,o,d){const v=o[0],T=o[1];return _[0]=d[0]*v+d[4]*T+d[12],_[1]=d[1]*v+d[5]*T+d[13],_[3]=d[3]*v+d[7]*T+d[15],_}const Vr=100;class la{constructor(o,d,v=new cs(o.width+200,o.height+200,25),T=new cs(o.width+200,o.height+200,25)){this.transform=o,this.grid=v,this.ignoredGrid=T,this.pitchfactor=Math.cos(o._pitch)*o.cameraToCenterDistance,this.screenRightBoundary=o.width+Vr,this.screenBottomBoundary=o.height+Vr,this.gridRightBoundary=o.width+200,this.gridBottomBoundary=o.height+200,this.fogState=d}placeCollisionBox(o,d,v,T,S,D,z,N){let q=v.projectedAnchorX,G=v.projectedAnchorY,Y=v.projectedAnchorZ;const ie=v.elevation,se=v.tileID,ue=o.getProjection();if(ie&&se){const[Re,Pe,Be]=ue.upVector(se.canonical,v.tileAnchorX,v.tileAnchorY),Oe=ue.upVectorScale(se.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;q+=Re*ie*Oe,G+=Pe*ie*Oe,Y+=Be*ie*Oe}const le=this.projectAndGetPerspectiveRatio(z,q,G,Y,v.tileID,ue.name==="globe"||!!ie||this.transform.pitch>0,ue),fe=D*le.perspectiveRatio,H=(v.x1*d+T.x-v.padding)*fe+le.point.x,oe=(v.y1*d+T.y-v.padding)*fe+le.point.y,ge=(v.x2*d+T.x+v.padding)*fe+le.point.x,_e=(v.y2*d+T.y+v.padding)*fe+le.point.y,Ae=le.perspectiveRatio<=.55||le.occluded;return!this.isInsideGrid(H,oe,ge,_e)||!S&&this.grid.hitTest(H,oe,ge,_e,N)||Ae?{box:[],offscreen:!1,occluded:le.occluded}:{box:[H,oe,ge,_e],offscreen:this.isOffscreen(H,oe,ge,_e),occluded:!1}}placeCollisionCircles(o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue,le){const fe=[],H=this.transform.elevation,oe=o.getProjection(),ge=H?H.getAtTileOffsetFunc(le,this.transform.center.lat,this.transform.worldSize,oe):null,_e=new t.Point(v.tileAnchorX,v.tileAnchorY);let{x:Ae,y:Re,z:Pe}=oe.projectTilePoint(_e.x,_e.y,le.canonical);if(ge){const[it,yt,ct]=ge(_e);Ae+=it,Re+=yt,Pe+=ct}const Be=oe.name==="globe",Oe=this.projectAndGetPerspectiveRatio(z,Ae,Re,Pe,le,Be||!!H||this.transform.pitch>0,oe),{perspectiveRatio:Xe}=Oe,pt=(Y?D/Xe:D*Xe)/t.ONE_EM,qe=Ki(Ae,Re,Pe,N),ot=Oe.signedDistanceFromCamera>0?Rl(pt,S,v.lineOffsetX*pt,v.lineOffsetY*pt,!1,qe,_e,v,T,N,{},H&&!Y?ge:null,Y&&!!H,oe,le,Y):null;let He=!1,dt=!1,$e=!0;if(ot&&!Oe.occluded){const it=.5*se*Xe+ue,yt=new t.Point(-100,-100),ct=new t.Point(this.screenRightBoundary,this.screenBottomBoundary),bt=new Va,{first:$t,last:un}=ot,Ut=$t.path.length;let Kt=[];for(let qt=Ut-1;qt>=1;qt--)Kt.push($t.path[qt]);for(let qt=1;qt(ge&&!Be&&(ei=ge(tiqt[3]<=0)&&(Kt=[]));let Cn=[];if(Kt.length>0){let qt=1/0,Yn=-1/0,ei=1/0,ti=-1/0;for(const ni of Kt)qt=Math.min(qt,ni[0]),ei=Math.min(ei,ni[1]),Yn=Math.max(Yn,ni[0]),ti=Math.max(ti,ni[1]);Yn>=yt.x&&qt<=ct.x&&ti>=yt.y&&ei<=ct.y&&(Cn=[Kt.map(ni=>new t.Point(ni[0],ni[1]))],(qtct.x||eict.y)&&(Cn=t.clipLine(Cn,yt.x,yt.y,ct.x,ct.y)))}for(const qt of Cn){bt.reset(qt,.25*it);let Yn=0;Yn=bt.length<=.5*it?1:Math.ceil(bt.paddedLength/An)+1;for(let ei=0;ei0?(t.transformMat4$1(N,N,o),this.fogState&&S&&z.name!=="globe"&&(q=function(ie,se,ue,le,fe,H){const oe=H.calculateFogTileMatrix(fe),ge=[se,ue,le];return t.transformMat4(ge,ge,oe),Lt(ie,ge,H.pitch,H._fov)}(this.fogState,d,v,T,S.toUnwrapped(),this.transform)>.9)):kn(N,N,o);const G=N[3];return{point:new t.Point((N[0]/G+1)/2*this.transform.width+Vr,(-N[1]/G+1)/2*this.transform.height+Vr),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(z)/G*.5,1.5),signedDistanceFromCamera:G,occluded:D&&N[2]>G||q}}isOffscreen(o,d,v,T){return v=this.screenRightBoundary||Tthis.screenBottomBoundary}isInsideGrid(o,d,v,T){return v>=0&&o=0&&dv.collisionGroupID===d}}return this.collisionGroups[o]}}function ca(_,o,d,v,T){const{horizontalAlign:S,verticalAlign:D}=t.getAnchorAlignment(_),z=-(S-.5)*o,N=-(D-.5)*d,q=t.evaluateVariableOffset(_,v);return new t.Point(z+q[0]*T,N+q[1]*T)}function fs(_,o,d,v,T){const S=new t.Point(_,o);return d&&S._rotate(v?T:-T),S}class xr{constructor(o,d,v,T,S){this.transform=o.clone(),this.projection=o.projection.name,this.collisionIndex=new la(this.transform,S),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=d,this.retainedQueryData={},this.collisionGroups=new Ko(v),this.collisionCircleArrays={},this.prevPlacement=T,T&&(T.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(o,d,v,T){const S=v.getBucket(d),D=v.latestFeatureIndex;if(!S||!D||d.id!==S.layerIds[0])return;const z=S.layers[0].layout,N=v.collisionBoxArray,q=Math.pow(2,this.transform.zoom-v.tileID.overscaledZ),G=v.tileSize/t.EXTENT,Y=v.tileID.toUnwrapped();this.transform.setProjection(S.projection);const ie=(se=v.tileID,ue=S.getProjection(),le=this.transform,ue.name===this.projection?le.calculateProjMatrix(se.toUnwrapped()):Ho(le,ue,se));var se,ue,le;const fe=z.get("text-pitch-alignment")==="map",H=z.get("text-rotation-alignment")==="map";d.compileFilter();const oe=d.dynamicFilter(),ge=d.dynamicFilterNeedsFeature(),_e=this.transform.calculatePixelsToTileUnitsMatrix(v),Ae=kr(ie,v.tileID.canonical,fe,H,this.transform,S.getProjection(),_e);let Re=null;if(fe){const Oe=Ti(ie,v.tileID.canonical,fe,H,this.transform,S.getProjection(),_e);Re=t.multiply([],this.transform.labelPlaneMatrix,Oe)}let Pe=null;oe&&v.latestFeatureIndex&&(Pe={unwrappedTileID:Y,dynamicFilter:oe,dynamicFilterNeedsFeature:ge,featureIndex:v.latestFeatureIndex}),this.retainedQueryData[S.bucketInstanceId]=new mi(S.bucketInstanceId,D,S.sourceLayerIndex,S.index,v.tileID);const Be={bucket:S,layout:z,posMatrix:ie,textLabelPlaneMatrix:Ae,labelToScreenMatrix:Re,clippingData:Pe,scale:q,textPixelRatio:G,holdingForFade:v.holdingForFade(),collisionBoxArray:N,partiallyEvaluatedTextSize:t.evaluateSizeForZoom(S.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:t.evaluateSizeForZoom(S.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(S.sourceID)};if(T)for(const Oe of S.sortKeyRanges){const{sortKey:Xe,symbolInstanceStart:pt,symbolInstanceEnd:qe}=Oe;o.push({sortKey:Xe,symbolInstanceStart:pt,symbolInstanceEnd:qe,parameters:Be})}else o.push({symbolInstanceStart:0,symbolInstanceEnd:S.symbolInstances.length,parameters:Be})}attemptAnchorPlacement(o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue,le,fe,H,oe){const{textOffset0:ge,textOffset1:_e,crossTileID:Ae}=ie,Re=[ge,_e],Pe=ca(o,v,T,Re,S),Be=this.collisionIndex.placeCollisionBox(ue,S,d,fs(Pe.x,Pe.y,D,z,this.transform.angle),Y,N,q,G.predicate);if(fe){const Oe=ue.getSymbolInstanceIconSize(oe,this.transform.zoom,ie.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(ue,Oe,fe,fs(Pe.x,Pe.y,D,z,this.transform.angle),Y,N,q,G.predicate).box.length===0)return}if(Be.box.length>0){let Oe;return this.prevPlacement&&this.prevPlacement.variableOffsets[Ae]&&this.prevPlacement.placements[Ae]&&this.prevPlacement.placements[Ae].text&&(Oe=this.prevPlacement.variableOffsets[Ae].anchor),this.variableOffsets[Ae]={textOffset:Re,width:v,height:T,anchor:o,textScale:S,prevAnchor:Oe},this.markUsedJustification(ue,o,ie,le),ue.allowVerticalPlacement&&(this.markUsedOrientation(ue,le,ie),this.placedOrientations[Ae]=le),{shift:Pe,placedGlyphBoxes:Be}}}placeLayerBucketPart(o,d,v,T){const{bucket:S,layout:D,posMatrix:z,textLabelPlaneMatrix:N,labelToScreenMatrix:q,clippingData:G,textPixelRatio:Y,holdingForFade:ie,collisionBoxArray:se,partiallyEvaluatedTextSize:ue,partiallyEvaluatedIconSize:le,collisionGroup:fe}=o.parameters,H=D.get("text-optional"),oe=D.get("icon-optional"),ge=D.get("text-allow-overlap"),_e=D.get("icon-allow-overlap"),Ae=D.get("text-rotation-alignment")==="map",Re=D.get("text-pitch-alignment")==="map",Pe=D.get("icon-text-fit")!=="none",Be=D.get("symbol-z-order")==="viewport-y";this.transform.setProjection(S.projection);let Oe=ge&&(_e||!S.hasIconData()||oe),Xe=_e&&(ge||!S.hasTextData()||H);!S.collisionArrays&&se&&S.deserializeCollisionBoxes(se),v&&T&&S.updateCollisionDebugBuffers(this.transform.zoom,se);const pt=(qe,ot,He)=>{const{crossTileID:dt,numVerticalGlyphVertices:$e}=qe;if(G){const wi={zoom:this.transform.zoom,pitch:this.transform.pitch};let ii=null;if(G.dynamicFilterNeedsFeature){const Gn=this.retainedQueryData[S.bucketInstanceId];ii=G.featureIndex.loadFeature({featureIndex:qe.featureIndex,bucketIndex:Gn.bucketIndex,sourceLayerIndex:Gn.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,G.dynamicFilter)(wi,ii,this.retainedQueryData[S.bucketInstanceId].tileID.canonical,new t.Point(qe.tileAnchorX,qe.tileAnchorY),this.transform.calculateDistanceTileData(G.unwrappedTileID)))return this.placements[dt]=new ua(!1,!1,!1,!0),void d.add(dt)}if(d.has(dt))return;if(ie)return void(this.placements[dt]=new ua(!1,!1,!1));let it=!1,yt=!1,ct=!0,bt=!1,$t=!1,un=null,Ut={box:null,offscreen:null,occluded:null},Kt={box:null,offscreen:null,occluded:null},An=null,Cn=null,qt=null,Yn=0,ei=0,ti=0;He.textFeatureIndex?Yn=He.textFeatureIndex:qe.useRuntimeCollisionCircles&&(Yn=qe.featureIndex),He.verticalTextFeatureIndex&&(ei=He.verticalTextFeatureIndex);const ni=wi=>{wi.tileID=this.retainedQueryData[S.bucketInstanceId].tileID;const ii=this.transform.elevation;(ii||wi.elevation)&&(wi.elevation=ii?ii.getAtTileOffset(wi.tileID,wi.tileAnchorX,wi.tileAnchorY):0)},Dr=He.textBox;if(Dr){ni(Dr);const wi=Gn=>{let Ui=t.WritingMode.horizontal;if(S.allowVerticalPlacement&&!Gn&&this.prevPlacement){const jr=this.prevPlacement.placedOrientations[dt];jr&&(this.placedOrientations[dt]=jr,Ui=jr,this.markUsedOrientation(S,Ui,qe))}return Ui},ii=(Gn,Ui)=>{if(S.allowVerticalPlacement&&$e>0&&He.verticalTextBox){for(const jr of S.writingModes)if(jr===t.WritingMode.vertical?(Ut=Ui(),Kt=Ut):Ut=Gn(),Ut&&Ut.box&&Ut.box.length)break}else Ut=Gn()};if(D.get("text-variable-anchor")){let Gn=D.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[dt]){const vi=this.prevPlacement.variableOffsets[dt];Gn.indexOf(vi.anchor)>0&&(Gn=Gn.filter(Qr=>Qr!==vi.anchor),Gn.unshift(vi.anchor))}const Ui=(vi,Qr,tc)=>{const wa=S.getSymbolInstanceTextSize(ue,qe,this.transform.zoom,ot),Ql=(vi.x2-vi.x1)*wa+2*vi.padding,bs=(vi.y2-vi.y1)*wa+2*vi.padding,qs=Pe&&!_e?Qr:null;qs&&ni(qs);let Ea={box:[],offscreen:!1,occluded:!1};const nc=ge?2*Gn.length:Gn.length;for(let eu=0;eu=Gn.length,qe,ot,S,tc,qs,ue,le);if(Th&&(Ea=Th.placedGlyphBoxes,Ea&&Ea.box&&Ea.box.length)){it=!0,un=Th.shift;break}}return Ea};ii(()=>Ui(Dr,He.iconBox,t.WritingMode.horizontal),()=>{const vi=He.verticalTextBox;return vi&&ni(vi),S.allowVerticalPlacement&&!(Ut&&Ut.box&&Ut.box.length)&&$e>0&&vi?Ui(vi,He.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),Ut&&(it=Ut.box,ct=Ut.offscreen,bt=Ut.occluded);const jr=wi(!(!Ut||!Ut.box));if(!it&&this.prevPlacement){const vi=this.prevPlacement.variableOffsets[dt];vi&&(this.variableOffsets[dt]=vi,this.markUsedJustification(S,vi.anchor,qe,jr))}}else{const Gn=(Ui,jr)=>{const vi=S.getSymbolInstanceTextSize(ue,qe,this.transform.zoom,ot),Qr=this.collisionIndex.placeCollisionBox(S,vi,Ui,new t.Point(0,0),ge,Y,z,fe.predicate);return Qr&&Qr.box&&Qr.box.length&&(this.markUsedOrientation(S,jr,qe),this.placedOrientations[dt]=jr),Qr};ii(()=>Gn(Dr,t.WritingMode.horizontal),()=>{const Ui=He.verticalTextBox;return S.allowVerticalPlacement&&$e>0&&Ui?(ni(Ui),Gn(Ui,t.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),wi(!!(Ut&&Ut.box&&Ut.box.length))}}if(An=Ut,it=An&&An.box&&An.box.length>0,ct=An&&An.offscreen,bt=An&&An.occluded,qe.useRuntimeCollisionCircles){const wi=S.text.placedSymbolArray.get(qe.centerJustifiedTextSymbolIndex>=0?qe.centerJustifiedTextSymbolIndex:qe.verticalPlacedTextSymbolIndex),ii=t.evaluateSizeForFeature(S.textSizeData,ue,wi),Gn=D.get("text-padding");Cn=this.collisionIndex.placeCollisionCircles(S,ge,wi,S.lineVertexArray,S.glyphOffsetArray,ii,z,N,q,v,Re,fe.predicate,qe.collisionCircleDiameter*ii/t.ONE_EM,Gn,this.retainedQueryData[S.bucketInstanceId].tileID),it=ge||Cn.circles.length>0&&!Cn.collisionDetected,ct=ct&&Cn.offscreen,bt=Cn.occluded}if(He.iconFeatureIndex&&(ti=He.iconFeatureIndex),He.iconBox){const wi=ii=>{ni(ii);const Gn=Pe&&un?fs(un.x,un.y,Ae,Re,this.transform.angle):new t.Point(0,0),Ui=S.getSymbolInstanceIconSize(le,this.transform.zoom,qe.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(S,Ui,ii,Gn,_e,Y,z,fe.predicate)};Kt&&Kt.box&&Kt.box.length&&He.verticalIconBox?(qt=wi(He.verticalIconBox),yt=qt.box.length>0):(qt=wi(He.iconBox),yt=qt.box.length>0),ct=ct&&qt.offscreen,$t=qt.occluded}const mr=H||qe.numHorizontalGlyphVertices===0&&$e===0,Co=oe||qe.numIconVertices===0;if(mr||Co?Co?mr||(yt=yt&&it):it=yt&&it:yt=it=yt&&it,it&&An&&An.box&&this.collisionIndex.insertCollisionBox(An.box,D.get("text-ignore-placement"),S.bucketInstanceId,Kt&&Kt.box&&ei?ei:Yn,fe.ID),yt&&qt&&this.collisionIndex.insertCollisionBox(qt.box,D.get("icon-ignore-placement"),S.bucketInstanceId,ti,fe.ID),Cn&&(it&&this.collisionIndex.insertCollisionCircles(Cn.circles,D.get("text-ignore-placement"),S.bucketInstanceId,Yn,fe.ID),v)){const wi=S.bucketInstanceId;let ii=this.collisionCircleArrays[wi];ii===void 0&&(ii=this.collisionCircleArrays[wi]=new hs);for(let Gn=0;Gn=0;--ot){const He=qe[ot];pt(S.symbolInstances.get(He),He,S.collisionArrays[He])}}else for(let qe=o.symbolInstanceStart;qe=0&&(o.text.placedSymbolArray.get(S).crossTileID=Y>=0&&S!==Y?0:q),D>=0&&(o.text.placedSymbolArray.get(D).crossTileID=Y>=0&&D!==Y?0:q),z>=0&&(o.text.placedSymbolArray.get(z).crossTileID=Y>=0&&z!==Y?0:q),N>=0&&(o.text.placedSymbolArray.get(N).crossTileID=Y>=0&&N!==Y?0:q)}markUsedOrientation(o,d,v){const T=d===t.WritingMode.horizontal||d===t.WritingMode.horizontalOnly?d:0,S=d===t.WritingMode.vertical?d:0,{leftJustifiedTextSymbolIndex:D,centerJustifiedTextSymbolIndex:z,rightJustifiedTextSymbolIndex:N,verticalPlacedTextSymbolIndex:q}=v,G=o.text.placedSymbolArray;D>=0&&(G.get(D).placedOrientation=T),z>=0&&(G.get(z).placedOrientation=T),N>=0&&(G.get(N).placedOrientation=T),q>=0&&(G.get(q).placedOrientation=S)}commit(o){this.commitTime=o,this.zoomAtLastRecencyCheck=this.transform.zoom;const d=this.prevPlacement;let v=!1;this.prevZoomAdjustment=d?d.zoomAdjustment(this.transform.zoom):0;const T=d?d.symbolFadeChange(o):1,S=d?d.opacities:{},D=d?d.variableOffsets:{},z=d?d.placedOrientations:{};for(const N in this.placements){const q=this.placements[N],G=S[N];G?(this.opacities[N]=new To(G,T,q.text,q.icon,null,q.clipped),v=v||q.text!==G.text.placed||q.icon!==G.icon.placed):(this.opacities[N]=new To(null,T,q.text,q.icon,q.skipFade,q.clipped),v=v||q.text||q.icon)}for(const N in S){const q=S[N];if(!this.opacities[N]){const G=new To(q,T,!1,!1);G.isHidden()||(this.opacities[N]=G,v=v||q.text.placed||q.icon.placed)}}for(const N in D)this.variableOffsets[N]||!this.opacities[N]||this.opacities[N].isHidden()||(this.variableOffsets[N]=D[N]);for(const N in z)this.placedOrientations[N]||!this.opacities[N]||this.opacities[N].isHidden()||(this.placedOrientations[N]=z[N]);v?this.lastPlacementChangeTime=o:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=d?d.lastPlacementChangeTime:o)}updateLayerOpacities(o,d){const v=new Set;for(const T of d){const S=T.getBucket(o);S&&T.latestFeatureIndex&&o.id===S.layerIds[0]&&this.updateBucketOpacities(S,v,T.collisionBoxArray)}}updateBucketOpacities(o,d,v){o.hasTextData()&&o.text.opacityVertexArray.clear(),o.hasIconData()&&o.icon.opacityVertexArray.clear(),o.hasIconCollisionBoxData()&&o.iconCollisionBox.collisionVertexArray.clear(),o.hasTextCollisionBoxData()&&o.textCollisionBox.collisionVertexArray.clear();const T=o.layers[0].layout,S=!!o.layers[0].dynamicFilter(),D=new To(null,0,!1,!1,!0),z=T.get("text-allow-overlap"),N=T.get("icon-allow-overlap"),q=T.get("text-variable-anchor"),G=T.get("text-rotation-alignment")==="map",Y=T.get("text-pitch-alignment")==="map",ie=T.get("icon-text-fit")!=="none",se=new To(null,0,z&&(N||!o.hasIconData()||T.get("icon-optional")),N&&(z||!o.hasTextData()||T.get("text-optional")),!0);!o.collisionArrays&&v&&(o.hasIconCollisionBoxData()||o.hasTextCollisionBoxData())&&o.deserializeCollisionBoxes(v);const ue=(fe,H,oe)=>{for(let ge=0;ge0||ge>0,Oe=Ae>0,Xe=this.placedOrientations[_e],pt=Xe===t.WritingMode.vertical,qe=Xe===t.WritingMode.horizontal||Xe===t.WritingMode.horizontalOnly;if(!Be&&!Oe||Pe.isHidden()||le++,Be){const ot=Vn(Pe.text);ue(o.text,oe,pt?Xn:ot),ue(o.text,ge,qe?Xn:ot);const He=Pe.text.isHidden(),{leftJustifiedTextSymbolIndex:dt,centerJustifiedTextSymbolIndex:$e,rightJustifiedTextSymbolIndex:it,verticalPlacedTextSymbolIndex:yt}=H,ct=o.text.placedSymbolArray,bt=He||pt?1:0;dt>=0&&(ct.get(dt).hidden=bt),$e>=0&&(ct.get($e).hidden=bt),it>=0&&(ct.get(it).hidden=bt),yt>=0&&(ct.get(yt).hidden=He||qe?1:0);const $t=this.variableOffsets[_e];$t&&this.markUsedJustification(o,$t.anchor,H,Xe);const un=this.placedOrientations[_e];un&&(this.markUsedJustification(o,"left",H,un),this.markUsedOrientation(o,un,H))}if(Oe){const ot=Vn(Pe.icon),{placedIconSymbolIndex:He,verticalPlacedIconSymbolIndex:dt}=H,$e=o.icon.placedSymbolArray,it=Pe.icon.isHidden()?1:0;He>=0&&(ue(o.icon,Ae,pt?Xn:ot),$e.get(He).hidden=it),dt>=0&&(ue(o.icon,H.numVerticalIconVertices,qe?Xn:ot),$e.get(dt).hidden=it)}if(o.hasIconCollisionBoxData()||o.hasTextCollisionBoxData()){const ot=o.collisionArrays[fe];if(ot){let He=new t.Point(0,0),dt=!0;if(ot.textBox||ot.verticalTextBox){if(q){const it=this.variableOffsets[_e];it?(He=ca(it.anchor,it.width,it.height,it.textOffset,it.textScale),G&&He._rotate(Y?this.transform.angle:-this.transform.angle)):dt=!1}S&&(dt=!Pe.clipped),ot.textBox&&rr(o.textCollisionBox.collisionVertexArray,Pe.text.placed,!dt||pt,He.x,He.y),ot.verticalTextBox&&rr(o.textCollisionBox.collisionVertexArray,Pe.text.placed,!dt||qe,He.x,He.y)}const $e=dt&&!!(!qe&&ot.verticalIconBox);ot.iconBox&&rr(o.iconCollisionBox.collisionVertexArray,Pe.icon.placed,$e,ie?He.x:0,ie?He.y:0),ot.verticalIconBox&&rr(o.iconCollisionBox.collisionVertexArray,Pe.icon.placed,!$e,ie?He.x:0,ie?He.y:0)}}}if(o.fullyClipped=le===0,o.sortFeatures(this.transform.angle),this.retainedQueryData[o.bucketInstanceId]&&(this.retainedQueryData[o.bucketInstanceId].featureSortOrder=o.featureSortOrder),o.hasTextData()&&o.text.opacityVertexBuffer&&o.text.opacityVertexBuffer.updateData(o.text.opacityVertexArray),o.hasIconData()&&o.icon.opacityVertexBuffer&&o.icon.opacityVertexBuffer.updateData(o.icon.opacityVertexArray),o.hasIconCollisionBoxData()&&o.iconCollisionBox.collisionVertexBuffer&&o.iconCollisionBox.collisionVertexBuffer.updateData(o.iconCollisionBox.collisionVertexArray),o.hasTextCollisionBoxData()&&o.textCollisionBox.collisionVertexBuffer&&o.textCollisionBox.collisionVertexBuffer.updateData(o.textCollisionBox.collisionVertexArray),o.bucketInstanceId in this.collisionCircleArrays){const fe=this.collisionCircleArrays[o.bucketInstanceId];o.placementInvProjMatrix=fe.invProjMatrix,o.placementViewportMatrix=fe.viewportMatrix,o.collisionCircleArray=fe.circles,delete this.collisionCircleArrays[o.bucketInstanceId]}}symbolFadeChange(o){return this.fadeDuration===0?1:(o-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(o){return Math.max(0,(this.transform.zoom-o)/1.5)}hasTransitions(o){return this.stale||o-this.lastPlacementChangeTimeo}setStale(){this.stale=!0}}function rr(_,o,d,v,T){_.emplaceBack(o?1:0,d?1:0,v||0,T||0),_.emplaceBack(o?1:0,d?1:0,v||0,T||0),_.emplaceBack(o?1:0,d?1:0,v||0,T||0),_.emplaceBack(o?1:0,d?1:0,v||0,T||0)}const or=Math.pow(2,25),Ai=Math.pow(2,24),Dl=Math.pow(2,17),ja=Math.pow(2,16),sr=Math.pow(2,9),Wr=Math.pow(2,8),zl=Math.pow(2,1);function Vn(_){if(_.opacity===0&&!_.placed)return 0;if(_.opacity===1&&_.placed)return 4294967295;const o=_.placed?1:0,d=Math.floor(127*_.opacity);return d*or+o*Ai+d*Dl+o*ja+d*sr+o*Wr+d*zl+o}const Xn=0;class ds{constructor(o){this._sortAcrossTiles=o.layout.get("symbol-z-order")!=="viewport-y"&&o.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(o,d,v,T,S){const D=this._bucketParts;for(;this._currentTileIndexz.sortKey-N.sortKey));this._currentPartIndex{const D=t.exported.now()-T;return!this._forceFullPlacement&&D>2};for(;this._currentPlacementIndex>=0;){const D=d[o[this._currentPlacementIndex]],z=this.placement.collisionIndex.transform.zoom;if(D.type==="symbol"&&(!D.minzoom||D.minzoom<=z)&&(!D.maxzoom||D.maxzoom>z)){if(this._inProgressLayer||(this._inProgressLayer=new ds(D)),this._inProgressLayer.continuePlacement(v[D.source],this.placement,this._showCollisionBoxes,D,S))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(o){return this.placement.commit(o),this.placement}}const fo=512/t.EXTENT/2;class Qi{constructor(o,d,v){this.tileID=o,this.bucketInstanceId=v,this.index=new t.KDBush(d.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const T=o.canonical.x*t.EXTENT,S=o.canonical.y*t.EXTENT;for(let D=0;Do.overscaledZ)for(const z in D){const N=D[z];N.tileID.isChildOf(o)&&N.findMatches(d.symbolInstances,o,T)}else{const z=D[o.scaledTo(Number(S)).key];z&&z.findMatches(d.symbolInstances,o,T)}}for(let S=0;S{d[v]=!0});for(const v in this.layerIndexes)d[v]||delete this.layerIndexes[v]}}const No=(_,o)=>t.emitValidationErrors(_,o&&o.filter(d=>d.identifier!=="source.canvas")),ha=t.pick(On,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),nh=t.pick(On,["setCenter","setZoom","setBearing","setPitch"]),Za={version:8,layers:[],sources:{}},Cr={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Ur extends t.Evented{constructor(o,d={}){super(),this.map=o,this.dispatcher=new tt(Xr(),this),this.imageManager=new lt,this.imageManager.setEventedParent(this),this.glyphManager=new t.GlyphManager(o._requestManager,d.localFontFamily?t.LocalGlyphMode.all:d.localIdeographFontFamily?t.LocalGlyphMode.ideographs:t.LocalGlyphMode.none,d.localFontFamily||d.localIdeographFontFamily),this.crossTileSymbolIndex=new po,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.getReferrer());const v=this;this._rtlTextPluginCallback=Ur.registerForPluginStateChange(T=>{v.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:T.pluginStatus,pluginURL:T.pluginURL},(S,D)=>{if(t.triggerPluginCompletionEvent(S),D&&D.every(z=>z))for(const z in v._sourceCaches){const N=v._sourceCaches[z],q=N.getSource().type;q!=="vector"&&q!=="geojson"||N.reload()}})}),this.on("data",T=>{if(T.dataType!=="source"||T.sourceDataType!=="metadata")return;const S=this.getSource(T.sourceId);if(S&&S.vectorLayerIds)for(const D in this._layers){const z=this._layers[D];z.source===S.id&&this._validateLayer(z)}})}loadURL(o,d={}){this.fire(new t.Event("dataloading",{dataType:"style"}));const v=typeof d.validate=="boolean"?d.validate:!t.isMapboxURL(o);o=this.map._requestManager.normalizeStyleURL(o,d.accessToken);const T=this.map._requestManager.transformRequest(o,t.ResourceType.Style);this._request=t.getJSON(T,(S,D)=>{this._request=null,S?this.fire(new t.ErrorEvent(S)):D&&this._load(D,v)})}loadJSON(o,d={}){this.fire(new t.Event("dataloading",{dataType:"style"})),this._request=t.exported.frame(()=>{this._request=null,this._load(o,d.validate!==!1)})}loadEmpty(){this.fire(new t.Event("dataloading",{dataType:"style"})),this._load(Za,!1)}_updateLayerCount(o,d){const v=d?1:-1;o.is3D()&&(this._num3DLayers+=v),o.type==="circle"&&(this._numCircleLayers+=v),o.type==="symbol"&&(this._numSymbolLayers+=v)}_load(o,d){if(d&&No(this,t.validateStyle(o)))return;this._loaded=!0,this.stylesheet=t.clone$1(o),this._updateMapProjection();for(const T in o.sources)this.addSource(T,o.sources[T],{validate:!1});this._changed=!1,o.sprite?this._loadSprite(o.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(o.glyphs);const v=oa(this.stylesheet.layers);this._order=v.map(T=>T.id),this._layers={},this._serializedLayers={};for(const T of v){const S=t.createStyleLayer(T);S.setEventedParent(this,{layer:{id:S.id}}),this._layers[S.id]=S,this._serializedLayers[S.id]=S.serialize(),this._updateLayerCount(S,!0)}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new At(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new t.Event("data",{dataType:"style"})),this.fire(new t.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(o){o?this.stylesheet.projection=o:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(o){this._spriteRequest=function(d,v,T){let S,D,z;const N=t.exported.devicePixelRatio>1?"@2x":"";let q=t.getJSON(v.transformRequest(v.normalizeSpriteURL(d,N,".json"),t.ResourceType.SpriteJSON),(ie,se)=>{q=null,z||(z=ie,S=se,Y())}),G=t.getImage(v.transformRequest(v.normalizeSpriteURL(d,N,".png"),t.ResourceType.SpriteImage),(ie,se)=>{G=null,z||(z=ie,D=se,Y())});function Y(){if(z)T(z);else if(S&&D){const ie=t.exported.getImageData(D),se={};for(const ue in S){const{width:le,height:fe,x:H,y:oe,sdf:ge,pixelRatio:_e,stretchX:Ae,stretchY:Re,content:Pe}=S[ue],Be=new t.RGBAImage({width:le,height:fe});t.RGBAImage.copy(ie,Be,{x:H,y:oe},{x:0,y:0},{width:le,height:fe}),se[ue]={data:Be,pixelRatio:_e,sdf:ge,stretchX:Ae,stretchY:Re,content:Pe}}T(null,se)}}return{cancel(){q&&(q.cancel(),q=null),G&&(G.cancel(),G=null)}}}(o,this.map._requestManager,(d,v)=>{if(this._spriteRequest=null,d)this.fire(new t.ErrorEvent(d));else if(v)for(const T in v)this.imageManager.addImage(T,v[T]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new t.Event("data",{dataType:"style"}))})}_validateLayer(o){const d=this.getSource(o.source);if(!d)return;const v=o.sourceLayer;v&&(d.type==="geojson"||d.vectorLayerIds&&d.vectorLayerIds.indexOf(v)===-1)&&this.fire(new t.ErrorEvent(new Error(`Source layer "${v}" does not exist on source "${d.id}" as specified by style layer "${o.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const o in this._sourceCaches)if(!this._sourceCaches[o].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(o){const d=[];for(const v of o){const T=this._layers[v];T.type!=="custom"&&d.push(T.serialize())}return d}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const o in this._sourceCaches)if(this._sourceCaches[o].hasTransition())return!0;for(const o in this._layers)if(this._layers[o].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(o){return!!this.terrain&&(typeof o.isLayerDraped=="function"?o.isLayerDraped():Cr[o.type])}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(o){if(!this._loaded)return;const d=this._changed;if(this._changed){const T=Object.keys(this._updatedLayers),S=Object.keys(this._removedLayers);(T.length||S.length)&&this._updateWorkerLayers(T,S);for(const D in this._updatedSources){const z=this._updatedSources[D];z==="reload"?this._reloadSource(D):z==="clear"&&this._clearSource(D)}this._updateTilesForChangedImages();for(const D in this._updatedPaintProps)this._layers[D].updateTransitions(o);this.light.updateTransitions(o),this.fog&&this.fog.updateTransitions(o),this._resetUpdates()}const v={};for(const T in this._sourceCaches){const S=this._sourceCaches[T];v[T]=S.used,S.used=!1}for(const T of this._order){const S=this._layers[T];if(S.recalculate(o,this._availableImages),!S.isHidden(o.zoom)){const z=this._getLayerSourceCache(S);z&&(z.used=!0)}const D=this.map.painter;if(D){const z=S.getProgramIds();if(!z)continue;const N=S.getProgramConfiguration(o.zoom);for(const q of z)D.useProgram(q,N)}}for(const T in v){const S=this._sourceCaches[T];v[T]!==S.used&&S.getSource().fire(new t.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:S.getSource().id}))}this.light.recalculate(o),this.terrain&&this.terrain.recalculate(o),this.fog&&this.fog.recalculate(o),this.z=o.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),d&&this.fire(new t.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const o=Object.keys(this._changedImages);if(o.length){for(const d in this._sourceCaches)this._sourceCaches[d].reloadTilesForDependencies(["icons","patterns"],o);this._changedImages={}}}_updateWorkerLayers(o,d){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(o),removedIds:d})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(o){if(this._checkLoaded(),No(this,t.validateStyle(o)))return!1;(o=t.clone$1(o)).layers=oa(o.layers);const d=function(T,S){if(!T)return[{command:On.setStyle,args:[S]}];let D=[];try{if(!E(T.version,S.version))return[{command:On.setStyle,args:[S]}];E(T.center,S.center)||D.push({command:On.setCenter,args:[S.center]}),E(T.zoom,S.zoom)||D.push({command:On.setZoom,args:[S.zoom]}),E(T.bearing,S.bearing)||D.push({command:On.setBearing,args:[S.bearing]}),E(T.pitch,S.pitch)||D.push({command:On.setPitch,args:[S.pitch]}),E(T.sprite,S.sprite)||D.push({command:On.setSprite,args:[S.sprite]}),E(T.glyphs,S.glyphs)||D.push({command:On.setGlyphs,args:[S.glyphs]}),E(T.transition,S.transition)||D.push({command:On.setTransition,args:[S.transition]}),E(T.light,S.light)||D.push({command:On.setLight,args:[S.light]}),E(T.fog,S.fog)||D.push({command:On.setFog,args:[S.fog]}),E(T.projection,S.projection)||D.push({command:On.setProjection,args:[S.projection]});const z={},N=[];(function(Y,ie,se,ue){let le;for(le in ie=ie||{},Y=Y||{})Y.hasOwnProperty(le)&&(ie.hasOwnProperty(le)||sa(le,se,ue));for(le in ie){if(!ie.hasOwnProperty(le))continue;const fe=ie[le];Y.hasOwnProperty(le)?E(Y[le],fe)||(Y[le].type==="geojson"&&fe.type==="geojson"&&us(Y,ie,le)?se.push({command:On.setGeoJSONSourceData,args:[le,fe.data]}):Ll(le,ie,se,ue)):Ri(le,ie,se)}})(T.sources,S.sources,N,z);const q=[];T.layers&&T.layers.forEach(Y=>{Y.source&&z[Y.source]?D.push({command:On.removeLayer,args:[Y.id]}):q.push(Y)});let G=T.terrain;G&&z[G.source]&&(D.push({command:On.setTerrain,args:[void 0]}),G=void 0),D=D.concat(N),E(G,S.terrain)||D.push({command:On.setTerrain,args:[S.terrain]}),function(Y,ie,se){ie=ie||[];const ue=(Y=Y||[]).map(co),le=ie.map(co),fe=Y.reduce(aa,{}),H=ie.reduce(aa,{}),oe=ue.slice(),ge=Object.create(null);let _e,Ae,Re,Pe,Be,Oe,Xe;for(_e=0,Ae=0;_e!(T.command in nh));if(d.length===0)return!1;const v=d.filter(T=>!(T.command in ha));if(v.length>0)throw new Error(`Unimplemented: ${v.map(T=>T.command).join(", ")}.`);return d.forEach(T=>{T.command!=="setTransition"&&T.command!=="setProjection"&&this[T.command].apply(this,T.args)}),this.stylesheet=o,this._updateMapProjection(),!0}addImage(o,d){return this.getImage(o)?this.fire(new t.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(o,d),this._afterImageUpdated(o),this)}updateImage(o,d){this.imageManager.updateImage(o,d)}getImage(o){return this.imageManager.getImage(o)}removeImage(o){return this.getImage(o)?(this.imageManager.removeImage(o),this._afterImageUpdated(o),this):this.fire(new t.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(o){this._availableImages=this.imageManager.listImages(),this._changedImages[o]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(o,d,v={}){if(this._checkLoaded(),this.getSource(o)!==void 0)throw new Error("There is already a source with this ID");if(!d.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(d).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(d.type)>=0&&this._validate(t.validateSource,`sources.${o}`,d,null,v))return;this.map&&this.map._collectResourceTiming&&(d.collectResourceTiming=!0);const T=En(o,d,this.dispatcher,this);T.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(o),source:T.serialize(),sourceId:o}));const S=D=>{const z=(D?"symbol:":"other:")+o,N=this._sourceCaches[z]=new t.SourceCache(z,T,D);(D?this._symbolSourceCaches:this._otherSourceCaches)[o]=N,N.style=this,N.onAdd(this.map)};S(!1),d.type!=="vector"&&d.type!=="geojson"||S(!0),T.onAdd&&T.onAdd(this.map),this._changed=!0}removeSource(o){this._checkLoaded();const d=this.getSource(o);if(!d)throw new Error("There is no source with this ID");for(const T in this._layers)if(this._layers[T].source===o)return this.fire(new t.ErrorEvent(new Error(`Source "${o}" cannot be removed while layer "${T}" is using it.`)));if(this.terrain&&this.terrain.get().source===o)return this.fire(new t.ErrorEvent(new Error(`Source "${o}" cannot be removed while terrain is using it.`)));const v=this._getSourceCaches(o);for(const T of v)delete this._sourceCaches[T.id],delete this._updatedSources[T.id],T.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:T.getSource().id})),T.setEventedParent(null),T.clearTiles();return delete this._otherSourceCaches[o],delete this._symbolSourceCaches[o],d.setEventedParent(null),d.onRemove&&d.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(o,d){this._checkLoaded(),this.getSource(o).setData(d),this._changed=!0}getSource(o){const d=this._getSourceCache(o);return d&&d.getSource()}_getSources(){const o=[];for(const d in this._otherSourceCaches){const v=this._getSourceCache(d);v&&o.push(v.getSource())}return o}addLayer(o,d,v={}){this._checkLoaded();const T=o.id;if(this.getLayer(T))return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${T}" already exists on this map`)));let S;if(o.type==="custom"){if(No(this,t.validateCustomStyleLayer(o)))return;S=t.createStyleLayer(o)}else{if(typeof o.source=="object"&&(this.addSource(T,o.source),o=t.clone$1(o),o=t.extend(o,{source:T})),this._validate(t.validateLayer,`layers.${T}`,o,{arrayIndex:-1},v))return;S=t.createStyleLayer(o),this._validateLayer(S),S.setEventedParent(this,{layer:{id:T}}),this._serializedLayers[S.id]=S.serialize(),this._updateLayerCount(S,!0)}const D=d?this._order.indexOf(d):this._order.length;if(d&&D===-1)return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${d}" does not exist on this map.`)));this._order.splice(D,0,T),this._layerOrderChanged=!0,this._layers[T]=S;const z=this._getLayerSourceCache(S);if(this._removedLayers[T]&&S.source&&z&&S.type!=="custom"){const N=this._removedLayers[T];delete this._removedLayers[T],N.type!==S.type?this._updatedSources[S.source]="clear":(this._updatedSources[S.source]="reload",z.pause())}this._updateLayer(S),S.onAdd&&S.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(o,d){if(this._checkLoaded(),this._changed=!0,!this._layers[o])return void this.fire(new t.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be moved.`)));if(o===d)return;const v=this._order.indexOf(o);this._order.splice(v,1);const T=d?this._order.indexOf(d):this._order.length;d&&T===-1?this.fire(new t.ErrorEvent(new Error(`Layer with id "${d}" does not exist on this map.`))):(this._order.splice(T,0,o),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(o){this._checkLoaded();const d=this._layers[o];if(!d)return void this.fire(new t.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be removed.`)));d.setEventedParent(null),this._updateLayerCount(d,!1);const v=this._order.indexOf(o);this._order.splice(v,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[o]=d,delete this._layers[o],delete this._serializedLayers[o],delete this._updatedLayers[o],delete this._updatedPaintProps[o],d.onRemove&&d.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(o){return this._layers[o]}hasLayer(o){return o in this._layers}hasLayerType(o){for(const d in this._layers)if(this._layers[d].type===o)return!0;return!1}setLayerZoomRange(o,d,v){this._checkLoaded();const T=this.getLayer(o);T?T.minzoom===d&&T.maxzoom===v||(d!=null&&(T.minzoom=d),v!=null&&(T.maxzoom=v),this._updateLayer(T)):this.fire(new t.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(o,d,v={}){this._checkLoaded();const T=this.getLayer(o);if(T){if(!E(T.filter,d))return d==null?(T.filter=void 0,void this._updateLayer(T)):void(this._validate(t.validateFilter,`layers.${T.id}.filter`,d,{layerType:T.type},v)||(T.filter=t.clone$1(d),this._updateLayer(T)))}else this.fire(new t.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be filtered.`)))}getFilter(o){const d=this.getLayer(o);return d&&t.clone$1(d.filter)}setLayoutProperty(o,d,v,T={}){this._checkLoaded();const S=this.getLayer(o);S?E(S.getLayoutProperty(d),v)||(S.setLayoutProperty(d,v,T),this._updateLayer(S)):this.fire(new t.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(o,d){const v=this.getLayer(o);if(v)return v.getLayoutProperty(d);this.fire(new t.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style.`)))}setPaintProperty(o,d,v,T={}){this._checkLoaded();const S=this.getLayer(o);S?E(S.getPaintProperty(d),v)||(S.setPaintProperty(d,v,T)&&this._updateLayer(S),this._changed=!0,this._updatedPaintProps[o]=!0):this.fire(new t.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(o,d){const v=this.getLayer(o);return v&&v.getPaintProperty(d)}setFeatureState(o,d){this._checkLoaded();const v=o.source,T=o.sourceLayer,S=this.getSource(v);if(!S)return void this.fire(new t.ErrorEvent(new Error(`The source '${v}' does not exist in the map's style.`)));const D=S.type;if(D==="geojson"&&T)return void this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(D==="vector"&&!T)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));o.id===void 0&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided.")));const z=this._getSourceCaches(v);for(const N of z)N.setFeatureState(T,o.id,d)}removeFeatureState(o,d){this._checkLoaded();const v=o.source,T=this.getSource(v);if(!T)return void this.fire(new t.ErrorEvent(new Error(`The source '${v}' does not exist in the map's style.`)));const S=T.type,D=S==="vector"?o.sourceLayer:void 0;if(S==="vector"&&!D)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(d&&typeof o.id!="string"&&typeof o.id!="number")return void this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const z=this._getSourceCaches(v);for(const N of z)N.removeFeatureState(D,o.id,d)}getFeatureState(o){this._checkLoaded();const d=o.source,v=o.sourceLayer,T=this.getSource(d);if(T){if(T.type!=="vector"||v)return o.id===void 0&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(d)[0].getFeatureState(v,o.id);this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new t.ErrorEvent(new Error(`The source '${d}' does not exist in the map's style.`)))}getTransition(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const o={};for(const d in this._sourceCaches){const v=this._sourceCaches[d].getSource();o[v.id]||(o[v.id]=v.serialize())}return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:o,layers:this._serializeLayers(this._order)},d=>d!==void 0)}_updateLayer(o){this._updatedLayers[o.id]=!0;const d=this._getLayerSourceCache(o);o.source&&!this._updatedSources[o.source]&&d&&d.getSource().type!=="raster"&&(this._updatedSources[o.source]="reload",d.pause()),this._changed=!0,o.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(o){const d=D=>this._layers[D].type==="fill-extrusion",v={},T=[];for(let D=this._order.length-1;D>=0;D--){const z=this._order[D];if(d(z)){v[z]=D;for(const N of o){const q=N[z];if(q)for(const G of q)T.push(G)}}}T.sort((D,z)=>z.intersectionZ-D.intersectionZ);const S=[];for(let D=this._order.length-1;D>=0;D--){const z=this._order[D];if(d(z))for(let N=T.length-1;N>=0;N--){const q=T[N].feature;if(v[q.layer.id]{const q=this.getLayer(N);return q&&q.is3D()}):this.has3DLayers(),z=Zt.createFromScreenPoints(o,v);for(const N in this._sourceCaches){const q=this._sourceCaches[N].getSource().id;d.layers&&!T[q]||S.push(yi(this._sourceCaches[N],this._layers,this._serializedLayers,z,d,v,D,!!this.map._showQueryGeometry))}return this.placement&&S.push(function(N,q,G,Y,ie,se,ue){const le={},fe=se.queryRenderedSymbols(Y),H=[];for(const oe of Object.keys(fe).map(Number))H.push(ue[oe]);H.sort(hr);for(const oe of H){const ge=oe.featureIndex.lookupSymbolFeatures(fe[oe.bucketInstanceId],q,oe.bucketIndex,oe.sourceLayerIndex,ie.filter,ie.layers,ie.availableImages,N);for(const _e in ge){const Ae=le[_e]=le[_e]||[],Re=ge[_e];Re.sort((Pe,Be)=>{const Oe=oe.featureSortOrder;if(Oe){const Xe=Oe.indexOf(Pe.featureIndex);return Oe.indexOf(Be.featureIndex)-Xe}return Be.featureIndex-Pe.featureIndex});for(const Pe of Re)Ae.push(Pe)}}for(const oe in le)le[oe].forEach(ge=>{const _e=ge.feature,Ae=G(N[oe]);if(!Ae)return;const Re=Ae.getFeatureState(_e.layer["source-layer"],_e.id);_e.source=_e.layer.source,_e.layer["source-layer"]&&(_e.sourceLayer=_e.layer["source-layer"]),_e.state=Re});return le}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),z.screenGeometry,d,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(S)}querySourceFeatures(o,d){d&&d.filter&&this._validate(t.validateFilter,"querySourceFeatures.filter",d.filter,null,d);const v=this._getSourceCaches(o);let T=[];for(const S of v)T=T.concat(ki(S,d));return T}addSourceType(o,d,v){return Ur.getSourceType(o)?v(new Error(`A source type called "${o}" already exists.`)):(Ur.setSourceType(o,d),d.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:o,url:d.workerSourceURL},v):v(null,null))}getLight(){return this.light.getLight()}setLight(o,d={}){this._checkLoaded();const v=this.light.getLight();let T=!1;for(const D in o)if(!E(o[D],v[D])){T=!0;break}if(!T)return;const S=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(o,d),this.light.updateTransitions(S)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(o,d=1){if(this._checkLoaded(),!o)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let v=o;if(d===1){if(typeof v.source=="object"){const T="terrain-dem-src";this.addSource(T,v.source),v=t.clone$1(v),v=t.extend(v,{source:T})}if(this._validate(t.validateTerrain,"terrain",v))return}if(!this.terrain||this.terrain&&d!==this.terrain.drapeRenderMode){if(!v)return;this._createTerrain(v,d)}else{const T=this.terrain,S=T.get();for(const D of Object.keys(t.spec.terrain))!v.hasOwnProperty(D)&&t.spec.terrain[D].default&&(v[D]=t.spec.terrain[D].default);for(const D in v)if(!E(v[D],S[D])){T.set(v),this.stylesheet.terrain=v;const z=this._setTransitionParameters({duration:0});T.updateTransitions(z);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(o){const d=this.fog=new Gt(o,this.map.transform);this.stylesheet.fog=o;const v=this._setTransitionParameters({duration:0});d.updateTransitions(v)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const o of this.map._markers)o._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(o){if(this._checkLoaded(),!o)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const d=this.fog,v=d.get();Object.keys(o).length===0&&d.set(o);for(const T in o)if(!E(o[T],v[T])){d.set(o),this.stylesheet.fog=o;const S=this._setTransitionParameters({duration:0});d.updateTransitions(S);break}}else this._createFog(o);this._markersNeedUpdate=!0}_setTransitionParameters(o){return{now:t.exported.now(),transition:t.extend(o,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const o=this._order.filter(v=>this.isLayerDraped(this._layers[v])),d=this._order.filter(v=>!this.isLayerDraped(this._layers[v]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...o),this._drapedFirstOrder.push(...d)}_createTerrain(o,d){const v=this.terrain=new Nt(o,d);this.stylesheet.terrain=o,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const T=this._setTransitionParameters({duration:0});v.updateTransitions(T)}_force3DLayerUpdate(){for(const o in this._layers){const d=this._layers[o];d.type==="fill-extrusion"&&this._updateLayer(d)}}_forceSymbolLayerUpdate(){for(const o in this._layers){const d=this._layers[o];d.type==="symbol"&&this._updateLayer(d)}}_validate(o,d,v,T,S={}){return(!S||S.validate!==!1)&&No(this,o.call(t.validateStyle,t.extend({key:d,style:this.serialize(),value:v,styleSpec:t.spec},T)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),t.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const o in this._layers)this._layers[o].setEventedParent(null);for(const o in this._sourceCaches)this._sourceCaches[o].clearTiles(),this._sourceCaches[o].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(o){const d=this._getSourceCaches(o);for(const v of d)v.clearTiles()}_reloadSource(o){const d=this._getSourceCaches(o);for(const v of d)v.resume(),v.reload()}_reloadSources(){for(const o of this._getSources())o.reload&&o.reload()}_updateSources(o){for(const d in this._sourceCaches)this._sourceCaches[d].update(o)}_generateCollisionBoxes(){for(const o in this._sourceCaches){const d=this._sourceCaches[o];d.resume(),d.reload()}}_updatePlacement(o,d,v,T,S=!1){let D=!1,z=!1;const N={};for(const q of this._order){const G=this._layers[q];if(G.type!=="symbol")continue;if(!N[G.source]){const ie=this._getLayerSourceCache(G);if(!ie)continue;N[G.source]=ie.getRenderableIds(!0).map(se=>ie.getTileByID(se)).sort((se,ue)=>ue.tileID.overscaledZ-se.tileID.overscaledZ||(se.tileID.isLessThan(ue.tileID)?-1:1))}const Y=this.crossTileSymbolIndex.addLayer(G,N[G.source],o.center.lng,o.projection);D=D||Y}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),S=S||this._layerOrderChanged||v===0,this._layerOrderChanged&&this.fire(new t.Event("neworder")),(S||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.exported.now(),o.zoom))&&(this.pauseablePlacement=new Ga(o,this._order,S,d,v,T,this.placement,this.fog&&o.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,N),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(t.exported.now()),z=!0),D&&this.pauseablePlacement.placement.setStale()),z||D)for(const q of this._order){const G=this._layers[q];G.type==="symbol"&&this.placement.updateLayerOpacities(G,N[G.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.exported.now())}_releaseSymbolFadeTiles(){for(const o in this._sourceCaches)this._sourceCaches[o].releaseSymbolFadeTiles()}getImages(o,d,v){this.imageManager.getImages(d.icons,v),this._updateTilesForChangedImages();const T=S=>{S&&S.setDependencies(d.tileID.key,d.type,d.icons)};T(this._otherSourceCaches[d.source]),T(this._symbolSourceCaches[d.source])}getGlyphs(o,d,v){this.glyphManager.getGlyphs(d.stacks,v)}getResource(o,d,v){return t.makeRequest(d,v)}_getSourceCache(o){return this._otherSourceCaches[o]}_getLayerSourceCache(o){return o.type==="symbol"?this._symbolSourceCaches[o.source]:this._otherSourceCaches[o.source]}_getSourceCaches(o){const d=[];return this._otherSourceCaches[o]&&d.push(this._otherSourceCaches[o]),this._symbolSourceCaches[o]&&d.push(this._symbolSourceCaches[o]),d}_isSourceCacheLoaded(o){const d=this._getSourceCaches(o);return d.length===0?(this.fire(new t.ErrorEvent(new Error(`There is no source with ID '${o}'`))),!1):d.every(v=>v.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Ur.getSourceType=function(_){return on[_]},Ur.setSourceType=function(_,o){on[_]=o},Ur.registerForPluginStateChange=t.registerForPluginStateChange;var Ol=` #define EPSILON 0.0000001 #define PI 3.141592653589793 #define EXTENT 8192.0 #define HALF_PI PI/2.0 #define QUARTER_PI PI/4.0 #define RAD_TO_DEG 180.0/PI #define DEG_TO_RAD PI/180.0 #define GLOBE_RADIUS EXTENT/PI/2.0`,er="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",Ar=` #define ELEVATION_SCALE 7.0 #define ELEVATION_OFFSET 450.0 #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix( mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;} #else vec3 elevationVector(vec2 pos) { return vec3(0,0,1); } #endif const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt) {float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);} #ifdef TERRAIN #ifdef TERRAIN_DEM_FLOAT_FORMAT uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev; #else uniform sampler2D u_dem;uniform sampler2D u_dem_prev; #endif uniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos)); #ifdef TERRAIN_DEM_NEAREST_FILTER return u_exaggeration*tl; #endif float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif }float prevElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif } #ifdef TERRAIN_VERTEX_MORPHING float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);} #else float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif return currentElevation(apos);} #endif highp float unpack_depth(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4( unpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy)) );return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) { #ifdef TERRAIN_DEM_FLOAT_FORMAT float tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a; #else vec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack); #endif return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);} #else float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; } #endif`,fa=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);} #endif`,Pr=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);} #endif`;let da={},mo={};const pa=[];Ns(Ol,pa),Ns(Ar,pa),Ns(fa,pa),Ns(Pr,pa),da=Un("",Ar),mo=Un(Pr,fa);const go=Un(` #if __VERSION__ >=300 #define varying in #define gl_FragColor glFragColor #define texture2D texture #define textureCube texture out vec4 glFragColor; #endif highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}`,` #if __VERSION__ >=300 #define attribute in #define varying out #define texture2D texture #endif float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;} #ifdef PROJECTION_GLOBE_VIEW vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) { #ifndef PROJECTED_POS_ON_VIEWPORT float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz; #else return vec3(0.0); #endif }vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);} #endif vec2 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 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered.`),ma=Ol,Nl=` #ifdef GL_ES precision mediump float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif`;var Bl={background:Un(`uniform vec4 u_color;uniform float u_opacity; #ifdef LIGHTING_3D_MODE varying vec4 v_color; #endif void main() {vec4 out_color; #ifdef LIGHTING_3D_MODE out_color=v_color; #else out_color=u_color; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #ifdef LIGHTING_3D_MODE uniform vec4 u_color;varying vec4 v_color; #endif void main() {gl_Position=u_matrix*vec4(a_pos,0,1); #ifdef LIGHTING_3D_MODE v_color=apply_lighting(u_color); #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),backgroundPattern:Un(`uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),circle:Un(`varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep( antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width) );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_apply_premultiplied(out_color,v_fog_pos); #endif gl_FragColor=out_color*(v_visibility*opacity_t); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`#define NUM_VISIBILITY_RINGS 2 #define INV_SQRT2 0.70710678 #define ELEVATION_BIAS 0.0001 #define NUM_SAMPLES_PER_RING 16 uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) { #if defined(TERRAIN) return elevation(pos)+ELEVATION_BIAS; #else return 0.0; #endif }vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale); #ifdef PITCH_WITH_MAP #ifdef PROJECTION_GLOBE_VIEW return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) ); #else return u_matrix*( world_center+vec4(sample_offset,0,0) ); #endif #else return projected_center+vec4(sample_offset,0,0); #endif }float get_sample_step() { #ifdef PITCH_WITH_MAP return 2.0*PI/float(NUM_SAMPLES_PER_RING); #else return PI/float(NUM_SAMPLES_PER_RING); #endif }void main(void) { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1); #else surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1); #endif vec4 projected_center=u_matrix*world_center;float view_scale=0.0; #ifdef PITCH_WITH_MAP #ifdef SCALE_WITH_MAP view_scale=1.0; #else view_scale=projected_center.w/u_camera_to_center_distance; #endif #else #ifdef SCALE_WITH_MAP view_scale=u_camera_to_center_distance; #else view_scale=projected_center.w; #endif #endif gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0; #ifdef TERRAIN float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center; #ifdef PITCH_WITH_MAP float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center; #else occlusion_world_center=world_center;occlusion_projected_center=projected_center; #endif for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING); #else visibility=1.0; #endif #ifdef PROJECTION_GLOBE_VIEW visibility=1.0; #endif v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur); #ifdef FOG v_fog_pos=fog_position(world_center.xyz); #endif }`),clippingMask:Un("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Un(`uniform highp float u_intensity;varying vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0); #ifdef FOG if (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);} #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif varying vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main(void) { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #else pos=vec3(tilePos+extrude,elevation(tilePos)); #endif gl_Position=u_matrix*vec4(pos,1); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),heatmapTexture:Un(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(0.0); #endif }`,"attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Un("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Un("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}",`attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2( 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;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Un("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",`attribute vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3; #endif varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0; #ifdef PROJECTION_GLOBE_VIEW gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1); #else gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1); #endif }`),fill:Un(`#pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity vec4 out_color=color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillOutline:Un(`varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillOutlinePattern:Un(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillPattern:Un(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillExtrusion:Un(`varying vec4 v_color; #ifdef RENDER_SHADOWS varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #ifdef ZERO_ROOF_RADIUS varying vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) varying highp vec3 v_normal; #endif void main() { #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) vec3 normal=v_normal; #endif float z;vec4 color; #ifdef ZERO_ROOF_RADIUS z=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z); #else color=v_color; #endif #ifdef FAUX_AO float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x; #ifdef ZERO_ROOF_RADIUS concave*=(1.0-z); #endif float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade; #endif #ifdef RENDER_SHADOWS #ifdef ZERO_ROOF_RADIUS normal=mix(normal,vec3(0.0,0.0,1.0),z); #endif color.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth); #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif varying vec4 v_color; #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth; #endif #ifdef ZERO_ROOF_RADIUS varying vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) varying highp vec3 v_normal; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0)); #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) v_normal=normal; #endif base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif float ele=0.0;float h=0.0;float c_ele;vec3 pos; #ifdef TERRAIN bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h); #else h=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden); #ifdef RENDER_SHADOWS v_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w; #endif float NdotL=0.0;float colorvalue=0.0; #ifdef LIGHTING_3D_MODE NdotL=calculate_NdotL(normal); #else colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL); #endif if (normal.y !=0.0) {float r=0.84; #ifndef LIGHTING_3D_MODE r=mix(0.7,0.98,1.0-u_lightintensity); #endif NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0); #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE v_color=apply_lighting(color,NdotL); #else v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0)); #endif v_color*=u_opacity; #ifdef ZERO_ROOF_RADIUS v_roof_color=vec4(0.0,0.0,0.0,1.0); #ifdef LIGHTING_3D_MODE v_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0))); #else float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0)); #endif v_roof_color*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),fillExtrusionPattern:Un(`uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE varying float v_NdotL; #endif varying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color,v_NdotL)*u_opacity; #else out_color=out_color*v_lighting; #endif #ifdef FAUX_AO float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif varying vec2 v_pos;varying vec4 v_lighting; #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE varying float v_NdotL; #endif #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif float ele=0.0;float h=z;vec3 p;float c_ele; #ifdef TERRAIN bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h); #else p=vec3(pos_nx.xy,z); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0 ? pos_nx.xy : vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0; #ifdef LIGHTING_3D_MODE NdotL=calculate_NdotL(normal); #else NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL); #endif if (normal.y !=0.0) {float r=0.84; #ifndef LIGHTING_3D_MODE r=mix(0.7,0.98,1.0-u_lightintensity); #endif NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE v_NdotL=NdotL; #else v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(p); #endif }`),hillshadePrepare:Un(`#ifdef GL_ES precision highp float; #endif uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) { #ifdef TERRAIN_DEM_FLOAT_FORMAT return texture2D(u_image,coord).a/4.0; #else vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0; #endif }void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2( (c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c) )/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4( deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Un(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef LIGHTING_3D_MODE gl_FragColor=apply_lighting(gl_FragColor); #endif #ifdef FOG gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos)); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),line:Un(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv; #ifdef RENDER_LINE_DASH uniform sampler2D u_dash_image;varying vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform sampler2D u_gradient_image; #endif uniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;} #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity float linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity 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); #ifdef RENDER_LINE_DASH float sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist); #endif highp vec4 out_color; #ifdef RENDER_LINE_GRADIENT out_color=texture2D(u_gradient_image,v_uv.xy); #else out_color=color; #endif float trimmed=1.0; #ifdef RENDER_LINE_TRIM_OFFSET highp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}} #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #ifdef RENDER_LINE_ALPHA_DISCARD if (alpha < u_alpha_discard_threshold) {discard;} #endif #ifdef RENDER_LINE_BORDER float edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2); #ifdef RENDER_LINE_BORDER_AUTO float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);} #else out_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha); #endif } #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define EXTRUDE_SCALE 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data; #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) attribute highp vec4 a_packed; #endif #ifdef RENDER_LINE_DASH attribute float a_linesofar; #endif uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv; #ifdef RENDER_LINE_DASH uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform float u_image_height; #endif #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude; #ifndef RENDER_TO_TEXTURE float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #else v_gamma_scale=1.0; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3]; #ifdef RENDER_LINE_GRADIENT highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end); #else v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end); #endif #endif #ifdef RENDER_LINE_DASH float scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y); #endif v_width2=vec2(outset,inset); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),linePattern:Un(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.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=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE color=apply_lighting(color); #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude; #ifndef RENDER_TO_TEXTURE float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #else v_gamma_scale=1.0; #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth; #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),raster:Un(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3( 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);vec3 out_color=mix(u_high_vec,u_low_vec,rgb); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply(out_color,v_fog_pos)); #endif gl_FragColor=vec4(out_color*color.a,color.a); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),symbolIcon:Un(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal; #endif 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 bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point; #ifdef PROJECTION_GLOBE_VIEW vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1); #else offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1); #endif vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #else gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #endif float projection_transition_fade=1.0; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif 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;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}`),symbolSDF:Un(`#define SDF_PX 8.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal; #endif 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_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point; #ifdef PROJECTION_GLOBE_VIEW vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1); #else offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1); #endif vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #else gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #endif float gamma_scale=gl_Position.w;float projection_transition_fade=1.0; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}`),symbolTextAndIcon:Un(`#define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal; #endif 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_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp( 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #else gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #endif float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}`),terrainRaster:Un(`uniform sampler2D u_image0;varying vec2 v_pos0; #ifdef FOG varying float v_fog_opacity; #endif #ifdef RENDER_SHADOWS varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth; #endif void main() {vec4 color=texture2D(u_image0,v_pos0); #ifdef RENDER_SHADOWS color.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth); #endif #ifdef FOG #ifdef ZERO_EXAGGERATION color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #else color=fog_dither(fog_apply_from_vert(color,v_fog_opacity)); #endif #endif gl_FragColor=color; #ifdef TERRAIN_WIREFRAME gl_FragColor=vec4(1.0,0.0,0.0,0.8); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;varying vec2 v_pos0; #ifdef FOG varying float v_fog_opacity; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth; #endif const float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height; #ifdef TERRAIN_WIREFRAME elevation+=wireframeOffset; #endif v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0); #ifdef FOG #ifdef ZERO_EXAGGERATION v_fog_pos=fog_position(decodedPos); #else v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation))); #endif #endif #ifdef RENDER_SHADOWS vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w; #endif }`),terrainDepth:Un(`#ifdef GL_ES precision highp float; #endif varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:Un(` varying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep( cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb; #ifdef FOG sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color); #endif sky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,er),skyboxGradient:Un(`varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5)); #ifdef FOG color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a; #endif color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,er),skyboxCapture:Un(` varying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m; #ifdef GL_ES precision highp float; #endif #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6) #define BETA_M vec3(21e-6,21e-6,21e-6) #define MIE_G 0.76 #define DENSITY_HEIGHT_SCALE_R 8000.0 #define DENSITY_HEIGHT_SCALE_M 1200.0 #define PLANET_RADIUS 6360e3 #define ATMOSPHERE_RADIUS 6420e3 #define SAMPLE_STEPS 10 #define DENSITY_STEPS 4 float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}`,"attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Un(`uniform sampler2D u_image0;varying vec2 v_pos0; #ifndef FOG uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport; #endif void main() {vec4 color; #ifdef CUSTOM_ANTIALIASING vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias); #else color=texture2D(u_image0,v_pos0); #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color; #ifdef TERRAIN_WIREFRAME gl_FragColor=vec4(1.0,0.0,0.0,0.8); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height; #ifdef GLOBE_POLES attribute vec3 a_globe_pos;attribute vec2 a_uv; #else attribute vec2 a_pos; #endif varying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() { #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;vec2 uv=a_uv; #else float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY); #endif v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale; #ifdef GLOBE_POLES vec3 up_vector=globe_derived_up_vector; #else vec3 up_vector=elevationVector(tile_pos); #endif float height=elevation(tile_pos); #ifdef TERRAIN_WIREFRAME height+=wireframeOffset; #endif globe_pos+=up_vector*height; #ifndef GLOBE_POLES globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z; #endif #ifdef GLOBE_POLES vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0); #else vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); #endif gl_Position=u_proj_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif }`),globeAtmosphere:Un(`uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir; #ifdef PROJECTION_GLOBE_VIEW globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;} #endif highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ? 0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle; #ifdef PROJECTION_GLOBE_VIEW highp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ? PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t); #else horizon_angle=horizon_angle_mercator; #endif horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x: (n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y: uv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}`,`attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix( mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`)};function Ns(_,o){const d=_.replace(/\s*\/\/[^\n]*\n/g,` `).split(` `);for(let v of d)if(v=v.trim(),v[0]==="#"&&v.includes("if")&&!v.includes("endif")){v=v.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const T=v.split(" ");for(const S of T)o.includes(S)||o.push(S)}}function Un(_,o){const d=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,v=o.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),T={},S=[...pa];return Ns(_,S),Ns(o,S),{fragmentSource:_=_.replace(d,(D,z,N,q,G)=>(T[G]=!0,z==="define"?` #ifndef HAS_UNIFORM_u_${G} varying ${N} ${q} ${G}; #else uniform ${N} ${q} u_${G}; #endif `:` #ifdef HAS_UNIFORM_u_${G} ${N} ${q} ${G} = u_${G}; #endif `)),vertexSource:o=o.replace(d,(D,z,N,q,G)=>{const Y=q==="float"?"vec2":"vec4",ie=G.match(/color/)?"color":Y;return T[G]?z==="define"?` #ifndef HAS_UNIFORM_u_${G} uniform lowp float u_${G}_t; attribute ${N} ${Y} a_${G}; varying ${N} ${q} ${G}; #else uniform ${N} ${q} u_${G}; #endif `:ie==="vec4"?` #ifndef HAS_UNIFORM_u_${G} ${G} = a_${G}; #else ${N} ${q} ${G} = u_${G}; #endif `:` #ifndef HAS_UNIFORM_u_${G} ${G} = unpack_mix_${ie}(a_${G}, u_${G}_t); #else ${N} ${q} ${G} = u_${G}; #endif `:z==="define"?` #ifndef HAS_UNIFORM_u_${G} uniform lowp float u_${G}_t; attribute ${N} ${Y} a_${G}; #else uniform ${N} ${q} u_${G}; #endif `:ie==="vec4"?` #ifndef HAS_UNIFORM_u_${G} ${N} ${q} ${G} = a_${G}; #else ${N} ${q} ${G} = u_${G}; #endif `:` #ifndef HAS_UNIFORM_u_${G} ${N} ${q} ${G} = unpack_mix_${ie}(a_${G}, u_${G}_t); #else ${N} ${q} ${G} = u_${G}; #endif `}),staticAttributes:v,usedDefines:S}}class ih{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(o,d,v,T,S,D,z){this.context=o;let N=this.boundPaintVertexBuffers.length!==T.length;for(let G=0;!N&&G{const ge=H.paint.get("hillshade-shadow-color"),_e=H.paint.get("hillshade-highlight-color"),Ae=H.paint.get("hillshade-accent-color");let Re=H.paint.get("hillshade-illumination-direction")*(Math.PI/180);H.paint.get("hillshade-illumination-anchor")==="viewport"&&(Re-=le.transform.angle);const Pe=!le.options.moving;return{u_matrix:oe||le.transform.calculateProjMatrix(fe.tileID.toUnwrapped(),Pe),u_image:0,u_latrange:Fl(0,fe.tileID),u_light:[H.paint.get("hillshade-exaggeration"),Re],u_shadow:ge,u_highlight:_e,u_accent:Ae}})(_,d,v,_.terrain?o.projMatrix:null);_.prepareDrawProgram(z,G,o.toUnwrapped());const{tileBoundsBuffer:ie,tileBoundsIndexBuffer:se,tileBoundsSegments:ue}=_.getTileBoundsBuffers(d);G.draw(z,N.TRIANGLES,T,S,D,t.CullFaceMode.disabled,Y,v.id,ie,se,ue)}function Bo(_,o,d){if(!o.needsDEMTextureUpload)return;const v=_.context,T=v.gl;v.pixelStoreUnpackPremultiplyAlpha.set(!1),o.demTexture=o.demTexture||_.getTileTexture(d.stride);const S=d.getPixels();o.demTexture?o.demTexture.update(S,{premultiply:!1}):o.demTexture=new t.Texture(v,S,T.RGBA,{premultiply:!1}),o.needsDEMTextureUpload=!1}function Lr(_,o,d,v,T,S){const D=_.context,z=D.gl;if(!o.dem)return;const N=o.dem;if(D.activeTexture.set(z.TEXTURE1),Bo(_,o,N),!o.demTexture)return;o.demTexture.bind(z.NEAREST,z.CLAMP_TO_EDGE);const q=N.dim;D.activeTexture.set(z.TEXTURE0);let G=o.fbo;if(!G){const ue=new t.Texture(D,{width:q,height:q,data:null},z.RGBA);ue.bind(z.LINEAR,z.CLAMP_TO_EDGE),G=o.fbo=D.createFramebuffer(q,q,!0),G.colorAttachment.set(ue.texture)}D.bindFramebuffer.set(G.framebuffer),D.viewport.set([0,0,q,q]);const{tileBoundsBuffer:Y,tileBoundsIndexBuffer:ie,tileBoundsSegments:se}=_.getMercatorTileBoundsBuffers();_.useProgram("hillshadePrepare").draw(D,z.TRIANGLES,v,T,S,t.CullFaceMode.disabled,((ue,le)=>{const fe=le.stride,H=t.create();return t.ortho(H,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(H,H,[0,-t.EXTENT,0]),{u_matrix:H,u_image:1,u_dimension:[fe,fe],u_zoom:ue.overscaledZ,u_unpack:le.unpackVector}})(o.tileID,N),d.id,Y,ie,se),o.needsHillshadePrepare=!1}const Vl=_=>({u_matrix:new t.UniformMatrix4f(_),u_image0:new t.Uniform1i(_),u_skirt_height:new t.Uniform1f(_)}),ps=(_,o)=>({u_matrix:_,u_image0:0,u_skirt_height:o}),$a=(_,o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue)=>({u_proj_matrix:Float32Array.from(_),u_globe_matrix:o,u_normalize_matrix:Float32Array.from(v),u_merc_matrix:d,u_zoom_transition:T,u_merc_center:S,u_image0:0,u_frustum_tl:D,u_frustum_tr:z,u_frustum_br:N,u_frustum_bl:q,u_globe_pos:G,u_globe_radius:Y,u_viewport:ie,u_grid_matrix:ue?Float32Array.from(ue):new Float32Array(9),u_skirt_height:se});function Jo(_,o){return _!=null&&o!=null&&!(!_.hasData()||!o.hasData())&&_.demTexture!=null&&o.demTexture!=null&&_.tileID.key!==o.tileID.key}const Io=new class{constructor(){this.operations={}}newMorphing(_,o,d,v,T){if(_ in this.operations){const S=this.operations[_];S.to.tileID.key!==d.tileID.key&&(S.queued=d)}else this.operations[_]={startTime:v,phase:0,duration:T,from:o,to:d,queued:null}}getMorphValuesForProxy(_){if(!(_ in this.operations))return null;const o=this.operations[_];return{from:o.from,to:o.to,phase:o.phase}}update(_){for(const o in this.operations){const d=this.operations[o];for(d.phase=(_-d.startTime)/d.duration;d.phase>=1||!this._validOp(d);)if(!this._nextOp(d,_)){delete this.operations[o];break}}}_nextOp(_,o){return!!_.queued&&(_.from=_.to,_.to=_.queued,_.queued=null,_.phase=0,_.startTime=o,!0)}_validOp(_){return _.from.hasData()&&_.to.hasData()}},Fo={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function ga(_){return 6*Math.pow(1.5,22-_)}function Yr(_,o){const d=1<<_.z;return!o&&(_.x===0||_.x===d-1)||_.y===0||_.y===d-1}const Bs=_=>({u_matrix:_});function br(_,o,d,v,T){if(T>0){const S=t.exported.now(),D=(S-_.timeAdded)/T,z=o?(S-o.timeAdded)/T:-1,N=d.getSource(),q=v.coveringZoomLevel({tileSize:N.tileSize,roundZoom:N.roundZoom}),G=!o||Math.abs(o.tileID.overscaledZ-q)>Math.abs(_.tileID.overscaledZ-q),Y=G&&_.refreshedUponExpiration?1:t.clamp(G?D:1-z,0,1);return _.refreshedUponExpiration&&D>=1&&(_.refreshedUponExpiration=!1),o?{opacity:1,mix:1-Y}:{opacity:Y,mix:0}}return{opacity:1,mix:0}}class ms extends t.SourceCache{constructor(o){const d={type:"raster-dem",maxzoom:o.transform.maxZoom},v=new tt(Xr(),null),T=En("mock-dem",d,v,o.style);super("mock-dem",T,!1),T.setEventedParent(this),this._sourceLoaded=!0}_loadTile(o,d){o.state="loaded",d(null)}}class Xa extends t.SourceCache{constructor(o){const d=En("proxy",{type:"geojson",maxzoom:o.transform.maxZoom},new tt(Xr(),null),o.style);super("proxy",d,!1),d.setEventedParent(this),this.map=this.getSource().map=o,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(o,d,v){if(o.freezeTileCoverage)return;this.transform=o;const T=o.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((S,D)=>{if(S[D.key]="",!this._tiles[D.key]){const z=new t.Tile(D,this._source.tileSize*D.overscaleFactor(),o.tileZoom);z.state="loaded",this._tiles[D.key]=z}return S},{});for(const S in this._tiles)S in T||(this.freeFBO(S),this._tiles[S].unloadVectorData(),delete this._tiles[S])}freeFBO(o){const d=this.proxyCachedFBO[o];if(d!==void 0){const v=Object.values(d);this.renderCachePool.push(...v),delete this.proxyCachedFBO[o]}}deallocRenderCache(){this.renderCache.forEach(o=>o.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class _a extends t.OverscaledTileID{constructor(o,d,v){super(o.overscaledZ,o.wrap,o.canonical.z,o.canonical.x,o.canonical.y),this.proxyTileKey=d,this.projMatrix=v}}class Wa extends t.Elevation{constructor(o,d){super(),this.painter=o,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[v,T,S]=function(N){const q=new t.StructArrayLayout2i4,G=new t.StructArrayLayout3ui6,Y=131;q.reserve(17161),G.reserve(33800);const ie=t.EXTENT/128,se=t.EXTENT+ie/2,ue=se+ie;for(let fe=-ie;fese||fe<0||fe>se?24575:0,ge=t.clamp(Math.round(H),0,t.EXTENT),_e=t.clamp(Math.round(fe),0,t.EXTENT);q.emplaceBack(ge+oe,_e)}const le=(fe,H)=>{const oe=H*Y+fe;G.emplaceBack(oe+1,oe,oe+Y),G.emplaceBack(oe+Y,oe+Y+1,oe+1)};for(let fe=1;fe<129;fe++)for(let H=1;H<129;H++)le(H,fe);return[0,129].forEach(fe=>{for(let H=0;H<130;H++)le(H,fe),le(fe,H)}),[q,G,32768]}(),D=o.context;this.gridBuffer=D.createVertexBuffer(v,t.posAttributes.members),this.gridIndexBuffer=D.createIndexBuffer(T),this.gridSegments=t.SegmentVector.simpleSegment(0,0,v.length,T.length),this.gridNoSkirtSegments=t.SegmentVector.simpleSegment(0,0,v.length,S),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Xa(d.map),this.orthoMatrix=t.create(),t.ortho(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,t.EXTENT,0,t.EXTENT,0,1);const z=D.gl;this._overlapStencilMode=new t.StencilMode({func:z.GEQUAL,mask:255},0,255,z.KEEP,z.KEEP,z.REPLACE),this._previousZoom=o.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=d,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new ms(d.map)}set style(o){o.on("data",this._onStyleDataEvent.bind(this)),o.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=o,this._checkRenderCacheEfficiency(),this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(o,d,v){if(o&&o.terrain){this._style!==o&&(this.style=o),this.enabled=!0;const T=o.terrain.properties;this.sourceCache=o.terrain.drapeRenderMode===0?this._mockSourceCache:o._getSourceCache(T.get("source")),this._exaggeration=T.get("exaggeration");const S=()=>{this.sourceCache.used&&t.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const D=this.getScaledDemTileSize();this.sourceCache.update(d,D,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,S(),this._initializing=!0),S(),d.updateElevation(!0,v),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(d),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(o){this._findCoveringTileCache[o]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const o=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||o.efficiency!==100&&t.warnOnce(`Terrain render cache efficiency is not optimal (${o.efficiency}%) and performance may be affected negatively, consider placing all background, fill and line layers before layer with id '${o.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(o){o.coord&&o.dataType==="source"?this._clearRenderCacheForTile(o.sourceCacheId,o.coord):o.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const o in this._style._sourceCaches)this._style._sourceCaches[o].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(o=>o.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const o=2*this.proxySourceCache.getSource().tileSize;return[o,o]}set useVertexMorphing(o){this._useVertexMorphing=o}updateTileBinding(o){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const d=this.proxySourceCache,v=this.painter.transform;this._initializing&&(this._initializing=v._centerAltitude===0&&this.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(v.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const T=this.proxyCoords=d.getIds().map(N=>{const q=d.getTileByID(N).tileID;return q.projMatrix=v.calculateProjMatrix(q.toUnwrapped()),q});(function(N,q){const G=q.transform.pointCoordinate(q.transform.getCameraPoint()),Y=new t.Point(G.x,G.y);N.sort((ie,se)=>{if(se.overscaledZ-ie.overscaledZ)return se.overscaledZ-ie.overscaledZ;const ue=new t.Point(ie.canonical.x+(1<{this.proxyToSource[N.key]={}}),this.terrainTileForTile={};const D=this._style._sourceCaches;for(const N in D){const q=D[N];if(!q.used||(q!==this.sourceCache&&this.resetTileLookupCache(q.id),this._setupProxiedCoordsForOrtho(q,o[N],S),q.usedForTerrain))continue;const G=o[N];q.getSource().reparseOverscaled&&this._assignTerrainTiles(G)}this.proxiedCoords[d.id]=T.map(N=>new _a(N,N.key,this.orthoMatrix)),this._assignTerrainTiles(T),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(S),this.renderingToTexture=!1,this._updateTimestamp=t.exported.now();const z={};this._visibleDemTiles=[];for(const N of this.proxyCoords){const q=this.terrainTileForTile[N.key];if(!q)continue;const G=q.tileID.key;G in z||(this._visibleDemTiles.push(q),z[G]=G)}}_assignTerrainTiles(o){this._initializing||o.forEach(d=>{if(this.terrainTileForTile[d.key])return;const v=this._findTileCoveringTileID(d,this.sourceCache);v&&(this.terrainTileForTile[d.key]=v)})}_prepareDEMTextures(){const o=this.painter.context,d=o.gl;for(const v in this.terrainTileForTile){const T=this.terrainTileForTile[v],S=T.dem;!S||T.demTexture&&!T.needsDEMTextureUpload||(o.activeTexture.set(d.TEXTURE1),Bo(this.painter,T,S))}}_prepareDemTileUniforms(o,d,v,T){if(!d||d.demTexture==null)return!1;const S=o.tileID.canonical,D=Math.pow(2,d.tileID.canonical.z-S.z),z=T||"";return v[`u_dem_tl${z}`]=[S.x*D%1,S.y*D%1],v[`u_dem_scale${z}`]=D,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const o=this.painter.context,d=o.gl;if(!this._emptyDepthBufferTexture){const v=new t.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new t.Texture(o,v,d.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let o=0;const d=this._visibleDemTiles.reduce((v,T)=>{if(!T.dem)return v;const S=T.dem.tree.minimums[0];return S>0&&o++,v+S},0);return o?d/o:0}_updateEmptyDEMTexture(){const o=this.painter.context,d=o.gl;o.activeTexture.set(d.TEXTURE2);const v=this._getLoadedAreaMinimum(),T=new t.RGBAImage({width:1,height:1},new Uint8Array(t.DEMData.pack(v,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let S=this._emptyDEMTexture;return S?S.update(T,{premultiply:!1}):S=this._emptyDEMTexture=new t.Texture(o,T,d.RGBA,{premultiply:!1}),S}setupElevationDraw(o,d,v){const T=this.painter.context,S=T.gl,D=(z=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:t.DEMData.getUnpackVector(z),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var z;D.u_dem_size=this.sourceCache.getSource().tileSize,D.u_exaggeration=this.exaggeration();let N=null,q=null,G=1;if(v&&v.morphing&&this._useVertexMorphing){const Y=v.morphing.srcDemTile,ie=v.morphing.dstDemTile;G=v.morphing.phase,Y&&ie&&(this._prepareDemTileUniforms(o,Y,D,"_prev")&&(q=Y),this._prepareDemTileUniforms(o,ie,D)&&(N=ie))}if(q&&N?(T.activeTexture.set(S.TEXTURE2),N.demTexture.bind(S.NEAREST,S.CLAMP_TO_EDGE,S.NEAREST),T.activeTexture.set(S.TEXTURE4),q.demTexture.bind(S.NEAREST,S.CLAMP_TO_EDGE,S.NEAREST),D.u_dem_lerp=G):(N=this.terrainTileForTile[o.tileID.key],T.activeTexture.set(S.TEXTURE2),(this._prepareDemTileUniforms(o,N,D)?N.demTexture:this.emptyDEMTexture).bind(S.NEAREST,S.CLAMP_TO_EDGE)),T.activeTexture.set(S.TEXTURE3),v&&v.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(S.NEAREST,S.CLAMP_TO_EDGE),this._depthFBO&&(D.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(S.NEAREST,S.CLAMP_TO_EDGE),D.u_depth_size_inv=[1,1]),v&&v.useMeterToDem&&N){const Y=(1<{if(H===dt)return;const it=[Fo[dt],"PROJECTION_GLOBE_VIEW"];_e&&it.push("CUSTOM_ANTIALIASING"),$e&&it.push(Fo[oe]),fe=q.useProgram("globeRaster",null,it),H=dt},Re=q.colorModeForRenderPass(),Pe=new t.DepthMode(le.LEQUAL,t.DepthMode.ReadWrite,q.depthRangeFor3D);Io.update(se);const Be=t.calculateGlobeMercatorMatrix(ge),Oe=[t.mercatorXfromLng(ge.center.lng),t.mercatorYfromLat(ge.center.lat)],Xe=oe?[!1,!0]:[!1],pt=q.globeSharedBuffers,qe=[ge.width*t.exported.devicePixelRatio,ge.height*t.exported.devicePixelRatio],ot=Float32Array.from(ge.globeMatrix),He={useDenormalizedUpVectorScale:!0};if(Xe.forEach(dt=>{const $e=q.transform,it=ga($e.zoom)*G.exaggeration();H=-1;const yt=dt?le.LINES:le.TRIANGLES;for(const ct of ie){const bt=Y.getTile(ct),$t=t.StencilMode.disabled,un=G.prevTerrainTileForTile[ct.key],Ut=G.terrainTileForTile[ct.key];Jo(un,Ut)&&Io.newMorphing(ct.key,un,Ut,se,250),ue.activeTexture.set(le.TEXTURE0),bt.texture.bind(le.LINEAR,le.CLAMP_TO_EDGE);const Kt=Io.getMorphValuesForProxy(ct.key),An=Kt?1:0;Kt&&t.extend$1(He,{morphing:{srcDemTile:Kt.from,dstDemTile:Kt.to,phase:t.easeCubicInOut(Kt.phase)}});const Cn=t.tileCornersToBounds(ct.canonical),qt=t.getLatitudinalLod(Cn.getCenter().lat),Yn=t.getGridMatrix(ct.canonical,Cn,qt,$e.worldSize/$e._pixelsPerMercatorPixel),ei=t.globeNormalizeECEF(t.globeTileBounds(ct.canonical)),ti=$a($e.projMatrix,ot,Be,ei,t.globeToMercatorTransition($e.zoom),Oe,$e.frustumCorners.TL,$e.frustumCorners.TR,$e.frustumCorners.BR,$e.frustumCorners.BL,$e.globeCenterInViewSpace,$e.globeRadius,qe,it,Yn);if(Ae(An,dt),G.setupElevationDraw(bt,fe,He),q.prepareDrawProgram(ue,fe,ct.toUnwrapped()),pt){const[ni,Dr,mr]=dt?pt.getWirefameBuffers(q.context,qt):pt.getGridBuffers(qt,it!==0);fe.draw(ue,yt,Pe,$t,Re,t.CullFaceMode.backCCW,ti,"globe_raster",ni,Dr,mr)}}}),pt){const dt=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];_e&&dt.push("CUSTOM_ANTIALIASING"),fe=q.useProgram("globeRaster",null,dt);for(const $e of ie){const{x:it,y:yt,z:ct}=$e.canonical,bt=yt===0,$t=yt===(1<ti.draw(ue,le.TRIANGLES,Pe,t.StencilMode.disabled,Re,t.CullFaceMode.disabled,$a(ge.projMatrix,qt,qt,Yn,0,Oe,ge.frustumCorners.TL,ge.frustumCorners.TR,ge.frustumCorners.BR,ge.frustumCorners.BL,ge.globeCenterInViewSpace,ge.globeRadius,qe,0),"globe_pole_raster",ni,Kt,An);G.setupElevationDraw(Cn,fe,He),q.prepareDrawProgram(ue,fe,$e.toUnwrapped()),bt&&ei(fe,un),$t&&(qt=t.scale(t.create(),qt,[1,-1,1]),ei(fe,Ut))}}}})(T,S,D,z,N);else{const q=T.context,G=q.gl;let Y,ie;const se=T.options.showTerrainWireframe?2:0,ue=(ge,_e)=>{if(ie===ge)return;const Ae=[Fo[ge]];_e&&Ae.push(Fo[se]),Y=T.useProgram("terrainRaster",null,Ae),ie=ge},le=T.colorModeForRenderPass(),fe=new t.DepthMode(G.LEQUAL,t.DepthMode.ReadWrite,T.depthRangeFor3D);Io.update(N);const H=T.transform,oe=ga(H.zoom)*S.exaggeration();(se?[!1,!0]:[!1]).forEach(ge=>{ie=-1;const _e=ge?G.LINES:G.TRIANGLES,[Ae,Re]=ge?S.getWirefameBuffer():[S.gridIndexBuffer,S.gridSegments];for(const Pe of z){const Be=D.getTile(Pe),Oe=t.StencilMode.disabled,Xe=S.prevTerrainTileForTile[Pe.key],pt=S.terrainTileForTile[Pe.key];Jo(Xe,pt)&&Io.newMorphing(Pe.key,Xe,pt,N,250),q.activeTexture.set(G.TEXTURE0),Be.texture.bind(G.LINEAR,G.CLAMP_TO_EDGE,G.LINEAR_MIPMAP_NEAREST);const qe=Io.getMorphValuesForProxy(Pe.key),ot=qe?1:0;let He;qe&&(He={morphing:{srcDemTile:qe.from,dstDemTile:qe.to,phase:t.easeCubicInOut(qe.phase)}});const dt=ps(Pe.projMatrix,Yr(Pe.canonical,H.renderWorldCopies)?oe/10:oe);ue(ot,ge),S.setupElevationDraw(Be,Y,He),T.prepareDrawProgram(q,Y,Pe.toUnwrapped()),Y.draw(q,_e,fe,Oe,le,t.CullFaceMode.backCCW,dt,"terrain_raster",S.gridBuffer,Ae,Re)}})}}(d,this,this.proxySourceCache,o,this._updateTimestamp),this.renderingToTexture=!0,d.gpuTimingDeferredRenderEnd(),o.splice(0,o.length))}renderBatch(o){if(this._drapedRenderBatches.length===0)return o+1;this.renderingToTexture=!0;const d=this.painter,v=this.painter.context,T=this.proxySourceCache,S=this.proxiedCoords[T.id],D=this._drapedRenderBatches.shift(),z=[],N=d.style.order;let q=0;for(const G of S){const Y=T.getTileByID(G.proxyTileKey),ie=T.proxyCachedFBO[G.key]?T.proxyCachedFBO[G.key][o]:void 0,se=ie!==void 0?T.renderCache[ie]:this.pool[q++],ue=ie!==void 0;if(Y.texture=se.tex,ue&&!se.dirty){z.push(Y.tileID);continue}let le;v.bindFramebuffer.set(se.fb.framebuffer),this.renderedToTile=!1,se.dirty&&(v.clear({color:t.Color.transparent,stencil:0}),se.dirty=!1);for(let fe=D.start;fe<=D.end;++fe){const H=d.style._layers[N[fe]];if(H.isHidden(d.transform.zoom))continue;const oe=d.style._getLayerSourceCache(H),ge=oe?this.proxyToSource[G.key][oe.id]:[G];if(!ge)continue;const _e=ge;v.viewport.set([0,0,se.fb.width,se.fb.height]),le!==(oe?oe.id:null)&&(this._setupStencil(se,ge,H,oe),le=oe?oe.id:null),d.renderLayer(d,oe,H,_e)}this.renderedToTile?(se.dirty=!0,z.push(Y.tileID)):ue||--q,q===5&&(q=0,this.renderToBackBuffer(z))}return this.renderToBackBuffer(z),this.renderingToTexture=!1,v.bindFramebuffer.set(null),v.viewport.set([0,0,d.width,d.height]),D.end+1}postRender(){}renderCacheEfficiency(o){const d=o.order.length;if(d===0)return{efficiency:100};let v,T=0,S=0,D=!1;for(let z=0;zd.dem).forEach(d=>{o=Math.min(o,d.dem.tree.minimums[0])}),o===0?o:(o-30)*this._exaggeration}raycast(o,d,v){if(!this._visibleDemTiles)return null;const T=this._visibleDemTiles.filter(S=>S.dem).map(S=>{const D=S.tileID,z=1<(S.t!==null?S.t:Number.MAX_VALUE)-(D.t!==null?D.t:Number.MAX_VALUE));for(const S of T){if(S.t==null)return null;const D=S.tile.dem.tree.raycast(S.minx,S.miny,S.maxx,S.maxy,o,d,v);if(D!=null)return D}return null}_createFBO(){const o=this.painter.context,d=o.gl,v=this.drapeBufferSize;o.activeTexture.set(d.TEXTURE0);const T=new t.Texture(o,{width:v[0],height:v[1],data:null},d.RGBA);T.bind(d.LINEAR,d.CLAMP_TO_EDGE);const S=o.createFramebuffer(v[0],v[1],!1);return S.colorAttachment.set(T.texture),S.depthAttachment=new me(o,S.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=o.createRenderbuffer(o.gl.DEPTH_STENCIL,v[0],v[1]),this._stencilRef=0,S.depthAttachment.set(this._sharedDepthStencil),o.clear({stencil:0})):S.depthAttachment.set(this._sharedDepthStencil),o.extTextureFilterAnisotropic&&!o.extTextureFilterAnisotropicForceOff&&d.texParameterf(d.TEXTURE_2D,o.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,o.extTextureFilterAnisotropicMax),{fb:S,tex:T,dirty:!1}}_initFBOPool(){for(;this.pool.length{const d=this._style._layers[o],v=d.isHidden(this.painter.transform.zoom);return d.type==="custom"?!v&&d.shouldRedrape():!v&&d.hasTransition()})}_clearLineLayersFromRenderCache(){let o=!1;for(const v of this._style._getSources())if(v instanceof It){o=!0;break}if(!o)return;const d={};for(let v=0;vd.renderCachePool.length){const D=Object.values(d.proxyCachedFBO);d.proxyCachedFBO={};for(let z=0;z=0;D--){const z=v[D];if(d.getTileByID(z.key),d.proxyCachedFBO[z.key]!==void 0){const N=o[z.key],q=this.proxyToSource[z.key];let G=0;for(const Y in q){const ie=q[Y],se=N[Y];if(!se||se.length!==ie.length||ie.some((ue,le)=>ue!==se[le]||T[Y]&&T[Y].hasOwnProperty(ue.key))){G=-1;break}++G}for(const Y in d.proxyCachedFBO[z.key])d.renderCache[d.proxyCachedFBO[z.key][Y]].dirty=G<0||G!==Object.values(N).length}}const S=[...this._drapedRenderBatches];S.sort((D,z)=>z.end-z.start-(D.end-D.start));for(const D of S)for(const z of v){if(d.proxyCachedFBO[z.key])continue;let N=d.renderCachePool.pop();N===void 0&&d.renderCache.length<50&&(N=d.renderCache.length,d.renderCache.push(this._createFBO())),N!==void 0&&(d.proxyCachedFBO[z.key]={},d.proxyCachedFBO[z.key][D.start]=N,d.renderCache[N].dirty=!0)}this._tilesDirty={}}_setupStencil(o,d,v,T){if(!T||!this._sourceTilesOverlap[T.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const S=this.painter.context,D=S.gl;if(d.length<=1)return void(this._overlapStencilType=!1);let z;if(v.isTileClipped())z=d.length,this._overlapStencilMode.test={func:D.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(d[0].overscaledZ>d[d.length-1].overscaledZ))return void(this._overlapStencilType=!1);z=1,this._overlapStencilMode.test={func:D.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+z>255&&(S.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=z,this._overlapStencilMode.ref=this._stencilRef,v.isTileClipped()&&this._renderTileClippingMasks(d,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(o){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[o.key]),this._overlapStencilMode):t.StencilMode.disabled}_renderTileClippingMasks(o,d){const v=this.painter,T=this.painter.context,S=T.gl;v._tileClippingMaskIDs={},T.setColorMode(t.ColorMode.disabled),T.setDepthMode(t.DepthMode.disabled);const D=v.useProgram("clippingMask");for(const z of o){const N=v._tileClippingMaskIDs[z.key]=--d;D.draw(T,S.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:S.ALWAYS,mask:0},N,255,S.KEEP,S.KEEP,S.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,Bs(z.projMatrix),"$clipping",v.tileExtentBuffer,v.quadTriangleIndexBuffer,v.tileExtentSegments)}}pointCoordinate(o){const d=this.painter.transform;if(o.x<0||o.x>d.width||o.y<0||o.y>d.height)return null;const v=[o.x,o.y,1,1];t.transformMat4$1(v,v,d.pixelMatrixInverse),t.scale$1(v,v,1/v[3]),v[0]/=d.worldSize,v[1]/=d.worldSize;const T=d._camera.position,S=t.mercatorZfromAltitude(1,d.center.lat),D=[T[0],T[1],T[2]/S,0],z=t.subtract([],v.slice(0,3),D);t.normalize(z,z);const N=this.raycast(D,z,this._exaggeration);return N!==null&&N?(t.scaleAndAdd(D,D,z,N),D[3]=D[2],D[2]*=S,D):null}drawDepth(){const o=this.painter,d=o.context,v=this.proxySourceCache,T=Math.ceil(o.width),S=Math.ceil(o.height);if(!this._depthFBO||this._depthFBO.width===T&&this._depthFBO.height===S||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const D=d.gl,z=d.createFramebuffer(T,S,!0);d.activeTexture.set(D.TEXTURE0);const N=new t.Texture(d,{width:T,height:S,data:null},D.RGBA);N.bind(D.NEAREST,D.CLAMP_TO_EDGE),z.colorAttachment.set(N.texture);const q=d.createRenderbuffer(d.gl.DEPTH_COMPONENT16,T,S);z.depthAttachment.set(q),this._depthFBO=z,this._depthTexture=N}d.bindFramebuffer.set(this._depthFBO.framebuffer),d.viewport.set([0,0,T,S]),function(D,z,N,q){if(D.transform.projection.name==="globe")return;const G=D.context,Y=G.gl;G.clear({depth:1});const ie=D.useProgram("terrainDepth"),se=new t.DepthMode(Y.LESS,t.DepthMode.ReadWrite,D.depthRangeFor3D);for(const ue of q){const le=N.getTile(ue),fe=ps(ue.projMatrix,0);z.setupElevationDraw(le,ie),ie.draw(G,Y.TRIANGLES,se,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.backCCW,fe,"terrain_depth",z.gridBuffer,z.gridIndexBuffer,z.gridNoSkirtSegments)}}(o,this,v,this.proxyCoords)}_setupProxiedCoordsForOrtho(o,d,v){if(o.getSource()instanceof wn)return this._setupProxiedCoordsForImageSource(o,d,v);this._findCoveringTileCache[o.id]=this._findCoveringTileCache[o.id]||{};const T=this.proxiedCoords[o.id]=[],S=this.proxyCoords;for(let z=0;z(G.min.x=Math.min(G.min.x,Y.x-z.x),G.min.y=Math.min(G.min.y,Y.y-z.y),G.max.x=Math.max(G.max.x,Y.x-z.x),G.max.y=Math.max(G.max.y,Y.y-z.y),G),{min:new t.Point(Number.MAX_VALUE,Number.MAX_VALUE),max:new t.Point(-Number.MAX_VALUE,-Number.MAX_VALUE)}),q=(G,Y)=>{const ie=G.wrap+G.canonical.x/(1<le+N.max.x||se+uefe+N.max.y};for(let G=0;GD.key===d.tileID.key);if(S)return S}if(d.tileID.key!==o.key){const S=o.canonical.z-d.tileID.canonical.z;let D,z,N;T=t.create();const q=d.tileID.wrap-o.wrap<0?(D=t.EXTENT>>S,z=D*((d.tileID.canonical.x<=Y){const ie=o.canonical.z-Y;d.getSource().reparseOverscaled?(z=Math.max(o.canonical.z+2,d.transform.tileZoom),D=new t.OverscaledTileID(z,o.wrap,Y,o.canonical.x>>ie,o.canonical.y>>ie)):ie!==0&&(z=Y,D=new t.OverscaledTileID(z,o.wrap,Y,o.canonical.x>>ie,o.canonical.y>>ie))}D.key!==o.key&&(q.push(D.key),v=d.getTile(D))}const G=Y=>{q.forEach(ie=>{T[ie]=Y}),q.length=0};for(z-=1;z>=N&&(!v||!v.hasData());z--){v&&G(v.tileID.key);const Y=D.calculateScaledKey(z);if(v=d.getTileByID(Y),v&&v.hasData())break;const ie=T[Y];if(ie===null)break;ie===void 0?q.push(Y):v=d.getTileByID(ie)}return G(v?v.tileID.key:null),v&&v.hasData()?v:null}findDEMTileFor(o){return this.enabled?this._findTileCoveringTileID(o,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(o,d){let v=this._tilesDirty[o];v||(v=this._tilesDirty[o]={}),v[d.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const o=function(d){let v=0;const T=new t.StructArrayLayout2ui4,S=131;for(let D=1;D<129;D++){for(let z=1;z<129;z++)v=D*S+z,T.emplaceBack(v,v+1),T.emplaceBack(v,v+S),T.emplaceBack(v+1,v+S),D===128&&T.emplaceBack(v+S,v+S+1);T.emplaceBack(v+1,v+1+S)}return T}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(o),this.wireframeSegments=t.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,o.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class Nn{static cacheKey(o,d,v,T){let S=`${d}${T?T.cacheKey:""}`;for(const D of v)o.usedDefines.includes(D)&&(S+=`/${D}`);return S}constructor(o,d,v,T,S,D){const z=o.gl;this.program=z.createProgram();const N=function(H){const oe=[];for(let ge=0;ge`#define ${H}`));const ie=o.isWebGL2?`#version 300 es `:"",se=ie+Y.concat(o.extStandardDerivatives&&ie.length===0?`#extension GL_OES_standard_derivatives : enable `.concat(Nl):Nl,Nl,ma,go.fragmentSource,mo.fragmentSource,v.fragmentSource).join(` `),ue=ie+Y.concat(` #ifdef GL_ES precision highp float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif`,ma,go.vertexSource,mo.vertexSource,da.vertexSource,v.vertexSource).join(` `),le=z.createShader(z.FRAGMENT_SHADER);if(z.isContextLost())return void(this.failedToCreate=!0);z.shaderSource(le,se),z.compileShader(le),z.attachShader(this.program,le);const fe=z.createShader(z.VERTEX_SHADER);if(z.isContextLost())this.failedToCreate=!0;else{z.shaderSource(fe,ue),z.compileShader(fe),z.attachShader(this.program,fe),this.attributes={},this.numAttributes=G.length;for(let H=0;H({u_dem:new t.Uniform1i(H),u_dem_prev:new t.Uniform1i(H),u_dem_unpack:new t.Uniform4f(H),u_dem_tl:new t.Uniform2f(H),u_dem_scale:new t.Uniform1f(H),u_dem_tl_prev:new t.Uniform2f(H),u_dem_scale_prev:new t.Uniform1f(H),u_dem_size:new t.Uniform1f(H),u_dem_lerp:new t.Uniform1f(H),u_exaggeration:new t.Uniform1f(H),u_depth:new t.Uniform1i(H),u_depth_size_inv:new t.Uniform2f(H),u_meter_to_dem:new t.Uniform1f(H),u_label_plane_matrix_inv:new t.UniformMatrix4f(H)}))(o)),D.includes("GLOBE")&&(this.globeUniforms=(H=>({u_tile_tl_up:new t.Uniform3f(H),u_tile_tr_up:new t.Uniform3f(H),u_tile_br_up:new t.Uniform3f(H),u_tile_bl_up:new t.Uniform3f(H),u_tile_up_scale:new t.Uniform1f(H)}))(o)),D.includes("FOG")&&(this.fogUniforms=(H=>({u_fog_matrix:new t.UniformMatrix4f(H),u_fog_range:new t.Uniform2f(H),u_fog_color:new t.Uniform4f(H),u_fog_horizon_blend:new t.Uniform1f(H),u_fog_temporal_offset:new t.Uniform1f(H),u_frustum_tl:new t.Uniform3f(H),u_frustum_tr:new t.Uniform3f(H),u_frustum_br:new t.Uniform3f(H),u_frustum_bl:new t.Uniform3f(H),u_globe_pos:new t.Uniform3f(H),u_globe_radius:new t.Uniform1f(H),u_globe_transition:new t.Uniform1f(H),u_is_globe:new t.Uniform1i(H),u_viewport:new t.Uniform2f(H)}))(o))}}setTerrainUniformValues(o,d){if(!this.terrainUniforms)return;const v=this.terrainUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const T in d)v[T]&&v[T].set(this.program,T,d[T])}}setGlobeUniformValues(o,d){if(!this.globeUniforms)return;const v=this.globeUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const T in d)v[T]&&v[T].set(this.program,T,d[T])}}setFogUniformValues(o,d){if(!this.fogUniforms)return;const v=this.fogUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const T in d)v[T].set(this.program,T,d[T])}}draw(o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue,le){const fe=o.gl;if(this.failedToCreate)return;o.program.set(this.program),o.setDepthMode(v),o.setStencilMode(T),o.setColorMode(S),o.setCullFace(D);for(const oe of Object.keys(this.fixedUniforms))this.fixedUniforms[oe].set(this.program,oe,z[oe]);ue&&ue.setUniforms(this.program,o,this.binderUniforms,ie,{zoom:se});const H={[fe.LINES]:2,[fe.TRIANGLES]:3,[fe.LINE_STRIP]:1}[d];for(const oe of Y.get()){const ge=oe.vaos||(oe.vaos={});(ge[N]||(ge[N]=new ih)).bind(o,this,q,ue?ue.getPaintVertexBuffers():[],G,oe.vertexOffset,le||[]),fe.drawElements(d,oe.primitiveLength*H,fe.UNSIGNED_SHORT,oe.primitiveOffset*H*2)}}}function gs(_,o){const d=Math.pow(2,o.tileID.overscaledZ),v=o.tileSize*Math.pow(2,_.transform.tileZoom)/d,T=v*(o.tileID.canonical.x+o.tileID.wrap*d),S=v*o.tileID.canonical.y;return{u_image:0,u_texsize:o.imageAtlasTexture.size,u_tile_units_to_pixels:1/Bt(o,1,_.transform.tileZoom),u_pixel_coord_upper:[T>>16,S>>16],u_pixel_coord_lower:[65535&T,65535&S]}}const Vu=t.create(),Ul=(_,o,d,v,T,S,D,z,N,q,G)=>{const Y=o.style.light,ie=Y.properties.get("position"),se=[ie.x,ie.y,ie.z],ue=t.create$1();Y.properties.get("anchor")==="viewport"&&(t.fromRotation(ue,-o.transform.angle),t.transformMat3(se,se,ue));const le=Y.properties.get("color"),fe=o.transform,H={u_matrix:_,u_lightpos:se,u_lightintensity:Y.properties.get("intensity"),u_lightcolor:[le.r,le.g,le.b],u_vertical_gradient:+d,u_opacity:v,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Vu,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:T,u_edge_radius:S};return fe.projection.name==="globe"&&(H.u_tile_id=[D.canonical.x,D.canonical.y,1<{const ie=Ul(_,o,d,v,T,S,D,N,q,G,Y),se={u_height_factor:-Math.pow(2,D.overscaledZ)/z.tileSize/8};return t.extend(ie,gs(o,z),se)},_s=_=>({u_matrix:_}),jl=(_,o,d)=>t.extend(_s(_),gs(o,d)),rh=(_,o)=>({u_matrix:_,u_world:o}),oh=(_,o,d,v)=>t.extend(jl(_,o,d),{u_world:v}),sh=t.create(),Ya=(_,o,d,v,T,S)=>{const D=_.transform,z=D.projection.name==="globe";let N;if(S.paint.get("circle-pitch-alignment")==="map")if(z){const G=t.globePixelsToTileUnits(D.zoom,o.canonical)*D._pixelsPerMercatorPixel;N=Float32Array.from([G,0,0,G])}else N=D.calculatePixelsToTileUnitsMatrix(d);else N=new Float32Array([D.pixelsToGLUnits[0],0,0,D.pixelsToGLUnits[1]]);const q={u_camera_to_center_distance:D.cameraToCenterDistance,u_matrix:_.translatePosMatrix(o.projMatrix,d,S.paint.get("circle-translate"),S.paint.get("circle-translate-anchor")),u_device_pixel_ratio:t.exported.devicePixelRatio,u_extrude_scale:N,u_inv_rot_matrix:sh,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(z){q.u_inv_rot_matrix=v,q.u_merc_center=T,q.u_tile_id=[o.canonical.x,o.canonical.y,1<{const o=[];return _.paint.get("circle-pitch-alignment")==="map"&&o.push("PITCH_WITH_MAP"),_.paint.get("circle-pitch-scale")==="map"&&o.push("SCALE_WITH_MAP"),o},Ha=(_,o,d,v)=>{const T=t.EXTENT/d.tileSize;return{u_matrix:_,u_camera_to_center_distance:o.getCameraToCenterDistance(v),u_extrude_scale:[o.pixelsToGLUnits[0]/T,o.pixelsToGLUnits[1]/T]}},Ka=(_,o,d=1)=>({u_matrix:_,u_color:o,u_overlay:0,u_overlay_scale:d}),ju=t.create(),Gu=(_,o,d,v,T,S,D)=>{const z=_.transform,N=z.projection.name==="globe",q=N?t.globePixelsToTileUnits(z.zoom,o.canonical)*z._pixelsPerMercatorPixel:Bt(d,1,S),G={u_matrix:o.projMatrix,u_extrude_scale:q,u_intensity:D,u_inv_rot_matrix:ju,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(N){G.u_inv_rot_matrix=v,G.u_merc_center=T,G.u_tile_id=[o.canonical.x,o.canonical.y,1<{const z=_.transform,N=z.calculatePixelsToTileUnitsMatrix(o);return{u_matrix:ql(_,o,d,v),u_pixels_to_tile_units:N,u_device_pixel_ratio:S,u_units_to_pixels:[1/z.pixelsToGLUnits[0],1/z.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:T,u_texsize:Vs(d)?o.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Fs(o,_.transform),u_alpha_discard_threshold:0,u_trim_offset:D}},ya=(_,o,d,v,T)=>{const S=_.transform;return{u_matrix:ql(_,o,d,v),u_texsize:o.imageAtlasTexture.size,u_pixels_to_tile_units:S.calculatePixelsToTileUnitsMatrix(o),u_device_pixel_ratio:T,u_image:0,u_tile_units_to_pixels:Fs(o,S),u_units_to_pixels:[1/S.pixelsToGLUnits[0],1/S.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Fs(_,o){return 1/Bt(_,1,o.tileZoom)}function ql(_,o,d,v){return _.translatePosMatrix(v||o.tileID.projMatrix,o,d.paint.get("line-translate"),d.paint.get("line-translate-anchor"))}function Vs(_){const o=_.paint.get("line-dasharray").value;return o.value||o.kind!=="constant"}const Ja=(_,o,d,v,T,S)=>{return{u_matrix:_,u_tl_parent:o,u_scale_parent:d,u_fade_t:v.mix,u_opacity:v.opacity*T.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:T.paint.get("raster-brightness-min"),u_brightness_high:T.paint.get("raster-brightness-max"),u_saturation_factor:(z=T.paint.get("raster-saturation"),z>0?1-1/(1.001-z):-z),u_contrast_factor:(D=T.paint.get("raster-contrast"),D>0?1/(1-D):1+D),u_spin_weights:_o(T.paint.get("raster-hue-rotate")),u_perspective_transform:S};var D,z};function _o(_){_*=Math.PI/180;const o=Math.sin(_),d=Math.cos(_);return[(2*d+1)/3,(-Math.sqrt(3)*o-d+1)/3,(Math.sqrt(3)*o-d+1)/3]}const Qa=t.create(),el=(_,o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue,le)=>{const fe=T.transform,H={u_is_size_zoom_constant:+(_==="constant"||_==="source"),u_is_size_feature_constant:+(_==="constant"||_==="camera"),u_size_t:o?o.uSizeT:0,u_size:o?o.uSize:0,u_camera_to_center_distance:fe.cameraToCenterDistance,u_rotate_symbol:+d,u_aspect_ratio:fe.width/fe.height,u_fade_change:T.options.fadeDuration?T.symbolFadeChange:1,u_matrix:S,u_label_plane_matrix:D,u_coord_matrix:z,u_is_text:+N,u_pitch_with_map:+v,u_texsize:q,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Qa,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Qa,u_up_vector:[0,-1,0]};return le.name==="globe"&&(H.u_tile_id=[G.canonical.x,G.canonical.y,1<t.extend(el(_,o,d,v,T,S,D,z,N,q,Y,ie,se,ue,le,fe),{u_gamma_scale:v?T.transform.cameraToCenterDistance*Math.cos(T.terrain?0:T.transform._pitch):1,u_device_pixel_ratio:t.exported.devicePixelRatio,u_is_halo:+G}),qu=(_,o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue,le)=>t.extend(Us(_,o,d,v,T,S,D,z,!0,N,!0,G,Y,ie,se,ue,le),{u_texsize_icon:q,u_texture_icon:1}),tl=(_,o,d)=>({u_matrix:_,u_opacity:o,u_color:d}),Zu=(_,o,d,v,T)=>t.extend(function(S,D,z){const N=D.imageManager.getPattern(S.toString()),{width:q,height:G}=D.imageManager.getPixelSize(),Y=Math.pow(2,z.tileID.overscaledZ),ie=z.tileSize*Math.pow(2,D.transform.tileZoom)/Y,se=ie*(z.tileID.canonical.x+z.tileID.wrap*Y),ue=ie*z.tileID.canonical.y;return{u_image:0,u_pattern_tl:N.tl,u_pattern_br:N.br,u_texsize:[q,G],u_pattern_size:N.displaySize,u_tile_units_to_pixels:1/Bt(z,1,D.transform.tileZoom),u_pixel_coord_upper:[se>>16,ue>>16],u_pixel_coord_lower:[65535&se,65535&ue]}}(v,d,T),{u_matrix:_,u_opacity:o}),Zl={fillExtrusion:_=>({u_matrix:new t.UniformMatrix4f(_),u_lightpos:new t.Uniform3f(_),u_lightintensity:new t.Uniform1f(_),u_lightcolor:new t.Uniform3f(_),u_vertical_gradient:new t.Uniform1f(_),u_opacity:new t.Uniform1f(_),u_edge_radius:new t.Uniform1f(_),u_ao:new t.Uniform2f(_),u_tile_id:new t.Uniform3f(_),u_zoom_transition:new t.Uniform1f(_),u_inv_rot_matrix:new t.UniformMatrix4f(_),u_merc_center:new t.Uniform2f(_),u_up_dir:new t.Uniform3f(_),u_height_lift:new t.Uniform1f(_)}),fillExtrusionPattern:_=>({u_matrix:new t.UniformMatrix4f(_),u_lightpos:new t.Uniform3f(_),u_lightintensity:new t.Uniform1f(_),u_lightcolor:new t.Uniform3f(_),u_vertical_gradient:new t.Uniform1f(_),u_height_factor:new t.Uniform1f(_),u_edge_radius:new t.Uniform1f(_),u_ao:new t.Uniform2f(_),u_tile_id:new t.Uniform3f(_),u_zoom_transition:new t.Uniform1f(_),u_inv_rot_matrix:new t.UniformMatrix4f(_),u_merc_center:new t.Uniform2f(_),u_up_dir:new t.Uniform3f(_),u_height_lift:new t.Uniform1f(_),u_image:new t.Uniform1i(_),u_texsize:new t.Uniform2f(_),u_pixel_coord_upper:new t.Uniform2f(_),u_pixel_coord_lower:new t.Uniform2f(_),u_tile_units_to_pixels:new t.Uniform1f(_),u_opacity:new t.Uniform1f(_)}),fill:_=>({u_matrix:new t.UniformMatrix4f(_)}),fillPattern:_=>({u_matrix:new t.UniformMatrix4f(_),u_image:new t.Uniform1i(_),u_texsize:new t.Uniform2f(_),u_pixel_coord_upper:new t.Uniform2f(_),u_pixel_coord_lower:new t.Uniform2f(_),u_tile_units_to_pixels:new t.Uniform1f(_)}),fillOutline:_=>({u_matrix:new t.UniformMatrix4f(_),u_world:new t.Uniform2f(_)}),fillOutlinePattern:_=>({u_matrix:new t.UniformMatrix4f(_),u_world:new t.Uniform2f(_),u_image:new t.Uniform1i(_),u_texsize:new t.Uniform2f(_),u_pixel_coord_upper:new t.Uniform2f(_),u_pixel_coord_lower:new t.Uniform2f(_),u_tile_units_to_pixels:new t.Uniform1f(_)}),circle:_=>({u_camera_to_center_distance:new t.Uniform1f(_),u_extrude_scale:new t.UniformMatrix2f(_),u_device_pixel_ratio:new t.Uniform1f(_),u_matrix:new t.UniformMatrix4f(_),u_inv_rot_matrix:new t.UniformMatrix4f(_),u_merc_center:new t.Uniform2f(_),u_tile_id:new t.Uniform3f(_),u_zoom_transition:new t.Uniform1f(_),u_up_dir:new t.Uniform3f(_)}),collisionBox:_=>({u_matrix:new t.UniformMatrix4f(_),u_camera_to_center_distance:new t.Uniform1f(_),u_extrude_scale:new t.Uniform2f(_)}),collisionCircle:_=>({u_matrix:new t.UniformMatrix4f(_),u_inv_matrix:new t.UniformMatrix4f(_),u_camera_to_center_distance:new t.Uniform1f(_),u_viewport_size:new t.Uniform2f(_)}),debug:_=>({u_color:new t.UniformColor(_),u_matrix:new t.UniformMatrix4f(_),u_overlay:new t.Uniform1i(_),u_overlay_scale:new t.Uniform1f(_)}),clippingMask:_=>({u_matrix:new t.UniformMatrix4f(_)}),heatmap:_=>({u_extrude_scale:new t.Uniform1f(_),u_intensity:new t.Uniform1f(_),u_matrix:new t.UniformMatrix4f(_),u_inv_rot_matrix:new t.UniformMatrix4f(_),u_merc_center:new t.Uniform2f(_),u_tile_id:new t.Uniform3f(_),u_zoom_transition:new t.Uniform1f(_),u_up_dir:new t.Uniform3f(_)}),heatmapTexture:_=>({u_image:new t.Uniform1i(_),u_color_ramp:new t.Uniform1i(_),u_opacity:new t.Uniform1f(_)}),hillshade:_=>({u_matrix:new t.UniformMatrix4f(_),u_image:new t.Uniform1i(_),u_latrange:new t.Uniform2f(_),u_light:new t.Uniform2f(_),u_shadow:new t.UniformColor(_),u_highlight:new t.UniformColor(_),u_accent:new t.UniformColor(_)}),hillshadePrepare:_=>({u_matrix:new t.UniformMatrix4f(_),u_image:new t.Uniform1i(_),u_dimension:new t.Uniform2f(_),u_zoom:new t.Uniform1f(_),u_unpack:new t.Uniform4f(_)}),line:_=>({u_matrix:new t.UniformMatrix4f(_),u_pixels_to_tile_units:new t.UniformMatrix2f(_),u_device_pixel_ratio:new t.Uniform1f(_),u_units_to_pixels:new t.Uniform2f(_),u_dash_image:new t.Uniform1i(_),u_gradient_image:new t.Uniform1i(_),u_image_height:new t.Uniform1f(_),u_texsize:new t.Uniform2f(_),u_tile_units_to_pixels:new t.Uniform1f(_),u_alpha_discard_threshold:new t.Uniform1f(_),u_trim_offset:new t.Uniform2f(_)}),linePattern:_=>({u_matrix:new t.UniformMatrix4f(_),u_texsize:new t.Uniform2f(_),u_pixels_to_tile_units:new t.UniformMatrix2f(_),u_device_pixel_ratio:new t.Uniform1f(_),u_image:new t.Uniform1i(_),u_units_to_pixels:new t.Uniform2f(_),u_tile_units_to_pixels:new t.Uniform1f(_),u_alpha_discard_threshold:new t.Uniform1f(_)}),raster:_=>({u_matrix:new t.UniformMatrix4f(_),u_tl_parent:new t.Uniform2f(_),u_scale_parent:new t.Uniform1f(_),u_fade_t:new t.Uniform1f(_),u_opacity:new t.Uniform1f(_),u_image0:new t.Uniform1i(_),u_image1:new t.Uniform1i(_),u_brightness_low:new t.Uniform1f(_),u_brightness_high:new t.Uniform1f(_),u_saturation_factor:new t.Uniform1f(_),u_contrast_factor:new t.Uniform1f(_),u_spin_weights:new t.Uniform3f(_),u_perspective_transform:new t.Uniform2f(_)}),symbolIcon:_=>({u_is_size_zoom_constant:new t.Uniform1i(_),u_is_size_feature_constant:new t.Uniform1i(_),u_size_t:new t.Uniform1f(_),u_size:new t.Uniform1f(_),u_camera_to_center_distance:new t.Uniform1f(_),u_rotate_symbol:new t.Uniform1i(_),u_aspect_ratio:new t.Uniform1f(_),u_fade_change:new t.Uniform1f(_),u_matrix:new t.UniformMatrix4f(_),u_label_plane_matrix:new t.UniformMatrix4f(_),u_coord_matrix:new t.UniformMatrix4f(_),u_is_text:new t.Uniform1i(_),u_pitch_with_map:new t.Uniform1i(_),u_texsize:new t.Uniform2f(_),u_tile_id:new t.Uniform3f(_),u_zoom_transition:new t.Uniform1f(_),u_inv_rot_matrix:new t.UniformMatrix4f(_),u_merc_center:new t.Uniform2f(_),u_camera_forward:new t.Uniform3f(_),u_tile_matrix:new t.UniformMatrix4f(_),u_up_vector:new t.Uniform3f(_),u_ecef_origin:new t.Uniform3f(_),u_texture:new t.Uniform1i(_)}),symbolSDF:_=>({u_is_size_zoom_constant:new t.Uniform1i(_),u_is_size_feature_constant:new t.Uniform1i(_),u_size_t:new t.Uniform1f(_),u_size:new t.Uniform1f(_),u_camera_to_center_distance:new t.Uniform1f(_),u_rotate_symbol:new t.Uniform1i(_),u_aspect_ratio:new t.Uniform1f(_),u_fade_change:new t.Uniform1f(_),u_matrix:new t.UniformMatrix4f(_),u_label_plane_matrix:new t.UniformMatrix4f(_),u_coord_matrix:new t.UniformMatrix4f(_),u_is_text:new t.Uniform1i(_),u_pitch_with_map:new t.Uniform1i(_),u_texsize:new t.Uniform2f(_),u_texture:new t.Uniform1i(_),u_gamma_scale:new t.Uniform1f(_),u_device_pixel_ratio:new t.Uniform1f(_),u_tile_id:new t.Uniform3f(_),u_zoom_transition:new t.Uniform1f(_),u_inv_rot_matrix:new t.UniformMatrix4f(_),u_merc_center:new t.Uniform2f(_),u_camera_forward:new t.Uniform3f(_),u_tile_matrix:new t.UniformMatrix4f(_),u_up_vector:new t.Uniform3f(_),u_ecef_origin:new t.Uniform3f(_),u_is_halo:new t.Uniform1i(_)}),symbolTextAndIcon:_=>({u_is_size_zoom_constant:new t.Uniform1i(_),u_is_size_feature_constant:new t.Uniform1i(_),u_size_t:new t.Uniform1f(_),u_size:new t.Uniform1f(_),u_camera_to_center_distance:new t.Uniform1f(_),u_rotate_symbol:new t.Uniform1i(_),u_aspect_ratio:new t.Uniform1f(_),u_fade_change:new t.Uniform1f(_),u_matrix:new t.UniformMatrix4f(_),u_label_plane_matrix:new t.UniformMatrix4f(_),u_coord_matrix:new t.UniformMatrix4f(_),u_is_text:new t.Uniform1i(_),u_pitch_with_map:new t.Uniform1i(_),u_texsize:new t.Uniform2f(_),u_texsize_icon:new t.Uniform2f(_),u_texture:new t.Uniform1i(_),u_texture_icon:new t.Uniform1i(_),u_gamma_scale:new t.Uniform1f(_),u_device_pixel_ratio:new t.Uniform1f(_),u_is_halo:new t.Uniform1i(_)}),background:_=>({u_matrix:new t.UniformMatrix4f(_),u_opacity:new t.Uniform1f(_),u_color:new t.UniformColor(_)}),backgroundPattern:_=>({u_matrix:new t.UniformMatrix4f(_),u_opacity:new t.Uniform1f(_),u_image:new t.Uniform1i(_),u_pattern_tl:new t.Uniform2f(_),u_pattern_br:new t.Uniform2f(_),u_texsize:new t.Uniform2f(_),u_pattern_size:new t.Uniform2f(_),u_pixel_coord_upper:new t.Uniform2f(_),u_pixel_coord_lower:new t.Uniform2f(_),u_tile_units_to_pixels:new t.Uniform1f(_)}),terrainRaster:Vl,terrainDepth:Vl,skybox:_=>({u_matrix:new t.UniformMatrix4f(_),u_sun_direction:new t.Uniform3f(_),u_cubemap:new t.Uniform1i(_),u_opacity:new t.Uniform1f(_),u_temporal_offset:new t.Uniform1f(_)}),skyboxGradient:_=>({u_matrix:new t.UniformMatrix4f(_),u_color_ramp:new t.Uniform1i(_),u_center_direction:new t.Uniform3f(_),u_radius:new t.Uniform1f(_),u_opacity:new t.Uniform1f(_),u_temporal_offset:new t.Uniform1f(_)}),skyboxCapture:_=>({u_matrix_3f:new t.UniformMatrix3f(_),u_sun_direction:new t.Uniform3f(_),u_sun_intensity:new t.Uniform1f(_),u_color_tint_r:new t.Uniform4f(_),u_color_tint_m:new t.Uniform4f(_),u_luminance:new t.Uniform1f(_)}),globeRaster:_=>({u_proj_matrix:new t.UniformMatrix4f(_),u_globe_matrix:new t.UniformMatrix4f(_),u_normalize_matrix:new t.UniformMatrix4f(_),u_merc_matrix:new t.UniformMatrix4f(_),u_zoom_transition:new t.Uniform1f(_),u_merc_center:new t.Uniform2f(_),u_image0:new t.Uniform1i(_),u_grid_matrix:new t.UniformMatrix3f(_),u_skirt_height:new t.Uniform1f(_),u_frustum_tl:new t.Uniform3f(_),u_frustum_tr:new t.Uniform3f(_),u_frustum_br:new t.Uniform3f(_),u_frustum_bl:new t.Uniform3f(_),u_globe_pos:new t.Uniform3f(_),u_globe_radius:new t.Uniform1f(_),u_viewport:new t.Uniform2f(_)}),globeAtmosphere:_=>({u_frustum_tl:new t.Uniform3f(_),u_frustum_tr:new t.Uniform3f(_),u_frustum_br:new t.Uniform3f(_),u_frustum_bl:new t.Uniform3f(_),u_horizon:new t.Uniform1f(_),u_transition:new t.Uniform1f(_),u_fadeout_range:new t.Uniform1f(_),u_color:new t.Uniform4f(_),u_high_color:new t.Uniform4f(_),u_space_color:new t.Uniform4f(_),u_star_intensity:new t.Uniform1f(_),u_star_density:new t.Uniform1f(_),u_star_size:new t.Uniform1f(_),u_temporal_offset:new t.Uniform1f(_),u_horizon_angle:new t.Uniform1f(_),u_rotation_matrix:new t.UniformMatrix4f(_)})};let nl;function Mo(_,o,d,v,T,S,D){const z=_.context,N=z.gl,q=_.transform,G=_.useProgram("collisionBox"),Y=[];let ie=0,se=0;for(let _e=0;_e0){const qe=t.create(),ot=Oe;t.mul(qe,Pe.placementInvProjMatrix,q.glCoordMatrix),t.mul(qe,qe,Pe.placementViewportMatrix),Y.push({circleArray:pt,circleOffset:se,transform:ot,invTransform:qe,projection:Pe.getProjection()}),ie+=pt.length/4,se=ie}Xe&&(_.terrain&&_.terrain.setupElevationDraw(Re,G),G.draw(z,N.LINES,t.DepthMode.disabled,t.StencilMode.disabled,_.colorModeForRenderPass(),t.CullFaceMode.disabled,Ha(Oe,q,Re,Pe.getProjection()),d.id,Xe.layoutVertexBuffer,Xe.indexBuffer,Xe.segments,null,q.zoom,null,[Xe.collisionVertexBuffer,Xe.collisionVertexBufferExt]))}if(!D||!Y.length)return;const ue=_.useProgram("collisionCircle"),le=new t.StructArrayLayout2f1f2i16;le.resize(4*ie),le._trim();let fe=0;for(const _e of Y)for(let Ae=0;Ae<_e.circleArray.length/4;Ae++){const Re=4*Ae,Pe=_e.circleArray[Re+0],Be=_e.circleArray[Re+1],Oe=_e.circleArray[Re+2],Xe=_e.circleArray[Re+3];le.emplace(fe++,Pe,Be,Oe,Xe,0),le.emplace(fe++,Pe,Be,Oe,Xe,1),le.emplace(fe++,Pe,Be,Oe,Xe,2),le.emplace(fe++,Pe,Be,Oe,Xe,3)}(!nl||nl.length<2*ie)&&(nl=function(_e){const Ae=2*_e,Re=new t.StructArrayLayout3ui6;Re.resize(Ae),Re._trim();for(let Pe=0;Pe=0&&(ue[_e.associatedIconIndex]={x:qe,y:ot,z:He,angle:ct})}else ho(Pe,ie)}if(G){se.clear();const ge=_.icon.placedSymbolArray;for(let _e=0;_eqe.sortKey-ot.sortKey);for(const qe of Oe){const ot=qe.state;if(_.terrain&&_.terrain.setupElevationDraw(ot.tile,ot.program,{useDepthForOcclusion:!Be,labelPlaneMatrixInv:ot.labelPlaneMatrixInv}),ie.activeTexture.set(se.TEXTURE0),ot.atlasTexture.bind(ot.atlasInterpolation,se.CLAMP_TO_EDGE),ot.atlasTextureIcon&&(ie.activeTexture.set(se.TEXTURE1),ot.atlasTextureIcon&&ot.atlasTextureIcon.bind(ot.atlasInterpolationIcon,se.CLAMP_TO_EDGE)),ot.isSDF){const He=ot.uniformValues;ot.hasHalo&&(He.u_is_halo=1,c(ot.buffers,qe.segments,d,_,ot.program,Ae,G,Y,He)),He.u_is_halo=0}c(ot.buffers,qe.segments,d,_,ot.program,Ae,G,Y,ot.uniformValues)}}function c(_,o,d,v,T,S,D,z,N){const q=v.context,G=[_.dynamicLayoutVertexBuffer,_.opacityVertexBuffer,_.globeExtVertexBuffer];T.draw(q,q.gl.TRIANGLES,S,D,z,t.CullFaceMode.disabled,N,d.id,_.layoutVertexBuffer,_.indexBuffer,o,d.paint,v.transform.zoom,_.programConfigurations.get(d.id),G)}function p(_,o,d,v,T,S,D){const z=_.context.gl,N=d.paint.get("fill-pattern"),q=N&&N.constantOr(1);let G,Y,ie,se,ue;D?(Y=q&&!d.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",G=z.LINES):(Y=q?"fillPattern":"fill",G=z.TRIANGLES);for(const le of v){const fe=o.getTile(le);if(q&&!fe.patternsLoaded())continue;const H=fe.getBucket(d);if(!H)continue;_.prepareDrawTile();const oe=H.programConfigurations.get(d.id),ge=_.useProgram(Y,oe);q&&(_.context.activeTexture.set(z.TEXTURE0),fe.imageAtlasTexture.bind(z.LINEAR,z.CLAMP_TO_EDGE),oe.updatePaintBuffers());const _e=N.constantOr(null);if(_e&&fe.imageAtlas){const Re=fe.imageAtlas.patternPositions[_e.toString()];Re&&oe.setConstantPatternPositions(Re)}const Ae=_.translatePosMatrix(le.projMatrix,fe,d.paint.get("fill-translate"),d.paint.get("fill-translate-anchor"));if(D){se=H.indexBuffer2,ue=H.segments2;const Re=_.terrain&&_.terrain.renderingToTexture?_.terrain.drapeBufferSize:[z.drawingBufferWidth,z.drawingBufferHeight];ie=Y==="fillOutlinePattern"&&q?oh(Ae,_,fe,Re):rh(Ae,Re)}else se=H.indexBuffer,ue=H.segments,ie=q?jl(Ae,_,fe):_s(Ae);_.prepareDrawProgram(_.context,ge,le.toUnwrapped()),ge.draw(_.context,G,T,_.stencilModeForClipping(le),S,t.CullFaceMode.disabled,ie,d.id,H.layoutVertexBuffer,se,ue,d.paint,_.transform.zoom,oe)}}function g(_,o,d,v,T,S,D){const z=_.context,N=z.gl,q=_.transform,G=d.paint.get("fill-extrusion-pattern"),Y=G.constantOr(1),ie=d.paint.get("fill-extrusion-opacity"),se=[d.paint.get("fill-extrusion-ambient-occlusion-intensity"),d.paint.get("fill-extrusion-ambient-occlusion-radius")],ue=d.layout.get("fill-extrusion-edge-radius"),le=ue>0&&!d.paint.get("fill-extrusion-rounded-roof"),fe=le?0:ue,H=q.projection.name==="globe"?t.fillExtrusionHeightLift():0,oe=q.projection.name==="globe",ge=oe?t.globeToMercatorTransition(q.zoom):0,_e=[t.mercatorXfromLng(q.center.lng),t.mercatorYfromLat(q.center.lat)],Ae=[];oe&&Ae.push("PROJECTION_GLOBE_VIEW"),se[0]>0&&Ae.push("FAUX_AO"),le&&Ae.push("ZERO_ROOF_RADIUS");for(const Re of v){const Pe=o.getTile(Re),Be=Pe.getBucket(d);if(!Be||Be.projection.name!==q.projection.name)continue;const Oe=Be.programConfigurations.get(d.id),Xe=_.useProgram(Y?"fillExtrusionPattern":"fillExtrusion",Oe,Ae);if(_.terrain){const it=_.terrain;if(_.style.terrainSetForDrapingOnly())it.setupElevationDraw(Pe,Xe,{useMeterToDem:!0});else{if(!Be.enableTerrain)continue;if(it.setupElevationDraw(Pe,Xe,{useMeterToDem:!0}),w(z,o,Re,Be,d,it),!Be.centroidVertexBuffer){const yt=Xe.attributes.a_centroid_pos;yt!==void 0&&N.vertexAttrib2f(yt,0,0)}}}Y&&(_.context.activeTexture.set(N.TEXTURE0),Pe.imageAtlasTexture.bind(N.LINEAR,N.CLAMP_TO_EDGE),Oe.updatePaintBuffers());const pt=G.constantOr(null);if(pt&&Pe.imageAtlas){const it=Pe.imageAtlas.patternPositions[pt.toString()];it&&Oe.setConstantPatternPositions(it)}const qe=_.translatePosMatrix(Re.projMatrix,Pe,d.paint.get("fill-extrusion-translate"),d.paint.get("fill-extrusion-translate-anchor")),ot=q.projection.createInversionMatrix(q,Re.canonical),He=d.paint.get("fill-extrusion-vertical-gradient"),dt=Y?Uu(qe,_,He,ie,se,fe,Re,Pe,H,ge,_e,ot):Ul(qe,_,He,ie,se,fe,Re,H,ge,_e,ot);_.prepareDrawProgram(z,Xe,Re.toUnwrapped());const $e=[];_.terrain&&$e.push(Be.centroidVertexBuffer),oe&&$e.push(Be.layoutVertexExtBuffer),Xe.draw(z,z.gl.TRIANGLES,T,S,D,t.CullFaceMode.backCCW,dt,d.id,Be.layoutVertexBuffer,Be.indexBuffer,Be.segments,d.paint,_.transform.zoom,Oe,$e)}}function w(_,o,d,v,T,S){const D=[H=>{let oe=H.canonical.x-1,ge=H.wrap;return oe<0&&(oe=(1<{let oe=H.canonical.x+1,ge=H.wrap;return oe===1<new t.OverscaledTileID(H.overscaledZ,H.wrap,H.canonical.z,H.canonical.x,(H.canonical.y===0?1<new t.OverscaledTileID(H.overscaledZ,H.wrap,H.canonical.z,H.canonical.x,H.canonical.y===(1<{const oe=o.getSource().minzoom,ge=Ae=>{const Re=o.getTileByID(Ae);if(Re&&Re.hasData())return Re.getBucket(T)},_e=[0,-1,1];for(const Ae of _e){if(H.overscaledZ+Ae(N[0]=Math.min(H.min.y,oe.min.y),N[1]=Math.max(H.max.y,oe.max.y),N[2]=t.EXTENT-oe.min.x>H.max.x?oe.min.x-t.EXTENT:H.max.x,N),G=(H,oe)=>(N[0]=Math.min(H.min.x,oe.min.x),N[1]=Math.max(H.max.x,oe.max.x),N[2]=t.EXTENT-oe.min.y>H.max.y?oe.min.y-t.EXTENT:H.max.y,N),Y=[(H,oe)=>q(H,oe),(H,oe)=>q(oe,H),(H,oe)=>G(H,oe),(H,oe)=>G(oe,H)],ie=new t.Point(0,0);let se,ue,le;const fe=(H,oe,ge,_e,Ae)=>{const Re=[[_e?ge:H,_e?H:ge,0],[_e?ge:oe,_e?oe:ge,0]],Pe=Ae<0?t.EXTENT+Ae:Ae,Be=[_e?Pe:(H+oe)/2,_e?(H+oe)/2:Pe,0];return ge===0&&Ae<0||ge!==0&&Ae>0?S.getForTilePoints(le,[Be],!0,ue):Re.push(Be),S.getForTilePoints(d,Re,!0,se),Math.max(Re[0][2],Re[1][2],Be[2])/S.exaggeration()};for(let H=0;H<4;H++){const oe=(H<2?1:5)-H,ge=v.borders[H];if(ge.length===0)continue;const _e=le=D[H](d),Ae=z(_e);if(!(Ae&&Ae instanceof t.FillExtrusionBucket&&Ae.enableTerrain)||v.borderDoneWithNeighborZ[H]===Ae.canonical.z&&Ae.borderDoneWithNeighborZ[oe]===v.canonical.z||(ue=S.findDEMTileFor(_e),!ue||!ue.dem))continue;if(!se){const Oe=S.findDEMTileFor(d);if(!Oe||!Oe.dem)return;se=Oe}const Re=Ae.borders[oe];let Pe=0;const Be=Ae.borderDoneWithNeighborZ[oe]!==v.canonical.z;if(v.canonical.z===Ae.canonical.z){for(let Oe=0;Oept[0]+3));)Be&&Ae.encodeCentroid(void 0,qe,!1),Pe++;if(qe&&Pept[1]-3)&&(He++,++Pe!==Re.length);)qe=Ae.featuresOnBorder[Re[Pe]];if(qe=Ae.featuresOnBorder[Re[ot]],Xe.intersectsCount()>1||qe.intersectsCount()>1||He!==1){He!==1&&(Pe=ot),v.encodeCentroid(void 0,Xe,!1),Be&&Ae.encodeCentroid(void 0,qe,!1);continue}const dt=Y[H](Xe,qe),$e=H%2?t.EXTENT-1:0;ie.x=fe(dt[0],Math.min(t.EXTENT-1,dt[1]),$e,H<2,dt[2]),ie.y=0,v.encodeCentroid(ie,Xe,!1),Be&&Ae.encodeCentroid(ie,qe,!1)}else v.encodeCentroid(void 0,Xe,!1)}v.borderDoneWithNeighborZ[H]=Ae.canonical.z,v.needsCentroidUpdate=!0,Be&&(Ae.borderDoneWithNeighborZ[oe]=v.canonical.z,Ae.needsCentroidUpdate=!0)}else{for(const Oe of ge)v.encodeCentroid(void 0,v.featuresOnBorder[Oe],!1);if(Be){for(const Oe of Re)Ae.encodeCentroid(void 0,Ae.featuresOnBorder[Oe],!1);Ae.borderDoneWithNeighborZ[oe]=v.canonical.z,Ae.needsCentroidUpdate=!0}v.borderDoneWithNeighborZ[H]=Ae.canonical.z,v.needsCentroidUpdate=!0}}(v.needsCentroidUpdate||!v.centroidVertexBuffer&&v.centroidVertexArray.length!==0)&&v.uploadCentroid(_)}const L=new t.Color(1,0,0,1),V=new t.Color(0,1,0,1),X=new t.Color(0,0,1,1),Q=new t.Color(1,0,1,1),ae=new t.Color(0,1,1,1);function Le(_,o,d){const v=_.context,T=_.transform,S=v.gl,D=T.projection.name==="globe",z=D?["PROJECTION_GLOBE_VIEW"]:null;let N=d.projMatrix;if(D&&t.globeToMercatorTransition(T.zoom)>0){const Xe=t.transitionTileAABBinECEF(d.canonical,T),pt=t.globeDenormalizeECEF(Xe);N=t.multiply(new Float32Array(16),T.globeMatrix,pt),t.multiply(N,T.projMatrix,N)}const q=_.useProgram("debug",null,z),G=o.getTileByID(d.key);_.terrain&&_.terrain.setupElevationDraw(G,q);const Y=t.DepthMode.disabled,ie=t.StencilMode.disabled,se=_.colorModeForRenderPass(),ue="$debug";v.activeTexture.set(S.TEXTURE0),_.emptyTexture.bind(S.LINEAR,S.CLAMP_TO_EDGE),D?G._makeGlobeTileDebugBuffers(_.context,T):G._makeDebugTileBoundsBuffers(_.context,T.projection);const le=G._tileDebugBuffer||_.debugBuffer,fe=G._tileDebugIndexBuffer||_.debugIndexBuffer,H=G._tileDebugSegments||_.debugSegments;q.draw(v,S.LINE_STRIP,Y,ie,se,t.CullFaceMode.disabled,Ka(N,t.Color.red),ue,le,fe,H,null,null,null,[G._globeTileDebugBorderBuffer]);const oe=G.latestRawTileData,ge=Math.floor((oe&&oe.byteLength||0)/1024),_e=o.getTile(d).tileSize,Ae=512/Math.min(_e,512)*(d.overscaledZ/T.zoom)*.5;let Re=d.canonical.toString();d.overscaledZ!==d.canonical.z&&(Re+=` => ${d.overscaledZ}`),Re+=` ${ge}kb`,function(Xe,pt){Xe.initDebugOverlayCanvas();const qe=Xe.debugOverlayCanvas,ot=Xe.context.gl,He=Xe.debugOverlayCanvas.getContext("2d");He.clearRect(0,0,qe.width,qe.height),He.shadowColor="white",He.shadowBlur=2,He.lineWidth=1.5,He.strokeStyle="white",He.textBaseline="top",He.font="bold 36px Open Sans, sans-serif",He.fillText(pt,5,5),He.strokeText(pt,5,5),Xe.debugOverlayTexture.update(qe),Xe.debugOverlayTexture.bind(ot.LINEAR,ot.CLAMP_TO_EDGE)}(_,Re);const Pe=G._tileDebugTextBuffer||_.debugBuffer,Be=G._tileDebugTextIndexBuffer||_.quadTriangleIndexBuffer,Oe=G._tileDebugTextSegments||_.debugSegments;q.draw(v,S.TRIANGLES,Y,ie,t.ColorMode.alphaBlended,t.CullFaceMode.disabled,Ka(N,t.Color.transparent,Ae),ue,Pe,Be,Oe,null,null,null,[G._globeTileDebugTextBuffer])}function Ne(_,o,d,v){kt(_,0,o+d/2,_.transform.width,d,v)}function rt(_,o,d,v){kt(_,o-d/2,0,d,_.transform.height,v)}function kt(_,o,d,v,T,S){const D=_.context,z=D.gl;z.enable(z.SCISSOR_TEST),z.scissor(o*t.exported.devicePixelRatio,d*t.exported.devicePixelRatio,v*t.exported.devicePixelRatio,T*t.exported.devicePixelRatio),D.clear({color:S}),z.disable(z.SCISSOR_TEST)}const Ct=t.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Qt}=Ct;function Ht(_,o,d,v){_.emplaceBack(o,d,v)}class dn{constructor(o){this.vertexArray=new t.StructArrayLayout3f12,this.indices=new t.StructArrayLayout3ui6,Ht(this.vertexArray,-1,-1,1),Ht(this.vertexArray,1,-1,1),Ht(this.vertexArray,-1,1,1),Ht(this.vertexArray,1,1,1),Ht(this.vertexArray,-1,-1,-1),Ht(this.vertexArray,1,-1,-1),Ht(this.vertexArray,-1,1,-1),Ht(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=o.createVertexBuffer(this.vertexArray,Qt),this.indexBuffer=o.createIndexBuffer(this.indices),this.segment=t.SegmentVector.simpleSegment(0,0,36,12)}}function Rn(_,o,d,v,T,S){const D=_.gl,z=o.paint.get("sky-atmosphere-color"),N=o.paint.get("sky-atmosphere-halo-color"),q=o.paint.get("sky-atmosphere-sun-intensity"),G=((Y,ie,se,ue,le)=>({u_matrix_3f:Y,u_sun_direction:ie,u_sun_intensity:se,u_color_tint_r:[ue.r,ue.g,ue.b,ue.a],u_color_tint_m:[le.r,le.g,le.b,le.a],u_luminance:5e-5}))(t.fromMat4(t.create$1(),v),T,q,z,N);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+S,o.skyboxTexture,0),d.draw(_,D.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.frontCW,G,"skyboxCapture",o.skyboxGeometry.vertexBuffer,o.skyboxGeometry.indexBuffer,o.skyboxGeometry.segment)}const ui=t.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class lr{constructor(o){const d=new t.StructArrayLayout5f20;d.emplaceBack(-1,1,1,0,0),d.emplaceBack(1,1,1,1,0),d.emplaceBack(1,-1,1,1,1),d.emplaceBack(-1,-1,1,0,1);const v=new t.StructArrayLayout3ui6;v.emplaceBack(0,1,2),v.emplaceBack(2,3,0),this.vertexBuffer=o.createVertexBuffer(d,ui.members),this.indexBuffer=o.createIndexBuffer(v),this.segments=t.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Vi={symbol:function(_,o,d,v,T){if(_.renderPass!=="translucent")return;const S=t.StencilMode.disabled,D=_.colorModeForRenderPass();d.layout.get("text-variable-anchor")&&function(z,N,q,G,Y,ie,se){const ue=N.transform,le=Y==="map",fe=ie==="map";for(const H of z){const oe=G.getTile(H),ge=oe.getBucket(q);if(!ge||!ge.text||!ge.text.segments.get().length)continue;const _e=t.evaluateSizeForZoom(ge.textSizeData,ue.zoom),Ae=li(H,ge.getProjection(),ue),Re=ue.calculatePixelsToTileUnitsMatrix(oe),Pe=Qe(Ae,oe.tileID.canonical,fe,le,ue,ge.getProjection(),Re),Be=q.layout.get("icon-text-fit")!=="none"&&ge.hasIconData();if(_e){const Oe=Math.pow(2,ue.zoom-oe.tileID.overscaledZ);Hr(ge,le,fe,se,t.symbolSize,ue,Pe,H,Oe,_e,Be)}}}(v,_,d,o,d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),T),d.paint.get("icon-opacity").constantOr(1)!==0&&M(_,o,d,v,!1,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),d.layout.get("icon-rotation-alignment"),d.layout.get("icon-pitch-alignment"),d.layout.get("icon-keep-upright"),S,D),d.paint.get("text-opacity").constantOr(1)!==0&&M(_,o,d,v,!0,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),d.layout.get("text-rotation-alignment"),d.layout.get("text-pitch-alignment"),d.layout.get("text-keep-upright"),S,D),o.map.showCollisionBoxes&&(Mo(_,o,d,v,d.paint.get("text-translate"),d.paint.get("text-translate-anchor"),!0),Mo(_,o,d,v,d.paint.get("icon-translate"),d.paint.get("icon-translate-anchor"),!1))},circle:function(_,o,d,v){if(_.renderPass!=="translucent")return;const T=d.paint.get("circle-opacity"),S=d.paint.get("circle-stroke-width"),D=d.paint.get("circle-stroke-opacity"),z=d.layout.get("circle-sort-key").constantOr(1)!==void 0;if(T.constantOr(1)===0&&(S.constantOr(1)===0||D.constantOr(1)===0))return;const N=_.context,q=N.gl,G=_.transform,Y=_.depthModeForSublayer(0,t.DepthMode.ReadOnly),ie=t.StencilMode.disabled,se=_.colorModeForRenderPass(),ue=G.projection.name==="globe",le=[t.mercatorXfromLng(G.center.lng),t.mercatorYfromLat(G.center.lat)],fe=[];for(let oe=0;oeoe.sortKey-ge.sortKey);const H={useDepthForOcclusion:!ue};for(const oe of fe){const{programConfiguration:ge,program:_e,layoutVertexBuffer:Ae,globeExtVertexBuffer:Re,indexBuffer:Pe,uniformValues:Be,tile:Oe}=oe.state,Xe=oe.segments;_.terrain&&_.terrain.setupElevationDraw(Oe,_e,H),_.prepareDrawProgram(N,_e,Oe.tileID.toUnwrapped()),_e.draw(N,q.TRIANGLES,Y,ie,se,t.CullFaceMode.disabled,Be,d.id,Ae,Pe,Xe,d.paint,G.zoom,ge,[Re])}},heatmap:function(_,o,d,v){if(d.paint.get("heatmap-opacity")!==0)if(_.renderPass==="offscreen"){const T=_.context,S=T.gl,D=t.StencilMode.disabled,z=new t.ColorMode([S.ONE,S.ONE],t.Color.transparent,[!0,!0,!0,!0]);(function(se,ue,le,fe){const H=se.gl,oe=ue.width*fe,ge=ue.height*fe;se.activeTexture.set(H.TEXTURE1),se.viewport.set([0,0,oe,ge]);let _e=le.heatmapFbo;if(!_e||_e&&(_e.width!==oe||_e.height!==ge)){_e&&_e.destroy();const Ae=H.createTexture();H.bindTexture(H.TEXTURE_2D,Ae),H.texParameteri(H.TEXTURE_2D,H.TEXTURE_WRAP_S,H.CLAMP_TO_EDGE),H.texParameteri(H.TEXTURE_2D,H.TEXTURE_WRAP_T,H.CLAMP_TO_EDGE),H.texParameteri(H.TEXTURE_2D,H.TEXTURE_MIN_FILTER,H.LINEAR),H.texParameteri(H.TEXTURE_2D,H.TEXTURE_MAG_FILTER,H.LINEAR),_e=le.heatmapFbo=se.createFramebuffer(oe,ge,!1),function(Re,Pe,Be,Oe,Xe,pt){const qe=Re.gl;qe.texImage2D(qe.TEXTURE_2D,0,Re.isWebGL2&&Re.extRenderToTextureHalfFloat?qe.RGBA16F:qe.RGBA,Xe,pt,0,qe.RGBA,Re.extRenderToTextureHalfFloat?Re.isWebGL2?qe.HALF_FLOAT:Re.extTextureHalfFloat.HALF_FLOAT_OES:qe.UNSIGNED_BYTE,null),Oe.colorAttachment.set(Be)}(se,0,Ae,_e,oe,ge)}else H.bindTexture(H.TEXTURE_2D,_e.colorAttachment.get()),se.bindFramebuffer.set(_e.framebuffer)})(T,_,d,_.transform.projection.name==="globe"?.5:.25),T.clear({color:t.Color.transparent});const N=_.transform,q=N.projection.name==="globe",G=q?["PROJECTION_GLOBE_VIEW"]:null,Y=q?t.CullFaceMode.frontCCW:t.CullFaceMode.disabled,ie=[t.mercatorXfromLng(N.center.lng),t.mercatorYfromLat(N.center.lat)];for(let se=0;se({u_image:0,u_color_ramp:1,u_opacity:Y.paint.get("heatmap-opacity")}))(0,S),S.id,T.viewportBuffer,T.quadTriangleIndexBuffer,T.viewportSegments,S.paint,T.transform.zoom)}(_,d))},line:function(_,o,d,v){if(_.renderPass!=="translucent")return;const T=d.paint.get("line-opacity"),S=d.paint.get("line-width");if(T.constantOr(1)===0||S.constantOr(1)===0)return;const D=_.depthModeForSublayer(0,t.DepthMode.ReadOnly),z=_.colorModeForRenderPass(),N=_.terrain&&_.terrain.renderingToTexture?1:t.exported.devicePixelRatio,q=d.paint.get("line-dasharray"),G=q.constantOr(1),Y=d.layout.get("line-cap"),ie=d.paint.get("line-pattern"),se=ie.constantOr(1),ue=d.paint.get("line-gradient"),le=se?"linePattern":"line",fe=_.context,H=fe.gl,oe=(_e=>{const Ae=[];Vs(_e)&&Ae.push("RENDER_LINE_DASH"),_e.paint.get("line-gradient")&&Ae.push("RENDER_LINE_GRADIENT");const Re=_e.paint.get("line-trim-offset");Re[0]===0&&Re[1]===0||Ae.push("RENDER_LINE_TRIM_OFFSET");const Pe=_e.paint.get("line-pattern").constantOr(1),Be=_e.paint.get("line-opacity").constantOr(1)!==1;return!Pe&&Be&&Ae.push("RENDER_LINE_ALPHA_DISCARD"),Ae})(d);let ge=oe.includes("RENDER_LINE_ALPHA_DISCARD");_.terrain&&_.terrain.clipOrMaskOverlapStencilType()&&(ge=!1);for(const _e of v){const Ae=o.getTile(_e);if(se&&!Ae.patternsLoaded())continue;const Re=Ae.getBucket(d);if(!Re)continue;_.prepareDrawTile();const Pe=Re.programConfigurations.get(d.id),Be=_.useProgram(le,Pe,oe),Oe=ie.constantOr(null);if(Oe&&Ae.imageAtlas){const it=Ae.imageAtlas.patternPositions[Oe.toString()];it&&Pe.setConstantPatternPositions(it)}const Xe=q.constantOr(null),pt=Y.constantOr(null);if(!se&&Xe&&pt&&Ae.lineAtlas){const it=Ae.lineAtlas.getDash(Xe,pt);it&&Pe.setConstantPatternPositions(it)}let[qe,ot]=d.paint.get("line-trim-offset");(pt==="round"||pt==="square")&&qe!==ot&&(qe===0&&(qe-=1),ot===1&&(ot+=1));const He=_.terrain?_e.projMatrix:null,dt=se?ya(_,Ae,d,He,N):ah(_,Ae,d,He,Re.lineClipsArray.length,N,[qe,ot]);if(ue){const it=Re.gradients[d.id];let yt=it.texture;if(d.gradientVersion!==it.version){let ct=256;if(d.stepInterpolant){const bt=o.getSource().maxzoom,$t=_e.canonical.z===bt?Math.ceil(1<<_.transform.maxZoom-_e.canonical.z):1;ct=t.clamp(t.nextPowerOfTwo(Re.maxLineLength/t.EXTENT*1024*$t),256,fe.maxTextureSize)}it.gradient=t.renderColorRamp({expression:d.gradientExpression(),evaluationKey:"lineProgress",resolution:ct,image:it.gradient||void 0,clips:Re.lineClipsArray}),it.texture?it.texture.update(it.gradient):it.texture=new t.Texture(fe,it.gradient,H.RGBA),it.version=d.gradientVersion,yt=it.texture}fe.activeTexture.set(H.TEXTURE1),yt.bind(d.stepInterpolant?H.NEAREST:H.LINEAR,H.CLAMP_TO_EDGE)}G&&(fe.activeTexture.set(H.TEXTURE0),Ae.lineAtlasTexture.bind(H.LINEAR,H.REPEAT),Pe.updatePaintBuffers()),se&&(fe.activeTexture.set(H.TEXTURE0),Ae.imageAtlasTexture.bind(H.LINEAR,H.CLAMP_TO_EDGE),Pe.updatePaintBuffers()),_.prepareDrawProgram(fe,Be,_e.toUnwrapped());const $e=it=>{Be.draw(fe,H.TRIANGLES,D,it,z,t.CullFaceMode.disabled,dt,d.id,Re.layoutVertexBuffer,Re.indexBuffer,Re.segments,d.paint,_.transform.zoom,Pe,[Re.layoutVertexBuffer2])};if(ge){const it=_.stencilModeForClipping(_e).ref;it===0&&_.terrain&&fe.clear({stencil:0});const yt={func:H.EQUAL,mask:255};dt.u_alpha_discard_threshold=.8,$e(new t.StencilMode(yt,it,255,H.KEEP,H.KEEP,H.INVERT)),dt.u_alpha_discard_threshold=0,$e(new t.StencilMode(yt,it,255,H.KEEP,H.KEEP,H.KEEP))}else $e(_.stencilModeForClipping(_e))}ge&&(_.resetStencilClippingMasks(),_.terrain&&fe.clear({stencil:0}))},fill:function(_,o,d,v){const T=d.paint.get("fill-color"),S=d.paint.get("fill-opacity");if(S.constantOr(1)===0)return;const D=_.colorModeForRenderPass(),z=d.paint.get("fill-pattern"),N=_.opaquePassEnabledForLayer()&&!z.constantOr(1)&&T.constantOr(t.Color.transparent).a===1&&S.constantOr(0)===1?"opaque":"translucent";if(_.renderPass===N){const q=_.depthModeForSublayer(1,_.renderPass==="opaque"?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly);p(_,o,d,v,q,D,!1)}if(_.renderPass==="translucent"&&d.paint.get("fill-antialias")){const q=_.depthModeForSublayer(d.getPaintProperty("fill-outline-color")?2:0,t.DepthMode.ReadOnly);p(_,o,d,v,q,D,!0)}},"fill-extrusion":function(_,o,d,v){const T=d.paint.get("fill-extrusion-opacity");if(T!==0&&_.renderPass==="translucent"){const S=new t.DepthMode(_.context.gl.LEQUAL,t.DepthMode.ReadWrite,_.depthRangeFor3D);if(T!==1||d.paint.get("fill-extrusion-pattern").constantOr(1))g(_,o,d,v,S,t.StencilMode.disabled,t.ColorMode.disabled),g(_,o,d,v,S,_.stencilModeFor3D(),_.colorModeForRenderPass()),_.resetStencilClippingMasks();else{const D=_.colorModeForRenderPass();g(_,o,d,v,S,t.StencilMode.disabled,D)}}},hillshade:function(_,o,d,v){if(_.renderPass!=="offscreen"&&_.renderPass!=="translucent")return;const T=_.context,S=_.depthModeForSublayer(0,t.DepthMode.ReadOnly),D=_.colorModeForRenderPass(),z=_.terrain&&_.terrain.renderingToTexture,[N,q]=_.renderPass!=="translucent"||z?[{},v]:_.stencilConfigForOverlap(v);for(const G of q){const Y=o.getTile(G);if(Y.needsHillshadePrepare&&_.renderPass==="offscreen")Lr(_,Y,d,S,t.StencilMode.disabled,D);else if(_.renderPass==="translucent"){const ie=z&&_.terrain?_.terrain.stencilModeForRTTOverlap(G):N[G.overscaledZ];Fu(_,G,Y,d,S,ie,D)}}T.viewport.set([0,0,_.width,_.height]),_.resetStencilClippingMasks()},raster:function(_,o,d,v,T,S){if(_.renderPass!=="translucent"||d.paint.get("raster-opacity")===0||!v.length)return;const D=_.context,z=D.gl,N=o.getSource(),q=_.useProgram("raster"),G=_.colorModeForRenderPass(),Y=_.terrain&&_.terrain.renderingToTexture,[ie,se]=N instanceof wn||Y?[{},v]:_.stencilConfigForOverlap(v),ue=se[se.length-1].overscaledZ,le=!_.options.moving;for(const fe of se){const H=Y?t.DepthMode.disabled:_.depthModeForSublayer(fe.overscaledZ-ue,d.paint.get("raster-opacity")===1?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly,z.LESS),oe=fe.toUnwrapped(),ge=o.getTile(fe);if(Y&&(!ge||!ge.hasData()))continue;const _e=Y?fe.projMatrix:_.transform.calculateProjMatrix(oe,le),Ae=_.terrain&&Y?_.terrain.stencilModeForRTTOverlap(fe):ie[fe.overscaledZ],Re=S?0:d.paint.get("raster-fade-duration");ge.registerFadeDuration(Re);const Pe=o.findLoadedParent(fe,0),Be=br(ge,Pe,o,_.transform,Re);let Oe,Xe;_.terrain&&_.terrain.prepareDrawTile();const pt=d.paint.get("raster-resampling")==="nearest"?z.NEAREST:z.LINEAR;D.activeTexture.set(z.TEXTURE0),ge.texture.bind(pt,z.CLAMP_TO_EDGE),D.activeTexture.set(z.TEXTURE1),Pe?(Pe.texture.bind(pt,z.CLAMP_TO_EDGE),Oe=Math.pow(2,Pe.tileID.overscaledZ-ge.tileID.overscaledZ),Xe=[ge.tileID.canonical.x*Oe%1,ge.tileID.canonical.y*Oe%1]):ge.texture.bind(pt,z.CLAMP_TO_EDGE),ge.texture.useMipmap&&D.extTextureFilterAnisotropic&&_.transform.pitch>20&&z.texParameterf(z.TEXTURE_2D,D.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,D.extTextureFilterAnisotropicMax);const qe=Ja(_e,Xe||[0,0],Oe||1,Be,d,N instanceof wn?N.perspectiveTransform:[0,0]);if(_.prepareDrawProgram(D,q,oe),N instanceof wn)N.boundsBuffer&&N.boundsSegments&&q.draw(D,z.TRIANGLES,H,t.StencilMode.disabled,G,t.CullFaceMode.disabled,qe,d.id,N.boundsBuffer,_.quadTriangleIndexBuffer,N.boundsSegments);else{const{tileBoundsBuffer:ot,tileBoundsIndexBuffer:He,tileBoundsSegments:dt}=_.getTileBoundsBuffers(ge);q.draw(D,z.TRIANGLES,H,Ae,G,t.CullFaceMode.disabled,qe,d.id,ot,He,dt)}}_.resetStencilClippingMasks()},background:function(_,o,d,v){const T=d.paint.get("background-color"),S=d.paint.get("background-opacity");if(S===0)return;const D=_.context,z=D.gl,N=_.transform,q=N.tileSize,G=d.paint.get("background-pattern");if(_.isPatternMissing(G))return;const Y=!G&&T.a===1&&S===1&&_.opaquePassEnabledForLayer()?"opaque":"translucent";if(_.renderPass!==Y)return;const ie=t.StencilMode.disabled,se=_.depthModeForSublayer(0,Y==="opaque"?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly),ue=_.colorModeForRenderPass(),le=_.useProgram(G?"backgroundPattern":"background");let fe,H=v;H||(fe=_.getBackgroundTiles(),H=Object.values(fe).map(oe=>oe.tileID)),G&&(D.activeTexture.set(z.TEXTURE0),_.imageManager.bind(_.context));for(const oe of H){const ge=oe.toUnwrapped(),_e=v?oe.projMatrix:_.transform.calculateProjMatrix(ge);_.prepareDrawTile();const Ae=o?o.getTile(oe):fe?fe[oe.key]:new t.Tile(oe,q,N.zoom,_),Re=G?Zu(_e,S,_,G,{tileID:oe,tileSize:q}):tl(_e,S,T);_.prepareDrawProgram(D,le,ge);const{tileBoundsBuffer:Pe,tileBoundsIndexBuffer:Be,tileBoundsSegments:Oe}=_.getTileBoundsBuffers(Ae);le.draw(D,z.TRIANGLES,se,ie,ue,t.CullFaceMode.disabled,Re,d.id,Pe,Be,Oe)}},sky:function(_,o,d){const v=_.transform,T=v.projection.name==="mercator"||v.projection.name==="globe"?1:t.smoothstep(7,8,v.zoom),S=d.paint.get("sky-opacity")*T;if(S===0)return;const D=_.context,z=d.paint.get("sky-type"),N=new t.DepthMode(D.gl.LEQUAL,t.DepthMode.ReadOnly,[0,1]),q=_.frameCounter/1e3%1;z==="atmosphere"?_.renderPass==="offscreen"?d.needsSkyboxCapture(_)&&(function(G,Y,ie,se){const ue=G.context,le=ue.gl;let fe=Y.skyboxFbo;if(!fe){fe=Y.skyboxFbo=ue.createFramebuffer(32,32,!1),Y.skyboxGeometry=new dn(ue),Y.skyboxTexture=ue.gl.createTexture(),le.bindTexture(le.TEXTURE_CUBE_MAP,Y.skyboxTexture),le.texParameteri(le.TEXTURE_CUBE_MAP,le.TEXTURE_WRAP_S,le.CLAMP_TO_EDGE),le.texParameteri(le.TEXTURE_CUBE_MAP,le.TEXTURE_WRAP_T,le.CLAMP_TO_EDGE),le.texParameteri(le.TEXTURE_CUBE_MAP,le.TEXTURE_MIN_FILTER,le.LINEAR),le.texParameteri(le.TEXTURE_CUBE_MAP,le.TEXTURE_MAG_FILTER,le.LINEAR);for(let _e=0;_e<6;++_e)le.texImage2D(le.TEXTURE_CUBE_MAP_POSITIVE_X+_e,0,le.RGBA,32,32,0,le.RGBA,le.UNSIGNED_BYTE,null)}ue.bindFramebuffer.set(fe.framebuffer),ue.viewport.set([0,0,32,32]);const H=Y.getCenter(G,!0),oe=G.useProgram("skyboxCapture"),ge=new Float64Array(16);t.identity(ge),t.rotateY(ge,ge,.5*-Math.PI),Rn(ue,Y,oe,ge,H,0),t.identity(ge),t.rotateY(ge,ge,.5*Math.PI),Rn(ue,Y,oe,ge,H,1),t.identity(ge),t.rotateX(ge,ge,.5*-Math.PI),Rn(ue,Y,oe,ge,H,2),t.identity(ge),t.rotateX(ge,ge,.5*Math.PI),Rn(ue,Y,oe,ge,H,3),t.identity(ge),Rn(ue,Y,oe,ge,H,4),t.identity(ge),t.rotateY(ge,ge,Math.PI),Rn(ue,Y,oe,ge,H,5),ue.viewport.set([0,0,G.width,G.height])}(_,d),d.markSkyboxValid(_)):_.renderPass==="sky"&&function(G,Y,ie,se,ue){const le=G.context,fe=le.gl,H=G.transform,oe=G.useProgram("skybox");le.activeTexture.set(fe.TEXTURE0),fe.bindTexture(fe.TEXTURE_CUBE_MAP,Y.skyboxTexture);const ge=((_e,Ae,Re,Pe,Be)=>({u_matrix:_e,u_sun_direction:Ae,u_cubemap:0,u_opacity:Pe,u_temporal_offset:Be}))(H.skyboxMatrix,Y.getCenter(G,!1),0,se,ue);G.prepareDrawProgram(le,oe),oe.draw(le,fe.TRIANGLES,ie,t.StencilMode.disabled,G.colorModeForRenderPass(),t.CullFaceMode.backCW,ge,"skybox",Y.skyboxGeometry.vertexBuffer,Y.skyboxGeometry.indexBuffer,Y.skyboxGeometry.segment)}(_,d,N,S,q):z==="gradient"&&_.renderPass==="sky"&&function(G,Y,ie,se,ue){const le=G.context,fe=le.gl,H=G.transform,oe=G.useProgram("skyboxGradient");Y.skyboxGeometry||(Y.skyboxGeometry=new dn(le)),le.activeTexture.set(fe.TEXTURE0);let ge=Y.colorRampTexture;ge||(ge=Y.colorRampTexture=new t.Texture(le,Y.colorRamp,fe.RGBA)),ge.bind(fe.LINEAR,fe.CLAMP_TO_EDGE);const _e=((Ae,Re,Pe,Be,Oe)=>({u_matrix:Ae,u_color_ramp:0,u_center_direction:Re,u_radius:t.degToRad(Pe),u_opacity:Be,u_temporal_offset:Oe}))(H.skyboxMatrix,Y.getCenter(G,!1),Y.paint.get("sky-gradient-radius"),se,ue);G.prepareDrawProgram(le,oe),oe.draw(le,fe.TRIANGLES,ie,t.StencilMode.disabled,G.colorModeForRenderPass(),t.CullFaceMode.backCW,_e,"skyboxGradient",Y.skyboxGeometry.vertexBuffer,Y.skyboxGeometry.indexBuffer,Y.skyboxGeometry.segment)}(_,d,N,S,q)},debug:function(_,o,d){for(let v=0;vT)return void(this.transform.fogCullDistSq=null);const S=v+.78*(T-v);this.transform.fogCullDistSq=S*S}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(o,d){if(this.width=o*t.exported.devicePixelRatio,this.height=d*t.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const v of this.style.order)this.style._layers[v].resize()}setup(){const o=this.context,d=new t.StructArrayLayout2i4;d.emplaceBack(0,0),d.emplaceBack(t.EXTENT,0),d.emplaceBack(0,t.EXTENT),d.emplaceBack(t.EXTENT,t.EXTENT),this.tileExtentBuffer=o.createVertexBuffer(d,t.posAttributes.members),this.tileExtentSegments=t.SegmentVector.simpleSegment(0,0,4,2);const v=new t.StructArrayLayout2i4;v.emplaceBack(0,0),v.emplaceBack(t.EXTENT,0),v.emplaceBack(0,t.EXTENT),v.emplaceBack(t.EXTENT,t.EXTENT),this.debugBuffer=o.createVertexBuffer(v,t.posAttributes.members),this.debugSegments=t.SegmentVector.simpleSegment(0,0,4,5);const T=new t.StructArrayLayout2i4;T.emplaceBack(-1,-1),T.emplaceBack(1,-1),T.emplaceBack(-1,1),T.emplaceBack(1,1),this.viewportBuffer=o.createVertexBuffer(T,t.posAttributes.members),this.viewportSegments=t.SegmentVector.simpleSegment(0,0,4,2);const S=new t.StructArrayLayout4i8;S.emplaceBack(0,0,0,0),S.emplaceBack(t.EXTENT,0,t.EXTENT,0),S.emplaceBack(0,t.EXTENT,0,t.EXTENT),S.emplaceBack(t.EXTENT,t.EXTENT,t.EXTENT,t.EXTENT),this.mercatorBoundsBuffer=o.createVertexBuffer(S,t.boundsAttributes.members),this.mercatorBoundsSegments=t.SegmentVector.simpleSegment(0,0,4,2);const D=new t.StructArrayLayout3ui6;D.emplaceBack(0,1,2),D.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=o.createIndexBuffer(D);const z=new t.StructArrayLayout1ui2;for(const q of[0,1,3,2,0])z.emplaceBack(q);this.debugIndexBuffer=o.createIndexBuffer(z),this.emptyTexture=new t.Texture(o,new t.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),o.gl.RGBA),this.identityMat=t.create();const N=this.context.gl;this.stencilClearMode=new t.StencilMode({func:N.ALWAYS,mask:0},0,255,N.ZERO,N.ZERO,N.ZERO),this.loadTimeStamps.push(t.window.performance.now()),this.atmosphereBuffer=new lr(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(o){return o._makeTileBoundsBuffers(this.context,this.transform.projection),o._tileBoundsBuffer?{tileBoundsBuffer:o._tileBoundsBuffer,tileBoundsIndexBuffer:o._tileBoundsIndexBuffer,tileBoundsSegments:o._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const o=this.context,d=o.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(o,d.TRIANGLES,t.DepthMode.disabled,this.stencilClearMode,t.ColorMode.disabled,t.CullFaceMode.disabled,Bs(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(o,d,v){if(!d||this.currentStencilSource===d.id||!o.isTileClipped()||!v||v.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let z=!1;for(const N of v)if(this._tileClippingMaskIDs[N.key]===void 0){z=!0;break}if(!z)return}this.currentStencilSource=d.id;const T=this.context,S=T.gl;this.nextStencilID+v.length>256&&this.clearStencil(),T.setColorMode(t.ColorMode.disabled),T.setDepthMode(t.DepthMode.disabled);const D=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const z of v){const N=d.getTile(z),q=this._tileClippingMaskIDs[z.key]=this.nextStencilID++,{tileBoundsBuffer:G,tileBoundsIndexBuffer:Y,tileBoundsSegments:ie}=this.getTileBoundsBuffers(N);D.draw(T,S.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:S.ALWAYS,mask:0},q,255,S.KEEP,S.KEEP,S.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,Bs(z.projMatrix),"$clipping",G,Y,ie)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const o=this.nextStencilID++,d=this.context.gl;return new t.StencilMode({func:d.NOTEQUAL,mask:255},o,255,d.KEEP,d.KEEP,d.REPLACE)}stencilModeForClipping(o){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(o);const d=this.context.gl;return new t.StencilMode({func:d.EQUAL,mask:255},this._tileClippingMaskIDs[o.key],0,d.KEEP,d.KEEP,d.REPLACE)}stencilConfigForOverlap(o){const d=this.context.gl,v=o.sort((D,z)=>z.overscaledZ-D.overscaledZ),T=v[v.length-1].overscaledZ,S=v[0].overscaledZ-T+1;if(S>1){this.currentStencilSource=void 0,this.nextStencilID+S>256&&this.clearStencil();const D={};for(let z=0;z=0;this.currentLayer--){const q=this.style._layers[v[this.currentLayer]],G=o._getLayerSourceCache(q);if(q.isSky())continue;const Y=G?D[G.id]:void 0;this._renderTileClippingMasks(q,G,Y),this.renderLayer(this,G,q,Y)}if(this.style.fog&&this.transform.projection.supportsFog&&function(q,G){const Y=q.context,ie=Y.gl,se=q.transform,ue=new t.DepthMode(ie.LEQUAL,t.DepthMode.ReadOnly,[0,1]),le=q.useProgram("globeAtmosphere",null,se.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),fe=t.globeToMercatorTransition(se.zoom),H=G.properties.get("color").toArray01(),oe=G.properties.get("high-color").toArray01(),ge=G.properties.get("space-color").toArray01PremultipliedAlpha(),_e=t.identity$1([]);t.rotateY$1(_e,_e,-t.degToRad(se._center.lng)),t.rotateX$1(_e,_e,t.degToRad(se._center.lat)),t.rotateZ$1(_e,_e,se.angle),t.rotateX$1(_e,_e,-se._pitch);const Ae=t.fromQuat(new Float32Array(16),_e),Re=t.mapValue(G.properties.get("star-intensity"),0,1,0,.25),Pe=5e-4,Be=t.mapValue(G.properties.get("horizon-blend"),0,1,Pe,.25),Oe=t.globeUseCustomAntiAliasing(q,Y,se)&&Be===Pe?se.worldSize/(2*Math.PI*1.025)-1:se.globeRadius,Xe=q.frameCounter/1e3%1,pt=t.length(se.globeCenterInViewSpace),qe=Math.sqrt(Math.pow(pt,2)-Math.pow(Oe,2)),ot=Math.acos(qe/pt),He=(($e,it,yt,ct,bt,$t,un,Ut,Kt,An,Cn,qt,Yn,ei)=>({u_frustum_tl:$e,u_frustum_tr:it,u_frustum_br:yt,u_frustum_bl:ct,u_horizon:bt,u_transition:$t,u_fadeout_range:un,u_color:Ut,u_high_color:Kt,u_space_color:An,u_star_intensity:Cn,u_star_size:5*t.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:qt,u_horizon_angle:Yn,u_rotation_matrix:ei}))(se.frustumCorners.TL,se.frustumCorners.TR,se.frustumCorners.BR,se.frustumCorners.BL,se.frustumCorners.horizon,fe,Be,H,oe,ge,Re,Xe,ot,Ae);q.prepareDrawProgram(Y,le);const dt=q.atmosphereBuffer;dt&&le.draw(Y,ie.TRIANGLES,ue,t.StencilMode.disabled,t.ColorMode.alphaBlended,t.CullFaceMode.backCW,He,"skybox",dt.vertexBuffer,dt.indexBuffer,dt.segments)}(this,this.style.fog),this.renderPass="sky",(t.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const Y=o._getLayerSourceCache(G);Y&&!G.isHidden(this.transform.zoom)&&(!q||q.getSource().maxzoom0?d.pop():null}isPatternMissing(o){return o===null||o!==void 0&&!this.imageManager.getPattern(o.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const o=this.terrain&&this.terrain.renderingToTexture,d=this.terrain&&this.terrain.exaggeration()===0,v=this.style&&this.style.fog,T=[];return this.terrainRenderModeElevated()&&T.push("TERRAIN"),this.transform.projection.name==="globe"&&T.push("GLOBE"),d&&T.push("ZERO_EXAGGERATION"),v&&!o&&v.getOpacity(this.transform.pitch)!==0&&T.push("FOG"),o&&T.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&T.push("OVERDRAW_INSPECTOR"),T}useProgram(o,d,v){this.cache=this.cache||{};const T=v||[],S=this.currentGlobalDefines().concat(T),D=Nn.cacheKey(Bl[o],o,S,d);return this.cache[D]||(this.cache[D]=new Nn(this.context,o,Bl[o],d,Zl[o],S)),this.cache[D]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const o=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(o.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=t.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(o,d,v){if(this.terrain&&this.terrain.renderingToTexture)return;const T=this.style.fog;if(T){const S=T.getOpacity(this.transform.pitch),D=((z,N,q,G,Y,ie,se,ue,le,fe,H)=>{const oe=z.transform,ge=N.properties.get("color").toArray01();ge[3]=G;const _e=z.frameCounter/1e3%1;return{u_fog_matrix:q?oe.calculateFogTileMatrix(q):z.identityMat,u_fog_range:N.getFovAdjustedRange(oe._fov),u_fog_color:ge,u_fog_horizon_blend:N.properties.get("horizon-blend"),u_fog_temporal_offset:_e,u_frustum_tl:Y,u_frustum_tr:ie,u_frustum_br:se,u_frustum_bl:ue,u_globe_pos:le,u_globe_radius:fe,u_viewport:H,u_globe_transition:t.globeToMercatorTransition(oe.zoom),u_is_globe:+(oe.projection.name==="globe")}})(this,T,v,S,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*t.exported.devicePixelRatio,this.transform.height*t.exported.devicePixelRatio]);d.setFogUniformValues(o,D)}}setTileLoadedFlag(o){this.tileLoaded=o}saveCanvasCopy(){const o=this.canvasCopy();o&&(this.frameCopies.push(o),this.tileLoaded=!1)}canvasCopy(){const o=this.context.gl,d=o.createTexture();return o.bindTexture(o.TEXTURE_2D,d),o.copyTexImage2D(o.TEXTURE_2D,0,o.RGBA,0,0,o.drawingBufferWidth,o.drawingBufferHeight,0),d}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const o=this.style&&this.style.fog;return!!o&&o.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const o=this._backgroundTiles,d=this._backgroundTiles={},v=this.transform.coveringTiles({tileSize:512});for(const T of v)d[T.key]=o[T.key]||new t.Tile(T,512,this.transform.tileZoom,this);return d}clearBackgroundTiles(){this._backgroundTiles={}}}class Jr{constructor(o=0,d=0,v=0,T=0){if(isNaN(o)||o<0||isNaN(d)||d<0||isNaN(v)||v<0||isNaN(T)||T<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=o,this.bottom=d,this.left=v,this.right=T}interpolate(o,d,v){return d.top!=null&&o.top!=null&&(this.top=t.number(o.top,d.top,v)),d.bottom!=null&&o.bottom!=null&&(this.bottom=t.number(o.bottom,d.bottom,v)),d.left!=null&&o.left!=null&&(this.left=t.number(o.left,d.left,v)),d.right!=null&&o.right!=null&&(this.right=t.number(o.right,d.right,v)),this}getCenter(o,d){const v=t.clamp((this.left+o-this.right)/2,0,o),T=t.clamp((this.top+d-this.bottom)/2,0,d);return new t.Point(v,T)}equals(o){return this.top===o.top&&this.bottom===o.bottom&&this.left===o.left&&this.right===o.right}clone(){return new Jr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function So(_,o){const d=t.getColumn(_,3);t.fromQuat(_,o),t.setColumn(_,3,d)}function Dn(_,o){const d=t.identity$1([]);return t.rotateZ$1(d,d,-o),t.rotateX$1(d,d,-_),d}function Vo(_,o){const d=[_[0],_[1],0],v=[o[0],o[1],0];if(t.length(d)>=1e-15){const D=t.normalize([],d);t.scale$2(v,D,t.dot(v,D)),o[0]=v[0],o[1]=v[1]}const T=t.cross([],o,_);if(t.len(T)<1e-15)return null;const S=Math.atan2(-T[1],T[0]);return Dn(Math.atan2(Math.sqrt(_[0]*_[0]+_[1]*_[1]),-_[2]),S)}class ys{constructor(o,d){this.position=o,this.orientation=d}get position(){return this._position}set position(o){if(o){const d=o instanceof t.MercatorCoordinate?o:new t.MercatorCoordinate(o[0],o[1],o[2]);this._renderWorldCopies&&(d.x=t.wrap(d.x,0,1)),this._position=d}else this._position=null}lookAtPoint(o,d){if(this.orientation=null,!this.position)return;const v=this.position,T=this._elevation?this._elevation.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(o)):0,S=t.MercatorCoordinate.fromLngLat(o,T),D=[S.x-v.x,S.y-v.y,S.z-v.z];d||(d=[0,0,1]),d[2]=Math.abs(d[2]),this.orientation=Vo(D,d)}setPitchBearing(o,d){this.orientation=Dn(t.degToRad(o),t.degToRad(-d))}}class va{constructor(o,d){this._transform=t.identity([]),this.orientation=d,this.position=o}get mercatorPosition(){const o=this.position;return new t.MercatorCoordinate(o[0],o[1],o[2])}get position(){const o=t.getColumn(this._transform,3);return[o[0],o[1],o[2]]}set position(o){var d;o&&t.setColumn(this._transform,3,[(d=o)[0],d[1],d[2],1])}get orientation(){return this._orientation}set orientation(o){this._orientation=o||t.identity$1([]),o&&So(this._transform,this._orientation)}getPitchBearing(){const o=this.forward(),d=this.right();return{bearing:Math.atan2(-d[1],d[0]),pitch:Math.atan2(Math.sqrt(o[0]*o[0]+o[1]*o[1]),-o[2])}}setPitchBearing(o,d){this._orientation=Dn(o,d),So(this._transform,this._orientation)}forward(){const o=t.getColumn(this._transform,2);return[-o[0],-o[1],-o[2]]}up(){const o=t.getColumn(this._transform,1);return[-o[0],-o[1],-o[2]]}right(){const o=t.getColumn(this._transform,0);return[o[0],o[1],o[2]]}getCameraToWorld(o,d){const v=new Float64Array(16);return t.invert(v,this.getWorldToCamera(o,d)),v}getWorldToCameraPosition(o,d,v){const T=this.position;t.scale$2(T,T,-o);const S=new Float64Array(16);return t.fromScaling(S,[v,v,v]),t.translate(S,S,T),S[10]*=d,S}getWorldToCamera(o,d){const v=new Float64Array(16),T=new Float64Array(4),S=this.position;return t.conjugate(T,this._orientation),t.scale$2(S,S,-o),t.fromQuat(v,T),t.translate(v,v,S),v[1]*=-1,v[5]*=-1,v[9]*=-1,v[13]*=-1,v[8]*=d,v[9]*=d,v[10]*=d,v[11]*=d,v}getCameraToClipPerspective(o,d,v,T){const S=new Float64Array(16);return t.perspective(S,o,d,v,T),S}getDistanceToElevation(o,d=!1){const v=o===0?0:t.mercatorZfromAltitude(o,d?t.latFromMercatorY(this.position[1]):this.position[1]),T=this.forward();return(v-this.position[2])/T[2]}clone(){return new va([...this.position],[...this.orientation])}}function vs(_,o){const d=js(_.projection,_.zoom,_.width,_.height),v=function(S,D,z,N,q){const G=new t.LngLat(z.lng-180*xs,z.lat),Y=new t.LngLat(z.lng+180*xs,z.lat),ie=S.project(G.lng,G.lat),se=S.project(Y.lng,Y.lat),ue=-Math.atan2(se.y-ie.y,se.x-ie.x),le=t.MercatorCoordinate.fromLngLat(z);le.y=t.clamp(le.y,-1+xs,1-xs);const fe=le.toLngLat(),H=S.project(fe.lng,fe.lat),oe=t.MercatorCoordinate.fromLngLat(fe);oe.x+=xs;const ge=oe.toLngLat(),_e=S.project(ge.lng,ge.lat),Ae=Xu(_e.x-H.x,_e.y-H.y,ue),Re=t.MercatorCoordinate.fromLngLat(fe);Re.y+=xs;const Pe=Re.toLngLat(),Be=S.project(Pe.lng,Pe.lat),Oe=Xu(Be.x-H.x,Be.y-H.y,ue),Xe=Math.abs(Ae.x)/Math.abs(Oe.y),pt=t.identity([]);t.rotateZ(pt,pt,-ue*(1-(q?0:N)));const qe=t.identity([]);return t.scale(qe,qe,[1,1-(1-Xe)*N,1]),qe[4]=-Oe.x/Oe.y*N,t.rotateZ(qe,qe,ue),t.multiply(qe,pt,qe),qe}(_.projection,0,_.center,d,o),T=rl(_);return t.scale(v,v,[T,T,1]),v}function rl(_){const o=_.projection,d=js(_.projection,_.zoom,_.width,_.height),v=pd(o,_.center),T=pd(o,t.LngLat.convert(o.center));return Math.pow(2,v*d+(1-d)*T)}function js(_,o,d,v,T=1/0){const S=_.range;if(!S)return 0;const D=Math.min(T,Math.max(d,v)),z=Math.log(D/1024)/Math.LN2;return t.smoothstep(S[0]+z,S[1]+z,o)}const xs=1/4e4;function pd(_,o){const d=t.clamp(o.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),v=new t.LngLat(o.lng-180*xs,d),T=new t.LngLat(o.lng+180*xs,d),S=_.project(v.lng,d),D=_.project(T.lng,d),z=t.MercatorCoordinate.fromLngLat(v),N=t.MercatorCoordinate.fromLngLat(T),q=D.x-S.x,G=D.y-S.y,Y=N.x-z.x,ie=N.y-z.y,se=Math.sqrt((Y*Y+ie*ie)/(q*q+G*G));return Math.log(se)/Math.LN2}function Xu(_,o,d){const v=Math.cos(d),T=Math.sin(d);return{x:_*v-o*T,y:_*T+o*v}}class ol{constructor(o,d,v,T,S,D,z){this.tileSize=512,this._renderWorldCopies=S===void 0||S,this._minZoom=o||0,this._maxZoom=d||22,this._minPitch=v??0,this._maxPitch=T??60,this.setProjection(D),this.setMaxBounds(z),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Jr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new va,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const o=new ol(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return o._elevation=this._elevation,o._centerAltitude=this._centerAltitude,o._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,o.tileSize=this.tileSize,o.mercatorFromTransition=this.mercatorFromTransition,o.width=this.width,o.height=this.height,o.cameraElevationReference=this.cameraElevationReference,o._center=this._center,o._setZoom(this.zoom),o._seaLevelZoom=this._seaLevelZoom,o.angle=this.angle,o._fov=this._fov,o._pitch=this._pitch,o._nearZ=this._nearZ,o._farZ=this._farZ,o._averageElevation=this._averageElevation,o._unmodified=this._unmodified,o._edgeInsets=this._edgeInsets.clone(),o._camera=this._camera.clone(),o._calcMatrices(),o.freezeTileCoverage=this.freezeTileCoverage,o.frustumCorners=this.frustumCorners,o}get elevation(){return this._elevation}set elevation(o){this._elevation!==o&&(this._elevation=o,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(o,d=!1){const v=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||v)&&this._updateCameraOnTerrain(),(o||v)&&this._constrainCamera(d),this._calcMatrices()}getProjection(){return t.pick(this.projection,["name","center","parallels"])}setProjection(o){this.projectionOptions=o||{name:"mercator"};const d=this.projection?this.getProjection():void 0;this.projection=t.getProjection(this.projectionOptions);const v=!E(d,this.getProjection());return v&&this._calcMatrices(),this.mercatorFromTransition=!1,v}setMercatorFromTransition(){const o=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=t.getProjection({name:"mercator"});const d=o!==this.projection.name;return d&&this._calcMatrices(),d}get minZoom(){return this._minZoom}set minZoom(o){this._minZoom!==o&&(this._minZoom=o,this.zoom=Math.max(this.zoom,o))}get maxZoom(){return this._maxZoom}set maxZoom(o){this._maxZoom!==o&&(this._maxZoom=o,this.zoom=Math.min(this.zoom,o))}get minPitch(){return this._minPitch}set minPitch(o){this._minPitch!==o&&(this._minPitch=o,this.pitch=Math.max(this.pitch,o))}get maxPitch(){return this._maxPitch}set maxPitch(o){this._maxPitch!==o&&(this._maxPitch=o,this.pitch=Math.min(this.pitch,o))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(o){o===void 0?o=!0:o===null&&(o=!1),this._renderWorldCopies=o}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const o=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(o))}get cameraWorldSize(){const o=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(o))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return t.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.Point(this.width,this.height)}get bearing(){return t.wrap(this.rotation,-180,180)}set bearing(o){this.rotation=o}get rotation(){return-this.angle/Math.PI*180}set rotation(o){const d=-o*Math.PI/180;var v;this.angle!==d&&(this._unmodified=!1,this.angle=d,this._calcMatrices(),this.rotationMatrix=(v=new t.ARRAY_TYPE(4),t.ARRAY_TYPE!=Float32Array&&(v[1]=0,v[2]=0),v[0]=1,v[3]=1,v),function(T,S,D){var z=S[0],N=S[1],q=S[2],G=S[3],Y=Math.sin(D),ie=Math.cos(D);T[0]=z*ie+q*Y,T[1]=N*ie+G*Y,T[2]=z*-Y+q*ie,T[3]=N*-Y+G*ie}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(o){const d=t.clamp(o,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==d&&(this._unmodified=!1,this._pitch=d,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const o=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/o)}set fov(o){o=Math.max(.01,Math.min(60,o)),this._fov!==o&&(this._unmodified=!1,this._fov=t.degToRad(o),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(o){this._averageElevation=o,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(o){const d=Math.min(Math.max(o,this.minZoom),this.maxZoom);this._zoom!==d&&(this._unmodified=!1,this._setZoom(d),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(o){this._zoom=o,this.scale=this.zoomScale(o),this.tileZoom=Math.floor(o),this.zoomFraction=o-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const o=this._elevation;this._centerAltitude=o.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=o.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValidForExaggeration!==void 0&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const o=this._elevation,d=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],v=this.horizonLineFromTop();let T=0,S=0;for(let D=0;Do.maxzoom&&(d=o.maxzoom);const D=this.locationCoordinate(this.center),z=this.center.lat,N=1<{const yt=new t.MercatorCoordinate($e.x+25e-6,$e.y,$e.z),ct=new t.MercatorCoordinate($e.x,$e.y+25e-6,$e.z),bt=$e.toLngLat(),$t=yt.toLngLat(),un=ct.toLngLat(),Ut=this.locationCoordinate(bt),Kt=this.locationCoordinate($t),An=this.locationCoordinate(un),Cn=Math.hypot(Kt.x-Ut.x,Kt.y-Ut.y),qt=Math.hypot(An.x-Ut.x,An.y-Ut.y);return Math.sqrt(Cn*qt)*Ae/25e-6},Pe=$e=>{const it=ge,yt=_e;return{aabb:t.tileAABB(this,N,0,0,0,$e,yt,it,this.projection),zoom:0,x:0,y:0,minZ:yt,maxZ:it,wrap:$e,fullyVisible:!1}},Be=[];let Oe=[];const Xe=d,pt=o.reparseOverscaled?v:d,qe=$e=>$e*$e,ot=qe((le-this._centerAltitude)*ue),He=$e=>{if(!this._elevation||!$e.tileID||!S)return;const it=this._elevation.getMinMaxForTile($e.tileID),yt=$e.aabb;it?(yt.min[2]=it.min,yt.max[2]=it.max,yt.center[2]=(yt.min[2]+yt.max[2])/2):($e.shouldSplit=dt($e),$e.shouldSplit||(yt.min[2]=yt.max[2]=yt.center[2]=this._centerAltitude))},dt=$e=>{if($e.zoom=.9)return!0}else if(T&&(ct=qe($e.aabb.distanceZ(fe)*ue)),this.projection.isReprojectedInTileSpace&&v<=5){const Ut=Math.pow(2,$e.zoom),Kt=Re(new t.MercatorCoordinate(($e.x+.5)/Ut,($e.y+.5)/Ut));bt=Kt>.85?1:Kt}const $t=it*it+yt*yt+ct,un=qe((1<{if(Kt*qe(.707)0;){const $e=Be.pop(),it=$e.x,yt=$e.y;let ct=$e.fullyVisible;if(!ct){const bt=$e.aabb.intersects(ie);if(bt===0)continue;ct=bt===2}if($e.zoom!==Xe&&dt($e))for(let bt=0;bt<4;bt++){const $t=(it<<1)+bt%2,un=(yt<<1)+(bt>>1),Ut={aabb:S?$e.aabb.quadrant(bt):t.tileAABB(this,N,$e.zoom+1,$t,un,$e.wrap,$e.minZ,$e.maxZ,this.projection),zoom:$e.zoom+1,x:$t,y:un,wrap:$e.wrap,fullyVisible:ct,tileID:void 0,shouldSplit:void 0,minZ:$e.minZ,maxZ:$e.maxZ};T&&!G&&(Ut.tileID=new t.OverscaledTileID($e.zoom+1===Xe?pt:$e.zoom+1,$e.wrap,$e.zoom+1,$t,un),He(Ut)),Be.push(Ut)}else{const bt=$e.zoom===Xe?pt:$e.zoom;if(o.minzoom&&o.minzoom>bt)continue;const $t=q[0]-(.5+it+($e.wrap<<$e.zoom))*(1<{const ct=[0,0,0,1],bt=[t.EXTENT,t.EXTENT,0,1],$t=this.calculateFogTileMatrix(yt.tileID.toUnwrapped());t.transformMat4$1(ct,ct,$t),t.transformMat4$1(bt,bt,$t);const un=t.getAABBPointSquareDist(ct,bt);if(un===0)return!0;let Ut=!1;const Kt=this._elevation;if(Kt&&un>$e&&it!==0){const An=this.calculateProjMatrix(yt.tileID.toUnwrapped());let Cn;o.isTerrainDEM||(Cn=Kt.getMinMaxForTile(yt.tileID)),Cn||(Cn={min:_e,max:ge});const qt=t.furthestTileCorner(this.rotation),Yn=[qt[0]*t.EXTENT,qt[1]*t.EXTENT,Cn.max];t.transformMat4(Yn,Yn,An),Ut=(1-Yn[1])*this.height*.5$e.distanceSq-it.distanceSq).map($e=>$e.tileID)}resize(o,d){this.width=o,this.height=d,this.pixelsToGLUnits=[2/o,-2/d],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(o){return Math.pow(2,o)}scaleZoom(o){return Math.log(o)/Math.LN2}project(o){const d=t.clamp(o.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),v=this.projection.project(o.lng,d);return new t.Point(v.x*this.worldSize,v.y*this.worldSize)}unproject(o){return this.projection.unproject(o.x/this.worldSize,o.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/t.mercatorZfromAltitude(1,this.center.lat)/this.worldSize}setLocationAtPoint(o,d){let v,T;const S=this.centerPoint;if(this.projection.name==="globe"){const z=this.worldSize;v=(d.x-S.x)/z,T=(d.y-S.y)/z}else{const z=this.pointCoordinate(d),N=this.pointCoordinate(S);v=z.x-N.x,T=z.y-N.y}const D=this.locationCoordinate(o);this.setLocation(new t.MercatorCoordinate(D.x-v,D.y-T))}setLocation(o){this.center=this.coordinateLocation(o),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(o){return this.projection.locationPoint(this,o)}locationPoint3D(o){return this.projection.locationPoint(this,o,!0)}pointLocation(o){return this.coordinateLocation(this.pointCoordinate(o))}pointLocation3D(o){return this.coordinateLocation(this.pointCoordinate3D(o))}locationCoordinate(o,d){const v=d?t.mercatorZfromAltitude(d,o.lat):void 0,T=this.projection.project(o.lng,o.lat);return new t.MercatorCoordinate(T.x,T.y,v)}coordinateLocation(o){return this.projection.unproject(o.x,o.y)}pointRayIntersection(o,d){const v=d??this._centerAltitude,T=[o.x,o.y,0,1],S=[o.x,o.y,1,1];t.transformMat4$1(T,T,this.pixelMatrixInverse),t.transformMat4$1(S,S,this.pixelMatrixInverse);const D=S[3];t.scale$1(T,T,1/T[3]),t.scale$1(S,S,1/D);const z=T[2],N=S[2];return{p0:T,p1:S,t:z===N?0:(v-z)/(N-z)}}screenPointToMercatorRay(o){const d=[o.x,o.y,0,1],v=[o.x,o.y,1,1];return t.transformMat4$1(d,d,this.pixelMatrixInverse),t.transformMat4$1(v,v,this.pixelMatrixInverse),t.scale$1(d,d,1/d[3]),t.scale$1(v,v,1/v[3]),d[2]=t.mercatorZfromAltitude(d[2],this._center.lat)*this.worldSize,v[2]=t.mercatorZfromAltitude(v[2],this._center.lat)*this.worldSize,t.scale$1(d,d,1/this.worldSize),t.scale$1(v,v,1/this.worldSize),new t.Ray([d[0],d[1],d[2]],t.normalize([],t.sub([],v,d)))}rayIntersectionCoordinate(o){const{p0:d,p1:v,t:T}=o,S=t.mercatorZfromAltitude(d[2],this._center.lat),D=t.mercatorZfromAltitude(v[2],this._center.lat);return new t.MercatorCoordinate(t.number(d[0],v[0],T)/this.worldSize,t.number(d[1],v[1],T)/this.worldSize,t.number(S,D,T))}pointCoordinate(o,d=this._centerAltitude){return this.projection.pointCoordinate(this,o.x,o.y,d)}pointCoordinate3D(o){if(!this.elevation)return this.pointCoordinate(o);let d=this.projection.pointCoordinate3D(this,o.x,o.y);if(d)return new t.MercatorCoordinate(d[0],d[1],d[2]);let v=0,T=this.horizonLineFromTop();if(o.y>T)return this.pointCoordinate(o);const S=.02*T,D=o.clone();for(let z=0;z<10&&T-v>S;z++){D.y=t.number(v,T,.66);const N=this.projection.pointCoordinate3D(this,D.x,D.y);N?(T=D.y,d=N):v=D.y}return d?new t.MercatorCoordinate(d[0],d[1],d[2]):this.pointCoordinate(o)}isPointAboveHorizon(o){return this.projection.isPointAboveHorizon(this,o)}isPointOnSurface(o){if(o.y<0||o.y>this.height||o.x<0||o.x>this.width)return!1;if(this.elevation||this.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX)return!this.isPointAboveHorizon(o);const d=this.pointCoordinate(o);return d.y>=0&&d.y<=1}_coordinatePoint(o,d){const v=d&&this.elevation?this.elevation.getAtPointOrZero(o,this._centerAltitude):this._centerAltitude,T=[o.x*this.worldSize,o.y*this.worldSize,v+o.toAltitude(),1];return t.transformMat4$1(T,T,this.pixelMatrix),T[3]>0?new t.Point(T[0]/T[3],T[1]/T[3]):new t.Point(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:o,left:d}=this._edgeInsets,v=this.height-this._edgeInsets.bottom,T=this.width-this._edgeInsets.right,S=this.pointLocation3D(new t.Point(d,o)),D=this.pointLocation3D(new t.Point(T,o)),z=this.pointLocation3D(new t.Point(T,v)),N=this.pointLocation3D(new t.Point(d,v));let q=Math.min(S.lng,D.lng,z.lng,N.lng),G=Math.max(S.lng,D.lng,z.lng,N.lng),Y=Math.min(S.lat,D.lat,z.lat,N.lat),ie=Math.max(S.lat,D.lat,z.lat,N.lat);const se=Math.pow(2,-this.zoom)/16*270,ue=this.projection.name==="globe"?1:4,le=(fe,H,oe,ge,_e)=>{const Ae=(fe+oe)/2,Re=(H+ge)/2,Pe=new t.Point(Ae,Re),{lng:Be,lat:Oe}=this.pointLocation3D(Pe),Xe=Math.max(0,q-Be,Y-Oe,Be-G,Oe-ie);q=Math.min(q,Be),G=Math.max(G,Be),Y=Math.min(Y,Oe),ie=Math.max(ie,Oe),(_ese)&&(le(fe,H,Ae,Re,_e+1),le(Ae,Re,oe,ge,_e+1))};if(le(d,o,T,o,1),le(T,o,T,v,1),le(T,v,d,v,1),le(d,v,d,o,1),this.projection.name==="globe"){const[fe,H]=t.polesInViewport(this);fe?(ie=90,G=180,q=-180):H&&(Y=-90,G=180,q=-180)}return new t.LngLatBounds(new t.LngLat(q,Y),new t.LngLat(G,ie))}_getBoundsRectangular(o,d){const{top:v,left:T}=this._edgeInsets,S=this.height-this._edgeInsets.bottom,D=this.width-this._edgeInsets.right,z=new t.Point(T,v),N=new t.Point(D,v),q=new t.Point(D,S),G=new t.Point(T,S);let Y=this.pointCoordinate(z,o),ie=this.pointCoordinate(N,o);const se=this.pointCoordinate(q,d),ue=this.pointCoordinate(G,d),le=(fe,H)=>(H.y-fe.y)/(H.x-fe.x);return Y.y>1&&ie.y>=0?Y=new t.MercatorCoordinate((1-ue.y)/le(ue,Y)+ue.x,1):Y.y<0&&ie.y<=1&&(Y=new t.MercatorCoordinate(-ue.y/le(ue,Y)+ue.x,0)),ie.y>1&&Y.y>=0?ie=new t.MercatorCoordinate((1-se.y)/le(se,ie)+se.x,1):ie.y<0&&Y.y<=1&&(ie=new t.MercatorCoordinate(-se.y/le(se,ie)+se.x,0)),new t.LngLatBounds().extend(this.coordinateLocation(Y)).extend(this.coordinateLocation(ie)).extend(this.coordinateLocation(ue)).extend(this.coordinateLocation(se))}_getBoundsRectangularTerrain(){const o=this.elevation;if(!o.visibleDemTiles.length||o.isUsingMockSource())return this._getBoundsRectangular(0,0);const d=o.visibleDemTiles.reduce((v,T)=>{if(T.dem){const S=T.dem.tree;v.min=Math.min(v.min,S.minimums[0]),v.max=Math.max(v.max,S.maximums[0])}return v},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(d.min*o.exaggeration(),d.max*o.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(o=!0){const d=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,v=this.height/2-d*(1-this._horizonShift);return o?Math.max(0,v):v}getMaxBounds(){return this.maxBounds}setMaxBounds(o){this.maxBounds=o,this.minLat=-t.MAX_MERCATOR_LATITUDE,this.maxLat=t.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,o&&(this.minLat=o.getSouth(),this.maxLat=o.getNorth(),this.minLng=o.getWest(),this.maxLng=o.getEast(),this.maxLngY&&(z=Y-q),Y-Gse&&(D=se-N),se-ie.5?ge-1:ge,_e>.5?_e-1:_e,0]),this.alignedProjMatrix=Ae,z=t.create(),t.scale(z,z,[this.width/2,-this.height/2,1]),t.translate(z,z,[1,-1,0]),this.labelPlaneMatrix=z,z=t.create(),t.scale(z,z,[1,-1,1]),t.translate(z,z,[-1,-1,0]),t.scale(z,z,[2/this.width,2/this.height,1]),this.glCoordMatrix=z,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},z=t.invert(new Float64Array(16),this.pixelMatrix),!z)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=z,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=t.calculateGlobeMatrix(this);const Re=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=t.transformMat4(Re,Re,S),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=z;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const o=this.cameraWorldSizeForFog,d=this.cameraPixelsPerMeter,v=this._camera.position,T=1/this.height/this._pixelsPerMercatorPixel,S=[o,o,d];t.scale$2(S,S,T),t.scale$2(v,v,-1),t.multiply$2(v,v,S);const D=t.create();t.translate(D,D,v),t.scale(D,D,S),this.mercatorFogMatrix=D,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(o,d,T)}_computeCameraPosition(o){const d=(o=o||this.pixelsPerMeter)/this.pixelsPerMeter,v=this._camera.forward(),T=this.point,S=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*d-o/this.worldSize*this._centerAltitude;return[T.x/this.worldSize-v[0]*S,T.y/this.worldSize-v[1]*S,o/this.worldSize*this._centerAltitude-v[2]*S]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(o){const d=this._maxCameraBoundsDistance()*Math.cos(this._pitch),v=this._camera.position[2],T=o[2];let S=1;this.projection.wrap&&(this.center=this.center.wrap()),T>0&&(S=Math.min((d-v)/T,1)),this._camera.position=t.scaleAndAdd([],this._camera.position,o,S),this._updateStateFromCamera()}_updateStateFromCamera(){const o=this._camera.position,d=this._camera.forward(),{pitch:v,bearing:T}=this._camera.getPitchBearing(),S=t.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,D=this._mercatorZfromZoom(this._maxZoom)*Math.cos(t.degToRad(this._maxPitch)),z=Math.max((o[2]-S)/Math.cos(v),D),N=this._zoomFromMercatorZ(z);t.scaleAndAdd(o,o,d,z),this._pitch=t.clamp(v,t.degToRad(this.minPitch),t.degToRad(this.maxPitch)),this.angle=t.wrap(T,-Math.PI,Math.PI),this._setZoom(t.clamp(N,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new t.MercatorCoordinate(o[0],o[1],o[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(o){return Math.pow(2,o)*this.tileSize}_mercatorZfromZoom(o){return this.cameraToCenterDistance/this._worldSizeFromZoom(o)}_minimumHeightOverTerrain(){const o=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(o)}_zoomFromMercatorZ(o){return this.scaleZoom(this.cameraToCenterDistance/(o*this.tileSize))}zoomFromMercatorZAdjusted(o){let d=0,v=t.GLOBE_ZOOM_THRESHOLD_MAX,T=0,S=1/0;for(;v-d>1e-6&&v>d;){const D=d+.5*(v-d),z=this.tileSize*Math.pow(2,D),N=this.getCameraToCenterDistance(this.projection,D,z),q=this.scaleZoom(N/(o*this.tileSize)),G=Math.abs(D-q);Gq||ie.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+t.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new t.Point(0,0),new t.Point(this.width,this.height))}zoomDeltaToMovement(o,d){const v=t.length(t.sub([],this._camera.position,o)),T=this._zoomFromMercatorZ(v)+d;return v-this._mercatorZfromZoom(T)}getCameraPoint(){if(this.projection.name==="globe"){const o=function([d,v,T],S){const D=[d,v,T,1];t.transformMat4$1(D,D,S);const z=D[3]=Math.max(D[3],1e-6);return D[0]/=z,D[1]/=z,D[2]/=z,D}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new t.Point(o[0],o[1])}{const o=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.Point(0,o))}}getCameraToCenterDistance(o,d=this.zoom,v=this.worldSize){const T=js(o,d,this.width,this.height,1024),S=o.pixelSpaceConversion(this.center.lat,v,T);return .5/Math.tan(.5*this._fov)*this.height*S}getWorldToCameraMatrix(){const o=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&t.multiply(o,o,this.globeMatrix),o}}function sl(_,o){let d=!1,v=null;const T=()=>{v=null,d&&(_(),v=setTimeout(T,o),d=!1)};return()=>(d=!0,v||T(),v)}class lh{constructor(o){this._hashName=o&&encodeURIComponent(o),t.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=sl(this._updateHashUnthrottled.bind(this),300)}addTo(o){return this._map=o,t.window.addEventListener("hashchange",this._onHashChange,!1),o.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),t.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const o=this._map;if(!o)return"";const d=$l(o);if(this._hashName){const v=this._hashName;let T=!1;const S=t.window.location.hash.slice(1).split("&").map(D=>{const z=D.split("=")[0];return z===v?(T=!0,`${z}=${d}`):D}).filter(D=>D);return T||S.push(`${v}=${d}`),`#${S.join("&")}`}return`#${d}`}_getCurrentHash(){const o=t.window.location.hash.replace("#","");if(this._hashName){let d;return o.split("&").map(v=>v.split("=")).forEach(v=>{v[0]===this._hashName&&(d=v)}),(d&&d[1]||"").split("/")}return o.split("/")}_onHashChange(){const o=this._map;if(!o)return!1;const d=this._getCurrentHash();if(d.length>=3&&!d.some(v=>isNaN(v))){const v=o.dragRotate.isEnabled()&&o.touchZoomRotate.isEnabled()?+(d[3]||0):o.getBearing();return o.jumpTo({center:[+d[2],+d[1]],zoom:+d[0],bearing:v,pitch:+(d[4]||0)}),!0}return!1}_updateHashUnthrottled(){const o=t.window.location.href.replace(/(#.+)?$/,this.getHashString());t.window.history.replaceState(t.window.history.state,null,o)}}function $l(_,o){const d=_.getCenter(),v=Math.round(100*_.getZoom())/100,T=Math.ceil((v*Math.LN2+Math.log(512/360/.5))/Math.LN10),S=Math.pow(10,T),D=Math.round(d.lng*S)/S,z=Math.round(d.lat*S)/S,N=_.getBearing(),q=_.getPitch();let G=o?`/${D}/${z}/${v}`:`${v}/${z}/${D}`;return(N||q)&&(G+="/"+Math.round(10*N)/10),q&&(G+=`/${Math.round(q)}`),G}const Xl={linearity:.3,easing:t.bezier(0,0,.3,1)},Wu=t.extend({deceleration:2500,maxSpeed:1400},Xl),Yu=t.extend({deceleration:20,maxSpeed:1400},Xl),Ot=t.extend({deceleration:1e3,maxSpeed:360},Xl),Uo=t.extend({deceleration:1e3,maxSpeed:90},Xl);class md{constructor(o){this._map=o,this.clear()}clear(){this._inertiaBuffer=[]}record(o){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.exported.now(),settings:o})}_drainInertiaBuffer(){const o=this._inertiaBuffer,d=t.exported.now();for(;o.length>0&&d-o[0].time>160;)o.shift()}_onMoveEnd(o){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const d={zoom:0,bearing:0,pitch:0,pan:new t.Point(0,0),pinchAround:void 0,around:void 0};for(const{settings:S}of this._inertiaBuffer)d.zoom+=S.zoomDelta||0,d.bearing+=S.bearingDelta||0,d.pitch+=S.pitchDelta||0,S.panDelta&&d.pan._add(S.panDelta),S.around&&(d.around=S.around),S.pinchAround&&(d.pinchAround=S.pinchAround);const v=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,T={};if(d.pan.mag()){const S=Yl(d.pan.mag(),v,t.extend({},Wu,o||{}));T.offset=d.pan.mult(S.amount/d.pan.mag()),T.center=this._map.transform.center,Wl(T,S)}if(d.zoom){const S=Yl(d.zoom,v,Yu);T.zoom=this._map.transform.zoom+S.amount,Wl(T,S)}if(d.bearing){const S=Yl(d.bearing,v,Ot);T.bearing=this._map.transform.bearing+t.clamp(S.amount,-179,179),Wl(T,S)}if(d.pitch){const S=Yl(d.pitch,v,Uo);T.pitch=this._map.transform.pitch+S.amount,Wl(T,S)}if(T.zoom||T.bearing){const S=d.pinchAround===void 0?d.around:d.pinchAround;T.around=S?this._map.unproject(S):this._map.getCenter()}return this.clear(),T.noMoveStart=!0,T}}function Wl(_,o){(!_.duration||_.durationd.unproject(N)),z=S.reduce((N,q,G,Y)=>N.add(q.div(Y.length)),new t.Point(0,0));super(o,{points:S,point:z,lngLats:D,lngLat:d.unproject(z),originalEvent:v}),this._defaultPrevented=!1}}class Hu extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(o,d,v){super(o,{originalEvent:v}),this._defaultPrevented=!1}}class uh{constructor(o,d){this._map=o,this._clickTolerance=d.clickTolerance}reset(){this._mousedownPos=void 0}wheel(o){return this._firePreventable(new Hu(o.type,this._map,o))}mousedown(o,d){return this._mousedownPos=d,this._firePreventable(new pr(o.type,this._map,o))}mouseup(o){this._map.fire(new pr(o.type,this._map,o))}preclick(o){const d=t.extend({},o);d.type="preclick",this._map.fire(new pr(d.type,this._map,d))}click(o,d){this._mousedownPos&&this._mousedownPos.dist(d)>=this._clickTolerance||(this.preclick(o),this._map.fire(new pr(o.type,this._map,o)))}dblclick(o){return this._firePreventable(new pr(o.type,this._map,o))}mouseover(o){this._map.fire(new pr(o.type,this._map,o))}mouseout(o){this._map.fire(new pr(o.type,this._map,o))}touchstart(o){return this._firePreventable(new Hl(o.type,this._map,o))}touchmove(o){this._map.fire(new Hl(o.type,this._map,o))}touchend(o){this._map.fire(new Hl(o.type,this._map,o))}touchcancel(o){this._map.fire(new Hl(o.type,this._map,o))}_firePreventable(o){if(this._map.fire(o),o.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ku{constructor(o){this._map=o}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(o){this._map.fire(new pr(o.type,this._map,o))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new pr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(o){this._delayContextMenu?this._contextMenuEvent=o:this._map.fire(new pr(o.type,this._map,o)),this._map.listens("contextmenu")&&o.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class gd{constructor(o,d){this._map=o,this._el=o.getCanvasContainer(),this._container=o.getContainer(),this._clickTolerance=d.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(o,d){this.isEnabled()&&o.shiftKey&&o.button===0&&(ye(),this._startPos=this._lastPos=d,this._active=!0)}mousemoveWindow(o,d){if(!this._active)return;const v=d,T=this._startPos,S=this._lastPos;if(!T||!S||S.equals(v)||!this._box&&v.dist(T){this._box&&(this._box.style.transform=`translate(${D}px,${N}px)`,this._box.style.width=z-D+"px",this._box.style.height=q-N+"px")})}mouseupWindow(o,d){if(!this._active)return;const v=this._startPos,T=d;if(v&&o.button===0){if(this.reset(),be(),v.x!==T.x||v.y!==T.y)return this._map.fire(new t.Event("boxzoomend",{originalEvent:o})),{cameraAnimation:S=>S.fitScreenCoordinates(v,T,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",o)}}keydown(o){this._active&&o.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",o))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),te(),delete this._startPos,delete this._lastPos}_fireEvent(o,d){return this._map.fire(new t.Event(o,{originalEvent:d}))}}function Ju(_,o){const d={};for(let v=0;v<_.length;v++)d[_[v].identifier]=o[v];return d}class al{constructor(o){this.reset(),this.numTouches=o.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(o,d,v){(this.centroid||v.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=o.timeStamp),v.length===this.numTouches&&(this.centroid=function(T){const S=new t.Point(0,0);for(const D of T)S._add(D);return S.div(T.length)}(d),this.touches=Ju(v,d)))}touchmove(o,d,v){if(this.aborted||!this.centroid)return;const T=Ju(v,d);for(const S in this.touches){const D=T[S];(!D||D.dist(this.touches[S])>30)&&(this.aborted=!0)}}touchend(o,d,v){if((!this.centroid||o.timeStamp-this.startTime>500)&&(this.aborted=!0),v.length===0){const T=!this.aborted&&this.centroid;if(this.reset(),T)return T}}}class ch{constructor(o){this.singleTap=new al(o),this.numTaps=o.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(o,d,v){this.singleTap.touchstart(o,d,v)}touchmove(o,d,v){this.singleTap.touchmove(o,d,v)}touchend(o,d,v){const T=this.singleTap.touchend(o,d,v);if(T){const S=o.timeStamp-this.lastTime<500,D=!this.lastTap||this.lastTap.dist(T)<30;if(S&&D||this.reset(),this.count++,this.lastTime=o.timeStamp,this.lastTap=T,this.count===this.numTaps)return this.reset(),T}}}class Dm{constructor(){this._zoomIn=new ch({numTouches:1,numTaps:2}),this._zoomOut=new ch({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(o,d,v){this._zoomIn.touchstart(o,d,v),this._zoomOut.touchstart(o,d,v)}touchmove(o,d,v){this._zoomIn.touchmove(o,d,v),this._zoomOut.touchmove(o,d,v)}touchend(o,d,v){const T=this._zoomIn.touchend(o,d,v),S=this._zoomOut.touchend(o,d,v);return T?(this._active=!0,o.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:D=>D.easeTo({duration:300,zoom:D.getZoom()+1,around:D.unproject(T)},{originalEvent:o})}):S?(this._active=!0,o.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:D=>D.easeTo({duration:300,zoom:D.getZoom()-1,around:D.unproject(S)},{originalEvent:o})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const _d={0:1,2:2};class ll{constructor(o){this.reset(),this._clickTolerance=o.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(o,d){return!1}_move(o,d){return{}}mousedown(o,d){if(this._lastPoint)return;const v=ze(o);this._correctButton(o,v)&&(this._lastPoint=d,this._eventButton=v)}mousemoveWindow(o,d){const v=this._lastPoint;if(v){if(o.preventDefault(),this._eventButton!=null&&function(T,S){const D=_d[S];return T.buttons===void 0||(T.buttons&D)!==D}(o,this._eventButton))this.reset();else if(this._moved||!(d.dist(v)0&&(this._active=!0);const T=Ju(v,d),S=new t.Point(0,0),D=new t.Point(0,0);let z=0;for(const q in T){const G=T[q],Y=this._touches[q];Y&&(S._add(G),D._add(G.sub(Y)),z++,T[q]=G)}if(this._touches=T,z{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class Kl{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(o){}_move(o,d,v){return{}}touchstart(o,d,v){this._firstTwoTouches||v.length<2||(this._firstTwoTouches=[v[0].identifier,v[1].identifier],this._start([d[0],d[1]]))}touchmove(o,d,v){const T=this._firstTwoTouches;if(!T)return;o.preventDefault();const[S,D]=T,z=Jl(v,d,S),N=Jl(v,d,D);if(!z||!N)return;const q=this._aroundCenter?null:z.add(N).div(2);return this._move([z,N],q,o)}touchend(o,d,v){if(!this._firstTwoTouches)return;const[T,S]=this._firstTwoTouches,D=Jl(v,d,T),z=Jl(v,d,S);D&&z||(this._active&&be(),this.reset())}touchcancel(){this.reset()}enable(o){this._enabled=!0,this._aroundCenter=!!o&&o.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Jl(_,o,d){for(let v=0;v<_.length;v++)if(_[v].identifier===d)return o[v]}function ph(_,o){return Math.log(_/o)/Math.LN2}class yd extends Kl{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(o){this._startDistance=this._distance=o[0].dist(o[1])}_move(o,d){const v=this._distance;if(this._distance=o[0].dist(o[1]),this._active||!(Math.abs(ph(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:ph(this._distance,v),pinchAround:d}}}function mh(_,o){return 180*_.angleWith(o)/Math.PI}class vd extends Kl{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(o){this._startVector=this._vector=o[0].sub(o[1]),this._minDiameter=o[0].dist(o[1])}_move(o,d){const v=this._vector;if(this._vector=o[0].sub(o[1]),v&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:mh(this._vector,v),pinchAround:d}}_isBelowThreshold(o){this._minDiameter=Math.min(this._minDiameter,o.mag());const d=25/(Math.PI*this._minDiameter)*360,v=this._startVector;if(!v)return!1;const T=mh(o,v);return Math.abs(T)Math.abs(_.x)}class xd extends Kl{constructor(o){super(),this._map=o}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(o){this._lastPoints=o,Gs(o[0].sub(o[1]))&&(this._valid=!1)}_move(o,d,v){const T=this._lastPoints;if(!T)return;const S=o[0].sub(T[0]),D=o[1].sub(T[1]);return this._map._cooperativeGestures&&!t.isFullscreen()&&v.touches.length<3||(this._valid=this.gestureBeginsVertically(S,D,v.timeStamp),!this._valid)?void 0:(this._lastPoints=o,this._active=!0,{pitchDelta:(S.y+D.y)/2*-.5})}gestureBeginsVertically(o,d,v){if(this._valid!==void 0)return this._valid;const T=o.mag()>=2,S=d.mag()>=2;if(!T&&!S)return;if(!T||!S)return this._firstMove==null&&(this._firstMove=v),v-this._firstMove<100&&void 0;const D=o.y>0==d.y>0;return Gs(o)&&Gs(d)&&D}}const bd={panStep:100,bearingStep:15,pitchStep:10};class zm{constructor(){const o=bd;this._panStep=o.panStep,this._bearingStep=o.bearingStep,this._pitchStep=o.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(o){if(o.altKey||o.ctrlKey||o.metaKey)return;let d=0,v=0,T=0,S=0,D=0;switch(o.keyCode){case 61:case 107:case 171:case 187:d=1;break;case 189:case 109:case 173:d=-1;break;case 37:o.shiftKey?v=-1:(o.preventDefault(),S=-1);break;case 39:o.shiftKey?v=1:(o.preventDefault(),S=1);break;case 38:o.shiftKey?T=1:(o.preventDefault(),D=-1);break;case 40:o.shiftKey?T=-1:(o.preventDefault(),D=1);break;default:return}return this._rotationDisabled&&(v=0,T=0),{cameraAnimation:z=>{const N=z.getZoom();z.easeTo({duration:300,easeId:"keyboardHandler",easing:wd,zoom:d?Math.round(N)+d*(o.shiftKey?2:1):N,bearing:z.getBearing()+v*this._bearingStep,pitch:z.getPitch()+T*this._pitchStep,offset:[-S*this._panStep,-D*this._panStep],center:z.getCenter()},{originalEvent:o})}}}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 wd(_){return _*(2-_)}const gh=4.000244140625;class Ed{constructor(o,d){this._map=o,this._el=o.getCanvasContainer(),this._handler=d,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,t.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(o){this._defaultZoomRate=o}setWheelZoomRate(o){this._wheelZoomRate=o}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(o){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!o&&o.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(o){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(o.ctrlKey||o.metaKey||this.isZooming()||t.isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let d=o.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*o.deltaY:o.deltaY;const v=t.exported.now(),T=v-(this._lastWheelEventTime||0);this._lastWheelEventTime=v,d!==0&&d%gh==0?this._type="wheel":d!==0&&Math.abs(d)<4?this._type="trackpad":T>400?(this._type=null,this._lastValue=d,this._timeout=setTimeout(this._onTimeout,40,o)):this._type||(this._type=Math.abs(T*d)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,d+=this._lastValue)),o.shiftKey&&d&&(d/=4),this._type&&(this._lastWheelEvent=o,this._delta-=d,this._active||this._start(o)),o.preventDefault()}_onTimeout(o){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(o)}_start(o){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 d=we(this._el,o);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:d,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const o=this._map.transform;this._type==="wheel"&&o.projection.wrap&&(o._center.lng>=180||o._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const d=()=>o._terrainEnabled()&&this._aroundCoord?o.computeZoomRelativeTo(this._aroundCoord):o.zoom;if(this._delta!==0){const N=this._type==="wheel"&&Math.abs(this._delta)>gh?this._wheelZoomRate:this._defaultZoomRate;let q=2/(1+Math.exp(-Math.abs(this._delta*N)));this._delta<0&&q!==0&&(q=1/q);const G=d(),Y=Math.pow(2,G),ie=typeof this._targetZoom=="number"?o.zoomScale(this._targetZoom):Y;this._targetZoom=Math.min(o.maxZoom,Math.max(o.minZoom,o.scaleZoom(ie*q))),this._type==="wheel"&&(this._startZoom=G,this._easing=this._smoothOutEasing(200)),this._delta=0}const v=typeof this._targetZoom=="number"?this._targetZoom:d(),T=this._startZoom,S=this._easing;let D,z=!1;if(this._type==="wheel"&&T&&S){const N=Math.min((t.exported.now()-this._lastWheelEventTime)/200,1),q=S(N);D=t.number(T,v,q),N<1?this._frameId||(this._frameId=!0):z=!0}else D=v,z=!0;return this._active=!0,z&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!z,zoomDelta:D-d(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(o){let d=t.ease;if(this._prevEase){const v=this._prevEase,T=(t.exported.now()-v.start)/v.duration,S=v.easing(T+.01)-v.easing(T),D=.27/Math.sqrt(S*S+1e-4)*.01,z=Math.sqrt(.0729-D*D);d=t.bezier(D,z,.25,1)}return this._prevEase={start:t.exported.now(),duration:o,easing:d},d}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=F("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(t.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")},200)}}class Td{constructor(o,d){this._clickZoom=o,this._tapZoom=d}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 Rr{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(o,d){return o.preventDefault(),{cameraAnimation:v=>{v.easeTo({duration:300,zoom:v.getZoom()+(o.shiftKey?-1:1),around:v.unproject(d)},{originalEvent:o})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Om{constructor(){this._tap=new ch({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(o,d,v){this._swipePoint||(this._tapTime&&o.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?v.length>0&&(this._swipePoint=d[0],this._swipeTouch=v[0].identifier):this._tap.touchstart(o,d,v))}touchmove(o,d,v){if(this._tapTime){if(this._swipePoint){if(v[0].identifier!==this._swipeTouch)return;const T=d[0],S=T.y-this._swipePoint.y;return this._swipePoint=T,o.preventDefault(),this._active=!0,{zoomDelta:S/128}}}else this._tap.touchmove(o,d,v)}touchend(o,d,v){this._tapTime?this._swipePoint&&v.length===0&&this.reset():this._tap.touchend(o,d,v)&&(this._tapTime=o.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Id{constructor(o,d,v){this._el=o,this._mousePan=d,this._touchPan=v}enable(o){this._inertiaOptions=o||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Nm{constructor(o,d,v){this._pitchWithRotate=o.pitchWithRotate,this._mouseRotate=d,this._mousePitch=v}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Bm{constructor(o,d,v,T){this._el=o,this._touchZoom=d,this._touchRotate=v,this._tapDragZoom=T,this._rotationDisabled=!1,this._enabled=!0}enable(o){this._touchZoom.enable(o),this._rotationDisabled||this._touchRotate.enable(o),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const ko=_=>_.zoom||_.drag||_.pitch||_.rotate;class Md extends t.Event{}class Fm{constructor(){this.constants=[1,1,.01],this.radius=0}setup(o,d){const v=t.sub([],d,o);this.radius=t.length(v[2]<0?t.div([],v,this.constants):[v[0],v[1],0])}projectRay(o){t.div(o,o,this.constants),t.normalize(o,o),t.mul$1(o,o,this.constants);const d=t.scale$2([],o,this.radius);if(d[2]>0){const v=t.scale$2([],[0,0,1],t.dot(d,[0,0,1])),T=t.scale$2([],t.normalize([],[d[0],d[1],0]),this.radius),S=t.add([],d,t.scale$2([],t.sub([],t.add([],T,v),d),2));d[0]=S[0],d[1]=S[1]}return d}}function jo(_){return _.panDelta&&_.panDelta.mag()||_.zoomDelta||_.bearingDelta||_.pitchDelta}class Qo{constructor(o,d){this._map=o,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new md(o),this._bearingSnap=d.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Fm,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(d),t.bindAll(["handleEvent","handleWindowEvent"],this);const v=this._el;this._listeners=[[v,"touchstart",{passive:!0}],[v,"touchmove",{passive:!1}],[v,"touchend",void 0],[v,"touchcancel",void 0],[v,"mousedown",void 0],[v,"mousemove",void 0],[v,"mouseup",void 0],[t.window.document,"mousemove",{capture:!0}],[t.window.document,"mouseup",void 0],[v,"mouseover",void 0],[v,"mouseout",void 0],[v,"dblclick",void 0],[v,"click",void 0],[v,"keydown",{capture:!1}],[v,"keyup",void 0],[v,"wheel",{passive:!1}],[v,"contextmenu",void 0],[t.window,"blur",void 0]];for(const[T,S,D]of this._listeners)T.addEventListener(S,T===t.window.document?this.handleWindowEvent:this.handleEvent,D)}destroy(){for(const[o,d,v]of this._listeners)o.removeEventListener(d,o===t.window.document?this.handleWindowEvent:this.handleEvent,v)}_addDefaultHandlers(o){const d=this._map,v=d.getCanvasContainer();this._add("mapEvent",new uh(d,o));const T=d.boxZoom=new gd(d,o);this._add("boxZoom",T);const S=new Dm,D=new Rr;d.doubleClickZoom=new Td(D,S),this._add("tapZoom",S),this._add("clickZoom",D);const z=new Om;this._add("tapDragZoom",z);const N=d.touchPitch=new xd(d);this._add("touchPitch",N);const q=new fh(o),G=new dh(o);d.dragRotate=new Nm(o,q,G),this._add("mouseRotate",q,["mousePitch"]),this._add("mousePitch",G,["mouseRotate"]);const Y=new hh(o),ie=new Qu(d,o);d.dragPan=new Id(v,Y,ie),this._add("mousePan",Y),this._add("touchPan",ie,["touchZoom","touchRotate"]);const se=new vd,ue=new yd;d.touchZoomRotate=new Bm(v,ue,se,z),this._add("touchRotate",se,["touchPan","touchZoom"]),this._add("touchZoom",ue,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Ku(d));const le=d.scrollZoom=new Ed(d,this);this._add("scrollZoom",le,["mousePan"]);const fe=d.keyboard=new zm;this._add("keyboard",fe);for(const H of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])o.interactive&&o[H]&&d[H].enable(o[H])}_add(o,d,v){this._handlers.push({handlerName:o,handler:d,allowed:v}),this._handlersById[o]=d}stop(o){if(!this._updatingCamera){for(const{handler:d}of this._handlers)d.reset();this._inertia.clear(),this._fireEvents({},{},o),this._changes=[]}}isActive(){for(const{handler:o}of this._handlers)if(o.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!ko(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(o,d,v){for(const T in o)if(T!==v&&(!d||d.indexOf(T)<0))return!0;return!1}handleWindowEvent(o){this.handleEvent(o,`${o.type}Window`)}_getMapTouches(o){const d=[];for(const v of o)this._el.contains(v.target)&&d.push(v);return d}handleEvent(o,d){this._updatingCamera=!0;const v=o.type==="renderFrame",T=v?void 0:o,S={needsRenderFrame:!1},D={},z={},N=o.touches?this._getMapTouches(o.touches):void 0,q=N?Ue(this._el,N):v?void 0:we(this._el,o);for(const{handlerName:ie,handler:se,allowed:ue}of this._handlers){if(!se.isEnabled())continue;let le;this._blockedByActive(z,ue,ie)?se.reset():se[d||o.type]&&(le=se[d||o.type](o,q,N),this.mergeHandlerResult(S,D,le,ie,T),le&&le.needsRenderFrame&&this._triggerRenderFrame()),(le||se.isActive())&&(z[ie]=se)}const G={};for(const ie in this._previousActiveHandlers)z[ie]||(G[ie]=T);this._previousActiveHandlers=z,(Object.keys(G).length||jo(S))&&(this._changes.push([S,D,G]),this._triggerRenderFrame()),(Object.keys(z).length||jo(S))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:Y}=S;Y&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Y(this._map))}mergeHandlerResult(o,d,v,T,S){if(!v)return;t.extend(o,v);const D={handlerName:T,originalEvent:v.originalEvent||S};v.zoomDelta!==void 0&&(d.zoom=D),v.panDelta!==void 0&&(d.drag=D),v.pitchDelta!==void 0&&(d.pitch=D),v.bearingDelta!==void 0&&(d.rotate=D)}_applyChanges(){const o={},d={},v={};for(const[T,S,D]of this._changes)T.panDelta&&(o.panDelta=(o.panDelta||new t.Point(0,0))._add(T.panDelta)),T.zoomDelta&&(o.zoomDelta=(o.zoomDelta||0)+T.zoomDelta),T.bearingDelta&&(o.bearingDelta=(o.bearingDelta||0)+T.bearingDelta),T.pitchDelta&&(o.pitchDelta=(o.pitchDelta||0)+T.pitchDelta),T.around!==void 0&&(o.around=T.around),T.aroundCoord!==void 0&&(o.aroundCoord=T.aroundCoord),T.pinchAround!==void 0&&(o.pinchAround=T.pinchAround),T.noInertia&&(o.noInertia=T.noInertia),t.extend(d,S),t.extend(v,D);this._updateMapTransform(o,d,v),this._changes=[]}_updateMapTransform(o,d,v){const T=this._map,S=T.transform,D=oe=>[oe.x,oe.y,oe.z];if((oe=>{const ge=this._eventsInProgress.drag;return ge&&!this._handlersById[ge.handlerName].isActive()})()&&!jo(o)){const oe=S.zoom;S.cameraElevationReference="sea",S.recenterOnTerrain(),S.cameraElevationReference="ground",oe!==S.zoom&&this._map._update(!0)}if(S._isCameraConstrained&&T._stop(!0),!jo(o))return void this._fireEvents(d,v,!0);let{panDelta:z,zoomDelta:N,bearingDelta:q,pitchDelta:G,around:Y,aroundCoord:ie,pinchAround:se}=o;S._isCameraConstrained&&(N>0&&(N=0),S._isCameraConstrained=!1),se!==void 0&&(Y=se),(N||(oe=>d[oe]&&!this._eventsInProgress[oe])("drag"))&&Y&&(this._dragOrigin=D(S.pointCoordinate3D(Y)),this._trackingEllipsoid.setup(S._camera.position,this._dragOrigin)),S.cameraElevationReference="sea",T._stop(!0),Y=Y||T.transform.centerPoint,q&&(S.bearing+=q),G&&(S.pitch+=G),S._updateCameraState();const ue=[0,0,0];if(z)if(S.projection.name==="mercator"){const oe=this._trackingEllipsoid.projectRay(S.screenPointToMercatorRay(Y).dir),ge=this._trackingEllipsoid.projectRay(S.screenPointToMercatorRay(Y.sub(z)).dir);ue[0]=ge[0]-oe[0],ue[1]=ge[1]-oe[1]}else{const oe=S.pointCoordinate(Y);if(S.projection.name==="globe"){z=z.rotate(-S.angle);const ge=S._pixelsPerMercatorPixel/S.worldSize;ue[0]=-z.x*t.mercatorScale(t.latFromMercatorY(oe.y))*ge,ue[1]=-z.y*t.mercatorScale(S.center.lat)*ge}else{const ge=S.pointCoordinate(Y.sub(z));oe&&ge&&(ue[0]=ge.x-oe.x,ue[1]=ge.y-oe.y)}}const le=S.zoom,fe=[0,0,0];if(N){const oe=D(ie||S.pointCoordinate3D(Y)),ge={dir:t.normalize([],t.sub([],oe,S._camera.position))};if(ge.dir[2]<0){const _e=S.zoomDeltaToMovement(oe,N);t.scale$2(fe,ge.dir,_e)}}const H=t.add(ue,ue,fe);S._translateCameraConstrained(H),N&&Math.abs(S.zoom-le)>1e-4&&S.recenterOnTerrain(),S.cameraElevationReference="ground",this._map._update(),o.noInertia||this._inertia.record(o),this._fireEvents(d,v,!0)}_fireEvents(o,d,v){const T=ko(this._eventsInProgress),S=ko(o),D={};for(const G in o){const{originalEvent:Y}=o[G];this._eventsInProgress[G]||(D[`${G}start`]=Y),this._eventsInProgress[G]=o[G]}!T&&S&&this._fireEvent("movestart",S.originalEvent);for(const G in D)this._fireEvent(G,D[G]);S&&this._fireEvent("move",S.originalEvent);for(const G in o){const{originalEvent:Y}=o[G];this._fireEvent(G,Y)}const z={};let N;for(const G in this._eventsInProgress){const{handlerName:Y,originalEvent:ie}=this._eventsInProgress[G];this._handlersById[Y].isActive()||(delete this._eventsInProgress[G],N=d[Y]||ie,z[`${G}end`]=N)}for(const G in z)this._fireEvent(G,z[G]);const q=ko(this._eventsInProgress);if(v&&(T||S)&&!q){this._updatingCamera=!0;const G=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),Y=ie=>ie!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Md("renderFrame",{timeStamp:o})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const xa="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class ec extends t.Evented{constructor(o,d){super(),this._moving=!1,this._zooming=!1,this.transform=o,this._bearingSnap=d.bearingSnap,this._respectPrefersReducedMotion=d.respectPrefersReducedMotion!==!1,t.bindAll(["_renderFrameCallback"],this)}getCenter(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(o,d){return this.jumpTo({center:o},d)}panBy(o,d,v){return o=t.Point.convert(o).mult(-1),this.panTo(this.transform.center,t.extend({offset:o},d),v)}panTo(o,d,v){return this.easeTo(t.extend({center:o},d),v)}getZoom(){return this.transform.zoom}setZoom(o,d){return this.jumpTo({zoom:o},d),this}zoomTo(o,d,v){return this.easeTo(t.extend({zoom:o},d),v)}zoomIn(o,d){return this.zoomTo(this.getZoom()+1,o,d),this}zoomOut(o,d){return this.zoomTo(this.getZoom()-1,o,d),this}getBearing(){return this.transform.bearing}setBearing(o,d){return this.jumpTo({bearing:o},d),this}getPadding(){return this.transform.padding}setPadding(o,d){return this.jumpTo({padding:o},d),this}rotateTo(o,d,v){return this.easeTo(t.extend({bearing:o},d),v)}resetNorth(o,d){return this.rotateTo(0,t.extend({duration:1e3},o),d),this}resetNorthPitch(o,d){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},o),d),this}snapToNorth(o,d){return Math.abs(this.getBearing())o.aspect?v/(2*Math.tan(.5*o.fovX)*o.aspect):T/(2*Math.tan(.5*o.fovY)*o.aspect)}_cameraForBoundsOnGlobe(o,d,v,T,S,D){const z=o.clone(),N=this._extendCameraOptions(D);z.bearing=T,z.pitch=S;const q=t.LngLat.convert(d),G=t.LngLat.convert(v),Y=.5*(q.lat+G.lat),ie=.5*(q.lng+G.lng),se=t.latLngToECEF(Y,ie),ue=t.normalize([],se),le=t.normalize([],t.cross([],ue,[0,1,0])),fe=t.cross([],le,ue),H=[le[0],le[1],le[2],0,fe[0],fe[1],fe[2],0,ue[0],ue[1],ue[2],0,0,0,0,1],oe=[se,t.latLngToECEF(q.lat,q.lng),t.latLngToECEF(G.lat,q.lng),t.latLngToECEF(G.lat,G.lng),t.latLngToECEF(q.lat,G.lng),t.latLngToECEF(Y,q.lng),t.latLngToECEF(Y,G.lng),t.latLngToECEF(q.lat,ie),t.latLngToECEF(G.lat,ie)];let ge=t.Aabb.fromPoints(oe.map(ct=>[t.dot(le,ct),t.dot(fe,ct),t.dot(ue,ct)]));const _e=t.transformMat4([],ge.center,H);t.squaredLength(_e)===0&&t.set(_e,0,0,1),t.normalize(_e,_e),t.scale$2(_e,_e,t.GLOBE_RADIUS),z.center=t.ecefToLatLng(_e);const Ae=z.getWorldToCameraMatrix(),Re=t.invert(new Float64Array(16),Ae);ge=t.Aabb.applyTransform(ge,t.multiply([],Ae,H)),t.transformMat4(_e,_e,Ae);const Pe=.5*(ge.max[2]-ge.min[2]),Be=this._minimumAABBFrustumDistance(z,ge),Oe=t.scale$2([],[0,0,1],Pe),Xe=t.add(Oe,_e,Oe),pt=Be+(z.pitch===0?0:t.distance(_e,Xe)),qe=z.globeCenterInViewSpace,ot=t.sub([],_e,[qe[0],qe[1],qe[2]]);t.normalize(ot,ot),t.scale$2(ot,ot,pt);const He=t.add([],_e,ot);t.transformMat4(He,He,Re);const dt=t.earthRadius/t.GLOBE_RADIUS,$e=t.length(He),it=t.mercatorZfromAltitude(Math.max($e*dt-t.earthRadius,Number.EPSILON),0),yt=Math.min(z.zoomFromMercatorZAdjusted(it),N.maxZoom);return yt>.5*(t.GLOBE_ZOOM_THRESHOLD_MIN+t.GLOBE_ZOOM_THRESHOLD_MAX)?(z.setProjection({name:"mercator"}),z.zoom=yt,this._cameraForBounds(z,d,v,T,S,D)):{center:z.center,zoom:yt,bearing:T,pitch:S}}queryTerrainElevation(o,d){const v=this.transform.elevation;return v?(d=t.extend({},{exaggerated:!0},d),v.getAtPoint(t.MercatorCoordinate.fromLngLat(o),null,d.exaggerated)):null}_cameraForBounds(o,d,v,T,S,D){if(o.projection.name==="globe")return this._cameraForBoundsOnGlobe(o,d,v,T,S,D);const z=o.clone(),N=this._extendCameraOptions(D),q=z.padding;z.bearing=T,z.pitch=S;const G=t.LngLat.convert(d),Y=t.LngLat.convert(v),ie=new t.LngLat(G.lng,Y.lat),se=new t.LngLat(Y.lng,G.lat),ue=z.project(G),le=z.project(Y),fe=this.queryTerrainElevation(G),H=this.queryTerrainElevation(Y),oe=this.queryTerrainElevation(ie),ge=this.queryTerrainElevation(se),_e=[[ue.x,ue.y,Math.min(fe||0,H||0,oe||0,ge||0)],[le.x,le.y,Math.max(fe||0,H||0,oe||0,ge||0)]];let Ae=t.Aabb.fromPoints(_e);const Re=z.getWorldToCameraMatrix(),Pe=t.invert(new Float64Array(16),Re);Ae=t.Aabb.applyTransform(Ae,Re);const Be=t.sub([],Ae.max,Ae.min),Oe=q.left||0,Xe=q.right||0,pt=q.bottom||0,qe=q.top||0,{left:ot,right:He,top:dt,bottom:$e}=N.padding,it=.5*(Oe+Xe),yt=.5*(qe+pt),ct=Math.min(z.scaleZoom(z.scale*Math.min((z.width-(Oe+Xe+ot+He))/Be[0],(z.height-(pt+qe+$e+dt))/Be[1])),N.maxZoom),bt=z.scale/z.zoomScale(ct);Ae=new t.Aabb([Ae.min[0]-(ot+it)*bt,Ae.min[1]-($e+yt)*bt,Ae.min[2]],[Ae.max[0]+(He+it)*bt,Ae.max[1]+(dt+yt)*bt,Ae.max[2]]);const $t=.5*Be[2],un=this._minimumAABBFrustumDistance(z,Ae),Ut=[0,0,1,0];t.transformMat4$1(Ut,Ut,Re),t.normalize$2(Ut,Ut);const Kt=t.scale$2([],Ut,un+$t),An=t.add([],Ae.center,Kt),Cn=(typeof N.offset.x=="number"&&typeof N.offset.y=="number"?new t.Point(N.offset.x,N.offset.y):t.Point.convert(N.offset)).rotate(-t.degToRad(T));Ae.center[0]-=Cn.x*bt,Ae.center[1]+=Cn.y*bt,t.transformMat4(Ae.center,Ae.center,Pe),t.transformMat4(An,An,Pe);const qt=[Ae.center[0],Ae.center[1],An[2]*z.pixelsPerMeter];t.scale$2(qt,qt,1/z.worldSize);const Yn=t.lngFromMercatorX(qt[0]),ei=t.latFromMercatorY(qt[1]),ti=Math.min(z._zoomFromMercatorZ(qt[2]),N.maxZoom),ni=new t.LngLat(Yn,ei);return z.mercatorFromTransition&&ti<.5*(t.GLOBE_ZOOM_THRESHOLD_MIN+t.GLOBE_ZOOM_THRESHOLD_MAX)?(z.setProjection({name:"globe"}),z.zoom=ti,this._cameraForBounds(z,d,v,T,S,D)):{center:ni,zoom:ti,bearing:T,pitch:S}}fitBounds(o,d,v){const T=this.cameraForBounds(o,d);return this._fitInternal(T,d,v)}fitScreenCoordinates(o,d,v,T,S){const D=t.Point.convert(o),z=t.Point.convert(d),N=new t.Point(Math.min(D.x,z.x),Math.min(D.y,z.y)),q=new t.Point(Math.max(D.x,z.x),Math.max(D.y,z.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(D,z))return this;const G=this.transform.pointLocation3D(N),Y=this.transform.pointLocation3D(q),ie=this.transform.pointLocation3D(new t.Point(N.x,q.y)),se=this.transform.pointLocation3D(new t.Point(q.x,N.y)),ue=[Math.min(G.lng,Y.lng,ie.lng,se.lng),Math.min(G.lat,Y.lat,ie.lat,se.lat)],le=[Math.max(G.lng,Y.lng,ie.lng,se.lng),Math.max(G.lat,Y.lat,ie.lat,se.lat)],fe=T&&T.pitch?T.pitch:this.getPitch(),H=this._cameraForBounds(this.transform,ue,le,v,fe,T);return this._fitInternal(H,T,S)}_fitInternal(o,d,v){return o?(delete(d=t.extend(o,d)).padding,d.linear?this.easeTo(d,v):this.flyTo(d,v)):this}jumpTo(o,d){this.stop();const v=o.preloadOnly?this.transform.clone():this.transform;let T=!1,S=!1,D=!1;return"zoom"in o&&v.zoom!==+o.zoom&&(T=!0,v.zoom=+o.zoom),o.center!==void 0&&(v.center=t.LngLat.convert(o.center)),"bearing"in o&&v.bearing!==+o.bearing&&(S=!0,v.bearing=+o.bearing),"pitch"in o&&v.pitch!==+o.pitch&&(D=!0,v.pitch=+o.pitch),o.padding==null||v.isPaddingEqual(o.padding)||(v.padding=o.padding),o.preloadOnly?(this._preloadTiles(v),this):(this.fire(new t.Event("movestart",d)).fire(new t.Event("move",d)),T&&this.fire(new t.Event("zoomstart",d)).fire(new t.Event("zoom",d)).fire(new t.Event("zoomend",d)),S&&this.fire(new t.Event("rotatestart",d)).fire(new t.Event("rotate",d)).fire(new t.Event("rotateend",d)),D&&this.fire(new t.Event("pitchstart",d)).fire(new t.Event("pitch",d)).fire(new t.Event("pitchend",d)),this.fire(new t.Event("moveend",d)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||t.warnOnce(xa),this.transform.getFreeCameraOptions()}setFreeCameraOptions(o,d){const v=this.transform;if(!v.projection.supportsFreeCamera)return t.warnOnce(xa),this;this.stop();const T=v.zoom,S=v.pitch,D=v.bearing;v.setFreeCameraOptions(o);const z=T!==v.zoom,N=S!==v.pitch,q=D!==v.bearing;return this.fire(new t.Event("movestart",d)).fire(new t.Event("move",d)),z&&this.fire(new t.Event("zoomstart",d)).fire(new t.Event("zoom",d)).fire(new t.Event("zoomend",d)),q&&this.fire(new t.Event("rotatestart",d)).fire(new t.Event("rotate",d)).fire(new t.Event("rotateend",d)),N&&this.fire(new t.Event("pitchstart",d)).fire(new t.Event("pitch",d)).fire(new t.Event("pitchend",d)),this.fire(new t.Event("moveend",d)),this}easeTo(o,d){this._stop(!1,o.easeId),((o=t.extend({offset:[0,0],duration:500,easing:t.ease},o)).animate===!1||this._prefersReducedMotion(o))&&(o.duration=0);const v=this.transform,T=this.getZoom(),S=this.getBearing(),D=this.getPitch(),z=this.getPadding(),N="zoom"in o?+o.zoom:T,q="bearing"in o?this._normalizeBearing(o.bearing,S):S,G="pitch"in o?+o.pitch:D,Y="padding"in o?o.padding:v.padding,ie=t.Point.convert(o.offset);let se,ue,le;if(v.projection.name==="globe"){const Oe=t.MercatorCoordinate.fromLngLat(v.center),Xe=ie.rotate(-v.angle);Oe.x+=Xe.x/v.worldSize,Oe.y+=Xe.y/v.worldSize;const pt=Oe.toLngLat(),qe=t.LngLat.convert(o.center||pt);this._normalizeCenter(qe),se=v.centerPoint.add(Xe),ue=new t.Point(Oe.x,Oe.y).mult(v.worldSize),le=new t.Point(t.mercatorXfromLng(qe.lng),t.mercatorYfromLat(qe.lat)).mult(v.worldSize).sub(ue)}else{se=v.centerPoint.add(ie);const Oe=v.pointLocation(se),Xe=t.LngLat.convert(o.center||Oe);this._normalizeCenter(Xe),ue=v.project(Oe),le=v.project(Xe).sub(ue)}const fe=v.zoomScale(N-T);let H,oe;o.around&&(H=t.LngLat.convert(o.around),oe=v.locationPoint(H));const ge=this._zooming||N!==T,_e=this._rotating||S!==q,Ae=this._pitching||G!==D,Re=!v.isPaddingEqual(Y),Pe=Oe=>Xe=>{if(ge&&(Oe.zoom=t.number(T,N,Xe)),_e&&(Oe.bearing=t.number(S,q,Xe)),Ae&&(Oe.pitch=t.number(D,G,Xe)),Re&&(Oe.interpolatePadding(z,Y,Xe),se=Oe.centerPoint.add(ie)),H)Oe.setLocationAtPoint(H,oe);else{const pt=Oe.zoomScale(Oe.zoom-T),qe=N>T?Math.min(2,fe):Math.max(.5,fe),ot=Math.pow(qe,1-Xe),He=Oe.unproject(ue.add(le.mult(Xe*ot)).mult(pt));Oe.setLocationAtPoint(Oe.renderWorldCopies?He.wrap():He,se)}return o.preloadOnly||this._fireMoveEvents(d),Oe};if(o.preloadOnly){const Oe=this._emulate(Pe,o.duration,v);return this._preloadTiles(Oe),this}const Be={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ge,this._rotating=_e,this._pitching=Ae,this._padding=Re,this._easeId=o.easeId,this._prepareEase(d,o.noMoveStart,Be),this._ease(Pe(v),Oe=>{v.recenterOnTerrain(),this._afterEase(d,Oe)},o),this}_prepareEase(o,d,v={}){this._moving=!0,this.transform.cameraElevationReference="sea",d||v.moving||this.fire(new t.Event("movestart",o)),this._zooming&&!v.zooming&&this.fire(new t.Event("zoomstart",o)),this._rotating&&!v.rotating&&this.fire(new t.Event("rotatestart",o)),this._pitching&&!v.pitching&&this.fire(new t.Event("pitchstart",o))}_fireMoveEvents(o){this.fire(new t.Event("move",o)),this._zooming&&this.fire(new t.Event("zoom",o)),this._rotating&&this.fire(new t.Event("rotate",o)),this._pitching&&this.fire(new t.Event("pitch",o))}_afterEase(o,d){if(this._easeId&&d&&this._easeId===d)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const v=this._zooming,T=this._rotating,S=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,v&&this.fire(new t.Event("zoomend",o)),T&&this.fire(new t.Event("rotateend",o)),S&&this.fire(new t.Event("pitchend",o)),this.fire(new t.Event("moveend",o))}flyTo(o,d){if(this._prefersReducedMotion(o)){const ct=t.pick(o,["center","zoom","bearing","pitch","around"]);return this.jumpTo(ct,d)}this.stop(),o=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},o);const v=this.transform,T=this.getZoom(),S=this.getBearing(),D=this.getPitch(),z=this.getPadding(),N="zoom"in o?t.clamp(+o.zoom,v.minZoom,v.maxZoom):T,q="bearing"in o?this._normalizeBearing(o.bearing,S):S,G="pitch"in o?+o.pitch:D,Y="padding"in o?o.padding:v.padding,ie=v.zoomScale(N-T),se=t.Point.convert(o.offset);let ue=v.centerPoint.add(se);const le=v.pointLocation(ue),fe=t.LngLat.convert(o.center||le);this._normalizeCenter(fe);const H=v.project(le),oe=v.project(fe).sub(H);let ge=o.curve;const _e=Math.max(v.width,v.height),Ae=_e/ie,Re=oe.mag();if("minZoom"in o){const ct=t.clamp(Math.min(o.minZoom,T,N),v.minZoom,v.maxZoom),bt=_e/v.zoomScale(ct-T);ge=Math.sqrt(bt/Re*2)}const Pe=ge*ge;function Be(ct){const bt=(Ae*Ae-_e*_e+(ct?-1:1)*Pe*Pe*Re*Re)/(2*(ct?Ae:_e)*Pe*Re);return Math.log(Math.sqrt(bt*bt+1)-bt)}function Oe(ct){return(Math.exp(ct)-Math.exp(-ct))/2}function Xe(ct){return(Math.exp(ct)+Math.exp(-ct))/2}const pt=Be(0);let qe=function(ct){return Xe(pt)/Xe(pt+ge*ct)},ot=function(ct){return _e*((Xe(pt)*(Oe(bt=pt+ge*ct)/Xe(bt))-Oe(pt))/Pe)/Re;var bt},He=(Be(1)-pt)/ge;if(Math.abs(Re)<1e-6||!isFinite(He)){if(Math.abs(_e-Ae)<1e-6)return this.easeTo(o,d);const ct=Ae<_e?-1:1;He=Math.abs(Math.log(Ae/_e))/ge,ot=function(){return 0},qe=function(bt){return Math.exp(ct*ge*bt)}}o.duration="duration"in o?+o.duration:1e3*He/("screenSpeed"in o?+o.screenSpeed/ge:+o.speed),o.maxDuration&&o.duration>o.maxDuration&&(o.duration=0);const dt=S!==q,$e=G!==D,it=!v.isPaddingEqual(Y),yt=ct=>bt=>{const $t=bt*He,un=1/qe($t);ct.zoom=bt===1?N:T+ct.scaleZoom(un),dt&&(ct.bearing=t.number(S,q,bt)),$e&&(ct.pitch=t.number(D,G,bt)),it&&(ct.interpolatePadding(z,Y,bt),ue=ct.centerPoint.add(se));const Ut=bt===1?fe:ct.unproject(H.add(oe.mult(ot($t))).mult(un));return ct.setLocationAtPoint(ct.renderWorldCopies?Ut.wrap():Ut,ue),ct._updateCameraOnTerrain(),o.preloadOnly||this._fireMoveEvents(d),ct};if(o.preloadOnly){const ct=this._emulate(yt,o.duration,v);return this._preloadTiles(ct),this}return this._zooming=!0,this._rotating=dt,this._pitching=$e,this._padding=it,this._prepareEase(d,!1),this._ease(yt(v),()=>this._afterEase(d),o),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(o,d){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const v=this._onEaseEnd;this._onEaseEnd=void 0,v.call(this,d)}if(!o){const v=this.handlers;v&&v.stop(!1)}return this}_ease(o,d,v){v.animate===!1||v.duration===0?(o(1),d()):(this._easeStart=t.exported.now(),this._easeOptions=v,this._onEaseFrame=o,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const o=Math.min((t.exported.now()-this._easeStart)/this._easeOptions.duration,1),d=this._onEaseFrame;d&&d(this._easeOptions.easing(o)),o<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(o,d){o=t.wrap(o,-180,180);const v=Math.abs(o-d);return Math.abs(o-360-d)180?-360:v<-180?360:0}_prefersReducedMotion(o){return this._respectPrefersReducedMotion&&t.exported.prefersReducedMotion&&!(o&&o.essential)}_emulate(o,d,v){const T=Math.ceil(15*d/1e3),S=[],D=o(v.clone());for(let z=0;z<=T;z++){const N=D(z/T);S.push(N.clone())}return S}}class Ft{constructor(o={}){this.options=o,t.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(o){const d=this.options&&this.options.compact;return this._map=o,this._container=F("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=F("button","mapboxgl-ctrl-attrib-button",this._container),F("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=F("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),d&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),d===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(o,d){const v=this._map._getUIString(`AttributionControl.${d}`);o.setAttribute("aria-label",v),o.removeAttribute("title"),o.firstElementChild&&o.firstElementChild.setAttribute("title",v)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let o=this._editLink;o||(o=this._editLink=this._container.querySelector(".mapbox-improve-map"));const d=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(o){const v=d.reduce((T,S,D)=>(S.value&&(T+=`${S.key}=${S.value}${DT.length-S.length),o=o.filter((T,S)=>{for(let D=S+1;D=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?o=[...this.options.customAttribution,...o]:o.unshift(this.options.customAttribution));const v=o.join(" | ");v!==this._attribHTML&&(this._attribHTML=v,o.length?(this._innerContainer.innerHTML=v,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class _h{constructor(){t.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(o){this._map=o,this._container=F("div","mapboxgl-ctrl");const d=F("a","mapboxgl-ctrl-logo");return d.target="_blank",d.rel="noopener nofollow",d.href="https://www.mapbox.com/",d.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),d.setAttribute("rel","noopener nofollow"),this._container.appendChild(d),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(o){o&&o.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const o=this._map.style._sourceCaches;if(Object.entries(o).length===0)return!0;for(const d in o){const v=o[d].getSource();if(v.hasOwnProperty("mapbox_logo")&&!v.mapbox_logo)return!1}return!0}_updateCompact(){const o=this._container.children;if(o.length){const d=o[0];this._map.getCanvasContainer().offsetWidth<250?d.classList.add("mapboxgl-compact"):d.classList.remove("mapboxgl-compact")}}}class yh{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(o){const d=++this._id;return this._queue.push({callback:o,id:d,cancelled:!1}),d}remove(o){const d=this._currentlyRunning,v=d?this._queue.concat(d):this._queue;for(const T of v)if(T.id===o)return void(T.cancelled=!0)}run(o=0){const d=this._currentlyRunning=this._queue;this._queue=[];for(const v of d)if(!v.cancelled&&(v.callback(o),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function ul(_,o,d){if(_=new t.LngLat(_.lng,_.lat),o){const v=new t.LngLat(_.lng-360,_.lat),T=new t.LngLat(_.lng+360,_.lat),S=360*Math.ceil(Math.abs(_.lng-d.center.lng)/360),D=d.locationPoint(_).distSqr(o),z=o.x<0||o.y<0||o.x>d.width||o.y>d.height;d.locationPoint(v).distSqr(o)180;){const v=d.locationPoint(_);if(v.x>=0&&v.y>=0&&v.x<=d.width&&v.y<=d.height)break;_.lng>d.center.lng?_.lng-=360:_.lng+=360}return _}const ba={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class zt extends t.Evented{constructor(o,d){if(super(),(o instanceof t.window.HTMLElement||d)&&(o=t.extend({element:o},d)),t.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=o&&o.anchor||"center",this._color=o&&o.color||"#3FB1CE",this._scale=o&&o.scale||1,this._draggable=o&&o.draggable||!1,this._clickTolerance=o&&o.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=o&&o.rotation||0,this._rotationAlignment=o&&o.rotationAlignment||"auto",this._pitchAlignment=o&&o.pitchAlignment&&o.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=o&&o.occludedOpacity||.2,o&&o.element)this._element=o.element,this._offset=t.Point.convert(o&&o.offset||[0,0]);else{this._defaultMarker=!0,this._element=F("div");const T=41,S=27,D=U("svg",{display:"block",height:T*this._scale+"px",width:S*this._scale+"px",viewBox:`0 0 ${S} ${T}`},this._element),z=U("radialGradient",{id:"shadowGradient"},U("defs",{},D));U("stop",{offset:"10%","stop-opacity":.4},z),U("stop",{offset:"100%","stop-opacity":.05},z),U("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},D),U("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},D),U("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},D),U("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},D),this._offset=t.Point.convert(o&&o.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",T=>{T.preventDefault()}),this._element.addEventListener("mousedown",T=>{T.preventDefault()});const v=this._element.classList;for(const T in ba)v.remove(`mapboxgl-marker-anchor-${T}`);v.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(o){return o===this._map||(this.remove(),this._map=o,o.getCanvasContainer().appendChild(this._element),o.on("move",this._updateMoving),o.on("moveend",this._update),o.on("remove",this._clearFadeTimer),o._addMarker(this),this.setDraggable(this._draggable),this._update(),o.on("click",this._onMapClick)),this}remove(){const o=this._map;return o&&(o.off("click",this._onMapClick),o.off("move",this._updateMoving),o.off("moveend",this._update),o.off("mousedown",this._addDragHandler),o.off("touchstart",this._addDragHandler),o.off("mouseup",this._onUp),o.off("touchend",this._onUp),o.off("mousemove",this._onMove),o.off("touchmove",this._onMove),o.off("remove",this._clearFadeTimer),o._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(o){return this._lngLat=t.LngLat.convert(o),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(o){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),o){if(!("offset"in o.options)){const T=Math.sqrt(Math.pow(13.5,2)/2);o.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[T,-1*(24.6+T)],"bottom-right":[-T,-1*(24.6+T)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=o,o._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(o){const d=o.code,v=o.charCode||o.keyCode;d!=="Space"&&d!=="Enter"&&v!==32&&v!==13||this.togglePopup()}_onMapClick(o){const d=o.originalEvent.target,v=this._element;this._popup&&(d===v||v.contains(d))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const o=this._popup;return o?(o.isOpen()?(o.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(o.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const o=this._map,d=this._pos;if(!o||!d)return!1;const v=o.unproject(d),T=o.getFreeCameraOptions();if(!T.position)return!1;const S=T.position.toLngLat();return S.distanceTo(v)<.9*S.distanceTo(this._lngLat)}_evaluateOpacity(){const o=this._map;if(!o)return;const d=this._pos;if(!d||d.x<0||d.x>o.transform.width||d.y<0||d.y>o.transform.height)return void this._clearFadeTimer();const v=o.unproject(d);let T;o._showingGlobe()&&t.isLngLatBehindGlobe(o.transform,this._lngLat)?T=0:(T=1-o._queryFogOpacity(v),o.transform._terrainEnabled()&&o.getTerrain()&&this._behindTerrain()&&(T*=this._occludedOpacity)),this._element.style.opacity=`${T}`,this._element.style.pointerEvents=T>0?"auto":"none",this._popup&&this._popup._setOpacity(T),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const o=this._pos;if(!o||!this._map)return;const d=this._offset.mult(this._scale);this._element.style.transform=` translate(${o.x}px,${o.y}px) ${ba[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${d.x}px,${d.y}px) `}_calculateXYTransform(){const o=this._pos,d=this._map,v=this.getPitchAlignment();if(!d||!o||v!=="map")return"";if(!d._showingGlobe()){const N=d.getPitch();return N?`rotateX(${N}deg)`:""}const T=t.radToDeg(t.globeTiltAtLngLat(d.transform,this._lngLat)),S=o.sub(t.globeCenterToScreenPoint(d.transform)),D=Math.abs(S.x)+Math.abs(S.y);if(D===0)return"";const z=T/D;return`rotateX(${-S.y*z}deg) rotateY(${S.x*z}deg)`}_calculateZTransform(){const o=this._pos,d=this._map;if(!d||!o)return"";let v=0;const T=this.getRotationAlignment();if(T==="map")if(d._showingGlobe()){const S=d.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),D=d.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(S);v=t.radToDeg(Math.atan2(D.y,D.x))-90}else v=-d.getBearing();else if(T==="horizon"){const S=t.smoothstep(4,6,d.getZoom()),D=t.globeCenterToScreenPoint(d.transform);D.y+=S*d.transform.height;const z=o.sub(D),N=t.radToDeg(Math.atan2(z.y,z.x));v=(N>90?N-270:N+90)*(1-S)}return v+=this._rotation,v?`rotateZ(${v}deg)`:""}_update(o){t.window.cancelAnimationFrame(this._updateFrameId);const d=this._map;d&&(d.transform.renderWorldCopies&&(this._lngLat=ul(this._lngLat,this._pos,d.transform)),this._pos=d.project(this._lngLat),o===!0?this._updateFrameId=t.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),d._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(d._showingGlobe()||d.getTerrain()||d.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(o){return this._offset=t.Point.convert(o),this._update(),this}_onMove(o){const d=this._map;if(!d)return;const v=this._pointerdownPos,T=this._positionDelta;if(v&&T){if(!this._isDragging){const S=this._clickTolerance||d._clickTolerance;if(o.point.dist(v)=this._endTime)return this._end;const d=t.easeCubicInOut((o-this._startTime)/(this._endTime-this._startTime));return this._start*(1-d)+this._end*d}isEasing(o){return o>=this._startTime&&o<=this._endTime}jumpTo(o){this._startTime=-1/0,this._endTime=-1/0,this._start=o,this._end=o}easeTo(o,d,v){this._start=this.getValue(d),this._end=o,this._startTime=d,this._endTime=d+v}}const kd={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},Cd={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0},Um={showCompass:!0,showZoom:!0,visualizePitch:!1};class jm{constructor(o,d,v=!1){this._clickTolerance=10,this.element=d,this.mouseRotate=new fh({clickTolerance:o.dragRotate._mouseRotate._clickTolerance}),this.map=o,v&&(this.mousePitch=new dh({clickTolerance:o.dragRotate._mousePitch._clickTolerance})),t.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),d.addEventListener("mousedown",this.mousedown),d.addEventListener("touchstart",this.touchstart,{passive:!1}),d.addEventListener("touchmove",this.touchmove),d.addEventListener("touchend",this.touchend),d.addEventListener("touchcancel",this.reset)}down(o,d){this.mouseRotate.mousedown(o,d),this.mousePitch&&this.mousePitch.mousedown(o,d),ye()}move(o,d){const v=this.map,T=this.mouseRotate.mousemoveWindow(o,d),S=T&&T.bearingDelta;if(S&&v.setBearing(v.getBearing()+S),this.mousePitch){const D=this.mousePitch.mousemoveWindow(o,d),z=D&&D.pitchDelta;z&&v.setPitch(v.getPitch()+z)}}off(){const o=this.element;o.removeEventListener("mousedown",this.mousedown),o.removeEventListener("touchstart",this.touchstart,{passive:!1}),o.removeEventListener("touchmove",this.touchmove),o.removeEventListener("touchend",this.touchend),o.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){te(),t.window.removeEventListener("mousemove",this.mousemove),t.window.removeEventListener("mouseup",this.mouseup)}mousedown(o){this.down(t.extend({},o,{ctrlKey:!0,preventDefault:()=>o.preventDefault()}),we(this.element,o)),t.window.addEventListener("mousemove",this.mousemove),t.window.addEventListener("mouseup",this.mouseup)}mousemove(o){this.move(o,we(this.element,o))}mouseup(o){this.mouseRotate.mouseupWindow(o),this.mousePitch&&this.mousePitch.mouseupWindow(o),this.offTemp()}touchstart(o){o.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=Ue(this.element,o.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>o.preventDefault()},this._startPos))}touchmove(o){o.targetTouches.length!==1?this.reset():(this._lastPos=Ue(this.element,o.targetTouches)[0],this.move({preventDefault:()=>o.preventDefault()},this._lastPos))}touchend(o){o.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)_.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(_.minPitch!=null&&_.maxPitch!=null&&_.minPitch>_.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(_.minPitch!=null&&_.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(_.maxPitch!=null&&_.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(_.antialias&&t.isSafariWithAntialiasingBug(t.window)&&(_.antialias=!1,t.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new ol(_.minZoom,_.maxZoom,_.minPitch,_.maxPitch,_.renderWorldCopies),_),this._interactive=_.interactive,this._minTileCacheSize=_.minTileCacheSize,this._maxTileCacheSize=_.maxTileCacheSize,this._failIfMajorPerformanceCaveat=_.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=_.preserveDrawingBuffer,this._antialias=_.antialias,this._useWebGL2=_.useWebGL2,this._trackResize=_.trackResize,this._bearingSnap=_.bearingSnap,this._refreshExpiredTiles=_.refreshExpiredTiles,this._fadeDuration=_.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=_.crossSourceCollisions,this._collectResourceTiming=_.collectResourceTiming,this._optimizeForTerrain=_.optimizeForTerrain,this._language=this._parseLanguage(_.language),this._worldview=_.worldview,this._renderTaskQueue=new yh,this._domRenderTaskQueue=new yh,this._controls=[],this._markers=[],this._popups=[],this._mapId=t.uniqueId(),this._locale=t.extend({},kd,_.locale),this._clickTolerance=_.clickTolerance,this._cooperativeGestures=_.cooperativeGestures,this._performanceMetricsCollection=_.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new xh(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new t.RequestManager(_.transformRequest,_.accessToken,_.testMode),this._silenceAuthErrors=!!_.testMode,typeof _.container=="string"){if(this._container=t.window.document.getElementById(_.container),!this._container)throw new Error(`Container '${_.container}' not found.`)}else{if(!(_.container instanceof t.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=_.container}if(this._container.childNodes.length>0&&t.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),_.maxBounds&&this.setMaxBounds(_.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),t.window!==void 0&&(t.window.addEventListener("online",this._onWindowOnline,!1),t.window.addEventListener("resize",this._onWindowResize,!1),t.window.addEventListener("orientationchange",this._onWindowResize,!1),t.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),t.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Qo(this,_),this._localFontFamily=_.localFontFamily,this._localIdeographFontFamily=_.localIdeographFontFamily,_.style&&this.setStyle(_.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),_.projection&&this.setProjection(_.projection),this._hash=_.hash&&new lh(typeof _.hash=="string"&&_.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:_.center,zoom:_.zoom,bearing:_.bearing,pitch:_.pitch}),_.bounds&&(this.resize(),this.fitBounds(_.bounds,t.extend({},_.fitBoundsOptions,{duration:0})))),this.resize(),_.attributionControl&&this.addControl(new Ft({customAttribution:_.customAttribution})),this._logoControl=new _h,this.addControl(this._logoControl,_.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",o=>{this._update(o.dataType==="style"),this.fire(new t.Event(`${o.dataType}data`,o))}),this.on("dataloading",o=>{this.fire(new t.Event(`${o.dataType}dataloading`,o))})}_getMapId(){return this._mapId}addControl(_,o){if(o===void 0&&(o=_.getDefaultPosition?_.getDefaultPosition():"top-right"),!_||!_.onAdd)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const d=_.onAdd(this);this._controls.push(_);const v=this._controlPositions[o];return o.indexOf("bottom")!==-1?v.insertBefore(d,v.firstChild):v.appendChild(d),this}removeControl(_){if(!_||!_.onRemove)return this.fire(new t.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const o=this._controls.indexOf(_);return o>-1&&this._controls.splice(o,1),_.onRemove(this),this}hasControl(_){return this._controls.indexOf(_)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(_){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const o=!this._moving;return o&&this.fire(new t.Event("movestart",_)).fire(new t.Event("move",_)),this.fire(new t.Event("resize",_)),o&&this.fire(new t.Event("moveend",_)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(_){return this.transform.setMaxBounds(t.LngLatBounds.convert(_)),this._update()}setMinZoom(_){if((_=_??-2)>=-2&&_<=this.transform.maxZoom)return this.transform.minZoom=_,this._update(),this.getZoom()<_?this.setZoom(_):this.fire(new t.Event("zoomstart")).fire(new t.Event("zoom")).fire(new t.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(_){if((_=_??22)>=this.transform.minZoom)return this.transform.maxZoom=_,this._update(),this.getZoom()>_?this.setZoom(_):this.fire(new t.Event("zoomstart")).fire(new t.Event("zoom")).fire(new t.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(_){if((_=_??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(_>=0&&_<=this.transform.maxPitch)return this.transform.minPitch=_,this._update(),this.getPitch()<_?this.setPitch(_):this.fire(new t.Event("pitchstart")).fire(new t.Event("pitch")).fire(new t.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(_){if((_=_??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(_>=this.transform.minPitch)return this.transform.maxPitch=_,this._update(),this.getPitch()>_?this.setPitch(_):this.fire(new t.Event("pitchstart")).fire(new t.Event("pitch")).fire(new t.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(_){return this.transform.renderWorldCopies=_,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(_){return _==="auto"?t.window.navigator.language:Array.isArray(_)?_.length===0?void 0:_.map(o=>o==="auto"?t.window.navigator.language:o):_}setLanguage(_){const o=this._parseLanguage(_);if(!this.style||o===this._language)return this;this._language=o,this.style._reloadSources();for(const d of this._controls)d._setLanguage&&d._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(_){return this.style&&_!==this._worldview?(this._worldview=_,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(_){return this._lazyInitEmptyStyle(),_?typeof _=="string"&&(_={name:_}):_=null,this._useExplicitProjection=!!_,this._prioritizeAndUpdateProjection(_,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const _=this.transform,o=_.projection.name;let d;o==="globe"&&_.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX?(_.setMercatorFromTransition(),d=!0):o==="mercator"&&_.zoom=t.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(_),this.style.applyProjectionUpdate(),o){this.painter.clearBackgroundTiles();for(const d in this.style._sourceCaches)this.style._sourceCaches[d].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(_){return this.transform.locationPoint3D(t.LngLat.convert(_))}unproject(_){return this.transform.pointLocation3D(t.Point.convert(_))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(_,o,d){if(_==="mouseenter"||_==="mouseover"){let v=!1;const T=D=>{const z=o.filter(q=>this.getLayer(q)),N=z.length?this.queryRenderedFeatures(D.point,{layers:z}):[];N.length?v||(v=!0,d.call(this,new pr(_,this,D.originalEvent,{features:N}))):v=!1},S=()=>{v=!1};return{layers:new Set(o),listener:d,delegates:{mousemove:T,mouseout:S}}}if(_==="mouseleave"||_==="mouseout"){let v=!1;const T=D=>{const z=o.filter(N=>this.getLayer(N));(z.length?this.queryRenderedFeatures(D.point,{layers:z}):[]).length?v=!0:v&&(v=!1,d.call(this,new pr(_,this,D.originalEvent)))},S=D=>{v&&(v=!1,d.call(this,new pr(_,this,D.originalEvent)))};return{layers:new Set(o),listener:d,delegates:{mousemove:T,mouseout:S}}}{const v=T=>{const S=o.filter(z=>this.getLayer(z)),D=S.length?this.queryRenderedFeatures(T.point,{layers:S}):[];D.length&&(T.features=D,d.call(this,T),delete T.features)};return{layers:new Set(o),listener:d,delegates:{[_]:v}}}}on(_,o,d){if(d===void 0)return super.on(_,o);Array.isArray(o)||(o=[o]);const v=this._createDelegatedListener(_,o,d);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[_]=this._delegatedListeners[_]||[],this._delegatedListeners[_].push(v);for(const T in v.delegates)this.on(T,v.delegates[T]);return this}once(_,o,d){if(d===void 0)return super.once(_,o);Array.isArray(o)||(o=[o]);const v=this._createDelegatedListener(_,o,d);for(const T in v.delegates)this.once(T,v.delegates[T]);return this}off(_,o,d){if(d===void 0)return super.off(_,o);o=new Set(Array.isArray(o)?o:[o]);const v=(S,D)=>{if(S.size!==D.size)return!1;for(const z of S)if(!D.has(z))return!1;return!0},T=this._delegatedListeners?this._delegatedListeners[_]:void 0;return T&&(S=>{for(let D=0;D{T?this.fire(new t.ErrorEvent(T)):S&&this._updateDiff(S,o)})}else typeof _=="object"&&this._updateDiff(_,o)}_updateDiff(_,o){try{this.style.setState(_)&&this._update(!0)}catch(d){t.warnOnce(`Unable to perform style diff: ${d.message||d.error||d}. Rebuilding the style from scratch.`),this._updateStyle(_,o)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(t.warnOnce("There is no style added to the map."),!1)}addSource(_,o){return this._lazyInitEmptyStyle(),this.style.addSource(_,o),this._update(!0)}isSourceLoaded(_){return!!this.style&&this.style._isSourceCacheLoaded(_)}areTilesLoaded(){const _=this.style&&this.style._sourceCaches;for(const o in _){const d=_[o]._tiles;for(const v in d){const T=d[v];if(T.state!=="loaded"&&T.state!=="errored")return!1}}return!0}addSourceType(_,o,d){this._lazyInitEmptyStyle(),this.style.addSourceType(_,o,d)}removeSource(_){return this.style.removeSource(_),this._updateTerrain(),this._update(!0)}getSource(_){return this.style.getSource(_)}addImage(_,o,{pixelRatio:d=1,sdf:v=!1,stretchX:T,stretchY:S,content:D}={}){if(this._lazyInitEmptyStyle(),o instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&o instanceof t.window.ImageBitmap){const{width:z,height:N,data:q}=t.exported.getImageData(o);this.style.addImage(_,{data:new t.RGBAImage({width:z,height:N},q),pixelRatio:d,stretchX:T,stretchY:S,content:D,sdf:v,version:0})}else if(o.width===void 0||o.height===void 0)this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:z,height:N}=o,q=o;this.style.addImage(_,{data:new t.RGBAImage({width:z,height:N},new Uint8Array(q.data)),pixelRatio:d,stretchX:T,stretchY:S,content:D,sdf:v,version:0,userImage:q}),q.onAdd&&q.onAdd(this,_)}}updateImage(_,o){const d=this.style.getImage(_);if(!d)return void this.fire(new t.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const v=o instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&o instanceof t.window.ImageBitmap?t.exported.getImageData(o):o,{width:T,height:S}=v;T!==void 0&&S!==void 0?T===d.data.width&&S===d.data.height?(d.data.replace(v.data,!(o instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&o instanceof t.window.ImageBitmap)),this.style.updateImage(_,d)):this.fire(new t.ErrorEvent(new Error(`The width and height of the updated image (${T}, ${S}) must be that same as the previous version of the image (${d.data.width}, ${d.data.height})`))):this.fire(new t.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(_){return _?!!this.style.getImage(_):(this.fire(new t.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(_){this.style.removeImage(_)}loadImage(_,o){t.getImage(this._requestManager.transformRequest(_,t.ResourceType.Image),(d,v)=>{o(d,v instanceof t.window.HTMLImageElement?t.exported.getImageData(v):v)})}listImages(){return this.style.listImages()}addLayer(_,o){return this._lazyInitEmptyStyle(),this.style.addLayer(_,o),this._update(!0)}moveLayer(_,o){return this.style.moveLayer(_,o),this._update(!0)}removeLayer(_){return this.style.removeLayer(_),this._update(!0)}getLayer(_){return this.style.getLayer(_)}setLayerZoomRange(_,o,d){return this.style.setLayerZoomRange(_,o,d),this._update(!0)}setFilter(_,o,d={}){return this.style.setFilter(_,o,d),this._update(!0)}getFilter(_){return this.style.getFilter(_)}setPaintProperty(_,o,d,v={}){return this.style.setPaintProperty(_,o,d,v),this._update(!0)}getPaintProperty(_,o){return this.style.getPaintProperty(_,o)}setLayoutProperty(_,o,d,v={}){return this.style.setLayoutProperty(_,o,d,v),this._update(!0)}getLayoutProperty(_,o){return this.style.getLayoutProperty(_,o)}setLight(_,o={}){return this._lazyInitEmptyStyle(),this.style.setLight(_,o),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(_){return this._lazyInitEmptyStyle(),!_&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(_),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(_){return this._lazyInitEmptyStyle(),this.style.setFog(_),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(_){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(t.LngLat.convert(_),this.transform):0}setFeatureState(_,o){return this.style.setFeatureState(_,o),this._update()}removeFeatureState(_,o){return this.style.removeFeatureState(_,o),this._update()}getFeatureState(_){return this.style.getFeatureState(_)}_updateContainerDimensions(){if(!this._container)return;const _=this._container.getBoundingClientRect().width||400,o=this._container.getBoundingClientRect().height||300;let d,v,T,S=this._container;for(;S&&(!v||!T);){const D=t.window.getComputedStyle(S).transform;D&&D!=="none"&&(d=D.match(/matrix.*\((.+)\)/)[1].split(", "),d[0]&&d[0]!=="0"&&d[0]!=="1"&&(v=d[0]),d[3]&&d[3]!=="0"&&d[3]!=="1"&&(T=d[3])),S=S.parentElement}this._containerWidth=v?Math.abs(_/v):_,this._containerHeight=T?Math.abs(o/T):o}_detectMissingCSS(){t.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&t.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const _=this._container;_.classList.add("mapboxgl-map"),(this._missingCSSCanary=F("div","mapboxgl-canary",_)).style.visibility="hidden",this._detectMissingCSS();const o=this._canvasContainer=F("div","mapboxgl-canvas-container",_);this._interactive&&o.classList.add("mapboxgl-interactive"),this._canvas=F("canvas","mapboxgl-canvas",o),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const d=this._controlContainer=F("div","mapboxgl-control-container",_),v=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(T=>{v[T]=F("div",`mapboxgl-ctrl-${T}`,d)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(_,o){const d=t.exported.devicePixelRatio||1;this._canvas.width=d*Math.ceil(_),this._canvas.height=d*Math.ceil(o),this._canvas.style.width=`${_}px`,this._canvas.style.height=`${o}px`}_addMarker(_){this._markers.push(_)}_removeMarker(_){const o=this._markers.indexOf(_);o!==-1&&this._markers.splice(o,1)}_addPopup(_){this._popups.push(_)}_removePopup(_){const o=this._popups.indexOf(_);o!==-1&&this._popups.splice(o,1)}_setupPainter(){const _=t.extend({},k.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),o=this._useWebGL2&&this._canvas.getContext("webgl2",_),d=o||this._canvas.getContext("webgl",_)||this._canvas.getContext("experimental-webgl",_);d?(this._useWebGL2&&!o&&t.warnOnce("Failed to create WebGL 2 context. Using WebGL 1."),t.storeAuthState(d,!0),this.painter=new dr(d,this.transform,!!o),this.on("data",v=>{v.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),t.exported$1.testSupport(d)):this.fire(new t.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(_){_.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new t.Event("webglcontextlost",{originalEvent:_}))}_contextRestored(_){this._setupPainter(),this.resize(),this._update(),this.fire(new t.Event("webglcontextrestored",{originalEvent:_}))}_onMapScroll(_){if(_.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(_){return this.style?(this._styleDirty=this._styleDirty||_,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(_){return this._update(),this._renderTaskQueue.add(_)}_cancelRenderFrame(_){this._renderTaskQueue.remove(_)}_requestDomTask(_){!this.loaded()||this.loaded()&&!this.isMoving()?_():this._domRenderTaskQueue.add(_)}_render(_){let o;const d=this.painter.context.extTimerQuery,v=t.exported.now();if(this.listens("gpu-timing-frame")&&(o=d.createQueryEXT(),d.beginQueryEXT(d.TIME_ELAPSED_EXT,o)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],t.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],t.window.performance.now())),this._renderTaskQueue.run(_),this._domRenderTaskQueue.run(_),this._removed)return;this._updateProjectionTransition();const T=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const z=this.transform.zoom,N=this.transform.pitch,q=t.exported.now(),G=new t.EvaluationParameters(z,{now:q,fadeDuration:T,pitch:N,transition:this.style.getTransition()});this.style.update(G)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let S=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),S=this._updateAverageElevation(v),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):S=this._updateAverageElevation(v),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,T,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:T,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new t.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),o){const z=t.exported.now()-v;d.endQueryEXT(d.TIME_ELAPSED_EXT,o),setTimeout(()=>{const N=d.getQueryObjectEXT(o,d.QUERY_RESULT_EXT)/1e6;d.deleteQueryEXT(o),this.fire(new t.Event("gpu-timing-frame",{cpuTime:z,gpuTime:N})),t.window.performance.mark("frame-gpu",{startTime:v,detail:{gpuTime:N}})},50)}if(this.listens("gpu-timing-layer")){const z=this.painter.collectGpuTimers();setTimeout(()=>{const N=this.painter.queryGpuTimers(z);this.fire(new t.Event("gpu-timing-layer",{layerTimes:N}))},50)}if(this.listens("gpu-timing-deferred-render")){const z=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const N=this.painter.queryGpuTimeDeferredRender(z);this.fire(new t.Event("gpu-timing-deferred-render",{gpuTime:N}))},50)}const D=this._sourcesDirty||this._styleDirty||this._placementDirty||S;if(D||this._repaint)this.triggerRepaint();else{const z=!this.isMoving()&&this.loaded();if(z&&(S=this._updateAverageElevation(v,!0)),S)this.triggerRepaint();else if(this._triggerFrame(!1),z&&(this.fire(new t.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const N=this._calculateSpeedIndex();this.fire(new t.Event("speedindexcompleted",{speedIndex:N})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||D||(this._fullyLoaded=!0,t.LivePerformanceUtils.mark(t.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&t.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(_){for(const o of this._markers)_&&!this.getRenderWorldCopies()&&(o._lngLat=o._lngLat.wrap()),o._update();for(const o of this._popups)!_||this.getRenderWorldCopies()||o._trackPointer||(o._lngLat=o._lngLat.wrap()),o._update()}_updateAverageElevation(_,o=!1){const d=v=>(this.transform.averageElevation=v,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&d(0);if((o||_-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(_)){const v=this.transform.averageElevation;let T=this.transform.sampleAverageElevation(),S=!1;this.transform.elevation&&(S=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(T)?T=0:this._averageElevationLastSampledAt=_;const D=Math.abs(v-T);if(D>1){if(this._isInitialLoad||S)return this._averageElevation.jumpTo(T),d(T);this._averageElevation.easeTo(T,_,300)}else if(D>1e-4)return this._averageElevation.jumpTo(T),d(T)}return!!this._averageElevation.isEasing(_)&&d(this._averageElevation.getValue(_))}_authenticate(){t.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,_=>{if(_&&(_.message===t.AUTH_ERR_MSG||_.status===401)){const o=this.painter.context.gl;t.storeAuthState(o,!1),this._logoControl instanceof _h&&this._logoControl._updateLogo(),o&&o.clear(o.DEPTH_BUFFER_BIT|o.COLOR_BUFFER_BIT|o.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new t.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),t.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const _=this._isDragging();this.painter.updateTerrain(this.style,_)}_calculateSpeedIndex(){const _=this.painter.canvasCopy(),o=this.painter.getCanvasCopiesAndTimestamps();o.timeStamps.push(performance.now());const d=this.painter.context.gl,v=d.createFramebuffer();function T(S){d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,S,0);const D=new Uint8Array(d.drawingBufferWidth*d.drawingBufferHeight*4);return d.readPixels(0,0,d.drawingBufferWidth,d.drawingBufferHeight,d.RGBA,d.UNSIGNED_BYTE,D),D}return d.bindFramebuffer(d.FRAMEBUFFER,v),this._canvasPixelComparison(T(_),o.canvasCopies.map(T),o.timeStamps)}_canvasPixelComparison(_,o,d){let v=d[1]-d[0];const T=_.length/4;for(let S=0;S{const d=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,d&&this._render(o)}))}_preloadTiles(_){const o=this.style?Object.values(this.style._sourceCaches):[];return t.asyncAll(o,(d,v)=>d._preloadTiles(_,v),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(_){this._trackResize&&this.resize({originalEvent:_})._update()}_onVisibilityChange(){t.window.document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(_){this._showTileBoundaries!==_&&(this._showTileBoundaries=_,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(_){this._showTerrainWireframe!==_&&(this._showTerrainWireframe=_,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(_){this._speedIndexTiming!==_&&(this._speedIndexTiming=_,this._update())}get showPadding(){return!!this._showPadding}set showPadding(_){this._showPadding!==_&&(this._showPadding=_,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(_){this._showCollisionBoxes!==_&&(this._showCollisionBoxes=_,_?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(_){this._showOverdrawInspector!==_&&(this._showOverdrawInspector=_,this._update())}get repaint(){return!!this._repaint}set repaint(_){this._repaint!==_&&(this._repaint=_,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(_){this._vertices=_,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(_){this._showTileAABBs!==_&&(this._showTileAABBs=_,_&&this._update())}_setCacheLimits(_,o){t.setCacheLimits(_,o)}get version(){return t.version}},NavigationControl:class{constructor(_){this.options=t.extend({},Um,_),this._container=F("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",o=>o.preventDefault()),this.options.showZoom&&(t.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",o=>{this._map&&this._map.zoomIn({},{originalEvent:o})}),F("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",o=>{this._map&&this._map.zoomOut({},{originalEvent:o})}),F("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(t.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",o=>{const d=this._map;d&&(this.options.visualizePitch?d.resetNorthPitch({},{originalEvent:o}):d.resetNorth({},{originalEvent:o}))}),this._compassIcon=F("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const _=this._map;if(!_)return;const o=_.getZoom(),d=o===_.getMaxZoom(),v=o===_.getMinZoom();this._zoomInButton.disabled=d,this._zoomOutButton.disabled=v,this._zoomInButton.setAttribute("aria-disabled",d.toString()),this._zoomOutButton.setAttribute("aria-disabled",v.toString())}_rotateCompassArrow(){const _=this._map;if(!_)return;const o=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(_.transform.pitch*(Math.PI/180)),.5)}) rotateX(${_.transform.pitch}deg) rotateZ(${_.transform.angle*(180/Math.PI)}deg)`:`rotate(${_.transform.angle*(180/Math.PI)}deg)`;_._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=o)})}onAdd(_){return this._map=_,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),_.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&_.on("pitch",this._rotateCompassArrow),_.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new jm(_,this._compass,this.options.visualizePitch)),this._container}onRemove(){const _=this._map;_&&(this._container.remove(),this.options.showZoom&&_.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&_.off("pitch",this._rotateCompassArrow),_.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(_,o){const d=F("button",_,this._container);return d.type="button",d.addEventListener("click",o),d}_setButtonTitle(_,o){if(!this._map)return;const d=this._map._getUIString(`NavigationControl.${o}`);_.setAttribute("aria-label",d),_.firstElementChild&&_.firstElementChild.setAttribute("title",d)}},GeolocateControl:class extends t.Evented{constructor(_){super(),this.options=t.extend({geolocation:t.window.navigator.geolocation},bh,_),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=sl(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(_){return this._map=_,this._container=F("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(_){const o=(d=!!this.options.geolocation)=>{this._supportsGeolocation=d,_(d)};this._supportsGeolocation!==void 0?_(this._supportsGeolocation):t.window.navigator.permissions!==void 0?t.window.navigator.permissions.query({name:"geolocation"}).then(d=>o(d.state!=="denied")).catch(()=>o()):o()}_isOutOfMapMaxBounds(_){const o=this._map.getMaxBounds(),d=_.coords;return!!o&&(d.longitudeo.getEast()||d.latitudeo.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(_){if(this._map){if(this._isOutOfMapMaxBounds(_))return this._setErrorState(),this.fire(new t.Event("outofmaxbounds",_)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=_,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(_),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(_),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",_)),this._finish()}}_updateCamera(_){const o=new t.LngLat(_.coords.longitude,_.coords.latitude),d=_.coords.accuracy,v=this._map.getBearing(),T=t.extend({bearing:v},this.options.fitBoundsOptions);this._map.fitBounds(o.toBounds(d),T,{geolocateSource:!0})}_updateMarker(_){if(_){const o=new t.LngLat(_.coords.longitude,_.coords.latitude);this._accuracyCircleMarker.setLngLat(o).addTo(this._map),this._userLocationDotMarker.setLngLat(o).addTo(this._map),this._accuracy=_.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const _=this._map.transform,o=t.mercatorZfromAltitude(1,_._center.lat)*_.worldSize,d=Math.ceil(2*this._accuracy*o);this._circleElement.style.width=`${d}px`,this._circleElement.style.height=`${d}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(_){if(this._map){if(this.options.trackUserLocation)if(_.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const o=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(_.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",_)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(_){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",o=>o.preventDefault()),this._geolocateButton=F("button","mapboxgl-ctrl-geolocate",this._container),F("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",_===!1){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const o=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o)}else{const o=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=F("div","mapboxgl-user-location"),this._dotElement.appendChild(F("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(F("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new zt({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=F("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new zt({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",o=>{o.geolocateSource||this._watchState!=="ACTIVE_LOCK"||o.originalEvent&&o.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new t.Event("trackuserlocationend")))})}}_onDeviceOrientation(_){this._userLocationDotMarker&&(_.webkitCompassHeading?this._heading=_.webkitCompassHeading:_.absolute===!0&&(this._heading=-1*_.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return t.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new t.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let _;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(_={maximumAge:6e5,timeout:0},this._noTimeout=!0):(_=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,_),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const _=()=>{t.window.addEventListener("ondeviceorientationabsolute"in t.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};t.window.DeviceMotionEvent!==void 0&&typeof t.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(o=>{o==="granted"&&_()}).catch(console.error):_()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),t.window.removeEventListener("deviceorientation",this._onDeviceOrientation),t.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Ft,ScaleControl:class{constructor(_){this.options=t.extend({},wh,_),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch{return!1}}(),t.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const _=this.options.maxWidth||100,o=this._map,d=o._containerHeight/2,v=o._containerWidth/2-_/2,T=o.unproject([v,d]),S=o.unproject([v+_,d]),D=T.distanceTo(S);if(this.options.unit==="imperial"){const z=3.2808*D;z>5280?this._setScale(_,z/5280,"mile"):this._setScale(_,z,"foot")}else this.options.unit==="nautical"?this._setScale(_,D/1852,"nautical-mile"):D>=1e3?this._setScale(_,D/1e3,"kilometer"):this._setScale(_,D,"meter")}_setScale(_,o,d){this._map._requestDomTask(()=>{const v=function(S){const D=Math.pow(10,`${Math.floor(S)}`.length-1);let z=S/D;return z=z>=10?10:z>=5?5:z>=3?3:z>=2?2:z>=1?1:function(N){const q=Math.pow(10,Math.ceil(-Math.log(N)/Math.LN10));return Math.round(N*q)/q}(z),D*z}(o),T=v/o;this._container.innerHTML=this._isNumberFormatSupported&&d!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:d}).format(v):`${v} ${Eh[d]}`,this._container.style.width=_*T+"px"})}onAdd(_){return this._map=_,this._language=_.getLanguage(),this._container=F("div","mapboxgl-ctrl mapboxgl-ctrl-scale",_.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(_){this._language=_,this._update()}setUnit(_){this.options.unit=_,this._update()}},FullscreenControl:class{constructor(_){this._fullscreen=!1,_&&_.container&&(_.container instanceof t.window.HTMLElement?this._container=_.container:t.warnOnce("Full screen control 'container' must be a DOM element.")),t.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in t.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(_){return this._map=_,this._container||(this._container=this._map.getContainer()),this._controlContainer=F("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",t.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!t.window.document.fullscreenEnabled&&!t.window.document.webkitFullscreenEnabled)}_setupUI(){const _=this._fullscreenButton=F("button","mapboxgl-ctrl-fullscreen",this._controlContainer);F("span","mapboxgl-ctrl-icon",_).setAttribute("aria-hidden","true"),_.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const _=this._getTitle();this._fullscreenButton.setAttribute("aria-label",_),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",_)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(t.window.document.fullscreenElement||t.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends t.Evented{constructor(_){super(),this.options=t.extend(Object.create(vh),_),t.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(_&&_.className?_.className.trim().split(/\s+/):[])}addTo(_){return this._map&&this.remove(),this._map=_,this.options.closeOnClick&&_.on("preclick",this._onClose),this.options.closeOnMove&&_.on("move",this._onClose),_.on("remove",this.remove),this._update(),_._addPopup(this),this._focusFirstElement(),this._trackPointer?(_.on("mousemove",this._onMouseEvent),_.on("mouseup",this._onMouseEvent),_._canvasContainer.classList.add("mapboxgl-track-pointer")):_.on("move",this._update),this.fire(new t.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const _=this._map;return _&&(_.off("move",this._update),_.off("move",this._onClose),_.off("preclick",this._onClose),_.off("click",this._onClose),_.off("remove",this.remove),_.off("mousemove",this._onMouseEvent),_.off("mouseup",this._onMouseEvent),_.off("drag",this._onMouseEvent),_._canvasContainer&&_._canvasContainer.classList.remove("mapboxgl-track-pointer"),_._removePopup(this),this._map=void 0),this.fire(new t.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(_){this._lngLat=t.LngLat.convert(_),this._pos=null,this._trackPointer=!1,this._update();const o=this._map;return o&&(o.on("move",this._update),o.off("mousemove",this._onMouseEvent),o._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const _=this._map;return _&&(_.off("move",this._update),_.on("mousemove",this._onMouseEvent),_.on("drag",this._onMouseEvent),_._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(_){return this.setDOMContent(t.window.document.createTextNode(_))}setHTML(_){const o=t.window.document.createDocumentFragment(),d=t.window.document.createElement("body");let v;for(d.innerHTML=_;v=d.firstChild,v;)o.appendChild(v);return this.setDOMContent(o)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(_){return this.options.maxWidth=_,this._update(),this}setDOMContent(_){let o=this._content;if(o)for(;o.hasChildNodes();)o.firstChild&&o.removeChild(o.firstChild);else o=this._content=F("div","mapboxgl-popup-content",this._container||void 0);if(o.appendChild(_),this.options.closeButton){const d=this._closeButton=F("button","mapboxgl-popup-close-button",o);d.type="button",d.setAttribute("aria-label","Close popup"),d.setAttribute("aria-hidden","true"),d.innerHTML="×",d.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(_){return this._classList.add(_),this._updateClassList(),this}removeClassName(_){return this._classList.delete(_),this._updateClassList(),this}setOffset(_){return this.options.offset=_,this._update(),this}toggleClassName(_){let o;return this._classList.delete(_)?o=!1:(this._classList.add(_),o=!0),this._updateClassList(),o}_onMouseEvent(_){this._update(_.point)}_getAnchor(_){if(this.options.anchor)return this.options.anchor;const o=this._map,d=this._container,v=this._pos;if(!o||!d||!v)return"bottom";const T=d.offsetWidth,S=d.offsetHeight,D=v.xo.transform.width-T/2;if(v.y+_o.transform.height-S){if(D)return"bottom-left";if(z)return"bottom-right"}return D?"left":z?"right":"bottom"}_updateClassList(){const _=this._container;if(!_)return;const o=[...this._classList];o.push("mapboxgl-popup"),this._anchor&&o.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&o.push("mapboxgl-popup-track-pointer"),_.className=o.join(" ")}_update(_){const o=this._map,d=this._content;if(!o||!this._lngLat&&!this._trackPointer||!d)return;let v=this._container;if(v||(v=this._container=F("div","mapboxgl-popup",o.getContainer()),this._tip=F("div","mapboxgl-popup-tip",v),v.appendChild(d)),this.options.maxWidth&&v.style.maxWidth!==this.options.maxWidth&&(v.style.maxWidth=this.options.maxWidth),o.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=ul(this._lngLat,this._pos,o.transform)),!this._trackPointer||_){const T=this._pos=this._trackPointer&&_?_:o.project(this._lngLat),S=Sd(this.options.offset),D=this._anchor=this._getAnchor(S.y),z=Sd(this.options.offset,D),N=T.add(z).round();o._requestDomTask(()=>{this._container&&D&&(this._container.style.transform=`${ba[D]} translate(${N.x}px,${N.y}px)`)})}if(!this._marker&&o._showingGlobe()){const T=t.isLngLatBehindGlobe(o.transform,this._lngLat)?0:1;this._setOpacity(T)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const _=this._container.querySelector(Vm);_&&_.focus()}_onClose(){this.remove()}_setOpacity(_){this._container&&(this._container.style.opacity=`${_}`),this._content&&(this._content.style.pointerEvents=_?"auto":"none")}},Marker:zt,Style:Ur,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.Point,MercatorCoordinate:t.MercatorCoordinate,FreeCameraOptions:ys,Evented:t.Evented,config:t.config,prewarm:function(){Xr().acquire($r)},clearPrewarmedResources:function(){const _=Li;_&&(_.isPreloaded()&&_.numActive()===1?(_.release($r),Li=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return t.config.ACCESS_TOKEN},set accessToken(_){t.config.ACCESS_TOKEN=_},get baseApiUrl(){return t.config.API_URL},set baseApiUrl(_){t.config.API_URL=_},get workerCount(){return Ci.workerCount},set workerCount(_){Ci.workerCount=_},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(_){t.config.MAX_PARALLEL_IMAGE_REQUESTS=_},clearStorage(_){t.clearTileCache(_)},workerUrl:"",workerClass:null,setNow:t.exported.setNow,restoreNow:t.exported.restoreNow};return cl});var x=h;return x})})(e_);var bb=e_.exports;const Nr=pu(bb),af=["17763402f97aa5d363379927f5ce70a6"][0],wb="pk.eyJ1IjoiYWVzcWUiLCJhIjoiY2lmNGVxYnNnMDNrenJya2xzbmQ4M281bCJ9.GfMJ8R2NX1dDcc9Hs2PO3A",mp="http://172.160.2.169:9010",lf="https://szpt.nmgjtjt.com:9008",uf="http://172.160.2.169:8090",cf=lf,hf="https://t0.tianditu.gov.cn",t_={TDT_ZXY_IMG:{version:8,sources:{"raster-tiles":{type:"raster",tileSize:256,tiles:[hf+"/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk="+af]},"raster-tiles-mark":{type:"raster",tileSize:256,tiles:[hf+"/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk="+af]}},layers:[{id:"raster-tiles",type:"raster",source:"raster-tiles",minzoom:0,maxzoom:22,layout:{visibility:"visible"}},{id:"raster-tiles-mark",type:"raster",source:"raster-tiles-mark",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]},TDT_WMTS_IMG:{version:8,sources:{"raster-white":{type:"raster",tileSize:256,tiles:[hf+"/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk="+af]},"raster-white-mark":{type:"raster",tileSize:256,tiles:[hf+"/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk="+af]}},layers:[{id:"raster-white",type:"raster",source:"raster-white",minzoom:0,maxzoom:22,layout:{visibility:"visible"}},{id:"raster-white-mark",type:"raster",source:"raster-white-mark",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]},SM_WMTS_VEC_WHITE:Object.assign({},{sources:{"raster-supermap-white":{type:"raster",tileSize:256,tiles:[uf+"/iserver/services/map-nmjtjt/wmts100/NMjtjtGis/default/GoogleMapsCompatible_NMjtjtGis/{z}/{y}/{x}.png"]}},layers:[{id:"raster-supermap-white",type:"raster",source:"raster-supermap-white",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]}),SM_WMTS_VEC_BLUE:Object.assign({},{sources:{"raster-supermap-blue":{type:"raster",tileSize:256,tiles:[uf+"/iserver/services/map-nmjtjtblue/wmts100/NMjtjtGis/default/GoogleMapsCompatible_NMjtjtGis/{z}/{y}/{x}.png"]}},layers:[{id:"raster-supermap-blue",type:"raster",source:"raster-supermap-blue",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]}),SM_WMTS_VEC_WHITE_BORDERLESS:Object.assign({},{sources:{"raster-supermap-white-borderless":{type:"raster",tileSize:256,tiles:[uf+"/iserver/services/map-nmjtjt_nm/wmts100/NMjtjtGis/default/GoogleMapsCompatible_NMjtjtGis/{z}/{y}/{x}.png"]}},layers:[{id:"raster-supermap-white-borderless",type:"raster",source:"raster-supermap-white-borderless",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]}),SM_WMTS_VEC_3D:Object.assign({},{sources:{"raster-supermap-3D":{type:"raster",tileSize:256,tiles:[uf+"/iserver/services/map-nmjtjtblue3d/wmts100/NMjtjtGis/default/GoogleMapsCompatible_NMjtjtGis/{z}/{y}/{x}.png"]}},layers:[{id:"raster-supermap-3D",type:"raster",source:"raster-supermap-3D",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]}),INTERNET_WMTS_VEC_WHITE:Object.assign({},{sources:{"internet-raster-supermap-white":{type:"raster",tileSize:256,tiles:[cf+"/map_nmjtjt_jt/NMjtjtGis/default/GoogleMapsCompatible_NMjtjtGis/{z}/{y}/{x}.png"]}},layers:[{id:"internet-raster-supermap-white",type:"raster",source:"internet-raster-supermap-white",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]}),INTERNET_WMTS_VEC_WHITE_BORDERLESS:Object.assign({},{sources:{"internet-raster-supermap-white-borderless":{type:"raster",tileSize:256,tiles:[cf+"/map_nmjtjt_nm/NMjtjtGis/default/GoogleMapsCompatible_NMjtjtGis/{z}/{y}/{x}.png"]}},layers:[{id:"internet-raster-supermap-white-borderless",type:"raster",source:"internet-raster-supermap-white-borderless",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]}),INTERNET_WMTS_VEC_BLUE:Object.assign({},{sources:{"internet-raster-supermap-blue":{type:"raster",tileSize:256,tiles:[cf+"/map_nmjtjtblue_jt/NMjtjtGis/default/GoogleMapsCompatible_NMjtjtGis/{z}/{y}/{x}.png"]}},layers:[{id:"internet-raster-supermap-blue",type:"raster",source:"internet-raster-supermap-blue",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]}),INTERNET_WMTS_VEC_3D:Object.assign({},{sources:{"internet-raster-supermap-3D":{type:"raster",tileSize:256,tiles:[cf+"/map_nmjtjtblue3d_jt/NMjtjtGis/default/GoogleMapsCompatible_NMjtjtGis/{z}/{y}/{x}.png"]}},layers:[{id:"internet-raster-supermap-3D",type:"raster",source:"internet-raster-supermap-3D",minzoom:0,maxzoom:22,layout:{visibility:"visible"}}]})},ff={center:[116.39,39.93],zoom:10,minZoom:3,maxZoom:22},Eb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABXUlEQVQ4T6VTu0oDURCdc29cENTEgPoBaiHY+cLaSmyWLEkj1lZi7Rf4AyL4A2KzIZ2VnVhpIVipP6BCTKIgJLn3yC7ZZXfdqJCtdu7MnJkzcwaS+d5dtwStF6D1LEUmAjdEPmnMK415nm40WskURAZF0HHdNXGc+Sxo0qYxT0Xfv4MIB+DhH9qVyhYKhZnfkuNi/f5bsV6/CkDCDtquu/5X5Sxw0EnJ928RcFaOs50KMKYMYE+ApfCdfCB5Llo3k3G2271Ey/NWofVi7DCmLMAxgMkUd/JDyKMkSNAFmtXqjgamomBYeyjARu4syBsqdRL5DNlBq1arQUTHCdaeZavHwwu6UGo/shXZGx0gS0GsPQCwOYTCNZU6TVMYZYjk49A1CrArIssDtd2TvMhdYxDwY5X/kGMspFAno0o5BvG8lZSocjrJPaZkXHTOVqm5MZHxwNcT+VLWvuSd8zcITMKOoWKQ5QAAAABJRU5ErkJggg==",Tb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABTklEQVQ4T6WTzS4EURCFv7o9G/EbCR4AC4mFxF9kjI2V2NuItZVYS/uJhHgBkXgB8QZWdsOKhMQKL4BEMMTC9C3pnumeO60HydzdrXPq1Kl7q4TUGdnSrtYyA16OXixtEWx4D8o8fuS4v9qWFzdFaheVgs+48ehPi7r3csDd2S6XIBrGqwIq0+vMeoae35JjLLA8FXc4DUUigYKvE39VTgtXnMiFhD13KnMuQS3dalgChqrxG7EcieHZ5b0KJ5L3dSznMRgDUbKwJ0J7nahSEmXNFQldSGFT5w10xGQLqwKTWW+hcG5g3+G+ycyGLojgJUHlMF09caeUjLCccC1fzQv8aEFZEWGqQQtFAwd1LTTziIFy2/gbhUVgOKomXIvlOPMbQzzt4j/TmAxShdzkKMcieZ9Rd6iynDRYpho1Xmfj0YelJUIMnzbgIWudvwHMF6CDKyS3NAAAAABJRU5ErkJggg==",Ib={hdgjdmap:{type:"vector",tiles:[mp+"/onlinemap/map/data/traffic_gjd/{z}/{x}/{y}.mvt"]}},Mb={hdgjdmap:{type:"vector",tiles:[lf+"/onlinemap/map/data/traffic_gjd/{z}/{x}/{y}.mvt"]}},Sb=[{id:"gjd_ld",type:"fill",source:"hdgjdmap","source-layer":"gjd_ld",name:"路段面",paint:{"fill-color":["match",["get","fcxx"],["200","300"],"#354a52","#dab74c"]},minzoom:5},{id:"gjd_lh",type:"fill",source:"hdgjdmap","source-layer":"gjd_lh",name:"面状绿化",paint:{"fill-pattern":"gjdMapLhdPicImg"},minzoom:4},{id:"gjd_bxm_ld",type:"fill",source:"hdgjdmap","source-layer":"gjd_bxm_ld",name:"路段标线",paint:{"fill-color":"#FFFFFF"},minzoom:8},{id:"gjd_dxjt",type:"fill",source:"hdgjdmap","source-layer":"gjd_dxjt",name:"路段标线",paint:{"fill-color":"#FFFFFF"},minzoom:5},{id:"gjd_lmwz",type:"fill",source:"hdgjdmap","source-layer":"gjd_lmwz",name:"路面文字",paint:{"fill-color":"#FFFFFF"},minzoom:8},{id:"gjd_fhl",type:"line",source:"hdgjdmap","source-layer":"gjd_fhl",name:"附属设施-线-护栏",paint:{"line-width":["interpolate",["linear"],["zoom"],12,2,20,6],"line-pattern":"gaojingduMapFanghulanSelect"},minzoom:9},{id:"gjd_jtydp",type:"symbol",source:"hdgjdmap","source-layer":"gjd_jtydp",name:"点状-诱导屏",layout:{"icon-image":"gjdMapQbbImg","icon-allow-overlap":!0,"icon-size":.5},minzoom:10},{id:"gjd_sxj",type:"symbol",source:"hdgjdmap","source-layer":"gjd_sxj",name:"点状-摄像机",layout:{"icon-image":"gjdMapShexiangjibzPicImg","icon-allow-overlap":!0,"icon-size":.5},minzoom:10},{id:"gjd_fzt",type:"symbol",source:"hdgjdmap","source-layer":"gjd_fzt",name:"点状-防撞桶",layout:{"icon-image":"gjdMapFztImg","icon-size":.5},minzoom:10},{id:"gjd_bzp",type:"symbol",source:"hdgjdmap","source-layer":"gjd_bzp",name:"点状-标志牌",layout:{"icon-image":["match",["get","bzdl"],"1","gjdMapJinlingbzPicImg","2","gjdMapJingggaobzImg","3","gjdMapZhishibzPicImg","4","gjdMapZhilubzPicImg","5","gjdMapLvyouqubzPicImg","6","gjdMapfuzubiaozhibzPicImg","7","gjdMapfuzubiaozhibzPicImg","gjdMapZhishibzPicImg"],"icon-allow-overlap":!0,"icon-size":.5},minzoom:10}],kb={version:8,glyphs:mp+"/maplib/fonts/{fontstack}/{range}.pbf",sprite:mp+"/maplib/sprite/default"},Cb={version:8,glyphs:lf+"/maplib/fonts/{fontstack}/{range}.pbf",sprite:lf+"/maplib/sprite/default"};class Ab{constructor(i={}){let s=Object.assign({},{isHighPrecision:!0},i);if(this._container=s.container,!this._container)throw new Error("请传入地图容器ID,才能创建地图。");Nr.accessToken=s.accessToken||wb,this._style=s.styleURL||t_.SM_WMTS_VEC_WHITE;let l=this.getNetworkStatus(this._style.sources);this._style=Object.assign({},l?Cb:kb,this._style),this.map2d=new Nr.Map({container:this._container,style:this._style,center:s.center||ff.center,zoom:s.zoom||ff.zoom,minZoom:s.minZoom||ff.minZoom,maxZoom:s.maxZoom||ff.maxZoom,transformRequest:s.transformRequest||function(h,f){return{url:h}}}),this.addSymbolImgLoad(),setTimeout(()=>{s.isHighPrecision&&this.addHighPrecision(l)},1e3)}addHighPrecision(i){let s=null;i?s=Mb:s=Ib;for(let l in s)this.map2d.addSource(l,s[l]);Sb.forEach(l=>{this.map2d.addLayer(l)})}getNetworkStatus(i){let s=!1;for(let l in i)l.indexOf("internet")>-1&&(s=!0);return s}addSymbolImgLoad(){this.map2d.loadImage(Tb,(i,s)=>{if(i)throw i;this.map2d.addImage("point",s)}),this.map2d.loadImage(Eb,(i,s)=>{if(i)throw i;this.map2d.addImage("pointSelect",s);var l=document.getElementsByClassName("mapboxgl-ctrl-bottom-left");l.length>0&&(l[0].style.display="none")})}addFeaturePoint(i,s,l={}){if(!this.map2d)throw new Error("未加载控件。");if(Array.isArray(s)){var h={type:"FeatureCollection",features:s};this.map2d.addSource(i,{type:"geojson",data:h}),this.map2d.addLayer({id:i,type:l.type?l.type:"circle",source:i,paint:l.paint?l.paint:{"circle-color":"blue","circle-radius":6},layout:l.layout?l.layout:{visibility:"visible"}})}}addFeatureLine(i,s,l={}){if(!this.map2d)throw new Error("未加载控件。");if(Array.isArray(s)){var h={type:"FeatureCollection",features:s};this.map2d.addSource(i,{type:"geojson",data:h}),this.map2d.addLayer({id:i,type:"line",source:i,paint:l.paint?l.paint:{"line-color":"#FFBD76","line-width":4},layout:l.layout?l.layout:{visibility:"visible"}})}}addFeatureFill(i,s,l={}){if(!this.map2d)throw new Error("未加载控件。");if(Array.isArray(s)){var h={type:"FeatureCollection",features:s};this.map2d.addSource(i,{type:"geojson",data:h}),this.map2d.addLayer({id:i,type:"fill",source:i,paint:l.paint?l.paint:{"fill-color":"rgba(93,174,255,0.4)","fill-opacity":.7,"fill-outline-color":"rgba(93,174,255,0.8)"},layout:l.layout?l.layout:{visibility:"visible"}})}}addCluster(i,s,l={clusterStyle:["#51bbd6",100,"#f1f075",750,"#f28cb1"]}){if(!this.map2d)throw new Error("未加载控件。");if(!Array.isArray(s))return;var h={type:"FeatureCollection",features:s};this.map2d.addSource(i,{type:"geojson",data:h,cluster:!0,clusterMaxZoom:14,clusterRadius:50});let f=l.clusterStyle||["#51bbd6",100,"#f1f075",750,"#f28cb1"];this.map2d.addLayer({id:i+"-cluster",type:"circle",source:i,filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],...f],"circle-radius":["step",["get","point_count"],20,100,30,750,40]}}),this.map2d.addLayer({id:i+"-cluster-count",type:"symbol",source:i,filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-font":["Microsoft YaHei Regular"],"text-size":12}}),this.map2d.addLayer({id:i,type:"symbol",source:i,filter:["!",["has","point_count"]],layout:{"icon-image":"point","icon-allow-overlap":!0,visibility:"visible"}})}addSymbolCluster(i,s,l={source:{clusterMaxZoom:14,clusterRadius:50},layout:{"icon-image":"point","icon-size":1.5,"text-field":"{point_count_abbreviated}","text-font":["Microsoft YaHei Regular"],"text-offset":[1,0],"text-anchor":"bottom","text-size":12},paint:{"text-opacity":1,"text-color":"red","text-halo-color":"rgba(0,0,0,0)","text-halo-width":0,"text-halo-blur":0,"text-translate":[0,0]},unclustered:{"icon-image":"point","icon-size":1,"icon-allow-overlap":!0}}){if(!this.map2d)throw new Error("未加载控件。");if(!Array.isArray(s))return;var h={type:"FeatureCollection",features:s};let x=Object.assign({},{"icon-image":"point","icon-size":1.5,"text-field":"{point_count_abbreviated}","text-font":["Microsoft YaHei Regular"],"text-offset":[1,0],"text-anchor":"bottom","text-size":12},l.layout||{}),t=Object.assign({},{"text-opacity":1,"text-color":"#000000","text-halo-color":"rgba(0,0,0,0)","text-halo-width":0,"text-halo-blur":0,"text-translate":[0,0]},l.paint||{});this.map2d.addSource(i,Object.assign({},{type:"geojson",data:h,cluster:!0,clusterMaxZoom:14,clusterRadius:50},l.source||{})),this.map2d.addLayer({id:i+"-cluster",type:"symbol",source:i,filter:["has","point_count"],layout:x,paint:t}),this.map2d.addLayer({id:i,type:"symbol",source:i,filter:["!",["has","point_count"]],layout:Object.assign({},{"icon-image":x["icon-image"],"icon-size":1,"icon-allow-overlap":!0,"text-allow-overlap":!0,visibility:"visible"},l.unclustered||{})})}flyTo(i){this.map2d&&this.map2d.flyTo({center:i.center,zoom:i.zoom,essential:!0,duration:i.duration||2e3,curve:1,bearing:i.bearing||0,pitch:i.pitch||0})}removeLayer(i){this.map2d.getLayer(i)&&(this.map2d.removeLayer(i),this.map2d.removeSource(i))}removeClusterLayer(i){this.map2d.getLayer(i)&&(this.map2d.removeLayer(i),this.map2d.removeLayer(i+"-cluster-count"),this.map2d.removeLayer(i+"-cluster"),this.map2d.removeSource(i))}removeSymbolClusterLayer(i){this.map2d.getLayer(i)&&(this.map2d.removeLayer(i),this.map2d.removeLayer(i+"-cluster"),this.map2d.removeSource(i))}}const Pb="0.1.0";class Lb{constructor(i={}){return this.hmap=i.map,this._anchor=i.anchor||"bottom-right",this._zoomcontrol=new Nr.NavigationControl({showZoom:!0,showCompass:!1}),this}addTo(i){this.hmap||(this.hmap=i),this.hmap.map2d.addControl(this._zoomcontrol,this._anchor)}remove(){if(this.hmap||this._zoomcontrol)throw new Error("未加载缩放控件。");this.hmap.map2d.removeControl(this._zoomcontrol)}}class Rb{constructor(i={}){return this.hmap=i.map,this._anchor=i.anchor||"bottom-right",this._fullscreen=new Nr.FullscreenControl({container:null}),this}addTo(i){this.hmap||(this.hmap=i),this._fullscreen.container=this.hmap.map2d.getContainer(),this.hmap.map2d.addControl(this._fullscreen,this._anchor)}remove(){if(this.hmap||this._fullscreen)throw new Error("未加载全屏控件。");this.hmap.map2d.removeControl(this._fullscreen)}}class Db{constructor(i={}){return this.hmap=i.map,this._anchor=i.anchor||"bottom-right",this._compass=new Nr.NavigationControl({showCompass:!0,showZoom:!1}),this}addTo(i){this.hmap||(this.hmap=i),this.hmap.map2d.addControl(this._compass,this._anchor)}remove(){if(this.hmap||this._compass)throw new Error("未加载指北针控件。");this.hmap.map2d.removeControl(this._compass)}}class zb{constructor(i={}){return this.hmap=i.map,this._anchor=i.anchor||"bottom-right",this._scaleline=new Nr.ScaleControl({unit:i.unit?i.unit:"metric"}),this}addTo(i){this.hmap||(this.hmap=i),this.hmap.map2d.addControl(this._scaleline,this._anchor)}remove(){if(this.hmap||this._scaleline)throw new Error("未加载比例尺控件。");this.hmap.map2d.removeControl(this._scaleline)}}class Ob{constructor(i={closeButton:!1,closeOnClick:!1,className:"mapbox-popup",maxWidth:"350px"}){return this.hmap=i.map,this.popup=new Nr.Popup(i),this.popup}}const Nb="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAUCAYAAAD/Rn+7AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAABmJLR0QA/wD/AP+gvaeTAAAF80lEQVRIS71WW2wUVRj+dmZ29r69bVpgaSktKNKGFi1ESYmtPCiREE2UB15NjCYaI+qLUWNCJPEFiS/44IPExBB9ISFRazRoBQkUHkyh3CyFtth2dynbbfcyMzszfufs9hJtdTHRL/17Zs+Z889//st3ftwv+g6gcepkqHCqB1p56j+Fpzziy+ehhyLYDwVRjwvn7N34s6ZW115VUwN/uMadyxbcxNQUuuuv3Hq0t9B6qQ+7LSANAzaV2K4fs0JP0Ib15OfISqUroLu7u8Xrul26rkNVVTlnmiYKhjF8+ty5i3KiDGngD68jHu/YNozcgM/KAwp9o1I0naOXI8UboPiBsUtA0QRGE2G5WaF+RXWh8FSKwvdVBXbNw4hZZ2AWXC7CVTxw+ed6+GwGNsKvJeBkZzVF9dArVM49RasI27ILIV9xJJ/Gsa538aE0kCo8w8d7s5r9ayAWnxZzy6K/vxVjqRgeahpD5yMT+H00gsujW5FxG1HUa+FowdLJygiNfo9cfCdc1VeeWUT0+nHMtexFJHcZ21v6aD0N1Rk2hsSxSw4wDRxuewVveAaPbjoZjVl71qwfLm9fHi8c7MHZC1cRra5B2+YN2Nkyi66WIWx4MAGDAbWLJeWVwnGAT75Yj1+m6jGbzTN1xvHWS9OINYG+BhIjcEdOoU59c1/207pVCa/3rwddQDat4OiJWhiGCd3nw1zexLWkjouTm/HMjiHmKMPAeIsUCNUA4VrmYhUlCgQoYhQSqi7PU8Qz8xBnR1uZGgqG7/mwKTiN1s2O1JVLM7p+aEognA8KJaDVwgM23Vw0ONLNDr0iTpNKhpBKJeH1epmPOry6TxrK3JJheee9GA4c2oi3P+rAoSPtyCQXdQk981IslEa37OktWzIIBgPwB4JSfhkShpRQVc+DVmOPIj4iwVEkvCwKelNlgYiUEqdJ3Q0yJA4LR6NxXooOncZWR0JIJ4DTqUbcduIY9zTiptqO5KhS0kUdGr26VMScp1S4CEZc1AZcHpaHpoymI5i7V1rzheTQxLr7Z6QzOsOgSgOlsMQ1lnbIzy/RwxrnhOj0rk7vCq9XAnGIiGbCS11C30wxiLlUeZFg1fsrMtAwVBro4QaFHqWIZ7rWp5XcL37LA5DT5nmtUgS8jsxBsd90vTBJc/NgKvBrFcBdxiXCwKUQ78zL/WBxnyNlKYSmigz0+W3mIJUwD6UiPoucNFlEArYt1m05FovlyQqRNTzcY8m9XljQeSHMQxB7RQZWhQ1pgDDKsR0qI+tTssJCOrJoWbB4VRlkV6NQoHcr86Ko9BlTg8n9JvdF1SzCsfKigAtDWVDFh5VoJhbLk4hpFMWyTHlioXQmk5N00LtqHOvUO4g7t/EABtHQTA8LXWVqWSpLaSY760Eq56KQz8mDraueQ5g8KmDmpEnjnt8+i+TrG2f9AZLnSsjNePD4yy00qohgOEyJwB8kd/n9OPLc1/KDwiABcR8vZDa9uzRT/5yeQ8NRHD7dgXwui/zcHA7uvYmn9pVSJHmL7DGJI0ohv6YvldqKWZLrSmKbLtY2VDGMBizDgM+rYHtzEa/2DiJKDyrkTsmZgnVoEVNUirDHEb/LIhJqXkT2/zwYRX42jVwmg8caJtESL2LiCjAxRObIwp0awQeyWbh67Imslb4R8Fhj0vrlcOb6OlxLRNDZNI3uzgneLGHcmG5DBnGY3mrYaoAfXmwW6qb6YTXvWr5ZuHYcU6ufRnX+CjpqvwMvN3Koi5lJGk+DxJVJ1vl4+/t4TUbg2xexuqFt20juzoBPXOKCQUSYxKIcKYJURfgM5pHwVHJmldjKNbZZ/ARLeyG0Tl0nAsl+FpV4gU6V3MN2i89WpBWamYRTyGiCP1XeTKIPkzlu24WgVhyxCzi262i53RL/BETDypTaz3ejgkUG7rFh1evaq6tq4IuUG9bEFHrXsmHtUVsHTmR3w2bD6qHzWOAMs2xYQyzonq/+vmHdtWNHC3m0S1yXCw1rqZKHfzx//oKc+Lf4iS1/4pvm/6nlB/4A2vW4jrsq6uIAAAAASUVORK5CYIL5gf8BfWaW4TntlBUAAAAASUVORK5CYII=";var ur=63710088e-1,df={centimeters:ur*100,centimetres:ur*100,degrees:360/(2*Math.PI),feet:ur*3.28084,inches:ur*39.37,kilometers:ur/1e3,kilometres:ur/1e3,meters:ur,metres:ur,miles:ur/1609.344,millimeters:ur*1e3,millimetres:ur*1e3,nauticalmiles:ur/1852,radians:1,yards:ur*1.0936},pf={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:29155334959812285e-23,millimeters:1e6,millimetres:1e6,yards:1.195990046};function nr(a,i,s={}){const l={type:"Feature"};return(s.id===0||s.id)&&(l.id=s.id),s.bbox&&(l.bbox=s.bbox),l.properties=i||{},l.geometry=a,l}function n_(a,i,s={}){switch(a){case"Point":return cn(i).geometry;case"LineString":return Zn(i).geometry;case"Polygon":return Mn(i).geometry;case"MultiPoint":return Tc(i).geometry;case"MultiLineString":return Pa(i).geometry;case"MultiPolygon":return oo(i).geometry;default:throw new Error(a+" is invalid")}}function cn(a,i,s={}){if(!a)throw new Error("coordinates is required");if(!Array.isArray(a))throw new Error("coordinates must be an Array");if(a.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!cr(a[0])||!cr(a[1]))throw new Error("coordinates must contain numbers");return nr({type:"Point",coordinates:a},i,s)}function i_(a,i,s={}){return Jt(a.map(l=>cn(l,i)),s)}function Mn(a,i,s={}){for(const h of a){if(h.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(h[h.length-1].length!==h[0].length)throw new Error("First and last Position are not equivalent.");for(let f=0;fMn(l,i)),s)}function Zn(a,i,s={}){if(a.length<2)throw new Error("coordinates must be an array of two or more positions");return nr({type:"LineString",coordinates:a},i,s)}function o_(a,i,s={}){return Jt(a.map(l=>Zn(l,i)),s)}function Jt(a,i={}){const s={type:"FeatureCollection"};return i.id&&(s.id=i.id),i.bbox&&(s.bbox=i.bbox),s.features=a,s}function Pa(a,i,s={}){return nr({type:"MultiLineString",coordinates:a},i,s)}function Tc(a,i,s={}){return nr({type:"MultiPoint",coordinates:a},i,s)}function oo(a,i,s={}){return nr({type:"MultiPolygon",coordinates:a},i,s)}function gp(a,i,s={}){return nr({type:"GeometryCollection",geometries:a},i,s)}function s_(a,i=0){if(i&&!(i>=0))throw new Error("precision must be a positive number");const s=Math.pow(10,i||0);return Math.round(a*s)/s}function Ic(a,i="kilometers"){const s=df[i];if(!s)throw new Error(i+" units is invalid");return a*s}function mu(a,i="kilometers"){const s=df[i];if(!s)throw new Error(i+" units is invalid");return a/s}function mf(a,i){return wl(mu(a,i))}function gu(a){let i=a%360;return i<0&&(i+=360),i}function a_(a){return a=a%360,a>0?a>180?a-360:a:a<-180?a+360:a}function wl(a){return a%(2*Math.PI)*180/Math.PI}function ir(a){return a%360*Math.PI/180}function El(a,i="kilometers",s="kilometers"){if(!(a>=0))throw new Error("length must be a positive number");return Ic(mu(a,i),s)}function _p(a,i="meters",s="kilometers"){if(!(a>=0))throw new Error("area must be a positive number");const l=pf[i];if(!l)throw new Error("invalid original units");const h=pf[s];if(!h)throw new Error("invalid final units");return a/l*h}function cr(a){return!isNaN(a)&&a!==null&&!Array.isArray(a)}function Hn(a){return a!==null&&typeof a=="object"&&!Array.isArray(a)}function gf(a){if(!a)throw new Error("bbox is required");if(!Array.isArray(a))throw new Error("bbox must be an Array");if(a.length!==4&&a.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");a.forEach(i=>{if(!cr(i))throw new Error("bbox must only contain numbers")})}function l_(a){if(!a)throw new Error("id is required");if(["string","number"].indexOf(typeof a)===-1)throw new Error("id must be a number or a string")}const Bb=Object.freeze(Object.defineProperty({__proto__:null,areaFactors:pf,azimuthToBearing:a_,bearingToAzimuth:gu,convertArea:_p,convertLength:El,degreesToRadians:ir,earthRadius:ur,factors:df,feature:nr,featureCollection:Jt,geometry:n_,geometryCollection:gp,isNumber:cr,isObject:Hn,lengthToDegrees:mf,lengthToRadians:mu,lineString:Zn,lineStrings:o_,multiLineString:Pa,multiPoint:Tc,multiPolygon:oo,point:cn,points:i_,polygon:Mn,polygons:r_,radiansToDegrees:wl,radiansToLength:Ic,round:s_,validateBBox:gf,validateId:l_},Symbol.toStringTag,{value:"Module"}));function Jn(a){if(!a)throw new Error("coord is required");if(!Array.isArray(a)){if(a.type==="Feature"&&a.geometry!==null&&a.geometry.type==="Point")return[...a.geometry.coordinates];if(a.type==="Point")return[...a.coordinates]}if(Array.isArray(a)&&a.length>=2&&!Array.isArray(a[0])&&!Array.isArray(a[1]))return[...a];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function _n(a){if(Array.isArray(a))return a;if(a.type==="Feature"){if(a.geometry!==null)return a.geometry.coordinates}else if(a.coordinates)return a.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function yp(a){if(a.length>1&&cr(a[0])&&cr(a[1]))return!0;if(Array.isArray(a[0])&&a[0].length)return yp(a[0]);throw new Error("coordinates must only contain numbers")}function u_(a,i,s){if(!i||!s)throw new Error("type and name required");if(!a||a.type!==i)throw new Error("Invalid input to "+s+": must be a "+i+", given "+a.type)}function Mc(a,i,s){if(!a)throw new Error("No feature passed");if(!s)throw new Error(".featureOf() requires a name");if(!a||a.type!=="Feature"||!a.geometry)throw new Error("Invalid input to "+s+", Feature with geometry required");if(!a.geometry||a.geometry.type!==i)throw new Error("Invalid input to "+s+": must be a "+i+", given "+a.geometry.type)}function Qs(a,i,s){if(!a)throw new Error("No featureCollection passed");if(!s)throw new Error(".collectionOf() requires a name");if(!a||a.type!=="FeatureCollection")throw new Error("Invalid input to "+s+", FeatureCollection required");for(const l of a.features){if(!l||l.type!=="Feature"||!l.geometry)throw new Error("Invalid input to "+s+", Feature with geometry required");if(!l.geometry||l.geometry.type!==i)throw new Error("Invalid input to "+s+": must be a "+i+", given "+l.geometry.type)}}function Ei(a){return a.type==="Feature"?a.geometry:a}function vo(a,i){return a.type==="FeatureCollection"?"FeatureCollection":a.type==="GeometryCollection"?"GeometryCollection":a.type==="Feature"&&a.geometry!==null?a.geometry.type:a.type}const Fb=Object.freeze(Object.defineProperty({__proto__:null,collectionOf:Qs,containsNumber:yp,featureOf:Mc,geojsonType:u_,getCoord:Jn,getCoords:_n,getGeom:Ei,getType:vo},Symbol.toStringTag,{value:"Module"}));function Ps(a,i,s={}){if(s.final===!0)return Vb(a,i);const l=Jn(a),h=Jn(i),f=ir(l[0]),x=ir(h[0]),t=ir(l[1]),E=ir(h[1]),k=Math.sin(x-f)*Math.cos(E),P=Math.cos(t)*Math.sin(E)-Math.sin(t)*Math.cos(E)*Math.cos(x-f);return wl(Math.atan2(k,P))}function Vb(a,i){let s=Ps(i,a);return s=(s+180)%360,s}function ea(a,i,s,l={}){const h=Jn(a),f=ir(h[0]),x=ir(h[1]),t=ir(s),E=mu(i,l.units),k=Math.asin(Math.sin(x)*Math.cos(E)+Math.cos(x)*Math.sin(E)*Math.cos(t)),P=f+Math.atan2(Math.sin(t)*Math.sin(E)*Math.cos(x),Math.cos(E)-Math.sin(x)*Math.sin(k)),R=wl(P),F=wl(k);return cn([R,F],l.properties)}function Wn(a,i,s={}){var l=Jn(a),h=Jn(i),f=ir(h[1]-l[1]),x=ir(h[0]-l[0]),t=ir(l[1]),E=ir(h[1]),k=Math.pow(Math.sin(f/2),2)+Math.pow(Math.sin(x/2),2)*Math.cos(t)*Math.cos(E);return Ic(2*Math.atan2(Math.sqrt(k),Math.sqrt(1-k)),s.units)}function Ub(a,i,s={}){const h=Ei(a).coordinates;let f=0;for(let x=0;x=f&&x===h.length-1);x++)if(f>=i){const t=i-f;if(t){const E=Ps(h[x],h[x-1])-180;return ea(h[x],t,E,s)}else return cn(h[x])}else f+=Wn(h[x],h[x+1],s);return cn(h[h.length-1])}function Tl(a,i,s={}){let l;return s.final?l=c_(Jn(i),Jn(a)):l=c_(Jn(a),Jn(i)),l>180?-(360-l):l}function c_(a,i){const s=ir(a[1]),l=ir(i[1]);let h=ir(i[0]-a[0]);h>Math.PI&&(h-=2*Math.PI),h<-Math.PI&&(h+=2*Math.PI);const f=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),x=Math.atan2(h,f);return(wl(x)+360)%360}function jb(a,i,s,l={}){if(!Hn(l))throw new Error("options is invalid");if(!a)throw new Error("startPoint is required");if(!i)throw new Error("midPoint is required");if(!s)throw new Error("endPoint is required");const h=a,f=i,x=s,t=gu(l.mercator!==!0?Ps(h,f):Tl(h,f)),E=gu(l.mercator!==!0?Ps(x,f):Tl(x,f)),k=Math.abs(t-E);return l.explementary===!0?360-k:k}function xi(a,i,s){if(a!==null)for(var l,h,f,x,t,E,k,P=0,R=0,F,U=a.type,Z=U==="FeatureCollection",J=U==="Feature",he=Z?a.features.length:1,ye=0;yeE||Z>k||J>P){t=R,E=l,k=Z,P=J,f=0;return}var he=Zn([t,R],s.properties);if(i(he,l,h,J,f)===!1)return!1;f++,t=R})===!1)return!1}}})}function Ep(a,i,s){var l=s,h=!1;return ta(a,function(f,x,t,E,k){h===!1&&s===void 0?l=f:l=i(l,f,x,t,E,k),h=!0}),l}function Tp(a,i){if(!a)throw new Error("geojson is required");Wi(a,function(s,l,h){if(s.geometry!==null){var f=s.geometry.type,x=s.geometry.coordinates;switch(f){case"LineString":if(i(s,l,h,0,0)===!1)return!1;break;case"Polygon":for(var t=0;ti+qb(s),0)}function qb(a){let i=0,s;switch(a.type){case"Polygon":return m_(a.coordinates);case"MultiPolygon":for(s=0;s0){i+=Math.abs(g_(a[0]));for(let s=1;s=i?(l+2)%i:l+2],t=h[0]*Mp,E=f[1]*Mp,k=x[0]*Mp;s+=(k-t)*Math.sin(E),l++}return s*Zb}function pi(a,i={}){if(a.bbox!=null&&i.recompute!==!0)return a.bbox;const s=[1/0,1/0,-1/0,-1/0];return xi(a,l=>{s[0]>l[0]&&(s[0]=l[0]),s[1]>l[1]&&(s[1]=l[1]),s[2]i[2]&&(s|=2),a[1]i[3]&&(s|=8),s}function Wb(a,i){const s=Ei(a),l=s.type,h=a.type==="Feature"?a.properties:{};let f=s.coordinates;switch(l){case"LineString":case"MultiLineString":{const x=[];return l==="LineString"&&(f=[f]),f.forEach(t=>{$b(t,i,x)}),x.length===1?Zn(x[0],h):Pa(x,h)}case"Polygon":return Mn(__(f,i),h);case"MultiPolygon":return oo(f.map(x=>__(x,i)),h);default:throw new Error("geometry "+l+" not supported")}}function __(a,i){const s=[];for(const l of a){const h=Xb(l,i);h.length>0&&((h[0][0]!==h[h.length-1][0]||h[0][1]!==h[h.length-1][1])&&h.push(h[0]),h.length>=4&&s.push(h))}return s}function kc(a,i={}){const s=Number(a[0]),l=Number(a[1]),h=Number(a[2]),f=Number(a[3]);if(a.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");const x=[s,l];return Mn([[x,[h,l],[h,f],[s,f],x]],i.properties,{bbox:a,id:i.id})}var Yb=class{constructor(a){this.points=a.points||[],this.duration=a.duration||1e4,this.sharpness=a.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=a.stepLength||60,this.length=this.points.length,this.delay=0;for(let i=0;ia&&(i.push(l),s=h)}return i}vector(a){const i=this.pos(a+10),s=this.pos(a-10);return{angle:180*Math.atan2(i.y-s.y,i.x-s.x)/3.14,speed:Math.sqrt((s.x-i.x)*(s.x-i.x)+(s.y-i.y)*(s.y-i.y)+(s.z-i.z)*(s.z-i.z))}}pos(a){let i=a-this.delay;i<0&&(i=0),i>this.duration&&(i=this.duration-1);const s=i/this.duration;if(s>=1)return this.points[this.length-1];const l=Math.floor((this.points.length-1)*s),h=(this.length-1)*s-l;return Hb(h,this.points[l],this.controls[l][1],this.controls[l+1][0],this.points[l+1])}};function Hb(a,i,s,l,h){const f=Kb(a);return{x:h.x*f[0]+l.x*f[1]+s.x*f[2]+i.x*f[3],y:h.y*f[0]+l.y*f[1]+s.y*f[2]+i.y*f[3],z:h.z*f[0]+l.z*f[1]+s.z*f[2]+i.z*f[3]}}function Kb(a){const i=a*a;return[i*a,3*i*(1-a),3*a*(1-a)*(1-a),(1-a)*(1-a)*(1-a)]}function Jb(a,i={}){const s=i.resolution||1e4,l=i.sharpness||.85,h=[],f=Ei(a).coordinates.map(k=>({x:k[0],y:k[1]})),x=new Yb({duration:s,points:f,sharpness:l}),t=k=>{var P=x.pos(k);Math.floor(k/100)%2===0&&h.push([P.x,P.y])};for(var E=0;E0}function Qb(a){const i=Ei(a).coordinates;if(i[0].length<=4)return!1;let s=!1;const l=i[0].length-1;for(let h=0;h0;else if(s!==k>0)return!0}return!1}function ew(a,i){var s=0,l=0,h=0,f=0,x=0,t=0,E=0,k=0,P=null,R=null,F=a[0],U=a[1],Z=i.length;for(s;s0&&k>0){P=R,t=k,x=P[0]-F;continue}if(E=R[0]-a[0],k>0&&t<=0){if(f=x*k-E*t,f>0)h=h+1;else if(f===0)return 0}else if(t>0&&k<=0){if(f=x*k-E*t,f<0)h=h+1;else if(f===0)return 0}else if(k===0&&t<0){if(f=x*k-E*t,f===0)return 0}else if(t===0&&k<0){if(f=x*k-E*t,f===0)return 0}else if(t===0&&k===0){if(E<=0&&x>=0)return 0;if(x<=0&&E>=0)return 0}P=R,t=k,x=E}}return h%2!==0}function Pn(a,i,s={}){if(!a)throw new Error("point is required");if(!i)throw new Error("polygon is required");const l=Jn(a),h=Ei(i),f=h.type,x=i.bbox;let t=h.coordinates;if(x&&tw(l,x)===!1)return!1;f==="Polygon"&&(t=[t]);let E=!1;for(var k=0;k=a[0]&&i[3]>=a[1]}function zn(a,i,s={}){const l=Jn(a),h=_n(i);for(let f=0;f"u"?null:s.epsilon))return!0}return!1}function nw(a,i,s,l,h){const f=s[0],x=s[1],t=a[0],E=a[1],k=i[0],P=i[1],R=s[0]-t,F=s[1]-E,U=k-t,Z=P-E,J=R*Z-F*U;if(h!==null){if(Math.abs(J)>h)return!1}else if(J!==0)return!1;if(l){if(l==="start")return Math.abs(U)>=Math.abs(Z)?U>0?t0?E=Math.abs(Z)?U>0?t<=f&&f0?E<=x&&x=Math.abs(Z)?U>0?t0?E=Math.abs(Z)?U>0?t<=f&&f<=k:k<=f&&f<=t:Z>0?E<=x&&x<=P:P<=x&&x<=E;return!1}function iw(a,i){const s=Ei(a),l=Ei(i),h=s.type,f=l.type,x=s.coordinates,t=l.coordinates;switch(h){case"Point":switch(f){case"Point":return kp(x,t);default:throw new Error("feature2 "+f+" geometry not supported")}case"MultiPoint":switch(f){case"Point":return ow(s,l);case"MultiPoint":return sw(s,l);default:throw new Error("feature2 "+f+" geometry not supported")}case"LineString":switch(f){case"Point":return zn(l,s,{ignoreEndVertices:!0});case"LineString":return uw(s,l);case"MultiPoint":return aw(s,l);default:throw new Error("feature2 "+f+" geometry not supported")}case"Polygon":switch(f){case"Point":return Pn(l,s,{ignoreBoundary:!0});case"LineString":return cw(s,l);case"Polygon":return y_(s,l);case"MultiPoint":return lw(s,l);default:throw new Error("feature2 "+f+" geometry not supported")}case"MultiPolygon":switch(f){case"Polygon":return rw(s,l);default:throw new Error("feature2 "+f+" geometry not supported")}default:throw new Error("feature1 "+h+" geometry not supported")}}function rw(a,i){return a.coordinates.some(s=>y_({type:"Polygon",coordinates:s},i))}function ow(a,i){let s,l=!1;for(s=0;si[0]||a[2]i[1]||a[3]0)for(let l=(this.length>>1)-1;l>=0;l--)this._down(l)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const i=this.data[0],s=this.data.pop();return this.length--,this.length>0&&(this.data[0]=s,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:s,compare:l}=this,h=s[i];for(;i>0;){const f=i-1>>1,x=s[f];if(l(h,x)>=0)break;s[i]=x,i=f}s[i]=h}_down(i){const{data:s,compare:l}=this,h=this.length>>1,f=s[i];for(;i=0)break;s[i]=t,i=x}s[i]=f}};function fw(a,i){return ai?1:0}function b_(a,i){return a.p.x>i.p.x?1:a.p.xi.p.y?1:-1:1}function dw(a,i){return a.rightSweepEvent.p.x>i.rightSweepEvent.p.x?1:a.rightSweepEvent.p.x0?(P.isLeftEndpoint=!0,k.isLeftEndpoint=!1):(k.isLeftEndpoint=!0,P.isLeftEndpoint=!1),i.push(k),i.push(P),x=t,xf=xf+1}}yf=yf+1}let mw=class{constructor(i){this.leftSweepEvent=i,this.rightSweepEvent=i.otherEvent}};function gw(a,i){if(a===null||i===null||a.leftSweepEvent.ringId===i.leftSweepEvent.ringId&&(a.rightSweepEvent.isSamePoint(i.leftSweepEvent)||a.rightSweepEvent.isSamePoint(i.leftSweepEvent)||a.rightSweepEvent.isSamePoint(i.rightSweepEvent)||a.leftSweepEvent.isSamePoint(i.leftSweepEvent)||a.leftSweepEvent.isSamePoint(i.rightSweepEvent)))return!1;const s=a.leftSweepEvent.p.x,l=a.leftSweepEvent.p.y,h=a.rightSweepEvent.p.x,f=a.rightSweepEvent.p.y,x=i.leftSweepEvent.p.x,t=i.leftSweepEvent.p.y,E=i.rightSweepEvent.p.x,k=i.rightSweepEvent.p.y,P=(k-t)*(h-s)-(E-x)*(f-l),R=(E-x)*(l-t)-(k-t)*(s-x),F=(h-s)*(l-t)-(f-l)*(s-x);if(P===0)return!1;const U=R/P,Z=F/P;if(U>=0&&U<=1&&Z>=0&&Z<=1){const J=s+U*(h-s),he=l+U*(f-l);return[J,he]}return!1}function _w(a,i){i=i||!1;const s=[],l=new x_([],dw);for(;a.length;){const h=a.pop();if(h.isLeftEndpoint){const f=new mw(h);for(let x=0;x{const P=k.join(",");E[P]||(E[P]=!0,t.push(k))})}else t=x;return Jt(t.map(E=>cn(E)))}function Cc(a,i={}){const s=Ei(a);switch(!i.properties&&a.type==="Feature"&&(i.properties=a.properties),s.type){case"Polygon":return xw(s,i);case"MultiPolygon":return bw(s,i);default:throw new Error("invalid poly")}}function xw(a,i={}){const l=Ei(a).coordinates,h=i.properties?i.properties:a.type==="Feature"?a.properties:{};return T_(l,h)}function bw(a,i={}){const l=Ei(a).coordinates,h=i.properties?i.properties:a.type==="Feature"?a.properties:{},f=[];return l.forEach(x=>{f.push(T_(x,h))}),Jt(f)}function T_(a,i){return a.length>1?Pa(a,i):Zn(a[0],i)}function I_(a,i){var s=Ei(a),l=Ei(i),h=s.type,f=l.type;switch(h){case"MultiPoint":switch(f){case"LineString":return M_(s,l);case"Polygon":return k_(s,l);default:throw new Error("feature2 "+f+" geometry not supported")}case"LineString":switch(f){case"MultiPoint":return M_(l,s);case"LineString":return ww(s,l);case"Polygon":return S_(s,l);default:throw new Error("feature2 "+f+" geometry not supported")}case"Polygon":switch(f){case"MultiPoint":return k_(l,s);case"LineString":return S_(l,s);default:throw new Error("feature2 "+f+" geometry not supported")}default:throw new Error("feature1 "+h+" geometry not supported")}}function M_(a,i){for(var s=!1,l=!1,h=a.coordinates.length,f=0;f0)for(var l=0;l0}function k_(a,i){var s=!1,l=!1,h=a.coordinates.length;for(let f=0;f=Math.abs(t)?x>0?a[0]<=s[0]&&s[0]<=i[0]:i[0]<=s[0]&&s[0]<=a[0]:t>0?a[1]<=s[1]&&s[1]<=i[1]:i[1]<=s[1]&&s[1]<=a[1]:Math.abs(x)>=Math.abs(t)?x>0?a[0]0?a[1]{Wi(i,t=>{if(f===!1)return!1;f=Ew(x.geometry,t.geometry,h)})}),f}function Ew(a,i,s){switch(a.type){case"Point":switch(i.type){case"Point":return!Sw(a.coordinates,i.coordinates);case"LineString":return!A_(i,a);case"Polygon":return!Pn(a,i)}break;case"LineString":switch(i.type){case"Point":return!A_(a,i);case"LineString":return!Tw(a,i,s);case"Polygon":return!P_(i,a,s)}break;case"Polygon":switch(i.type){case"Point":return!Pn(i,a);case"LineString":return!P_(a,i,s);case"Polygon":return!Iw(i,a,s)}}return!1}function A_(a,i){for(let s=0;s0}function P_(a,i,s){for(const h of i.coordinates)if(Pn(h,a))return!0;return os(i,Cc(a),{ignoreSelfIntersections:s}).features.length>0}function Iw(a,i,s){for(const h of a.coordinates[0])if(Pn(h,i))return!0;for(const h of i.coordinates[0])if(Pn(h,a))return!0;return os(Cc(a),Cc(i),{ignoreSelfIntersections:s}).features.length>0}function Mw(a,i,s){const l=s[0]-a[0],h=s[1]-a[1],f=i[0]-a[0],x=i[1]-a[1];return l*x-h*f!==0?!1:Math.abs(f)>=Math.abs(x)?f>0?a[0]<=s[0]&&s[0]<=i[0]:i[0]<=s[0]&&s[0]<=a[0]:x>0?a[1]<=s[1]&&s[1]<=i[1]:i[1]<=s[1]&&s[1]<=a[1]}function Sw(a,i){return a[0]===i[0]&&a[1]===i[1]}var kw=Object.defineProperty,vu=(a,i)=>kw(a,"name",{value:i,configurable:!0}),L_=class{constructor(i){this.direction=!1,this.compareProperties=!0;var s,l,h;this.precision=10**-((s=i==null?void 0:i.precision)!=null?s:17),this.direction=(l=i==null?void 0:i.direction)!=null?l:!1,this.compareProperties=(h=i==null?void 0:i.compareProperties)!=null?h:!0}compare(i,s){if(i.type!==s.type||!Ac(i,s))return!1;switch(i.type){case"Point":return this.compareCoord(i.coordinates,s.coordinates);case"LineString":return this.compareLine(i.coordinates,s.coordinates);case"Polygon":return this.comparePolygon(i,s);case"GeometryCollection":return this.compareGeometryCollection(i,s);case"Feature":return this.compareFeature(i,s);case"FeatureCollection":return this.compareFeatureCollection(i,s);default:if(i.type.startsWith("Multi")){const l=Ap(i),h=Ap(s);return l.every(f=>h.some(x=>this.compare(f,x)))}}return!1}compareCoord(i,s){return i.length===s.length&&i.every((l,h)=>Math.abs(l-s[h])=0&&(l=[].concat(i.slice(h,i.length),i.slice(1,h+1))),l}comparePath(i,s){return i.every((l,h)=>this.compareCoord(l,s[h]))}comparePolygon(i,s){if(this.compareLine(i.coordinates[0],s.coordinates[0],1,!0)){const l=i.coordinates.slice(1,i.coordinates.length),h=s.coordinates.slice(1,s.coordinates.length);return l.every(f=>h.some(x=>this.compareLine(f,x,1,!0)))}return!1}compareGeometryCollection(i,s){return Ac(i.geometries,s.geometries)&&this.compareBBox(i,s)&&i.geometries.every((l,h)=>this.compare(l,s.geometries[h]))}compareFeature(i,s){return i.id===s.id&&(this.compareProperties?Lp(i.properties,s.properties):!0)&&this.compareBBox(i,s)&&this.compare(i.geometry,s.geometry)}compareFeatureCollection(i,s){return Ac(i.features,s.features)&&this.compareBBox(i,s)&&i.features.every((l,h)=>this.compare(l,s.features[h]))}compareBBox(i,s){return!i.bbox&&!s.bbox||(i.bbox&&s.bbox?this.compareCoord(i.bbox,s.bbox):!1)}};vu(L_,"GeojsonEquality");var Cw=L_;function Ac(a,i){return a.coordinates?a.coordinates.length===i.coordinates.length:a.length===i.length}vu(Ac,"sameLength");function Ap(a){return a.coordinates.map(i=>({type:a.type.replace("Multi",""),coordinates:i}))}vu(Ap,"explode");function Pp(a,i,s){return new Cw(s).compare(a,i)}vu(Pp,"geojsonEquality");function Lp(a,i){if(a===null&&i===null)return!0;if(a===null||i===null)return!1;const s=Object.keys(a),l=Object.keys(i);if(s.length!==l.length)return!1;for(var h of s){const f=a[h],x=i[h],t=R_(f)&&R_(x);if(t&&!Lp(f,x)||!t&&f!==x)return!1}return!0}vu(Lp,"equal");var R_=vu(a=>a!=null&&typeof a=="object","isObject");function La(a,i={}){var s=typeof i=="object"?i.mutate:i;if(!a)throw new Error("geojson is required");var l=vo(a),h=[];switch(l){case"LineString":h=Rp(a,l);break;case"MultiLineString":case"Polygon":_n(a).forEach(function(x){h.push(Rp(x,l))});break;case"MultiPolygon":_n(a).forEach(function(x){var t=[];x.forEach(function(E){t.push(Rp(E,l))}),h.push(t)});break;case"Point":return a;case"MultiPoint":var f={};_n(a).forEach(function(x){var t=x.join("-");Object.prototype.hasOwnProperty.call(f,t)||(h.push(x),f[t]=!0)});break;default:throw new Error(l+" geometry not supported")}return a.coordinates?s===!0?(a.coordinates=h,a):{type:l,coordinates:h}:s===!0?(a.geometry.coordinates=h,a):nr({type:l,coordinates:h},a.properties,{bbox:a.bbox,id:a.id})}function Rp(a,i){var s=_n(a);if(s.length===2&&!D_(s[0],s[1]))return s;var l=[],h=s.length-1,f=l.length;l.push(s[0]);for(var x=1;x2&&z_(l[f-3],l[f-1],l[f-2])&&l.splice(l.length-2,1))}if(l.push(s[s.length-1]),f=l.length,(i==="Polygon"||i==="MultiPolygon")&&D_(s[0],s[s.length-1])&&f<4)throw new Error("invalid polygon");return i==="LineString"&&f<3||z_(l[f-3],l[f-1],l[f-2])&&l.splice(l.length-2,1),l}function D_(a,i){return a[0]===i[0]&&a[1]===i[1]}function z_(a,i,s){var l=s[0],h=s[1],f=a[0],x=a[1],t=i[0],E=i[1],k=l-f,P=h-x,R=t-f,F=E-x,U=k*F-P*R;return U!==0?!1:Math.abs(R)>=Math.abs(F)?R>0?f<=l&&l<=t:t<=l&&l<=f:F>0?x<=h&&h<=E:E<=h&&h<=x}function Aw(a,i,s={}){let l=s.precision;if(l=l==null||isNaN(l)?6:l,typeof l!="number"||!(l>=0))throw new Error("precision must be a positive number");const h=Ei(a).type,f=Ei(i).type;return h!==f?!1:Pp(La(a),La(i),{precision:l})}function O_(a,i,s={}){var l;const h=(l=s.ignoreSelfIntersections)!=null?l:!1;let f=!1;return Wi(a,x=>{Wi(i,t=>{if(f===!0)return!0;f=!Cp(x.geometry,t.geometry,{ignoreSelfIntersections:h})})}),f}function Pw(a,i,s,l,h){N_(a,i,s||0,l||a.length-1,h||Lw)}function N_(a,i,s,l,h){for(;l>s;){if(l-s>600){var f=l-s+1,x=i-s+1,t=Math.log(f),E=.5*Math.exp(2*t/3),k=.5*Math.sqrt(t*E*(f-E)/f)*(x-f/2<0?-1:1),P=Math.max(s,Math.floor(i-x*E/f+k)),R=Math.min(l,Math.floor(i+(f-x)*E/f+k));N_(a,i,P,R,h)}var F=a[i],U=s,Z=l;for(Pc(a,s,i),h(a[l],F)>0&&Pc(a,s,l);U0;)Z--}h(a[s],F)===0?Pc(a,s,Z):(Z++,Pc(a,Z,l)),Z<=i&&(s=Z+1),i<=Z&&(l=Z-1)}}function Pc(a,i,s){var l=a[i];a[i]=a[s],a[s]=l}function Lw(a,i){return ai?1:0}let so=class{constructor(i=9){this._maxEntries=Math.max(4,i),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(i){let s=this.data;const l=[];if(!wf(i,s))return l;const h=this.toBBox,f=[];for(;s;){for(let x=0;x=0&&f[s].children.length>this._maxEntries;)this._split(f,s),s--;this._adjustParentBBoxes(h,f,s)}_split(i,s){const l=i[s],h=l.children.length,f=this._minEntries;this._chooseSplitAxis(l,f,h);const x=this._chooseSplitIndex(l,f,h),t=bu(l.children.splice(x,l.children.length-x));t.height=l.height,t.leaf=l.leaf,xu(l,this.toBBox),xu(t,this.toBBox),s?i[s-1].children.push(t):this._splitRoot(l,t)}_splitRoot(i,s){this.data=bu([i,s]),this.data.height=i.height+1,this.data.leaf=!1,xu(this.data,this.toBBox)}_chooseSplitIndex(i,s,l){let h,f=1/0,x=1/0;for(let t=s;t<=l-s;t++){const E=Lc(i,0,t,this.toBBox),k=Lc(i,t,l,this.toBBox),P=Nw(E,k),R=Dp(E)+Dp(k);P=s;k--){const P=i.children[k];Rc(t,i.leaf?f(P):P),E+=bf(t)}return E}_adjustParentBBoxes(i,s,l){for(let h=l;h>=0;h--)Rc(s[h],i)}_condense(i){for(let s=i.length-1,l;s>=0;s--)i[s].children.length===0?s>0?(l=i[s-1].children,l.splice(l.indexOf(i[s]),1)):this.clear():xu(i[s],this.toBBox)}};function Rw(a,i,s){if(!s)return i.indexOf(a);for(let l=0;l=a.minX&&i.maxY>=a.minY}function bu(a){return{children:a,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function B_(a,i,s,l,h){const f=[i,s];for(;f.length;){if(s=f.pop(),i=f.pop(),s-i<=l)continue;const x=i+Math.ceil((s-i)/l/2)*l;Pw(a,x,i,s,h),f.push(i,x,x,s)}}const Bw=Object.freeze(Object.defineProperty({__proto__:null,default:so},Symbol.toStringTag,{value:"Module"}));function Ef(a){var i=new so(a);return i.insert=function(s){if(s.type!=="Feature")throw new Error("invalid feature");return s.bbox=s.bbox?s.bbox:pi(s),so.prototype.insert.call(this,s)},i.load=function(s){var l=[];return Array.isArray(s)?s.forEach(function(h){if(h.type!=="Feature")throw new Error("invalid features");h.bbox=h.bbox?h.bbox:pi(h),l.push(h)}):Bn(s,function(h){if(h.type!=="Feature")throw new Error("invalid features");h.bbox=h.bbox?h.bbox:pi(h),l.push(h)}),so.prototype.load.call(this,l)},i.remove=function(s,l){if(s.type!=="Feature")throw new Error("invalid feature");return s.bbox=s.bbox?s.bbox:pi(s),so.prototype.remove.call(this,s,l)},i.clear=function(){return so.prototype.clear.call(this)},i.search=function(s){var l=so.prototype.search.call(this,this.toBBox(s));return Jt(l)},i.collides=function(s){return so.prototype.collides.call(this,this.toBBox(s))},i.all=function(){var s=so.prototype.all.call(this);return Jt(s)},i.toJSON=function(){return so.prototype.toJSON.call(this)},i.fromJSON=function(s){return so.prototype.fromJSON.call(this,s)},i.toBBox=function(s){var l;if(s.bbox)l=s.bbox;else if(Array.isArray(s)&&s.length===4)l=s;else if(Array.isArray(s)&&s.length===6)l=[s[0],s[1],s[3],s[4]];else if(s.type==="Feature")l=pi(s);else if(s.type==="FeatureCollection")l=pi(s);else throw new Error("invalid geojson");return{minX:l[0],minY:l[1],maxX:l[2],maxY:l[3]}},i}function wu(a){if(!a)throw new Error("geojson is required");const i=[];return Wi(a,s=>{Fw(s,i)}),Jt(i)}function Fw(a,i){let s=[];const l=a.geometry;if(l!==null){switch(l.type){case"Polygon":s=_n(l);break;case"LineString":s=[_n(l)]}s.forEach(h=>{Vw(h,a.properties).forEach(x=>{x.id=i.length,i.push(x)})})}}function Vw(a,i){const s=[];return a.reduce((l,h)=>{const f=Zn([l,h],i);return f.bbox=Uw(l,h),s.push(f),h}),s}function Uw(a,i){const s=a[0],l=a[1],h=i[0],f=i[1],x=sh?s:h,k=l>f?l:f;return[x,t,E,k]}var jw=Object.defineProperty,Gw=Object.defineProperties,qw=Object.getOwnPropertyDescriptors,F_=Object.getOwnPropertySymbols,Zw=Object.prototype.hasOwnProperty,$w=Object.prototype.propertyIsEnumerable,V_=(a,i,s)=>i in a?jw(a,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[i]=s,Il=(a,i)=>{for(var s in i||(i={}))Zw.call(i,s)&&V_(a,s,i[s]);if(F_)for(var s of F_(i))$w.call(i,s)&&V_(a,s,i[s]);return a},Ml=(a,i)=>Gw(a,qw(i));function Ra(a,i,s={}){if(!a||!i)throw new Error("lines and pt are required arguments");let l=cn([1/0,1/0],{dist:1/0,index:-1,multiFeatureIndex:-1,location:-1}),h=0;return Wi(a,function(f,x,t){const E=_n(f);for(let k=0;k0&&ye.features[0]&&(te=Ml(Il({},ye.features[0]),{properties:{dist:Wn(i,ye.features[0],s),multiFeatureIndex:t,location:h+Wn(P,ye.features[0],s)}})),P.properties.dist{ta(i,F=>{U_(R,F).features.length&&x++})});break;case"Polygon":case"MultiPolygon":ta(a,R=>{ta(i,F=>{os(R,F).features.length&&x++})});break}return x>0}function Yw(a,i){if(!a)throw new Error("line1 is required");if(!i)throw new Error("line2 is required");var s=j_(a,"line1");if(s!=="LineString")throw new Error("line1 must be a LineString");var l=j_(i,"line2");if(l!=="LineString")throw new Error("line2 must be a LineString");for(var h=wu(La(a)).features,f=wu(La(i)).features,x=0;x1;case"MultiPoint":for(var h=0;h0&&os(Mn([l[0]]),Mn([l[h]])).features.length>1)return!1;return!0;case"MultiPolygon":for(var h=0;h0&&os(Mn([f[0]]),Mn([f[x]])).features.length>1)return!1;return!0;default:return!1}}function q_(a){return a[0][0]===a[a.length-1][0]&&a[0][1]===a[a.length-1][1]}function Z_(a){for(var i=0;ii[0]||a[2]i[1]||a[3]"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function k(M,c,p){return k=E()?Reflect.construct:function(g,w,L){var V=[null];V.push.apply(V,w);var X=new(Function.bind.apply(g,V));return L&&t(X,L.prototype),X},k.apply(null,arguments)}function P(M){var c=typeof Map=="function"?new Map:void 0;return P=function(p){if(p===null||(g=p,Function.toString.call(g).indexOf("[native code]")===-1))return p;var g;if(typeof p!="function")throw new TypeError("Super expression must either be null or a function");if(c!==void 0){if(c.has(p))return c.get(p);c.set(p,w)}function w(){return k(p,arguments,x(this).constructor)}return w.prototype=Object.create(p.prototype,{constructor:{value:w,enumerable:!1,writable:!0,configurable:!0}}),t(w,p)},P(M)}function R(M){if(M===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return M}function F(M,c){if(c&&(typeof c=="object"||typeof c=="function"))return c;if(c!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return R(M)}function U(M){var c=E();return function(){var p,g=x(M);if(c){var w=x(this).constructor;p=Reflect.construct(g,arguments,w)}else p=g.apply(this,arguments);return F(this,p)}}function Z(M,c,p){return Z=typeof Reflect<"u"&&Reflect.get?Reflect.get:function(g,w,L){var V=function(Q,ae){for(;!Object.prototype.hasOwnProperty.call(Q,ae)&&(Q=x(Q))!==null;);return Q}(g,w);if(V){var X=Object.getOwnPropertyDescriptor(V,w);return X.get?X.get.call(L):X.value}},Z(M,c,p||M)}function J(M){return function(c){if(Array.isArray(c))return ye(c)}(M)||function(c){if(typeof Symbol<"u"&&c[Symbol.iterator]!=null||c["@@iterator"]!=null)return Array.from(c)}(M)||he(M)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function he(M,c){if(M){if(typeof M=="string")return ye(M,c);var p=Object.prototype.toString.call(M).slice(8,-1);return p==="Object"&&M.constructor&&(p=M.constructor.name),p==="Map"||p==="Set"?Array.from(M):p==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(p)?ye(M,c):void 0}}function ye(M,c){(c==null||c>M.length)&&(c=M.length);for(var p=0,g=new Array(c);p=M.length?{done:!0}:{done:!1,value:M[g++]}},e:function(Q){throw Q},f:w}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var L,V=!0,X=!1;return{s:function(){p=p.call(M)},n:function(){var Q=p.next();return V=Q.done,Q},e:function(Q){X=!0,L=Q},f:function(){try{V||p.return==null||p.return()}finally{if(X)throw L}}}}var ce=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(c){this._quadrantSegments=c,this._quadrantSegments===0&&(this._joinStyle=M.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=M.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),c<=0&&(this._quadrantSegments=1),this._joinStyle!==M.JOIN_ROUND&&(this._quadrantSegments=M.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this._joinStyle}},{key:"setJoinStyle",value:function(c){this._joinStyle=c}},{key:"setSimplifyFactor",value:function(c){this._simplifyFactor=c<0?0:c}},{key:"getSimplifyFactor",value:function(){return this._simplifyFactor}},{key:"getQuadrantSegments",value:function(){return this._quadrantSegments}},{key:"setEndCapStyle",value:function(c){this._endCapStyle=c}},{key:"getMitreLimit",value:function(){return this._mitreLimit}},{key:"setMitreLimit",value:function(c){this._mitreLimit=c}},{key:"setSingleSided",value:function(c){this._isSingleSided=c}}],[{key:"constructor_",value:function(){if(this._quadrantSegments=M.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=M.CAP_ROUND,this._joinStyle=M.JOIN_ROUND,this._mitreLimit=M.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=M.DEFAULT_SIMPLIFY_FACTOR,arguments.length!==0){if(arguments.length===1){var c=arguments[0];this.setQuadrantSegments(c)}else if(arguments.length===2){var p=arguments[0],g=arguments[1];this.setQuadrantSegments(p),this.setEndCapStyle(g)}else if(arguments.length===4){var w=arguments[0],L=arguments[1],V=arguments[2],X=arguments[3];this.setQuadrantSegments(w),this.setEndCapStyle(L),this.setJoinStyle(V),this.setMitreLimit(X)}}}},{key:"bufferDistanceError",value:function(c){var p=Math.PI/2/c;return 1-Math.cos(p/2)}}]),M}();ce.CAP_ROUND=1,ce.CAP_FLAT=2,ce.CAP_SQUARE=3,ce.JOIN_ROUND=1,ce.JOIN_MITRE=2,ce.JOIN_BEVEL=3,ce.DEFAULT_QUADRANT_SEGMENTS=8,ce.DEFAULT_MITRE_LIMIT=5,ce.DEFAULT_SIMPLIFY_FACTOR=.01;var be=function(M){f(p,M);var c=U(p);function p(g){var w;return s(this,p),(w=c.call(this,g)).name=Object.keys({Exception:p})[0],w}return h(p,[{key:"toString",value:function(){return this.message}}]),p}(P(Error)),we=function(M){f(p,M);var c=U(p);function p(g){var w;return s(this,p),(w=c.call(this,g)).name=Object.keys({IllegalArgumentException:p})[0],w}return p}(be),Ue=function(){function M(){s(this,M)}return h(M,[{key:"filter",value:function(c){}}]),M}();function ze(){}function Ve(){}function Ie(){}var ft,lt,Je,At,ut,Nt,Lt,Yt,Mt=function(){function M(){s(this,M)}return h(M,null,[{key:"equalsWithTolerance",value:function(c,p,g){return Math.abs(c-p)<=g}}]),M}(),Gt=function(){function M(c,p){s(this,M),this.low=p||0,this.high=c||0}return h(M,null,[{key:"toBinaryString",value:function(c){var p,g="";for(p=2147483648;p>0;p>>>=1)g+=(c.high&p)===p?"1":"0";for(p=2147483648;p>0;p>>>=1)g+=(c.low&p)===p?"1":"0";return g}}]),M}();function tt(){}function Bt(){}tt.NaN=NaN,tt.isNaN=function(M){return Number.isNaN(M)},tt.isInfinite=function(M){return!Number.isFinite(M)},tt.MAX_VALUE=Number.MAX_VALUE,tt.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,tt.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,typeof Float64Array=="function"&&typeof Int32Array=="function"?(Nt=2146435072,Lt=new Float64Array(1),Yt=new Int32Array(Lt.buffer),tt.doubleToLongBits=function(M){Lt[0]=M;var c=0|Yt[0],p=0|Yt[1];return(p&Nt)===Nt&&1048575&p&&c!==0&&(c=0,p=2146959360),new Gt(p,c)},tt.longBitsToDouble=function(M){return Yt[0]=M.low,Yt[1]=M.high,Lt[0]}):(ft=1023,lt=Math.log2,Je=Math.floor,At=Math.pow,ut=function(){for(var M=53;M>0;M--){var c=At(2,M)-1;if(Je(lt(c))+1===M)return c}return 0}(),tt.doubleToLongBits=function(M){var c,p,g,w,L,V,X,Q,ae;if(M<0||1/M===Number.NEGATIVE_INFINITY?(V=-2147483648,M=-M):V=0,M===0)return new Gt(Q=V,ae=0);if(M===1/0)return new Gt(Q=2146435072|V,ae=0);if(M!=M)return new Gt(Q=2146959360,ae=0);if(w=0,ae=0,(c=Je(M))>1)if(c<=ut)(w=Je(lt(c)))<=20?(ae=0,Q=c<<20-w&1048575):(ae=c%(p=At(2,g=w-20))<<32-g,Q=c/p&1048575);else for(g=c,ae=0;(g=Je(p=g/2))!==0;)w++,ae>>>=1,ae|=(1&Q)<<31,Q>>>=1,p!==g&&(Q|=524288);if(X=w+ft,L=c===0,c=M-c,w<52&&c!==0)for(g=0;;){if((p=2*c)>=1?(c=p-1,L?(X--,L=!1):(g<<=1,g|=1,w++)):(c=p,L?--X==0&&(w++,L=!1):(g<<=1,w++)),w===20)Q|=g,g=0;else if(w===52){ae|=g;break}if(p===1){w<20?Q|=g<<20-w:w<52&&(ae|=g<<52-w);break}}return Q|=X<<20,new Gt(Q|=V,ae)},tt.longBitsToDouble=function(M){var c,p,g,w,L=M.high,V=M.low,X=L&1<<31?-1:1;for(g=((2146435072&L)>>20)-ft,w=0,p=524288,c=1;c<=20;c++)L&p&&(w+=At(2,-c)),p>>>=1;for(p=-2147483648,c=21;c<=52;c++)V&p&&(w+=At(2,-c)),p>>>=1;if(g===-1023){if(w===0)return 0*X;g=-1022}else{if(g===1024)return w===0?X/0:NaN;w+=1}return X*w*At(2,g)});var Zt=function(M){f(p,M);var c=U(p);function p(g){var w;return s(this,p),(w=c.call(this,g)).name=Object.keys({RuntimeException:p})[0],w}return p}(be),Vt=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,null,[{key:"constructor_",value:function(){if(arguments.length===0)Zt.constructor_.call(this);else if(arguments.length===1){var g=arguments[0];Zt.constructor_.call(this,g)}}}]),p}(Zt),St=function(){function M(){s(this,M)}return h(M,null,[{key:"shouldNeverReachHere",value:function(){if(arguments.length===0)M.shouldNeverReachHere(null);else if(arguments.length===1){var c=arguments[0];throw new Vt("Should never reach here"+(c!==null?": "+c:""))}}},{key:"isTrue",value:function(){if(arguments.length===1){var c=arguments[0];M.isTrue(c,null)}else if(arguments.length===2){var p=arguments[0],g=arguments[1];if(!p)throw g===null?new Vt:new Vt(g)}}},{key:"equals",value:function(){if(arguments.length===2){var c=arguments[0],p=arguments[1];M.equals(c,p,null)}else if(arguments.length===3){var g=arguments[0],w=arguments[1],L=arguments[2];if(!w.equals(g))throw new Vt("Expected "+g+" but encountered "+w+(L!==null?": "+L:""))}}}]),M}(),hn=new ArrayBuffer(8),rn=new Float64Array(hn),Tn=new Int32Array(hn),je=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getM",value:function(){return tt.NaN}},{key:"setOrdinate",value:function(c,p){switch(c){case M.X:this.x=p;break;case M.Y:this.y=p;break;case M.Z:this.setZ(p);break;default:throw new we("Invalid ordinate index: "+c)}}},{key:"equals2D",value:function(){if(arguments.length===1){var c=arguments[0];return this.x===c.x&&this.y===c.y}if(arguments.length===2){var p=arguments[0],g=arguments[1];return!!Mt.equalsWithTolerance(this.x,p.x,g)&&!!Mt.equalsWithTolerance(this.y,p.y,g)}}},{key:"setM",value:function(c){throw new we("Invalid ordinate index: "+M.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(c){switch(c){case M.X:return this.x;case M.Y:return this.y;case M.Z:return this.getZ()}throw new we("Invalid ordinate index: "+c)}},{key:"equals3D",value:function(c){return this.x===c.x&&this.y===c.y&&(this.getZ()===c.getZ()||tt.isNaN(this.getZ())&&tt.isNaN(c.getZ()))}},{key:"equals",value:function(c){return c instanceof M&&this.equals2D(c)}},{key:"equalInZ",value:function(c,p){return Mt.equalsWithTolerance(this.getZ(),c.getZ(),p)}},{key:"setX",value:function(c){this.x=c}},{key:"compareTo",value:function(c){var p=c;return this.xp.x?1:this.yp.y?1:0}},{key:"getX",value:function(){return this.x}},{key:"setZ",value:function(c){this.z=c}},{key:"clone",value:function(){try{return null}catch(c){if(c instanceof CloneNotSupportedException)return St.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw c}}},{key:"copy",value:function(){return new M(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}},{key:"distance3D",value:function(c){var p=this.x-c.x,g=this.y-c.y,w=this.getZ()-c.getZ();return Math.sqrt(p*p+g*g+w*w)}},{key:"getY",value:function(){return this.y}},{key:"setY",value:function(c){this.y=c}},{key:"distance",value:function(c){var p=this.x-c.x,g=this.y-c.y;return Math.sqrt(p*p+g*g)}},{key:"hashCode",value:function(){var c=17;return c=37*(c=37*c+M.hashCode(this.x))+M.hashCode(this.y)}},{key:"setCoordinate",value:function(c){this.x=c.x,this.y=c.y,this.z=c.getZ()}},{key:"interfaces_",get:function(){return[ze,Ve,Ie]}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,arguments.length===0)M.constructor_.call(this,0,0);else if(arguments.length===1){var c=arguments[0];M.constructor_.call(this,c.x,c.y,c.getZ())}else if(arguments.length===2){var p=arguments[0],g=arguments[1];M.constructor_.call(this,p,g,M.NULL_ORDINATE)}else if(arguments.length===3){var w=arguments[0],L=arguments[1],V=arguments[2];this.x=w,this.y=L,this.z=V}}},{key:"hashCode",value:function(c){return rn[0]=c,Tn[0]^Tn[1]}}]),M}(),Kn=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"compare",value:function(c,p){var g=M.compare(c.x,p.x);if(g!==0)return g;var w=M.compare(c.y,p.y);return w!==0?w:this._dimensionsToTest<=2?0:M.compare(c.getZ(),p.getZ())}},{key:"interfaces_",get:function(){return[Bt]}}],[{key:"constructor_",value:function(){if(this._dimensionsToTest=2,arguments.length===0)M.constructor_.call(this,2);else if(arguments.length===1){var c=arguments[0];if(c!==2&&c!==3)throw new we("only 2 or 3 dimensions may be specified");this._dimensionsToTest=c}}},{key:"compare",value:function(c,p){return cp?1:tt.isNaN(c)?tt.isNaN(p)?0:-1:tt.isNaN(p)?1:0}}]),M}();je.DimensionalComparator=Kn,je.NULL_ORDINATE=tt.NaN,je.X=0,je.Y=1,je.Z=2,je.M=3;var bn=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(c){if(!(c instanceof M))return!1;var p=c;return this.isNull()?p.isNull():this._maxx===p.getMaxX()&&this._maxy===p.getMaxY()&&this._minx===p.getMinX()&&this._miny===p.getMinY()}},{key:"intersection",value:function(c){if(this.isNull()||c.isNull()||!this.intersects(c))return new M;var p=this._minx>c._minx?this._minx:c._minx,g=this._miny>c._miny?this._miny:c._miny;return new M(p,this._maxx=this._minx&&p.getMaxX()<=this._maxx&&p.getMinY()>=this._miny&&p.getMaxY()<=this._maxy}}else if(arguments.length===2){var g=arguments[0],w=arguments[1];return!this.isNull()&&g>=this._minx&&g<=this._maxx&&w>=this._miny&&w<=this._maxy}}},{key:"intersects",value:function(){if(arguments.length===1){if(arguments[0]instanceof M){var c=arguments[0];return!this.isNull()&&!c.isNull()&&!(c._minx>this._maxx||c._maxxthis._maxy||c._maxythis._maxx)return!1;var V=g.x>w.x?g.x:w.x;if(Vthis._maxy)return!1;var Q=g.y>w.y?g.y:w.y;return!(Qthis._maxx||aethis._maxy||Lethis._maxx&&(this._maxx=p._maxx),p._minythis._maxy&&(this._maxy=p._maxy))}}else if(arguments.length===2){var g=arguments[0],w=arguments[1];this.isNull()?(this._minx=g,this._maxx=g,this._miny=w,this._maxy=w):(gthis._maxx&&(this._maxx=g),wthis._maxy&&(this._maxy=w))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var c=this.getWidth(),p=this.getHeight();return cp._minx?1:this._minyp._miny?1:this._maxxp._maxx?1:this._maxyp._maxy?1:0}},{key:"translate",value:function(c,p){if(this.isNull())return null;this.init(this.getMinX()+c,this.getMaxX()+c,this.getMinY()+p,this.getMaxY()+p)}},{key:"copy",value:function(){return new M(this)}},{key:"toString",value:function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}},{key:"setToNull",value:function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}},{key:"disjoint",value:function(c){return!(!this.isNull()&&!c.isNull())||c._minx>this._maxx||c._maxxthis._maxy||c._maxyp?c:p}},{key:"expandBy",value:function(){if(arguments.length===1){var c=arguments[0];this.expandBy(c,c)}else if(arguments.length===2){var p=arguments[0],g=arguments[1];if(this.isNull())return null;this._minx-=p,this._maxx+=p,this._miny-=g,this._maxy+=g,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}},{key:"contains",value:function(){if(arguments.length===1){if(arguments[0]instanceof M){var c=arguments[0];return this.covers(c)}if(arguments[0]instanceof je){var p=arguments[0];return this.covers(p)}}else if(arguments.length===2){var g=arguments[0],w=arguments[1];return this.covers(g,w)}}},{key:"centre",value:function(){return this.isNull()?null:new je((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}},{key:"init",value:function(){if(arguments.length===0)this.setToNull();else if(arguments.length===1){if(arguments[0]instanceof je){var c=arguments[0];this.init(c.x,c.x,c.y,c.y)}else if(arguments[0]instanceof M){var p=arguments[0];this._minx=p._minx,this._maxx=p._maxx,this._miny=p._miny,this._maxy=p._maxy}}else if(arguments.length===2){var g=arguments[0],w=arguments[1];this.init(g.x,w.x,g.y,w.y)}else if(arguments.length===4){var L=arguments[0],V=arguments[1],X=arguments[2],Q=arguments[3];Lc._maxx&&(p=this._minx-c._maxx);var g=0;return this._maxyc._maxy&&(g=this._miny-c._maxy),p===0?g:g===0?p:Math.sqrt(p*p+g*g)}},{key:"hashCode",value:function(){var c=17;return c=37*(c=37*(c=37*(c=37*c+je.hashCode(this._minx))+je.hashCode(this._maxx))+je.hashCode(this._miny))+je.hashCode(this._maxy)}},{key:"interfaces_",get:function(){return[ze,Ie]}}],[{key:"constructor_",value:function(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,arguments.length===0)this.init();else if(arguments.length===1){if(arguments[0]instanceof je){var c=arguments[0];this.init(c.x,c.x,c.y,c.y)}else if(arguments[0]instanceof M){var p=arguments[0];this.init(p)}}else if(arguments.length===2){var g=arguments[0],w=arguments[1];this.init(g.x,w.x,g.y,w.y)}else if(arguments.length===4){var L=arguments[0],V=arguments[1],X=arguments[2],Q=arguments[3];this.init(L,V,X,Q)}}},{key:"intersects",value:function(){if(arguments.length===3){var c=arguments[0],p=arguments[1],g=arguments[2];return g.x>=(c.xp.x?c.x:p.x)&&g.y>=(c.yp.y?c.y:p.y)}if(arguments.length===4){var w=arguments[0],L=arguments[1],V=arguments[2],X=arguments[3],Q=Math.min(V.x,X.x),ae=Math.max(V.x,X.x),Le=Math.min(w.x,L.x),Ne=Math.max(w.x,L.x);return!(Le>ae)&&!(Neae)&&!(Ne=this.size())throw new zo;return this.array[g]}},{key:"push",value:function(g){return this.array.push(g),g}},{key:"pop",value:function(){if(this.array.length===0)throw new Wo;return this.array.pop()}},{key:"peek",value:function(){if(this.array.length===0)throw new Wo;return this.array[this.array.length-1]}},{key:"empty",value:function(){return this.array.length===0}},{key:"isEmpty",value:function(){return this.empty()}},{key:"search",value:function(g){return this.array.indexOf(g)}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}}]),p}(Fr);function an(M,c){return M.interfaces_&&M.interfaces_.indexOf(c)>-1}var lo=function(){function M(c){s(this,M),this.str=c}return h(M,[{key:"append",value:function(c){this.str+=c}},{key:"setCharAt",value:function(c,p){this.str=this.str.substr(0,c)+p+this.str.substr(c+1)}},{key:"toString",value:function(){return this.str}}]),M}(),uo=function(){function M(c){s(this,M),this.value=c}return h(M,[{key:"intValue",value:function(){return this.value}},{key:"compareTo",value:function(c){return this.valuec?1:0}}],[{key:"compare",value:function(c,p){return cp?1:0}},{key:"isNan",value:function(c){return Number.isNaN(c)}},{key:"valueOf",value:function(c){return new M(c)}}]),M}(),Mr=function(){function M(){s(this,M)}return h(M,null,[{key:"isWhitespace",value:function(c){return c<=32&&c>=0||c===127}},{key:"toUpperCase",value:function(c){return c.toUpperCase()}}]),M}(),tn=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"le",value:function(c){return this._hi9?(Ne=!0,rt="9"):rt="0"+Le,X.append(rt),g=g.subtract(M.valueOf(Le)).multiply(M.TEN),Ne&&g.selfAdd(M.TEN);var kt=!0,Ct=M.magnitude(g._hi);if(Ct<0&&Math.abs(Ct)>=Q-ae&&(kt=!1),!kt)break}return p[0]=w,X.toString()}},{key:"sqr",value:function(){return this.multiply(this)}},{key:"doubleValue",value:function(){return this._hi+this._lo}},{key:"subtract",value:function(){if(arguments[0]instanceof M){var c=arguments[0];return this.add(c.negate())}if(typeof arguments[0]=="number"){var p=arguments[0];return this.add(-p)}}},{key:"equals",value:function(){if(arguments.length===1&&arguments[0]instanceof M){var c=arguments[0];return this._hi===c._hi&&this._lo===c._lo}}},{key:"isZero",value:function(){return this._hi===0&&this._lo===0}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof M){var c=arguments[0];return this.isNaN()?this:this.selfAdd(-c._hi,-c._lo)}if(typeof arguments[0]=="number"){var p=arguments[0];return this.isNaN()?this:this.selfAdd(-p,0)}}},{key:"getSpecialNumberString",value:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}},{key:"min",value:function(c){return this.le(c)?this:c}},{key:"selfDivide",value:function(){if(arguments.length===1){if(arguments[0]instanceof M){var c=arguments[0];return this.selfDivide(c._hi,c._lo)}if(typeof arguments[0]=="number"){var p=arguments[0];return this.selfDivide(p,0)}}else if(arguments.length===2){var g=arguments[0],w=arguments[1],L=null,V=null,X=null,Q=null,ae=null,Le=null,Ne=null,rt=null;return ae=this._hi/g,rt=(L=(Le=M.SPLIT*ae)-(L=Le-ae))*(X=(rt=M.SPLIT*g)-(X=rt-g))-(Ne=ae*g)+L*(Q=g-X)+(V=ae-L)*X+V*Q,rt=ae+(Le=(this._hi-Ne-rt+this._lo-ae*w)/g),this._hi=rt,this._lo=ae-rt+Le,this}}},{key:"dump",value:function(){return"DD<"+this._hi+", "+this._lo+">"}},{key:"divide",value:function(){if(arguments[0]instanceof M){var c=arguments[0],p=null,g=null,w=null,L=null,V=null,X=null,Q=null,ae=null;g=(V=this._hi/c._hi)-(p=(X=M.SPLIT*V)-(p=X-V)),ae=p*(w=(ae=M.SPLIT*c._hi)-(w=ae-c._hi))-(Q=V*c._hi)+p*(L=c._hi-w)+g*w+g*L;var Le=ae=V+(X=(this._hi-Q-ae+this._lo-V*c._lo)/c._hi),Ne=V-ae+X;return new M(Le,Ne)}if(typeof arguments[0]=="number"){var rt=arguments[0];return tt.isNaN(rt)?M.createNaN():M.copy(this).selfDivide(rt,0)}}},{key:"ge",value:function(c){return this._hi>c._hi||this._hi===c._hi&&this._lo>=c._lo}},{key:"pow",value:function(c){if(c===0)return M.valueOf(1);var p=new M(this),g=M.valueOf(1),w=Math.abs(c);if(w>1)for(;w>0;)w%2==1&&g.selfMultiply(p),(w/=2)>0&&(p=p.sqr());else g=p;return c<0?g.reciprocal():g}},{key:"ceil",value:function(){if(this.isNaN())return M.NaN;var c=Math.ceil(this._hi),p=0;return c===this._hi&&(p=Math.ceil(this._lo)),new M(c,p)}},{key:"compareTo",value:function(c){var p=c;return this._hip._hi?1:this._lop._lo?1:0}},{key:"rint",value:function(){return this.isNaN()?this:this.add(.5).floor()}},{key:"setValue",value:function(){if(arguments[0]instanceof M){var c=arguments[0];return this.init(c),this}if(typeof arguments[0]=="number"){var p=arguments[0];return this.init(p),this}}},{key:"max",value:function(c){return this.ge(c)?this:c}},{key:"sqrt",value:function(){if(this.isZero())return M.valueOf(0);if(this.isNegative())return M.NaN;var c=1/Math.sqrt(this._hi),p=this._hi*c,g=M.valueOf(p),w=this.subtract(g.sqr())._hi*(.5*c);return g.add(w)}},{key:"selfAdd",value:function(){if(arguments.length===1){if(arguments[0]instanceof M){var c=arguments[0];return this.selfAdd(c._hi,c._lo)}if(typeof arguments[0]=="number"){var p=arguments[0],g=null,w=null,L=null,V=null,X=null,Q=null;return V=(L=this._hi+p)-(X=L-this._hi),w=(Q=(V=p-X+(this._hi-V))+this._lo)+(L-(g=L+Q)),this._hi=g+w,this._lo=w+(g-this._hi),this}}else if(arguments.length===2){var ae=arguments[0],Le=arguments[1],Ne=null,rt=null,kt=null,Ct=null,Qt=null,Ht=null,dn=null;Ct=this._hi+ae,rt=this._lo+Le,Qt=Ct-(Ht=Ct-this._hi),kt=rt-(dn=rt-this._lo);var Rn=(Ne=Ct+(Ht=(Qt=ae-Ht+(this._hi-Qt))+rt))+(Ht=(kt=Le-dn+(this._lo-kt))+(Ht+(Ct-Ne))),ui=Ht+(Ne-Rn);return this._hi=Rn,this._lo=ui,this}}},{key:"selfMultiply",value:function(){if(arguments.length===1){if(arguments[0]instanceof M){var c=arguments[0];return this.selfMultiply(c._hi,c._lo)}if(typeof arguments[0]=="number"){var p=arguments[0];return this.selfMultiply(p,0)}}else if(arguments.length===2){var g=arguments[0],w=arguments[1],L=null,V=null,X=null,Q=null,ae=null,Le=null;L=(ae=M.SPLIT*this._hi)-this._hi,Le=M.SPLIT*g,L=ae-L,V=this._hi-L,X=Le-g;var Ne=(ae=this._hi*g)+(Le=L*(X=Le-X)-ae+L*(Q=g-X)+V*X+V*Q+(this._hi*w+this._lo*g)),rt=Le+(L=ae-Ne);return this._hi=Ne,this._lo=rt,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return M.NaN;var c=Math.floor(this._hi),p=0;return c===this._hi&&(p=Math.floor(this._lo)),new M(c,p)}},{key:"negate",value:function(){return this.isNaN()?this:new M(-this._hi,-this._lo)}},{key:"clone",value:function(){try{return null}catch(c){if(c instanceof CloneNotSupportedException)return null;throw c}}},{key:"multiply",value:function(){if(arguments[0]instanceof M){var c=arguments[0];return c.isNaN()?M.createNaN():M.copy(this).selfMultiply(c)}if(typeof arguments[0]=="number"){var p=arguments[0];return tt.isNaN(p)?M.createNaN():M.copy(this).selfMultiply(p,0)}}},{key:"isNaN",value:function(){return tt.isNaN(this._hi)}},{key:"intValue",value:function(){return Math.trunc(this._hi)}},{key:"toString",value:function(){var c=M.magnitude(this._hi);return c>=-3&&c<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var c=this.getSpecialNumberString();if(c!==null)return c;var p=new Array(1).fill(null),g=this.extractSignificantDigits(!0,p),w=p[0]+1,L=g;if(g.charAt(0)===".")L="0"+g;else if(w<0)L="0."+M.stringOfChar("0",-w)+g;else if(g.indexOf(".")===-1){var V=w-g.length;L=g+M.stringOfChar("0",V)+".0"}return this.isNegative()?"-"+L:L}},{key:"reciprocal",value:function(){var c,p,g,w,L=null,V=null,X=null,Q=null;c=(g=1/this._hi)-(L=(X=M.SPLIT*g)-(L=X-g)),V=(Q=M.SPLIT*this._hi)-this._hi;var ae=g+(X=(1-(w=g*this._hi)-(Q=L*(V=Q-V)-w+L*(p=this._hi-V)+c*V+c*p)-g*this._lo)/this._hi);return new M(ae,g-ae+X)}},{key:"toSciNotation",value:function(){if(this.isZero())return M.SCI_NOT_ZERO;var c=this.getSpecialNumberString();if(c!==null)return c;var p=new Array(1).fill(null),g=this.extractSignificantDigits(!1,p),w=M.SCI_NOT_EXPONENT_CHAR+p[0];if(g.charAt(0)==="0")throw new IllegalStateException("Found leading zero: "+g);var L="";g.length>1&&(L=g.substring(1));var V=g.charAt(0)+"."+L;return this.isNegative()?"-"+V+w:V+w}},{key:"abs",value:function(){return this.isNaN()?M.NaN:this.isNegative()?this.negate():new M(this)}},{key:"isPositive",value:function(){return this._hi>0||this._hi===0&&this._lo>0}},{key:"lt",value:function(c){return this._hic._hi||this._hi===c._hi&&this._lo>c._lo}},{key:"isNegative",value:function(){return this._hi<0||this._hi===0&&this._lo<0}},{key:"trunc",value:function(){return this.isNaN()?M.NaN:this.isPositive()?this.floor():this.ceil()}},{key:"signum",value:function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}},{key:"interfaces_",get:function(){return[Ie,ze,Ve]}}],[{key:"constructor_",value:function(){if(this._hi=0,this._lo=0,arguments.length===0)this.init(0);else if(arguments.length===1){if(typeof arguments[0]=="number"){var c=arguments[0];this.init(c)}else if(arguments[0]instanceof M){var p=arguments[0];this.init(p)}else if(typeof arguments[0]=="string"){var g=arguments[0];M.constructor_.call(this,M.parse(g))}}else if(arguments.length===2){var w=arguments[0],L=arguments[1];this.init(w,L)}}},{key:"determinant",value:function(){if(typeof arguments[3]=="number"&&typeof arguments[2]=="number"&&typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var c=arguments[0],p=arguments[1],g=arguments[2],w=arguments[3];return M.determinant(M.valueOf(c),M.valueOf(p),M.valueOf(g),M.valueOf(w))}if(arguments[3]instanceof M&&arguments[2]instanceof M&&arguments[0]instanceof M&&arguments[1]instanceof M){var L=arguments[0],V=arguments[1],X=arguments[2],Q=arguments[3],ae=L.multiply(Q).selfSubtract(V.multiply(X));return ae}}},{key:"sqr",value:function(c){return M.valueOf(c).selfMultiply(c)}},{key:"valueOf",value:function(){if(typeof arguments[0]=="string"){var c=arguments[0];return M.parse(c)}if(typeof arguments[0]=="number"){var p=arguments[0];return new M(p)}}},{key:"sqrt",value:function(c){return M.valueOf(c).sqrt()}},{key:"parse",value:function(c){for(var p=0,g=c.length;Mr.isWhitespace(c.charAt(p));)p++;var w=!1;if(p=g);){var Ne=c.charAt(p);if(p++,Mr.isDigit(Ne)){var rt=Ne-"0";V.selfMultiply(M.TEN),V.selfAdd(rt),X++}else{if(Ne!=="."){if(Ne==="e"||Ne==="E"){var kt=c.substring(p);try{ae=uo.parseInt(kt)}catch(Rn){throw Rn instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+kt+" in string "+c):Rn}break}throw new NumberFormatException("Unexpected character '"+Ne+"' at position "+p+" in string "+c)}Q=X,Le=!0}}var Ct=V;Le||(Q=X);var Qt=X-Q-ae;if(Qt===0)Ct=V;else if(Qt>0){var Ht=M.TEN.pow(Qt);Ct=V.divide(Ht)}else if(Qt<0){var dn=M.TEN.pow(-Qt);Ct=V.multiply(dn)}return w?Ct.negate():Ct}},{key:"createNaN",value:function(){return new M(tt.NaN,tt.NaN)}},{key:"copy",value:function(c){return new M(c)}},{key:"magnitude",value:function(c){var p=Math.abs(c),g=Math.log(p)/Math.log(10),w=Math.trunc(Math.floor(g));return 10*Math.pow(10,w)<=p&&(w+=1),w}},{key:"stringOfChar",value:function(c,p){for(var g=new lo,w=0;w0){if(V<=0)return M.signum(X);w=L+V}else{if(!(L<0)||V>=0)return M.signum(X);w=-L-V}var Q=M.DP_SAFE_EPSILON*w;return X>=Q||-X>=Q?M.signum(X):2}},{key:"signum",value:function(c){return c>0?1:c<0?-1:0}}]),M}();as.DP_SAFE_EPSILON=1e-15;var Ln=function(){function M(){s(this,M)}return h(M,[{key:"getM",value:function(c){if(this.hasM()){var p=this.getDimension()-this.getMeasures();return this.getOrdinate(c,p)}return tt.NaN}},{key:"setOrdinate",value:function(c,p,g){}},{key:"getZ",value:function(c){return this.hasZ()?this.getOrdinate(c,2):tt.NaN}},{key:"size",value:function(){}},{key:"getOrdinate",value:function(c,p){}},{key:"getCoordinate",value:function(){}},{key:"getCoordinateCopy",value:function(c){}},{key:"createCoordinate",value:function(){}},{key:"getDimension",value:function(){}},{key:"hasM",value:function(){return this.getMeasures()>0}},{key:"getX",value:function(c){}},{key:"hasZ",value:function(){return this.getDimension()-this.getMeasures()>2}},{key:"getMeasures",value:function(){return 0}},{key:"expandEnvelope",value:function(c){}},{key:"copy",value:function(){}},{key:"getY",value:function(c){}},{key:"toCoordinateArray",value:function(){}},{key:"interfaces_",get:function(){return[Ve]}}]),M}();Ln.X=0,Ln.Y=1,Ln.Z=2,Ln.M=3;var sn=function(){function M(){s(this,M)}return h(M,null,[{key:"index",value:function(c,p,g){return as.orientationIndex(c,p,g)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var c=arguments[0],p=c.length-1;if(p<3)throw new we("Ring has fewer than 4 points, so orientation cannot be determined");for(var g=c[0],w=0,L=1;L<=p;L++){var V=c[L];V.y>g.y&&(g=V,w=L)}var X=w;do(X-=1)<0&&(X=p);while(c[X].equals2D(g)&&X!==w);var Q=w;do Q=(Q+1)%p;while(c[Q].equals2D(g)&&Q!==w);var ae=c[X],Le=c[Q];if(ae.equals2D(g)||Le.equals2D(g)||ae.equals2D(Le))return!1;var Ne=M.index(ae,g,Le),rt=null;return rt=Ne===0?ae.x>Le.x:Ne>0,rt}if(an(arguments[0],Ln)){var kt=arguments[0],Ct=kt.size()-1;if(Ct<3)throw new we("Ring has fewer than 4 points, so orientation cannot be determined");for(var Qt=kt.getCoordinate(0),Ht=0,dn=1;dn<=Ct;dn++){var Rn=kt.getCoordinate(dn);Rn.y>Qt.y&&(Qt=Rn,Ht=dn)}var ui=null,lr=Ht;do(lr-=1)<0&&(lr=Ct),ui=kt.getCoordinate(lr);while(ui.equals2D(Qt)&&lr!==Ht);var Vi=null,dr=Ht;do dr=(dr+1)%Ct,Vi=kt.getCoordinate(dr);while(Vi.equals2D(Qt)&&dr!==Ht);if(ui.equals2D(Qt)||Vi.equals2D(Qt)||ui.equals2D(Vi))return!1;var Jr=M.index(ui,Qt,Vi);return Jr===0?ui.x>Vi.x:Jr>0}}}]),M}();sn.CLOCKWISE=-1,sn.RIGHT=sn.CLOCKWISE,sn.COUNTERCLOCKWISE=1,sn.LEFT=sn.COUNTERCLOCKWISE,sn.COLLINEAR=0,sn.STRAIGHT=sn.COLLINEAR;var ra=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getCoordinate",value:function(){return this._minCoord}},{key:"getRightmostSide",value:function(c,p){var g=this.getRightmostSideOfSegment(c,p);return g<0&&(g=this.getRightmostSideOfSegment(c,p-1)),g<0&&(this._minCoord=null,this.checkForRightmostCoordinate(c)),g}},{key:"findRightmostEdgeAtVertex",value:function(){var c=this._minDe.getEdge().getCoordinates();St.isTrue(this._minIndex>0&&this._minIndexthis._minCoord.y&&g.y>this._minCoord.y&&w===sn.CLOCKWISE)&&(L=!0),L&&(this._minIndex=this._minIndex-1)}},{key:"getRightmostSideOfSegment",value:function(c,p){var g=c.getEdge().getCoordinates();if(p<0||p+1>=g.length||g[p].y===g[p+1].y)return-1;var w=wt.LEFT;return g[p].ythis._minCoord.x)&&(this._minDe=c,this._minIndex=g,this._minCoord=p[g])}},{key:"findRightmostEdgeAtNode",value:function(){var c=this._minDe.getNode().getEdges();this._minDe=c.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}},{key:"findEdge",value:function(c){for(var p=c.iterator();p.hasNext();){var g=p.next();g.isForward()&&this.checkForRightmostCoordinate(g)}St.isTrue(this._minIndex!==0||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),this._minIndex===0?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===wt.LEFT&&(this._orientedDe=this._minDe.getSym())}}],[{key:"constructor_",value:function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}}]),M}(),vr=function(M){f(p,M);var c=U(p);function p(g,w){var L;return s(this,p),(L=c.call(this,w?g+" [ "+w+" ]":g)).pt=w?new je(w):void 0,L.name=Object.keys({TopologyException:p})[0],L}return h(p,[{key:"getCoordinate",value:function(){return this.pt}}]),p}(Zt),Yo=function(){function M(){s(this,M),this.array=[]}return h(M,[{key:"addLast",value:function(c){this.array.push(c)}},{key:"removeFirst",value:function(){return this.array.shift()}},{key:"isEmpty",value:function(){return this.array.length===0}}]),M}(),nn=function(M,c){f(g,M);var p=U(g);function g(w){var L;return s(this,g),(L=p.call(this)).array=[],w instanceof Fn&&L.addAll(w),L}return h(g,[{key:"interfaces_",get:function(){return[Fr,Fn]}},{key:"ensureCapacity",value:function(){}},{key:"add",value:function(w){return arguments.length===1?this.array.push(w):this.array.splice(arguments[0],0,arguments[1]),!0}},{key:"clear",value:function(){this.array=[]}},{key:"addAll",value:function(w){var L,V=te(w);try{for(V.s();!(L=V.n()).done;){var X=L.value;this.array.push(X)}}catch(Q){V.e(Q)}finally{V.f()}}},{key:"set",value:function(w,L){var V=this.array[w];return this.array[w]=L,V}},{key:"iterator",value:function(){return new ls(this)}},{key:"get",value:function(w){if(w<0||w>=this.size())throw new zo;return this.array[w]}},{key:"isEmpty",value:function(){return this.array.length===0}},{key:"sort",value:function(w){w?this.array.sort(function(L,V){return w.compare(L,V)}):this.array.sort()}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"remove",value:function(w){for(var L=0,V=this.array.length;L=1&&p.getDepth(wt.LEFT)<=0&&!p.isInteriorAreaEdge()&&p.setInResult(!0)}}},{key:"computeDepths",value:function(c){var p=new Yi,g=new Yo,w=c.getNode();for(g.addLast(w),p.add(w),c.setVisited(!0);!g.isEmpty();){var L=g.removeFirst();p.add(L),this.computeNodeDepth(L);for(var V=L.getEdges().iterator();V.hasNext();){var X=V.next().getSym();if(!X.isVisited()){var Q=X.getNode();p.contains(Q)||(g.addLast(Q),p.add(Q))}}}}},{key:"compareTo",value:function(c){var p=c;return this._rightMostCoord.xp._rightMostCoord.x?1:0}},{key:"getEnvelope",value:function(){if(this._env===null){for(var c=new bn,p=this._dirEdgeList.iterator();p.hasNext();)for(var g=p.next().getEdge().getCoordinates(),w=0;wp.x?c.x:p.x,Q=c.y>p.y?c.y:p.y,ae=g.xw.x?g.x:w.x,rt=g.y>w.y?g.y:w.y,kt=((L>ae?L:ae)+(XLe?V:Le)+(Qg?g:c}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var w=arguments[0],L=arguments[1],V=arguments[2];return wV?V:w}}},{key:"wrap",value:function(c,p){return c<0?p- -c%p:c%p}},{key:"max",value:function(){if(arguments.length===3){var c=arguments[0],p=arguments[1],g=arguments[2],w=c;return p>w&&(w=p),g>w&&(w=g),w}if(arguments.length===4){var L=arguments[0],V=arguments[1],X=arguments[2],Q=arguments[3],ae=L;return V>ae&&(ae=V),X>ae&&(ae=X),Q>ae&&(ae=Q),ae}}},{key:"average",value:function(c,p){return(c+p)/2}}]),M}();ee.LOG_10=Math.log(10);var ne=function(){function M(){s(this,M)}return h(M,null,[{key:"segmentToSegment",value:function(c,p,g,w){if(c.equals(p))return M.pointToSegment(c,g,w);if(g.equals(w))return M.pointToSegment(w,c,p);var L=!1;if(bn.intersects(c,p,g,w)){var V=(p.x-c.x)*(w.y-g.y)-(p.y-c.y)*(w.x-g.x);if(V===0)L=!0;else{var X=(c.y-g.y)*(w.x-g.x)-(c.x-g.x)*(w.y-g.y),Q=((c.y-g.y)*(p.x-c.x)-(c.x-g.x)*(p.y-c.y))/V,ae=X/V;(ae<0||ae>1||Q<0||Q>1)&&(L=!0)}}else L=!0;return L?ee.min(M.pointToSegment(c,g,w),M.pointToSegment(p,g,w),M.pointToSegment(g,c,p),M.pointToSegment(w,c,p)):0}},{key:"pointToSegment",value:function(c,p,g){if(p.x===g.x&&p.y===g.y)return c.distance(p);var w=(g.x-p.x)*(g.x-p.x)+(g.y-p.y)*(g.y-p.y),L=((c.x-p.x)*(g.x-p.x)+(c.y-p.y)*(g.y-p.y))/w;if(L<=0)return c.distance(p);if(L>=1)return c.distance(g);var V=((p.y-c.y)*(g.x-p.x)-(p.x-c.x)*(g.y-p.y))/w;return Math.abs(V)*Math.sqrt(w)}},{key:"pointToLinePerpendicular",value:function(c,p,g){var w=(g.x-p.x)*(g.x-p.x)+(g.y-p.y)*(g.y-p.y),L=((p.y-c.y)*(g.x-p.x)-(p.x-c.x)*(g.y-p.y))/w;return Math.abs(L)*Math.sqrt(w)}},{key:"pointToSegmentString",value:function(c,p){if(p.length===0)throw new we("Line array must contain at least one vertex");for(var g=c.distance(p[0]),w=0;w0)&&(V=Q,L=X)}return L}}},{key:"extend",value:function(c,p,g){var w=c.create(g,p.getDimension()),L=p.size();if(M.copy(p,0,w,0,L),L>0)for(var V=L;V0)&&(p=w)}return p}}]),M}(),me=function(){function M(){s(this,M)}return h(M,null,[{key:"toDimensionSymbol",value:function(c){switch(c){case M.FALSE:return M.SYM_FALSE;case M.TRUE:return M.SYM_TRUE;case M.DONTCARE:return M.SYM_DONTCARE;case M.P:return M.SYM_P;case M.L:return M.SYM_L;case M.A:return M.SYM_A}throw new we("Unknown dimension value: "+c)}},{key:"toDimensionValue",value:function(c){switch(Mr.toUpperCase(c)){case M.SYM_FALSE:return M.FALSE;case M.SYM_TRUE:return M.TRUE;case M.SYM_DONTCARE:return M.DONTCARE;case M.SYM_P:return M.P;case M.SYM_L:return M.L;case M.SYM_A:return M.A}throw new we("Unknown dimension symbol: "+c)}}]),M}();me.P=0,me.L=1,me.A=2,me.FALSE=-1,me.TRUE=-2,me.DONTCARE=-3,me.SYM_FALSE="F",me.SYM_TRUE="T",me.SYM_DONTCARE="*",me.SYM_P="0",me.SYM_L="1",me.SYM_A="2";var Ye=function(){function M(){s(this,M)}return h(M,[{key:"filter",value:function(c){}}]),M}(),xt=function(){function M(){s(this,M)}return h(M,[{key:"filter",value:function(c,p){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}]),M}(),It=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new bn:this._points.expandEnvelope(new bn)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this._points.toCoordinateArray()}},{key:"copyInternal",value:function(){return new p(this._points.copy(),this._factory)}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof gt){var g=arguments[0],w=arguments[1];if(!this.isEquivalentClass(g))return!1;var L=g;if(this._points.size()!==L._points.size())return!1;for(var V=0;V0){var L=this._points.copy();Fe.reverse(L),this._points=L}return null}}}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._points.getCoordinate(0)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?me.FALSE:0}},{key:"isClosed",value:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}},{key:"reverseInternal",value:function(){var g=this._points.copy();return Fe.reverse(g),this.getFactory().createLineString(g)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return gt.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return De.ofLine(this._points)}},{key:"getNumPoints",value:function(){return this._points.size()}},{key:"compareToSameClass",value:function(){if(arguments.length===1){for(var g=arguments[0],w=g,L=0,V=0;L= 2)");this._points=g}},{key:"isCoordinate",value:function(g){for(var w=0;w=1&&this.getCoordinateSequence().size()= 4)")}},{key:"getGeometryType",value:function(){return gt.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var g=arguments[0],w=arguments[1];It.constructor_.call(this,g,w),this.validateConstruction()}}]),p}(It);Ci.MINIMUM_VALID_SIZE=4;var Li=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"setOrdinate",value:function(g,w){switch(g){case p.X:this.x=w;break;case p.Y:this.y=w;break;default:throw new we("Invalid ordinate index: "+g)}}},{key:"getZ",value:function(){return je.NULL_ORDINATE}},{key:"getOrdinate",value:function(g){switch(g){case p.X:return this.x;case p.Y:return this.y}throw new we("Invalid ordinate index: "+g)}},{key:"setZ",value:function(g){throw new we("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new p(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"setCoordinate",value:function(g){this.x=g.x,this.y=g.y,this.z=g.getZ()}}],[{key:"constructor_",value:function(){if(arguments.length===0)je.constructor_.call(this);else if(arguments.length===1){if(arguments[0]instanceof p){var g=arguments[0];je.constructor_.call(this,g.x,g.y)}else if(arguments[0]instanceof je){var w=arguments[0];je.constructor_.call(this,w.x,w.y)}}else if(arguments.length===2){var L=arguments[0],V=arguments[1];je.constructor_.call(this,L,V,je.NULL_ORDINATE)}}}]),p}(je);Li.X=0,Li.Y=1,Li.Z=-1,Li.M=-1;var Xr=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(g,w){switch(g){case p.X:this.x=w;break;case p.Y:this.y=w;break;case p.M:this._m=w;break;default:throw new we("Invalid ordinate index: "+g)}}},{key:"setM",value:function(g){this._m=g}},{key:"getZ",value:function(){return je.NULL_ORDINATE}},{key:"getOrdinate",value:function(g){switch(g){case p.X:return this.x;case p.Y:return this.y;case p.M:return this._m}throw new we("Invalid ordinate index: "+g)}},{key:"setZ",value:function(g){throw new we("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new p(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(g){this.x=g.x,this.y=g.y,this.z=g.getZ(),this._m=g.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,arguments.length===0)je.constructor_.call(this),this._m=0;else if(arguments.length===1){if(arguments[0]instanceof p){var g=arguments[0];je.constructor_.call(this,g.x,g.y),this._m=g._m}else if(arguments[0]instanceof je){var w=arguments[0];je.constructor_.call(this,w.x,w.y),this._m=this.getM()}}else if(arguments.length===3){var L=arguments[0],V=arguments[1],X=arguments[2];je.constructor_.call(this,L,V,je.NULL_ORDINATE),this._m=X}}}]),p}(je);Xr.X=0,Xr.Y=1,Xr.Z=-1,Xr.M=2;var Pl=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(g,w){switch(g){case je.X:this.x=w;break;case je.Y:this.y=w;break;case je.Z:this.z=w;break;case je.M:this._m=w;break;default:throw new we("Invalid ordinate index: "+g)}}},{key:"setM",value:function(g){this._m=g}},{key:"getOrdinate",value:function(g){switch(g){case je.X:return this.x;case je.Y:return this.y;case je.Z:return this.getZ();case je.M:return this.getM()}throw new we("Invalid ordinate index: "+g)}},{key:"copy",value:function(){return new p(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(g){this.x=g.x,this.y=g.y,this.z=g.getZ(),this._m=g.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,arguments.length===0)je.constructor_.call(this),this._m=0;else if(arguments.length===1){if(arguments[0]instanceof p){var g=arguments[0];je.constructor_.call(this,g),this._m=g._m}else if(arguments[0]instanceof je){var w=arguments[0];je.constructor_.call(this,w),this._m=this.getM()}}else if(arguments.length===4){var L=arguments[0],V=arguments[1],X=arguments[2],Q=arguments[3];je.constructor_.call(this,L,V,X),this._m=Q}}}]),p}(je),oa=function(){function M(){s(this,M)}return h(M,null,[{key:"measures",value:function(c){return c instanceof Li?0:c instanceof Xr||c instanceof Pl?1:0}},{key:"dimension",value:function(c){return c instanceof Li?2:c instanceof Xr?3:c instanceof Pl?4:3}},{key:"create",value:function(){if(arguments.length===1){var c=arguments[0];return M.create(c,0)}if(arguments.length===2){var p=arguments[0],g=arguments[1];return p===2?new Li:p===3&&g===0?new je:p===3&&g===1?new Xr:p===4&&g===1?new Pl:new je}}}]),M}(),On=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"getCoordinate",value:function(g){return this.get(g)}},{key:"addAll",value:function(){if(arguments.length===2&&typeof arguments[1]=="boolean"&&an(arguments[0],Fn)){for(var g=arguments[0],w=arguments[1],L=!1,V=g.iterator();V.hasNext();)this.add(V.next(),w),L=!0;return L}return Z(x(p.prototype),"addAll",this).apply(this,arguments)}},{key:"clone",value:function(){for(var g=Z(x(p.prototype),"clone",this).call(this),w=0;w=1){var Q=this.get(this.size()-1);if(Q.equals2D(V))return null}Z(x(p.prototype),"add",this).call(this,V)}else if(arguments[0]instanceof Object&&typeof arguments[1]=="boolean"){var ae=arguments[0],Le=arguments[1];return this.add(ae,Le),!0}}else if(arguments.length===3){if(typeof arguments[2]=="boolean"&&arguments[0]instanceof Array&&typeof arguments[1]=="boolean"){var Ne=arguments[0],rt=arguments[1],kt=arguments[2];if(kt)for(var Ct=0;Ct=0;Qt--)this.add(Ne[Qt],rt);return!0}if(typeof arguments[2]=="boolean"&&Number.isInteger(arguments[0])&&arguments[1]instanceof je){var Ht=arguments[0],dn=arguments[1],Rn=arguments[2];if(!Rn){var ui=this.size();if(ui>0){if(Ht>0){var lr=this.get(Ht-1);if(lr.equals2D(dn))return null}if(HtDn&&(Vo=-1);for(var ys=So;ys!==Dn;ys+=Vo)this.add(dr[ys],Jr);return!0}}},{key:"closeRing",value:function(){if(this.size()>0){var g=this.get(0).copy();this.add(g,!1)}}}],[{key:"constructor_",value:function(){if(arguments.length!==0){if(arguments.length===1){var g=arguments[0];this.ensureCapacity(g.length),this.add(g,!0)}else if(arguments.length===2){var w=arguments[0],L=arguments[1];this.ensureCapacity(w.length),this.add(w,L)}}}}]),p}(nn);On.coordArrayType=new Array(0).fill(null);var Ri=function(){function M(){s(this,M)}return h(M,null,[{key:"isRing",value:function(c){return!(c.length<4)&&!!c[0].equals2D(c[c.length-1])}},{key:"ptNotInList",value:function(c,p){for(var g=0;g=c?p:[]}},{key:"indexOf",value:function(c,p){for(var g=0;g0)&&(p=c[g]);return p}},{key:"extract",value:function(c,p,g){p=ee.clamp(p,0,c.length);var w=(g=ee.clamp(g,-1,c.length))-p+1;g<0&&(w=0),p>=c.length&&(w=0),gw.length)return 1;if(g.length===0)return 0;var L=Ri.compare(g,w);return Ri.isEqualReversed(g,w)?0:L}},{key:"OLDcompare",value:function(c,p){var g=c,w=p;if(g.lengthw.length)return 1;if(g.length===0)return 0;for(var L=Ri.increasingDirection(g),V=Ri.increasingDirection(w),X=L>0?0:g.length-1,Q=V>0?0:g.length-1,ae=0;ae0){var c=new us(17*this._coordinates.length);c.append("("),c.append(this._coordinates[0]);for(var p=1;p3&&(w=3),w<2&&(w=2),new Sr(g,w)}if(arguments.length===3){var L=arguments[0],V=arguments[1],X=arguments[2],Q=V-X;return X>1&&(X=1),Q>3&&(Q=3),Q<2&&(Q=2),new Sr(L,Q+X,X)}}}},{key:"interfaces_",get:function(){return[ve,Ie]}}],[{key:"instance",value:function(){return M.instanceObject}}]),M}();co.instanceObject=new co;var aa=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"copyInternal",value:function(){for(var g=new Array(this._geometries.length).fill(null),w=0;w=0?c:p}}]),M}(),wo=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"readResolve",value:function(){return M.nameToTypeMap.get(this._name)}},{key:"toString",value:function(){return this._name}},{key:"interfaces_",get:function(){return[Ie]}}],[{key:"constructor_",value:function(){this._name=null;var c=arguments[0];this._name=c,M.nameToTypeMap.put(c,this)}}]),M}();wo.nameToTypeMap=new cs,Fi.Type=wo,Fi.FIXED=new wo("FIXED"),Fi.FLOATING=new wo("FLOATING"),Fi.FLOATING_SINGLE=new wo("FLOATING SINGLE"),Fi.maximumPreciseValue=9007199254740992;var Qe=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"copyInternal",value:function(){for(var g=new Array(this._geometries.length).fill(null),w=0;w1){if(Q instanceof Sn)return this.createMultiPolygon(M.toPolygonArray(c));if(Q instanceof It)return this.createMultiLineString(M.toLineStringArray(c));if(Q instanceof ln)return this.createMultiPoint(M.toPointArray(c));St.shouldNeverReachHere("Unhandled geometry type: "+Q.getGeometryType())}return Q}},{key:"createMultiPointFromCoords",value:function(c){return this.createMultiPoint(c!==null?this.getCoordinateSequenceFactory().create(c):null)}},{key:"createPoint",value:function(){if(arguments.length===0)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof je){var c=arguments[0];return this.createPoint(c!==null?this.getCoordinateSequenceFactory().create([c]):null)}if(an(arguments[0],Ln)){var p=arguments[0];return new ln(p,this)}}}},{key:"getCoordinateSequenceFactory",value:function(){return this._coordinateSequenceFactory}},{key:"createPolygon",value:function(){if(arguments.length===0)return this.createPolygon(null,null);if(arguments.length===1){if(an(arguments[0],Ln)){var c=arguments[0];return this.createPolygon(this.createLinearRing(c))}if(arguments[0]instanceof Array){var p=arguments[0];return this.createPolygon(this.createLinearRing(p))}if(arguments[0]instanceof Ci){var g=arguments[0];return this.createPolygon(g,null)}}else if(arguments.length===2){var w=arguments[0],L=arguments[1];return new Sn(w,L,this)}}},{key:"getSRID",value:function(){return this._SRID}},{key:"createGeometryCollection",value:function(){if(arguments.length===0)return new $n(null,this);if(arguments.length===1){var c=arguments[0];return new $n(c,this)}}},{key:"getPrecisionModel",value:function(){return this._precisionModel}},{key:"createLinearRing",value:function(){if(arguments.length===0)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof Array){var c=arguments[0];return this.createLinearRing(c!==null?this.getCoordinateSequenceFactory().create(c):null)}if(an(arguments[0],Ln)){var p=arguments[0];return new Ci(p,this)}}}},{key:"createMultiPolygon",value:function(){if(arguments.length===0)return new aa(null,this);if(arguments.length===1){var c=arguments[0];return new aa(c,this)}}},{key:"createMultiPoint",value:function(){if(arguments.length===0)return new $r(null,this);if(arguments.length===1){if(arguments[0]instanceof Array){var c=arguments[0];return new $r(c,this)}if(an(arguments[0],Ln)){var p=arguments[0];if(p===null)return this.createMultiPoint(new Array(0).fill(null));for(var g=new Array(p.size()).fill(null),w=0;w="a"&&c<="z"||c>="A"&&c<="Z"}},{key:"isNumeric_",value:function(c,p){return c>="0"&&c<="9"||c=="."&&!(p!==void 0&&p)}},{key:"isWhiteSpace_",value:function(c){return c==" "||c==" "||c=="\r"||c==` `}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var c,p=this.nextChar_(),g=this.index_,w=p;if(p=="(")c=Pt;else if(p==",")c=Ji;else if(p==")")c=fn;else if(this.isNumeric_(p)||p=="-")c=In,w=this.readNumber_();else if(this.isAlpha_(p))c=Oo,w=this.readText_();else{if(this.isWhiteSpace_(p))return this.nextToken();if(p!=="")throw new Error("Unexpected character: "+p);c=ho}return{position:g,value:w,type:c}}},{key:"readNumber_",value:function(){var c,p=this.index_,g=!1,w=!1;do c=="."?g=!0:c!="e"&&c!="E"||(w=!0),c=this.nextChar_();while(this.isNumeric_(c,g)||!w&&(c=="e"||c=="E")||w&&(c=="-"||c=="+"));return parseFloat(this.wkt.substring(p,this.index_--))}},{key:"readText_",value:function(){var c,p=this.index_;do c=this.nextChar_();while(this.isAlpha_(c));return this.wkt.substring(p,this.index_--).toUpperCase()}}]),M}(),la=function(){function M(c,p){s(this,M),this.lexer_=c,this.token_,this.layout_=Ti,this.factory=p}return h(M,[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(c){return this.token_.type==c}},{key:"match",value:function(c){var p=this.isTokenType(c);return p&&this.consume_(),p}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var c=Ti,p=this.token_;if(this.isTokenType(Oo)){var g=p.value;g==="Z"?c=Ki:g==="M"?c=Nu:g==="ZM"&&(c=Eo),c!==Ti&&this.consume_()}return c}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(Pt)){var c=[];do c.push(this.parseGeometry_());while(this.match(Ji));if(this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(Pt)){var c=this.parsePoint_();if(this.match(fn))return c}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(Pt)){var c=this.parsePointList_();if(this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(Pt)){var c=this.parseLineStringTextList_();if(this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var c;if(this.match(Pt)){if(c=this.token_.type==Pt?this.parsePointTextList_():this.parsePointList_(),this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(Pt)){var c=this.parseLineStringTextList_();if(this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(Pt)){var c=this.parsePolygonTextList_();if(this.match(fn))return c}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var c=[],p=this.layout_.length,g=0;g1?c.createPolygon(dn[0],dn.slice(1)):c.createPolygon(dn[0])},w=this.token_;if(this.match(Oo)){var L=w.value;if(this.layout_=this.parseGeometryLayout_(),L=="GEOMETRYCOLLECTION"){var V=this.parseGeometryCollectionText_();return c.createGeometryCollection(V)}switch(L){case"POINT":var X=this.parsePointText_();return X?c.createPoint(k(je,J(X))):c.createPoint();case"LINESTRING":var Q=this.parseLineStringText_().map(p);return c.createLineString(Q);case"LINEARRING":var ae=this.parseLineStringText_().map(p);return c.createLinearRing(ae);case"POLYGON":var Le=this.parsePolygonText_();return Le&&Le.length!==0?g(Le):c.createPolygon();case"MULTIPOINT":var Ne=this.parseMultiPointText_();if(!Ne||Ne.length===0)return c.createMultiPoint();var rt=Ne.map(p).map(function(Ht){return c.createPoint(Ht)});return c.createMultiPoint(rt);case"MULTILINESTRING":var kt=this.parseMultiLineStringText_().map(function(Ht){return c.createLineString(Ht.map(p))});return c.createMultiLineString(kt);case"MULTIPOLYGON":var Ct=this.parseMultiPolygonText_();if(!Ct||Ct.length===0)return c.createMultiPolygon();var Qt=Ct.map(g);return c.createMultiPolygon(Qt);default:throw new Error("Invalid geometry type: "+L)}}throw new Error(this.formatErrorMessage_())}}]),M}();function Ho(M){if(M.isEmpty())return"";var c=M.getCoordinate(),p=[c.x,c.y];return c.z===void 0||Number.isNaN(c.z)||p.push(c.z),c.m===void 0||Number.isNaN(c.m)||p.push(c.m),p.join(" ")}function fr(M){for(var c=M.getCoordinates().map(function(L){var V=[L.x,L.y];return L.z===void 0||Number.isNaN(L.z)||V.push(L.z),L.m===void 0||Number.isNaN(L.m)||V.push(L.m),V}),p=[],g=0,w=c.length;g0&&(c+=" "+g),M.isEmpty()?c+" "+Rl:c+" ("+p(M)+")"}var ua=function(){function M(c){s(this,M),this.geometryFactory=c||new kr,this.precisionModel=this.geometryFactory.getPrecisionModel()}return h(M,[{key:"read",value:function(c){var p=new Vr(c);return new la(p,this.geometryFactory).parse()}},{key:"write",value:function(c){return To(c)}}]),M}(),hs=function(){function M(c){s(this,M),this.parser=new ua(c)}return h(M,[{key:"write",value:function(c){return this.parser.write(c)}}],[{key:"toLineString",value:function(c,p){if(arguments.length!==2)throw new Error("Not implemented");return"LINESTRING ( "+c.x+" "+c.y+", "+p.x+" "+p.y+" )"}}]),M}(),mi=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getIndexAlongSegment",value:function(c,p){return this.computeIntLineIndex(),this._intLineIndex[c][p]}},{key:"getTopologySummary",value:function(){var c=new us;return this.isEndPoint()&&c.append(" endpoint"),this._isProper&&c.append(" proper"),this.isCollinear()&&c.append(" collinear"),c.toString()}},{key:"computeIntersection",value:function(c,p,g,w){this._inputLines[0][0]=c,this._inputLines[0][1]=p,this._inputLines[1][0]=g,this._inputLines[1][1]=w,this._result=this.computeIntersect(c,p,g,w)}},{key:"getIntersectionNum",value:function(){return this._result}},{key:"computeIntLineIndex",value:function(){if(arguments.length===0)this._intLineIndex===null&&(this._intLineIndex=Array(2).fill().map(function(){return Array(2)}),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(arguments.length===1){var c=arguments[0],p=this.getEdgeDistance(c,0),g=this.getEdgeDistance(c,1);p>g?(this._intLineIndex[c][0]=0,this._intLineIndex[c][1]=1):(this._intLineIndex[c][0]=1,this._intLineIndex[c][1]=0)}}},{key:"isProper",value:function(){return this.hasIntersection()&&this._isProper}},{key:"setPrecisionModel",value:function(c){this._precisionModel=c}},{key:"isInteriorIntersection",value:function(){if(arguments.length===0)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(arguments.length===1){for(var c=arguments[0],p=0;pL?w:L;else{var X=Math.abs(c.x-p.x),Q=Math.abs(c.y-p.y);(V=w>L?X:Q)!==0||c.equals(p)||(V=Math.max(X,Q))}return St.isTrue(!(V===0&&!c.equals(p)),"Bad distance calculation"),V}},{key:"nonRobustComputeEdgeDistance",value:function(c,p,g){var w=c.x-p.x,L=c.y-p.y,V=Math.sqrt(w*w+L*L);return St.isTrue(!(V===0&&!c.equals(p)),"Invalid distance calculation"),V}}]),M}();mi.DONT_INTERSECT=0,mi.DO_INTERSECT=1,mi.COLLINEAR=2,mi.NO_INTERSECTION=0,mi.POINT_INTERSECTION=1,mi.COLLINEAR_INTERSECTION=2;var Ko=function(M){f(p,M);var c=U(p);function p(){return s(this,p),c.call(this)}return h(p,[{key:"isInSegmentEnvelopes",value:function(g){var w=new bn(this._inputLines[0][0],this._inputLines[0][1]),L=new bn(this._inputLines[1][0],this._inputLines[1][1]);return w.contains(g)&&L.contains(g)}},{key:"computeIntersection",value:function(){if(arguments.length!==3)return Z(x(p.prototype),"computeIntersection",this).apply(this,arguments);var g=arguments[0],w=arguments[1],L=arguments[2];if(this._isProper=!1,bn.intersects(w,L,g)&&sn.index(w,L,g)===0&&sn.index(L,w,g)===0)return this._isProper=!0,(g.equals(w)||g.equals(L))&&(this._isProper=!1),this._result=mi.POINT_INTERSECTION,null;this._result=mi.NO_INTERSECTION}},{key:"intersection",value:function(g,w,L,V){var X=this.intersectionSafe(g,w,L,V);return this.isInSegmentEnvelopes(X)||(X=new je(p.nearestEndpoint(g,w,L,V))),this._precisionModel!==null&&this._precisionModel.makePrecise(X),X}},{key:"checkDD",value:function(g,w,L,V,X){var Q=as.intersection(g,w,L,V),ae=this.isInSegmentEnvelopes(Q);xe.out.println("DD in env = "+ae+" --------------------- "+Q),X.distance(Q)>1e-4&&xe.out.println("Distance = "+X.distance(Q))}},{key:"intersectionSafe",value:function(g,w,L,V){var X=Os.intersection(g,w,L,V);return X===null&&(X=p.nearestEndpoint(g,w,L,V)),X}},{key:"computeCollinearIntersection",value:function(g,w,L,V){var X=bn.intersects(g,w,L),Q=bn.intersects(g,w,V),ae=bn.intersects(L,V,g),Le=bn.intersects(L,V,w);return X&&Q?(this._intPt[0]=L,this._intPt[1]=V,mi.COLLINEAR_INTERSECTION):ae&&Le?(this._intPt[0]=g,this._intPt[1]=w,mi.COLLINEAR_INTERSECTION):X&&ae?(this._intPt[0]=L,this._intPt[1]=g,!L.equals(g)||Q||Le?mi.COLLINEAR_INTERSECTION:mi.POINT_INTERSECTION):X&&Le?(this._intPt[0]=L,this._intPt[1]=w,!L.equals(w)||Q||ae?mi.COLLINEAR_INTERSECTION:mi.POINT_INTERSECTION):Q&&ae?(this._intPt[0]=V,this._intPt[1]=g,!V.equals(g)||X||Le?mi.COLLINEAR_INTERSECTION:mi.POINT_INTERSECTION):Q&&Le?(this._intPt[0]=V,this._intPt[1]=w,!V.equals(w)||X||ae?mi.COLLINEAR_INTERSECTION:mi.POINT_INTERSECTION):mi.NO_INTERSECTION}},{key:"computeIntersect",value:function(g,w,L,V){if(this._isProper=!1,!bn.intersects(g,w,L,V))return mi.NO_INTERSECTION;var X=sn.index(g,w,L),Q=sn.index(g,w,V);if(X>0&&Q>0||X<0&&Q<0)return mi.NO_INTERSECTION;var ae=sn.index(L,V,g),Le=sn.index(L,V,w);return ae>0&&Le>0||ae<0&&Le<0?mi.NO_INTERSECTION:X===0&&Q===0&&ae===0&&Le===0?this.computeCollinearIntersection(g,w,L,V):(X===0||Q===0||ae===0||Le===0?(this._isProper=!1,g.equals2D(L)||g.equals2D(V)?this._intPt[0]=g:w.equals2D(L)||w.equals2D(V)?this._intPt[0]=w:X===0?this._intPt[0]=new je(L):Q===0?this._intPt[0]=new je(V):ae===0?this._intPt[0]=new je(g):Le===0&&(this._intPt[0]=new je(w))):(this._isProper=!0,this._intPt[0]=this.intersection(g,w,L,V)),mi.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(g,w,L,V){var X=g,Q=ne.pointToSegment(g,L,V),ae=ne.pointToSegment(w,L,V);return aew&&(g=p.x,w=c.x),this._p.x>=g&&this._p.x<=w&&(this._isPointOnSegment=!0),null}if(c.y>this._p.y&&p.y<=this._p.y||p.y>this._p.y&&c.y<=this._p.y){var L=sn.index(c,p,this._p);if(L===sn.COLLINEAR)return this._isPointOnSegment=!0,null;p.ythis.location.length){var p=new Array(3).fill(null);p[wt.ON]=this.location[wt.ON],p[wt.LEFT]=Me.NONE,p[wt.RIGHT]=Me.NONE,this.location=p}for(var g=0;g1&&c.append(Me.toLocationSymbol(this.location[wt.LEFT])),c.append(Me.toLocationSymbol(this.location[wt.ON])),this.location.length>1&&c.append(Me.toLocationSymbol(this.location[wt.RIGHT])),c.toString()}},{key:"setLocations",value:function(c,p,g){this.location[wt.ON]=c,this.location[wt.LEFT]=p,this.location[wt.RIGHT]=g}},{key:"get",value:function(c){return c1}},{key:"isAnyNull",value:function(){for(var c=0;cthis._maxNodeDegree&&(this._maxNodeDegree=p),c=this.getNext(c)}while(c!==this._startDe);this._maxNodeDegree*=2}},{key:"addPoints",value:function(c,p,g){var w=c.getCoordinates();if(p){var L=1;g&&(L=0);for(var V=L;V=0;Q--)this._pts.add(w[Q])}}},{key:"isHole",value:function(){return this._isHole}},{key:"setInResult",value:function(){var c=this._startDe;do c.getEdge().setInResult(!0),c=c.getNext();while(c!==this._startDe)}},{key:"containsPoint",value:function(c){var p=this.getLinearRing();if(!p.getEnvelopeInternal().contains(c)||!fs.isInRing(c,p.getCoordinates()))return!1;for(var g=this._holes.iterator();g.hasNext();)if(g.next().containsPoint(c))return!1;return!0}},{key:"addHole",value:function(c){this._holes.add(c)}},{key:"isShell",value:function(){return this._shell===null}},{key:"getLabel",value:function(){return this._label}},{key:"getEdges",value:function(){return this._edges}},{key:"getMaxNodeDegree",value:function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree}},{key:"getShell",value:function(){return this._shell}},{key:"mergeLabel",value:function(){if(arguments.length===1){var c=arguments[0];this.mergeLabel(c,0),this.mergeLabel(c,1)}else if(arguments.length===2){var p=arguments[0],g=arguments[1],w=p.getLocation(g,wt.RIGHT);if(w===Me.NONE)return null;if(this._label.getLocation(g)===Me.NONE)return this._label.setLocation(g,w),null}}},{key:"setShell",value:function(c){this._shell=c,c!==null&&c.addHole(this)}},{key:"toPolygon",value:function(c){for(var p=new Array(this._holes.size()).fill(null),g=0;g=2,"found partial label"),this.computeIM(c)}},{key:"isInResult",value:function(){return this._isInResult}},{key:"isVisited",value:function(){return this._isVisited}}],[{key:"constructor_",value:function(){if(this._label=null,this._isInResult=!1,this._isCovered=!1,this._isCoveredSet=!1,this._isVisited=!1,arguments.length!==0){if(arguments.length===1){var c=arguments[0];this._label=c}}}}]),M}(),sr=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"isIncidentEdgeInResult",value:function(){for(var g=this.getEdges().getEdges().iterator();g.hasNext();)if(g.next().getEdge().isInResult())return!0;return!1}},{key:"isIsolated",value:function(){return this._label.getGeometryCount()===1}},{key:"getCoordinate",value:function(){return this._coord}},{key:"print",value:function(g){g.println("node "+this._coord+" lbl: "+this._label)}},{key:"computeIM",value:function(g){}},{key:"computeMergedLocation",value:function(g,w){var L=Me.NONE;if(L=this._label.getLocation(w),!g.isNull(w)){var V=g.getLocation(w);L!==Me.BOUNDARY&&(L=V)}return L}},{key:"setLabel",value:function(){if(arguments.length!==2||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return Z(x(p.prototype),"setLabel",this).apply(this,arguments);var g=arguments[0],w=arguments[1];this._label===null?this._label=new rr(g,w):this._label.setLocation(g,w)}},{key:"getEdges",value:function(){return this._edges}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof p){var g=arguments[0];this.mergeLabel(g._label)}else if(arguments[0]instanceof rr)for(var w=arguments[0],L=0;L<2;L++){var V=this.computeMergedLocation(w,L),X=this._label.getLocation(L);X===Me.NONE&&this._label.setLocation(L,V)}}},{key:"add",value:function(g){this._edges.insert(g),g.setNode(this)}},{key:"setLabelBoundary",value:function(g){if(this._label===null)return null;var w=Me.NONE;this._label!==null&&(w=this._label.getLocation(g));var L=null;switch(w){case Me.BOUNDARY:L=Me.INTERIOR;break;case Me.INTERIOR:default:L=Me.BOUNDARY}this._label.setLocation(g,L)}}],[{key:"constructor_",value:function(){this._coord=null,this._edges=null;var g=arguments[0],w=arguments[1];this._coord=g,this._edges=w,this._label=new rr(0,Me.NONE)}}]),p}(ja),Wr=function(M){f(p,M);var c=U(p);function p(){return s(this,p),c.apply(this,arguments)}return p}(Va);function zl(M){return M==null?0:M.color}function Vn(M){return M==null?null:M.parent}function Xn(M,c){M!==null&&(M.color=c)}function ds(M){return M==null?null:M.left}function Ga(M){return M==null?null:M.right}var fo=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),(g=c.call(this)).root_=null,g.size_=0,g}return h(p,[{key:"get",value:function(g){for(var w=this.root_;w!==null;){var L=g.compareTo(w.key);if(L<0)w=w.left;else{if(!(L>0))return w.value;w=w.right}}return null}},{key:"put",value:function(g,w){if(this.root_===null)return this.root_={key:g,value:w,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var L,V,X=this.root_;do if(L=X,(V=g.compareTo(X.key))<0)X=X.left;else{if(!(V>0)){var Q=X.value;return X.value=w,Q}X=X.right}while(X!==null);var ae={key:g,left:null,right:null,value:w,parent:L,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return V<0?L.left=ae:L.right=ae,this.fixAfterInsertion(ae),this.size_++,null}},{key:"fixAfterInsertion",value:function(g){var w;for(g.color=1;g!=null&&g!==this.root_&&g.parent.color===1;)Vn(g)===ds(Vn(Vn(g)))?zl(w=Ga(Vn(Vn(g))))===1?(Xn(Vn(g),0),Xn(w,0),Xn(Vn(Vn(g)),1),g=Vn(Vn(g))):(g===Ga(Vn(g))&&(g=Vn(g),this.rotateLeft(g)),Xn(Vn(g),0),Xn(Vn(Vn(g)),1),this.rotateRight(Vn(Vn(g)))):zl(w=ds(Vn(Vn(g))))===1?(Xn(Vn(g),0),Xn(w,0),Xn(Vn(Vn(g)),1),g=Vn(Vn(g))):(g===ds(Vn(g))&&(g=Vn(g),this.rotateRight(g)),Xn(Vn(g),0),Xn(Vn(Vn(g)),1),this.rotateLeft(Vn(Vn(g))));this.root_.color=0}},{key:"values",value:function(){var g=new nn,w=this.getFirstEntry();if(w!==null)for(g.add(w.value);(w=p.successor(w))!==null;)g.add(w.value);return g}},{key:"entrySet",value:function(){var g=new Yi,w=this.getFirstEntry();if(w!==null)for(g.add(w);(w=p.successor(w))!==null;)g.add(w);return g}},{key:"rotateLeft",value:function(g){if(g!=null){var w=g.right;g.right=w.left,w.left!=null&&(w.left.parent=g),w.parent=g.parent,g.parent==null?this.root_=w:g.parent.left===g?g.parent.left=w:g.parent.right=w,w.left=g,g.parent=w}}},{key:"rotateRight",value:function(g){if(g!=null){var w=g.left;g.left=w.right,w.right!=null&&(w.right.parent=g),w.parent=g.parent,g.parent==null?this.root_=w:g.parent.right===g?g.parent.right=w:g.parent.left=w,w.right=g,g.parent=w}}},{key:"getFirstEntry",value:function(){var g=this.root_;if(g!=null)for(;g.left!=null;)g=g.left;return g}},{key:"size",value:function(){return this.size_}},{key:"containsKey",value:function(g){for(var w=this.root_;w!==null;){var L=g.compareTo(w.key);if(L<0)w=w.left;else{if(!(L>0))return!0;w=w.right}}return!1}}],[{key:"successor",value:function(g){var w;if(g===null)return null;if(g.right!==null){for(w=g.right;w.left!==null;)w=w.left;return w}w=g.parent;for(var L=g;w!==null&&L===w.right;)L=w,w=w.parent;return w}}]),p}(Wr),Qi=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"find",value:function(c){return this.nodeMap.get(c)}},{key:"addNode",value:function(){if(arguments[0]instanceof je){var c=arguments[0],p=this.nodeMap.get(c);return p===null&&(p=this.nodeFact.createNode(c),this.nodeMap.put(c,p)),p}if(arguments[0]instanceof sr){var g=arguments[0],w=this.nodeMap.get(g.getCoordinate());return w===null?(this.nodeMap.put(g.getCoordinate(),g),g):(w.mergeLabel(g),w)}}},{key:"print",value:function(c){for(var p=this.iterator();p.hasNext();)p.next().print(c)}},{key:"iterator",value:function(){return this.nodeMap.values().iterator()}},{key:"values",value:function(){return this.nodeMap.values()}},{key:"getBoundaryNodes",value:function(c){for(var p=new nn,g=this.iterator();g.hasNext();){var w=g.next();w.getLabel().getLocation(c)===Me.BOUNDARY&&p.add(w)}return p}},{key:"add",value:function(c){var p=c.getCoordinate();this.addNode(p).add(c)}}],[{key:"constructor_",value:function(){this.nodeMap=new fo,this.nodeFact=null;var c=arguments[0];this.nodeFact=c}}]),M}(),ar=function(){function M(){s(this,M)}return h(M,null,[{key:"isNorthern",value:function(c){return c===M.NE||c===M.NW}},{key:"isOpposite",value:function(c,p){return c!==p&&(c-p+4)%4===2}},{key:"commonHalfPlane",value:function(c,p){if(c===p)return c;if((c-p+4)%4===2)return-1;var g=cp?c:p)===3?3:g}},{key:"isInHalfPlane",value:function(c,p){return p===M.SE?c===M.SE||c===M.SW:c===p||c===p+1}},{key:"quadrant",value:function(){if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var c=arguments[0],p=arguments[1];if(c===0&&p===0)throw new we("Cannot compute the quadrant for point ( "+c+", "+p+" )");return c>=0?p>=0?M.NE:M.SE:p>=0?M.NW:M.SW}if(arguments[0]instanceof je&&arguments[1]instanceof je){var g=arguments[0],w=arguments[1];if(w.x===g.x&&w.y===g.y)throw new we("Cannot compute the quadrant for two identical points "+g);return w.x>=g.x?w.y>=g.y?M.NE:M.SE:w.y>=g.y?M.NW:M.SW}}}]),M}();ar.NE=0,ar.NW=1,ar.SW=2,ar.SE=3;var qa=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"compareDirection",value:function(c){return this._dx===c._dx&&this._dy===c._dy?0:this._quadrant>c._quadrant?1:this._quadrant2){V.linkDirectedEdgesForMinimalEdgeRings();var X=V.buildMinimalRings(),Q=this.findShell(X);Q!==null?(this.placePolygonHoles(Q,X),p.add(Q)):g.addAll(X)}else w.add(V)}return w}},{key:"buildMaximalEdgeRings",value:function(c){for(var p=new nn,g=c.iterator();g.hasNext();){var w=g.next();if(w.isInResult()&&w.getLabel().isArea()&&w.getEdgeRing()===null){var L=new Dl(w,this._geometryFactory);p.add(L),L.setInResult()}}return p}},{key:"placePolygonHoles",value:function(c,p){for(var g=p.iterator();g.hasNext();){var w=g.next();w.isHole()&&w.setShell(c)}}},{key:"getPolygons",value:function(){return this.computePolygons(this._shellList)}},{key:"findShell",value:function(c){for(var p=0,g=null,w=c.iterator();w.hasNext();){var L=w.next();L.isHole()||(g=L,p++)}return St.isTrue(p<=1,"found two shells in MinimalEdgeRing list"),g}},{key:"add",value:function(){if(arguments.length===1){var c=arguments[0];this.add(c.getEdgeEnds(),c.getNodes())}else if(arguments.length===2){var p=arguments[0],g=arguments[1];ha.linkResultDirectedEdges(g);var w=this.buildMaximalEdgeRings(p),L=new nn,V=this.buildMinimalEdgeRings(w,this._shellList,L);this.sortShellsAndHoles(V,this._shellList,L),this.placeFreeHoles(this._shellList,L)}}}],[{key:"constructor_",value:function(){this._geometryFactory=null,this._shellList=new nn;var c=arguments[0];this._geometryFactory=c}},{key:"findEdgeRingContaining",value:function(c,p){for(var g=c.getLinearRing(),w=g.getEnvelopeInternal(),L=g.getCoordinateN(0),V=null,X=null,Q=p.iterator();Q.hasNext();){var ae=Q.next(),Le=ae.getLinearRing(),Ne=Le.getEnvelopeInternal();if(!Ne.equals(w)&&Ne.contains(w)){L=Ri.ptNotInList(g.getCoordinates(),Le.getCoordinates());var rt=!1;fs.isInRing(L,Le.getCoordinates())&&(rt=!0),rt&&(V===null||X.contains(Ne))&&(X=(V=ae).getLinearRing().getEnvelopeInternal())}}return V}}]),M}(),Za=function(){function M(){s(this,M)}return h(M,[{key:"getBounds",value:function(){}}]),M}(),Cr=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getItem",value:function(){return this._item}},{key:"getBounds",value:function(){return this._bounds}},{key:"interfaces_",get:function(){return[Za,Ie]}}],[{key:"constructor_",value:function(){this._bounds=null,this._item=null;var c=arguments[0],p=arguments[1];this._bounds=c,this._item=p}}]),M}(),Ur=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"poll",value:function(){if(this.isEmpty())return null;var c=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),c}},{key:"size",value:function(){return this._size}},{key:"reorder",value:function(c){for(var p=null,g=this._items.get(c);2*c<=this._size&&((p=2*c)!==this._size&&this._items.get(p+1).compareTo(this._items.get(p))<0&&p++,this._items.get(p).compareTo(g)<0);c=p)this._items.set(c,this._items.get(p));this._items.set(c,g)}},{key:"clear",value:function(){this._size=0,this._items.clear()}},{key:"peek",value:function(){return this.isEmpty()?null:this._items.get(1)}},{key:"isEmpty",value:function(){return this._size===0}},{key:"add",value:function(c){this._items.add(null),this._size+=1;var p=this._size;for(this._items.set(0,c);c.compareTo(this._items.get(Math.trunc(p/2)))<0;p/=2)this._items.set(p,this._items.get(Math.trunc(p/2)));this._items.set(p,c)}}],[{key:"constructor_",value:function(){this._size=null,this._items=null,this._size=0,this._items=new nn,this._items.add(null)}}]),M}(),Ol=function(){function M(){s(this,M)}return h(M,[{key:"insert",value:function(c,p){}},{key:"remove",value:function(c,p){}},{key:"query",value:function(){}}]),M}(),er=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getLevel",value:function(){return this._level}},{key:"size",value:function(){return this._childBoundables.size()}},{key:"getChildBoundables",value:function(){return this._childBoundables}},{key:"addChildBoundable",value:function(c){St.isTrue(this._bounds===null),this._childBoundables.add(c)}},{key:"isEmpty",value:function(){return this._childBoundables.isEmpty()}},{key:"getBounds",value:function(){return this._bounds===null&&(this._bounds=this.computeBounds()),this._bounds}},{key:"interfaces_",get:function(){return[Za,Ie]}}],[{key:"constructor_",value:function(){if(this._childBoundables=new nn,this._bounds=null,this._level=null,arguments.length!==0){if(arguments.length===1){var c=arguments[0];this._level=c}}}}]),M}(),Ar={reverseOrder:function(){return{compare:function(M,c){return c.compareTo(M)}}},min:function(M){return Ar.sort(M),M.get(0)},sort:function(M,c){var p=M.toArray();c?on.sort(p,c):on.sort(p);for(var g=M.iterator(),w=0,L=p.length;wM.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,c,p),null):(this.expand(this._boundable2,this._boundable1,!0,c,p),null);if(g)return this.expand(this._boundable1,this._boundable2,!1,c,p),null;if(w)return this.expand(this._boundable2,this._boundable1,!0,c,p),null;throw new we("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(M.isComposite(this._boundable1)||M.isComposite(this._boundable2))}},{key:"compareTo",value:function(c){var p=c;return this._distancep._distance?1:0}},{key:"expand",value:function(c,p,g,w,L){for(var V=c.getChildBoundables().iterator();V.hasNext();){var X=V.next(),Q=null;(Q=g?new M(p,X,this._itemDistance):new M(X,p,this._itemDistance)).getDistance()-2),w.getLevel()===g)return L.add(w),null;for(var V=w.getChildBoundables().iterator();V.hasNext();){var X=V.next();X instanceof er?this.boundablesAtLevel(g,X,L):(St.isTrue(X instanceof Cr),g===-1&&L.add(X))}return null}}},{key:"query",value:function(){if(arguments.length===1){var c=arguments[0];this.build();var p=new nn;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),c)&&this.queryInternal(c,this._root,p),p}if(arguments.length===2){var g=arguments[0],w=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),g)&&this.queryInternal(g,this._root,w)}}},{key:"build",value:function(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0}},{key:"getRoot",value:function(){return this.build(),this._root}},{key:"remove",value:function(){if(arguments.length===2){var c=arguments[0],p=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),c)&&this.remove(c,this._root,p)}if(arguments.length===3){var g=arguments[0],w=arguments[1],L=arguments[2],V=this.removeItem(w,L);if(V)return!0;for(var X=null,Q=w.getChildBoundables().iterator();Q.hasNext();){var ae=Q.next();if(this.getIntersectsOp().intersects(ae.getBounds(),g)&&ae instanceof er&&(V=this.remove(g,ae,L))){X=ae;break}}return X!==null&&X.getChildBoundables().isEmpty()&&w.getChildBoundables().remove(X),V}}},{key:"createHigherLevels",value:function(c,p){St.isTrue(!c.isEmpty());var g=this.createParentBoundables(c,p+1);return g.size()===1?g.get(0):this.createHigherLevels(g,p+1)}},{key:"depth",value:function(){if(arguments.length===0)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(arguments.length===1){for(var c=arguments[0],p=0,g=c.getChildBoundables().iterator();g.hasNext();){var w=g.next();if(w instanceof er){var L=this.depth(w);L>p&&(p=L)}}return p+1}}},{key:"createParentBoundables",value:function(c,p){St.isTrue(!c.isEmpty());var g=new nn;g.add(this.createNode(p));var w=new nn(c);Ar.sort(w,this.getComparator());for(var L=w.iterator();L.hasNext();){var V=L.next();this.lastNode(g).getChildBoundables().size()===this.getNodeCapacity()&&g.add(this.createNode(p)),this.lastNode(g).addChildBoundable(V)}return g}},{key:"isEmpty",value:function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}},{key:"interfaces_",get:function(){return[Ie]}}],[{key:"constructor_",value:function(){if(this._root=null,this._built=!1,this._itemBoundables=new nn,this._nodeCapacity=null,arguments.length===0)M.constructor_.call(this,M.DEFAULT_NODE_CAPACITY);else if(arguments.length===1){var c=arguments[0];St.isTrue(c>1,"Node capacity must be greater than 1"),this._nodeCapacity=c}}},{key:"compareDoubles",value:function(c,p){return c>p?1:c0);for(var L=new nn,V=0;V=0;){var Ne=ae.poll(),rt=Ne.getDistance();if(rt>=Q)break;if(Ne.isLeaves())if(Le.size()rt&&(Le.poll(),Le.add(Ne));var Ct=Le.peek();Q=Ct.getDistance()}else Ne.expandToQueue(ae,Q)}return p.getItems(Le)}}},{key:"createNode",value:function(g){return new ma(g)}},{key:"size",value:function(){return arguments.length===0?Z(x(p.prototype),"size",this).call(this):Z(x(p.prototype),"size",this).apply(this,arguments)}},{key:"insert",value:function(){if(!(arguments.length===2&&arguments[1]instanceof Object&&arguments[0]instanceof bn))return Z(x(p.prototype),"insert",this).apply(this,arguments);var g=arguments[0],w=arguments[1];if(g.isNull())return null;Z(x(p.prototype),"insert",this).call(this,g,w)}},{key:"getIntersectsOp",value:function(){return p.intersectsOp}},{key:"verticalSlices",value:function(g,w){for(var L=Math.trunc(Math.ceil(g.size()/w)),V=new Array(w).fill(null),X=g.iterator(),Q=0;Q0;){var ae=Q.poll(),Le=ae.getDistance();if(Le>=V)break;ae.isLeaves()?(V=Le,X=ae):ae.expandToQueue(Q,V)}return X===null?null:[X.getBoundable(0).getItem(),X.getBoundable(1).getItem()]}}else{if(arguments.length===2){var Ne=arguments[0],rt=arguments[1];if(this.isEmpty()||Ne.isEmpty())return null;var kt=new Pr(this.getRoot(),Ne.getRoot(),rt);return this.nearestNeighbour(kt)}if(arguments.length===3){var Ct=arguments[0],Qt=arguments[1],Ht=arguments[2],dn=new Cr(Ct,Qt),Rn=new Pr(this.getRoot(),dn,Ht);return this.nearestNeighbour(Rn)[0]}if(arguments.length===4){var ui=arguments[0],lr=arguments[1],Vi=arguments[2],dr=arguments[3],Jr=new Cr(ui,lr),So=new Pr(this.getRoot(),Jr,Vi);return this.nearestNeighbourK(So,dr)}}}},{key:"isWithinDistance",value:function(){if(arguments.length===2){var g=arguments[0],w=arguments[1],L=tt.POSITIVE_INFINITY,V=new Ur;for(V.add(g);!V.isEmpty();){var X=V.poll(),Q=X.getDistance();if(Q>w)return!1;if(X.maximumDistance()<=w)return!0;if(X.isLeaves()){if((L=Q)<=w)return!0}else X.expandToQueue(V,L)}return!1}if(arguments.length===3){var ae=arguments[0],Le=arguments[1],Ne=arguments[2],rt=new Pr(this.getRoot(),ae.getRoot(),Le);return this.isWithinDistance(rt,Ne)}}},{key:"interfaces_",get:function(){return[Ol,Ie]}}],[{key:"constructor_",value:function(){if(arguments.length===0)p.constructor_.call(this,p.DEFAULT_NODE_CAPACITY);else if(arguments.length===1){var g=arguments[0];mo.constructor_.call(this,g)}}},{key:"centreX",value:function(g){return p.avg(g.getMinX(),g.getMaxX())}},{key:"avg",value:function(g,w){return(g+w)/2}},{key:"getItems",value:function(g){for(var w=new Array(g.size()).fill(null),L=0;!g.isEmpty();){var V=g.poll();w[L]=V.getBoundable(0).getItem(),L++}return w}},{key:"centreY",value:function(g){return p.avg(g.getMinY(),g.getMaxY())}}]),p}(mo),ma=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"computeBounds",value:function(){for(var g=null,w=this.getChildBoundables().iterator();w.hasNext();){var L=w.next();g===null?g=new bn(L.getBounds()):g.expandToInclude(L.getBounds())}return g}}],[{key:"constructor_",value:function(){var g=arguments[0];er.constructor_.call(this,g)}}]),p}(er);go.STRtreeNode=ma,go.xComparator=new(function(){function M(){s(this,M)}return h(M,[{key:"interfaces_",get:function(){return[Bt]}},{key:"compare",value:function(c,p){return mo.compareDoubles(go.centreX(c.getBounds()),go.centreX(p.getBounds()))}}]),M}()),go.yComparator=new(function(){function M(){s(this,M)}return h(M,[{key:"interfaces_",get:function(){return[Bt]}},{key:"compare",value:function(c,p){return mo.compareDoubles(go.centreY(c.getBounds()),go.centreY(p.getBounds()))}}]),M}()),go.intersectsOp=new(function(){function M(){s(this,M)}return h(M,[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(c,p){return c.intersects(p)}}]),M}()),go.DEFAULT_NODE_CAPACITY=10;var Nl=function(){function M(){s(this,M)}return h(M,null,[{key:"relativeSign",value:function(c,p){return cp?1:0}},{key:"compare",value:function(c,p,g){if(p.equals2D(g))return 0;var w=M.relativeSign(p.x,g.x),L=M.relativeSign(p.y,g.y);switch(c){case 0:return M.compareValue(w,L);case 1:return M.compareValue(L,w);case 2:return M.compareValue(L,-w);case 3:return M.compareValue(-w,L);case 4:return M.compareValue(-w,-L);case 5:return M.compareValue(-L,-w);case 6:return M.compareValue(-L,w);case 7:return M.compareValue(w,-L)}return St.shouldNeverReachHere("invalid octant value"),0}},{key:"compareValue",value:function(c,p){return c<0?-1:c>0?1:p<0?-1:p>0?1:0}}]),M}(),Bl=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(c){c.print(this.coord),c.print(" seg # = "+this.segmentIndex)}},{key:"compareTo",value:function(c){var p=c;return this.segmentIndexp.segmentIndex?1:this.coord.equals2D(p.coord)?0:this._isInterior?p._isInterior?Nl.compare(this._segmentOctant,this.coord,p.coord):1:-1}},{key:"isEndPoint",value:function(c){return this.segmentIndex===0&&!this._isInterior||this.segmentIndex===c}},{key:"toString",value:function(){return this.segmentIndex+":"+this.coord.toString()}},{key:"isInterior",value:function(){return this._isInterior}},{key:"interfaces_",get:function(){return[ze]}}],[{key:"constructor_",value:function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var c=arguments[0],p=arguments[1],g=arguments[2],w=arguments[3];this._segString=c,this.coord=new je(p),this.segmentIndex=g,this._segmentOctant=w,this._isInterior=!p.equals2D(c.getCoordinate(g))}}]),M}(),Ns=function(){function M(){s(this,M)}return h(M,[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}]),M}(),Un=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getSplitCoordinates",value:function(){var c=new On;this.addEndpoints();for(var p=this.iterator(),g=p.next();p.hasNext();){var w=p.next();this.addEdgeCoordinates(g,w,c),g=w}return c.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var c=new nn;this.findCollapsesFromInsertedNodes(c),this.findCollapsesFromExistingVertices(c);for(var p=c.iterator();p.hasNext();){var g=p.next().intValue();this.add(this._edge.getCoordinate(g),g)}}},{key:"createSplitEdgePts",value:function(c,p){var g=p.segmentIndex-c.segmentIndex+2;if(g===2)return[new je(c.coord),new je(p.coord)];var w=this._edge.getCoordinate(p.segmentIndex),L=p.isInterior()||!p.coord.equals2D(w);L||g--;var V=new Array(g).fill(null),X=0;V[X++]=new je(c.coord);for(var Q=c.segmentIndex+1;Q<=p.segmentIndex;Q++)V[X++]=this._edge.getCoordinate(Q);return L&&(V[X]=new je(p.coord)),V}},{key:"print",value:function(c){c.println("Intersections:");for(var p=this.iterator();p.hasNext();)p.next().print(c)}},{key:"findCollapsesFromExistingVertices",value:function(c){for(var p=0;p=0?p>=0?g>=w?0:1:g>=w?7:6:p>=0?g>=w?3:2:g>=w?4:5}if(arguments[0]instanceof je&&arguments[1]instanceof je){var L=arguments[0],V=arguments[1],X=V.x-L.x,Q=V.y-L.y;if(X===0&&Q===0)throw new we("Cannot compute the octant for two identical points "+L);return M.octant(X,Q)}}}]),M}(),Fl=function(){function M(){s(this,M)}return h(M,[{key:"getCoordinates",value:function(){}},{key:"size",value:function(){}},{key:"getCoordinate",value:function(c){}},{key:"isClosed",value:function(){}},{key:"setData",value:function(c){}},{key:"getData",value:function(){}}]),M}(),Fu=function(){function M(){s(this,M)}return h(M,[{key:"addIntersection",value:function(c,p){}},{key:"interfaces_",get:function(){return[Fl]}}]),M}(),Bo=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getCoordinates",value:function(){return this._pts}},{key:"size",value:function(){return this._pts.length}},{key:"getCoordinate",value:function(c){return this._pts[c]}},{key:"isClosed",value:function(){return this._pts[0].equals(this._pts[this._pts.length-1])}},{key:"getSegmentOctant",value:function(c){return c===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(c),this.getCoordinate(c+1))}},{key:"setData",value:function(c){this._data=c}},{key:"safeOctant",value:function(c,p){return c.equals2D(p)?0:ih.octant(c,p)}},{key:"getData",value:function(){return this._data}},{key:"addIntersection",value:function(){if(arguments.length===2){var c=arguments[0],p=arguments[1];this.addIntersectionNode(c,p)}else if(arguments.length===4){var g=arguments[0],w=arguments[1],L=arguments[3],V=new je(g.getIntersection(L));this.addIntersection(V,w)}}},{key:"toString",value:function(){return hs.toLineString(new Sr(this._pts))}},{key:"getNodeList",value:function(){return this._nodeList}},{key:"addIntersectionNode",value:function(c,p){var g=p,w=g+1;if(w=0&&g>=0||p<=0&&g<=0?Math.max(p,g):0}if(arguments[0]instanceof je){var w=arguments[0];return sn.index(this.p0,this.p1,w)}}},{key:"toGeometry",value:function(c){return c.createLineString([this.p0,this.p1])}},{key:"isVertical",value:function(){return this.p0.x===this.p1.x}},{key:"equals",value:function(c){if(!(c instanceof M))return!1;var p=c;return this.p0.equals(p.p0)&&this.p1.equals(p.p1)}},{key:"intersection",value:function(c){var p=new Ko;return p.computeIntersection(this.p0,this.p1,c.p0,c.p1),p.hasIntersection()?p.getIntersection(0):null}},{key:"project",value:function(){if(arguments[0]instanceof je){var c=arguments[0];if(c.equals(this.p0)||c.equals(this.p1))return new je(c);var p=this.projectionFactor(c),g=new je;return g.x=this.p0.x+p*(this.p1.x-this.p0.x),g.y=this.p0.y+p*(this.p1.y-this.p0.y),g}if(arguments[0]instanceof M){var w=arguments[0],L=this.projectionFactor(w.p0),V=this.projectionFactor(w.p1);if(L>=1&&V>=1||L<=0&&V<=0)return null;var X=this.project(w.p0);L<0&&(X=this.p0),L>1&&(X=this.p1);var Q=this.project(w.p1);return V<0&&(Q=this.p0),V>1&&(Q=this.p1),new M(X,Q)}}},{key:"normalize",value:function(){this.p1.compareTo(this.p0)<0&&this.reverse()}},{key:"angle",value:function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}},{key:"getCoordinate",value:function(c){return c===0?this.p0:this.p1}},{key:"distancePerpendicular",value:function(c){return ne.pointToLinePerpendicular(c,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return M.midPoint(this.p0,this.p1)}},{key:"projectionFactor",value:function(c){if(c.equals(this.p0))return 0;if(c.equals(this.p1))return 1;var p=this.p1.x-this.p0.x,g=this.p1.y-this.p0.y,w=p*p+g*g;return w<=0?tt.NaN:((c.x-this.p0.x)*p+(c.y-this.p0.y)*g)/w}},{key:"closestPoints",value:function(c){var p=this.intersection(c);if(p!==null)return[p,p];var g=new Array(2).fill(null),w=tt.MAX_VALUE,L=null,V=this.closestPoint(c.p0);w=V.distance(c.p0),g[0]=V,g[1]=c.p0;var X=this.closestPoint(c.p1);(L=X.distance(c.p1))0&&p<1?this.project(c):this.p0.distance(c)1||tt.isNaN(p))&&(p=1),p}},{key:"toString",value:function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}},{key:"isHorizontal",value:function(){return this.p0.y===this.p1.y}},{key:"reflect",value:function(c){var p=this.p1.getY()-this.p0.getY(),g=this.p0.getX()-this.p1.getX(),w=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),L=p*p+g*g,V=p*p-g*g,X=c.getX(),Q=c.getY();return new je((-V*X-2*p*g*Q-2*p*w)/L,(V*Q-2*p*g*X-2*g*w)/L)}},{key:"distance",value:function(){if(arguments[0]instanceof M){var c=arguments[0];return ne.segmentToSegment(this.p0,this.p1,c.p0,c.p1)}if(arguments[0]instanceof je){var p=arguments[0];return ne.pointToSegment(p,this.p0,this.p1)}}},{key:"pointAlong",value:function(c){var p=new je;return p.x=this.p0.x+c*(this.p1.x-this.p0.x),p.y=this.p0.y+c*(this.p1.y-this.p0.y),p}},{key:"hashCode",value:function(){var c=tt.doubleToLongBits(this.p0.x);c^=31*tt.doubleToLongBits(this.p0.y);var p=Math.trunc(c)^Math.trunc(c>>32),g=tt.doubleToLongBits(this.p1.x);return g^=31*tt.doubleToLongBits(this.p1.y),p^(Math.trunc(g)^Math.trunc(g>>32))}},{key:"interfaces_",get:function(){return[ze,Ie]}}],[{key:"constructor_",value:function(){if(this.p0=null,this.p1=null,arguments.length===0)M.constructor_.call(this,new je,new je);else if(arguments.length===1){var c=arguments[0];M.constructor_.call(this,c.p0,c.p1)}else if(arguments.length===2){var p=arguments[0],g=arguments[1];this.p0=p,this.p1=g}else if(arguments.length===4){var w=arguments[0],L=arguments[1],V=arguments[2],X=arguments[3];M.constructor_.call(this,new je(w,L),new je(V,X))}}},{key:"midPoint",value:function(c,p){return new je((c.x+p.x)/2,(c.y+p.y)/2)}}]),M}(),Vl=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"overlap",value:function(){if(arguments.length!==2){if(arguments.length===4){var c=arguments[0],p=arguments[1],g=arguments[2],w=arguments[3];c.getLineSegment(p,this._overlapSeg1),g.getLineSegment(w,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}}}}],[{key:"constructor_",value:function(){this._overlapSeg1=new Lr,this._overlapSeg2=new Lr}}]),M}(),ps=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getLineSegment",value:function(c,p){p.p0=this._pts[c],p.p1=this._pts[c+1]}},{key:"computeSelect",value:function(c,p,g,w){var L=this._pts[p],V=this._pts[g];if(g-p==1)return w.select(this,p),null;if(!c.intersects(L,V))return null;var X=Math.trunc((p+g)/2);p=c.length-1)return c.length-1;for(var w=ar.quadrant(c[g],c[g+1]),L=p+1;LL.getId()&&(L.computeOverlaps(X,g),this._nOverlaps++),this._segInt.isDone())return null}}}],[{key:"constructor_",value:function(){if(this._monoChains=new nn,this._index=new go,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0,arguments.length!==0){if(arguments.length===1){var g=arguments[0];Io.constructor_.call(this,g)}}}}]),p}(Io),ga=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"overlap",value:function(){if(arguments.length!==4)return Z(x(p.prototype),"overlap",this).apply(this,arguments);var g=arguments[0],w=arguments[1],L=arguments[2],V=arguments[3],X=g.getContext(),Q=L.getContext();this._si.processIntersections(X,w,Q,V)}}],[{key:"constructor_",value:function(){this._si=null;var g=arguments[0];this._si=g}}]),p}(Vl);Fo.SegmentOverlapAction=ga;var Yr=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"isDeletable",value:function(c,p,g,w){var L=this._inputLine[c],V=this._inputLine[p],X=this._inputLine[g];return!!this.isConcave(L,V,X)&&!!this.isShallow(L,V,X,w)&&this.isShallowSampled(L,V,c,g,w)}},{key:"deleteShallowConcavities",value:function(){for(var c=1,p=this.findNextNonDeletedIndex(c),g=this.findNextNonDeletedIndex(p),w=!1;g=0;w--)this.addPt(c[w])}},{key:"isRedundant",value:function(c){if(this._ptList.size()<1)return!1;var p=this._ptList.get(this._ptList.size()-1);return c.distance(p)Math.PI;)c-=M.PI_TIMES_2;for(;c<=-Math.PI;)c+=M.PI_TIMES_2;return c}},{key:"angle",value:function(){if(arguments.length===1){var c=arguments[0];return Math.atan2(c.y,c.x)}if(arguments.length===2){var p=arguments[0],g=arguments[1],w=g.x-p.x,L=g.y-p.y;return Math.atan2(L,w)}}},{key:"isAcute",value:function(c,p,g){var w=c.x-p.x,L=c.y-p.y;return w*(g.x-p.x)+L*(g.y-p.y)>0}},{key:"isObtuse",value:function(c,p,g){var w=c.x-p.x,L=c.y-p.y;return w*(g.x-p.x)+L*(g.y-p.y)<0}},{key:"interiorAngle",value:function(c,p,g){var w=M.angle(p,c),L=M.angle(p,g);return Math.abs(L-w)}},{key:"normalizePositive",value:function(c){if(c<0){for(;c<0;)c+=M.PI_TIMES_2;c>=M.PI_TIMES_2&&(c=0)}else{for(;c>=M.PI_TIMES_2;)c-=M.PI_TIMES_2;c<0&&(c=0)}return c}},{key:"angleBetween",value:function(c,p,g){var w=M.angle(p,c),L=M.angle(p,g);return M.diff(w,L)}},{key:"diff",value:function(c,p){var g=null;return(g=cMath.PI&&(g=2*Math.PI-g),g}},{key:"toRadians",value:function(c){return c*Math.PI/180}},{key:"getTurn",value:function(c,p){var g=Math.sin(p-c);return g>0?M.COUNTERCLOCKWISE:g<0?M.CLOCKWISE:M.NONE}},{key:"angleBetweenOriented",value:function(c,p,g){var w=M.angle(p,c),L=M.angle(p,g)-w;return L<=-Math.PI?L+M.PI_TIMES_2:L>Math.PI?L-M.PI_TIMES_2:L}}]),M}();br.PI_TIMES_2=2*Math.PI,br.PI_OVER_2=Math.PI/2,br.PI_OVER_4=Math.PI/4,br.COUNTERCLOCKWISE=sn.COUNTERCLOCKWISE,br.CLOCKWISE=sn.CLOCKWISE,br.NONE=sn.COLLINEAR;var ms=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"addNextSegment",value:function(c,p){if(this._s0=this._s1,this._s1=this._s2,this._s2=c,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var g=sn.index(this._s0,this._s1,this._s2),w=g===sn.CLOCKWISE&&this._side===wt.LEFT||g===sn.COUNTERCLOCKWISE&&this._side===wt.RIGHT;g===0?this.addCollinear(p):w?this.addOutsideTurn(g,p):this.addInsideTurn(g,p)}},{key:"addLineEndCap",value:function(c,p){var g=new Lr(c,p),w=new Lr;this.computeOffsetSegment(g,wt.LEFT,this._distance,w);var L=new Lr;this.computeOffsetSegment(g,wt.RIGHT,this._distance,L);var V=p.x-c.x,X=p.y-c.y,Q=Math.atan2(X,V);switch(this._bufParams.getEndCapStyle()){case ce.CAP_ROUND:this._segList.addPt(w.p1),this.addDirectedFillet(p,Q+Math.PI/2,Q-Math.PI/2,sn.CLOCKWISE,this._distance),this._segList.addPt(L.p1);break;case ce.CAP_FLAT:this._segList.addPt(w.p1),this._segList.addPt(L.p1);break;case ce.CAP_SQUARE:var ae=new je;ae.x=Math.abs(this._distance)*Math.cos(Q),ae.y=Math.abs(this._distance)*Math.sin(Q);var Le=new je(w.p1.x+ae.x,w.p1.y+ae.y),Ne=new je(L.p1.x+ae.x,L.p1.y+ae.y);this._segList.addPt(Le),this._segList.addPt(Ne)}}},{key:"getCoordinates",value:function(){return this._segList.getCoordinates()}},{key:"addMitreJoin",value:function(c,p,g,w){var L=Os.intersection(p.p0,p.p1,g.p0,g.p1);if(L!==null&&(w<=0?1:L.distance(c)/Math.abs(w))<=this._bufParams.getMitreLimit())return this._segList.addPt(L),null;this.addLimitedMitreJoin(p,g,w,this._bufParams.getMitreLimit())}},{key:"addOutsideTurn",value:function(c,p){if(this._offset0.p1.distance(this._offset1.p0)=Ne&&(Q-=2*Math.PI),this._segList.addPt(p),this.addDirectedFillet(c,Q,Ne,w,L),this._segList.addPt(g)}},{key:"addLastSegment",value:function(){this._segList.addPt(this._offset1.p1)}},{key:"initSideSegments",value:function(c,p,g){this._s1=c,this._s2=p,this._side=g,this._seg1.setCoordinates(c,p),this.computeOffsetSegment(this._seg1,g,this._distance,this._offset1)}},{key:"addLimitedMitreJoin",value:function(c,p,g,w){var L=this._seg0.p1,V=br.angle(L,this._seg0.p0),X=br.angleBetweenOriented(this._seg0.p0,L,this._seg1.p1)/2,Q=br.normalize(V+X),ae=br.normalize(Q+Math.PI),Le=w*g,Ne=g-Le*Math.abs(Math.sin(X)),rt=L.x+Le*Math.cos(ae),kt=L.y+Le*Math.sin(ae),Ct=new je(rt,kt),Qt=new Lr(L,Ct),Ht=Qt.pointAlongOffset(1,Ne),dn=Qt.pointAlongOffset(1,-Ne);this._side===wt.LEFT?(this._segList.addPt(Ht),this._segList.addPt(dn)):(this._segList.addPt(dn),this._segList.addPt(Ht))}},{key:"addDirectedFillet",value:function(c,p,g,w,L){var V=w===sn.CLOCKWISE?-1:1,X=Math.abs(p-g),Q=Math.trunc(X/this._filletAngleQuantum+.5);if(Q<1)return null;for(var ae=X/Q,Le=new je,Ne=0;Ne0){var g=new je((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(g);var w=new je((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(w)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}},{key:"createCircle",value:function(c){var p=new je(c.x+this._distance,c.y);this._segList.addPt(p),this.addDirectedFillet(c,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}},{key:"addBevelJoin",value:function(c,p){this._segList.addPt(c.p1),this._segList.addPt(p.p0)}},{key:"init",value:function(c){this._distance=c,this._maxCurveSegmentError=c*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new Bs,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(c*M.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}},{key:"addCollinear",value:function(c){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===ce.JOIN_BEVEL||this._bufParams.getJoinStyle()===ce.JOIN_MITRE?(c&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,sn.CLOCKWISE,this._distance))}},{key:"closeRing",value:function(){this._segList.closeRing()}},{key:"hasNarrowConcaveAngle",value:function(){return this._hasNarrowConcaveAngle}}],[{key:"constructor_",value:function(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new Lr,this._seg1=new Lr,this._offset0=new Lr,this._offset1=new Lr,this._side=0,this._hasNarrowConcaveAngle=!1;var c=arguments[0],p=arguments[1],g=arguments[2];this._precisionModel=c,this._bufParams=p,this._li=new Ko,this._filletAngleQuantum=Math.PI/2/p.getQuadrantSegments(),p.getQuadrantSegments()>=8&&p.getJoinStyle()===ce.JOIN_ROUND&&(this._closingSegLengthFactor=M.MAX_CLOSING_SEG_LEN_FACTOR),this.init(g)}}]),M}();ms.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,ms.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,ms.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,ms.MAX_CLOSING_SEG_LEN_FACTOR=80;var Xa=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getOffsetCurve",value:function(c,p){if(this._distance=p,p===0)return null;var g=p<0,w=Math.abs(p),L=this.getSegGen(w);c.length<=1?this.computePointCurve(c[0],L):this.computeOffsetCurve(c,g,L);var V=L.getCoordinates();return g&&Ri.reverse(V),V}},{key:"computeSingleSidedBufferCurve",value:function(c,p,g){var w=this.simplifyTolerance(this._distance);if(p){g.addSegments(c,!0);var L=Yr.simplify(c,-w),V=L.length-1;g.initSideSegments(L[V],L[V-1],wt.LEFT),g.addFirstSegment();for(var X=V-2;X>=0;X--)g.addNextSegment(L[X],!0)}else{g.addSegments(c,!1);var Q=Yr.simplify(c,w),ae=Q.length-1;g.initSideSegments(Q[0],Q[1],wt.LEFT),g.addFirstSegment();for(var Le=2;Le<=ae;Le++)g.addNextSegment(Q[Le],!0)}g.addLastSegment(),g.closeRing()}},{key:"computeRingBufferCurve",value:function(c,p,g){var w=this.simplifyTolerance(this._distance);p===wt.RIGHT&&(w=-w);var L=Yr.simplify(c,w),V=L.length-1;g.initSideSegments(L[V-1],L[0],p);for(var X=1;X<=V;X++){var Q=X!==1;g.addNextSegment(L[X],Q)}g.closeRing()}},{key:"computeLineBufferCurve",value:function(c,p){var g=this.simplifyTolerance(this._distance),w=Yr.simplify(c,g),L=w.length-1;p.initSideSegments(w[0],w[1],wt.LEFT);for(var V=2;V<=L;V++)p.addNextSegment(w[V],!0);p.addLastSegment(),p.addLineEndCap(w[L-1],w[L]);var X=Yr.simplify(c,-g),Q=X.length-1;p.initSideSegments(X[Q],X[Q-1],wt.LEFT);for(var ae=Q-2;ae>=0;ae--)p.addNextSegment(X[ae],!0);p.addLastSegment(),p.addLineEndCap(X[1],X[0]),p.closeRing()}},{key:"computePointCurve",value:function(c,p){switch(this._bufParams.getEndCapStyle()){case ce.CAP_ROUND:p.createCircle(c);break;case ce.CAP_SQUARE:p.createSquare(c)}}},{key:"getLineCurve",value:function(c,p){if(this._distance=p,this.isLineOffsetEmpty(p))return null;var g=Math.abs(p),w=this.getSegGen(g);if(c.length<=1)this.computePointCurve(c[0],w);else if(this._bufParams.isSingleSided()){var L=p<0;this.computeSingleSidedBufferCurve(c,L,w)}else this.computeLineBufferCurve(c,w);return w.getCoordinates()}},{key:"getBufferParameters",value:function(){return this._bufParams}},{key:"simplifyTolerance",value:function(c){return c*this._bufParams.getSimplifyFactor()}},{key:"getRingCurve",value:function(c,p,g){if(this._distance=g,c.length<=2)return this.getLineCurve(c,g);if(g===0)return M.copyCoordinates(c);var w=this.getSegGen(g);return this.computeRingBufferCurve(c,p,w),w.getCoordinates()}},{key:"computeOffsetCurve",value:function(c,p,g){var w=this.simplifyTolerance(this._distance);if(p){var L=Yr.simplify(c,-w),V=L.length-1;g.initSideSegments(L[V],L[V-1],wt.LEFT),g.addFirstSegment();for(var X=V-2;X>=0;X--)g.addNextSegment(L[X],!0)}else{var Q=Yr.simplify(c,w),ae=Q.length-1;g.initSideSegments(Q[0],Q[1],wt.LEFT),g.addFirstSegment();for(var Le=2;Le<=ae;Le++)g.addNextSegment(Q[Le],!0)}g.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(c){return c===0||c<0&&!this._bufParams.isSingleSided()}},{key:"getSegGen",value:function(c){return new ms(this._precisionModel,this._bufParams,c)}}],[{key:"constructor_",value:function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var c=arguments[0],p=arguments[1];this._precisionModel=c,this._bufParams=p}},{key:"copyCoordinates",value:function(c){for(var p=new Array(c.length).fill(null),g=0;gL.getMaxY()||this.findStabbedSegments(c,w.getDirectedEdges(),p)}return p}if(arguments.length===3){if(an(arguments[2],Fr)&&arguments[0]instanceof je&&arguments[1]instanceof po)for(var V=arguments[0],X=arguments[1],Q=arguments[2],ae=X.getEdge().getCoordinates(),Le=0;Lethis._seg.p1.y&&this._seg.reverse();var Ne=Math.max(this._seg.p0.x,this._seg.p1.x);if(!(Nethis._seg.p1.y||sn.index(this._seg.p0,this._seg.p1,V)===sn.RIGHT)){var rt=X.getDepth(wt.LEFT);this._seg.p0.equals(ae[Le])||(rt=X.getDepth(wt.RIGHT));var kt=new Wa(this._seg,rt);Q.add(kt)}}else if(an(arguments[2],Fr)&&arguments[0]instanceof je&&an(arguments[1],Fr))for(var Ct=arguments[0],Qt=arguments[1],Ht=arguments[2],dn=Qt.iterator();dn.hasNext();){var Rn=dn.next();Rn.isForward()&&this.findStabbedSegments(Ct,Rn,Ht)}}}},{key:"getDepth",value:function(c){var p=this.findStabbedSegments(c);return p.size()===0?0:Ar.min(p)._leftDepth}}],[{key:"constructor_",value:function(){this._subgraphs=null,this._seg=new Lr;var c=arguments[0];this._subgraphs=c}}]),M}(),Wa=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"compareTo",value:function(c){var p=c;if(this._upwardSeg.minX()>=p._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=p._upwardSeg.minX())return-1;var g=this._upwardSeg.orientationIndex(p._upwardSeg);return g!==0||(g=-1*p._upwardSeg.orientationIndex(this._upwardSeg))!==0?g:this._upwardSeg.compareTo(p._upwardSeg)}},{key:"compareX",value:function(c,p){var g=c.p0.compareTo(p.p0);return g!==0?g:c.p1.compareTo(p.p1)}},{key:"toString",value:function(){return this._upwardSeg.toString()}},{key:"interfaces_",get:function(){return[ze]}}],[{key:"constructor_",value:function(){this._upwardSeg=null,this._leftDepth=null;var c=arguments[0],p=arguments[1];this._upwardSeg=new Lr(c),this._leftDepth=p}}]),M}();_a.DepthSegment=Wa;var Nn=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,null,[{key:"constructor_",value:function(){be.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}]),p}(be),gs=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getY",value:function(){var c=this.y/this.w;if(tt.isNaN(c)||tt.isInfinite(c))throw new Nn;return c}},{key:"getX",value:function(){var c=this.x/this.w;if(tt.isNaN(c)||tt.isInfinite(c))throw new Nn;return c}},{key:"getCoordinate",value:function(){var c=new je;return c.x=this.getX(),c.y=this.getY(),c}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.w=null,arguments.length===0)this.x=0,this.y=0,this.w=1;else if(arguments.length===1){var c=arguments[0];this.x=c.x,this.y=c.y,this.w=1}else if(arguments.length===2){if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var p=arguments[0],g=arguments[1];this.x=p,this.y=g,this.w=1}else if(arguments[0]instanceof M&&arguments[1]instanceof M){var w=arguments[0],L=arguments[1];this.x=w.y*L.w-L.y*w.w,this.y=L.x*w.w-w.x*L.w,this.w=w.x*L.y-L.x*w.y}else if(arguments[0]instanceof je&&arguments[1]instanceof je){var V=arguments[0],X=arguments[1];this.x=V.y-X.y,this.y=X.x-V.x,this.w=V.x*X.y-X.x*V.y}}else if(arguments.length===3){var Q=arguments[0],ae=arguments[1],Le=arguments[2];this.x=Q,this.y=ae,this.w=Le}else if(arguments.length===4){var Ne=arguments[0],rt=arguments[1],kt=arguments[2],Ct=arguments[3],Qt=Ne.y-rt.y,Ht=rt.x-Ne.x,dn=Ne.x*rt.y-rt.x*Ne.y,Rn=kt.y-Ct.y,ui=Ct.x-kt.x,lr=kt.x*Ct.y-Ct.x*kt.y;this.x=Ht*lr-ui*dn,this.y=Rn*dn-Qt*lr,this.w=Qt*ui-Rn*Ht}}}]),M}(),Vu=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"area",value:function(){return M.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return M.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(c){if(c===null)throw new we("Supplied point is null.");return M.interpolateZ(c,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return M.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return M.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return M.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return M.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return M.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return M.inCentre(this.p0,this.p1,this.p2)}}],[{key:"constructor_",value:function(){this.p0=null,this.p1=null,this.p2=null;var c=arguments[0],p=arguments[1],g=arguments[2];this.p0=c,this.p1=p,this.p2=g}},{key:"area",value:function(c,p,g){return Math.abs(((g.x-c.x)*(p.y-c.y)-(p.x-c.x)*(g.y-c.y))/2)}},{key:"signedArea",value:function(c,p,g){return((g.x-c.x)*(p.y-c.y)-(p.x-c.x)*(g.y-c.y))/2}},{key:"det",value:function(c,p,g,w){return c*w-p*g}},{key:"interpolateZ",value:function(c,p,g,w){var L=p.x,V=p.y,X=g.x-L,Q=w.x-L,ae=g.y-V,Le=w.y-V,Ne=X*Le-Q*ae,rt=c.x-L,kt=c.y-V,Ct=(Le*rt-Q*kt)/Ne,Qt=(-ae*rt+X*kt)/Ne;return p.getZ()+Ct*(g.getZ()-p.getZ())+Qt*(w.getZ()-p.getZ())}},{key:"longestSideLength",value:function(c,p,g){var w=c.distance(p),L=p.distance(g),V=g.distance(c),X=w;return L>X&&(X=L),V>X&&(X=V),X}},{key:"circumcentreDD",value:function(c,p,g){var w=tn.valueOf(c.x).subtract(g.x),L=tn.valueOf(c.y).subtract(g.y),V=tn.valueOf(p.x).subtract(g.x),X=tn.valueOf(p.y).subtract(g.y),Q=tn.determinant(w,L,V,X).multiply(2),ae=w.sqr().add(L.sqr()),Le=V.sqr().add(X.sqr()),Ne=tn.determinant(L,ae,X,Le),rt=tn.determinant(w,ae,V,Le),kt=tn.valueOf(g.x).subtract(Ne.divide(Q)).doubleValue(),Ct=tn.valueOf(g.y).add(rt.divide(Q)).doubleValue();return new je(kt,Ct)}},{key:"isAcute",value:function(c,p,g){return!!br.isAcute(c,p,g)&&!!br.isAcute(p,g,c)&&!!br.isAcute(g,c,p)}},{key:"circumcentre",value:function(c,p,g){var w=g.x,L=g.y,V=c.x-w,X=c.y-L,Q=p.x-w,ae=p.y-L,Le=2*M.det(V,X,Q,ae),Ne=M.det(X,V*V+X*X,ae,Q*Q+ae*ae),rt=M.det(V,V*V+X*X,Q,Q*Q+ae*ae);return new je(w-Ne/Le,L+rt/Le)}},{key:"perpendicularBisector",value:function(c,p){var g=p.x-c.x,w=p.y-c.y,L=new gs(c.x+g/2,c.y+w/2,1),V=new gs(c.x-w+g/2,c.y+g+w/2,1);return new gs(L,V)}},{key:"angleBisector",value:function(c,p,g){var w=p.distance(c),L=w/(w+p.distance(g)),V=g.x-c.x,X=g.y-c.y;return new je(c.x+L*V,c.y+L*X)}},{key:"area3D",value:function(c,p,g){var w=p.x-c.x,L=p.y-c.y,V=p.getZ()-c.getZ(),X=g.x-c.x,Q=g.y-c.y,ae=g.getZ()-c.getZ(),Le=L*ae-V*Q,Ne=V*X-w*ae,rt=w*Q-L*X,kt=Le*Le+Ne*Ne+rt*rt,Ct=Math.sqrt(kt)/2;return Ct}},{key:"centroid",value:function(c,p,g){var w=(c.x+p.x+g.x)/3,L=(c.y+p.y+g.y)/3;return new je(w,L)}},{key:"inCentre",value:function(c,p,g){var w=p.distance(g),L=c.distance(g),V=c.distance(p),X=w+L+V,Q=(w*c.x+L*p.x+V*g.x)/X,ae=(w*c.y+L*p.y+V*g.y)/X;return new je(Q,ae)}}]),M}(),Ul=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"addRingSide",value:function(c,p,g,w,L){if(p===0&&c.length=Ci.MINIMUM_VALID_SIZE&&sn.isCCW(c)&&(V=L,X=w,g=wt.opposite(g));var Q=this._curveBuilder.getRingCurve(c,g,p);this.addCurve(Q,V,X)}},{key:"addRingBothSides",value:function(c,p){this.addRingSide(c,p,wt.LEFT,Me.EXTERIOR,Me.INTERIOR),this.addRingSide(c,p,wt.RIGHT,Me.INTERIOR,Me.EXTERIOR)}},{key:"addPoint",value:function(c){if(this._distance<=0)return null;var p=c.getCoordinates(),g=this._curveBuilder.getLineCurve(p,this._distance);this.addCurve(g,Me.EXTERIOR,Me.INTERIOR)}},{key:"addPolygon",value:function(c){var p=this._distance,g=wt.LEFT;this._distance<0&&(p=-this._distance,g=wt.RIGHT);var w=c.getExteriorRing(),L=Ri.removeRepeatedPoints(w.getCoordinates());if(this._distance<0&&this.isErodedCompletely(w,this._distance)||this._distance<=0&&L.length<3)return null;this.addRingSide(L,p,g,Me.EXTERIOR,Me.INTERIOR);for(var V=0;V0&&this.isErodedCompletely(X,-this._distance)||this.addRingSide(Q,p,wt.opposite(g),Me.INTERIOR,Me.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(c,p){var g=new Vu(c[0],c[1],c[2]),w=g.inCentre();return ne.pointToSegment(w,g.p0,g.p1)L}},{key:"addCollection",value:function(c){for(var p=0;p=this._max)throw new Si;var c=this._parent.getGeometryN(this._index++);return c instanceof $n?(this._subcollectionIterator=new M(c),this._subcollectionIterator.next()):c}},{key:"remove",value:function(){throw new yn(this.getClass().getName())}},{key:"hasNext",value:function(){if(this._atStart)return!0;if(this._subcollectionIterator!==null){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}},{key:"interfaces_",get:function(){return[Ns]}}],[{key:"constructor_",value:function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var c=arguments[0];this._parent=c,this._atStart=!0,this._index=0,this._max=c.getNumGeometries()}},{key:"isAtomic",value:function(c){return!(c instanceof $n)}}]),M}(),jl=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"locate",value:function(c){return M.locate(c,this._geom)}},{key:"interfaces_",get:function(){return[Uu]}}],[{key:"constructor_",value:function(){this._geom=null;var c=arguments[0];this._geom=c}},{key:"locatePointInPolygon",value:function(c,p){if(p.isEmpty())return Me.EXTERIOR;var g=p.getExteriorRing(),w=M.locatePointInRing(c,g);if(w!==Me.INTERIOR)return w;for(var L=0;L=0;L--){var V=this._edgeList.get(L),X=V.getSym();w===null&&(w=X),g!==null&&X.setNext(g),g=V}w.setNext(g)}},{key:"computeDepths",value:function(){if(arguments.length===1){var g=arguments[0],w=this.findIndex(g),L=g.getDepth(wt.LEFT),V=g.getDepth(wt.RIGHT),X=this.computeDepths(w+1,this._edgeList.size(),L),Q=this.computeDepths(0,w,X);if(Q!==V)throw new vr("depth mismatch at "+g.getCoordinate())}else if(arguments.length===3){for(var ae=arguments[0],Le=arguments[1],Ne=arguments[2],rt=Ne,kt=ae;kt=0;X--){var Q=this._resultAreaEdgeList.get(X),ae=Q.getSym();switch(w===null&&Q.getEdgeRing()===g&&(w=Q),V){case this._SCANNING_FOR_INCOMING:if(ae.getEdgeRing()!==g)continue;L=ae,V=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(Q.getEdgeRing()!==g)continue;L.setNextMin(Q),V=this._SCANNING_FOR_INCOMING}}V===this._LINKING_TO_OUTGOING&&(St.isTrue(w!==null,"found null for first outgoing dirEdge"),St.isTrue(w.getEdgeRing()===g,"unable to link last incoming dirEdge"),L.setNextMin(w))}},{key:"getOutgoingDegree",value:function(){if(arguments.length===0){for(var g=0,w=this.iterator();w.hasNext();){var L=w.next();L.isInResult()&&g++}return g}if(arguments.length===1){for(var V=arguments[0],X=0,Q=this.iterator();Q.hasNext();){var ae=Q.next();ae.getEdgeRing()===V&&X++}return X}}},{key:"getLabel",value:function(){return this._label}},{key:"findCoveredLineEdges",value:function(){for(var g=Me.NONE,w=this.iterator();w.hasNext();){var L=w.next(),V=L.getSym();if(!L.isLineEdge()){if(L.isInResult()){g=Me.INTERIOR;break}if(V.isInResult()){g=Me.EXTERIOR;break}}}if(g===Me.NONE)return null;for(var X=g,Q=this.iterator();Q.hasNext();){var ae=Q.next(),Le=ae.getSym();ae.isLineEdge()?ae.getEdge().setCovered(X===Me.INTERIOR):(ae.isInResult()&&(X=Me.EXTERIOR),Le.isInResult()&&(X=Me.INTERIOR))}}},{key:"computeLabelling",value:function(g){Z(x(p.prototype),"computeLabelling",this).call(this,g),this._label=new rr(Me.NONE);for(var w=this.iterator();w.hasNext();)for(var L=w.next().getEdge().getLabel(),V=0;V<2;V++){var X=L.getLocation(V);X!==Me.INTERIOR&&X!==Me.BOUNDARY||this._label.setLocation(V,Me.INTERIOR)}}}],[{key:"constructor_",value:function(){this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}}]),p}(rh),sh=function(M){f(p,M);var c=U(p);function p(){return s(this,p),c.call(this)}return h(p,[{key:"createNode",value:function(g){return new sr(g,new oh)}}]),p}(No),Ya=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"compareTo",value:function(c){var p=c;return M.compareOriented(this._pts,this._orientation,p._pts,p._orientation)}},{key:"interfaces_",get:function(){return[ze]}}],[{key:"constructor_",value:function(){this._pts=null,this._orientation=null;var c=arguments[0];this._pts=c,this._orientation=M.orientation(c)}},{key:"orientation",value:function(c){return Ri.increasingDirection(c)===1}},{key:"compareOriented",value:function(c,p,g,w){for(var L=p?1:-1,V=w?1:-1,X=p?c.length:-1,Q=w?g.length:-1,ae=p?0:c.length-1,Le=w?0:g.length-1;;){var Ne=c[ae].compareTo(g[Le]);if(Ne!==0)return Ne;var rt=(ae+=L)===X,kt=(Le+=V)===Q;if(rt&&!kt)return-1;if(!rt&&kt)return 1;if(rt&&kt)return 0}}}]),M}(),Gl=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"print",value:function(c){c.print("MULTILINESTRING ( ");for(var p=0;p0&&c.print(","),c.print("(");for(var w=g.getCoordinates(),L=0;L0&&c.print(","),c.print(w[L].x+" "+w[L].y);c.println(")")}c.print(") ")}},{key:"addAll",value:function(c){for(var p=c.iterator();p.hasNext();)this.add(p.next())}},{key:"findEdgeIndex",value:function(c){for(var p=0;pc?1:this.distp?1:0}},{key:"interfaces_",get:function(){return[ze]}}],[{key:"constructor_",value:function(){this.coord=null,this.segmentIndex=null,this.dist=null;var c=arguments[0],p=arguments[1],g=arguments[2];this.coord=new je(c),this.segmentIndex=p,this.dist=g}}]),M}(),Gu=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"print",value:function(c){c.println("Intersections:");for(var p=this.iterator();p.hasNext();)p.next().print(c)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(c){this.addEndpoints();for(var p=this.iterator(),g=p.next();p.hasNext();){var w=p.next(),L=this.createSplitEdge(g,w);c.add(L),g=w}}},{key:"addEndpoints",value:function(){var c=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[c],c,0)}},{key:"createSplitEdge",value:function(c,p){var g=p.segmentIndex-c.segmentIndex+2,w=this.edge.pts[p.segmentIndex],L=p.dist>0||!p.coord.equals2D(w);L||g--;var V=new Array(g).fill(null),X=0;V[X++]=new je(c.coord);for(var Q=c.segmentIndex+1;Q<=p.segmentIndex;Q++)V[X++]=this.edge.pts[Q];return L&&(V[X]=p.coord),new Ja(V,new rr(this.edge._label))}},{key:"add",value:function(c,p,g){var w=new ju(c,p,g),L=this._nodeMap.get(w);return L!==null?L:(this._nodeMap.put(w,w),w)}},{key:"isIntersection",value:function(c){for(var p=this.iterator();p.hasNext();)if(p.next().coord.equals(c))return!0;return!1}}],[{key:"constructor_",value:function(){this._nodeMap=new fo,this.edge=null;var c=arguments[0];this.edge=c}}]),M}(),ah=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(M.isTrue(this._matrix[Me.INTERIOR][Me.INTERIOR])||M.isTrue(this._matrix[Me.INTERIOR][Me.BOUNDARY])||M.isTrue(this._matrix[Me.BOUNDARY][Me.INTERIOR])||M.isTrue(this._matrix[Me.BOUNDARY][Me.BOUNDARY]))&&this._matrix[Me.EXTERIOR][Me.INTERIOR]===me.FALSE&&this._matrix[Me.EXTERIOR][Me.BOUNDARY]===me.FALSE}},{key:"isCoveredBy",value:function(){return(M.isTrue(this._matrix[Me.INTERIOR][Me.INTERIOR])||M.isTrue(this._matrix[Me.INTERIOR][Me.BOUNDARY])||M.isTrue(this._matrix[Me.BOUNDARY][Me.INTERIOR])||M.isTrue(this._matrix[Me.BOUNDARY][Me.BOUNDARY]))&&this._matrix[Me.INTERIOR][Me.EXTERIOR]===me.FALSE&&this._matrix[Me.BOUNDARY][Me.EXTERIOR]===me.FALSE}},{key:"set",value:function(){if(arguments.length===1)for(var c=arguments[0],p=0;p=0&&p>=0&&this.setAtLeast(c,p,g)}},{key:"isWithin",value:function(){return M.isTrue(this._matrix[Me.INTERIOR][Me.INTERIOR])&&this._matrix[Me.INTERIOR][Me.EXTERIOR]===me.FALSE&&this._matrix[Me.BOUNDARY][Me.EXTERIOR]===me.FALSE}},{key:"isTouches",value:function(c,p){return c>p?this.isTouches(p,c):(c===me.A&&p===me.A||c===me.L&&p===me.L||c===me.L&&p===me.A||c===me.P&&p===me.A||c===me.P&&p===me.L)&&this._matrix[Me.INTERIOR][Me.INTERIOR]===me.FALSE&&(M.isTrue(this._matrix[Me.INTERIOR][Me.BOUNDARY])||M.isTrue(this._matrix[Me.BOUNDARY][Me.INTERIOR])||M.isTrue(this._matrix[Me.BOUNDARY][Me.BOUNDARY]))}},{key:"isOverlaps",value:function(c,p){return c===me.P&&p===me.P||c===me.A&&p===me.A?M.isTrue(this._matrix[Me.INTERIOR][Me.INTERIOR])&&M.isTrue(this._matrix[Me.INTERIOR][Me.EXTERIOR])&&M.isTrue(this._matrix[Me.EXTERIOR][Me.INTERIOR]):c===me.L&&p===me.L&&this._matrix[Me.INTERIOR][Me.INTERIOR]===1&&M.isTrue(this._matrix[Me.INTERIOR][Me.EXTERIOR])&&M.isTrue(this._matrix[Me.EXTERIOR][Me.INTERIOR])}},{key:"isEquals",value:function(c,p){return c===p&&M.isTrue(this._matrix[Me.INTERIOR][Me.INTERIOR])&&this._matrix[Me.INTERIOR][Me.EXTERIOR]===me.FALSE&&this._matrix[Me.BOUNDARY][Me.EXTERIOR]===me.FALSE&&this._matrix[Me.EXTERIOR][Me.INTERIOR]===me.FALSE&&this._matrix[Me.EXTERIOR][Me.BOUNDARY]===me.FALSE}},{key:"toString",value:function(){for(var c=new us("123456789"),p=0;p<3;p++)for(var g=0;g<3;g++)c.setCharAt(3*p+g,me.toDimensionSymbol(this._matrix[p][g]));return c.toString()}},{key:"setAll",value:function(c){for(var p=0;p<3;p++)for(var g=0;g<3;g++)this._matrix[p][g]=c}},{key:"get",value:function(c,p){return this._matrix[c][p]}},{key:"transpose",value:function(){var c=this._matrix[1][0];return this._matrix[1][0]=this._matrix[0][1],this._matrix[0][1]=c,c=this._matrix[2][0],this._matrix[2][0]=this._matrix[0][2],this._matrix[0][2]=c,c=this._matrix[2][1],this._matrix[2][1]=this._matrix[1][2],this._matrix[1][2]=c,this}},{key:"matches",value:function(c){if(c.length!==9)throw new we("Should be length 9: "+c);for(var p=0;p<3;p++)for(var g=0;g<3;g++)if(!M.matches(this._matrix[p][g],c.charAt(3*p+g)))return!1;return!0}},{key:"add",value:function(c){for(var p=0;p<3;p++)for(var g=0;g<3;g++)this.setAtLeast(p,g,c.get(p,g))}},{key:"isDisjoint",value:function(){return this._matrix[Me.INTERIOR][Me.INTERIOR]===me.FALSE&&this._matrix[Me.INTERIOR][Me.BOUNDARY]===me.FALSE&&this._matrix[Me.BOUNDARY][Me.INTERIOR]===me.FALSE&&this._matrix[Me.BOUNDARY][Me.BOUNDARY]===me.FALSE}},{key:"isCrosses",value:function(c,p){return c===me.P&&p===me.L||c===me.P&&p===me.A||c===me.L&&p===me.A?M.isTrue(this._matrix[Me.INTERIOR][Me.INTERIOR])&&M.isTrue(this._matrix[Me.INTERIOR][Me.EXTERIOR]):c===me.L&&p===me.P||c===me.A&&p===me.P||c===me.A&&p===me.L?M.isTrue(this._matrix[Me.INTERIOR][Me.INTERIOR])&&M.isTrue(this._matrix[Me.EXTERIOR][Me.INTERIOR]):c===me.L&&p===me.L&&this._matrix[Me.INTERIOR][Me.INTERIOR]===0}},{key:"interfaces_",get:function(){return[Ve]}}],[{key:"constructor_",value:function(){if(this._matrix=null,arguments.length===0)this._matrix=Array(3).fill().map(function(){return Array(3)}),this.setAll(me.FALSE);else if(arguments.length===1){if(typeof arguments[0]=="string"){var c=arguments[0];M.constructor_.call(this),this.set(c)}else if(arguments[0]instanceof M){var p=arguments[0];M.constructor_.call(this),this._matrix[Me.INTERIOR][Me.INTERIOR]=p._matrix[Me.INTERIOR][Me.INTERIOR],this._matrix[Me.INTERIOR][Me.BOUNDARY]=p._matrix[Me.INTERIOR][Me.BOUNDARY],this._matrix[Me.INTERIOR][Me.EXTERIOR]=p._matrix[Me.INTERIOR][Me.EXTERIOR],this._matrix[Me.BOUNDARY][Me.INTERIOR]=p._matrix[Me.BOUNDARY][Me.INTERIOR],this._matrix[Me.BOUNDARY][Me.BOUNDARY]=p._matrix[Me.BOUNDARY][Me.BOUNDARY],this._matrix[Me.BOUNDARY][Me.EXTERIOR]=p._matrix[Me.BOUNDARY][Me.EXTERIOR],this._matrix[Me.EXTERIOR][Me.INTERIOR]=p._matrix[Me.EXTERIOR][Me.INTERIOR],this._matrix[Me.EXTERIOR][Me.BOUNDARY]=p._matrix[Me.EXTERIOR][Me.BOUNDARY],this._matrix[Me.EXTERIOR][Me.EXTERIOR]=p._matrix[Me.EXTERIOR][Me.EXTERIOR]}}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&typeof arguments[1]=="string"){var c=arguments[0],p=arguments[1];return p===me.SYM_DONTCARE||p===me.SYM_TRUE&&(c>=0||c===me.TRUE)||p===me.SYM_FALSE&&c===me.FALSE||p===me.SYM_P&&c===me.P||p===me.SYM_L&&c===me.L||p===me.SYM_A&&c===me.A}if(typeof arguments[0]=="string"&&typeof arguments[1]=="string"){var g=arguments[0],w=arguments[1],L=new M(g);return L.matches(w)}}},{key:"isTrue",value:function(c){return c>=0||c===me.TRUE}}]),M}(),ya=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"size",value:function(){return this._size}},{key:"addAll",value:function(c){return c===null||c.length===0?null:(this.ensureCapacity(this._size+c.length),xe.arraycopy(c,0,this._data,this._size,c.length),void(this._size+=c.length))}},{key:"ensureCapacity",value:function(c){if(c<=this._data.length)return null;var p=Math.max(c,2*this._data.length);this._data=on.copyOf(this._data,p)}},{key:"toArray",value:function(){var c=new Array(this._size).fill(null);return xe.arraycopy(this._data,0,c,0,this._size),c}},{key:"add",value:function(c){this.ensureCapacity(this._size+1),this._data[this._size]=c,++this._size}}],[{key:"constructor_",value:function(){if(this._data=null,this._size=0,arguments.length===0)M.constructor_.call(this,10);else if(arguments.length===1){var c=arguments[0];this._data=new Array(c).fill(null)}}}]),M}(),Fs=function(){function M(){s(this,M)}return h(M,[{key:"getChainStartIndices",value:function(c){var p=0,g=new ya(Math.trunc(c.length/2));g.add(p);do{var w=this.findChainEnd(c,p);g.add(w),p=w}while(pg?p:g}},{key:"getMinX",value:function(c){var p=this.pts[this.startIndex[c]].x,g=this.pts[this.startIndex[c+1]].x;return pp&&(w=1),this._depth[c][g]=w}}}},{key:"getDelta",value:function(c){return this._depth[c][wt.RIGHT]-this._depth[c][wt.LEFT]}},{key:"getLocation",value:function(c,p){return this._depth[c][p]<=0?Me.EXTERIOR:Me.INTERIOR}},{key:"toString",value:function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]}},{key:"add",value:function(){if(arguments.length===1)for(var c=arguments[0],p=0;p<2;p++)for(var g=1;g<3;g++){var w=c.getLocation(p,g);w!==Me.EXTERIOR&&w!==Me.INTERIOR||(this.isNull(p,g)?this._depth[p][g]=M.depthAtLocation(w):this._depth[p][g]+=M.depthAtLocation(w))}else if(arguments.length===3){var L=arguments[0],V=arguments[1],X=arguments[2];X===Me.INTERIOR&&this._depth[L][V]++}}}],[{key:"constructor_",value:function(){this._depth=Array(2).fill().map(function(){return Array(3)});for(var c=0;c<2;c++)for(var p=0;p<3;p++)this._depth[c][p]=M.NULL_VALUE}},{key:"depthAtLocation",value:function(c){return c===Me.EXTERIOR?0:c===Me.INTERIOR?1:M.NULL_VALUE}}]),M}();Vs.NULL_VALUE=-1;var Ja=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"getDepth",value:function(){return this._depth}},{key:"getCollapsedEdge",value:function(){var g=new Array(2).fill(null);return g[0]=this.pts[0],g[1]=this.pts[1],new p(g,rr.toLineLabel(this._label))}},{key:"isIsolated",value:function(){return this._isIsolated}},{key:"getCoordinates",value:function(){return this.pts}},{key:"setIsolated",value:function(g){this._isIsolated=g}},{key:"setName",value:function(g){this._name=g}},{key:"equals",value:function(g){if(!(g instanceof p))return!1;var w=g;if(this.pts.length!==w.pts.length)return!1;for(var L=!0,V=!0,X=this.pts.length,Q=0;Q0?this.pts[0]:null;if(arguments.length===1){var g=arguments[0];return this.pts[g]}}},{key:"print",value:function(g){g.print("edge "+this._name+": "),g.print("LINESTRING (");for(var w=0;w0&&g.print(","),g.print(this.pts[w].x+" "+this.pts[w].y);g.print(") "+this._label+" "+this._depthDelta)}},{key:"computeIM",value:function(g){p.updateIM(this._label,g)}},{key:"isCollapsed",value:function(){return!!this._label.isArea()&&this.pts.length===3&&!!this.pts[0].equals(this.pts[2])}},{key:"isClosed",value:function(){return this.pts[0].equals(this.pts[this.pts.length-1])}},{key:"getMaximumSegmentIndex",value:function(){return this.pts.length-1}},{key:"getDepthDelta",value:function(){return this._depthDelta}},{key:"getNumPoints",value:function(){return this.pts.length}},{key:"printReverse",value:function(g){g.print("edge "+this._name+": ");for(var w=this.pts.length-1;w>=0;w--)g.print(this.pts[w]+" ");g.println("")}},{key:"getMonotoneChainEdge",value:function(){return this._mce===null&&(this._mce=new ql(this)),this._mce}},{key:"getEnvelope",value:function(){if(this._env===null){this._env=new bn;for(var g=0;g0&&g.append(","),g.append(this.pts[w].x+" "+this.pts[w].y);return g.append(") "+this._label+" "+this._depthDelta),g.toString()}},{key:"isPointwiseEqual",value:function(g){if(this.pts.length!==g.pts.length)return!1;for(var w=0;ww||this._maxyV;if(X)return!1;var Q=this.intersectsToleranceSquare(c,p);return St.isTrue(!(X&&Q),"Found bad envelope test"),Q}},{key:"initCorners",value:function(c){var p=.5;this._minx=c.x-p,this._maxx=c.x+p,this._miny=c.y-p,this._maxy=c.y+p,this._corner[0]=new je(this._maxx,this._maxy),this._corner[1]=new je(this._minx,this._maxy),this._corner[2]=new je(this._minx,this._miny),this._corner[3]=new je(this._maxx,this._miny)}},{key:"intersects",value:function(c,p){return this._scaleFactor===1?this.intersectsScaled(c,p):(this.copyScaled(c,this._p0Scaled),this.copyScaled(p,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))}},{key:"scale",value:function(c){return Math.round(c*this._scaleFactor)}},{key:"getCoordinate",value:function(){return this._originalPt}},{key:"copyScaled",value:function(c,p){p.x=this.scale(c.x),p.y=this.scale(c.y)}},{key:"getSafeEnvelope",value:function(){if(this._safeEnv===null){var c=M.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new bn(this._originalPt.x-c,this._originalPt.x+c,this._originalPt.y-c,this._originalPt.y+c)}return this._safeEnv}},{key:"intersectsPixelClosure",value:function(c,p){return this._li.computeIntersection(c,p,this._corner[0],this._corner[1]),!!this._li.hasIntersection()||(this._li.computeIntersection(c,p,this._corner[1],this._corner[2]),!!this._li.hasIntersection()||(this._li.computeIntersection(c,p,this._corner[2],this._corner[3]),!!this._li.hasIntersection()||(this._li.computeIntersection(c,p,this._corner[3],this._corner[0]),!!this._li.hasIntersection())))}},{key:"intersectsToleranceSquare",value:function(c,p){var g=!1,w=!1;return this._li.computeIntersection(c,p,this._corner[0],this._corner[1]),!!this._li.isProper()||(this._li.computeIntersection(c,p,this._corner[1],this._corner[2]),!!this._li.isProper()||(this._li.hasIntersection()&&(g=!0),this._li.computeIntersection(c,p,this._corner[2],this._corner[3]),!!this._li.isProper()||(this._li.hasIntersection()&&(w=!0),this._li.computeIntersection(c,p,this._corner[3],this._corner[0]),!!this._li.isProper()||!(!g||!w)||!!c.equals(this._pt)||!!p.equals(this._pt))))}},{key:"addSnappedNode",value:function(c,p){var g=c.getCoordinate(p),w=c.getCoordinate(p+1);return!!this.intersects(g,w)&&(c.addIntersection(this.getCoordinate(),p),!0)}}],[{key:"constructor_",value:function(){this._li=null,this._pt=null,this._originalPt=null,this._ptScaled=null,this._p0Scaled=null,this._p1Scaled=null,this._scaleFactor=null,this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,this._corner=new Array(4).fill(null),this._safeEnv=null;var c=arguments[0],p=arguments[1],g=arguments[2];if(this._originalPt=c,this._pt=c,this._scaleFactor=p,this._li=g,p<=0)throw new we("Scale factor must be non-zero");p!==1&&(this._pt=new je(this.scale(c.x),this.scale(c.y)),this._p0Scaled=new je,this._p1Scaled=new je),this.initCorners(this._pt)}}]),M}();Us.SAFE_ENV_EXPANSION_FACTOR=.75;var qu=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"select",value:function(){if(arguments.length!==1){if(arguments.length===2){var c=arguments[0],p=arguments[1];c.getLineSegment(p,this.selectedSegment),this.select(this.selectedSegment)}}}}],[{key:"constructor_",value:function(){this.selectedSegment=new Lr}}]),M}(),tl=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"snap",value:function(){if(arguments.length===1){var c=arguments[0];return this.snap(c,null,-1)}if(arguments.length===3){var p=arguments[0],g=arguments[1],w=arguments[2],L=p.getSafeEnvelope(),V=new Zu(p,g,w);return this._index.query(L,new(function(){function X(){s(this,X)}return h(X,[{key:"interfaces_",get:function(){return[da]}},{key:"visitItem",value:function(Q){Q.select(L,V)}}]),X}())),V.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var c=arguments[0];this._index=c}}]),M}(),Zu=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),g=c.call(this),p.constructor_.apply(R(g),arguments),g}return h(p,[{key:"isNodeAdded",value:function(){return this._isNodeAdded}},{key:"select",value:function(){if(!(arguments.length===2&&Number.isInteger(arguments[1])&&arguments[0]instanceof ps))return Z(x(p.prototype),"select",this).apply(this,arguments);var g=arguments[0],w=arguments[1],L=g.getContext();if(this._parentEdge===L&&(w===this._hotPixelVertexIndex||w+1===this._hotPixelVertexIndex))return null;this._isNodeAdded|=this._hotPixel.addSnappedNode(L,w)}}],[{key:"constructor_",value:function(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var g=arguments[0],w=arguments[1],L=arguments[2];this._hotPixel=g,this._parentEdge=w,this._hotPixelVertexIndex=L}}]),p}(qu);tl.HotPixelSnapAction=Zu;var Zl=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"processIntersections",value:function(c,p,g,w){if(c===g&&p===w)return null;var L=c.getCoordinates()[p],V=c.getCoordinates()[p+1],X=g.getCoordinates()[w],Q=g.getCoordinates()[w+1];if(this._li.computeIntersection(L,V,X,Q),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var ae=0;ae=0;c--){try{this.bufferReducedPrecision(c)}catch(L){if(!(L instanceof vr))throw L;this._saveException=L}if(this._resultGeometry!==null)return null}throw this._saveException}if(arguments.length===1){var p=arguments[0],g=M.precisionScaleFactor(this._argGeom,this._distance,p),w=new Fi(g);this.bufferFixedPrecision(w)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),this._resultGeometry!==null)return null;var c=this._argGeom.getFactory().getPrecisionModel();c.getType()===Fi.FIXED?this.bufferFixedPrecision(c):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(c){this._bufParams.setQuadrantSegments(c)}},{key:"bufferOriginalPrecision",value:function(){try{var c=new _o(this._bufParams);this._resultGeometry=c.buffer(this._argGeom,this._distance)}catch(p){if(!(p instanceof Zt))throw p;this._saveException=p}}},{key:"getResultGeometry",value:function(c){return this._distance=c,this.computeGeometry(),this._resultGeometry}},{key:"setEndCapStyle",value:function(c){this._bufParams.setEndCapStyle(c)}}],[{key:"constructor_",value:function(){if(this._argGeom=null,this._distance=null,this._bufParams=new ce,this._resultGeometry=null,this._saveException=null,arguments.length===1){var c=arguments[0];this._argGeom=c}else if(arguments.length===2){var p=arguments[0],g=arguments[1];this._argGeom=p,this._bufParams=g}}},{key:"bufferOp",value:function(){if(arguments.length===2){var c=arguments[0],p=arguments[1],g=new M(c),w=g.getResultGeometry(p);return w}if(arguments.length===3){if(Number.isInteger(arguments[2])&&arguments[0]instanceof gt&&typeof arguments[1]=="number"){var L=arguments[0],V=arguments[1],X=arguments[2],Q=new M(L);Q.setQuadrantSegments(X);var ae=Q.getResultGeometry(V);return ae}if(arguments[2]instanceof ce&&arguments[0]instanceof gt&&typeof arguments[1]=="number"){var Le=arguments[0],Ne=arguments[1],rt=arguments[2],kt=new M(Le,rt),Ct=kt.getResultGeometry(Ne);return Ct}}else if(arguments.length===4){var Qt=arguments[0],Ht=arguments[1],dn=arguments[2],Rn=arguments[3],ui=new M(Qt);ui.setQuadrantSegments(dn),ui.setEndCapStyle(Rn);var lr=ui.getResultGeometry(Ht);return lr}}},{key:"precisionScaleFactor",value:function(c,p,g){var w=c.getEnvelopeInternal(),L=ee.max(Math.abs(w.getMaxX()),Math.abs(w.getMaxY()),Math.abs(w.getMinX()),Math.abs(w.getMinY()))+2*(p>0?p:0),V=g-Math.trunc(Math.log(L)/Math.log(10)+1);return Math.pow(10,V)}}]),M}();Mo.CAP_ROUND=ce.CAP_ROUND,Mo.CAP_BUTT=ce.CAP_FLAT,Mo.CAP_FLAT=ce.CAP_FLAT,Mo.CAP_SQUARE=ce.CAP_SQUARE,Mo.MAX_PRECISION_DIGITS=12;var $u=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],il=function(){function M(c){s(this,M),this.geometryFactory=c||new kr}return h(M,[{key:"read",value:function(c){var p,g=(p=typeof c=="string"?JSON.parse(c):c).type;if(!Hr[g])throw new Error("Unknown GeoJSON type: "+p.type);return $u.indexOf(g)!==-1?Hr[g].call(this,p.coordinates):g==="GeometryCollection"?Hr[g].call(this,p.geometries):Hr[g].call(this,p)}},{key:"write",value:function(c){var p=c.getGeometryType();if(!Kr[p])throw new Error("Geometry is not supported");return Kr[p].call(this,c)}}]),M}(),Hr={Feature:function(M){var c={};for(var p in M)c[p]=M[p];if(M.geometry){var g=M.geometry.type;if(!Hr[g])throw new Error("Unknown GeoJSON type: "+M.type);c.geometry=this.read(M.geometry)}return M.bbox&&(c.bbox=Hr.bbox.call(this,M.bbox)),c},FeatureCollection:function(M){var c={};if(M.features){c.features=[];for(var p=0;p1?0:a<-1?Qn:Math.acos(a)}function Sl(a){return a>1?Ls:a<-1?-Ls:Math.asin(a)}function zc(){}function Mf(a,i){a&&ey.hasOwnProperty(a.type)&&ey[a.type](a,i)}var Q_={Feature:function(a,i){Mf(a.geometry,i)},FeatureCollection:function(a,i){for(var s=a.features,l=-1,h=s.length;++lQn?a-Rs:a<-Qn?a+Rs:a,i]}Up.invert=Up;function fE(a,i,s){return(a%=Rs)?i||s?ny(ry(a),oy(i,s)):ry(a):i||s?oy(i,s):Up}function iy(a){return function(i,s){return i+=a,[i>Qn?i-Rs:i<-Qn?i+Rs:i,s]}}function ry(a){var i=iy(a);return i.invert=iy(-a),i}function oy(a,i){var s=Oi(a),l=Ni(a),h=Oi(i),f=Ni(i);function x(t,E){var k=Oi(E),P=Oi(t)*k,R=Ni(t)*k,F=Ni(E),U=F*s+P*l;return[Tu(R*h-U*f,P*s-F*l),Sl(U*h+R*f)]}return x.invert=function(t,E){var k=Oi(E),P=Oi(t)*k,R=Ni(t)*k,F=Ni(E),U=F*h-R*f;return[Tu(R*h+F*f,P*s+U*l),Sl(U*s-P*l)]},x}function dE(a,i,s,l,h,f){if(s){var x=Oi(i),t=Ni(i),E=l*s;h==null?(h=i+l*Rs,f=i-E/2):(h=sy(x,h),f=sy(x,f),(l>0?hf)&&(h+=l*Rs));for(var k,P=h;l>0?P>f:P1&&a.push(a.pop().concat(a.shift()))},result:function(){var s=a;return a=[],i=null,s}}}function pE(a,i,s,l,h,f){var x=a[0],t=a[1],E=i[0],k=i[1],P=0,R=1,F=E-x,U=k-t,Z;if(Z=s-x,!(!F&&Z>0)){if(Z/=F,F<0){if(Z0){if(Z>R)return;Z>P&&(P=Z)}if(Z=h-x,!(!F&&Z<0)){if(Z/=F,F<0){if(Z>R)return;Z>P&&(P=Z)}else if(F>0){if(Z0)){if(Z/=U,U<0){if(Z0){if(Z>R)return;Z>P&&(P=Z)}if(Z=f-t,!(!U&&Z<0)){if(Z/=U,U<0){if(Z>R)return;Z>P&&(P=Z)}else if(U>0){if(Z0&&(a[0]=x+P*F,a[1]=t+P*U),R<1&&(i[0]=x+R*F,i[1]=t+R*U),!0}}}}}function Af(a,i){return Tr(a[0]-i[0])=0;--t)h.point((R=P[t])[0],R[1]);else l(F.x,F.p.x,-1,h);F=F.p}F=F.o,P=F.z,U=!U}while(!F.v);h.lineEnd()}}}function uy(a){if(i=a.length){for(var i,s=0,l=a[0],h;++si?1:a>=i?0:NaN}function mE(a){return a.length===1&&(a=gE(a)),{left:function(i,s,l,h){for(l==null&&(l=0),h==null&&(h=i.length);l>>1;a(i[f],s)<0?l=f+1:h=f}return l},right:function(i,s,l,h){for(l==null&&(l=0),h==null&&(h=i.length);l>>1;a(i[f],s)>0?h=f:l=f+1}return l}}}function gE(a){return function(i,s){return cy(a(i),s)}}mE(cy);function hy(a){for(var i=a.length,s,l=-1,h=0,f,x;++l=0;)for(x=a[i],s=x.length;--s>=0;)f[--h]=x[s];return f}var Oc=1e9,Lf=-Oc;function _E(a,i,s,l){function h(k,P){return a<=k&&k<=s&&i<=P&&P<=l}function f(k,P,R,F){var U=0,Z=0;if(k==null||(U=x(k,R))!==(Z=x(P,R))||E(k,P)<0^R>0)do F.point(U===0||U===3?a:s,U>1?l:i);while((U=(U+R+4)%4)!==Z);else F.point(P[0],P[1])}function x(k,P){return Tr(k[0]-a)0?0:3:Tr(k[0]-s)0?2:1:Tr(k[1]-i)0?1:0:P>0?3:2}function t(k,P){return E(k.x,P.x)}function E(k,P){var R=x(k,1),F=x(P,1);return R!==F?R-F:R===0?P[1]-k[1]:R===1?k[0]-P[0]:R===2?k[1]-P[1]:P[0]-k[0]}return function(k){var P=k,R=ay(),F,U,Z,J,he,ye,te,ce,be,we,Ue,ze={point:Ve,lineStart:Je,lineEnd:At,polygonStart:ft,polygonEnd:lt};function Ve(Nt,Lt){h(Nt,Lt)&&P.point(Nt,Lt)}function Ie(){for(var Nt=0,Lt=0,Yt=U.length;Ltl&&(St-Zt)*(l-Vt)>(hn-Vt)*(a-Zt)&&++Nt:hn<=l&&(St-Zt)*(l-Vt)<(hn-Vt)*(a-Zt)&&--Nt;return Nt}function ft(){P=R,F=[],U=[],Ue=!0}function lt(){var Nt=Ie(),Lt=Ue&&Nt,Yt=(F=hy(F)).length;(Lt||Yt)&&(k.polygonStart(),Lt&&(k.lineStart(),f(null,null,1,k),k.lineEnd()),Yt&&ly(F,t,Nt,f,k),k.polygonEnd()),P=k,F=U=Z=null}function Je(){ze.point=ut,U&&U.push(Z=[]),we=!0,be=!1,te=ce=NaN}function At(){F&&(ut(J,he),ye&&be&&R.rejoin(),F.push(R.result())),ze.point=Ve,be&&P.lineEnd()}function ut(Nt,Lt){var Yt=h(Nt,Lt);if(U&&Z.push([Nt,Lt]),we)J=Nt,he=Lt,ye=Yt,we=!1,Yt&&(P.lineStart(),P.point(Nt,Lt));else if(Yt&&be)P.point(Nt,Lt);else{var Mt=[te=Math.max(Lf,Math.min(Oc,te)),ce=Math.max(Lf,Math.min(Oc,ce))],Gt=[Nt=Math.max(Lf,Math.min(Oc,Nt)),Lt=Math.max(Lf,Math.min(Oc,Lt))];pE(Mt,Gt,a,i,s,l)?(be||(P.lineStart(),P.point(Mt[0],Mt[1])),P.point(Gt[0],Gt[1]),Yt||P.lineEnd(),Ue=!1):Yt&&(P.lineStart(),P.point(Nt,Lt),Ue=!1)}te=Nt,ce=Lt,be=Yt}return ze}}var jp=Da();function yE(a,i){var s=i[0],l=i[1],h=[Ni(s),-Oi(s),0],f=0,x=0;jp.reset();for(var t=0,E=a.length;t=0?1:-1,Ve=ze*Ue,Ie=Ve>Qn,ft=Z*be;if(jp.add(Tu(ft*ze*Ni(Ve),J*we+ft*Oi(Ve))),f+=Ie?Ue+ze*Rs:Ue,Ie^F>=s^te>=s){var lt=kf(Mu(R),Mu(ye));Vp(lt);var Je=kf(h,lt);Vp(Je);var At=(Ie^Ue>=0?-1:1)*Sl(Je[2]);(l>At||l===At&&(lt[0]||lt[1]))&&(x+=Ie^Ue>=0?1:-1)}}return(f<-Mi||fNc&&(Nc=a),iDf&&(Df=i)}Da();function py(a,i,s,l){return function(h,f){var x=i(f),t=h.invert(l[0],l[1]),E=ay(),k=i(E),P=!1,R,F,U,Z={point:J,lineStart:ye,lineEnd:te,polygonStart:function(){Z.point=ce,Z.lineStart=be,Z.lineEnd=we,F=[],R=[]},polygonEnd:function(){Z.point=J,Z.lineStart=ye,Z.lineEnd=te,F=hy(F);var Ue=yE(R,t);F.length?(P||(f.polygonStart(),P=!0),ly(F,bE,Ue,s,f)):Ue&&(P||(f.polygonStart(),P=!0),f.lineStart(),s(null,null,1,f),f.lineEnd()),P&&(f.polygonEnd(),P=!1),F=R=null},sphere:function(){f.polygonStart(),f.lineStart(),s(null,null,1,f),f.lineEnd(),f.polygonEnd()}};function J(Ue,ze){var Ve=h(Ue,ze);a(Ue=Ve[0],ze=Ve[1])&&f.point(Ue,ze)}function he(Ue,ze){var Ve=h(Ue,ze);x.point(Ve[0],Ve[1])}function ye(){Z.point=he,x.lineStart()}function te(){Z.point=J,x.lineEnd()}function ce(Ue,ze){U.push([Ue,ze]);var Ve=h(Ue,ze);k.point(Ve[0],Ve[1])}function be(){k.lineStart(),U=[]}function we(){ce(U[0][0],U[0][1]),k.lineEnd();var Ue=k.clean(),ze=E.result(),Ve,Ie=ze.length,ft,lt,Je;if(U.pop(),R.push(U),U=null,!!Ie){if(Ue&1){if(lt=ze[0],(ft=lt.length-1)>0){for(P||(f.polygonStart(),P=!0),f.lineStart(),Ve=0;Ve1&&Ue&2&&ze.push(ze.pop().concat(ze.shift())),F.push(ze.filter(xE))}}return Z}}function xE(a){return a.length>1}function bE(a,i){return((a=a.x)[0]<0?a[1]-Ls-Mi:Ls-a[1])-((i=i.x)[0]<0?i[1]-Ls-Mi:Ls-i[1])}const my=py(function(){return!0},wE,TE,[-Qn,-Ls]);function wE(a){var i=NaN,s=NaN,l=NaN,h;return{lineStart:function(){a.lineStart(),h=1},point:function(f,x){var t=f>0?Qn:-Qn,E=Tr(f-i);Tr(E-Qn)0?Ls:-Ls),a.point(l,s),a.lineEnd(),a.lineStart(),a.point(t,s),a.point(f,s),h=0):l!==t&&E>=Qn&&(Tr(i-l)Mi?cE((Ni(i)*(f=Oi(l))*Ni(s)-Ni(l)*(h=Oi(i))*Ni(a))/(h*f*x)):(i+l)/2}function TE(a,i,s,l){var h;if(a==null)h=s*Ls,l.point(-Qn,h),l.point(0,h),l.point(Qn,h),l.point(Qn,0),l.point(Qn,-h),l.point(0,-h),l.point(-Qn,-h),l.point(-Qn,0),l.point(-Qn,h);else if(Tr(a[0]-i[0])>Mi){var f=a[0]0,h=Tr(s)>Mi;function f(P,R,F,U){dE(U,a,i,F,P,R)}function x(P,R){return Oi(P)*Oi(R)>s}function t(P){var R,F,U,Z,J;return{lineStart:function(){Z=U=!1,J=1},point:function(he,ye){var te=[he,ye],ce,be=x(he,ye),we=l?be?0:k(he,ye):be?k(he+(he<0?Qn:-Qn),ye):0;if(!R&&(Z=U=be)&&P.lineStart(),be!==U&&(ce=E(R,te),(!ce||Af(R,ce)||Af(te,ce))&&(te[0]+=Mi,te[1]+=Mi,be=x(te[0],te[1]))),be!==U)J=0,be?(P.lineStart(),ce=E(te,R),P.point(ce[0],ce[1])):(ce=E(R,te),P.point(ce[0],ce[1]),P.lineEnd()),R=ce;else if(h&&R&&l^be){var Ue;!(we&F)&&(Ue=E(te,R,!0))&&(J=0,l?(P.lineStart(),P.point(Ue[0][0],Ue[0][1]),P.point(Ue[1][0],Ue[1][1]),P.lineEnd()):(P.point(Ue[1][0],Ue[1][1]),P.lineEnd(),P.lineStart(),P.point(Ue[0][0],Ue[0][1])))}be&&(!R||!Af(R,te))&&P.point(te[0],te[1]),R=te,U=be,F=we},lineEnd:function(){U&&P.lineEnd(),R=null},clean:function(){return J|(Z&&U)<<1}}}function E(P,R,F){var U=Mu(P),Z=Mu(R),J=[1,0,0],he=kf(U,Z),ye=Sf(he,he),te=he[0],ce=ye-te*te;if(!ce)return!F&&P;var be=s*ye/ce,we=-s*te/ce,Ue=kf(J,he),ze=Cf(J,be),Ve=Cf(he,we);Fp(ze,Ve);var Ie=Ue,ft=Sf(ze,Ie),lt=Sf(Ie,Ie),Je=ft*ft-lt*(Sf(ze,ze)-1);if(!(Je<0)){var At=Iu(Je),ut=Cf(Ie,(-ft-At)/lt);if(Fp(ut,ze),ut=Bp(ut),!F)return ut;var Nt=P[0],Lt=R[0],Yt=P[1],Mt=R[1],Gt;Lt0^ut[1]<(Tr(ut[0]-Nt)Qn^(Nt<=ut[0]&&ut[0]<=Lt)){var Vt=Cf(Ie,(-ft+At)/lt);return Fp(Vt,ze),[ut,Bp(Vt)]}}}function k(P,R){var F=l?a:Qn-a,U=0;return P<-F?U|=1:P>F&&(U|=2),R<-F?U|=4:R>F&&(U|=8),U}return py(x,t,f,l?[0,-a]:[-Qn,a-Qn])}function gy(a){return function(i){var s=new Gp;for(var l in a)s[l]=a[l];return s.stream=i,s}}function Gp(){}Gp.prototype={constructor:Gp,point:function(a,i){this.stream.point(a,i)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function _y(a,i,s){var l=i[1][0]-i[0][0],h=i[1][1]-i[0][1],f=a.clipExtent&&a.clipExtent();a.scale(150).translate([0,0]),f!=null&&a.clipExtent(null),hE(s,a.stream(dy));var x=dy.result(),t=Math.min(l/(x[1][0]-x[0][0]),h/(x[1][1]-x[0][1])),E=+i[0][0]+(l-t*(x[1][0]+x[0][0]))/2,k=+i[0][1]+(h-t*(x[1][1]+x[0][1]))/2;return f!=null&&a.clipExtent(f),a.scale(t*150).translate([E,k])}function ME(a,i,s){return _y(a,[[0,0],i],s)}var yy=16,SE=Oi(30*$o);function vy(a,i){return+i?CE(a,i):kE(a)}function kE(a){return gy({point:function(i,s){i=a(i,s),this.stream.point(i[0],i[1])}})}function CE(a,i){function s(l,h,f,x,t,E,k,P,R,F,U,Z,J,he){var ye=k-l,te=P-h,ce=ye*ye+te*te;if(ce>4*i&&J--){var be=x+F,we=t+U,Ue=E+Z,ze=Iu(be*be+we*we+Ue*Ue),Ve=Sl(Ue/=ze),Ie=Tr(Tr(Ue)-1)i||Tr((ye*At+te*ut)/ce-.5)>.3||x*F+t*U+E*Z2?ut[2]%360*$o:0,Je()):[k*za,P*za,R*za]},Ie.precision=function(ut){return arguments.length?(Ue=vy(lt,we=ut*ut),At()):Iu(we)},Ie.fitExtent=function(ut,Nt){return _y(Ie,ut,Nt)},Ie.fitSize=function(ut,Nt){return ME(Ie,ut,Nt)};function Je(){U=ny(F=fE(k,P,R),i);var ut=i(t,E);return f=l-ut[0]*s,x=h+ut[1]*s,At()}function At(){return ze=Ve=null,Ie}return function(){return i=a.apply(this,arguments),Ie.invert=i.invert&&ft,Je()}}function xy(a){return function(i,s){var l=Oi(i),h=Oi(s),f=a(l*h);return[f*h*Ni(i),f*Ni(s)]}}function by(a){return function(i,s){var l=Iu(i*i+s*s),h=a(l),f=Ni(h),x=Oi(h);return[Tu(i*f,l*x),Sl(l&&s*f/l)]}}var RE=xy(function(a){return Iu(2/(1+a))});RE.invert=by(function(a){return 2*Sl(a/2)});var wy=xy(function(a){return(a=J_(a))&&a/Ni(a)});wy.invert=by(function(a){return a});function DE(){return PE(wy).scale(79.4188).clipAngle(179.999)}function Ey(a,i){return[a,i]}Ey.invert=Ey;var{BufferOp:zE,GeoJSONReader:OE,GeoJSONWriter:NE}=uE;function Bc(a,i,s){s=s||{};var l=s.units||"kilometers",h=s.steps||8;if(!a)throw new Error("geojson is required");if(typeof s!="object")throw new Error("options must be an object");if(typeof h!="number")throw new Error("steps must be an number");if(i===void 0)throw new Error("radius is required");if(h<=0)throw new Error("steps must be greater than 0");var f=[];switch(a.type){case"GeometryCollection":return Br(a,function(x){var t=zf(x,i,l,h);t&&f.push(t)}),Jt(f);case"FeatureCollection":return Bn(a,function(x){var t=zf(x,i,l,h);t&&Bn(t,function(E){E&&f.push(E)})}),Jt(f)}return zf(a,i,l,h)}function zf(a,i,s,l){var h=a.properties||{},f=a.type==="Feature"?a.geometry:a;if(f.type==="GeometryCollection"){var x=[];return Br(a,function(J){var he=zf(J,i,s,l);he&&x.push(he)}),Jt(x)}var t=BE(f),E={type:f.type,coordinates:Iy(f.coordinates,t)},k=new OE,P=k.read(E),R=Ic(mu(i,s),"meters"),F=zE.bufferOp(P,R,l),U=new NE;if(F=U.write(F),!Ty(F.coordinates)){var Z={type:F.type,coordinates:My(F.coordinates,t)};return nr(Z,h)}}function Ty(a){return Array.isArray(a[0])?Ty(a[0]):isNaN(a[0])}function Iy(a,i){return typeof a[0]!="object"?i(a):a.map(function(s){return Iy(s,i)})}function My(a,i){return typeof a[0]!="object"?i.invert(a):a.map(function(s){return My(s,i)})}function BE(a){var i=Eu(a).geometry.coordinates,s=[-i[0],-i[1]];return DE().rotate(s).scale(ur)}function qp(a,i={}){let s=0,l=0,h=0;return Br(a,function(f,x,t){let E=i.weight?t==null?void 0:t[i.weight]:void 0;if(E=E??1,!cr(E))throw new Error("weight value must be a number for feature index "+x);E=Number(E),E>0&&xi(f,function(k){s+=k[0]*E,l+=k[1]*E,h+=E})}),cn([s/h,l/h],i.properties,i)}function na(a,i={}){let s=0,l=0,h=0;return xi(a,function(f){s+=f[0],l+=f[1],h++},!0),cn([s/h,l/h],i.properties)}function FE(a,i={}){if(i=i||{},!Hn(i))throw new Error("options is invalid");var s=i.counter||10;if(!cr(s))throw new Error("counter must be a number");var l=i.weight,h=qp(a,{weight:i.weight}),f=Jt([]);Bn(a,function(t){var E;f.features.push(na(t,{properties:{weight:(E=t.properties)==null?void 0:E[l]}}))});const x={tolerance:i.tolerance,medianCandidates:[]};return Sy(h.geometry.coordinates,[0,0],f,x,s)}function Sy(a,i,s,l,h){var f=l.tolerance||.001,x=0,t=0,E=0,k=0;if(Bn(s,function(F){var U,Z=(U=F.properties)==null?void 0:U.weight,J=Z??1;if(J=Number(J),!cr(J))throw new Error("weight value must be a number");if(J>0){k+=1;var he=J*Wn(F,a);he===0&&(he=1);var ye=J/he;x+=F.geometry.coordinates[0]*ye,t+=F.geometry.coordinates[1]*ye,E+=ye}}),k<1)throw new Error("no features to measure");var P=x/E,R=t/E;return k===1||h===0||Math.abs(P-i[0])0)for(let l=(this.length>>1)-1;l>=0;l--)this._down(l)}push(i){this.data.push(i),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const i=this.data[0],s=this.data.pop();return this.length--,this.length>0&&(this.data[0]=s,this._down(0)),i}peek(){return this.data[0]}_up(i){const{data:s,compare:l}=this,h=s[i];for(;i>0;){const f=i-1>>1,x=s[f];if(l(h,x)>=0)break;s[i]=x,i=f}s[i]=h}_down(i){const{data:s,compare:l}=this,h=this.length>>1,f=s[i];for(;i=0)break;s[i]=t,i=x}s[i]=f}}function jE(a,i){return ai?1:0}const GE=Qg(Object.freeze(Object.defineProperty({__proto__:null,default:UE},Symbol.toStringTag,{value:"Module"})));var Of={exports:{}},qE=function(i,s,l,h){var f=i[0],x=i[1],t=!1;l===void 0&&(l=0),h===void 0&&(h=s.length);for(var E=(h-l)/2,k=0,P=E-1;kx!=Z>x&&f<(U-R)*(x-F)/(Z-F)+R;J&&(t=!t)}return t},ZE=function(i,s,l,h){var f=i[0],x=i[1],t=!1;l===void 0&&(l=0),h===void 0&&(h=s.length);for(var E=h-l,k=0,P=E-1;kx!=Z>x&&f<(U-R)*(x-F)/(Z-F)+R;J&&(t=!t)}return t},ky=qE,Cy=ZE;Of.exports=function(i,s,l,h){return s.length>0&&Array.isArray(s[0])?Cy(i,s,l,h):ky(i,s,l,h)},Of.exports.nested=Cy,Of.exports.flat=ky;var $E=Of.exports,$p={exports:{}};(function(a,i){(function(s,l){l(i)})(pp,function(s){const h=33306690738754706e-32;function f(J,he,ye,te,ce){let be,we,Ue,ze,Ve=he[0],Ie=te[0],ft=0,lt=0;Ie>Ve==Ie>-Ve?(be=Ve,Ve=he[++ft]):(be=Ie,Ie=te[++lt]);let Je=0;if(ftVe==Ie>-Ve?(Ue=be-((we=Ve+be)-Ve),Ve=he[++ft]):(Ue=be-((we=Ie+be)-Ie),Ie=te[++lt]),be=we,Ue!==0&&(ce[Je++]=Ue);ftVe==Ie>-Ve?(Ue=be-((we=be+Ve)-(ze=we-be))+(Ve-ze),Ve=he[++ft]):(Ue=be-((we=be+Ie)-(ze=we-be))+(Ie-ze),Ie=te[++lt]),be=we,Ue!==0&&(ce[Je++]=Ue);for(;ft0!=Ue>0)return ze;const Ve=Math.abs(we+Ue);return Math.abs(ze)>=t*Ve?ze:-function(Ie,ft,lt,Je,At,ut,Nt){let Lt,Yt,Mt,Gt,tt,Bt,Zt,Vt,St,hn,rn,Tn,je,Kn,bn,gt,Me,Fn;const Si=Ie-At,yn=lt-At,_i=ft-ut,Yi=Je-ut;tt=(bn=(Vt=Si-(Zt=(Bt=134217729*Si)-(Bt-Si)))*(hn=Yi-(St=(Bt=134217729*Yi)-(Bt-Yi)))-((Kn=Si*Yi)-Zt*St-Vt*St-Zt*hn))-(rn=bn-(Me=(Vt=_i-(Zt=(Bt=134217729*_i)-(Bt-_i)))*(hn=yn-(St=(Bt=134217729*yn)-(Bt-yn)))-((gt=_i*yn)-Zt*St-Vt*St-Zt*hn))),P[0]=bn-(rn+tt)+(tt-Me),tt=(je=Kn-((Tn=Kn+rn)-(tt=Tn-Kn))+(rn-tt))-(rn=je-gt),P[1]=je-(rn+tt)+(tt-gt),tt=(Fn=Tn+rn)-Tn,P[2]=Tn-(Fn-tt)+(rn-tt),P[3]=Fn;let Hi=function(bo,an){let lo=an[0];for(let uo=1;uo=wt||-Hi>=wt||(Lt=Ie-(Si+(tt=Ie-Si))+(tt-At),Mt=lt-(yn+(tt=lt-yn))+(tt-At),Yt=ft-(_i+(tt=ft-_i))+(tt-ut),Gt=Je-(Yi+(tt=Je-Yi))+(tt-ut),Lt===0&&Yt===0&&Mt===0&&Gt===0)||(wt=k*Nt+h*Math.abs(Hi),(Hi+=Si*Gt+Yi*Lt-(_i*Mt+yn*Yt))>=wt||-Hi>=wt))return Hi;tt=(bn=(Vt=Lt-(Zt=(Bt=134217729*Lt)-(Bt-Lt)))*(hn=Yi-(St=(Bt=134217729*Yi)-(Bt-Yi)))-((Kn=Lt*Yi)-Zt*St-Vt*St-Zt*hn))-(rn=bn-(Me=(Vt=Yt-(Zt=(Bt=134217729*Yt)-(Bt-Yt)))*(hn=yn-(St=(Bt=134217729*yn)-(Bt-yn)))-((gt=Yt*yn)-Zt*St-Vt*St-Zt*hn))),Z[0]=bn-(rn+tt)+(tt-Me),tt=(je=Kn-((Tn=Kn+rn)-(tt=Tn-Kn))+(rn-tt))-(rn=je-gt),Z[1]=je-(rn+tt)+(tt-gt),tt=(Fn=Tn+rn)-Tn,Z[2]=Tn-(Fn-tt)+(rn-tt),Z[3]=Fn;const Wo=f(4,P,4,Z,R);tt=(bn=(Vt=Si-(Zt=(Bt=134217729*Si)-(Bt-Si)))*(hn=Gt-(St=(Bt=134217729*Gt)-(Bt-Gt)))-((Kn=Si*Gt)-Zt*St-Vt*St-Zt*hn))-(rn=bn-(Me=(Vt=_i-(Zt=(Bt=134217729*_i)-(Bt-_i)))*(hn=Mt-(St=(Bt=134217729*Mt)-(Bt-Mt)))-((gt=_i*Mt)-Zt*St-Vt*St-Zt*hn))),Z[0]=bn-(rn+tt)+(tt-Me),tt=(je=Kn-((Tn=Kn+rn)-(tt=Tn-Kn))+(rn-tt))-(rn=je-gt),Z[1]=je-(rn+tt)+(tt-gt),tt=(Fn=Tn+rn)-Tn,Z[2]=Tn-(Fn-tt)+(rn-tt),Z[3]=Fn;const zo=f(Wo,R,4,Z,F);tt=(bn=(Vt=Lt-(Zt=(Bt=134217729*Lt)-(Bt-Lt)))*(hn=Gt-(St=(Bt=134217729*Gt)-(Bt-Gt)))-((Kn=Lt*Gt)-Zt*St-Vt*St-Zt*hn))-(rn=bn-(Me=(Vt=Yt-(Zt=(Bt=134217729*Yt)-(Bt-Yt)))*(hn=Mt-(St=(Bt=134217729*Mt)-(Bt-Mt)))-((gt=Yt*Mt)-Zt*St-Vt*St-Zt*hn))),Z[0]=bn-(rn+tt)+(tt-Me),tt=(je=Kn-((Tn=Kn+rn)-(tt=Tn-Kn))+(rn-tt))-(rn=je-gt),Z[1]=je-(rn+tt)+(tt-gt),tt=(Fn=Tn+rn)-Tn,Z[2]=Tn-(Fn-tt)+(rn-tt),Z[3]=Fn;const Fr=f(zo,F,4,Z,U);return U[Fr-1]}(J,he,ye,te,ce,be,Ve)},s.orient2dfast=function(J,he,ye,te,ce,be){return(he-be)*(ye-ce)-(J-ce)*(te-be)},Object.defineProperty(s,"__esModule",{value:!0})})})($p,$p.exports);var XE=$p.exports,Ay=VE,Nf=GE,WE=$E,YE=XE.orient2d;Nf.default&&(Nf=Nf.default),Zp.exports=Py,Zp.exports.default=Py;function Py(a,i,s){i=Math.max(0,i===void 0?2:i),s=s||0;var l=eT(a),h=new Ay(16);h.toBBox=function(te){return{minX:te[0],minY:te[1],maxX:te[0],maxY:te[1]}},h.compareMinX=function(te,ce){return te[0]-ce[0]},h.compareMinY=function(te,ce){return te[1]-ce[1]},h.load(a);for(var f=[],x=0,t;xf||t.push({node:P,dist:R})}for(;t.length&&!t.peek().node.children;){var F=t.pop(),U=F.node,Z=Yp(U,i,s),J=Yp(U,l,h);if(F.dist=i.minX&&a[0]<=i.maxX&&a[1]>=i.minY&&a[1]<=i.maxY}function Ry(a,i,s){for(var l=Math.min(a[0],i[0]),h=Math.min(a[1],i[1]),f=Math.max(a[0],i[0]),x=Math.max(a[1],i[1]),t=s.search({minX:l,minY:h,maxX:f,maxY:x}),E=0;E0!=ku(a,i,l)>0&&ku(s,l,a)>0!=ku(s,l,i)>0}function Xp(a){var i=a.p,s=a.next.p;return a.minX=Math.min(i[0],s[0]),a.minY=Math.min(i[1],s[1]),a.maxX=Math.max(i[0],s[0]),a.maxY=Math.max(i[1],s[1]),a}function eT(a){for(var i=a[0],s=a[0],l=a[0],h=a[0],f=0;fl[0]&&(l=x),x[1]h[1]&&(h=x)}var t=[i,s,l,h],E=t.slice();for(f=0;f1?(l=s[0],h=s[1]):t>0&&(l+=f*t,h+=x*t)}return f=a[0]-l,x=a[1]-h,f*f+x*x}function Bf(a,i,s,l,h,f,x,t){var E=s-a,k=l-i,P=x-h,R=t-f,F=a-h,U=i-f,Z=E*E+k*k,J=E*P+k*R,he=P*P+R*R,ye=E*F+k*U,te=P*F+R*U,ce=Z*he-J*J,be,we,Ue,ze,Ve=ce,Ie=ce;ce===0?(we=0,Ve=1,ze=te,Ie=he):(we=J*te-he*ye,ze=Z*te-J*ye,we<0?(we=0,ze=te,Ie=he):we>Ve&&(we=Ve,ze=te+J,Ie=he)),ze<0?(ze=0,-ye<0?we=0:-ye>Z?we=Ve:(we=-ye,Ve=Z)):ze>Ie&&(ze=Ie,-ye+J<0?we=0:-ye+J>Z?we=Ve:(we=-ye+J,Ve=Z)),be=we===0?0:we/Ve,Ue=ze===0?0:ze/Ie;var ft=(1-be)*a+be*s,lt=(1-be)*i+be*l,Je=(1-Ue)*h+Ue*x,At=(1-Ue)*f+Ue*t,ut=Je-ft,Nt=At-lt;return ut*ut+Nt*Nt}function tT(a,i){return a[0]===i[0]?a[1]-i[1]:a[0]-i[0]}function nT(a){a.sort(tT);for(var i=[],s=0;s=2&&ku(i[i.length-2],i[i.length-1],a[s])<=0;)i.pop();i.push(a[s])}for(var l=[],h=a.length-1;h>=0;h--){for(;l.length>=2&&ku(l[l.length-2],l[l.length-1],a[h])<=0;)l.pop();l.push(a[h])}return l.pop(),i.pop(),i.concat(l)}var iT=Zp.exports;const rT=pu(iT);function zy(a,i={}){i.concavity=i.concavity||1/0;const s=[];if(xi(a,h=>{s.push([h[0],h[1]])}),!s.length)return null;const l=rT(s,i.concavity);return l.length>3?Mn([l]):null}function Oy(a,i={}){switch(vo(a)){case"Point":return cn(Jn(a),i.properties);case"Polygon":var s=[];xi(a,function(be){s.push(be)});var l=na(a,{properties:i.properties}),h=l.geometry.coordinates,f=0,x=0,t=0,E,k,P,R,F,U,Z,J,he=s.map(function(be){return[be[0]-h[0],be[1]-h[1]]});for(E=0;E{switch(s){case"type":case"properties":case"geometry":return;default:i[s]=a[s]}}),i.properties=Ff(a.properties),a.geometry==null?i.geometry=null:i.geometry=Hp(a.geometry),i}function Ff(a){const i={};return a&&Object.keys(a).forEach(s=>{const l=a[s];typeof l=="object"?l===null?i[s]=null:Array.isArray(l)?i[s]=l.map(h=>h):i[s]=Ff(l):i[s]=l}),i}function oT(a){const i={type:"FeatureCollection"};return Object.keys(a).forEach(s=>{switch(s){case"type":case"features":return;default:i[s]=a[s]}}),i.features=a.features.map(s=>Ny(s)),i}function Hp(a){const i={type:a.type};return a.bbox&&(i.bbox=a.bbox),a.type==="GeometryCollection"?(i.geometries=a.geometries.map(s=>Hp(s)),i):(i.coordinates=By(a.coordinates),i)}function By(a){const i=a;return typeof i[0]!="object"?i.slice():i.map(s=>By(s))}function Fy(a,i){if(!a)throw new Error("geojson is required");if(a.type!=="FeatureCollection")throw new Error("geojson must be a FeatureCollection");if(i==null)throw new Error("filter is required");var s=[];return Bn(a,function(l){Vf(l.properties,i)&&s.push(l)}),Jt(s)}function Kp(a,i,s){if(!a)throw new Error("geojson is required");if(a.type!=="FeatureCollection")throw new Error("geojson must be a FeatureCollection");if(i==null)throw new Error("property is required");for(var l=Jp(a,i),h=Object.keys(l),f=0;f!1),t=a.features.map(U=>!1),E=a.features.map(U=>!1),k=a.features.map(U=>-1);f.load(a.features.map((U,Z)=>{var[J,he]=U.geometry.coordinates;return{minX:J,minY:he,maxX:J,maxY:he,index:Z}}));const P=U=>{const Z=a.features[U],[J,he]=Z.geometry.coordinates,ye=Math.max(he-h,-90),te=Math.min(he+h,90),ce=function(){return ye<0&&te>0?h:Math.abs(ye){const Ve=ze.index,Ie=a.features[Ve];return Wn(Z,Ie,{units:"kilometers"})<=i})},R=(U,Z)=>{for(var J=0;J=l&&Z.push(...te)}t[ye]||(t[ye]=!0,k[ye]=U)}};var F=0;return a.features.forEach((U,Z)=>{if(x[Z])return;const J=P(Z);if(J.length>=l){const he=F;F++,x[Z]=!0,R(he,J)}else E[Z]=!0}),a.features.forEach((U,Z)=>{var J=a.features[Z];J.properties||(J.properties={}),k[Z]>=0?(J.properties.dbscan=E[Z]?"edge":"core",J.properties.cluster=k[Z]):J.properties.dbscan="noise"}),a}var jy={eudist:function(i,s,l){for(var h=i.length,f=0,x=0;x0;h.length0;){var E=i[Math.floor(Math.random()*x)],k=t?E.join("_"):""+E;l[k]||(l[k]=!0,h.push(E))}if(h.length0,t=i[Math.floor(Math.random()*f)];for(x?t.join("_"):""+t,h.push(t);h.length0,U=[];if(s)s=="kmrand"?h=dT(a,i):s=="kmpp"?h=pT(a,i):h=s;else for(var Z={};h.lengths&&(i.numberOfClusters=s),i.mutate!==!0&&(a=yr(a));var l=Sc(a),h=l.slice(0,i.numberOfClusters),f=_T(l,i.numberOfClusters,h),x={};return f.centroids.forEach(function(t,E){x[E]=t}),Bn(a,function(t,E){var k=f.idxs[E];t.properties.cluster=k,t.properties.centroid=x[k]}),a}var vT=so;function xT(a,i,s,l){var h=new vT(6),f=i.features.map(function(x){var t;return{minX:x.geometry.coordinates[0],minY:x.geometry.coordinates[1],maxX:x.geometry.coordinates[0],maxY:x.geometry.coordinates[1],property:(t=x.properties)==null?void 0:t[s]}});return h.load(f),a.features.forEach(function(x){x.properties||(x.properties={});var t=pi(x),E=h.search({minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}),k=[];E.forEach(function(P){Pn([P.minX,P.minY],x)&&k.push(P.property)}),x.properties[l]=k}),a}function bT(a){var i={MultiPoint:{coordinates:[],properties:[]},MultiLineString:{coordinates:[],properties:[]},MultiPolygon:{coordinates:[],properties:[]}};return Bn(a,s=>{var l;switch((l=s.geometry)==null?void 0:l.type){case"Point":i.MultiPoint.coordinates.push(s.geometry.coordinates),i.MultiPoint.properties.push(s.properties);break;case"MultiPoint":i.MultiPoint.coordinates.push(...s.geometry.coordinates),i.MultiPoint.properties.push(s.properties);break;case"LineString":i.MultiLineString.coordinates.push(s.geometry.coordinates),i.MultiLineString.properties.push(s.properties);break;case"MultiLineString":i.MultiLineString.coordinates.push(...s.geometry.coordinates),i.MultiLineString.properties.push(s.properties);break;case"Polygon":i.MultiPolygon.coordinates.push(s.geometry.coordinates),i.MultiPolygon.properties.push(s.properties);break;case"MultiPolygon":i.MultiPolygon.coordinates.push(...s.geometry.coordinates),i.MultiPolygon.properties.push(s.properties);break}}),Jt(Object.keys(i).filter(function(s){return i[s].coordinates.length}).sort().map(function(s){var l={type:s,coordinates:i[s].coordinates},h={collectedProperties:i[s].properties};return nr(l,h)}))}function Xy(a,i){let s=!1;return Jt(TT(a.features.map(l=>{const h={x:l.geometry.coordinates[0],y:l.geometry.coordinates[1]};return i?h.z=l.properties[i]:l.geometry.coordinates.length===3&&(s=!0,h.z=l.geometry.coordinates[2]),h})).map(l=>{const h=[l.a.x,l.a.y],f=[l.b.x,l.b.y],x=[l.c.x,l.c.y];let t={};return s?(h.push(l.a.z),f.push(l.b.z),x.push(l.c.z)):t={a:l.a.z,b:l.b.z,c:l.c.z},Mn([[h,f,x,h]],t)}))}var Wy=class{constructor(a,i,s){this.a=a,this.b=i,this.c=s;const l=i.x-a.x,h=i.y-a.y,f=s.x-a.x,x=s.y-a.y,t=l*(a.x+i.x)+h*(a.y+i.y),E=f*(a.x+s.x)+x*(a.y+s.y),k=2*(l*(s.y-i.y)-h*(s.x-i.x));let P,R;this.x=(x*t-h*E)/k,this.y=(l*E-f*t)/k,P=this.x-a.x,R=this.y-a.y,this.r=P*P+R*R}};function wT(a,i){return i.x-a.x}function ET(a){let i=a.length,s,l,h,f,x;e:for(;i;)for(l=a[--i],s=a[--i],h=i;h;)if(x=a[--h],f=a[--h],s===f&&l===x||s===x&&l===f){a.splice(i,2),a.splice(h,2),i-=2;continue e}}function TT(a){if(a.length<3)return[];a.sort(wT);let i=a.length-1;const s=a[i].x,l=a[0].x;let h=a[i].y,f=h;const x=1e-12;let t,E,k,P,R,F;for(;i--;)a[i].yf&&(f=a[i].y);let U=l-s,Z=f-h;const J=U>Z?U:Z,he=(l+s)*.5,ye=(f+h)*.5,te=[new Wy({__sentinel:!0,x:he-20*J,y:ye-J},{__sentinel:!0,x:he,y:ye+20*J},{__sentinel:!0,x:he+20*J,y:ye-J})],ce=[],be=[];let we;for(i=a.length;i--;){for(be.length=0,we=te.length;we--;){if(U=a[i].x-te[we].x,U>0&&U*U>te[we].r){ce.push(te[we]),te.splice(we,1);continue}Z=a[i].y-te[we].y,!(U*U+Z*Z>te[we].r)&&(be.push(te[we].a,te[we].b,te[we].b,te[we].c,te[we].c,te[we].a),te.splice(we,1))}for(ET(be),we=be.length;we;)E=be[--we],t=be[--we],k=a[i],P=E.x-t.x,R=E.y-t.y,F=2*(P*(k.y-E.y)-R*(k.x-E.x)),Math.abs(F)>x&&te.push(new Wy(t,E,k))}for(Array.prototype.push.apply(ce,te),i=ce.length;i--;)(ce[i].a.__sentinel||ce[i].b.__sentinel||ce[i].c.__sentinel)&&ce.splice(i,1);return ce}function IT(a){return a}function MT(a){if(a==null)return IT;var i,s,l=a.scale[0],h=a.scale[1],f=a.translate[0],x=a.translate[1];return function(t,E){E||(i=s=0);var k=2,P=t.length,R=new Array(P);for(R[0]=(i+=t[0])*l+f,R[1]=(s+=t[1])*h+x;k1)for(var R=1,F=t(k[0]),U,Z;RF&&(Z=k[0],k[0]=k[R],k[R]=Z,F=U);return k}).filter(function(E){return E.length>0})}}var tm=Object.prototype.hasOwnProperty;function LT(a){var i=1/0,s=1/0,l=-1/0,h=-1/0;function f(R){R!=null&&tm.call(x,R.type)&&x[R.type](R)}var x={GeometryCollection:function(R){R.geometries.forEach(f)},Point:function(R){t(R.coordinates)},MultiPoint:function(R){R.coordinates.forEach(t)},LineString:function(R){E(R.arcs)},MultiLineString:function(R){R.arcs.forEach(E)},Polygon:function(R){R.arcs.forEach(E)},MultiPolygon:function(R){R.arcs.forEach(k)}};function t(R){var F=R[0],U=R[1];Fl&&(l=F),Uh&&(h=U)}function E(R){R.forEach(t)}function k(R){R.forEach(E)}for(var P in a)f(a[P]);return l>=i&&h>=s?[i,s,l,h]:void 0}function RT(a,i,s,l,h){arguments.length===3&&(l=Array,h=null);for(var f=new l(a=1<=a)throw new Error("full hashset");U=f[F=F+1&x]}return f[F]=R,!0}function k(R){for(var F=i(R)&x,U=f[F],Z=0;U!=h;){if(s(U,R))return!0;if(++Z>=a)break;U=f[F=F+1&x]}return!1}function P(){for(var R=[],F=0,U=f.length;F=a)throw new Error("full hashmap");ye=x[he=he+1&E]}return x[he]=Z,t[he]=J,J}function R(Z,J){for(var he=i(Z)&E,ye=x[he],te=0;ye!=h;){if(s(ye,Z))return t[he];if(++te>=a)throw new Error("full hashmap");ye=x[he=he+1&E]}return x[he]=Z,t[he]=J,J}function F(Z,J){for(var he=i(Z)&E,ye=x[he],te=0;ye!=h;){if(s(ye,Z))return t[he];if(++te>=a)break;ye=x[he=he+1&E]}return J}function U(){for(var Z=[],J=0,he=x.length;J>7^Uf[2]^Uf[3],i&2147483647}function DT(a){var i=a.coordinates,s=a.lines,l=a.rings,h=Ue(),f=new Int32Array(i.length),x=new Int32Array(i.length),t=new Int32Array(i.length),E=new Int8Array(i.length),k=0,P,R,F,U,Z;for(P=0,R=i.length;P=0){var Lt=t[At];(Nt!==Je||Lt!==ut)&&(Nt!==ut||Lt!==Je)&&(++k,E[At]=1)}else x[At]=Je,t[At]=ut}}function Ue(){for(var lt=nm(i.length*1.4,ze,Ve,Int32Array,-1,Int32Array),Je=new Int32Array(i.length),At=0,ut=i.length;At>1),h;i{const t=$T(f,x);return t||(l.push(f),x)});return h&&l.push(h),l.length?l.length===1?l[0]:Pa(l.map(f=>f.coordinates)):null}function jf(a){return a[0].toString()+","+a[1].toString()}function $T(a,i){const s=a.geometry.coordinates,l=i.geometry.coordinates,h=jf(s[0]),f=jf(s[s.length-1]),x=jf(l[0]),t=jf(l[l.length-1]);let E;if(h===t)E=l.concat(s.slice(1));else if(x===f)E=s.concat(l.slice(1));else if(h===x)E=s.slice(1).reverse().concat(l);else if(f===t)E=s.concat(l.reverse().slice(1));else return null;return Zn(E)}function XT(a,i={}){if(vo(a)!=="FeatureCollection")throw new Error("geojson must be a FeatureCollection");if(!a.features.length)throw new Error("geojson is empty");(i.mutate===!1||i.mutate===void 0)&&(a=yr(a));const s=[];Wi(a,f=>{s.push(f.geometry)});const l=jT({geoms:gp(s).geometry});return AT(l,l.objects.geoms.geometries)}function WT(a,i={}){if(i=i||{},!Hn(i))throw new Error("options is invalid");const s=i.mutate;if(vo(a)!=="FeatureCollection")throw new Error("geojson must be a FeatureCollection");if(!a.features.length)throw new Error("geojson is empty");(s===!1||s===void 0)&&(a=yr(a));const l=YT(a);if(!l)throw new Error("geojson must be homogenous");const h=a;switch(l){case"LineString":return ZT(h,i);case"Polygon":return XT(h,i);default:throw new Error(l+" is not supported")}}function YT(a){const i={};Wi(a,l=>{i[l.geometry.type]=!0});const s=Object.keys(i);return s.length===1?s[0]:null}function HT(a,i={}){const s=i.maxEdge||1/0,l=KT(a),h=Xy(l);if(h.features=h.features.filter(x=>{const t=x.geometry.coordinates[0][0],E=x.geometry.coordinates[0][1],k=x.geometry.coordinates[0][2],P=Wn(t,E,i),R=Wn(E,k,i),F=Wn(t,k,i);return P<=s&&R<=s&&F<=s}),h.features.length<1)return null;const f=WT(h);return f.coordinates.length===1&&(f.coordinates=f.coordinates[0],f.type="Polygon"),nr(f)}function KT(a){const i=[],s={};return Bn(a,l=>{if(!l.geometry)return;const h=l.geometry.coordinates.join("-");Object.prototype.hasOwnProperty.call(s,h)||(i.push(l),s[h]=!0)}),Jt(i)}/** * splaytree v3.1.2 * Fast Splay tree for Node and browser * * @author Alexander Milevski * @license MIT * @preserve *//*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function JT(a,i){var s={label:0,sent:function(){if(f[0]&1)throw f[1];return f[1]},trys:[],ops:[]},l,h,f,x;return x={next:t(0),throw:t(1),return:t(2)},typeof Symbol=="function"&&(x[Symbol.iterator]=function(){return this}),x;function t(k){return function(P){return E([k,P])}}function E(k){if(l)throw new TypeError("Generator is already executing.");for(;s;)try{if(l=1,h&&(f=k[0]&2?h.return:k[0]?h.throw||((f=h.return)&&f.call(h),0):h.next)&&!(f=f.call(h,k[1])).done)return f;switch(h=0,f&&(k=[k[0]&2,f.value]),k[0]){case 0:case 1:f=k;break;case 4:return s.label++,{value:k[1],done:!1};case 5:s.label++,h=k[1],k=[0];continue;case 7:k=s.ops.pop(),s.trys.pop();continue;default:if(f=s.trys,!(f=f.length>0&&f[f.length-1])&&(k[0]===6||k[0]===2)){s=0;continue}if(k[0]===3&&(!f||k[1]>f[0]&&k[1]i?1:a0){if(i.right===null)break;if(s(a,i.right.key)>0){var t=i.right;if(i.right=t.left,t.left=i,i=t,i.right===null)break}h.right=i,h=i,i=i.right}else break}return h.right=i.left,f.left=i.right,i.left=l.right,i.right=l.left,i}function sm(a,i,s,l){var h=new Oa(a,i);if(s===null)return h.left=h.right=null,h;s=Na(a,s,l);var f=l(a,s.key);return f<0?(h.left=s.left,h.right=s,s.left=null):f>=0&&(h.right=s.right,h.left=s,s.right=null),h}function Qy(a,i,s){var l=null,h=null;if(i){i=Na(a,i,s);var f=s(i.key,a);f===0?(l=i.left,h=i.right):f<0?(h=i.right,i.right=null,l=i):(l=i.left,i.left=null,h=i)}return{left:l,right:h}}function e2(a,i,s){return i===null?a:(a===null||(i=Na(a.key,i,s),i.left=a),i)}function am(a,i,s,l,h){if(a){l(""+i+(s?"└── ":"├── ")+h(a)+` `);var f=i+(s?" ":"│ ");a.left&&am(a.left,f,!1,l,h),a.right&&am(a.right,f,!0,l,h)}}var lm=function(){function a(i){i===void 0&&(i=QT),this._root=null,this._size=0,this._comparator=i}return a.prototype.insert=function(i,s){return this._size++,this._root=sm(i,s,this._root,this._comparator)},a.prototype.add=function(i,s){var l=new Oa(i,s);this._root===null&&(l.left=l.right=null,this._size++,this._root=l);var h=this._comparator,f=Na(i,this._root,h),x=h(i,f.key);return x===0?this._root=f:(x<0?(l.left=f.left,l.right=f,f.left=null):x>0&&(l.right=f.right,l.left=f,f.right=null),this._size++,this._root=l),this._root},a.prototype.remove=function(i){this._root=this._remove(i,this._root,this._comparator)},a.prototype._remove=function(i,s,l){var h;if(s===null)return null;s=Na(i,s,l);var f=l(i,s.key);return f===0?(s.left===null?h=s.right:(h=Na(i,s.left,l),h.right=s.right),this._size--,h):s},a.prototype.pop=function(){var i=this._root;if(i){for(;i.left;)i=i.left;return this._root=Na(i.key,this._root,this._comparator),this._root=this._remove(i.key,this._root,this._comparator),{key:i.key,data:i.data}}return null},a.prototype.findStatic=function(i){for(var s=this._root,l=this._comparator;s;){var h=l(i,s.key);if(h===0)return s;h<0?s=s.left:s=s.right}return null},a.prototype.find=function(i){return this._root&&(this._root=Na(i,this._root,this._comparator),this._comparator(i,this._root.key)!==0)?null:this._root},a.prototype.contains=function(i){for(var s=this._root,l=this._comparator;s;){var h=l(i,s.key);if(h===0)return!0;h<0?s=s.left:s=s.right}return!1},a.prototype.forEach=function(i,s){for(var l=this._root,h=[],f=!1;!f;)l!==null?(h.push(l),l=l.left):h.length!==0?(l=h.pop(),i.call(s,l),l=l.right):f=!0;return this},a.prototype.range=function(i,s,l,h){for(var f=[],x=this._comparator,t=this._root,E;f.length!==0||t;)if(t)f.push(t),t=t.left;else{if(t=f.pop(),E=x(t.key,s),E>0)break;if(x(t.key,i)>=0&&l.call(h,t))return this;t=t.right}return this},a.prototype.keys=function(){var i=[];return this.forEach(function(s){var l=s.key;return i.push(l)}),i},a.prototype.values=function(){var i=[];return this.forEach(function(s){var l=s.data;return i.push(l)}),i},a.prototype.min=function(){return this._root?this.minNode(this._root).key:null},a.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},a.prototype.minNode=function(i){if(i===void 0&&(i=this._root),i)for(;i.left;)i=i.left;return i},a.prototype.maxNode=function(i){if(i===void 0&&(i=this._root),i)for(;i.right;)i=i.right;return i},a.prototype.at=function(i){for(var s=this._root,l=!1,h=0,f=[];!l;)if(s)f.push(s),s=s.left;else if(f.length>0){if(s=f.pop(),h===i)return s;h++,s=s.right}else l=!0;return null},a.prototype.next=function(i){var s=this._root,l=null;if(i.right){for(l=i.right;l.left;)l=l.left;return l}for(var h=this._comparator;s;){var f=h(i.key,s.key);if(f===0)break;f<0?(l=s,s=s.left):s=s.right}return l},a.prototype.prev=function(i){var s=this._root,l=null;if(i.left!==null){for(l=i.left;l.right;)l=l.right;return l}for(var h=this._comparator;s;){var f=h(i.key,s.key);if(f===0)break;f<0?s=s.left:(l=s,s=s.right)}return l},a.prototype.clear=function(){return this._root=null,this._size=0,this},a.prototype.toList=function(){return n2(this._root)},a.prototype.load=function(i,s,l){s===void 0&&(s=[]),l===void 0&&(l=!1);var h=i.length,f=this._comparator;if(l&&hm(i,s,0,h-1,f),this._root===null)this._root=um(i,s,0,h),this._size=h;else{var x=i2(this.toList(),t2(i,s),f);h=this._size+h,this._root=cm({head:x},0,h)}return this},a.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(a.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),a.prototype.toString=function(i){i===void 0&&(i=function(l){return String(l.key)});var s=[];return am(this._root,"",!0,function(l){return s.push(l)},i),s.join("")},a.prototype.update=function(i,s,l){var h=this._comparator,f=Qy(i,this._root,h),x=f.left,t=f.right;h(i,s)<0?t=sm(s,l,t,h):x=sm(s,l,x,h),this._root=e2(x,t,h)},a.prototype.split=function(i){return Qy(i,this._root,this._comparator)},a.prototype[Symbol.iterator]=function(){var i,s,l;return JT(this,function(h){switch(h.label){case 0:i=this._root,s=[],l=!1,h.label=1;case 1:return l?[3,6]:i===null?[3,2]:(s.push(i),i=i.left,[3,5]);case 2:return s.length===0?[3,4]:(i=s.pop(),[4,i]);case 3:return h.sent(),i=i.right,[3,5];case 4:l=!0,h.label=5;case 5:return[3,1];case 6:return[2]}})},a}();function um(a,i,s,l){var h=l-s;if(h>0){var f=s+Math.floor(h/2),x=a[f],t=i[f],E=new Oa(x,t);return E.left=um(a,i,s,f),E.right=um(a,i,f+1,l),E}return null}function t2(a,i){for(var s=new Oa(null,null),l=s,h=0;h0?(i=f=f.next=s.pop(),i=i.right):l=!0;return f.next=null,h.next}function cm(a,i,s){var l=s-i;if(l>0){var h=i+Math.floor(l/2),f=cm(a,i,h),x=a.head;return x.left=f,a.head=a.head.next,x.right=cm(a,h+1,s),x}return null}function i2(a,i,s){for(var l=new Oa(null,null),h=l,f=a,x=i;f!==null&&x!==null;)s(f.key,x.key)<0?(h.next=f,f=f.next):(h.next=x,x=x.next),h=h.next;return f!==null?h.next=f:x!==null&&(h.next=x),l.next}function hm(a,i,s,l,h){if(!(s>=l)){for(var f=a[s+l>>1],x=s-1,t=l+1;;){do x++;while(h(a[x],f)<0);do t--;while(h(a[t],f)>0);if(x>=t)break;var E=a[x];a[x]=a[t],a[t]=E,E=i[x],i[x]=i[t],i[t]=E}hm(a,i,s,t,h),hm(a,i,t+1,l,h)}}const ia=11102230246251565e-32,qr=134217729,r2=(3+8*ia)*ia;function fm(a,i,s,l,h){let f,x,t,E,k=i[0],P=l[0],R=0,F=0;P>k==P>-k?(f=k,k=i[++R]):(f=P,P=l[++F]);let U=0;if(Rk==P>-k?(x=k+f,t=f-(x-k),k=i[++R]):(x=P+f,t=f-(x-P),P=l[++F]),f=x,t!==0&&(h[U++]=t);Rk==P>-k?(x=f+k,E=x-f,t=f-(x-E)+(k-E),k=i[++R]):(x=f+P,E=x-f,t=f-(x-E)+(P-E),P=l[++F]),f=x,t!==0&&(h[U++]=t);for(;R=ut||-At>=ut||(R=a-Ie,t=a-(Ie+R)+(R-h),R=s-ft,k=s-(ft+R)+(R-h),R=i-lt,E=i-(lt+R)+(R-f),R=l-Je,P=l-(Je+R)+(R-f),t===0&&E===0&&k===0&&P===0)||(ut=l2*x+r2*Math.abs(At),At+=Ie*P+Je*t-(lt*k+ft*E),At>=ut||-At>=ut))return At;be=t*Je,F=qr*t,U=F-(F-t),Z=t-U,F=qr*Je,J=F-(F-Je),he=Je-J,we=Z*he-(be-U*J-Z*J-U*he),Ue=E*ft,F=qr*E,U=F-(F-E),Z=E-U,F=qr*ft,J=F-(F-ft),he=ft-J,ze=Z*he-(Ue-U*J-Z*J-U*he),ye=we-ze,R=we-ye,ao[0]=we-(ye+R)+(R-ze),te=be+ye,R=te-be,ce=be-(te-R)+(ye-R),ye=ce-Ue,R=ce-ye,ao[1]=ce-(ye+R)+(R-Ue),Ve=te+ye,R=Ve-te,ao[2]=te-(Ve-R)+(ye-R),ao[3]=Ve;const Nt=fm(4,Cu,4,ao,e0);be=Ie*P,F=qr*Ie,U=F-(F-Ie),Z=Ie-U,F=qr*P,J=F-(F-P),he=P-J,we=Z*he-(be-U*J-Z*J-U*he),Ue=lt*k,F=qr*lt,U=F-(F-lt),Z=lt-U,F=qr*k,J=F-(F-k),he=k-J,ze=Z*he-(Ue-U*J-Z*J-U*he),ye=we-ze,R=we-ye,ao[0]=we-(ye+R)+(R-ze),te=be+ye,R=te-be,ce=be-(te-R)+(ye-R),ye=ce-Ue,R=ce-ye,ao[1]=ce-(ye+R)+(R-Ue),Ve=te+ye,R=Ve-te,ao[2]=te-(Ve-R)+(ye-R),ao[3]=Ve;const Lt=fm(Nt,e0,4,ao,t0);be=t*P,F=qr*t,U=F-(F-t),Z=t-U,F=qr*P,J=F-(F-P),he=P-J,we=Z*he-(be-U*J-Z*J-U*he),Ue=E*k,F=qr*E,U=F-(F-E),Z=E-U,F=qr*k,J=F-(F-k),he=k-J,ze=Z*he-(Ue-U*J-Z*J-U*he),ye=we-ze,R=we-ye,ao[0]=we-(ye+R)+(R-ze),te=be+ye,R=te-be,ce=be-(te-R)+(ye-R),ye=ce-Ue,R=ce-ye,ao[1]=ce-(ye+R)+(R-Ue),Ve=te+ye,R=Ve-te,ao[2]=te-(Ve-R)+(ye-R),ao[3]=Ve;const Yt=fm(Lt,t0,4,ao,n0);return n0[Yt-1]}function c2(a,i,s,l,h,f){const x=(i-f)*(s-h),t=(a-h)*(l-f),E=x-t,k=Math.abs(x+t);return Math.abs(E)>=s2*k?E:-u2(a,i,s,l,h,f,k)}const Uc=(a,i)=>a.ll.x<=i.x&&i.x<=a.ur.x&&a.ll.y<=i.y&&i.y<=a.ur.y,dm=(a,i)=>{if(i.ur.x{if(-Baa.x*i.y-a.y*i.x,o0=(a,i)=>a.x*i.x+a.y*i.y,s0=(a,i,s)=>{const l=c2(a.x,a.y,i.x,i.y,s.x,s.y);return l>0?-1:l<0?1:0},qf=a=>Math.sqrt(o0(a,a)),d2=(a,i,s)=>{const l={x:i.x-a.x,y:i.y-a.y},h={x:s.x-a.x,y:s.y-a.y};return Gf(h,l)/qf(h)/qf(l)},p2=(a,i,s)=>{const l={x:i.x-a.x,y:i.y-a.y},h={x:s.x-a.x,y:s.y-a.y};return o0(h,l)/qf(h)/qf(l)},a0=(a,i,s)=>i.y===0?null:{x:a.x+i.x/i.y*(s-a.y),y:s},l0=(a,i,s)=>i.x===0?null:{x:s,y:a.y+i.y/i.x*(s-a.x)},m2=(a,i,s,l)=>{if(i.x===0)return l0(s,l,a.x);if(l.x===0)return l0(a,i,s.x);if(i.y===0)return a0(s,l,a.y);if(l.y===0)return a0(a,i,s.y);const h=Gf(i,l);if(h==0)return null;const f={x:s.x-a.x,y:s.y-a.y},x=Gf(f,i)/h,t=Gf(f,l)/h,E=a.x+t*i.x,k=s.x+x*l.x,P=a.y+t*i.y,R=s.y+x*l.y,F=(E+k)/2,U=(P+R)/2;return{x:F,y:U}};class Xo{static compare(i,s){const l=Xo.comparePoints(i.point,s.point);return l!==0?l:(i.point!==s.point&&i.link(s),i.isLeft!==s.isLeft?i.isLeft?1:-1:Fa.compare(i.segment,s.segment))}static comparePoints(i,s){return i.xs.x?1:i.ys.y?1:0}constructor(i,s){i.events===void 0?i.events=[this]:i.events.push(this),this.point=i,this.isLeft=s}link(i){if(i.point===this.point)throw new Error("Tried to link already linked events");const s=i.point.events;for(let l=0,h=s.length;l{const f=h.otherSE;s.set(h,{sine:d2(this.point,i.point,f.point),cosine:p2(this.point,i.point,f.point)})};return(h,f)=>{s.has(h)||l(h),s.has(f)||l(f);const{sine:x,cosine:t}=s.get(h),{sine:E,cosine:k}=s.get(f);return x>=0&&E>=0?tk?-1:0:x<0&&E<0?tk?1:0:Ex?1:0}}}let g2=0;class Fa{static compare(i,s){const l=i.leftSE.point.x,h=s.leftSE.point.x,f=i.rightSE.point.x,x=s.rightSE.point.x;if(xt&&E>k)return-1;const R=i.comparePoint(s.leftSE.point);if(R<0)return 1;if(R>0)return-1;const F=s.comparePoint(i.rightSE.point);return F!==0?F:-1}if(l>h){if(tE&&t>P)return 1;const R=s.comparePoint(i.leftSE.point);if(R!==0)return R;const F=i.comparePoint(s.rightSE.point);return F<0?1:F>0?-1:1}if(tE)return 1;if(fx){const R=i.comparePoint(s.rightSE.point);if(R<0)return 1;if(R>0)return-1}if(f!==x){const R=k-t,F=f-l,U=P-E,Z=x-h;if(R>F&&UZ)return-1}return f>x?1:fP?1:i.ids.id?1:0}constructor(i,s,l,h){this.id=++g2,this.leftSE=i,i.segment=this,i.otherSE=s,this.rightSE=s,s.segment=this,s.otherSE=i,this.rings=l,this.windings=h}static fromRing(i,s,l){let h,f,x;const t=Xo.comparePoints(i,s);if(t<0)h=i,f=s,x=1;else if(t>0)h=s,f=i,x=-1;else throw new Error(`Tried to create degenerate segment at [${i.x}, ${i.y}]`);const E=new Xo(h,!0),k=new Xo(f,!1);return new Fa(E,k,[l],[x])}replaceRightSE(i){this.rightSE=i,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const i=this.leftSE.point.y,s=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:is?i:s}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(i){return i.x===this.leftSE.point.x&&i.y===this.leftSE.point.y||i.x===this.rightSE.point.x&&i.y===this.rightSE.point.y}comparePoint(i){if(this.isAnEndpoint(i))return 0;const s=this.leftSE.point,l=this.rightSE.point,h=this.vector();if(s.x===l.x)return i.x===s.x?0:i.x0&&t.swapEvents(),Xo.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),l&&(h.checkForConsuming(),f.checkForConsuming()),s}swapEvents(){const i=this.rightSE;this.rightSE=this.leftSE,this.leftSE=i,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let s=0,l=this.windings.length;s0){const f=s;s=l,l=f}if(s.prev===l){const f=s;s=l,l=f}for(let f=0,x=l.rings.length;fh.length===1&&h[0].isSubject;this._isInResult=l(i)!==l(s);break}default:throw new Error(`Unrecognized operation type found ${ss.type}`)}return this._isInResult}}class u0{constructor(i,s,l){if(!Array.isArray(i)||i.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=s,this.isExterior=l,this.segments=[],typeof i[0][0]!="number"||typeof i[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const h=jc.round(i[0][0],i[0][1]);this.bbox={ll:{x:h.x,y:h.y},ur:{x:h.x,y:h.y}};let f=h;for(let x=1,t=i.length;xthis.bbox.ur.x&&(this.bbox.ur.x=E.x),E.y>this.bbox.ur.y&&(this.bbox.ur.y=E.y),f=E)}(h.x!==f.x||h.y!==f.y)&&this.segments.push(Fa.fromRing(f,h,this))}getSweepEvents(){const i=[];for(let s=0,l=this.segments.length;sthis.bbox.ur.x&&(this.bbox.ur.x=f.bbox.ur.x),f.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=f.bbox.ur.y),this.interiorRings.push(f)}this.multiPoly=s}getSweepEvents(){const i=this.exteriorRing.getSweepEvents();for(let s=0,l=this.interiorRings.length;sthis.bbox.ur.x&&(this.bbox.ur.x=f.bbox.ur.x),f.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=f.bbox.ur.y),this.polys.push(f)}this.isSubject=s}getSweepEvents(){const i=[];for(let s=0,l=this.polys.length;s0&&(i=x)}let s=i.segment.prevInResult(),l=s?s.prevInResult():null;for(;;){if(!s)return null;if(!l)return s.ringOut;if(l.ringOut!==s.ringOut)return l.ringOut.enclosingRing()!==s.ringOut?s.ringOut:s.ringOut.enclosingRing();s=l.prevInResult(),l=s?s.prevInResult():null}}}class h0{constructor(i){this.exteriorRing=i,i.poly=this,this.interiorRings=[]}addInterior(i){this.interiorRings.push(i),i.poly=this}getGeom(){const i=[this.exteriorRing.getGeom()];if(i[0]===null)return null;for(let s=0,l=this.interiorRings.length;s1&&arguments[1]!==void 0?arguments[1]:Fa.compare;this.queue=i,this.tree=new lm(s),this.segments=[]}process(i){const s=i.segment,l=[];if(i.consumedBy)return i.isLeft?this.queue.remove(i.otherSE):this.tree.remove(s),l;const h=i.isLeft?this.tree.add(s):this.tree.find(s);if(!h)throw new Error(`Unable to find segment #${s.id} [${s.leftSE.point.x}, ${s.leftSE.point.y}] -> [${s.rightSE.point.x}, ${s.rightSE.point.y}] in SweepLine tree.`);let f=h,x=h,t,E;for(;t===void 0;)f=this.tree.prev(f),f===null?t=null:f.key.consumedBy===void 0&&(t=f.key);for(;E===void 0;)x=this.tree.next(x),x===null?E=null:x.key.consumedBy===void 0&&(E=x.key);if(i.isLeft){let k=null;if(t){const R=t.getIntersection(s);if(R!==null&&(s.isAnEndpoint(R)||(k=R),!t.isAnEndpoint(R))){const F=this._splitSafely(t,R);for(let U=0,Z=F.length;U0?(this.tree.remove(s),l.push(i)):(this.segments.push(s),s.prev=t)}else{if(t&&E){const k=t.getIntersection(E);if(k!==null){if(!t.isAnEndpoint(k)){const P=this._splitSafely(t,k);for(let R=0,F=P.length;Rf0)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}const x=new v2(f);let t=f.size,E=f.pop();for(;E;){const R=E.key;if(f.size===t){const U=R.segment;throw new Error(`Unable to pop() ${R.isLeft?"left":"right"} SweepEvent [${R.point.x}, ${R.point.y}] from segment #${U.id} [${U.leftSE.point.x}, ${U.leftSE.point.y}] -> [${U.rightSE.point.x}, ${U.rightSE.point.y}] from queue.`)}if(f.size>f0)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(x.segments.length>x2)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");const F=x.process(R);for(let U=0,Z=F.length;U1?i-1:0),l=1;l1?i-1:0),l=1;l1?i-1:0),l=1;l1?i-1:0),l=1;l{i.push(h.coordinates)}),i.length<2)throw new Error("Must have at least two features");const s=a.features[0].properties||{},l=Ds.difference(i[0],...i.slice(1));return l.length===0?null:l.length===1?Mn(l[0],s):oo(l,s)}function pm(a){if(!a)throw new Error("geojson is required");var i=[];return Wi(a,function(s){i.push(s)}),Jt(i)}function E2(a,i={}){if(i=i||{},!Hn(i))throw new Error("options is invalid");const{propertyName:s}=i;Qs(a,"Polygon","dissolve");const l=[];if(s){const h={};Bn(a,function(x){x.properties&&(Object.prototype.hasOwnProperty.call(h,x.properties[s])||(h[x.properties[s]]=[]),h[x.properties[s]].push(x))});const f=Object.keys(h);for(let x=0;x{k.push(na(R))});const P=[];for(let R=0;RU+Z,0);for(let U=0;U180?-360:x[0]-t[0]>180?360:0,cn(t,l.properties)}function I2(a,i,s,l){l=l===void 0?ur:Number(l);const h=i/l,f=a[0]*Math.PI/180,x=ir(a[1]),t=ir(s),E=h*Math.cos(t);let k=x+E;Math.abs(k)>Math.PI/2&&(k=k>0?Math.PI-k:-Math.PI-k);const P=Math.log(Math.tan(k/2+Math.PI/4)/Math.tan(x/2+Math.PI/4)),R=Math.abs(P)>1e-11?E/P:Math.cos(x),F=h*Math.sin(t)/R;return[((f+F)*180/Math.PI+540)%360-180,k*180/Math.PI]}function $f(a,i,s={}){const l=Jn(a),h=Jn(i);h[0]+=h[0]-l[0]>180?-360:l[0]-h[0]>180?360:0;const f=M2(l,h);return El(f,"meters",s.units)}function M2(a,i,s){s=s===void 0?ur:Number(s);const l=s,h=a[1]*Math.PI/180,f=i[1]*Math.PI/180,x=f-h;let t=Math.abs(i[0]-a[0])*Math.PI/180;t>Math.PI&&(t-=2*Math.PI);const E=Math.log(Math.tan(f/2+Math.PI/4)/Math.tan(h/2+Math.PI/4)),k=Math.abs(E)>1e-11?x/E:Math.cos(h);return Math.sqrt(x*x+k*k*t*t)*l}function p0(a,i,s){if(s=s||{},!Hn(s))throw new Error("options is invalid");const l=s.pivot,h=s.mutate;if(!a)throw new Error("geojson is required");if(i==null||isNaN(i))throw new Error("angle is required");if(i===0)return a;const f=l??na(a);return(h===!1||h===void 0)&&(a=yr(a)),xi(a,function(x){const E=Tl(f,x)+i,k=$f(f,x),P=_n(Au(f,k,E));x[0]=P[0],x[1]=P[1]}),a}function m0(a,i,s,l){l=l||{};const h=l.steps||64,f=l.units||"kilometers",x=l.angle||0,t=l.pivot||a,E=l.properties||{};if(!a)throw new Error("center is required");if(!i)throw new Error("xSemiAxis is required");if(!s)throw new Error("ySemiAxis is required");if(!Hn(l))throw new Error("options must be an object");if(!cr(h))throw new Error("steps must be a number");if(!cr(x))throw new Error("angle must be a number");const k=Jn(a);if(f!=="degrees"){const R=Au(a,i,90,{units:f}),F=Au(a,s,0,{units:f});i=Jn(R)[0]-k[0],s=Jn(F)[1]-k[1]}const P=[];for(let R=0;R=-270&&(U=-U),F<-180&&F>=-360&&(Z=-Z),f==="degrees"){const J=ir(x),he=U*Math.cos(J)+Z*Math.sin(J),ye=Z*Math.cos(J)-U*Math.sin(J);U=he,Z=ye}P.push([U+k[0],Z+k[1]])}return P.push(P[0]),f==="degrees"?Mn([P],E):p0(Mn([P],E),x,{pivot:t})}function g0(a){const i=a*Math.PI/180;return Math.tan(i)}function _0(a){return kc(pi(a))}function Xf(a){const i=[];return a.type==="FeatureCollection"?Bn(a,function(s){xi(s,function(l){i.push(cn(l,s.properties))})}):a.type==="Feature"?xi(a,function(s){i.push(cn(s,a.properties))}):xi(a,function(s){i.push(cn(s))}),Jt(i)}function S2(a,i){var s;if(i=i||{},!Hn(i))throw new Error("options is invalid");const l=(s=i.mutate)!=null?s:!1;if(!a)throw new Error("geojson is required");return(l===!1||l===void 0)&&(a=yr(a)),xi(a,function(h){var f=h[0],x=h[1];h[0]=x,h[1]=f}),a}var y0=Math.PI/180,v0=180/Math.PI,Gc=function(a,i){this.lon=a,this.lat=i,this.x=y0*a,this.y=y0*i};Gc.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)},Gc.prototype.antipode=function(){var a=-1*this.lat,i=this.lon<0?180+this.lon:(180-this.lon)*-1;return new Gc(i,a)};var x0=function(){this.coords=[],this.length=0};x0.prototype.move_to=function(a){this.length++,this.coords.push(a)};var mm=function(a){this.properties=a||{},this.geometries=[]};mm.prototype.json=function(){if(this.geometries.length<=0)return{geometry:{type:"LineString",coordinates:null},type:"Feature",properties:this.properties};if(this.geometries.length===1)return{geometry:{type:"LineString",coordinates:this.geometries[0].coords},type:"Feature",properties:this.properties};for(var a=[],i=0;iF&&(J>P&&ZP&&JE&&(E=he)}var ye=[];if(t&&E0&&Math.abs(be-s[ce-1][0])>F){var we=parseFloat(s[ce-1][0]),Ue=parseFloat(s[ce-1][1]),ze=parseFloat(s[ce][0]),Ve=parseFloat(s[ce][1]);if(we>-180&&we-180&&s[ce-1][0]P&&we<180&&ze===-180&&ce+1P&&s[ce-1][0]<180){te.push([180,s[ce][1]]),ce++,te.push([s[ce][0],s[ce][1]]);continue}if(weP){var Ie=we;we=ze,ze=Ie;var ft=Ue;Ue=Ve,Ve=ft}if(we>P&&ze=180&&weP?180:-180,Je]),te=[],te.push([s[ce-1][0]>P?-180:180,Je]),ye.push(te)}else te=[],ye.push(te);te.push([be,s[ce][1]])}else te.push([s[ce][0],s[ce][1]])}}else{var At=[];ye.push(At);for(var ut=0;ut{s.push(h.coordinates)}),s.length<2)throw new Error("Must specify at least 2 geometries");const l=Ds.intersection(s[0],...s.slice(1));return l.length===0?null:l.length===1?Mn(l[0],i.properties):oo(l,i.properties)}function b0(a,i,s={}){const l=JSON.stringify(s.properties||{}),[h,f,x,t]=a,E=(f+t)/2,k=(h+x)/2,R=i*2/Wn([h,E],[x,E],s)*(x-h),U=i*2/Wn([k,f],[k,t],s)*(t-f),Z=R/2,J=Z*2,he=Math.sqrt(3)/2*U,ye=x-h,te=t-f,ce=3/4*J,be=he,we=(ye-J)/(J-Z/2),Ue=Math.floor(we),ze=(Ue*ce-Z/2-ye)/2-Z/2+ce/2,Ve=Math.floor((te-he)/he);let Ie=(te-Ve*he)/2;const ft=Ve*he-te>he/2;ft&&(Ie-=he/4);const lt=[],Je=[];for(let ut=0;ut<6;ut++){const Nt=2*Math.PI/6*ut;lt.push(Math.cos(Nt)),Je.push(Math.sin(Nt))}const At=[];for(let ut=0;ut<=Ue;ut++)for(let Nt=0;Nt<=Ve;Nt++){const Lt=ut%2===1;if(Nt===0&&Lt||Nt===0&&ft)continue;const Yt=ut*ce+h-ze;let Mt=Nt*be+f+Ie;if(Lt&&(Mt-=he/2),s.triangles===!0)A2([Yt,Mt],R/2,U/2,JSON.parse(l),lt,Je).forEach(function(Gt){s.mask?qc(Jt([s.mask,Gt]))&&At.push(Gt):At.push(Gt)});else{const Gt=C2([Yt,Mt],R/2,U/2,JSON.parse(l),lt,Je);s.mask?qc(Jt([s.mask,Gt]))&&At.push(Gt):At.push(Gt)}}return Jt(At)}function C2(a,i,s,l,h,f){const x=[];for(let t=0;t<6;t++){const E=a[0]+i*h[t],k=a[1]+s*f[t];x.push([E,k])}return x.push(x[0].slice()),Mn([x],l)}function A2(a,i,s,l,h,f){const x=[];for(let t=0;t<6;t++){const E=[];E.push(a),E.push([a[0]+i*h[t],a[1]+s*f[t]]),E.push([a[0]+i*h[(t+1)%6],a[1]+s*f[(t+1)%6]]),E.push(a),x.push(Mn([E],l))}return x}function w0(a,i,s={}){s.mask&&!s.units&&(s.units="kilometers");for(var l=[],h=a[0],f=a[1],x=a[2],t=a[3],E=i/Wn([h,f],[x,f],s),k=E*(x-h),P=i/Wn([h,f],[h,t],s),R=P*(t-f),F=x-h,U=t-f,Z=Math.floor(F/k),J=Math.floor(U/R),he=(F-Z*k)/2,ye=(U-J*R)/2,te=h+he;te<=x;){for(var ce=f+ye;ce<=t;){var be=cn([te,ce],s.properties);s.mask?$_(be,s.mask)&&l.push(be):l.push(be),ce+=R}te+=k}return Jt(l)}function E0(a,i,s,l={}){const h=[],f=a[0],x=a[1],t=a[2],E=a[3],k=t-f,P=El(i,l.units,"degrees"),R=E-x,F=El(s,l.units,"degrees"),U=Math.floor(Math.abs(k)/P),Z=Math.floor(Math.abs(R)/F),J=(k-U*P)/2,he=(R-Z*F)/2;let ye=f+J;for(let te=0;te */function L2(a,i,s){return al&&(h=s,s=l,l=h),al?(a-l)/(a-i):(a-s)/(a-i)}function D2(a,i,s,l){return as||a[t][h-1]s){l=!1;break}if(l&&(a[f-1][0]s||a[f-1][h-1]s)&&(l=!1),l){for(x=0;xs||a[f-1][x]s){l=!1;break}}return l}function F2(a,i){var s,l,h,f,x;for(s=!0,l=a[0].length,h=a.length,x=0;x=i||a[x][l-1]>=i){s=!1;break}if(s&&(a[h-1][0]>=i||a[h-1][l-1]>=i)&&(s=!1),s){for(f=0;f=i||a[h-1][f]>i){s=!1;break}}return s}function V2(a,i,s){var l,h,f,x,t,E,k,P,R,F,U,Z,J,he,ye,te,ce=[],be=a.length-1,we=a[0].length-1,Ue=[["rt","rb"],["br","bl"],["lb","lt"],["tl","tr"]],ze=[0,-1,0,1],Ve=[-1,0,1,0],Ie=["bl","lb","lt","tl","tr","rt","rb","br"],ft={bl:1,br:1,lb:2,lt:2,tl:3,tr:3,rt:0,rb:0};return B2(a,s.minV,s.maxV)&&(s.linearRing?ce.push([[0,0],[0,be],[we,be],[we,0],[0,0]]):ce.push([[0,0],[0,be],[we,be],[we,0]])),i.forEach(function(lt,Je){lt.forEach(function(At,ut){for(l=null,f=0;f<8;f++)if(l=Ie[f],typeof At.edges[l]=="object"){for(h=[],x=At.edges[l],k=l,P=Je,R=ut,F=!1,U=[Je+x.path[0][0],ut+x.path[0][1]],h.push(U);!F&&(Z=i[P][R],typeof Z.edges[k]=="object");)if(x=Z.edges[k],delete Z.edges[k],ye=x.path[1],ye[0]+=P,ye[1]+=R,h.push(ye),k=x.move.enter,P=P+x.move.x,R=R+x.move.y,typeof i[P]>"u"||typeof i[P][R]>"u"){if(J=0,he=0,P===we)P--,J=0;else if(P<0)P++,J=2;else if(R===be)R--,J=3;else if(R<0)R++,J=1;else throw new Error("Left the grid somewhere in the interior!");if(P===Je&&R===ut&&J===ft[l]){F=!0,k=l;break}for(;;){if(te=!1,he>4)throw new Error("Direction change counter overflow! This should never happen!");if(!(typeof i[P]>"u"||typeof i[P][R]>"u")){for(Z=i[P][R],t=0;t"u"||typeof i[P][R]>"u")&&(J===0&&R<0||J===1&&P<0||J===2&&R===be||J===3&&P===we)&&(P-=ze[J],R-=Ve[J],J=(J+1)%4,he++),P===Je&&R===ut&&J===ft[l]){F=!0,k=l;break}}}s.linearRing&&(h[h.length-1][0]!==U[0]||h[h.length-1][1]!==U[1])&&h.push(U),ce.push(h)}})}),ce}function U2(a,i,s){var l,h,f,x,t,E,k,P,R,F,U,Z,J,he,ye,te=[],ce=a.length-1,be=a[0].length-1,we=["right","bottom","left","top"],Ue=[0,-1,0,1],ze=[-1,0,1,0],Ve={bottom:1,left:2,top:3,right:0};return s.noFrame||F2(a,s.threshold)&&(s.linearRing?te.push([[0,0],[0,ce],[be,ce],[be,0],[0,0]]):te.push([[0,0],[0,ce],[be,ce],[be,0]])),i.forEach(function(Ie,ft){Ie.forEach(function(lt,Je){for(l=null,h=0;h<4;h++)if(l=we[h],typeof lt.edges[l]=="object"){for(t=[],f=lt.edges[l],E=l,k=ft,P=Je,R=!1,F=[ft+f.path[0][0],Je+f.path[0][1]],t.push(F);!R&&(x=i[k][P],typeof x.edges[E]=="object");)if(f=x.edges[E],delete x.edges[E],U=f.path[1],U[0]+=k,U[1]+=P,t.push(U),E=f.move.enter,k=k+f.move.x,P=P+f.move.y,typeof i[k]>"u"||typeof i[k][P]>"u"){if(!s.linearRing)break;if(Z=0,J=0,k===be?(k--,Z=0):k<0?(k++,Z=2):P===ce?(P--,Z=3):P<0&&(P++,Z=1),k===ft&&P===Je&&Z===Ve[l]){R=!0,E=l;break}for(;;){if(he=!1,J>4)throw new Error("Direction change counter overflow! This should never happen!");if(!(typeof i[k]>"u"||typeof i[k][P]>"u")&&(x=i[k][P],ye=we[Z],typeof x.edges[ye]=="object")){f=x.edges[ye],t.push(M0(k,P,Z,f.path)),E=ye,he=!0;break}if(he)break;if(t.push(S0(k,P,Z)),k+=Ue[Z],P+=ze[Z],(typeof i[k]>"u"||typeof i[k][P]>"u")&&(Z===0&&P<0||Z===1&&k<0||Z===2&&P===ce||Z===3&&k===be)&&(k-=Ue[Z],P-=ze[Z],Z=(Z+1)%4,J++),k===ft&&P===Je&&Z===Ve[l]){R=!0,E=l;break}}}s.linearRing&&(t[t.length-1][0]!==F[0]||t[t.length-1][1]!==F[1])&&t.push(F),te.push(t)}})}),te}function Cl(a,i,s,l,h){var f=l,x=h,t=0,E=0;if(this.x=i,this.y=s,this.lowerBound=null,this.upperBound=null,this.childA=null,this.childB=null,this.childC=null,this.childD=null,l===1&&h===1)this.lowerBound=Math.min(a[s][i],a[s][i+1],a[s+1][i+1],a[s+1][i]),this.upperBound=Math.max(a[s][i],a[s][i+1],a[s+1][i+1],a[s+1][i]);else{if(l>1){for(;f!==0;)f=f>>1,t++;l===1<1){for(;x!==0;)x=x>>1,E++;h===1<0&&(this.childB=new Cl(a,i+f,s,l-f,x),this.lowerBound=Math.min(this.lowerBound,this.childB.lowerBound),this.upperBound=Math.max(this.upperBound,this.childB.upperBound),h-x>0&&(this.childC=new Cl(a,i+f,s+x,l-f,h-x),this.lowerBound=Math.min(this.lowerBound,this.childC.lowerBound),this.upperBound=Math.max(this.upperBound,this.childC.upperBound))),h-x>0&&(this.childD=new Cl(a,i,s+x,f,h-x),this.lowerBound=Math.min(this.lowerBound,this.childD.lowerBound),this.upperBound=Math.max(this.upperBound,this.childD.upperBound))}}Cl.prototype.cellsInBand=function(a,i,s){var l=[];return s=typeof s>"u"?!0:s,this.lowerBound>i||this.upperBound=i)&&l.push({x:this.x,y:this.y})),l},Cl.prototype.cellsBelowThreshold=function(a,i){var s=[];return i=typeof i>"u"?!0:i,this.lowerBound>a||(this.childA||this.childB||this.childC||this.childD?(this.childA&&(s=s.concat(this.childA.cellsBelowThreshold(a,i))),this.childB&&(s=s.concat(this.childB.cellsBelowThreshold(a,i))),this.childD&&(s=s.concat(this.childD.cellsBelowThreshold(a,i))),this.childC&&(s=s.concat(this.childC.cellsBelowThreshold(a,i)))):(i||this.upperBound>=a)&&s.push({x:this.x,y:this.y})),s};function Yf(a){var i,s;if(!a)throw new Error("data is required");if(!Array.isArray(a)||!Array.isArray(a[0]))throw new Error("data must be scalar field, i.e. array of arrays");if(a.length<2)throw new Error("data must contain at least two rows");if(s=a[0].length,s<2)throw new Error("data must contain at least two columns");for(i=1;i=J?8:0,P|=F>=J?4:0,P|=U>=J?2:0,P|=Z>=J?1:0,P=+P,k={cval:P,polygons:[],edges:{},x0:Z,x1:U,x2:F,x3:R},P){case 0:l.polygons&&k.polygons.push([[0,0],[0,1],[1,1],[1,0]]);break;case 15:break;case 14:h=l.interpolate(Z,R,J),t=l.interpolate(Z,U,J),l.polygons_full&&(k.edges.left={path:[[0,h],[t,0]],move:{x:0,y:-1,enter:"top"}}),l.polygons&&k.polygons.push([[0,0],[0,h],[t,0]]);break;case 13:t=l.interpolate(Z,U,J),f=l.interpolate(U,F,J),l.polygons_full&&(k.edges.bottom={path:[[t,0],[1,f]],move:{x:1,y:0,enter:"left"}}),l.polygons&&k.polygons.push([[t,0],[1,f],[1,0]]);break;case 11:f=l.interpolate(U,F,J),x=l.interpolate(R,F,J),l.polygons_full&&(k.edges.right={path:[[1,f],[x,1]],move:{x:0,y:1,enter:"bottom"}}),l.polygons&&k.polygons.push([[1,f],[x,1],[1,1]]);break;case 7:h=l.interpolate(Z,R,J),x=l.interpolate(R,F,J),l.polygons_full&&(k.edges.top={path:[[x,1],[0,h]],move:{x:-1,y:0,enter:"right"}}),l.polygons&&k.polygons.push([[x,1],[0,h],[0,1]]);break;case 1:h=l.interpolate(Z,R,J),t=l.interpolate(Z,U,J),l.polygons_full&&(k.edges.bottom={path:[[t,0],[0,h]],move:{x:-1,y:0,enter:"right"}}),l.polygons&&k.polygons.push([[t,0],[0,h],[0,1],[1,1],[1,0]]);break;case 2:t=l.interpolate(Z,U,J),f=l.interpolate(U,F,J),l.polygons_full&&(k.edges.right={path:[[1,f],[t,0]],move:{x:0,y:-1,enter:"top"}}),l.polygons&&k.polygons.push([[0,0],[0,1],[1,1],[1,f],[t,0]]);break;case 4:f=l.interpolate(U,F,J),x=l.interpolate(R,F,J),l.polygons_full&&(k.edges.top={path:[[x,1],[1,f]],move:{x:1,y:0,enter:"left"}}),l.polygons&&k.polygons.push([[0,0],[0,1],[x,1],[1,f],[1,0]]);break;case 8:h=l.interpolate(Z,R,J),x=l.interpolate(R,F,J),l.polygons_full&&(k.edges.left={path:[[0,h],[x,1]],move:{x:0,y:1,enter:"bottom"}}),l.polygons&&k.polygons.push([[0,0],[0,h],[x,1],[1,1],[1,0]]);break;case 12:h=l.interpolate(Z,R,J),f=l.interpolate(U,F,J),l.polygons_full&&(k.edges.left={path:[[0,h],[1,f]],move:{x:1,y:0,enter:"left"}}),l.polygons&&k.polygons.push([[0,0],[0,h],[1,f],[1,0]]);break;case 9:t=l.interpolate(Z,U,J),x=l.interpolate(R,F,J),l.polygons_full&&(k.edges.bottom={path:[[t,0],[x,1]],move:{x:0,y:1,enter:"bottom"}}),l.polygons&&k.polygons.push([[t,0],[x,1],[1,1],[1,0]]);break;case 3:h=l.interpolate(Z,R,J),f=l.interpolate(U,F,J),l.polygons_full&&(k.edges.right={path:[[1,f],[0,h]],move:{x:-1,y:0,enter:"right"}}),l.polygons&&k.polygons.push([[0,h],[0,1],[1,1],[1,f]]);break;case 6:t=l.interpolate(Z,U,J),x=l.interpolate(R,F,J),l.polygons_full&&(k.edges.top={path:[[x,1],[t,0]],move:{x:0,y:-1,enter:"top"}}),l.polygons&&k.polygons.push([[0,0],[0,1],[x,1],[t,0]]);break;case 10:h=l.interpolate(Z,R,J),f=l.interpolate(U,F,J),t=l.interpolate(Z,U,J),x=l.interpolate(R,F,J),E=(Z+U+F+R)/4,l.polygons_full&&(Ef?2:xF?128:64,x|=EF?32:16,x|=kF?8:4,x|=PF?2:1,x=+x,f=0,h={cval:x,polygons:[],edges:{},x0:P,x1:k,x2:E,x3:t,x:i,y:s},x){case 85:vt.square(h,P,k,E,t,l);case 0:case 170:break;case 169:vt.triangle_bl(h,P,k,E,t,l);break;case 166:vt.triangle_br(h,P,k,E,t,l);break;case 154:vt.triangle_tr(h,P,k,E,t,l);break;case 106:vt.triangle_tl(h,P,k,E,t,l);break;case 1:vt.triangle_bl(h,P,k,E,t,l);break;case 4:vt.triangle_br(h,P,k,E,t,l);break;case 16:vt.triangle_tr(h,P,k,E,t,l);break;case 64:vt.triangle_tl(h,P,k,E,t,l);break;case 168:vt.tetragon_bl(h,P,k,E,t,l);break;case 162:vt.tetragon_br(h,P,k,E,t,l);break;case 138:vt.tetragon_tr(h,P,k,E,t,l);break;case 42:vt.tetragon_tl(h,P,k,E,t,l);break;case 2:vt.tetragon_bl(h,P,k,E,t,l);break;case 8:vt.tetragon_br(h,P,k,E,t,l);break;case 32:vt.tetragon_tr(h,P,k,E,t,l);break;case 128:vt.tetragon_tl(h,P,k,E,t,l);break;case 5:vt.tetragon_b(h,P,k,E,t,l);break;case 20:vt.tetragon_r(h,P,k,E,t,l);break;case 80:vt.tetragon_t(h,P,k,E,t,l);break;case 65:vt.tetragon_l(h,P,k,E,t,l);break;case 165:vt.tetragon_b(h,P,k,E,t,l);break;case 150:vt.tetragon_r(h,P,k,E,t,l);break;case 90:vt.tetragon_t(h,P,k,E,t,l);break;case 105:vt.tetragon_l(h,P,k,E,t,l);break;case 160:vt.tetragon_lr(h,P,k,E,t,l);break;case 130:vt.tetragon_tb(h,P,k,E,t,l);break;case 10:vt.tetragon_lr(h,P,k,E,t,l);break;case 40:vt.tetragon_tb(h,P,k,E,t,l);break;case 101:vt.pentagon_tr(h,P,k,E,t,l);break;case 149:vt.pentagon_tl(h,P,k,E,t,l);break;case 86:vt.pentagon_bl(h,P,k,E,t,l);break;case 89:vt.pentagon_br(h,P,k,E,t,l);break;case 69:vt.pentagon_tr(h,P,k,E,t,l);break;case 21:vt.pentagon_tl(h,P,k,E,t,l);break;case 84:vt.pentagon_bl(h,P,k,E,t,l);break;case 81:vt.pentagon_br(h,P,k,E,t,l);break;case 96:vt.pentagon_tr_rl(h,P,k,E,t,l);break;case 24:vt.pentagon_rb_bt(h,P,k,E,t,l);break;case 6:vt.pentagon_bl_lr(h,P,k,E,t,l);break;case 129:vt.pentagon_lt_tb(h,P,k,E,t,l);break;case 74:vt.pentagon_tr_rl(h,P,k,E,t,l);break;case 146:vt.pentagon_rb_bt(h,P,k,E,t,l);break;case 164:vt.pentagon_bl_lr(h,P,k,E,t,l);break;case 41:vt.pentagon_lt_tb(h,P,k,E,t,l);break;case 66:vt.pentagon_bl_tb(h,P,k,E,t,l);break;case 144:vt.pentagon_lt_rl(h,P,k,E,t,l);break;case 36:vt.pentagon_tr_bt(h,P,k,E,t,l);break;case 9:vt.pentagon_rb_lr(h,P,k,E,t,l);break;case 104:vt.pentagon_bl_tb(h,P,k,E,t,l);break;case 26:vt.pentagon_lt_rl(h,P,k,E,t,l);break;case 134:vt.pentagon_tr_bt(h,P,k,E,t,l);break;case 161:vt.pentagon_rb_lr(h,P,k,E,t,l);break;case 37:vt.hexagon_lt_tr(h,P,k,E,t,l);break;case 148:vt.hexagon_bl_lt(h,P,k,E,t,l);break;case 82:vt.hexagon_bl_rb(h,P,k,E,t,l);break;case 73:vt.hexagon_tr_rb(h,P,k,E,t,l);break;case 133:vt.hexagon_lt_tr(h,P,k,E,t,l);break;case 22:vt.hexagon_bl_lt(h,P,k,E,t,l);break;case 88:vt.hexagon_bl_rb(h,P,k,E,t,l);break;case 97:vt.hexagon_tr_rb(h,P,k,E,t,l);break;case 145:vt.hexagon_lt_rb(h,P,k,E,t,l);break;case 25:vt.hexagon_lt_rb(h,P,k,E,t,l);break;case 70:vt.hexagon_bl_tr(h,P,k,E,t,l);break;case 100:vt.hexagon_bl_tr(h,P,k,E,t,l);break;case 17:f=xo(P,k,E,t,R,F),f===0?(vt.triangle_bl(h,P,k,E,t,l),vt.triangle_tr(h,P,k,E,t,l)):vt.hexagon_lt_rb(h,P,k,E,t,l);break;case 68:f=xo(P,k,E,t,R,F),f===0?(vt.triangle_tl(h,P,k,E,t,l),vt.triangle_br(h,P,k,E,t,l)):vt.hexagon_bl_tr(h,P,k,E,t,l);break;case 153:f=xo(P,k,E,t,R,F),f===2?(vt.triangle_bl(h,P,k,E,t,l),vt.triangle_tr(h,P,k,E,t,l)):vt.hexagon_lt_rb(h,P,k,E,t,l);break;case 102:f=xo(P,k,E,t,R,F),f===2?(vt.triangle_tl(h,P,k,E,t,l),vt.triangle_br(h,P,k,E,t,l)):vt.hexagon_bl_tr(h,P,k,E,t,l);break;case 152:f=xo(P,k,E,t,R,F),f===2?(vt.triangle_tr(h,P,k,E,t,l),vt.tetragon_bl(h,P,k,E,t,l)):vt.heptagon_tr(h,P,k,E,t,l);break;case 137:f=xo(P,k,E,t,R,F),f===2?(vt.triangle_bl(h,P,k,E,t,l),vt.tetragon_tr(h,P,k,E,t,l)):vt.heptagon_bl(h,P,k,E,t,l);break;case 98:f=xo(P,k,E,t,R,F),f===2?(vt.triangle_tl(h,P,k,E,t,l),vt.tetragon_br(h,P,k,E,t,l)):vt.heptagon_tl(h,P,k,E,t,l);break;case 38:f=xo(P,k,E,t,R,F),f===2?(vt.triangle_br(h,P,k,E,t,l),vt.tetragon_tl(h,P,k,E,t,l)):vt.heptagon_br(h,P,k,E,t,l);break;case 18:f=xo(P,k,E,t,R,F),f===0?(vt.triangle_tr(h,P,k,E,t,l),vt.tetragon_bl(h,P,k,E,t,l)):vt.heptagon_tr(h,P,k,E,t,l);break;case 33:f=xo(P,k,E,t,R,F),f===0?(vt.triangle_bl(h,P,k,E,t,l),vt.tetragon_tr(h,P,k,E,t,l)):vt.heptagon_bl(h,P,k,E,t,l);break;case 72:f=xo(P,k,E,t,R,F),f===0?(vt.triangle_tl(h,P,k,E,t,l),vt.tetragon_br(h,P,k,E,t,l)):vt.heptagon_tl(h,P,k,E,t,l);break;case 132:f=xo(P,k,E,t,R,F),f===0?(vt.triangle_br(h,P,k,E,t,l),vt.tetragon_tl(h,P,k,E,t,l)):vt.heptagon_br(h,P,k,E,t,l);break;case 136:f=xo(P,k,E,t,R,F),f===0?(vt.tetragon_tl(h,P,k,E,t,l),vt.tetragon_br(h,P,k,E,t,l)):f===1?vt.octagon(h,P,k,E,t,l):(vt.tetragon_bl(h,P,k,E,t,l),vt.tetragon_tr(h,P,k,E,t,l));break;case 34:f=xo(P,k,E,t,R,F),f===0?(vt.tetragon_bl(h,P,k,E,t,l),vt.tetragon_tr(h,P,k,E,t,l)):f===1?vt.octagon(h,P,k,E,t,l):(vt.tetragon_tl(h,P,k,E,t,l),vt.tetragon_br(h,P,k,E,t,l));break}return h}}var q2=Object.defineProperty,k0=Object.getOwnPropertySymbols,Z2=Object.prototype.hasOwnProperty,$2=Object.prototype.propertyIsEnumerable,C0=(a,i,s)=>i in a?q2(a,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[i]=s,A0=(a,i)=>{for(var s in i||(i={}))Z2.call(i,s)&&C0(a,s,i[s]);if(k0)for(var s of k0(i))$2.call(i,s)&&C0(a,s,i[s]);return a};function X2(a,i){if(i=i||{},!Hn(i))throw new Error("options is invalid");var s=i.zProperty||"elevation",l=i.flip,h=i.flags;Qs(a,"Point","input must contain Points");for(var f=W2(a,l),x=[],t=0;t{if(f[P]&&!Hn(f[P]))throw new Error("Each mappedProperty is required to be an Object");const R=A0(A0({},h),f[P]);return R[l]=k[l],oo(k.groupedRings,R)});return Jt(E)}function H2(a,i,s){const l=[];for(let h=1;h[J[0]*P+x,J[1]*R+t])})}),F})}function J2(a){const i=a.map(function(s){return{ring:s,area:_u(Mn([s]))}});return i.sort(function(s,l){return l.area-s.area}),i.map(function(s){return s.ring})}function Q2(a){const i=a.map(l=>({lrCoordinates:l,grouped:!1})),s=[];for(;!tI(i);)for(let l=0;li in a?nI(a,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[i]=s,R0=(a,i)=>{for(var s in i||(i={}))iI.call(i,s)&&L0(a,s,i[s]);if(P0)for(var s of P0(i))rI.call(i,s)&&L0(a,s,i[s]);return a};function oI(a,i){if(i=i||{},!Hn(i))throw new Error("options is invalid");var s=i.zProperty||"elevation",l=i.flip,h=i.flags;Qs(a,"Point","input must contain Points");for(var f=sI(a,l),x=[],t=0;t{U[0]=U[0]*P+x,U[1]=U[1]*R+t};return a.forEach(U=>{xi(U,F)}),a}function ym(a){let i,s;const l={type:"FeatureCollection",features:[]};if(a.type==="Feature"?s=a.geometry:s=a,s.type==="LineString")i=[s.coordinates];else if(s.type==="MultiLineString")i=s.coordinates;else if(s.type==="MultiPolygon")i=[].concat(...s.coordinates);else if(s.type==="Polygon")i=s.coordinates;else throw new Error("Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry");return i.forEach(h=>{i.forEach(f=>{for(let x=0;x=0&&k<=1&&(U.onLine1=!0),P>=0&&P<=1&&(U.onLine2=!0),U.onLine1&&U.onLine2?[U.x,U.y]:!1)}function D0(a,i={}){return Ep(a,(s,l)=>{const h=l.geometry.coordinates;return s+Wn(h[0],h[1],i)},0)}function z0(a,i,s,l,h={}){const f=h.steps||64,x=O0(s),t=O0(l),E=!Array.isArray(a)&&a.type==="Feature"?a.properties:{};if(x===t)return Zn(Fc(a,i,h).geometry.coordinates[0],E);const k=x,P=x=t&&R===h.length-1);R++){if(t>i&&f.length===0){if(E=i-t,!E)return f.push(h[R]),Zn(f);k=Ps(h[R],h[R-1])-180,P=ea(h[R],E,k,l),f.push(P.geometry.coordinates)}if(t>=s)return E=s-t,E?(k=Ps(h[R],h[R-1])-180,P=ea(h[R],E,k,l),f.push(P.geometry.coordinates),Zn(f)):(f.push(h[R]),Zn(f));if(t>=i&&f.push(h[R]),R===h.length-1)return Zn(f);t+=Wn(h[R],h[R+1],l)}if(t0){var P=l[E-1],R=yI(k,P);R!==!1&&(P[1]=R,k[0]=R),x.push(P[0]),E===f.length-2&&(x.push(k[0]),x.push(k[1]))}f.length===2&&(x.push(k[0]),x.push(k[1]))}}),Zn(x,a.properties)}function xI(a,i,s){var l=Math.sqrt((a[0]-i[0])*(a[0]-i[0])+(a[1]-i[1])*(a[1]-i[1])),h=a[0]+s*(i[1]-a[1])/l,f=i[0]+s*(i[1]-a[1])/l,x=a[1]+s*(a[0]-i[0])/l,t=i[1]+s*(a[0]-i[0])/l;return[[h,x],[f,t]]}function bI(a,i,s){var l=_n(s);if(vo(s)!=="LineString")throw new Error("line must be a LineString");var h=Ra(s,a),f=Ra(s,i),x;h.properties.index<=f.properties.index?x=[h,f]:x=[f,h];for(var t=[x[0].geometry.coordinates],E=x[0].properties.index+1;E=x){var t=(s+h)/2;return[i,t-(l-i)/2,l,t+(l-i)/2]}else{var E=(i+l)/2;return[E-(h-s)/2,s,E+(h-s)/2,h]}}function V0(a,i){if(i=i??{},!Hn(i))throw new Error("options is invalid");var s=i.precision,l=i.coordinates,h=i.mutate;if(s=s==null||isNaN(s)?6:s,l=l==null||isNaN(l)?3:l,!a)throw new Error(" is required");if(typeof s!="number")throw new Error(" must be a number");if(typeof l!="number")throw new Error(" must be a number");(h===!1||h===void 0)&&(a=JSON.parse(JSON.stringify(a)));var f=Math.pow(10,s);return xi(a,function(x){wI(x,f,l)}),a}function wI(a,i,s){a.length>s&&a.splice(s,a.length);for(var l=0;l1&&s.push(Zn(P)),Jt(s)}function j0(a,i){if(!i.features.length)throw new Error("lines must contain features");if(i.features.length===1)return i.features[0];var s,l=1/0;return Bn(i,function(h){var f=Ra(h,a),x=f.properties.dist;xE?(t.unshift(k),E=P):t.push(k)}else t.push(k)}),Mn(t,i);default:throw new Error("geometry type "+x+" is not supported")}}function q0(a){var i=a[0],s=i[0],l=i[1],h=a[a.length-1],f=h[0],x=h[1];return(s!==f||l!==x)&&a.push(i),a}function II(a){var i=a[0],s=a[1],l=a[2],h=a[3];return Math.abs(i-l)*Math.abs(s-h)}function MI(a,i,s){var l;const h=(l=s==null?void 0:s.mutate)!=null?l:!1;let f=i;i&&h===!1&&(f=yr(i));const x=kI(f);let t=null;return a.type==="FeatureCollection"?t=SI(a):a.type==="Feature"?t=wm(Ds.union(a.geometry.coordinates)):t=wm(Ds.union(a.coordinates)),t.geometry.coordinates.forEach(function(E){x.geometry.coordinates.push(E[0])}),x}function SI(a){const i=a.features.length===2?Ds.union(a.features[0].geometry.coordinates,a.features[1].geometry.coordinates):Ds.union.apply(Ds,a.features.map(function(s){return s.geometry.coordinates}));return wm(i)}function wm(a){return oo(a)}function kI(a){let s=[[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]];return a&&(a.type==="Feature"?s=a.geometry.coordinates:s=a.coordinates),Mn(s)}function CI(a,i){const s=Wn(a,i),l=Ps(a,i);return ea(a,s/2,l)}function AI(a,i){var s,l;const h=i.inputField,f=i.threshold||1e5,x=i.p||2,t=(s=i.binary)!=null?s:!1,E=i.alpha||-1,k=(l=i.standardization)!=null?l:!0,P=d0(a,{alpha:E,binary:t,p:x,standardization:k,threshold:f}),R=[];Bn(a,ft=>{const lt=ft.properties||{};R.push(lt[h])});const F=Z0(R),U=PI(R);let Z=0,J=0,he=0,ye=0;const te=P.length;for(let ft=0;fti in a?LI(a,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[i]=s,W0=(a,i)=>{for(var s in i||(i={}))zI.call(i,s)&&X0(a,s,i[s]);if($0)for(var s of $0(i))OI.call(i,s)&&X0(a,s,i[s]);return a},Y0=(a,i)=>RI(a,DI(i));function Qf(a,i,s={}){if(!a)throw new Error("targetPoint is required");if(!i)throw new Error("points is required");let l=1/0,h=0;Bn(i,(x,t)=>{const E=Wn(a,x,s);E{f.push(na(R))});const x=f.length,t=f.map((R,F)=>{const U=Jt(f.filter((Z,J)=>J!==F));return Wn(R,Qf(R,U).geometry.coordinates,{units:h})}).reduce((R,F)=>R+F,0)/x,E=x/_p(_u(s),"meters",h),k=1/(2*Math.sqrt(E)),P=.26136/Math.sqrt(x*E);return l.nearestNeighborAnalysis={units:h,arealUnits:h+"²",observedMeanDistance:t,expectedMeanDistance:k,nearestNeighborIndex:t/k,numberOfPoints:x,zScore:(t-k)/P},s.properties=l,s}function H0(a,i,s={}){if(s.method||(s.method="geodesic"),s.units||(s.units="kilometers"),!a)throw new Error("pt is required");if(Array.isArray(a)?a=cn(a):a.type==="Point"?a=nr(a):Mc(a,"Point","point"),!i)throw new Error("line is required");Array.isArray(i)?i=Zn(i):i.type==="LineString"?i=nr(i):Mc(i,"LineString","line");let l=1/0;const h=a.geometry.coordinates;return ta(i,f=>{const x=f.geometry.coordinates[0],t=f.geometry.coordinates[1],E=BI(h,x,t,s);Ei in a?FI(a,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[i]=s,Tm=(a,i)=>{for(var s in i||(i={}))VI.call(i,s)&&Q0(a,s,i[s]);if(J0)for(var s of J0(i))UI.call(i,s)&&Q0(a,s,i[s]);return a};function jI(a,i,s={}){const l=s.units,h=s.properties||{},f=GI(a);if(!f.features.length)throw new Error("points must contain features");if(!i)throw new Error("line is required");if(vo(i)!=="LineString")throw new Error("line must be a LineString");let x=1/0,t=null;return Bn(f,E=>{const k=H0(E,i,{units:l});k{l.type==="Point"&&i.push({type:"Feature",properties:{},geometry:l})}),{type:"FeatureCollection",features:i};case"FeatureCollection":return a.features=a.features.filter(l=>l.geometry.type==="Point"),a;default:throw new Error("points must be a Point Collection")}}function qI(a,i){const s=Jn(a),f=Ei(i).coordinates[0];if(f.length<4)throw new Error("OuterRing of a Polygon must have 4 or more Positions.");const x=i.type==="Feature"&&i.properties||{},t=x.a,E=x.b,k=x.c,P=s[0],R=s[1],F=f[0][0],U=f[0][1],Z=t!==void 0?t:f[0][2],J=f[1][0],he=f[1][1],ye=E!==void 0?E:f[1][2],te=f[2][0],ce=f[2][1],be=k!==void 0?k:f[2][2];return(be*(P-F)*(R-he)+Z*(P-J)*(R-ce)+ye*(P-te)*(R-U)-ye*(P-F)*(R-ce)-be*(P-J)*(R-U)-Z*(P-te)*(R-he))/((P-F)*(R-he)+(P-J)*(R-ce)+(P-te)*(R-U)-(P-F)*(R-ce)-(P-J)*(R-U)-(P-te)*(R-he))}function ZI(a){const i=$I(a),s=Eu(i);let l=!1,h=0;for(;!l&&h0)-(a<0)||+a}function Im(a,i,s){const l=i[0]-a[0],h=i[1]-a[1],f=s[0]-i[0],x=s[1]-i[1];return XI(l*x-f*h)}function WI(a,i){const s=a.geometry.coordinates[0].map(x=>x[0]),l=a.geometry.coordinates[0].map(x=>x[1]),h=i.geometry.coordinates[0].map(x=>x[0]),f=i.geometry.coordinates[0].map(x=>x[1]);return Math.max.apply(null,s)===Math.max.apply(null,h)&&Math.max.apply(null,l)===Math.max.apply(null,f)&&Math.min.apply(null,s)===Math.min.apply(null,h)&&Math.min.apply(null,l)===Math.min.apply(null,f)}function nv(a,i){return i.geometry.coordinates[0].every(s=>Pn(cn(s),a))}function YI(a,i){return a[0]===i[0]&&a[1]===i[1]}var iv=class yb{static buildId(i){return i.join(",")}constructor(i){this.id=yb.buildId(i),this.coordinates=i,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1}removeInnerEdge(i){this.innerEdges=this.innerEdges.filter(s=>s.from.id!==i.from.id)}removeOuterEdge(i){this.outerEdges=this.outerEdges.filter(s=>s.to.id!==i.to.id)}addOuterEdge(i){this.outerEdges.push(i),this.outerEdgesSorted=!1}sortOuterEdges(){this.outerEdgesSorted||(this.outerEdges.sort((i,s)=>{const l=i.to,h=s.to;if(l.coordinates[0]-this.coordinates[0]>=0&&h.coordinates[0]-this.coordinates[0]<0)return 1;if(l.coordinates[0]-this.coordinates[0]<0&&h.coordinates[0]-this.coordinates[0]>=0)return-1;if(l.coordinates[0]-this.coordinates[0]===0&&h.coordinates[0]-this.coordinates[0]===0)return l.coordinates[1]-this.coordinates[1]>=0||h.coordinates[1]-this.coordinates[1]>=0?l.coordinates[1]-h.coordinates[1]:h.coordinates[1]-l.coordinates[1];const f=Im(this.coordinates,l.coordinates,h.coordinates);if(f<0)return 1;if(f>0)return-1;const x=Math.pow(l.coordinates[0]-this.coordinates[0],2)+Math.pow(l.coordinates[1]-this.coordinates[1],2),t=Math.pow(h.coordinates[0]-this.coordinates[0],2)+Math.pow(h.coordinates[1]-this.coordinates[1],2);return x-t}),this.outerEdgesSorted=!0)}getOuterEdges(){return this.sortOuterEdges(),this.outerEdges}getOuterEdge(i){return this.sortOuterEdges(),this.outerEdges[i]}addInnerEdge(i){this.innerEdges.push(i)}},HI=class vb{getSymetric(){return this.symetric||(this.symetric=new vb(this.to,this.from),this.symetric.symetric=this),this.symetric}constructor(i,s){this.from=i,this.to=s,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this)}deleteEdge(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)}isEqual(i){return this.from.id===i.from.id&&this.to.id===i.to.id}toString(){return`Edge { ${this.from.id} -> ${this.to.id} }`}toLineString(){return Zn([this.from.coordinates,this.to.coordinates])}compareTo(i){return Im(i.from.coordinates,i.to.coordinates,this.to.coordinates)}},rv=class{constructor(){this.edges=[],this.polygon=void 0,this.envelope=void 0}push(a){this.edges.push(a),this.polygon=this.envelope=void 0}get(a){return this.edges[a]}get length(){return this.edges.length}forEach(a){this.edges.forEach(a)}map(a){return this.edges.map(a)}some(a){return this.edges.some(a)}isValid(){return!0}isHole(){const a=this.edges.reduce((h,f,x)=>(f.from.coordinates[1]>this.edges[h].from.coordinates[1]&&(h=x),h),0),i=(a===0?this.length:a)-1,s=(a+1)%this.length,l=Im(this.edges[i].from.coordinates,this.edges[a].from.coordinates,this.edges[s].from.coordinates);return l===0?this.edges[i].from.coordinates[0]>this.edges[s].from.coordinates[0]:l>0}toMultiPoint(){return Tc(this.edges.map(a=>a.from.coordinates))}toPolygon(){if(this.polygon)return this.polygon;const a=this.edges.map(i=>i.from.coordinates);return a.push(this.edges[0].from.coordinates),this.polygon=Mn([a])}getEnvelope(){return this.envelope?this.envelope:this.envelope=_0(this.toPolygon())}static findEdgeRingContaining(a,i){const s=a.getEnvelope();let l,h;return i.forEach(f=>{const x=f.getEnvelope();if(h&&(l=h.getEnvelope()),!WI(x,s)&&nv(x,s)){const t=a.map(k=>k.from.coordinates);let E;for(const k of t)f.some(P=>YI(k,P.from.coordinates))||(E=k);E&&f.inside(cn(E))&&(!h||nv(l,x))&&(h=f)}}),h}inside(a){return Pn(a,this.toPolygon())}};function KI(a){if(!a)throw new Error("No geojson passed");if(a.type!=="FeatureCollection"&&a.type!=="GeometryCollection"&&a.type!=="MultiLineString"&&a.type!=="LineString"&&a.type!=="Feature")throw new Error(`Invalid input type '${a.type}'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature`)}var JI=class xb{static fromGeoJson(i){KI(i);const s=new xb;return Wi(i,l=>{Mc(l,"LineString","Graph::fromGeoJson"),vp(l,(h,f)=>{if(h){const x=s.getNode(h),t=s.getNode(f);s.addEdge(x,t)}return f})}),s}getNode(i){const s=iv.buildId(i);let l=this.nodes[s];return l||(l=this.nodes[s]=new iv(i)),l}addEdge(i,s){const l=new HI(i,s),h=l.getSymetric();this.edges.push(l),this.edges.push(h)}constructor(){this.edges=[],this.nodes={}}deleteDangles(){Object.keys(this.nodes).map(i=>this.nodes[i]).forEach(i=>this._removeIfDangle(i))}_removeIfDangle(i){if(i.innerEdges.length<=1){const s=i.getOuterEdges().map(l=>l.to);this.removeNode(i),s.forEach(l=>this._removeIfDangle(l))}}deleteCutEdges(){this._computeNextCWEdges(),this._findLabeledEdgeRings(),this.edges.forEach(i=>{i.label===i.symetric.label&&(this.removeEdge(i.symetric),this.removeEdge(i))})}_computeNextCWEdges(i){typeof i>"u"?Object.keys(this.nodes).forEach(s=>this._computeNextCWEdges(this.nodes[s])):i.getOuterEdges().forEach((s,l)=>{i.getOuterEdge((l===0?i.getOuterEdges().length:l)-1).symetric.next=s})}_computeNextCCWEdges(i,s){const l=i.getOuterEdges();let h,f;for(let x=l.length-1;x>=0;--x){let t=l[x],E=t.symetric,k,P;t.label===s&&(k=t),E.label===s&&(P=E),!(!k||!P)&&(P&&(f=P),k&&(f&&(f.next=k,f=void 0),h||(h=k)))}f&&(f.next=h)}_findLabeledEdgeRings(){const i=[];let s=0;return this.edges.forEach(l=>{if(l.label>=0)return;i.push(l);let h=l;do h.label=s,h=h.next;while(!l.isEqual(h));s++}),i}getEdgeRings(){this._computeNextCWEdges(),this.edges.forEach(s=>{s.label=void 0}),this._findLabeledEdgeRings().forEach(s=>{this._findIntersectionNodes(s).forEach(l=>{this._computeNextCCWEdges(l,s.label)})});const i=[];return this.edges.forEach(s=>{s.ring||i.push(this._findEdgeRing(s))}),i}_findIntersectionNodes(i){const s=[];let l=i;do{let h=0;l.from.getOuterEdges().forEach(f=>{f.label===i.label&&++h}),h>1&&s.push(l.from),l=l.next}while(!i.isEqual(l));return s}_findEdgeRing(i){let s=i;const l=new rv;do l.push(s),s.ring=l,s=s.next;while(!i.isEqual(s));return l}removeNode(i){i.getOuterEdges().forEach(s=>this.removeEdge(s)),i.innerEdges.forEach(s=>this.removeEdge(s)),delete this.nodes[i.id]}removeEdge(i){this.edges=this.edges.filter(s=>!s.isEqual(i)),i.deleteEdge()}};function QI(a){const i=JI.fromGeoJson(a);i.deleteDangles(),i.deleteCutEdges();const s=[],l=[];return i.getEdgeRings().filter(h=>h.isValid()).forEach(h=>{h.isHole()?s.push(h):l.push(h)}),s.forEach(h=>{rv.findEdgeRingContaining(h,l)&&l.push(h)}),Jt(l.map(h=>h.toPolygon()))}function eM(a,i){i=i||{},i.iterations=i.iterations||1;const{iterations:s}=i,l=[];if(!a)throw new Error("inputPolys is required");return Br(a,function(h,f,x){if(h.type==="Polygon"){let t=[[]];for(let E=0;E0&&(P=Mn(t).geometry),tM(P,k),t=k.slice(0)}l.push(Mn(t,x))}else if(h.type==="MultiPolygon"){let t=[[[]]];for(let E=0;E0&&(P=oo(t).geometry),nM(P,k),t=k.slice(0)}l.push(oo(t,x))}else throw new Error("geometry is invalid, must be Polygon or MultiPolygon")}),Jt(l)}function tM(a,i){var s,l;xi(a,function(h,f,x,t,E){if(l!==E)i.push([]);else{var k=s[0],P=s[1],R=h[0],F=h[1];i[E].push([.75*k+.25*R,.75*P+.25*F]),i[E].push([.25*k+.75*R,.25*P+.75*F])}s=h,l=E},!1),i.forEach(function(h){h.push(h[0])})}function nM(a,i){let s,l,h;xi(a,function(f,x,t,E,k){if(l!==E)i.push([[]]);else if(h!==k)i[E].push([]);else{var P=s[0],R=s[1],F=f[0],U=f[1];i[E][k].push([.75*P+.25*F,.75*R+.25*U]),i[E][k].push([.25*P+.75*F,.25*R+.75*U])}s=f,l=E,h=k},!1),i.forEach(function(f){f.forEach(function(x){x.push(x[0])})})}function iM(a,i){const s=_n(a),l=_n(i);let h=[],f=[],x;const t=pi(i);let E=0,k=null;switch(s[0]>t[0]&&s[0]t[1]&&s[1]0?oM(i,x,l)||(l=x):s>0&&E<=0&&(rM(i,x,h)||(h=x)),s=E}return[l,h]}function rM(a,i,s){return Zc(a,i,s)>0}function oM(a,i,s){return Zc(a,i,s)<0}function Zc(a,i,s){return(i[0]-a[0])*(s[1]-a[1])-(s[0]-a[0])*(i[1]-a[1])}function sv(a,i={}){return lv(a,"mercator",i)}function av(a,i={}){return lv(a,"wgs84",i)}function lv(a,i,s={}){s=s||{};var l=s.mutate;if(!a)throw new Error("geojson is required");return Array.isArray(a)&&cr(a[0])?a=i==="mercator"?uv(a):cv(a):(l!==!0&&(a=yr(a)),xi(a,function(h){var f=i==="mercator"?uv(h):cv(h);h[0]=f[0],h[1]=f[1]})),a}function uv(a){var i=Math.PI/180,s=6378137,l=20037508342789244e-9,h=Math.abs(a[0])<=180?a[0]:a[0]-sM(a[0])*360,f=[s*h*i,s*Math.log(Math.tan(Math.PI*.25+.5*a[1]*i))];return f[0]>l&&(f[0]=l),f[0]<-l&&(f[0]=-l),f[1]>l&&(f[1]=l),f[1]<-l&&(f[1]=-l),f}function cv(a){var i=180/Math.PI,s=6378137;return[a[0]*i/s,(Math.PI*.5-2*Math.atan(Math.exp(-a[1]/s)))*i]}function sM(a){return a<0?-1:a>0?1:0}const aM=Object.freeze(Object.defineProperty({__proto__:null,toMercator:sv,toWgs84:av},Symbol.toStringTag,{value:"Module"}));function lM(a,i){i=i||{};const s=i.studyBbox||pi(a),l=i.confidenceLevel||20,h=a.features,f=h.length,x=_u(kc(s)),t=Math.sqrt(x/f*2),k=_m(s,t,{units:"meters"}).features,P={};for(let ze=0;zeF&&(F=Ve)}const U=[],Z=Object.keys(P).length,J=R/Z;let he=0;for(let ze=0;zece&&(ce=Ve)}const we=uM[l]/Math.sqrt(Z),Ue={criticalValue:we,isRandom:!0,maxAbsoluteDifference:ce,observedDistribution:ye};return ce>we&&(Ue.isRandom=!1),Ue}var uM={20:1.07275,15:1.13795,10:1.22385,5:1.3581,2:1.51743,1:1.62762};function cM(a,i){return i[0]<=a[0]&&i[1]<=a[1]&&i[2]>=a[0]&&i[3]>=a[1]}function hM(a){const i=[];function s(l){return l===0||l===1?1:i[l]>0?i[l]:i[l]=s(l-1)*l}return s(a)}function hv(a){return td(a),ed(a)}function ed(a){return Array.isArray(a)?gv(a):a&&a.bbox?gv(a.bbox):[dM(),pM()]}function td(a){a!=null&&(Array.isArray(a)?gf(a):a.bbox!=null&&gf(a.bbox))}function fv(a,i={}){td(i.bbox),a==null&&(a=1);const s=[];for(let l=0;lh)throw new Error("max_radial_length is greater than the radius of the bbox");const f=[i.bbox[0]+i.max_radial_length,i.bbox[1]+i.max_radial_length,i.bbox[2]-i.max_radial_length,i.bbox[3]-i.max_radial_length],x=[];for(let t=0;t{F[R]=R>0?P+F[R-1]:P}),k.forEach(P=>{P=P*2*Math.PI/k[k.length-1];const R=Math.random();E.push([R*(i.max_radial_length||10)*Math.sin(P),R*(i.max_radial_length||10)*Math.cos(P)])}),E[E.length-1]=E[0],E=E.map(fM(ed(f))),x.push(Mn([E]))}return Jt(x)}function pv(a,i={}){if(i=i||{},!Hn(i))throw new Error("options is invalid");const s=i.bbox;td(s);let l=i.num_vertices,h=i.max_length,f=i.max_rotation;a==null&&(a=1),(!cr(l)||l===void 0||l<2)&&(l=10),(!cr(h)||h===void 0)&&(h=1e-4),(!cr(f)||f===void 0)&&(f=Math.PI/8);const x=[];for(let t=0;t[i[0]+a[0],i[1]+a[1]]}function mv(){return Math.random()-.5}function dM(){return mv()*360}function pM(){return mv()*180}function gv(a){return[Math.random()*(a[2]-a[0])+a[0],Math.random()*(a[3]-a[1])+a[1]]}const mM=Object.freeze(Object.defineProperty({__proto__:null,randomLineString:pv,randomPoint:fv,randomPolygon:dv,randomPosition:hv},Symbol.toStringTag,{value:"Module"}));function gM(a,i={}){var s,l;if(i=i||{},!Hn(i))throw new Error("options is invalid");const h=(s=i.mutate)!=null?s:!1,f=(l=i.reverse)!=null?l:!1;if(!a)throw new Error(" is required");if(typeof f!="boolean")throw new Error(" must be a boolean");if(typeof h!="boolean")throw new Error(" must be a boolean");!h&&a.type!=="Point"&&a.type!=="MultiPoint"&&(a=yr(a));const x=[];switch(a.type){case"GeometryCollection":return Br(a,function(t){nd(t,f)}),a;case"FeatureCollection":return Bn(a,function(t){const E=nd(t,f);Bn(E,function(k){x.push(k)})}),Jt(x)}return nd(a,f)}function nd(a,i){switch(a.type==="Feature"?a.geometry.type:a.type){case"GeometryCollection":return Br(a,function(l){nd(l,i)}),a;case"LineString":return _v(_n(a),i),a;case"Polygon":return yv(_n(a),i),a;case"MultiLineString":return _n(a).forEach(function(l){_v(l,i)}),a;case"MultiPolygon":return _n(a).forEach(function(l){yv(l,i)}),a;case"Point":case"MultiPoint":return a}}function _v(a,i){_f(a)===i&&a.reverse()}function yv(a,i){_f(a[0])!==i&&a[0].reverse();for(let s=1;sh;)x=Math.floor((l+1)*Math.random()),f=s[x],s[x]=s[l],s[l]=f;return s.slice(h)}function vM(a,i,s,l,h={}){if(h=h||{},!Hn(h))throw new Error("options is invalid");const f=h.properties;if(!a)throw new Error("center is required");if(s==null)throw new Error("bearing1 is required");if(l==null)throw new Error("bearing2 is required");if(!i)throw new Error("radius is required");if(typeof h!="object")throw new Error("options must be an object");if(vv(s)===vv(l))return Fc(a,i,h);const x=_n(a),t=z0(a,i,s,l,h),E=[[x]];return xi(t,function(k){E[0].push(k)}),E[0].push(x),Mn(E,f)}function vv(a){let i=a%360;return i<0&&(i+=360),i}function xv(a,i,s){if(s=s||{},!Hn(s))throw new Error("options is invalid");const l=s.origin||"centroid",h=s.mutate||!1;if(!a)throw new Error("geojson required");if(typeof i!="number"||i<=0)throw new Error("invalid factor");const f=Array.isArray(l)||typeof l=="object";return h!==!0&&(a=yr(a)),a.type==="FeatureCollection"&&!f?(Bn(a,function(x,t){a.features[t]=bv(x,i,l)}),a):bv(a,i,l)}function bv(a,i,s){const l=vo(a)==="Point",h=xM(a,s);return i===1||l||(xi(a,function(f){const x=$f(h,f),t=Tl(h,f),E=x*i,k=_n(Au(h,E,t));f[0]=k[0],f[1]=k[1],f.length===3&&(f[2]*=i)}),delete a.bbox),a}function xM(a,i){if(i==null&&(i="centroid"),Array.isArray(i)||typeof i=="object")return Jn(i);const s=a.bbox?a.bbox:pi(a,{recompute:!0}),l=s[0],h=s[1],f=s[2],x=s[3];switch(i){case"sw":case"southwest":case"westsouth":case"bottomleft":return cn([l,h]);case"se":case"southeast":case"eastsouth":case"bottomright":return cn([f,h]);case"nw":case"northwest":case"westnorth":case"topleft":return cn([l,x]);case"ne":case"northeast":case"eastnorth":case"topright":return cn([f,x]);case"center":return Eu(a);case void 0:case null:case"centroid":return na(a);default:throw new Error("invalid origin")}}function wv(a){for(var i=a,s=[];i.parent;)s.unshift(i),i=i.parent;return s}function bM(){return new Ev(function(a){return a.f})}var id={search:function(a,i,s,l){var h;a.cleanDirty(),l=l||{};var f=l.heuristic||id.heuristics.manhattan,x=(h=l.closest)!=null?h:!1,t=bM(),E=i;for(i.h=f(i,s),t.push(i);t.size()>0;){var k=t.pop();if(k===s)return wv(k);k.closed=!0;for(var P=a.neighbors(k),R=0,F=P.length;R0&&(this.content[0]=i,this.bubbleUp(0)),a},remove:function(a){var i=this.content.indexOf(a),s=this.content.pop();i!==this.content.length-1&&(this.content[i]=s,this.scoreFunction(s)0;){var s=(a+1>>1)-1,l=this.content[s];if(this.scoreFunction(i)=P;){const Zt=[],Vt=[];let St=k+ze,hn=0;for(;St<=R;){const rn=cn([St,Nt]),Tn=EM(rn,l);Zt.push(Tn?0:1),Vt.push(St+"|"+Nt);const je=Wn(rn,a);!Tn&&je1?(l=s[0],h=s[1]):t>0&&(l+=f*t,h+=x*t)}return f=a[0]-l,x=a[1]-h,f*f+x*x}function MM(a,i){for(var s=a[0],l=[s],h,f=1,x=a.length;fi&&(l.push(h),s=h);return s!==h&&l.push(h),l}function Mm(a,i,s,l,h){for(var f=l,x,t=i+1;tf&&(x=t,f=E)}f>l&&(x-i>1&&Mm(a,i,x,l,h),h.push(a[x]),s-x>1&&Mm(a,x,s,l,h))}function SM(a,i){var s=a.length-1,l=[a[0]];return Mm(a,0,s,i,l),l.push(a[s]),l}function od(a,i,s){if(a.length<=2)return a;var l=i!==void 0?i*i:1;return a=s?a:MM(a,l),a=SM(a,l),a}function kM(a,i={}){var s,l,h;if(i=i??{},!Hn(i))throw new Error("options is invalid");const f=(s=i.tolerance)!=null?s:1,x=(l=i.highQuality)!=null?l:!1,t=(h=i.mutate)!=null?h:!1;if(!a)throw new Error("geojson is required");if(f&&f<0)throw new Error("invalid tolerance");return t!==!0&&(a=yr(a)),Br(a,function(E){CM(E,f,x)}),a}function CM(a,i,s){const l=a.type;if(l==="Point"||l==="MultiPoint")return a;if(La(a,{mutate:!0}),l!=="GeometryCollection")switch(l){case"LineString":a.coordinates=od(a.coordinates,i,s);break;case"MultiLineString":a.coordinates=a.coordinates.map(h=>od(h,i,s));break;case"Polygon":a.coordinates=Tv(a.coordinates,i,s);break;case"MultiPolygon":a.coordinates=a.coordinates.map(h=>Tv(h,i,s))}return a}function Tv(a,i,s){return a.map(function(l){if(l.length<4)throw new Error("invalid polygon");let h=i,f=od(l,h,s);for(;!AM(f);)h-=h*.01,f=od(l,h,s);return(f[f.length-1][0]!==f[0][0]||f[f.length-1][1]!==f[0][1])&&f.push(f[0]),f})}function AM(a){return a.length<3?!1:!(a.length===3&&a[2][0]===a[0][0]&&a[2][1]===a[0][1])}function PM(a,i){var s;if(i=i||{},!Hn(i))throw new Error("options is invalid");const l=i.steps||64,h=i.weight,f=i.properties||{};if(!cr(l))throw new Error("steps must be a number");if(!Hn(f))throw new Error("properties must be a number");const x=Sc(a).length,t=qp(a,{weight:h});let E=0,k=0,P=0;Bn(a,function(Ve){var Ie;const ft=h&&((Ie=Ve.properties)==null?void 0:Ie[h])||1,lt=Iv(_n(Ve),_n(t));E+=Math.pow(lt.x,2)*ft,k+=Math.pow(lt.y,2)*ft,P+=lt.x*lt.y*ft});const R=E-k,F=Math.sqrt(Math.pow(R,2)+4*Math.pow(P,2)),U=2*P,Z=Math.atan((R+F)/U),J=Z*180/Math.PI;let he=0,ye=0,te=0;Bn(a,function(Ve){var Ie;const ft=h&&((Ie=Ve.properties)==null?void 0:Ie[h])||1,lt=Iv(_n(Ve),_n(t));he+=Math.pow(lt.x*Math.cos(Z)-lt.y*Math.sin(Z),2)*ft,ye+=Math.pow(lt.x*Math.sin(Z)+lt.y*Math.cos(Z),2)*ft,te+=ft});const ce=Math.sqrt(2*he/te),be=Math.sqrt(2*ye/te),we=m0(t,ce,be,{units:"degrees",angle:J,steps:l,properties:f}),Ue=tv(a,Jt([we])),ze={meanCenterCoordinates:_n(t),semiMajorAxis:ce,semiMinorAxis:be,numberOfFeatures:x,angle:J,percentageWithinEllipse:100*Sc(Ue).length/x};return we.properties=(s=we.properties)!=null?s:{},we.properties.standardDeviationalEllipse=ze,we}function Iv(a,i){return{x:a[0]-i[0],y:a[1]-i[1]}}function LM(a,i,s,l){return a=yr(a),i=yr(i),Bn(a,function(h){h.properties||(h.properties={}),Bn(i,function(f){h.properties&&f.properties&&h.properties[l]===void 0&&Pn(h,f)&&(h.properties[l]=f.properties[s])})}),a}var Sm={exports:{}};Sm.exports=sd,Sm.exports.default=sd;function sd(a,i,s){s=s||2;var l=i&&i.length,h=l?i[0]*s:a.length,f=Mv(a,0,h,s,!0),x=[];if(!f||f.next===f.prev)return x;var t,E,k,P,R,F,U;if(l&&(f=NM(a,i,f,s)),a.length>80*s){t=k=a[0],E=P=a[1];for(var Z=s;Zk&&(k=R),F>P&&(P=F);U=Math.max(k-t,P-E),U=U!==0?32767/U:0}return $c(f,x,s,t,E,U,0),x}function Mv(a,i,s,l,h){var f,x;if(h===Am(a,i,s,l)>0)for(f=i;f=i;f-=l)x=Cv(f,a[f],a[f+1],x);return x&&ad(x,x.next)&&(Wc(x),x=x.next),x}function Al(a,i){if(!a)return a;i||(i=a);var s=a,l;do if(l=!1,!s.steiner&&(ad(s,s.next)||Bi(s.prev,s,s.next)===0)){if(Wc(s),s=i=s.prev,s===s.next)break;l=!0}else s=s.next;while(l||s!==i);return i}function $c(a,i,s,l,h,f,x){if(a){!x&&f&&jM(a,l,h,f);for(var t=a,E,k;a.prev!==a.next;){if(E=a.prev,k=a.next,f?DM(a,l,h,f):RM(a)){i.push(E.i/s|0),i.push(a.i/s|0),i.push(k.i/s|0),Wc(a),a=k.next,t=k.next;continue}if(a=k,a===t){x?x===1?(a=zM(Al(a),i,s),$c(a,i,s,l,h,f,2)):x===2&&OM(a,i,s,l,h,f):$c(Al(a),i,s,l,h,f,1);break}}}}function RM(a){var i=a.prev,s=a,l=a.next;if(Bi(i,s,l)>=0)return!1;for(var h=i.x,f=s.x,x=l.x,t=i.y,E=s.y,k=l.y,P=hf?h>x?h:x:f>x?f:x,U=t>E?t>k?t:k:E>k?E:k,Z=l.next;Z!==i;){if(Z.x>=P&&Z.x<=F&&Z.y>=R&&Z.y<=U&&Lu(h,t,f,E,x,k,Z.x,Z.y)&&Bi(Z.prev,Z,Z.next)>=0)return!1;Z=Z.next}return!0}function DM(a,i,s,l){var h=a.prev,f=a,x=a.next;if(Bi(h,f,x)>=0)return!1;for(var t=h.x,E=f.x,k=x.x,P=h.y,R=f.y,F=x.y,U=tE?t>k?t:k:E>k?E:k,he=P>R?P>F?P:F:R>F?R:F,ye=km(U,Z,i,s,l),te=km(J,he,i,s,l),ce=a.prevZ,be=a.nextZ;ce&&ce.z>=ye&&be&&be.z<=te;){if(ce.x>=U&&ce.x<=J&&ce.y>=Z&&ce.y<=he&&ce!==h&&ce!==x&&Lu(t,P,E,R,k,F,ce.x,ce.y)&&Bi(ce.prev,ce,ce.next)>=0||(ce=ce.prevZ,be.x>=U&&be.x<=J&&be.y>=Z&&be.y<=he&&be!==h&&be!==x&&Lu(t,P,E,R,k,F,be.x,be.y)&&Bi(be.prev,be,be.next)>=0))return!1;be=be.nextZ}for(;ce&&ce.z>=ye;){if(ce.x>=U&&ce.x<=J&&ce.y>=Z&&ce.y<=he&&ce!==h&&ce!==x&&Lu(t,P,E,R,k,F,ce.x,ce.y)&&Bi(ce.prev,ce,ce.next)>=0)return!1;ce=ce.prevZ}for(;be&&be.z<=te;){if(be.x>=U&&be.x<=J&&be.y>=Z&&be.y<=he&&be!==h&&be!==x&&Lu(t,P,E,R,k,F,be.x,be.y)&&Bi(be.prev,be,be.next)>=0)return!1;be=be.nextZ}return!0}function zM(a,i,s){var l=a;do{var h=l.prev,f=l.next.next;!ad(h,f)&&Sv(h,l,l.next,f)&&Xc(h,f)&&Xc(f,h)&&(i.push(h.i/s|0),i.push(l.i/s|0),i.push(f.i/s|0),Wc(l),Wc(l.next),l=a=f),l=l.next}while(l!==a);return Al(l)}function OM(a,i,s,l,h,f){var x=a;do{for(var t=x.next.next;t!==x.prev;){if(x.i!==t.i&&ZM(x,t)){var E=kv(x,t);x=Al(x,x.next),E=Al(E,E.next),$c(x,i,s,l,h,f,0),$c(E,i,s,l,h,f,0);return}t=t.next}x=x.next}while(x!==a)}function NM(a,i,s,l){var h=[],f,x,t,E,k;for(f=0,x=i.length;f=s.next.y&&s.next.y!==s.y){var t=s.x+(h-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=l&&t>f&&(f=t,x=s.x=s.x&&s.x>=k&&l!==s.x&&Lu(hx.x||s.x===x.x&&UM(x,s)))&&(x=s,R=F)),s=s.next;while(s!==E);return x}function UM(a,i){return Bi(a.prev,a,i.prev)<0&&Bi(i.next,a,a.next)<0}function jM(a,i,s,l){var h=a;do h.z===0&&(h.z=km(h.x,h.y,i,s,l)),h.prevZ=h.prev,h.nextZ=h.next,h=h.next;while(h!==a);h.prevZ.nextZ=null,h.prevZ=null,GM(h)}function GM(a){var i,s,l,h,f,x,t,E,k=1;do{for(s=a,a=null,f=null,x=0;s;){for(x++,l=s,t=0,i=0;i0||E>0&&l;)t!==0&&(E===0||!l||s.z<=l.z)?(h=s,s=s.nextZ,t--):(h=l,l=l.nextZ,E--),f?f.nextZ=h:a=h,h.prevZ=f,f=h;s=l}f.nextZ=null,k*=2}while(x>1);return a}function km(a,i,s,l,h){return a=(a-s)*h|0,i=(i-l)*h|0,a=(a|a<<8)&16711935,a=(a|a<<4)&252645135,a=(a|a<<2)&858993459,a=(a|a<<1)&1431655765,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,a|i<<1}function qM(a){var i=a,s=a;do(i.x=(a-x)*(f-t)&&(a-x)*(l-t)>=(s-x)*(i-t)&&(s-x)*(f-t)>=(h-x)*(l-t)}function ZM(a,i){return a.next.i!==i.i&&a.prev.i!==i.i&&!$M(a,i)&&(Xc(a,i)&&Xc(i,a)&&XM(a,i)&&(Bi(a.prev,a,i.prev)||Bi(a,i.prev,i))||ad(a,i)&&Bi(a.prev,a,a.next)>0&&Bi(i.prev,i,i.next)>0)}function Bi(a,i,s){return(i.y-a.y)*(s.x-i.x)-(i.x-a.x)*(s.y-i.y)}function ad(a,i){return a.x===i.x&&a.y===i.y}function Sv(a,i,s,l){var h=ud(Bi(a,i,s)),f=ud(Bi(a,i,l)),x=ud(Bi(s,l,a)),t=ud(Bi(s,l,i));return!!(h!==f&&x!==t||h===0&&ld(a,s,i)||f===0&&ld(a,l,i)||x===0&&ld(s,a,l)||t===0&&ld(s,i,l))}function ld(a,i,s){return i.x<=Math.max(a.x,s.x)&&i.x>=Math.min(a.x,s.x)&&i.y<=Math.max(a.y,s.y)&&i.y>=Math.min(a.y,s.y)}function ud(a){return a>0?1:a<0?-1:0}function $M(a,i){var s=a;do{if(s.i!==a.i&&s.next.i!==a.i&&s.i!==i.i&&s.next.i!==i.i&&Sv(s,s.next,a,i))return!0;s=s.next}while(s!==a);return!1}function Xc(a,i){return Bi(a.prev,a,a.next)<0?Bi(a,i,a.next)>=0&&Bi(a,a.prev,i)>=0:Bi(a,i,a.prev)<0||Bi(a,a.next,i)<0}function XM(a,i){var s=a,l=!1,h=(a.x+i.x)/2,f=(a.y+i.y)/2;do s.y>f!=s.next.y>f&&s.next.y!==s.y&&h<(s.next.x-s.x)*(f-s.y)/(s.next.y-s.y)+s.x&&(l=!l),s=s.next;while(s!==a);return l}function kv(a,i){var s=new Cm(a.i,a.x,a.y),l=new Cm(i.i,i.x,i.y),h=a.next,f=i.prev;return a.next=i,i.prev=a,s.next=h,h.prev=s,l.next=s,s.prev=l,f.next=l,l.prev=f,l}function Cv(a,i,s,l){var h=new Cm(a,i,s);return l?(h.next=l.next,h.prev=l,l.next.prev=h,l.next=h):(h.prev=h,h.next=h),h}function Wc(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function Cm(a,i,s){this.i=a,this.x=i,this.y=s,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}sd.deviation=function(a,i,s,l){var h=i&&i.length,f=h?i[0]*s:a.length,x=Math.abs(Am(a,0,f,s));if(h)for(var t=0,E=i.length;t0&&(l+=a[h-1].length,s.holes.push(l))}return s};var WM=Sm.exports;const YM=pu(WM);function HM(a){if(!a.geometry||a.geometry.type!=="Polygon"&&a.geometry.type!=="MultiPolygon")throw new Error("input must be a Polygon or MultiPolygon");const i={type:"FeatureCollection",features:[]};return a.geometry.type==="Polygon"?i.features=Av(a.geometry.coordinates):a.geometry.coordinates.forEach(function(s){i.features=i.features.concat(Av(s))}),i}function Av(a){const i=KM(a),s=2,l=YM(i.vertices,i.holes,s),h=[],f=[];l.forEach(function(t,E){const k=l[E];f.push([i.vertices[k*s],i.vertices[k*s+1]])});for(var x=0;x0&&(l+=a[h-1].length,s.holes.push(l))}return s}function JM(a,i,s,l){if(l=l||{},!Hn(l))throw new Error("options is invalid");var h=l.units,f=l.zTranslation,x=l.mutate;if(!a)throw new Error("geojson is required");if(i==null||isNaN(i))throw new Error("distance is required");if(f&&typeof f!="number"&&isNaN(f))throw new Error("zTranslation is not a number");if(f=f!==void 0?f:0,i===0&&f===0)return a;if(s==null||isNaN(s))throw new Error("direction is required");return i<0&&(i=-i,s=s+180),(x===!1||x===void 0)&&(a=yr(a)),xi(a,function(t){var E=_n(Au(t,i,s,{units:h}));t[0]=E[0],t[1]=E[1],f&&t.length===3&&(t[2]+=f)}),a}function QM(a,i={}){const s=[];if(Br(a,h=>{s.push(h.coordinates)}),s.length<2)throw new Error("Must have at least 2 geometries");const l=Ds.union(s[0],...s.slice(1));return l.length===0?null:l.length===1?Mn(l[0],i.properties):oo(l,i.properties)}function eS(a,i,s){if(a.geometry.type!=="Polygon")throw new Error("The input feature must be a Polygon");s===void 0&&(s=1);var l=a.geometry.coordinates,h=[],f={};if(s){for(var x=[],t=0;t=1||ft<=0||lt>=1||lt<=0)){var Je=Ie,At=!f[Je];At&&(f[Je]=!0),i?h.push(i(Ie,ye,te,we,Ue,ft,ce,be,ze,Ve,lt,At)):h.push(Ie)}}}function he(ye,te){var ce=l[ye][te],be=l[ye][te+1],we,Ue,ze,Ve;return ce[0]k[St.isect].coord?-1:1});for(var ze=[];ye.length>0;){var Ve=ye.pop(),Ie=Ve.isect,ft=Ve.parent,lt=Ve.winding,Je=ze.length,At=[k[Ie].coord],ut=Ie;if(k[Ie].ringAndEdge1Walkable)var Nt=k[Ie].ringAndEdge1,Lt=k[Ie].nxtIsectAlongRingAndEdge1;else var Nt=k[Ie].ringAndEdge2,Lt=k[Ie].nxtIsectAlongRingAndEdge2;for(;!Hc(k[Ie].coord,k[Lt].coord);){At.push(k[Lt].coord);for(var Yt=void 0,te=0;te1)for(var St=0;St"u"&&(i=!0),a.length!=3)throw new Error("This function requires an array of three points [x,y]");var s=(a[1][0]-a[0][0])*(a[2][1]-a[0][1])-(a[1][1]-a[0][1])*(a[2][0]-a[0][0]);return s>=0==i}function iS(a){for(var i=0,s=0;s0)){if(J/=U,U<0){if(J0){if(J>F)return;J>R&&(R=J)}if(J=l-t,!(!U&&J<0)){if(J/=U,U<0){if(J>F)return;J>R&&(R=J)}else if(U>0){if(J0)){if(J/=Z,Z<0){if(J0){if(J>F)return;J>R&&(R=J)}if(J=h-E,!(!Z&&J<0)){if(J/=Z,Z<0){if(J>F)return;J>R&&(R=J)}else if(Z>0){if(J0)&&!(F<1)||(R>0&&(a[0]=[t+R*U,E+R*Z]),F<1&&(a[1]=[t+F*U,E+F*Z])),!0}}}}}function lS(a,i,s,l,h){var f=a[1];if(f)return!0;var x=a[0],t=a.left,E=a.right,k=t[0],P=t[1],R=E[0],F=E[1],U=(k+R)/2,Z=(P+F)/2,J,he;if(F===P){if(U=l)return;if(k>R){if(!x)x=[U,s];else if(x[1]>=h)return;f=[U,h]}else{if(!x)x=[U,h];else if(x[1]1)if(k>R){if(!x)x=[(s-he)/J,s];else if(x[1]>=h)return;f=[(h-he)/J,h]}else{if(!x)x=[(h-he)/J,h];else if(x[1]=l)return;f=[l,J*l+he]}else{if(!x)x=[l,J*l+he];else if(x[0]bi||Math.abs(f[0][1]-f[1][1])>bi))&&delete Zr[h]}function cS(a){return Do[a.index]={site:a,halfedges:[]}}function hS(a,i){var s=a.site,l=i.left,h=i.right;return s===h&&(h=l,l=s),h?Math.atan2(h[1]-l[1],h[0]-l[0]):(s===l?(l=i[1],h=i[0]):(l=i[0],h=i[1]),Math.atan2(l[0]-h[0],h[1]-l[1]))}function Ov(a,i){return i[+(i.left!==a.site)]}function fS(a,i){return i[+(i.left===a.site)]}function dS(){for(var a=0,i=Do.length,s,l,h,f;abi||Math.abs(he-U)>bi)&&(k.splice(E,0,Zr.push(eh(t,Z,Math.abs(J-a)bi?[a,Math.abs(F-a)bi?[Math.abs(U-l)bi?[s,Math.abs(F-s)bi?[Math.abs(U-i)=-xS)){var U=E*E+k*k,Z=P*P+R*R,J=(R*U-k*Z)/F,he=(E*Z-P*U)/F,ye=Nv.pop()||new mS;ye.arc=a,ye.site=h,ye.x=J+x,ye.y=(ye.cy=he+t)+Math.sqrt(J*J+he*he),a.circle=ye;for(var te=null,ce=th._;ce;)if(ye.ybi)t=t.L;else if(x=i-vS(t,s),x>bi){if(!t.R){l=t;break}t=t.R}else{f>-bi?(l=t.P,h=t):x>-bi?(l=t,h=t.N):l=h=t;break}cS(a);var E=Fv(a);if(Ou.insert(l,E),!(!l&&!h)){if(l===h){zu(l),h=Fv(l.site),Ou.insert(E,h),E.edge=h.edge=Qc(l.site,E.site),Du(l),Du(h);return}if(!h){E.edge=Qc(l.site,E.site);return}zu(l),zu(h);var k=l.site,P=k[0],R=k[1],F=a[0]-P,U=a[1]-R,Z=h.site,J=Z[0]-P,he=Z[1]-R,ye=2*(F*he-U*J),te=F*F+U*U,ce=J*J+he*he,be=[(he*te-U*ce)/ye+P,(F*ce-J*te)/ye+R];dd(h.edge,k,Z,be),E.edge=Qc(k,a,null,be),h.edge=Qc(a,Z,null,be),Du(l),Du(h)}}function Vv(a,i){var s=a.site,l=s[0],h=s[1],f=h-i;if(!f)return l;var x=a.P;if(!x)return-1/0;s=x.site;var t=s[0],E=s[1],k=E-i;if(!k)return t;var P=t-l,R=1/f-1/k,F=P/k;return R?(-F+Math.sqrt(F*F-2*R*(P*P/(-2*k)-E+k/2+h-f/2)))/R+l:(l+t)/2}function vS(a,i){var s=a.N;if(s)return Vv(s,i);var l=a.site;return l[1]===i?l[0]:1/0}var bi=1e-6,xS=1e-12,Ou,Do,th,Zr;function bS(a,i,s){return(a[0]-s[0])*(i[1]-a[1])-(a[0]-i[0])*(s[1]-a[1])}function wS(a,i){return i[1]-a[1]||i[0]-a[0]}function Rm(a,i){var s=a.sort(wS).pop(),l,h,f;for(Zr=[],Do=new Array(a.length),Ou=new hd,th=new hd;;)if(f=Pm,s&&(!f||s[1]=x)return null;var E=a-t.site[0],k=i-t.site[1],P=E*E+k*k;do t=l.cells[h=f],f=null,t.halfedges.forEach(function(R){var F=l.edges[R],U=F.left;if(!((U===t.site||!U)&&!(U=F.right))){var Z=a-U[0],J=i-U[1],he=Z*Z+J*J;hel.geometry.coordinates[0]).y(l=>l.geometry.coordinates[1]).extent([[s[0],s[1]],[s[2],s[3]]]).polygons(a.features).map(function(l,h){return Object.assign(TS(l),{properties:Ff(a.features[h].properties)})}))}const MS=Object.freeze(Object.defineProperty({__proto__:null,along:Ub,angle:jb,applyFilter:Vf,area:_u,areaFactors:pf,azimuthToBearing:a_,bbox:pi,bboxClip:Wb,bboxPolygon:kc,bearing:Ps,bearingToAzimuth:gu,bezierSpline:Jb,booleanClockwise:_f,booleanConcave:Qb,booleanContains:iw,booleanCrosses:I_,booleanDisjoint:Cp,booleanEqual:Aw,booleanIntersects:O_,booleanOverlap:Ww,booleanParallel:Yw,booleanPointInPolygon:Pn,booleanPointOnLine:zn,booleanTouches:Kw,booleanValid:Jw,booleanWithin:$_,buffer:Bc,center:Eu,centerMean:qp,centerMedian:FE,centerOfMass:Oy,centroid:na,circle:Fc,cleanCoords:La,clone:yr,cloneProperties:Ff,clusterEach:Kp,clusterReduce:Vy,clusters:sT,clustersDbscan:lT,clustersKmeans:yT,collect:xT,collectionOf:Qs,combine:bT,concave:HT,containsNumber:yp,convertArea:_p,convertLength:El,convex:zy,coordAll:Sc,coordEach:xi,coordReduce:vp,createBins:Jp,degreesToRadians:ir,destination:ea,difference:w2,dissolve:E2,distance:Wn,distanceWeight:d0,earthRadius:ur,ellipse:m0,envelope:_0,explode:Xf,factors:df,feature:nr,featureCollection:Jt,featureEach:Bn,featureOf:Mc,featureReduce:bp,filterProperties:Uy,findPoint:p_,findSegment:d_,flatten:pm,flattenEach:Wi,flattenReduce:f_,flip:S2,geojsonRbush:Ef,geojsonType:u_,geomEach:Br,geomReduce:wp,geometry:n_,geometryCollection:gp,getCluster:Fy,getCoord:Jn,getCoords:_n,getGeom:Ei,getType:vo,greatCircle:k2,helpers:Bb,hexGrid:b0,interpolate:P2,intersect:qc,invariant:Fb,isNumber:cr,isObject:Hn,isobands:Y2,isolines:aI,kinks:ym,length:D0,lengthToDegrees:mf,lengthToRadians:mu,lineArc:z0,lineChunk:hI,lineEach:Tp,lineIntersect:os,lineOffset:vI,lineOverlap:U_,lineReduce:Ip,lineSegment:wu,lineSlice:bI,lineSliceAlong:N0,lineSplit:EI,lineString:Zn,lineStrings:o_,lineToPolygon:TI,mask:MI,meta:Gb,midpoint:CI,moranIndex:AI,multiLineString:Pa,multiPoint:Tc,multiPolygon:oo,nearestNeighborAnalysis:NI,nearestPoint:Qf,nearestPointOnLine:Ra,nearestPointToLine:jI,planepoint:qI,point:cn,pointGrid:w0,pointOnFeature:ZI,pointToLineDistance:H0,points:i_,pointsWithinPolygon:tv,polygon:Mn,polygonSmooth:eM,polygonTangents:iM,polygonToLine:Cc,polygonize:QI,polygons:r_,projection:aM,propEach:xp,propReduce:h_,propertiesContainsFilter:Qp,quadratAnalysis:lM,radiansToDegrees:wl,radiansToLength:Ic,random:mM,randomLineString:pv,randomPoint:fv,randomPolygon:dv,randomPosition:hv,rectangleGrid:E0,rewind:gM,rhumbBearing:Tl,rhumbDestination:Au,rhumbDistance:$f,round:s_,sample:_M,sector:vM,segmentEach:ta,segmentReduce:Ep,shortestPath:wM,simplify:kM,square:F0,squareGrid:_m,standardDeviationalEllipse:PM,tag:LM,tesselate:HM,tin:Xy,toMercator:sv,toWgs84:av,transformRotate:p0,transformScale:xv,transformTranslate:JM,triangleGrid:T0,truncate:V0,union:QM,unkinkPolygon:Rv,validateBBox:gf,validateId:l_,voronoi:IS},Symbol.toStringTag,{value:"Module"}));class SS{constructor(i){return this.layerName="track-playback-route",this.interval=0,this.totalTime=0,this.startTime=0,this.requestId=null,this.currentPointIndex=0,this.features=[],this.marker=null,this.map=i,this}load(i=[],s=5e3,l={}){if(this.map.getLayer(this.layerName))this.remove(),this.load(i,s,l);else{let h=document.createElement("img");h.src=Nb,this.marker=new Nr.Marker(h),this.totalTime=s,this.interval=s/i.length,this.features=i;let x=Object.assign({},{"line-color":"#A8C2F6","line-width":5},l);this.map.addSource(this.layerName,{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:i}}}),this.map.addLayer({id:this.layerName,source:this.layerName,type:"line",paint:x}),this.setVehiclePositionAndRotation(i[0],0)}}play(){this.startTime=performance.now(),requestAnimationFrame(this.animateVehicle.bind(this))}pause(){cancelAnimationFrame(this.requestId)}animateVehicle(i){const s=i-this.startTime,l=s/this.totalTime;let h=Math.floor(this.features.length*l);if(h<0&&(h=0),h{l.properties.drawOption=s,l.properties.complete=!0,this.geojson_point.features.push(l)}):i.type==="LineString"||i.type==="MultiLineString"?Wi(i,l=>{l.properties.drawOption=s,l.properties.complete=!0,this.geojson_line.features.push(l)}):(i.type==="Polygon"||i.type==="MultiPolygon")&&Wi(i,l=>{l.properties.drawOption=s,l.properties.complete=!0,this.geojson_polygon.features.push(l)}),this.repaint()}_onMousedown(i){const s=[[i.point.x-2,i.point.y-2],[i.point.x+2,i.point.y+2]],l=this._map.queryRenderedFeatures(s,{layers:["MapTools_point"]});if(l.length>0){this.isActive=!0;const h=l[0].properties;i.originalEvent.button===2&&h.type==="01"?h.type==="01"&&(h.source==="geojson_line"&&this.geojson_line.features[h.source_fea_index].geometry.coordinates.length>2?(this.temp_line.geometry.coordinates.length==2&&h.source_coord_index==this.geojson_line.features[h.source_fea_index].geometry.coordinates.length-1&&(this.temp_line.geometry.coordinates[0]=this.geojson_line.features[this.geojson_line.features.length-1].geometry.coordinates[this.geojson_line.features[h.source_fea_index].geometry.coordinates.length-2],this._map.getSource("MapTools_temp_line").setData({type:"FeatureCollection",features:[this.temp_line]})),this.geojson_line.features[h.source_fea_index].geometry.coordinates.splice(h.source_coord_index,1),this.repaint()):h.source==="geojson_polygon"&&this.geojson_polygon.features[h.source_fea_index].geometry.coordinates[h.source_geometry_index].length>4&&(this.temp_line.geometry.coordinates.length==3&&h.source_coord_index==this.geojson_polygon.features[h.source_fea_index].geometry.coordinates[h.source_geometry_index].length-2&&(this.temp_line.geometry.coordinates[0]=this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry.coordinates[h.source_geometry_index][this.geojson_polygon.features[h.source_fea_index].geometry.coordinates[h.source_geometry_index].length-3],this._map.getSource("MapTools_temp_line").setData({type:"FeatureCollection",features:[this.temp_line]})),this.geojson_polygon.features[h.source_fea_index].geometry.coordinates[h.source_geometry_index].splice(h.source_coord_index,1),this.repaint())):i.originalEvent.button===0&&(h.type==="02"&&(h.source==="geojson_line"?(this.geojson_line.features[h.source_fea_index].geometry.coordinates.splice(h.source_coord_index,0,[i.lngLat.lng,i.lngLat.lat]),this.repaint()):h.source==="geojson_polygon"&&(this.geojson_polygon.features[h.source_fea_index].geometry.coordinates[h.source_geometry_index].splice(h.source_coord_index,0,[i.lngLat.lng,i.lngLat.lat]),this.repaint())),this._map.dragPan.disable(),this.draging_point=h)}}_onMouseup(i){if(this.draging_point!=null){const s=this._callback.Mouseup;s&&(this.draging_point.source==="geojson_point"?s(this.mode,this.drawOption,this.geojson_point.features[this.geojson_point.features.length-1].geometry):this.draging_point.source==="geojson_line"?s(this.mode,this.drawOption,this.geojson_line.features[this.geojson_line.features.length-1].geometry):this.draging_point.source==="geojson_polygon"&&s(this.mode,this.drawOption,this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry)),this.draging_point=null,this._map.dragPan.enable(),this.isActive=!1}}_onClick(i){this.mode!==""&&(window.clearTimeout(this.timeId),this.timeId=window.setTimeout(()=>{if(this.click_x=i.lngLat.lng,this.click_y=i.lngLat.lat,this.temp_line.geometry.coordinates[0]=[i.lngLat.lng,i.lngLat.lat],this.mode==="point")this.geojson_point.features.push(cn([i.lngLat.lng,i.lngLat.lat],{drawOption:this.drawOption})),(!this.drawOption||!this.drawOption.multiple)&&this.complate(),this.repaint();else if(this.mode==="line")this.geojson_line.features[this.geojson_line.features.length-1].geometry.coordinates.push([i.lngLat.lng,i.lngLat.lat]),this.repaint();else if(this.mode==="polygon"){const s=this.geojson_polygon.features[this.geojson_polygon.features.length-1];s.geometry.coordinates[0].length==0?s.geometry.coordinates[0].push([i.lngLat.lng,i.lngLat.lat],[i.lngLat.lng,i.lngLat.lat]):s.geometry.coordinates[0].splice(s.geometry.coordinates[0].length-1,0,[i.lngLat.lng,i.lngLat.lat]),this.repaint()}},250))}_onMousemove(i){if(this.draging_point!=null){this.draging_point.source==="geojson_point"?(this.geojson_point.features[this.draging_point.source_fea_index].geometry.coordinates=[i.lngLat.lng,i.lngLat.lat],this.repaint()):this.draging_point.source==="geojson_line"?(this.geojson_line.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_coord_index]=[i.lngLat.lng,i.lngLat.lat],this.repaint()):this.draging_point.source==="geojson_polygon"&&(this.draging_point.source_coord_index===0||this.draging_point.source_coord_index===this.geojson_polygon.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_geometry_index].length-1?(this.geojson_polygon.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_geometry_index][0]=[i.lngLat.lng,i.lngLat.lat],this.geojson_polygon.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_geometry_index][this.geojson_polygon.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_geometry_index].length-1]=[i.lngLat.lng,i.lngLat.lat]):this.geojson_polygon.features[this.draging_point.source_fea_index].geometry.coordinates[this.draging_point.source_geometry_index][this.draging_point.source_coord_index]=[i.lngLat.lng,i.lngLat.lat],this.repaint());return}if(this.mode!==""){if(this._map.getCanvas().style.cursor="crosshair",this.tooltip)this.tooltip.setLngLat([i.lngLat.lng,i.lngLat.lat]);else{const s=document.createElement("div");s.style.backgroundColor="#FFFFFF",s.style.boxShadow=" 0 3px 8px rgba(107, 108, 124, 0.08);",s.style.borderRadius="8px",s.style.height="32px",s.style.lineHeight="32px",s.style.fontSize="13px",s.style.padding="0 8px",this.mode==="point"&&(!this.drawOption||!this.drawOption.multiple)?(s.innerHTML="单击结束",s.style.width="68px",this.tooltip=new Nr.Marker({element:s,offset:[40,0]}).setLngLat([i.lngLat.lng,i.lngLat.lat]).addTo(this._map)):(s.innerHTML="单击鼠标开始,双击结束",s.style.width="159px",this.tooltip=new Nr.Marker({element:s,offset:[100,0]}).setLngLat([i.lngLat.lng,i.lngLat.lat]).addTo(this._map))}if(this.temp_line.geometry.coordinates.length>0){if(this.mode==="line")this.temp_line.geometry.coordinates[1]=[i.lngLat.lng,i.lngLat.lat],this._map.getSource("MapTools_temp_line").setData({type:"FeatureCollection",features:[this.temp_line]});else if(this.mode==="polygon")this.temp_line.geometry.coordinates[1]=[i.lngLat.lng,i.lngLat.lat],this.temp_line.geometry.coordinates[2]=this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry.coordinates[0][0],this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry.coordinates[0].length<=3?this.temp_line.geometry.coordinates[3]=this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry.coordinates[0][1]:this.temp_line.geometry.coordinates.length==4&&this.temp_line.geometry.coordinates.pop(),this._map.getSource("MapTools_temp_line").setData({type:"FeatureCollection",features:[this.temp_line]});else if(this.mode==="rect")this.temp_line.geometry.coordinates[1]=[this.temp_line.geometry.coordinates[0][0],i.lngLat.lat],this.temp_line.geometry.coordinates[2]=[i.lngLat.lng,i.lngLat.lat],this.temp_line.geometry.coordinates[3]=[i.lngLat.lng,this.temp_line.geometry.coordinates[0][1]],this.temp_line.geometry.coordinates[4]=this.temp_line.geometry.coordinates[0],this._map.getSource("MapTools_temp_line").setData(this.temp_line);else if(this.mode==="circle"){const s=Wn(this.temp_line.geometry.coordinates[0],[i.lngLat.lng,i.lngLat.lat]),l=Fc(this.temp_line.geometry.coordinates[0],s);this.temp_line.geometry.coordinates[1]=[i.lngLat.lng,i.lngLat.lat],this._map.getSource("MapTools_temp_line").setData({type:"FeatureCollection",features:[this.temp_line,l]})}}}}_onDblClick(i){if(window.clearTimeout(this.timeId),this.dblclick_x=i.lngLat.lng,this.dblclick_y=i.lngLat.lat,this.mode==="point")this.geojson_point.features.push(cn([i.lngLat.lng,i.lngLat.lat]));else if(this.mode==="line")this.geojson_line.features[this.geojson_line.features.length-1].geometry.coordinates.push([i.lngLat.lng,i.lngLat.lat]);else if(this.mode==="polygon"){const h=this.geojson_polygon.features[this.geojson_polygon.features.length-1];h.geometry.coordinates[0].length==0?h.geometry.coordinates[0].push([i.lngLat.lng,i.lngLat.lat],[i.lngLat.lng,i.lngLat.lat]):h.geometry.coordinates[0].splice(h.geometry.coordinates[0].length-1,0,[i.lngLat.lng,i.lngLat.lat])}else if(this.mode==="rect"){if(isNaN(this.click_x)||isNaN(this.click_y)||this.click_x==this.dblclick_x||this.click_y==this.dblclick_y)return;const h=this.geojson_polygon.features[this.geojson_polygon.features.length-1];h.geometry.coordinates[0][0]=[this.click_x,this.click_y],h.geometry.coordinates[0][1]=[this.click_x,this.dblclick_y],h.geometry.coordinates[0][2]=[this.dblclick_x,this.dblclick_y],h.geometry.coordinates[0][3]=[this.dblclick_x,this.click_y],h.geometry.coordinates[0][4]=[this.click_x,this.click_y]}else if(this.mode==="circle"){if(isNaN(this.click_x)||isNaN(this.click_y))return;const h=Wn([this.click_x,this.click_y],[this.dblclick_x,this.dblclick_y]),f=Fc([this.click_x,this.click_y],h);this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry=f.geometry,this.geojson_polygon.features[this.geojson_polygon.features.length-1].properties.radius=h}const s=this.geojson_line.features[this.geojson_line.features.length-1];s&&s.geometry.coordinates.length<2?this.geojson_line.features.pop():s&&s.properties.complete==!1&&(s.properties.complete=!0);const l=this.geojson_polygon.features[this.geojson_polygon.features.length-1];l&&l.geometry.coordinates[0].length<4?this.geojson_polygon.features.pop():l&&l.properties.complete==!1&&(l.properties.complete=!0),window.setTimeout(()=>{this._map&&this._map.doubleClickZoom.enable()},0),this.repaint(),this.complate()}complate(){const i=this._callback.complate;i&&(this.mode==="point"?i(this.mode,this.drawOption,this.geojson_point.features[this.geojson_point.features.length-1].geometry):this.mode==="line"?i(this.mode,this.drawOption,this.geojson_line.features[this.geojson_line.features.length-1].geometry):(this.mode==="polygon"||this.mode==="rect"||this.mode==="circle")&&(this.geojson_polygon.features.length||console.log("请正确画"),i(this.mode,this.drawOption,this.geojson_polygon.features[this.geojson_polygon.features.length-1].geometry))),this._map.getCanvas().style.cursor="",this.temp_line.geometry.coordinates=[],this._map.getSource("MapTools_temp_line").setData(this.temp_line),this.tooltip&&(this.tooltip.remove(),this.tooltip=null),this.click_x=Number.NaN,this.click_y=Number.NaN,this.move_x=Number.NaN,this.move_y=Number.NaN,this.dblclick_x=Number.NaN,this.dblclick_y=Number.NaN,this.mode="",this.isActive=!1}repaint(){const i=[];for(let s=0;s{xi(s,(h,f)=>{const x=cn(h,{source:"geojson_point",source_fea_index:l,source_coord_index:f,type:"01"});if(i.push(x),s.properties.drawOption&&s.properties.drawOption.buffer&&s.properties.drawOption.buffer>0){const t=Bc(s,s.properties.drawOption.buffer,{units:"kilometers"});i.push(t)}if(s.properties.drawOption&&s.properties.drawOption.delete){const t=document.createElement("div");t.style.backgroundColor="#FFFFFF",t.style.padding="5px 8px",t.style["border-radius"]="4px",t.style.boxShadow=" 0 3px 8px rgba(107, 108, 124, 0.08);",t.style.fontSize="12px";const E=document.createElement("a");E.href="javascript:void(0)",E.innerHTML="删除",E.onclick=(function(P){return(function(){this.delPoint(P)}).bind(this)}).bind(this)(l),t.appendChild(E);const k=new Nr.Marker({element:t,offset:[0,20]}).setLngLat(s.geometry.coordinates).addTo(this._map);this.markers.push(k)}})}),Bn(this.geojson_line,(s,l)=>{if(s.geometry.coordinates.length>=2){if(i.push(s),s.properties.drawOption&&s.properties.drawOption.buffer&&s.properties.drawOption.buffer>0)if(ym(s).features.length>0){const f=wu(s);Bn(f,x=>{const t=Bc(x,s.properties.drawOption.buffer,{units:"kilometers"});i.push(t)})}else{const f=Bc(s,s.properties.drawOption.buffer,{units:"kilometers"});i.push(f)}else if(s.properties.drawOption&&s.properties.drawOption.distance){let h=0;xi(s,(f,x)=>{h+=x==0?0:Wn(f,s.geometry.coordinates[x-1]);const t=document.createElement("div");if(t.style.backgroundColor=this.options.markerBackgroundColor,t.style.border="solid 1px #D1D1D1",t.style.padding="3px",t.style["border-radius"]="5px",x==0)t.innerHTML="起点";else if(x==s.geometry.coordinates.length-1&&s.properties.complete==!0){t.innerHTML=`总长 ${h.toLocaleString()}千米  `;const k=document.createElement("a");k.className="btn",k.style.width="150px",k.href="javascript:void(0)",k.innerHTML="删除",k.onclick=(function(P){return(function(){this.delLine(P)}).bind(this)}).bind(this)(l),t.appendChild(k)}else t.innerHTML=`${h.toLocaleString()}千米`;const E=new Nr.Marker({element:t,offset:[0,20]}).setLngLat(f).addTo(this._map);this.markers.push(E)})}if(s.properties.drawOption&&s.properties.drawOption.delete&&!s.properties.drawOption.distance&&s.properties.complete==!0){const h=document.createElement("div");h.style.backgroundColor="#FFFFFF",h.style.padding="5px 8px",h.style["border-radius"]="4px",h.style.boxShadow=" 0 3px 8px rgba(107, 108, 124, 0.08);",h.style.fontSize="12px";const f=document.createElement("a");f.href="javascript:void(0)",f.className="delIcon",f.innerHTML="删除",f.onclick=(function(E){return(function(){this.delLine(E)}).bind(this)}).bind(this)(l),h.appendChild(f);const x=s.geometry.coordinates[s.geometry.coordinates.length-1],t=new Nr.Marker({element:h,offset:[0,20]}).setLngLat(x).addTo(this._map);this.markers.push(t)}xi(s,(h,f)=>{let x=cn(h,{source:"geojson_line",source_fea_index:l,source_coord_index:f,type:"01"});if(i.push(x),f>0){const t=(h[0]+s.geometry.coordinates[f-1][0])/2,E=(h[1]+s.geometry.coordinates[f-1][1])/2;x=cn([t,E],{source:"geojson_line",source_fea_index:l,source_coord_index:f,type:"02"}),i.push(x)}})}}),Bn(this.geojson_polygon,(s,l)=>{if(s.geometry.coordinates[0].length>=4){const h=this.makevalid(s);if(i.push(h),s.properties.drawOption&&s.properties.drawOption.buffer&&s.properties.drawOption.buffer>0){const f=Bc(h,s.properties.drawOption.buffer,{units:"kilometers"});i.push(f)}if(s.properties.mode!="circle")for(let f=0;f0){const E=(s.geometry.coordinates[f][x][0]+s.geometry.coordinates[f][x-1][0])/2,k=(s.geometry.coordinates[f][x][1]+s.geometry.coordinates[f][x-1][1])/2;t=cn([E,k],{source:"geojson_polygon",source_fea_index:l,source_geometry_index:f,source_coord_index:x,type:"02"}),i.push(t)}}if(s.properties.drawOption&&s.properties.drawOption.area&&s.properties.complete==!0){const f=document.createElement("div");f.style.backgroundColor=this.options.markerBackgroundColor,f.style.border="solid 1px #D1D1D1",f.style.padding="3px",f.style["border-radius"]="5px";const x=_u(s)/1e3/1e3;f.innerHTML=`${x.toLocaleString()}平方千米  `;const t=document.createElement("a");t.href="javascript:void(0)",t.innerHTML="删除",t.onclick=(function(P){return(function(){this.delPolygon(P)}).bind(this)}).bind(this)(l),f.appendChild(t);const E=Eu(s).geometry.coordinates,k=new Nr.Marker({element:f,offset:[-20,-10]}).setLngLat(E).addTo(this._map);this.markers.push(k)}if(s.properties.drawOption&&s.properties.drawOption.delete&&!s.properties.drawOption.area&&s.properties.complete==!0){const f=document.createElement("div");f.style.backgroundColor=this.options.markerBackgroundColor,f.style.border="solid 1px #D1D1D1",f.style.padding="3px",f.style["border-radius"]="5px";const x=document.createElement("a");x.href="javascript:void(0)",x.innerHTML="删除",x.onclick=(function(k){return(function(){this.delPolygon(k)}).bind(this)}).bind(this)(l),f.appendChild(x);const t=Eu(s).geometry.coordinates,E=new Nr.Marker({element:f,offset:[0,20]}).setLngLat(t).addTo(this._map);this.markers.push(E)}}}),this._map.getSource("MapTools_geojson").setData(Jt(i))}delPoint(i){this.geojson_point.features.splice(i,1),this.repaint()}delLine(i){this.geojson_line.features.splice(i,1),this.repaint()}delPolygon(i){this.geojson_polygon.features.splice(i,1),this.repaint()}clean(){this.geojson_point.features.length=0,this.geojson_line.features.length=0,this.geojson_polygon.features.length=0,this.completeCallback=null,this._map.getCanvas().style.cursor="",this.temp_line.geometry.coordinates=[],this._map.getSource("MapTools_temp_line").setData(this.temp_line),this.tooltip&&(this.tooltip.remove(),this.tooltip=null),this.click_x=Number.NaN,this.click_y=Number.NaN,this.move_x=Number.NaN,this.move_y=Number.NaN,this.dblclick_x=Number.NaN,this.dblclick_y=Number.NaN,window.setTimeout(()=>{this._map.doubleClickZoom.enable()},0),this.repaint(),this.mode="",this.isActive=!1}getAll(){return{point:this.geojson_point.features,line:this.geojson_line.features,polygon:this.geojson_polygon.features}}makevalid(i){if(i=La(i),ym(i).features.length<1)return i;const l=Rv(i),h=[];return Bn(l,x=>{h.push(x.geometry.coordinates)}),oo(h)}}const AS=[{name:"防撞桶",id:"gjd_fzt"},{name:"标志牌",id:"gjd_bzp"}],PS={PI:3.141592653589793,x_pi:3.141592653589793*3e3/180,delta:function(a,i){var s=6378245,l=.006693421622965943,h=this.transformLat(i-105,a-35),f=this.transformLon(i-105,a-35),x=a/180*this.PI,t=Math.sin(x);t=1-l*t*t;var E=Math.sqrt(t);return h=h*180/(s*(1-l)/(t*E)*this.PI),f=f*180/(s/E*Math.cos(x)*this.PI),{lat:h,lon:f}},gcj_encrypt:function(a,i){if(this.outOfChina(a,i))return{lat:a,lon:i};var s=this.delta(a,i);return{lat:a+s.lat,lon:i+s.lon}},gcj_decrypt:function(a,i){if(this.outOfChina(a,i))return{lat:a,lon:i};var s=this.delta(a,i);return{lat:a-s.lat,lon:i-s.lon}},gcj_decrypt_exact:function(a,i){for(var s=.01,l=1e-9,h=s,f=s,x=a-h,t=i-f,E=a+h,k=i+f,P,R,F=0;;){P=(x+E)/2,R=(t+k)/2;var U=this.gcj_encrypt(P,R);if(h=U.lat-a,f=U.lon-i,Math.abs(h)0?E=P:x=P,f>0?k=R:t=R,++F>1e4))break}return{lat:P,lon:R}},bd_encrypt:function(a,i){var s=i,l=a,h=Math.sqrt(s*s+l*l)+2e-5*Math.sin(l*this.x_pi),f=Math.atan2(l,s)+3e-6*Math.cos(s*this.x_pi);return bdLon=h*Math.cos(f)+.0065,bdLat=h*Math.sin(f)+.006,{lat:bdLat,lon:bdLon}},bd_decrypt:function(a,i){var s=i-.0065,l=a-.006,h=Math.sqrt(s*s+l*l)-2e-5*Math.sin(l*this.x_pi),f=Math.atan2(l,s)-3e-6*Math.cos(s*this.x_pi),x=h*Math.cos(f),t=h*Math.sin(f);return{lat:t,lon:x}},mercator_encrypt:function(a,i){var s=i*2003750834e-2/180,l=Math.log(Math.tan((90+a)*this.PI/360))/(this.PI/180);return l=l*2003750834e-2/180,{lat:l,lon:s}},mercator_decrypt:function(a,i){var s=i/2003750834e-2*180,l=a/2003750834e-2*180;return l=180/this.PI*(2*Math.atan(Math.exp(l*this.PI/180))-this.PI/2),{lat:l,lon:s}},outOfChina:function(a,i){return i<72.004||i>137.8347||a<.8293||a>55.8271},transformLat:function(a,i){var s=-100+2*a+3*i+.2*i*i+.1*a*i+.2*Math.sqrt(Math.abs(a));return s+=(20*Math.sin(6*a*this.PI)+20*Math.sin(2*a*this.PI))*2/3,s+=(20*Math.sin(i*this.PI)+40*Math.sin(i/3*this.PI))*2/3,s+=(160*Math.sin(i/12*this.PI)+320*Math.sin(i*this.PI/30))*2/3,s},transformLon:function(a,i){var s=300+a+2*i+.1*a*a+.1*a*i+.1*Math.sqrt(Math.abs(a));return s+=(20*Math.sin(6*a*this.PI)+20*Math.sin(2*a*this.PI))*2/3,s+=(20*Math.sin(a*this.PI)+40*Math.sin(a/3*this.PI))*2/3,s+=(150*Math.sin(a/12*this.PI)+300*Math.sin(a/30*this.PI))*2/3,s}},Ir={};return Ir.name="WebGIS SDK",Ir.version=Ir.Version=Pb,Ir.MapStyle=t_,Ir.map=Ab,Ir.ZoomControl=Lb,Ir.FullScreenControl=Rb,Ir.CompassControl=Db,Ir.ScalelineControl=zb,Ir.Popup=Ob,Ir.trackPlayback=SS,Ir.MapTools=CS,Ir.Transforms=PS,Ir._defaultMap=Nr,Ir._defaultMap=Nr,Ir.turf=MS,Ir.controlLayer=AS,Ir}();