|
|
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)<e)return r;var y=this.sampleCurveDerivativeX(r);if(Math.abs(y)<1e-6)break;r-=m/y}var b=0,I=1;for(r=n,u=0;u<20&&(m=this.sampleCurveX(r),!(Math.abs(m-n)<e));u++)n>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<y;b=m++)r=n[m],u=n[b],e+=(u.x-r.x)*(r.y+u.y);return e}function Hi(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function wt(n){const e={};if(n.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\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<R.MAX_PARALLEL_IMAGE_REQUESTS;){const y=ee.shift(),{requestParameters:b,callback:I,cancelled:C}=y;C||(y.cancel=ve(b,I).cancel)}},m=zs(n,(y,b,I,C)=>{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(;m<e.length;m++){const I=r.parse(e[m],m,kn);if(!I)return null;b.push(I)}return new qa(u,b)}evaluate(e){for(let r=0;r<this.args.length;r++){const u=this.args[r].evaluate(e);if(!To(this.type,Xn(u)))return u;if(r===this.args.length-1)throw new Qi(`Expected value to be of type ${li(this.type)}, but found ${li(Xn(u))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.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;b<e.length;b++){const I=r.parse(e[b],b,kn);if(!I)return null;y.push(I)}return new Za(m,y)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let r,u;for(const m of this.args){if(r=m.evaluate(e),u=null,r instanceof Ai)return r;if(typeof r=="string"){const y=e.parseColor(r);if(y)return y}else if(Array.isArray(r)&&(u=r.length<3||r.length>4?`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;$<e.length;$++){const W=e[$],K=Array.isArray(A)?A[$-1]:A.type,re=C.parse(W,1+B.length,K);if(!re){j=!0;break}B.push(re)}if(!j)if(Array.isArray(A)&&A.length!==B.length)C.error(`Expected ${A.length} arguments, but found ${B.length} instead.`);else{for(let $=0;$<B.length;$++){const W=Array.isArray(A)?A[$]:A.type,K=B[$];C.concat($+1).checkSubtype(W,K.type)}if(C.errors.length===0)return new er(u,y,O,B)}}if(I.length===1)r.errors.push(...C.errors);else{const A=(I.length?I:b).map(([B])=>{return j=B,Array.isArray(j)?`(${j.map(li).join(", ")})`:`(${li(j.type)}...)`;var j}).join(" | "),O=[];for(let B=1;B<e.length;B++){const j=r.parse(e[B],1+O.length);if(!j)return null;O.push(li(j.type))}r.error(`Expected arguments of type ${A}, but found (${O.join(", ")}) instead.`)}return null}static register(e,r){er.definitions=r;for(const u in r)e[u]=er}}var Ar=er;class fa{constructor(e,r,u){this.type=Vr,this.locale=u,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const u=e[1];if(typeof u!="object"||Array.isArray(u))return r.error("Collator options argument must be an object.");const m=r.parse(u["case-sensitive"]!==void 0&&u["case-sensitive"],1,In);if(!m)return null;const y=r.parse(u["diacritic-sensitive"]!==void 0&&u["diacritic-sensitive"],1,In);if(!y)return null;let b=null;return u.locale&&(b=r.parse(u.locale,1,fn),!b)?null:new fa(m,y,b)}evaluate(e){return new Dl(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}const Pr=8192;function da(n,e){n[0]=Math.min(n[0],e[0]),n[1]=Math.min(n[1],e[1]),n[2]=Math.max(n[2],e[0]),n[3]=Math.max(n[3],e[1])}function mo(n,e){return!(n[0]<=e[0]||n[2]>=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<I;b++){const C=e[b];for(let A=0,O=C.length;A<O-1;A++){if(go(n,C[A],C[A+1]))return!1;(m=C[A])[1]>(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;r<e.length;r++)if(ma(n,e[r]))return!0;return!1}function Bl(n,e,r,u){const m=u[0]-r[0],y=u[1]-r[1],b=(n[0]-r[0])*y-m*(n[1]-r[1]),I=(e[0]-r[0])*y-m*(e[1]-r[1]);return b>0&&I<0||b<0&&I>0}function Ns(n,e,r){for(const A of r)for(let O=0;O<A.length-1;++O)if((I=[(b=A[O+1])[0]-(y=A[O])[0],b[1]-y[1]])[0]*(C=[(m=e)[0]-(u=n)[0],m[1]-u[1]])[1]-I[1]*C[0]!=0&&Bl(u,m,y,b)&&Bl(y,b,u,m))return!0;var u,m,y,b,I,C;return!1}function Un(n,e){for(let r=0;r<n.length;++r)if(!ma(n[r],e))return!1;for(let r=0;r<n.length-1;++r)if(Ns(n[r],n[r+1],e))return!1;return!0}function ih(n,e){for(let r=0;r<e.length;r++)if(Un(n,e[r]))return!0;return!1}function Fl(n,e,r){const u=[];for(let m=0;m<n.length;m++){const y=[];for(let b=0;b<n[m].length;b++){const I=pa(n[m][b],r);da(e,I),y.push(I)}u.push(y)}return u}function Fu(n,e,r){const u=[];for(let m=0;m<n.length;m++){const y=Fl(n[m],e,r);u.push(y)}return u}function Bo(n,e,r,u){if(n[0]<r[0]||n[0]>r[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<u.features.length;++m){const y=u.features[m].geometry.type;if(y==="Polygon"||y==="MultiPolygon")return new ps(u,u.features[m].geometry)}else if(u.type==="Feature"){const m=u.geometry.type;if(m==="Polygon"||m==="MultiPolygon")return new ps(u,u.geometry)}else if(u.type==="Polygon"||u.type==="MultiPolygon")return new ps(u,u)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(r,u){const m=[1/0,1/0,-1/0,-1/0],y=[1/0,1/0,-1/0,-1/0],b=r.canonicalID();if(!b)return!1;if(u.type==="Polygon"){const I=Fl(u.coordinates,y,b),C=Lr(r.geometry(),m,y,b);if(!mo(m,y))return!1;for(const A of C)if(!ma(A,I))return!1}if(u.type==="MultiPolygon"){const I=Fu(u.coordinates,y,b),C=Lr(r.geometry(),m,y,b);if(!mo(m,y))return!1;for(const A of C)if(!Nl(A,I))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(r,u){const m=[1/0,1/0,-1/0,-1/0],y=[1/0,1/0,-1/0,-1/0],b=r.canonicalID();if(!b)return!1;if(u.type==="Polygon"){const I=Fl(u.coordinates,y,b),C=Vl(r.geometry(),m,y,b);if(!mo(m,y))return!1;for(const A of C)if(!Un(A,I))return!1}if(u.type==="MultiPolygon"){const I=Fu(u.coordinates,y,b),C=Vl(r.geometry(),m,y,b);if(!mo(m,y))return!1;for(const A of C)if(!ih(A,I))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var $a=ps;function Jo(n){if(n instanceof Ar&&(n.name==="get"&&n.args.length===1||n.name==="feature-state"||n.name==="has"&&n.args.length===1||n.name==="properties"||n.name==="geometry-type"||n.name==="id"||/^filter-/.test(n.name))||n instanceof $a)return!1;let e=!0;return n.eachChild(r=>{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||e<m)return I;y=I+1}else{if(!(u>e))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<e.length;b+=2){const I=b===1?-1/0:e[b],C=e[b+1],A=b,O=b+1;if(typeof I!="number")return r.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',A);if(m.length&&m[m.length-1][0]>=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;r<this.labels.length;r++)r>0&&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<b.length;A+=2){const O=b[A],B=b[A+1],j=A+3,$=A+4;if(typeof O!="number")return r.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',j);if(I.length&&I[I.length-1][0]>=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;u<this.labels.length;u++)r.push(this.labels[u],this.outputs[u].serialize());return r}}function Ja(n,e,r,u){const m=u-r,y=n-r;return m===0?0:e===1?y/m:(Math.pow(e,y)-1)/(Math.pow(e,m)-1)}var _o=Vs;class Qa{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let u=null;const m=r.expectedType;m&&m.kind!=="value"&&(u=m);const y=[];for(const I of e.slice(1)){const C=r.parse(I,1+y.length,u,void 0,{typeAnnotation:"omit"});if(!C)return null;u=u||C.type,y.push(C)}const b=m&&y.some(I=>To(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<e.length-1;y+=2){const b=e[y];if(typeof b!="string")return r.error(`Expected string, but found ${typeof b} instead.`,y);if(/[^a-zA-Z0-9_]/.test(b))return r.error("Variable names must contain only alphanumeric characters or '_'.",y);const I=r.parse(e[y+1],y+1);if(!I)return null;u.push([b,I])}const m=r.parse(e[e.length-1],e.length-1,r.expectedType,u);return m?new Us(u,m):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[r,u]of this.bindings)e.push(r,u.serialize());return e.push(this.result.serialize()),e}}var qu=Us;class tl{constructor(e,r,u){this.type=e,this.index=r,this.input=u}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,Pt),m=r.parse(e[2],2,fr(r.expectedType||kn));return u&&m?new tl(m.type.itemType,u,m):null}evaluate(e){const r=this.index.evaluate(e),u=this.input.evaluate(e);if(r<0)throw new Qi(`Array index out of bounds: ${r} < 0.`);if(r>=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;A<e.length-1;A+=2){let O=e[A];const B=e[A+1];Array.isArray(O)||(O=[O]);const j=r.concat(A);if(O.length===0)return j.error("Expected at least one branch label.");for(const W of O){if(typeof W!="number"&&typeof W!="string")return j.error("Branch labels must be numbers or strings.");if(typeof W=="number"&&Math.abs(W)>Number.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;b<e.length-1;b+=2){const I=r.parse(e[b],b,In);if(!I)return null;const C=r.parse(e[b+1],b+1,u);if(!C)return null;m.push([I,C]),u=u||C.type}const y=r.parse(e[e.length-1],e.length-1,u);return y?new Kr(u,m,y):null}evaluate(e){for(const[r,u]of this.branches)if(r.evaluate(e))return u.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[r,u]of this.branches)e(r),e(u);e(this.otherwise)}outputDefined(){return this.branches.every(([e,r])=>r.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<r},function(n,e,r,u){return u.compare(e,r)<0}),ae=L(">",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<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->=":[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;$<n.stops.length;$++){const W=n.stops[$],K=W[0].zoom;A[K]===void 0&&(A[K]={zoom:K,type:n.type,property:n.property,default:n.default,stops:[]},O.push(K)),A[K].stops.push([W[0].value,W[1]])}const B=[];for(const $ of O)B.push([A[$].zoom,va(A[$],e)]);const j={name:"linear"};return{kind:"composite",interpolationType:j,interpolationFactor:_o.interpolationFactor.bind(void 0,j),zoomStops:B.map($=>$[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.length<r["min-length"])return[new Ot(y,e,`array length at least ${r["min-length"]} expected, length ${e.length} found`)];let I={type:r.value,values:r.values,minimum:r.minimum,maximum:r.maximum,function:void 0};m.$version<7&&(I.function=r.function),Dn(r.value)==="object"&&(I=r.value);let C=[];for(let A=0;A<e.length;A++)C=C.concat(b({array:e,arrayIndex:A,value:e[A],valueSpec:I,style:u,styleSpec:m,key:`${y}[${A}]`}));return C}function Wl(n){const e=n.key,r=n.value,u=n.valueSpec;let m=Dn(r);if(m==="number"&&r!=r&&(m="NaN"),m!=="number")return[new Ot(e,r,`number expected, ${m} found`)];if("minimum"in u){let y=u.minimum;if(Dn(u.minimum)==="array"&&(y=u.minimum[n.arrayIndex]),r<y)return[new Ot(e,r,`${r} is less than the minimum value ${y}`)]}if("maximum"in u){let y=u.maximum;if(Dn(u.maximum)==="array"&&(y=u.maximum[n.arrayIndex]),r>y)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&&re<m?[new Ot($.key,de,"stop domain values must appear in ascending order")]:(m=re,r==="categorical"&&re in b?[new Ot($.key,de,"stop domain values must be unique")]:(b[re]=!0,[])):[new Ot($.key,de,`integer expected, found ${String(re)}`)]}}function pr(n){const e=(n.expressionContext==="property"?Xl:sl)(Ki(n.value),n.valueSpec);if(e.result==="error")return e.value.map(u=>new 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;u<r.length;u++)if(al(r[u]))return!0}return r}(n);return e===!0?e:e.map(r=>gd(r))}function Ju(n){let e=!1;const r=[];if(n[0]==="case"){for(let u=1;u<n.length-1;u+=2)e=e||al(n[u]),r.push(n[u+1]);r.push(n[n.length-1])}else if(n[0]==="match"){e=e||al(n[1]);for(let u=2;u<n.length-1;u+=2)r.push(n[u+1]);r.push(n[n.length-1])}else if(n[0]==="step"){e=e||al(n[1]);for(let u=1;u<n.length-1;u+=2)r.push(n[u+1])}e&&(n.length=0,n.push("any",...r));for(let u=1;u<n.length;u++)Ju(n[u])}function al(n){if(!Array.isArray(n))return!1;if((e=n[0])==="pitch"||e==="distance-from-center")return!0;var e;for(let r=1;r<n.length;r++)if(al(n[r]))return!0;return!1}const ch=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Dm(n,e){return n<e?-1:n>e?1:0}function _d(n){if(!Array.isArray(n))return!1;if(n[0]==="within")return!0;for(let e=1;e<n.length;e++)if(_d(n[e]))return!0;return!1}function ll(n){if(!n)return!0;const e=n[0];return n.length<=1?e!=="any":e==="=="?hh(n[1],n[2],"=="):e==="!="?Qu(hh(n[1],n[2],"==")):e==="<"||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<e.length;b++)m=Dn(e[b]),Ti(e[1])==="$type"?y=y.concat(Hu({key:`${r}[${b}]`,value:e[b],valueSpec:u.geometry_type,style:n.style,styleSpec:n.styleSpec})):m!=="string"&&m!=="number"&&m!=="boolean"&&y.push(new Ot(`${r}[${b}]`,e[b],`string, number, or boolean expected, ${m} found`));break;case"any":case"all":case"none":for(let b=1;b<e.length;b++)y=y.concat(Jl({key:`${r}[${b}]`,value:e[b],style:n.style,styleSpec:n.styleSpec}));break;case"has":case"!has":m=Dn(e[1]),e.length!==2?y.push(new Ot(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):m!=="string"&&y.push(new Ot(`${r}[1]`,e[1],`string expected, ${m} found`));break;case"within":m=Dn(e[1]),e.length!==2?y.push(new Ot(r,e,`filter array for "${e[0]}" operator must have 2 elements`)):m!=="object"&&y.push(new Ot(`${r}[1]`,e[1],`object expected, ${m} found`))}return y}function ph(n,e){const r=n.key,u=n.style,m=n.styleSpec,y=n.value,b=n.objectKey,I=m[`${e}_${n.layerType}`];if(!I)return[];const C=b.match(/^(.*)-transition$/);if(e==="paint"&&C&&I[C[1]]&&I[C[1]].transition)return Rr({key:r,value:y,valueSpec:m.transition,style:u,styleSpec:m});const A=n.valueSpec||I[b];if(!A)return[new Ot(r,y,`unknown property "${b}"`)];let O;if(Dn(y)==="string"&&dr(A)&&!A.tokens&&(O=/^{([^}]+)}$/.exec(y))){const j=`\`{ "type": "identity", "property": ${O?JSON.stringify(O[1]):'"_"'} }\``;return[new Ot(r,y,`"${b}" does not support interpolation syntax
|
|
|
Use an identity property function instead: ${j}.`)]}const B=[];return n.layerType==="symbol"&&(b==="text-field"&&u&&!u.glyphs&&B.push(new Ot(r,y,'use of "text-field" requires a style "glyphs" property')),b==="text-font"&&Vo(Ki(y))&&Ti(y.type)==="identity"&&B.push(new Ot(r,y,'"text-font" does not support identity functions'))),B.concat(Rr({key:n.key,value:y,valueSpec:A,style:u,styleSpec:m,expressionContext:"property",propertyType:e,propertyKey:b}))}function yd(n){return ph(n,"paint")}function mh(n){return ph(n,"layout")}function vd(n){let e=[];const r=n.value,u=n.key,m=n.style,y=n.styleSpec;r.type||r.ref||e.push(new Ot(u,r,'either "type" or "ref" is required'));let b=Ti(r.type);const I=Ti(r.ref);if(r.id){const C=Ti(r.id);for(let A=0;A<n.arrayIndex;A++){const O=m.layers[A];Ti(O.id)===C&&e.push(new Ot(u,r.id,`duplicate layer id "${r.id}", previously used at line ${O.id.__line__}`))}}if("ref"in r){let C;["type","source","source-layer","filter","layout"].forEach(A=>{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<this.d*this.d;y++){var b=m[jo+y],I=m[jo+y+1];u.push(b===I?null:m.subarray(b,I))}var C=m[jo+u.length+1];this.keys=m.subarray(m[jo+u.length],C),this.bboxes=m.subarray(C),this.insert=this._insertReadonly}else{this.d=e+2*r;for(var A=0;A<this.d*this.d;A++)u.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=n,this.padding=r,this.scale=e/n,this.uid=0;var O=r/e*n;this.min=-O,this.max=n+O}Qo.prototype.insert=function(n,e,r,u,m){this._forEachCell(e,r,u,m,this._insertCell,this.uid++),this.keys.push(n),this.bboxes.push(e),this.bboxes.push(r),this.bboxes.push(u),this.bboxes.push(m)},Qo.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Qo.prototype._insertCell=function(n,e,r,u,m,y){this.cells[m].push(y)},Qo.prototype.query=function(n,e,r,u,m){var y=this.min,b=this.max;if(n<=y&&e<=y&&b<=r&&b<=u&&!m)return Array.prototype.slice.call(this.keys);var I=[];return this._forEachCell(n,e,r,u,this._queryCell,I,{},m),I},Qo.prototype._queryCell=function(n,e,r,u,m,y,b,I){var C=this.cells[m];if(C!==null)for(var A=this.keys,O=this.bboxes,B=0;B<C.length;B++){var j=C[B];if(b[j]===void 0){var $=4*j;(I?I(O[$+0],O[$+1],O[$+2],O[$+3]):n<=O[$+2]&&e<=O[$+3]&&r>=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<this.cells.length;u++)r+=this.cells[u].length;var m=new Int32Array(e+r+this.keys.length+this.bboxes.length);m[0]=this.extent,m[1]=this.n,m[2]=this.padding;for(var y=e,b=0;b<n.length;b++){var I=n[b];m[jo+b]=y,m.set(I,y),y+=I.length}return m[jo+n.length]=y,m.set(this.keys,y),m[jo+n.length+1]=y+=this.keys.length,m.set(this.bboxes,y),y+=this.bboxes.length,m.buffer};var xa=ce(Fm);const ec={};function Ft(n,e,r={}){Object.defineProperty(n,"_classRegistryKey",{value:e,writeable:!1}),ec[e]={klass:n,omit:r.omit||[]}}Ft(Object,"Object"),xa.serialize=function(n,e){const r=n.toArrayBuffer();return e&&e.push(r),{buffer:r}},xa.deserialize=function(n){return new xa(n.buffer)},Object.defineProperty(xa,"name",{value:"Grid"}),Ft(xa,"Grid"),Ft(Ai,"Color"),Ft(Error,"Error"),Ft(Yo,"AJAXError"),Ft(Wr,"ResolvedImage"),Ft(Wu,"StylePropertyFunction"),Ft(Xu,"StyleExpression",{omit:["_evaluator"]}),Ft($l,"ZoomDependentExpression"),Ft(lh,"ZoomConstantExpression"),Ft(Ar,"CompoundExpression",{omit:["_evaluate"]});for(const n in ui)ec[ui[n]._classRegistryKey]||Ft(ui[n],`Expression${n}`);function _h(n){return n&&typeof ArrayBuffer<"u"&&(n instanceof ArrayBuffer||n.constructor&&n.constructor.name==="ArrayBuffer")}function yh(n){return E.ImageBitmap&&n instanceof E.ImageBitmap}function ul(n,e){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)return n;if(_h(n)||yh(n))return e&&e.push(n),n;if(ArrayBuffer.isView(n)){const r=n;return e&&e.push(r.buffer),r}if(n instanceof E.ImageData)return e&&e.push(n.data.buffer),n;if(Array.isArray(n)){const r=[];for(const u of n)r.push(ul(u,e));return r}if(typeof n=="object"){const r=n.constructor,u=r._classRegistryKey;if(!u)throw new Error(`can't serialize object of unregistered class ${u}`);const m=r.serialize?r.serialize(n,e):{};if(!r.serialize){for(const y in n)n.hasOwnProperty(y)&&(ec[u].omit.indexOf(y)>=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(m<this.begin)return b.possiblyEvaluate(e,r,u);{const I=(m-this.begin)/(this.end-this.begin);return this.property.interpolate(b.possiblyEvaluate(e,r,u),y,Nt(I))}}return y}}class se{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,u){const m=new fe(this._properties);for(const y of Object.keys(this._values))m._values[y]=this._values[y].possiblyEvaluate(e,r,u);return m}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class ue{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return Fn(this._values[e].value)}setValue(e,r){this._values[e]=new q(this._values[e].property,r===null?void 0:Fn(r))}serialize(){const e={};for(const r of Object.keys(this._values)){const u=this.getValue(r);u!==void 0&&(e[r]=u)}return e}possiblyEvaluate(e,r,u){const m=new fe(this._properties);for(const y of Object.keys(this._values))m._values[y]=this._values[y].possiblyEvaluate(e,r,u);return m}}class le{constructor(e,r,u){this.property=e,this.value=r,this.parameters=u}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,u,m){return this.property.evaluate(this.value,this.parameters,e,r,u,m)}}class fe{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class H{constructor(e){this.specification=e}possiblyEvaluate(e,r){return e.expression.evaluate(r)}interpolate(e,r,u){const m=gs[this.specification.type];return m?m(e,r,u):e}}class oe{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,u,m){return new le(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},u,m)}:e.expression,r)}interpolate(e,r,u){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new le(this,{kind:"constant",value:void 0},e.parameters);const m=gs[this.specification.type];return m?new le(this,{kind:"constant",value:m(e.value.value,r.value.value,u)},e.parameters):e}evaluate(e,r,u,m,y,b){return e.kind==="constant"?e.value:e.evaluate(r,u,m,y,b)}}class ge{constructor(e){this.specification=e}possiblyEvaluate(e,r,u,m){return!!e.expression.evaluate(r,null,{},u,m)}interpolate(){return!1}}class _e{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const r=new N(0,{});for(const u in e){const m=e[u];m.specification.overridable&&this.overridableProperties.push(u);const y=this.defaultPropertyValues[u]=new q(m,void 0),b=this.defaultTransitionablePropertyValues[u]=new G(m);this.defaultTransitioningPropertyValues[u]=b.untransitioned(),this.defaultPossiblyEvaluatedValues[u]=y.possiblyEvaluate(r)}}}function Ae(n,e){return 256*(n=Mt(Math.floor(n),0,255))+Mt(Math.floor(e),0,255)}Ft(oe,"DataDrivenProperty"),Ft(H,"DataConstantProperty"),Ft(ge,"ColorRampProperty");const Re={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Pe{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Be{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const 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<u;)C=255&n.charCodeAt(A)|(255&n.charCodeAt(++A))<<8|(255&n.charCodeAt(++A))<<16|(255&n.charCodeAt(++A))<<24,++A,m=27492+(65535&(y=5*(65535&(m=(m^=C=(65535&(C=(C=(65535&C)*b+(((C>>>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<m;){const b=u+m>>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<u;){const m=n[r+u>>1];let y=r-1,b=u+1;for(;;){do y++;while(n[y]<m);do b--;while(n[b]>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-b?(qm(n,e,r,b),r=b+1):(qm(n,e,b+1,u),u=b)}}function Pd(n,e,r){const u=n[e];n[e]=n[r],n[r]=u}Ft(Ad,"FeaturePositionMap");class Ta{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,r){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,r),this.initialized=!0),!!this.location}}class Ld extends Ta{constructor(e){super(e),this.current=0}set(e,r,u){this.fetchUniformLocation(e,r)&&this.current!==u&&(this.current=u,this.gl.uniform1f(this.location,u))}}class qv extends Ta{constructor(e){super(e),this.current=[0,0,0,0]}set(e,r,u){this.fetchUniformLocation(e,r)&&(u[0]===this.current[0]&&u[1]===this.current[1]&&u[2]===this.current[2]&&u[3]===this.current[3]||(this.current=u,this.gl.uniform4f(this.location,u[0],u[1],u[2],u[3])))}}class Zv extends Ta{constructor(e){super(e),this.current=Ai.transparent}set(e,r,u){this.fetchUniformLocation(e,r)&&(u.r===this.current.r&&u.g===this.current.g&&u.b===this.current.b&&u.a===this.current.a||(this.current=u,this.gl.uniform4f(this.location,u.r,u.g,u.b,u.a)))}}const RS=new Float32Array(16),DS=new Float32Array(9),zS=new Float32Array(4);function Zm(n){return[Ae(255*n.r,255*n.g),Ae(255*n.b,255*n.a)]}class Ih{constructor(e,r,u){this.value=e,this.uniformNames=r.map(m=>`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<r;y++)this.paintVertexArray.emplace(y,m[0],m[1])}else{for(let m=e;m<r;m++)this.paintVertexArray.emplace(m,u);this.maxValue=Math.max(this.maxValue,Math.abs(u))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class ws{constructor(e,r,u,m,y,b){this.expression=e,this.uniformNames=r.map(I=>`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<r;I++)this.paintVertexArray.emplace(I,y[0],y[1],b[0],b[1])}else{for(let y=e;y<r;y++)this.paintVertexArray.emplace(y,u,m);this.maxValue=Math.max(this.maxValue,Math.abs(u),Math.abs(m))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,r,u,m,y){const b=this.useIntegerZoom?Math.floor(u.zoom):u.zoom,I=Mt(this.expression.interpolationFactor(b,this.zoom,this.zoom+1),0,1);r.set(e,y,I)}getBinding(e,r){return new Ld(e)}}class hl{constructor(e,r,u,m,y){this.expression=e,this.layerId=y,this.paintVertexAttributes=(u==="array"?Ea:qs).members;for(let b=0;b<r.length;++b);this.paintVertexArray=new m}populatePaintArray(e,r,u){const m=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(m,e,r.patterns&&r.patterns[this.layerId],u)}updatePaintArray(e,r,u,m,y,b){this._setPaintValues(e,r,u.patterns&&u.patterns[this.layerId],b)}_setPaintValues(e,r,u,m){if(!m||!u)return;const y=m[u];if(!y)return;const{tl:b,br:I,pixelRatio:C}=y;for(let A=e;A<r;A++)this.paintVertexArray.emplace(A,b[0],b[1],I[0],I[1],C)}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class fl{constructor(e,r,u=()=>!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<u.paintVertexAttributes.length;m++)e.push(u.paintVertexAttributes[m].name)}return e}getBinderUniforms(){const e=[];for(const r in this.binders){const u=this.binders[r];if(u instanceof Ih||u instanceof ic||u instanceof ws)for(const m of u.uniformNames)e.push(m)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const r=[];for(const u in this.binders){const m=this.binders[u];if(m instanceof Ih||m instanceof ic||m instanceof ws)for(const y of m.uniformNames)r.push({name:y,property:u,binding:m.getBinding(e,y)})}return r}setUniforms(e,r,u,m,y){for(const{name:b,property:I,binding:C}of u)this.binders[I].setUniform(e,C,y,m.get(I),b)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const r=this.binders[e];(r instanceof Ia||r instanceof ws||r instanceof hl)&&r.paintVertexBuffer&&this._buffers.push(r.paintVertexBuffer)}}upload(e){for(const r in this.binders){const u=this.binders[r];(u instanceof Ia||u instanceof ws||u instanceof hl)&&u.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const r=this.binders[e];(r instanceof Ia||r instanceof ws||r instanceof hl)&&r.destroy()}}}class tu{constructor(e,r,u=()=>!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.minzoom)||!!(this.maxzoom&&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 A<Rd?null:(b*=A=1/A,I*=A,C*=A,u=Math.sin(e),m=Math.cos(e),n[0]=b*b*(y=1-m)+m,n[1]=I*b*y+C*u,n[2]=C*b*y-I*u,n[3]=0,n[4]=b*I*y-C*u,n[5]=I*I*y+m,n[6]=C*I*y+b*u,n[7]=0,n[8]=b*C*y+I*u,n[9]=I*C*y-b*u,n[10]=C*C*y+m,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n)}Math.hypot||(Math.hypot=function(){for(var n=0,e=arguments.length;e--;)n+=arguments[e]*arguments[e];return Math.sqrt(n)});var jS=nu;function Wm(){var n=new Ao(3);return Ao!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function Jv(n){var e=new Ao(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function Sh(n){return Math.hypot(n[0],n[1],n[2])}function rc(n,e,r){var u=new Ao(3);return u[0]=n,u[1]=e,u[2]=r,u}function Ma(n,e,r){return n[0]=e[0]+r[0],n[1]=e[1]+r[1],n[2]=e[2]+r[2],n}function Ym(n,e,r){return n[0]=e[0]-r[0],n[1]=e[1]-r[1],n[2]=e[2]-r[2],n}function Qv(n,e,r){return n[0]=e[0]*r[0],n[1]=e[1]*r[1],n[2]=e[2]*r[2],n}function kh(n,e,r){return n[0]=Math.min(e[0],r[0]),n[1]=Math.min(e[1],r[1]),n[2]=Math.min(e[2],r[2]),n}function Ch(n,e,r){return n[0]=Math.max(e[0],r[0]),n[1]=Math.max(e[1],r[1]),n[2]=Math.max(e[2],r[2]),n}function Go(n,e,r){return n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n}function Ah(n,e,r,u){return n[0]=e[0]+r[0]*u,n[1]=e[1]+r[1]*u,n[2]=e[2]+r[2]*u,n}function eo(n,e){var r=e[0],u=e[1],m=e[2],y=r*r+u*u+m*m;return y>0&&(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<u.length;++m)zi(u[m],u[m],r);return to.fromPoints(u)}constructor(e,r){this.min=e,this.max=r,this.center=Go([],Ma([],this.min,this.max),.5)}quadrant(e){const r=[e%2==0,e<2],u=Jv(this.min),m=Jv(this.max);for(let y=0;y<r.length;y++)u[y]=r[y]?this.min[y]:this.center[y],m[y]=r[y]?this.center[y]:this.max[y];return m[2]=this.max[2],new to(u,m)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,r=this.max;return[[e[0],e[1],e[2]],[r[0],e[1],e[2]],[r[0],r[1],e[2]],[e[0],r[1],e[2]],[e[0],e[1],r[2]],[r[0],e[1],r[2]],[r[0],r[1],r[2]],[e[0],r[1],r[2]]]}intersects(e){const r=this.getCorners();let u=!0;for(let m=0;m<e.planes.length;m++){const y=e.planes[m];let b=0;for(let I=0;I<r.length;I++)b+=ts(y,r[I])+y[3]>=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;I<e.points.length;I++){const C=e.points[I][m]-this.min[m];y=Math.min(y,C),b=Math.max(b,C)}if(b<0||y>this.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(W<Math.acos($)){if(!u)return null;const mt=[],Ke=[];Go(mt,b,O/$),eo(Ke,Is(Ke,mt,A)),eo(b,Ma(b,A,Go(b,Ke,Math.tan(W)*O)))}const K=[];new Km(m,b).closestPointOnSphere(C,j,K);const re=eo([],bo(I,0)),de=eo([],bo(I,1)),Te=eo([],bo(I,2)),pe=ts(re,K),Ee=ts(de,K),Ce=ts(Te,K),Se=At(Math.asin(-Ee/j));let We=At(Math.atan2(pe,Ce));We=n.center.lng+function(mt,Ke){const st=(Ke-mt+180)%360-180;return st<-180?st+360:st}(n.center.lng,We);const Ze=Xs(We),nt=Mt(Ws(Se),0,1);return new lc(Ze,nt)}class YS{constructor(e,r,u){this.a=Is([],e,u),this.b=Is([],r,u),this.center=u;const m=eo([],this.a),y=eo([],this.b);this.angle=Math.acos(ts(m,y))}}function tg(n,e){if(n.angle===0)return null;let r;return r=n.a[e]===0?1/n.angle*.5*Math.PI:1/n.angle*Math.atan(n.b[e]/n.a[e]/Math.sin(n.angle)-1/Math.tan(n.angle)),r<0||r>1?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<<st);let jt=mt*Rt,Dt=jt+Rt,pn=Ke*Rt,Tt=pn+Rt,Xt=0;const mn=(jt+Dt)/2-Et;return mn>.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;mt<b.length;mt++)su(b[mt],Ze[mt],We);const nt=Ma([],Ze[Te],Ze[(Te+1)%4]);Go(nt,nt,.5),su(Se,nt,We)}for(const Ze of b)kh(A,A,Ze),Ch(C,C,Ze);return A[2]=Math.min(pe[2],Ee[2]),kh(A,A,Se),Ch(C,C,Se),new to(A,C)}function Od({x:n,y:e,z:r}){const u=1/(1<<r),m=new ri(qo(n*u),zr((e+1)*u)),y=new ri(qo((n+1)*u),zr(e*u));return new dl(m,y)}function ng(n){const e=Je(n.getNorth()),r=Je(n.getSouth()),u=Math.cos(e),m=Math.cos(r),y=Math.sin(e),b=Math.sin(r),I=n.getWest(),C=n.getEast();return[oc(m,b,I),oc(m,b,C),oc(u,y,C),oc(u,y,I)]}function oc(n,e,r,u=Zs){return r=Je(r),[n*Math.sin(r)*u,-e*u,n*Math.cos(r)*u]}function sc(n,e,r){return oc(Math.cos(Je(n)),Math.sin(Je(n)),e,r)}function Dh(n,e,r,u){const m=1<<r.z,y=(n/Wt+r.x)/m;return sc(zr((e/Wt+r.y)/m),qo(y),u)}function Nd({min:n,max:e}){return XS/Math.max(e[0]-n[0],e[1]-n[1],e[2]-n[2])}const dx=new Float64Array(16);function zh(n){const e=Nd(n),r=Hv(dx,[e,e,e]);return Mh(r,r,((u=[])[0]=-(m=n.min)[0],u[1]=-m[1],u[2]=-m[2],u));var u,m}function ig(n){const e=(u=n.min,(r=dx)[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=u[0],r[13]=u[1],r[14]=u[2],r[15]=1,r);var r,u;const m=1/Nd(n);return iu(e,e,[m,m,m])}function px(n,e,r,u,m){const y=function(C){const A=Wt/(2*Math.PI);return C/(2*Math.PI)/A}(r),b=[n,e,-r/(2*Math.PI)],I=Ts(new Float64Array(16));return Mh(I,I,b),iu(I,I,[y,y,y]),Xm(I,I,Je(-m)),Dd(I,I,Je(-u)),I}function ac(n){return Gt(eg,ux,n)}function mx(n,e){const r=sc(e.lat,e.lng),u=function(W){const K=sc(W._center.lat,W._center.lng);let re=Hm([],rc(0,1,0),K);const de=Kv([],-W.angle,K);re=zi(re,re,de),Kv(de,-W._pitch,re);const Te=eo([],K);return Go(Te,Te,zd(W.cameraToCenterDistance/W.pixelsPerMeter)),zi(Te,Te,de),Ma([],K,Te)}(n);return b=(m=Ym([],u,r))[0],I=m[1],C=m[2],A=(y=r)[0],O=y[1],B=y[2],$=(j=Math.sqrt(b*b+I*I+C*C)*Math.sqrt(A*A+O*O+B*B))&&ts(m,y)/j,Math.acos(Math.min(Math.max($,-1),1));var m,y,b,I,C,A,O,B,j,$}function rg(n,e){return mx(n,e)>Math.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: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}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;I<n.length;I++){const C=n[I],{x:A,y:O}=C;e(C),sg(b,m,y,A,O,u,C,e,r),m=A,y=O,u=C}return b}function ag(n,e,r,u){if(u(e,r)){const m=e.add(r)._mult(.5);ag(n,e,m,u),ag(n,m,r,u)}else n.push(r)}function QS(n,e){let r=n[0];const u=[r];for(let m=1;m<n.length;m++){const y=n[m];ag(u,r,y,e),r=y}return u}const lg=Math.pow(2,14)-1,bx=-lg-1;function ek(n,e){const r=Math.round(n.x*e),u=Math.round(n.y*e);return n.x=Mt(r,bx,lg),n.y=Mt(u,bx,lg),(r<n.x||r>n.x+1||u<n.y||u>n.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<<e.z,{scale:I,x:C,y:A,projection:O}=r,B=j=>{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<u.length;j++)if(n.type!==1)u[j]=xx(u[j],B,1);else{const $=[];for(const W of u[j])W.x<0||W.x>=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;r<n.length;r++)if(lu(e,n[r]))return!0;for(let r=0;r<e.length;r++)if(lu(n,e[r]))return!0;return!!cg(n,e)}function tk(n,e,r){return!!lu(n,e)||!!hg(e,n,r)}function Ex(n,e){if(n.length===1)return Ix(e,n[0]);for(let r=0;r<e.length;r++){const u=e[r];for(let m=0;m<u.length;m++)if(lu(n,u[m]))return!0}for(let r=0;r<n.length;r++)if(Ix(e,n[r]))return!0;for(let r=0;r<e.length;r++)if(cg(n,e[r]))return!0;return!1}function nk(n,e,r){if(n.length>1){if(cg(n,e))return!0;for(let u=0;u<e.length;u++)if(hg(e[u],n,r))return!0}for(let u=0;u<n.length;u++)if(hg(n[u],e,r))return!0;return!1}function cg(n,e){if(n.length===0||e.length===0)return!1;for(let r=0;r<n.length-1;r++){const u=n[r],m=n[r+1];for(let y=0;y<e.length-1;y++)if(ik(u,m,e[y],e[y+1]))return!0}return!1}function ik(n,e,r,u){return _i(n,r,u)!==_i(e,r,u)&&_i(n,e,r)!==_i(n,e,u)}function hg(n,e,r){const u=r*r;if(e.length===1)return n.distSqr(e[0])<u;for(let m=1;m<e.length;m++)if(Tx(n,e[m-1],e[m])<u)return!0;return!1}function Tx(n,e,r){const u=e.distSqr(r);if(u===0)return n.distSqr(e);const m=((n.x-e.x)*(r.x-e.x)+(n.y-e.y)*(r.y-e.y))/u;return n.distSqr(m<0?e:m>1?r:r.sub(e)._mult(m)._add(e))}function Ix(n,e){let r,u,m,y=!1;for(let b=0;b<n.length;b++){r=n[b];for(let I=0,C=r.length-1;I<r.length;C=I++)u=r[I],m=r[C],u.y>e.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;u<n.length;m=u++){const y=n[u],b=n[m];y.y>e.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;b<n.length-1;b++)if(rk(n[b],n[b+1],y))return!0;return!1}function rk(n,e,r){const u=r[0],m=r[2];if(n.x<u.x&&e.x<u.x||n.x>m.x&&e.x>m.x||n.y<u.y&&e.y<u.y||n.y>m.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;I<n.length;I++)b.push(n[I].sub(y));return b}function kx(n,e,r,u){const m=Ie.convert(n)._mult(u);return e==="viewport"&&m._rotate(-r),m}Ft(ug,"CircleBucket",{omit:["layers"]});const ok=new _e({"circle-sort-key":new oe(Qe.layout_circle["circle-sort-key"])});var sk={paint:new _e({"circle-radius":new oe(Qe.paint_circle["circle-radius"]),"circle-color":new oe(Qe.paint_circle["circle-color"]),"circle-blur":new oe(Qe.paint_circle["circle-blur"]),"circle-opacity":new oe(Qe.paint_circle["circle-opacity"]),"circle-translate":new H(Qe.paint_circle["circle-translate"]),"circle-translate-anchor":new H(Qe.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new H(Qe.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new H(Qe.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new oe(Qe.paint_circle["circle-stroke-width"]),"circle-stroke-color":new oe(Qe.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new oe(Qe.paint_circle["circle-stroke-opacity"])}),layout:ok};function Cx(n,e,r,u,m,y,b,I,C){if(y&&n.queryGeometry.isAboveHorizon)return!1;y&&(C*=n.pixelToTileUnitsFactor);const A=n.tileID.canonical,O=r.projection.upVectorScale(A,r.center.lat,r.worldSize).metersToTile;for(const B of e)for(const j of B){const $=j.add(I),W=m&&r.elevation?r.elevation.exaggeration()*m.getElevationAt($.x,$.y,!0):0,K=r.projection.projectTilePoint($.x,$.y,A);if(W>0){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<<A.z));C/=r.projection.pixelsPerMeter(pe,1)/Ms(1,pe)}if(tk(de,re,C))return!0}return!1}function ak(n,e,r,u){const m=ru([],[n,e,r,1],u);return new Ie(m[0]/m[3],m[1]/m[3])}const Ax=rc(0,0,0),lk=rc(0,0,1);function uk(n,e){const r=Wm();return Ax[2]=e,n.intersectsPlane(Ax,lk,r),new Ie(r[0],r[1])}class Px extends ug{}function Lx(n,{width:e,height:r},u,m){if(m){if(m instanceof Uint8ClampedArray)m=new Uint8Array(m.buffer);else if(m.length!==e*r*u)throw new RangeError("mismatched image size")}else m=new Uint8Array(e*r*u);return n.width=e,n.height=r,n.data=m,n}function Rx(n,e,r){const{width:u,height:m}=e;u===n.width&&m===n.height||(fg(n,e,{x:0,y:0},{x:0,y:0},{width:Math.min(n.width,u),height:Math.min(n.height,m)},r),n.width=u,n.height=m,n.data=e.data)}function fg(n,e,r,u,m,y){if(m.width===0||m.height===0)return e;if(m.width>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<m.height;C++){const A=((r.y+C)*n.width+r.x)*y,O=((u.y+C)*e.width+u.x)*y;for(let B=0;B<m.width*y;B++)I[O+B]=b[A+B]}return e}Ft(Px,"HeatmapBucket",{omit:["layers"]});class ka{constructor(e,r){Lx(this,e,1,r)}resize(e){Rx(this,new ka(e),1)}clone(){return new ka({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,u,m,y){fg(e,r,u,m,y,1)}}class Po{constructor(e,r){Lx(this,e,4,r)}resize(e){Rx(this,new Po(e),4)}replace(e,r){r?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Po({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,r,u,m,y){fg(e,r,u,m,y,4)}}Ft(ka,"AlphaImage"),Ft(Po,"RGBAImage");var ck={paint:new _e({"heatmap-radius":new oe(Qe.paint_heatmap["heatmap-radius"]),"heatmap-weight":new oe(Qe.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new H(Qe.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ge(Qe.paint_heatmap["heatmap-color"]),"heatmap-opacity":new H(Qe.paint_heatmap["heatmap-opacity"])})};function dg(n){const e={},r=n.resolution||256,u=n.clips?n.clips.length:1,m=n.image||new Po({width:r,height:u}),y=(b,I,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;b<u;++b,I+=4*r)for(let C=0,A=0;C<r;C++,A+=4){const O=C/(r-1),{start:B,end:j}=n.clips[b];y(I,A,B*(1-O)+j*O)}else for(let b=0,I=0;b<r;b++,I+=4)y(0,I,b/(r-1));return m}var hk={paint:new _e({"hillshade-illumination-direction":new H(Qe.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new H(Qe.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new H(Qe.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new H(Qe.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new H(Qe.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new H(Qe.paint_hillshade["hillshade-accent-color"])})};const fk=Oe([{name:"a_pos",components:2,type:"Int16"}],4),{members:dk}=fk;var pg={exports:{}};function Ud(n,e,r){r=r||2;var u,m,y,b,I,C,A,O=e&&e.length,B=O?e[0]*r:n.length,j=Dx(n,0,B,r,!0),$=[];if(!j||j.next===j.prev)return $;if(O&&(j=function(K,re,de,Te){var pe,Ee,Ce,Se=[];for(pe=0,Ee=re.length;pe<Ee;pe++)(Ce=Dx(K,re[pe]*Te,pe<Ee-1?re[pe+1]*Te:K.length,Te,!1))===Ce.next&&(Ce.steiner=!0),Se.push(bk(Ce));for(Se.sort(yk),pe=0;pe<Se.length;pe++)de=vk(Se[pe],de);return de}(n,e,j,r)),n.length>80*r){u=y=n[0],m=b=n[1];for(var W=r;W<B;W+=r)(I=n[W])<u&&(u=I),(C=n[W+1])<m&&(m=C),I>y&&(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<r;y+=u)b=Nx(y,n[y],n[y+1],b);else for(y=r-u;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;re<Ze&&(Se++,Te=Te.nextZ);re++);for(We=Ze;Se>0||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=m<y?m<b?m:b:y<b?y:b,B=I<C?I<A?I:A:C<A?C:A,j=m>y?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,$=I<C?I<A?I:A:C<A?C:A,W=O<B?O<j?O:j:B<j?B:j,K=I>C?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.next.x?I:I.next,B===C))return b}I=I.next}while(I!==y);if(!b)return null;var j,$=b,W=b.x,K=b.y,re=1/0;I=b;do C>=I.x&&I.x>=W&&C!==I.x&&cc(A<K?C:O,A,W,K,A<K?O:C,A,I.x,I.y)&&(j=Math.abs(A-I.y)/(C-I.x),Bh(I,m)&&(j<re||j===re&&(I.x>b.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<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==n);return r}function cc(n,e,r,u,m,y,b,I){return(m-b)*(e-I)>=(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;y<r;y+=u)m+=(n[b]-n[y])*(n[y+1]+n[b+1]),b=y;return m}pg.exports=Ud,pg.exports.default=Ud,Ud.deviation=function(n,e,r,u){var m=e&&e.length,y=Math.abs(_g(n,0,m?e[0]*r:n.length,r));if(m)for(var b=0,I=e.length;b<I;b++)y-=Math.abs(_g(n,e[b]*r,b<I-1?e[b+1]*r:n.length,r));var C=0;for(b=0;b<u.length;b+=3){var A=u[b]*r,O=u[b+1]*r,B=u[b+2]*r;C+=Math.abs((n[A]-n[B])*(n[O+1]-n[A+1])-(n[A]-n[O])*(n[B+1]-n[A+1]))}return y===0&&C===0?0:Math.abs((C-y)/y)},Ud.flatten=function(n){for(var e=n[0][0].length,r={vertices:[],holes:[],dimensions:e},u=0,m=0;m<n.length;m++){for(var y=0;y<n[m].length;y++)for(var b=0;b<e;b++)r.vertices.push(n[m][y][b]);m>0&&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);B<j;){for(Vh(n,B,j),B++,j--;m(n[B],O)<0;)B++;for(;m(n[j],O)>0;)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 n<e?-1:n>e?1:0}function vg(n,e){const r=n.length;if(r<=1)return[n];const u=[];let m,y;for(let b=0;b<r;b++){const I=Yi(n[b]);I!==0&&(n[b].area=Math.abs(I),y===void 0&&(y=I<0),y===I<0?(m&&u.push(m),m=[n[b]]):m.push(n[b]))}if(m&&u.push(m),e>1)for(let b=0;b<u.length;b++)u[b].length<=e||(Ek(u[b],e,1,u[b].length-1,Ik),u[b]=u[b].slice(0,e));return u}function Ik(n,e){return e.area-n.area}function xg(n,e,r){const u=r.patternDependencies;let m=!1;for(const y of e){const b=y.paint.get(`${n}-pattern`);b.isConstant()||(m=!0);const I=b.constantOr(null);I&&(m=!0,u[I]=!0)}return m}function bg(n,e,r,u,m){const y=m.patternDependencies;for(const b of e){const I=b.paint.get(`${n}-pattern`).value;if(I.kind!=="constant"){let C=I.evaluate({zoom:u},r,{},m.availableImages);C=C&&C.name?C.name:C,y[C]=!0,r.patterns[b.id]=C}}return r}class Zd{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.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<W.length;de++)this.layoutVertexArray.emplaceBack(W[de].x,W[de].y),this.indexArray2.emplaceBack(re+de-1,re+de),B.push(W[de].x),B.push(W[de].y);K.vertexLength+=W.length,K.primitiveLength+=W.length}const $=yg(B,j);for(let W=0;W<$.length;W+=3)this.indexArray.emplaceBack(O+$[W],O+$[W+1],O+$[W+2]);A.vertexLength+=C,A.primitiveLength+=$.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,u,y,b,m)}}Ft(Zd,"FillBucket",{omit:["layers","patternFeatures"]});const Mk=new _e({"fill-sort-key":new oe(Qe.layout_fill["fill-sort-key"])});var Sk={paint:new _e({"fill-antialias":new H(Qe.paint_fill["fill-antialias"]),"fill-opacity":new oe(Qe.paint_fill["fill-opacity"]),"fill-color":new oe(Qe.paint_fill["fill-color"]),"fill-outline-color":new oe(Qe.paint_fill["fill-outline-color"]),"fill-translate":new H(Qe.paint_fill["fill-translate"]),"fill-translate-anchor":new H(Qe.paint_fill["fill-translate-anchor"]),"fill-pattern":new oe(Qe.paint_fill["fill-pattern"])}),layout:Mk};const kk=Oe([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Ck=Oe([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Ak=Oe([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Pk}=kk;var $d={},Lk=ze,Fx=hc;function hc(n,e,r,u,m){this.properties={},this.extent=r,this.type=0,this._pbf=n,this._geometry=-1,this._keys=u,this._values=m,n.readFields(Rk,this,e)}function Rk(n,e,r){n==1?e.id=r.readVarint():n==2?function(u,m){for(var y=u.readVarint()+u.pos;u.pos<y;){var b=m._keys[u.readVarint()],I=m._values[u.readVarint()];m.properties[b]=I}}(r,e):n==3?e.type=r.readVarint():n==4&&(e._geometry=r.pos)}function Dk(n){for(var e,r,u=0,m=0,y=n.length,b=y-1;m<y;b=m++)u+=((r=n[b]).x-(e=n[m]).x)*(e.y+r.y);return u}hc.types=["Unknown","Point","LineString","Polygon"],hc.prototype.loadGeometry=function(){var n=this._pbf;n.pos=this._geometry;for(var e,r=n.readVarint()+n.pos,u=1,m=0,y=0,b=0,I=[];n.pos<r;){if(m<=0){var C=n.readVarint();u=7&C,m=C>>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<e;){if(u<=0){var O=n.readVarint();r=7&O,u=O>>3}if(u--,r===1||r===2)(m+=n.readSVarint())<b&&(b=m),m>I&&(I=m),(y+=n.readSVarint())<C&&(C=y),y>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<C.length;u++)B[u]=C[u][0];O(C=B);break;case 2:for(u=0;u<C.length;u++)O(C[u]);break;case 3:for(C=function($){var W=$.length;if(W<=1)return[$];for(var K,re,de=[],Te=0;Te<W;Te++){var pe=Dk($[Te]);pe!==0&&(re===void 0&&(re=pe<0),re===pe<0?(K&&de.push(K),K=[$[Te]]):K.push($[Te]))}return K&&de.push(K),de}(C),u=0;u<C.length;u++)for(m=0;m<C[u].length;m++)O(C[u][m])}C.length===1?C=C[0]:A="Multi"+A;var j={type:"Feature",geometry:{type:A,coordinates:C},properties:this.properties};return"id"in this&&(j.id=this.id),j};var zk=Fx,Vx=Ux;function Ux(n,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=n,this._keys=[],this._values=[],this._features=[],n.readFields(Ok,this,e),this.length=this._features.length}function Ok(n,e,r){n===15?e.version=r.readVarint():n===1?e.name=r.readString():n===5?e.extent=r.readVarint():n===2?e._features.push(r.pos):n===3?e._keys.push(r.readString()):n===4&&e._values.push(function(u){for(var m=null,y=u.readVarint()+u.pos;u.pos<y;){var b=u.readVarint()>>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;j<C.length-1;j++){const $=C[j].x,W=C[j].y,K=C[j+1].x,re=C[j+1].y,de=u===0?$:W,Te=u===0?K:re;de<e?Te>e&&y(A,$,W,K,re,e):de>r?Te<r&&y(A,$,W,K,re,r):A.push(C[j]),Te<e&&de>=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.x<u.x?u.x=e.x:e.x>m.x&&(m.x=e.x),e.y<u.y?u.y=e.y:e.y>m.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];r<u[0]&&(u[0]=r),r>u[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<<y.z)*2));return 80150034*b/(b*b+1)/Wt/(1<<y.z)}(u),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:y,id:b,index:I,sourceLayerIndex:C}of e){const A=this.layers[0]._featureFilter.needGeometry,O=au(y,A);if(!this.layers[0]._featureFilter.filter(new N(this.zoom),O,u))continue;const B={id:b,sourceLayerIndex:C,index:I,geometry:A?O.geometry:Sa(y,u,m),properties:y.properties,type:y.type,patterns:{}},j=this.layoutVertexArray.length;this.hasPattern?this.features.push(bg("fill-extrusion",this.layers,B,this.zoom,r)):this.addFeature(B,B.geometry,I,u,{},r.availableImages,m),r.featureIndex.insert(y,B.geometry,I,C,this.index,j)}this.sortBorders()}addFeatures(e,r,u,m,y){for(const b of this.features){const{geometry:I}=b;this.addFeature(b,I,b.index,r,u,m,y)}this.sortBorders()}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,Pk),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Ak.members,!0))),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.centroidVertexArray.length!==0&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Ck.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,u,m,y,b,I){const C=[new Ie(0,0),new Ie(Wt,Wt)],A=I.projection,O=A.name==="globe",B=this.enableTerrain&&!O?new jx:null,j=Fk[e.type]==="Polygon";O&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new yt);const $=vg(r,500);for(let de=$.length-1;de>=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;st<nt.length;st++){const at=nt[st],ht=nt[st===nt.length-1?1:st+1];let{x:Et,y:et}=at;if(re){Ke=ht.sub(at)._perp()._unit();const Rt=mt.add(Ke)._unit(),jt=re*Math.min(4,1/(mt.x*Rt.x+mt.y*Rt.y));Et+=jt*Rt.x,et+=jt*Rt.y,mt=Ke}Uh(this.layoutVertexArray,Et,et,0,0,1,1,0),Ce.vertexLength++,Se.push(at.x,at.y),O&&jh(this.layoutVertexExtArray,A.projectTilePoint(Et,et,m),A.upVector(m,Et,et))}}const Ze=yg(Se,We);for(let nt=0;nt<Ze.length;nt+=3)this.indexArray.emplaceBack(pe+Ze[nt],pe+Ze[nt+2],pe+Ze[nt+1]),Ce.primitiveLength++}for(const Se of de){B&&Se.length&&B.startRing(Se[0]);let We,Ze,nt,mt=Se.length>4&&$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;at<Se.length;at++){let Et=Se[at-1],et=Se[at];const Rt=Se[at===Se.length-1?1:at+1];if(B&&j&&B.currentPolyCount.top++,Zx(et,Et,Te)){re&&(Ze=Rt.sub(et)._perp()._unit(),st=!st);continue}B&&B.append(et,Et);const jt=et.sub(Et)._perp(),Dt=jt.x/(Math.abs(jt.x)+Math.abs(jt.y)),pn=jt.y>0?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;C<I.top;C++)this.centroidVertexArray.emplace(b++,m,y);for(let C=0;C<2*I.edges;C++)this.centroidVertexArray.emplace(b++,0,y),this.centroidVertexArray.emplace(b++,m,y)}}}function Gx(n,e){const r=n.add(e)._unit();return n.x*r.x+n.y*r.y}function Uk(n,e,r,u){const m=e.sub(n)._perp()._unit(),y=r.sub(e)._perp()._unit();return qx(n,e,r,Gx(m,y),u)}function qx(n,e,r,u,m){const y=Math.sqrt(1-u*u);return Math.min(n.dist(e)/3,e.dist(r)/3,m*y/u)}function Zx(n,e,r){return n.x<r[0].x&&e.x<r[0].x||n.x>r[1].x&&e.x>r[1].x||n.y<r[0].y&&e.y<r[0].y||n.y>r[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<<r.z,m=qo(r.x/u),y=qo((r.x+1)/u),b=zr(r.y/u),I=zr((r.y+1)/u);return function(C,A,O,B,j=0,$){const W=[];if(!C.length||!O||!B)return W;const K=(Se,We)=>{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;Se<Math.abs(Te);Se++)pe.push(Te>0?0:1);for(let Se=0;Se<Math.min(re,de);Se++)pe.push(0),pe.push(1);let Ee=C;if(Ee=Wd(Ee,A[0].y-j,A[1].y+j,1),Ee=Wd(Ee,A[0].x-j,A[1].x+j,0),!Ee.length)return W;const Ce=[];for(pe.length?Ce.push({polygons:Ee,bounds:A,depth:0}):K(Ee,A);Ce.length;){const Se=Ce.pop(),We=Se.depth,Ze=pe[We],nt=Se.bounds[0],mt=Se.bounds[1],Ke=Ze===0?nt.x:nt.y,st=Ze===0?mt.x:mt.y,at=$?$(Ze,Ke,st):.5*(Ke+st),ht=Wd(Se.polygons,Ke-j,at+j,Ze),Et=Wd(Se.polygons,at-j,st+j,Ze);if(ht.length){const et=[nt,new Ie(Ze===0?at:mt.x,Ze===1?at:mt.y)];pe.length>We+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<<O-1,A+=(b&C?1:0)+(I&C?2:0);return A}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(r==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",m).replace("{bbox-epsg-3857}",u)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Kx{constructor(e,r){this.wrap=e,this.canonical=r,this.key=qh(e,r.z,r.z,r.x,r.y)}}class no{constructor(e,r,u,m,y){this.overscaledZ=e,this.wrap=r,this.canonical=new Yd(u,+m,+y),this.key=r===0&&e===u?this.canonical.key:qh(r,e,u,m,y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const r=this.canonical.z-e;return e>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<this.overscaledZ&&e.canonical.x===this.canonical.x>>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.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new no(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new no(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Kx(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function qh(n,e,r,u,m){const y=1<<Math.min(r,22);let b=y*(m%y)+u%y;return n&&r<22&&(b+=y*y*((n<0?-2*n-1:2*n)%(1<<2*(22-r)))),16*(32*b+r)+(e-r)}Ft(Yd,"CanonicalTileID"),Ft(no,"OverscaledTileID",{omit:["projMatrix"]});class fc extends Ie{constructor(e,r,u){super(e,r),this.z=u}}function Zh(n,e){return n.x*e.x+n.y*e.y}function Jx(n,e){if(n.length===1){let r=0;const u=e[r++];let m;for(;!m||u.equals(m);)if(m=e[r++],!m)return 1/0;for(;r<e.length;r++){const y=e[r],b=n[0],I=m.sub(u),C=y.sub(u),A=b.sub(u),O=Zh(I,I),B=Zh(I,C),j=Zh(C,C),$=Zh(A,I),W=Zh(A,C),K=O*j-B*B,re=(j*$-B*W)/K,de=(O*W-B*$)/K,Te=u.z*(1-re-de)+m.z*re+y.z*de;if(isFinite(Te))return Te}return 1/0}{let r=1/0;for(const u of e)r=Math.min(r,u.z);return r}}function Qx(n,e,r,u,m,y,b,I){const C=b*m.getElevationAt(n,e,!0,!0),A=y[0]!==0,O=A?y[1]===0?b*(y[0]/7-450):b*function(B,j,$){const W=Math.floor(j[0]/8),K=Math.floor(j[1]/8),re=10*(j[0]-8*W),de=10*(j[1]-8*K),Te=B.getElevationAt(W,K,!0,!0),pe=B.getMeterToDEM($),Ee=Math.floor(.5*(re*pe-1)),Ce=Math.floor(.5*(de*pe-1)),Se=B.tileCoordToPixel(W,K),We=2*Ee+1,Ze=2*Ce+1,nt=function(Et,et,Rt,jt,Dt){return[Et.getElevationAtPixel(et,Rt,!0),Et.getElevationAtPixel(et+Dt,Rt,!0),Et.getElevationAtPixel(et,Rt+Dt,!0),Et.getElevationAtPixel(et+jt,Rt+Dt,!0)]}(B,Se.x-Ee,Se.y-Ce,We,Ze),mt=Math.abs(nt[0]-nt[1]),Ke=Math.abs(nt[2]-nt[3]),st=Math.abs(nt[0]-nt[2])+Math.abs(nt[1]-nt[3]),at=Math.min(.25,.5*pe*(mt+Ke)/We),ht=Math.min(.25,.5*pe*st/Ze);return Te+Math.max(at*re,ht*de)}(m,y,I):C;return{base:C+(r===0)?-1:r,top:A?Math.max(O+u,C+r+2):C+u}}const qk=Oe([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Zk}=qk,$k=Oe([{name:"a_packed",components:4,type:"Float32"}]),{members:Xk}=$k,Wk=Xd.types,Yk=Math.cos(Math.PI/180*37.5);class Hd{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.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<e.length-1;de++)this.totalDistance+=e[de].dist(e[de+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const I=Wk[r.type]==="Polygon";let C=e.length;for(;C>=2&&e[C-1].equals(e[C-2]);)C--;let A=0;for(;A<C-1&&e[A].equals(e[A+1]);)A++;if(C<(I?3:2))return;u==="bevel"&&(y=1.05);const O=this.overscaling<=16?15*Wt/(512*this.overscaling):0,B=this.segments.prepareSegment(10*C,this.layoutVertexArray,this.indexArray);let j,$,W,K,re;this.e1=this.e2=-1,I&&(j=e[C-2],re=e[A].sub(j)._unit()._perp());for(let de=A;de<C;de++){if(W=de===C-1?I?e[A+1]:void 0:e[de+1],W&&e[de].equals(W))continue;re&&(K=re),j&&($=j),j=e[de],re=W?W.sub(j)._unit()._perp():K,K=K||re;let Te=K.add(re);Te.x===0&&Te.y===0||Te._unit();const pe=K.x*re.x+K.y*re.y,Ee=Te.x*re.x+Te.y*re.y,Ce=Ee!==0?1/Ee:1/0,Se=2*Math.sqrt(2-2*Ee),We=Ee<Yk&&$&&W,Ze=K.x*re.y-K.y*re.x>0;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"&&(Ce<b?mt="miter":Ce<=2&&(mt="fakeround")),mt==="miter"&&Ce>y&&(mt="bevel"),mt==="bevel"&&(Ce>2&&(mt="flipbevel"),Ce<y&&(mt="miter")),$&&this.updateDistance($,j),mt==="miter")Te._mult(Ce),this.addCurrentVertex(j,Te,0,0,B);else if(mt==="flipbevel"){if(Ce>100)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;Et<ht;Et++){let et=Et/ht;if(et!==.5){const jt=et-.5;et+=et*jt*(et-1)*((1.0904+pe*(pe*(3.55645-1.43519*pe)-3.2452))*jt*jt+(.848013+pe*(.215638*pe-1.06021)))}const Rt=re.sub(K)._mult(et)._add(K)._unit()._mult(Ze?-1:1);this.addHalfVertex(j,Rt.x,Rt.y,!1,Ze,0,B)}}W&&this.addCurrentVertex(j,re,-st,-at,B)}else if(mt==="butt")this.addCurrentVertex(j,Te,0,0,B);else if(mt==="square"){const Ke=$?1:-1;$||this.addCurrentVertex(j,Te,Ke,Ke,B),this.addCurrentVertex(j,Te,0,0,B),$&&this.addCurrentVertex(j,Te,Ke,Ke,B)}else mt==="round"&&($&&(this.addCurrentVertex(j,K,0,0,B),this.addCurrentVertex(j,K,1,1,B,!0)),W&&(this.addCurrentVertex(j,re,-1,-1,B,!0),this.addCurrentVertex(j,re,0,0,B)));if(We&&de<C-1){const Ke=j.dist(W);if(Ke>2*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.length&&u[y]<=n;)y++;y=Math.max(0,y-1);let b=y;for(;b<u.length&&u[b]<n+1;)b++;b=Math.min(u.length-1,b);const I=u[y],C=u[b];return r.kind==="composite"?{kind:"composite",minZoom:I,maxZoom:C,interpolationType:m}:{kind:"camera",minZoom:I,maxZoom:C,minSize:r.evaluate(new N(I)),maxSize:r.evaluate(new N(C)),interpolationType:m}}}function Kd(n,{uSize:e,uSizeT:r},{lowerSize:u,upperSize:m}){return n.kind==="source"?u/Ss:n.kind==="composite"?Nn(u/Ss,m/Ss,r):e}function dc(n,e){let r=0,u=0;if(n.kind==="constant")u=n.layoutSize;else if(n.kind!=="source"){const{interpolationType:m,minZoom:y,maxZoom:b}=n,I=m?Mt(_o.interpolationFactor(m,e,y,b),0,1):0;n.kind==="camera"?u=Nn(n.minSize,n.maxSize,I):r=I}return{uSizeT:r,uSize:u}}var iC=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:Ss,evaluateSizeForFeature:Kd,evaluateSizeForZoom:dc,getSizeData:Eg});function rC(n,e,r){return n.sections.forEach(u=>{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<<I)-1,A=C>>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<<A)-1,B=O>>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<<m|I,A+=m;A>0;n[r+$]=255&b,$+=W,b/=256,A-=8);n[r+$-W]|=128*K};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */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<n.length;r++)e.writeVarint(n[r])}function lC(n,e){for(var r=0;r<n.length;r++)e.writeSVarint(n[r])}function uC(n,e){for(var r=0;r<n.length;r++)e.writeFloat(n[r])}function cC(n,e){for(var r=0;r<n.length;r++)e.writeDouble(n[r])}function hC(n,e){for(var r=0;r<n.length;r++)e.writeBoolean(n[r])}function fC(n,e){for(var r=0;r<n.length;r++)e.writeFixed32(n[r])}function dC(n,e){for(var r=0;r<n.length;r++)e.writeSFixed32(n[r])}function pC(n,e){for(var r=0;r<n.length;r++)e.writeFixed64(n[r])}function mC(n,e){for(var r=0;r<n.length;r++)e.writeSFixed64(n[r])}function Jd(n,e){return(n[e]|n[e+1]<<8|n[e+2]<<16)+16777216*n[e+3]}function mc(n,e,r){n[r]=e,n[r+1]=e>>>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<r;){var u=this.readVarint(),m=u>>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;b<m;){var I,C,A,O=r[b],B=null,j=O>239?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.pos<r;)n.push(this.readVarint(e));return n},readPackedSVarint:function(n){if(this.type!==ci.Bytes)return n.push(this.readSVarint());var e=Ca(this);for(n=n||[];this.pos<e;)n.push(this.readSVarint());return n},readPackedBoolean:function(n){if(this.type!==ci.Bytes)return n.push(this.readBoolean());var e=Ca(this);for(n=n||[];this.pos<e;)n.push(this.readBoolean());return n},readPackedFloat:function(n){if(this.type!==ci.Bytes)return n.push(this.readFloat());var e=Ca(this);for(n=n||[];this.pos<e;)n.push(this.readFloat());return n},readPackedDouble:function(n){if(this.type!==ci.Bytes)return n.push(this.readDouble());var e=Ca(this);for(n=n||[];this.pos<e;)n.push(this.readDouble());return n},readPackedFixed32:function(n){if(this.type!==ci.Bytes)return n.push(this.readFixed32());var e=Ca(this);for(n=n||[];this.pos<e;)n.push(this.readFixed32());return n},readPackedSFixed32:function(n){if(this.type!==ci.Bytes)return n.push(this.readSFixed32());var e=Ca(this);for(n=n||[];this.pos<e;)n.push(this.readSFixed32());return n},readPackedFixed64:function(n){if(this.type!==ci.Bytes)return n.push(this.readFixed64());var e=Ca(this);for(n=n||[];this.pos<e;)n.push(this.readFixed64());return n},readPackedSFixed64:function(n){if(this.type!==ci.Bytes)return n.push(this.readSFixed64());var e=Ca(this);for(n=n||[];this.pos<e;)n.push(this.readSFixed64());return n},skip:function(n){var e=7&n;if(e===ci.Varint)for(;this.buf[this.pos++]>127;);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;e<this.pos+n;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(n){this.realloc(4),mc(this.buf,n,this.pos),this.pos+=4},writeSFixed32:function(n){this.realloc(4),mc(this.buf,n,this.pos),this.pos+=4},writeFixed64:function(n){this.realloc(8),mc(this.buf,-1&n,this.pos),mc(this.buf,Math.floor(n*a1),this.pos+4),this.pos+=8},writeSFixed64:function(n){this.realloc(8),mc(this.buf,-1&n,this.pos),mc(this.buf,Math.floor(n*a1),this.pos+4),this.pos+=8},writeVarint:function(n){(n=+n||0)>268435455||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;C<m.length;C++){if((b=m.charCodeAt(C))>55295&&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<e;r++)this.buf[this.pos++]=n[r]},writeRawMessage:function(n,e){this.pos++;var r=this.pos;n(e,this);var u=this.pos-r;u>=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();I<u.length&&(u[I]=A)}else b.h===C.h?(C.x+=b.w,C.w-=b.w):b.w===C.w?(C.y+=b.h,C.h-=b.h):(u.push({x:C.x+b.w,y:C.y,w:C.w-b.w,h:b.h}),C.y+=b.h,C.h-=b.h);break}}return{w:m,h:y,fill:e/(m*y)||0}}const yo=1;class Sg{constructor(e,{pixelRatio:r,version:u,stretchX:m,stretchY:y,content:b}){this.paddedRect=e,this.pixelRatio=r,this.stretchX=m,this.stretchY=y,this.content=b,this.version=u}get tl(){return[this.paddedRect.x+yo,this.paddedRect.y+yo]}get br(){return[this.paddedRect.x+this.paddedRect.w-yo,this.paddedRect.y+this.paddedRect.h-yo]}get displaySize(){return[(this.paddedRect.w-2*yo)/this.pixelRatio,(this.paddedRect.h-2*yo)/this.pixelRatio]}}class f1{constructor(e,r){const u={},m={};this.haveRenderCallbacks=[];const y=[];this.addImages(e,u,y),this.addImages(r,m,y);const{w:b,h:I}=Mg(y),C=new Po({width:b||1,height:I||1});for(const A in e){const O=e[A],B=u[A].paddedRect;Po.copy(O.data,C,{x:0,y:0},{x:B.x+yo,y:B.y+yo},O.data)}for(const A in r){const O=r[A],B=m[A].paddedRect,j=B.x+yo,$=B.y+yo,W=O.data.width,K=O.data.height;Po.copy(O.data,C,{x:0,y:0},{x:j,y:$},O.data),Po.copy(O.data,C,{x:0,y:K-1},{x:j,y:$-1},{width:W,height:1}),Po.copy(O.data,C,{x:0,y:0},{x:j,y:$+K},{width:W,height:1}),Po.copy(O.data,C,{x:W-1,y:0},{x:j-1,y:$},{width:1,height:K}),Po.copy(O.data,C,{x:0,y:0},{x:j+W,y:$},{width:1,height:K})}this.image=C,this.iconPositions=u,this.patternPositions=m}addImages(e,r,u){for(const m in e){const y=e[m],b={x:0,y:0,w:y.data.width+2*yo,h:y.data.height+2*yo};u.push(b),r[m]=new Sg(b,y),y.hasRenderCallback&&this.haveRenderCallbacks.push(m)}}patchUpdatedImages(e,r){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(u=>e.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<e.sections.length;m++){const y=e.sections[m];y.image?u.addImageSection(y):u.addTextSection(y,r)}return u}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(e){this.text=function(r,u){let m="";for(let y=0;y<r.length;y++){const b=r.charCodeAt(y+1)||null,I=r.charCodeAt(y-1)||null;m+=!u&&(b&&kd(b)&&!$h[r[y+1]]||I&&kd(I)&&!$h[r[y-1]])||!$h[r[y]]?r[y]:$h[r[y]]}return m}(this.text,e)}trim(){let e=0;for(let u=0;u<this.text.length&&ep[this.text.charCodeAt(u)];u++)e++;let r=this.text.length;for(let u=this.text.length-1;u>=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<e.text.length;++m)this.sectionIndex.push(u)}addImageSection(e){const r=e.image?e.image.name:"";if(r.length===0)return void yn("Can't add FormattedSection with an empty image.");const u=this.getNextImageSectionCharCode();u?(this.text+=String.fromCharCode(u),this.sections.push(Xh.forImage(r)),this.sectionIndex.push(this.sections.length-1)):yn("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=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<Rt.length();jn++){const gn=Rt.getSection(jn);mn+=p1(Rt.getCharCode(jn),gn,pn,Tt,jt,Xt)}return mn/Math.max(1,Math.ceil(mn/Dt))}(Se,We,Ze,nt,mt,Ke),ht=Se.text.indexOf("")>=0;let Et=0;for(let Rt=0;Rt<Se.length();Rt++){const jt=Se.getSection(Rt),Dt=Se.getCharCode(Rt);if(ep[Dt]||(Et+=p1(Dt,jt,nt,mt,We,Ke)),Rt<Se.length()-1){const pn=!((et=Dt)<11904||!(zt["Bopomofo Extended"](et)||zt.Bopomofo(et)||zt["CJK Compatibility Forms"](et)||zt["CJK Compatibility Ideographs"](et)||zt["CJK Compatibility"](et)||zt["CJK Radicals Supplement"](et)||zt["CJK Strokes"](et)||zt["CJK Symbols and Punctuation"](et)||zt["CJK Unified Ideographs Extension A"](et)||zt["CJK Unified Ideographs"](et)||zt["Enclosed CJK Letters and Months"](et)||zt["Halfwidth and Fullwidth Forms"](et)||zt.Hiragana(et)||zt["Ideographic Description Characters"](et)||zt["Kangxi Radicals"](et)||zt["Katakana Phonetic Extensions"](et)||zt.Katakana(et)||zt["Vertical Forms"](et)||zt["Yi Radicals"](et)||zt["Yi Syllables"](et)));(vC[Dt]||pn||jt.imageName)&&st.push(g1(Rt+1,Et,at,st,xC(Dt,Se.getCharCode(Rt+1),pn&&ht),!1))}}var et;return _1(g1(Se.length(),Et,at,st,0,!0))}(K,A,y,e,u,$),{processBidirectionalText:Te,processStyledBidirectionalText:pe}=z;if(Te&&K.sections.length===1){const Se=Te(K.toString(),de);for(const We of Se){const Ze=new gc;Ze.text=We,Ze.sections=K.sections;for(let nt=0;nt<We.length;nt++)Ze.sectionIndex.push(0);re.push(Ze)}}else if(pe){const Se=pe(K.text,K.sectionIndex,de);for(const We of Se){const Ze=new gc;Ze.text=We[0],Ze.sectionIndex=We[1],Ze.sections=K.sections,re.push(Ze)}}else re=function(Se,We){const Ze=[],nt=Se.text;let mt=0;for(const Ke of We)Ze.push(Se.substring(mt,Ke)),mt=Ke;return mt<nt.length&&Ze.push(Se.substring(mt,nt.length)),Ze}(K,de);const Ee=[],Ce={positionedLines:Ee,text:K.toString(),top:O[1],bottom:O[1],left:O[0],right:O[0],writingMode:B,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(Se,We,Ze,nt,mt,Ke,st,at,ht,Et,et,Rt){let jt=0,Dt=0,pn=0;const Tt=at==="right"?1:at==="left"?0:.5;let Xt=!1;for(const vn of mt){const xn=vn.getSections();for(const oi of xn){if(oi.imageName)continue;const hi=We[oi.fontStack];if(hi&&(Xt=hi.ascender!==void 0&&hi.descender!==void 0,!Xt))break}if(!Xt)break}let mn=0;for(const vn of mt){vn.trim();const xn=vn.getMaxScale(),oi=(xn-1)*wr,hi={positionedGlyphs:[],lineOffset:0};Se.positionedLines[mn]=hi;const fi=hi.positionedGlyphs;let si=0;if(!vn.length()){Dt+=Ke,++mn;continue}let Ii=0,Di=0;for(let ai=0;ai<vn.length();ai++){const tr=vn.getSection(ai),Zi=vn.getSectionIndex(ai),Pi=vn.getCharCode(ai);let qn=tr.scale,$i=null,di=null,io=null,Xi=wr,Er=0;const gr=!(ht===Zo.horizontal||!et&&!xh(Pi)||et&&(ep[Pi]||(jn=Pi,zt.Arabic(jn)||zt["Arabic Supplement"](jn)||zt["Arabic Extended-A"](jn)||zt["Arabic Presentation Forms-A"](jn)||zt["Arabic Presentation Forms-B"](jn))));if(tr.imageName){const ro=nt[tr.imageName];if(!ro)continue;io=tr.imageName,Se.iconsInText=Se.iconsInText||!0,di=ro.paddedRect;const _r=ro.displaySize;qn=qn*wr/Rt,$i={width:_r[0],height:_r[1],left:yo,top:-h1,advance:gr?_r[1]:_r[0],localGlyph:!1},Er=Xt?-$i.height*qn:d1+xn*wr-_r[1]*qn,Xi=$i.advance;const As=(gr?_r[0]:_r[1])*qn-wr*xn;As>0&&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<of&&(Ii=of,Di=(Ec-rf)/2*qn),Er=-Ec*qn}else Er=d1+(xn-qn)*wr}gr?(Se.verticalizable=!0,fi.push({glyph:Pi,imageName:io,x:jt,y:Dt+Er,vertical:gr,scale:qn,localGlyph:$i.localGlyph,fontStack:tr.fontStack,sectionIndex:Zi,metrics:$i,rect:di}),jt+=Xi*qn+Et):(fi.push({glyph:Pi,imageName:io,x:jt,y:Dt+Er,vertical:gr,scale:qn,localGlyph:$i.localGlyph,fontStack:tr.fontStack,sectionIndex:Zi,metrics:$i,rect:di}),jt+=$i.advance*qn+Et)}fi.length!==0&&(pn=Math.max(jt-Et,pn),Xt?y1(fi,Tt,si,Di,Ke*xn/2):y1(fi,Tt,si,0,Ke/2)),jt=0;const qi=Ke*xn+si;hi.lineOffset=Math.max(si,oi),Dt+=qi,++mn}var jn;const gn=Dt,{horizontalAlign:en,verticalAlign:gi}=Cg(st);(function(vn,xn,oi,hi,fi,si){const Ii=(xn-oi)*fi,Di=-si*hi;for(const qi of vn)for(const ai of qi.positionedGlyphs)ai.x+=Ii,ai.y+=Di})(Se.positionedLines,Tt,en,gi,pn,gn),Se.top+=-gi*gn,Se.bottom=Se.top+gn,Se.left+=-en*pn,Se.right=Se.left+pn,Se.hasBaseline=Xt}(Ce,e,r,u,re,b,I,C,B,A,j,W),!function(Se){for(const We of Se)if(We.positionedGlyphs.length!==0)return!1;return!0}(Ee)&&Ce}const ep={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},vC={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function p1(n,e,r,u,m,y){if(e.imageName){const b=u[e.imageName];return b?b.displaySize[0]*e.scale*wr/y+m:0}{const b=r[e.fontStack],I=b&&b.glyphs[n];return I?I.metrics.advance*e.scale+m:0}}function m1(n,e,r,u){const m=Math.pow(n-e,2);return u?n<e?m/2:2*m:m+Math.abs(r)*r}function xC(n,e,r){let u=0;return n===10&&(u-=1e4),r&&(u+=150),n!==40&&n!==65288||(u+=50),e!==41&&e!==65289||(u+=50),u}function g1(n,e,r,u,m,y){let b=null,I=m1(e,r,m,y);for(const C of u){const A=m1(e-C.x,r,m,y)+C.badness;A<=I&&(b=C,I=A)}return{index:n,x:e,priorBreak:b,badness:I}}function _1(n){return n?_1(n.priorBreak).concat(n.index):[]}function Cg(n){let e=.5,r=.5;switch(n){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(n){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:e,verticalAlign:r}}function y1(n,e,r,u,m){if(!(e||r||u||m))return;const y=n.length-1,b=n[y],I=(b.x+b.metrics.advance*b.scale)*e;for(let C=0;C<=y;C++)n[C].x-=I,n[C].y+=r+u+m}function bC(n,e,r){const{horizontalAlign:u,verticalAlign:m}=Cg(r),y=e[0]-n.displaySize[0]*u,b=e[1]-n.displaySize[1]*m;return{image:n,top:b,bottom:b+n.displaySize[1],left:y,right:y+n.displaySize[0]}}function v1(n,e,r,u,m,y){const b=n.image;let I;if(b.content){const re=b.content,de=b.pixelRatio||1;I=[re[0]/de,re[1]/de,b.displaySize[0]-re[2]/de,b.displaySize[1]-re[3]/de]}const C=e.left*y,A=e.right*y;let O,B,j,$;r==="width"||r==="both"?($=m[0]+C-u[3],B=m[0]+A+u[1]):($=m[0]+(C+A-b.displaySize[0])/2,B=$+b.displaySize[0]);const W=e.top*y,K=e.bottom*y;return r==="height"||r==="both"?(O=m[1]+W-u[0],j=m[1]+K+u[2]):(O=m[1]+(W+K-b.displaySize[1])/2,j=O+b.displaySize[1]),{image:b,top:O,right:B,bottom:j,left:$,collisionPadding:I}}class Aa extends Ie{constructor(e,r,u,m,y){super(e,r),this.angle=m,this.z=u,y!==void 0&&(this.segment=y)}clone(){return new Aa(this.x,this.y,this.z,this.angle,this.segment)}}function x1(n,e,r,u,m){if(e.segment===void 0)return!0;let y=e,b=e.segment+1,I=0;for(;I>-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(;I<r/2;){const O=n[b],B=n[b+1];if(!B)return!1;let j=n[b-1].angleTo(O)-O.angleTo(B);for(j=Math.abs((j+3*Math.PI)%(2*Math.PI)-Math.PI),C.push({distance:I,angleDelta:j}),A+=j;I-C[0].distance>u;)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;r<n.length-1;r++)e+=n[r].dist(n[r+1]);return e}function w1(n,e,r){return n?.6*e*r:0}function E1(n,e){return Math.max(n?n.right-n.left:0,e?e.right-e.left:0)}function wC(n,e,r,u,m,y){const b=w1(r,m,y),I=E1(r,u)*y;let C=0;const A=b1(n)/2;for(let O=0;O<n.length-1;O++){const B=n[O],j=n[O+1],$=B.dist(j);if(C+$>A){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<e/4&&(e=B+e/4),T1(n,j?e/2*I%e:(O/2+2*y)*b*I%e,e,A,r,B,j,!1,C)}function T1(n,e,r,u,m,y,b,I,C){const A=y/2,O=b1(n);let B=0,j=e-r,$=[];for(let W=0;W<n.length-1;W++){const K=n[W],re=n[W+1],de=K.dist(re),Te=re.angleTo(K);for(;j+r<B+de;){j+=r;const pe=(j-B)/de,Ee=Nn(K.x,re.x,pe),Ce=Nn(K.y,re.y,pe);if(Ee>=0&&Ee<C&&Ce>=0&&Ce<C&&j-A>=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<n.length;b++){const I=n[b];let C;for(let A=0;A<I.length-1;A++){let O=I[A],B=I[A+1];O.x<e&&B.x<e||(O.x<e?O=new Ie(e,O.y+(e-O.x)/(B.x-O.x)*(B.y-O.y))._round():B.x<e&&(B=new Ie(e,O.y+(e-O.x)/(B.x-O.x)*(B.y-O.y))._round()),O.y<r&&B.y<r||(O.y<r?O=new Ie(O.x+(r-O.y)/(B.y-O.y)*(B.x-O.x),r)._round():B.y<r&&(B=new Ie(O.x+(r-O.y)/(B.y-O.y)*(B.x-O.x),r)._round()),O.x>=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<e+u;A++)S1(n,r*y+A,y,m,b,I,C);for(let A=r;A<r+m;A++)S1(n,A*y+e,1,u,b,I,C)}function S1(n,e,r,u,m,y,b){y[0]=0,b[0]=-Wh,b[1]=Wh,m[0]=n[e];for(let I=1,C=0,A=0;I<u;I++){m[I]=n[e+I*r];const O=I*I;do{const B=y[C];A=(m[I]-m[B]+O-B*B)/(I-B)/2}while(A<=b[C]&&--C>-1);C++,y[C]=I,b[C]=A,b[C+1]=Wh}for(let I=0,C=0;I<u;I++){for(;b[C+1]<I;)C++;const A=y[C],O=I-A;n[e+I*r]=m[A]+O*O}}const ks=2,Ag={none:0,ideographs:1,all:2};class _c{constructor(e,r,u){this.requestManager=e,this.localGlyphMode=r,this.localFontFamily=u,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,r){const u=[];for(const m in e)for(const y of e[m])u.push({stack:m,id:y});Bt(u,({stack:m,id:y},b)=>{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;pe<C;pe++)for(let Ee=0;Ee<I;Ee++){const Ce=Te.data[4*(pe*I+Ee)+3]/255;if(Ce===0)continue;const Se=(pe+K)*A+Ee+K;if(Ce===1)de[Se]=0,re[Se]=Wh;else{const We=.5-Ce;de[Se]=We>0?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;pe<B;pe++){const Ee=Math.sqrt(de[pe])-Math.sqrt(re[pe]);j[pe]=Math.round(255-255*(Ee/this.radius+this.cutoff))}return $}};const yc=yo;function k1(n,e,r,u){const m=[],y=n.image,b=y.pixelRatio,I=y.paddedRect.w-2*yc,C=y.paddedRect.h-2*yc,A=n.right-n.left,O=n.bottom-n.top,B=y.stretchX||[[0,I]],j=y.stretchY||[[0,C]],$=(Ke,st)=>Ke+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;at<Ke.length-1;at++){const ht=Ke[at],Et=Ke[at+1];for(let et=0;et<st.length-1;et++)m.push(mt(ht,st[et],Et,st[et+1]))}}else m.push(mt({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:I+1},{fixed:0,stretch:C+1}));return m}function tp(n,e,r){let u=0;for(const m of n)u+=Math.max(e,Math.min(r,m[1]))-Math.max(e,Math.min(r,m[0]));return u}function C1(n,e,r){const u=[{fixed:-yc,stretch:0}];for(const[m,y]of n){const b=u[u.length-1];u.push({fixed:m-b.stretch,stretch:b.stretch}),u.push({fixed:m-b.stretch,stretch:b.stretch+(y-m)})}return u.push({fixed:e+yc,stretch:r}),u}function np(n,e,r,u){return n/e*r+u}function ip(n,e,r,u){return n-e*r/u}function TC(n,e,r,u){const m=e+n.positionedLines[u].lineOffset;return u===0?r+m/2:r+(m+(e+n.positionedLines[u-1].lineOffset))/2}class IC{constructor(e=[],r=MC){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)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<m;){let b=1+(e<<1),I=r[b];const C=b+1;if(C<this.length&&u(r[C],I)<0&&(b=C,I=r[C]),u(I,y)>=0)break;r[e]=I,e=b}r[e]=y}}function MC(n,e){return n<e?-1:n>e?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;$<I.length;$++){const W=I[$];(!$||W.x<u)&&(u=W.x),(!$||W.y<m)&&(m=W.y),(!$||W.x>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;$<y;$+=C)for(let W=m;W<b;W+=C)O.push(new vc($+A,W+A,A,n));let B=function($){let W=0,K=0,re=0;const de=$[0];for(let Te=0,pe=de.length,Ee=pe-1;Te<pe;Ee=Te++){const Ce=de[Te],Se=de[Ee],We=Ce.x*Se.y-Se.x*Ce.y;K+=(Ce.x+Se.x)*We,re+=(Ce.y+Se.y)*We,W+=3*We}return new vc(K/W,re/W,0,$)}(n),j=O.length;for(;O.length;){const $=O.pop();($.d>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;A<b.length;A++){const O=b[A];for(let B=0,j=O.length,$=j-1;B<j;$=B++){const W=O[B],K=O[$];W.y>y.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<Dt.length;Tt++){const Xt=Dt[Tt];if(!pe.horizontal[Xt])if(pn)pe.horizontal[Xt]=pe.horizontal[0];else{const mn=kg(Ee,e,r,m,re,Rt,Ke,"center",Xt,st,Se,Zo.horizontal,!1,Te,de);mn&&(pe.horizontal[Xt]=mn,pn=mn.positionedLines.length===1)}}jt("left")}else{if(Et==="auto"&&(Et=Lg(at)),et||O.get("text-writing-mode").indexOf("horizontal")>=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;Dt<et;++Dt){const pn=Ce.positionedLines[Dt];jt=TC(Ce,Rt,jt,Dt);for(const Tt of pn.positionedGlyphs){if(!Tt.rect)continue;const Xt=Tt.rect||{};let mn=h1+1,jn=!0,gn=1,en=0;if(Tt.imageName){const di=mt[Tt.imageName];if(!di)continue;if(di.sdf){yn("SDF images are not supported in formatted text and will be ignored.");continue}jn=!1,gn=di.pixelRatio,mn=yo/gn}const gi=(Ze||Ke)&&Tt.vertical,vn=Tt.metrics.advance*Tt.scale/2,xn=Tt.metrics,oi=Tt.rect;if(oi===null)continue;Ke&&Ce.verticalizable&&(en=Tt.imageName?vn-Tt.metrics.width*Tt.scale/2:0);const hi=Ze?[Tt.x+vn,Tt.y]:[0,0];let fi=[0,0],si=[0,0],Ii=!1;Ze||(gi?(si=[Tt.x+vn+ht[0],Tt.y+ht[1]-en],Ii=!0):fi=[Tt.x+vn+Se[0],Tt.y+Se[1]-en]);const Di=oi.w*Tt.scale/(gn*(Tt.localGlyph?ks:1)),qi=oi.h*Tt.scale/(gn*(Tt.localGlyph?ks:1));let ai,tr,Zi,Pi;if(gi){const di=Tt.y-jt,io=new Ie(-vn,vn-di),Xi=-Math.PI/2,Er=new Ie(...si);ai=new Ie(-vn+fi[0],fi[1]),ai._rotateAround(Xi,io)._add(Er),ai.x+=-di+vn,ai.y-=(xn.left-mn)*Tt.scale;const gr=Tt.imageName?xn.advance*Tt.scale:wr*Tt.scale,ro=String.fromCharCode(Tt.glyph);oC(ro)?ai.x+=(1-mn)*Tt.scale:sC(ro)?ai.x+=gr-xn.height*Tt.scale+(-mn-1)*Tt.scale:ai.x+=Tt.imageName||xn.width+2*mn===oi.w&&xn.height+2*mn===oi.h?(gr-qi)/2:(gr-(xn.height+2*mn)*Tt.scale)/2,tr=new Ie(ai.x,ai.y-Di),Zi=new Ie(ai.x+qi,ai.y),Pi=new Ie(ai.x+qi,ai.y-Di)}else{const di=(xn.left-mn)*Tt.scale-vn+fi[0],io=(-xn.top-mn)*Tt.scale+fi[1],Xi=di+Di,Er=io+qi;ai=new Ie(di,io),tr=new Ie(Xi,io),Zi=new Ie(di,Er),Pi=new Ie(Xi,Er)}if(at){let di;di=Ze?new Ie(0,0):Ii?new Ie(ht[0],ht[1]):new Ie(Se[0],Se[1]),ai._rotateAround(at,di),tr._rotateAround(at,di),Zi._rotateAround(at,di),Pi._rotateAround(at,di)}const qn=new Ie(0,0),$i=new Ie(0,0);st.push({tl:ai,tr,bl:Zi,br:Pi,tex:Xt,writingMode:Ce.writingMode,glyphOffset:hi,sectionIndex:Tt.sectionIndex,isSDF:jn,pixelOffsetTL:qn,pixelOffsetBR:$i,minFontScaleX:0,minFontScaleY:0})}}return st}(0,u,C,y,b,I,m,n.allowVerticalPlacement),Te=n.textSizeData;let pe=null;Te.kind==="source"?(pe=[Ss*y.layout.get("text-size").evaluate(I,{},re)],pe[0]>ml&&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])<r)return!0}else m[e]=[];return m[e].push(u),!1}function R1(n,e){const r=n.fovAboveCenter,u=n.elevation?n.elevation.getMinElevationBelowMSL()*e:0,m=(n._camera.position[2]*n.worldSize-u)/Math.cos(n._pitch),y=Math.sin(r)*m/Math.sin(Math.max(Math.PI/2-n._pitch-r,.01)),b=Math.sin(n._pitch)*y+m;return Math.min(1.01*b,m*(1/n._horizonShift))}function cu(n,e){if(!e.isReprojectedInTileSpace)return{scale:1<<n.z,x:n.x,y:n.y,x2:n.x+1,y2:n.y+1,projection:e};const r=Math.pow(2,-n.z),u=n.x*r,m=(n.x+1)*r,y=n.y*r,b=(n.y+1)*r,I=qo(u),C=qo(m),A=zr(y),O=zr(b),B=e.project(I,A),j=e.project(C,A),$=e.project(C,O),W=e.project(I,O);let K=Math.min(B.x,j.x,$.x,W.x),re=Math.min(B.y,j.y,$.y,W.y),de=Math.max(B.x,j.x,$.x,W.x),Te=Math.max(B.y,j.y,$.y,W.y);const pe=r/16;function Ee(Se,We,Ze,nt,mt,Ke){const st=(Ze+mt)/2,at=(nt+Ke)/2,ht=e.project(qo(st),zr(at)),Et=Math.max(0,K-ht.x,re-ht.y,ht.x-de,ht.y-Te);K=Math.min(K,ht.x),de=Math.max(de,ht.x),re=Math.min(re,ht.y),Te=Math.max(Te,ht.y),Et>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.y<u}createInversionMatrix(e,r){return RC}createTileMatrix(e,r,u){let m,y,b;const I=u.canonical,C=Ts(new Float64Array(16));if(this.isReprojectedInTileSpace){const A=cu(I,this);m=1,y=A.x+u.wrap*A.scale,b=A.y,iu(C,C,[m/A.scale,m/A.scale,e.pixelsPerMeter/r])}else m=r/e.zoomScale(I.z),y=(I.x+Math.pow(2,I.z)*u.wrap)*m,b=I.y*m;return Mh(C,C,[y,b,0]),iu(C,C,[m/Wt,m/Wt,1]),C}upVector(e,r,u){return[0,0,1]}upVectorScale(e,r,u){return{metersToTile:1}}}class DC extends gl{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[r,u]=this.parallels=e.parallels||[29.5,45.5],m=Math.sin(Je(r));this.n=(m+Math.sin(Je(u)))/2,this.c=1+m*(2*this.n-m),this.r0=Math.sqrt(this.c)/this.n}project(e,r){const{n:u,c:m,r0:y}=this,b=Je(e-this.center[0]),I=Je(r),C=Math.sqrt(m-2*u*Math.sin(I))/u;return{x:C*Math.sin(b*u),y:C*Math.cos(b*u)-y,z:0}}unproject(e,r){const{n:u,c:m,r0:y}=this,b=y+r;let I=Math.atan2(e,Math.abs(b))*Math.sign(b);b*u<0&&(I-=Math.PI*Math.sign(e)*Math.sign(b));const C=Je(this.center[0])*u;I=tt(I,-Math.PI-C,Math.PI-C);const A=Mt(At(I/u)+this.center[0],-180,180),O=Math.asin(Mt((m-(e*e+b*b)*u*u)/(2*u),-1,1)),B=Mt(At(O),-Or,Or);return new ri(A,B)}}const Hh=1.340264,Kh=-.081106,Jh=893e-6,Qh=.003796,op=Math.sqrt(3)/2;class zC extends gl{project(e,r){r=r/180*Math.PI,e=e/180*Math.PI;const u=Math.asin(op*Math.sin(r)),m=u*u,y=m*m*m;return{x:.5*(e*Math.cos(u)/(op*(Hh+3*Kh*m+y*(7*Jh+9*Qh*m)))/Math.PI+.5),y:1-.5*(u*(Hh+Kh*m+y*(Jh+Qh*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=u*u,y=m*m*m;for(let O,B,j,$=0;$<12&&(B=u*(Hh+Kh*m+y*(Jh+Qh*m))-r,j=Hh+3*Kh*m+y*(7*Jh+9*Qh*m),O=B/j,u=Mt(u-O,-Math.PI/3,Math.PI/3),m=u*u,y=m*m*m,!(Math.abs(O)<1e-12));++$);const b=op*e*(Hh+3*Kh*m+y*(7*Jh+9*Qh*m))/Math.cos(u),I=Math.asin(Math.sin(u)/op),C=Mt(180*b/Math.PI,-180,180),A=Mt(180*I/Math.PI,-Or,Or);return new ri(C,A)}}class OC extends gl{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,r){return{x:.5+e/360,y:.5-r/360,z:0}}unproject(e,r){const u=360*(e-.5),m=Mt(360*(.5-r),-Or,Or);return new ri(u,m)}}const bc=Math.PI/2;function sp(n){return Math.tan((bc+n)/2)}class NC extends gl{constructor(e){super(e),this.center=e.center||[0,30];const[r,u]=this.parallels=e.parallels||[30,30];let m=Je(r),y=Je(u);this.southernCenter=m+y<0,this.southernCenter&&(m=-m,y=-y);const b=Math.cos(m),I=sp(m);this.n=m===y?Math.sin(m):Math.log(b/Math.cos(y))/Math.log(sp(y)/I),this.f=b*Math.pow(sp(m),this.n)/this.n}project(e,r){r=Je(r),this.southernCenter&&(r=-r),e=Je(e-this.center[0]);const u=1e-6,{n:m,f:y}=this;y>0?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;b<e.length;b++)if(r[e.charCodeAt(b)]=!0,m&&y){const I=$h[e.charAt(b)];I&&(r[I.charCodeAt(0)]=!0)}}populate(e,r,u,m){const y=this.layers[0],b=y.layout,I=this.projection.name==="globe",C=b.get("text-font"),A=b.get("text-field"),O=b.get("icon-image"),B=(A.value.kind!=="constant"||A.value.value instanceof sr&&!A.value.value.isEmpty()||A.value.value.toString().length>0)&&(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))<st;for(let ht=0;ht<Ke.length;ht++)Ke[ht]=QS(Ke[ht],at)}let Ze,nt;if(B){const Ke=y.getValueAndResolveTokens("text-field",We,u,re),st=sr.factory(Ke);GC(st)&&(this.hasRTLText=!0),(!this.hasRTLText||S()==="unavailable"||this.hasRTLText&&z.isParsed())&&(Ze=rC(st,y,We))}if(j){const Ke=y.getValueAndResolveTokens("icon-image",We,u,re);nt=Ke instanceof Wr?Ke:Wr.fromString(Ke)}if(!Ze&&!nt)continue;const mt=this.sortFeaturesByKey?$.evaluate(We,{},u):void 0;if(this.features.push({id:pe,text:Ze,icon:nt,index:Ee,sourceLayerIndex:Ce,geometry:We.geometry,properties:Te.properties,type:UC[Te.type],sortKey:mt}),nt&&(W[nt.name]=!0),Ze){const Ke=C.evaluate(We,{},u).join(","),st=b.get("text-rotation-alignment")==="map"&&b.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Zo.vertical)>=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;Ke<Te.length;Ke++){const st=Te[Ke],at=st.geometry,ht=st.text?st.text.toString():null;if(!ht){We(Ke);continue}const Et=mt(ht,at),et=mt(ht,at,!0);if(Et in Ee&&et in pe&&Ee[Et]!==pe[et]){const Rt=nt(Et,et,at),jt=Ze(Et,et,Ce[Rt].geometry);delete pe[Et],delete Ee[et],Ee[mt(ht,Ce[jt].geometry,!0)]=jt,Ce[Rt].geometry=null}else Et in Ee?Ze(Et,et,at):et in pe?nt(Et,et,at):(We(Ke),pe[Et]=Se-1,Ee[et]=Se-1)}return Ce.filter(Ke=>Ke.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<r.length;Ze++){const{tl:nt,tr:mt,bl:Ke,br:st,tex:at,pixelOffsetTL:ht,pixelOffsetBR:Et,minFontScaleX:et,minFontScaleY:Rt,glyphOffset:jt,isSDF:Dt,sectionIndex:pn}=r[Ze],Tt=Te.vertexLength,Xt=jt[1];if(ap(re,A.x,A.y,nt.x,Xt+nt.y,at.x,at.y,u,Dt,ht.x,ht.y,et,Rt),ap(re,A.x,A.y,mt.x,Xt+mt.y,at.x+at.w,at.y,u,Dt,Et.x,ht.y,et,Rt),ap(re,A.x,A.y,Ke.x,Xt+Ke.y,at.x,at.y+at.h,u,Dt,ht.x,Et.y,et,Rt),ap(re,A.x,A.y,st.x,Xt+st.y,at.x+at.w,at.y+at.h,u,Dt,Et.x,Et.y,et,Rt),C){const{x:mn,y:jn,z:gn}=C.anchor,[en,gi,vn]=C.up;lp(de,mn,jn,gn,en,gi,vn),lp(de,mn,jn,gn,en,gi,vn),lp(de,mn,jn,gn,en,gi,vn),lp(de,mn,jn,gn,en,gi,vn),up(e.dynamicLayoutVertexArray,mn,jn,gn,Ce)}else up(e.dynamicLayoutVertexArray,A.x,A.y,A.z,Ce);K.emplaceBack(Tt,Tt+1,Tt+2),K.emplaceBack(Tt+1,Tt+2,Tt+3),Te.vertexLength+=4,Te.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(jt[0]),Ze!==r.length-1&&pn===r[Ze+1].sectionIndex||e.programConfigurations.populatePaintArrays(re.length,b,b.index,{},$,W,Se&&Se[pn])}const We=C?C.anchor:A;e.placedSymbolArray.emplaceBack(We.x,We.y,We.z,A.x,A.y,pe,this.glyphOffsetArray.length-pe,Ee,O,B,A.segment,u?u[0]:0,u?u[1]:0,m[0],m[1],I,0,!1,0,j,0)}_commitLayoutVertex(e,r,u,m,y,b,I){e.emplaceBack(r,u,m,y,b,Math.round(I.x),Math.round(I.y))}_addCollisionDebugVertices(e,r,u,m,y,b,I){const C=u.segments.prepareSegment(4,u.layoutVertexArray,u.indexArray),A=C.vertexLength,O=I.tileAnchorX,B=I.tileAnchorY;for(let $=0;$<4;$++)u.collisionVertexArray.emplaceBack(0,0,0,0);u.collisionVertexArrayExt.emplaceBack(r,-e.padding,-e.padding),u.collisionVertexArrayExt.emplaceBack(r,e.padding,-e.padding),u.collisionVertexArrayExt.emplaceBack(r,e.padding,e.padding),u.collisionVertexArrayExt.emplaceBack(r,-e.padding,e.padding),this._commitLayoutVertex(u.layoutVertexArray,m,y,b,O,B,new Ie(e.x1,e.y1)),this._commitLayoutVertex(u.layoutVertexArray,m,y,b,O,B,new Ie(e.x2,e.y1)),this._commitLayoutVertex(u.layoutVertexArray,m,y,b,O,B,new Ie(e.x2,e.y2)),this._commitLayoutVertex(u.layoutVertexArray,m,y,b,O,B,new Ie(e.x1,e.y2)),C.vertexLength+=4;const j=u.indexArray;j.emplaceBack(A,A+1),j.emplaceBack(A+1,A+2),j.emplaceBack(A+2,A+3),j.emplaceBack(A+3,A),C.primitiveLength+=4}_addTextDebugCollisionBoxes(e,r,u,m,y,b){for(let I=m;I<y;I++){const C=u.get(I),A=this.getSymbolInstanceTextSize(e,b,r,I);this._addCollisionDebugVertices(C,A,this.textCollisionBox,C.projectedAnchorX,C.projectedAnchorY,C.projectedAnchorZ,b)}}_addIconDebugCollisionBoxes(e,r,u,m,y,b){for(let I=m;I<y;I++){const C=u.get(I),A=this.getSymbolInstanceIconSize(e,r,b.placedIconSymbolIndex);this._addCollisionDebugVertices(C,A,this.iconCollisionBox,C.projectedAnchorX,C.projectedAnchorY,C.projectedAnchorZ,b)}}generateCollisionDebugBuffers(e,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new zg(Ut,i1.members,mr),this.iconCollisionBox=new zg(Ut,i1.members,mr);const u=dc(this.iconSizeData,e),m=dc(this.textSizeData,e);for(let y=0;y<this.symbolInstances.length;y++){const b=this.symbolInstances.get(y);this._addTextDebugCollisionBoxes(m,e,r,b.textBoxStartIndex,b.textBoxEndIndex,b),this._addTextDebugCollisionBoxes(m,e,r,b.verticalTextBoxStartIndex,b.verticalTextBoxEndIndex,b),this._addIconDebugCollisionBoxes(u,e,r,b.iconBoxStartIndex,b.iconBoxEndIndex,b),this._addIconDebugCollisionBoxes(u,e,r,b.verticalIconBoxStartIndex,b.verticalIconBoxEndIndex,b)}}getSymbolInstanceTextSize(e,r,u,m){const y=this.text.placedSymbolArray.get(r.rightJustifiedTextSymbolIndex>=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;I<y;I++){const C=u.get(I),A=this.getSymbolInstanceTextSize(e,b,r,I);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,A,C.padding)}}_updateIconDebugCollisionBoxes(e,r,u,m,y,b){for(let I=m;I<y;I++){const C=u.get(I),A=this.getSymbolInstanceIconSize(e,r,b);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,A,C.padding)}}updateCollisionDebugBuffers(e,r){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const u=dc(this.iconSizeData,e),m=dc(this.textSizeData,e);for(let y=0;y<this.symbolInstances.length;y++){const b=this.symbolInstances.get(y);this._updateTextDebugCollisionBoxes(m,e,r,b.textBoxStartIndex,b.textBoxEndIndex,b),this._updateTextDebugCollisionBoxes(m,e,r,b.verticalTextBoxStartIndex,b.verticalTextBoxEndIndex,b),this._updateIconDebugCollisionBoxes(u,e,r,b.iconBoxStartIndex,b.iconBoxEndIndex,b.placedIconSymbolIndex),this._updateIconDebugCollisionBoxes(u,e,r,b.verticalIconBoxStartIndex,b.verticalIconBoxEndIndex,b.placedIconSymbolIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,r,u,m,y,b,I,C,A){const O={};if(r<u){const{x1:B,y1:j,x2:$,y2:W,padding:K,projectedAnchorX:re,projectedAnchorY:de,projectedAnchorZ:Te,tileAnchorX:pe,tileAnchorY:Ee,featureIndex:Ce}=e.get(r);O.textBox={x1:B,y1:j,x2:$,y2:W,padding:K,projectedAnchorX:re,projectedAnchorY:de,projectedAnchorZ:Te,tileAnchorX:pe,tileAnchorY:Ee},O.textFeatureIndex=Ce}if(m<y){const{x1:B,y1:j,x2:$,y2:W,padding:K,projectedAnchorX:re,projectedAnchorY:de,projectedAnchorZ:Te,tileAnchorX:pe,tileAnchorY:Ee,featureIndex:Ce}=e.get(m);O.verticalTextBox={x1:B,y1:j,x2:$,y2:W,padding:K,projectedAnchorX:re,projectedAnchorY:de,projectedAnchorZ:Te,tileAnchorX:pe,tileAnchorY:Ee},O.verticalTextFeatureIndex=Ce}if(b<I){const{x1:B,y1:j,x2:$,y2:W,padding:K,projectedAnchorX:re,projectedAnchorY:de,projectedAnchorZ:Te,tileAnchorX:pe,tileAnchorY:Ee,featureIndex:Ce}=e.get(b);O.iconBox={x1:B,y1:j,x2:$,y2:W,padding:K,projectedAnchorX:re,projectedAnchorY:de,projectedAnchorZ:Te,tileAnchorX:pe,tileAnchorY:Ee},O.iconFeatureIndex=Ce}if(C<A){const{x1:B,y1:j,x2:$,y2:W,padding:K,projectedAnchorX:re,projectedAnchorY:de,projectedAnchorZ:Te,tileAnchorX:pe,tileAnchorY:Ee,featureIndex:Ce}=e.get(C);O.verticalIconBox={x1:B,y1:j,x2:$,y2:W,padding:K,projectedAnchorX:re,projectedAnchorY:de,projectedAnchorZ:Te,tileAnchorX:pe,tileAnchorY:Ee},O.verticalIconFeatureIndex=Ce}return O}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let r=0;r<this.symbolInstances.length;r++){const u=this.symbolInstances.get(r);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,u.textBoxStartIndex,u.textBoxEndIndex,u.verticalTextBoxStartIndex,u.verticalTextBoxEndIndex,u.iconBoxStartIndex,u.iconBoxEndIndex,u.verticalIconBoxStartIndex,u.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){const u=e.placedSymbolArray.get(r),m=u.vertexStartIndex+4*u.numGlyphs;for(let y=u.vertexStartIndex;y<m;y+=4)e.indexArray.emplaceBack(y,y+1,y+2),e.indexArray.emplaceBack(y+1,y+2,y+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const r=Math.sin(e),u=Math.cos(e),m=[],y=[],b=[];for(let I=0;I<this.symbolInstances.length;++I){b.push(I);const C=this.symbolInstances.get(I);m.push(0|Math.round(r*C.tileAnchorX+u*C.tileAnchorY)),y.push(C.featureIndex)}return b.sort((I,C)=>m[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;Ce<Ee.length&&(j[0]=Ee.geta_centroid_pos0(Ce),j[1]=Ee.geta_centroid_pos1(Ce))}if(j[0]===0&&j[1]===1)return!1;y.projection.name==="globe"&&(u=Yx([u],[new Ie(0,0),new Ie(Wt,Wt)],n.tileID.canonical).map(Ee=>Ee.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<Ce.length;Ze++){const nt=Ce[Ze],mt=Ee[Ze];for(let Ke=0;Ke<nt.length-1;Ke++){const st=nt[Ke],at=[st,nt[Ke+1],mt[Ke+1],mt[Ke],st];wx(Se,at)&&(We=Math.min(We,Jx(Se,at)))}}return We!==1/0&&We}(de,Te,pe.isPointQuery()?pe.screenBounds:pe.screenGeometry)}},line:class extends Es{constructor(n){super(n,e1),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(n){if(n==="line-gradient"){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Wa,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}recalculate(n,e){super.recalculate(n,e),this.paint._values["line-floorwidth"]=t1.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,n)}createBucket(n){return new Hd(n)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(n){return new fl(this,n)}queryRadius(n){const e=n,r=n1(uc("line-width",this,e),uc("line-gap-width",this,e)),u=uc("line-offset",this,e);return r/2+Math.abs(u)+Vd(this.paint.get("line-translate"))}queryIntersectsFeature(n,e,r,u,m,y){if(n.queryGeometry.isAboveHorizon)return!1;const b=Sx(n.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),y.angle,n.pixelToTileUnitsFactor),I=n.pixelToTileUnitsFactor/2*n1(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),C=this.paint.get("line-offset").evaluate(e,r);return C&&(u=function(A,O){const B=[],j=new Ie(0,0);for(let $=0;$<A.length;$++){const W=A[$],K=[];for(let re=0;re<W.length;re++){const de=W[re],Te=W[re+1],pe=re===0?j:de.sub(W[re-1])._unit()._perp(),Ee=re===W.length-1?j:Te.sub(de)._unit()._perp(),Ce=pe._add(Ee)._unit();Ce._mult(1/(Ce.x*Ee.x+Ce.y*Ee.y)),K.push(Ce._mult(O)._add(de))}B.push(K)}return B}(u,C*n.pixelToTileUnitsFactor)),function(A,O,B){for(let j=0;j<O.length;j++){const $=O[j];if(A.length>=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<this.taskQueue.length;m++){const y=this.tasks[this.taskQueue[m]];y.priority<r&&(r=y.priority,e=m)}if(e===null)return null;const u=this.taskQueue[e];return this.taskQueue.splice(e,1),u}remove(){this.invoker.remove()}}class V1{constructor(e){this._stringToNumber={},this._numberToString=[];for(let r=0;r<e.length;r++){const u=e[r];this._stringToNumber[u]=r,this._numberToString[r]=u}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}const JC=["tile","layer","source","sourceLayer","state"];class U1{constructor(e,r,u,m,y){this.type="Feature",this._vectorTileFeature=e,this._z=r,this._x=u,this._y=m,this.properties=e.properties,this.id=y}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};this.id!==void 0&&(e.id=this.id);for(const r of JC)this[r]!==void 0&&(e[r]=this[r]);return e}}const rs=32,Ys=33,yl=new Uint16Array(8184);for(let n=0;n<2046;n++){let e=n+2,r=0,u=0,m=0,y=0,b=0,I=0;for(1&e?m=y=b=rs:r=u=I=rs;(e>>=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;r<co.now()||this.fadeEndTime&&r<this.fadeEndTime||(this.fadeEndTime=r)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=cu(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,r,u){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(m,y){const b={};if(!y)return b;for(const I of m){const C=I.layerIds.map(A=>y.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;j<b.length;j++){const $=b.feature(j);if(I.needGeometry){const re=au($,!0);if(!I.filter(new N(this.tileID.overscaledZ),re,this.tileID.canonical))continue}else if(!I.filter(new N(this.tileID.overscaledZ),$))continue;const W=u.getId($,y),K=new U1($,C,A,O,W);K.tile=B,e.push(K)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const r=this.expirationTime;if(e.cacheControl){const u=wt(e.cacheControl);u["max-age"]&&(this.expirationTime=Date.now()+1e3*u["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const u=Date.now();let m=!1;if(this.expirationTime>u)m=!1;else if(r)if(this.expirationTime<r)m=!0;else{const y=this.expirationTime-r;y?this.expirationTime=u+Math.max(y,3e4):m=!0}else m=!0;m?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(e,r){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0||!r)return;const u=this.latestFeatureIndex.loadVTLayers(),m=r.style.listImages();for(const y in this.buckets){if(!r.style.hasLayer(y))continue;const b=this.buckets[y],I=b.layers[0].sourceLayer||"_geojsonTileLayer",C=u[I],A=e[I];if(!C||!A||Object.keys(A).length===0)continue;if(b.update(A,C,m,this.imageAtlas&&this.imageAtlas.patternPositions||{}),b instanceof Hd||b instanceof Zd){const B=r.style._getSourceCache(b.layers[0].source);r._terrain&&r._terrain.enabled&&B&&b.programConfigurations.needsUpload&&r._terrain._clearRenderCacheForTile(B.id,this.tileID)}const O=r&&r.style&&r.style.getLayer(y);O&&(this.queryPadding=Math.max(this.queryPadding,O.queryRadius(b)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<co.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=co.now()+e}setTexture(e,r){const u=r.context,m=u.gl;this.texture=this.texture||r.getTileTexture(e.width),this.texture?this.texture.update(e,{useMipmap:!0}):(this.texture=new ef(u,e,m.RGBA,{useMipmap:!0}),this.texture.bind(m.LINEAR,m.CLAMP_TO_EDGE))}setDependencies(e,r){const u={};for(const m of r)u[m]=!0;this.dependencies[e]=u}hasDependency(e,r){for(const u of e){const m=this.dependencies[u];if(m){for(const y of r)if(m[y])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,r){if(!r||r.name==="mercator"||this._tileDebugBuffer)return;const u=Sa(q1,this.tileID.canonical,this.tileTransform)[0],m=new pt,y=new Co;for(let b=0;b<u.length;b++){const{x:I,y:C}=u[b];m.emplaceBack(I,C),y.emplaceBack(b)}y.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(y),this._tileDebugBuffer=e.createVertexBuffer(m,Lh.members),this._tileDebugSegments=ji.simpleSegment(0,0,m.length,y.length)}_makeTileBoundsBuffers(e,r){if(this._tileBoundsBuffer||!r||r.name==="mercator")return;const u=Sa(q1,this.tileID.canonical,this.tileTransform)[0];let m,y;if(this.isRaster){const b=function(I,C){const A=cu(I,C),O=Math.pow(2,I.z);for(let re=0;re<Ys;re++)for(let de=0;de<Ys;de++){const Te=qo((I.x+(de+j1(de))/rs)/O),pe=zr((I.y+(re+j1(re))/rs)/O),Ee=C.project(Te,pe),Ce=re*Ys+de;Hs[2*Ce+0]=Math.round((Ee.x*A.scale-A.x)*Wt),Hs[2*Ce+1]=Math.round((Ee.y*A.scale-A.y)*Wt)}vl.fill(0),hp.fill(0);for(let re=2045;re>=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;I<b.length;I+=3)y.emplaceBack(b[I],b[I+1],b[I+2])}this._tileBoundsBuffer=e.createVertexBuffer(m,G1.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(y),this._tileBoundsSegments=ji.simpleSegment(0,0,m.length,y.length)}_makeGlobeTileDebugBuffers(e,r){const u=r.projection;if(!u||u.name!=="globe"||r.freezeTileCoverage)return;const m=this.tileID.canonical,y=zh(hx(m,r)),b=ac(r.zoom);let I;b>0&&(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<<u.z,O=Xs(m.center.lng),B=Ws(m.center.lat),j=(u.x+.5)/A-O;let $=0;j>.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;Ee<re;Ee++){const Ce=j+Ee*de,Se=$+Ee*Te;I.emplaceBack(Ce,Se);const We=this._globePoint(Ce,Se,r,u,m,y,b);A.emplaceBack(We[0],We[1],We[2]),C.emplaceBack(pe+Ee)}},B=Wt;O(0,0,B,0,16),O(B,0,B,B,16),O(B,B,0,B,16),O(0,B,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(C),this._tileDebugBuffer=e.createVertexBuffer(I,Lh.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(A,lx.members),this._tileDebugSegments=ji.simpleSegment(0,0,I.length,C.length)}_makeGlobeTileDebugTextBuffer(e,r,u,m,y,b){const I=Wt/4,C=new pt,A=new qt,O=new qe,B=25;A.reserve(32),C.reserve(B),O.reserve(B);const j=($,W)=>B*$+W;for(let $=0;$<B;$++){const W=$*I;for(let K=0;K<B;K++){const re=K*I;C.emplaceBack(re,W);const de=this._globePoint(re,W,r,u,m,y,b);O.emplaceBack(de[0],de[1],de[2])}}for(let $=0;$<4;$++)for(let W=0;W<4;W++){const K=j($,W),re=j($,W+1),de=j($+1,W),Te=j($+1,W+1);A.emplaceBack(K,re,de),A.emplaceBack(de,re,Te)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(A),this._tileDebugTextBuffer=e.createVertexBuffer(C,Lh.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(O,lx.members),this._tileDebugTextSegments=ji.simpleSegment(0,0,B,32)}}class QC{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,r,u){const m=String(r);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][m]=this.stateChanges[e][m]||{},Vt(this.stateChanges[e][m],u),this.deletedStates[e]===null){this.deletedStates[e]={};for(const y in this.state[e])y!==m&&(this.deletedStates[e][y]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][m]===null){this.deletedStates[e][m]={};for(const y in this.state[e][m])u[y]||(this.deletedStates[e][m][y]=null)}else for(const y in u)this.deletedStates[e]&&this.deletedStates[e][m]&&this.deletedStates[e][m][y]===null&&delete this.deletedStates[e][m][y]}removeFeatureState(e,r,u){if(this.deletedStates[e]===null)return;const m=String(r);if(this.deletedStates[e]=this.deletedStates[e]||{},u&&r!==void 0)this.deletedStates[e][m]!==null&&(this.deletedStates[e][m]=this.deletedStates[e][m]||{},this.deletedStates[e][m][u]=null);else if(r!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][m])for(u in this.deletedStates[e][m]={},this.stateChanges[e][m])this.deletedStates[e][m][u]=null;else this.deletedStates[e][m]=null;else this.deletedStates[e]=null}getState(e,r){const u=String(r),m=Vt({},(this.state[e]||{})[u],(this.stateChanges[e]||{})[u]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const y=this.deletedStates[e][r];if(y===null)return{};for(const b in y)delete m[b]}return m}initializeTileState(e,r){e.setFeatureState(this.state,r)}coalesceChanges(e,r){const u={};for(const m in this.stateChanges){this.state[m]=this.state[m]||{};const y={};for(const b in this.stateChanges[m])this.state[m][b]||(this.state[m][b]={}),Vt(this.state[m][b],this.stateChanges[m][b]),y[b]=this.state[m][b];u[m]=y}for(const m in this.deletedStates){this.state[m]=this.state[m]||{};const y={};if(this.deletedStates[m]===null)for(const b in this.state[m])y[b]={},this.state[m][b]={};else for(const b in this.deletedStates[m]){if(this.deletedStates[m][b]===null)this.state[m][b]={};else if(this.state[m][b])for(const I of Object.keys(this.deletedStates[m][b]))delete this.state[m][b][I];y[b]=this.state[m][b]}u[m]=u[m]||{},Vt(u[m],y)}if(this.stateChanges={},this.deletedStates={},Object.keys(u).length!==0)for(const m in e)e[m].setFeatureState(u,r)}}class Z1{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,r){const u=this.toIdx(e,r);return{min:this.minimums[u],max:this.maximums[u]}}isLeaf(e,r){return this.leaves[this.toIdx(e,r)]}toIdx(e,r){return r*this.size+e}}function $1(n,e,r,u){let m=0,y=Number.MAX_VALUE;for(let b=0;b<3;b++)if(Math.abs(u[b])<1e-15){if(r[b]<n[b]||r[b]>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),A<y&&(y=A),m>y)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<<r,O=y-u,B=b-m,j=(n+1)/A*O+u,$=(e+0)/A*B+m,W=(e+1)/A*B+m;I[0]=(n+0)/A*O+u,I[1]=$,C[0]=j,C[1]=W}class H1{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const r=function(y){const b=Math.ceil(Math.log2(y.dim/8)),I=[];let C=Math.ceil(Math.pow(2,b));const A=1/C,O=($,W,K,re,de)=>{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;$<C*C;$++){O($%C,Math.floor($/C),A,!1,j);const W=xl(j[0],j[1],y),K=xl(j[2],j[1],y),re=xl(j[2],j[3],y),de=xl(j[0],j[3],y);B.minimums.push(Math.min(W,K,re,de)),B.maximums.push(Math.max(W,K,re,de)),B.leaves.push(1)}for(I.push(B),C/=2;C>=1;C/=2){const $=I[I.length-1];B=new Z1(C);for(let W=0;W<C*C;W++){O(W%C,Math.floor(W/C),2,!0,j);const K=$.getElevation(j[0],j[1]),re=$.getElevation(j[2],j[1]),de=$.getElevation(j[2],j[3]),Te=$.getElevation(j[0],j[3]),pe=$.isLeaf(j[0],j[1]),Ee=$.isLeaf(j[2],j[1]),Ce=$.isLeaf(j[2],j[3]),Se=$.isLeaf(j[0],j[3]),We=Math.min(K.min,re.min,de.min,Te.min),Ze=Math.max(K.max,re.max,de.max,Te.max),nt=pe&&Ee&&Ce&&Se;B.maximums.push(Ze),B.minimums.push(We),B.leaves.push(Ze-We<=5&&nt?1:0)}I.push(B)}return I}(this.dem),u=r.length-1,m=r[u];this._addNode(m.minimums[0],m.maximums[0],m.leaves[0]),this._construct(r,0,0,u,0)}raycastRoot(e,r,u,m,y,b,I=1){return $1([e,r,-100],[u,m,this.maximums[0]*I],y,b)}raycast(e,r,u,m,y,b,I=1){if(!this.nodeCount)return null;const C=this.raycastRoot(e,r,u,m,y,b,I);if(C==null)return null;const A=[],O=[],B=[],j=[],$=[{idx:0,t:C,nodex:0,nodey:0,depth:0}];for(;$.length>0;){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<<Te,Ce=(re+0)/Ee,Se=(re+1)/Ee,We=(de+0)/Ee,Ze=(de+1)/Ee,nt=xl(Ce,We,this.dem)*I,mt=xl(Se,We,this.dem)*I,Ke=xl(Se,Ze,this.dem)*I,st=xl(Ce,Ze,this.dem)*I,at=X1(B[0],B[1],nt,j[0],B[1],mt,j[0],j[1],Ke,y,b),ht=X1(j[0],j[1],Ke,B[0],j[1],st,B[0],B[1],nt,y,b),Et=Math.min(at!==null?at:Number.MAX_VALUE,ht!==null?ht:Number.MAX_VALUE);if(Et!==Number.MAX_VALUE)return Et;{const et=Ah([],y,b,K);if(K1(nt,mt,st,Ke,W1(et[0],B[0],j[0]),W1(et[1],B[1],j[1]))>=et[2])return K}continue}let pe=0;for(let Ee=0;Ee<this._siblingOffset.length;Ee++){Y1((re<<1)+this._siblingOffset[Ee][0],(de<<1)+this._siblingOffset[Ee][1],Te+1,e,r,u,m,B,j),B[2]=-100,j[2]=this.maximums[this.childOffsets[W]+Ee]*I;const Ce=$1(B,j,y,b);if(Ce!=null){const Se=Ce;A[Ee]=Se;let We=!1;for(let Ze=0;Ze<pe&&!We;Ze++)Se>=A[O[Ze]]&&(O.splice(Ze,0,Ee),We=!0);We||(O[pe]=Ee),pe++}}for(let Ee=0;Ee<pe;Ee++){const Ce=O[Ee];$.push({idx:this.childOffsets[W]+Ce,t:A[Ce],nodex:(re<<1)+this._siblingOffset[Ce][0],nodey:(de<<1)+this._siblingOffset[Ce][1],depth:Te+1})}}return null}_addNode(e,r,u){return this.minimums.push(e),this.maximums.push(r),this.leaves.push(u),this.childOffsets.push(0),this.nodeCount++}_construct(e,r,u,m,y){if(e[m].isLeaf(r,u)===1)return;this.childOffsets[y]||(this.childOffsets[y]=this.nodeCount);const b=m-1,I=e[b];let C=0,A=0;for(let O=0;O<this._siblingOffset.length;O++){const B=2*r+this._siblingOffset[O][0],j=2*u+this._siblingOffset[O][1],$=I.getElevation(B,j),W=I.isLeaf(B,j),K=this._addNode($.min,$.max,W);W&&(C|=1<<O),A||(A=K)}for(let O=0;O<this._siblingOffset.length;O++)C&1<<O||this._construct(e,2*r+this._siblingOffset[O][0],2*u+this._siblingOffset[O][1],b,A+O)}}function K1(n,e,r,u,m,y){return Nn(Nn(n,r,y),Nn(e,u,y),m)}function xl(n,e,r){const u=r.dim,m=Mt(n*u-.5,0,u-1),y=Mt(e*u-.5,0,u-1),b=Math.floor(m),I=Math.floor(y),C=Math.min(b+1,u-1),A=Math.min(I+1,u-1);return K1(r.get(b,I),r.get(C,I),r.get(b,A),r.get(C,A),m-b,y-I)}const J1={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function eA(n,e,r){return(256*n*256+256*e+r)/10-1e4}function tA(n,e,r){return 256*n+e+r/256-32768}class fp{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,r,u,m=!1,y=!1){if(this.uid=e,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(u&&u!=="mapbox"&&u!=="terrarium")return yn(`"${u}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=r.height;const b=this.dim=r.height-2,I=new Uint32Array(r.data.buffer);if(this.pixels=new Uint8Array(r.data.buffer),this.encoding=u||"mapbox",this.borderReady=m,!m){for(let C=0;C<b;C++)I[this._idx(-1,C)]=I[this._idx(0,C)],I[this._idx(b,C)]=I[this._idx(b-1,C)],I[this._idx(C,-1)]=I[this._idx(C,0)],I[this._idx(C,b)]=I[this._idx(C,b-1)];I[this._idx(-1,-1)]=I[this._idx(0,0)],I[this._idx(b,-1)]=I[this._idx(b-1,0)],I[this._idx(-1,b)]=I[this._idx(0,b-1)],I[this._idx(b,b)]=I[this._idx(b-1,b-1)],y&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new H1(this)}get(e,r,u=!1){u&&(e=Mt(e,-1,this.dim),r=Mt(r,-1,this.dim));const m=4*this._idx(e,r);return(this.encoding==="terrarium"?tA:eA)(this.pixels[m],this.pixels[m+1],this.pixels[m+2])}static getUnpackVector(e){return J1[e]}get unpackVector(){return J1[this.encoding]}_idx(e,r){if(e<-1||e>=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<I;O++)for(let B=m;B<y;B++){const j=4*this._idx(B,O),$=4*this._idx(B+C,O+A);this.pixels[j+0]=e.pixels[$+0],this.pixels[j+1]=e.pixels[$+1],this.pixels[j+2]=e.pixels[$+2],this.pixels[j+3]=e.pixels[$+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Ft(fp,"DEMData"),Ft(H1,"DemMinMaxQuadTree",{omit:["dem"]});class nA{constructor(e,r){this.max=e,this.onRemove=r,this.reset()}reset(){for(const e in this.data)for(const r of this.data[e])r.timeout&&clearTimeout(r.timeout),this.onRemove(r.value);return this.data={},this.order=[],this}add(e,r,u){const m=e.wrapped().key;this.data[m]===void 0&&(this.data[m]=[]);const y={value:r,timeout:void 0};if(u!==void 0&&(y.timeout=setTimeout(()=>{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;m<r.length;m++){const y=r[m];if(e.neighboringTiles&&e.neighboringTiles[y]){const b=this.getTileByID(y);u(e,b),u(b,e)}}function u(m,y){if(!m.dem||m.dem.borderReady)return;m.needsHillshadePrepare=!0,m.needsDEMTextureUpload=!0;let b=y.tileID.canonical.x-m.tileID.canonical.x;const I=y.tileID.canonical.y-m.tileID.canonical.y,C=Math.pow(2,m.tileID.canonical.z),A=y.tileID.key;b===0&&I===0||Math.abs(I)>1||(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&&(C[A.key]=A)}this._retainLoadedChildren(C,m,I,r);for(const A of e){let O=this._tiles[A.key];if(O.hasData())continue;if(A.canonical.z>=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<<n.z;return[n.x/r+e,(n.x+1)/r+e]}hu.maxOverzooming=10,hu.maxUnderzooming=3;class dp{constructor(e,r,u){this._demTile=e,this._dem=this._demTile.dem,this._scale=r,this._offset=u}static create(e,r,u){const m=u||e.findDEMTileFor(r);if(!m||!m.dem)return;const y=m.dem,b=m.tileID,I=1<<r.canonical.z-b.canonical.z;return new dp(m,m.tileSize/Wt/I,[(r.canonical.x/I-b.canonical.x)*y.dim,(r.canonical.y/I-b.canonical.y)*y.dim])}tileCoordToPixel(e,r){const u=r*this._scale+this._offset[1],m=Math.floor(e*this._scale+this._offset[0]),y=Math.floor(u);return new Ie(m,y)}getElevationAt(e,r,u,m){const y=e*this._scale+this._offset[0],b=r*this._scale+this._offset[1],I=Math.floor(y),C=Math.floor(b),A=this._dem;return m=!!m,u?Nn(Nn(A.get(I,C,m),A.get(I,C+1,m),b-C),Nn(A.get(I+1,C,m),A.get(I+1,C+1,m),b-C),y-I):A.get(I,C,m)}getElevationAtPixel(e,r,u){return this._dem.get(e,r,!!u)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Ms(1,e)*this._dem.stride}}class tb{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new xa(Wt,16,0),this.featureIndexArray=new Ql,this.promoteId=r}insert(e,r,u,m,y,b=0){const I=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(u,m,y,b);const C=this.grid;for(let A=0;A<r.length;A++){const O=r[A],B=[1/0,1/0,-1/0,-1/0];for(let j=0;j<O.length;j++){const $=O[j];B[0]=Math.min(B[0],$.x),B[1]=Math.min(B[1],$.y),B[2]=Math.max(B[2],$.x),B[3]=Math.max(B[3],$.y)}B[0]<Wt&&B[1]<Wt&&B[2]>=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<O.length;W++){const K=O[W];if(K===$)continue;$=K;const re=this.featureIndexArray.get(K);let de=null;this.loadMatchingFeature(j,re,b,y.layers,y.availableImages,r,u,m,(Te,pe,Ee,Ce=0)=>(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<Te.length;Ee++)if(pe.indexOf(Te[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<W.length;Te++){const pe=W[Te];if(m&&m.indexOf(pe)<0)continue;const Ee=b[pe];if(!Ee)continue;let Ce={};de!==void 0&&C&&(Ce=C.getState(Ee.sourceLayer||"_geojsonTileLayer",de));const Se=Vt({},I[pe]);Se.paint=nb(Se.paint,Ee.paint,re,Ce,y),Se.layout=nb(Se.layout,Ee.layout,re,Ce,y);const We=!A||A(re,Ee,Ce,$);if(!We)continue;const Ze=new U1(re,this.z,this.x,this.y,de);Ze.layer=Se;let nt=e[pe];nt===void 0&&(nt=e[pe]=[]),nt.push({featureIndex:O,feature:Ze,intersectionZ:We})}}lookupSymbolFeatures(e,r,u,m,y,b,I,C){const A={};this.loadVTLayers();const O=Ku(y);for(const B of e)this.loadMatchingFeature(A,{bucketIndex:u,sourceLayerIndex:m,featureIndex:B,layoutVertexArrayOffset:0},O,b,I,C,r);return A}loadFeature(e){const{featureIndex:r,sourceLayerIndex:u}=e;this.loadVTLayers();const m=this.sourceLayerCoder.decode(u),y=this.vtFeatures[m];if(y[r])return y[r];const b=this.vtLayers[m].feature(r);return y[r]=b,b}hasLayer(e){for(const r of this.bucketLayerIDs)for(const u of r)if(e===u)return!0;return!1}getId(e,r){let u=e.id;if(this.promoteId){const m=typeof this.promoteId=="string"?this.promoteId:this.promoteId[r];m!=null&&(u=e.properties[m]),typeof u=="boolean"&&(u=Number(u))}return u}}function nb(n,e,r,u,m){return gt(n,(y,b)=>{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;A<e.length;A++){I=!I;const O=e[A];y=C*u,C+=O,b=C*u,m.push({left:y,right:b,isDash:I,zeroLength:O===0})}return m}addRoundDash(e,r,u){const m=r/2;for(let y=-u;y<=u;y++){const b=this.width*(this.nextRow+u+y);let I=0,C=e[I];for(let A=0;A<this.width;A++){A/C.right>1&&(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;C<this.width;C++){C/I.right>1&&(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<e.length;O++)e[O]<0&&(yn("Negative value is found in line dasharray, replacing values with 0"),e[O]=0),I+=e[O];if(I!==0){const O=this.width/I,B=this.getDashRanges(e,this.width,O);m?this.addRoundDash(B,O,y):this.addRegularDash(B,r==="square"?.5*O:0)}const C=this.nextRow+y;this.nextRow+=b;const A={tl:[C,y],br:[I,0]};return this.positions[u]=A,A}}Ft(ib,"LineAtlas");const rb=1*ks;class ob{constructor(e){const r={},u=[];for(const I in e){const C=e[I],A=r[I]={};for(const O in C.glyphs){const B=C.glyphs[+O];if(!B||B.bitmap.width===0||B.bitmap.height===0)continue;const j=B.metrics.localGlyph?rb:1,$={x:0,y:0,w:B.bitmap.width+2*j,h:B.bitmap.height+2*j};u.push($),A[O]=$}}const{w:m,h:y}=Mg(u),b=new ka({width:m||1,height:y||1});for(const I in e){const C=e[I];for(const A in C.glyphs){const O=C.glyphs[+A];if(!O||O.bitmap.width===0||O.bitmap.height===0)continue;const B=r[I][A],j=O.metrics.localGlyph?rb:1;ka.copy(O.bitmap,b,{x:0,y:0},{x:B.x+j,y:B.y+j},O.bitmap)}}this.image=b,this.positions=r}}Ft(ob,"GlyphAtlas");class rA{constructor(e){this.tileID=new no(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.enableTerrain=!!e.enableTerrain,this.isSymbolTile=e.isSymbolTile,this.tileTransform=cu(e.tileID.canonical,e.projection),this.projection=e.projection}parse(e,r,u,m,y){this.status="parsing",this.data=e,this.collisionBoxArray=new ii;const b=new V1(Object.keys(e.layers).sort()),I=new tb(this.tileID,this.promoteId);I.bucketLayerIDs=[];const C={},A=new ib(256,256),O={featureIndex:I,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:A,availableImages:u},B=r.familiesBySource[this.source];for(const Ce in B){const Se=e.layers[Ce];if(!Se)continue;let We=!1,Ze=!1;for(const Ke of B[Ce])Ke[0].type==="symbol"?We=!0:Ze=!0;if(this.isSymbolTile===!0&&!We||this.isSymbolTile===!1&&!Ze)continue;Se.version===1&&yn(`Vector tile source "${this.source}" layer "${Ce}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const nt=b.encode(Ce),mt=[];for(let Ke=0;Ke<Se.length;Ke++){const st=Se.feature(Ke),at=I.getId(st,Ce);mt.push({feature:st,id:at,index:Ke,sourceLayerIndex:nt})}for(const Ke of B[Ce]){const st=Ke[0];this.isSymbolTile!==void 0&&st.type==="symbol"!==this.isSymbolTile||st.minzoom&&this.zoom<Math.floor(st.minzoom)||st.maxzoom&&this.zoom>=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);I<C;){for(nf(n,e,I,C),I++,C--;e[2*I+y]<b;)I++;for(;e[2*C+y]>b;)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:"<cancel>",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==="<cancel>"){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==="<response>"){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:"<response>",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<<r,m=Math.floor(n.x),y=Math.floor((n.x-m)*u),b=Math.floor(n.y*u),I=this.findDEMTileFor(new no(r,m,r,y,b));return!(!I||!I.dem)}getAtPointOrZero(n,e=0){return this.getAtPoint(n,e)||0}getAtPoint(n,e,r=!0){if(this.isUsingMockSource())return null;e==null&&(e=null);const u=this._source();if(!u||n.y<0||n.y>1)return e;const m=u.getSource().maxzoom,y=1<<m,b=Math.floor(n.x),I=n.x-b,C=new no(m,b,m,Math.floor(I*y),Math.floor(n.y*y)),A=this.findDEMTileFor(C);if(!A||!A.dem)return e;const O=A.dem,B=1<<A.tileID.canonical.z,j=(I*B-A.tileID.canonical.x)*O.dim,$=(n.y*B-A.tileID.canonical.y)*O.dim,W=Math.floor(j),K=Math.floor($);return(r?this.exaggeration():1)*Nn(Nn(O.get(W,K),O.get(W,K+1),$-K),Nn(O.get(W+1,K),O.get(W+1,K+1),$-K),j-W)}getAtTileOffset(n,e,r){const u=1<<n.canonical.z;return this.getAtPointOrZero(new lc(n.wrap+(n.canonical.x+e/Wt)/u,(n.canonical.y+r/Wt)/u))}getAtTileOffsetFunc(n,e,r,u){return m=>{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<<n.canonical.z-u.canonical.z;let y=n.canonical.x/m-u.canonical.x,b=n.canonical.y/m-u.canonical.y,I=0;for(let C=0;C<n.canonical.z-u.canonical.z&&!r.leaves[I];C++){y*=2,b*=2;const A=2*Math.floor(b)+Math.floor(y);I=r.childOffsets[I]+A,y%=1,b%=1}return{min:this.exaggeration()*r.minimums[I],max:this.exaggeration()*r.maximums[I]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(n,e,r){throw new Error("Pure virtual method called.")}pointCoordinate(n){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(n){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},t.ErrorEvent=Fi,t.EvaluationParameters=N,t.Event=cs,t.Evented=wo,t.FillExtrusionBucket=Gh,t.Frustum=Qm,t.FrustumCorners=Jm,t.GLOBE_RADIUS=Zs,t.GLOBE_SCALE_MATCH_LATITUDE=45,t.GLOBE_ZOOM_THRESHOLD_MAX=ux,t.GLOBE_ZOOM_THRESHOLD_MIN=eg,t.GlobeSharedBuffers=class{constructor(n){this._createGrid(n),this._createPoles(n)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const n of this._poleSegments)n.destroy();for(const n of this._gridSegments)n.withSkirts.destroy(),n.withoutSkirts.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const n of this._wireframeSegments)n.destroy()}}_fillGridMeshWithLods(n,e){const r=new pt,u=new qt,m=[],y=n+1+2,b=e[0]+1,I=e[0]+1+(1+e.length),C=(A,O,B)=>{let j=A===y-1?A-2:A===0?A:A-1;return j+=B?24575:0,[j,O]};for(let A=0;A<y;++A)r.emplaceBack(...C(A,0,!0));for(let A=0;A<b;++A)for(let O=0;O<y;++O)r.emplaceBack(...C(O,A,(O===0||O===y-1)&&!0));for(let A=0;A<e.length;++A){const O=e[A];for(let B=0;B<y;++B)r.emplaceBack(...C(B,O,!0))}for(let A=0;A<e.length;++A){const O=u.length,B=e[A]+1+2,j=new qt;for(let K=0;K<B-1;K++){const re=K===B-2,de=re?y*(I-e.length+A-K):y;for(let Te=0;Te<y-1;Te++){const pe=K*y+Te;K===0||re||Te===0||Te===y-2?(j.emplaceBack(pe+1,pe,pe+de),j.emplaceBack(pe+de,pe+de+1,pe+1)):(u.emplaceBack(pe+1,pe,pe+de),u.emplaceBack(pe+de,pe+de+1,pe+1))}}const $=ji.simpleSegment(0,O,r.length,u.length-O);for(let K=0;K<j.uint16.length;K+=3)u.emplaceBack(j.uint16[K],j.uint16[K+1],j.uint16[K+2]);const W=ji.simpleSegment(0,O,r.length,u.length-O);m.push({withoutSkirts:$,withSkirts:W})}return{vertices:r,indices:u,segments:m}}_createGrid(n){const e=this._fillGridMeshWithLods(ou,Rh);this._gridSegments=e.segments,this._gridBuffer=n.createVertexBuffer(e.vertices,Lh.members),this._gridIndexBuffer=n.createIndexBuffer(e.indices,!0)}_createPoles(n){const e=new qt;for(let m=0;m<=ou;m++)e.emplaceBack(0,m+1,m+2);this._poleIndexBuffer=n.createIndexBuffer(e,!0);const r=new ni,u=new ni;this._poleSegments=[];for(let m=0,y=0;m<eg;m++){const b=360/(1<<m);r.emplaceBack(0,-Zs,0,.5,0),u.emplaceBack(0,-Zs,0,.5,1);for(let I=0;I<=ou;I++){const C=I/ou,A=Nn(0,b,C),[O,B,j]=oc(KS,JS,A,Zs);r.emplaceBack(O,B,j,C,0),u.emplaceBack(O,B,j,C,1)}this._poleSegments.push(ji.simpleSegment(y,0,66,64)),y+=66}this._poleNorthVertexBuffer=n.createVertexBuffer(r,ax,!1),this._poleSouthVertexBuffer=n.createVertexBuffer(u,ax,!1)}getGridBuffers(n,e){return[this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[n].withSkirts:this._gridSegments[n].withoutSkirts]}getPoleBuffers(n){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[n]]}getWirefameBuffers(n,e){if(!this._wireframeSegments){const r=new mr,u=ou,m=u+1+2,y=1;this._wireframeSegments=[];for(let b=0,I=0;b<Rh.length;b++){const C=Rh[b];for(let O=y;O<C+y;O++)for(let B=y;B<u+y;B++){const j=O*m+B;r.emplaceBack(j,j+1),r.emplaceBack(j,j+m),r.emplaceBack(j,j+m+1)}const A=C*u*3;this._wireframeSegments.push(ji.simpleSegment(0,I,(C+1)*m,A)),I+=A}this._wireframeIndexBuffer=n.createIndexBuffer(r)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[e]]}},t.GlyphManager=_c,t.ImagePosition=Sg,t.KDBush=qg,t.LivePerformanceUtils=Pl,t.LngLat=ri,t.LngLatBounds=dl,t.LocalGlyphMode=Ag,t.MAX_MERCATOR_LATITUDE=Or,t.MercatorCoordinate=lc,t.ONE_EM=wr,t.OverscaledTileID=no,t.PerformanceMarkers=Xr,t.Point=Ie,t.Properties=_e,t.RGBAImage=Po,t.Ray=Km,t.RequestManager=class{constructor(n,e,r){this._transformRequestFn=n,this._customAccessToken=e,this._silenceAuthErrors=!!r,this._createSkuToken()}_createSkuToken(){const n=function(){let e="";for(let r=0;r<10;r++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",te,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=n.token,this._skuTokenExpiresAt=n.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._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;u<n.length;u++){const m=tt(u-1,-1,n.length-1),y=tt(u+1,-1,n.length-1),b=n[u],I=n[y],C=n[m].sub(b).unit(),A=I.sub(b).unit(),O=A.angleWithSep(C.x,C.y),B=C.add(A).unit().mult(-1*e/Math.sin(O/2));r.push(b.add(B))}return r},t.cacheEntryPossiblyAdded=function(n){ra++,ra>uo&&(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;u<r.length-n;u++)e.delete(r[u])})})},t.evaluateSizeForFeature=Kd,t.evaluateSizeForZoom=dc,t.evaluateVariableOffset=A1,t.evented=T,t.exactEquals=function(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]},t.exactEquals$1=function(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]},t.exported=co,t.exported$1=F,t.extend=Vt,t.extend$1=kr,t.fillExtrusionHeightLift=Wx,t.filterObject=Me,t.fromMat4=function(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[4],n[4]=e[5],n[5]=e[6],n[6]=e[8],n[7]=e[9],n[8]=e[10],n},t.fromQuat=function(n,e){var r=e[0],u=e[1],m=e[2],y=e[3],b=r+r,I=u+u,C=m+m,A=r*b,O=u*b,B=u*I,j=m*b,$=m*I,W=m*C,K=y*b,re=y*I,de=y*C;return n[0]=1-B-W,n[1]=O+de,n[2]=j-re,n[3]=0,n[4]=O-de,n[5]=1-A-W,n[6]=$+K,n[7]=0,n[8]=j+re,n[9]=$-K,n[10]=1-A-B,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n},t.fromRotation=function(n,e){var r=Math.sin(e),u=Math.cos(e);return n[0]=u,n[1]=r,n[2]=0,n[3]=-r,n[4]=u,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n},t.fromScaling=Hv,t.furthestTileCorner=function(n){const e=Math.round((n+45+360)%360/90)%4;return ut[e]},t.getAABBPointSquareDist=function(n,e,r){let u=0;for(let m=0;m<2;++m){const y=r?r[m]:0;n[m]>y&&(u+=(n[m]-y)*(n[m]-y)),e[m]<y&&(u+=(y-e[m])*(y-e[m]))}return u},t.getAnchorAlignment=Cg,t.getAnchorJustification=Lg,t.getBounds=function(n){let e=1/0,r=1/0,u=-1/0,m=-1/0;for(const y of n)e=Math.min(e,y.x),r=Math.min(r,y.y),u=Math.max(u,y.x),m=Math.max(m,y.y);return{min:new Ie(e,r),max:new Ie(u,m)}},t.getColumn=bo,t.getDefaultExportFromCjs=ce,t.getGridMatrix=function(n,e,r,u){const m=e.getNorth(),y=e.getSouth(),b=e.getWest(),I=e.getEast(),C=1<<n.z,A=I-b,O=m-y,B=A/ou,j=-O/Rh[r],$=[0,B,0,j,0,0,m,b,0];if(n.z>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<n.length;u++){const m=E.document.createElement("source");Os(n[u])||(r.crossOrigin="Anonymous"),m.src=n[u],r.appendChild(m)}return{cancel:()=>{}}},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<<n)-.5)*Math.PI*2;return Dd(u,r.globeMatrix,m),Float32Array.from(u)},t.globeTileBounds=$s,t.globeTiltAtLngLat=mx,t.globeToMercatorTransition=ac,t.globeUseCustomAntiAliasing=function(n,e,r){const u=ac(r.zoom),m=n.style.map._antialias,y=!!e.extStandardDerivatives,b=e.extStandardDerivativesForceOff||n.terrain&&n.terrain.exaggeration()>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;u<e.length;u++){const m=e[u];m in n&&(r[m]=n[m])}return r},t.plugin=z,t.pointGeometry=ze,t.polesInViewport=function(n){const e=Ts(new Float64Array(16));nu(e,n.pixelMatrix,n.globeMatrix);const r=[0,ns,0],u=[0,is,0];return zi(r,r,e),zi(u,u,e),[r[0]>0&&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;me<ke.length;me++){const Ye=De&&De[ke[me].id]||k(ke[me]);De&&(De[ke[me].id]=Ye);let xt=Ge[Ye];xt||(xt=Ge[Ye]=[]),xt.push(ke[me])}const Fe=[];for(const me in Ge)Fe.push(Ge[me]);return Fe}(t.values(this._layerConfigs),this.keyCache);for(const ke of ve){const De=ke.map(It=>this._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<xe.length;ne++)U(xe[ne],!ee)}}function U(xe,ee){for(var ne=0,ve=0,ke=0,De=xe.length,Ge=De-1;ke<De;Ge=ke++){var Fe=(xe[ke][0]-xe[Ge][0])*(xe[Ge][1]+xe[ke][1]),me=ne+Fe;ve+=Math.abs(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<ee.features.length;ve++)xe(ee.features[ve],ne);else if(ke==="GeometryCollection")for(ve=0;ve<ee.geometries.length;ve++)xe(ee.geometries[ve],ne);else if(ke==="Feature")xe(ee.geometry,ne);else if(ke==="Polygon")F(ee.coordinates,ne);else if(ke==="MultiPolygon")for(ve=0;ve<ee.coordinates.length;ve++)F(ee.coordinates[ve],ne);return ee});const J=t.VectorTileFeature.prototype.toGeoJSON;var he={exports:{}},ye=t.pointGeometry,te=t.vectorTile.VectorTileFeature,ce=be;function be(xe,ee){this.options=ee||{},this.features=xe,this.length=xe.length}function we(xe,ee){this.id=typeof xe.id=="number"?xe.id:void 0,this.type=xe.type,this.rawGeometry=xe.type===1?[xe.geometry]:xe.geometry,this.properties=xe.tags,this.extent=ee||4096}be.prototype.feature=function(xe){return new we(this.features[xe],this.options.extent)},we.prototype.loadGeometry=function(){var xe=this.rawGeometry;this.geometry=[];for(var ee=0;ee<xe.length;ee++){for(var ne=xe[ee],ve=[],ke=0;ke<ne.length;ke++)ve.push(new ye(ne[ke][0],ne[ke][1]));this.geometry.push(ve)}return this.geometry},we.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var xe=this.geometry,ee=1/0,ne=-1/0,ve=1/0,ke=-1/0,De=0;De<xe.length;De++)for(var Ge=xe[De],Fe=0;Fe<Ge.length;Fe++){var me=Ge[Fe];ee=Math.min(ee,me.x),ne=Math.max(ne,me.x),ve=Math.min(ve,me.y),ke=Math.max(ke,me.y)}return[ee,ve,ne,ke]},we.prototype.toGeoJSON=te.prototype.toGeoJSON;var Ue=t.pbf,ze=ce;function Ve(xe){var ee=new Ue;return function(ne,ve){for(var ke in ne.layers)ve.writeMessage(3,Ie,ne.layers[ke])}(xe,ee),ee.finish()}function Ie(xe,ee){var ne;ee.writeVarintField(15,xe.version||1),ee.writeStringField(1,xe.name||""),ee.writeVarintField(5,xe.extent||4096);var ve={keys:[],values:[],keycache:{},valuecache:{}};for(ne=0;ne<xe.length;ne++)ve.feature=xe.feature(ne),ee.writeMessage(2,ft,ve);var ke=ve.keys;for(ne=0;ne<ke.length;ne++)ee.writeStringField(3,ke[ne]);var De=ve.values;for(ne=0;ne<De.length;ne++)ee.writeMessage(4,Nt,De[ne])}function ft(xe,ee){var ne=xe.feature;ne.id!==void 0&&ee.writeVarintField(1,ne.id),ee.writeMessage(2,lt,xe),ee.writeVarintField(3,ne.type),ee.writeMessage(4,ut,ne)}function lt(xe,ee){var ne=xe.feature,ve=xe.keys,ke=xe.values,De=xe.keycache,Ge=xe.valuecache;for(var Fe in ne.properties){var me=ne.properties[Fe],Ye=De[Fe];if(me!==null){Ye===void 0&&(ve.push(Fe),De[Fe]=Ye=ve.length-1),ee.writeVarint(Ye);var xt=typeof me;xt!=="string"&&xt!=="boolean"&&xt!=="number"&&(me=JSON.stringify(me));var It=xt+":"+me,_t=Ge[It];_t===void 0&&(ke.push(me),Ge[It]=_t=ke.length-1),ee.writeVarint(_t)}}}function Je(xe,ee){return(ee<<3)+(7&xe)}function At(xe){return xe<<1^xe>>31}function ut(xe,ee){for(var ne=xe.loadGeometry(),ve=xe.type,ke=0,De=0,Ge=ne.length,Fe=0;Fe<Ge;Fe++){var me=ne[Fe],Ye=1;ve===1&&(Ye=me.length),ee.writeVarint(Je(1,Ye));for(var xt=ve===3?me.length-1:me.length,It=0;It<xt;It++){It===1&&ve!==1&&ee.writeVarint(Je(2,xt-1));var _t=me[It].x-ke,ln=me[It].y-De;ee.writeVarint(At(_t)),ee.writeVarint(At(ln)),ke+=_t,De+=ln}ve===3&&ee.writeVarint(Je(7,1))}}function Nt(xe,ee){var ne=typeof xe;ne==="string"?ee.writeStringField(1,xe):ne==="boolean"?ee.writeBooleanField(7,xe):ne==="number"&&(xe%1!=0?ee.writeDoubleField(3,xe):xe<0?ee.writeSVarintField(6,xe):ee.writeVarintField(5,xe))}he.exports=Ve,he.exports.fromVectorTileJs=Ve,he.exports.fromGeojsonVt=function(xe,ee){ee=ee||{};var ne={};for(var ve in xe)ne[ve]=new ze(xe[ve].features,ee),ne[ve].name=ve,ne[ve].version=ee.version,ne[ve].extent=ee.extent;return Ve({layers:ne})},he.exports.GeoJSONWrapper=ze;var Lt=t.getDefaultExportFromCjs(he.exports);const Yt={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:xe=>xe},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<ee.length;me++){const Ye=ee[me];if(!Ye.geometry)continue;const[xt,It]=Ye.geometry.coordinates,_t=Mt(rn(xt)),ln=Mt(Tn(It));Ge.push(_t,ln,1/0,me,-1,1),this.options.reduce&&Ge.push(0)}let Fe=this.trees[ke+1]=this._createTree(Ge);ne&&console.timeEnd(De);for(let me=ke;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):De<ke?De++:ee.push(Fe),ee.length===ve)break}return De}_createTree(ee){const ne=new t.KDBush(ee.length/this.stride|0,this.options.nodeSize,Float32Array);for(let ve=0;ve<ee.length;ve+=this.stride)ne.add(ee[ve],ee[ve+1]);return ne.finish(),ne.data=ee,ne}_addTileFeatures(ee,ne,ve,ke,De,Ge){for(const Fe of ee){const me=Fe*this.stride,Ye=ne[me+Bt]>1;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;It<me.length;It+=xt){if(me[It+2]<=ne)continue;me[It+2]=ne;const _t=me[It],ln=me[It+1],wn=ee.within(me[It],me[It+1],Fe),on=me[It+Bt];let En=on;for(const Sn of wn){const yi=Sn*xt;me[yi+2]>ne&&(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;Sn<xt;Sn++)Ye.push(me[It+Sn]);if(En>1)for(const Sn of wn){const yi=Sn*xt;if(!(me[yi+2]<=ne)){me[yi+2]=ne;for(let ki=0;ki<xt;ki++)Ye.push(me[yi+ki])}}}}return Ye}_getOriginId(ee){return ee-this.points.length>>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;_t<ne;_t+=3){var ln=bn(xe[_t],xe[_t+1],me,Ye,xt,It);if(ln>De)ke=_t,De=ln;else if(ln===De){var wn=Math.abs(_t-Ge);wn<Fe&&(ke=_t,Fe=wn)}}De>ve&&(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;me<Ge.length;me++)Me(De,Ge[me]);else if(Fe==="MultiPolygon")for(me=0;me<Ge.length;me++)for(var Ye=0;Ye<Ge[me].length;Ye++)Me(De,Ge[me][Ye])}(ke),ke}function Me(xe,ee){for(var ne=0;ne<ee.length;ne+=3)xe.minX=Math.min(xe.minX,ee[ne]),xe.minY=Math.min(xe.minY,ee[ne+1]),xe.maxX=Math.max(xe.maxX,ee[ne]),xe.maxY=Math.max(xe.maxY,ee[ne+1])}function Fn(xe,ee,ne,ve){if(ee.geometry){var ke=ee.geometry.coordinates,De=ee.geometry.type,Ge=Math.pow(ne.tolerance/((1<<ne.maxZoom)*ne.extent),2),Fe=[],me=ee.id;if(ne.promoteId?me=ee.properties[ne.promoteId]:ne.generateId&&(me=ve||0),De==="Point")Si(ke,Fe);else if(De==="MultiPoint")for(var Ye=0;Ye<ke.length;Ye++)Si(ke[Ye],Fe);else if(De==="LineString")yn(ke,Fe,Ge,!1);else if(De==="MultiLineString"){if(ne.lineMetrics){for(Ye=0;Ye<ke.length;Ye++)yn(ke[Ye],Fe=[],Ge,!1),xe.push(gt(me,"LineString",Fe,ee.properties));return}_i(ke,Fe,Ge,!1)}else if(De==="Polygon")_i(ke,Fe,Ge,!0);else{if(De!=="MultiPolygon"){if(De==="GeometryCollection"){for(Ye=0;Ye<ee.geometry.geometries.length;Ye++)Fn(xe,{id:me,geometry:ee.geometry.geometries[Ye],properties:ee.properties},ne,ve);return}throw new Error("Input data is not a valid GeoJSON object.")}for(Ye=0;Ye<ke.length;Ye++){var xt=[];_i(ke[Ye],xt,Ge,!0),Fe.push(xt)}}xe.push(gt(me,De,Fe,ee.properties))}}function Si(xe,ee){ee.push(Yi(xe[0])),ee.push(Hi(xe[1])),ee.push(0)}function yn(xe,ee,ne,ve){for(var ke,De,Ge=0,Fe=0;Fe<xe.length;Fe++){var me=Yi(xe[Fe][0]),Ye=Hi(xe[Fe][1]);ee.push(me),ee.push(Ye),ee.push(0),Fe>0&&(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;ke<xe.length;ke++){var De=[];yn(xe[ke],De,ne,ve),ee.push(De)}}function Yi(xe){return xe/360+.5}function Hi(xe){var 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 wt(xe,ee,ne,ve,ke,De,Ge,Fe){if(ve/=ee,De>=(ne/=ee)&&Ge<ve)return xe;if(Ge<ne||De>=ve)return null;for(var me=[],Ye=0;Ye<xe.length;Ye++){var xt=xe[Ye],It=xt.geometry,_t=xt.type,ln=ke===0?xt.minX:xt.minY,wn=ke===0?xt.maxX:xt.maxY;if(ln>=ne&&wn<ve)me.push(xt);else if(!(wn<ne||ln>=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<It.length;En++){var Sn=[];bo(It[En],Sn,ne,ve,ke,!0),Sn.length&&on.push(Sn)}if(on.length){if(Fe.lineMetrics&&_t==="LineString"){for(En=0;En<on.length;En++)me.push(gt(xt.id,_t,on[En],xt.tags));continue}_t!=="LineString"&&_t!=="MultiLineString"||(on.length===1?(_t="LineString",on=on[0]):_t="MultiLineString"),_t!=="Point"&&_t!=="MultiPoint"||(_t=on.length===3?"Point":"MultiPoint"),me.push(gt(xt.id,_t,on,xt.tags))}}}return me.length?me:null}function Wo(xe,ee,ne,ve,ke){for(var De=0;De<xe.length;De+=3){var Ge=xe[De+ke];Ge>=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;_t<xe.length-3;_t+=3){var ln=xe[_t],wn=xe[_t+1],on=xe[_t+2],En=xe[_t+3],Sn=xe[_t+4],yi=ke===0?ln:wn,ki=ke===0?En:Sn,hr=!1;Ge&&(Fe=Math.sqrt(Math.pow(ln-En,2)+Math.pow(wn-Sn,2))),yi<ne?ki>ne&&(me=xt(Ye,ln,wn,En,Sn,ne),Ge&&(Ye.start=It+Fe*me)):yi>ve?ki<ve&&(me=xt(Ye,ln,wn,En,Sn,ve),Ge&&(Ye.start=It+Fe*me)):an(Ye,ln,wn,on),ki<ne&&yi>=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;Ge<xe.length;Ge++)zo(xe[Ge],ee,ne,ve,ke,De,!1)}function an(xe,ee,ne,ve){xe.push(ee),xe.push(ne),xe.push(ve)}function lo(xe,ee,ne,ve,ke,De){var Ge=(De-ee)/(ve-ee);return xe.push(De),xe.push(ne+(ke-ne)*Ge),xe.push(1),Ge}function uo(xe,ee,ne,ve,ke,De){var Ge=(De-ne)/(ke-ne);return xe.push(ee+(ve-ee)*Ge),xe.push(De),xe.push(1),Ge}function Mr(xe,ee){for(var ne=[],ve=0;ve<xe.length;ve++){var ke,De=xe[ve],Ge=De.type;if(Ge==="Point"||Ge==="MultiPoint"||Ge==="LineString")ke=tn(De.geometry,ee);else if(Ge==="MultiLineString"||Ge==="Polygon"){ke=[];for(var Fe=0;Fe<De.geometry.length;Fe++)ke.push(tn(De.geometry[Fe],ee))}else if(Ge==="MultiPolygon")for(ke=[],Fe=0;Fe<De.geometry.length;Fe++){for(var me=[],Ye=0;Ye<De.geometry[Fe].length;Ye++)me.push(tn(De.geometry[Fe][Ye],ee));ke.push(me)}ne.push(gt(De.id,Ge,ke,De.tags))}return ne}function tn(xe,ee){var ne=[];ne.size=xe.size,xe.start!==void 0&&(ne.start=xe.start,ne.end=xe.end);for(var ve=0;ve<xe.length;ve+=3)ne.push(xe[ve]+ee,xe[ve+1],xe[ve+2]);return ne}function as(xe,ee){if(xe.transformed)return xe;var ne,ve,ke,De=1<<xe.z,Ge=xe.x,Fe=xe.y;for(ne=0;ne<xe.features.length;ne++){var me=xe.features[ne],Ye=me.geometry,xt=me.type;if(me.geometry=[],xt===1)for(ve=0;ve<Ye.length;ve+=2)me.geometry.push(Ln(Ye[ve],Ye[ve+1],ee,De,Ge,Fe));else for(ve=0;ve<Ye.length;ve++){var It=[];for(ke=0;ke<Ye[ve].length;ke+=2)It.push(Ln(Ye[ve][ke],Ye[ve][ke+1],ee,De,Ge,Fe));me.geometry.push(It)}}return xe.transformed=!0,xe}function Ln(xe,ee,ne,ve,ke,De){return[Math.round(ne*(xe*ve-ke)),Math.round(ne*(ee*ve-De))]}function sn(xe,ee,ne,ve,ke){for(var De=ee===ke.maxZoom?0:ke.tolerance/((1<<ee)*ke.extent),Ge={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:ne,y:ve,z:ee,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},Fe=0;Fe<xe.length;Fe++){Ge.numFeatures++,ra(Ge,xe[Fe],De,ke);var me=xe[Fe].minX,Ye=xe[Fe].minY,xt=xe[Fe].maxX,It=xe[Fe].maxY;me<Ge.minX&&(Ge.minX=me),Ye<Ge.minY&&(Ge.minY=Ye),xt>Ge.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;Fe<ke.length;Fe+=3)Ge.push(ke[Fe]),Ge.push(ke[Fe+1]),xe.numPoints++,xe.numSimplified++;else if(De==="LineString")vr(Ge,ke,xe,ne,!1,!1);else if(De==="MultiLineString"||De==="Polygon")for(Fe=0;Fe<ke.length;Fe++)vr(Ge,ke[Fe],xe,ne,De==="Polygon",Fe===0);else if(De==="MultiPolygon")for(var me=0;me<ke.length;me++){var Ye=ke[me];for(Fe=0;Fe<Ye.length;Fe++)vr(Ge,Ye[Fe],xe,ne,!0,Fe===0)}if(Ge.length){var xt=ee.tags||null;if(De==="LineString"&&ve.lineMetrics){for(var It in xt={},ee.tags)xt[It]=ee.tags[It];xt.mapbox_clip_start=ke.start/ke.size,xt.mapbox_clip_end=ke.end/ke.size}var _t={geometry:Ge,type:De==="Polygon"||De==="MultiPolygon"?3:De==="LineString"||De==="MultiLineString"?2:1,tags:xt};ee.id!==null&&(_t.id=ee.id),xe.features.push(_t)}}function vr(xe,ee,ne,ve,ke,De){var Ge=ve*ve;if(ve>0&&ee.size<(ke?Ge:ve))ne.numPoints+=ee.length/3;else{for(var Fe=[],me=0;me<ee.length;me+=3)(ve===0||ee[me+2]>Ge)&&(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;_t<ln;wn=_t,_t+=2)It+=(Ye[_t]-Ye[wn])*(Ye[_t+1]+Ye[wn+1]);if(It>0===xt)for(_t=0,ln=Ye.length;_t<ln/2;_t+=2){var on=Ye[_t],En=Ye[_t+1];Ye[_t]=Ye[ln-2-_t],Ye[_t+1]=Ye[ln-1-_t],Ye[ln-2-_t]=on,Ye[ln-1-_t]=En}}(Fe,De),xe.push(Fe)}}function Yo(xe,ee){var ne=(ee=this.options=function(ke,De){for(var Ge in De)ke[Ge]=De[Ge];return ke}(Object.create(this.options),ee)).debug;if(ne&&console.time("preprocess data"),ee.maxZoom<0||ee.maxZoom>24)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;Fe<ke.features.length;Fe++)Fn(Ge,ke.features[Fe],De,Fe);else Fn(Ge,ke.type==="Feature"?ke:{geometry:ke},De);return Ge}(xe,ee);this.tiles={},this.tileCoords=[],ne&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",ee.indexMaxZoom,ee.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),ve=function(ke,De){var Ge=De.buffer/De.extent,Fe=ke,me=wt(ke,1,-1-Ge,Ge,0,-1,2,De),Ye=wt(ke,1,1-Ge,2+Ge,0,-1,2,De);return(me||Ye)&&(Fe=wt(ke,1,-Ge,1+Ge,0,-1,2,De)||[],me&&(Fe=Mr(me,1).concat(Fe)),Ye&&(Fe=Fe.concat(Mr(Ye,-1)))),Fe}(ve,ee),ve.length&&this.splitTile(ve,0,0,0),ne&&(ve.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function nn(xe,ee,ne){return 32*((1<<xe)*ne+ee)+xe}function ls(xe,ee){const ne=xe.tileID.canonical;if(!this._geoJSONIndex)return ee(null,null);const ve=this._geoJSONIndex.getTile(ne.z,ne.x,ne.y);if(!ve)return ee(null,null);const ke=new class{constructor(Ge){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.EXTENT,this.length=Ge.length,this._features=Ge}feature(Ge){return new class{constructor(Fe){this._feature=Fe,this.extent=t.EXTENT,this.type=Fe.type,this.properties=Fe.tags,"id"in Fe&&!isNaN(Fe.id)&&(this.id=parseInt(Fe.id,10))}loadGeometry(){if(this._feature.type===1){const Fe=[];for(const me of this._feature.geometry)Fe.push([new t.Point(me[0],me[1])]);return Fe}{const Fe=[];for(const me of this._feature.geometry){const Ye=[];for(const xt of me)Ye.push(new t.Point(xt[0],xt[1]));Fe.push(Ye)}return Fe}}toGeoJSON(Fe,me,Ye){return J.call(this,Fe,me,Ye)}}(this._features[Ge])}}(ve.features);let De=Lt(ke);De.byteOffset===0&&De.byteLength===De.buffer.byteLength||(De=new Uint8Array(De)),ee(null,{vectorTile:ke,rawData:De.buffer})}Yo.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},Yo.prototype.splitTile=function(xe,ee,ne,ve,ke,De,Ge){for(var Fe=[xe,ee,ne,ve],me=this.options,Ye=me.debug;Fe.length;){ve=Fe.pop(),ne=Fe.pop(),ee=Fe.pop(),xe=Fe.pop();var xt=1<<ee,It=nn(ee,ne,ve),_t=this.tiles[It];if(!_t&&(Ye>1&&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<<ke-ee;if(ne!==Math.floor(De/wn)||ve!==Math.floor(Ge/wn))continue}else if(ee===me.indexMaxZoom||_t.numPoints<=me.indexMaxPoints)continue;if(_t.source=null,xe.length!==0){Ye>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<<xe,Fe=nn(xe,ee=(ee%Ge+Ge)%Ge,ne);if(this.tiles[Fe])return as(this.tiles[Fe],ke);De>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<o.length;T++)v.push(Ve(_,d,o[T]));return v}function ze(_){return t.window.InstallTrigger!==void 0&&_.button===2&&_.ctrlKey&&t.window.navigator.platform.toUpperCase().indexOf("MAC")>=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]<v||T[1]<T[0]||d<T[1])return!1;v=T[1]}return!0}_validateContent(o,d){return!(o&&(o.length!==4||o[0]<0||d.data.width<o[0]||o[1]<0||d.data.height<o[1]||o[2]<0||d.data.width<o[2]||o[3]<0||d.data.height<o[3]||o[2]<o[0]||o[3]<o[1]))}updateImage(o,d){d.version=this.images[o].version+1,this.images[o]=d,this.updatedImages[o]=!0}removeImage(o){const d=this.images[o];delete this.images[o],delete this.patterns[o],d.userImage&&d.userImage.onRemove&&d.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(o,d){let v=!0;if(!this.isLoaded())for(const T of o)this.images[T]||(v=!1);this.isLoaded()||v?this._notify(o,d):this.requestors.push({ids:o,callback:d})}_notify(o,d){const v={};for(const T of o){this.images[T]||this.fire(new t.Event("styleimagemissing",{id:T}));const S=this.images[T];S?v[T]={data:S.data.clone(),pixelRatio:S.pixelRatio,sdf:S.sdf,version:S.version,stretchX:S.stretchX,stretchY:S.stretchY,content:S.content,hasRenderCallback:!!(S.userImage&&S.userImage.render)}:t.warnOnce(`Image "${T}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}d(null,v)}getPixelSize(){const{width:o,height:d}=this.atlasImage;return{width:o,height:d}}getPattern(o){const d=this.patterns[o],v=this.getImage(o);if(!v)return null;if(d&&d.position.version===v.version)return d.position;if(d)d.position.version=v.version;else{const T={w:v.data.width+2,h:v.data.height+2,x:0,y:0},S=new t.ImagePosition(T,v);this.patterns[o]={bin:T,position:S}}return this._updatePatternAtlas(),this.patterns[o].position}bind(o){const d=o.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.Texture(o,this.atlasImage,d.RGBA),this.atlasTexture&&this.atlasTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE)}_updatePatternAtlas(){const o=[];for(const S in this.patterns)o.push(this.patterns[S].bin);const{w:d,h:v}=t.potpack(o),T=this.atlasImage;T.resize({width:d||1,height:v||1});for(const S in this.patterns){const{bin:D}=this.patterns[S],z=D.x+1,N=D.y+1,q=this.images[S].data,G=q.width,Y=q.height;t.RGBAImage.copy(q,T,{x:0,y:0},{x:z,y:N},{width:G,height:Y}),t.RGBAImage.copy(q,T,{x:0,y:Y-1},{x:z,y:N-1},{width:G,height:1}),t.RGBAImage.copy(q,T,{x:0,y:0},{x:z,y:N+Y},{width:G,height:1}),t.RGBAImage.copy(q,T,{x:G-1,y:0},{x:z-1,y:N},{width:1,height:Y}),t.RGBAImage.copy(q,T,{x:0,y:0},{x:z+G,y:N},{width:1,height:Y})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(o){for(const d of o){if(this.callbackDispatchedThisFrame[d])continue;this.callbackDispatchedThisFrame[d]=!0;const v=this.images[d];ft(v)&&this.updateImage(d,v)}}}const Je=new t.Properties({anchor:new t.DataConstantProperty(t.spec.light.anchor),position:new class{constructor(){this.specification=t.spec.light.position}possiblyEvaluate(_,o){return function([d,v,T]){const S=t.degToRad(v+90),D=t.degToRad(T);return{x:d*Math.cos(S)*Math.sin(D),y:d*Math.sin(S)*Math.sin(D),z:d*Math.cos(D),azimuthal:v,polar:T}}(_.expression.evaluate(o))}interpolate(_,o,d){return{x:t.number(_.x,o.x,d),y:t.number(_.y,o.y,d),z:t.number(_.z,o.z,d),azimuthal:t.number(_.azimuthal,o.azimuthal,d),polar:t.number(_.polar,o.polar,d)}}},color:new t.DataConstantProperty(t.spec.light.color),intensity:new t.DataConstantProperty(t.spec.light.intensity)});class At extends t.Evented{constructor(o){super(),this._transitionable=new t.Transitionable(Je),this.setLight(o),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(o,d={}){if(!this._validate(t.validateLight,o,d))for(const v in o){const T=o[v];t.endsWith(v,"-transition")?this._transitionable.setTransition(v.slice(0,-11),T):this._transitionable.setValue(v,T)}}updateTransitions(o){this._transitioning=this._transitionable.transitioned(o,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(o){this.properties=this._transitioning.possiblyEvaluate(o)}_validate(o,d,v){return(!v||v.validate!==!1)&&t.emitValidationErrors(this,o.call(t.validateStyle,t.extend({value:d,style:{glyphs:!0,sprite:!0},styleSpec:t.spec})))}}const ut=new t.Properties({source:new t.DataConstantProperty(t.spec.terrain.source),exaggeration:new t.DataConstantProperty(t.spec.terrain.exaggeration)});let Nt=class extends t.Evented{constructor(_,o){super(),this._transitionable=new t.Transitionable(ut),this.set(_),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=o}get(){return this._transitionable.serialize()}set(_){for(const o in _){const d=_[o];t.endsWith(o,"-transition")?this._transitionable.setTransition(o.slice(0,-11),d):this._transitionable.setValue(o,d)}}updateTransitions(_){this._transitioning=this._transitionable.transitioned(_,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(_){this.properties=this._transitioning.possiblyEvaluate(_)}};function Lt(_,o,d,v){const T=t.smoothstep(45,65,d),[S,D]=Yt(_,v),z=t.length(o);let N=1-Math.min(1,Math.exp((z-S)/(D-S)*-6));return N*=N*N,N=Math.min(1,1.00747*N),N*T*_.alpha}function Yt(_,o){const d=.5/Math.tan(.5*o);return[_.range[0]+d,_.range[1]+d]}const Mt=new t.Properties({range:new t.DataConstantProperty(t.spec.fog.range),color:new t.DataConstantProperty(t.spec.fog.color),"high-color":new t.DataConstantProperty(t.spec.fog["high-color"]),"space-color":new t.DataConstantProperty(t.spec.fog["space-color"]),"horizon-blend":new t.DataConstantProperty(t.spec.fog["horizon-blend"]),"star-intensity":new t.DataConstantProperty(t.spec.fog["star-intensity"])});class Gt extends t.Evented{constructor(o,d){super(),this._transitionable=new t.Transitionable(Mt),this.set(o),this._transitioning=this._transitionable.untransitioned(),this._transform=d}get state(){const o=this._transform,d=o.projection.name==="globe",v=t.globeToMercatorTransition(o.zoom),T=this.properties.get("range"),S=[.5,3];return{range:d?[t.number(S[0],T[0],v),t.number(S[1],T[1],v)]:T,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(o,d={}){if(!this._validate(t.validateFog,o,d)){for(const v of Object.keys(t.spec.fog))o&&o[v]===void 0&&(o[v]=t.spec.fog[v].default);for(const v in o){const T=o[v];t.endsWith(v,"-transition")?this._transitionable.setTransition(v.slice(0,-11),T):this._transitionable.setValue(v,T)}}}getOpacity(o){if(!this._transform.projection.supportsFog)return 0;const d=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:t.smoothstep(45,65,o))*d.a}getOpacityAtLatLng(o,d){return this._transform.projection.supportsFog?function(v,T,S){const D=t.MercatorCoordinate.fromLngLat(T),z=S.elevation?S.elevation.getAtPointOrZero(D):0,N=[D.x,D.y,z];return t.transformMat4(N,N,S.mercatorFogMatrix),Lt(v,N,S.pitch,S._fov)}(this.state,o,d):0}getFovAdjustedRange(o){return this._transform.projection.supportsFog?Yt(this.state,o):[0,1]}updateTransitions(o){this._transitioning=this._transitionable.transitioned(o,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(o){this.properties=this._transitioning.possiblyEvaluate(o)}_validate(o,d,v){return(!v||v.validate!==!1)&&t.emitValidationErrors(this,o.call(t.validateStyle,t.extend({value:d,style:{glyphs:!0,sprite:!0},styleSpec:t.spec})))}}class tt{constructor(o,d){this.workerPool=o,this.actors=[],this.currentActor=0,this.id=t.uniqueId();const v=this.workerPool.acquire(this.id);for(let T=0;T<v.length;T++){const S=new tt.Actor(v[T],d,this.id);S.name=`Worker ${T}`,this.actors.push(S)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{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.splice(3,0,this.cameraPoint):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]<G[3],ue=t.polygonContainsPoint(S,ie)&&q[3]<G[3];if(!se&&!ue)return null;const le=function(Pe,Be,Oe){for(let Xe=1;Xe<Pe.length;Xe++){const pt=St(Be.pointCoordinate3D(Pe[Xe-1]).x),qe=St(Be.pointCoordinate3D(Pe[Xe]).x);if(Oe<0){if(pt<qe)return{idx:Xe,t:-pt/(qe-1-pt)}}else if(qe<pt)return{idx:Xe,t:(1-pt)/(qe+1-pt)}}return null}(S,D,se?-1:1);if(!le)return null;const{idx:fe,t:H}=le;let oe=fe>1?Vt(S.slice(0,fe),D):[],ge=fe<S.length?Vt(S.slice(fe),D):[];oe=oe.map(Pe=>new 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;Y<S.length-1;Y++)S[Y].x>N&&(N=S[Y].x,q=Y);for(let Y=0;Y<S.length-1;Y++){const ie=(q+Y)%(S.length-1),se=S[ie],ue=S[ie+1];Math.abs(se.x-ue.x)>.5&&(se.x<ue.x?(se.x+=1,ie===0&&(S[S.length-1].x+=1)):(ue.x+=1,ie+1===S.length-1&&(S[0].x+=1)),z=!0)}const G=t.mercatorXfromLng(D.center.lng);return z&&G<Math.abs(G-1)&&S.forEach(Y=>{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<S&&o.y>=T&&o.y<D}}class je{constructor(o,d,v){this.context=o;const T=o.gl;this.buffer=T.createBuffer(),this.dynamicDraw=!!v,this.context.unbindVAO(),o.bindElementBuffer.set(this.buffer),T.bufferData(T.ELEMENT_ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?T.DYNAMIC_DRAW:T.STATIC_DRAW),this.dynamicDraw||d.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(o){const d=this.context.gl;this.context.unbindVAO(),this.bind(),d.bufferSubData(d.ELEMENT_ARRAY_BUFFER,0,o.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Kn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class bn{constructor(o,d,v,T){this.length=d.length,this.attributes=v,this.itemSize=d.bytesPerElement,this.dynamicDraw=T,this.context=o;const S=o.gl;this.buffer=S.createBuffer(),o.bindVertexBuffer.set(this.buffer),S.bufferData(S.ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?S.DYNAMIC_DRAW:S.STATIC_DRAW),this.dynamicDraw||d.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(o){const d=this.context.gl;this.bind(),d.bufferSubData(d.ARRAY_BUFFER,0,o.arrayBuffer)}enableAttributes(o,d){for(let v=0;v<this.attributes.length;v++){const T=d.attributes[this.attributes[v].name];T!==void 0&&o.enableVertexAttribArray(T)}}setVertexAttribPointers(o,d,v){for(let T=0;T<this.attributes.length;T++){const S=this.attributes[T],D=d.attributes[S.name];D!==void 0&&o.vertexAttribPointer(D,S.components,o[Kn[S.type]],!1,this.itemSize,S.offset+this.itemSize*(v||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class gt{constructor(o){this.gl=o.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(o){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Me extends gt{getDefault(){return t.Color.transparent}set(o){const d=this.current;(o.r!==d.r||o.g!==d.g||o.b!==d.b||o.a!==d.a||this.dirty)&&(this.gl.clearColor(o.r,o.g,o.b,o.a),this.current=o,this.dirty=!1)}}class Fn extends gt{getDefault(){return 1}set(o){(o!==this.current||this.dirty)&&(this.gl.clearDepth(o),this.current=o,this.dirty=!1)}}class Si extends gt{getDefault(){return 0}set(o){(o!==this.current||this.dirty)&&(this.gl.clearStencil(o),this.current=o,this.dirty=!1)}}class yn extends gt{getDefault(){return[!0,!0,!0,!0]}set(o){const d=this.current;(o[0]!==d[0]||o[1]!==d[1]||o[2]!==d[2]||o[3]!==d[3]||this.dirty)&&(this.gl.colorMask(o[0],o[1],o[2],o[3]),this.current=o,this.dirty=!1)}}class _i extends gt{getDefault(){return!0}set(o){(o!==this.current||this.dirty)&&(this.gl.depthMask(o),this.current=o,this.dirty=!1)}}class Yi extends gt{getDefault(){return 255}set(o){(o!==this.current||this.dirty)&&(this.gl.stencilMask(o),this.current=o,this.dirty=!1)}}class Hi extends gt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(o){const d=this.current;(o.func!==d.func||o.ref!==d.ref||o.mask!==d.mask||this.dirty)&&(this.gl.stencilFunc(o.func,o.ref,o.mask),this.current=o,this.dirty=!1)}}class wt extends gt{getDefault(){const o=this.gl;return[o.KEEP,o.KEEP,o.KEEP]}set(o){const d=this.current;(o[0]!==d[0]||o[1]!==d[1]||o[2]!==d[2]||this.dirty)&&(this.gl.stencilOp(o[0],o[1],o[2]),this.current=o,this.dirty=!1)}}class Wo extends gt{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;o?d.enable(d.STENCIL_TEST):d.disable(d.STENCIL_TEST),this.current=o,this.dirty=!1}}class zo extends gt{getDefault(){return[0,1]}set(o){const d=this.current;(o[0]!==d[0]||o[1]!==d[1]||this.dirty)&&(this.gl.depthRange(o[0],o[1]),this.current=o,this.dirty=!1)}}class Fr extends gt{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;o?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST),this.current=o,this.dirty=!1}}class bo extends gt{getDefault(){return this.gl.LESS}set(o){(o!==this.current||this.dirty)&&(this.gl.depthFunc(o),this.current=o,this.dirty=!1)}}class an extends gt{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;o?d.enable(d.BLEND):d.disable(d.BLEND),this.current=o,this.dirty=!1}}class lo extends gt{getDefault(){const o=this.gl;return[o.ONE,o.ZERO]}set(o){const d=this.current;(o[0]!==d[0]||o[1]!==d[1]||this.dirty)&&(this.gl.blendFunc(o[0],o[1]),this.current=o,this.dirty=!1)}}class uo extends gt{getDefault(){return t.Color.transparent}set(o){const d=this.current;(o.r!==d.r||o.g!==d.g||o.b!==d.b||o.a!==d.a||this.dirty)&&(this.gl.blendColor(o.r,o.g,o.b,o.a),this.current=o,this.dirty=!1)}}class Mr extends gt{getDefault(){return this.gl.FUNC_ADD}set(o){(o!==this.current||this.dirty)&&(this.gl.blendEquation(o),this.current=o,this.dirty=!1)}}class tn extends gt{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;o?d.enable(d.CULL_FACE):d.disable(d.CULL_FACE),this.current=o,this.dirty=!1}}class as extends gt{getDefault(){return this.gl.BACK}set(o){(o!==this.current||this.dirty)&&(this.gl.cullFace(o),this.current=o,this.dirty=!1)}}class Ln extends gt{getDefault(){return this.gl.CCW}set(o){(o!==this.current||this.dirty)&&(this.gl.frontFace(o),this.current=o,this.dirty=!1)}}let sn,ra=class extends gt{getDefault(){return null}set(_){(_!==this.current||this.dirty)&&(this.gl.useProgram(_),this.current=_,this.dirty=!1)}};class vr extends gt{getDefault(){return this.gl.TEXTURE0}set(o){(o!==this.current||this.dirty)&&(this.gl.activeTexture(o),this.current=o,this.dirty=!1)}}class Yo extends gt{getDefault(){const o=this.gl;return[0,0,o.drawingBufferWidth,o.drawingBufferHeight]}set(o){const d=this.current;(o[0]!==d[0]||o[1]!==d[1]||o[2]!==d[2]||o[3]!==d[3]||this.dirty)&&(this.gl.viewport(o[0],o[1],o[2],o[3]),this.current=o,this.dirty=!1)}}class nn extends gt{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.bindFramebuffer(d.FRAMEBUFFER,o),this.current=o,this.dirty=!1}}class ls extends gt{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.bindRenderbuffer(d.RENDERBUFFER,o),this.current=o,this.dirty=!1}}class zs extends gt{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.bindTexture(d.TEXTURE_2D,o),this.current=o,this.dirty=!1}}class Os extends gt{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.bindBuffer(d.ARRAY_BUFFER,o),this.current=o,this.dirty=!1}}class xe extends gt{getDefault(){return null}set(o){const d=this.gl;d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,o),this.current=o,this.dirty=!1}}class ee extends gt{constructor(o){super(o),this.vao=o.extVertexArrayObject}getDefault(){return null}set(o){this.vao&&(o!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(o),this.current=o,this.dirty=!1)}}class ne extends gt{getDefault(){return 4}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_ALIGNMENT,o),this.current=o,this.dirty=!1}}class ve extends gt{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o),this.current=o,this.dirty=!1}}class ke extends gt{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_FLIP_Y_WEBGL,o),this.current=o,this.dirty=!1}}class De extends gt{constructor(o,d){super(o),this.context=o,this.parent=d}getDefault(){return null}}class Ge extends De{setDirty(){this.dirty=!0}set(o){if(o===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const d=this.gl;d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,o,0),this.current=o,this.dirty=!1}}class Fe extends De{attachment(){return this.gl.DEPTH_ATTACHMENT}set(o){if(o===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const d=this.gl;d.framebufferRenderbuffer(d.FRAMEBUFFER,this.attachment(),d.RENDERBUFFER,o),this.current=o,this.dirty=!1}}class me extends Fe{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Ye{constructor(o,d,v,T){this.context=o,this.width=d,this.height=v;const S=this.framebuffer=o.gl.createFramebuffer();this.colorAttachment=new Ge(o,S),T&&(this.depthAttachment=new Fe(o,S))}destroy(){const o=this.context.gl,d=this.colorAttachment.get();if(d&&o.deleteTexture(d),this.depthAttachment){const v=this.depthAttachment.get();v&&o.deleteRenderbuffer(v)}o.deleteFramebuffer(this.framebuffer)}}class xt{constructor(o,d=!1){if(this.gl=o,this.isWebGL2=d,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),d){const v=o;this.extVertexArrayObject={createVertexArrayOES:v.createVertexArray.bind(o),deleteVertexArrayOES:v.deleteVertexArray.bind(o),bindVertexArrayOES:v.bindVertexArray.bind(o)}}this.clearColor=new Me(this),this.clearDepth=new Fn(this),this.clearStencil=new Si(this),this.colorMask=new yn(this),this.depthMask=new _i(this),this.stencilMask=new Yi(this),this.stencilFunc=new Hi(this),this.stencilOp=new wt(this),this.stencilTest=new Wo(this),this.depthRange=new zo(this),this.depthTest=new Fr(this),this.depthFunc=new bo(this),this.blend=new an(this),this.blendFunc=new lo(this),this.blendColor=new uo(this),this.blendEquation=new Mr(this),this.cullFace=new tn(this),this.cullFaceSide=new as(this),this.frontFace=new Ln(this),this.program=new ra(this),this.activeTexture=new vr(this),this.viewport=new Yo(this),this.bindFramebuffer=new nn(this),this.bindRenderbuffer=new ls(this),this.bindTexture=new zs(this),this.bindVertexBuffer=new Os(this),this.bindElementBuffer=new xe(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new ee(this),this.pixelStoreUnpack=new ne(this),this.pixelStoreUnpackPremultiplyAlpha=new ve(this),this.pixelStoreUnpackFlipY=new ke(this),this.extTextureFilterAnisotropic=o.getExtension("EXT_texture_filter_anisotropic")||o.getExtension("MOZ_EXT_texture_filter_anisotropic")||o.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=o.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extDebugRendererInfo=o.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=o.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=o.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),d||(this.extTextureHalfFloat=o.getExtension("OES_texture_half_float")),(d||this.extTextureHalfFloat&&o.getExtension("OES_texture_half_float_linear"))&&(this.extRenderToTextureHalfFloat=o.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=d||o.getExtension("OES_standard_derivatives"),this.extTimerQuery=o.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=o.getParameter(o.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(o,d){return new je(this,o,d)}createVertexBuffer(o,d,v){return new bn(this,o,d,v)}createRenderbuffer(o,d,v){const T=this.gl,S=T.createRenderbuffer();return this.bindRenderbuffer.set(S),T.renderbufferStorage(T.RENDERBUFFER,o,d,v),this.bindRenderbuffer.set(null),S}createFramebuffer(o,d,v){return new Ye(this,o,d,v)}clear({color:o,depth:d,stencil:v}){const T=this.gl;let S=0;o&&(S|=T.COLOR_BUFFER_BIT,this.clearColor.set(o),this.colorMask.set([!0,!0,!0,!0])),d!==void 0&&(S|=T.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(d),this.depthMask.set(!0)),v!==void 0&&(S|=T.STENCIL_BUFFER_BIT,this.clearStencil.set(v),this.stencilMask.set(255)),T.clear(S)}setCullFace(o){o.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(o.mode),this.frontFace.set(o.frontFace))}setDepthMode(o){o.func!==this.gl.ALWAYS||o.mask?(this.depthTest.set(!0),this.depthFunc.set(o.func),this.depthMask.set(o.mask),this.depthRange.set(o.range)):this.depthTest.set(!1)}setStencilMode(o){o.test.func!==this.gl.ALWAYS||o.mask?(this.stencilTest.set(!0),this.stencilMask.set(o.mask),this.stencilOp.set([o.fail,o.depthFail,o.pass]),this.stencilFunc.set({func:o.test.func,ref:o.ref,mask:o.test.mask})):this.stencilTest.set(!1)}setColorMode(o){E(o.blendFunction,t.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(o.blendFunction),this.blendColor.set(o.blendColor)),this.colorMask.set(o.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class It extends t.Evented{constructor(o,d,v,T){if(super(),this.id=o,this.dispatcher=v,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,t.extend(this,t.pick(d,["url","scheme","tileSize","promoteId"])),this._options=t.extend({type:"vector"},d),this._collectResourceTiming=d.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(T),this._tileWorkers={},this._deduped=new t.DedupedRequest}load(o){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"}));const d=Array.isArray(this.map._language)?this.map._language.join():this.map._language,v=this.map._worldview;this._tileJSONRequest=rn(this._options,this.map._requestManager,d,v,(T,S)=>{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<d&&(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}),z}unloadTile(_){_.demTexture&&this.map.painter.saveTileTexture(_.demTexture),_.fbo&&(_.fbo.destroy(),delete _.fbo),_.dem&&delete _.dem,delete _.neighboringTiles,_.state="unloaded"}},geojson:class extends t.Evented{constructor(_,o,d,v){super(),this.id=_,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=d.getActor(),this.setEventedParent(v),this._data=o.data,this._options=t.extend({},o),this._collectResourceTiming=o.collectResourceTiming,o.maxzoom!==void 0&&(this.maxzoom=o.maxzoom),o.type&&(this.type=o.type),o.attribution&&(this.attribution=o.attribution),this.promoteId=o.promoteId;const T=t.EXTENT/this.tileSize;this.workerOptions=t.extend({source:this.id,cluster:o.cluster||!1,geojsonVtOptions:{buffer:(o.buffer!==void 0?o.buffer:128)*T,tolerance:(o.tolerance!==void 0?o.tolerance:.375)*T,extent:t.EXTENT,maxZoom:this.maxzoom,lineMetrics:o.lineMetrics||!1,generateId:o.generateId||!1},superclusterOptions:{maxZoom:o.clusterMaxZoom!==void 0?o.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,o.clusterMinPoints||2),extent:t.EXTENT,radius:(o.clusterRadius!==void 0?o.clusterRadius:50)*T,log:!1,generateId:o.generateId||!1},clusterProperties:o.clusterProperties,filter:o.filter},o.workerOptions)}onAdd(_){this.map=_,this.setData(this._data)}setData(_){return this._data=_,this._updateWorkerData(),this}getClusterExpansionZoom(_,o){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:_,source:this.id},o),this}getClusterChildren(_,o){return this.actor.send("geojson.getClusterChildren",{clusterId:_,source:this.id},o),this}getClusterLeaves(_,o,d,v){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:_,limit:o,offset:d},v),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new t.Event("dataloading",{dataType:"source"})),this._loaded=!1;const _=t.extend({},this.workerOptions),o=this._data;typeof o=="string"?(_.request=this.map._requestManager.transformRequest(t.exported.resolveURL(o),t.ResourceType.Source),_.request.collectResourceTiming=this._collectResourceTiming):_.data=JSON.stringify(o),this._pendingLoad=this.actor.send(`${this.type}.loadData`,_,(d,v)=>{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.start(0)||_>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.length;S++){const D=d[S],z=D.tileID.canonical.key;T[z]||(T[z]=!0,D.querySourceFeatures(v,o))}return v}function hr(_,o){const d=_.tileID,v=o.tileID;return d.overscaledZ-v.overscaledZ||d.canonical.y-v.canonical.y||d.wrap-v.wrap||d.canonical.x-v.canonical.x}function $n(){return cl.workerClass!=null?new cl.workerClass:new t.window.Worker(cl.workerUrl)}const $r="mapboxgl_preloaded_worker_pool";class Ci{constructor(){this.active={}}acquire(o){if(!this.workers)for(this.workers=[];this.workers.length<Ci.workerCount;)this.workers.push(new $n);return this.active[o]=!0,this.workers.slice()}release(o){delete this.active[o],this.numActive()===0&&(this.workers.forEach(d=>{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;v<this.points.length;v++)this._distances[v]=this._distances[v-1]+this.points[v].dist(this.points[v-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(d||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(o){if(this.points.length===1)return this.points[0];o=t.clamp(o,0,1);let d=1,v=this._distances[d];const T=o*this.paddedLength+this.padding;for(;v<T&&d<this._distances.length;)v=this._distances[++d];const S=d-1,D=this._distances[S],z=v-D,N=z>0?(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;D<this.xCellCount*this.yCellCount;D++)T.push([]),S.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=o,this.height=d,this.xScale=this.xCellCount/o,this.yScale=this.yCellCount/d,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(o,d,v,T,S){this._forEachCell(d,v,T,S,this._insertBoxCell,this.boxUid++),this.boxKeys.push(o),this.bboxes.push(d),this.bboxes.push(v),this.bboxes.push(T),this.bboxes.push(S)}insertCircle(o,d,v,T){this._forEachCell(d-T,v-T,d+T,v+T,this._insertCircleCell,this.circleUid++),this.circleKeys.push(o),this.circles.push(d),this.circles.push(v),this.circles.push(T)}_insertBoxCell(o,d,v,T,S,D){this.boxCells[S].push(D)}_insertCircleCell(o,d,v,T,S,D){this.circleCells[S].push(D)}_query(o,d,v,T,S,D){if(v<0||o>this.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;N<this.boxKeys.length;N++)z.push({key:this.boxKeys[N],x1:this.bboxes[4*N],y1:this.bboxes[4*N+1],x2:this.bboxes[4*N+2],y2:this.bboxes[4*N+3]});for(let N=0;N<this.circleKeys.length;N++){const q=this.circles[3*N],G=this.circles[3*N+1],Y=this.circles[3*N+2];z.push({key:this.circleKeys[N],x1:q-Y,y1:G-Y,x2:q+Y,y2:G+Y})}return D?z.filter(D):z}return this._forEachCell(o,d,v,T,this._queryCell,z,{hitTest:S,seenUids:{box:{},circle:{}}},D),S?z.length>0: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;Re<oe.length;Re++){const Pe=oe.get(Re),{numGlyphs:Be,writingMode:Oe}=Pe;if(Oe!==t.WritingMode.vertical||Ae||_e===t.WritingMode.horizontal||(Ae=!0),_e=Oe,(Pe.hidden||Oe===t.WritingMode.vertical)&&!Ae){ho(Be,le);continue}Ae=!1;const Xe=new t.Point(Pe.tileAnchorX,Pe.tileAnchorY);let{x:pt,y:qe,z:ot}=G.projection.projectTilePoint(Xe.x,Xe.y,q.canonical);if(N){const[un,Ut,Kt]=N(Xe);pt+=un,qe+=Ut,ot+=Kt}const He=[pt,qe,ot,1];if(t.transformMat4$1(He,He,o),!Eo(He,ue)){ho(Be,le);continue}const dt=Nu(d.transform.cameraToCenterDistance,He[3]),$e=t.evaluateSizeForFeature(Y,ie,Pe),it=D?$e/dt:$e*dt,yt=Ki(pt,qe,ot,T);if(yt[3]<=0){ho(Be,le);continue}let ct={};const bt=D?null:N,$t=Pt(Pe,it,!1,z,o,T,S,_.glyphOffsetArray,H,le,fe,yt,Xe,ct,ge,bt,G.projection,q,D);Ae=$t.useVertical,bt&&$t.needsFlipping&&(ct={}),($t.notEnoughRoom||Ae||$t.needsFlipping&&Pt(Pe,it,!0,z,o,T,S,_.glyphOffsetArray,H,le,fe,yt,Xe,ct,ge,bt,G.projection,q,D).notEnoughRoom)&&ho(Be,le)}v?(_.text.dynamicLayoutVertexBuffer.updateData(le),fe&&_.text.globeExtVertexBuffer.updateData(fe)):(_.icon.dynamicLayoutVertexBuffer.updateData(le),fe&&_.icon.globeExtVertexBuffer.updateData(fe))}function Rl(_,o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue,le){const{lineStartIndex:fe,glyphStartIndex:H,segment:oe}=z,ge=H+z.numGlyphs,_e=fe+z.lineLength,Ae=o.getoffsetX(H),Re=o.getoffsetX(ge-1),Pe=Ji(_*Ae,d,v,T,S,D,oe,fe,_e,N,q,G,Y,ie,!0,se,ue,le);if(!Pe)return null;const Be=Ji(_*Re,d,v,T,S,D,oe,fe,_e,N,q,G,Y,ie,!0,se,ue,le);return Be?{first:Pe,last:Be}:null}function Oo(_,o,d,v){return _===t.WritingMode.horizontal&&Math.abs(v)>Math.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;dt<Pe+Be-1;dt++){const $e=Ji(ge*z.getoffsetX(dt),_e,Ae,d,Y,ie,Oe,Re,qe,N,S,se,le,!1,!1,fe,H,oe);if(!$e)return q.length-=4*(dt-Pe),{notEnoughRoom:!0};ot($e)}ot(He.last)}else{if(v&&!d){const dt=Ki(ie.x,ie.y,0,T),$e=Re+Oe+1,it=new t.Point(N.getx($e),N.gety($e)),yt=Ki(it.x,it.y,0,T),ct=yt[3]>0?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<z||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<un.path.length;qt++)Kt.push(un.path[qt]);const An=2.5*it;q&&(Kt=Kt.map(([qt,Yn,ei],ti)=>(ge&&!Be&&(ei=ge(ti<Ut-1?$t.tilePath[Ut-1-ti]:un.tilePath[ti-Ut+2])[2]),Ki(qt,Yn,ei,q))),Kt.some(qt=>qt[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]))],(qt<yt.x||Yn>ct.x||ei<yt.y||ti>ct.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;ei<Yn;ei++){const ti=ei/Math.max(Yn-1,1),ni=bt.lerp(ti),Dr=ni.x+Vr,mr=ni.y+Vr;fe.push(Dr,mr,it,0);const Co=Dr-it,es=mr-it,wi=Dr+it,ii=mr+it;if($e=$e&&this.isOffscreen(Co,es,wi,ii),dt=dt||this.isInsideGrid(Co,es,wi,ii),!d&&this.grid.hitTestCircle(Dr,mr,it,ie)&&(He=!0,!G))return{circles:[],offscreen:!1,collisionDetected:He,occluded:!1}}}}return{circles:!G&&He||!dt?[]:fe,offscreen:$e,collisionDetected:He,occluded:Oe.occluded}}queryRenderedSymbols(o){if(o.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const d=[];let v=1/0,T=1/0,S=-1/0,D=-1/0;for(const G of o){const Y=new t.Point(G.x+Vr,G.y+Vr);v=Math.min(v,Y.x),T=Math.min(T,Y.y),S=Math.max(S,Y.x),D=Math.max(D,Y.y),d.push(Y)}const z=this.grid.query(v,T,S,D).concat(this.ignoredGrid.query(v,T,S,D)),N={},q={};for(const G of z){const Y=G.key;if(N[Y.bucketInstanceId]===void 0&&(N[Y.bucketInstanceId]={}),N[Y.bucketInstanceId][Y.featureIndex])continue;const ie=[new t.Point(G.x1,G.y1),new t.Point(G.x2,G.y1),new t.Point(G.x2,G.y2),new t.Point(G.x1,G.y2)];t.polygonIntersectsPolygon(d,ie)&&(N[Y.bucketInstanceId][Y.featureIndex]=!0,q[Y.bucketInstanceId]===void 0&&(q[Y.bucketInstanceId]=[]),q[Y.bucketInstanceId].push(Y.featureIndex))}return q}insertCollisionBox(o,d,v,T,S){(d?this.ignoredGrid:this.grid).insert({bucketInstanceId:v,featureIndex:T,collisionGroupID:S},o[0],o[1],o[2],o[3])}insertCollisionCircles(o,d,v,T,S){const D=d?this.ignoredGrid:this.grid,z={bucketInstanceId:v,featureIndex:T,collisionGroupID:S};for(let N=0;N<o.length;N+=4)D.insertCircle(z,o[N],o[N+1],o[N+2])}projectAndGetPerspectiveRatio(o,d,v,T,S,D,z){const N=[d,v,T,1];let q=!1;T||this.transform.pitch>0?(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<Vr||o>=this.screenRightBoundary||T<Vr||d>this.screenBottomBoundary}isInsideGrid(o,d,v,T){return v>=0&&o<this.gridRightBoundary&&T>=0&&d<this.gridBottomBoundary}getViewportMatrix(){const o=t.identity([]);return t.translate(o,o,[-100,-100,0]),o}}function Ho(_,o,d){const v=o.createTileMatrix(_,_.worldSize,d.toUnwrapped());return t.multiply(new Float32Array(16),_.projMatrix,v)}function fr(_,o,d){if(o.projection.name===d.projection.name)return _.projMatrix;const v=d.clone();return v.setProjection(o.projection),Ho(v,o.getProjection(),_)}function li(_,o,d){return o.name===d.projection.name?_.projMatrix:Ho(d,o,_)}class Bu{constructor(o,d,v,T){this.opacity=o?Math.max(0,Math.min(1,o.opacity+(o.placed?d:-d))):T&&v?1:0,this.placed=v}isHidden(){return this.opacity===0&&!this.placed}}class To{constructor(o,d,v,T,S,D=!1){this.text=new Bu(o?o.text:null,d,v,S),this.icon=new Bu(o?o.icon:null,d,T,S),this.clipped=D}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class ua{constructor(o,d,v,T=!1){this.text=o,this.icon=d,this.skipFade=v,this.clipped=T}}class hs{constructor(){this.invProjMatrix=t.create(),this.viewportMatrix=t.create(),this.circles=[]}}class mi{constructor(o,d,v,T,S){this.bucketInstanceId=o,this.featureIndex=d,this.sourceLayerIndex=v,this.bucketIndex=T,this.tileID=S}}class Ko{constructor(o){this.crossSourceCollisions=o,this.maxGroupID=0,this.collisionGroups={}}get(o){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[o]){const d=++this.maxGroupID;this.collisionGroups[o]={ID:d,predicate:v=>v.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<nc;++eu){const Th=this.attemptAnchorPlacement(Gn[eu%Gn.length],vi,Ql,bs,wa,Ae,Re,Y,z,fe,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<Cn.circles.length;Gn+=4)ii.circles.push(Cn.circles[Gn+0]),ii.circles.push(Cn.circles[Gn+1]),ii.circles.push(Cn.circles[Gn+2]),ii.circles.push(Cn.collisionDetected?1:0)}const es=S.projection.name!=="globe";Oe=Oe&&(es||!bt),Xe=Xe&&(es||!$t),this.placements[dt]=new ua(it||Oe,yt||Xe,ct||S.justReloaded),d.add(dt)};if(Be){const qe=S.getSortedSymbolIndexes(this.transform.angle);for(let ot=qe.length-1;ot>=0;--ot){const He=qe[ot];pt(S.symbolInstances.get(He),He,S.collisionArrays[He])}}else for(let qe=o.symbolInstanceStart;qe<o.symbolInstanceEnd;qe++)pt(S.symbolInstances.get(qe),qe,S.collisionArrays[qe]);if(v&&S.bucketInstanceId in this.collisionCircleArrays){const qe=this.collisionCircleArrays[S.bucketInstanceId];t.invert(qe.invProjMatrix,z),qe.viewportMatrix=this.collisionIndex.getViewportMatrix()}S.justReloaded=!1}markUsedJustification(o,d,v,T){const{leftJustifiedTextSymbolIndex:S,centerJustifiedTextSymbolIndex:D,rightJustifiedTextSymbolIndex:z,verticalPlacedTextSymbolIndex:N,crossTileID:q}=v,G=t.getAnchorJustification(d),Y=T===t.WritingMode.vertical?N:G==="left"?S:G==="center"?D:G==="right"?z:-1;S>=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;ge<H/4;ge++)fe.opacityVertexArray.emplaceBack(oe)};let le=0;for(let fe=0;fe<o.symbolInstances.length;fe++){const H=o.symbolInstances.get(fe),{numHorizontalGlyphVertices:oe,numVerticalGlyphVertices:ge,crossTileID:_e,numIconVertices:Ae}=H,Re=d.has(_e);let Pe=this.opacities[_e];Re?Pe=D:Pe||(Pe=se,this.opacities[_e]=Pe),d.add(_e);const Be=oe>0||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.lastPlacementChangeTime<this.fadeDuration}stillRecent(o,d){const v=this.zoomAtLastRecencyCheck===d?1-this.zoomAdjustment(d):1;return this.zoomAtLastRecencyCheck=d,this.commitTime+this.fadeDuration*v>o}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._currentTileIndex<o.length;)if(d.getBucketParts(D,T,o[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,S())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,D.sort((z,N)=>z.sortKey-N.sortKey));this._currentPartIndex<D.length;){const z=D[this._currentPartIndex];if(d.placeLayerBucketPart(z,this._seenCrossTileIDs,v,z.symbolInstanceStart===0),this._currentPartIndex++,S())return!0}return!1}}class Ga{constructor(o,d,v,T,S,D,z,N){this.placement=new xr(o,S,D,z,N),this._currentPlacementIndex=d.length-1,this._forceFullPlacement=v,this._showCollisionBoxes=T,this._done=!1}isDone(){return this._done}continuePlacement(o,d,v){const T=t.exported.now(),S=()=>{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;D<d.length;D++){const{key:z,crossTileID:N,tileAnchorX:q,tileAnchorY:G}=d.get(D),Y=Math.floor((T+q)*fo),ie=Math.floor((S+G)*fo);this.index.add(Y,ie),this.keys.push(z),this.crossTileIDs.push(N)}this.index.finish()}findMatches(o,d,v){const T=this.tileID.canonical.z<d.canonical.z?1:Math.pow(2,this.tileID.canonical.z-d.canonical.z),S=fo/Math.pow(2,d.canonical.z-this.tileID.canonical.z),D=d.canonical.x*t.EXTENT,z=d.canonical.y*t.EXTENT;for(let N=0;N<o.length;N++){const q=o.get(N);if(q.crossTileID)continue;const{key:G,tileAnchorX:Y,tileAnchorY:ie}=q,se=Math.floor((D+Y)*S),ue=Math.floor((z+ie)*S),le=this.index.range(se-T,ue-T,se+T,ue+T);for(const fe of le){const H=this.crossTileIDs[fe];if(this.keys[fe]===G&&!v.has(H)){v.add(H),q.crossTileID=H;break}}}}}class ar{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class qa{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(o){const d=Math.round((o-this.lng)/360);if(d!==0)for(const v in this.indexes){const T=this.indexes[v],S={};for(const D in T){const z=T[D];z.tileID=z.tileID.unwrapTo(z.tileID.wrap+d),S[z.tileID.key]=z}this.indexes[v]=S}this.lng=o}addBucket(o,d,v){if(this.indexes[o.overscaledZ]&&this.indexes[o.overscaledZ][o.key]){if(this.indexes[o.overscaledZ][o.key].bucketInstanceId===d.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(o.overscaledZ,this.indexes[o.overscaledZ][o.key])}for(let S=0;S<d.symbolInstances.length;S++)d.symbolInstances.get(S).crossTileID=0;this.usedCrossTileIDs[o.overscaledZ]||(this.usedCrossTileIDs[o.overscaledZ]=new Set);const T=this.usedCrossTileIDs[o.overscaledZ];for(const S in this.indexes){const D=this.indexes[S];if(Number(S)>o.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.symbolInstances.length;S++){const D=d.symbolInstances.get(S);D.crossTileID||(D.crossTileID=v.generate(),T.add(D.crossTileID))}return this.indexes[o.overscaledZ]===void 0&&(this.indexes[o.overscaledZ]={}),this.indexes[o.overscaledZ][o.key]=new Qi(o,d.symbolInstances,d.bucketInstanceId),!0}removeBucketCrossTileIDs(o,d){for(const v of d.crossTileIDs)this.usedCrossTileIDs[o].delete(v)}removeStaleBuckets(o){let d=!1;for(const v in this.indexes){const T=this.indexes[v];for(const S in T)o[T[S].bucketInstanceId]||(this.removeBucketCrossTileIDs(v,T[S]),delete T[S],d=!0)}return d}}class po{constructor(){this.layerIndexes={},this.crossTileIDs=new ar,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(o,d,v,T){let S=this.layerIndexes[o.id];S===void 0&&(S=this.layerIndexes[o.id]=new qa);let D=!1;const z={};T.name!=="globe"&&S.handleWrapJump(v);for(const N of d){const q=N.getBucket(o);q&&o.id===q.layerIds[0]&&(q.bucketInstanceId||(q.bucketInstanceId=++this.maxBucketInstanceId),S.addBucket(N.tileID,q,this.crossTileIDs)&&(D=!0),z[q.bucketInstanceId]=!0)}return S.removeStaleBuckets(z)&&(D=!0),D}pruneUnusedLayers(o){const d={};o.forEach(v=>{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<ue.length;_e++)Re=ue[_e],H.hasOwnProperty(Re)?Ae++:(se.push({command:On.removeLayer,args:[Re]}),oe.splice(oe.indexOf(Re,Ae),1));for(_e=0,Ae=0;_e<le.length;_e++)Re=le[le.length-1-_e],oe[oe.length-1-_e]!==Re&&(fe.hasOwnProperty(Re)?(se.push({command:On.removeLayer,args:[Re]}),oe.splice(oe.lastIndexOf(Re,oe.length-Ae),1)):Ae++,Oe=oe[oe.length-_e],se.push({command:On.addLayer,args:[H[Re],Oe]}),oe.splice(oe.length-_e,0,Re),ge[Re]=!0);for(_e=0;_e<le.length;_e++)if(Re=le[_e],Pe=fe[Re],Be=H[Re],!ge[Re]&&!E(Pe,Be))if(E(Pe.source,Be.source)&&E(Pe["source-layer"],Be["source-layer"])&&E(Pe.type,Be.type)){for(Xe in Sr(Pe.layout,Be.layout,se,Re,null,On.setLayoutProperty),Sr(Pe.paint,Be.paint,se,Re,null,On.setPaintProperty),E(Pe.filter,Be.filter)||se.push({command:On.setFilter,args:[Re,Be.filter]}),E(Pe.minzoom,Be.minzoom)&&E(Pe.maxzoom,Be.maxzoom)||se.push({command:On.setLayerZoomRange,args:[Re,Be.minzoom,Be.maxzoom]}),Pe)Pe.hasOwnProperty(Xe)&&Xe!=="layout"&&Xe!=="paint"&&Xe!=="filter"&&Xe!=="metadata"&&Xe!=="minzoom"&&Xe!=="maxzoom"&&(Xe.indexOf("paint.")===0?Sr(Pe[Xe],Be[Xe],se,Re,Xe.slice(6),On.setPaintProperty):E(Pe[Xe],Be[Xe])||se.push({command:On.setLayerProperty,args:[Re,Xe,Be[Xe]]}));for(Xe in Be)Be.hasOwnProperty(Xe)&&!Pe.hasOwnProperty(Xe)&&Xe!=="layout"&&Xe!=="paint"&&Xe!=="filter"&&Xe!=="metadata"&&Xe!=="minzoom"&&Xe!=="maxzoom"&&(Xe.indexOf("paint.")===0?Sr(Pe[Xe],Be[Xe],se,Re,Xe.slice(6),On.setPaintProperty):E(Pe[Xe],Be[Xe])||se.push({command:On.setLayerProperty,args:[Re,Xe,Be[Xe]]}))}else se.push({command:On.removeLayer,args:[Re]}),Oe=oe[oe.lastIndexOf(Re)+1],se.push({command:On.addLayer,args:[Be,Oe]})}(q,S.layers,D)}catch(z){console.warn("Unable to compute style diff:",z),D=[{command:On.setStyle,args:[S]}]}return D}(this.serialize(),o).filter(T=>!(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]<D)break;S.push(q),T.pop()}else for(const N of o){const q=N[z];if(q)for(const G of q)S.push(G.feature)}}return S}queryRenderedFeatures(o,d,v){d&&d.filter&&this._validate(t.validateFilter,"queryRenderedFeatures.filter",d.filter,null,d);const T={};if(d&&d.layers){if(!Array.isArray(d.layers))return this.fire(new t.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const N of d.layers){const q=this._layers[N];if(!q)return this.fire(new t.ErrorEvent(new Error(`The layer '${N}' does not exist in the map's style and cannot be queried for features.`))),[];T[q.source]=!0}}const S=[];d.availableImages=this._availableImages;const D=d&&d.layers?d.layers.some(N=>{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<T.length;G++)this.boundPaintVertexBuffers[G]!==T[G]&&(N=!0);let q=this.boundDynamicVertexBuffers.length!==z.length;for(let G=0;!q&&G<z.length;G++)this.boundDynamicVertexBuffers[G]!==z[G]&&(q=!0);if(!o.extVertexArrayObject||!this.vao||this.boundProgram!==d||this.boundLayoutVertexBuffer!==v||N||q||this.boundIndexBuffer!==S||this.boundVertexOffset!==D)this.freshBind(d,v,T,S,D,z);else{o.bindVertexArrayOES.set(this.vao);for(const G of z)G&&G.bind();S&&S.dynamicDraw&&S.bind()}}freshBind(o,d,v,T,S,D){let z;const N=o.numAttributes,q=this.context,G=q.gl;if(q.extVertexArrayObject)this.vao&&this.destroy(),this.vao=q.extVertexArrayObject.createVertexArrayOES(),q.bindVertexArrayOES.set(this.vao),z=0,this.boundProgram=o,this.boundLayoutVertexBuffer=d,this.boundPaintVertexBuffers=v,this.boundIndexBuffer=T,this.boundVertexOffset=S,this.boundDynamicVertexBuffers=D;else{z=q.currentNumAttributes||0;for(let Y=N;Y<z;Y++)G.disableVertexAttribArray(Y)}d.enableAttributes(G,o),d.bind(),d.setVertexAttribPointers(G,o,S);for(const Y of v)Y.enableAttributes(G,o),Y.bind(),Y.setVertexAttribPointers(G,o,S);for(const Y of D)Y&&(Y.enableAttributes(G,o),Y.bind(),Y.setVertexAttribPointers(G,o,S));T&&T.bind(),q.currentNumAttributes=N}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function Fl(_,o){const d=Math.pow(2,o.canonical.z),v=o.canonical.y;return[new t.MercatorCoordinate(0,v/d).toLngLat().lat,new t.MercatorCoordinate(0,(v+1)/d).toLngLat().lat]}function Fu(_,o,d,v,T,S,D){const z=_.context,N=z.gl,q=d.fbo;if(!q)return;_.prepareDrawTile();const G=_.useProgram("hillshade");z.activeTexture.set(N.TEXTURE0),N.bindTexture(N.TEXTURE_2D,q.colorAttachment.get());const Y=((le,fe,H,oe)=>{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;fe<ue;fe+=ie)for(let H=-ie;H<ue;H+=ie){const oe=H<0||H>se||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<<ie.canonical.z)*ie.wrap,ie.canonical.y),le=new t.Point(se.canonical.x+(1<<se.canonical.z)*se.wrap,se.canonical.y),fe=Y.mult(1<<ie.canonical.z);return fe.x-=.5,fe.y-=.5,fe.distSqr(ue)-fe.distSqr(le)})})(T,this.painter),this._previousZoom=v.zoom;const S=this.proxyToSource||{};this.proxyToSource={},T.forEach(N=>{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<<N.tileID.canonical.z)*t.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;D.u_meter_to_dem=Y}if(v&&v.labelPlaneMatrixInv&&(D.u_label_plane_matrix_inv=v.labelPlaneMatrixInv),d.setTerrainUniformValues(T,D),this.painter.transform.projection.name==="globe"){const Y=this.globeUniformValues(this.painter.transform,o.tileID.canonical,v&&v.useDenormalizedUpVectorScale);d.setGlobeUniformValues(T,Y)}}globeUniformValues(o,d,v){const T=o.projection;return{u_tile_tl_up:T.upVector(d,0,0),u_tile_tr_up:T.upVector(d,t.EXTENT,0),u_tile_br_up:T.upVector(d,t.EXTENT,t.EXTENT),u_tile_bl_up:T.upVector(d,0,t.EXTENT),u_tile_up_scale:v?t.globeMetersToEcef(1):T.upVectorScale(d,o.center.lat,o.worldSize).metersToTile}}renderToBackBuffer(o){const d=this.painter,v=this.painter.context;o.length!==0&&(v.bindFramebuffer.set(null),v.viewport.set([0,0,d.width,d.height]),d.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(T,S,D,z,N){if(T.transform.projection.name==="globe")(function(q,G,Y,ie,se){const ue=q.context,le=ue.gl;let fe,H;const oe=q.options.showTerrainWireframe?2:0,ge=q.transform,_e=t.globeUseCustomAntiAliasing(q,ue,ge),Ae=(dt,$e)=>{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<<ct)-1,[un,Ut,Kt,An]=pt.getPoleBuffers(ct);if(An&&(bt||$t)){const Cn=Y.getTile($e);ue.activeTexture.set(le.TEXTURE0),Cn.texture.bind(le.LINEAR,le.CLAMP_TO_EDGE);let qt=t.globePoleMatrixForTile(ct,it,ge);const Yn=t.globeNormalizeECEF(t.globeTileBounds($e.canonical)),ei=(ti,ni)=>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;z<d;++z){const N=o._layers[o.order[z]];this._style.isLayerDraped(N)?(D&&++T,++S):D||(D=!0,v=N.id)}return S===0?{efficiency:100}:{efficiency:100*(1-T/S),firstUndrapedLayer:v}}getMinElevationBelowMSL(){let o=0;return this._visibleDemTiles.filter(d=>d.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<<D.overscaledZ,{x:N,y:q}=D.canonical,G=N/z,Y=(N+1)/z,ie=q/z,se=(q+1)/z;return{minx:G,miny:ie,maxx:Y,maxy:se,t:S.dem.tree.raycastRoot(G,ie,Y,se,o,d,v),tile:S}});T.sort((S,D)=>(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<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const o in this._style._sourceCaches)if(this._style._sourceCaches[o].hasTransition())return!0;return this._style.order.some(o=>{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;v<this._style.order.length;++v){const T=this._style._layers[this._style.order[v]],S=this._style._getLayerSourceCache(T);if(S&&!d[S.id]&&!T.isHidden(this.painter.transform.zoom)&&T.type==="line"&&T.widthExpression()instanceof t.ZoomDependentExpression){d[S.id]=!0;for(const D of this.proxyCoords){const z=this.proxyToSource[D.key][S.id];if(z)for(const N of z)this._clearRenderCacheForTile(S.id,N)}}}}_clearRasterLayersFromRenderCache(){let o=!1;for(const v in this._style._sourceCaches)if(this._style._sourceCaches[v]._source instanceof _t){o=!0;break}if(!o)return;const d={};for(let v=0;v<this._style.order.length;++v){const T=this._style._layers[this._style.order[v]],S=this._style._getLayerSourceCache(T);if(!S||d[S.id]||T.isHidden(this.painter.transform.zoom)||T.type!=="raster")continue;const D=T.paint.get("raster-fade-duration");for(const z of this.proxyCoords){const N=this.proxyToSource[z.key][S.id];if(N)for(const q of N){const G=br(S.getTile(q),S.findLoadedParent(q,0),S,this.painter.transform,D);(G.opacity!==1||G.mix!==0)&&this._clearRenderCacheForTile(S.id,q)}}}}_setupDrapedRenderBatches(){const o=this._style.order,d=o.length;if(d===0)return;const v=[];let T,S=0,D=this._style._layers[o[S]];for(;!this._style.isLayerDraped(D)&&D.isHidden(this.painter.transform.zoom)&&++S<d;)D=this._style._layers[o[S]];for(;S<d;++S){const z=this._style._layers[o[S]];z.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(z)?T===void 0&&(T=S):T!==void 0&&(v.push({start:T,end:S-1}),T=void 0))}T!==void 0&&v.push({start:T,end:S-1}),this._drapedRenderBatches=v}_setupRenderCache(o){const d=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,d.renderCache.length>d.renderCachePool.length){const D=Object.values(d.proxyCachedFBO);d.proxyCachedFBO={};for(let z=0;z<D.length;++z){const N=Object.values(D[z]);d.renderCachePool.push(...N)}}return}this._clearRasterLayersFromRenderCache();const v=this.proxyCoords,T=this._tilesDirty;for(let D=v.length-1;D>=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<S.length;z++){const N=S[z],q=this._findTileCoveringTileID(N,o);if(q){const G=this._createProxiedId(N,q,v[N.key]&&v[N.key][o.id]);T.push(G),this.proxyToSource[N.key][o.id]=[G]}}let D=!1;for(let z=0;z<d.length;z++){const N=o.getTile(d[z]);if(!N||!N.hasData())continue;const q=this._findTileCoveringTileID(N.tileID,this.proxySourceCache);if(q&&q.tileID.canonical.z!==N.tileID.canonical.z){const G=this.proxyToSource[q.tileID.key][o.id],Y=this._createProxiedId(q.tileID,N,v[q.tileID.key]&&v[q.tileID.key][o.id]);G?G.splice(G.length-1,0,Y):this.proxyToSource[q.tileID.key][o.id]=[Y],T.push(Y),D=!0}}this._sourceTilesOverlap[o.id]=D}_setupProxiedCoordsForImageSource(o,d,v){if(!o.getSource().loaded())return;const T=this.proxiedCoords[o.id]=[],S=this.proxyCoords,D=o.getSource(),z=new t.Point(D.tileID.x,D.tileID.y)._div(1<<D.tileID.z),N=D.coordinates.map(t.MercatorCoordinate.fromLngLat).reduce((G,Y)=>(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<<G.canonical.z),se=G.canonical.y/(1<<G.canonical.z),ue=t.EXTENT/(1<<G.canonical.z),le=Y.wrap+Y.canonical.x/(1<<Y.canonical.z),fe=Y.canonical.y/(1<<Y.canonical.z);return ie+ue<le+N.min.x||ie>le+N.max.x||se+ue<fe+N.min.y||se>fe+N.max.y};for(let G=0;G<S.length;G++){const Y=S[G];for(let ie=0;ie<d.length;ie++){const se=o.getTile(d[ie]);if(!se||!se.hasData()||q(Y,se.tileID))continue;const ue=this._createProxiedId(Y,se,v[Y.key]&&v[Y.key][o.id]),le=this.proxyToSource[Y.key][o.id];le?le.push(ue):this.proxyToSource[Y.key][o.id]=[ue],T.push(ue)}}}_createProxiedId(o,d,v){let T=this.orthoMatrix;if(v){const S=v.find(D=>D.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<<o.overscaledZ;S>0?(D=t.EXTENT>>S,z=D*((d.tileID.canonical.x<<S)-o.canonical.x+q),N=D*((d.tileID.canonical.y<<S)-o.canonical.y)):(D=t.EXTENT<<-S,z=t.EXTENT*(d.tileID.canonical.x-(o.canonical.x+q<<-S)),N=t.EXTENT*(d.tileID.canonical.y-(o.canonical.y<<-S))),t.ortho(T,0,D,0,D,0,1),t.translate(T,T,[z,N,0])}return new _a(d.tileID,o.key,T)}_findTileCoveringTileID(o,d){let v=d.getTile(o);if(v&&v.hasData())return v;const T=this._findCoveringTileCache[d.id],S=T[o.key];if(v=S?d.getTileByID(S):null,v&&v.hasData()||S===null)return v;let D=v?v.tileID:o,z=D.overscaledZ;const N=d.getSource().minzoom,q=[];if(!S){const Y=d.getSource().maxzoom;if(o.canonical.z>=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<H.length;ge++){if(H[ge]===null)continue;const _e=H[ge].split(" ");oe.push(_e.pop())}return oe}(v.staticAttributes),q=T?T.getBinderAttributes():[],G=N.concat(q);let Y=T?T.defines():[];Y=Y.concat(D.map(H=>`#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<this.numAttributes;H++)G[H]&&(z.bindAttribLocation(this.program,H,G[H]),this.attributes[G[H]]=H);z.linkProgram(this.program),z.deleteShader(fe),z.deleteShader(le),this.fixedUniforms=S(o),this.binderUniforms=T?T.getUniforms(o):[],D.includes("TERRAIN")&&(this.terrainUniforms=(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<<D.canonical.z],H.u_zoom_transition=N,H.u_inv_rot_matrix=G,H.u_merc_center=q,H.u_up_dir=fe.projection.upVector(new t.CanonicalTileID(0,0,0),q[0]*t.EXTENT,q[1]*t.EXTENT),H.u_height_lift=z),H},Uu=(_,o,d,v,T,S,D,z,N,q,G,Y)=>{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<<o.canonical.z],q.u_zoom_transition=t.globeToMercatorTransition(D.zoom);const G=T[0]*t.EXTENT,Y=T[1]*t.EXTENT;q.u_up_dir=D.projection.upVector(new t.CanonicalTileID(0,0,0),G,Y)}return q},Gl=_=>{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<<o.canonical.z],G.u_zoom_transition=t.globeToMercatorTransition(z.zoom);const Y=T[0]*t.EXTENT,ie=T[1]*t.EXTENT;G.u_up_dir=z.projection.upVector(new t.CanonicalTileID(0,0,0),Y,ie)}return G},ah=(_,o,d,v,T,S,D)=>{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<<G.canonical.z],H.u_zoom_transition=Y,H.u_inv_rot_matrix=se,H.u_merc_center=ie,H.u_camera_forward=fe._camera.forward(),H.u_ecef_origin=t.globeECEFOrigin(fe.globeMatrix,G.toUnwrapped()),H.u_tile_matrix=Float32Array.from(fe.globeMatrix),H.u_up_vector=ue),H},Us=(_,o,d,v,T,S,D,z,N,q,G,Y,ie,se,ue,le,fe)=>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;_e<v.length;_e++){const Ae=v[_e],Re=o.getTile(Ae),Pe=Re.getBucket(d);if(!Pe)continue;const Be=fr(Ae,Pe,q);let Oe=Be;T[0]===0&&T[1]===0||(Oe=_.translatePosMatrix(Be,Re,T,S));const Xe=D?Pe.textCollisionBox:Pe.iconCollisionBox,pt=Pe.collisionCircleArray;if(pt.length>0){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<Ae;Pe++){const Be=6*Pe;Re.uint16[Be+0]=4*Pe+0,Re.uint16[Be+1]=4*Pe+1,Re.uint16[Be+2]=4*Pe+2,Re.uint16[Be+3]=4*Pe+2,Re.uint16[Be+4]=4*Pe+3,Re.uint16[Be+5]=4*Pe+0}return Re}(ie));const H=z.createIndexBuffer(nl,!0),oe=z.createVertexBuffer(le,t.collisionCircleLayout.members,!0);for(const _e of Y){const Ae={u_matrix:_e.transform,u_inv_matrix:_e.invTransform,u_camera_to_center_distance:(ge=q).getCameraToCenterDistance(_e.projection),u_viewport_size:[ge.width,ge.height]};ue.draw(z,N.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,_.colorModeForRenderPass(),t.CullFaceMode.disabled,Ae,d.id,oe,H,t.SegmentVector.simpleSegment(0,2*_e.circleOffset,_e.circleArray.length,_e.circleArray.length/2),null,q.zoom)}var ge;oe.destroy(),H.destroy()}const $u=t.create();function il({width:_,height:o,anchor:d,textOffset:v,textScale:T},S){const{horizontalAlign:D,verticalAlign:z}=t.getAnchorAlignment(d),N=-(D-.5)*_,q=-(z-.5)*o,G=t.evaluateVariableOffset(d,v);return new t.Point((N/T+G[0])*S,(q/T+G[1])*S)}function Hr(_,o,d,v,T,S,D,z,N,q,G){const Y=_.text.placedSymbolArray,ie=_.text.dynamicLayoutVertexArray,se=_.icon.dynamicLayoutVertexArray,ue={},le=_.getProjection(),fe=li(z,le,S),H=S.elevation,oe=le.upVectorScale(z.canonical,S.center.lat,S.worldSize).metersToTile;ie.clear();for(let ge=0;ge<Y.length;ge++){const _e=Y.get(ge),{tileAnchorX:Ae,tileAnchorY:Re,numGlyphs:Pe}=_e,Be=_e.hidden||!_e.crossTileID||_.allowVerticalPlacement&&!_e.placedOrientation?null:v[_e.crossTileID];if(Be){let Oe=0,Xe=0,pt=0;if(H){const bt=H?H.getAtTileOffset(z,Ae,Re):0,[$t,un,Ut]=le.upVector(z.canonical,Ae,Re);Oe=bt*$t*oe,Xe=bt*un*oe,pt=bt*Ut*oe}let[qe,ot,He,dt]=Ki(_e.projectedAnchorX+Oe,_e.projectedAnchorY+Xe,_e.projectedAnchorZ+pt,d?fe:D);const $e=Nu(S.getCameraToCenterDistance(le),dt);let it=T.evaluateSizeForFeature(_.textSizeData,q,_e)*$e/t.ONE_EM;d&&(it*=_.tilePixelRatio/N);const yt=il(Be,it);d?({x:qe,y:ot,z:He}=le.projectTilePoint(Ae+yt.x,Re+yt.y,z.canonical),[qe,ot,He]=Ki(qe+Oe,ot+Xe,He+pt,D)):(o&&yt._rotate(-S.angle),qe+=yt.x,ot+=yt.y,He=0);const ct=_.allowVerticalPlacement&&_e.placedOrientation===t.WritingMode.vertical?Math.PI/2:0;for(let bt=0;bt<Pe;bt++)t.addDynamicAttributes(ie,qe,ot,He,ct);G&&_e.associatedIconIndex>=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;_e<ge.length;_e++){const Ae=ge.get(_e),{numGlyphs:Re}=Ae,Pe=ue[_e];if(Ae.hidden||!Pe)ho(Re,se);else{const{x:Be,y:Oe,z:Xe,angle:pt}=Pe;for(let qe=0;qe<Re;qe++)t.addDynamicAttributes(se,Be,Oe,Xe,pt)}}_.icon.dynamicLayoutVertexBuffer.updateData(se)}_.text.dynamicLayoutVertexBuffer.updateData(ie)}function Kr(_,o,d){return d.iconsInText&&o?"symbolTextAndIcon":_?"symbolSDF":"symbolIcon"}function M(_,o,d,v,T,S,D,z,N,q,G,Y){const ie=_.context,se=ie.gl,ue=_.transform,le=z==="map",fe=N==="map",H=le&&d.layout.get("symbol-placement")!=="point",oe=le&&!fe&&!H,ge=d.layout.get("symbol-sort-key").constantOr(1)!==void 0;let _e=!1;const Ae=_.depthModeForSublayer(0,t.DepthMode.ReadOnly),Re=[t.mercatorXfromLng(ue.center.lng),t.mercatorYfromLat(ue.center.lat)],Pe=d.layout.get("text-variable-anchor"),Be=ue.projection.name==="globe",Oe=[],Xe=[0,-1,0];let pt=Xe;!Be&&!ue.mercatorFromTransition||le||(pt=function(qe){const ot=qe._camera.getWorldToCamera(qe.worldSize,1),He=t.multiply([],ot,qe.globeMatrix);t.invert(He,He);const dt=[0,0,0],$e=[0,1,0,0];return t.transformMat4$1($e,$e,He),dt[0]=$e[0],dt[1]=$e[1],dt[2]=$e[2],t.normalize(dt,dt),dt}(ue));for(const qe of v){const ot=o.getTile(qe),He=ot.getBucket(d);if(!He||He.projection.name==="mercator"&&Be)continue;const dt=T?He.text:He.icon;if(!dt||He.fullyClipped||!dt.segments.get().length)continue;const $e=dt.programConfigurations.get(d.id),it=T||He.sdfIcons,yt=T?He.textSizeData:He.iconSizeData,ct=fe||ue.pitch!==0,bt=t.evaluateSizeForZoom(yt,ue.zoom);let $t,un,Ut,Kt,An=[0,0],Cn=null;if(T)un=ot.glyphAtlasTexture,Ut=se.LINEAR,$t=ot.glyphAtlasTexture.size,He.iconsInText&&(An=ot.imageAtlasTexture.size,Cn=ot.imageAtlasTexture,Kt=ct||_.options.rotating||_.options.zooming||yt.kind==="composite"||yt.kind==="camera"?se.LINEAR:se.NEAREST);else{const bs=d.layout.get("icon-size").constantOr(0)!==1||He.iconsNeedLinear;un=ot.imageAtlasTexture,Ut=it||_.options.rotating||_.options.zooming||bs||ct?se.LINEAR:se.NEAREST,$t=ot.imageAtlasTexture.size}const qt=He.projection.name==="globe",Yn=qt?pt:Xe,ei=qt?t.globeToMercatorTransition(ue.zoom):0,ti=li(qe,He.getProjection(),ue),ni=ue.calculatePixelsToTileUnitsMatrix(ot),Dr=Qe(ti,ot.tileID.canonical,fe,le,ue,He.getProjection(),ni),mr=_.terrain&&fe&&H?t.invert(t.create(),Dr):$u,Co=Ti(ti,ot.tileID.canonical,fe,le,ue,He.getProjection(),ni),es=Pe&&He.hasTextData(),wi=d.layout.get("icon-text-fit")!=="none"&&es&&He.hasIconData();if(H){const bs=ue.elevation,qs=bs?bs.getAtTileOffsetFunc(qe,ue.center.lat,ue.worldSize,He.getProjection()):null,Ea=kr(ti,ot.tileID.canonical,fe,le,ue,He.getProjection(),ni);Ua(He,ti,_,T,Ea,Co,fe,q,qs,qe)}const ii=H||T&&Pe||wi,Gn=_.translatePosMatrix(ti,ot,S,D),Ui=ii?$u:Dr,jr=_.translatePosMatrix(Co,ot,S,D,!0),vi=He.getProjection().createInversionMatrix(ue,qe.canonical),Qr=[];_.terrainRenderModeElevated()&&fe&&Qr.push("PITCH_WITH_MAP_TERRAIN"),qt&&Qr.push("PROJECTION_GLOBE_VIEW"),ii&&Qr.push("PROJECTED_POS_ON_VIEWPORT");const tc=it&&d.paint.get(T?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let wa;wa=it?He.iconsInText?qu(yt.kind,bt,oe,fe,_,Gn,Ui,jr,$t,An,qe,ei,Re,vi,Yn,He.getProjection()):Us(yt.kind,bt,oe,fe,_,Gn,Ui,jr,T,$t,!0,qe,ei,Re,vi,Yn,He.getProjection()):el(yt.kind,bt,oe,fe,_,Gn,Ui,jr,T,$t,qe,ei,Re,vi,Yn,He.getProjection());const Ql={program:_.useProgram(Kr(it,T,He),$e,Qr),buffers:dt,uniformValues:wa,atlasTexture:un,atlasTextureIcon:Cn,atlasInterpolation:Ut,atlasInterpolationIcon:Kt,isSDF:it,hasHalo:tc,tile:ot,labelPlaneMatrixInv:mr};if(ge&&He.canOverlap){_e=!0;const bs=dt.segments.get();for(const qs of bs)Oe.push({segments:new t.SegmentVector([qs]),sortKey:qs.sortKey,state:Ql})}else Oe.push({segments:dt.segments,sortKey:0,state:Ql})}_e&&Oe.sort((qe,ot)=>qe.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<<H.canonical.z)-1,ge--),new t.OverscaledTileID(H.overscaledZ,ge,H.canonical.z,oe,H.canonical.y)},H=>{let oe=H.canonical.x+1,ge=H.wrap;return oe===1<<H.canonical.z&&(oe=0,ge++),new t.OverscaledTileID(H.overscaledZ,ge,H.canonical.z,oe,H.canonical.y)},H=>new t.OverscaledTileID(H.overscaledZ,H.wrap,H.canonical.z,H.canonical.x,(H.canonical.y===0?1<<H.canonical.z:H.canonical.y)-1),H=>new t.OverscaledTileID(H.overscaledZ,H.wrap,H.canonical.z,H.canonical.x,H.canonical.y===(1<<H.canonical.z)-1?0:H.canonical.y+1)],z=H=>{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<oe)continue;const Re=ge(H.calculateScaledKey(H.overscaledZ+Ae));if(Re)return Re}},N=[0,0,0],q=(H,oe)=>(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;Oe<ge.length;Oe++){const Xe=v.featuresOnBorder[ge[Oe]],pt=Xe.borders[H];let qe;for(;Pe<Re.length&&(qe=Ae.featuresOnBorder[Re[Pe]],!(qe.borders[oe][1]>pt[0]+3));)Be&&Ae.encodeCentroid(void 0,qe,!1),Pe++;if(qe&&Pe<Re.length){const ot=Pe;let He=0;for(;!(qe.borders[oe][0]>pt[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;oe<v.length;oe++){const ge=v[oe],_e=o.getTile(ge),Ae=_e.getBucket(d);if(!Ae||Ae.projection.name!==G.projection.name)continue;const Re=Ae.programConfigurations.get(d.id),Pe=Gl(d);ue&&Pe.push("PROJECTION_GLOBE_VIEW");const Be=_.useProgram("circle",Re,Pe),Oe=Ae.layoutVertexBuffer,Xe=Ae.globeExtVertexBuffer,pt=Ae.indexBuffer,qe=G.projection.createInversionMatrix(G,ge.canonical),ot={programConfiguration:Re,program:Be,layoutVertexBuffer:Oe,globeExtVertexBuffer:Xe,indexBuffer:pt,uniformValues:Ya(_,ge,_e,qe,le,d),tile:_e};if(z){const He=Ae.segments.get();for(const dt of He)fe.push({segments:new t.SegmentVector([dt]),sortKey:dt.sortKey,state:ot})}else fe.push({segments:Ae.segments,sortKey:0,state:ot})}z&&fe.sort((oe,ge)=>oe.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<v.length;se++){const ue=v[se];if(o.hasRenderableParent(ue))continue;const le=o.getTile(ue),fe=le.getBucket(d);if(!fe||fe.projection.name!==N.projection.name)continue;const H=fe.programConfigurations.get(d.id),oe=_.useProgram("heatmap",H,G),{zoom:ge}=_.transform;_.terrain&&_.terrain.setupElevationDraw(le,oe),_.prepareDrawProgram(T,oe,ue.toUnwrapped());const _e=N.projection.createInversionMatrix(N,ue.canonical);oe.draw(T,S.TRIANGLES,t.DepthMode.disabled,D,z,Y,Gu(_,ue,le,_e,ie,ge,d.paint.get("heatmap-intensity")),d.id,fe.layoutVertexBuffer,fe.indexBuffer,fe.segments,d.paint,_.transform.zoom,H,q?[fe.globeExtVertexBuffer]:null)}T.viewport.set([0,0,_.width,_.height])}else _.renderPass==="translucent"&&(_.context.setColorMode(_.colorModeForRenderPass()),function(T,S){const D=T.context,z=D.gl,N=S.heatmapFbo;if(!N)return;D.activeTexture.set(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,N.colorAttachment.get()),D.activeTexture.set(z.TEXTURE1);let q=S.colorRampTexture;q||(q=S.colorRampTexture=new t.Texture(D,S.colorRamp,z.RGBA)),q.bind(z.LINEAR,z.CLAMP_TO_EDGE),T.useProgram("heatmapTexture").draw(D,z.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,T.colorModeForRenderPass(),t.CullFaceMode.disabled,((G,Y,ie,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;v<d.length;v++)Le(_,o,d[v])},custom:function(_,o,d,v){const T=_.context,S=d.implementation;if(!_.transform.projection.unsupportedLayers||!_.transform.projection.unsupportedLayers.includes("custom")||_.terrain&&(_.terrain.renderingToTexture||_.renderPass==="offscreen")&&d.isLayerDraped()){if(_.renderPass==="offscreen"){const D=S.prerender;if(D){if(_.setCustomLayerDefaults(),T.setColorMode(_.colorModeForRenderPass()),_.transform.projection.name==="globe"){const z=_.transform.pointMerc;D.call(S,T.gl,_.transform.customLayerMatrix(),_.transform.getProjection(),_.transform.globeToMercatorMatrix(),t.globeToMercatorTransition(_.transform.zoom),[z.x,z.y],_.transform.pixelsPerMeterRatio)}else D.call(S,T.gl,_.transform.customLayerMatrix());T.setDirty(),_.setBaseState()}}else if(_.renderPass==="translucent"){if(_.terrain&&_.terrain.renderingToTexture){const z=S.renderToTile;if(z){const N=v[0].canonical,q=new t.MercatorCoordinate(N.x+v[0].wrap*(1<<N.z),N.y,N.z);T.setDepthMode(t.DepthMode.disabled),T.setStencilMode(t.StencilMode.disabled),T.setColorMode(_.colorModeForRenderPass()),_.setCustomLayerDefaults(),z.call(S,T.gl,q),T.setDirty(),_.setBaseState()}return}_.setCustomLayerDefaults(),T.setColorMode(_.colorModeForRenderPass()),T.setStencilMode(t.StencilMode.disabled);const D=S.renderingMode==="3d"?new t.DepthMode(_.context.gl.LEQUAL,t.DepthMode.ReadWrite,_.depthRangeFor3D):_.depthModeForSublayer(0,t.DepthMode.ReadOnly);if(T.setDepthMode(D),_.transform.projection.name==="globe"){const z=_.transform.pointMerc;S.render(T.gl,_.transform.customLayerMatrix(),_.transform.getProjection(),_.transform.globeToMercatorMatrix(),t.globeToMercatorTransition(_.transform.zoom),[z.x,z.y],_.transform.pixelsPerMeterRatio)}else S.render(T.gl,_.transform.customLayerMatrix());T.setDirty(),_.setBaseState(),T.bindFramebuffer.set(null)}}else t.warnOnce("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")}};class dr{constructor(o,d,v=!1){this.context=new xt(o,v),this.transform=d,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=t.SourceCache.maxUnderzooming+t.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(o,d){const v=!!o&&!!o.terrain&&this.transform.projection.supportsTerrain;if(!(v||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Wa(this,o));const T=this._terrain;this.transform.elevation=v?T:null,T.update(o,this.transform,d)}_updateFog(o){const d=o.fog;if(!d||this.transform.projection.name==="globe"||d.getOpacity(this.transform.pitch)<1||d.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[v,T]=d.getFovAdjustedRange(this.transform._fov);if(v>T)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<S;z++)D[z+T]=new t.StencilMode({func:d.GEQUAL,mask:255},z+this.nextStencilID,255,d.KEEP,d.KEEP,d.REPLACE);return this.nextStencilID+=S,[D,v]}return[{[T]:t.StencilMode.disabled},v]}colorModeForRenderPass(){const o=this.context.gl;return this._showOverdrawInspector?new t.ColorMode([o.CONSTANT_COLOR,o.ONE],new t.Color(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?t.ColorMode.unblended:t.ColorMode.alphaBlended}depthModeForSublayer(o,d,v){if(!this.opaquePassEnabledForLayer())return t.DepthMode.disabled;const T=1-((1+this.currentLayer)*this.numSublayers+o)*this.depthEpsilon;return new t.DepthMode(v||this.context.gl.LEQUAL,d,[T,T])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(o,d){this.style=o,this.options=d,this.imageManager=o.imageManager,this.glyphManager=o.glyphManager,this.symbolFadeChange=o.placement.symbolFadeChange(t.exported.now()),this.imageManager.beginFrame();const v=this.style.order,T=this.style._sourceCaches;for(const q in T){const G=T[q];G.used&&G.prepare(this.context)}const S={},D={},z={};for(const q in T){const G=T[q];S[q]=G.getVisibleCoordinates(),D[q]=S[q].slice().reverse(),z[q]=G.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let q=0;q<v.length;q++)if(this.style._layers[v[q]].is3D()){this.opaquePassCutoff=q;break}if(this.terrain&&(this.terrain.updateTileBinding(z),this.opaquePassCutoff=0),this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new t.GlobeSharedBuffers(this.context)),!t.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(const q of v){const G=this.style._layers[q],Y=o._getLayerSourceCache(G);if(!G.hasOffscreenPass()||G.isHidden(this.transform.zoom))continue;const ie=Y?D[Y.id]:void 0;(G.type==="custom"||G.isSky()||ie&&ie.length)&&this.renderLayer(this,Y,G,ie)}this.depthRangeFor3D=[0,1-(o.order.length+2)*this.numSublayers*this.depthEpsilon];const N=this.terrain;if(N&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&N.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]),this.context.clear({color:d.showOverdrawInspector?t.Color.black:t.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=d.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=v.length-1;this.currentLayer>=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<v.length;this.currentLayer++){const q=this.style._layers[v[this.currentLayer]],G=o._getLayerSourceCache(q);q.isSky()&&this.renderLayer(this,G,q,G?D[G.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<v.length;){const q=this.style._layers[v[this.currentLayer]],G=o._getLayerSourceCache(q);if(q.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(q)){if(q.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const Y=G?(q.type==="symbol"?z:D)[G.id]:void 0;this._renderTileClippingMasks(q,G,G?S[G.id]:void 0),this.renderLayer(this,G,q,Y),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let q=null;t.values(this.style._layers).forEach(G=>{const Y=o._getLayerSourceCache(G);Y&&!G.isHidden(this.transform.zoom)&&(!q||q.getSource().maxzoom<Y.getSource().maxzoom)&&(q=Y)}),q&&this.options.showTileBoundaries&&Vi.debug(this,q,q.getVisibleCoordinates())}this.options.showPadding&&function(q){const G=q.transform.padding;Ne(q,q.transform.height-(G.top||0),3,L),Ne(q,G.bottom||0,3,V),rt(q,G.left||0,3,X),rt(q,q.transform.width-(G.right||0),3,Q);const Y=q.transform.centerPoint;(function(ie,se,ue,le){kt(ie,se-1,ue-10,2,20,le),kt(ie,se-10,ue-1,20,2,le)})(q,Y.x,q.transform.height-Y.y,ae)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(t.window.performance.now()),this.saveCanvasCopy())}renderLayer(o,d,v,T){v.isHidden(this.transform.zoom)||(v.type==="background"||v.type==="sky"||v.type==="custom"||T&&T.length)&&(this.id=v.id,this.gpuTimingStart(v),(!o.transform.projection.unsupportedLayers||!o.transform.projection.unsupportedLayers.includes(v.type)||o.terrain&&v.type==="custom")&&Vi[v.type](o,d,v,T,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(o){if(!this.options.gpuTiming)return;const d=this.context.extTimerQuery;let v=this.gpuTimers[o.id];v||(v=this.gpuTimers[o.id]={calls:0,cpuTime:0,query:d.createQueryEXT()}),v.calls++,d.beginQueryEXT(d.TIME_ELAPSED_EXT,v.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const o=this.context.extTimerQuery,d=o.createQueryEXT();this.deferredRenderGpuTimeQueries.push(d),o.beginQueryEXT(o.TIME_ELAPSED_EXT,d)}}gpuTimingDeferredRenderEnd(){if(!this.options.gpuTimingDeferredRender)return;const o=this.context.extTimerQuery;o.endQueryEXT(o.TIME_ELAPSED_EXT)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const o=this.context.extTimerQuery;o.endQueryEXT(o.TIME_ELAPSED_EXT)}collectGpuTimers(){const o=this.gpuTimers;return this.gpuTimers={},o}collectDeferredRenderGpuQueries(){const o=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],o}queryGpuTimers(o){const d={};for(const v in o){const T=o[v],S=this.context.extTimerQuery,D=S.getQueryObjectEXT(T.query,S.QUERY_RESULT_EXT)/1e6;S.deleteQueryEXT(T.query),d[v]=D}return d}queryGpuTimeDeferredRender(o){if(!this.options.gpuTimingDeferredRender)return 0;const d=this.context.extTimerQuery;let v=0;for(const T of o)v+=d.getQueryObjectEXT(T,d.QUERY_RESULT_EXT)/1e6,d.deleteQueryEXT(T);return v}translatePosMatrix(o,d,v,T,S){if(!v[0]&&!v[1])return o;const D=S?T==="map"?this.transform.angle:0:T==="viewport"?-this.transform.angle:0;if(D){const q=Math.sin(D),G=Math.cos(D);v=[v[0]*G-v[1]*q,v[0]*q+v[1]*G]}const z=[S?v[0]:Bt(d,v[0],this.transform.zoom),S?v[1]:Bt(d,v[1],this.transform.zoom),0],N=new Float32Array(16);return t.translate(N,o,z),N}saveTileTexture(o){const d=this._tileTextures[o.size[0]];d?d.push(o):this._tileTextures[o.size[0]]=[o]}getTileTexture(o){const d=this._tileTextures[o];return d&&d.length>0?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;D<d.length;D++){const z=new t.Point(d[D][0]*this.width,v+d[D][1]*(this.height-v)),N=o.pointCoordinate(z);if(!N)continue;const q=1/Math.hypot(N[0]-this._camera.position[0],N[1]-this._camera.position[1]);T+=N[3]*q,S+=q}return S===0?NaN:T/S}get center(){return this._center}set center(o){o.lat===this._center.lat&&o.lng===this._center.lng||(this._unmodified=!1,this._center=o,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const o=this._seaLevelZoom,d=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),v=this.pixelsPerMeter/this.worldSize*d,T=this._mercatorZfromZoom(o),S=this._mercatorZfromZoom(this._maxZoom),D=Math.max(T-v,S);this._setZoom(this._zoomFromMercatorZ(D))}get padding(){return this._edgeInsets.toJSON()}set padding(o){this._edgeInsets.equals(o)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,o,1),this._calcMatrices())}computeZoomRelativeTo(o){const d=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,o.toAltitude()));let v;v=o.z<this._camera.position[2]?[d.x,d.y,d.z]:[o.x,o.y,o.z];const T=t.length(t.sub([],this._camera.position,v));return t.clamp(this._zoomFromMercatorZ(T),this._minZoom,this._maxZoom)}setFreeCameraOptions(o){if(!this.height||!o.position&&!o.orientation)return;this._updateCameraState();let d=!1;if(o.orientation&&!t.exactEquals(o.orientation,this._camera.orientation)&&(d=this._setCameraOrientation(o.orientation)),o.position){const v=[o.position.x,o.position.y,o.position.z];t.exactEquals$1(v,this._camera.position)||(this._setCameraPosition(v),d=!0)}d&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const o=this._camera.position,d=new ys;return d.position=new t.MercatorCoordinate(o[0],o[1],o[2]),d.orientation=this._camera.orientation,d._elevation=this.elevation,d._renderWorldCopies=this.renderWorldCopies,d}_setCameraOrientation(o){if(!t.length$1(o))return!1;t.normalize$1(o,o);const d=t.transformQuat([],[0,0,-1],o),v=t.transformQuat([],[0,-1,0],o);if(v[2]<0)return!1;const T=Vo(d,v);return!!T&&(this._camera.orientation=T,!0)}_setCameraPosition(o){const d=this.zoomScale(this.minZoom)*this.tileSize,v=this.zoomScale(this.maxZoom)*this.tileSize,T=this.cameraToCenterDistance;o[2]=t.clamp(o[2],T/v,T/d),this._camera.position=o}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(o){return this._edgeInsets.equals(o)}interpolatePadding(o,d,v){this._unmodified=!1,this._edgeInsets.interpolate(o,d,v),this._constrain(),this._calcMatrices()}coveringZoomLevel(o){const d=(o.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/o.tileSize));return Math.max(0,d)}getVisibleUnwrappedCoordinates(o){const d=[new t.UnwrappedTileID(0,o)];if(this.renderWorldCopies){const v=this.pointCoordinate(new t.Point(0,0)),T=this.pointCoordinate(new t.Point(this.width,0)),S=this.pointCoordinate(new t.Point(this.width,this.height)),D=this.pointCoordinate(new t.Point(0,this.height)),z=Math.floor(Math.min(v.x,T.x,S.x,D.x)),N=Math.floor(Math.max(v.x,T.x,S.x,D.x)),q=1;for(let G=z-q;G<=N+q;G++)G!==0&&d.push(new t.UnwrappedTileID(G,o))}return d}coveringTiles(o){let d=this.coveringZoomLevel(o);const v=d,T=this.elevation&&!o.isTerrainDEM,S=this.projection.name==="mercator";if(o.minzoom!==void 0&&d<o.minzoom)return[];o.maxzoom!==void 0&&d>o.maxzoom&&(d=o.maxzoom);const D=this.locationCoordinate(this.center),z=this.center.lat,N=1<<d,q=[N*D.x,N*D.y,0],G=this.projection.name==="globe",Y=!G,ie=t.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,d,Y),se=G?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),ue=N*t.mercatorZfromAltitude(1,this.center.lat),le=this._camera.position[2]/t.mercatorZfromAltitude(1,this.center.lat),fe=[N*se.x,N*se.y,le*(Y?1:ue)],H=this.cameraToCenterDistance/o.tileSize*(o.roundZoom?1:.502),oe=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?d:0,ge=o.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,_e=o.isTerrainDEM?-ge:this._elevation?this._elevation.getMinElevationBelowMSL():0,Ae=this.projection.isReprojectedInTileSpace?rl(this):1,Re=$e=>{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<oe)return!0;if($e.zoom===Xe)return!1;if($e.shouldSplit!=null)return $e.shouldSplit;const it=$e.aabb.distanceX(fe),yt=$e.aabb.distanceY(fe);let ct=ot,bt=1;if(G){ct=qe($e.aabb.distanceZ(fe));const Ut=Math.pow(2,$e.zoom),Kt=t.latFromMercatorY(($e.y+1)/Ut),An=t.latFromMercatorY($e.y/Ut),Cn=Math.min(Math.max(z,Kt),An),qt=t.circumferenceAtLatitude(Cn)/t.circumferenceAtLatitude(z);if(bt=Cn===z?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,qt/this._mercatorScaleRatio),this.zoom<=t.GLOBE_ZOOM_THRESHOLD_MIN&&$e.zoom===Xe-1&&qt>=.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<<Xe-$e.zoom)*H*bt*((Ut,Kt)=>{if(Kt*qe(.707)<Ut)return 1;const An=Math.sqrt(Kt/Ut);return An/(1.4144271570014144+(Math.pow(1.1,An-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(ct,ot),$t));return $t<un};if(this.renderWorldCopies)for(let $e=1;$e<=3;$e++)Be.push(Pe(-$e)),Be.push(Pe($e));for(Be.push(Pe(0));Be.length>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<<d-$e.zoom),un=q[1]-.5-yt,Ut=$e.tileID?$e.tileID:new t.OverscaledTileID(bt,$e.wrap,$e.zoom,it,yt);Oe.push({tileID:Ut,distanceSq:$t*$t+un*un})}}if(this.fogCullDistSq){const $e=this.fogCullDistSq,it=this.horizonLineFromTop();Oe=Oe.filter(yt=>{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<it}return un<$e||Ut})}return Oe.sort(($e,it)=>$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),(_e<ue||Xe>se)&&(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.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=t.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=t.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=t.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=t.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(o,d){return this.projection.createTileMatrix(this,d,o)}calculateDistanceTileData(o){const d=o.key,v=this._distanceTileDataCache;if(v[d])return v[d];const T=o.canonical,S=1/this.height,D=this.cameraWorldSize,z=D/this.zoomScale(T.z),N=(T.x+Math.pow(2,T.z)*o.wrap)*z,q=T.y*z,G=this.point;G.x*=D/this.worldSize,G.y*=D/this.worldSize;const Y=this.angle,ie=Math.sin(-Y),se=-Math.cos(-Y);return v[d]={bearing:[ie,se],center:[(G.x-N)*S,(G.y-q)*S],scale:z/t.EXTENT*S},v[d]}calculateFogTileMatrix(o){const d=o.key,v=this._fogTileMatrixCache;if(v[d])return v[d];const T=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,o);return t.multiply(T,this.worldToFogMatrix,T),v[d]=new Float32Array(T),v[d]}calculateProjMatrix(o,d=!1){const v=o.key,T=d?this._alignedProjMatrixCache:this._projMatrixCache;if(T[v])return T[v];const S=this.calculatePosMatrix(o,this.worldSize);return t.multiply(S,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:d?this.alignedProjMatrix:this.projMatrix,S),T[v]=new Float32Array(S),T[v]}calculatePixelsToTileUnitsMatrix(o){const d=o.tileID.key,v=this._pixelsToTileUnitsCache;if(v[d])return v[d];const T=function(S,D){const{scale:z}=S.tileTransform,N=z*t.EXTENT/(S.tileSize*Math.pow(2,D.zoom-S.tileID.overscaledZ+S.tileID.canonical.z));return q=new Float32Array(4),ie=(G=D.inverseAdjustmentMatrix)[1],se=G[2],ue=G[3],fe=(Y=[N,N])[1],q[0]=G[0]*(le=Y[0]),q[1]=ie*le,q[2]=se*fe,q[3]=ue*fe,q;var q,G,Y,ie,se,ue,le,fe}(o,this);return v[d]=T,v[d]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){const o=1/this.worldSize,d=t.fromScaling([],[o,o,o]);return t.multiply(d,d,this.globeMatrix),d}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;const o=this._elevation;this._updateCameraState();const d=t.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,v=this._computeCameraPosition(d),T=this._camera.forward(),S=t.mercatorZfromAltitude(1,this._center.lat);v[2]/=S,T[2]/=S,t.normalize(T,T);const D=o.raycast(v,T,o.exaggeration());if(D){const z=t.scaleAndAdd([],v,T,D),N=new t.MercatorCoordinate(z[0],z[1],t.mercatorZfromAltitude(z[2],t.latFromMercatorY(z[1]))),q=(N.z+t.length([N.x-v[0],N.y-v[1],N.z-v[2]*S]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(q),this._centerAltitude=N.toAltitude(),this._center=this.coordinateLocation(N),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(o=!1){if(!this._elevation)return;const d=this._elevation,v=t.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,T=this._computeCameraPosition(v),S=d.getAtPointOrZero(new t.MercatorCoordinate(...T)),D=this.pixelsPerMeter/this.worldSize*S,z=this._minimumHeightOverTerrain(),N=T[2]-D;if(N<=z)if(N<0||o){const q=this.locationCoordinate(this._center,this._centerAltitude),G=[T[0],T[1],q.z-T[2]],Y=t.length(G);G[2]-=(z-N)/this._pixelsPerMercatorPixel;const ie=t.length(G);if(ie===0)return;t.scale$2(G,G,Y/ie*this._pixelsPerMercatorPixel),this._camera.position=[T[0],T[1],q.z*this._pixelsPerMercatorPixel-G[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const o=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||o){const ie=this.center;return ie.lat=t.clamp(ie.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!o)&&(ie.lng=t.clamp(ie.lng,this.minLng,this.maxLng)),this.center=ie,void(this._constraining=!1)}const d=this._unmodified,{x:v,y:T}=this.point;let S=0,D=v,z=T;const N=this.width/2,q=this.height/2,G=this.worldMinY*this.scale,Y=this.worldMaxY*this.scale;if(T-q<G&&(z=G+q),T+q>Y&&(z=Y-q),Y-G<this.height&&(S=Math.max(S,this.height/(Y-G)),z=(Y+G)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const ie=this.worldMinX*this.scale,se=this.worldMaxX*this.scale,ue=this.worldSize/2-(ie+se)/2;D=(v+ue+this.worldSize)%this.worldSize-ue,D-N<ie&&(D=ie+N),D+N>se&&(D=se-N),se-ie<this.width&&(S=Math.max(S,this.width/(se-ie)),D=(se+ie)/2)}D===v&&z===T||(this.center=this.unproject(new t.Point(D,z))),S&&(this.zoom+=this.scaleZoom(S)),this._constrainCamera(),this._unmodified=d,this._constraining=!1}_minZoomForBounds(){let o=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(o=Math.max(o,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),o}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const o=this.centerOffset,d=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=t.mercatorZfromAltitude(1,this.center.lat)/t.mercatorZfromAltitude(1,t.GLOBE_SCALE_MATCH_LATITUDE));const v=js(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,v),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const T=this.projection.zAxisUnit==="meters"?d:1,S=this._camera.getWorldToCamera(this.worldSize,T),D=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);D[8]=2*-o.x/this.width,D[9]=2*o.y/this.height;let z=t.mul([],D,S);if(this.projection.isReprojectedInTileSpace){const Re=this.locationCoordinate(this.center),Pe=t.identity([]);t.translate(Pe,Pe,[Re.x*this.worldSize,Re.y*this.worldSize,0]),t.multiply(Pe,Pe,vs(this)),t.translate(Pe,Pe,[-Re.x*this.worldSize,-Re.y*this.worldSize,0]),t.multiply(z,z,Pe),this.inverseAdjustmentMatrix=function(Be){const Oe=vs(Be,!0);return Ie([],[Oe[0],Oe[1],Oe[4],Oe[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=t.scale([],z,[this.worldSize,this.worldSize,this.worldSize/T,1]),this.projMatrix=z,this.invProjMatrix=t.invert(new Float64Array(16),this.projMatrix);const N=t.invert([],D);this.frustumCorners=t.FrustumCorners.fromInvProjectionMatrix(N,this.horizonLineFromTop(),this.height);const q=new Float32Array(16);t.identity(q),t.scale(q,q,[1,-1,1]),t.rotateX(q,q,this._pitch),t.rotateZ(q,q,this.angle);const G=t.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),Y=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;G[8]=2*-o.x/this.width,G[9]=2*(o.y+Y)/this.height,this.skyboxMatrix=t.multiply(q,G,q);const ie=this.point,se=ie.x,ue=ie.y,le=this.width%2/2,fe=this.height%2/2,H=Math.cos(this.angle),oe=Math.sin(this.angle),ge=se-Math.round(se)+H*le+oe*fe,_e=ue-Math.round(ue)+H*fe+oe*le,Ae=new Float64Array(z);if(t.translate(Ae,Ae,[ge>.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);G<S&&(S=G,T=D),D<q?d=D:v=D}return T}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(t.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(o,d){const v=Math.min(o.x,d.x),T=Math.max(o.x,d.x),S=Math.min(o.y,d.y),D=Math.max(o.y,d.y);if(S<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;const z=[new t.Point(v,S),new t.Point(T,D),new t.Point(v,D),new t.Point(T,S)],N=this.renderWorldCopies?-3:0,q=this.renderWorldCopies?4:1;for(const G of z){const Y=this.pointRayIntersection(G);if(Y.t<0)return!0;const ie=this.rayIntersectionCoordinate(Y);if(ie.x<N||ie.y<0||ie.x>q||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||_.duration<o.duration)&&(_.duration=o.duration,_.easing=o.easing)}function Yl(_,o,d){const{maxSpeed:v,linearity:T,deceleration:S}=d,D=t.clamp(_*T/(o/1e3),-v,v),z=Math.abs(D)/(S*T);return{easing:d.easing,duration:1e3*z,amount:D*(z/2)}}class pr extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(o,d,v,T={}){const S=we(d.getCanvasContainer(),v),D=d.unproject(S);super(o,t.extend({point:S,lngLat:D,originalEvent:v},T)),this._defaultPrevented=!1,this.target=d}}class Hl extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(o,d,v){const T=o==="touchend"?v.changedTouches:v.touches,S=Ue(d.getCanvasContainer(),T),D=S.map(N=>d.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._clickTolerance)return;this._lastPos=v,this._box||(this._box=F("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",o));const D=Math.min(T.x,v.x),z=Math.max(T.x,v.x),N=Math.min(T.y,v.y),q=Math.max(T.y,v.y);this._map._requestDomTask(()=>{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)<this._clickTolerance))return this._moved=!0,this._lastPoint=d,this._move(v,d)}}mouseupWindow(o){this._lastPoint&&ze(o)===this._eventButton&&(this._moved&&be(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class hh extends ll{mousedown(o,d){super.mousedown(o,d),this._lastPoint&&(this._active=!0)}_correctButton(o,d){return d===0&&!o.ctrlKey}_move(o,d){return{around:d,panDelta:d.sub(o)}}}class fh extends ll{_correctButton(o,d){return d===0&&o.ctrlKey||d===2}_move(o,d){const v=.8*(d.x-o.x);if(v)return this._active=!0,{bearingDelta:v}}contextmenu(o){o.preventDefault()}}class dh extends ll{_correctButton(o,d){return d===0&&o.ctrlKey||d===2}_move(o,d){const v=-.5*(d.y-o.y);if(v)return this._active=!0,{pitchDelta:v}}contextmenu(o){o.preventDefault()}}class Qu{constructor(o,d){this._map=o,this._el=o.getCanvasContainer(),this._minTouches=1,this._clickTolerance=d.clickTolerance||1,this.reset(),t.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new t.Point(0,0)}touchstart(o,d,v){return this._calculateTransform(o,d,v)}touchmove(o,d,v){if(this._active&&!(v.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(v.length===1&&!t.isFullscreen())return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return o.cancelable&&o.preventDefault(),this._calculateTransform(o,d,v)}}touchend(o,d,v){this._calculateTransform(o,d,v),this._active&&v.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(o,d,v){v.length>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._minTouches||!D.mag())return;const N=D.div(z);return this._sum._add(N),this._sum.mag()<this._clickTolerance?void 0:{around:S.div(z),panDelta:N}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=F("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{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)<d}}function Gs(_){return Math.abs(_.y)>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<ie&&ie<this._bearingSnap;G?(Y(G.bearing||this._map.getBearing())&&(G.bearing=0),this._map.easeTo(G,{originalEvent:N})):(this._map.fire(new t.Event("moveend",{originalEvent:N})),Y(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(o,d){this._map.fire(new t.Event(o,d?{originalEvent:d}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(o=>{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())<this._bearingSnap?this.resetNorth(o,d):this}getPitch(){return this.transform.pitch}setPitch(o,d){return this.jumpTo({pitch:o},d),this}cameraForBounds(o,d){o=t.LngLatBounds.convert(o);const v=d&&d.bearing||0,T=d&&d.pitch||0,S=o.getNorthWest(),D=o.getSouthEast();return this._cameraForBounds(this.transform,S,D,v,T,d)}_extendCameraOptions(o){const d={top:0,bottom:0,right:0,left:0};if(typeof(o=t.extend({padding:d,offset:[0,0],maxZoom:this.transform.maxZoom},o)).padding=="number"){const v=o.padding;o.padding={top:v,bottom:v,right:v,left:v}}return o.padding=t.extend(d,o.padding),o}_minimumAABBFrustumDistance(o,d){const v=d.max[0]-d.min[0],T=d.max[1]-d.min[1];return v/T>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)<v&&(o-=360),Math.abs(o+360-d)<v&&(o+=360),o}_normalizeCenter(o){const d=this.transform;if(!d.renderWorldCopies||d.maxBounds)return;const v=o.lng-d.center.lng;o.lng+=v>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}${D<d.length-1?"&":""}`),T),"?");o.href=`${t.config.FEEDBACK_URL}/${v}#${$l(this._map,!0)}`,o.rel="noopener nofollow",this._setElementTitle(o,"MapFeedback")}}_updateData(o){!o||o.sourceDataType!=="metadata"&&o.sourceDataType!=="visibility"&&o.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let o=[];if(this._map.style.stylesheet){const T=this._map.style.stylesheet;this.styleOwner=T.owner,this.styleId=T.id}const d=this._map.style._sourceCaches;for(const T in d){const S=d[T];if(S.used){const D=S.getSource();D.attribution&&o.indexOf(D.attribution)<0&&o.push(D.attribution)}}o.sort((T,S)=>T.length-S.length),o=o.filter((T,S)=>{for(let D=S+1;D<o.length;D++)if(o[D].indexOf(T)>=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)<D&&(z||Math.abs(v.lng-d.center.lng)<S)?_=v:d.locationPoint(T).distSqr(o)<D&&(z||Math.abs(T.lng-d.center.lng)<S)&&(_=T)}for(;Math.abs(_.lng-d.center.lng)>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)<S)return;this._isDragging=!0}this._pos=o.point.sub(T),this._lngLat=d.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new t.Event("dragstart"))),this.fire(new t.Event("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const o=this._map;o&&(o.off("mousemove",this._onMove),o.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new t.Event("dragend")),this._state="inactive"}_addDragHandler(o){const d=this._map,v=this._pos;d&&v&&this._element.contains(o.originalEvent.target)&&(o.preventDefault(),this._positionDelta=o.point.sub(v),this._pointerdownPos=o.point,this._state="pending",d.on("mousemove",this._onMove),d.on("touchmove",this._onMove),d.once("mouseup",this._onUp),d.once("touchend",this._onUp))}setDraggable(o){this._draggable=!!o;const d=this._map;return d&&(o?(d.on("mousedown",this._addDragHandler),d.on("touchstart",this._addDragHandler)):(d.off("mousedown",this._addDragHandler),d.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(o){return this._rotation=o||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(o){return this._rotationAlignment=o||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(o){return this._pitchAlignment=o||"auto",this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(o){return this._occludedOpacity=o||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const vh={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Vm=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Sd(_=new t.Point(0,0),o="bottom"){if(typeof _=="number"){const d=Math.round(Math.sqrt(.5*Math.pow(_,2)));switch(o){case"top":return new t.Point(0,_);case"top-left":return new t.Point(d,d);case"top-right":return new t.Point(-d,d);case"bottom":return new t.Point(0,-_);case"bottom-left":return new t.Point(d,-d);case"bottom-right":return new t.Point(-d,-d);case"left":return new t.Point(_,0);case"right":return new t.Point(-_,0)}return new t.Point(0,0)}return _ instanceof t.Point||Array.isArray(_)?t.Point.convert(_):t.Point.convert(_[o]||[0,0])}class xh{constructor(o){this.jumpTo(o)}getValue(o){if(o<=this._startTime)return this._start;if(o>=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)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const bh={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},wh={maxWidth:100,unit:"metric"},Eh={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},cl={version:t.version,supported:k,setRTLTextPlugin:t.setRTLTextPlugin,getRTLTextPluginStatus:t.getRTLTextPluginStatus,Map:class extends ec{constructor(_){if(t.LivePerformanceUtils.mark(t.PerformanceMarkers.create),(_=t.extend({},Cd,_)).minZoom!=null&&_.maxZoom!=null&&_.minZoom>_.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&&(_.setProjection({name:"globe"}),d=!0),d&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(_,o){return this._updateProjection(_||o||{name:"mercator"})}_updateProjection(_){let o;if(o=_.name==="globe"&&this.transform.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<S.length;D++){const z=S[D];if(z.listener===d&&v(z.layers,o)){for(const N in z.delegates)this.off(N,z.delegates[N]);return S.splice(D,1),this}}})(T),this}queryRenderedFeatures(_,o){return this.style?(o!==void 0||_===void 0||_ instanceof t.Point||Array.isArray(_)||(o=_,_=void 0),this.style.queryRenderedFeatures(_=_||[[0,0],[this.transform.width,this.transform.height]],o=o||{},this.transform)):[]}querySourceFeatures(_,o){return this.style.querySourceFeatures(_,o)}isPointOnSurface(_){const{name:o}=this.transform.projection;return o!=="globe"&&o!=="mercator"&&t.warnOnce(`${o} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(t.Point.convert(_))}setStyle(_,o){return(o=t.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},o)).diff!==!1&&o.localIdeographFontFamily===this._localIdeographFontFamily&&o.localFontFamily===this._localFontFamily&&this.style&&_?(this._diffStyle(_,o),this):(this._localIdeographFontFamily=o.localIdeographFontFamily,this._localFontFamily=o.localFontFamily,this._updateStyle(_,o))}_getUIString(_){const o=this._locale[_];if(o==null)throw new Error(`Missing UI string '${_}'`);return o}_updateStyle(_,o){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),_&&(this.style=new Ur(this,o||{}),this.style.setEventedParent(this,{style:this.style}),typeof _=="string"?this.style.loadURL(_):this.style.loadJSON(_)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Ur(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(_,o){if(typeof _=="string"){const d=this._requestManager.normalizeStyleURL(_),v=this._requestManager.transformRequest(d,t.ResourceType.Style);t.getJSON(v,(T,S)=>{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<o.length;S++){const D=o[S];let z=0;for(let N=0;N<D.length;N+=4)D[N]===_[N]&&D[N+1]===_[N+1]&&D[N+2]===_[N+2]&&D[N+3]===_[N+3]&&(z+=1);v+=(d[S+2]-d[S+1])*(1-z/T)}return v}remove(){this._hash&&this._hash.remove();for(const o of this._controls)o.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),t.window!==void 0&&(t.window.removeEventListener("resize",this._onWindowResize,!1),t.window.removeEventListener("orientationchange",this._onWindowResize,!1),t.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),t.window.removeEventListener("online",this._onWindowOnline,!1),t.window.removeEventListener("visibilitychange",this._onVisibilityChange,!1));const _=this.painter.context.gl.getExtension("WEBGL_lose_context");_&&_.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),t.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new t.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(_){this._renderNextFrame=this._renderNextFrame||_,this.style&&!this._frame&&(this._frame=t.exported.frame(o=>{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.longitude<o.getWest()||d.longitude>o.getEast()||d.latitude<o.getSouth()||d.latitude>o.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.x<T/2,z=v.x>o.transform.width-T/2;if(v.y+_<S)return D?"top-left":z?"top-right":"top";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;f<h[h.length-1].length;f++)if(h[h.length-1][f]!==h[0][f])throw new Error("First and last Position are not equivalent.")}return nr({type:"Polygon",coordinates:a},i,s)}function r_(a,i,s={}){return Jt(a.map(l=>Mn(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<h.length&&!(i>=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;ye<he;ye++){k=Z?a.features[ye].geometry:J?a.geometry:a,F=k?k.type==="GeometryCollection":!1,t=F?k.geometries.length:1;for(var te=0;te<t;te++){var ce=0,be=0;if(x=F?k.geometries[te]:k,x!==null){E=x.coordinates;var we=x.type;switch(P=s&&(we==="Polygon"||we==="MultiPolygon")?1:0,we){case null:break;case"Point":if(i(E,R,ye,ce,be)===!1)return!1;R++,ce++;break;case"LineString":case"MultiPoint":for(l=0;l<E.length;l++){if(i(E[l],R,ye,ce,be)===!1)return!1;R++,we==="MultiPoint"&&ce++}we==="LineString"&&ce++;break;case"Polygon":case"MultiLineString":for(l=0;l<E.length;l++){for(h=0;h<E[l].length-P;h++){if(i(E[l][h],R,ye,ce,be)===!1)return!1;R++}we==="MultiLineString"&&ce++,we==="Polygon"&&be++}we==="Polygon"&&ce++;break;case"MultiPolygon":for(l=0;l<E.length;l++){for(be=0,h=0;h<E[l].length;h++){for(f=0;f<E[l][h].length-P;f++){if(i(E[l][h][f],R,ye,ce,be)===!1)return!1;R++}be++}ce++}break;case"GeometryCollection":for(l=0;l<x.geometries.length;l++)if(xi(x.geometries[l],i,s)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function vp(a,i,s,l){var h=s;return xi(a,function(f,x,t,E,k){x===0&&s===void 0?h=f:h=i(h,f,x,t,E,k)},l),h}function xp(a,i){var s;switch(a.type){case"FeatureCollection":for(s=0;s<a.features.length&&i(a.features[s].properties,s)!==!1;s++);break;case"Feature":i(a.properties,0);break}}function h_(a,i,s){var l=s;return xp(a,function(h,f){f===0&&s===void 0?l=h:l=i(l,h,f)}),l}function Bn(a,i){if(a.type==="Feature")i(a,0);else if(a.type==="FeatureCollection")for(var s=0;s<a.features.length&&i(a.features[s],s)!==!1;s++);}function bp(a,i,s){var l=s;return Bn(a,function(h,f){f===0&&s===void 0?l=h:l=i(l,h,f)}),l}function Sc(a){var i=[];return xi(a,function(s){i.push(s)}),i}function Br(a,i){var s,l,h,f,x,t,E,k,P,R,F=0,U=a.type==="FeatureCollection",Z=a.type==="Feature",J=U?a.features.length:1;for(s=0;s<J;s++){for(t=U?a.features[s].geometry:Z?a.geometry:a,k=U?a.features[s].properties:Z?a.properties:{},P=U?a.features[s].bbox:Z?a.bbox:void 0,R=U?a.features[s].id:Z?a.id:void 0,E=t?t.type==="GeometryCollection":!1,x=E?t.geometries.length:1,h=0;h<x;h++){if(f=E?t.geometries[h]:t,f===null){if(i(null,F,k,P,R)===!1)return!1;continue}switch(f.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(i(f,F,k,P,R)===!1)return!1;break}case"GeometryCollection":{for(l=0;l<f.geometries.length;l++)if(i(f.geometries[l],F,k,P,R)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}F++}}function wp(a,i,s){var l=s;return Br(a,function(h,f,x,t,E){f===0&&s===void 0?l=h:l=i(l,h,f,x,t,E)}),l}function Wi(a,i){Br(a,function(s,l,h,f,x){var t=s===null?null:s.type;switch(t){case null:case"Point":case"LineString":case"Polygon":return i(nr(s,h,{bbox:f,id:x}),l,0)===!1?!1:void 0}var E;switch(t){case"MultiPoint":E="Point";break;case"MultiLineString":E="LineString";break;case"MultiPolygon":E="Polygon";break}for(var k=0;k<s.coordinates.length;k++){var P=s.coordinates[k],R={type:E,coordinates:P};if(i(nr(R,h),l,k)===!1)return!1}})}function f_(a,i,s){var l=s;return Wi(a,function(h,f,x){f===0&&x===0&&s===void 0?l=h:l=i(l,h,f,x)}),l}function ta(a,i){Wi(a,function(s,l,h){var f=0;if(s.geometry){var x=s.geometry.type;if(!(x==="Point"||x==="MultiPoint")){var t,E=0,k=0,P=0;if(xi(s,function(R,F,U,Z,J){if(t===void 0||l>E||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;t<x.length;t++)if(i(Zn(x[t],s.properties),l,h,t)===!1)return!1;break}}})}function Ip(a,i,s){var l=s;return Tp(a,function(h,f,x,t){f===0&&s===void 0?l=h:l=i(l,h,f,x,t)}),l}function d_(a,i){if(i=i||{},!Hn(i))throw new Error("options is invalid");var s=i.featureIndex||0,l=i.multiFeatureIndex||0,h=i.geometryIndex||0,f=i.segmentIndex||0,x=i.properties,t;switch(a.type){case"FeatureCollection":s<0&&(s=a.features.length+s),x=x||a.features[s].properties,t=a.features[s].geometry;break;case"Feature":x=x||a.properties,t=a.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":t=a;break;default:throw new Error("geojson is invalid")}if(t===null)return null;var E=t.coordinates;switch(t.type){case"Point":case"MultiPoint":return null;case"LineString":return f<0&&(f=E.length+f-1),Zn([E[f],E[f+1]],x,i);case"Polygon":return h<0&&(h=E.length+h),f<0&&(f=E[h].length+f-1),Zn([E[h][f],E[h][f+1]],x,i);case"MultiLineString":return l<0&&(l=E.length+l),f<0&&(f=E[l].length+f-1),Zn([E[l][f],E[l][f+1]],x,i);case"MultiPolygon":return l<0&&(l=E.length+l),h<0&&(h=E[l].length+h),f<0&&(f=E[l][h].length-f-1),Zn([E[l][h][f],E[l][h][f+1]],x,i)}throw new Error("geojson is invalid")}function p_(a,i){if(i=i||{},!Hn(i))throw new Error("options is invalid");var s=i.featureIndex||0,l=i.multiFeatureIndex||0,h=i.geometryIndex||0,f=i.coordIndex||0,x=i.properties,t;switch(a.type){case"FeatureCollection":s<0&&(s=a.features.length+s),x=x||a.features[s].properties,t=a.features[s].geometry;break;case"Feature":x=x||a.properties,t=a.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":t=a;break;default:throw new Error("geojson is invalid")}if(t===null)return null;var E=t.coordinates;switch(t.type){case"Point":return cn(E,x,i);case"MultiPoint":return l<0&&(l=E.length+l),cn(E[l],x,i);case"LineString":return f<0&&(f=E.length+f),cn(E[f],x,i);case"Polygon":return h<0&&(h=E.length+h),f<0&&(f=E[h].length+f),cn(E[h][f],x,i);case"MultiLineString":return l<0&&(l=E.length+l),f<0&&(f=E[l].length+f),cn(E[l][f],x,i);case"MultiPolygon":return l<0&&(l=E.length+l),h<0&&(h=E[l].length+h),f<0&&(f=E[l][h].length-f),cn(E[l][h][f],x,i)}throw new Error("geojson is invalid")}const Gb=Object.freeze(Object.defineProperty({__proto__:null,coordAll:Sc,coordEach:xi,coordReduce:vp,featureEach:Bn,featureReduce:bp,findPoint:p_,findSegment:d_,flattenEach:Wi,flattenReduce:f_,geomEach:Br,geomReduce:wp,lineEach:Tp,lineReduce:Ip,propEach:xp,propReduce:h_,segmentEach:ta,segmentReduce:Ep},Symbol.toStringTag,{value:"Module"}));function _u(a){return wp(a,(i,s)=>i+qb(s),0)}function qb(a){let i=0,s;switch(a.type){case"Polygon":return m_(a.coordinates);case"MultiPolygon":for(s=0;s<a.coordinates.length;s++)i+=m_(a.coordinates[s]);return i;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function m_(a){let i=0;if(a&&a.length>0){i+=Math.abs(g_(a[0]));for(let s=1;s<a.length;s++)i-=Math.abs(g_(a[s]))}return i}var Zb=ur*ur/2,Mp=Math.PI/180;function g_(a){const i=a.length-1;if(i<=2)return 0;let s=0,l=0;for(;l<i;){const h=a[l],f=a[l+1===i?0:l+1],x=a[l+2>=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]<l[0]&&(s[2]=l[0]),s[3]<l[1]&&(s[3]=l[1])}),s}function $b(a,i,s){var l=a.length,h=yu(a[0],i),f=[],x,t,E;let k,P;for(s||(s=[]),x=1;x<l;x++){for(k=a[x-1],P=a[x],t=E=yu(P,i);;)if(h|t){if(h&t)break;h?(k=Sp(k,P,h,i),h=yu(k,i)):(P=Sp(k,P,t,i),t=yu(P,i))}else{f.push(k),t!==E?(f.push(P),x<l-1&&(s.push(f),f=[])):x===l-1&&f.push(P);break}h=E}return f.length&&s.push(f),s}function Xb(a,i){var s,l,h,f,x,t,E;for(l=1;l<=8;l*=2){for(s=[],h=a[a.length-1],f=!(yu(h,i)&l),x=0;x<a.length;x++)t=a[x],E=!(yu(t,i)&l),E!==f&&s.push(Sp(h,t,l,i)),E&&s.push(t),h=t,f=E;if(a=s,!a.length)break}return s}function Sp(a,i,s,l){return s&8?[a[0]+(i[0]-a[0])*(l[3]-a[1])/(i[1]-a[1]),l[3]]:s&4?[a[0]+(i[0]-a[0])*(l[1]-a[1])/(i[1]-a[1]),l[1]]:s&2?[l[2],a[1]+(i[1]-a[1])*(l[2]-a[0])/(i[0]-a[0])]:s&1?[l[0],a[1]+(i[1]-a[1])*(l[0]-a[0])/(i[0]-a[0])]:null}function yu(a,i){var s=0;return a[0]<i[0]?s|=1:a[0]>i[2]&&(s|=2),a[1]<i[1]?s|=4: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;i<this.length;i++)this.points[i].z=this.points[i].z||0;for(let i=0;i<this.length-1;i++){const s=this.points[i],l=this.points[i+1];this.centers.push({x:(s.x+l.x)/2,y:(s.y+l.y)/2,z:(s.z+l.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(let i=0;i<this.centers.length-1;i++){const s=this.points[i+1].x-(this.centers[i].x+this.centers[i+1].x)/2,l=this.points[i+1].y-(this.centers[i].y+this.centers[i+1].y)/2,h=this.points[i+1].z-(this.centers[i].y+this.centers[i+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[i+1].x+this.sharpness*(this.centers[i].x+s),y:(1-this.sharpness)*this.points[i+1].y+this.sharpness*(this.centers[i].y+l),z:(1-this.sharpness)*this.points[i+1].z+this.sharpness*(this.centers[i].z+h)},{x:(1-this.sharpness)*this.points[i+1].x+this.sharpness*(this.centers[i+1].x+s),y:(1-this.sharpness)*this.points[i+1].y+this.sharpness*(this.centers[i+1].y+l),z:(1-this.sharpness)*this.points[i+1].z+this.sharpness*(this.centers[i+1].z+h)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}cacheSteps(a){const i=[];let s=this.pos(0);i.push(0);for(let l=0;l<this.duration;l+=10){const h=this.pos(l);Math.sqrt((h.x-s.x)*(h.x-s.x)+(h.y-s.y)*(h.y-s.y)+(h.z-s.z)*(h.z-s.z))>a&&(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;E<x.duration;E+=10)t(E);return t(x.duration),Zn(h,i.properties)}function _f(a){const i=_n(a);let s=0,l=1,h,f;for(;l<i.length;)h=f||i[0],f=i[l],s+=(f[0]-h[0])*(f[1]+h[1]),l++;return s>0}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;h<l;h++){const f=i[0][(h+2)%l][0]-i[0][(h+1)%l][0],x=i[0][(h+2)%l][1]-i[0][(h+1)%l][1],t=i[0][h][0]-i[0][(h+1)%l][0],E=i[0][h][1]-i[0][(h+1)%l][1],k=f*E-x*t;if(h===0)s=k>0;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;s<Z;s++){l=0;var J=i[s].length-1,he=i[s];if(P=he[0],P[0]!==he[J][0]&&P[1]!==he[J][1])throw new Error("First and last coordinates in a ring must be the same");for(x=P[0]-F,t=P[1]-U,l;l<J;l++){if(R=he[l+1],k=R[1]-U,t<0&&k<0||t>0&&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<t.length;++k){const P=ew(l,t[k]);if(P===0)return!s.ignoreBoundary;P&&(E=!0)}return E}function tw(a,i){return i[0]<=a[0]&&i[1]<=a[1]&&i[2]>=a[0]&&i[3]>=a[1]}function zn(a,i,s={}){const l=Jn(a),h=_n(i);for(let f=0;f<h.length-1;f++){let x=!1;if(s.ignoreEndVertices&&(f===0&&(x="start"),f===h.length-2&&(x="end"),f===0&&f+1===h.length-1&&(x="both")),nw(h[f],h[f+1],l,x,typeof s.epsilon>"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?t<f&&f<=k:k<=f&&f<t:Z>0?E<x&&x<=P:P<=x&&x<E;if(l==="end")return Math.abs(U)>=Math.abs(Z)?U>0?t<=f&&f<k:k<f&&f<=t:Z>0?E<=x&&x<P:P<x&&x<=E;if(l==="both")return Math.abs(U)>=Math.abs(Z)?U>0?t<f&&f<k:k<f&&f<t:Z>0?E<x&&x<P:P<x&&x<E}else return Math.abs(U)>=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;s<a.coordinates.length;s++)if(kp(a.coordinates[s],i.coordinates)){l=!0;break}return l}function sw(a,i){for(const s of i.coordinates){let l=!1;for(const h of a.coordinates)if(kp(s,h)){l=!0;break}if(!l)return!1}return!0}function aw(a,i){let s=!1;for(const l of i.coordinates)if(zn(l,a,{ignoreEndVertices:!0})&&(s=!0),!zn(l,a))return!1;return!!s}function lw(a,i){for(const s of i.coordinates)if(!Pn(s,a,{ignoreBoundary:!0}))return!1;return!0}function uw(a,i){let s=!1;for(const l of i.coordinates)if(zn({type:"Point",coordinates:l},a,{ignoreEndVertices:!0})&&(s=!0),!zn({type:"Point",coordinates:l},a,{ignoreEndVertices:!1}))return!1;return s}function cw(a,i){let s=!1,l=0;const h=pi(a),f=pi(i);if(!v_(h,f))return!1;for(l;l<i.coordinates.length-1;l++){const x=hw(i.coordinates[l],i.coordinates[l+1]);if(Pn({type:"Point",coordinates:x},a,{ignoreBoundary:!0})){s=!0;break}}return s}function y_(a,i){if(a.type==="Feature"&&a.geometry===null||i.type==="Feature"&&i.geometry===null)return!1;const s=pi(a),l=pi(i);if(!v_(s,l))return!1;const h=Ei(i).coordinates;for(const f of h)for(const x of f)if(!Pn(x,a))return!1;return!0}function v_(a,i){return!(a[0]>i[0]||a[2]<i[2]||a[1]>i[1]||a[3]<i[3])}function kp(a,i){return a[0]===i[0]&&a[1]===i[1]}function hw(a,i){return[(a[0]+i[0])/2,(a[1]+i[1])/2]}let x_=class{constructor(i=[],s=fw){if(this.data=i,this.length=this.data.length,this.compare=s,this.length>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<h;){let x=(i<<1)+1,t=s[x];const E=x+1;if(E<this.length&&l(s[E],t)<0&&(x=E,t=s[E]),l(t,f)>=0)break;s[i]=t,i=x}s[i]=f}};function fw(a,i){return a<i?-1:a>i?1:0}function b_(a,i){return a.p.x>i.p.x?1:a.p.x<i.p.x?-1:a.p.y!==i.p.y?a.p.y>i.p.y?1:-1:1}function dw(a,i){return a.rightSweepEvent.p.x>i.rightSweepEvent.p.x?1:a.rightSweepEvent.p.x<i.rightSweepEvent.p.x?-1:a.rightSweepEvent.p.y!==i.rightSweepEvent.p.y?a.rightSweepEvent.p.y<i.rightSweepEvent.p.y?1:-1:1}class w_{constructor(i,s,l,h){this.p={x:i[0],y:i[1]},this.featureId=s,this.ringId=l,this.eventId=h,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(i){return this.p.x===i.p.x&&this.p.y===i.p.y}}function pw(a,i){if(a.type==="FeatureCollection"){const s=a.features;for(let l=0;l<s.length;l++)E_(s[l],i)}else E_(a,i)}let yf=0,vf=0,xf=0;function E_(a,i){const s=a.type==="Feature"?a.geometry:a;let l=s.coordinates;(s.type==="Polygon"||s.type==="MultiLineString")&&(l=[l]),s.type==="LineString"&&(l=[[l]]);for(let h=0;h<l.length;h++)for(let f=0;f<l[h].length;f++){let x=l[h][f][0],t=null;vf=vf+1;for(let E=0;E<l[h][f].length-1;E++){t=l[h][f][E+1];const k=new w_(x,yf,vf,xf),P=new w_(t,yf,vf,xf+1);k.otherEvent=P,P.otherEvent=k,b_(k,P)>0?(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<l.data.length;x++){const t=l.data[x];if(i&&t.leftSweepEvent.featureId===h.featureId)continue;const E=gw(f,t);E!==!1&&s.push(E)}l.push(f)}else h.isLeftEndpoint===!1&&l.pop()}return s}function yw(a,i){const s=new x_([],b_);return pw(a,s),_w(s,i)}var vw=yw;function os(a,i,s={}){const{removeDuplicates:l=!0,ignoreSelfIntersections:h=!1}=s;let f=[];a.type==="FeatureCollection"?f=f.concat(a.features):a.type==="Feature"?f.push(a):(a.type==="LineString"||a.type==="Polygon"||a.type==="MultiLineString"||a.type==="MultiPolygon")&&f.push(nr(a)),i.type==="FeatureCollection"?f=f.concat(i.features):i.type==="Feature"?f.push(i):(i.type==="LineString"||i.type==="Polygon"||i.type==="MultiLineString"||i.type==="MultiPolygon")&&f.push(nr(i));const x=vw(Jt(f),h);let t=[];if(l){const E={};x.forEach(k=>{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;f<h&&!s&&!l;){for(var x=0;x<i.coordinates.length-1;x++){var t=!0;(x===0||x===i.coordinates.length-2)&&(t=!1),C_(i.coordinates[x],i.coordinates[x+1],a.coordinates[f],t)?s=!0:l=!0}f++}return s&&l}function ww(a,i){var s=os(a,i);if(s.features.length>0)for(var l=0;l<a.coordinates.length-1;l++)for(var h=0;h<i.coordinates.length-1;h++){var f=!0;if((h===0||h===i.coordinates.length-2)&&(f=!1),C_(a.coordinates[l],a.coordinates[l+1],i.coordinates[h],f))return!0}return!1}function S_(a,i){const s=Cc(i);return os(a,s).features.length>0}function k_(a,i){var s=!1,l=!1,h=a.coordinates.length;for(let f=0;f<h&&(!s||!l);f++)Pn(cn(a.coordinates[f]),i)?s=!0:l=!0;return l&&s}function C_(a,i,s,l){var h=s[0]-a[0],f=s[1]-a[1],x=i[0]-a[0],t=i[1]-a[1],E=h*t-f*x;return E!==0?!1:l?Math.abs(x)>=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]<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]}function Cp(a,i,s={}){var l;const h=(l=s.ignoreSelfIntersections)!=null?l:!1;let f=!0;return Wi(a,x=>{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;s<a.coordinates.length-1;s++)if(Mw(a.coordinates[s],a.coordinates[s+1],i.coordinates))return!0;return!1}function Tw(a,i,s){return os(a,i,{ignoreSelfIntersections:s}).features.length>0}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])<this.precision)}compareLine(i,s,l=0,h=!1){if(!Ac(i,s))return!1;const f=i;let x=s;if(h&&!this.compareCoord(f[0],x[0])){const E=this.fixStartIndex(x,f);if(E)x=E;else return!1}const t=this.compareCoord(f[l],x[l]);return this.direction||t?this.comparePath(f,x):this.compareCoord(f[l],x[x.length-(1+l)])?this.comparePath(f.slice().reverse(),x):!1}fixStartIndex(i,s){let l,h=-1;for(let f=0;f<i.length;f++)if(this.compareCoord(i[f],s[0])){h=f;break}return 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;x<h;x++){var t=l[l.length-1];s[x][0]===t[0]&&s[x][1]===t[1]||(l.push(s[x]),f=l.length,f>2&&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);U<Z;){for(Pc(a,U,Z),U++,Z--;h(a[U],F)<0;)U++;for(;h(a[Z],F)>0;)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 a<i?-1:a>i?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<s.children.length;x++){const t=s.children[x],E=s.leaf?h(t):t;wf(i,E)&&(s.leaf?l.push(t):zp(i,E)?this._all(t,l):f.push(t))}s=f.pop()}return l}collides(i){let s=this.data;if(!wf(i,s))return!1;const l=[];for(;s;){for(let h=0;h<s.children.length;h++){const f=s.children[h],x=s.leaf?this.toBBox(f):f;if(wf(i,x)){if(s.leaf||zp(i,x))return!0;l.push(f)}}s=l.pop()}return!1}load(i){if(!(i&&i.length))return this;if(i.length<this._minEntries){for(let l=0;l<i.length;l++)this.insert(i[l]);return this}let s=this._build(i.slice(),0,i.length-1,0);if(!this.data.children.length)this.data=s;else if(this.data.height===s.height)this._splitRoot(this.data,s);else{if(this.data.height<s.height){const l=this.data;this.data=s,s=l}this._insert(s,this.data.height-s.height-1,!0)}return this}insert(i){return i&&this._insert(i,this.data.height-1),this}clear(){return this.data=bu([]),this}remove(i,s){if(!i)return this;let l=this.data;const h=this.toBBox(i),f=[],x=[];let t,E,k;for(;l||f.length;){if(l||(l=f.pop(),E=f[f.length-1],t=x.pop(),k=!0),l.leaf){const P=Rw(i,l.children,s);if(P!==-1)return l.children.splice(P,1),f.push(l),this._condense(f),this}!k&&!l.leaf&&zp(l,h)?(f.push(l),x.push(t),t=0,E=l,l=l.children[0]):E?(t++,l=E.children[t],k=!1):l=null}return this}toBBox(i){return i}compareMinX(i,s){return i.minX-s.minX}compareMinY(i,s){return i.minY-s.minY}toJSON(){return this.data}fromJSON(i){return this.data=i,this}_all(i,s){const l=[];for(;i;)i.leaf?s.push(...i.children):l.push(...i.children),i=l.pop();return s}_build(i,s,l,h){const f=l-s+1;let x=this._maxEntries,t;if(f<=x)return t=bu(i.slice(s,l+1)),xu(t,this.toBBox),t;h||(h=Math.ceil(Math.log(f)/Math.log(x)),x=Math.ceil(f/Math.pow(x,h-1))),t=bu([]),t.leaf=!1,t.height=h;const E=Math.ceil(f/x),k=E*Math.ceil(Math.sqrt(x));B_(i,s,l,k,this.compareMinX);for(let P=s;P<=l;P+=k){const R=Math.min(P+k-1,l);B_(i,P,R,E,this.compareMinY);for(let F=P;F<=R;F+=E){const U=Math.min(F+E-1,R);t.children.push(this._build(i,F,U,h-1))}}return xu(t,this.toBBox),t}_chooseSubtree(i,s,l,h){for(;h.push(s),!(s.leaf||h.length-1===l);){let f=1/0,x=1/0,t;for(let E=0;E<s.children.length;E++){const k=s.children[E],P=Dp(k),R=Ow(i,k)-P;R<x?(x=R,f=P<f?P:f,t=k):R===x&&P<f&&(f=P,t=k)}s=t||s.children[0]}return s}_insert(i,s,l){const h=l?i:this.toBBox(i),f=[],x=this._chooseSubtree(h,this.data,s,f);for(x.children.push(i),Rc(x,h);s>=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<f?(f=P,h=t,x=R<x?R:x):P===f&&R<x&&(x=R,h=t)}return h||l-s}_chooseSplitAxis(i,s,l){const h=i.leaf?this.compareMinX:Dw,f=i.leaf?this.compareMinY:zw,x=this._allDistMargin(i,s,l,h),t=this._allDistMargin(i,s,l,f);x<t&&i.children.sort(h)}_allDistMargin(i,s,l,h){i.children.sort(h);const f=this.toBBox,x=Lc(i,0,s,f),t=Lc(i,l-s,l,f);let E=bf(x)+bf(t);for(let k=s;k<l-s;k++){const P=i.children[k];Rc(x,i.leaf?f(P):P),E+=bf(x)}for(let k=l-s-1;k>=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<i.length;l++)if(s(a,i[l]))return l;return-1}function xu(a,i){Lc(a,0,a.children.length,i,a)}function Lc(a,i,s,l,h){h||(h=bu(null)),h.minX=1/0,h.minY=1/0,h.maxX=-1/0,h.maxY=-1/0;for(let f=i;f<s;f++){const x=a.children[f];Rc(h,a.leaf?l(x):x)}return h}function Rc(a,i){return a.minX=Math.min(a.minX,i.minX),a.minY=Math.min(a.minY,i.minY),a.maxX=Math.max(a.maxX,i.maxX),a.maxY=Math.max(a.maxY,i.maxY),a}function Dw(a,i){return a.minX-i.minX}function zw(a,i){return a.minY-i.minY}function Dp(a){return(a.maxX-a.minX)*(a.maxY-a.minY)}function bf(a){return a.maxX-a.minX+(a.maxY-a.minY)}function Ow(a,i){return(Math.max(i.maxX,a.maxX)-Math.min(i.minX,a.minX))*(Math.max(i.maxY,a.maxY)-Math.min(i.minY,a.minY))}function Nw(a,i){const s=Math.max(a.minX,i.minX),l=Math.max(a.minY,i.minY),h=Math.min(a.maxX,i.maxX),f=Math.min(a.maxY,i.maxY);return Math.max(0,h-s)*Math.max(0,f-l)}function zp(a,i){return a.minX<=i.minX&&a.minY<=i.minY&&i.maxX<=a.maxX&&i.maxY<=a.maxY}function wf(a,i){return i.minX<=a.maxX&&i.minY<=a.maxY&&i.maxX>=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=s<h?s:h,t=l<f?l:f,E=s>h?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;k<E.length-1;k++){const P=cn(E[k]);P.properties.dist=Wn(i,P,s);const R=cn(E[k+1]);R.properties.dist=Wn(i,R,s);const F=Wn(P,R,s),U=Math.max(P.properties.dist,R.properties.dist),Z=Ps(P,R),J=ea(i,U,Z+90,s),he=ea(i,U,Z-90,s),ye=os(Zn([J.geometry.coordinates,he.geometry.coordinates]),Zn([P.geometry.coordinates,R.geometry.coordinates]));let te;ye.features.length>0&&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<l.properties.dist&&(l=Ml(Il({},P),{properties:Ml(Il({},P.properties),{index:k,multiFeatureIndex:t,location:h})})),R.properties.dist<l.properties.dist&&(l=Ml(Il({},R),{properties:Ml(Il({},R.properties),{index:k+1,multiFeatureIndex:t,location:h+F})})),te&&te.properties.dist<l.properties.dist&&(l=Ml(Il({},te),{properties:Ml(Il({},te.properties),{index:k})})),h+=F}}),l}var Xw=function a(i,s){if(i===s)return!0;if(i&&s&&typeof i=="object"&&typeof s=="object"){if(i.constructor!==s.constructor)return!1;var l,h,f;if(Array.isArray(i)){if(l=i.length,l!=s.length)return!1;for(h=l;h--!==0;)if(!a(i[h],s[h]))return!1;return!0}if(i.constructor===RegExp)return i.source===s.source&&i.flags===s.flags;if(i.valueOf!==Object.prototype.valueOf)return i.valueOf()===s.valueOf();if(i.toString!==Object.prototype.toString)return i.toString()===s.toString();if(f=Object.keys(i),l=f.length,l!==Object.keys(s).length)return!1;for(h=l;h--!==0;)if(!Object.prototype.hasOwnProperty.call(s,f[h]))return!1;for(h=l;h--!==0;){var x=f[h];if(!a(i[x],s[x]))return!1}return!0}return i!==i&&s!==s};const Dc=pu(Xw);function U_(a,i,s={}){if(s=s||{},!Hn(s))throw new Error("options is invalid");var l=s.tolerance||0,h=[],f=Ef();const x=wu(a);f.load(x);var t;let E=[];return ta(i,function(k){var P=!1;k&&(Bn(f.search(k),function(R){if(P===!1){var F=_n(k).sort(),U=_n(R).sort();if(Dc(F,U))P=!0,t?t=Op(t,k)||t:t=k;else if(l===0?zn(F[0],R)&&zn(F[1],R):Ra(R,F[0]).properties.dist<=l&&Ra(R,F[1]).properties.dist<=l)P=!0,t?t=Op(t,k)||t:t=k;else if(l===0?zn(U[0],k)&&zn(U[1],k):Ra(k,U[0]).properties.dist<=l&&Ra(k,U[1]).properties.dist<=l)if(t){const Z=Op(t,R);Z?t=Z:E.push(R)}else t=R}}),P===!1&&t&&(h.push(t),E.length&&(h=h.concat(E),E=[]),t=void 0))}),t&&h.push(t),Jt(h)}function Op(a,i){var s=_n(i),l=_n(a),h=l[0],f=l[l.length-1],x=a.geometry.coordinates;if(Dc(s[0],h))x.unshift(s[1]);else if(Dc(s[0],f))x.push(s[1]);else if(Dc(s[1],h))x.unshift(s[0]);else if(Dc(s[1],f))x.push(s[0]);else return;return a}function Ww(a,i){const s=Ei(a),l=Ei(i),h=s.type,f=l.type;if(h==="MultiPoint"&&f!=="MultiPoint"||(h==="LineString"||h==="MultiLineString")&&f!=="LineString"&&f!=="MultiLineString"||(h==="Polygon"||h==="MultiPolygon")&&f!=="Polygon"&&f!=="MultiPolygon")throw new Error("features must be of the same type");if(h==="Point")throw new Error("Point geometry not supported");if(Pp(a,i,{precision:6}))return!1;let x=0;switch(h){case"MultiPoint":for(var t=0;t<s.coordinates.length;t++)for(var E=0;E<l.coordinates.length;E++){var k=s.coordinates[t],P=l.coordinates[E];if(k[0]===P[0]&&k[1]===P[1])return!0}return!1;case"LineString":case"MultiLineString":ta(a,R=>{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;x<h.length;x++){var t=h[x].geometry.coordinates;if(!f[x])break;var E=f[x].geometry.coordinates;if(!Hw(t,E))return!1}return!0}function Hw(a,i){var s=gu(Tl(a[0],a[1])),l=gu(Tl(i[0],i[1]));return s===l||(l-s)%180===0}function j_(a,i){if(a.geometry&&a.geometry.type)return a.geometry.type;if(a.type)return a.type;throw new Error("Invalid GeoJSON object for "+i)}function Kw(a,i){var s=Ei(a),l=Ei(i),h=s.type,f=l.type;switch(h){case"Point":switch(f){case"LineString":return Gr(s,l);case"MultiLineString":for(var x=!1,t=0;t<l.coordinates.length;t++)Gr(s,{type:"LineString",coordinates:l.coordinates[t]})&&(x=!0);return x;case"Polygon":for(var E=0;E<l.coordinates.length;E++)if(zn(s,{type:"LineString",coordinates:l.coordinates[E]}))return!0;return!1;case"MultiPolygon":for(var E=0;E<l.coordinates.length;E++)for(var t=0;t<l.coordinates[E].length;t++)if(zn(s,{type:"LineString",coordinates:l.coordinates[E][t]}))return!0;return!1;default:throw new Error("feature2 "+f+" geometry not supported")}case"MultiPoint":switch(f){case"LineString":for(var x=!1,E=0;E<s.coordinates.length;E++)if(x||Gr({type:"Point",coordinates:s.coordinates[E]},l)&&(x=!0),zn({type:"Point",coordinates:s.coordinates[E]},l,{ignoreEndVertices:!0}))return!1;return x;case"MultiLineString":for(var x=!1,E=0;E<s.coordinates.length;E++)for(var t=0;t<l.coordinates.length;t++)if(x||Gr({type:"Point",coordinates:s.coordinates[E]},{type:"LineString",coordinates:l.coordinates[t]})&&(x=!0),zn({type:"Point",coordinates:s.coordinates[E]},{type:"LineString",coordinates:l.coordinates[t]},{ignoreEndVertices:!0}))return!1;return x;case"Polygon":for(var x=!1,E=0;E<s.coordinates.length;E++)if(x||zn({type:"Point",coordinates:s.coordinates[E]},{type:"LineString",coordinates:l.coordinates[0]})&&(x=!0),Pn({type:"Point",coordinates:s.coordinates[E]},l,{ignoreBoundary:!0}))return!1;return x;case"MultiPolygon":for(var x=!1,E=0;E<s.coordinates.length;E++)for(var t=0;t<l.coordinates.length;t++)if(x||zn({type:"Point",coordinates:s.coordinates[E]},{type:"LineString",coordinates:l.coordinates[t][0]})&&(x=!0),Pn({type:"Point",coordinates:s.coordinates[E]},{type:"Polygon",coordinates:l.coordinates[t]},{ignoreBoundary:!0}))return!1;return x;default:throw new Error("feature2 "+f+" geometry not supported")}case"LineString":switch(f){case"Point":return Gr(l,s);case"MultiPoint":for(var x=!1,E=0;E<l.coordinates.length;E++)if(x||Gr({type:"Point",coordinates:l.coordinates[E]},s)&&(x=!0),zn({type:"Point",coordinates:l.coordinates[E]},s,{ignoreEndVertices:!0}))return!1;return x;case"LineString":var k=!1;if(Gr({type:"Point",coordinates:s.coordinates[0]},l)&&(k=!0),Gr({type:"Point",coordinates:s.coordinates[s.coordinates.length-1]},l)&&(k=!0),k===!1)return!1;for(var E=0;E<s.coordinates.length;E++)if(zn({type:"Point",coordinates:s.coordinates[E]},l,{ignoreEndVertices:!0}))return!1;return k;case"MultiLineString":for(var k=!1,E=0;E<l.coordinates.length;E++){Gr({type:"Point",coordinates:s.coordinates[0]},{type:"LineString",coordinates:l.coordinates[E]})&&(k=!0),Gr({type:"Point",coordinates:s.coordinates[s.coordinates.length-1]},{type:"LineString",coordinates:l.coordinates[E]})&&(k=!0);for(var t=0;t<s.coordinates[E].length;t++)if(zn({type:"Point",coordinates:s.coordinates[t]},{type:"LineString",coordinates:l.coordinates[E]},{ignoreEndVertices:!0}))return!1}return k;case"Polygon":for(var x=!1,E=0;E<s.coordinates.length;E++)if(x||zn({type:"Point",coordinates:s.coordinates[E]},{type:"LineString",coordinates:l.coordinates[0]})&&(x=!0),Pn({type:"Point",coordinates:s.coordinates[E]},l,{ignoreBoundary:!0}))return!1;return x;case"MultiPolygon":for(var x=!1,E=0;E<s.coordinates.length;E++){for(var t=0;t<l.coordinates.length;t++)x||zn({type:"Point",coordinates:s.coordinates[E]},{type:"LineString",coordinates:l.coordinates[t][0]})&&(x=!0);if(Pn({type:"Point",coordinates:s.coordinates[E]},l,{ignoreBoundary:!0}))return!1}return x;default:throw new Error("feature2 "+f+" geometry not supported")}case"MultiLineString":switch(f){case"Point":for(var E=0;E<s.coordinates.length;E++)if(Gr(l,{type:"LineString",coordinates:s.coordinates[E]}))return!0;return!1;case"MultiPoint":for(var x=!1,E=0;E<s.coordinates.length;E++)for(var t=0;t<l.coordinates.length;t++)if(x||Gr({type:"Point",coordinates:l.coordinates[t]},{type:"LineString",coordinates:s.coordinates[t]})&&(x=!0),zn({type:"Point",coordinates:l.coordinates[t]},{type:"LineString",coordinates:s.coordinates[t]},{ignoreEndVertices:!0}))return!1;return x;case"LineString":for(var k=!1,E=0;E<s.coordinates.length;E++){Gr({type:"Point",coordinates:s.coordinates[E][0]},l)&&(k=!0),Gr({type:"Point",coordinates:s.coordinates[E][s.coordinates[E].length-1]},l)&&(k=!0);for(var t=0;t<l.coordinates.length;t++)if(zn({type:"Point",coordinates:l.coordinates[t]},{type:"LineString",coordinates:s.coordinates[E]},{ignoreEndVertices:!0}))return!1}return k;case"MultiLineString":for(var k=!1,E=0;E<s.coordinates.length;E++)for(var t=0;t<l.coordinates.length;t++){Gr({type:"Point",coordinates:s.coordinates[E][0]},{type:"LineString",coordinates:l.coordinates[t]})&&(k=!0),Gr({type:"Point",coordinates:s.coordinates[E][s.coordinates[E].length-1]},{type:"LineString",coordinates:l.coordinates[t]})&&(k=!0);for(var P=0;P<s.coordinates[E].length;P++)if(zn({type:"Point",coordinates:s.coordinates[E][P]},{type:"LineString",coordinates:l.coordinates[t]},{ignoreEndVertices:!0}))return!1}return k;case"Polygon":for(var x=!1,E=0;E<s.coordinates.length;E++)for(var t=0;t<s.coordinates.length;t++)if(x||zn({type:"Point",coordinates:s.coordinates[E][t]},{type:"LineString",coordinates:l.coordinates[0]})&&(x=!0),Pn({type:"Point",coordinates:s.coordinates[E][t]},l,{ignoreBoundary:!0}))return!1;return x;case"MultiPolygon":for(var x=!1,E=0;E<l.coordinates[0].length;E++)for(var t=0;t<s.coordinates.length;t++)for(var P=0;P<s.coordinates[t].length;P++)if(x||zn({type:"Point",coordinates:s.coordinates[t][P]},{type:"LineString",coordinates:l.coordinates[0][E]})&&(x=!0),Pn({type:"Point",coordinates:s.coordinates[t][P]},{type:"Polygon",coordinates:[l.coordinates[0][E]]},{ignoreBoundary:!0}))return!1;return x;default:throw new Error("feature2 "+f+" geometry not supported")}case"Polygon":switch(f){case"Point":for(var E=0;E<s.coordinates.length;E++)if(zn(l,{type:"LineString",coordinates:s.coordinates[E]}))return!0;return!1;case"MultiPoint":for(var x=!1,E=0;E<l.coordinates.length;E++)if(x||zn({type:"Point",coordinates:l.coordinates[E]},{type:"LineString",coordinates:s.coordinates[0]})&&(x=!0),Pn({type:"Point",coordinates:l.coordinates[E]},s,{ignoreBoundary:!0}))return!1;return x;case"LineString":for(var x=!1,E=0;E<l.coordinates.length;E++)if(x||zn({type:"Point",coordinates:l.coordinates[E]},{type:"LineString",coordinates:s.coordinates[0]})&&(x=!0),Pn({type:"Point",coordinates:l.coordinates[E]},s,{ignoreBoundary:!0}))return!1;return x;case"MultiLineString":for(var x=!1,E=0;E<l.coordinates.length;E++)for(var t=0;t<l.coordinates[E].length;t++)if(x||zn({type:"Point",coordinates:l.coordinates[E][t]},{type:"LineString",coordinates:s.coordinates[0]})&&(x=!0),Pn({type:"Point",coordinates:l.coordinates[E][t]},s,{ignoreBoundary:!0}))return!1;return x;case"Polygon":for(var x=!1,E=0;E<s.coordinates[0].length;E++)if(x||zn({type:"Point",coordinates:s.coordinates[0][E]},{type:"LineString",coordinates:l.coordinates[0]})&&(x=!0),Pn({type:"Point",coordinates:s.coordinates[0][E]},l,{ignoreBoundary:!0}))return!1;return x;case"MultiPolygon":for(var x=!1,E=0;E<l.coordinates[0].length;E++)for(var t=0;t<s.coordinates[0].length;t++)if(x||zn({type:"Point",coordinates:s.coordinates[0][t]},{type:"LineString",coordinates:l.coordinates[0][E]})&&(x=!0),Pn({type:"Point",coordinates:s.coordinates[0][t]},{type:"Polygon",coordinates:l.coordinates[0][E]},{ignoreBoundary:!0}))return!1;return x;default:throw new Error("feature2 "+f+" geometry not supported")}case"MultiPolygon":switch(f){case"Point":for(var E=0;E<s.coordinates[0].length;E++)if(zn(l,{type:"LineString",coordinates:s.coordinates[0][E]}))return!0;return!1;case"MultiPoint":for(var x=!1,E=0;E<s.coordinates[0].length;E++)for(var t=0;t<l.coordinates.length;t++)if(x||zn({type:"Point",coordinates:l.coordinates[t]},{type:"LineString",coordinates:s.coordinates[0][E]})&&(x=!0),Pn({type:"Point",coordinates:l.coordinates[t]},{type:"Polygon",coordinates:s.coordinates[0][E]},{ignoreBoundary:!0}))return!1;return x;case"LineString":for(var x=!1,E=0;E<s.coordinates[0].length;E++)for(var t=0;t<l.coordinates.length;t++)if(x||zn({type:"Point",coordinates:l.coordinates[t]},{type:"LineString",coordinates:s.coordinates[0][E]})&&(x=!0),Pn({type:"Point",coordinates:l.coordinates[t]},{type:"Polygon",coordinates:s.coordinates[0][E]},{ignoreBoundary:!0}))return!1;return x;case"MultiLineString":for(var x=!1,E=0;E<s.coordinates.length;E++)for(var t=0;t<l.coordinates.length;t++)for(var P=0;P<l.coordinates[t].length;P++)if(x||zn({type:"Point",coordinates:l.coordinates[t][P]},{type:"LineString",coordinates:s.coordinates[E][0]})&&(x=!0),Pn({type:"Point",coordinates:l.coordinates[t][P]},{type:"Polygon",coordinates:[s.coordinates[E][0]]},{ignoreBoundary:!0}))return!1;return x;case"Polygon":for(var x=!1,E=0;E<s.coordinates[0].length;E++)for(var t=0;t<s.coordinates[0][E].length;t++)if(x||zn({type:"Point",coordinates:s.coordinates[0][E][t]},{type:"LineString",coordinates:l.coordinates[0]})&&(x=!0),Pn({type:"Point",coordinates:s.coordinates[0][E][t]},l,{ignoreBoundary:!0}))return!1;return x;case"MultiPolygon":for(var x=!1,E=0;E<s.coordinates[0].length;E++)for(var t=0;t<l.coordinates[0].length;t++)for(var P=0;P<s.coordinates[0].length;P++)if(x||zn({type:"Point",coordinates:s.coordinates[0][E][P]},{type:"LineString",coordinates:l.coordinates[0][t]})&&(x=!0),Pn({type:"Point",coordinates:s.coordinates[0][E][P]},{type:"Polygon",coordinates:l.coordinates[0][t]},{ignoreBoundary:!0}))return!1;return x;default:throw new Error("feature2 "+f+" geometry not supported")}default:throw new Error("feature1 "+h+" geometry not supported")}}function Gr(a,i){return!!(G_(i.coordinates[0],a.coordinates)||G_(i.coordinates[i.coordinates.length-1],a.coordinates))}function G_(a,i){return a[0]===i[0]&&a[1]===i[1]}function Jw(a){if(!a.type)return!1;const i=Ei(a),s=i.type,l=i.coordinates;switch(s){case"Point":return l.length>1;case"MultiPoint":for(var h=0;h<l.length;h++)if(l[h].length<2)return!1;return!0;case"LineString":if(l.length<2)return!1;for(var h=0;h<l.length;h++)if(l[h].length<2)return!1;return!0;case"MultiLineString":if(l.length<2)return!1;for(var h=0;h<l.length;h++)if(l[h].length<2)return!1;return!0;case"Polygon":for(var h=0;h<i.coordinates.length;h++)if(l[h].length<4||!q_(l[h])||Z_(l[h])||h>0&&os(Mn([l[0]]),Mn([l[h]])).features.length>1)return!1;return!0;case"MultiPolygon":for(var h=0;h<i.coordinates.length;h++)for(var f=i.coordinates[h],x=0;x<f.length;x++)if(f[x].length<4||!q_(f[x])||Z_(f[x])||x===0&&!Qw(f,i.coordinates,h)||x>0&&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;i<a.length-1;i++)for(var s=a[i],l=i+1;l<a.length-2;l++){var h=[a[l],a[l+1]];if(zn(s,Zn(h)))return!0}return!1}function Qw(a,i,s){for(var l=Mn(a),h=s+1;h<i.length;h++)if(!Cp(l,Mn(i[h]))&&I_(l,Zn(i[h][0])))return!1;return!0}function $_(a,i){var s=Ei(a),l=Ei(i),h=s.type,f=l.type;switch(h){case"Point":switch(f){case"MultiPoint":return eE(s,l);case"LineString":return zn(s,l,{ignoreEndVertices:!0});case"Polygon":case"MultiPolygon":return Pn(s,l,{ignoreBoundary:!0});default:throw new Error("feature2 "+f+" geometry not supported")}case"MultiPoint":switch(f){case"MultiPoint":return tE(s,l);case"LineString":return nE(s,l);case"Polygon":case"MultiPolygon":return iE(s,l);default:throw new Error("feature2 "+f+" geometry not supported")}case"LineString":switch(f){case"LineString":return rE(s,l);case"Polygon":case"MultiPolygon":return oE(s,l);default:throw new Error("feature2 "+f+" geometry not supported")}case"Polygon":switch(f){case"Polygon":case"MultiPolygon":return sE(s,l);default:throw new Error("feature2 "+f+" geometry not supported")}default:throw new Error("feature1 "+h+" geometry not supported")}}function eE(a,i){var s,l=!1;for(s=0;s<i.coordinates.length;s++)if(W_(i.coordinates[s],a.coordinates)){l=!0;break}return l}function tE(a,i){for(var s=0;s<a.coordinates.length;s++){for(var l=!1,h=0;h<i.coordinates.length;h++)W_(a.coordinates[s],i.coordinates[h])&&(l=!0);if(!l)return!1}return!0}function nE(a,i){for(var s=!1,l=0;l<a.coordinates.length;l++){if(!zn(a.coordinates[l],i))return!1;s||(s=zn(a.coordinates[l],i,{ignoreEndVertices:!0}))}return s}function iE(a,i){for(var s=!0,l=!1,h=0;h<a.coordinates.length;h++){if(l=Pn(a.coordinates[h],i),!l){s=!1;break}l=Pn(a.coordinates[h],i,{ignoreBoundary:!0})}return s&&l}function rE(a,i){for(var s=0;s<a.coordinates.length;s++)if(!zn(a.coordinates[s],i))return!1;return!0}function oE(a,i){var s=pi(i),l=pi(a);if(!X_(s,l))return!1;for(var h=!1,f=0;f<a.coordinates.length;f++){if(!Pn(a.coordinates[f],i))return!1;if(h||(h=Pn(a.coordinates[f],i,{ignoreBoundary:!0})),!h&&f<a.coordinates.length-1){var x=aE(a.coordinates[f],a.coordinates[f+1]);h=Pn(x,i,{ignoreBoundary:!0})}}return h}function sE(a,i){var s=pi(a),l=pi(i);if(!X_(l,s))return!1;for(var h=0;h<a.coordinates[0].length;h++)if(!Pn(a.coordinates[0][h],i))return!1;return!0}function X_(a,i){return!(a[0]>i[0]||a[2]<i[2]||a[1]>i[1]||a[3]<i[3])}function W_(a,i){return a[0]===i[0]&&a[1]===i[1]}function aE(a,i){return[(a[0]+i[0])/2,(a[1]+i[1])/2]}function Eu(a,i={}){const s=pi(a),l=(s[0]+s[2])/2,h=(s[1]+s[3])/2;return cn([l,h],i.properties,i)}var Y_={exports:{}};(function(a,i){(function(s,l){a.exports=l()})(pp,function(){function s(M,c){if(!(M instanceof c))throw new TypeError("Cannot call a class as a function")}function l(M,c){for(var p=0;p<c.length;p++){var g=c[p];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(M,g.key,g)}}function h(M,c,p){return c&&l(M.prototype,c),p&&l(M,p),M}function f(M,c){if(typeof c!="function"&&c!==null)throw new TypeError("Super expression must either be null or a function");M.prototype=Object.create(c&&c.prototype,{constructor:{value:M,writable:!0,configurable:!0}}),c&&t(M,c)}function x(M){return x=Object.setPrototypeOf?Object.getPrototypeOf:function(c){return c.__proto__||Object.getPrototypeOf(c)},x(M)}function t(M,c){return t=Object.setPrototypeOf||function(p,g){return p.__proto__=g,p},t(M,c)}function E(){if(typeof Reflect>"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<c;p++)g[p]=M[p];return g}function te(M,c){var p=typeof Symbol<"u"&&M[Symbol.iterator]||M["@@iterator"];if(!p){if(Array.isArray(M)||(p=he(M))||c){p&&(M=p);var g=0,w=function(){};return{s:w,n:function(){return g>=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.x<p.x?-1:this.x>p.x?1:this.y<p.y?-1:this.y>p.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 c<p?-1:c>p?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<c._maxx?this._maxx:c._maxx,g,this._maxy<c._maxy?this._maxy:c._maxy)}},{key:"isNull",value:function(){return this._maxx<this._minx}},{key:"getMaxX",value:function(){return this._maxx}},{key:"covers",value:function(){if(arguments.length===1){if(arguments[0]instanceof je){var c=arguments[0];return this.covers(c.x,c.y)}if(arguments[0]instanceof M){var p=arguments[0];return!this.isNull()&&!p.isNull()&&p.getMinX()>=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._maxx<this._minx||c._miny>this._maxy||c._maxy<this._miny)}if(arguments[0]instanceof je){var p=arguments[0];return this.intersects(p.x,p.y)}}else if(arguments.length===2){if(arguments[0]instanceof je&&arguments[1]instanceof je){var g=arguments[0],w=arguments[1];if(this.isNull())return!1;var L=g.x<w.x?g.x:w.x;if(L>this._maxx)return!1;var V=g.x>w.x?g.x:w.x;if(V<this._minx)return!1;var X=g.y<w.y?g.y:w.y;if(X>this._maxy)return!1;var Q=g.y>w.y?g.y:w.y;return!(Q<this._miny)}if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var ae=arguments[0],Le=arguments[1];return!this.isNull()&&!(ae>this._maxx||ae<this._minx||Le>this._maxy||Le<this._miny)}}}},{key:"getMinY",value:function(){return this._miny}},{key:"getDiameter",value:function(){if(this.isNull())return 0;var c=this.getWidth(),p=this.getHeight();return Math.sqrt(c*c+p*p)}},{key:"getMinX",value:function(){return this._minx}},{key:"expandToInclude",value:function(){if(arguments.length===1){if(arguments[0]instanceof je){var c=arguments[0];this.expandToInclude(c.x,c.y)}else if(arguments[0]instanceof M){var p=arguments[0];if(p.isNull())return null;this.isNull()?(this._minx=p.getMinX(),this._maxx=p.getMaxX(),this._miny=p.getMinY(),this._maxy=p.getMaxY()):(p._minx<this._minx&&(this._minx=p._minx),p._maxx>this._maxx&&(this._maxx=p._maxx),p._miny<this._miny&&(this._miny=p._miny),p._maxy>this._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):(g<this._minx&&(this._minx=g),g>this._maxx&&(this._maxx=g),w<this._miny&&(this._miny=w),w>this._maxy&&(this._maxy=w))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var c=this.getWidth(),p=this.getHeight();return c<p?c:p}},{key:"getWidth",value:function(){return this.isNull()?0:this._maxx-this._minx}},{key:"compareTo",value:function(c){var p=c;return this.isNull()?p.isNull()?0:-1:p.isNull()?1:this._minx<p._minx?-1:this._minx>p._minx?1:this._miny<p._miny?-1:this._miny>p._miny?1:this._maxx<p._maxx?-1:this._maxx>p._maxx?1:this._maxy<p._maxy?-1:this._maxy>p._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._maxx<this._minx||c._miny>this._maxy||c._maxy<this._miny}},{key:"getHeight",value:function(){return this.isNull()?0:this._maxy-this._miny}},{key:"maxExtent",value:function(){if(this.isNull())return 0;var c=this.getWidth(),p=this.getHeight();return c>p?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];L<V?(this._minx=L,this._maxx=V):(this._minx=V,this._maxx=L),X<Q?(this._miny=X,this._maxy=Q):(this._miny=Q,this._maxy=X)}}},{key:"getMaxY",value:function(){return this._maxy}},{key:"distance",value:function(c){if(this.intersects(c))return 0;var p=0;this._maxx<c._minx?p=c._minx-this._maxx:this._minx>c._maxx&&(p=this._minx-c._maxx);var g=0;return this._maxy<c._miny?g=c._miny-this._maxy:this._miny>c._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.x<p.x?c.x:p.x)&&g.x<=(c.x>p.x?c.x:p.x)&&g.y>=(c.y<p.y?c.y:p.y)&&g.y<=(c.y>p.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)&&!(Ne<Q)&&(Q=Math.min(V.y,X.y),ae=Math.max(V.y,X.y),Le=Math.min(w.y,L.y),Ne=Math.max(w.y,L.y),!(Le>ae)&&!(Ne<Q))}}}]),M}(),gt=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"isGeometryCollection",value:function(){return this.getTypeCode()===M.TYPECODE_GEOMETRYCOLLECTION}},{key:"getFactory",value:function(){return this._factory}},{key:"getGeometryN",value:function(c){return this}},{key:"getArea",value:function(){return 0}},{key:"isRectangle",value:function(){return!1}},{key:"equalsExact",value:function(c){return this===c||this.equalsExact(c,0)}},{key:"geometryChanged",value:function(){this.apply(M.geometryChangedFilter)}},{key:"geometryChangedAction",value:function(){this._envelope=null}},{key:"equalsNorm",value:function(c){return c!==null&&this.norm().equalsExact(c.norm())}},{key:"getLength",value:function(){return 0}},{key:"getNumGeometries",value:function(){return 1}},{key:"compareTo",value:function(){var c;if(arguments.length===1){var p=arguments[0];return c=p,this.getTypeCode()!==c.getTypeCode()?this.getTypeCode()-c.getTypeCode():this.isEmpty()&&c.isEmpty()?0:this.isEmpty()?-1:c.isEmpty()?1:this.compareToSameClass(p)}if(arguments.length===2){var g=arguments[0],w=arguments[1];return c=g,this.getTypeCode()!==c.getTypeCode()?this.getTypeCode()-c.getTypeCode():this.isEmpty()&&c.isEmpty()?0:this.isEmpty()?-1:c.isEmpty()?1:this.compareToSameClass(g,w)}}},{key:"getUserData",value:function(){return this._userData}},{key:"getSRID",value:function(){return this._SRID}},{key:"getEnvelope",value:function(){return this.getFactory().toGeometry(this.getEnvelopeInternal())}},{key:"checkNotGeometryCollection",value:function(c){if(c.getTypeCode()===M.TYPECODE_GEOMETRYCOLLECTION)throw new we("This method does not support GeometryCollection arguments")}},{key:"equal",value:function(c,p,g){return g===0?c.equals(p):c.distance(p)<=g}},{key:"norm",value:function(){var c=this.copy();return c.normalize(),c}},{key:"reverse",value:function(){var c=this.reverseInternal();return this.envelope!=null&&(c.envelope=this.envelope.copy()),c.setSRID(this.getSRID()),c}},{key:"copy",value:function(){var c=this.copyInternal();return c.envelope=this._envelope==null?null:this._envelope.copy(),c._SRID=this._SRID,c._userData=this._userData,c}},{key:"getPrecisionModel",value:function(){return this._factory.getPrecisionModel()}},{key:"getEnvelopeInternal",value:function(){return this._envelope===null&&(this._envelope=this.computeEnvelopeInternal()),new bn(this._envelope)}},{key:"setSRID",value:function(c){this._SRID=c}},{key:"setUserData",value:function(c){this._userData=c}},{key:"compare",value:function(c,p){for(var g=c.iterator(),w=p.iterator();g.hasNext()&&w.hasNext();){var L=g.next(),V=w.next(),X=L.compareTo(V);if(X!==0)return X}return g.hasNext()?1:w.hasNext()?-1:0}},{key:"hashCode",value:function(){return this.getEnvelopeInternal().hashCode()}},{key:"isEquivalentClass",value:function(c){return this.getClass()===c.getClass()}},{key:"isGeometryCollectionOrDerived",value:function(){return this.getTypeCode()===M.TYPECODE_GEOMETRYCOLLECTION||this.getTypeCode()===M.TYPECODE_MULTIPOINT||this.getTypeCode()===M.TYPECODE_MULTILINESTRING||this.getTypeCode()===M.TYPECODE_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[Ve,ze,Ie]}},{key:"getClass",value:function(){return M}}],[{key:"hasNonEmptyElements",value:function(c){for(var p=0;p<c.length;p++)if(!c[p].isEmpty())return!0;return!1}},{key:"hasNullElements",value:function(c){for(var p=0;p<c.length;p++)if(c[p]===null)return!0;return!1}}]),M}();gt.constructor_=function(M){M&&(this._envelope=null,this._userData=null,this._factory=M,this._SRID=M.getSRID())},gt.TYPECODE_POINT=0,gt.TYPECODE_MULTIPOINT=1,gt.TYPECODE_LINESTRING=2,gt.TYPECODE_LINEARRING=3,gt.TYPECODE_MULTILINESTRING=4,gt.TYPECODE_POLYGON=5,gt.TYPECODE_MULTIPOLYGON=6,gt.TYPECODE_GEOMETRYCOLLECTION=7,gt.TYPENAME_POINT="Point",gt.TYPENAME_MULTIPOINT="MultiPoint",gt.TYPENAME_LINESTRING="LineString",gt.TYPENAME_LINEARRING="LinearRing",gt.TYPENAME_MULTILINESTRING="MultiLineString",gt.TYPENAME_POLYGON="Polygon",gt.TYPENAME_MULTIPOLYGON="MultiPolygon",gt.TYPENAME_GEOMETRYCOLLECTION="GeometryCollection",gt.geometryChangedFilter={get interfaces_(){return[Ue]},filter:function(M){M.geometryChangedAction()}};var Me=function(){function M(){s(this,M)}return h(M,null,[{key:"toLocationSymbol",value:function(c){switch(c){case M.EXTERIOR:return"e";case M.BOUNDARY:return"b";case M.INTERIOR:return"i";case M.NONE:return"-"}throw new we("Unknown location value: "+c)}}]),M}();Me.INTERIOR=0,Me.BOUNDARY=1,Me.EXTERIOR=2,Me.NONE=-1;var Fn=function(){function M(){s(this,M)}return h(M,[{key:"add",value:function(){}},{key:"addAll",value:function(){}},{key:"isEmpty",value:function(){}},{key:"iterator",value:function(){}},{key:"size",value:function(){}},{key:"toArray",value:function(){}},{key:"remove",value:function(){}}]),M}(),Si=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({NoSuchElementException:p})[0],w}return p}(be),yn=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({UnsupportedOperationException:p})[0],w}return p}(be),_i=function(M){f(p,M);var c=U(p);function p(){return s(this,p),c.apply(this,arguments)}return h(p,[{key:"contains",value:function(){}}]),p}(Fn),Yi=function(M,c){f(g,M);var p=U(g);function g(w){var L;return s(this,g),(L=p.call(this)).map=new Map,w instanceof Fn&&L.addAll(w),L}return h(g,[{key:"contains",value:function(w){var L=w.hashCode?w.hashCode():w;return!!this.map.has(L)}},{key:"add",value:function(w){var L=w.hashCode?w.hashCode():w;return!this.map.has(L)&&!!this.map.set(L,w)}},{key:"addAll",value:function(w){var L,V=te(w);try{for(V.s();!(L=V.n()).done;){var X=L.value;this.add(X)}}catch(Q){V.e(Q)}finally{V.f()}return!0}},{key:"remove",value:function(){throw new yn}},{key:"size",value:function(){return this.map.size}},{key:"isEmpty",value:function(){return this.map.size===0}},{key:"toArray",value:function(){return Array.from(this.map.values())}},{key:"iterator",value:function(){return new Hi(this.map)}},{key:c,value:function(){return this.map}}]),g}(_i,Symbol.iterator),Hi=function(){function M(c){s(this,M),this.iterator=c.values();var p=this.iterator.next(),g=p.done,w=p.value;this.done=g,this.value=w}return h(M,[{key:"next",value:function(){if(this.done)throw new Si;var c=this.value,p=this.iterator.next(),g=p.done,w=p.value;return this.done=g,this.value=w,c}},{key:"hasNext",value:function(){return!this.done}},{key:"remove",value:function(){throw new yn}}]),M}(),wt=function(){function M(){s(this,M)}return h(M,null,[{key:"opposite",value:function(c){return c===M.LEFT?M.RIGHT:c===M.RIGHT?M.LEFT:c}}]),M}();wt.ON=0,wt.LEFT=1,wt.RIGHT=2;var Wo=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({EmptyStackException:p})[0],w}return p}(be),zo=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({IndexOutOfBoundsException:p})[0],w}return p}(be),Fr=function(M){f(p,M);var c=U(p);function p(){return s(this,p),c.apply(this,arguments)}return h(p,[{key:"get",value:function(){}},{key:"set",value:function(){}},{key:"isEmpty",value:function(){}}]),p}(Fn),bo=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),(g=c.call(this)).array=[],g}return h(p,[{key:"add",value:function(g){return this.array.push(g),!0}},{key:"get",value:function(g){if(g<0||g>=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.value<c?-1:this.value>c?1:0}}],[{key:"compare",value:function(c,p){return c<p?-1:c>p?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._hi<c._hi||this._hi===c._hi&&this._lo<=c._lo}},{key:"extractSignificantDigits",value:function(c,p){var g=this.abs(),w=M.magnitude(g._hi),L=M.TEN.pow(w);(g=g.divide(L)).gt(M.TEN)?(g=g.divide(M.TEN),w+=1):g.lt(M.ONE)&&(g=g.multiply(M.TEN),w-=1);for(var V=w+1,X=new lo,Q=M.MAX_PRINT_DIGITS-1,ae=0;ae<=Q;ae++){c&&ae===V&&X.append(".");var Le=Math.trunc(g._hi);if(Le<0)break;var Ne=!1,rt=0;Le>9?(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._hi<p._hi?-1:this._hi>p._hi?1:this._lo<p._lo?-1:this._lo>p._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._hi<c._hi||this._hi===c._hi&&this._lo<c._lo}},{key:"add",value:function(){if(arguments[0]instanceof M){var c=arguments[0];return M.copy(this).selfAdd(c)}if(typeof arguments[0]=="number"){var p=arguments[0];return M.copy(this).selfAdd(p)}}},{key:"init",value:function(){if(arguments.length===1){if(typeof arguments[0]=="number"){var c=arguments[0];this._hi=c,this._lo=0}else if(arguments[0]instanceof M){var p=arguments[0];this._hi=p._hi,this._lo=p._lo}}else if(arguments.length===2){var g=arguments[0],w=arguments[1];this._hi=g,this._lo=w}}},{key:"gt",value:function(c){return this._hi>c._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 L=c.charAt(p);L!=="-"&&L!=="+"||(p++,L==="-"&&(w=!0))}for(var V=new M,X=0,Q=0,ae=0,Le=!1;!(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;w<p;w++)g.append(c);return g.toString()}}]),M}();tn.PI=new tn(3.141592653589793,12246467991473532e-32),tn.TWO_PI=new tn(6.283185307179586,24492935982947064e-32),tn.PI_2=new tn(1.5707963267948966,6123233995736766e-32),tn.E=new tn(2.718281828459045,14456468917292502e-32),tn.NaN=new tn(tt.NaN,tt.NaN),tn.EPS=123259516440783e-46,tn.SPLIT=134217729,tn.MAX_PRINT_DIGITS=32,tn.TEN=tn.valueOf(10),tn.ONE=tn.valueOf(1),tn.SCI_NOT_EXPONENT_CHAR="E",tn.SCI_NOT_ZERO="0.0E0";var as=function(){function M(){s(this,M)}return h(M,null,[{key:"orientationIndex",value:function(c,p,g){var w=M.orientationIndexFilter(c,p,g);if(w<=1)return w;var L=tn.valueOf(p.x).selfAdd(-c.x),V=tn.valueOf(p.y).selfAdd(-c.y),X=tn.valueOf(g.x).selfAdd(-p.x),Q=tn.valueOf(g.y).selfAdd(-p.y);return L.selfMultiply(Q).selfSubtract(V.selfMultiply(X)).signum()}},{key:"signOfDet2x2",value:function(){if(arguments[3]instanceof tn&&arguments[2]instanceof tn&&arguments[0]instanceof tn&&arguments[1]instanceof tn){var c=arguments[0],p=arguments[1],g=arguments[2],w=arguments[3],L=c.multiply(w).selfSubtract(p.multiply(g));return L.signum()}if(typeof arguments[3]=="number"&&typeof arguments[2]=="number"&&typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var V=arguments[0],X=arguments[1],Q=arguments[2],ae=arguments[3],Le=tn.valueOf(V),Ne=tn.valueOf(X),rt=tn.valueOf(Q),kt=tn.valueOf(ae),Ct=Le.multiply(kt).selfSubtract(Ne.multiply(rt));return Ct.signum()}}},{key:"intersection",value:function(c,p,g,w){var L=new tn(c.y).selfSubtract(p.y),V=new tn(p.x).selfSubtract(c.x),X=new tn(c.x).selfMultiply(p.y).selfSubtract(new tn(p.x).selfMultiply(c.y)),Q=new tn(g.y).selfSubtract(w.y),ae=new tn(w.x).selfSubtract(g.x),Le=new tn(g.x).selfMultiply(w.y).selfSubtract(new tn(w.x).selfMultiply(g.y)),Ne=V.multiply(Le).selfSubtract(ae.multiply(X)),rt=Q.multiply(X).selfSubtract(L.multiply(Le)),kt=L.multiply(ae).selfSubtract(Q.multiply(V)),Ct=Ne.selfDivide(kt).doubleValue(),Qt=rt.selfDivide(kt).doubleValue();return tt.isNaN(Ct)||tt.isInfinite(Ct)||tt.isNaN(Qt)||tt.isInfinite(Qt)?null:new je(Ct,Qt)}},{key:"orientationIndexFilter",value:function(c,p,g){var w=null,L=(c.x-g.x)*(p.y-g.y),V=(c.y-g.y)*(p.x-g.x),X=L-V;if(L>0){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._minIndex<c.length,"rightmost point expected to be interior vertex of edge");var p=c[this._minIndex-1],g=c[this._minIndex+1],w=sn.index(this._minCoord,g,p),L=!1;(p.y<this._minCoord.y&&g.y<this._minCoord.y&&w===sn.COUNTERCLOCKWISE||p.y>this._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].y<g[p+1].y&&(w=wt.RIGHT),w}},{key:"getEdge",value:function(){return this._orientedDe}},{key:"checkForRightmostCoordinate",value:function(c){for(var p=c.getEdge().getCoordinates(),g=0;g<p.length-1;g++)(this._minCoord===null||p[g].x>this._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<V;L++)if(this.array[L]===w)return!!this.array.splice(L,1);return!1}},{key:c,value:function(){return this.array.values()}}]),g}(Fr,Symbol.iterator),ls=function(){function M(c){s(this,M),this.arrayList=c,this.position=0}return h(M,[{key:"next",value:function(){if(this.position===this.arrayList.size())throw new Si;return this.arrayList.get(this.position++)}},{key:"hasNext",value:function(){return this.position<this.arrayList.size()}},{key:"set",value:function(c){return this.arrayList.set(this.position-1,c)}},{key:"remove",value:function(){this.arrayList.remove(this.arrayList.get(this.position))}}]),M}(),zs=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"clearVisitedEdges",value:function(){for(var c=this._dirEdgeList.iterator();c.hasNext();)c.next().setVisited(!1)}},{key:"getRightmostCoordinate",value:function(){return this._rightMostCoord}},{key:"computeNodeDepth",value:function(c){for(var p=null,g=c.getEdges().iterator();g.hasNext();){var w=g.next();if(w.isVisited()||w.getSym().isVisited()){p=w;break}}if(p===null)throw new vr("unable to find edge to compute depths at "+c.getCoordinate());c.getEdges().computeDepths(p);for(var L=c.getEdges().iterator();L.hasNext();){var V=L.next();V.setVisited(!0),this.copySymDepths(V)}}},{key:"computeDepth",value:function(c){this.clearVisitedEdges();var p=this._finder.getEdge();p.getNode(),p.getLabel(),p.setEdgeDepths(wt.RIGHT,c),this.copySymDepths(p),this.computeDepths(p)}},{key:"create",value:function(c){this.addReachable(c),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()}},{key:"findResultEdges",value:function(){for(var c=this._dirEdgeList.iterator();c.hasNext();){var p=c.next();p.getDepth(wt.RIGHT)>=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.x<p._rightMostCoord.x?-1:this._rightMostCoord.x>p._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;w<g.length-1;w++)c.expandToInclude(g[w]);this._env=c}return this._env}},{key:"addReachable",value:function(c){var p=new bo;for(p.add(c);!p.empty();){var g=p.pop();this.add(g,p)}}},{key:"copySymDepths",value:function(c){var p=c.getSym();p.setDepth(wt.LEFT,c.getDepth(wt.RIGHT)),p.setDepth(wt.RIGHT,c.getDepth(wt.LEFT))}},{key:"add",value:function(c,p){c.setVisited(!0),this._nodes.add(c);for(var g=c.getEdges().iterator();g.hasNext();){var w=g.next();this._dirEdgeList.add(w);var L=w.getSym().getNode();L.isVisited()||p.push(L)}}},{key:"getNodes",value:function(){return this._nodes}},{key:"getDirectedEdges",value:function(){return this._dirEdgeList}},{key:"interfaces_",get:function(){return[ze]}}],[{key:"constructor_",value:function(){this._finder=null,this._dirEdgeList=new nn,this._nodes=new nn,this._rightMostCoord=null,this._env=null,this._finder=new ra}}]),M}(),Os=function(){function M(){s(this,M)}return h(M,null,[{key:"intersection",value:function(c,p,g,w){var L=c.x<p.x?c.x:p.x,V=c.y<p.y?c.y:p.y,X=c.x>p.x?c.x:p.x,Q=c.y>p.y?c.y:p.y,ae=g.x<w.x?g.x:w.x,Le=g.y<w.y?g.y:w.y,Ne=g.x>w.x?g.x:w.x,rt=g.y>w.y?g.y:w.y,kt=((L>ae?L:ae)+(X<Ne?X:Ne))/2,Ct=((V>Le?V:Le)+(Q<rt?Q:rt))/2,Qt=c.x-kt,Ht=c.y-Ct,dn=p.x-kt,Rn=p.y-Ct,ui=g.x-kt,lr=g.y-Ct,Vi=w.x-kt,dr=w.y-Ct,Jr=Ht-Rn,So=dn-Qt,Dn=Qt*Rn-dn*Ht,Vo=lr-dr,ys=Vi-ui,va=ui*dr-Vi*lr,vs=Jr*ys-Vo*So,rl=(So*va-ys*Dn)/vs,js=(Vo*Dn-Jr*va)/vs;return tt.isNaN(rl)||tt.isInfinite(rl)||tt.isNaN(js)||tt.isInfinite(js)?null:new je(rl+kt,js+Ct)}}]),M}(),xe=function(){function M(){s(this,M)}return h(M,null,[{key:"arraycopy",value:function(c,p,g,w,L){for(var V=0,X=p;X<p+L;X++)g[w+V]=c[X],V++}},{key:"getProperty",value:function(c){return{"line.separator":`
|
|
|
`}[c]}}]),M}(),ee=function(){function M(){s(this,M)}return h(M,null,[{key:"log10",value:function(c){var p=Math.log(c);return tt.isInfinite(p)||tt.isNaN(p)?p:p/M.LOG_10}},{key:"min",value:function(c,p,g,w){var L=c;return p<L&&(L=p),g<L&&(L=g),w<L&&(L=w),L}},{key:"clamp",value:function(){if(typeof arguments[2]=="number"&&typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var c=arguments[0],p=arguments[1],g=arguments[2];return c<p?p:c>g?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 w<L?L:w>V?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;w<p.length-1;w++){var L=M.pointToSegment(c,p[w],p[w+1]);L<g&&(g=L)}return g}}]),M}(),ve=function(){function M(){s(this,M)}return h(M,[{key:"create",value:function(){if(arguments.length===1)arguments[0]instanceof Array||an(arguments[0],Ln);else if(arguments.length!==2){if(arguments.length===3){var c=arguments[0],p=arguments[1];return this.create(c,p)}}}}]),M}(),ke=function(){function M(){s(this,M)}return h(M,[{key:"filter",value:function(c){}}]),M}(),De=function(){function M(){s(this,M)}return h(M,null,[{key:"ofLine",value:function(c){var p=c.size();if(p<=1)return 0;var g=0,w=new je;c.getCoordinate(0,w);for(var L=w.x,V=w.y,X=1;X<p;X++){c.getCoordinate(X,w);var Q=w.x,ae=w.y,Le=Q-L,Ne=ae-V;g+=Math.sqrt(Le*Le+Ne*Ne),L=Q,V=ae}return g}}]),M}(),Ge=function M(){s(this,M)},Fe=function(){function M(){s(this,M)}return h(M,null,[{key:"copyCoord",value:function(c,p,g,w){for(var L=Math.min(c.getDimension(),g.getDimension()),V=0;V<L;V++)g.setOrdinate(w,V,c.getOrdinate(p,V))}},{key:"isRing",value:function(c){var p=c.size();return p===0||!(p<=3)&&c.getOrdinate(0,Ln.X)===c.getOrdinate(p-1,Ln.X)&&c.getOrdinate(0,Ln.Y)===c.getOrdinate(p-1,Ln.Y)}},{key:"scroll",value:function(){if(arguments.length===2){if(an(arguments[0],Ln)&&Number.isInteger(arguments[1])){var c=arguments[0],p=arguments[1];M.scroll(c,p,M.isRing(c))}else if(an(arguments[0],Ln)&&arguments[1]instanceof je){var g=arguments[0],w=arguments[1],L=M.indexOf(w,g);if(L<=0)return null;M.scroll(g,L)}}else if(arguments.length===3){var V=arguments[0],X=arguments[1],Q=arguments[2],ae=X;if(ae<=0)return null;for(var Le=V.copy(),Ne=Q?V.size()-1:V.size(),rt=0;rt<Ne;rt++)for(var kt=0;kt<V.getDimension();kt++)V.setOrdinate(rt,kt,Le.getOrdinate((X+rt)%Ne,kt));if(Q)for(var Ct=0;Ct<V.getDimension();Ct++)V.setOrdinate(Ne,Ct,V.getOrdinate(0,Ct))}}},{key:"isEqual",value:function(c,p){var g=c.size();if(g!==p.size())return!1;for(var w=Math.min(c.getDimension(),p.getDimension()),L=0;L<g;L++)for(var V=0;V<w;V++){var X=c.getOrdinate(L,V),Q=p.getOrdinate(L,V);if(c.getOrdinate(L,V)!==p.getOrdinate(L,V)&&(!tt.isNaN(X)||!tt.isNaN(Q)))return!1}return!0}},{key:"minCoordinateIndex",value:function(){if(arguments.length===1){var c=arguments[0];return M.minCoordinateIndex(c,0,c.size()-1)}if(arguments.length===3){for(var p=arguments[0],g=arguments[1],w=arguments[2],L=-1,V=null,X=g;X<=w;X++){var Q=p.getCoordinate(X);(V===null||V.compareTo(Q)>0)&&(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;V<g;V++)M.copy(p,L-1,w,V,1);return w}},{key:"reverse",value:function(c){for(var p=c.size()-1,g=Math.trunc(p/2),w=0;w<=g;w++)M.swap(c,w,p-w)}},{key:"swap",value:function(c,p,g){if(p===g)return null;for(var w=0;w<c.getDimension();w++){var L=c.getOrdinate(p,w);c.setOrdinate(p,w,c.getOrdinate(g,w)),c.setOrdinate(g,w,L)}}},{key:"copy",value:function(c,p,g,w,L){for(var V=0;V<L;V++)M.copyCoord(c,p+V,g,w+V)}},{key:"ensureValidRing",value:function(c,p){var g=p.size();return g===0?p:g<=3?M.createClosedRing(c,p,4):p.getOrdinate(0,Ln.X)===p.getOrdinate(g-1,Ln.X)&&p.getOrdinate(0,Ln.Y)===p.getOrdinate(g-1,Ln.Y)?p:M.createClosedRing(c,p,g+1)}},{key:"indexOf",value:function(c,p){for(var g=0;g<p.size();g++)if(c.x===p.getOrdinate(g,Ln.X)&&c.y===p.getOrdinate(g,Ln.Y))return g;return-1}},{key:"createClosedRing",value:function(c,p,g){var w=c.create(g,p.getDimension()),L=p.size();M.copy(p,0,w,0,L);for(var V=L;V<g;V++)M.copy(p,0,w,V,1);return w}},{key:"minCoordinate",value:function(c){for(var p=null,g=0;g<c.size();g++){var w=c.getCoordinate(g);(p===null||p.compareTo(w)>0)&&(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;V<this._points.size();V++)if(!this.equal(this._points.getCoordinate(V),L._points.getCoordinate(V),w))return!1;return!0}return Z(x(p.prototype),"equalsExact",this).apply(this,arguments)}},{key:"normalize",value:function(){for(var g=0;g<Math.trunc(this._points.size()/2);g++){var w=this._points.size()-1-g;if(!this._points.getCoordinate(g).equals(this._points.getCoordinate(w))){if(this._points.getCoordinate(g).compareTo(this._points.getCoordinate(w))>0){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<this._points.size()&&V<w._points.size();){var X=this._points.getCoordinate(L).compareTo(w._points.getCoordinate(V));if(X!==0)return X;L++,V++}return L<this._points.size()?1:V<w._points.size()?-1:0}if(arguments.length===2){var Q=arguments[0],ae=arguments[1],Le=Q;return ae.compare(this._points,Le._points)}}},{key:"apply",value:function(){if(an(arguments[0],ke))for(var g=arguments[0],w=0;w<this._points.size();w++)g.filter(this._points.getCoordinate(w));else if(an(arguments[0],xt)){var L=arguments[0];if(this._points.size()===0)return null;for(var V=0;V<this._points.size()&&(L.filter(this._points,V),!L.isDone());V++);L.isGeometryChanged()&&this.geometryChanged()}else if(an(arguments[0],Ye)){var X=arguments[0];X.filter(this)}else if(an(arguments[0],Ue)){var Q=arguments[0];Q.filter(this)}}},{key:"getBoundary",value:function(){throw new yn}},{key:"isEquivalentClass",value:function(g){return g instanceof p}},{key:"getCoordinateN",value:function(g){return this._points.getCoordinate(g)}},{key:"getGeometryType",value:function(){return gt.TYPENAME_LINESTRING}},{key:"getCoordinateSequence",value:function(){return this._points}},{key:"isEmpty",value:function(){return this._points.size()===0}},{key:"init",value:function(g){if(g===null&&(g=this.getFactory().getCoordinateSequenceFactory().create([])),g.size()===1)throw new we("Invalid number of points in LineString (found "+g.size()+" - must be 0 or >= 2)");this._points=g}},{key:"isCoordinate",value:function(g){for(var w=0;w<this._points.size();w++)if(this._points.getCoordinate(w).equals(g))return!0;return!1}},{key:"getStartPoint",value:function(){return this.isEmpty()?null:this.getPointN(0)}},{key:"getPointN",value:function(g){return this.getFactory().createPoint(this._points.getCoordinate(g))}},{key:"interfaces_",get:function(){return[Ge]}}],[{key:"constructor_",value:function(){if(this._points=null,arguments.length!==0){if(arguments.length===2){var g=arguments[0],w=arguments[1];gt.constructor_.call(this,w),this.init(g)}}}}]),p}(gt),_t=function M(){s(this,M)},ln=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(){if(this.isEmpty())return new bn;var g=new bn;return g.expandToInclude(this._coordinates.getX(0),this._coordinates.getY(0)),g}},{key:"getCoordinates",value:function(){return this.isEmpty()?[]:[this.getCoordinate()]}},{key:"copyInternal",value:function(){return new p(this._coordinates.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];return!!this.isEquivalentClass(g)&&(!(!this.isEmpty()||!g.isEmpty())||this.isEmpty()===g.isEmpty()&&this.equal(g.getCoordinate(),this.getCoordinate(),w))}return Z(x(p.prototype),"equalsExact",this).apply(this,arguments)}},{key:"normalize",value:function(){}},{key:"getCoordinate",value:function(){return this._coordinates.size()!==0?this._coordinates.getCoordinate(0):null}},{key:"getBoundaryDimension",value:function(){return me.FALSE}},{key:"reverseInternal",value:function(){return this.getFactory().createPoint(this._coordinates.copy())}},{key:"getTypeCode",value:function(){return gt.TYPECODE_POINT}},{key:"getDimension",value:function(){return 0}},{key:"getNumPoints",value:function(){return this.isEmpty()?0:1}},{key:"getX",value:function(){if(this.getCoordinate()===null)throw new IllegalStateException("getX called on empty Point");return this.getCoordinate().x}},{key:"compareToSameClass",value:function(){if(arguments.length===1){var g=arguments[0],w=g;return this.getCoordinate().compareTo(w.getCoordinate())}if(arguments.length===2){var L=arguments[0],V=arguments[1],X=L;return V.compare(this._coordinates,X._coordinates)}}},{key:"apply",value:function(){if(an(arguments[0],ke)){var g=arguments[0];if(this.isEmpty())return null;g.filter(this.getCoordinate())}else if(an(arguments[0],xt)){var w=arguments[0];if(this.isEmpty())return null;w.filter(this._coordinates,0),w.isGeometryChanged()&&this.geometryChanged()}else if(an(arguments[0],Ye)){var L=arguments[0];L.filter(this)}else if(an(arguments[0],Ue)){var V=arguments[0];V.filter(this)}}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return gt.TYPENAME_POINT}},{key:"getCoordinateSequence",value:function(){return this._coordinates}},{key:"getY",value:function(){if(this.getCoordinate()===null)throw new IllegalStateException("getY called on empty Point");return this.getCoordinate().y}},{key:"isEmpty",value:function(){return this._coordinates.size()===0}},{key:"init",value:function(g){g===null&&(g=this.getFactory().getCoordinateSequenceFactory().create([])),St.isTrue(g.size()<=1),this._coordinates=g}},{key:"isSimple",value:function(){return!0}},{key:"interfaces_",get:function(){return[_t]}}],[{key:"constructor_",value:function(){this._coordinates=null;var g=arguments[0],w=arguments[1];gt.constructor_.call(this,w),this.init(g)}}]),p}(gt),wn=function(){function M(){s(this,M)}return h(M,null,[{key:"ofRing",value:function(){if(arguments[0]instanceof Array){var c=arguments[0];return Math.abs(M.ofRingSigned(c))}if(an(arguments[0],Ln)){var p=arguments[0];return Math.abs(M.ofRingSigned(p))}}},{key:"ofRingSigned",value:function(){if(arguments[0]instanceof Array){var c=arguments[0];if(c.length<3)return 0;for(var p=0,g=c[0].x,w=1;w<c.length-1;w++){var L=c[w].x-g,V=c[w+1].y,X=c[w-1].y;p+=L*(X-V)}return p/2}if(an(arguments[0],Ln)){var Q=arguments[0],ae=Q.size();if(ae<3)return 0;var Le=new je,Ne=new je,rt=new je;Q.getCoordinate(0,Ne),Q.getCoordinate(1,rt);var kt=Ne.x;rt.x-=kt;for(var Ct=0,Qt=1;Qt<ae-1;Qt++)Le.y=Ne.y,Ne.x=rt.x,Ne.y=rt.y,Q.getCoordinate(Qt+1,rt),rt.x-=kt,Ct+=Ne.x*(Le.y-rt.y);return Ct/2}}}]),M}(),on=function(){function M(){s(this,M)}return h(M,null,[{key:"sort",value:function(){var c=arguments,p=arguments[0];if(arguments.length===1)p.sort(function(kt,Ct){return kt.compareTo(Ct)});else if(arguments.length===2)p.sort(function(kt,Ct){return c[1].compare(kt,Ct)});else if(arguments.length===3){var g=p.slice(arguments[1],arguments[2]);g.sort();var w=p.slice(0,arguments[1]).concat(g,p.slice(arguments[2],p.length));p.splice(0,p.length);var L,V=te(w);try{for(V.s();!(L=V.n()).done;){var X=L.value;p.push(X)}}catch(kt){V.e(kt)}finally{V.f()}}else if(arguments.length===4){var Q=p.slice(arguments[1],arguments[2]);Q.sort(function(kt,Ct){return c[3].compare(kt,Ct)});var ae=p.slice(0,arguments[1]).concat(Q,p.slice(arguments[2],p.length));p.splice(0,p.length);var Le,Ne=te(ae);try{for(Ne.s();!(Le=Ne.n()).done;){var rt=Le.value;p.push(rt)}}catch(kt){Ne.e(kt)}finally{Ne.f()}}}},{key:"asList",value:function(c){var p,g=new nn,w=te(c);try{for(w.s();!(p=w.n()).done;){var L=p.value;g.add(L)}}catch(V){w.e(V)}finally{w.f()}return g}},{key:"copyOf",value:function(c,p){return c.slice(0,p)}}]),M}(),En=function M(){s(this,M)},Sn=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._shell.getEnvelopeInternal()}},{key:"getCoordinates",value:function(){if(this.isEmpty())return[];for(var g=new Array(this.getNumPoints()).fill(null),w=-1,L=this._shell.getCoordinates(),V=0;V<L.length;V++)g[++w]=L[V];for(var X=0;X<this._holes.length;X++)for(var Q=this._holes[X].getCoordinates(),ae=0;ae<Q.length;ae++)g[++w]=Q[ae];return g}},{key:"getArea",value:function(){var g=0;g+=wn.ofRing(this._shell.getCoordinateSequence());for(var w=0;w<this._holes.length;w++)g-=wn.ofRing(this._holes[w].getCoordinateSequence());return g}},{key:"copyInternal",value:function(){for(var g=this._shell.copy(),w=new Array(this._holes.length).fill(null),L=0;L<this._holes.length;L++)w[L]=this._holes[L].copy();return new p(g,w,this._factory)}},{key:"isRectangle",value:function(){if(this.getNumInteriorRing()!==0||this._shell===null||this._shell.getNumPoints()!==5)return!1;for(var g=this._shell.getCoordinateSequence(),w=this.getEnvelopeInternal(),L=0;L<5;L++){var V=g.getX(L);if(V!==w.getMinX()&&V!==w.getMaxX())return!1;var X=g.getY(L);if(X!==w.getMinY()&&X!==w.getMaxY())return!1}for(var Q=g.getX(0),ae=g.getY(0),Le=1;Le<=4;Le++){var Ne=g.getX(Le),rt=g.getY(Le);if(Ne!==Q==(rt!==ae))return!1;Q=Ne,ae=rt}return!0}},{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,V=this._shell,X=L._shell;if(!V.equalsExact(X,w)||this._holes.length!==L._holes.length)return!1;for(var Q=0;Q<this._holes.length;Q++)if(!this._holes[Q].equalsExact(L._holes[Q],w))return!1;return!0}return Z(x(p.prototype),"equalsExact",this).apply(this,arguments)}},{key:"normalize",value:function(){if(arguments.length===0){this._shell=this.normalized(this._shell,!0);for(var g=0;g<this._holes.length;g++)this._holes[g]=this.normalized(this._holes[g],!1);on.sort(this._holes)}else if(arguments.length===2){var w=arguments[0],L=arguments[1];if(w.isEmpty())return null;var V=w.getCoordinateSequence(),X=Fe.minCoordinateIndex(V,0,V.size()-2);Fe.scroll(V,X,!0),sn.isCCW(V)===L&&Fe.reverse(V)}}},{key:"getCoordinate",value:function(){return this._shell.getCoordinate()}},{key:"getNumInteriorRing",value:function(){return this._holes.length}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"reverseInternal",value:function(){for(var g=this.getExteriorRing().reverse(),w=new Array(this.getNumInteriorRing()).fill(null),L=0;L<w.length;L++)w[L]=this.getInteriorRingN(L).reverse();return this.getFactory().createPolygon(g,w)}},{key:"getTypeCode",value:function(){return gt.TYPECODE_POLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getLength",value:function(){var g=0;g+=this._shell.getLength();for(var w=0;w<this._holes.length;w++)g+=this._holes[w].getLength();return g}},{key:"getNumPoints",value:function(){for(var g=this._shell.getNumPoints(),w=0;w<this._holes.length;w++)g+=this._holes[w].getNumPoints();return g}},{key:"convexHull",value:function(){return this.getExteriorRing().convexHull()}},{key:"normalized",value:function(g,w){var L=g.copy();return this.normalize(L,w),L}},{key:"compareToSameClass",value:function(){if(arguments.length===1){var g=arguments[0],w=this._shell,L=g._shell;return w.compareToSameClass(L)}if(arguments.length===2){var V=arguments[0],X=arguments[1],Q=V,ae=this._shell,Le=Q._shell,Ne=ae.compareToSameClass(Le,X);if(Ne!==0)return Ne;for(var rt=this.getNumInteriorRing(),kt=Q.getNumInteriorRing(),Ct=0;Ct<rt&&Ct<kt;){var Qt=this.getInteriorRingN(Ct),Ht=Q.getInteriorRingN(Ct),dn=Qt.compareToSameClass(Ht,X);if(dn!==0)return dn;Ct++}return Ct<rt?1:Ct<kt?-1:0}}},{key:"apply",value:function(){if(an(arguments[0],ke)){var g=arguments[0];this._shell.apply(g);for(var w=0;w<this._holes.length;w++)this._holes[w].apply(g)}else if(an(arguments[0],xt)){var L=arguments[0];if(this._shell.apply(L),!L.isDone())for(var V=0;V<this._holes.length&&(this._holes[V].apply(L),!L.isDone());V++);L.isGeometryChanged()&&this.geometryChanged()}else if(an(arguments[0],Ye)){var X=arguments[0];X.filter(this)}else if(an(arguments[0],Ue)){var Q=arguments[0];Q.filter(this),this._shell.apply(Q);for(var ae=0;ae<this._holes.length;ae++)this._holes[ae].apply(Q)}}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();var g=new Array(this._holes.length+1).fill(null);g[0]=this._shell;for(var w=0;w<this._holes.length;w++)g[w+1]=this._holes[w];return g.length<=1?this.getFactory().createLinearRing(g[0].getCoordinateSequence()):this.getFactory().createMultiLineString(g)}},{key:"getGeometryType",value:function(){return gt.TYPENAME_POLYGON}},{key:"getExteriorRing",value:function(){return this._shell}},{key:"isEmpty",value:function(){return this._shell.isEmpty()}},{key:"getInteriorRingN",value:function(g){return this._holes[g]}},{key:"interfaces_",get:function(){return[En]}}],[{key:"constructor_",value:function(){this._shell=null,this._holes=null;var g=arguments[0],w=arguments[1],L=arguments[2];if(gt.constructor_.call(this,L),g===null&&(g=this.getFactory().createLinearRing()),w===null&&(w=[]),gt.hasNullElements(w))throw new we("holes must not contain null elements");if(g.isEmpty()&>.hasNonEmptyElements(w))throw new we("shell is empty but holes are not");this._shell=g,this._holes=w}}]),p}(gt),yi=function(M){f(p,M);var c=U(p);function p(){return s(this,p),c.apply(this,arguments)}return p}(_i),ki=function(M){f(p,M);var c=U(p);function p(g){var w;return s(this,p),(w=c.call(this)).array=[],g instanceof Fn&&w.addAll(g),w}return h(p,[{key:"contains",value:function(g){var w,L=te(this.array);try{for(L.s();!(w=L.n()).done;)if(w.value.compareTo(g)===0)return!0}catch(V){L.e(V)}finally{L.f()}return!1}},{key:"add",value:function(g){if(this.contains(g))return!1;for(var w=0,L=this.array.length;w<L;w++)if(this.array[w].compareTo(g)===1)return!!this.array.splice(w,0,g);return this.array.push(g),!0}},{key:"addAll",value:function(g){var w,L=te(g);try{for(L.s();!(w=L.n()).done;){var V=w.value;this.add(V)}}catch(X){L.e(X)}finally{L.f()}return!0}},{key:"remove",value:function(){throw new yn}},{key:"size",value:function(){return this.array.length}},{key:"isEmpty",value:function(){return this.array.length===0}},{key:"toArray",value:function(){return this.array.slice()}},{key:"iterator",value:function(){return new hr(this.array)}}]),p}(yi),hr=function(){function M(c){s(this,M),this.array=c,this.position=0}return h(M,[{key:"next",value:function(){if(this.position===this.array.length)throw new Si;return this.array[this.position++]}},{key:"hasNext",value:function(){return this.position<this.array.length}},{key:"remove",value:function(){throw new yn}}]),M}(),$n=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(){for(var g=new bn,w=0;w<this._geometries.length;w++)g.expandToInclude(this._geometries[w].getEnvelopeInternal());return g}},{key:"getGeometryN",value:function(g){return this._geometries[g]}},{key:"getCoordinates",value:function(){for(var g=new Array(this.getNumPoints()).fill(null),w=-1,L=0;L<this._geometries.length;L++)for(var V=this._geometries[L].getCoordinates(),X=0;X<V.length;X++)g[++w]=V[X];return g}},{key:"getArea",value:function(){for(var g=0,w=0;w<this._geometries.length;w++)g+=this._geometries[w].getArea();return g}},{key:"copyInternal",value:function(){for(var g=new Array(this._geometries.length).fill(null),w=0;w<g.length;w++)g[w]=this._geometries[w].copy();return new p(g,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._geometries.length!==L._geometries.length)return!1;for(var V=0;V<this._geometries.length;V++)if(!this._geometries[V].equalsExact(L._geometries[V],w))return!1;return!0}return Z(x(p.prototype),"equalsExact",this).apply(this,arguments)}},{key:"normalize",value:function(){for(var g=0;g<this._geometries.length;g++)this._geometries[g].normalize();on.sort(this._geometries)}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._geometries[0].getCoordinate()}},{key:"getBoundaryDimension",value:function(){for(var g=me.FALSE,w=0;w<this._geometries.length;w++)g=Math.max(g,this._geometries[w].getBoundaryDimension());return g}},{key:"reverseInternal",value:function(){for(var g=this._geometries.length,w=new nn(g),L=0;L<g;L++)w.add(this._geometries[L].reverse());return this.getFactory().buildGeometry(w)}},{key:"getTypeCode",value:function(){return gt.TYPECODE_GEOMETRYCOLLECTION}},{key:"getDimension",value:function(){for(var g=me.FALSE,w=0;w<this._geometries.length;w++)g=Math.max(g,this._geometries[w].getDimension());return g}},{key:"getLength",value:function(){for(var g=0,w=0;w<this._geometries.length;w++)g+=this._geometries[w].getLength();return g}},{key:"getNumPoints",value:function(){for(var g=0,w=0;w<this._geometries.length;w++)g+=this._geometries[w].getNumPoints();return g}},{key:"getNumGeometries",value:function(){return this._geometries.length}},{key:"compareToSameClass",value:function(){if(arguments.length===1){var g=arguments[0],w=new ki(on.asList(this._geometries)),L=new ki(on.asList(g._geometries));return this.compare(w,L)}if(arguments.length===2){for(var V=arguments[0],X=arguments[1],Q=V,ae=this.getNumGeometries(),Le=Q.getNumGeometries(),Ne=0;Ne<ae&&Ne<Le;){var rt=this.getGeometryN(Ne),kt=Q.getGeometryN(Ne),Ct=rt.compareToSameClass(kt,X);if(Ct!==0)return Ct;Ne++}return Ne<ae?1:Ne<Le?-1:0}}},{key:"apply",value:function(){if(an(arguments[0],ke))for(var g=arguments[0],w=0;w<this._geometries.length;w++)this._geometries[w].apply(g);else if(an(arguments[0],xt)){var L=arguments[0];if(this._geometries.length===0)return null;for(var V=0;V<this._geometries.length&&(this._geometries[V].apply(L),!L.isDone());V++);L.isGeometryChanged()&&this.geometryChanged()}else if(an(arguments[0],Ye)){var X=arguments[0];X.filter(this);for(var Q=0;Q<this._geometries.length;Q++)this._geometries[Q].apply(X)}else if(an(arguments[0],Ue)){var ae=arguments[0];ae.filter(this);for(var Le=0;Le<this._geometries.length;Le++)this._geometries[Le].apply(ae)}}},{key:"getBoundary",value:function(){return gt.checkNotGeometryCollection(this),St.shouldNeverReachHere(),null}},{key:"getGeometryType",value:function(){return gt.TYPENAME_GEOMETRYCOLLECTION}},{key:"isEmpty",value:function(){for(var g=0;g<this._geometries.length;g++)if(!this._geometries[g].isEmpty())return!1;return!0}}],[{key:"constructor_",value:function(){if(this._geometries=null,arguments.length!==0){if(arguments.length===2){var g=arguments[0],w=arguments[1];if(gt.constructor_.call(this,w),g===null&&(g=[]),gt.hasNullElements(g))throw new we("geometries must not contain null elements");this._geometries=g}}}}]),p}(gt),$r=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<g.length;w++)g[w]=this._geometries[w].copy();return new p(g,this._factory)}},{key:"isValid",value:function(){return!0}},{key:"equalsExact",value:function(){if(arguments.length===2&&typeof arguments[1]=="number"&&arguments[0]instanceof gt){var g=arguments[0],w=arguments[1];return!!this.isEquivalentClass(g)&&Z(x(p.prototype),"equalsExact",this).call(this,g,w)}return Z(x(p.prototype),"equalsExact",this).apply(this,arguments)}},{key:"getCoordinate",value:function(){if(arguments.length===1&&Number.isInteger(arguments[0])){var g=arguments[0];return this._geometries[g].getCoordinate()}return Z(x(p.prototype),"getCoordinate",this).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return me.FALSE}},{key:"getTypeCode",value:function(){return gt.TYPECODE_MULTIPOINT}},{key:"getDimension",value:function(){return 0}},{key:"getBoundary",value:function(){return this.getFactory().createGeometryCollection()}},{key:"getGeometryType",value:function(){return gt.TYPENAME_MULTIPOINT}},{key:"interfaces_",get:function(){return[_t]}}],[{key:"constructor_",value:function(){var g=arguments[0],w=arguments[1];$n.constructor_.call(this,g,w)}}]),p}($n),Ci=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(){return new p(this._points.copy(),this._factory)}},{key:"getBoundaryDimension",value:function(){return me.FALSE}},{key:"isClosed",value:function(){return!!this.isEmpty()||Z(x(p.prototype),"isClosed",this).call(this)}},{key:"reverseInternal",value:function(){var g=this._points.copy();return Fe.reverse(g),this.getFactory().createLinearRing(g)}},{key:"getTypeCode",value:function(){return gt.TYPECODE_LINEARRING}},{key:"validateConstruction",value:function(){if(!this.isEmpty()&&!Z(x(p.prototype),"isClosed",this).call(this))throw new we("Points of LinearRing do not form a closed linestring");if(this.getCoordinateSequence().size()>=1&&this.getCoordinateSequence().size()<p.MINIMUM_VALID_SIZE)throw new we("Invalid number of points in LinearRing (found "+this.getCoordinateSequence().size()+" - must be 0 or >= 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<this.size();w++)g.add(w,this.get(w).clone());return g}},{key:"toCoordinateArray",value:function(){if(arguments.length===0)return this.toArray(p.coordArrayType);if(arguments.length===1){var g=arguments[0];if(g)return this.toArray(p.coordArrayType);for(var w=this.size(),L=new Array(w).fill(null),V=0;V<w;V++)L[V]=this.get(w-V-1);return L}}},{key:"add",value:function(){if(arguments.length===1){var g=arguments[0];return Z(x(p.prototype),"add",this).call(this,g)}if(arguments.length===2){if(arguments[0]instanceof Array&&typeof arguments[1]=="boolean"){var w=arguments[0],L=arguments[1];return this.add(w,L,!0),!0}if(arguments[0]instanceof je&&typeof arguments[1]=="boolean"){var V=arguments[0],X=arguments[1];if(!X&&this.size()>=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<Ne.length;Ct++)this.add(Ne[Ct],rt);else for(var Qt=Ne.length-1;Qt>=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(Ht<ui){var Vi=this.get(Ht);if(Vi.equals2D(dn))return null}}}Z(x(p.prototype),"add",this).call(this,Ht,dn)}}else if(arguments.length===4){var dr=arguments[0],Jr=arguments[1],So=arguments[2],Dn=arguments[3],Vo=1;So>Dn&&(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.length;g++){var w=c[g];if(M.indexOf(w,p)<0)return w}return null}},{key:"scroll",value:function(c,p){var g=M.indexOf(p,c);if(g<0)return null;var w=new Array(c.length).fill(null);xe.arraycopy(c,g,w,0,c.length-g),xe.arraycopy(c,0,w,c.length-g,g),xe.arraycopy(w,0,c,0,c.length)}},{key:"equals",value:function(){if(arguments.length===2){var c=arguments[0],p=arguments[1];if(c===p)return!0;if(c===null||p===null||c.length!==p.length)return!1;for(var g=0;g<c.length;g++)if(!c[g].equals(p[g]))return!1;return!0}if(arguments.length===3){var w=arguments[0],L=arguments[1],V=arguments[2];if(w===L)return!0;if(w===null||L===null||w.length!==L.length)return!1;for(var X=0;X<w.length;X++)if(V.compare(w[X],L[X])!==0)return!1;return!0}}},{key:"intersection",value:function(c,p){for(var g=new On,w=0;w<c.length;w++)p.intersects(c[w])&&g.add(c[w],!0);return g.toCoordinateArray()}},{key:"measures",value:function(c){if(c===null||c.length===0)return 0;var p,g=0,w=te(c);try{for(w.s();!(p=w.n()).done;){var L=p.value;g=Math.max(g,oa.measures(L))}}catch(V){w.e(V)}finally{w.f()}return g}},{key:"hasRepeatedPoints",value:function(c){for(var p=1;p<c.length;p++)if(c[p-1].equals(c[p]))return!0;return!1}},{key:"removeRepeatedPoints",value:function(c){return M.hasRepeatedPoints(c)?new On(c,!1).toCoordinateArray():c}},{key:"reverse",value:function(c){for(var p=c.length-1,g=Math.trunc(p/2),w=0;w<=g;w++){var L=c[w];c[w]=c[p-w],c[p-w]=L}}},{key:"removeNull",value:function(c){for(var p=0,g=0;g<c.length;g++)c[g]!==null&&p++;var w=new Array(p).fill(null);if(p===0)return w;for(var L=0,V=0;V<c.length;V++)c[V]!==null&&(w[L++]=c[V]);return w}},{key:"copyDeep",value:function(){if(arguments.length===1){for(var c=arguments[0],p=new Array(c.length).fill(null),g=0;g<c.length;g++)p[g]=c[g].copy();return p}if(arguments.length===5)for(var w=arguments[0],L=arguments[1],V=arguments[2],X=arguments[3],Q=arguments[4],ae=0;ae<Q;ae++)V[X+ae]=w[L+ae].copy()}},{key:"isEqualReversed",value:function(c,p){for(var g=0;g<c.length;g++){var w=c[g],L=p[c.length-g-1];if(w.compareTo(L)!==0)return!1}return!0}},{key:"envelope",value:function(c){for(var p=new bn,g=0;g<c.length;g++)p.expandToInclude(c[g]);return p}},{key:"toCoordinateArray",value:function(c){return c.toArray(M.coordArrayType)}},{key:"dimension",value:function(c){if(c===null||c.length===0)return 3;var p,g=0,w=te(c);try{for(w.s();!(p=w.n()).done;){var L=p.value;g=Math.max(g,oa.dimension(L))}}catch(V){w.e(V)}finally{w.f()}return g}},{key:"atLeastNCoordinatesOrNothing",value:function(c,p){return p.length>=c?p:[]}},{key:"indexOf",value:function(c,p){for(var g=0;g<p.length;g++)if(c.equals(p[g]))return g;return-1}},{key:"increasingDirection",value:function(c){for(var p=0;p<Math.trunc(c.length/2);p++){var g=c.length-1-p,w=c[p].compareTo(c[g]);if(w!==0)return w}return 1}},{key:"compare",value:function(c,p){for(var g=0;g<c.length&&g<p.length;){var w=c[g].compareTo(p[g]);if(w!==0)return w;g++}return g<p.length?-1:g<c.length?1:0}},{key:"minCoordinate",value:function(c){for(var p=null,g=0;g<c.length;g++)(p===null||p.compareTo(c[g])>0)&&(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),g<p&&(w=0);var L=new Array(w).fill(null);if(w===0)return L;for(var V=0,X=p;X<=g;X++)L[V++]=c[X];return L}}]),M}(),sa=function(){function M(){s(this,M)}return h(M,[{key:"compare",value:function(c,p){var g=c,w=p;return Ri.compare(g,w)}},{key:"interfaces_",get:function(){return[Bt]}}]),M}(),Ll=function(){function M(){s(this,M)}return h(M,[{key:"compare",value:function(c,p){var g=c,w=p;if(g.length<w.length)return-1;if(g.length>w.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.length<w.length)return-1;if(g.length>w.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;ae<g.length;ae++){var Le=g[X].compareTo(w[Q]);if(Le!==0)return Le;X+=L,Q+=V}return 0}},{key:"interfaces_",get:function(){return[Bt]}}]),M}();Ri.ForwardComparator=sa,Ri.BidirectionalComparator=Ll,Ri.coordArrayType=new Array(0).fill(null);var us=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}(),Sr=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getM",value:function(c){return this.hasM()?this._coordinates[c].getM():tt.NaN}},{key:"setOrdinate",value:function(c,p,g){switch(p){case Ln.X:this._coordinates[c].x=g;break;case Ln.Y:this._coordinates[c].y=g;break;default:this._coordinates[c].setOrdinate(p,g)}}},{key:"getZ",value:function(c){return this.hasZ()?this._coordinates[c].getZ():tt.NaN}},{key:"size",value:function(){return this._coordinates.length}},{key:"getOrdinate",value:function(c,p){switch(p){case Ln.X:return this._coordinates[c].x;case Ln.Y:return this._coordinates[c].y;default:return this._coordinates[c].getOrdinate(p)}}},{key:"getCoordinate",value:function(){if(arguments.length===1){var c=arguments[0];return this._coordinates[c]}if(arguments.length===2){var p=arguments[0],g=arguments[1];g.setCoordinate(this._coordinates[p])}}},{key:"getCoordinateCopy",value:function(c){var p=this.createCoordinate();return p.setCoordinate(this._coordinates[c]),p}},{key:"createCoordinate",value:function(){return oa.create(this.getDimension(),this.getMeasures())}},{key:"getDimension",value:function(){return this._dimension}},{key:"getX",value:function(c){return this._coordinates[c].x}},{key:"getMeasures",value:function(){return this._measures}},{key:"expandEnvelope",value:function(c){for(var p=0;p<this._coordinates.length;p++)c.expandToInclude(this._coordinates[p]);return c}},{key:"copy",value:function(){for(var c=new Array(this.size()).fill(null),p=0;p<this._coordinates.length;p++){var g=this.createCoordinate();g.setCoordinate(this._coordinates[p]),c[p]=g}return new M(c,this._dimension,this._measures)}},{key:"toString",value:function(){if(this._coordinates.length>0){var c=new us(17*this._coordinates.length);c.append("("),c.append(this._coordinates[0]);for(var p=1;p<this._coordinates.length;p++)c.append(", "),c.append(this._coordinates[p]);return c.append(")"),c.toString()}return"()"}},{key:"getY",value:function(c){return this._coordinates[c].y}},{key:"toCoordinateArray",value:function(){return this._coordinates}},{key:"interfaces_",get:function(){return[Ln,Ie]}}],[{key:"constructor_",value:function(){if(this._dimension=3,this._measures=0,this._coordinates=null,arguments.length===1){if(arguments[0]instanceof Array){var c=arguments[0];M.constructor_.call(this,c,Ri.dimension(c),Ri.measures(c))}else if(Number.isInteger(arguments[0])){var p=arguments[0];this._coordinates=new Array(p).fill(null);for(var g=0;g<p;g++)this._coordinates[g]=new je}else if(an(arguments[0],Ln)){var w=arguments[0];if(w===null)return this._coordinates=new Array(0).fill(null),null;this._dimension=w.getDimension(),this._measures=w.getMeasures(),this._coordinates=new Array(w.size()).fill(null);for(var L=0;L<this._coordinates.length;L++)this._coordinates[L]=w.getCoordinateCopy(L)}}else if(arguments.length===2){if(arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var V=arguments[0],X=arguments[1];M.constructor_.call(this,V,X,Ri.measures(V))}else if(Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var Q=arguments[0],ae=arguments[1];this._coordinates=new Array(Q).fill(null),this._dimension=ae;for(var Le=0;Le<Q;Le++)this._coordinates[Le]=oa.create(ae)}}else if(arguments.length===3){if(Number.isInteger(arguments[2])&&arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var Ne=arguments[0],rt=arguments[1],kt=arguments[2];this._dimension=rt,this._measures=kt,this._coordinates=Ne===null?new Array(0).fill(null):Ne}else if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var Ct=arguments[0],Qt=arguments[1],Ht=arguments[2];this._coordinates=new Array(Ct).fill(null),this._dimension=Qt,this._measures=Ht;for(var dn=0;dn<Ct;dn++)this._coordinates[dn]=this.createCoordinate()}}}}]),M}(),co=function(){function M(){s(this,M)}return h(M,[{key:"readResolve",value:function(){return M.instance()}},{key:"create",value:function(){if(arguments.length===1){if(arguments[0]instanceof Array){var c=arguments[0];return new Sr(c)}if(an(arguments[0],Ln)){var p=arguments[0];return new Sr(p)}}else{if(arguments.length===2){var g=arguments[0],w=arguments[1];return w>3&&(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<g.length;w++)g[w]=this._geometries[w].copy();return new p(g,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];return!!this.isEquivalentClass(g)&&Z(x(p.prototype),"equalsExact",this).call(this,g,w)}return Z(x(p.prototype),"equalsExact",this).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return 1}},{key:"getTypeCode",value:function(){return gt.TYPECODE_MULTIPOLYGON}},{key:"getDimension",value:function(){return 2}},{key:"getBoundary",value:function(){if(this.isEmpty())return this.getFactory().createMultiLineString();for(var g=new nn,w=0;w<this._geometries.length;w++)for(var L=this._geometries[w].getBoundary(),V=0;V<L.getNumGeometries();V++)g.add(L.getGeometryN(V));var X=new Array(g.size()).fill(null);return this.getFactory().createMultiLineString(g.toArray(X))}},{key:"getGeometryType",value:function(){return gt.TYPENAME_MULTIPOLYGON}},{key:"interfaces_",get:function(){return[En]}}],[{key:"constructor_",value:function(){var g=arguments[0],w=arguments[1];$n.constructor_.call(this,g,w)}}]),p}($n),Va=function(){function M(){s(this,M)}return h(M,[{key:"get",value:function(){}},{key:"put",value:function(){}},{key:"size",value:function(){}},{key:"values",value:function(){}},{key:"entrySet",value:function(){}}]),M}(),cs=function(M){f(p,M);var c=U(p);function p(){var g;return s(this,p),(g=c.call(this)).map=new Map,g}return h(p,[{key:"get",value:function(g){return this.map.get(g)||null}},{key:"put",value:function(g,w){return this.map.set(g,w),w}},{key:"values",value:function(){for(var g=new nn,w=this.map.values(),L=w.next();!L.done;)g.add(L.value),L=w.next();return g}},{key:"entrySet",value:function(){var g=new Yi;return this.map.entries().forEach(function(w){return g.add(w)}),g}},{key:"size",value:function(){return this.map.size()}}]),p}(Va),Fi=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"equals",value:function(c){if(!(c instanceof M))return!1;var p=c;return this._modelType===p._modelType&&this._scale===p._scale}},{key:"compareTo",value:function(c){var p=c,g=this.getMaximumSignificantDigits(),w=p.getMaximumSignificantDigits();return uo.compare(g,w)}},{key:"getScale",value:function(){return this._scale}},{key:"isFloating",value:function(){return this._modelType===M.FLOATING||this._modelType===M.FLOATING_SINGLE}},{key:"getType",value:function(){return this._modelType}},{key:"toString",value:function(){var c="UNKNOWN";return this._modelType===M.FLOATING?c="Floating":this._modelType===M.FLOATING_SINGLE?c="Floating-Single":this._modelType===M.FIXED&&(c="Fixed (Scale="+this.getScale()+")"),c}},{key:"makePrecise",value:function(){if(typeof arguments[0]=="number"){var c=arguments[0];return tt.isNaN(c)||this._modelType===M.FLOATING_SINGLE?c:this._modelType===M.FIXED?Math.round(c*this._scale)/this._scale:c}if(arguments[0]instanceof je){var p=arguments[0];if(this._modelType===M.FLOATING)return null;p.x=this.makePrecise(p.x),p.y=this.makePrecise(p.y)}}},{key:"getMaximumSignificantDigits",value:function(){var c=16;return this._modelType===M.FLOATING?c=16:this._modelType===M.FLOATING_SINGLE?c=6:this._modelType===M.FIXED&&(c=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),c}},{key:"setScale",value:function(c){this._scale=Math.abs(c)}},{key:"interfaces_",get:function(){return[Ie,ze]}}],[{key:"constructor_",value:function(){if(this._modelType=null,this._scale=null,arguments.length===0)this._modelType=M.FLOATING;else if(arguments.length===1){if(arguments[0]instanceof wo){var c=arguments[0];this._modelType=c,c===M.FIXED&&this.setScale(1)}else if(typeof arguments[0]=="number"){var p=arguments[0];this._modelType=M.FIXED,this.setScale(p)}else if(arguments[0]instanceof M){var g=arguments[0];this._modelType=g._modelType,this._scale=g._scale}}}},{key:"mostPrecise",value:function(c,p){return c.compareTo(p)>=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;w<g.length;w++)g[w]=this._geometries[w].copy();return new p(g,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];return!!this.isEquivalentClass(g)&&Z(x(p.prototype),"equalsExact",this).call(this,g,w)}return Z(x(p.prototype),"equalsExact",this).apply(this,arguments)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?me.FALSE:0}},{key:"isClosed",value:function(){if(this.isEmpty())return!1;for(var g=0;g<this._geometries.length;g++)if(!this._geometries[g].isClosed())return!1;return!0}},{key:"getTypeCode",value:function(){return gt.TYPECODE_MULTILINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getBoundary",value:function(){throw new yn}},{key:"getGeometryType",value:function(){return gt.TYPENAME_MULTILINESTRING}},{key:"interfaces_",get:function(){return[Ge]}}],[{key:"constructor_",value:function(){var g=arguments[0],w=arguments[1];$n.constructor_.call(this,g,w)}}]),p}($n),kr=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"createEmpty",value:function(c){switch(c){case-1:return this.createGeometryCollection();case 0:return this.createPoint();case 1:return this.createLineString();case 2:return this.createPolygon();default:throw new we("Invalid dimension: "+c)}}},{key:"toGeometry",value:function(c){return c.isNull()?this.createPoint():c.getMinX()===c.getMaxX()&&c.getMinY()===c.getMaxY()?this.createPoint(new je(c.getMinX(),c.getMinY())):c.getMinX()===c.getMaxX()||c.getMinY()===c.getMaxY()?this.createLineString([new je(c.getMinX(),c.getMinY()),new je(c.getMaxX(),c.getMaxY())]):this.createPolygon(this.createLinearRing([new je(c.getMinX(),c.getMinY()),new je(c.getMinX(),c.getMaxY()),new je(c.getMaxX(),c.getMaxY()),new je(c.getMaxX(),c.getMinY()),new je(c.getMinX(),c.getMinY())]),null)}},{key:"createLineString",value:function(){if(arguments.length===0)return this.createLineString(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof Array){var c=arguments[0];return this.createLineString(c!==null?this.getCoordinateSequenceFactory().create(c):null)}if(an(arguments[0],Ln)){var p=arguments[0];return new It(p,this)}}}},{key:"createMultiLineString",value:function(){if(arguments.length===0)return new Qe(null,this);if(arguments.length===1){var c=arguments[0];return new Qe(c,this)}}},{key:"buildGeometry",value:function(c){for(var p=null,g=!1,w=!1,L=c.iterator();L.hasNext();){var V=L.next(),X=V.getTypeCode();p===null&&(p=X),X!==p&&(g=!0),V instanceof $n&&(w=!0)}if(p===null)return this.createGeometryCollection();if(g||w)return this.createGeometryCollection(M.toGeometryArray(c));var Q=c.iterator().next();if(c.size()>1){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<p.size();w++){var L=this.getCoordinateSequenceFactory().create(1,p.getDimension(),p.getMeasures());Fe.copy(p,w,L,0,1),g[w]=this.createPoint(L)}return this.createMultiPoint(g)}}}},{key:"interfaces_",get:function(){return[Ie]}}],[{key:"constructor_",value:function(){if(this._precisionModel=null,this._coordinateSequenceFactory=null,this._SRID=null,arguments.length===0)M.constructor_.call(this,new Fi,0);else if(arguments.length===1){if(an(arguments[0],ve)){var c=arguments[0];M.constructor_.call(this,new Fi,0,c)}else if(arguments[0]instanceof Fi){var p=arguments[0];M.constructor_.call(this,p,0,M.getDefaultCoordinateSequenceFactory())}}else if(arguments.length===2){var g=arguments[0],w=arguments[1];M.constructor_.call(this,g,w,M.getDefaultCoordinateSequenceFactory())}else if(arguments.length===3){var L=arguments[0],V=arguments[1],X=arguments[2];this._precisionModel=L,this._coordinateSequenceFactory=X,this._SRID=V}}},{key:"toMultiPolygonArray",value:function(c){var p=new Array(c.size()).fill(null);return c.toArray(p)}},{key:"toGeometryArray",value:function(c){if(c===null)return null;var p=new Array(c.size()).fill(null);return c.toArray(p)}},{key:"getDefaultCoordinateSequenceFactory",value:function(){return co.instance()}},{key:"toMultiLineStringArray",value:function(c){var p=new Array(c.size()).fill(null);return c.toArray(p)}},{key:"toLineStringArray",value:function(c){var p=new Array(c.size()).fill(null);return c.toArray(p)}},{key:"toMultiPointArray",value:function(c){var p=new Array(c.size()).fill(null);return c.toArray(p)}},{key:"toLinearRingArray",value:function(c){var p=new Array(c.size()).fill(null);return c.toArray(p)}},{key:"toPointArray",value:function(c){var p=new Array(c.size()).fill(null);return c.toArray(p)}},{key:"toPolygonArray",value:function(c){var p=new Array(c.size()).fill(null);return c.toArray(p)}},{key:"createPointFromInternalCoord",value:function(c,p){return p.getPrecisionModel().makePrecise(c),p.getFactory().createPoint(c)}}]),M}(),Ti="XY",Ki="XYZ",Nu="XYM",Eo="XYZM",Ua={POINT:"Point",LINE_STRING:"LineString",LINEAR_RING:"LinearRing",POLYGON:"Polygon",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon",GEOMETRY_COLLECTION:"GeometryCollection",CIRCLE:"Circle"},Rl="EMPTY",Oo=1,Pt=2,fn=3,In=4,Ji=5,ho=6;for(var kn in Ua)Ua[kn].toUpperCase();var Vr=function(){function M(c){s(this,M),this.wkt=c,this.index_=-1}return h(M,[{key:"isAlpha_",value:function(c){return c>="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;g<p;++g){var w=this.token_;if(!this.match(In))break;c.push(w.value)}if(c.length==p)return c;throw new Error(this.formatErrorMessage_())}},{key:"parsePointList_",value:function(){for(var c=[this.parsePoint_()];this.match(Ji);)c.push(this.parsePoint_());return c}},{key:"parsePointTextList_",value:function(){for(var c=[this.parsePointText_()];this.match(Ji);)c.push(this.parsePointText_());return c}},{key:"parseLineStringTextList_",value:function(){for(var c=[this.parseLineStringText_()];this.match(Ji);)c.push(this.parseLineStringText_());return c}},{key:"parsePolygonTextList_",value:function(){for(var c=[this.parsePolygonText_()];this.match(Ji);)c.push(this.parsePolygonText_());return c}},{key:"isEmptyGeometry_",value:function(){var c=this.isTokenType(Oo)&&this.token_.value==Rl;return c&&this.consume_(),c}},{key:"formatErrorMessage_",value:function(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}},{key:"parseGeometry_",value:function(){var c=this.factory,p=function(Ht){return k(je,J(Ht))},g=function(Ht){var dn=Ht.map(function(Rn){return c.createLinearRing(Rn.map(p))});return dn.length>1?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;g<w;++g)p.push(c[g].join(" "));return p.join(", ")}function li(M){var c=[];c.push("("+fr(M.getExteriorRing())+")");for(var p=0,g=M.getNumInteriorRing();p<g;++p)c.push("("+fr(M.getInteriorRingN(p))+")");return c.join(", ")}var Bu={Point:Ho,LineString:fr,LinearRing:fr,Polygon:li,MultiPoint:function(M){for(var c=[],p=0,g=M.getNumGeometries();p<g;++p)c.push("("+Ho(M.getGeometryN(p))+")");return c.join(", ")},MultiLineString:function(M){for(var c=[],p=0,g=M.getNumGeometries();p<g;++p)c.push("("+fr(M.getGeometryN(p))+")");return c.join(", ")},MultiPolygon:function(M){for(var c=[],p=0,g=M.getNumGeometries();p<g;++p)c.push("("+li(M.getGeometryN(p))+")");return c.join(", ")},GeometryCollection:function(M){for(var c=[],p=0,g=M.getNumGeometries();p<g;++p)c.push(To(M.getGeometryN(p)));return c.join(", ")}};function To(M){var c=M.getGeometryType(),p=Bu[c];c=c.toUpperCase();var g=function(w){var L="";if(w.isEmpty())return L;var V=w.getCoordinate();return V.z===void 0||Number.isNaN(V.z)||(L+="Z"),V.m===void 0||Number.isNaN(V.m)||(L+="M"),L}(M);return g.length>0&&(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;p<this._result;p++)if(!this._intPt[p].equals2D(this._inputLines[c][0])&&!this._intPt[p].equals2D(this._inputLines[c][1]))return!0;return!1}}},{key:"getIntersection",value:function(c){return this._intPt[c]}},{key:"isEndPoint",value:function(){return this.hasIntersection()&&!this._isProper}},{key:"hasIntersection",value:function(){return this._result!==M.NO_INTERSECTION}},{key:"getEdgeDistance",value:function(c,p){return M.computeEdgeDistance(this._intPt[p],this._inputLines[c][0],this._inputLines[c][1])}},{key:"isCollinear",value:function(){return this._result===M.COLLINEAR_INTERSECTION}},{key:"toString",value:function(){return hs.toLineString(this._inputLines[0][0],this._inputLines[0][1])+" - "+hs.toLineString(this._inputLines[1][0],this._inputLines[1][1])+this.getTopologySummary()}},{key:"getEndpoint",value:function(c,p){return this._inputLines[c][p]}},{key:"isIntersection",value:function(c){for(var p=0;p<this._result;p++)if(this._intPt[p].equals2D(c))return!0;return!1}},{key:"getIntersectionAlongSegment",value:function(c,p){return this.computeIntLineIndex(),this._intPt[this._intLineIndex[c][p]]}}],[{key:"constructor_",value:function(){this._result=null,this._inputLines=Array(2).fill().map(function(){return Array(2)}),this._intPt=new Array(2).fill(null),this._intLineIndex=null,this._isProper=null,this._pa=null,this._pb=null,this._precisionModel=null,this._intPt[0]=new je,this._intPt[1]=new je,this._pa=this._intPt[0],this._pb=this._intPt[1],this._result=0}},{key:"computeEdgeDistance",value:function(c,p,g){var w=Math.abs(g.x-p.x),L=Math.abs(g.y-p.y),V=-1;if(c.equals(p))V=0;else if(c.equals(g))V=w>L?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 ae<Q&&(Q=ae,X=w),(ae=ne.pointToSegment(L,g,w))<Q&&(Q=ae,X=L),(ae=ne.pointToSegment(V,g,w))<Q&&(Q=ae,X=V),X}}]),p}(mi),ca=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"countSegment",value:function(c,p){if(c.x<this._p.x&&p.x<this._p.x)return null;if(this._p.x===p.x&&this._p.y===p.y)return this._isPointOnSegment=!0,null;if(c.y===this._p.y&&p.y===this._p.y){var g=c.x,w=p.x;return g>w&&(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.y<c.y&&(L=-L),L===sn.LEFT&&this._crossingCount++}}},{key:"isPointInPolygon",value:function(){return this.getLocation()!==Me.EXTERIOR}},{key:"getLocation",value:function(){return this._isPointOnSegment?Me.BOUNDARY:this._crossingCount%2==1?Me.INTERIOR:Me.EXTERIOR}},{key:"isOnSegment",value:function(){return this._isPointOnSegment}}],[{key:"constructor_",value:function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var c=arguments[0];this._p=c}},{key:"locatePointInRing",value:function(){if(arguments[0]instanceof je&&an(arguments[1],Ln)){for(var c=arguments[0],p=arguments[1],g=new M(c),w=new je,L=new je,V=1;V<p.size();V++)if(p.getCoordinate(V,w),p.getCoordinate(V-1,L),g.countSegment(w,L),g.isOnSegment())return g.getLocation();return g.getLocation()}if(arguments[0]instanceof je&&arguments[1]instanceof Array){for(var X=arguments[0],Q=arguments[1],ae=new M(X),Le=1;Le<Q.length;Le++){var Ne=Q[Le],rt=Q[Le-1];if(ae.countSegment(Ne,rt),ae.isOnSegment())return ae.getLocation()}return ae.getLocation()}}}]),M}(),fs=function(){function M(){s(this,M)}return h(M,null,[{key:"isOnLine",value:function(){if(arguments[0]instanceof je&&an(arguments[1],Ln)){for(var c=arguments[0],p=arguments[1],g=new Ko,w=new je,L=new je,V=p.size(),X=1;X<V;X++)if(p.getCoordinate(X-1,w),p.getCoordinate(X,L),g.computeIntersection(c,w,L),g.hasIntersection())return!0;return!1}if(arguments[0]instanceof je&&arguments[1]instanceof Array){for(var Q=arguments[0],ae=arguments[1],Le=new Ko,Ne=1;Ne<ae.length;Ne++){var rt=ae[Ne-1],kt=ae[Ne];if(Le.computeIntersection(Q,rt,kt),Le.hasIntersection())return!0}return!1}}},{key:"locateInRing",value:function(c,p){return ca.locatePointInRing(c,p)}},{key:"isInRing",value:function(c,p){return M.locateInRing(c,p)!==Me.EXTERIOR}}]),M}(),xr=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"setAllLocations",value:function(c){for(var p=0;p<this.location.length;p++)this.location[p]=c}},{key:"isNull",value:function(){for(var c=0;c<this.location.length;c++)if(this.location[c]!==Me.NONE)return!1;return!0}},{key:"setAllLocationsIfNull",value:function(c){for(var p=0;p<this.location.length;p++)this.location[p]===Me.NONE&&(this.location[p]=c)}},{key:"isLine",value:function(){return this.location.length===1}},{key:"merge",value:function(c){if(c.location.length>this.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;g<this.location.length;g++)this.location[g]===Me.NONE&&g<c.location.length&&(this.location[g]=c.location[g])}},{key:"getLocations",value:function(){return this.location}},{key:"flip",value:function(){if(this.location.length<=1)return null;var c=this.location[wt.LEFT];this.location[wt.LEFT]=this.location[wt.RIGHT],this.location[wt.RIGHT]=c}},{key:"toString",value:function(){var c=new lo;return this.location.length>1&&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 c<this.location.length?this.location[c]:Me.NONE}},{key:"isArea",value:function(){return this.location.length>1}},{key:"isAnyNull",value:function(){for(var c=0;c<this.location.length;c++)if(this.location[c]===Me.NONE)return!0;return!1}},{key:"setLocation",value:function(){if(arguments.length===1){var c=arguments[0];this.setLocation(wt.ON,c)}else if(arguments.length===2){var p=arguments[0],g=arguments[1];this.location[p]=g}}},{key:"init",value:function(c){this.location=new Array(c).fill(null),this.setAllLocations(Me.NONE)}},{key:"isEqualOnSide",value:function(c,p){return this.location[p]===c.location[p]}},{key:"allPositionsEqual",value:function(c){for(var p=0;p<this.location.length;p++)if(this.location[p]!==c)return!1;return!0}}],[{key:"constructor_",value:function(){if(this.location=null,arguments.length===1){if(arguments[0]instanceof Array){var c=arguments[0];this.init(c.length)}else if(Number.isInteger(arguments[0])){var p=arguments[0];this.init(1),this.location[wt.ON]=p}else if(arguments[0]instanceof M){var g=arguments[0];if(this.init(g.location.length),g!==null)for(var w=0;w<this.location.length;w++)this.location[w]=g.location[w]}}else if(arguments.length===3){var L=arguments[0],V=arguments[1],X=arguments[2];this.init(3),this.location[wt.ON]=L,this.location[wt.LEFT]=V,this.location[wt.RIGHT]=X}}}]),M}(),rr=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getGeometryCount",value:function(){var c=0;return this.elt[0].isNull()||c++,this.elt[1].isNull()||c++,c}},{key:"setAllLocations",value:function(c,p){this.elt[c].setAllLocations(p)}},{key:"isNull",value:function(c){return this.elt[c].isNull()}},{key:"setAllLocationsIfNull",value:function(){if(arguments.length===1){var c=arguments[0];this.setAllLocationsIfNull(0,c),this.setAllLocationsIfNull(1,c)}else if(arguments.length===2){var p=arguments[0],g=arguments[1];this.elt[p].setAllLocationsIfNull(g)}}},{key:"isLine",value:function(c){return this.elt[c].isLine()}},{key:"merge",value:function(c){for(var p=0;p<2;p++)this.elt[p]===null&&c.elt[p]!==null?this.elt[p]=new xr(c.elt[p]):this.elt[p].merge(c.elt[p])}},{key:"flip",value:function(){this.elt[0].flip(),this.elt[1].flip()}},{key:"getLocation",value:function(){if(arguments.length===1){var c=arguments[0];return this.elt[c].get(wt.ON)}if(arguments.length===2){var p=arguments[0],g=arguments[1];return this.elt[p].get(g)}}},{key:"toString",value:function(){var c=new lo;return this.elt[0]!==null&&(c.append("A:"),c.append(this.elt[0].toString())),this.elt[1]!==null&&(c.append(" B:"),c.append(this.elt[1].toString())),c.toString()}},{key:"isArea",value:function(){if(arguments.length===0)return this.elt[0].isArea()||this.elt[1].isArea();if(arguments.length===1){var c=arguments[0];return this.elt[c].isArea()}}},{key:"isAnyNull",value:function(c){return this.elt[c].isAnyNull()}},{key:"setLocation",value:function(){if(arguments.length===2){var c=arguments[0],p=arguments[1];this.elt[c].setLocation(wt.ON,p)}else if(arguments.length===3){var g=arguments[0],w=arguments[1],L=arguments[2];this.elt[g].setLocation(w,L)}}},{key:"isEqualOnSide",value:function(c,p){return this.elt[0].isEqualOnSide(c.elt[0],p)&&this.elt[1].isEqualOnSide(c.elt[1],p)}},{key:"allPositionsEqual",value:function(c,p){return this.elt[c].allPositionsEqual(p)}},{key:"toLine",value:function(c){this.elt[c].isArea()&&(this.elt[c]=new xr(this.elt[c].location[0]))}}],[{key:"constructor_",value:function(){if(this.elt=new Array(2).fill(null),arguments.length===1){if(Number.isInteger(arguments[0])){var c=arguments[0];this.elt[0]=new xr(c),this.elt[1]=new xr(c)}else if(arguments[0]instanceof M){var p=arguments[0];this.elt[0]=new xr(p.elt[0]),this.elt[1]=new xr(p.elt[1])}}else if(arguments.length===2){var g=arguments[0],w=arguments[1];this.elt[0]=new xr(Me.NONE),this.elt[1]=new xr(Me.NONE),this.elt[g].setLocation(w)}else if(arguments.length===3){var L=arguments[0],V=arguments[1],X=arguments[2];this.elt[0]=new xr(L,V,X),this.elt[1]=new xr(L,V,X)}else if(arguments.length===4){var Q=arguments[0],ae=arguments[1],Le=arguments[2],Ne=arguments[3];this.elt[0]=new xr(Me.NONE,Me.NONE,Me.NONE),this.elt[1]=new xr(Me.NONE,Me.NONE,Me.NONE),this.elt[Q].setLocations(ae,Le,Ne)}}},{key:"toLineLabel",value:function(c){for(var p=new M(Me.NONE),g=0;g<2;g++)p.setLocation(g,c.getLocation(g));return p}}]),M}(),or=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"computeRing",value:function(){if(this._ring!==null)return null;for(var c=new Array(this._pts.size()).fill(null),p=0;p<this._pts.size();p++)c[p]=this._pts.get(p);this._ring=this._geometryFactory.createLinearRing(c),this._isHole=sn.isCCW(this._ring.getCoordinates())}},{key:"isIsolated",value:function(){return this._label.getGeometryCount()===1}},{key:"computePoints",value:function(c){this._startDe=c;var p=c,g=!0;do{if(p===null)throw new vr("Found null DirectedEdge");if(p.getEdgeRing()===this)throw new vr("Directed Edge visited twice during ring-building at "+p.getCoordinate());this._edges.add(p);var w=p.getLabel();St.isTrue(w.isArea()),this.mergeLabel(w),this.addPoints(p.getEdge(),p.isForward(),g),g=!1,this.setEdgeRing(p,this),p=this.getNext(p)}while(p!==this._startDe)}},{key:"getLinearRing",value:function(){return this._ring}},{key:"getCoordinate",value:function(c){return this._pts.get(c)}},{key:"computeMaxNodeDegree",value:function(){this._maxNodeDegree=0;var c=this._startDe;do{var p=c.getNode().getEdges().getOutgoingDegree(this);p>this._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<w.length;V++)this._pts.add(w[V])}else{var X=w.length-2;g&&(X=w.length-1);for(var Q=X;Q>=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<this._holes.size();g++)p[g]=this._holes.get(g).getLinearRing();return c.createPolygon(this.getLinearRing(),p)}}],[{key:"constructor_",value:function(){if(this._startDe=null,this._maxNodeDegree=-1,this._edges=new nn,this._pts=new nn,this._label=new rr(Me.NONE),this._ring=null,this._isHole=null,this._shell=null,this._holes=new nn,this._geometryFactory=null,arguments.length!==0){if(arguments.length===2){var c=arguments[0],p=arguments[1];this._geometryFactory=p,this.computePoints(c),this.computeRing()}}}}]),M}(),Ai=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:"setEdgeRing",value:function(g,w){g.setMinEdgeRing(w)}},{key:"getNext",value:function(g){return g.getNextMin()}}],[{key:"constructor_",value:function(){var g=arguments[0],w=arguments[1];or.constructor_.call(this,g,w)}}]),p}(or),Dl=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:"buildMinimalRings",value:function(){var g=new nn,w=this._startDe;do{if(w.getMinEdgeRing()===null){var L=new Ai(w,this._geometryFactory);g.add(L)}w=w.getNext()}while(w!==this._startDe);return g}},{key:"setEdgeRing",value:function(g,w){g.setEdgeRing(w)}},{key:"linkDirectedEdgesForMinimalEdgeRings",value:function(){var g=this._startDe;do g.getNode().getEdges().linkMinimalDirectedEdges(this),g=g.getNext();while(g!==this._startDe)}},{key:"getNext",value:function(g){return g.getNext()}}],[{key:"constructor_",value:function(){var g=arguments[0],w=arguments[1];or.constructor_.call(this,g,w)}}]),p}(or),ja=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"setVisited",value:function(c){this._isVisited=c}},{key:"setInResult",value:function(c){this._isInResult=c}},{key:"isCovered",value:function(){return this._isCovered}},{key:"isCoveredSet",value:function(){return this._isCoveredSet}},{key:"setLabel",value:function(c){this._label=c}},{key:"getLabel",value:function(){return this._label}},{key:"setCovered",value:function(c){this._isCovered=c,this._isCoveredSet=!0}},{key:"updateIM",value:function(c){St.isTrue(this._label.getGeometryCount()>=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=c<p?c:p;return g===0&&(c>p?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._quadrant<c._quadrant?-1:sn.index(c._p0,c._p1,this._p1)}},{key:"getDy",value:function(){return this._dy}},{key:"getCoordinate",value:function(){return this._p0}},{key:"setNode",value:function(c){this._node=c}},{key:"print",value:function(c){var p=Math.atan2(this._dy,this._dx),g=this.getClass().getName(),w=g.lastIndexOf("."),L=g.substring(w+1);c.print(" "+L+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+p+" "+this._label)}},{key:"compareTo",value:function(c){var p=c;return this.compareDirection(p)}},{key:"getDirectedCoordinate",value:function(){return this._p1}},{key:"getDx",value:function(){return this._dx}},{key:"getLabel",value:function(){return this._label}},{key:"getEdge",value:function(){return this._edge}},{key:"getQuadrant",value:function(){return this._quadrant}},{key:"getNode",value:function(){return this._node}},{key:"toString",value:function(){var c=Math.atan2(this._dy,this._dx),p=this.getClass().getName(),g=p.lastIndexOf(".");return" "+p.substring(g+1)+": "+this._p0+" - "+this._p1+" "+this._quadrant+":"+c+" "+this._label}},{key:"computeLabel",value:function(c){}},{key:"init",value:function(c,p){this._p0=c,this._p1=p,this._dx=p.x-c.x,this._dy=p.y-c.y,this._quadrant=ar.quadrant(this._dx,this._dy),St.isTrue(!(this._dx===0&&this._dy===0),"EdgeEnd with identical endpoints found")}},{key:"interfaces_",get:function(){return[ze]}}],[{key:"constructor_",value:function(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,arguments.length===1){var c=arguments[0];this._edge=c}else if(arguments.length===3){var p=arguments[0],g=arguments[1],w=arguments[2];M.constructor_.call(this,p,g,w,null)}else if(arguments.length===4){var L=arguments[0],V=arguments[1],X=arguments[2],Q=arguments[3];M.constructor_.call(this,L),this.init(V,X),this._label=Q}}}]),M}(),po=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:"getNextMin",value:function(){return this._nextMin}},{key:"getDepth",value:function(g){return this._depth[g]}},{key:"setVisited",value:function(g){this._isVisited=g}},{key:"computeDirectedLabel",value:function(){this._label=new rr(this._edge.getLabel()),this._isForward||this._label.flip()}},{key:"getNext",value:function(){return this._next}},{key:"setDepth",value:function(g,w){if(this._depth[g]!==-999&&this._depth[g]!==w)throw new vr("assigned depths do not match",this.getCoordinate());this._depth[g]=w}},{key:"isInteriorAreaEdge",value:function(){for(var g=!0,w=0;w<2;w++)this._label.isArea(w)&&this._label.getLocation(w,wt.LEFT)===Me.INTERIOR&&this._label.getLocation(w,wt.RIGHT)===Me.INTERIOR||(g=!1);return g}},{key:"setNextMin",value:function(g){this._nextMin=g}},{key:"print",value:function(g){Z(x(p.prototype),"print",this).call(this,g),g.print(" "+this._depth[wt.LEFT]+"/"+this._depth[wt.RIGHT]),g.print(" ("+this.getDepthDelta()+")"),this._isInResult&&g.print(" inResult")}},{key:"setMinEdgeRing",value:function(g){this._minEdgeRing=g}},{key:"isLineEdge",value:function(){var g=this._label.isLine(0)||this._label.isLine(1),w=!this._label.isArea(0)||this._label.allPositionsEqual(0,Me.EXTERIOR),L=!this._label.isArea(1)||this._label.allPositionsEqual(1,Me.EXTERIOR);return g&&w&&L}},{key:"setEdgeRing",value:function(g){this._edgeRing=g}},{key:"getMinEdgeRing",value:function(){return this._minEdgeRing}},{key:"getDepthDelta",value:function(){var g=this._edge.getDepthDelta();return this._isForward||(g=-g),g}},{key:"setInResult",value:function(g){this._isInResult=g}},{key:"getSym",value:function(){return this._sym}},{key:"isForward",value:function(){return this._isForward}},{key:"getEdge",value:function(){return this._edge}},{key:"printEdge",value:function(g){this.print(g),g.print(" "),this._isForward?this._edge.print(g):this._edge.printReverse(g)}},{key:"setSym",value:function(g){this._sym=g}},{key:"setVisitedEdge",value:function(g){this.setVisited(g),this._sym.setVisited(g)}},{key:"setEdgeDepths",value:function(g,w){var L=this.getEdge().getDepthDelta();this._isForward||(L=-L);var V=1;g===wt.LEFT&&(V=-1);var X=wt.opposite(g),Q=w+L*V;this.setDepth(g,w),this.setDepth(X,Q)}},{key:"getEdgeRing",value:function(){return this._edgeRing}},{key:"isInResult",value:function(){return this._isInResult}},{key:"setNext",value:function(g){this._next=g}},{key:"isVisited",value:function(){return this._isVisited}}],[{key:"constructor_",value:function(){this._isForward=null,this._isInResult=!1,this._isVisited=!1,this._sym=null,this._next=null,this._nextMin=null,this._edgeRing=null,this._minEdgeRing=null,this._depth=[0,-999,-999];var g=arguments[0],w=arguments[1];if(qa.constructor_.call(this,g),this._isForward=w,w)this.init(g.getCoordinate(0),g.getCoordinate(1));else{var L=g.getNumPoints()-1;this.init(g.getCoordinate(L),g.getCoordinate(L-1))}this.computeDirectedLabel()}},{key:"depthFactor",value:function(g,w){return g===Me.EXTERIOR&&w===Me.INTERIOR?1:g===Me.INTERIOR&&w===Me.EXTERIOR?-1:0}}]),p}(qa),No=function(){function M(){s(this,M)}return h(M,[{key:"createNode",value:function(c){return new sr(c,null)}}]),M}(),ha=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"printEdges",value:function(c){c.println("Edges:");for(var p=0;p<this._edges.size();p++){c.println("edge "+p+":");var g=this._edges.get(p);g.print(c),g.eiList.print(c)}}},{key:"find",value:function(c){return this._nodes.find(c)}},{key:"addNode",value:function(){if(arguments[0]instanceof sr){var c=arguments[0];return this._nodes.addNode(c)}if(arguments[0]instanceof je){var p=arguments[0];return this._nodes.addNode(p)}}},{key:"getNodeIterator",value:function(){return this._nodes.iterator()}},{key:"linkResultDirectedEdges",value:function(){for(var c=this._nodes.iterator();c.hasNext();)c.next().getEdges().linkResultDirectedEdges()}},{key:"debugPrintln",value:function(c){xe.out.println(c)}},{key:"isBoundaryNode",value:function(c,p){var g=this._nodes.find(p);if(g===null)return!1;var w=g.getLabel();return w!==null&&w.getLocation(c)===Me.BOUNDARY}},{key:"linkAllDirectedEdges",value:function(){for(var c=this._nodes.iterator();c.hasNext();)c.next().getEdges().linkAllDirectedEdges()}},{key:"matchInSameDirection",value:function(c,p,g,w){return!!c.equals(g)&&sn.index(c,p,w)===sn.COLLINEAR&&ar.quadrant(c,p)===ar.quadrant(g,w)}},{key:"getEdgeEnds",value:function(){return this._edgeEndList}},{key:"debugPrint",value:function(c){xe.out.print(c)}},{key:"getEdgeIterator",value:function(){return this._edges.iterator()}},{key:"findEdgeInSameDirection",value:function(c,p){for(var g=0;g<this._edges.size();g++){var w=this._edges.get(g),L=w.getCoordinates();if(this.matchInSameDirection(c,p,L[0],L[1])||this.matchInSameDirection(c,p,L[L.length-1],L[L.length-2]))return w}return null}},{key:"insertEdge",value:function(c){this._edges.add(c)}},{key:"findEdgeEnd",value:function(c){for(var p=this.getEdgeEnds().iterator();p.hasNext();){var g=p.next();if(g.getEdge()===c)return g}return null}},{key:"addEdges",value:function(c){for(var p=c.iterator();p.hasNext();){var g=p.next();this._edges.add(g);var w=new po(g,!0),L=new po(g,!1);w.setSym(L),L.setSym(w),this.add(w),this.add(L)}}},{key:"add",value:function(c){this._nodes.add(c),this._edgeEndList.add(c)}},{key:"getNodes",value:function(){return this._nodes.values()}},{key:"findEdge",value:function(c,p){for(var g=0;g<this._edges.size();g++){var w=this._edges.get(g),L=w.getCoordinates();if(c.equals(L[0])&&p.equals(L[1]))return w}return null}}],[{key:"constructor_",value:function(){if(this._edges=new nn,this._nodes=null,this._edgeEndList=new nn,arguments.length===0)this._nodes=new Qi(new No);else if(arguments.length===1){var c=arguments[0];this._nodes=new Qi(c)}}},{key:"linkResultDirectedEdges",value:function(c){for(var p=c.iterator();p.hasNext();)p.next().getEdges().linkResultDirectedEdges()}}]),M}(),nh=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"sortShellsAndHoles",value:function(c,p,g){for(var w=c.iterator();w.hasNext();){var L=w.next();L.isHole()?g.add(L):p.add(L)}}},{key:"computePolygons",value:function(c){for(var p=new nn,g=c.iterator();g.hasNext();){var w=g.next().toPolygon(this._geometryFactory);p.add(w)}return p}},{key:"placeFreeHoles",value:function(c,p){for(var g=p.iterator();g.hasNext();){var w=g.next();if(w.getShell()===null){var L=M.findEdgeRingContaining(w,c);if(L===null)throw new vr("unable to assign hole to a shell",w.getCoordinate(0));w.setShell(L)}}}},{key:"buildMinimalEdgeRings",value:function(c,p,g){for(var w=new nn,L=c.iterator();L.hasNext();){var V=L.next();if(V.getMaxNodeDegree()>2){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;w<L;w++)g.next(),g.set(p[w])},singletonList:function(M){var c=new nn;return c.add(M),c}},fa=function(){function M(){s(this,M)}return h(M,null,[{key:"maxDistance",value:function(c,p,g,w,L,V,X,Q){var ae=M.distance(c,p,L,V);return ae=Math.max(ae,M.distance(c,p,X,Q)),ae=Math.max(ae,M.distance(g,w,L,V)),ae=Math.max(ae,M.distance(g,w,X,Q))}},{key:"distance",value:function(c,p,g,w){var L=g-c,V=w-p;return Math.sqrt(L*L+V*V)}},{key:"maximumDistance",value:function(c,p){var g=Math.min(c.getMinX(),p.getMinX()),w=Math.min(c.getMinY(),p.getMinY()),L=Math.max(c.getMaxX(),p.getMaxX()),V=Math.max(c.getMaxY(),p.getMaxY());return M.distance(g,w,L,V)}},{key:"minMaxDistance",value:function(c,p){var g=c.getMinX(),w=c.getMinY(),L=c.getMaxX(),V=c.getMaxY(),X=p.getMinX(),Q=p.getMinY(),ae=p.getMaxX(),Le=p.getMaxY(),Ne=M.maxDistance(g,w,g,V,X,Q,X,Le);return Ne=Math.min(Ne,M.maxDistance(g,w,g,V,X,Q,ae,Q)),Ne=Math.min(Ne,M.maxDistance(g,w,g,V,ae,Le,X,Le)),Ne=Math.min(Ne,M.maxDistance(g,w,g,V,ae,Le,ae,Q)),Ne=Math.min(Ne,M.maxDistance(g,w,L,w,X,Q,X,Le)),Ne=Math.min(Ne,M.maxDistance(g,w,L,w,X,Q,ae,Q)),Ne=Math.min(Ne,M.maxDistance(g,w,L,w,ae,Le,X,Le)),Ne=Math.min(Ne,M.maxDistance(g,w,L,w,ae,Le,ae,Q)),Ne=Math.min(Ne,M.maxDistance(L,V,g,V,X,Q,X,Le)),Ne=Math.min(Ne,M.maxDistance(L,V,g,V,X,Q,ae,Q)),Ne=Math.min(Ne,M.maxDistance(L,V,g,V,ae,Le,X,Le)),Ne=Math.min(Ne,M.maxDistance(L,V,g,V,ae,Le,ae,Q)),Ne=Math.min(Ne,M.maxDistance(L,V,L,w,X,Q,X,Le)),Ne=Math.min(Ne,M.maxDistance(L,V,L,w,X,Q,ae,Q)),Ne=Math.min(Ne,M.maxDistance(L,V,L,w,ae,Le,X,Le)),Ne=Math.min(Ne,M.maxDistance(L,V,L,w,ae,Le,ae,Q))}}]),M}(),Pr=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"maximumDistance",value:function(){return fa.maximumDistance(this._boundable1.getBounds(),this._boundable2.getBounds())}},{key:"expandToQueue",value:function(c,p){var g=M.isComposite(this._boundable1),w=M.isComposite(this._boundable2);if(g&&w)return M.area(this._boundable1)>M.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._distance<p._distance?-1:this._distance>p._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()<L&&w.add(Q)}}},{key:"getBoundable",value:function(c){return c===0?this._boundable1:this._boundable2}},{key:"getDistance",value:function(){return this._distance}},{key:"distance",value:function(){return this.isLeaves()?this._itemDistance.distance(this._boundable1,this._boundable2):this._boundable1.getBounds().distance(this._boundable2.getBounds())}},{key:"interfaces_",get:function(){return[ze]}}],[{key:"constructor_",value:function(){this._boundable1=null,this._boundable2=null,this._distance=null,this._itemDistance=null;var c=arguments[0],p=arguments[1],g=arguments[2];this._boundable1=c,this._boundable2=p,this._itemDistance=g,this._distance=this.distance()}},{key:"area",value:function(c){return c.getBounds().getArea()}},{key:"isComposite",value:function(c){return c instanceof er}}]),M}(),da=function(){function M(){s(this,M)}return h(M,[{key:"visitItem",value:function(c){}}]),M}(),mo=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"queryInternal",value:function(){if(an(arguments[2],da)&&arguments[0]instanceof Object&&arguments[1]instanceof er)for(var c=arguments[0],p=arguments[1],g=arguments[2],w=p.getChildBoundables(),L=0;L<w.size();L++){var V=w.get(L);this.getIntersectsOp().intersects(V.getBounds(),c)&&(V instanceof er?this.queryInternal(c,V,g):V instanceof Cr?g.visitItem(V.getItem()):St.shouldNeverReachHere())}else if(an(arguments[2],Fr)&&arguments[0]instanceof Object&&arguments[1]instanceof er)for(var X=arguments[0],Q=arguments[1],ae=arguments[2],Le=Q.getChildBoundables(),Ne=0;Ne<Le.size();Ne++){var rt=Le.get(Ne);this.getIntersectsOp().intersects(rt.getBounds(),X)&&(rt instanceof er?this.queryInternal(X,rt,ae):rt instanceof Cr?ae.add(rt.getItem()):St.shouldNeverReachHere())}}},{key:"getNodeCapacity",value:function(){return this._nodeCapacity}},{key:"lastNode",value:function(c){return c.get(c.size()-1)}},{key:"size",value:function(){if(arguments.length===0)return this.isEmpty()?0:(this.build(),this.size(this._root));if(arguments.length===1){for(var c=arguments[0],p=0,g=c.getChildBoundables().iterator();g.hasNext();){var w=g.next();w instanceof er?p+=this.size(w):w instanceof Cr&&(p+=1)}return p}}},{key:"removeItem",value:function(c,p){for(var g=null,w=c.getChildBoundables().iterator();w.hasNext();){var L=w.next();L instanceof Cr&&L.getItem()===p&&(g=L)}return g!==null&&(c.getChildBoundables().remove(g),!0)}},{key:"itemsTree",value:function(){if(arguments.length===0){this.build();var c=this.itemsTree(this._root);return c===null?new nn:c}if(arguments.length===1){for(var p=arguments[0],g=new nn,w=p.getChildBoundables().iterator();w.hasNext();){var L=w.next();if(L instanceof er){var V=this.itemsTree(L);V!==null&&g.add(V)}else L instanceof Cr?g.add(L.getItem()):St.shouldNeverReachHere()}return g.size()<=0?null:g}}},{key:"insert",value:function(c,p){St.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new Cr(c,p))}},{key:"boundablesAtLevel",value:function(){if(arguments.length===1){var c=arguments[0],p=new nn;return this.boundablesAtLevel(c,this._root,p),p}if(arguments.length===3){var g=arguments[0],w=arguments[1],L=arguments[2];if(St.isTrue(g>-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:c<p?-1:0}}]),M}();mo.IntersectsOp=function(){},mo.DEFAULT_NODE_CAPACITY=10;var pa=function(){function M(){s(this,M)}return h(M,[{key:"distance",value:function(c,p){}}]),M}(),go=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:"createParentBoundablesFromVerticalSlices",value:function(g,w){St.isTrue(g.length>0);for(var L=new nn,V=0;V<g.length;V++)L.addAll(this.createParentBoundablesFromVerticalSlice(g[V],w));return L}},{key:"nearestNeighbourK",value:function(){if(arguments.length===2){var g=arguments[0],w=arguments[1];return this.nearestNeighbourK(g,tt.POSITIVE_INFINITY,w)}if(arguments.length===3){var L=arguments[0],V=arguments[1],X=arguments[2],Q=V,ae=new Ur;ae.add(L);for(var Le=new Ur;!ae.isEmpty()&&Q>=0;){var Ne=ae.poll(),rt=Ne.getDistance();if(rt>=Q)break;if(Ne.isLeaves())if(Le.size()<X)Le.add(Ne);else{var kt=Le.peek();kt.getDistance()>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;Q<w;Q++){V[Q]=new nn;for(var ae=0;X.hasNext()&&ae<L;){var Le=X.next();V[Q].add(Le),ae++}}return V}},{key:"query",value:function(){if(arguments.length===1){var g=arguments[0];return Z(x(p.prototype),"query",this).call(this,g)}if(arguments.length===2){var w=arguments[0],L=arguments[1];Z(x(p.prototype),"query",this).call(this,w,L)}}},{key:"getComparator",value:function(){return p.yComparator}},{key:"createParentBoundablesFromVerticalSlice",value:function(g,w){return Z(x(p.prototype),"createParentBoundables",this).call(this,g,w)}},{key:"remove",value:function(){if(arguments.length===2&&arguments[1]instanceof Object&&arguments[0]instanceof bn){var g=arguments[0],w=arguments[1];return Z(x(p.prototype),"remove",this).call(this,g,w)}return Z(x(p.prototype),"remove",this).apply(this,arguments)}},{key:"depth",value:function(){return arguments.length===0?Z(x(p.prototype),"depth",this).call(this):Z(x(p.prototype),"depth",this).apply(this,arguments)}},{key:"createParentBoundables",value:function(g,w){St.isTrue(!g.isEmpty());var L=Math.trunc(Math.ceil(g.size()/this.getNodeCapacity())),V=new nn(g);Ar.sort(V,p.xComparator);var X=this.verticalSlices(V,Math.trunc(Math.ceil(Math.sqrt(L))));return this.createParentBoundablesFromVerticalSlices(X,w)}},{key:"nearestNeighbour",value:function(){if(arguments.length===1){if(an(arguments[0],pa)){var g=arguments[0];if(this.isEmpty())return null;var w=new Pr(this.getRoot(),this.getRoot(),g);return this.nearestNeighbour(w)}if(arguments[0]instanceof Pr){var L=arguments[0],V=tt.POSITIVE_INFINITY,X=null,Q=new Ur;for(Q.add(L);!Q.isEmpty()&&V>0;){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 c<p?-1:c>p?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.segmentIndex<p.segmentIndex?-1:this.segmentIndex>p.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<this._edge.size()-2;p++){var g=this._edge.getCoordinate(p);this._edge.getCoordinate(p+1);var w=this._edge.getCoordinate(p+2);g.equals2D(w)&&c.add(uo.valueOf(p+1))}}},{key:"addEdgeCoordinates",value:function(c,p,g){var w=this.createSplitEdgePts(c,p);g.add(w,!1)}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(c){this.addEndpoints(),this.addCollapsedNodes();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:"findCollapseIndex",value:function(c,p,g){if(!c.coord.equals2D(p.coord))return!1;var w=p.segmentIndex-c.segmentIndex;return p.isInterior()||w--,w===1&&(g[0]=c.segmentIndex+1,!0)}},{key:"findCollapsesFromInsertedNodes",value:function(c){for(var p=new Array(1).fill(null),g=this.iterator(),w=g.next();g.hasNext();){var L=g.next();this.findCollapseIndex(w,L,p)&&c.add(uo.valueOf(p[0])),w=L}}},{key:"getEdge",value:function(){return this._edge}},{key:"addEndpoints",value:function(){var c=this._edge.size()-1;this.add(this._edge.getCoordinate(0),0),this.add(this._edge.getCoordinate(c),c)}},{key:"createSplitEdge",value:function(c,p){var g=this.createSplitEdgePts(c,p);return new Bo(g,this._edge.getData())}},{key:"add",value:function(c,p){var g=new Bl(this._edge,c,p,this._edge.getSegmentOctant(p)),w=this._nodeMap.get(g);return w!==null?(St.isTrue(w.coord.equals2D(c),"Found equal nodes with different coordinates"),w):(this._nodeMap.put(g,g),g)}},{key:"checkSplitEdgesCorrectness",value:function(c){var p=this._edge.getCoordinates(),g=c.get(0).getCoordinate(0);if(!g.equals2D(p[0]))throw new Zt("bad split edge start point at "+g);var w=c.get(c.size()-1).getCoordinates(),L=w[w.length-1];if(!L.equals2D(p[p.length-1]))throw new Zt("bad split edge end point at "+L)}}],[{key:"constructor_",value:function(){this._nodeMap=new fo,this._edge=null;var c=arguments[0];this._edge=c}}]),M}(),ih=function(){function M(){s(this,M)}return h(M,null,[{key:"octant",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 octant for point ( "+c+", "+p+" )");var g=Math.abs(c),w=Math.abs(p);return c>=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<this._pts.length){var L=this._pts[w];c.equals2D(L)&&(g=w)}return this._nodeList.add(c,g)}},{key:"addIntersections",value:function(c,p,g){for(var w=0;w<c.getIntersectionNum();w++)this.addIntersection(c,p,g,w)}},{key:"interfaces_",get:function(){return[Fu]}}],[{key:"constructor_",value:function(){this._nodeList=new Un(this),this._pts=null,this._data=null;var c=arguments[0],p=arguments[1];this._pts=c,this._data=p}},{key:"getNodedSubstrings",value:function(){if(arguments.length===1){var c=arguments[0],p=new nn;return M.getNodedSubstrings(c,p),p}if(arguments.length===2)for(var g=arguments[0],w=arguments[1],L=g.iterator();L.hasNext();){var V=L.next();V.getNodeList().addSplitEdges(w)}}}]),M}(),Lr=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"minX",value:function(){return Math.min(this.p0.x,this.p1.x)}},{key:"orientationIndex",value:function(){if(arguments[0]instanceof M){var c=arguments[0],p=sn.index(this.p0,this.p1,c.p0),g=sn.index(this.p0,this.p1,c.p1);return p>=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))<w&&(w=L,g[0]=X,g[1]=c.p1);var Q=c.closestPoint(this.p0);(L=Q.distance(this.p0))<w&&(w=L,g[0]=this.p0,g[1]=Q);var ae=c.closestPoint(this.p1);return(L=ae.distance(this.p1))<w&&(w=L,g[0]=this.p1,g[1]=ae),g}},{key:"closestPoint",value:function(c){var p=this.projectionFactor(c);return p>0&&p<1?this.project(c):this.p0.distance(c)<this.p1.distance(c)?this.p0:this.p1}},{key:"maxX",value:function(){return Math.max(this.p0.x,this.p1.x)}},{key:"getLength",value:function(){return this.p0.distance(this.p1)}},{key:"compareTo",value:function(c){var p=c,g=this.p0.compareTo(p.p0);return g!==0?g:this.p1.compareTo(p.p1)}},{key:"reverse",value:function(){var c=this.p0;this.p0=this.p1,this.p1=c}},{key:"equalsTopo",value:function(c){return this.p0.equals(c.p0)&&this.p1.equals(c.p1)||this.p0.equals(c.p1)&&this.p1.equals(c.p0)}},{key:"lineIntersection",value:function(c){return Os.intersection(this.p0,this.p1,c.p0,c.p1)}},{key:"maxY",value:function(){return Math.max(this.p0.y,this.p1.y)}},{key:"pointAlongOffset",value:function(c,p){var g=this.p0.x+c*(this.p1.x-this.p0.x),w=this.p0.y+c*(this.p1.y-this.p0.y),L=this.p1.x-this.p0.x,V=this.p1.y-this.p0.y,X=Math.sqrt(L*L+V*V),Q=0,ae=0;if(p!==0){if(X<=0)throw new IllegalStateException("Cannot compute offset from zero-length line segment");Q=p*L/X,ae=p*V/X}return new je(g-ae,w+Q)}},{key:"setCoordinates",value:function(){if(arguments.length===1){var c=arguments[0];this.setCoordinates(c.p0,c.p1)}else if(arguments.length===2){var p=arguments[0],g=arguments[1];this.p0.x=p.x,this.p0.y=p.y,this.p1.x=g.x,this.p1.y=g.y}}},{key:"segmentFraction",value:function(c){var p=this.projectionFactor(c);return p<0?p=0:(p>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<X&&this.computeSelect(c,p,X,w),X<g&&this.computeSelect(c,X,g,w)}},{key:"getCoordinates",value:function(){for(var c=new Array(this._end-this._start+1).fill(null),p=0,g=this._start;g<=this._end;g++)c[p++]=this._pts[g];return c}},{key:"computeOverlaps",value:function(){if(arguments.length===2){var c=arguments[0],p=arguments[1];this.computeOverlaps(this._start,this._end,c,c._start,c._end,p)}else if(arguments.length===6){var g=arguments[0],w=arguments[1],L=arguments[2],V=arguments[3],X=arguments[4],Q=arguments[5];if(w-g==1&&X-V==1)return Q.overlap(this,g,L,V),null;if(!this.overlaps(g,w,L,V,X))return null;var ae=Math.trunc((g+w)/2),Le=Math.trunc((V+X)/2);g<ae&&(V<Le&&this.computeOverlaps(g,ae,L,V,Le,Q),Le<X&&this.computeOverlaps(g,ae,L,Le,X,Q)),ae<w&&(V<Le&&this.computeOverlaps(ae,w,L,V,Le,Q),Le<X&&this.computeOverlaps(ae,w,L,Le,X,Q))}}},{key:"setId",value:function(c){this._id=c}},{key:"select",value:function(c,p){this.computeSelect(c,this._start,this._end,p)}},{key:"getEnvelope",value:function(){if(this._env===null){var c=this._pts[this._start],p=this._pts[this._end];this._env=new bn(c,p)}return this._env}},{key:"overlaps",value:function(c,p,g,w,L){return bn.intersects(this._pts[c],this._pts[p],g._pts[w],g._pts[L])}},{key:"getEndIndex",value:function(){return this._end}},{key:"getStartIndex",value:function(){return this._start}},{key:"getContext",value:function(){return this._context}},{key:"getId",value:function(){return this._id}}],[{key:"constructor_",value:function(){this._pts=null,this._start=null,this._end=null,this._env=null,this._context=null,this._id=null;var c=arguments[0],p=arguments[1],g=arguments[2],w=arguments[3];this._pts=c,this._start=p,this._end=g,this._context=w}}]),M}(),$a=function(){function M(){s(this,M)}return h(M,null,[{key:"findChainEnd",value:function(c,p){for(var g=p;g<c.length-1&&c[g].equals2D(c[g+1]);)g++;if(g>=c.length-1)return c.length-1;for(var w=ar.quadrant(c[g],c[g+1]),L=p+1;L<c.length&&!(!c[L-1].equals2D(c[L])&&ar.quadrant(c[L-1],c[L])!==w);)L++;return L-1}},{key:"getChains",value:function(){if(arguments.length===1){var c=arguments[0];return M.getChains(c,null)}if(arguments.length===2){var p=arguments[0],g=arguments[1],w=new nn,L=0;do{var V=M.findChainEnd(p,L),X=new ps(p,L,V,g);w.add(X),L=V}while(L<p.length-1);return w}}}]),M}(),Jo=function(){function M(){s(this,M)}return h(M,[{key:"computeNodes",value:function(c){}},{key:"getNodedSubstrings",value:function(){}}]),M}(),Io=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"setSegmentIntersector",value:function(c){this._segInt=c}},{key:"interfaces_",get:function(){return[Jo]}}],[{key:"constructor_",value:function(){if(this._segInt=null,arguments.length!==0){if(arguments.length===1){var c=arguments[0];this.setSegmentIntersector(c)}}}}]),M}(),Fo=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:"getMonotoneChains",value:function(){return this._monoChains}},{key:"getNodedSubstrings",value:function(){return Bo.getNodedSubstrings(this._nodedSegStrings)}},{key:"getIndex",value:function(){return this._index}},{key:"add",value:function(g){for(var w=$a.getChains(g.getCoordinates(),g).iterator();w.hasNext();){var L=w.next();L.setId(this._idCounter++),this._index.insert(L.getEnvelope(),L),this._monoChains.add(L)}}},{key:"computeNodes",value:function(g){this._nodedSegStrings=g;for(var w=g.iterator();w.hasNext();)this.add(w.next());this.intersectChains()}},{key:"intersectChains",value:function(){for(var g=new ga(this._segInt),w=this._monoChains.iterator();w.hasNext();)for(var L=w.next(),V=this._index.query(L.getEnvelope()).iterator();V.hasNext();){var X=V.next();if(X.getId()>L.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<this._inputLine.length;){var L=!1;this.isDeletable(c,p,g,this._distanceTol)&&(this._isDeleted[p]=M.DELETE,L=!0,w=!0),c=L?g:p,p=this.findNextNonDeletedIndex(c),g=this.findNextNonDeletedIndex(p)}return w}},{key:"isShallowConcavity",value:function(c,p,g,w){return sn.index(c,p,g)===this._angleOrientation&&ne.pointToSegment(p,c,g)<w}},{key:"isShallowSampled",value:function(c,p,g,w,L){var V=Math.trunc((w-g)/M.NUM_PTS_TO_CHECK);V<=0&&(V=1);for(var X=g;X<w;X+=V)if(!this.isShallow(c,p,this._inputLine[X],L))return!1;return!0}},{key:"isConcave",value:function(c,p,g){var w=sn.index(c,p,g)===this._angleOrientation;return w}},{key:"simplify",value:function(c){this._distanceTol=Math.abs(c),c<0&&(this._angleOrientation=sn.CLOCKWISE),this._isDeleted=new Array(this._inputLine.length).fill(null);var p=!1;do p=this.deleteShallowConcavities();while(p);return this.collapseLine()}},{key:"findNextNonDeletedIndex",value:function(c){for(var p=c+1;p<this._inputLine.length&&this._isDeleted[p]===M.DELETE;)p++;return p}},{key:"isShallow",value:function(c,p,g,w){return ne.pointToSegment(p,c,g)<w}},{key:"collapseLine",value:function(){for(var c=new On,p=0;p<this._inputLine.length;p++)this._isDeleted[p]!==M.DELETE&&c.add(this._inputLine[p]);return c.toCoordinateArray()}}],[{key:"constructor_",value:function(){this._inputLine=null,this._distanceTol=null,this._isDeleted=null,this._angleOrientation=sn.COUNTERCLOCKWISE;var c=arguments[0];this._inputLine=c}},{key:"simplify",value:function(c,p){return new M(c).simplify(p)}}]),M}();Yr.INIT=0,Yr.DELETE=1,Yr.KEEP=1,Yr.NUM_PTS_TO_CHECK=10;var Bs=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getCoordinates",value:function(){return this._ptList.toArray(M.COORDINATE_ARRAY_TYPE)}},{key:"setPrecisionModel",value:function(c){this._precisionModel=c}},{key:"addPt",value:function(c){var p=new je(c);if(this._precisionModel.makePrecise(p),this.isRedundant(p))return null;this._ptList.add(p)}},{key:"reverse",value:function(){}},{key:"addPts",value:function(c,p){if(p)for(var g=0;g<c.length;g++)this.addPt(c[g]);else for(var w=c.length-1;w>=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)<this._minimimVertexDistance}},{key:"toString",value:function(){return new kr().createLineString(this.getCoordinates()).toString()}},{key:"closeRing",value:function(){if(this._ptList.size()<1)return null;var c=new je(this._ptList.get(0)),p=this._ptList.get(this._ptList.size()-1);if(c.equals(p))return null;this._ptList.add(c)}},{key:"setMinimumVertexDistance",value:function(c){this._minimimVertexDistance=c}}],[{key:"constructor_",value:function(){this._ptList=null,this._precisionModel=null,this._minimimVertexDistance=0,this._ptList=new nn}}]),M}();Bs.COORDINATE_ARRAY_TYPE=new Array(0).fill(null);var br=function(){function M(){s(this,M)}return h(M,null,[{key:"toDegrees",value:function(c){return 180*c/Math.PI}},{key:"normalize",value:function(c){for(;c>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=c<p?p-c:c-p)>Math.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)<this._distance*M.OFFSET_SEGMENT_SEPARATION_FACTOR)return this._segList.addPt(this._offset0.p1),null;this._bufParams.getJoinStyle()===ce.JOIN_MITRE?this.addMitreJoin(this._s1,this._offset0,this._offset1,this._distance):this._bufParams.getJoinStyle()===ce.JOIN_BEVEL?this.addBevelJoin(this._offset0,this._offset1):(p&&this._segList.addPt(this._offset0.p1),this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,c,this._distance),this._segList.addPt(this._offset1.p0))}},{key:"createSquare",value:function(c){this._segList.addPt(new je(c.x+this._distance,c.y+this._distance)),this._segList.addPt(new je(c.x+this._distance,c.y-this._distance)),this._segList.addPt(new je(c.x-this._distance,c.y-this._distance)),this._segList.addPt(new je(c.x-this._distance,c.y+this._distance)),this._segList.closeRing()}},{key:"addSegments",value:function(c,p){this._segList.addPts(c,p)}},{key:"addFirstSegment",value:function(){this._segList.addPt(this._offset1.p0)}},{key:"addCornerFillet",value:function(c,p,g,w,L){var V=p.x-c.x,X=p.y-c.y,Q=Math.atan2(X,V),ae=g.x-c.x,Le=g.y-c.y,Ne=Math.atan2(Le,ae);w===sn.CLOCKWISE?Q<=Ne&&(Q+=2*Math.PI):Q>=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;Ne<Q;Ne++){var rt=p+V*Ne*ae;Le.x=c.x+L*Math.cos(rt),Le.y=c.y+L*Math.sin(rt),this._segList.addPt(Le)}}},{key:"computeOffsetSegment",value:function(c,p,g,w){var L=p===wt.LEFT?1:-1,V=c.p1.x-c.p0.x,X=c.p1.y-c.p0.y,Q=Math.sqrt(V*V+X*X),ae=L*g*V/Q,Le=L*g*X/Q;w.p0.x=c.p0.x-Le,w.p0.y=c.p0.y+ae,w.p1.x=c.p1.x-Le,w.p1.y=c.p1.y+ae}},{key:"addInsideTurn",value:function(c,p){if(this._li.computeIntersection(this._offset0.p0,this._offset0.p1,this._offset1.p0,this._offset1.p1),this._li.hasIntersection())this._segList.addPt(this._li.getIntersection(0));else if(this._hasNarrowConcaveAngle=!0,this._offset0.p1.distance(this._offset1.p0)<this._distance*M.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR)this._segList.addPt(this._offset0.p1);else{if(this._segList.addPt(this._offset0.p1),this._closingSegLengthFactor>0){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;g<p.length;g++)p[g]=new je(c[g]);return p}}]),M}(),_a=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"findStabbedSegments",value:function(){if(arguments.length===1){for(var c=arguments[0],p=new nn,g=this._subgraphs.iterator();g.hasNext();){var w=g.next(),L=w.getEnvelope();c.y<L.getMinY()||c.y>L.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;Le<ae.length-1;Le++){this._seg.p0=ae[Le],this._seg.p1=ae[Le+1],this._seg.p0.y>this._seg.p1.y&&this._seg.reverse();var Ne=Math.max(this._seg.p0.x,this._seg.p1.x);if(!(Ne<V.x)&&!(this._seg.isHorizontal()||V.y<this._seg.p0.y||V.y>this._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)return null;var V=w,X=L;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;V<c.getNumInteriorRing();V++){var X=c.getInteriorRingN(V),Q=Ri.removeRepeatedPoints(X.getCoordinates());this._distance>0&&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)<Math.abs(p)}},{key:"addLineString",value:function(c){if(this._curveBuilder.isLineOffsetEmpty(this._distance))return null;var p=Ri.removeRepeatedPoints(c.getCoordinates());if(Ri.isRing(p)&&!this._curveBuilder.getBufferParameters().isSingleSided())this.addRingBothSides(p,this._distance);else{var g=this._curveBuilder.getLineCurve(p,this._distance);this.addCurve(g,Me.EXTERIOR,Me.INTERIOR)}}},{key:"addCurve",value:function(c,p,g){if(c===null||c.length<2)return null;var w=new Bo(c,new rr(0,Me.BOUNDARY,p,g));this._curveList.add(w)}},{key:"getCurves",value:function(){return this.add(this._inputGeom),this._curveList}},{key:"add",value:function(c){if(c.isEmpty())return null;if(c instanceof Sn)this.addPolygon(c);else if(c instanceof It)this.addLineString(c);else if(c instanceof ln)this.addPoint(c);else if(c instanceof $r)this.addCollection(c);else if(c instanceof Qe)this.addCollection(c);else if(c instanceof aa)this.addCollection(c);else{if(!(c instanceof $n))throw new yn(c.getGeometryType());this.addCollection(c)}}},{key:"isErodedCompletely",value:function(c,p){var g=c.getCoordinates();if(g.length<4)return p<0;if(g.length===4)return this.isTriangleErodedCompletely(g,p);var w=c.getEnvelopeInternal(),L=Math.min(w.getHeight(),w.getWidth());return p<0&&2*Math.abs(p)>L}},{key:"addCollection",value:function(c){for(var p=0;p<c.getNumGeometries();p++){var g=c.getGeometryN(p);this.add(g)}}}],[{key:"constructor_",value:function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new nn;var c=arguments[0],p=arguments[1],g=arguments[2];this._inputGeom=c,this._distance=p,this._curveBuilder=g}}]),M}(),Uu=function(){function M(){s(this,M)}return h(M,[{key:"locate",value:function(c){}}]),M}(),_s=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"next",value:function(){if(this._atStart)return this._atStart=!1,M.isAtomic(this._parent)&&this._index++,this._parent;if(this._subcollectionIterator!==null){if(this._subcollectionIterator.hasNext())return this._subcollectionIterator.next();this._subcollectionIterator=null}if(this._index>=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<p.getNumInteriorRing();L++){var V=p.getInteriorRingN(L),X=M.locatePointInRing(c,V);if(X===Me.BOUNDARY)return Me.BOUNDARY;if(X===Me.INTERIOR)return Me.EXTERIOR}return Me.INTERIOR}},{key:"locatePointInRing",value:function(c,p){return p.getEnvelopeInternal().intersects(c)?fs.locateInRing(c,p.getCoordinates()):Me.EXTERIOR}},{key:"containsPointInPolygon",value:function(c,p){return Me.EXTERIOR!==M.locatePointInPolygon(c,p)}},{key:"locateInGeometry",value:function(c,p){if(p instanceof Sn)return M.locatePointInPolygon(c,p);if(p instanceof $n)for(var g=new _s(p);g.hasNext();){var w=g.next();if(w!==p){var L=M.locateInGeometry(c,w);if(L!==Me.EXTERIOR)return L}}return Me.EXTERIOR}},{key:"isContained",value:function(c,p){return Me.EXTERIOR!==M.locate(c,p)}},{key:"locate",value:function(c,p){return p.isEmpty()?Me.EXTERIOR:p.getEnvelopeInternal().intersects(c)?M.locateInGeometry(c,p):Me.EXTERIOR}}]),M}(),rh=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getNextCW",value:function(c){this.getEdges();var p=this._edgeList.indexOf(c),g=p-1;return p===0&&(g=this._edgeList.size()-1),this._edgeList.get(g)}},{key:"propagateSideLabels",value:function(c){for(var p=Me.NONE,g=this.iterator();g.hasNext();){var w=g.next().getLabel();w.isArea(c)&&w.getLocation(c,wt.LEFT)!==Me.NONE&&(p=w.getLocation(c,wt.LEFT))}if(p===Me.NONE)return null;for(var L=p,V=this.iterator();V.hasNext();){var X=V.next(),Q=X.getLabel();if(Q.getLocation(c,wt.ON)===Me.NONE&&Q.setLocation(c,wt.ON,L),Q.isArea(c)){var ae=Q.getLocation(c,wt.LEFT),Le=Q.getLocation(c,wt.RIGHT);if(Le!==Me.NONE){if(Le!==L)throw new vr("side location conflict",X.getCoordinate());ae===Me.NONE&&St.shouldNeverReachHere("found single null side (at "+X.getCoordinate()+")"),L=ae}else St.isTrue(Q.getLocation(c,wt.LEFT)===Me.NONE,"found single null side"),Q.setLocation(c,wt.RIGHT,L),Q.setLocation(c,wt.LEFT,L)}}}},{key:"getCoordinate",value:function(){var c=this.iterator();return c.hasNext()?c.next().getCoordinate():null}},{key:"print",value:function(c){xe.out.println("EdgeEndStar: "+this.getCoordinate());for(var p=this.iterator();p.hasNext();)p.next().print(c)}},{key:"isAreaLabelsConsistent",value:function(c){return this.computeEdgeEndLabels(c.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)}},{key:"checkAreaLabelsConsistent",value:function(c){var p=this.getEdges();if(p.size()<=0)return!0;var g=p.size()-1,w=p.get(g).getLabel().getLocation(c,wt.LEFT);St.isTrue(w!==Me.NONE,"Found unlabelled area edge");for(var L=w,V=this.iterator();V.hasNext();){var X=V.next().getLabel();St.isTrue(X.isArea(c),"Found non-area edge");var Q=X.getLocation(c,wt.LEFT),ae=X.getLocation(c,wt.RIGHT);if(Q===ae||ae!==L)return!1;L=Q}return!0}},{key:"findIndex",value:function(c){this.iterator();for(var p=0;p<this._edgeList.size();p++)if(this._edgeList.get(p)===c)return p;return-1}},{key:"iterator",value:function(){return this.getEdges().iterator()}},{key:"getEdges",value:function(){return this._edgeList===null&&(this._edgeList=new nn(this._edgeMap.values())),this._edgeList}},{key:"getLocation",value:function(c,p,g){return this._ptInAreaLocation[c]===Me.NONE&&(this._ptInAreaLocation[c]=jl.locate(p,g[c].getGeometry())),this._ptInAreaLocation[c]}},{key:"toString",value:function(){var c=new lo;c.append("EdgeEndStar: "+this.getCoordinate()),c.append(`
|
|
|
`);for(var p=this.iterator();p.hasNext();){var g=p.next();c.append(g),c.append(`
|
|
|
`)}return c.toString()}},{key:"computeEdgeEndLabels",value:function(c){for(var p=this.iterator();p.hasNext();)p.next().computeLabel(c)}},{key:"computeLabelling",value:function(c){this.computeEdgeEndLabels(c[0].getBoundaryNodeRule()),this.propagateSideLabels(0),this.propagateSideLabels(1);for(var p=[!1,!1],g=this.iterator();g.hasNext();)for(var w=g.next().getLabel(),L=0;L<2;L++)w.isLine(L)&&w.getLocation(L)===Me.BOUNDARY&&(p[L]=!0);for(var V=this.iterator();V.hasNext();)for(var X=V.next(),Q=X.getLabel(),ae=0;ae<2;ae++)if(Q.isAnyNull(ae)){var Le=Me.NONE;if(p[ae])Le=Me.EXTERIOR;else{var Ne=X.getCoordinate();Le=this.getLocation(ae,Ne,c)}Q.setAllLocationsIfNull(ae,Le)}}},{key:"getDegree",value:function(){return this._edgeMap.size()}},{key:"insertEdgeEnd",value:function(c,p){this._edgeMap.put(c,p),this._edgeList=null}}],[{key:"constructor_",value:function(){this._edgeMap=new fo,this._edgeList=null,this._ptInAreaLocation=[Me.NONE,Me.NONE]}}]),M}(),oh=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:"linkResultDirectedEdges",value:function(){this.getResultAreaEdges();for(var g=null,w=null,L=this._SCANNING_FOR_INCOMING,V=0;V<this._resultAreaEdgeList.size();V++){var X=this._resultAreaEdgeList.get(V),Q=X.getSym();if(X.getLabel().isArea())switch(g===null&&X.isInResult()&&(g=X),L){case this._SCANNING_FOR_INCOMING:if(!Q.isInResult())continue;w=Q,L=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(!X.isInResult())continue;w.setNext(X),L=this._SCANNING_FOR_INCOMING}}if(L===this._LINKING_TO_OUTGOING){if(g===null)throw new vr("no outgoing dirEdge found",this.getCoordinate());St.isTrue(g.isInResult(),"unable to link last incoming dirEdge"),w.setNext(g)}}},{key:"insert",value:function(g){var w=g;this.insertEdgeEnd(w,w)}},{key:"getRightmostEdge",value:function(){var g=this.getEdges(),w=g.size();if(w<1)return null;var L=g.get(0);if(w===1)return L;var V=g.get(w-1),X=L.getQuadrant(),Q=V.getQuadrant();return ar.isNorthern(X)&&ar.isNorthern(Q)?L:ar.isNorthern(X)||ar.isNorthern(Q)?L.getDy()!==0?L:V.getDy()!==0?V:(St.shouldNeverReachHere("found two horizontal edges incident on node"),null):V}},{key:"print",value:function(g){xe.out.println("DirectedEdgeStar: "+this.getCoordinate());for(var w=this.iterator();w.hasNext();){var L=w.next();g.print("out "),L.print(g),g.println(),g.print("in "),L.getSym().print(g),g.println()}}},{key:"getResultAreaEdges",value:function(){if(this._resultAreaEdgeList!==null)return this._resultAreaEdgeList;this._resultAreaEdgeList=new nn;for(var g=this.iterator();g.hasNext();){var w=g.next();(w.isInResult()||w.getSym().isInResult())&&this._resultAreaEdgeList.add(w)}return this._resultAreaEdgeList}},{key:"updateLabelling",value:function(g){for(var w=this.iterator();w.hasNext();){var L=w.next().getLabel();L.setAllLocationsIfNull(0,g.getLocation(0)),L.setAllLocationsIfNull(1,g.getLocation(1))}}},{key:"linkAllDirectedEdges",value:function(){this.getEdges();for(var g=null,w=null,L=this._edgeList.size()-1;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<Le;kt++){var Ct=this._edgeList.get(kt);Ct.setEdgeDepths(wt.RIGHT,rt),rt=Ct.getDepth(wt.LEFT)}return rt}}},{key:"mergeSymLabels",value:function(){for(var g=this.iterator();g.hasNext();){var w=g.next();w.getLabel().merge(w.getSym().getLabel())}}},{key:"linkMinimalDirectedEdges",value:function(g){for(var w=null,L=null,V=this._SCANNING_FOR_INCOMING,X=this._resultAreaEdgeList.size()-1;X>=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;p<this._edges.size();p++){var g=this._edges.get(p);p>0&&c.print(","),c.print("(");for(var w=g.getCoordinates(),L=0;L<w.length;L++)L>0&&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;p<this._edges.size();p++)if(this._edges.get(p).equals(c))return p;return-1}},{key:"iterator",value:function(){return this._edges.iterator()}},{key:"getEdges",value:function(){return this._edges}},{key:"get",value:function(c){return this._edges.get(c)}},{key:"findEqualEdge",value:function(c){var p=new Ya(c.getCoordinates());return this._ocaMap.get(p)}},{key:"add",value:function(c){this._edges.add(c);var p=new Ya(c.getCoordinates());this._ocaMap.put(p,c)}}],[{key:"constructor_",value:function(){this._edges=new nn,this._ocaMap=new fo}}]),M}(),Ha=function(){function M(){s(this,M)}return h(M,[{key:"processIntersections",value:function(c,p,g,w){}},{key:"isDone",value:function(){}}]),M}(),Ka=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"isTrivialIntersection",value:function(c,p,g,w){if(c===g&&this._li.getIntersectionNum()===1){if(M.isAdjacentSegments(p,w))return!0;if(c.isClosed()){var L=c.size()-1;if(p===0&&w===L||w===0&&p===L)return!0}}return!1}},{key:"getProperIntersectionPoint",value:function(){return this._properIntersectionPoint}},{key:"hasProperInteriorIntersection",value:function(){return this._hasProperInterior}},{key:"getLineIntersector",value:function(){return this._li}},{key:"hasProperIntersection",value:function(){return this._hasProper}},{key:"processIntersections",value:function(c,p,g,w){if(c===g&&p===w)return null;this.numTests++;var L=c.getCoordinates()[p],V=c.getCoordinates()[p+1],X=g.getCoordinates()[w],Q=g.getCoordinates()[w+1];this._li.computeIntersection(L,V,X,Q),this._li.hasIntersection()&&(this.numIntersections++,this._li.isInteriorIntersection()&&(this.numInteriorIntersections++,this._hasInterior=!0),this.isTrivialIntersection(c,p,g,w)||(this._hasIntersection=!0,c.addIntersections(this._li,p,0),g.addIntersections(this._li,w,1),this._li.isProper()&&(this.numProperIntersections++,this._hasProper=!0,this._hasProperInterior=!0)))}},{key:"hasIntersection",value:function(){return this._hasIntersection}},{key:"isDone",value:function(){return!1}},{key:"hasInteriorIntersection",value:function(){return this._hasInterior}},{key:"interfaces_",get:function(){return[Ha]}}],[{key:"constructor_",value:function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._hasInterior=!1,this._properIntersectionPoint=null,this._li=null,this._isSelfIntersection=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0;var c=arguments[0];this._li=c}},{key:"isAdjacentSegments",value:function(c,p){return Math.abs(c-p)===1}}]),M}(),ju=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getSegmentIndex",value:function(){return this.segmentIndex}},{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(c){c.print(this.coord),c.print(" seg # = "+this.segmentIndex),c.println(" dist = "+this.dist)}},{key:"compareTo",value:function(c){var p=c;return this.compare(p.segmentIndex,p.dist)}},{key:"isEndPoint",value:function(c){return this.segmentIndex===0&&this.dist===0||this.segmentIndex===c}},{key:"toString",value:function(){return this.coord+" seg # = "+this.segmentIndex+" dist = "+this.dist}},{key:"getDistance",value:function(){return this.dist}},{key:"compare",value:function(c,p){return this.segmentIndex<c?-1:this.segmentIndex>c?1:this.dist<p?-1:this.dist>p?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<c.length;p++){var g=Math.trunc(p/3),w=p%3;this._matrix[g][w]=me.toDimensionValue(c.charAt(p))}else if(arguments.length===3){var L=arguments[0],V=arguments[1],X=arguments[2];this._matrix[L][V]=X}}},{key:"isContains",value:function(){return M.isTrue(this._matrix[Me.INTERIOR][Me.INTERIOR])&&this._matrix[Me.EXTERIOR][Me.INTERIOR]===me.FALSE&&this._matrix[Me.EXTERIOR][Me.BOUNDARY]===me.FALSE}},{key:"setAtLeast",value:function(){if(arguments.length===1)for(var c=arguments[0],p=0;p<c.length;p++){var g=Math.trunc(p/3),w=p%3;this.setAtLeast(g,w,me.toDimensionValue(c.charAt(p)))}else if(arguments.length===3){var L=arguments[0],V=arguments[1],X=arguments[2];this._matrix[L][V]<X&&(this._matrix[L][V]=X)}}},{key:"setAtLeastIfValid",value:function(c,p,g){c>=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(p<c.length-1);return g.toArray()}},{key:"findChainEnd",value:function(c,p){for(var g=ar.quadrant(c[p],c[p+1]),w=p+1;w<c.length&&ar.quadrant(c[w-1],c[w])===g;)w++;return w-1}},{key:"OLDgetChainStartIndices",value:function(c){var p=0,g=new nn;g.add(p);do{var w=this.findChainEnd(c,p);g.add(w),p=w}while(p<c.length-1);return M.toIntArray(g)}}],[{key:"toIntArray",value:function(c){for(var p=new Array(c.size()).fill(null),g=0;g<p.length;g++)p[g]=c.get(g).intValue();return p}}]),M}(),ql=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getCoordinates",value:function(){return this.pts}},{key:"getMaxX",value:function(c){var p=this.pts[this.startIndex[c]].x,g=this.pts[this.startIndex[c+1]].x;return p>g?p:g}},{key:"getMinX",value:function(c){var p=this.pts[this.startIndex[c]].x,g=this.pts[this.startIndex[c+1]].x;return p<g?p:g}},{key:"computeIntersectsForChain",value:function(){if(arguments.length===4){var c=arguments[0],p=arguments[1],g=arguments[2],w=arguments[3];this.computeIntersectsForChain(this.startIndex[c],this.startIndex[c+1],p,p.startIndex[g],p.startIndex[g+1],w)}else if(arguments.length===6){var L=arguments[0],V=arguments[1],X=arguments[2],Q=arguments[3],ae=arguments[4],Le=arguments[5];if(V-L==1&&ae-Q==1)return Le.addIntersections(this.e,L,X.e,Q),null;if(!this.overlaps(L,V,X,Q,ae))return null;var Ne=Math.trunc((L+V)/2),rt=Math.trunc((Q+ae)/2);L<Ne&&(Q<rt&&this.computeIntersectsForChain(L,Ne,X,Q,rt,Le),rt<ae&&this.computeIntersectsForChain(L,Ne,X,rt,ae,Le)),Ne<V&&(Q<rt&&this.computeIntersectsForChain(Ne,V,X,Q,rt,Le),rt<ae&&this.computeIntersectsForChain(Ne,V,X,rt,ae,Le))}}},{key:"overlaps",value:function(c,p,g,w,L){return bn.intersects(this.pts[c],this.pts[p],g.pts[w],g.pts[L])}},{key:"getStartIndexes",value:function(){return this.startIndex}},{key:"computeIntersects",value:function(c,p){for(var g=0;g<this.startIndex.length-1;g++)for(var w=0;w<c.startIndex.length-1;w++)this.computeIntersectsForChain(g,c,w,p)}}],[{key:"constructor_",value:function(){this.e=null,this.pts=null,this.startIndex=null;var c=arguments[0];this.e=c,this.pts=c.getCoordinates();var p=new Fs;this.startIndex=p.getChainStartIndices(this.pts)}}]),M}(),Vs=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"getDepth",value:function(c,p){return this._depth[c][p]}},{key:"setDepth",value:function(c,p,g){this._depth[c][p]=g}},{key:"isNull",value:function(){if(arguments.length===0){for(var c=0;c<2;c++)for(var p=0;p<3;p++)if(this._depth[c][p]!==M.NULL_VALUE)return!1;return!0}if(arguments.length===1){var g=arguments[0];return this._depth[g][1]===M.NULL_VALUE}if(arguments.length===2){var w=arguments[0],L=arguments[1];return this._depth[w][L]===M.NULL_VALUE}}},{key:"normalize",value:function(){for(var c=0;c<2;c++)if(!this.isNull(c)){var p=this._depth[c][1];this._depth[c][2]<p&&(p=this._depth[c][2]),p<0&&(p=0);for(var g=1;g<3;g++){var w=0;this._depth[c][g]>p&&(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;Q<this.pts.length;Q++)if(this.pts[Q].equals2D(w.pts[Q])||(L=!1),this.pts[Q].equals2D(w.pts[--X])||(V=!1),!L&&!V)return!1;return!0}},{key:"getCoordinate",value:function(){if(arguments.length===0)return this.pts.length>0?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;w<this.pts.length;w++)w>0&&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;g<this.pts.length;g++)this._env.expandToInclude(this.pts[g])}return this._env}},{key:"addIntersection",value:function(g,w,L,V){var X=new je(g.getIntersection(V)),Q=w,ae=g.getEdgeDistance(L,V),Le=Q+1;if(Le<this.pts.length){var Ne=this.pts[Le];X.equals2D(Ne)&&(Q=Le,ae=0)}this.eiList.add(X,Q,ae)}},{key:"toString",value:function(){var g=new us;g.append("edge "+this._name+": "),g.append("LINESTRING (");for(var w=0;w<this.pts.length;w++)w>0&&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;w<this.pts.length;w++)if(!this.pts[w].equals2D(g.pts[w]))return!1;return!0}},{key:"setDepthDelta",value:function(g){this._depthDelta=g}},{key:"getEdgeIntersectionList",value:function(){return this.eiList}},{key:"addIntersections",value:function(g,w,L){for(var V=0;V<g.getIntersectionNum();V++)this.addIntersection(g,w,L,V)}}],[{key:"constructor_",value:function(){if(this.pts=null,this._env=null,this.eiList=new Gu(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new Vs,this._depthDelta=0,arguments.length===1){var g=arguments[0];p.constructor_.call(this,g,null)}else if(arguments.length===2){var w=arguments[0],L=arguments[1];this.pts=w,this._label=L}}},{key:"updateIM",value:function(){if(!(arguments.length===2&&arguments[1]instanceof ah&&arguments[0]instanceof rr))return Z(x(p),"updateIM",this).apply(this,arguments);var g=arguments[0],w=arguments[1];w.setAtLeastIfValid(g.getLocation(0,wt.ON),g.getLocation(1,wt.ON),1),g.isArea()&&(w.setAtLeastIfValid(g.getLocation(0,wt.LEFT),g.getLocation(1,wt.LEFT),2),w.setAtLeastIfValid(g.getLocation(0,wt.RIGHT),g.getLocation(1,wt.RIGHT),2))}}]),p}(ja),_o=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"setWorkingPrecisionModel",value:function(c){this._workingPrecisionModel=c}},{key:"insertUniqueEdge",value:function(c){var p=this._edgeList.findEqualEdge(c);if(p!==null){var g=p.getLabel(),w=c.getLabel();p.isPointwiseEqual(c)||(w=new rr(c.getLabel())).flip(),g.merge(w);var L=M.depthDelta(w),V=p.getDepthDelta()+L;p.setDepthDelta(V)}else this._edgeList.add(c),c.setDepthDelta(M.depthDelta(c.getLabel()))}},{key:"buildSubgraphs",value:function(c,p){for(var g=new nn,w=c.iterator();w.hasNext();){var L=w.next(),V=L.getRightmostCoordinate(),X=new _a(g).getDepth(V);L.computeDepth(X),L.findResultEdges(),g.add(L),p.add(L.getDirectedEdges(),L.getNodes())}}},{key:"createSubgraphs",value:function(c){for(var p=new nn,g=c.getNodes().iterator();g.hasNext();){var w=g.next();if(!w.isVisited()){var L=new zs;L.create(w),p.add(L)}}return Ar.sort(p,Ar.reverseOrder()),p}},{key:"createEmptyResultGeometry",value:function(){return this._geomFact.createPolygon()}},{key:"getNoder",value:function(c){if(this._workingNoder!==null)return this._workingNoder;var p=new Fo,g=new Ko;return g.setPrecisionModel(c),p.setSegmentIntersector(new Ka(g)),p}},{key:"buffer",value:function(c,p){var g=this._workingPrecisionModel;g===null&&(g=c.getPrecisionModel()),this._geomFact=c.getFactory();var w=new Xa(g,this._bufParams),L=new Ul(c,p,w).getCurves();if(L.size()<=0)return this.createEmptyResultGeometry();this.computeNodedEdges(L,g),this._graph=new ha(new sh),this._graph.addEdges(this._edgeList.getEdges());var V=this.createSubgraphs(this._graph),X=new nh(this._geomFact);this.buildSubgraphs(V,X);var Q=X.getPolygons();return Q.size()<=0?this.createEmptyResultGeometry():this._geomFact.buildGeometry(Q)}},{key:"computeNodedEdges",value:function(c,p){var g=this.getNoder(p);g.computeNodes(c);for(var w=g.getNodedSubstrings().iterator();w.hasNext();){var L=w.next(),V=L.getCoordinates();if(V.length!==2||!V[0].equals2D(V[1])){var X=L.getData(),Q=new Ja(L.getCoordinates(),new rr(X));this.insertUniqueEdge(Q)}}}},{key:"setNoder",value:function(c){this._workingNoder=c}}],[{key:"constructor_",value:function(){this._bufParams=null,this._workingPrecisionModel=null,this._workingNoder=null,this._geomFact=null,this._graph=null,this._edgeList=new Gl;var c=arguments[0];this._bufParams=c}},{key:"depthDelta",value:function(c){var p=c.getLocation(0,wt.LEFT),g=c.getLocation(0,wt.RIGHT);return p===Me.INTERIOR&&g===Me.EXTERIOR?1:p===Me.EXTERIOR&&g===Me.INTERIOR?-1:0}},{key:"convertSegStrings",value:function(c){for(var p=new kr,g=new nn;c.hasNext();){var w=c.next(),L=p.createLineString(w.getCoordinates());g.add(L)}return p.buildGeometry(g)}}]),M}(),Qa=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"rescale",value:function(){if(an(arguments[0],Fn))for(var c=arguments[0],p=c.iterator();p.hasNext();){var g=p.next();this.rescale(g.getCoordinates())}else if(arguments[0]instanceof Array){for(var w=arguments[0],L=0;L<w.length;L++)w[L].x=w[L].x/this._scaleFactor+this._offsetX,w[L].y=w[L].y/this._scaleFactor+this._offsetY;w.length===2&&w[0].equals2D(w[1])&&xe.out.println(w)}}},{key:"scale",value:function(){if(an(arguments[0],Fn)){for(var c=arguments[0],p=new nn(c.size()),g=c.iterator();g.hasNext();){var w=g.next();p.add(new Bo(this.scale(w.getCoordinates()),w.getData()))}return p}if(arguments[0]instanceof Array){for(var L=arguments[0],V=new Array(L.length).fill(null),X=0;X<L.length;X++)V[X]=new je(Math.round((L[X].x-this._offsetX)*this._scaleFactor),Math.round((L[X].y-this._offsetY)*this._scaleFactor),L[X].getZ());var Q=Ri.removeRepeatedPoints(V);return Q}}},{key:"isIntegerPrecision",value:function(){return this._scaleFactor===1}},{key:"getNodedSubstrings",value:function(){var c=this._noder.getNodedSubstrings();return this._isScaled&&this.rescale(c),c}},{key:"computeNodes",value:function(c){var p=c;this._isScaled&&(p=this.scale(c)),this._noder.computeNodes(p)}},{key:"interfaces_",get:function(){return[Jo]}}],[{key:"constructor_",value:function(){if(this._noder=null,this._scaleFactor=null,this._offsetX=null,this._offsetY=null,this._isScaled=!1,arguments.length===2){var c=arguments[0],p=arguments[1];M.constructor_.call(this,c,p,0,0)}else if(arguments.length===4){var g=arguments[0],w=arguments[1];this._noder=g,this._scaleFactor=w,this._isScaled=!this.isIntegerPrecision()}}}]),M}(),el=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"checkEndPtVertexIntersections",value:function(){if(arguments.length===0)for(var c=this._segStrings.iterator();c.hasNext();){var p=c.next(),g=p.getCoordinates();this.checkEndPtVertexIntersections(g[0],this._segStrings),this.checkEndPtVertexIntersections(g[g.length-1],this._segStrings)}else if(arguments.length===2){for(var w=arguments[0],L=arguments[1],V=L.iterator();V.hasNext();)for(var X=V.next(),Q=X.getCoordinates(),ae=1;ae<Q.length-1;ae++)if(Q[ae].equals(w))throw new Zt("found endpt/interior pt intersection at index "+ae+" :pt "+w)}}},{key:"checkInteriorIntersections",value:function(){if(arguments.length===0)for(var c=this._segStrings.iterator();c.hasNext();)for(var p=c.next(),g=this._segStrings.iterator();g.hasNext();){var w=g.next();this.checkInteriorIntersections(p,w)}else if(arguments.length===2)for(var L=arguments[0],V=arguments[1],X=L.getCoordinates(),Q=V.getCoordinates(),ae=0;ae<X.length-1;ae++)for(var Le=0;Le<Q.length-1;Le++)this.checkInteriorIntersections(L,ae,V,Le);else if(arguments.length===4){var Ne=arguments[0],rt=arguments[1],kt=arguments[2],Ct=arguments[3];if(Ne===kt&&rt===Ct)return null;var Qt=Ne.getCoordinates()[rt],Ht=Ne.getCoordinates()[rt+1],dn=kt.getCoordinates()[Ct],Rn=kt.getCoordinates()[Ct+1];if(this._li.computeIntersection(Qt,Ht,dn,Rn),this._li.hasIntersection()&&(this._li.isProper()||this.hasInteriorIntersection(this._li,Qt,Ht)||this.hasInteriorIntersection(this._li,dn,Rn)))throw new Zt("found non-noded intersection at "+Qt+"-"+Ht+" and "+dn+"-"+Rn)}}},{key:"checkValid",value:function(){this.checkEndPtVertexIntersections(),this.checkInteriorIntersections(),this.checkCollapses()}},{key:"checkCollapses",value:function(){if(arguments.length===0)for(var c=this._segStrings.iterator();c.hasNext();){var p=c.next();this.checkCollapses(p)}else if(arguments.length===1)for(var g=arguments[0],w=g.getCoordinates(),L=0;L<w.length-2;L++)this.checkCollapse(w[L],w[L+1],w[L+2])}},{key:"hasInteriorIntersection",value:function(c,p,g){for(var w=0;w<c.getIntersectionNum();w++){var L=c.getIntersection(w);if(!L.equals(p)&&!L.equals(g))return!0}return!1}},{key:"checkCollapse",value:function(c,p,g){if(c.equals(g))throw new Zt("found non-noded collapse at "+M.fact.createLineString([c,p,g]))}}],[{key:"constructor_",value:function(){this._li=new Ko,this._segStrings=null;var c=arguments[0];this._segStrings=c}}]),M}();el.fact=new kr;var Us=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"intersectsScaled",value:function(c,p){var g=Math.min(c.x,p.x),w=Math.max(c.x,p.x),L=Math.min(c.y,p.y),V=Math.max(c.y,p.y),X=this._maxx<g||this._minx>w||this._maxy<L||this._miny>V;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<this._li.getIntersectionNum();ae++)this._interiorIntersections.add(this._li.getIntersection(ae));c.addIntersections(this._li,p,0),g.addIntersections(this._li,w,1)}}},{key:"isDone",value:function(){return!1}},{key:"getInteriorIntersections",value:function(){return this._interiorIntersections}},{key:"interfaces_",get:function(){return[Ha]}}],[{key:"constructor_",value:function(){this._li=null,this._interiorIntersections=null;var c=arguments[0];this._li=c,this._interiorIntersections=new nn}}]),M}(),nl=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"checkCorrectness",value:function(c){var p=Bo.getNodedSubstrings(c),g=new el(p);try{g.checkValid()}catch(w){if(!(w instanceof be))throw w;w.printStackTrace()}}},{key:"getNodedSubstrings",value:function(){return Bo.getNodedSubstrings(this._nodedSegStrings)}},{key:"snapRound",value:function(c,p){var g=this.findInteriorIntersections(c,p);this.computeIntersectionSnaps(g),this.computeVertexSnaps(c)}},{key:"findInteriorIntersections",value:function(c,p){var g=new Zl(p);return this._noder.setSegmentIntersector(g),this._noder.computeNodes(c),g.getInteriorIntersections()}},{key:"computeVertexSnaps",value:function(){if(an(arguments[0],Fn))for(var c=arguments[0],p=c.iterator();p.hasNext();){var g=p.next();this.computeVertexSnaps(g)}else if(arguments[0]instanceof Bo)for(var w=arguments[0],L=w.getCoordinates(),V=0;V<L.length;V++){var X=new Us(L[V],this._scaleFactor,this._li),Q=this._pointSnapper.snap(X,w,V);Q&&w.addIntersection(L[V],V)}}},{key:"computeNodes",value:function(c){this._nodedSegStrings=c,this._noder=new Fo,this._pointSnapper=new tl(this._noder.getIndex()),this.snapRound(c,this._li)}},{key:"computeIntersectionSnaps",value:function(c){for(var p=c.iterator();p.hasNext();){var g=p.next(),w=new Us(g,this._scaleFactor,this._li);this._pointSnapper.snap(w)}}},{key:"interfaces_",get:function(){return[Jo]}}],[{key:"constructor_",value:function(){this._pm=null,this._li=null,this._scaleFactor=null,this._noder=null,this._pointSnapper=null,this._nodedSegStrings=null;var c=arguments[0];this._pm=c,this._li=new Ko,this._li.setPrecisionModel(c),this._scaleFactor=c.getScale()}}]),M}(),Mo=function(){function M(){s(this,M),M.constructor_.apply(this,arguments)}return h(M,[{key:"bufferFixedPrecision",value:function(c){var p=new Qa(new nl(new Fi(1)),c.getScale()),g=new _o(this._bufParams);g.setWorkingPrecisionModel(c),g.setNoder(p),this._resultGeometry=g.buffer(this._argGeom,this._distance)}},{key:"bufferReducedPrecision",value:function(){if(arguments.length===0){for(var c=M.MAX_PRECISION_DIGITS;c>=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;p<M.features.length;++p)c.features.push(this.read(M.features[p]))}return M.bbox&&(c.bbox=this.parse.bbox.call(this,M.bbox)),c},coordinates:function(M){for(var c=[],p=0;p<M.length;++p){var g=M[p];c.push(k(je,J(g)))}return c},bbox:function(M){return this.geometryFactory.createLinearRing([new je(M[0],M[1]),new je(M[2],M[1]),new je(M[2],M[3]),new je(M[0],M[3]),new je(M[0],M[1])])},Point:function(M){var c=k(je,J(M));return this.geometryFactory.createPoint(c)},MultiPoint:function(M){for(var c=[],p=0;p<M.length;++p)c.push(Hr.Point.call(this,M[p]));return this.geometryFactory.createMultiPoint(c)},LineString:function(M){var c=Hr.coordinates.call(this,M);return this.geometryFactory.createLineString(c)},MultiLineString:function(M){for(var c=[],p=0;p<M.length;++p)c.push(Hr.LineString.call(this,M[p]));return this.geometryFactory.createMultiLineString(c)},Polygon:function(M){for(var c=Hr.coordinates.call(this,M[0]),p=this.geometryFactory.createLinearRing(c),g=[],w=1;w<M.length;++w){var L=M[w],V=Hr.coordinates.call(this,L),X=this.geometryFactory.createLinearRing(V);g.push(X)}return this.geometryFactory.createPolygon(p,g)},MultiPolygon:function(M){for(var c=[],p=0;p<M.length;++p){var g=M[p];c.push(Hr.Polygon.call(this,g))}return this.geometryFactory.createMultiPolygon(c)},GeometryCollection:function(M){for(var c=[],p=0;p<M.length;++p){var g=M[p];c.push(this.read(g))}return this.geometryFactory.createGeometryCollection(c)}},Kr={coordinate:function(M){var c=[M.x,M.y];return M.z&&c.push(M.z),M.m&&c.push(M.m),c},Point:function(M){return{type:"Point",coordinates:Kr.coordinate.call(this,M.getCoordinate())}},MultiPoint:function(M){for(var c=[],p=0;p<M._geometries.length;++p){var g=M._geometries[p],w=Kr.Point.call(this,g);c.push(w.coordinates)}return{type:"MultiPoint",coordinates:c}},LineString:function(M){for(var c=[],p=M.getCoordinates(),g=0;g<p.length;++g){var w=p[g];c.push(Kr.coordinate.call(this,w))}return{type:"LineString",coordinates:c}},MultiLineString:function(M){for(var c=[],p=0;p<M._geometries.length;++p){var g=M._geometries[p],w=Kr.LineString.call(this,g);c.push(w.coordinates)}return{type:"MultiLineString",coordinates:c}},Polygon:function(M){var c=[],p=Kr.LineString.call(this,M._shell);c.push(p.coordinates);for(var g=0;g<M._holes.length;++g){var w=M._holes[g],L=Kr.LineString.call(this,w);c.push(L.coordinates)}return{type:"Polygon",coordinates:c}},MultiPolygon:function(M){for(var c=[],p=0;p<M._geometries.length;++p){var g=M._geometries[p],w=Kr.Polygon.call(this,g);c.push(w.coordinates)}return{type:"MultiPolygon",coordinates:c}},GeometryCollection:function(M){for(var c=[],p=0;p<M._geometries.length;++p){var g=M._geometries[p],w=g.getGeometryType();c.push(Kr[w].call(this,g))}return{type:"GeometryCollection",geometries:c}}};return{BufferOp:Mo,GeoJSONReader:function(){function M(c){s(this,M),this.parser=new il(c||new kr)}return h(M,[{key:"read",value:function(c){return this.parser.read(c)}}]),M}(),GeoJSONWriter:function(){function M(){s(this,M),this.parser=new il(this.geometryFactory)}return h(M,[{key:"write",value:function(c){return this.parser.write(c)}}]),M}()}})})(Y_);var lE=Y_.exports;const uE=pu(lE);function Da(){return new Tf}function Tf(){this.reset()}Tf.prototype={constructor:Tf,reset:function(){this.s=this.t=0},add:function(a){H_(If,a,this.t),H_(this,If.s,this.s),this.s?this.t+=If.t:this.s=If.t},valueOf:function(){return this.s}};var If=new Tf;function H_(a,i,s){var l=a.s=i+s,h=l-i,f=l-h;a.t=i-f+(s-h)}var Mi=1e-6,Qn=Math.PI,Ls=Qn/2,K_=Qn/4,Rs=Qn*2,za=180/Qn,$o=Qn/180,Tr=Math.abs,cE=Math.atan,Tu=Math.atan2,Oi=Math.cos,Ni=Math.sin,Iu=Math.sqrt;function J_(a){return a>1?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;++l<h;)Mf(s[l].geometry,i)}},ey={Sphere:function(a,i){i.sphere()},Point:function(a,i){a=a.coordinates,i.point(a[0],a[1],a[2])},MultiPoint:function(a,i){for(var s=a.coordinates,l=-1,h=s.length;++l<h;)a=s[l],i.point(a[0],a[1],a[2])},LineString:function(a,i){Np(a.coordinates,i,0)},MultiLineString:function(a,i){for(var s=a.coordinates,l=-1,h=s.length;++l<h;)Np(s[l],i,0)},Polygon:function(a,i){ty(a.coordinates,i)},MultiPolygon:function(a,i){for(var s=a.coordinates,l=-1,h=s.length;++l<h;)ty(s[l],i)},GeometryCollection:function(a,i){for(var s=a.geometries,l=-1,h=s.length;++l<h;)Mf(s[l],i)}};function Np(a,i,s){var l=-1,h=a.length-s,f;for(i.lineStart();++l<h;)f=a[l],i.point(f[0],f[1],f[2]);i.lineEnd()}function ty(a,i){var s=-1,l=a.length;for(i.polygonStart();++s<l;)Np(a[s],i,1);i.polygonEnd()}function hE(a,i){a&&Q_.hasOwnProperty(a.type)?Q_[a.type](a,i):Mf(a,i)}Da(),Da();function Bp(a){return[Tu(a[1],a[0]),Sl(a[2])]}function Mu(a){var i=a[0],s=a[1],l=Oi(s);return[l*Oi(i),l*Ni(i),Ni(s)]}function Sf(a,i){return a[0]*i[0]+a[1]*i[1]+a[2]*i[2]}function kf(a,i){return[a[1]*i[2]-a[2]*i[1],a[2]*i[0]-a[0]*i[2],a[0]*i[1]-a[1]*i[0]]}function Fp(a,i){a[0]+=i[0],a[1]+=i[1],a[2]+=i[2]}function Cf(a,i){return[a[0]*i,a[1]*i,a[2]*i]}function Vp(a){var i=Iu(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);a[0]/=i,a[1]/=i,a[2]/=i}Da();function ny(a,i){function s(l,h){return l=a(l,h),i(l[0],l[1])}return a.invert&&i.invert&&(s.invert=function(l,h){return l=i.invert(l,h),l&&a.invert(l[0],l[1])}),s}function Up(a,i){return[a>Qn?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?h<f:h>f)&&(h+=l*Rs));for(var k,P=h;l>0?P>f:P<f;P-=E)k=Bp([x,-t*Oi(P),-t*Ni(P)]),a.point(k[0],k[1])}}function sy(a,i){i=Mu(i),i[0]-=a,Vp(i);var s=J_(-i[1]);return((-i[2]<0?-s:s)+Rs-Mi)%Rs}function ay(){var a=[],i;return{point:function(s,l){i.push([s,l])},lineStart:function(){a.push(i=[])},lineEnd:zc,rejoin:function(){a.length>1&&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(Z<P)return;Z<R&&(R=Z)}else if(F>0){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(Z<P)return;Z<R&&(R=Z)}if(Z=l-t,!(!U&&Z>0)){if(Z/=U,U<0){if(Z<P)return;Z<R&&(R=Z)}else if(U>0){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(Z<P)return;Z<R&&(R=Z)}return P>0&&(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])<Mi&&Tr(a[1]-i[1])<Mi}function Pf(a,i,s,l){this.x=a,this.z=i,this.o=s,this.e=l,this.v=!1,this.n=this.p=null}function ly(a,i,s,l,h){var f=[],x=[],t,E;if(a.forEach(function(Z){if(!((J=Z.length-1)<=0)){var J,he=Z[0],ye=Z[J],te;if(Af(he,ye)){for(h.lineStart(),t=0;t<J;++t)h.point((he=Z[t])[0],he[1]);h.lineEnd();return}f.push(te=new Pf(he,Z,null,!0)),x.push(te.o=new Pf(he,null,te,!1)),f.push(te=new Pf(ye,Z,null,!1)),x.push(te.o=new Pf(ye,null,te,!0))}}),!!f.length){for(x.sort(i),uy(f),uy(x),t=0,E=x.length;t<E;++t)x[t].e=s=!s;for(var k=f[0],P,R;;){for(var F=k,U=!0;F.v;)if((F=F.n)===k)return;P=F.z,h.lineStart();do{if(F.v=F.o.v=!0,F.e){if(U)for(t=0,E=P.length;t<E;++t)h.point((R=P[t])[0],R[1]);else l(F.x,F.n.x,1,h);F=F.n}else{if(U)for(P=F.p.z,t=P.length-1;t>=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;++s<i;)l.n=h=a[s],h.p=l,l=h;l.n=h=a[0],h.p=l}}function cy(a,i){return a<i?-1:a>i?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<h;){var f=l+h>>>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<h;){var f=l+h>>>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<i;)h+=a[l].length;for(f=new Array(h);--i>=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)<Mi?P>0?0:3:Tr(k[0]-s)<Mi?P>0?2:1:Tr(k[1]-i)<Mi?P>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;Lt<Yt;++Lt)for(var Mt=U[Lt],Gt=1,tt=Mt.length,Bt=Mt[0],Zt,Vt,St=Bt[0],hn=Bt[1];Gt<tt;++Gt)Zt=St,Vt=hn,Bt=Mt[Gt],St=Bt[0],hn=Bt[1],Vt<=l?hn>l&&(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<E;++t)if(P=(k=a[t]).length)for(var k,P,R=k[P-1],F=R[0],U=R[1]/2+K_,Z=Ni(U),J=Oi(U),he=0;he<P;++he,F=te,Z=be,J=we,R=ye){var ye=k[he],te=ye[0],ce=ye[1]/2+K_,be=Ni(ce),we=Oi(ce),Ue=te-F,ze=Ue>=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||f<Mi&&jp<-Mi)^x&1}Da();function fy(a){return a}Da(),Da();var Su=1/0,Rf=Su,Nc=-Su,Df=Nc,dy={point:vE,lineStart:zc,lineEnd:zc,polygonStart:zc,polygonEnd:zc,result:function(){var a=[[Su,Rf],[Nc,Df]];return Nc=Df=-(Rf=Su=1/0),a}};function vE(a,i){a<Su&&(Su=a),a>Nc&&(Nc=a),i<Rf&&(Rf=i),i>Df&&(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;Ve<ft;++Ve)f.point((Je=lt[Ve])[0],Je[1]);f.lineEnd()}return}Ie>1&&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)<Mi?(a.point(i,s=(s+x)/2>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&&(i-=l*Mi),Tr(f-t)<Mi&&(f-=t*Mi),s=EE(i,s,f,x),a.point(l,s),a.lineEnd(),a.lineStart(),a.point(t,s),h=0),a.point(i=f,s=x),l=t},lineEnd:function(){a.lineEnd(),i=s=NaN},clean:function(){return 2-h}}}function EE(a,i,s,l){var h,f,x=Ni(a-s);return Tr(x)>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]<i[0]?Qn:-Qn;h=s*f/2,l.point(-f,h),l.point(0,h),l.point(f,h)}else l.point(i[0],i[1])}function IE(a,i){var s=Oi(a),l=s>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;Lt<Nt&&(Gt=Nt,Nt=Lt,Lt=Gt);var tt=Lt-Nt,Bt=Tr(tt-Qn)<Mi,Zt=Bt||tt<Mi;if(!Bt&&Mt<Yt&&(Gt=Yt,Yt=Mt,Mt=Gt),Zt?Bt?Yt+Mt>0^ut[1]<(Tr(ut[0]-Nt)<Mi?Yt:Mt):Yt<=ut[1]&&ut[1]<=Mt:tt>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)<Mi||Tr(f-R)<Mi?(f+R)/2:Tu(we,be),ft=a(Ie,Ve),lt=ft[0],Je=ft[1],At=lt-l,ut=Je-h,Nt=te*At-ye*ut;(Nt*Nt/ce>i||Tr((ye*At+te*ut)/ce-.5)>.3||x*F+t*U+E*Z<SE)&&(s(l,h,f,x,t,E,lt,Je,Ie,be/=ze,we/=ze,Ue,J,he),he.point(lt,Je),s(lt,Je,Ie,be,we,Ue,k,P,R,F,U,Z,J,he))}}return function(l){var h,f,x,t,E,k,P,R,F,U,Z,J,he={point:ye,lineStart:te,lineEnd:be,polygonStart:function(){l.polygonStart(),he.lineStart=we},polygonEnd:function(){l.polygonEnd(),he.lineStart=te}};function ye(Ve,Ie){Ve=a(Ve,Ie),l.point(Ve[0],Ve[1])}function te(){R=NaN,he.point=ce,l.lineStart()}function ce(Ve,Ie){var ft=Mu([Ve,Ie]),lt=a(Ve,Ie);s(R,F,P,U,Z,J,R=lt[0],F=lt[1],P=Ve,U=ft[0],Z=ft[1],J=ft[2],yy,l),l.point(R,F)}function be(){he.point=ye,l.lineEnd()}function we(){te(),he.point=Ue,he.lineEnd=ze}function Ue(Ve,Ie){ce(h=Ve,Ie),f=R,x=F,t=U,E=Z,k=J,he.point=ce}function ze(){s(R,F,P,U,Z,J,f,x,h,t,E,k,yy,l),he.lineEnd=be,be()}return he}}var AE=gy({point:function(a,i){this.stream.point(a*$o,i*$o)}});function PE(a){return LE(function(){return a})()}function LE(a){var i,s=150,l=480,h=250,f,x,t=0,E=0,k=0,P=0,R=0,F,U,Z=null,J=my,he=null,ye,te,ce,be=fy,we=.5,Ue=vy(lt,we),ze,Ve;function Ie(ut){return ut=U(ut[0]*$o,ut[1]*$o),[ut[0]*s+f,x-ut[1]*s]}function ft(ut){return ut=U.invert((ut[0]-f)/s,(x-ut[1])/s),ut&&[ut[0]*za,ut[1]*za]}function lt(ut,Nt){return ut=i(ut,Nt),[ut[0]*s+f,x-ut[1]*s]}Ie.stream=function(ut){return ze&&Ve===ut?ze:ze=AE(J(F,Ue(be(Ve=ut))))},Ie.clipAngle=function(ut){return arguments.length?(J=+ut?IE(Z=ut*$o,6*$o):(Z=null,my),At()):Z*za},Ie.clipExtent=function(ut){return arguments.length?(be=ut==null?(he=ye=te=ce=null,fy):_E(he=+ut[0][0],ye=+ut[0][1],te=+ut[1][0],ce=+ut[1][1]),At()):he==null?null:[[he,ye],[te,ce]]},Ie.scale=function(ut){return arguments.length?(s=+ut,Je()):s},Ie.translate=function(ut){return arguments.length?(l=+ut[0],h=+ut[1],Je()):[l,h]},Ie.center=function(ut){return arguments.length?(t=ut[0]%360*$o,E=ut[1]%360*$o,Je()):[t*za,E*za]},Ie.rotate=function(ut){return arguments.length?(k=ut[0]%360*$o,P=ut[1]%360*$o,R=ut.length>2?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])<f&&Math.abs(R-i[1])<f?cn([P,R],{medianCandidates:l.medianCandidates}):(l.medianCandidates.push([P,R]),Sy([P,R],a,s,l,h-1))}var Zp={exports:{}};const VE=Qg(Bw);class UE{constructor(i=[],s=jE){if(this.data=i,this.length=this.data.length,this.compare=s,this.length>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<h;){let x=(i<<1)+1,t=s[x];const E=x+1;if(E<this.length&&l(s[E],t)<0&&(x=E,t=s[E]),l(t,f)>=0)break;s[i]=t,i=x}s[i]=f}}function jE(a,i){return a<i?-1:a>i?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;k<E;P=k++){var R=s[l+k*2+0],F=s[l+k*2+1],U=s[l+P*2+0],Z=s[l+P*2+1],J=F>x!=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;k<E;P=k++){var R=s[k+l][0],F=s[k+l][1],U=s[P+l][0],Z=s[P+l][1],J=F>x!=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(ft<J&<<ye)for(Ie>Ve==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);ft<J&<<ye;)Ie>Ve==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(;ft<J;)Ue=be-((we=be+Ve)-(ze=we-be))+(Ve-ze),Ve=he[++ft],be=we,Ue!==0&&(ce[Je++]=Ue);for(;lt<ye;)Ue=be-((we=be+Ie)-(ze=we-be))+(Ie-ze),Ie=te[++lt],be=we,Ue!==0&&(ce[Je++]=Ue);return be===0&&Je!==0||(ce[Je++]=be),Je}function x(J){return new Float64Array(J)}const t=33306690738754716e-32,E=22204460492503146e-32,k=11093356479670487e-47,P=x(4),R=x(8),F=x(12),U=x(16),Z=x(4);s.orient2d=function(J,he,ye,te,ce,be){const we=(he-be)*(ye-ce),Ue=(J-ce)*(te-be),ze=we-Ue;if(we===0||Ue===0||we>0!=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<bo;uo++)lo+=an[uo];return lo}(4,P),wt=E*Nt;if(Hi>=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;x<l.length;x++){var E=l[x];h.remove(E),t=Dy(E,t),f.push(t)}var k=new Ay(16);for(x=0;x<f.length;x++)k.insert(Xp(f[x]));for(var P=i*i,R=s*s;f.length;){var F=f.shift(),U=F.p,Z=F.next.p,J=Wp(U,Z);if(!(J<R)){var he=J/P;E=HE(h,F.prev.p,U,Z,F.next.next.p,he,k),E&&Math.min(Wp(E,U),Wp(E,Z))<=he&&(f.push(F),f.push(Dy(E,F)),h.remove(E),k.remove(F),k.insert(Xp(F)),k.insert(Xp(F.next)))}}F=t;var ye=[];do ye.push(F.p),F=F.next;while(F!==t);return ye.push(F.p),ye}function HE(a,i,s,l,h,f,x){for(var t=new Nf([],KE),E=a.data;E;){for(var k=0;k<E.children.length;k++){var P=E.children[k],R=E.leaf?Yp(P,s,l):JE(s,l,P);R>f||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<Z&&F.dist<J&&Ry(s,U,x)&&Ry(l,U,x))return U}E=t.pop(),E&&(E=E.node)}return null}function KE(a,i){return a.dist-i.dist}function JE(a,i,s){if(Ly(a,s)||Ly(i,s))return 0;var l=Bf(a[0],a[1],i[0],i[1],s.minX,s.minY,s.maxX,s.minY);if(l===0)return 0;var h=Bf(a[0],a[1],i[0],i[1],s.minX,s.minY,s.minX,s.maxY);if(h===0)return 0;var f=Bf(a[0],a[1],i[0],i[1],s.maxX,s.minY,s.maxX,s.maxY);if(f===0)return 0;var x=Bf(a[0],a[1],i[0],i[1],s.minX,s.maxY,s.maxX,s.maxY);return x===0?0:Math.min(l,h,f,x)}function Ly(a,i){return a[0]>=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;E<t.length;E++)if(QE(t[E].p,t[E].next.p,a,i))return!1;return!0}function ku(a,i,s){return YE(a[0],a[1],i[0],i[1],s[0],s[1])}function QE(a,i,s,l){return a!==l&&i!==s&&ku(a,i,s)>0!=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;f<a.length;f++){var x=a[f];x[0]<i[0]&&(i=x),x[0]>l[0]&&(l=x),x[1]<s[1]&&(s=x),x[1]>h[1]&&(h=x)}var t=[i,s,l,h],E=t.slice();for(f=0;f<a.length;f++)WE(a[f],t)||E.push(a[f]);return nT(E)}function Dy(a,i){var s={p:a,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Wp(a,i){var s=a[0]-i[0],l=a[1]-i[1];return s*s+l*l}function Yp(a,i,s){var l=i[0],h=i[1],f=s[0]-l,x=s[1]-h;if(f!==0||x!==0){var t=((a[0]-l)*f+(a[1]-h)*x)/(f*f+x*x);t>1?(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<a.length;s++){for(;i.length>=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<s.length-1;E++)k=he[E],R=k[0],U=k[1],P=he[E+1],F=P[0],Z=P[1],J=R*Z-F*U,t+=J,f+=(R+F)*J,x+=(U+Z)*J;if(t===0)return l;var ye=t*.5,te=1/(6*ye);return cn([h[0]+te*f,h[1]+te*x],i.properties);default:var ce=zy(a);return ce?Oy(ce,{properties:i.properties}):na(a,{properties:i.properties})}}function Fc(a,i,s={}){const l=s.steps||64,h=s.properties?s.properties:!Array.isArray(a)&&a.type==="Feature"&&a.properties?a.properties:{},f=[];for(let x=0;x<l;x++)f.push(ea(a,i,x*-360/l,s).geometry.coordinates);return f.push(f[0]),Mn([f],h)}function yr(a){if(!a)throw new Error("geojson is required");switch(a.type){case"Feature":return Ny(a);case"FeatureCollection":return oT(a);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Hp(a);default:throw new Error("unknown GeoJSON type")}}function Ny(a){const i={type:"Feature"};return Object.keys(a).forEach(s=>{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<h.length;f++){for(var x=h[f],t=l[x],E=[],k=0;k<t.length;k++)E.push(a.features[t[k]]);s(Jt(E),x,f)}}function Vy(a,i,s,l){var h=l;return Kp(a,i,function(f,x,t){t===0&&l===void 0?h=f:h=s(h,f,x,t)}),h}function Jp(a,i){var s={};return Bn(a,function(l,h){var f=l.properties||{};if(Object.prototype.hasOwnProperty.call(f,String(i))){var x=f[i];Object.prototype.hasOwnProperty.call(s,x)?s[x].push(h):s[x]=[h]}}),s}function Vf(a,i){if(a===void 0)return!1;var s=typeof i;if(s==="number"||s==="string")return Object.prototype.hasOwnProperty.call(a,i);if(Array.isArray(i)){for(var l=0;l<i.length;l++)if(!Vf(a,i[l]))return!1;return!0}else return Qp(a,i)}function Qp(a,i){for(var s=Object.keys(i),l=0;l<s.length;l++){var h=s[l];if(a[h]!==i[h])return!1}return!0}function Uy(a,i){if(!i)return{};if(!i.length)return{};for(var s={},l=0;l<i.length;l++){var h=i[l];Object.prototype.hasOwnProperty.call(a,h)&&(s[h]=a[h])}return s}const sT=Object.freeze(Object.defineProperty({__proto__:null,applyFilter:Vf,clusterEach:Kp,clusterReduce:Vy,createBins:Jp,filterProperties:Uy,getCluster:Fy,propertiesContainsFilter:Qp},Symbol.toStringTag,{value:"Module"}));var aT=so;function lT(a,i,s={}){s.mutate!==!0&&(a=yr(a));const l=s.minPoints||3,h=mf(i,s.units);var f=new aT(a.features.length),x=a.features.map(U=>!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)<Math.abs(te)?h/Math.cos(ir(te)):h/Math.cos(ir(ye))}(),be=Math.max(J-ce,-360),we=Math.min(J+ce,360),Ue={minX:be,minY:ye,maxX:we,maxY:te};return f.search(Ue).filter(ze=>{const Ve=ze.index,Ie=a.features[Ve];return Wn(Z,Ie,{units:"kilometers"})<=i})},R=(U,Z)=>{for(var J=0;J<Z.length;J++){var he=Z[J];const ye=he.index;if(!x[ye]){x[ye]=!0;const te=P(ye);te.length>=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;x<h;x++){var t=(i[x]||0)-(s[x]||0);f+=t*t}return l?Math.sqrt(f):f},mandist:function(i,s,l){for(var h=i.length,f=0,x=0;x<h;x++)f+=Math.abs((i[x]||0)-(s[x]||0));return l?Math.sqrt(f):f},dist:function(i,s,l){var h=Math.abs(i-s);return l?h:h*h}},Gy=jy,uT=Gy.eudist,cT=Gy.dist,hT={kmrand:function(i,s){for(var l={},h=[],f=s<<2,x=i.length,t=i[0].length>0;h.length<s&&f-- >0;){var E=i[Math.floor(Math.random()*x)],k=t?E.join("_"):""+E;l[k]||(l[k]=!0,h.push(E))}if(h.length<s)throw new Error("Error initializating clusters");return h},kmpp:function(i,s){var l=i[0].length?uT:cT,h=[],f=i.length,x=i[0].length>0,t=i[Math.floor(Math.random()*f)];for(x?t.join("_"):""+t,h.push(t);h.length<s;){for(var E=[],k=h.length,P=0,R=[],F=0;F<f;F++){for(var U=1/0,Z=0;Z<k;Z++){var J=l(i[F],h[Z]);J<=U&&(U=J)}E[F]=U}for(var he=0;he<f;he++)P+=E[he];for(var ye=0;ye<f;ye++)R[ye]={i:ye,v:i[ye],pr:E[ye]/P,cs:0};R.sort(function(we,Ue){return we.pr-Ue.pr}),R[0].cs=R[0].pr;for(var te=1;te<f;te++)R[te].cs=R[te-1].cs+R[te].pr;for(var ce=Math.random(),be=0;be<f-1&&R[be++].cs<ce;);h.push(R[be-1].v)}return h}},em=jy,qy=hT,fT=em.eudist;em.mandist,em.dist;var dT=qy.kmrand,pT=qy.kmpp,Zy=1e4;function $y(a,i,s){s=s||[];for(var l=0;l<a;l++)s[l]=i;return s}function mT(a,i,s,l){var h=[],f=[],x=[],t=[],E=!1,k=l||Zy,P=a.length,R=a[0].length,F=R>0,U=[];if(s)s=="kmrand"?h=dT(a,i):s=="kmpp"?h=pT(a,i):h=s;else for(var Z={};h.length<i;){var J=Math.floor(Math.random()*P);Z[J]||(Z[J]=!0,h.push(a[J]))}do{$y(i,0,U);for(var he=0;he<P;he++){for(var ye=1/0,te=0,ce=0;ce<i;ce++){var t=F?fT(a[he],h[ce]):Math.abs(a[he]-h[ce]);t<=ye&&(ye=t,te=ce)}x[he]=te,U[te]++}for(var be=[],f=[],we=0;we<i;we++)be[we]=F?$y(R,0,be[we]):0,f[we]=h[we];if(F){for(var Ue=0;Ue<i;Ue++)h[Ue]=[];for(var ze=0;ze<P;ze++)for(var Ve=x[ze],Ie=be[Ve],ft=a[ze],lt=0;lt<R;lt++)Ie[lt]+=ft[lt];E=!0;for(var Je=0;Je<i;Je++){for(var At=h[Je],ut=be[Je],Nt=f[Je],Lt=U[Je],Yt=0;Yt<R;Yt++)At[Yt]=ut[Yt]/Lt||0;if(E){for(var Mt=0;Mt<R;Mt++)if(Nt[Mt]!=At[Mt]){E=!1;break}}}}else{for(var Gt=0;Gt<P;Gt++){var tt=x[Gt];be[tt]+=a[Gt]}for(var Bt=0;Bt<i;Bt++)h[Bt]=be[Bt]/U[Bt]||0;E=!0;for(var Zt=0;Zt<i;Zt++)if(f[Zt]!=h[Zt]){E=!1;break}}E=E||--k<=0}while(!E);return{it:Zy-k,k:i,idxs:x,centroids:h}}var gT=mT;const _T=pu(gT);function yT(a,i={}){var s=a.features.length;i.numberOfClusters=i.numberOfClusters||Math.round(Math.sqrt(s/2)),i.numberOfClusters>s&&(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].y<h&&(h=a[i].y),a[i].y>f&&(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;k<P;)R[k]=t[k],++k;return R}}function ST(a,i){for(var s,l=a.length,h=l-i;h<--l;)s=a[h],a[h++]=a[l],a[l]=s}function Yy(a,i){var s=MT(a.transform),l=a.arcs;function h(P,R){R.length&&R.pop();for(var F=l[P<0?~P:P],U=0,Z=F.length;U<Z;++U)R.push(s(F[U],U));P<0&&ST(R,Z)}function f(P){return s(P)}function x(P){for(var R=[],F=0,U=P.length;F<U;++F)h(P[F],R);return R.length<2&&R.push(R[0]),R}function t(P){for(var R=x(P);R.length<4;)R.push(R[0]);return R}function E(P){return P.map(t)}function k(P){var R=P.type,F;switch(R){case"GeometryCollection":return{type:R,geometries:P.geometries.map(k)};case"Point":F=f(P.coordinates);break;case"MultiPoint":F=P.coordinates.map(f);break;case"LineString":F=x(P.arcs);break;case"MultiLineString":F=P.arcs.map(x);break;case"Polygon":F=E(P.arcs);break;case"MultiPolygon":F=P.arcs.map(E);break;default:return null}return{type:R,coordinates:F}}return k(i)}function kT(a,i){var s={},l={},h={},f=[],x=-1;i.forEach(function(k,P){var R=a.arcs[k<0?~k:k],F;R.length<3&&!R[1][0]&&!R[1][1]&&(F=i[++x],i[x]=k,i[P]=F)}),i.forEach(function(k){var P=t(k),R=P[0],F=P[1],U,Z;if(U=h[R])if(delete h[U.end],U.push(k),U.end=F,Z=l[F]){delete l[Z.start];var J=Z===U?U:U.concat(Z);l[J.start=U.start]=h[J.end=Z.end]=J}else l[U.start]=h[U.end]=U;else if(U=l[F])if(delete l[U.start],U.unshift(k),U.start=R,Z=h[R]){delete h[Z.end];var he=Z===U?U:Z.concat(U);l[he.start=Z.start]=h[he.end=U.end]=he}else l[U.start]=h[U.end]=U;else U=[k],l[U.start=R]=h[U.end=F]=U});function t(k){var P=a.arcs[k<0?~k:k],R=P[0],F;return a.transform?(F=[0,0],P.forEach(function(U){F[0]+=U[0],F[1]+=U[1]})):F=P[P.length-1],k<0?[F,R]:[R,F]}function E(k,P){for(var R in k){var F=k[R];delete P[F.start],delete F.start,delete F.end,F.forEach(function(U){s[U<0?~U:U]=1}),f.push(F)}}return E(h,l),E(l,h),i.forEach(function(k){s[k<0?~k:k]||f.push([k])}),f}function CT(a){for(var i=-1,s=a.length,l,h=a[s-1],f=0;++i<s;)l=h,h=a[i],f+=l[0]*h[1]-l[1]*h[0];return Math.abs(f)}function AT(a){return Yy(a,PT.apply(this,arguments))}function PT(a,i){var s={},l=[],h=[];i.forEach(f);function f(E){switch(E.type){case"GeometryCollection":E.geometries.forEach(f);break;case"Polygon":x(E.arcs);break;case"MultiPolygon":E.arcs.forEach(x);break}}function x(E){E.forEach(function(k){k.forEach(function(P){(s[P=P<0?~P:P]||(s[P]=[])).push(E)})}),l.push(E)}function t(E){return CT(Yy(a,{type:"Polygon",arcs:[E]}).coordinates[0])}return l.forEach(function(E){if(!E._){var k=[],P=[E];for(E._=1,h.push(k);E=P.pop();)k.push(E),E.forEach(function(R){R.forEach(function(F){s[F<0?~F:F].forEach(function(U){U._||(U._=1,P.push(U))})})})}}),l.forEach(function(E){delete E._}),{type:"MultiPolygon",arcs:h.map(function(E){var k=[],P;if(E.forEach(function(J){J.forEach(function(he){he.forEach(function(ye){s[ye<0?~ye:ye].length<2&&k.push(ye)})})}),k=kT(a,k),(P=k.length)>1)for(var R=1,F=t(k[0]),U,Z;R<P;++R)(U=t(k[R]))>F&&(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];F<i&&(i=F),F>l&&(l=F),U<s&&(s=U),U>h&&(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<<Math.max(4,Math.ceil(Math.log(a)/Math.LN2))),x=a-1,t=0;t<a;++t)f[t]=h;function E(R){for(var F=i(R)&x,U=f[F],Z=0;U!=h;){if(s(U,R))return!0;if(++Z>=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<U;++F){var Z=f[F];Z!=h&&R.push(Z)}return R}return{add:E,has:k,values:P}}function nm(a,i,s,l,h,f){arguments.length===3&&(l=f=Array,h=null);for(var x=new l(a=1<<Math.max(4,Math.ceil(Math.log(a)/Math.LN2))),t=new f(a),E=a-1,k=0;k<a;++k)x[k]=h;function P(Z,J){for(var he=i(Z)&E,ye=x[he],te=0;ye!=h;){if(s(ye,Z))return t[he]=J;if(++te>=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<he;++J){var ye=x[J];ye!=h&&Z.push(ye)}return Z}return{set:P,maybeSet:R,get:F,keys:U}}function kl(a,i){return a[0]===i[0]&&a[1]===i[1]}var Hy=new ArrayBuffer(16),Ky=new Float64Array(Hy),Uf=new Uint32Array(Hy);function im(a){Ky[0]=a[0],Ky[1]=a[1];var i=Uf[0]^Uf[1];return i=i<<5^i>>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<R;++P)f[P]=x[P]=t[P]=-1;for(P=0,R=s.length;P<R;++P){var J=s[P],he=J[0],ye=J[1];for(U=h[he],Z=h[++he],++k,E[U]=1;++he<=ye;)we(P,F=U,U=Z,Z=h[he]);++k,E[Z]=1}for(P=0,R=i.length;P<R;++P)f[P]=-1;for(P=0,R=l.length;P<R;++P){var te=l[P],ce=te[0]+1,be=te[1];for(F=h[be-1],U=h[ce-1],Z=h[ce],we(P,F,U,Z);++ce<=be;)we(P,F=U,U=Z,Z=h[ce])}function we(lt,Je,At,ut){if(f[At]!==lt){f[At]=lt;var Nt=x[At];if(Nt>=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<ut;++At)Je[At]=lt.maybeSet(At,At);return Je}function ze(lt){return im(i[lt])}function Ve(lt,Je){return kl(i[lt],i[Je])}f=x=t=null;var Ie=RT(k*1.4,im,kl),ft;for(P=0,R=i.length;P<R;++P)E[ft=h[P]]&&Ie.add(i[ft]);return Ie}function zT(a){var i=DT(a),s=a.coordinates,l=a.lines,h=a.rings,f,x,t;for(x=0,t=l.length;x<t;++x)for(var E=l[x],k=E[0],P=E[1];++k<P;)i.has(s[k])&&(f={0:k,1:E[1]},E[1]=k,E=E.next=f);for(x=0,t=h.length;x<t;++x)for(var R=h[x],F=R[0],U=F,Z=R[1],J=i.has(s[F]);++U<Z;)i.has(s[U])&&(J?(f={0:U,1:R[1]},R[1]=U,R=R.next=f):(OT(s,F,Z,Z-U),s[Z]=s[F],J=!0,U=F));return a}function OT(a,i,s,l){rm(a,i,s),rm(a,i,i+l),rm(a,i+l,s)}function rm(a,i,s){for(var l=i+(s---i>>1),h;i<l;++i,--s)h=a[i],a[i]=a[s],a[s]=h}function NT(a){var i=a.coordinates,s=a.lines,l,h=a.rings,f,x=s.length+h.length,t,E;for(delete a.lines,delete a.rings,t=0,E=s.length;t<E;++t)for(l=s[t];l=l.next;)++x;for(t=0,E=h.length;t<E;++t)for(f=h[t];f=f.next;)++x;var k=nm(x*2*1.4,im,kl),P=a.arcs=[];for(t=0,E=s.length;t<E;++t){l=s[t];do R(l);while(l=l.next)}for(t=0,E=h.length;t<E;++t)if(f=h[t],f.next)do R(f);while(f=f.next);else F(f);function R(te){var ce,be,we,Ue,ze,Ve,Ie,ft;if(we=k.get(ce=i[te[0]])){for(Ie=0,ft=we.length;Ie<ft;++Ie)if(Ue=we[Ie],U(Ue,te)){te[0]=Ue[0],te[1]=Ue[1];return}}if(ze=k.get(be=i[te[1]])){for(Ie=0,ft=ze.length;Ie<ft;++Ie)if(Ve=ze[Ie],Z(Ve,te)){te[1]=Ve[0],te[0]=Ve[1];return}}we?we.push(te):k.set(ce,[te]),ze?ze.push(te):k.set(be,[te]),P.push(te)}function F(te){var ce,be,we,Ue,ze;if(be=k.get(ce=i[te[0]]))for(Ue=0,ze=be.length;Ue<ze;++Ue){if(we=be[Ue],J(we,te)){te[0]=we[0],te[1]=we[1];return}if(he(we,te)){te[0]=we[1],te[1]=we[0];return}}if(be=k.get(ce=i[te[0]+ye(te)]))for(Ue=0,ze=be.length;Ue<ze;++Ue){if(we=be[Ue],J(we,te)){te[0]=we[0],te[1]=we[1];return}if(he(we,te)){te[0]=we[1],te[1]=we[0];return}}be?be.push(te):k.set(ce,[te]),P.push(te)}function U(te,ce){var be=te[0],we=ce[0],Ue=te[1],ze=ce[1];if(be-Ue!==we-ze)return!1;for(;be<=Ue;++be,++we)if(!kl(i[be],i[we]))return!1;return!0}function Z(te,ce){var be=te[0],we=ce[0],Ue=te[1],ze=ce[1];if(be-Ue!==we-ze)return!1;for(;be<=Ue;++be,--ze)if(!kl(i[be],i[ze]))return!1;return!0}function J(te,ce){var be=te[0],we=ce[0],Ue=te[1],ze=ce[1],Ve=Ue-be;if(Ve!==ze-we)return!1;for(var Ie=ye(te),ft=ye(ce),lt=0;lt<Ve;++lt)if(!kl(i[be+(lt+Ie)%Ve],i[we+(lt+ft)%Ve]))return!1;return!0}function he(te,ce){var be=te[0],we=ce[0],Ue=te[1],ze=ce[1],Ve=Ue-be;if(Ve!==ze-we)return!1;for(var Ie=ye(te),ft=Ve-ye(ce),lt=0;lt<Ve;++lt)if(!kl(i[be+(lt+Ie)%Ve],i[ze-(lt+ft)%Ve]))return!1;return!0}function ye(te){for(var ce=te[0],be=te[1],we=ce,Ue=we,ze=i[we];++we<be;){var Ve=i[we];(Ve[0]<ze[0]||Ve[0]===ze[0]&&Ve[1]<ze[1])&&(Ue=we,ze=Ve)}return Ue-ce}return a}function BT(a){var i=-1,s=[],l=[],h=[];function f(R){R&&tm.call(x,R.type)&&x[R.type](R)}var x={GeometryCollection:function(R){R.geometries.forEach(f)},LineString:function(R){R.arcs=t(R.arcs)},MultiLineString:function(R){R.arcs=R.arcs.map(t)},Polygon:function(R){R.arcs=R.arcs.map(E)},MultiPolygon:function(R){R.arcs=R.arcs.map(k)}};function t(R){for(var F=0,U=R.length;F<U;++F)h[++i]=R[F];var Z={0:i-U+1,1:i};return s.push(Z),Z}function E(R){for(var F=0,U=R.length;F<U;++F)h[++i]=R[F];var Z={0:i-U+1,1:i};return l.push(Z),Z}function k(R){return R.map(E)}for(var P in a)f(a[P]);return{type:"Topology",coordinates:h,lines:s,rings:l,objects:a}}function FT(a){var i={},s;for(s in a)i[s]=VT(a[s]);return i}function VT(a){return a==null?{type:null}:(a.type==="FeatureCollection"?UT:a.type==="Feature"?Jy:om)(a)}function UT(a){var i={type:"GeometryCollection",geometries:a.features.map(Jy)};return a.bbox!=null&&(i.bbox=a.bbox),i}function Jy(a){var i=om(a.geometry),s;a.id!=null&&(i.id=a.id),a.bbox!=null&&(i.bbox=a.bbox);for(s in a.properties){i.properties=a.properties;break}return i}function om(a){if(a==null)return{type:null};var i=a.type==="GeometryCollection"?{type:"GeometryCollection",geometries:a.geometries.map(om)}:a.type==="Point"||a.type==="MultiPoint"?{type:a.type,coordinates:a.coordinates}:{type:a.type,arcs:a.coordinates};return a.bbox!=null&&(i.bbox=a.bbox),i}function jT(a,i){var s=LT(a=FT(a)),l=NT(zT(BT(a))),h=l.coordinates,f=nm(l.arcs.length*1.4,GT,qT);a=l.objects,l.bbox=s,l.arcs=l.arcs.map(function(R,F){return f.set(R,F),h.slice(R[0],R[1]+1)}),delete l.coordinates,h=null;function x(R){R&&tm.call(t,R.type)&&t[R.type](R)}var t={GeometryCollection:function(R){R.geometries.forEach(x)},LineString:function(R){R.arcs=E(R.arcs)},MultiLineString:function(R){R.arcs=R.arcs.map(E)},Polygon:function(R){R.arcs=R.arcs.map(E)},MultiPolygon:function(R){R.arcs=R.arcs.map(k)}};function E(R){var F=[];do{var U=f.get(R);F.push(R[0]<R[1]?U:~U)}while(R=R.next);return F}function k(R){return R.map(E)}for(var P in a)x(a[P]);return l}function GT(a){var i=a[0],s=a[1],l;return s<i&&(l=i,i=s,s=l),i+31*s}function qT(a,i){var s=a[0],l=a[1],h=i[0],f=i[1],x;return l<s&&(x=s,s=l,l=x),f<h&&(x=h,h=f,f=x),s===h&&l===f}function ZT(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=[],h=Ip(a,(f,x)=>{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 <info@w8r.name>
|
|
|
* @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]<f[3])){s.label=k[1];break}if(k[0]===6&&s.label<f[1]){s.label=f[1],f=k;break}if(f&&s.label<f[2]){s.label=f[2],s.ops.push(k);break}f[2]&&s.ops.pop(),s.trys.pop();continue}k=i.call(a,s)}catch(P){k=[6,P],h=0}finally{l=f=0}if(k[0]&5)throw k[1];return{value:k[0]?k[1]:void 0,done:!0}}}var Oa=function(){function a(i,s){this.next=null,this.key=i,this.data=s,this.left=null,this.right=null}return a}();function QT(a,i){return a>i?1:a<i?-1:0}function Na(a,i,s){for(var l=new Oa(null,null),h=l,f=l;;){var x=s(a,i.key);if(x<0){if(i.left===null)break;if(s(a,i.left.key)<0){var t=i.left;if(i.left=t.right,t.right=i,i=t,i.left===null)break}f.left=i,f=i,i=i.left}else if(x>0){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;h<a.length;h++)l=l.next=new Oa(a[h],i[h]);return l.next=null,s.next}function n2(a){for(var i=a,s=[],l=!1,h=new Oa(null,null),f=h;!l;)i?(s.push(i),i=i.left):s.length>0?(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(R<a&&F<s)for(P>k==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);R<a&&F<s;)P>k==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<a;)x=f+k,E=x-f,t=f-(x-E)+(k-E),k=i[++R],f=x,t!==0&&(h[U++]=t);for(;F<s;)x=f+P,E=x-f,t=f-(x-E)+(P-E),P=l[++F],f=x,t!==0&&(h[U++]=t);return(f!==0||U===0)&&(h[U++]=f),U}function o2(a,i){let s=i[0];for(let l=1;l<a;l++)s+=i[l];return s}function Vc(a){return new Float64Array(a)}const s2=(3+16*ia)*ia,a2=(2+12*ia)*ia,l2=(9+64*ia)*ia*ia,Cu=Vc(4),e0=Vc(8),t0=Vc(12),n0=Vc(16),ao=Vc(4);function u2(a,i,s,l,h,f,x){let t,E,k,P,R,F,U,Z,J,he,ye,te,ce,be,we,Ue,ze,Ve;const Ie=a-h,ft=s-h,lt=i-f,Je=l-f;be=Ie*Je,F=qr*Ie,U=F-(F-Ie),Z=Ie-U,F=qr*Je,J=F-(F-Je),he=Je-J,we=Z*he-(be-U*J-Z*J-U*he),Ue=lt*ft,F=qr*lt,U=F-(F-lt),Z=lt-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,Cu[0]=we-(ye+R)+(R-ze),te=be+ye,R=te-be,ce=be-(te-R)+(ye-R),ye=ce-Ue,R=ce-ye,Cu[1]=ce-(ye+R)+(R-Ue),Ve=te+ye,R=Ve-te,Cu[2]=te-(Ve-R)+(ye-R),Cu[3]=Ve;let At=o2(4,Cu),ut=a2*x;if(At>=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<a.ll.x||a.ur.x<i.ll.x||i.ur.y<a.ll.y||a.ur.y<i.ll.y)return null;const s=a.ll.x<i.ll.x?i.ll.x:a.ll.x,l=a.ur.x<i.ur.x?a.ur.x:i.ur.x,h=a.ll.y<i.ll.y?i.ll.y:a.ll.y,f=a.ur.y<i.ur.y?a.ur.y:i.ur.y;return{ll:{x:s,y:h},ur:{x:l,y:f}}};let Ba=Number.EPSILON;Ba===void 0&&(Ba=Math.pow(2,-52));const h2=Ba*Ba,i0=(a,i)=>{if(-Ba<a&&a<Ba&&-Ba<i&&i<Ba)return 0;const s=a-i;return s*s<h2*a*i?0:a<i?-1:1};class f2{constructor(){this.reset()}reset(){this.xRounder=new r0,this.yRounder=new r0}round(i,s){return{x:this.xRounder.round(i),y:this.yRounder.round(s)}}}class r0{constructor(){this.tree=new lm,this.round(0)}round(i){const s=this.tree.add(i),l=this.tree.prev(s);if(l!==null&&i0(s.key,l.key)===0)return this.tree.remove(i),l.key;const h=this.tree.next(s);return h!==null&&i0(s.key,h.key)===0?(this.tree.remove(i),h.key):i}}const jc=new f2,Gf=(a,i)=>a.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.x<s.x?-1:i.x>s.x?1:i.y<s.y?-1:i.y>s.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<h;l++){const f=s[l];this.point.events.push(f),f.point=this.point}this.checkForConsuming()}checkForConsuming(){const i=this.point.events.length;for(let s=0;s<i;s++){const l=this.point.events[s];if(l.segment.consumedBy===void 0)for(let h=s+1;h<i;h++){const f=this.point.events[h];f.consumedBy===void 0&&l.otherSE.point.events===f.otherSE.point.events&&l.segment.consume(f.segment)}}}getAvailableLinkedEvents(){const i=[];for(let s=0,l=this.point.events.length;s<l;s++){const h=this.point.events[s];h!==this&&!h.segment.ringOut&&h.segment.isInResult()&&i.push(h)}return i}getLeftmostComparator(i){const s=new Map,l=h=>{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?t<k?1:t>k?-1:0:x<0&&E<0?t<k?-1:t>k?1:0:E<x?-1:E>x?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(x<l)return 1;if(f<h)return-1;const t=i.leftSE.point.y,E=s.leftSE.point.y,k=i.rightSE.point.y,P=s.rightSE.point.y;if(l<h){if(E<t&&E<k)return 1;if(E>t&&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(t<E&&t<P)return-1;if(t>E&&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(t<E)return-1;if(t>E)return 1;if(f<x){const R=s.comparePoint(i.rightSE.point);if(R!==0)return R}if(f>x){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&&U<Z)return 1;if(R<F&&U>Z)return-1}return f>x?1:f<x||k<P?-1:k>P?1:i.id<s.id?-1:i.id>s.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:i<s?i:s},ur:{x:this.rightSE.point.x,y:i>s?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.x<s.x?1:-1;const f=(i.y-s.y)/h.y,x=s.x+f*h.x;if(i.x===x)return 0;const t=(i.x-s.x)/h.x,E=s.y+t*h.y;return i.y===E?0:i.y<E?-1:1}getIntersection(i){const s=this.bbox(),l=i.bbox(),h=dm(s,l);if(h===null)return null;const f=this.leftSE.point,x=this.rightSE.point,t=i.leftSE.point,E=i.rightSE.point,k=Uc(s,t)&&this.comparePoint(t)===0,P=Uc(l,f)&&i.comparePoint(f)===0,R=Uc(s,E)&&this.comparePoint(E)===0,F=Uc(l,x)&&i.comparePoint(x)===0;if(P&&k)return F&&!R?x:!F&&R?E:null;if(P)return R&&f.x===E.x&&f.y===E.y?null:f;if(k)return F&&x.x===t.x&&x.y===t.y?null:t;if(F&&R)return null;if(F)return x;if(R)return E;const U=m2(f,this.vector(),t,i.vector());return U===null||!Uc(h,U)?null:jc.round(U.x,U.y)}split(i){const s=[],l=i.events!==void 0,h=new Xo(i,!0),f=new Xo(i,!1),x=this.rightSE;this.replaceRightSE(f),s.push(f),s.push(h);const t=new Fa(h,x,this.rings.slice(),this.windings.slice());return Xo.comparePoints(t.leftSE.point,t.rightSE.point)>0&&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;s<l;s++)this.windings[s]*=-1}consume(i){let s=this,l=i;for(;s.consumedBy;)s=s.consumedBy;for(;l.consumedBy;)l=l.consumedBy;const h=Fa.compare(s,l);if(h!==0){if(h>0){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;f<x;f++){const t=l.rings[f],E=l.windings[f],k=s.rings.indexOf(t);k===-1?(s.rings.push(t),s.windings.push(E)):s.windings[k]+=E}l.rings=null,l.windings=null,l.consumedBy=s,l.leftSE.consumedBy=s.leftSE,l.rightSE.consumedBy=s.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{const i=this.prev.consumedBy||this.prev;this._beforeState=i.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;const i=this.beforeState();this._afterState={rings:i.rings.slice(0),windings:i.windings.slice(0),multiPolys:[]};const s=this._afterState.rings,l=this._afterState.windings,h=this._afterState.multiPolys;for(let t=0,E=this.rings.length;t<E;t++){const k=this.rings[t],P=this.windings[t],R=s.indexOf(k);R===-1?(s.push(k),l.push(P)):l[R]+=P}const f=[],x=[];for(let t=0,E=s.length;t<E;t++){if(l[t]===0)continue;const k=s[t],P=k.poly;if(x.indexOf(P)===-1)if(k.isExterior)f.push(P);else{x.indexOf(P)===-1&&x.push(P);const R=f.indexOf(k.poly);R!==-1&&f.splice(R,1)}}for(let t=0,E=f.length;t<E;t++){const k=f[t].multiPoly;h.indexOf(k)===-1&&h.push(k)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;const i=this.beforeState().multiPolys,s=this.afterState().multiPolys;switch(ss.type){case"union":{const l=i.length===0,h=s.length===0;this._isInResult=l!==h;break}case"intersection":{let l,h;i.length<s.length?(l=i.length,h=s.length):(l=s.length,h=i.length),this._isInResult=h===ss.numMultiPolys&&l<h;break}case"xor":{const l=Math.abs(i.length-s.length);this._isInResult=l%2===1;break}case"difference":{const l=h=>h.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;x<t;x++){if(typeof i[x][0]!="number"||typeof i[x][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let E=jc.round(i[x][0],i[x][1]);E.x===f.x&&E.y===f.y||(this.segments.push(Fa.fromRing(f,E,this)),E.x<this.bbox.ll.x&&(this.bbox.ll.x=E.x),E.y<this.bbox.ll.y&&(this.bbox.ll.y=E.y),E.x>this.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;s<l;s++){const h=this.segments[s];i.push(h.leftSE),i.push(h.rightSE)}return i}}class _2{constructor(i,s){if(!Array.isArray(i))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new u0(i[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let l=1,h=i.length;l<h;l++){const f=new u0(i[l],this,!1);f.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=f.bbox.ll.x),f.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=f.bbox.ll.y),f.bbox.ur.x>this.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;s<l;s++){const h=this.interiorRings[s].getSweepEvents();for(let f=0,x=h.length;f<x;f++)i.push(h[f])}return i}}class c0{constructor(i,s){if(!Array.isArray(i))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof i[0][0][0]=="number"&&(i=[i])}catch{}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let l=0,h=i.length;l<h;l++){const f=new _2(i[l],this);f.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=f.bbox.ll.x),f.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=f.bbox.ll.y),f.bbox.ur.x>this.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;s<l;s++){const h=this.polys[s].getSweepEvents();for(let f=0,x=h.length;f<x;f++)i.push(h[f])}return i}}class Zf{static factory(i){const s=[];for(let l=0,h=i.length;l<h;l++){const f=i[l];if(!f.isInResult()||f.ringOut)continue;let x=null,t=f.leftSE,E=f.rightSE;const k=[t],P=t.point,R=[];for(;x=t,t=E,k.push(t),t.point!==P;)for(;;){const F=t.getAvailableLinkedEvents();if(F.length===0){const J=k[0].point,he=k[k.length-1].point;throw new Error(`Unable to complete output ring starting at [${J.x}, ${J.y}]. Last matching segment found ends at [${he.x}, ${he.y}].`)}if(F.length===1){E=F[0].otherSE;break}let U=null;for(let J=0,he=R.length;J<he;J++)if(R[J].point===t.point){U=J;break}if(U!==null){const J=R.splice(U)[0],he=k.splice(J.index);he.unshift(he[0].otherSE),s.push(new Zf(he.reverse()));continue}R.push({index:k.length,point:t.point});const Z=t.getLeftmostComparator(x);E=F.sort(Z)[0].otherSE;break}s.push(new Zf(k))}return s}constructor(i){this.events=i;for(let s=0,l=i.length;s<l;s++)i[s].segment.ringOut=this;this.poly=null}getGeom(){let i=this.events[0].point;const s=[i];for(let k=1,P=this.events.length-1;k<P;k++){const R=this.events[k].point,F=this.events[k+1].point;s0(R,i,F)!==0&&(s.push(R),i=R)}if(s.length===1)return null;const l=s[0],h=s[1];s0(l,i,h)===0&&s.shift(),s.push(s[0]);const f=this.isExteriorRing()?1:-1,x=this.isExteriorRing()?0:s.length-1,t=this.isExteriorRing()?s.length:-1,E=[];for(let k=x;k!=t;k+=f)E.push([s[k].x,s[k].y]);return E}isExteriorRing(){if(this._isExteriorRing===void 0){const i=this.enclosingRing();this._isExteriorRing=i?!i.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let i=this.events[0];for(let h=1,f=this.events.length;h<f;h++){const x=this.events[h];Xo.compare(i,x)>0&&(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;s<l;s++){const h=this.interiorRings[s].getGeom();h!==null&&i.push(h)}return i}}class y2{constructor(i){this.rings=i,this.polys=this._composePolys(i)}getGeom(){const i=[];for(let s=0,l=this.polys.length;s<l;s++){const h=this.polys[s].getGeom();h!==null&&i.push(h)}return i}_composePolys(i){const s=[];for(let l=0,h=i.length;l<h;l++){const f=i[l];if(!f.poly)if(f.isExteriorRing())s.push(new h0(f));else{const x=f.enclosingRing();x.poly||s.push(new h0(x)),x.poly.addInterior(f)}}return s}}class v2{constructor(i){let s=arguments.length>1&&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;U<Z;U++)l.push(F[U])}}let P=null;if(E){const R=E.getIntersection(s);if(R!==null&&(s.isAnEndpoint(R)||(P=R),!E.isAnEndpoint(R))){const F=this._splitSafely(E,R);for(let U=0,Z=F.length;U<Z;U++)l.push(F[U])}}if(k!==null||P!==null){let R=null;k===null?R=P:P===null?R=k:R=Xo.comparePoints(k,P)<=0?k:P,this.queue.remove(s.rightSE),l.push(s.rightSE);const F=s.split(R);for(let U=0,Z=F.length;U<Z;U++)l.push(F[U])}l.length>0?(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;R<F;R++)l.push(P[R])}if(!E.isAnEndpoint(k)){const P=this._splitSafely(E,k);for(let R=0,F=P.length;R<F;R++)l.push(P[R])}}}this.tree.remove(s)}return l}_splitSafely(i,s){this.tree.remove(i);const l=i.rightSE;this.queue.remove(l);const h=i.split(s);return h.push(l),i.consumedBy===void 0&&this.tree.add(i),h}}const f0=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,x2=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class b2{run(i,s,l){ss.type=i,jc.reset();const h=[new c0(s,!0)];for(let R=0,F=l.length;R<F;R++)h.push(new c0(l[R],!1));if(ss.numMultiPolys=h.length,ss.type==="difference"){const R=h[0];let F=1;for(;F<h.length;)dm(h[F].bbox,R.bbox)!==null?F++:h.splice(F,1)}if(ss.type==="intersection")for(let R=0,F=h.length;R<F;R++){const U=h[R];for(let Z=R+1,J=h.length;Z<J;Z++)if(dm(U.bbox,h[Z].bbox)===null)return[]}const f=new lm(Xo.compare);for(let R=0,F=h.length;R<F;R++){const U=h[R].getSweepEvents();for(let Z=0,J=U.length;Z<J;Z++)if(f.insert(U[Z]),f.size>f0)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;U<Z;U++){const J=F[U];J.consumedBy===void 0&&f.insert(J)}t=f.size,E=f.pop()}jc.reset();const k=Zf.factory(x.segments);return new y2(k).getGeom()}}const ss=new b2;var Ds={union:function(a){for(var i=arguments.length,s=new Array(i>1?i-1:0),l=1;l<i;l++)s[l-1]=arguments[l];return ss.run("union",a,s)},intersection:function(a){for(var i=arguments.length,s=new Array(i>1?i-1:0),l=1;l<i;l++)s[l-1]=arguments[l];return ss.run("intersection",a,s)},xor:function(a){for(var i=arguments.length,s=new Array(i>1?i-1:0),l=1;l<i;l++)s[l-1]=arguments[l];return ss.run("xor",a,s)},difference:function(a){for(var i=arguments.length,s=new Array(i>1?i-1:0),l=1;l<i;l++)s[l-1]=arguments[l];return ss.run("difference",a,s)}};function w2(a){const i=[];if(Br(a,h=>{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<f.length;x++){const t=oo(Ds.union.apply(null,h[f[x]].map(function(E){return E.geometry.coordinates})));t&&t.properties&&(t.properties[s]=f[x],l.push(t))}}else return pm(oo(Ds.union.apply(null,a.features.map(function(h){return h.geometry.coordinates}))));return pm(Jt(l))}function T2(a,i,s=2){const l=Jn(a),h=Jn(i),f=l[0]-h[0],x=l[1]-h[1];return s===1?Math.abs(f)+Math.abs(x):Math.pow(Math.pow(f,s)+Math.pow(x,s),1/s)}function d0(a,i){var s,l;i=i||{};const h=i.threshold||1e4,f=i.p||2,x=(s=i.binary)!=null?s:!1,t=i.alpha||-1,E=(l=i.standardization)!=null?l:!1,k=[];Bn(a,R=>{k.push(na(R))});const P=[];for(let R=0;R<k.length;R++)P[R]=[];for(let R=0;R<k.length;R++)for(let F=R;F<k.length;F++){R===F&&(P[R][F]=0);const U=T2(k[R],k[F],f);P[R][F]=U,P[F][R]=U}for(let R=0;R<k.length;R++)for(let F=0;F<k.length;F++){const U=P[R][F];U!==0&&(x?U<=h?P[R][F]=1:P[R][F]=0:U<=h?P[R][F]=Math.pow(U,t):P[R][F]=0)}if(E)for(let R=0;R<k.length;R++){const F=P[R].reduce((U,Z)=>U+Z,0);for(let U=0;U<k.length;U++)P[R][U]=P[R][U]/F}return P}function Au(a,i,s,l={}){const h=i<0;let f=El(Math.abs(i),l.units,"meters");h&&(f=-Math.abs(f));const x=Jn(a),t=I2(x,f,s);return t[0]+=t[0]-x[0]>180?-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<h;R+=1){const F=R*-360/h;let U=i*s/Math.sqrt(Math.pow(s,2)+Math.pow(i,2)*Math.pow(g0(F),2)),Z=i*s/Math.sqrt(Math.pow(i,2)+Math.pow(s,2)/Math.pow(g0(F),2));if(F<-90&&F>=-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;i<this.geometries.length;i++)a.push(this.geometries[i].coords);return{geometry:{type:"MultiLineString",coordinates:a},type:"Feature",properties:this.properties}},mm.prototype.wkt=function(){for(var a="",i="LINESTRING(",s=function(f){i+=f[0]+" "+f[1]+","},l=0;l<this.geometries.length;l++){if(this.geometries[l].coords.length===0)return"LINESTRING(empty)";var h=this.geometries[l].coords;h.forEach(s),a+=i.substring(0,i.length-1)+")"}return a};var gm=function(a,i,s){if(!a||a.x===void 0||a.y===void 0)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");if(!i||i.x===void 0||i.y===void 0)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");this.start=new Gc(a.x,a.y),this.end=new Gc(i.x,i.y),this.properties=s||{};var l=this.start.x-this.end.x,h=this.start.y-this.end.y,f=Math.pow(Math.sin(h/2),2)+Math.cos(this.start.y)*Math.cos(this.end.y)*Math.pow(Math.sin(l/2),2);if(this.g=2*Math.asin(Math.sqrt(f)),this.g===Math.PI)throw new Error("it appears "+a.view()+" and "+i.view()+" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite");if(isNaN(this.g))throw new Error("could not calculate great circle between "+a+" and "+i)};gm.prototype.interpolate=function(a){var i=Math.sin((1-a)*this.g)/Math.sin(this.g),s=Math.sin(a*this.g)/Math.sin(this.g),l=i*Math.cos(this.start.y)*Math.cos(this.start.x)+s*Math.cos(this.end.y)*Math.cos(this.end.x),h=i*Math.cos(this.start.y)*Math.sin(this.start.x)+s*Math.cos(this.end.y)*Math.sin(this.end.x),f=i*Math.sin(this.start.y)+s*Math.sin(this.end.y),x=v0*Math.atan2(f,Math.sqrt(Math.pow(l,2)+Math.pow(h,2))),t=v0*Math.atan2(h,l);return[t,x]},gm.prototype.Arc=function(a,i){var s=[];if(!a||a<=2)s.push([this.start.lon,this.start.lat]),s.push([this.end.lon,this.end.lat]);else for(var l=1/(a-1),h=0;h<a;++h){var f=l*h,x=this.interpolate(f);s.push(x)}for(var t=!1,E=0,k=i&&i.offset?i.offset:10,P=180-k,R=-180+k,F=360-k,U=1;U<s.length;++U){var Z=s[U-1][0],J=s[U][0],he=Math.abs(J-Z);he>F&&(J>P&&Z<R||Z>P&&J<R)?t=!0:he>E&&(E=he)}var ye=[];if(t&&E<k){var te=[];ye.push(te);for(var ce=0;ce<s.length;++ce){var be=parseFloat(s[ce][0]);if(ce>0&&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<R&&ze===180&&ce+1<s.length&&s[ce-1][0]>-180&&s[ce-1][0]<R){te.push([-180,s[ce][1]]),ce++,te.push([s[ce][0],s[ce][1]]);continue}else if(we>P&&we<180&&ze===-180&&ce+1<s.length&&s[ce-1][0]>P&&s[ce-1][0]<180){te.push([180,s[ce][1]]),ce++,te.push([s[ce][0],s[ce][1]]);continue}if(we<R&&ze>P){var Ie=we;we=ze,ze=Ie;var ft=Ue;Ue=Ve,Ve=ft}if(we>P&&ze<R&&(ze+=360),we<=180&&ze>=180&&we<ze){var lt=(180-we)/(ze-we),Je=lt*Ve+(1-lt)*Ue;te.push([s[ce-1][0]>P?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.length;++ut)At.push([s[ut][0],s[ut][1]])}for(var Nt=new mm(this.properties),Lt=0;Lt<ye.length;++Lt){var Yt=new x0;Nt.geometries.push(Yt);for(var Mt=ye[Lt],Gt=0;Gt<Mt.length;++Gt)Yt.move_to(Mt[Gt])}return Nt};function k2(a,i,s){if(s=s||{},typeof s!="object")throw new Error("options is invalid");var l=s.properties,h=s.npoints,f=s.offset;a=Jn(a),i=Jn(i),l=l||{},h=h||100,f=f||10;var x=new gm({x:a[0],y:a[1]},{x:i[0],y:i[1]},l),t=x.Arc(h,{offset:f});return t.json()}/*!
|
|
|
* Copyright (c) 2019, Dane Springmeyer
|
|
|
*
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
* met:
|
|
|
*
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
* the documentation and/or other materials provided with the
|
|
|
* distribution.
|
|
|
*
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
*/function qc(a,i={}){const s=[];if(Br(a,h=>{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<U;te++){let ce=x+he;for(let be=0;be<Z;be++){const we=Mn([[[ye,ce],[ye,ce+F],[ye+P,ce+F],[ye+P,ce],[ye,ce]]],l.properties);l.mask?O_(l.mask,we)&&h.push(we):h.push(we),ce+=F}ye+=P}return Jt(h)}function _m(a,i,s={}){return E0(a,i,i,s)}function T0(a,i,s={}){for(var l=[],h=i/Wn([a[0],a[1]],[a[2],a[1]],s),f=h*(a[2]-a[0]),x=i/Wn([a[0],a[1]],[a[0],a[3]],s),t=x*(a[3]-a[1]),E=0,k=a[0];k<=a[2];){for(var P=0,R=a[1];R<=a[3];){var F=null,U=null;E%2===0&&P%2===0?(F=Mn([[[k,R],[k,R+t],[k+f,R],[k,R]]],s.properties),U=Mn([[[k,R+t],[k+f,R+t],[k+f,R],[k,R+t]]],s.properties)):E%2===0&&P%2===1?(F=Mn([[[k,R],[k+f,R+t],[k+f,R],[k,R]]],s.properties),U=Mn([[[k,R],[k,R+t],[k+f,R+t],[k,R]]],s.properties)):P%2===0&&E%2===1?(F=Mn([[[k,R],[k,R+t],[k+f,R+t],[k,R]]],s.properties),U=Mn([[[k,R],[k+f,R+t],[k+f,R],[k,R]]],s.properties)):P%2===1&&E%2===1&&(F=Mn([[[k,R],[k,R+t],[k+f,R],[k,R]]],s.properties),U=Mn([[[k,R+t],[k+f,R+t],[k+f,R],[k,R+t]]],s.properties)),s.mask?(qc(Jt([s.mask,F]))&&l.push(F),qc(Jt([s.mask,U]))&&l.push(U)):(l.push(F),l.push(U)),R+=t,P++}E++,k+=f}return Jt(l)}function P2(a,i,s){if(s=s||{},typeof s!="object")throw new Error("options is invalid");var l=s.gridType,h=s.property,f=s.weight;if(!a)throw new Error("points is required");if(Qs(a,"Point","input must contain Points"),!i)throw new Error("cellSize is required");if(f!==void 0&&typeof f!="number")throw new Error("weight must be a number");h=h||"elevation",l=l||"square",f=f||1;var x=pi(a),t;switch(l){case"point":case"points":t=w0(x,i,s);break;case"square":case"squares":t=_m(x,i,s);break;case"hex":case"hexes":t=b0(x,i,s);break;case"triangle":case"triangles":t=T0(x,i,s);break;default:throw new Error("invalid gridType")}var E=[];return Bn(t,function(k){var P=0,R=0;Bn(a,function(U){var Z=l==="point"?k:na(k),J=Wn(Z,U,s),he;if(h!==void 0&&(he=U.properties[h]),he===void 0&&(he=U.geometry.coordinates[2]),he===void 0)throw new Error("zValue is missing");J===0&&(P=he);var ye=1/Math.pow(J,f);R+=ye,P+=ye*he});var F=yr(k);F.properties[h]=P/R,E.push(F)}),Jt(E)}/*!
|
|
|
* MarchingSquaresJS
|
|
|
* version 1.3.3
|
|
|
* https://github.com/RaumZeit/MarchingSquares.js
|
|
|
*
|
|
|
* @license GNU Affero General Public License.
|
|
|
* Copyright (c) 2015-2019 Ronny Lorenz <ronny@tbi.univie.ac.at>
|
|
|
*/function L2(a,i,s){return a<i?(s-a)/(i-a):(a-s)/(a-i)}function R2(a,i,s,l){var h;return s>l&&(h=s,s=l,l=h),a<i?a<s?(s-a)/(i-a):(l-a)/(i-a):a>l?(a-l)/(a-i):(a-s)/(a-i)}function D2(a,i,s,l){return a<i?(s-a)/(i-a):(a-l)/(a-i)}function z2(a,i,s,l){return a<i?(l-a)/(i-a):(a-s)/(a-i)}function I0(){this.successCallback=null,this.verbose=!1,this.polygons=!1,this.polygons_full=!1,this.linearRing=!0,this.noQuadTree=!1,this.noFrame=!1}function O2(a){var i,s,l,h,f;for(h=new I0,a=a||{},f=Object.keys(h),i=0;i<f.length;i++)s=f[i],l=a[s],typeof l<"u"&&l!==null&&(h[s]=l);return h.polygons_full=!h.polygons,h.interpolate=R2,h.interpolate_a=D2,h.interpolate_b=z2,h}function N2(a){var i,s,l,h,f;for(h=new I0,a=a||{},f=Object.keys(h),i=0;i<f.length;i++)s=f[i],l=a[s],typeof l<"u"&&l!==null&&(h[s]=l);return h.polygons_full=!h.polygons,h.interpolate=L2,h}function Wf(a,i,s,l){var h=[];return a.polygons.forEach(function(f){f.forEach(function(x){x[0]+=i,x[1]+=s}),l.linearRing&&f.push(f[0]),h.push(f)}),h}function M0(a,i,s,l){return s===0?(a+=1,i+=l[0][1]):s===1?a+=l[0][0]:s===2?i+=l[0][1]:s===3&&(a+=l[0][0],i+=1),[a,i]}function S0(a,i,s){return s===0?a++:s===1||(s===2?i++:s===3&&(a++,i++)),[a,i]}function B2(a,i,s){var l,h,f,x,t;for(l=!0,h=a[0].length,f=a.length,t=0;t<f;t++)if(a[t][0]<i||a[t][0]>s||a[t][h-1]<i||a[t][h-1]>s){l=!1;break}if(l&&(a[f-1][0]<i||a[f-1][0]>s||a[f-1][h-1]<i||a[f-1][h-1]>s)&&(l=!1),l){for(x=0;x<h-1;x++)if(a[0][x]<i||a[0][x]>s||a[f-1][x]<i||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<h;x++)if(a[x][0]>=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<l-1;f++)if(a[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<Ue[J].length;t++)if(E=Ue[J][t],typeof Z.edges[E]=="object"){x=Z.edges[E],h.push(M0(P,R,J,x.path)),k=E,te=!0;break}}if(te)break;if(h.push(S0(P,R,J)),P+=ze[J],R+=Ve[J],(typeof i[P]>"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<<t-1&&t--,f=1<<t-1}if(h>1){for(;x!==0;)x=x>>1,E++;h===1<<E-1&&E--,x=1<<E-1}this.childA=new Cl(a,i,s,f,x),this.lowerBound=this.childA.lowerBound,this.upperBound=this.childA.upperBound,l-f>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<a||(this.childA||this.childB||this.childC||this.childD?(this.childA&&(l=l.concat(this.childA.cellsInBand(a,i,s))),this.childB&&(l=l.concat(this.childB.cellsInBand(a,i,s))),this.childD&&(l=l.concat(this.childD.cellsInBand(a,i,s))),this.childC&&(l=l.concat(this.childC.cellsInBand(a,i,s)))):(s||this.lowerBound<=a||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<a.length;i++){if(!Array.isArray(a[i]))throw new Error("Row "+i+" is not an array");if(a[i].length!=s)throw new Error("unequal row lengths detected, please provide a regular grid")}this.data=a,this.root=new Cl(a,0,0,a[0].length-1,a.length-1)}function j2(a,i,s){var l,h,f,x=!1,t=!1,E=null,k=null,P=null,R=null,F=null,U=[];if(!a)throw new Error("data is required");if(i==null)throw new Error("threshold is required");if(s&&typeof s!="object")throw new Error("options must be an object");if(l=N2(s),a instanceof Yf)E=a,k=a.root,P=a.data,l.noQuadTree||(x=!0);else if(Array.isArray(a)&&Array.isArray(a[0]))P=a;else throw new Error("input is neither array of arrays nor object retrieved from 'QuadTree()'");if(Array.isArray(i)){for(t=!0,l.noQuadTree||(x=!0),h=0;h<i.length;h++)if(isNaN(+i[h]))throw new Error("threshold["+h+"] is not a number")}else{if(isNaN(+i))throw new Error("threshold must be a number or array of numbers");i=[i]}return x&&!k&&(E=new Yf(P),k=E.root,P=E.data),l.verbose&&(l.polygons?console.log("MarchingSquaresJS-isoLines: returning single lines (polygons) for each grid cell"):console.log("MarchingSquaresJS-isoLines: returning line paths (polygons) for entire data grid"),t&&console.log("MarchingSquaresJS-isoLines: multiple lines requested, returning array of line paths instead of lines for a single threshold")),i.forEach(function(Z,J){if(F=[],l.threshold=Z,l.verbose&&console.log("MarchingSquaresJS-isoLines: computing iso lines for threshold "+Z),l.polygons)if(x)k.cellsBelowThreshold(l.threshold,!0).forEach(function(he){F=F.concat(Wf(Hf(P,he.x,he.y,l),he.x,he.y,l))});else for(f=0;f<P.length-1;++f)for(J=0;J<P[0].length-1;++J)F=F.concat(Wf(Hf(P,J,f,l),J,f,l));else{for(R=[],J=0;J<P[0].length-1;++J)R[J]=[];if(x)k.cellsBelowThreshold(l.threshold,!1).forEach(function(he){R[he.x][he.y]=Hf(P,he.x,he.y,l)});else for(J=0;J<P[0].length-1;++J)for(f=0;f<P.length-1;++f)R[J][f]=Hf(P,J,f,l);F=U2(P,R,l)}t?U.push(F):U=F,typeof l.successCallback=="function"&&l.successCallback(U,Z)}),U}function Hf(a,i,s,l){var h,f,x,t,E,k,P=0,R=a[s+1][i],F=a[s+1][i+1],U=a[s][i+1],Z=a[s][i],J=l.threshold;if(!(isNaN(Z)||isNaN(U)||isNaN(F)||isNaN(R))){switch(P|=R>=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&&(E<J?(k.edges.left={path:[[0,h],[x,1]],move:{x:0,y:1,enter:"bottom"}},k.edges.right={path:[[1,f],[t,0]],move:{x:0,y:-1,enter:"top"}}):(k.edges.right={path:[[1,f],[x,1]],move:{x:0,y:1,enter:"bottom"}},k.edges.left={path:[[0,h],[t,0]],move:{x:0,y:-1,enter:"top"}})),l.polygons&&(E<J?k.polygons.push([[0,0],[0,h],[x,1],[1,1],[1,f],[t,0]]):(k.polygons.push([[0,0],[0,h],[t,0]]),k.polygons.push([[x,1],[1,1],[1,f]])));break;case 5: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&&(E<J?(k.edges.bottom={path:[[t,0],[0,h]],move:{x:-1,y:0,enter:"right"}},k.edges.top={path:[[x,1],[1,f]],move:{x:1,y:0,enter:"left"}}):(k.edges.top={path:[[x,1],[0,h]],move:{x:-1,y:0,enter:"right"}},k.edges.bottom={path:[[t,0],[1,f]],move:{x:1,y:0,enter:"left"}})),l.polygons&&(E<J?k.polygons.push([[0,h],[0,1],[x,1],[1,f],[1,0],[t,0]]):(k.polygons.push([[0,h],[0,1],[x,1]]),k.polygons.push([[t,0],[1,f],[1,0]])));break}return k}}var vt={square:function(a,i,s,l,h,f){f.polygons&&a.polygons.push([[0,0],[0,1],[1,1],[1,0]])},triangle_bl:function(a,i,s,l,h,f){var x=f.interpolate(i,s,f.minV,f.maxV),t=f.interpolate(i,h,f.minV,f.maxV);f.polygons_full&&(a.edges.lb={path:[[0,t],[x,0]],move:{x:0,y:-1,enter:"tl"}}),f.polygons&&a.polygons.push([[0,t],[x,0],[0,0]])},triangle_br:function(a,i,s,l,h,f){var x=f.interpolate(i,s,f.minV,f.maxV),t=f.interpolate(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.br={path:[[x,0],[1,t]],move:{x:1,y:0,enter:"lb"}}),f.polygons&&a.polygons.push([[x,0],[1,t],[1,0]])},triangle_tr:function(a,i,s,l,h,f){var x=f.interpolate(s,l,f.minV,f.maxV),t=f.interpolate(h,l,f.minV,f.maxV);f.polygons_full&&(a.edges.rt={path:[[1,x],[t,1]],move:{x:0,y:1,enter:"br"}}),f.polygons&&a.polygons.push([[1,x],[t,1],[1,1]])},triangle_tl:function(a,i,s,l,h,f){var x=f.interpolate(h,l,f.minV,f.maxV),t=f.interpolate(i,h,f.minV,f.maxV);f.polygons_full&&(a.edges.tl={path:[[x,1],[0,t]],move:{x:-1,y:0,enter:"rt"}}),f.polygons&&a.polygons.push([[0,t],[0,1],[x,1]])},tetragon_t:function(a,i,s,l,h,f){var x=f.interpolate(s,l,f.minV,f.maxV),t=f.interpolate(i,h,f.minV,f.maxV);f.polygons_full&&(a.edges.rt={path:[[1,x],[0,t]],move:{x:-1,y:0,enter:"rt"}}),f.polygons&&a.polygons.push([[0,t],[0,1],[1,1],[1,x]])},tetragon_r:function(a,i,s,l,h,f){var x=f.interpolate(i,s,f.minV,f.maxV),t=f.interpolate(h,l,f.minV,f.maxV);f.polygons_full&&(a.edges.br={path:[[x,0],[t,1]],move:{x:0,y:1,enter:"br"}}),f.polygons&&a.polygons.push([[x,0],[t,1],[1,1],[1,0]])},tetragon_b:function(a,i,s,l,h,f){var x=f.interpolate(i,h,f.minV,f.maxV),t=f.interpolate(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.lb={path:[[0,x],[1,t]],move:{x:1,y:0,enter:"lb"}}),f.polygons&&a.polygons.push([[0,0],[0,x],[1,t],[1,0]])},tetragon_l:function(a,i,s,l,h,f){var x=f.interpolate(h,l,f.minV,f.maxV),t=f.interpolate(i,s,f.minV,f.maxV);f.polygons_full&&(a.edges.tl={path:[[x,1],[t,0]],move:{x:0,y:-1,enter:"tl"}}),f.polygons&&a.polygons.push([[0,0],[0,1],[x,1],[t,0]])},tetragon_bl:function(a,i,s,l,h,f){var x=f.interpolate_a(i,s,f.minV,f.maxV),t=f.interpolate_b(i,s,f.minV,f.maxV),E=f.interpolate_a(i,h,f.minV,f.maxV),k=f.interpolate_b(i,h,f.minV,f.maxV);f.polygons_full&&(a.edges.bl={path:[[x,0],[0,E]],move:{x:-1,y:0,enter:"rb"}},a.edges.lt={path:[[0,k],[t,0]],move:{x:0,y:-1,enter:"tr"}}),f.polygons&&a.polygons.push([[x,0],[0,E],[0,k],[t,0]])},tetragon_br:function(a,i,s,l,h,f){var x=f.interpolate_a(i,s,f.minV,f.maxV),t=f.interpolate_b(i,s,f.minV,f.maxV),E=f.interpolate_a(s,l,f.minV,f.maxV),k=f.interpolate_b(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.bl={path:[[x,0],[1,k]],move:{x:1,y:0,enter:"lt"}},a.edges.rb={path:[[1,E],[t,0]],move:{x:0,y:-1,enter:"tr"}}),f.polygons&&a.polygons.push([[x,0],[1,k],[1,E],[t,0]])},tetragon_tr:function(a,i,s,l,h,f){var x=f.interpolate_a(h,l,f.minV,f.maxV),t=f.interpolate_b(h,l,f.minV,f.maxV),E=f.interpolate_b(s,l,f.minV,f.maxV),k=f.interpolate_a(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.rb={path:[[1,k],[x,1]],move:{x:0,y:1,enter:"bl"}},a.edges.tr={path:[[t,1],[1,E]],move:{x:1,y:0,enter:"lt"}}),f.polygons&&a.polygons.push([[1,k],[x,1],[t,1],[1,E]])},tetragon_tl:function(a,i,s,l,h,f){var x=f.interpolate_a(h,l,f.minV,f.maxV),t=f.interpolate_b(h,l,f.minV,f.maxV),E=f.interpolate_b(i,h,f.minV,f.maxV),k=f.interpolate_a(i,h,f.minV,f.maxV);f.polygons_full&&(a.edges.tr={path:[[t,1],[0,k]],move:{x:-1,y:0,enter:"rb"}},a.edges.lt={path:[[0,E],[x,1]],move:{x:0,y:1,enter:"bl"}}),f.polygons&&a.polygons.push([[t,1],[0,k],[0,E],[x,1]])},tetragon_lr:function(a,i,s,l,h,f){var x=f.interpolate_a(i,h,f.minV,f.maxV),t=f.interpolate_b(i,h,f.minV,f.maxV),E=f.interpolate_b(s,l,f.minV,f.maxV),k=f.interpolate_a(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.lt={path:[[0,t],[1,E]],move:{x:1,y:0,enter:"lt"}},a.edges.rb={path:[[1,k],[0,x]],move:{x:-1,y:0,enter:"rb"}}),f.polygons&&a.polygons.push([[0,x],[0,t],[1,E],[1,k]])},tetragon_tb:function(a,i,s,l,h,f){var x=f.interpolate_a(h,l,f.minV,f.maxV),t=f.interpolate_b(h,l,f.minV,f.maxV),E=f.interpolate_b(i,s,f.minV,f.maxV),k=f.interpolate_a(i,s,f.minV,f.maxV);f.polygons_full&&(a.edges.tr={path:[[t,1],[E,0]],move:{x:0,y:-1,enter:"tr"}},a.edges.bl={path:[[k,0],[x,1]],move:{x:0,y:1,enter:"bl"}}),f.polygons&&a.polygons.push([[k,0],[x,1],[t,1],[E,0]])},pentagon_tr:function(a,i,s,l,h,f){var x=f.interpolate(h,l,f.minV,f.maxV),t=f.interpolate(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.tl={path:[[x,1],[1,t]],move:{x:1,y:0,enter:"lb"}}),f.polygons&&a.polygons.push([[0,0],[0,1],[x,1],[1,t],[1,0]])},pentagon_tl:function(a,i,s,l,h,f){var x=f.interpolate(i,h,f.minV,f.maxV),t=f.interpolate(h,l,f.minV,f.maxV);f.polygons_full&&(a.edges.lb={path:[[0,x],[t,1]],move:{x:0,y:1,enter:"br"}}),f.polygons&&a.polygons.push([[0,0],[0,x],[t,1],[1,1],[1,0]])},pentagon_br:function(a,i,s,l,h,f){var x=f.interpolate(i,s,f.minV,f.maxV),t=f.interpolate(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.rt={path:[[1,t],[x,0]],move:{x:0,y:-1,enter:"tl"}}),f.polygons&&a.polygons.push([[0,0],[0,1],[1,1],[1,t],[x,0]])},pentagon_bl:function(a,i,s,l,h,f){var x=f.interpolate(i,h,f.minV,f.maxV),t=f.interpolate(i,s,f.minV,f.maxV);f.polygons_full&&(a.edges.br={path:[[t,0],[0,x]],move:{x:-1,y:0,enter:"rt"}}),f.polygons&&a.polygons.push([[0,x],[0,1],[1,1],[1,0],[t,0]])},pentagon_tr_rl:function(a,i,s,l,h,f){var x=f.interpolate(i,h,f.minV,f.maxV),t=f.interpolate(h,l,f.minV,f.maxV),E=f.interpolate_b(s,l,f.minV,f.maxV),k=f.interpolate_a(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.tl={path:[[t,1],[1,E]],move:{x:1,y:0,enter:"lt"}},a.edges.rb={path:[[1,k],[0,x]],move:{x:-1,y:0,enter:"rt"}}),f.polygons&&a.polygons.push([[0,x],[0,1],[t,1],[1,E],[1,k]])},pentagon_rb_bt:function(a,i,s,l,h,f){var x=f.interpolate(s,l,f.minV,f.maxV),t=f.interpolate_b(i,s,f.minV,f.maxV),E=f.interpolate_a(i,s,f.minV,f.maxV),k=f.interpolate(h,l,f.minV,f.maxV);f.polygons_full&&(a.edges.rt={path:[[1,x],[t,0]],move:{x:0,y:-1,enter:"tr"}},a.edges.bl={path:[[E,0],[k,1]],move:{x:0,y:1,enter:"br"}}),f.polygons&&a.polygons.push([[k,1],[1,1],[1,x],[t,0],[E,0]])},pentagon_bl_lr:function(a,i,s,l,h,f){var x=f.interpolate(i,s,f.minV,f.maxV),t=f.interpolate_a(i,h,f.minV,f.maxV),E=f.interpolate_b(i,h,f.minV,f.maxV),k=f.interpolate(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.br={path:[[x,0],[0,t]],move:{x:-1,y:0,enter:"rb"}},a.edges.lt={path:[[0,E],[1,k]],move:{x:1,y:0,enter:"lb"}}),f.polygons&&a.polygons.push([[x,0],[0,t],[0,E],[1,k],[1,0]])},pentagon_lt_tb:function(a,i,s,l,h,f){var x=f.interpolate(i,h,f.minV,f.maxV),t=f.interpolate_a(h,l,f.minV,f.maxV),E=f.interpolate_b(h,l,f.minV,f.maxV),k=f.interpolate(i,s,f.minV,f.maxV);f.polygons_full&&(a.edges.lb={path:[[0,x],[t,1]],move:{x:0,y:1,enter:"bl"}},a.edges.tr={path:[[E,1],[k,0]],move:{x:0,y:-1,enter:"tl"}}),f.polygons&&a.polygons.push([[0,0],[0,x],[t,1],[E,1],[k,0]])},pentagon_bl_tb:function(a,i,s,l,h,f){var x=f.interpolate(i,h,f.minV,f.maxV),t=f.interpolate(h,l,f.minV,f.maxV),E=f.interpolate_b(i,s,f.minV,f.maxV),k=f.interpolate_a(i,s,f.minV,f.maxV);f.polygons_full&&(a.edges.bl={path:[[k,0],[0,x]],move:{x:-1,y:0,enter:"rt"}},a.edges.tl={path:[[t,1],[E,0]],move:{x:0,y:-1,enter:"tr"}}),f.polygons&&a.polygons.push([[0,x],[0,1],[t,1],[E,0],[k,0]])},pentagon_lt_rl:function(a,i,s,l,h,f){var x=f.interpolate_a(i,h,f.minV,f.maxV),t=f.interpolate_b(i,h,f.minV,f.maxV),E=f.interpolate(h,l,f.minV,f.maxV),k=f.interpolate(s,h,f.minV,f.maxV);f.polygons_full&&(a.edges.lt={path:[[0,t],[E,1]],move:{x:0,y:1,enter:"br"}},a.edges.rt={path:[[1,k],[0,x]],move:{x:-1,y:0,enter:"rb"}}),f.polygons&&a.polygons.push([[0,x],[0,t],[E,1],[1,1],[1,k]])},pentagon_tr_bt:function(a,i,s,l,h,f){var x=f.interpolate_a(h,l,f.minV,f.maxV),t=f.interpolate_b(h,l,f.minV,f.maxV),E=f.interpolate(s,l,f.minV,f.maxV),k=f.interpolate(i,s,f.minV,f.maxV);f.polygons_full&&(a.edges.br={path:[[k,0],[x,1]],move:{x:0,y:1,enter:"bl"}},a.edges.tr={path:[[t,1],[1,E]],move:{x:1,y:0,enter:"lb"}}),f.polygons&&a.polygons.push([[x,1],[t,1],[1,E],[1,0],[k,0]])},pentagon_rb_lr:function(a,i,s,l,h,f){var x=f.interpolate(i,h,f.minV,f.maxV),t=f.interpolate_b(s,l,f.minV,f.maxV),E=f.interpolate_a(s,l,f.minV,f.maxV),k=f.interpolate(i,s,f.minV,f.maxV);f.polygons_full&&(a.edges.lb={path:[[0,x],[1,t]],move:{x:1,y:0,enter:"lt"}},a.edges.rb={path:[[1,E],[k,0]],move:{x:0,y:-1,enter:"tl"}}),f.polygons&&a.polygons.push([[0,0],[0,x],[1,t],[1,E],[k,0]])},hexagon_lt_tr:function(a,i,s,l,h,f){var x=f.interpolate(i,h,f.minV,f.maxV),t=f.interpolate_a(h,l,f.minV,f.maxV),E=f.interpolate_b(h,l,f.minV,f.maxV),k=f.interpolate(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.lb={path:[[0,x],[t,1]],move:{x:0,y:1,enter:"bl"}},a.edges.tr={path:[[E,1],[1,k]],move:{x:1,y:0,enter:"lb"}}),f.polygons&&a.polygons.push([[0,0],[0,x],[t,1],[E,1],[1,k],[1,0]])},hexagon_bl_lt:function(a,i,s,l,h,f){var x=f.interpolate(i,s,f.minV,f.maxV),t=f.interpolate_a(i,h,f.minV,f.maxV),E=f.interpolate_b(i,h,f.minV,f.maxV),k=f.interpolate(h,l,f.minV,f.maxV);f.polygons_full&&(a.edges.br={path:[[x,0],[0,t]],move:{x:-1,y:0,enter:"rb"}},a.edges.lt={path:[[0,E],[k,1]],move:{x:0,y:1,enter:"br"}}),f.polygons&&a.polygons.push([[x,0],[0,t],[0,E],[k,1],[1,1],[1,0]])},hexagon_bl_rb:function(a,i,s,l,h,f){var x=f.interpolate_a(i,s,f.minV,f.maxV),t=f.interpolate_b(i,s,f.minV,f.maxV),E=f.interpolate(i,h,f.minV,f.maxV),k=f.interpolate(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.bl={path:[[x,0],[0,E]],move:{x:-1,y:0,enter:"rt"}},a.edges.rt={path:[[1,k],[t,0]],move:{x:0,y:-1,enter:"tr"}}),f.polygons&&a.polygons.push([[x,0],[0,E],[0,1],[1,1],[1,k],[t,0]])},hexagon_tr_rb:function(a,i,s,l,h,f){var x=f.interpolate(i,s,f.minV,f.maxV),t=f.interpolate(h,l,f.minV,f.maxV),E=f.interpolate_b(s,l,f.minV,f.maxV),k=f.interpolate_a(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.tl={path:[[t,1],[1,E]],move:{x:1,y:0,enter:"lt"}},a.edges.rb={path:[[1,k],[x,0]],move:{x:0,y:-1,enter:"tl"}}),f.polygons&&a.polygons.push([[0,0],[0,1],[t,1],[1,E],[1,k],[x,0]])},hexagon_lt_rb:function(a,i,s,l,h,f){var x=f.interpolate(i,h,f.minV,f.maxV),t=f.interpolate(h,l,f.minV,f.maxV),E=f.interpolate(s,l,f.minV,f.maxV),k=f.interpolate(i,s,f.minV,f.maxV);f.polygons_full&&(a.edges.lb={path:[[0,x],[t,1]],move:{x:0,y:1,enter:"br"}},a.edges.rt={path:[[1,E],[k,0]],move:{x:0,y:-1,enter:"tl"}}),f.polygons&&a.polygons.push([[0,0],[0,x],[t,1],[1,1],[1,E],[k,0]])},hexagon_bl_tr:function(a,i,s,l,h,f){var x=f.interpolate(i,s,f.minV,f.maxV),t=f.interpolate(i,h,f.minV,f.maxV),E=f.interpolate(h,l,f.minV,f.maxV),k=f.interpolate(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.br={path:[[x,0],[0,t]],move:{x:-1,y:0,enter:"rt"}},a.edges.tl={path:[[E,1],[1,k]],move:{x:1,y:0,enter:"lb"}}),f.polygons&&a.polygons.push([[x,0],[0,t],[0,1],[E,1],[1,k],[1,0]])},heptagon_tr:function(a,i,s,l,h,f){var x=f.interpolate_a(i,s,f.minV,f.maxV),t=f.interpolate_b(i,s,f.minV,f.maxV),E=f.interpolate_a(i,h,f.minV,f.maxV),k=f.interpolate_b(i,h,f.minV,f.maxV),P=f.interpolate(h,l,f.minV,f.maxV),R=f.interpolate(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.bl={path:[[x,0],[0,E]],move:{x:-1,y:0,enter:"rb"}},a.edges.lt={path:[[0,k],[P,1]],move:{x:0,y:1,enter:"br"}},a.edges.rt={path:[[1,R],[t,0]],move:{x:0,y:-1,enter:"tr"}}),f.polygons&&a.polygons.push([[x,0],[0,E],[0,k],[P,1],[1,1],[1,R],[t,0]])},heptagon_bl:function(a,i,s,l,h,f){var x=f.interpolate(i,s,f.minV,f.maxV),t=f.interpolate(i,h,f.minV,f.maxV),E=f.interpolate_a(h,l,f.minV,f.maxV),k=f.interpolate_b(h,l,f.minV,f.maxV),P=f.interpolate_b(s,l,f.minV,f.maxV),R=f.interpolate_a(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.lb={path:[[0,t],[E,1]],move:{x:0,y:1,enter:"bl"}},a.edges.tr={path:[[k,1],[1,P]],move:{x:1,y:0,enter:"lt"}},a.edges.rb={path:[[1,R],[x,0]],move:{x:0,y:-1,enter:"tl"}}),f.polygons&&a.polygons.push([[0,0],[0,t],[E,1],[k,1],[1,P],[1,R],[x,0]])},heptagon_tl:function(a,i,s,l,h,f){var x=f.interpolate_a(i,s,f.minV,f.maxV),t=f.interpolate_b(i,s,f.minV,f.maxV),E=f.interpolate(i,h,f.minV,f.maxV),k=f.interpolate(h,l,f.minV,f.maxV),P=f.interpolate_b(s,l,f.minV,f.maxV),R=f.interpolate_a(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.bl={path:[[x,0],[0,E]],move:{x:-1,y:0,enter:"rt"}},a.edges.tl={path:[[k,1],[1,P]],move:{x:1,y:0,enter:"lt"}},a.edges.rb={path:[[1,R],[t,0]],move:{x:0,y:-1,enter:"tr"}}),f.polygons&&a.polygons.push([[x,0],[0,E],[0,1],[k,1],[1,P],[1,R],[t,0]])},heptagon_br:function(a,i,s,l,h,f){var x=f.interpolate(i,s,f.minV,f.maxV),t=f.interpolate_a(i,h,f.minV,f.maxV),E=f.interpolate_b(i,h,f.minV,f.maxV),k=f.interpolate_a(h,l,f.minV,f.maxV),P=f.interpolate_b(h,l,f.minV,f.maxV),R=f.interpolate(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.br={path:[[x,0],[0,t]],move:{x:-1,y:0,enter:"rb"}},a.edges.lt={path:[[0,E],[k,1]],move:{x:0,y:1,enter:"bl"}},a.edges.tr={path:[[P,1],[1,R]],move:{x:1,y:0,enter:"lb"}}),f.polygons&&a.polygons.push([[x,0],[0,t],[0,E],[k,1],[P,1],[1,R],[1,0]])},octagon:function(a,i,s,l,h,f){var x=f.interpolate_a(i,s,f.minV,f.maxV),t=f.interpolate_b(i,s,f.minV,f.maxV),E=f.interpolate_a(i,h,f.minV,f.maxV),k=f.interpolate_b(i,h,f.minV,f.maxV),P=f.interpolate_a(h,l,f.minV,f.maxV),R=f.interpolate_b(h,l,f.minV,f.maxV),F=f.interpolate_b(s,l,f.minV,f.maxV),U=f.interpolate_a(s,l,f.minV,f.maxV);f.polygons_full&&(a.edges.bl={path:[[x,0],[0,E]],move:{x:-1,y:0,enter:"rb"}},a.edges.lt={path:[[0,k],[P,1]],move:{x:0,y:1,enter:"bl"}},a.edges.tr={path:[[R,1],[1,F]],move:{x:1,y:0,enter:"lt"}},a.edges.rb={path:[[1,U],[t,0]],move:{x:0,y:-1,enter:"tr"}}),f.polygons&&a.polygons.push([[x,0],[0,E],[0,k],[P,1],[R,1],[1,F],[1,U],[t,0]])}};function G2(a,i,s,l){var h,f,x,t=!1,E=null,k=null,P=null,R=null,F=!1,U=[],Z=[],J=[];if(!a)throw new Error("data is required");if(i==null)throw new Error("lowerBound is required");if(s==null)throw new Error("bandWidth is required");if(x=O2(l),a instanceof Yf)E=a,k=a.root,P=a.data,x.noQuadTree||(t=!0);else if(Array.isArray(a)&&Array.isArray(a[0]))P=a;else throw new Error("input is neither array of arrays nor object retrieved from 'QuadTree()'");if(Array.isArray(i)){for(F=!0,x.noQuadTree||(t=!0),h=0;h<i.length;h++)if(isNaN(+i[h]))throw new Error("lowerBound["+h+"] is not a number");if(Array.isArray(s)){if(i.length!==s.length)throw new Error("lowerBound and bandWidth have unequal lengths");for(h=0;h<s.length;h++)if(isNaN(+s[h]))throw new Error("bandWidth["+h+"] is not a number")}else{if(isNaN(+s))throw new Error("bandWidth must be a number");for(U=[],h=0;h<i.length;h++)U.push(s);s=U}}else{if(isNaN(+i))throw new Error("lowerBound must be a number");if(i=[i],isNaN(+s))throw new Error("bandWidth must be a number");s=[s]}return t&&!k&&(E=new Yf(P),k=E.root,P=E.data),x.verbose&&(x.polygons?console.log("MarchingSquaresJS-isoBands: returning single polygons for each grid cell"):console.log("MarchingSquaresJS-isoBands: returning polygon paths for entire data grid"),F&&console.log("MarchingSquaresJS-isoBands: multiple bands requested, returning array of band polygons instead of polygons for a single band")),i.forEach(function(he,ye){if(Z=[],x.minV=he,x.maxV=he+s[ye],x.verbose&&console.log("MarchingSquaresJS-isoBands: computing isobands for ["+he+":"+(he+s[ye])+"]"),x.polygons)if(t)k.cellsInBand(x.minV,x.maxV,!0).forEach(function(te){Z=Z.concat(Wf(Kf(P,te.x,te.y,x),te.x,te.y,x))});else for(f=0;f<P.length-1;++f)for(h=0;h<P[0].length-1;++h)Z=Z.concat(Wf(Kf(P,h,f,x),h,f,x));else{for(R=[],h=0;h<P[0].length-1;++h)R[h]=[];if(t)k.cellsInBand(x.minV,x.maxV,!1).forEach(function(te){R[te.x][te.y]=Kf(P,te.x,te.y,x)});else for(h=0;h<P[0].length-1;++h)for(f=0;f<P.length-1;++f)R[h][f]=Kf(P,h,f,x);Z=V2(P,R,x)}F?J.push(Z):J=Z,typeof x.successCallback=="function"&&x.successCallback(J,he,s[ye])}),J}function xo(a,i,s,l,h,f){var x=(l+s+i+a)/4;return x>f?2:x<h?0:1}function Kf(a,i,s,l){var h,f,x=0,t=a[s+1][i],E=a[s+1][i+1],k=a[s][i+1],P=a[s][i],R=l.minV,F=l.maxV;if(!(isNaN(P)||isNaN(k)||isNaN(E)||isNaN(t))){switch(x|=t<R?0:t>F?128:64,x|=E<R?0:E>F?32:16,x|=k<R?0:k>F?8:4,x|=P<R?0:P>F?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<f.length;t++){for(var E=f[t],k=[],P=0;P<E.length;P++){var R=E[P];R.properties[s]?k.push(R.properties[s]):k.push(0),h===!0&&(R.properties.matrixPosition=[t,P])}x.push(k)}return x}function W2(a,i){var s={};Bn(a,function(f){var x=_n(f)[1];s[x]||(s[x]=[]),s[x].push(f)});var l=Object.keys(s).map(function(f){var x=s[f],t=x.sort(function(E,k){return _n(E)[0]-_n(k)[0]});return t}),h=l.sort(function(f,x){return i?_n(f[0])[1]-_n(x[0])[1]:_n(x[0])[1]-_n(f[0])[1]});return h}function Y2(a,i,s){if(s=s||{},!Hn(s))throw new Error("options is invalid");const l=s.zProperty||"elevation",h=s.commonProperties||{},f=s.breaksProperties||[];if(Qs(a,"Point","Input must contain Points"),!i)throw new Error("breaks is required");if(!Array.isArray(i))throw new Error("breaks is not an Array");if(!Hn(h))throw new Error("commonProperties is not an Object");if(!Array.isArray(f))throw new Error("breaksProperties is not an Array");const x=X2(a,{zProperty:l,flip:!0});let t=H2(x,i,l);t=K2(t,x,a);const E=t.map((k,P)=>{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<i.length;h++){const f=+i[h-1],x=+i[h],t=G2(a,f,x-f),E=J2(t),k=Q2(E);l.push({groupedRings:k,[s]:f+"-"+x})}return l}function K2(a,i,s){const l=pi(s),h=l[2]-l[0],f=l[3]-l[1],x=l[0],t=l[1],E=i[0].length-1,k=i.length-1,P=h/E,R=f/k;return a.map(function(F){return F.groupedRings=F.groupedRings.map(function(U){return U.map(function(Z){return Z.map(J=>[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;l<i.length;l++)if(!i[l].grouped){const h=[];h.push(i[l].lrCoordinates),i[l].grouped=!0;const f=Mn([i[l].lrCoordinates]);for(let x=l+1;x<i.length;x++)if(!i[x].grouped){const t=Mn([i[x].lrCoordinates]);eI(t,f)&&(h.push(i[x].lrCoordinates),i[x].grouped=!0)}s.push(h)}return s}function eI(a,i){const s=Xf(a);for(let l=0;l<s.features.length;l++)if(!Pn(s.features[l],i))return!1;return!0}function tI(a){for(let i=0;i<a.length;i++)if(a[i].grouped===!1)return!1;return!0}var nI=Object.defineProperty,P0=Object.getOwnPropertySymbols,iI=Object.prototype.hasOwnProperty,rI=Object.prototype.propertyIsEnumerable,L0=(a,i,s)=>i 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<f.length;t++){for(var E=f[t],k=[],P=0;P<E.length;P++){var R=E[P];R.properties[s]?k.push(R.properties[s]):k.push(0),h===!0&&(R.properties.matrixPosition=[t,P])}x.push(k)}return x}function sI(a,i){var s={};Bn(a,function(f){var x=_n(f)[1];s[x]||(s[x]=[]),s[x].push(f)});var l=Object.keys(s).map(function(f){var x=s[f],t=x.sort(function(E,k){return _n(E)[0]-_n(k)[0]});return t}),h=l.sort(function(f,x){return i?_n(f[0])[1]-_n(x[0])[1]:_n(x[0])[1]-_n(f[0])[1]});return h}function aI(a,i,s){if(s=s||{},!Hn(s))throw new Error("options is invalid");const l=s.zProperty||"elevation",h=s.commonProperties||{},f=s.breaksProperties||[];if(Qs(a,"Point","Input must contain Points"),!i)throw new Error("breaks is required");if(!Array.isArray(i))throw new Error("breaks must be an Array");if(!Hn(h))throw new Error("commonProperties must be an Object");if(!Array.isArray(f))throw new Error("breaksProperties must be an Array");const x=oI(a,{zProperty:l,flip:!0}),t=lI(x,i,l,h,f),E=uI(t,x,a);return Jt(E)}function lI(a,i,s,l,h){const f=[];for(let x=0;x<i.length;x++){const t=+i[x],E=R0(R0({},l),h[x]);E[s]=t;const k=Pa(j2(a,t,{linearRing:!1,noFrame:!0}),E);f.push(k)}return f}function uI(a,i,s){const l=pi(s),h=l[2]-l[0],f=l[3]-l[1],x=l[0],t=l[1],E=i[0].length-1,k=i.length-1,P=h/E,R=f/k,F=U=>{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<h.length-1;x++)for(let t=x;t<f.length-1;t++){if(h===f&&(Math.abs(x-t)===1||x===0&&t===h.length-2&&h[x][0]===h[h.length-1][0]&&h[x][1]===h[h.length-1][1]))continue;const E=cI(h[x][0],h[x][1],h[x+1][0],h[x+1][1],f[t][0],f[t][1],f[t+1][0],f[t+1][1]);E&&l.features.push(cn([E[0],E[1]]))}})}),l}function cI(a,i,s,l,h,f,x,t){let E,k,P,R,F;const U={x:null,y:null,onLine1:!1,onLine2:!1};return E=(t-f)*(s-a)-(x-h)*(l-i),E===0?U.x!==null&&U.y!==null?U:!1:(k=i-f,P=a-h,R=(x-h)*k-(t-f)*P,F=(s-a)*k-(l-i)*P,k=R/E,P=F/E,U.x=a+k*(s-a),U.y=i+k*(l-i),k>=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?t:t+360;let R=k;const F=[];let U=0;const Z=(P-k)/f;for(;R<=P;)F.push(ea(a,i,R,h).geometry.coordinates),U++,R=k+U*Z;return Zn(F,E)}function O0(a){let i=a%360;return i<0&&(i+=360),i}function N0(a,i,s,l){if(l=l||{},!Hn(l))throw new Error("options is invalid");var h,f=[];if(a.type==="Feature")h=a.geometry.coordinates;else if(a.type==="LineString")h=a.coordinates;else throw new Error("input must be a LineString Feature or Geometry");for(var x=h.length,t=0,E,k,P,R=0;R<h.length&&!(i>=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(t<i&&h.length===x)throw new Error("Start position is beyond line");var F=h[h.length-1];return Zn([F,F])}function hI(a,i,s){if(s=s||{},!Hn(s))throw new Error("options is invalid");var l=s.units,h=s.reverse;if(!a)throw new Error("geojson is required");if(i<=0)throw new Error("segmentLength must be greater than 0");var f=[];return Wi(a,function(x){h&&(x.geometry.coordinates=x.geometry.coordinates.reverse()),fI(x,i,l,function(t){f.push(t)})}),Jt(f)}function fI(a,i,s,l){var h=D0(a,{units:s});if(h<=i)return l(a);var f=h/i;Number.isInteger(f)||(f=Math.floor(f)+1);for(var x=0;x<f;x++){var t=N0(a,i*x,i*(x+1),{units:s});l(t,x)}}function Jf(a){var i=a[0],s=a[1];return[s[0]-i[0],s[1]-i[1]]}function vm(a,i){return a[0]*i[1]-i[0]*a[1]}function dI(a,i){return[a[0]+i[0],a[1]+i[1]]}function pI(a,i){return[a[0]-i[0],a[1]-i[1]]}function mI(a,i){return[a*i[0],a*i[1]]}function gI(a,i){var s=a[0],l=Jf(a),h=i[0],f=Jf(i),x=vm(l,f),t=pI(h,s),E=vm(t,f),k=E/x,P=dI(s,mI(k,l));return P}function _I(a,i){var s=Jf(a),l=Jf(i);return vm(s,l)===0}function yI(a,i){return _I(a,i)?!1:gI(a,i)}function vI(a,i,s){if(s=s||{},!Hn(s))throw new Error("options is invalid");var l=s.units;if(!a)throw new Error("geojson is required");if(i==null||isNaN(i))throw new Error("distance is required");var h=vo(a),f=a.properties;switch(h){case"LineString":return B0(a,i,l);case"MultiLineString":var x=[];return Wi(a,function(t){x.push(B0(t,i,l).geometry.coordinates)}),Pa(x,f);default:throw new Error("geometry "+h+" is not supported")}}function B0(a,i,s){var l=[],h=mf(i,s),f=_n(a),x=[];return f.forEach(function(t,E){if(E!==f.length-1){var k=xI(t,f[E+1],h);if(l.push(k),E>0){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[1].properties.index+1;E++)t.push(l[E]);return t.push(x[1].geometry.coordinates),Zn(t,s.properties)}function F0(a){var i=a[0],s=a[1],l=a[2],h=a[3],f=Wn(a.slice(0,2),[l,s]),x=Wn(a.slice(0,2),[i,h]);if(f>=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("<geojson> is required");if(typeof s!="number")throw new Error("<precision> must be a number");if(typeof l!="number")throw new Error("<coordinates> 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;l<a.length;l++)a[l]=Math.round(a[l]*i)/i;return a}function EI(a,i){if(!a)throw new Error("line is required");if(!i)throw new Error("splitter is required");var s=vo(a),l=vo(i);if(s!=="LineString")throw new Error("line must be LineString");if(l==="FeatureCollection")throw new Error("splitter cannot be a FeatureCollection");if(l==="GeometryCollection")throw new Error("splitter cannot be a GeometryCollection");var h=V0(i,{precision:7});switch(l){case"Point":return xm(a,h);case"MultiPoint":return U0(a,h);case"LineString":case"MultiLineString":case"Polygon":case"MultiPolygon":return U0(a,os(a,h,{ignoreSelfIntersections:!0}))}}function U0(a,i){var s=[],l=Ef();return Wi(i,function(h){if(s.forEach(function(t,E){t.id=E}),!s.length)s=xm(a,h).features,s.forEach(function(t){t.bbox||(t.bbox=F0(pi(t)))}),l.load(Jt(s));else{var f=l.search(h);if(f.features.length){var x=j0(h,f);s=s.filter(function(t){return t.id!==x.id}),l.remove(x),Bn(xm(x,h),function(t){s.push(t),l.insert(t)})}}}),Jt(s)}function xm(a,i){var s=[],l=_n(a)[0],h=_n(a)[a.geometry.coordinates.length-1];if(bm(l,Jn(i))||bm(h,Jn(i)))return Jt([a]);var f=Ef(),x=wu(a);f.load(x);var t=f.search(i);if(!t.features.length)return Jt([a]);var E=j0(i,t),k=[l],P=bp(x,function(R,F,U){var Z=_n(F)[1],J=Jn(i);return U===E.id?(R.push(J),s.push(Zn(R)),bm(J,Z)?[J]:[J,Z]):(R.push(Z),R)},k);return P.length>1&&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;x<l&&(s=h,l=x)}),s}function bm(a,i){return a[0]===i[0]&&a[1]===i[1]}function TI(a,i={}){var s,l,h,f=i.properties,x=(s=i.autoComplete)!=null?s:!0,t=(l=i.orderCoords)!=null?l:!0,E=(h=i.mutate)!=null?h:!1;switch(E||(a=yr(a)),a.type){case"FeatureCollection":var k=[];return a.features.forEach(function(P){k.push(_n(G0(P,{},x,t)))}),oo(k,f);default:return G0(a,f,x,t)}}function G0(a,i,s,l){i=i||(a.type==="Feature"?a.properties:{});var h=Ei(a),f=h.coordinates,x=h.type;if(!f.length)throw new Error("line must contain coordinates");switch(x){case"LineString":return s&&(f=q0(f)),Mn([f],i);case"MultiLineString":var t=[],E=0;return f.forEach(function(k){if(s&&(k=q0(k)),l){var P=II(pi(Zn(k)));P>E?(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;ft<te;ft++){let lt=0;for(let Je=0;Je<te;Je++)Z+=P[ft][Je]*(R[ft]-F)*(R[Je]-F),J+=P[ft][Je],he+=Math.pow(P[ft][Je]+P[Je][ft],2),lt+=P[ft][Je]+P[Je][ft];ye+=Math.pow(lt,2)}he=.5*he;const ce=Z/J/U,be=-1/(te-1),we=te*te*he-te*ye+3*(J*J),Ue=(te-1)*(te+1)*(J*J),ze=we/Ue-be*be,Ve=Math.sqrt(ze),Ie=(ce-be)/Ve;return{expectedMoranIndex:be,moranIndex:ce,stdNorm:Ve,zNorm:Ie}}function Z0(a){let i=0;for(const s of a)i+=s;return i/a.length}function PI(a){const i=Z0(a);let s=0;for(const l of a)s+=Math.pow(l-i,2);return s/a.length}var LI=Object.defineProperty,RI=Object.defineProperties,DI=Object.getOwnPropertyDescriptors,$0=Object.getOwnPropertySymbols,zI=Object.prototype.hasOwnProperty,OI=Object.prototype.propertyIsEnumerable,X0=(a,i,s)=>i 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<l&&(h=t,l=E)});const f=yr(i.features[h]);return Y0(W0({},f),{properties:Y0(W0({},f.properties),{featureIndex:h,distanceToPoint:l})})}function NI(a,i){i=i||{};const s=i.studyArea||kc(pi(a)),l=i.properties||{},h=i.units||"kilometers",f=[];Bn(a,R=>{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);E<l&&(l=E)}),El(l,"degrees",s.units)}function BI(a,i,s,l){const h=[s[0]-i[0],s[1]-i[1]],f=[a[0]-i[0],a[1]-i[1]],x=K0(f,h);if(x<=0)return Em(a,i,{method:l.method,units:"degrees"});const t=K0(h,h);if(t<=x)return Em(a,s,{method:l.method,units:"degrees"});const E=x/t,k=[i[0]+E*h[0],i[1]+E*h[1]];return Em(a,k,{method:l.method,units:"degrees"})}function K0(a,i){return a[0]*i[0]+a[1]*i[1]}function Em(a,i,s){return s.method==="planar"?$f(a,i,s):Wn(a,i,s)}var FI=Object.defineProperty,J0=Object.getOwnPropertySymbols,VI=Object.prototype.hasOwnProperty,UI=Object.prototype.propertyIsEnumerable,Q0=(a,i,s)=>i 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<x&&(x=k,t=E)}),t&&(t.properties=Tm(Tm(Tm({},{dist:x}),t.properties),h)),t}function GI(a){const i=[];switch(a.geometry?a.geometry.type:a.type){case"GeometryCollection":return Br(a,l=>{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&&h<i.features.length;){const f=i.features[h].geometry;let x,t,E,k,P,R,F=!1;if(f.type==="Point")s.geometry.coordinates[0]===f.coordinates[0]&&s.geometry.coordinates[1]===f.coordinates[1]&&(l=!0);else if(f.type==="MultiPoint"){let U=!1,Z=0;for(;!U&&Z<f.coordinates.length;)s.geometry.coordinates[0]===f.coordinates[Z][0]&&s.geometry.coordinates[1]===f.coordinates[Z][1]&&(l=!0,U=!0),Z++}else if(f.type==="LineString"){let U=0;for(;!F&&U<f.coordinates.length-1;)x=s.geometry.coordinates[0],t=s.geometry.coordinates[1],E=f.coordinates[U][0],k=f.coordinates[U][1],P=f.coordinates[U+1][0],R=f.coordinates[U+1][1],ev(x,t,E,k,P,R)&&(F=!0,l=!0),U++}else if(f.type==="MultiLineString"){let U=0;for(;U<f.coordinates.length;){F=!1;let Z=0;const J=f.coordinates[U];for(;!F&&Z<J.length-1;)x=s.geometry.coordinates[0],t=s.geometry.coordinates[1],E=J[Z][0],k=J[Z][1],P=J[Z+1][0],R=J[Z+1][1],ev(x,t,E,k,P,R)&&(F=!0,l=!0),Z++;U++}}else(f.type==="Polygon"||f.type==="MultiPolygon")&&Pn(s,f)&&(l=!0);h++}if(l)return s;{const f=Jt([]);for(let x=0;x<i.features.length;x++)f.features=f.features.concat(Xf(i.features[x]).features);return cn(Qf(s,f).geometry.coordinates)}}function $I(a){return a.type!=="FeatureCollection"?a.type!=="Feature"?Jt([nr(a)]):Jt([a]):a}function ev(a,i,s,l,h,f){const x=Math.sqrt((h-s)*(h-s)+(f-l)*(f-l)),t=Math.sqrt((a-s)*(a-s)+(i-l)*(i-l)),E=Math.sqrt((h-a)*(h-a)+(f-i)*(f-i));return x===t+E}function tv(a,i){const s=[];return Bn(a,function(l){let h=!1;if(l.geometry.type==="Point")Br(i,function(x){Pn(l,x)&&(h=!0)}),h&&s.push(l);else if(l.geometry.type==="MultiPoint"){var f=[];Br(i,function(x){xi(l,function(t){Pn(t,x)&&(h=!0,f.push(t))})}),h&&s.push(Tc(f,l.properties))}else throw new Error("Input geometry must be a Point or MultiPoint")}),Jt(s)}function XI(a){return(a>0)-(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;E<s;E++){let k=[],P=h;E>0&&(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;E<s;E++){let k=[],P=h;E>0&&(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[2]&&s[1]>t[1]&&s[1]<t[3]&&(k=Qf(a,Xf(i)),E=k.properties.featureIndex),vo(i)){case"Polygon":h=l[0][E],f=l[0][0],k!==null&&k.geometry.coordinates[1]<s[1]&&(f=l[0][E]),x=Zc(l[0][0],l[0][l[0].length-1],s),[h,f]=ov(l[0],s,x,h,f);break;case"MultiPolygon":for(var R=0,F=0,U=0,Z=0;Z<l[0].length;Z++){R=Z;for(var J=!1,he=0;he<l[0][Z].length;he++){if(F=he,U===E){J=!0;break}U++}if(J)break}h=l[0][R][F],f=l[0][R][F],x=Zc(l[0][0][0],l[0][0][l[0][0].length-1],s),l.forEach(function(ye){[h,f]=ov(ye[0],s,x,h,f)});break}return Jt([cn(h),cn(f)])}function ov(a,i,s,l,h){for(let f=0;f<a.length;f++){const x=a[f];let t=a[f+1];f===a.length-1&&(t=a[0]);const E=Zc(x,t,i);s<=0&&E>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;ze<k.length;ze++)P[ze]={box:pi(k[ze]),cnt:0};let R=0;for(const ze of h)for(const Ve of Object.keys(P)){const Ie=P[Ve].box;if(cM(Jn(ze),Ie)){P[Ve].cnt+=1,R+=1;break}}let F=0;for(const ze of Object.keys(P)){const Ve=P[ze].cnt;Ve>F&&(F=Ve)}const U=[],Z=Object.keys(P).length,J=R/Z;let he=0;for(let ze=0;ze<F+1;ze++)he+=Math.exp(-J)*Math.pow(J,ze)/hM(ze),U.push(he);const ye=[];let te=0;for(let ze=0;ze<F+1;ze++){for(const Ie of Object.keys(P))P[Ie].cnt===ze&&(te+=1);const Ve=te/Z;ye.push(Ve)}let ce=0;for(let ze=0;ze<F+1;ze++){const Ve=Math.abs(U[ze]-ye[ze]);Ve>ce&&(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;l<a;l++)s.push(cn(ed(i.bbox)));return Jt(s)}function dv(a,i={}){td(i.bbox),a==null&&(a=1),(i.bbox===void 0||i.bbox===null)&&(i.bbox=[-180,-90,180,90]),(!cr(i.num_vertices)||i.num_vertices===void 0)&&(i.num_vertices=10),(!cr(i.max_radial_length)||i.max_radial_length===void 0)&&(i.max_radial_length=10);const s=Math.abs(i.bbox[0]-i.bbox[2]),l=Math.abs(i.bbox[1]-i.bbox[3]),h=Math.min(s/2,l/2);if(i.max_radial_length>h)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<a;t++){let E=[];const k=[...Array(i.num_vertices+1)].map(Math.random);k.forEach((P,R,F)=>{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<a;t++){const k=[ed(s)];for(let P=0;P<l-1;P++){const F=(P===0?Math.random()*2*Math.PI:Math.tan((k[P][1]-k[P-1][1])/(k[P][0]-k[P-1][0])))+(Math.random()-.5)*f*2,U=Math.random()*h;k.push([k[P][0]+U*Math.cos(F),k[P][1]+U*Math.sin(F)])}x.push(Zn(k))}return Jt(x)}function fM(a){return i=>[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("<geojson> is required");if(typeof f!="boolean")throw new Error("<reverse> must be a boolean");if(typeof h!="boolean")throw new Error("<mutate> 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;s<a.length;s++)_f(a[s])===i&&a[s].reverse()}function _M(a,i){if(!a)throw new Error("fc is required");if(i==null)throw new Error("num is required");if(typeof i!="number")throw new Error("num must be a number");var s=Jt(yM(a.features,i));return s}function yM(a,i){for(var s=a.slice(0),l=a.length,h=l-i,f,x;l-- >h;)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;R<F;++R){var U=P[R];if(!(U.closed||U.isWall())){var Z=k.g+U.getCost(k),J=U.visited;(!J||Z<U.g)&&(U.visited=!0,U.parent=k,U.h=U.h||f(U,s),U.g=Z,U.f=U.g+U.h,a.markDirty(U),x&&(U.h<E.h||U.h===E.h&&U.g<E.g)&&(E=U),J?t.rescoreElement(U):t.push(U))}}}return x?wv(E):[]},heuristics:{manhattan:function(a,i){var s=Math.abs(i.x-a.x),l=Math.abs(i.y-a.y);return s+l},diagonal:function(a,i){var s=1,l=Math.sqrt(2),h=Math.abs(i.x-a.x),f=Math.abs(i.y-a.y);return s*(h+f)+(l-2*s)*Math.min(h,f)}},cleanNode:function(a){a.f=0,a.g=0,a.h=0,a.visited=!1,a.closed=!1,a.parent=null}};function Pu(a,i){i=i||{},this.nodes=[],this.diagonal=!!i.diagonal,this.grid=[];for(var s=0;s<a.length;s++){this.grid[s]=[];for(var l=0,h=a[s];l<h.length;l++){var f=new rd(s,l,h[l]);this.grid[s][l]=f,this.nodes.push(f)}}this.init()}Pu.prototype.init=function(){this.dirtyNodes=[];for(var a=0;a<this.nodes.length;a++)id.cleanNode(this.nodes[a])},Pu.prototype.cleanDirty=function(){for(var a=0;a<this.dirtyNodes.length;a++)id.cleanNode(this.dirtyNodes[a]);this.dirtyNodes=[]},Pu.prototype.markDirty=function(a){this.dirtyNodes.push(a)},Pu.prototype.neighbors=function(a){var i=[],s=a.x,l=a.y,h=this.grid;return h[s-1]&&h[s-1][l]&&i.push(h[s-1][l]),h[s+1]&&h[s+1][l]&&i.push(h[s+1][l]),h[s]&&h[s][l-1]&&i.push(h[s][l-1]),h[s]&&h[s][l+1]&&i.push(h[s][l+1]),this.diagonal&&(h[s-1]&&h[s-1][l-1]&&i.push(h[s-1][l-1]),h[s+1]&&h[s+1][l-1]&&i.push(h[s+1][l-1]),h[s-1]&&h[s-1][l+1]&&i.push(h[s-1][l+1]),h[s+1]&&h[s+1][l+1]&&i.push(h[s+1][l+1])),i},Pu.prototype.toString=function(){for(var a=[],i=this.grid,s,l,h,f,x=0,t=i.length;x<t;x++){for(s=[],l=i[x],h=0,f=l.length;h<f;h++)s.push(l[h].weight);a.push(s.join(" "))}return a.join(`
|
|
|
`)};function rd(a,i,s){this.x=a,this.y=i,this.weight=s}rd.prototype.toString=function(){return"["+this.x+" "+this.y+"]"},rd.prototype.getCost=function(a){return a&&a.x!==this.x&&a.y!==this.y?this.weight*1.41421:this.weight},rd.prototype.isWall=function(){return this.weight===0};function Ev(a){this.content=[],this.scoreFunction=a}Ev.prototype={push:function(a){this.content.push(a),this.sinkDown(this.content.length-1)},pop:function(){var a=this.content[0],i=this.content.pop();return this.content.length>0&&(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)<this.scoreFunction(a)?this.sinkDown(i):this.bubbleUp(i))},size:function(){return this.content.length},rescoreElement:function(a){this.sinkDown(this.content.indexOf(a))},sinkDown:function(a){for(var i=this.content[a];a>0;){var s=(a+1>>1)-1,l=this.content[s];if(this.scoreFunction(i)<this.scoreFunction(l))this.content[s]=i,this.content[a]=l,a=s;else break}},bubbleUp:function(a){for(var i=this.content.length,s=this.content[a],l=this.scoreFunction(s);;){var h=a+1<<1,f=h-1,x=null,t;if(f<i){var E=this.content[f];t=this.scoreFunction(E),t<l&&(x=f)}if(h<i){var k=this.content[h],P=this.scoreFunction(k);P<(x===null?l:t)&&(x=h)}if(x!==null)this.content[a]=this.content[x],this.content[x]=s,a=x;else break}}};function wM(a,i,s={}){if(s=s||{},!Hn(s))throw new Error("options is invalid");let l=s.obstacles||Jt([]),h=s.resolution||100;if(!a)throw new Error("start is required");if(!i)throw new Error("end is required");if(h&&(!cr(h)||h<=0))throw new Error("options.resolution must be a number, greater than 0");const f=Jn(a),x=Jn(i);if(a=cn(f),i=cn(x),l.type==="FeatureCollection"){if(l.features.length===0)return Zn([f,x])}else if(l.type==="Polygon")l=Jt([nr(Ei(l))]);else throw new Error("invalid obstacles");const t=l;t.features.push(a),t.features.push(i);const E=pi(xv(kc(pi(t)),1.15)),[k,P,R,F]=E,Z=Wn([k,P],[R,P],s)/h;t.features.pop(),t.features.pop();const he=Z/Wn([k,P],[R,P],s)*(R-k),te=Z/Wn([k,P],[k,F],s)*(F-P),ce=R-k,be=F-P,we=Math.floor(ce/he),Ue=Math.floor(be/te),ze=(ce-we*he)/2,Ve=(be-Ue*te)/2,Ie=[],ft=[];let lt,Je,At=1/0,ut=1/0,Nt=F-Ve,Lt=0;for(;Nt>=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&&je<At&&(At=je,lt={x:hn,y:Lt});const Kn=Wn(rn,i);!Tn&&Kn<ut&&(ut=Kn,Je={x:hn,y:Lt}),St+=he,hn++}ft.push(Zt),Ie.push(Vt),Nt-=te,Lt++}const Yt=new Pu(ft,{diagonal:!0}),Mt=Yt.grid[lt.y][lt.x],Gt=Yt.grid[Je.y][Je.x],tt=id.search(Yt,Mt,Gt),Bt=[f];return tt.forEach(function(Zt){const Vt=Ie[Zt.x][Zt.y].split("|");Bt.push([+Vt[0],+Vt[1]])}),Bt.push(x),La(Zn(Bt))}function EM(a,i){for(let s=0;s<i.features.length;s++)if(Pn(a,i.features[s]))return!0;return!1}function TM(a,i){var s=a[0]-i[0],l=a[1]-i[1];return s*s+l*l}function IM(a,i,s){var l=i[0],h=i[1],f=s[0]-l,x=s[1]-h;if(f!==0||x!==0){var t=((a[0]-l)*f+(a[1]-h)*x)/(f*f+x*x);t>1?(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;f<x;f++)h=a[f],TM(h,s)>i&&(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;t<s;t++){var E=IM(a[t],a[i],a[s]);E>f&&(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;Z<h;Z+=s)R=a[Z],F=a[Z+1],R<t&&(t=R),F<E&&(E=F),R>k&&(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<s;f+=l)x=Cv(f,a[f],a[f+1],x);else for(f=s-l;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=h<f?h<x?h:x:f<x?f:x,R=t<E?t<k?t:k:E<k?E:k,F=h>f?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=t<E?t<k?t:k:E<k?E:k,Z=P<R?P<F?P:F:R<F?R:F,J=t>E?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<x;f++)t=i[f]*l,E=f<x-1?i[f+1]*l:a.length,k=Mv(a,t,E,l,!1),k===k.next&&(k.steiner=!0),h.push(qM(k));for(h.sort(BM),f=0;f<h.length;f++)s=FM(h[f],s);return s}function BM(a,i){return a.x-i.x}function FM(a,i){var s=VM(a,i);if(!s)return i;var l=kv(s,a);return Al(l,l.next),Al(s,s.next)}function VM(a,i){var s=i,l=a.x,h=a.y,f=-1/0,x;do{if(h<=s.y&&h>=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.next.x?s:s.next,t===l))return x}s=s.next}while(s!==i);if(!x)return null;var E=x,k=x.x,P=x.y,R=1/0,F;s=x;do l>=s.x&&s.x>=k&&l!==s.x&&Lu(h<P?l:f,h,k,P,h<P?f:l,h,s.x,s.y)&&(F=Math.abs(h-s.y)/(l-s.x),Xc(s,a)&&(F<R||F===R&&(s.x>x.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;i<k&&(t++,l=l.nextZ,!!l);i++);for(E=k;t>0||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<s.x||i.x===s.x&&i.y<s.y)&&(s=i),i=i.next;while(i!==a);return s}function Lu(a,i,s,l,h,f,x,t){return(h-x)*(i-t)>=(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;t<E;t++){var k=i[t]*s,P=t<E-1?i[t+1]*s:a.length;x-=Math.abs(Am(a,k,P,s))}var R=0;for(t=0;t<l.length;t+=3){var F=l[t]*s,U=l[t+1]*s,Z=l[t+2]*s;R+=Math.abs((a[F]-a[Z])*(a[U+1]-a[F+1])-(a[F]-a[U])*(a[Z+1]-a[F+1]))}return x===0&&R===0?0:Math.abs((R-x)/x)};function Am(a,i,s,l){for(var h=0,f=i,x=s-l;f<s;f+=l)h+=(a[x]-a[f])*(a[f+1]+a[x+1]),x=f;return h}sd.flatten=function(a){for(var i=a[0][0].length,s={vertices:[],holes:[],dimensions:i},l=0,h=0;h<a.length;h++){for(var f=0;f<a[h].length;f++)for(var x=0;x<i;x++)s.vertices.push(a[h][f][x]);h>0&&(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;x<f.length;x+=3){const t=f.slice(x,x+3);t.push(f[x]),h.push(Mn([t]))}return h}function KM(a){const i=a[0][0].length,s={vertices:[],holes:[],dimensions:i};let l=0;for(let h=0;h<a.length;h++){for(let f=0;f<a[h].length;f++)for(let x=0;x<i;x++)s.vertices.push(a[h][f][x]);h>0&&(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<l.length;t++)for(var E=0;E<l[t].length-1;E++)x.push(he(t,E));var k=new so;k.load(x)}for(var P=0;P<l.length;P++)for(var R=0;R<l[P].length-1;R++)if(s){var F=k.search(he(P,R));F.forEach(function(ye){var te=ye.ring,ce=ye.edge;J(P,R,te,ce)})}else for(var U=0;U<l.length;U++)for(var Z=0;Z<l[U].length-1;Z++)J(P,R,U,Z);return i||(h={type:"Feature",geometry:{type:"MultiPoint",coordinates:h}}),h;function J(ye,te,ce,be){var we=l[ye][te],Ue=l[ye][te+1],ze=l[ce][be],Ve=l[ce][be+1],Ie=tS(we,Ue,ze,Ve);if(Ie!==null){var ft,lt;if(Ue[0]!==we[0]?ft=(Ie[0]-we[0])/(Ue[0]-we[0]):ft=(Ie[1]-we[1])/(Ue[1]-we[1]),Ve[0]!==ze[0]?lt=(Ie[0]-ze[0])/(Ve[0]-ze[0]):lt=(Ie[1]-ze[1])/(Ve[1]-ze[1]),!(ft>=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]<be[0]?(we=ce[0],Ue=be[0]):(we=be[0],Ue=ce[0]),ce[1]<be[1]?(ze=ce[1],Ve=be[1]):(ze=be[1],Ve=ce[1]),{minX:we,minY:ze,maxX:Ue,maxY:Ve,ring:ye,edge:te}}}function tS(a,i,s,l){if(Yc(a,s)||Yc(a,l)||Yc(i,s)||Yc(l,s))return null;var h=a[0],f=a[1],x=i[0],t=i[1],E=s[0],k=s[1],P=l[0],R=l[1],F=(h-x)*(k-R)-(f-t)*(E-P);if(F===0)return null;var U=((h*t-f*x)*(E-P)-(h-x)*(E*R-k*P))/F,Z=((h*t-f*x)*(k-R)-(f-t)*(E*R-k*P))/F;return[U,Z]}function Yc(a,i){if(!a||!i||a.length!==i.length)return!1;for(var s=0,l=a.length;s<l;s++)if(a[s]instanceof Array&&i[s]instanceof Array){if(!Yc(a[s],i[s]))return!1}else if(a[s]!==i[s])return!1;return!0}function nS(a){if(a.type!="Feature")throw new Error("The input must a geojson object of type Feature");if(a.geometry===void 0||a.geometry==null)throw new Error("The input must a geojson object with a non-empty geometry");if(a.geometry.type!="Polygon")throw new Error("The input must be a geojson Polygon");for(var i=a.geometry.coordinates.length,s=[],te=0;te<i;te++){var l=a.geometry.coordinates[te];Hc(l[0],l[l.length-1])||l.push(l[0]);for(var h=0;h<l.length-1;h++)s.push(l[h])}if(!rS(s))throw new Error("The input polygon may not have duplicate vertices (except for the first and last vertex of each ring)");var f=s.length,x=eS(a,function(St,hn,rn,Tn,je,Kn,bn,gt,Me,Fn,Si,yn){return[St,hn,rn,Tn,je,Kn,bn,gt,Me,Fn,Si,yn]}),t=x.length;if(t==0){for(var ze=[],te=0;te<i;te++)ze.push(Mn([a.geometry.coordinates[te]],{parent:-1,winding:iS(a.geometry.coordinates[te])}));var Gt=Jt(ze);return tt(),Bt(),Gt}for(var E=[],k=[],te=0;te<i;te++){E.push([]);for(var h=0;h<a.geometry.coordinates[te].length-1;h++)E[te].push([new Pv(a.geometry.coordinates[te][Ru(h+1,a.geometry.coordinates[te].length-1)],1,[te,h],[te,Ru(h+1,a.geometry.coordinates[te].length-1)],void 0)]),k.push(new Lv(a.geometry.coordinates[te][h],[te,Ru(h-1,a.geometry.coordinates[te].length-1)],[te,h],void 0,void 0,!1,!0))}for(var te=0;te<t;te++)E[x[te][1]][x[te][2]].push(new Pv(x[te][0],x[te][5],[x[te][1],x[te][2]],[x[te][6],x[te][7]],void 0)),x[te][11]&&k.push(new Lv(x[te][0],[x[te][1],x[te][2]],[x[te][6],x[te][7]],void 0,void 0,!0,!0));for(var P=k.length,te=0;te<E.length;te++)for(var h=0;h<E[te].length;h++)E[te][h].sort(function(hn,rn){return hn.param<rn.param?-1:1});for(var R=[],te=0;te<P;te++)R.push({minX:k[te].coord[0],minY:k[te].coord[1],maxX:k[te].coord[0],maxY:k[te].coord[1],index:te});var F=new so;F.load(R);for(var te=0;te<E.length;te++)for(var h=0;h<E[te].length;h++)for(var U=0;U<E[te][h].length;U++){var Z;U==E[te][h].length-1?Z=E[te][Ru(h+1,a.geometry.coordinates[te].length-1)][0].coord:Z=E[te][h][U+1].coord;var J=F.search({minX:Z[0],minY:Z[1],maxX:Z[0],maxY:Z[1]})[0];E[te][h][U].nxtIsectAlongEdgeIn=J.index}for(var te=0;te<E.length;te++)for(var h=0;h<E[te].length;h++)for(var U=0;U<E[te][h].length;U++){var Z=E[te][h][U].coord,J=F.search({minX:Z[0],minY:Z[1],maxX:Z[0],maxY:Z[1]})[0],he=J.index;he<f?k[he].nxtIsectAlongRingAndEdge2=E[te][h][U].nxtIsectAlongEdgeIn:Hc(k[he].ringAndEdge1,E[te][h][U].ringAndEdgeIn)?k[he].nxtIsectAlongRingAndEdge1=E[te][h][U].nxtIsectAlongEdgeIn:k[he].nxtIsectAlongRingAndEdge2=E[te][h][U].nxtIsectAlongEdgeIn}for(var ye=[],te=0,h=0;h<i;h++){for(var ce=te,U=0;U<a.geometry.coordinates[h].length-1;U++)k[te].coord[0]<k[ce].coord[0]&&(ce=te),te++;for(var be=k[ce].nxtIsectAlongRingAndEdge2,U=0;U<k.length;U++)if(k[U].nxtIsectAlongRingAndEdge1==ce||k[U].nxtIsectAlongRingAndEdge2==ce){var we=U;break}var Ue=cd([k[we].coord,k[ce].coord,k[be].coord],!0)?1:-1;ye.push({isect:ce,parent:-1,winding:Ue})}ye.sort(function(Vt,St){return k[Vt.isect].coord>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;te<ye.length;te++)if(ye[te].isect==Lt){Yt=te;break}if(Yt!=null&&ye.splice(Yt,1),Hc(Nt,k[Lt].ringAndEdge1)){if(Nt=k[Lt].ringAndEdge2,k[Lt].ringAndEdge2Walkable=!1,k[Lt].ringAndEdge1Walkable){var Mt={isect:Lt};cd([k[ut].coord,k[Lt].coord,k[k[Lt].nxtIsectAlongRingAndEdge2].coord],lt==1)?(Mt.parent=ft,Mt.winding=-lt):(Mt.parent=Je,Mt.winding=lt),ye.push(Mt)}ut=Lt,Lt=k[Lt].nxtIsectAlongRingAndEdge2}else{if(Nt=k[Lt].ringAndEdge1,k[Lt].ringAndEdge1Walkable=!1,k[Lt].ringAndEdge2Walkable){var Mt={isect:Lt};cd([k[ut].coord,k[Lt].coord,k[k[Lt].nxtIsectAlongRingAndEdge1].coord],lt==1)?(Mt.parent=ft,Mt.winding=-lt):(Mt.parent=Je,Mt.winding=lt),ye.push(Mt)}ut=Lt,Lt=k[Lt].nxtIsectAlongRingAndEdge1}}At.push(k[Lt].coord),ze.push(Mn([At],{index:Je,parent:ft,winding:lt,netWinding:void 0}))}var Gt=Jt(ze);tt(),Bt();function tt(){for(var Vt=[],St=0;St<Gt.features.length;St++)Gt.features[St].properties.parent==-1&&Vt.push(St);if(Vt.length>1)for(var St=0;St<Vt.length;St++){for(var hn=-1,rn=1/0,Tn=0;Tn<Gt.features.length;Tn++)Vt[St]!=Tn&&Pn(Gt.features[Vt[St]].geometry.coordinates[0][0],Gt.features[Tn],{ignoreBoundary:!0})&&_u(Gt.features[Tn])<rn&&(hn=Tn);Gt.features[Vt[St]].properties.parent=hn}}function Bt(){for(var Vt=0;Vt<Gt.features.length;Vt++)if(Gt.features[Vt].properties.parent==-1){var St=Gt.features[Vt].properties.winding;Gt.features[Vt].properties.netWinding=St,Zt(Vt,St)}}function Zt(Vt,St){for(var hn=0;hn<Gt.features.length;hn++)if(Gt.features[hn].properties.parent==Vt){var rn=St+Gt.features[hn].properties.winding;Gt.features[hn].properties.netWinding=rn,Zt(hn,rn)}}return Gt}var Pv=function(a,i,s,l,h){this.coord=a,this.param=i,this.ringAndEdgeIn=s,this.ringAndEdgeOut=l,this.nxtIsectAlongEdgeIn=h},Lv=function(a,i,s,l,h,f,x){this.coord=a,this.ringAndEdge1=i,this.ringAndEdge2=s,this.nxtIsectAlongRingAndEdge1=l,this.nxtIsectAlongRingAndEdge2=h,this.ringAndEdge1Walkable=f,this.ringAndEdge2Walkable=x};function cd(a,i){if(typeof i>"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;s<a.length-1;s++)a[s][0]<a[i][0]&&(i=s);if(cd([a[Ru(i-1,a.length-1)],a[i],a[Ru(i+1,a.length-1)]],!0))var l=1;else var l=-1;return l}function Hc(a,i){if(!a||!i||a.length!=i.length)return!1;for(var s=0,l=a.length;s<l;s++)if(a[s]instanceof Array&&i[s]instanceof Array){if(!Hc(a[s],i[s]))return!1}else if(a[s]!=i[s])return!1;return!0}function Ru(a,i){return(a%i+i)%i}function rS(a){for(var i={},s=1,l=0,h=a.length;l<h;++l){if(Object.prototype.hasOwnProperty.call(i,a[l])){s=0;break}i[a[l]]=1}return s}function Rv(a){var i=[];return Wi(a,function(s){s.geometry.type==="Polygon"&&Bn(nS(s),function(l){i.push(Mn(l.geometry.coordinates,s.properties))})}),Jt(i)}function Dv(a){return function(){return a}}function oS(a){return a[0]}function sS(a){return a[1]}function hd(){this._=null}function fd(a){a.U=a.C=a.L=a.R=a.P=a.N=null}hd.prototype={constructor:hd,insert:function(a,i){var s,l,h;if(a){if(i.P=a,i.N=a.N,a.N&&(a.N.P=i),a.N=i,a.R){for(a=a.R;a.L;)a=a.L;a.L=i}else a.R=i;s=a}else this._?(a=zv(this._),i.P=null,i.N=a,a.P=a.L=i,s=a):(i.P=i.N=null,this._=i,s=null);for(i.L=i.R=null,i.U=s,i.C=!0,a=i;s&&s.C;)l=s.U,s===l.L?(h=l.R,h&&h.C?(s.C=h.C=!1,l.C=!0,a=l):(a===s.R&&(Kc(this,s),a=s,s=a.U),s.C=!1,l.C=!0,Jc(this,l))):(h=l.L,h&&h.C?(s.C=h.C=!1,l.C=!0,a=l):(a===s.L&&(Jc(this,s),a=s,s=a.U),s.C=!1,l.C=!0,Kc(this,l))),s=a.U;this._.C=!1},remove:function(a){a.N&&(a.N.P=a.P),a.P&&(a.P.N=a.N),a.N=a.P=null;var i=a.U,s,l=a.L,h=a.R,f,x;if(l?h?f=zv(h):f=l:f=h,i?i.L===a?i.L=f:i.R=f:this._=f,l&&h?(x=f.C,f.C=a.C,f.L=l,l.U=f,f!==h?(i=f.U,f.U=a.U,a=f.R,i.L=a,f.R=h,h.U=f):(f.U=i,i=f,a=f.R)):(x=a.C,a=f),a&&(a.U=i),!x){if(a&&a.C){a.C=!1;return}do{if(a===this._)break;if(a===i.L){if(s=i.R,s.C&&(s.C=!1,i.C=!0,Kc(this,i),s=i.R),s.L&&s.L.C||s.R&&s.R.C){(!s.R||!s.R.C)&&(s.L.C=!1,s.C=!0,Jc(this,s),s=i.R),s.C=i.C,i.C=s.R.C=!1,Kc(this,i),a=this._;break}}else if(s=i.L,s.C&&(s.C=!1,i.C=!0,Jc(this,i),s=i.L),s.L&&s.L.C||s.R&&s.R.C){(!s.L||!s.L.C)&&(s.R.C=!1,s.C=!0,Kc(this,s),s=i.L),s.C=i.C,i.C=s.L.C=!1,Jc(this,i),a=this._;break}s.C=!0,a=i,i=i.U}while(!a.C);a&&(a.C=!1)}}};function Kc(a,i){var s=i,l=i.R,h=s.U;h?h.L===s?h.L=l:h.R=l:a._=l,l.U=h,s.U=l,s.R=l.L,s.R&&(s.R.U=s),l.L=s}function Jc(a,i){var s=i,l=i.L,h=s.U;h?h.L===s?h.L=l:h.R=l:a._=l,l.U=h,s.U=l,s.L=l.R,s.L&&(s.L.U=s),l.R=s}function zv(a){for(;a.L;)a=a.L;return a}function Qc(a,i,s,l){var h=[null,null],f=Zr.push(h)-1;return h.left=a,h.right=i,s&&dd(h,a,i,s),l&&dd(h,i,a,l),Do[a.index].halfedges.push(f),Do[i.index].halfedges.push(f),h}function eh(a,i,s){var l=[i,s];return l.left=a,l}function dd(a,i,s,l){!a[0]&&!a[1]?(a[0]=l,a.left=i,a.right=s):a.left===s?a[1]=l:a[0]=l}function aS(a,i,s,l,h){var f=a[0],x=a[1],t=f[0],E=f[1],k=x[0],P=x[1],R=0,F=1,U=k-t,Z=P-E,J;if(J=i-t,!(!U&&J>0)){if(J/=U,U<0){if(J<R)return;J<F&&(F=J)}else if(U>0){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(J<R)return;J<F&&(F=J)}if(J=s-E,!(!Z&&J>0)){if(J/=Z,Z<0){if(J<R)return;J<F&&(F=J)}else if(Z>0){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(J<R)return;J<F&&(F=J)}return!(R>0)&&!(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<i||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]<s)return;f=[U,s]}}else if(J=(k-R)/(F-P),he=Z-J*U,J<-1||J>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]<s)return;f=[(s-he)/J,s]}else if(P<F){if(!x)x=[i,J*i+he];else if(x[0]>=l)return;f=[l,J*l+he]}else{if(!x)x=[l,J*l+he];else if(x[0]<i)return;f=[i,J*i+he]}return a[0]=x,a[1]=f,!0}function uS(a,i,s,l){for(var h=Zr.length,f;h--;)(!lS(f=Zr[h],a,i,s,l)||!aS(f,a,i,s,l)||!(Math.abs(f[0][0]-f[1][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;a<i;++a)if((s=Do[a])&&(f=(l=s.halfedges).length)){var x=new Array(f),t=new Array(f);for(h=0;h<f;++h)x[h]=h,t[h]=hS(s,Zr[l[h]]);for(x.sort(function(E,k){return t[k]-t[E]}),h=0;h<f;++h)t[h]=l[x[h]];for(h=0;h<f;++h)l[h]=t[h]}}function pS(a,i,s,l){var h=Do.length,f,x,t,E,k,P,R,F,U,Z,J,he,ye=!0;for(f=0;f<h;++f)if(x=Do[f]){for(t=x.site,k=x.halfedges,E=k.length;E--;)Zr[k[E]]||k.splice(E,1);for(E=0,P=k.length;E<P;)Z=fS(x,Zr[k[E]]),J=Z[0],he=Z[1],R=Ov(x,Zr[k[++E%P]]),F=R[0],U=R[1],(Math.abs(J-F)>bi||Math.abs(he-U)>bi)&&(k.splice(E,0,Zr.push(eh(t,Z,Math.abs(J-a)<bi&&l-he>bi?[a,Math.abs(F-a)<bi?U:l]:Math.abs(he-l)<bi&&s-J>bi?[Math.abs(U-l)<bi?F:s,l]:Math.abs(J-s)<bi&&he-i>bi?[s,Math.abs(F-s)<bi?U:i]:Math.abs(he-i)<bi&&J-a>bi?[Math.abs(U-i)<bi?F:a,i]:null))-1),++P);P&&(ye=!1)}if(ye){var te,ce,be,we=1/0;for(f=0,ye=null;f<h;++f)(x=Do[f])&&(t=x.site,te=t[0]-a,ce=t[1]-i,be=te*te+ce*ce,be<we&&(we=be,ye=x));if(ye){var Ue=[a,i],ze=[a,l],Ve=[s,l],Ie=[s,i];ye.halfedges.push(Zr.push(eh(t=ye.site,Ue,ze))-1,Zr.push(eh(t,ze,Ve))-1,Zr.push(eh(t,Ve,Ie))-1,Zr.push(eh(t,Ie,Ue))-1)}}for(f=0;f<h;++f)(x=Do[f])&&(x.halfedges.length||delete Do[f])}var Nv=[],Pm;function mS(){fd(this),this.x=this.y=this.arc=this.site=this.cy=null}function Du(a){var i=a.P,s=a.N;if(!(!i||!s)){var l=i.site,h=a.site,f=s.site;if(l!==f){var x=h[0],t=h[1],E=l[0]-x,k=l[1]-t,P=f[0]-x,R=f[1]-t,F=2*(E*R-k*P);if(!(F>=-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.y<ce.y||ye.y===ce.y&&ye.x<=ce.x)if(ce.L)ce=ce.L;else{te=ce.P;break}else if(ce.R)ce=ce.R;else{te=ce;break}th.insert(te,ye),te||(Pm=ye)}}}}function zu(a){var i=a.circle;i&&(i.P||(Pm=i.N),th.remove(i),Nv.push(i),fd(i),a.circle=null)}var Bv=[];function gS(){fd(this),this.edge=this.site=this.circle=null}function Fv(a){var i=Bv.pop()||new gS;return i.site=a,i}function Lm(a){zu(a),Ou.remove(a),Bv.push(a),fd(a)}function _S(a){var i=a.circle,s=i.x,l=i.cy,h=[s,l],f=a.P,x=a.N,t=[a];Lm(a);for(var E=f;E.circle&&Math.abs(s-E.circle.x)<bi&&Math.abs(l-E.circle.cy)<bi;)f=E.P,t.unshift(E),Lm(E),E=f;t.unshift(E),zu(E);for(var k=x;k.circle&&Math.abs(s-k.circle.x)<bi&&Math.abs(l-k.circle.cy)<bi;)x=k.N,t.push(k),Lm(k),k=x;t.push(k),zu(k);var P=t.length,R;for(R=1;R<P;++R)k=t[R],E=t[R-1],dd(k.edge,E.site,k.site,h);E=t[0],k=t[P-1],k.edge=Qc(E.site,k.site,null,h),Du(E),Du(k)}function yS(a){for(var i=a[0],s=a[1],l,h,f,x,t=Ou._;t;)if(f=Vv(t,s)-i,f>bi)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]<f.y||s[1]===f.y&&s[0]<f.x))(s[0]!==l||s[1]!==h)&&(yS(s),l=s[0],h=s[1]),s=a.pop();else if(f)_S(f.arc);else break;if(dS(),i){var x=+i[0][0],t=+i[0][1],E=+i[1][0],k=+i[1][1];uS(x,t,E,k),pS(x,t,E,k)}this.edges=Zr,this.cells=Do,Ou=th=Zr=Do=null}Rm.prototype={constructor:Rm,polygons:function(){var a=this.edges;return this.cells.map(function(i){var s=i.halfedges.map(function(l){return Ov(i,a[l])});return s.data=i.site.data,s})},triangles:function(){var a=[],i=this.edges;return this.cells.forEach(function(s,l){if(t=(f=s.halfedges).length)for(var h=s.site,f,x=-1,t,E,k=i[f[t-1]],P=k.left===h?k.right:k.left;++x<t;)E=P,k=i[f[x]],P=k.left===h?k.right:k.left,E&&P&&l<E.index&&l<P.index&&bS(h,E,P)<0&&a.push([h.data,E.data,P.data])}),a},links:function(){return this.edges.filter(function(a){return a.right}).map(function(a){return{source:a.left.data,target:a.right.data}})},find:function(a,i,s){for(var l=this,h,f=l._found||0,x=l.cells.length,t;!(t=l.cells[f]);)if(++f>=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;he<P&&(P=he,f=U.index)}});while(f!==null);return l._found=h,s==null||P<=s*s?t.site:null}};function ES(){var a=oS,i=sS,s=null;function l(h){return new Rm(h.map(function(f,x){var t=[Math.round(a(f,x,h)/bi)*bi,Math.round(i(f,x,h)/bi)*bi];return t.index=x,t.data=f,t}),s)}return l.polygons=function(h){return l(h).polygons()},l.links=function(h){return l(h).links()},l.triangles=function(h){return l(h).triangles()},l.x=function(h){return arguments.length?(a=typeof h=="function"?h:Dv(+h),l):a},l.y=function(h){return arguments.length?(i=typeof h=="function"?h:Dv(+h),l):i},l.extent=function(h){return arguments.length?(s=h==null?null:[[+h[0][0],+h[0][1]],[+h[1][0],+h[1][1]]],l):s&&[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},l.size=function(h){return arguments.length?(s=h==null?null:[[0,0],[+h[0],+h[1]]],l):s&&[s[1][0]-s[0][0],s[1][1]-s[0][1]]},l}function TS(a){return a=a.slice(),a.push(a[0]),Mn([a])}function IS(a,i){if(i=i||{},!Hn(i))throw new Error("options is invalid");const s=i.bbox||[-180,-85,180,85];if(!a)throw new Error("points is required");if(!Array.isArray(s))throw new Error("bbox is invalid");return Qs(a,"Point","points"),Jt(ES().x(l=>l.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<this.features.length-1){const f=this.features[h],x=this.features[h+1],t=s%this.interval/this.interval;if(f&&x){const E=f[0]+(x[0]-f[0])*t,k=f[1]+(x[1]-f[1])*t;let P=Ps(cn(f),cn(x))+90;this.setVehiclePositionAndRotation([E,k],P),this.requestId=requestAnimationFrame(this.animateVehicle.bind(this))}}else{cancelAnimationFrame(this.requestId),this.currentPointIndex=0,this.startTime=0;return}}setVehiclePositionAndRotation(i,s){this.marker&&(this.marker.setRotation(s),this.marker.setLngLat(i).addTo(this.map))}remove(){this.map.getLayer(this.layerName)&&(this.map.removeLayer(this.layerName),this.map.removeSource(this.layerName),this.marker&&this.marker.remove(),this.startTime=0,cancelAnimationFrame(this.requestId))}}const kS={circleStrokeWidth:1.5,circleStrokeColor:"#ffffff",circleRadius:4,circleColor:"#ff7500",lineColor:"rgba(255,0,51,0.5)",lineWidth:1.5,fillColor:"rgba(255,102,102,0.1)",markerBackgroundColor:"#CCCCFF"};class CS{constructor(i){this.options={...kS,...i}}addTo(i){return this._map=i.map2d,this._map.on("click",this._onClick.bind(this)),this._map.on("dblclick",this._onDblClick.bind(this)),this._map.on("mousemove",this._onMousemove.bind(this)),this._map.on("mousedown",this._onMousedown.bind(this)),this._map.on("mouseup",this._onMouseup.bind(this)),this.geojson_point={type:"FeatureCollection",features:[]},this.geojson_line={type:"FeatureCollection",features:[]},this.geojson_polygon={type:"FeatureCollection",features:[]},this.temp_line={type:"Feature",geometry:{type:"LineString",coordinates:[]}},this.mode="",this.drawOption={},this.markers=[],this.tooltip=null,this.draging_point=null,this.isActive=!1,this._onMapLoad(),this._callback={},this.timeId=0,this.click_x=0,this.click_y=0,this.dblclick_x=0,this.dblclick_y=0,this.move_x=0,this.move_y=0,this}_onMapLoad(){this._map.addSource("MapTools_geojson",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this._map.addSource("MapTools_temp_line",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this._map.addLayer({id:"MapTools_polygon",type:"fill",source:"MapTools_geojson",paint:{"fill-color":this.options.fillColor},filter:["in","$type","Polygon"]}),this._map.addLayer({id:"MapTools_line",type:"line",source:"MapTools_geojson",paint:{"line-color":this.options.lineColor,"line-width":this.options.lineWidth},filter:["in","$type","LineString","Polygon"]}),this._map.addLayer({id:"MapTools_line_temp",type:"line",source:"MapTools_temp_line",paint:{"line-color":this.options.lineColor,"line-width":this.options.lineWidth,"line-dasharray":[4,7]}}),this._map.addLayer({id:"MapTools_point",type:"circle",source:"MapTools_geojson",paint:{"circle-stroke-width":["match",["get","type"],"01",this.options.circleStrokeWidth,1],"circle-stroke-color":this.options.circleStrokeColor,"circle-radius":["match",["get","type"],"01",this.options.circleRadius,3],"circle-color":this.options.circleColor},filter:["in","$type","Point"]})}remove(){for(let i=0;i<this.markers.length;i++)this.markers[i].remove();this._map.getLayer("MapTools_polygon")&&(this._map.removeLayer("MapTools_polygon"),this._map.removeLayer("MapTools_line"),this._map.removeLayer("MapTools_line_temp"),this._map.removeLayer("MapTools_point"),this._map.removeSource("MapTools_geojson"),this._map.removeSource("MapTools_temp_line")),this._map.off("click",this._onClick),this._map.off("dblclick",this._onDblClick),this._map.off("mousemove",this._onMousemove)}on(i,s){this._callback[i]=s}setMode(i,s){if((this.mode===""||this.temp_line.geometry.coordinates.length==0)&&i!=""&&i!="***END***"){if(this.mode=i,this.drawOption=s,this.isActive=!0,this._map.doubleClickZoom.disable(),this.temp_line.geometry.coordinates=[],i==="line"){const l={type:"Feature",properties:{complete:!1,drawOption:s,mode:i},geometry:{type:"LineString",coordinates:[]}};this.geojson_line.features.push(l)}else if(i==="polygon"||i==="rect"||i==="circle"){const l={type:"Feature",properties:{complete:!1,drawOption:s,mode:i},geometry:{type:"Polygon",coordinates:[[]]}};this.geojson_polygon.features.push(l)}}}edit(i,s){i.type==="Point"||i.type==="MultiPoint"?Wi(i,l=>{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<this.markers.length;s++)this.markers[s].remove();Bn(this.geojson_point,(s,l)=>{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;f<s.geometry.coordinates.length;f++)for(let x=0;x<s.geometry.coordinates[f].length;x++){let t=cn(s.geometry.coordinates[f][x],{source:"geojson_polygon",source_fea_index:l,source_geometry_index:f,source_coord_index:x,type:"01"});if(i.push(t),x>0){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)<l&&Math.abs(f)<l||(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}();
|