var z3=Object.defineProperty;var k3=(u,e,t)=>e in u?z3(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t;var O3=(u,e)=>()=>(e||u((e={exports:{}}).exports,e),e.exports);var zi=(u,e,t)=>(k3(u,typeof e!="symbol"?e+"":e,t),t);var EH=O3(N_=>{function ES(u,e){for(var t=0;tr[c]})}}}return Object.freeze(Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const p of c)if(p.type==="childList")for(const y of p.addedNodes)y.tagName==="LINK"&&y.rel==="modulepreload"&&r(y)}).observe(document,{childList:!0,subtree:!0});function t(c){const p={};return c.integrity&&(p.integrity=c.integrity),c.referrerpolicy&&(p.referrerPolicy=c.referrerpolicy),c.crossorigin==="use-credentials"?p.credentials="include":c.crossorigin==="anonymous"?p.credentials="omit":p.credentials="same-origin",p}function r(c){if(c.ep)return;c.ep=!0;const p=t(c);fetch(c.href,p)}})();if(typeof window<"u"){let u=function(){var e=document.body,t=document.getElementById("__svg__icons__dom__");t||(t=document.createElementNS("http://www.w3.org/2000/svg","svg"),t.style.position="absolute",t.style.width="0",t.style.height="0",t.id="__svg__icons__dom__",t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("xmlns:link","http://www.w3.org/1999/xlink")),t.innerHTML='',e.insertBefore(t,e.lastChild)};var loadSvg=u;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()}class N3{constructor(e){zi(this,"_CompEventChain");zi(this,"_parentUnit");this._CompEventChain=e}get parentUnit(){return this._parentUnit}setParentUnit(e){return this._parentUnit=e,this}get CompEventChain(){return this._CompEventChain}addEvent(e){return this._CompEventChain.push(e),this}setCompEvent(e){return this._CompEventChain}remoteCompEvent(e){return this._CompEventChain}setCompEventChain(e){return this._CompEventChain=e,this._CompEventChain}clearCompEvent(){return this._CompEventChain=[],this._CompEventChain}}class Q3{constructor(e){zi(this,"_id");zi(this,"_position");zi(this,"_info");zi(this,"_eventchain",new N3([]).setParentUnit(this));return this._id=e,this}get id(){return this._id}setId(e){return this._id=e,this}get position(){return this._position}setPosition(e){return this._position=e,this}get info(){return this._info}setInfo(e){return this._info=e,this}get eventchain(){return this._eventchain}setEventchain(e){return this._eventchain=e.setParentUnit(this),this}addEvent(e){return this._eventchain.addEvent(e),this}async eventStart(){}}var Ou=(u=>(u.stop="stop",u.run="run",u.pause="pause",u))(Ou||{});class V3{constructor(){zi(this,"_FnQueue",[]);zi(this,"_index",0);zi(this,"_QueueStatus",Ou.stop)}get FnQueue(){return this._FnQueue}formatEventChain2Queue(e,t=()=>{}){let r=0,c=0;for(let p of e.ids)if(r+=p.eventchain.CompEventChain.length,p.eventchain.CompEventChain.length>0){let y=p.eventchain.parentUnit;for(let i of p.eventchain.CompEventChain){c+=1;let C={fn:i.Fn,args:Object.assign(y,{args:i.args}),prepare:i.prepareTime,delay:i.delayTime};this._FnQueue.push(C),t((c/r).toFixed(1))}}return this}async start(e,t=()=>{}){if(this._QueueStatus===Ou.stop?(this._index=-1,this._QueueStatus=Ou.run):this._QueueStatus===Ou.pause?this._QueueStatus=Ou.run:(this._index=-1,this._QueueStatus=Ou.run),this._FnQueue.length!==0)for(let r in this._FnQueue)if(this._QueueStatus===Ou.run){if(parseInt(r)>this._index){let c=this._FnQueue[r];this._index=parseInt(r),await this.runFun(c),this._index+1===this._FnQueue.length&&t(this._index)}}else break}async runPrepare(e){return new Promise(async(t,r)=>{await setTimeout(()=>{t()},e.prepare)})}async runFun(e){return await this.runPrepare(e),new Promise(async(t,r)=>{await e.fn(e.args),await setTimeout(()=>{t()},e.delay)})}stop(){this._QueueStatus=Ou.stop}pause(){this._QueueStatus=Ou.pause}}class J1{constructor(){zi(this,"_ids",[]);zi(this,"_queue");zi(this,"_loop");zi(this,"_loopIndex",0);zi(this,"_loopDone",()=>{});this._queue=new V3}setLoop(e,t=()=>{}){return this._loop=e,this._loopDone=t,this}destory(){this._ids=[],this._queue=null}get queue(){return this._queue}get ids(){return this._ids}start(){this.queue.start({},this.queneEndOnceLoop.bind(this))}stop(){this.queue.stop()}pause(){this.queue.pause()}queneEndOnceLoop(e){this._loopIndex+=1,this._loop===-1?this.start():this._loop>this._loopIndex?this.start():this._loopDone()}addUnit(e){return this._ids.push(e),this}removeUnit(e){let t=[];for(let r in this._ids){let c=this._ids[r];c.id!==e&&t.push(c)}return this._ids=t,this}clearUnit(){return this._ids=[],this}buildQueue(e){return this.queue.formatEventChain2Queue(this,e),this}}var TS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof{}<"u"?{}:typeof self<"u"?self:{},R_={},H3=u=>encodeURIComponent(u).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),SS="%[a-f0-9]{2}",DC=new RegExp("("+SS+")|([^%]+?)","gi"),PC=new RegExp("("+SS+")+","gi");function cb(u,e){try{return[decodeURIComponent(u.join(""))]}catch{}if(u.length===1)return u;e=e||1;var t=u.slice(0,e),r=u.slice(e);return Array.prototype.concat.call([],cb(t),cb(r))}function G3(u){try{return decodeURIComponent(u)}catch{for(var e=u.match(DC)||[],t=1;t{if(!(typeof u=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[u];const t=u.indexOf(e);return t===-1?[u]:[u.slice(0,t),u.slice(t+e.length)]},$3=function(u,e){for(var t={},r=Object.keys(u),c=Array.isArray(e),p=0;pae==null;function y(ae){switch(ae.arrayFormat){case"index":return le=>(Ae,we)=>{const me=Ae.length;return we===void 0||ae.skipNull&&we===null||ae.skipEmptyString&&we===""?Ae:we===null?[...Ae,[D(le,ae),"[",me,"]"].join("")]:[...Ae,[D(le,ae),"[",D(me,ae),"]=",D(we,ae)].join("")]};case"bracket":return le=>(Ae,we)=>we===void 0||ae.skipNull&&we===null||ae.skipEmptyString&&we===""?Ae:we===null?[...Ae,[D(le,ae),"[]"].join("")]:[...Ae,[D(le,ae),"[]=",D(we,ae)].join("")];case"comma":case"separator":return le=>(Ae,we)=>we==null||we.length===0?Ae:Ae.length===0?[[D(le,ae),"=",D(we,ae)].join("")]:[[Ae,D(we,ae)].join(ae.arrayFormatSeparator)];default:return le=>(Ae,we)=>we===void 0||ae.skipNull&&we===null||ae.skipEmptyString&&we===""?Ae:we===null?[...Ae,D(le,ae)]:[...Ae,[D(le,ae),"=",D(we,ae)].join("")]}}function i(ae){let le;switch(ae.arrayFormat){case"index":return(Ae,we,me)=>{if(le=/\[(\d*)\]$/.exec(Ae),Ae=Ae.replace(/\[\d*\]$/,""),!le){me[Ae]=we;return}me[Ae]===void 0&&(me[Ae]={}),me[Ae][le[1]]=we};case"bracket":return(Ae,we,me)=>{if(le=/(\[\])$/.exec(Ae),Ae=Ae.replace(/\[\]$/,""),!le){me[Ae]=we;return}if(me[Ae]===void 0){me[Ae]=[we];return}me[Ae]=[].concat(me[Ae],we)};case"comma":case"separator":return(Ae,we,me)=>{const Pe=typeof we=="string"&&we.includes(ae.arrayFormatSeparator),it=typeof we=="string"&&!Pe&&U(we,ae).includes(ae.arrayFormatSeparator);we=it?U(we,ae):we;const Me=Pe||it?we.split(ae.arrayFormatSeparator).map(Ke=>U(Ke,ae)):we===null?we:U(we,ae);me[Ae]=Me};default:return(Ae,we,me)=>{if(me[Ae]===void 0){me[Ae]=we;return}me[Ae]=[].concat(me[Ae],we)}}}function C(ae){if(typeof ae!="string"||ae.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function D(ae,le){return le.encode?le.strict?e(ae):encodeURIComponent(ae):ae}function U(ae,le){return le.decode?t(ae):ae}function N(ae){return Array.isArray(ae)?ae.sort():typeof ae=="object"?N(Object.keys(ae)).sort((le,Ae)=>Number(le)-Number(Ae)).map(le=>ae[le]):ae}function R(ae){const le=ae.indexOf("#");return le!==-1&&(ae=ae.slice(0,le)),ae}function G(ae){let le="";const Ae=ae.indexOf("#");return Ae!==-1&&(le=ae.slice(Ae)),le}function J(ae){ae=R(ae);const le=ae.indexOf("?");return le===-1?"":ae.slice(le+1)}function Y(ae,le){return le.parseNumbers&&!Number.isNaN(Number(ae))&&typeof ae=="string"&&ae.trim()!==""?ae=Number(ae):le.parseBooleans&&ae!==null&&(ae.toLowerCase()==="true"||ae.toLowerCase()==="false")&&(ae=ae.toLowerCase()==="true"),ae}function B(ae,le){le=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},le),C(le.arrayFormatSeparator);const Ae=i(le),we=Object.create(null);if(typeof ae!="string"||(ae=ae.trim().replace(/^[?#&]/,""),!ae))return we;for(const me of ae.split("&")){if(me==="")continue;let[Pe,it]=r(le.decode?me.replace(/\+/g," "):me,"=");it=it===void 0?null:["comma","separator"].includes(le.arrayFormat)?it:U(it,le),Ae(U(Pe,le),it,we)}for(const me of Object.keys(we)){const Pe=we[me];if(typeof Pe=="object"&&Pe!==null)for(const it of Object.keys(Pe))Pe[it]=Y(Pe[it],le);else we[me]=Y(Pe,le)}return le.sort===!1?we:(le.sort===!0?Object.keys(we).sort():Object.keys(we).sort(le.sort)).reduce((me,Pe)=>{const it=we[Pe];return Boolean(it)&&typeof it=="object"&&!Array.isArray(it)?me[Pe]=N(it):me[Pe]=it,me},Object.create(null))}u.extract=J,u.parse=B,u.stringify=(ae,le)=>{if(!ae)return"";le=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},le),C(le.arrayFormatSeparator);const Ae=it=>le.skipNull&&p(ae[it])||le.skipEmptyString&&ae[it]==="",we=y(le),me={};for(const it of Object.keys(ae))Ae(it)||(me[it]=ae[it]);const Pe=Object.keys(me);return le.sort!==!1&&Pe.sort(le.sort),Pe.map(it=>{const Me=ae[it];return Me===void 0?"":Me===null?D(it,le):Array.isArray(Me)?Me.reduce(we(it),[]).join("&"):D(it,le)+"="+D(Me,le)}).filter(it=>it.length>0).join("&")},u.parseUrl=(ae,le)=>{le=Object.assign({decode:!0},le);const[Ae,we]=r(ae,"#");return Object.assign({url:Ae.split("?")[0]||"",query:B(J(ae),le)},le&&le.parseFragmentIdentifier&&we?{fragmentIdentifier:U(we,le)}:{})},u.stringifyUrl=(ae,le)=>{le=Object.assign({encode:!0,strict:!0},le);const Ae=R(ae.url).split("?")[0]||"",we=u.extract(ae.url),me=u.parse(we,{sort:!1}),Pe=Object.assign(me,ae.query);let it=u.stringify(Pe,le);it&&(it=`?${it}`);let Me=G(ae.url);return ae.fragmentIdentifier&&(Me=`#${D(ae.fragmentIdentifier,le)}`),`${Ae}${it}${Me}`},u.pick=(ae,le,Ae)=>{Ae=Object.assign({parseFragmentIdentifier:!0},Ae);const{url:we,query:me,fragmentIdentifier:Pe}=u.parseUrl(ae,Ae);return u.stringifyUrl({url:we,query:c(me,le),fragmentIdentifier:Pe},Ae)},u.exclude=(ae,le,Ae)=>{const we=Array.isArray(le)?me=>!le.includes(me):(me,Pe)=>!le(me,Pe);return u.pick(ae,we,Ae)}})(R_);const Z3=ES({__proto__:null,default:R_},[R_]);/*! * html2canvas 1.4.1 * Copyright (c) 2022 Niklas von Hertzen * Released under MIT License *//*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var hb=function(u,e){return hb=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var c in r)Object.prototype.hasOwnProperty.call(r,c)&&(t[c]=r[c])},hb(u,e)};function uu(u,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");hb(u,e);function t(){this.constructor=u}u.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var ub=function(){return ub=Object.assign||function(e){for(var t,r=1,c=arguments.length;r0&&p[p.length-1])&&(D[0]===6||D[0]===2)){t=0;continue}if(D[0]===3&&(!p||D[1]>p[0]&&D[1]=55296&&c<=56319&&t>10)+55296,y%1024+56320)),(c+1===t||r.length>16384)&&(p+=String.fromCharCode.apply(String,r),r.length=0)}return p},UC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",q3=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var I0=0;I0"u"?[]:new Uint8Array(256);for(var F0=0;F0>4,U[c++]=(y&15)<<4|i>>2,U[c++]=(i&3)<<6|C&63;return D},J3=function(u){for(var e=u.length,t=[],r=0;r>hf,iL=1<>hf,rL=MS+nL,sL=rL,oL=32,aL=sL+oL,lL=65536>>B2,cL=1<=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>hf],t=(t<>hf)],t=(t<>B2),t=this.index[t],t+=e>>hf&hL,t=this.index[t],t=(t<"u"?[]:new Uint8Array(256);for(var L0=0;L0OC?(c.push(!0),i-=OC):c.push(!1),["normal","auto","loose"].indexOf(e)!==-1&&[8208,8211,12316,12448].indexOf(p)!==-1)return r.push(y),t.push(pb);if(i===gL||i===Ab){if(y===0)return r.push(y),t.push(qp);var C=t[y-1];return CL.indexOf(C)===-1?(r.push(r[y-1]),t.push(C)):(r.push(y),t.push(qp))}if(r.push(y),i===wL)return t.push(e==="strict"?fb:z_);if(i===DS||i===vL)return t.push(qp);if(i===bL)return p>=131072&&p<=196605||p>=196608&&p<=262141?t.push(z_):t.push(qp);t.push(i)}),[r,t,c]},rw=function(u,e,t,r){var c=r[t];if(Array.isArray(u)?u.indexOf(c)!==-1:u===c)for(var p=t;p<=r.length;){p++;var y=r[p];if(y===e)return!0;if(y!==Zd)break}if(c===Zd)for(var p=t;p>0;){p--;var i=r[p];if(Array.isArray(u)?u.indexOf(i)!==-1:u===i)for(var C=t;C<=r.length;){C++;var y=r[C];if(y===e)return!0;if(y!==Zd)break}if(i!==Zd)break}return!1},jC=function(u,e){for(var t=u;t>=0;){var r=e[t];if(r===Zd)t--;else return r}return 0},SL=function(u,e,t,r,c){if(t[r]===0)return Kr;var p=r-1;if(Array.isArray(c)&&c[p]===!0)return Kr;var y=p-1,i=p+1,C=e[p],D=y>=0?e[y]:0,U=e[i];if(C===IS&&U===FS)return Kr;if(vb.indexOf(C)!==-1)return PS;if(vb.indexOf(U)!==-1||US.indexOf(U)!==-1)return Kr;if(jC(p,e)===LS)return R0;if(xb.get(u[p])===Ab||(C===P0||C===U0)&&xb.get(u[i])===Ab||C===NC||U===NC||C===QC||[Zd,db,f_].indexOf(C)===-1&&U===QC||[D0,Yg,xL,nm,rm].indexOf(U)!==-1||jC(p,e)===Jg||rw(iw,Jg,p,e)||rw([D0,Yg],fb,p,e)||rw(VC,VC,p,e))return Kr;if(C===Zd)return R0;if(C===iw||U===iw)return Kr;if(U===pb||C===pb)return R0;if([db,f_,fb].indexOf(U)!==-1||C===yL||D===_b&&EL.indexOf(C)!==-1||C===rm&&U===_b||U===HC||PA.indexOf(U)!==-1&&C===Mc||PA.indexOf(C)!==-1&&U===Mc||C===g_&&[z_,P0,U0].indexOf(U)!==-1||[z_,P0,U0].indexOf(C)!==-1&&U===m_||PA.indexOf(C)!==-1&&GC.indexOf(U)!==-1||GC.indexOf(C)!==-1&&PA.indexOf(U)!==-1||[g_,m_].indexOf(C)!==-1&&(U===Mc||[Jg,f_].indexOf(U)!==-1&&e[i+1]===Mc)||[Jg,f_].indexOf(C)!==-1&&U===Mc||C===Mc&&[Mc,rm,nm].indexOf(U)!==-1)return Kr;if([Mc,rm,nm,D0,Yg].indexOf(U)!==-1)for(var N=p;N>=0;){var R=e[N];if(R===Mc)return Kr;if([rm,nm].indexOf(R)!==-1)N--;else break}if([g_,m_].indexOf(U)!==-1)for(var N=[D0,Yg].indexOf(C)!==-1?y:p;N>=0;){var R=e[N];if(R===Mc)return Kr;if([rm,nm].indexOf(R)!==-1)N--;else break}if(yb===C&&[yb,Vx,mb,gb].indexOf(U)!==-1||[Vx,mb].indexOf(C)!==-1&&[Vx,Hx].indexOf(U)!==-1||[Hx,gb].indexOf(C)!==-1&&U===Hx||WC.indexOf(C)!==-1&&[HC,m_].indexOf(U)!==-1||WC.indexOf(U)!==-1&&C===g_||PA.indexOf(C)!==-1&&PA.indexOf(U)!==-1||C===nm&&PA.indexOf(U)!==-1||PA.concat(Mc).indexOf(C)!==-1&&U===Jg&&BL.indexOf(u[i])===-1||PA.concat(Mc).indexOf(U)!==-1&&C===Yg)return Kr;if(C===nw&&U===nw){for(var G=t[p],J=1;G>0&&(G--,e[G]===nw);)J++;if(J%2!==0)return Kr}return C===P0&&U===U0?Kr:R0},ML=function(u,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var t=TL(u,e.lineBreak),r=t[0],c=t[1],p=t[2];(e.wordBreak==="break-all"||e.wordBreak==="break-word")&&(c=c.map(function(i){return[Mc,qp,DS].indexOf(i)!==-1?z_:i}));var y=e.wordBreak==="keep-all"?p.map(function(i,C){return i&&u[C]>=19968&&u[C]<=40959}):void 0;return[r,c,y]},IL=function(){function u(e,t,r,c){this.codePoints=e,this.required=t===PS,this.start=r,this.end=c}return u.prototype.slice=function(){return Bo.apply(void 0,this.codePoints.slice(this.start,this.end))},u}(),FL=function(u,e){var t=Iv(u),r=ML(t,e),c=r[0],p=r[1],y=r[2],i=t.length,C=0,D=0;return{next:function(){if(D>=i)return{done:!0,value:null};for(var U=Kr;D=RS&&u<=57},uD=function(u){return u>=55296&&u<=57343},sm=function(u){return nl(u)||u>=OS&&u<=QS||u>=zS&&u<=oD},AD=function(u){return u>=zS&&u<=lD},dD=function(u){return u>=OS&&u<=hD},pD=function(u){return AD(u)||dD(u)},fD=function(u){return u>=XL},Q0=function(u){return u===tv||u===PL||u===UL},iv=function(u){return pD(u)||fD(u)||u===OL},qC=function(u){return iv(u)||nl(u)||u===nc},mD=function(u){return u>=eD&&u<=tD||u===iD||u>=nD&&u<=rD||u===sD},Kd=function(u,e){return u!==B_?!1:e!==tv},V0=function(u,e,t){return u===nc?iv(e)||Kd(e,t):iv(u)?!0:!!(u===B_&&Kd(u,e))},ow=function(u,e,t){return u===sf||u===nc?nl(e)?!0:e===k_&&nl(t):nl(u===k_?e:u)},gD=function(u){var e=0,t=1;(u[e]===sf||u[e]===nc)&&(u[e]===nc&&(t=-1),e++);for(var r=[];nl(u[e]);)r.push(u[e++]);var c=r.length?parseInt(Bo.apply(void 0,r),10):0;u[e]===k_&&e++;for(var p=[];nl(u[e]);)p.push(u[e++]);var y=p.length,i=y?parseInt(Bo.apply(void 0,p),10):0;(u[e]===NS||u[e]===kS)&&e++;var C=1;(u[e]===sf||u[e]===nc)&&(u[e]===nc&&(C=-1),e++);for(var D=[];nl(u[e]);)D.push(u[e++]);var U=D.length?parseInt(Bo.apply(void 0,D),10):0;return t*(c+i*Math.pow(10,-y))*Math.pow(10,C*U)},_D={type:2},yD={type:3},xD={type:4},vD={type:13},wD={type:8},bD={type:21},BD={type:9},CD={type:10},ED={type:11},TD={type:12},SD={type:14},H0={type:23},MD={type:1},ID={type:25},FD={type:24},LD={type:26},DD={type:27},PD={type:28},UD={type:29},RD={type:31},wb={type:32},VS=function(){function u(){this._value=[]}return u.prototype.write=function(e){this._value=this._value.concat(Iv(e))},u.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==wb;)e.push(t),t=this.consumeToken();return e},u.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case z0:return this.consumeStringToken(z0);case RL:var t=this.peekCodePoint(0),r=this.peekCodePoint(1),c=this.peekCodePoint(2);if(qC(t)||Kd(r,c)){var p=V0(t,r,c)?DL:LL,y=this.consumeName();return{type:5,value:y,flags:p}}break;case zL:if(this.peekCodePoint(0)===e_)return this.consumeCodePoint(),vD;break;case k0:return this.consumeStringToken(k0);case O0:return _D;case t_:return yD;case sw:if(this.peekCodePoint(0)===e_)return this.consumeCodePoint(),SD;break;case sf:if(ow(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case qL:return xD;case nc:var i=e,C=this.peekCodePoint(0),D=this.peekCodePoint(1);if(ow(i,C,D))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(V0(i,C,D))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(C===nc&&D===VL)return this.consumeCodePoint(),this.consumeCodePoint(),FD;break;case k_:if(ow(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case $C:if(this.peekCodePoint(0)===sw)for(this.consumeCodePoint();;){var U=this.consumeCodePoint();if(U===sw&&(U=this.consumeCodePoint(),U===$C))return this.consumeToken();if(U===Ru)return this.consumeToken()}break;case YL:return LD;case JL:return DD;case QL:if(this.peekCodePoint(0)===NL&&this.peekCodePoint(1)===nc&&this.peekCodePoint(2)===nc)return this.consumeCodePoint(),this.consumeCodePoint(),ID;break;case HL:var N=this.peekCodePoint(0),R=this.peekCodePoint(1),G=this.peekCodePoint(2);if(V0(N,R,G)){var y=this.consumeName();return{type:7,value:y}}break;case GL:return PD;case B_:if(Kd(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case WL:return UD;case jL:if(this.peekCodePoint(0)===e_)return this.consumeCodePoint(),wD;break;case KL:return ED;case $L:return TD;case aD:case cD:var J=this.peekCodePoint(0),Y=this.peekCodePoint(1);return J===sf&&(sm(Y)||Y===N0)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case ZC:if(this.peekCodePoint(0)===e_)return this.consumeCodePoint(),BD;if(this.peekCodePoint(0)===ZC)return this.consumeCodePoint(),bD;break;case ZL:if(this.peekCodePoint(0)===e_)return this.consumeCodePoint(),CD;break;case Ru:return wb}return Q0(e)?(this.consumeWhiteSpace(),RD):nl(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):iv(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:Bo(e)}},u.prototype.consumeCodePoint=function(){var e=this._value.shift();return typeof e>"u"?-1:e},u.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},u.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},u.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();sm(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var r=!1;t===N0&&e.length<6;)e.push(t),t=this.consumeCodePoint(),r=!0;if(r){var c=parseInt(Bo.apply(void 0,e.map(function(C){return C===N0?RS:C})),16),p=parseInt(Bo.apply(void 0,e.map(function(C){return C===N0?QS:C})),16);return{type:30,start:c,end:p}}var y=parseInt(Bo.apply(void 0,e),16);if(this.peekCodePoint(0)===nc&&sm(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var i=[];sm(t)&&i.length<6;)i.push(t),t=this.consumeCodePoint();var p=parseInt(Bo.apply(void 0,i),16);return{type:30,start:y,end:p}}else return{type:30,start:y,end:y}},u.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return e.toLowerCase()==="url"&&this.peekCodePoint(0)===O0?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===O0?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},u.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===Ru)return{type:22,value:""};var t=this.peekCodePoint(0);if(t===k0||t===z0){var r=this.consumeStringToken(this.consumeCodePoint());return r.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===Ru||this.peekCodePoint(0)===t_)?(this.consumeCodePoint(),{type:22,value:r.value}):(this.consumeBadUrlRemnants(),H0)}for(;;){var c=this.consumeCodePoint();if(c===Ru||c===t_)return{type:22,value:Bo.apply(void 0,e)};if(Q0(c))return this.consumeWhiteSpace(),this.peekCodePoint(0)===Ru||this.peekCodePoint(0)===t_?(this.consumeCodePoint(),{type:22,value:Bo.apply(void 0,e)}):(this.consumeBadUrlRemnants(),H0);if(c===z0||c===k0||c===O0||mD(c))return this.consumeBadUrlRemnants(),H0;if(c===B_)if(Kd(c,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),H0;else e.push(c)}},u.prototype.consumeWhiteSpace=function(){for(;Q0(this.peekCodePoint(0));)this.consumeCodePoint()},u.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(e===t_||e===Ru)return;Kd(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},u.prototype.consumeStringSlice=function(e){for(var t=5e4,r="";e>0;){var c=Math.min(t,e);r+=Bo.apply(void 0,this._value.splice(0,c)),e-=c}return this._value.shift(),r},u.prototype.consumeStringToken=function(e){var t="",r=0;do{var c=this._value[r];if(c===Ru||c===void 0||c===e)return t+=this.consumeStringSlice(r),{type:0,value:t};if(c===tv)return this._value.splice(0,r),MD;if(c===B_){var p=this._value[r+1];p!==Ru&&p!==void 0&&(p===tv?(t+=this.consumeStringSlice(r),r=-1,this._value.shift()):Kd(c,p)&&(t+=this.consumeStringSlice(r),t+=Bo(this.consumeEscapedCodePoint()),r=-1))}r++}while(!0)},u.prototype.consumeNumber=function(){var e=[],t=ly,r=this.peekCodePoint(0);for((r===sf||r===nc)&&e.push(this.consumeCodePoint());nl(this.peekCodePoint(0));)e.push(this.consumeCodePoint());r=this.peekCodePoint(0);var c=this.peekCodePoint(1);if(r===k_&&nl(c))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=KC;nl(this.peekCodePoint(0));)e.push(this.consumeCodePoint());r=this.peekCodePoint(0),c=this.peekCodePoint(1);var p=this.peekCodePoint(2);if((r===NS||r===kS)&&((c===sf||c===nc)&&nl(p)||nl(c)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=KC;nl(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[gD(e),t]},u.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],r=e[1],c=this.peekCodePoint(0),p=this.peekCodePoint(1),y=this.peekCodePoint(2);if(V0(c,p,y)){var i=this.consumeName();return{type:15,number:t,flags:r,unit:i}}return c===kL?(this.consumeCodePoint(),{type:16,number:t,flags:r}):{type:17,number:t,flags:r}},u.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(sm(e)){for(var t=Bo(e);sm(this.peekCodePoint(0))&&t.length<6;)t+=Bo(this.consumeCodePoint());Q0(this.peekCodePoint(0))&&this.consumeCodePoint();var r=parseInt(t,16);return r===0||uD(r)||r>1114111?XC:r}return e===Ru?XC:e},u.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(qC(t))e+=Bo(t);else if(Kd(t,this.peekCodePoint(0)))e+=Bo(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}},u}(),HS=function(){function u(e){this._tokens=e}return u.create=function(e){var t=new VS;return t.write(e),new u(t.read())},u.parseValue=function(e){return u.create(e).parseComponentValue()},u.parseValues=function(e){return u.create(e).parseComponentValues()},u.prototype.parseComponentValue=function(){for(var e=this.consumeToken();e.type===31;)e=this.consumeToken();if(e.type===32)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},u.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(t.type===32)return e;e.push(t),e.push()}},u.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},u.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},r=this.consumeToken();;){if(r.type===32||kD(r,e))return t;this.reconsumeToken(r),t.values.push(this.consumeComponentValue()),r=this.consumeToken()}},u.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var r=this.consumeToken();if(r.type===32||r.type===3)return t;this.reconsumeToken(r),t.values.push(this.consumeComponentValue())}},u.prototype.consumeToken=function(){var e=this._tokens.shift();return typeof e>"u"?wb:e},u.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},u}(),cy=function(u){return u.type===15},Xm=function(u){return u.type===17},Ms=function(u){return u.type===20},zD=function(u){return u.type===0},bb=function(u,e){return Ms(u)&&u.value===e},GS=function(u){return u.type!==31},Hm=function(u){return u.type!==31&&u.type!==4},$u=function(u){var e=[],t=[];return u.forEach(function(r){if(r.type===4){if(t.length===0)throw new Error("Error parsing function args, zero tokens for arg");e.push(t),t=[];return}r.type!==31&&t.push(r)}),t.length&&e.push(t),e},kD=function(u,e){return e===11&&u.type===12||e===28&&u.type===29?!0:e===2&&u.type===3},sp=function(u){return u.type===17||u.type===15},zo=function(u){return u.type===16||sp(u)},WS=function(u){return u.length>1?[u[0],u[1]]:[u[0]]},ka={type:17,number:0,flags:ly},C2={type:16,number:50,flags:ly},Xd={type:16,number:100,flags:ly},__=function(u,e,t){var r=u[0],c=u[1];return[Gs(r,e),Gs(typeof c<"u"?c:r,t)]},Gs=function(u,e){if(u.type===16)return u.number/100*e;if(cy(u))switch(u.unit){case"rem":case"em":return 16*u.number;case"px":default:return u.number}return u.number},jS="deg",KS="grad",$S="rad",ZS="turn",Fv={name:"angle",parse:function(u,e){if(e.type===15)switch(e.unit){case jS:return Math.PI*e.number/180;case KS:return Math.PI/200*e.number;case $S:return e.number;case ZS:return Math.PI*2*e.number}throw new Error("Unsupported angle type")}},XS=function(u){return u.type===15&&(u.unit===jS||u.unit===KS||u.unit===$S||u.unit===ZS)},qS=function(u){var e=u.filter(Ms).map(function(t){return t.value}).join(" ");switch(e){case"to bottom right":case"to right bottom":case"left top":case"top left":return[ka,ka];case"to top":case"bottom":return bh(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[ka,Xd];case"to right":case"left":return bh(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[Xd,Xd];case"to bottom":case"top":return bh(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[Xd,ka];case"to left":case"right":return bh(270)}return 0},bh=function(u){return Math.PI*u/180},ep={name:"color",parse:function(u,e){if(e.type===18){var t=OD[e.name];if(typeof t>"u")throw new Error('Attempting to parse an unsupported color function "'+e.name+'"');return t(u,e.values)}if(e.type===5){if(e.value.length===3){var r=e.value.substring(0,1),c=e.value.substring(1,2),p=e.value.substring(2,3);return qd(parseInt(r+r,16),parseInt(c+c,16),parseInt(p+p,16),1)}if(e.value.length===4){var r=e.value.substring(0,1),c=e.value.substring(1,2),p=e.value.substring(2,3),y=e.value.substring(3,4);return qd(parseInt(r+r,16),parseInt(c+c,16),parseInt(p+p,16),parseInt(y+y,16)/255)}if(e.value.length===6){var r=e.value.substring(0,2),c=e.value.substring(2,4),p=e.value.substring(4,6);return qd(parseInt(r,16),parseInt(c,16),parseInt(p,16),1)}if(e.value.length===8){var r=e.value.substring(0,2),c=e.value.substring(2,4),p=e.value.substring(4,6),y=e.value.substring(6,8);return qd(parseInt(r,16),parseInt(c,16),parseInt(p,16),parseInt(y,16)/255)}}if(e.type===20){var i=jA[e.value.toUpperCase()];if(typeof i<"u")return i}return jA.TRANSPARENT}},tp=function(u){return(255&u)===0},ga=function(u){var e=255&u,t=255&u>>8,r=255&u>>16,c=255&u>>24;return e<255?"rgba("+c+","+r+","+t+","+e/255+")":"rgb("+c+","+r+","+t+")"},qd=function(u,e,t,r){return(u<<24|e<<16|t<<8|Math.round(r*255)<<0)>>>0},YC=function(u,e){if(u.type===17)return u.number;if(u.type===16){var t=e===3?1:255;return e===3?u.number/100*t:Math.round(u.number/100*t)}return 0},JC=function(u,e){var t=e.filter(Hm);if(t.length===3){var r=t.map(YC),c=r[0],p=r[1],y=r[2];return qd(c,p,y,1)}if(t.length===4){var i=t.map(YC),c=i[0],p=i[1],y=i[2],C=i[3];return qd(c,p,y,C)}return 0};function aw(u,e,t){return t<0&&(t+=1),t>=1&&(t-=1),t<1/6?(e-u)*t*6+u:t<1/2?e:t<2/3?(e-u)*6*(2/3-t)+u:u}var eE=function(u,e){var t=e.filter(Hm),r=t[0],c=t[1],p=t[2],y=t[3],i=(r.type===17?bh(r.number):Fv.parse(u,r))/(Math.PI*2),C=zo(c)?c.number/100:0,D=zo(p)?p.number/100:0,U=typeof y<"u"&&zo(y)?Gs(y,1):1;if(C===0)return qd(D*255,D*255,D*255,1);var N=D<=.5?D*(C+1):D+C-D*C,R=D*2-N,G=aw(R,N,i+1/3),J=aw(R,N,i),Y=aw(R,N,i-1/3);return qd(G*255,J*255,Y*255,U)},OD={hsl:eE,hsla:eE,rgb:JC,rgba:JC},C_=function(u,e){return ep.parse(u,HS.create(e).parseComponentValue())},jA={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},ND={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(u,e){return e.map(function(t){if(Ms(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},QD={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Lv=function(u,e){var t=ep.parse(u,e[0]),r=e[1];return r&&zo(r)?{color:t,stop:r}:{color:t,stop:null}},tE=function(u,e){var t=u[0],r=u[u.length-1];t.stop===null&&(t.stop=ka),r.stop===null&&(r.stop=Xd);for(var c=[],p=0,y=0;yp?c.push(C):c.push(p),p=C}else c.push(null)}for(var D=null,y=0;yy.optimumDistance)?{optimumCorner:i,optimumDistance:U}:y},{optimumDistance:c?1/0:-1/0,optimumCorner:null}).optimumCorner},GD=function(u,e,t,r,c){var p=0,y=0;switch(u.size){case 0:u.shape===0?p=y=Math.min(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-c)):u.shape===1&&(p=Math.min(Math.abs(e),Math.abs(e-r)),y=Math.min(Math.abs(t),Math.abs(t-c)));break;case 2:if(u.shape===0)p=y=Math.min(lu(e,t),lu(e,t-c),lu(e-r,t),lu(e-r,t-c));else if(u.shape===1){var i=Math.min(Math.abs(t),Math.abs(t-c))/Math.min(Math.abs(e),Math.abs(e-r)),C=iE(r,c,e,t,!0),D=C[0],U=C[1];p=lu(D-e,(U-t)/i),y=i*p}break;case 1:u.shape===0?p=y=Math.max(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-c)):u.shape===1&&(p=Math.max(Math.abs(e),Math.abs(e-r)),y=Math.max(Math.abs(t),Math.abs(t-c)));break;case 3:if(u.shape===0)p=y=Math.max(lu(e,t),lu(e,t-c),lu(e-r,t),lu(e-r,t-c));else if(u.shape===1){var i=Math.max(Math.abs(t),Math.abs(t-c))/Math.max(Math.abs(e),Math.abs(e-r)),N=iE(r,c,e,t,!1),D=N[0],U=N[1];p=lu(D-e,(U-t)/i),y=i*p}break}return Array.isArray(u.size)&&(p=Gs(u.size[0],r),y=u.size.length===2?Gs(u.size[1],c):p),[p,y]},WD=function(u,e){var t=bh(180),r=[];return $u(e).forEach(function(c,p){if(p===0){var y=c[0];if(y.type===20&&y.value==="to"){t=qS(c);return}else if(XS(y)){t=Fv.parse(u,y);return}}var i=Lv(u,c);r.push(i)}),{angle:t,stops:r,type:1}},G0=function(u,e){var t=bh(180),r=[];return $u(e).forEach(function(c,p){if(p===0){var y=c[0];if(y.type===20&&["top","left","right","bottom"].indexOf(y.value)!==-1){t=qS(c);return}else if(XS(y)){t=(Fv.parse(u,y)+bh(270))%bh(360);return}}var i=Lv(u,c);r.push(i)}),{angle:t,stops:r,type:1}},jD=function(u,e){var t=bh(180),r=[],c=1,p=0,y=3,i=[];return $u(e).forEach(function(C,D){var U=C[0];if(D===0){if(Ms(U)&&U.value==="linear"){c=1;return}else if(Ms(U)&&U.value==="radial"){c=2;return}}if(U.type===18){if(U.name==="from"){var N=ep.parse(u,U.values[0]);r.push({stop:ka,color:N})}else if(U.name==="to"){var N=ep.parse(u,U.values[0]);r.push({stop:Xd,color:N})}else if(U.name==="color-stop"){var R=U.values.filter(Hm);if(R.length===2){var N=ep.parse(u,R[1]),G=R[0];Xm(G)&&r.push({stop:{type:16,number:G.number*100,flags:G.flags},color:N})}}}}),c===1?{angle:(t+bh(180))%bh(360),stops:r,type:c}:{size:y,shape:p,stops:r,position:i,type:c}},YS="closest-side",JS="farthest-side",eM="closest-corner",tM="farthest-corner",iM="circle",nM="ellipse",rM="cover",sM="contain",KD=function(u,e){var t=0,r=3,c=[],p=[];return $u(e).forEach(function(y,i){var C=!0;if(i===0){var D=!1;C=y.reduce(function(N,R){if(D)if(Ms(R))switch(R.value){case"center":return p.push(C2),N;case"top":case"left":return p.push(ka),N;case"right":case"bottom":return p.push(Xd),N}else(zo(R)||sp(R))&&p.push(R);else if(Ms(R))switch(R.value){case iM:return t=0,!1;case nM:return t=1,!1;case"at":return D=!0,!1;case YS:return r=0,!1;case rM:case JS:return r=1,!1;case sM:case eM:return r=2,!1;case tM:return r=3,!1}else if(sp(R)||zo(R))return Array.isArray(r)||(r=[]),r.push(R),!1;return N},C)}if(C){var U=Lv(u,y);c.push(U)}}),{size:r,shape:t,stops:c,position:p,type:2}},W0=function(u,e){var t=0,r=3,c=[],p=[];return $u(e).forEach(function(y,i){var C=!0;if(i===0?C=y.reduce(function(U,N){if(Ms(N))switch(N.value){case"center":return p.push(C2),!1;case"top":case"left":return p.push(ka),!1;case"right":case"bottom":return p.push(Xd),!1}else if(zo(N)||sp(N))return p.push(N),!1;return U},C):i===1&&(C=y.reduce(function(U,N){if(Ms(N))switch(N.value){case iM:return t=0,!1;case nM:return t=1,!1;case sM:case YS:return r=0,!1;case JS:return r=1,!1;case eM:return r=2,!1;case rM:case tM:return r=3,!1}else if(sp(N)||zo(N))return Array.isArray(r)||(r=[]),r.push(N),!1;return U},C)),C){var D=Lv(u,y);c.push(D)}}),{size:r,shape:t,stops:c,position:p,type:2}},$D=function(u){return u.type===1},ZD=function(u){return u.type===2},E2={name:"image",parse:function(u,e){if(e.type===22){var t={url:e.value,type:0};return u.cache.addImage(e.value),t}if(e.type===18){var r=oM[e.name];if(typeof r>"u")throw new Error('Attempting to parse an unsupported image function "'+e.name+'"');return r(u,e.values)}throw new Error("Unsupported image type "+e.type)}};function XD(u){return!(u.type===20&&u.value==="none")&&(u.type!==18||!!oM[u.name])}var oM={"linear-gradient":WD,"-moz-linear-gradient":G0,"-ms-linear-gradient":G0,"-o-linear-gradient":G0,"-webkit-linear-gradient":G0,"radial-gradient":KD,"-moz-radial-gradient":W0,"-ms-radial-gradient":W0,"-o-radial-gradient":W0,"-webkit-radial-gradient":W0,"-webkit-gradient":jD},qD={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(u,e){if(e.length===0)return[];var t=e[0];return t.type===20&&t.value==="none"?[]:e.filter(function(r){return Hm(r)&&XD(r)}).map(function(r){return E2.parse(u,r)})}},YD={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(u,e){return e.map(function(t){if(Ms(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},JD={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(u,e){return $u(e).map(function(t){return t.filter(zo)}).map(WS)}},eP={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(u,e){return $u(e).map(function(t){return t.filter(Ms).map(function(r){return r.value}).join(" ")}).map(tP)}},tP=function(u){switch(u){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;case"repeat":default:return 0}},Om;(function(u){u.AUTO="auto",u.CONTAIN="contain",u.COVER="cover"})(Om||(Om={}));var iP={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(u,e){return $u(e).map(function(t){return t.filter(nP)})}},nP=function(u){return Ms(u)||zo(u)},Dv=function(u){return{name:"border-"+u+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},rP=Dv("top"),sP=Dv("right"),oP=Dv("bottom"),aP=Dv("left"),Pv=function(u){return{name:"border-radius-"+u,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return WS(t.filter(zo))}}},lP=Pv("top-left"),cP=Pv("top-right"),hP=Pv("bottom-right"),uP=Pv("bottom-left"),Uv=function(u){return{name:"border-"+u+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},AP=Uv("top"),dP=Uv("right"),pP=Uv("bottom"),fP=Uv("left"),Rv=function(u){return{name:"border-"+u+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return cy(t)?t.number:0}}},mP=Rv("top"),gP=Rv("right"),_P=Rv("bottom"),yP=Rv("left"),xP={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},vP={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(u,e){switch(e){case"rtl":return 1;case"ltr":default:return 0}}},wP={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(u,e){return e.filter(Ms).reduce(function(t,r){return t|bP(r.value)},0)}},bP=function(u){switch(u){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},BP={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(u,e){switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},CP={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(u,e){return e.type===20&&e.value==="normal"?0:e.type===17||e.type===15?e.number:0}},nv;(function(u){u.NORMAL="normal",u.STRICT="strict"})(nv||(nv={}));var EP={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(u,e){switch(e){case"strict":return nv.STRICT;case"normal":default:return nv.NORMAL}}},TP={name:"line-height",initialValue:"normal",prefix:!1,type:4},nE=function(u,e){return Ms(u)&&u.value==="normal"?1.2*e:u.type===17?e*u.number:zo(u)?Gs(u,e):e},SP={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(u,e){return e.type===20&&e.value==="none"?null:E2.parse(u,e)}},MP={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(u,e){switch(e){case"inside":return 0;case"outside":default:return 1}}},Bb={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(u,e){switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":return 22;case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;case"none":default:return-1}}},zv=function(u){return{name:"margin-"+u,initialValue:"0",prefix:!1,type:4}},IP=zv("top"),FP=zv("right"),LP=zv("bottom"),DP=zv("left"),PP={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(u,e){return e.filter(Ms).map(function(t){switch(t.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;case"visible":default:return 0}})}},UP={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(u,e){switch(e){case"break-word":return"break-word";case"normal":default:return"normal"}}},kv=function(u){return{name:"padding-"+u,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},RP=kv("top"),zP=kv("right"),kP=kv("bottom"),OP=kv("left"),NP={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(u,e){switch(e){case"right":return 2;case"center":case"justify":return 1;case"left":default:return 0}}},QP={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(u,e){switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},VP={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(u,e){return e.length===1&&bb(e[0],"none")?[]:$u(e).map(function(t){for(var r={color:jA.TRANSPARENT,offsetX:ka,offsetY:ka,blur:ka},c=0,p=0;p"u")throw new Error('Attempting to parse an unsupported transform function "'+e.name+'"');return t(e.values)}return null}},WP=function(u){var e=u.filter(function(t){return t.type===17}).map(function(t){return t.number});return e.length===6?e:null},jP=function(u){var e=u.filter(function(C){return C.type===17}).map(function(C){return C.number}),t=e[0],r=e[1];e[2],e[3];var c=e[4],p=e[5];e[6],e[7],e[8],e[9],e[10],e[11];var y=e[12],i=e[13];return e[14],e[15],e.length===16?[t,r,c,p,y,i]:null},KP={matrix:WP,matrix3d:jP},rE={type:16,number:50,flags:ly},$P=[rE,rE],ZP={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(u,e){var t=e.filter(zo);return t.length!==2?$P:[t[0],t[1]]}},XP={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(u,e){switch(e){case"hidden":return 1;case"collapse":return 2;case"visible":default:return 0}}},E_;(function(u){u.NORMAL="normal",u.BREAK_ALL="break-all",u.KEEP_ALL="keep-all"})(E_||(E_={}));var qP={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(u,e){switch(e){case"break-all":return E_.BREAK_ALL;case"keep-all":return E_.KEEP_ALL;case"normal":default:return E_.NORMAL}}},YP={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(u,e){if(e.type===20)return{auto:!0,order:0};if(Xm(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},aM={name:"time",parse:function(u,e){if(e.type===15)switch(e.unit.toLowerCase()){case"s":return 1e3*e.number;case"ms":return e.number}throw new Error("Unsupported time type")}},JP={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(u,e){return Xm(e)?e.number:1}},eU={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},tU={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(u,e){return e.filter(Ms).map(function(t){switch(t.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(function(t){return t!==0})}},iU={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(u,e){var t=[],r=[];return e.forEach(function(c){switch(c.type){case 20:case 0:t.push(c.value);break;case 17:t.push(c.number.toString());break;case 4:r.push(t.join(" ")),t.length=0;break}}),t.length&&r.push(t.join(" ")),r.map(function(c){return c.indexOf(" ")===-1?c:"'"+c+"'"})}},nU={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},rU={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(u,e){if(Xm(e))return e.number;if(Ms(e))switch(e.value){case"bold":return 700;case"normal":default:return 400}return 400}},sU={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(u,e){return e.filter(Ms).map(function(t){return t.value})}},oU={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(u,e){switch(e){case"oblique":return"oblique";case"italic":return"italic";case"normal":default:return"normal"}}},ra=function(u,e){return(u&e)!==0},aU={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(u,e){if(e.length===0)return[];var t=e[0];return t.type===20&&t.value==="none"?[]:e}},lU={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(u,e){if(e.length===0)return null;var t=e[0];if(t.type===20&&t.value==="none")return null;for(var r=[],c=e.filter(GS),p=0;p1?1:0],this.overflowWrap=Nn(e,UP,t.overflowWrap),this.paddingTop=Nn(e,RP,t.paddingTop),this.paddingRight=Nn(e,zP,t.paddingRight),this.paddingBottom=Nn(e,kP,t.paddingBottom),this.paddingLeft=Nn(e,OP,t.paddingLeft),this.paintOrder=Nn(e,dU,t.paintOrder),this.position=Nn(e,QP,t.position),this.textAlign=Nn(e,NP,t.textAlign),this.textDecorationColor=Nn(e,eU,(r=t.textDecorationColor)!==null&&r!==void 0?r:t.color),this.textDecorationLine=Nn(e,tU,(c=t.textDecorationLine)!==null&&c!==void 0?c:t.textDecoration),this.textShadow=Nn(e,VP,t.textShadow),this.textTransform=Nn(e,HP,t.textTransform),this.transform=Nn(e,GP,t.transform),this.transformOrigin=Nn(e,ZP,t.transformOrigin),this.visibility=Nn(e,XP,t.visibility),this.webkitTextStrokeColor=Nn(e,pU,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=Nn(e,fU,t.webkitTextStrokeWidth),this.wordBreak=Nn(e,qP,t.wordBreak),this.zIndex=Nn(e,YP,t.zIndex)}return u.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&this.visibility===0},u.prototype.isTransparent=function(){return tp(this.backgroundColor)},u.prototype.isTransformed=function(){return this.transform!==null},u.prototype.isPositioned=function(){return this.position!==0},u.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},u.prototype.isFloating=function(){return this.float!==0},u.prototype.isInlineLevel=function(){return ra(this.display,4)||ra(this.display,33554432)||ra(this.display,268435456)||ra(this.display,536870912)||ra(this.display,67108864)||ra(this.display,134217728)},u}(),gU=function(){function u(e,t){this.content=Nn(e,aU,t.content),this.quotes=Nn(e,uU,t.quotes)}return u}(),oE=function(){function u(e,t){this.counterIncrement=Nn(e,lU,t.counterIncrement),this.counterReset=Nn(e,cU,t.counterReset)}return u}(),Nn=function(u,e,t){var r=new VS,c=t!==null&&typeof t<"u"?t.toString():e.initialValue;r.write(c);var p=new HS(r.read());switch(e.type){case 2:var y=p.parseComponentValue();return e.parse(u,Ms(y)?y.value:e.initialValue);case 0:return e.parse(u,p.parseComponentValue());case 1:return e.parse(u,p.parseComponentValues());case 4:return p.parseComponentValue();case 3:switch(e.format){case"angle":return Fv.parse(u,p.parseComponentValue());case"color":return ep.parse(u,p.parseComponentValue());case"image":return E2.parse(u,p.parseComponentValue());case"length":var i=p.parseComponentValue();return sp(i)?i:ka;case"length-percentage":var C=p.parseComponentValue();return zo(C)?C:ka;case"time":return aM.parse(u,p.parseComponentValue())}break}},_U="data-html2canvas-debug",yU=function(u){var e=u.getAttribute(_U);switch(e){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},Cb=function(u,e){var t=yU(u);return t===1||e===t},Zu=function(){function u(e,t){if(this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Cb(t,3))debugger;this.styles=new mU(e,window.getComputedStyle(t,null)),Sb(t)&&(this.styles.animationDuration.some(function(r){return r>0})&&(t.style.animationDuration="0s"),this.styles.transform!==null&&(t.style.transform="none")),this.bounds=Mv(this.context,t),Cb(t,4)&&(this.flags|=16)}return u}(),xU="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=",aE="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y_=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var j0=0;j0>4,U[c++]=(y&15)<<4|i>>2,U[c++]=(i&3)<<6|C&63;return D},wU=function(u){for(var e=u.length,t=[],r=0;r>uf,CU=1<>uf,TU=lM+EU,SU=TU,MU=32,IU=SU+MU,FU=65536>>T2,LU=1<=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>uf],t=(t<>uf)],t=(t<>T2),t=this.index[t],t+=e>>uf&DU,t=this.index[t],t=(t<"u"?[]:new Uint8Array(256);for(var K0=0;K0=55296&&c<=56319&&t>10)+55296,y%1024+56320)),(c+1===t||r.length>16384)&&(p+=String.fromCharCode.apply(String,r),r.length=0)}return p},VU=UU(xU),yh="\xD7",fw="\xF7",HU=function(u){return VU.get(u)},GU=function(u,e,t){var r=t-2,c=e[r],p=e[t-1],y=e[t];if(p===hw&&y===uw)return yh;if(p===hw||p===uw||p===hE||y===hw||y===uw||y===hE)return fw;if(p===AE&&[AE,Aw,dE,pE].indexOf(y)!==-1||(p===dE||p===Aw)&&(y===Aw||y===dw)||(p===pE||p===dw)&&y===dw||y===fE||y===uE||y===OU||p===kU)return yh;if(p===fE&&y===mE){for(;c===uE;)c=e[--r];if(c===mE)return yh}if(p===pw&&y===pw){for(var i=0;c===pw;)i++,c=e[--r];if(i%2===0)return yh}return fw},WU=function(u){var e=NU(u),t=e.length,r=0,c=0,p=e.map(HU);return{next:function(){if(r>=t)return{done:!0,value:null};for(var y=yh;ry.x||U.y>y.y;return y=U,D===0?!0:N});return u.body.removeChild(e),i},ZU=function(){return typeof new Image().crossOrigin<"u"},XU=function(){return typeof new XMLHttpRequest().responseType=="string"},qU=function(u){var e=new Image,t=u.createElement("canvas"),r=t.getContext("2d");if(!r)return!1;e.src="data:image/svg+xml,";try{r.drawImage(e,0,0),t.toDataURL()}catch{return!1}return!0},gE=function(u){return u[0]===0&&u[1]===255&&u[2]===0&&u[3]===255},YU=function(u){var e=u.createElement("canvas"),t=100;e.width=t,e.height=t;var r=e.getContext("2d");if(!r)return Promise.reject(!1);r.fillStyle="rgb(0, 255, 0)",r.fillRect(0,0,t,t);var c=new Image,p=e.toDataURL();c.src=p;var y=Eb(t,t,0,0,c);return r.fillStyle="red",r.fillRect(0,0,t,t),_E(y).then(function(i){r.drawImage(i,0,0);var C=r.getImageData(0,0,t,t).data;r.fillStyle="red",r.fillRect(0,0,t,t);var D=u.createElement("div");return D.style.backgroundImage="url("+p+")",D.style.height=t+"px",gE(C)?_E(Eb(t,t,0,0,D)):Promise.reject(!1)}).then(function(i){return r.drawImage(i,0,0),gE(r.getImageData(0,0,t,t).data)}).catch(function(){return!1})},Eb=function(u,e,t,r,c){var p="http://www.w3.org/2000/svg",y=document.createElementNS(p,"svg"),i=document.createElementNS(p,"foreignObject");return y.setAttributeNS(null,"width",u.toString()),y.setAttributeNS(null,"height",e.toString()),i.setAttributeNS(null,"width","100%"),i.setAttributeNS(null,"height","100%"),i.setAttributeNS(null,"x",t.toString()),i.setAttributeNS(null,"y",r.toString()),i.setAttributeNS(null,"externalResourcesRequired","true"),y.appendChild(i),i.appendChild(c),y},_E=function(u){return new Promise(function(e,t){var r=new Image;r.onload=function(){return e(r)},r.onerror=t,r.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(u))})},za={get SUPPORT_RANGE_BOUNDS(){var u=KU(document);return Object.defineProperty(za,"SUPPORT_RANGE_BOUNDS",{value:u}),u},get SUPPORT_WORD_BREAKING(){var u=za.SUPPORT_RANGE_BOUNDS&&$U(document);return Object.defineProperty(za,"SUPPORT_WORD_BREAKING",{value:u}),u},get SUPPORT_SVG_DRAWING(){var u=qU(document);return Object.defineProperty(za,"SUPPORT_SVG_DRAWING",{value:u}),u},get SUPPORT_FOREIGNOBJECT_DRAWING(){var u=typeof Array.from=="function"&&typeof window.fetch=="function"?YU(document):Promise.resolve(!1);return Object.defineProperty(za,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:u}),u},get SUPPORT_CORS_IMAGES(){var u=ZU();return Object.defineProperty(za,"SUPPORT_CORS_IMAGES",{value:u}),u},get SUPPORT_RESPONSE_TYPE(){var u=XU();return Object.defineProperty(za,"SUPPORT_RESPONSE_TYPE",{value:u}),u},get SUPPORT_CORS_XHR(){var u="withCredentials"in new XMLHttpRequest;return Object.defineProperty(za,"SUPPORT_CORS_XHR",{value:u}),u},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var u=!!(typeof Intl<"u"&&Intl.Segmenter);return Object.defineProperty(za,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:u}),u}},T_=function(){function u(e,t){this.text=e,this.bounds=t}return u}(),JU=function(u,e,t,r){var c=i4(e,t),p=[],y=0;return c.forEach(function(i){if(t.textDecorationLine.length||i.trim().length>0)if(za.SUPPORT_RANGE_BOUNDS){var C=yE(r,y,i.length).getClientRects();if(C.length>1){var D=S2(i),U=0;D.forEach(function(R){p.push(new T_(R,ZA.fromDOMRectList(u,yE(r,U+y,R.length).getClientRects()))),U+=R.length})}else p.push(new T_(i,ZA.fromDOMRectList(u,C)))}else{var N=r.splitText(i.length);p.push(new T_(i,e4(u,r))),r=N}else za.SUPPORT_RANGE_BOUNDS||(r=r.splitText(i.length));y+=i.length}),p},e4=function(u,e){var t=e.ownerDocument;if(t){var r=t.createElement("html2canvaswrapper");r.appendChild(e.cloneNode(!0));var c=e.parentNode;if(c){c.replaceChild(r,e);var p=Mv(u,r);return r.firstChild&&c.replaceChild(r.firstChild,r),p}}return ZA.EMPTY},yE=function(u,e,t){var r=u.ownerDocument;if(!r)throw new Error("Node has no owner document");var c=r.createRange();return c.setStart(u,e),c.setEnd(u,e+t),c},S2=function(u){if(za.SUPPORT_NATIVE_TEXT_SEGMENTATION){var e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(u)).map(function(t){return t.segment})}return jU(u)},t4=function(u,e){if(za.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(t.segment(u)).map(function(r){return r.segment})}return r4(u,e)},i4=function(u,e){return e.letterSpacing!==0?S2(u):t4(u,e)},n4=[32,160,4961,65792,65793,4153,4241],r4=function(u,e){for(var t=FL(u,{lineBreak:e.lineBreak,wordBreak:e.overflowWrap==="break-word"?"break-word":e.wordBreak}),r=[],c,p=function(){if(c.value){var y=c.value.slice(),i=Iv(y),C="";i.forEach(function(D){n4.indexOf(D)===-1?C+=Bo(D):(C.length&&r.push(C),r.push(Bo(D)),C="")}),C.length&&r.push(C)}};!(c=t.next()).done;)p();return r},s4=function(){function u(e,t,r){this.text=o4(t.data,r.textTransform),this.textBounds=JU(e,this.text,r,t)}return u}(),o4=function(u,e){switch(e){case 1:return u.toLowerCase();case 3:return u.replace(a4,l4);case 2:return u.toUpperCase();default:return u}},a4=/(^|\s|:|-|\(|\))([a-z])/g,l4=function(u,e,t){return u.length>0?e+t.toUpperCase():u},cM=function(u){uu(e,u);function e(t,r){var c=u.call(this,t,r)||this;return c.src=r.currentSrc||r.src,c.intrinsicWidth=r.naturalWidth,c.intrinsicHeight=r.naturalHeight,c.context.cache.addImage(c.src),c}return e}(Zu),hM=function(u){uu(e,u);function e(t,r){var c=u.call(this,t,r)||this;return c.canvas=r,c.intrinsicWidth=r.width,c.intrinsicHeight=r.height,c}return e}(Zu),uM=function(u){uu(e,u);function e(t,r){var c=u.call(this,t,r)||this,p=new XMLSerializer,y=Mv(t,r);return r.setAttribute("width",y.width+"px"),r.setAttribute("height",y.height+"px"),c.svg="data:image/svg+xml,"+encodeURIComponent(p.serializeToString(r)),c.intrinsicWidth=r.width.baseVal.value,c.intrinsicHeight=r.height.baseVal.value,c.context.cache.addImage(c.svg),c}return e}(Zu),AM=function(u){uu(e,u);function e(t,r){var c=u.call(this,t,r)||this;return c.value=r.value,c}return e}(Zu),Tb=function(u){uu(e,u);function e(t,r){var c=u.call(this,t,r)||this;return c.start=r.start,c.reversed=typeof r.reversed=="boolean"&&r.reversed===!0,c}return e}(Zu),c4=[{type:15,flags:0,unit:"px",number:3}],h4=[{type:16,flags:0,number:50}],u4=function(u){return u.width>u.height?new ZA(u.left+(u.width-u.height)/2,u.top,u.height,u.height):u.width0)t.textNodes.push(new s4(u,c,t.styles));else if(Fm(c))if(wM(c)&&c.assignedNodes)c.assignedNodes().forEach(function(i){return Gx(u,i,t,r)});else{var y=mM(u,c);y.styles.isVisible()&&(f4(c,y,r)?y.flags|=4:m4(y.styles)&&(y.flags|=2),p4.indexOf(c.tagName)!==-1&&(y.flags|=8),t.elements.push(y),c.slot,c.shadowRoot?Gx(u,c.shadowRoot,y,r):!ov(c)&&!yM(c)&&!av(c)&&Gx(u,c,y,r))}},mM=function(u,e){return Mb(e)?new cM(u,e):xM(e)?new hM(u,e):yM(e)?new uM(u,e):g4(e)?new AM(u,e):_4(e)?new Tb(u,e):y4(e)?new M2(u,e):av(e)?new dM(u,e):ov(e)?new pM(u,e):vM(e)?new fM(u,e):new Zu(u,e)},gM=function(u,e){var t=mM(u,e);return t.flags|=4,Gx(u,e,t,t),t},f4=function(u,e,t){return e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||I2(u)&&t.styles.isTransparent()},m4=function(u){return u.isPositioned()||u.isFloating()},_M=function(u){return u.nodeType===Node.TEXT_NODE},Fm=function(u){return u.nodeType===Node.ELEMENT_NODE},Sb=function(u){return Fm(u)&&typeof u.style<"u"&&!Wx(u)},Wx=function(u){return typeof u.className=="object"},g4=function(u){return u.tagName==="LI"},_4=function(u){return u.tagName==="OL"},y4=function(u){return u.tagName==="INPUT"},x4=function(u){return u.tagName==="HTML"},yM=function(u){return u.tagName==="svg"},I2=function(u){return u.tagName==="BODY"},xM=function(u){return u.tagName==="CANVAS"},vE=function(u){return u.tagName==="VIDEO"},Mb=function(u){return u.tagName==="IMG"},vM=function(u){return u.tagName==="IFRAME"},wE=function(u){return u.tagName==="STYLE"},v4=function(u){return u.tagName==="SCRIPT"},ov=function(u){return u.tagName==="TEXTAREA"},av=function(u){return u.tagName==="SELECT"},wM=function(u){return u.tagName==="SLOT"},bE=function(u){return u.tagName.indexOf("-")>0},w4=function(){function u(){this.counters={}}return u.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},u.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},u.prototype.pop=function(e){var t=this;e.forEach(function(r){return t.counters[r].pop()})},u.prototype.parse=function(e){var t=this,r=e.counterIncrement,c=e.counterReset,p=!0;r!==null&&r.forEach(function(i){var C=t.counters[i.counter];C&&i.increment!==0&&(p=!1,C.length||C.push(1),C[Math.max(0,C.length-1)]+=i.increment)});var y=[];return p&&c.forEach(function(i){var C=t.counters[i.counter];y.push(i.counter),C||(C=t.counters[i.counter]=[]),C.push(i.reset)}),y},u}(),BE={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},CE={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u0554","\u0553","\u0552","\u0551","\u0550","\u054F","\u054E","\u054D","\u054C","\u054B","\u054A","\u0549","\u0548","\u0547","\u0546","\u0545","\u0544","\u0543","\u0542","\u0541","\u0540","\u053F","\u053E","\u053D","\u053C","\u053B","\u053A","\u0539","\u0538","\u0537","\u0536","\u0535","\u0534","\u0533","\u0532","\u0531"]},b4={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["\u05D9\u05F3","\u05D8\u05F3","\u05D7\u05F3","\u05D6\u05F3","\u05D5\u05F3","\u05D4\u05F3","\u05D3\u05F3","\u05D2\u05F3","\u05D1\u05F3","\u05D0\u05F3","\u05EA","\u05E9","\u05E8","\u05E7","\u05E6","\u05E4","\u05E2","\u05E1","\u05E0","\u05DE","\u05DC","\u05DB","\u05D9\u05D8","\u05D9\u05D7","\u05D9\u05D6","\u05D8\u05D6","\u05D8\u05D5","\u05D9","\u05D8","\u05D7","\u05D6","\u05D5","\u05D4","\u05D3","\u05D2","\u05D1","\u05D0"]},B4={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u10F5","\u10F0","\u10EF","\u10F4","\u10EE","\u10ED","\u10EC","\u10EB","\u10EA","\u10E9","\u10E8","\u10E7","\u10E6","\u10E5","\u10E4","\u10F3","\u10E2","\u10E1","\u10E0","\u10DF","\u10DE","\u10DD","\u10F2","\u10DC","\u10DB","\u10DA","\u10D9","\u10D8","\u10D7","\u10F1","\u10D6","\u10D5","\u10D4","\u10D3","\u10D2","\u10D1","\u10D0"]},om=function(u,e,t,r,c,p){return ut?O_(u,c,p.length>0):r.integers.reduce(function(y,i,C){for(;u>=i;)u-=i,y+=r.values[C];return y},"")+p},bM=function(u,e,t,r){var c="";do t||u--,c=r(u)+c,u/=e;while(u*e>=e);return c},wo=function(u,e,t,r,c){var p=t-e+1;return(u<0?"-":"")+(bM(Math.abs(u),p,r,function(y){return Bo(Math.floor(y%p)+e)})+c)},Op=function(u,e,t){t===void 0&&(t=". ");var r=e.length;return bM(Math.abs(u),r,!1,function(c){return e[Math.floor(c%r)]})+t},Mm=1<<0,Gd=1<<1,Wd=1<<2,x_=1<<3,UA=function(u,e,t,r,c,p){if(u<-9999||u>9999)return O_(u,4,c.length>0);var y=Math.abs(u),i=c;if(y===0)return e[0]+i;for(var C=0;y>0&&C<=4;C++){var D=y%10;D===0&&ra(p,Mm)&&i!==""?i=e[D]+i:D>1||D===1&&C===0||D===1&&C===1&&ra(p,Gd)||D===1&&C===1&&ra(p,Wd)&&u>100||D===1&&C>1&&ra(p,x_)?i=e[D]+(C>0?t[C-1]:"")+i:D===1&&C>0&&(i=t[C-1]+i),y=Math.floor(y/10)}return(u<0?r:"")+i},EE="\u5341\u767E\u5343\u842C",TE="\u62FE\u4F70\u4EDF\u842C",SE="\u30DE\u30A4\u30CA\u30B9",mw="\uB9C8\uC774\uB108\uC2A4",O_=function(u,e,t){var r=t?". ":"",c=t?"\u3001":"",p=t?", ":"",y=t?" ":"";switch(e){case 0:return"\u2022"+y;case 1:return"\u25E6"+y;case 2:return"\u25FE"+y;case 5:var i=wo(u,48,57,!0,r);return i.length<4?"0"+i:i;case 4:return Op(u,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",c);case 6:return om(u,1,3999,BE,3,r).toLowerCase();case 7:return om(u,1,3999,BE,3,r);case 8:return wo(u,945,969,!1,r);case 9:return wo(u,97,122,!1,r);case 10:return wo(u,65,90,!1,r);case 11:return wo(u,1632,1641,!0,r);case 12:case 49:return om(u,1,9999,CE,3,r);case 35:return om(u,1,9999,CE,3,r).toLowerCase();case 13:return wo(u,2534,2543,!0,r);case 14:case 30:return wo(u,6112,6121,!0,r);case 15:return Op(u,"\u5B50\u4E11\u5BC5\u536F\u8FB0\u5DF3\u5348\u672A\u7533\u9149\u620C\u4EA5",c);case 16:return Op(u,"\u7532\u4E59\u4E19\u4E01\u620A\u5DF1\u5E9A\u8F9B\u58EC\u7678",c);case 17:case 48:return UA(u,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",EE,"\u8CA0",c,Gd|Wd|x_);case 47:return UA(u,"\u96F6\u58F9\u8CB3\u53C3\u8086\u4F0D\u9678\u67D2\u634C\u7396",TE,"\u8CA0",c,Mm|Gd|Wd|x_);case 42:return UA(u,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",EE,"\u8D1F",c,Gd|Wd|x_);case 41:return UA(u,"\u96F6\u58F9\u8D30\u53C1\u8086\u4F0D\u9646\u67D2\u634C\u7396",TE,"\u8D1F",c,Mm|Gd|Wd|x_);case 26:return UA(u,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u4E07",SE,c,0);case 25:return UA(u,"\u96F6\u58F1\u5F10\u53C2\u56DB\u4F0D\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343\u4E07",SE,c,Mm|Gd|Wd);case 31:return UA(u,"\uC601\uC77C\uC774\uC0BC\uC0AC\uC624\uC721\uCE60\uD314\uAD6C","\uC2ED\uBC31\uCC9C\uB9CC",mw,p,Mm|Gd|Wd);case 33:return UA(u,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u842C",mw,p,0);case 32:return UA(u,"\u96F6\u58F9\u8CB3\u53C3\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343",mw,p,Mm|Gd|Wd);case 18:return wo(u,2406,2415,!0,r);case 20:return om(u,1,19999,B4,3,r);case 21:return wo(u,2790,2799,!0,r);case 22:return wo(u,2662,2671,!0,r);case 22:return om(u,1,10999,b4,3,r);case 23:return Op(u,"\u3042\u3044\u3046\u3048\u304A\u304B\u304D\u304F\u3051\u3053\u3055\u3057\u3059\u305B\u305D\u305F\u3061\u3064\u3066\u3068\u306A\u306B\u306C\u306D\u306E\u306F\u3072\u3075\u3078\u307B\u307E\u307F\u3080\u3081\u3082\u3084\u3086\u3088\u3089\u308A\u308B\u308C\u308D\u308F\u3090\u3091\u3092\u3093");case 24:return Op(u,"\u3044\u308D\u306F\u306B\u307B\u3078\u3068\u3061\u308A\u306C\u308B\u3092\u308F\u304B\u3088\u305F\u308C\u305D\u3064\u306D\u306A\u3089\u3080\u3046\u3090\u306E\u304A\u304F\u3084\u307E\u3051\u3075\u3053\u3048\u3066\u3042\u3055\u304D\u3086\u3081\u307F\u3057\u3091\u3072\u3082\u305B\u3059");case 27:return wo(u,3302,3311,!0,r);case 28:return Op(u,"\u30A2\u30A4\u30A6\u30A8\u30AA\u30AB\u30AD\u30AF\u30B1\u30B3\u30B5\u30B7\u30B9\u30BB\u30BD\u30BF\u30C1\u30C4\u30C6\u30C8\u30CA\u30CB\u30CC\u30CD\u30CE\u30CF\u30D2\u30D5\u30D8\u30DB\u30DE\u30DF\u30E0\u30E1\u30E2\u30E4\u30E6\u30E8\u30E9\u30EA\u30EB\u30EC\u30ED\u30EF\u30F0\u30F1\u30F2\u30F3",c);case 29:return Op(u,"\u30A4\u30ED\u30CF\u30CB\u30DB\u30D8\u30C8\u30C1\u30EA\u30CC\u30EB\u30F2\u30EF\u30AB\u30E8\u30BF\u30EC\u30BD\u30C4\u30CD\u30CA\u30E9\u30E0\u30A6\u30F0\u30CE\u30AA\u30AF\u30E4\u30DE\u30B1\u30D5\u30B3\u30A8\u30C6\u30A2\u30B5\u30AD\u30E6\u30E1\u30DF\u30B7\u30F1\u30D2\u30E2\u30BB\u30B9",c);case 34:return wo(u,3792,3801,!0,r);case 37:return wo(u,6160,6169,!0,r);case 38:return wo(u,4160,4169,!0,r);case 39:return wo(u,2918,2927,!0,r);case 40:return wo(u,1776,1785,!0,r);case 43:return wo(u,3046,3055,!0,r);case 44:return wo(u,3174,3183,!0,r);case 45:return wo(u,3664,3673,!0,r);case 46:return wo(u,3872,3881,!0,r);case 3:default:return wo(u,48,57,!0,r)}},BM="data-html2canvas-ignore",ME=function(){function u(e,t,r){if(this.context=e,this.options=r,this.scrolledElements=[],this.referenceElement=t,this.counters=new w4,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return u.prototype.toIFrame=function(e,t){var r=this,c=C4(e,t);if(!c.contentWindow)return Promise.reject("Unable to find iframe window");var p=e.defaultView.pageXOffset,y=e.defaultView.pageYOffset,i=c.contentWindow,C=i.document,D=S4(c).then(function(){return Ml(r,void 0,void 0,function(){var U,N;return il(this,function(R){switch(R.label){case 0:return this.scrolledElements.forEach(L4),i&&(i.scrollTo(t.left,t.top),/(iPad|iPhone|iPod)/g.test(navigator.userAgent)&&(i.scrollY!==t.top||i.scrollX!==t.left)&&(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(i.scrollX-t.left,i.scrollY-t.top,0,0))),U=this.options.onclone,N=this.clonedReferenceElement,typeof N>"u"?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:C.fonts&&C.fonts.ready?[4,C.fonts.ready]:[3,2];case 1:R.sent(),R.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,T4(C)]:[3,4];case 3:R.sent(),R.label=4;case 4:return typeof U=="function"?[2,Promise.resolve().then(function(){return U(C,N)}).then(function(){return c})]:[2,c]}})})});return C.open(),C.write(I4(document.doctype)+""),F4(this.referenceElement.ownerDocument,p,y),C.replaceChild(C.adoptNode(this.documentElement),C.documentElement),C.close(),D},u.prototype.createElementClone=function(e){if(Cb(e,2))debugger;if(xM(e))return this.createCanvasClone(e);if(vE(e))return this.createVideoClone(e);if(wE(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return Mb(t)&&(Mb(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager")),bE(t)?this.createCustomElementClone(t):t},u.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return gw(e.style,t),t},u.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var r=[].slice.call(t.cssRules,0).reduce(function(p,y){return y&&typeof y.cssText=="string"?p+y.cssText:p},""),c=e.cloneNode(!1);return c.textContent=r,c}}catch(p){if(this.context.logger.error("Unable to access cssRules property",p),p.name!=="SecurityError")throw p}return e.cloneNode(!1)},u.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var r=e.ownerDocument.createElement("img");try{return r.src=e.toDataURL(),r}catch{this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var c=e.cloneNode(!1);try{c.width=e.width,c.height=e.height;var p=e.getContext("2d"),y=c.getContext("2d");if(y)if(!this.options.allowTaint&&p)y.putImageData(p.getImageData(0,0,e.width,e.height),0,0);else{var i=(t=e.getContext("webgl2"))!==null&&t!==void 0?t:e.getContext("webgl");if(i){var C=i.getContextAttributes();(C==null?void 0:C.preserveDrawingBuffer)===!1&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}y.drawImage(e,0,0)}return c}catch{this.context.logger.info("Unable to clone canvas as it is tainted",e)}return c},u.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var r=t.getContext("2d");try{return r&&(r.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||r.getImageData(0,0,t.width,t.height)),t}catch{this.context.logger.info("Unable to clone video as it is tainted",e)}var c=e.ownerDocument.createElement("canvas");return c.width=e.offsetWidth,c.height=e.offsetHeight,c},u.prototype.appendChildNode=function(e,t,r){(!Fm(t)||!v4(t)&&!t.hasAttribute(BM)&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(t)))&&(!this.options.copyStyles||!Fm(t)||!wE(t))&&e.appendChild(this.cloneNode(t,r))},u.prototype.cloneChildNodes=function(e,t,r){for(var c=this,p=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;p;p=p.nextSibling)if(Fm(p)&&wM(p)&&typeof p.assignedNodes=="function"){var y=p.assignedNodes();y.length&&y.forEach(function(i){return c.appendChildNode(t,i,r)})}else this.appendChildNode(t,p,r)},u.prototype.cloneNode=function(e,t){if(_M(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var r=e.ownerDocument.defaultView;if(r&&Fm(e)&&(Sb(e)||Wx(e))){var c=this.createElementClone(e);c.style.transitionProperty="none";var p=r.getComputedStyle(e),y=r.getComputedStyle(e,":before"),i=r.getComputedStyle(e,":after");this.referenceElement===e&&Sb(c)&&(this.clonedReferenceElement=c),I2(c)&&U4(c);var C=this.counters.parse(new oE(this.context,p)),D=this.resolvePseudoContent(e,c,y,S_.BEFORE);bE(e)&&(t=!0),vE(e)||this.cloneChildNodes(e,c,t),D&&c.insertBefore(D,c.firstChild);var U=this.resolvePseudoContent(e,c,i,S_.AFTER);return U&&c.appendChild(U),this.counters.pop(C),(p&&(this.options.copyStyles||Wx(e))&&!vM(e)||t)&&gw(p,c),(e.scrollTop!==0||e.scrollLeft!==0)&&this.scrolledElements.push([c,e.scrollLeft,e.scrollTop]),(ov(e)||av(e))&&(ov(c)||av(c))&&(c.value=e.value),c}return e.cloneNode(!1)},u.prototype.resolvePseudoContent=function(e,t,r,c){var p=this;if(!!r){var y=r.content,i=t.ownerDocument;if(!(!i||!y||y==="none"||y==="-moz-alt-content"||r.display==="none")){this.counters.parse(new oE(this.context,r));var C=new gU(this.context,r),D=i.createElement("html2canvaspseudoelement");gw(r,D),C.content.forEach(function(N){if(N.type===0)D.appendChild(i.createTextNode(N.value));else if(N.type===22){var R=i.createElement("img");R.src=N.value,R.style.opacity="1",D.appendChild(R)}else if(N.type===18){if(N.name==="attr"){var G=N.values.filter(Ms);G.length&&D.appendChild(i.createTextNode(e.getAttribute(G[0].value)||""))}else if(N.name==="counter"){var J=N.values.filter(Hm),Y=J[0],B=J[1];if(Y&&Ms(Y)){var ae=p.counters.getCounterValue(Y.value),le=B&&Ms(B)?Bb.parse(p.context,B.value):3;D.appendChild(i.createTextNode(O_(ae,le,!1)))}}else if(N.name==="counters"){var Ae=N.values.filter(Hm),Y=Ae[0],we=Ae[1],B=Ae[2];if(Y&&Ms(Y)){var me=p.counters.getCounterValues(Y.value),Pe=B&&Ms(B)?Bb.parse(p.context,B.value):3,it=we&&we.type===0?we.value:"",Me=me.map(function(oi){return O_(oi,Pe,!1)}).join(it);D.appendChild(i.createTextNode(Me))}}}else if(N.type===20)switch(N.value){case"open-quote":D.appendChild(i.createTextNode(sE(C.quotes,p.quoteDepth++,!0)));break;case"close-quote":D.appendChild(i.createTextNode(sE(C.quotes,--p.quoteDepth,!1)));break;default:D.appendChild(i.createTextNode(N.value))}}),D.className=Ib+" "+Fb;var U=c===S_.BEFORE?" "+Ib:" "+Fb;return Wx(t)?t.className.baseValue+=U:t.className+=U,D}}},u.destroy=function(e){return e.parentNode?(e.parentNode.removeChild(e),!0):!1},u}(),S_;(function(u){u[u.BEFORE=0]="BEFORE",u[u.AFTER=1]="AFTER"})(S_||(S_={}));var C4=function(u,e){var t=u.createElement("iframe");return t.className="html2canvas-container",t.style.visibility="hidden",t.style.position="fixed",t.style.left="-10000px",t.style.top="0px",t.style.border="0",t.width=e.width.toString(),t.height=e.height.toString(),t.scrolling="no",t.setAttribute(BM,"true"),u.body.appendChild(t),t},E4=function(u){return new Promise(function(e){if(u.complete){e();return}if(!u.src){e();return}u.onload=e,u.onerror=e})},T4=function(u){return Promise.all([].slice.call(u.images,0).map(E4))},S4=function(u){return new Promise(function(e,t){var r=u.contentWindow;if(!r)return t("No window assigned for iframe");var c=r.document;r.onload=u.onload=function(){r.onload=u.onload=null;var p=setInterval(function(){c.body.childNodes.length>0&&c.readyState==="complete"&&(clearInterval(p),e(u))},50)}})},M4=["all","d","content"],gw=function(u,e){for(var t=u.length-1;t>=0;t--){var r=u.item(t);M4.indexOf(r)===-1&&e.style.setProperty(r,u.getPropertyValue(r))}return e},I4=function(u){var e="";return u&&(e+=""),e},F4=function(u,e,t){u&&u.defaultView&&(e!==u.defaultView.pageXOffset||t!==u.defaultView.pageYOffset)&&u.defaultView.scrollTo(e,t)},L4=function(u){var e=u[0],t=u[1],r=u[2];e.scrollLeft=t,e.scrollTop=r},D4=":before",P4=":after",Ib="___html2canvas___pseudoelement_before",Fb="___html2canvas___pseudoelement_after",IE=`{ content: "" !important; display: none !important; }`,U4=function(u){R4(u,"."+Ib+D4+IE+` .`+Fb+P4+IE)},R4=function(u,e){var t=u.ownerDocument;if(t){var r=t.createElement("style");r.textContent=e,u.appendChild(r)}},CM=function(){function u(){}return u.getOrigin=function(e){var t=u._link;return t?(t.href=e,t.href=t.href,t.protocol+t.hostname+t.port):"about:blank"},u.isSameOrigin=function(e){return u.getOrigin(e)===u._origin},u.setContext=function(e){u._link=e.document.createElement("a"),u._origin=u.getOrigin(e.location.href)},u._origin="about:blank",u}(),z4=function(){function u(e,t){this.context=e,this._options=t,this._cache={}}return u.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)||(yw(e)||Q4(e))&&(this._cache[e]=this.loadImage(e)).catch(function(){}),t},u.prototype.match=function(e){return this._cache[e]},u.prototype.loadImage=function(e){return Ml(this,void 0,void 0,function(){var t,r,c,p,y=this;return il(this,function(i){switch(i.label){case 0:return t=CM.isSameOrigin(e),r=!_w(e)&&this._options.useCORS===!0&&za.SUPPORT_CORS_IMAGES&&!t,c=!_w(e)&&!t&&!yw(e)&&typeof this._options.proxy=="string"&&za.SUPPORT_CORS_XHR&&!r,!t&&this._options.allowTaint===!1&&!_w(e)&&!yw(e)&&!c&&!r?[2]:(p=e,c?[4,this.proxy(p)]:[3,2]);case 1:p=i.sent(),i.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise(function(C,D){var U=new Image;U.onload=function(){return C(U)},U.onerror=D,(V4(p)||r)&&(U.crossOrigin="anonymous"),U.src=p,U.complete===!0&&setTimeout(function(){return C(U)},500),y._options.imageTimeout>0&&setTimeout(function(){return D("Timed out ("+y._options.imageTimeout+"ms) loading image")},y._options.imageTimeout)})];case 3:return[2,i.sent()]}})})},u.prototype.has=function(e){return typeof this._cache[e]<"u"},u.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},u.prototype.proxy=function(e){var t=this,r=this._options.proxy;if(!r)throw new Error("No proxy defined");var c=e.substring(0,256);return new Promise(function(p,y){var i=za.SUPPORT_RESPONSE_TYPE?"blob":"text",C=new XMLHttpRequest;C.onload=function(){if(C.status===200)if(i==="text")p(C.response);else{var N=new FileReader;N.addEventListener("load",function(){return p(N.result)},!1),N.addEventListener("error",function(R){return y(R)},!1),N.readAsDataURL(C.response)}else y("Failed to proxy resource "+c+" with status code "+C.status)},C.onerror=y;var D=r.indexOf("?")>-1?"&":"?";if(C.open("GET",""+r+D+"url="+encodeURIComponent(e)+"&responseType="+i),i!=="text"&&C instanceof XMLHttpRequest&&(C.responseType=i),t._options.imageTimeout){var U=t._options.imageTimeout;C.timeout=U,C.ontimeout=function(){return y("Timed out ("+U+"ms) proxying "+c)}}C.send()})},u}(),k4=/^data:image\/svg\+xml/i,O4=/^data:image\/.*;base64,/i,N4=/^data:image\/.*/i,Q4=function(u){return za.SUPPORT_SVG_DRAWING||!H4(u)},_w=function(u){return N4.test(u)},V4=function(u){return O4.test(u)},yw=function(u){return u.substr(0,4)==="blob"},H4=function(u){return u.substr(-3).toLowerCase()==="svg"||k4.test(u)},Rn=function(){function u(e,t){this.type=0,this.x=e,this.y=t}return u.prototype.add=function(e,t){return new u(this.x+e,this.y+t)},u}(),am=function(u,e,t){return new Rn(u.x+(e.x-u.x)*t,u.y+(e.y-u.y)*t)},$0=function(){function u(e,t,r,c){this.type=1,this.start=e,this.startControl=t,this.endControl=r,this.end=c}return u.prototype.subdivide=function(e,t){var r=am(this.start,this.startControl,e),c=am(this.startControl,this.endControl,e),p=am(this.endControl,this.end,e),y=am(r,c,e),i=am(c,p,e),C=am(y,i,e);return t?new u(this.start,r,y,C):new u(C,i,p,this.end)},u.prototype.add=function(e,t){return new u(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))},u.prototype.reverse=function(){return new u(this.end,this.endControl,this.startControl,this.start)},u}(),vh=function(u){return u.type===1},G4=function(){function u(e){var t=e.styles,r=e.bounds,c=__(t.borderTopLeftRadius,r.width,r.height),p=c[0],y=c[1],i=__(t.borderTopRightRadius,r.width,r.height),C=i[0],D=i[1],U=__(t.borderBottomRightRadius,r.width,r.height),N=U[0],R=U[1],G=__(t.borderBottomLeftRadius,r.width,r.height),J=G[0],Y=G[1],B=[];B.push((p+C)/r.width),B.push((J+N)/r.width),B.push((y+Y)/r.height),B.push((D+R)/r.height);var ae=Math.max.apply(Math,B);ae>1&&(p/=ae,y/=ae,C/=ae,D/=ae,N/=ae,R/=ae,J/=ae,Y/=ae);var le=r.width-C,Ae=r.height-R,we=r.width-N,me=r.height-Y,Pe=t.borderTopWidth,it=t.borderRightWidth,Me=t.borderBottomWidth,Ke=t.borderLeftWidth,Et=Gs(t.paddingTop,e.bounds.width),oi=Gs(t.paddingRight,e.bounds.width),Ci=Gs(t.paddingBottom,e.bounds.width),te=Gs(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=p>0||y>0?ro(r.left+Ke/3,r.top+Pe/3,p-Ke/3,y-Pe/3,xs.TOP_LEFT):new Rn(r.left+Ke/3,r.top+Pe/3),this.topRightBorderDoubleOuterBox=p>0||y>0?ro(r.left+le,r.top+Pe/3,C-it/3,D-Pe/3,xs.TOP_RIGHT):new Rn(r.left+r.width-it/3,r.top+Pe/3),this.bottomRightBorderDoubleOuterBox=N>0||R>0?ro(r.left+we,r.top+Ae,N-it/3,R-Me/3,xs.BOTTOM_RIGHT):new Rn(r.left+r.width-it/3,r.top+r.height-Me/3),this.bottomLeftBorderDoubleOuterBox=J>0||Y>0?ro(r.left+Ke/3,r.top+me,J-Ke/3,Y-Me/3,xs.BOTTOM_LEFT):new Rn(r.left+Ke/3,r.top+r.height-Me/3),this.topLeftBorderDoubleInnerBox=p>0||y>0?ro(r.left+Ke*2/3,r.top+Pe*2/3,p-Ke*2/3,y-Pe*2/3,xs.TOP_LEFT):new Rn(r.left+Ke*2/3,r.top+Pe*2/3),this.topRightBorderDoubleInnerBox=p>0||y>0?ro(r.left+le,r.top+Pe*2/3,C-it*2/3,D-Pe*2/3,xs.TOP_RIGHT):new Rn(r.left+r.width-it*2/3,r.top+Pe*2/3),this.bottomRightBorderDoubleInnerBox=N>0||R>0?ro(r.left+we,r.top+Ae,N-it*2/3,R-Me*2/3,xs.BOTTOM_RIGHT):new Rn(r.left+r.width-it*2/3,r.top+r.height-Me*2/3),this.bottomLeftBorderDoubleInnerBox=J>0||Y>0?ro(r.left+Ke*2/3,r.top+me,J-Ke*2/3,Y-Me*2/3,xs.BOTTOM_LEFT):new Rn(r.left+Ke*2/3,r.top+r.height-Me*2/3),this.topLeftBorderStroke=p>0||y>0?ro(r.left+Ke/2,r.top+Pe/2,p-Ke/2,y-Pe/2,xs.TOP_LEFT):new Rn(r.left+Ke/2,r.top+Pe/2),this.topRightBorderStroke=p>0||y>0?ro(r.left+le,r.top+Pe/2,C-it/2,D-Pe/2,xs.TOP_RIGHT):new Rn(r.left+r.width-it/2,r.top+Pe/2),this.bottomRightBorderStroke=N>0||R>0?ro(r.left+we,r.top+Ae,N-it/2,R-Me/2,xs.BOTTOM_RIGHT):new Rn(r.left+r.width-it/2,r.top+r.height-Me/2),this.bottomLeftBorderStroke=J>0||Y>0?ro(r.left+Ke/2,r.top+me,J-Ke/2,Y-Me/2,xs.BOTTOM_LEFT):new Rn(r.left+Ke/2,r.top+r.height-Me/2),this.topLeftBorderBox=p>0||y>0?ro(r.left,r.top,p,y,xs.TOP_LEFT):new Rn(r.left,r.top),this.topRightBorderBox=C>0||D>0?ro(r.left+le,r.top,C,D,xs.TOP_RIGHT):new Rn(r.left+r.width,r.top),this.bottomRightBorderBox=N>0||R>0?ro(r.left+we,r.top+Ae,N,R,xs.BOTTOM_RIGHT):new Rn(r.left+r.width,r.top+r.height),this.bottomLeftBorderBox=J>0||Y>0?ro(r.left,r.top+me,J,Y,xs.BOTTOM_LEFT):new Rn(r.left,r.top+r.height),this.topLeftPaddingBox=p>0||y>0?ro(r.left+Ke,r.top+Pe,Math.max(0,p-Ke),Math.max(0,y-Pe),xs.TOP_LEFT):new Rn(r.left+Ke,r.top+Pe),this.topRightPaddingBox=C>0||D>0?ro(r.left+Math.min(le,r.width-it),r.top+Pe,le>r.width+it?0:Math.max(0,C-it),Math.max(0,D-Pe),xs.TOP_RIGHT):new Rn(r.left+r.width-it,r.top+Pe),this.bottomRightPaddingBox=N>0||R>0?ro(r.left+Math.min(we,r.width-Ke),r.top+Math.min(Ae,r.height-Me),Math.max(0,N-it),Math.max(0,R-Me),xs.BOTTOM_RIGHT):new Rn(r.left+r.width-it,r.top+r.height-Me),this.bottomLeftPaddingBox=J>0||Y>0?ro(r.left+Ke,r.top+Math.min(me,r.height-Me),Math.max(0,J-Ke),Math.max(0,Y-Me),xs.BOTTOM_LEFT):new Rn(r.left+Ke,r.top+r.height-Me),this.topLeftContentBox=p>0||y>0?ro(r.left+Ke+te,r.top+Pe+Et,Math.max(0,p-(Ke+te)),Math.max(0,y-(Pe+Et)),xs.TOP_LEFT):new Rn(r.left+Ke+te,r.top+Pe+Et),this.topRightContentBox=C>0||D>0?ro(r.left+Math.min(le,r.width+Ke+te),r.top+Pe+Et,le>r.width+Ke+te?0:C-Ke+te,D-(Pe+Et),xs.TOP_RIGHT):new Rn(r.left+r.width-(it+oi),r.top+Pe+Et),this.bottomRightContentBox=N>0||R>0?ro(r.left+Math.min(we,r.width-(Ke+te)),r.top+Math.min(Ae,r.height+Pe+Et),Math.max(0,N-(it+oi)),R-(Me+Ci),xs.BOTTOM_RIGHT):new Rn(r.left+r.width-(it+oi),r.top+r.height-(Me+Ci)),this.bottomLeftContentBox=J>0||Y>0?ro(r.left+Ke+te,r.top+me,Math.max(0,J-(Ke+te)),Y-(Me+Ci),xs.BOTTOM_LEFT):new Rn(r.left+Ke+te,r.top+r.height-(Me+Ci))}return u}(),xs;(function(u){u[u.TOP_LEFT=0]="TOP_LEFT",u[u.TOP_RIGHT=1]="TOP_RIGHT",u[u.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",u[u.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(xs||(xs={}));var ro=function(u,e,t,r,c){var p=4*((Math.sqrt(2)-1)/3),y=t*p,i=r*p,C=u+t,D=e+r;switch(c){case xs.TOP_LEFT:return new $0(new Rn(u,D),new Rn(u,D-i),new Rn(C-y,e),new Rn(C,e));case xs.TOP_RIGHT:return new $0(new Rn(u,e),new Rn(u+y,e),new Rn(C,D-i),new Rn(C,D));case xs.BOTTOM_RIGHT:return new $0(new Rn(C,e),new Rn(C,e+i),new Rn(u+y,D),new Rn(u,D));case xs.BOTTOM_LEFT:default:return new $0(new Rn(C,D),new Rn(C-y,D),new Rn(u,e+i),new Rn(u,e))}},lv=function(u){return[u.topLeftBorderBox,u.topRightBorderBox,u.bottomRightBorderBox,u.bottomLeftBorderBox]},W4=function(u){return[u.topLeftContentBox,u.topRightContentBox,u.bottomRightContentBox,u.bottomLeftContentBox]},cv=function(u){return[u.topLeftPaddingBox,u.topRightPaddingBox,u.bottomRightPaddingBox,u.bottomLeftPaddingBox]},j4=function(){function u(e,t,r){this.offsetX=e,this.offsetY=t,this.matrix=r,this.type=0,this.target=6}return u}(),Z0=function(){function u(e,t){this.path=e,this.target=t,this.type=1}return u}(),K4=function(){function u(e){this.opacity=e,this.type=2,this.target=6}return u}(),$4=function(u){return u.type===0},EM=function(u){return u.type===1},Z4=function(u){return u.type===2},FE=function(u,e){return u.length===e.length?u.some(function(t,r){return t===e[r]}):!1},X4=function(u,e,t,r,c){return u.map(function(p,y){switch(y){case 0:return p.add(e,t);case 1:return p.add(e+r,t);case 2:return p.add(e+r,t+c);case 3:return p.add(e,t+c)}return p})},TM=function(){function u(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return u}(),SM=function(){function u(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new G4(this.container),this.container.styles.opacity<1&&this.effects.push(new K4(this.container.styles.opacity)),this.container.styles.transform!==null){var r=this.container.bounds.left+this.container.styles.transformOrigin[0].number,c=this.container.bounds.top+this.container.styles.transformOrigin[1].number,p=this.container.styles.transform;this.effects.push(new j4(r,c,p))}if(this.container.styles.overflowX!==0){var y=lv(this.curves),i=cv(this.curves);FE(y,i)?this.effects.push(new Z0(y,6)):(this.effects.push(new Z0(y,2)),this.effects.push(new Z0(i,4)))}}return u.prototype.getEffects=function(e){for(var t=[2,3].indexOf(this.container.styles.position)===-1,r=this.parent,c=this.effects.slice(0);r;){var p=r.effects.filter(function(C){return!EM(C)});if(t||r.container.styles.position!==0||!r.parent){if(c.unshift.apply(c,p),t=[2,3].indexOf(r.container.styles.position)===-1,r.container.styles.overflowX!==0){var y=lv(r.curves),i=cv(r.curves);FE(y,i)||c.unshift(new Z0(i,6))}}else c.unshift.apply(c,p);r=r.parent}return c.filter(function(C){return ra(C.target,e)})},u}(),Lb=function(u,e,t,r){u.container.elements.forEach(function(c){var p=ra(c.flags,4),y=ra(c.flags,2),i=new SM(c,u);ra(c.styles.display,2048)&&r.push(i);var C=ra(c.flags,8)?[]:r;if(p||y){var D=p||c.styles.isPositioned()?t:e,U=new TM(i);if(c.styles.isPositioned()||c.styles.opacity<1||c.styles.isTransformed()){var N=c.styles.zIndex.order;if(N<0){var R=0;D.negativeZIndex.some(function(J,Y){return N>J.element.container.styles.zIndex.order?(R=Y,!1):R>0}),D.negativeZIndex.splice(R,0,U)}else if(N>0){var G=0;D.positiveZIndex.some(function(J,Y){return N>=J.element.container.styles.zIndex.order?(G=Y+1,!1):G>0}),D.positiveZIndex.splice(G,0,U)}else D.zeroOrAutoZIndexOrTransformedOrOpacity.push(U)}else c.styles.isFloating()?D.nonPositionedFloats.push(U):D.nonPositionedInlineLevel.push(U);Lb(i,U,p?U:t,C)}else c.styles.isInlineLevel()?e.inlineLevel.push(i):e.nonInlineLevel.push(i),Lb(i,e,t,C);ra(c.flags,8)&&MM(c,C)})},MM=function(u,e){for(var t=u instanceof Tb?u.start:1,r=u instanceof Tb?u.reversed:!1,c=0;c"u"?u[0]:t},rR=function(u,e,t,r,c){var p=e[0],y=e[1],i=t[0],C=t[1];switch(u){case 2:return[new Rn(Math.round(r.left),Math.round(r.top+y)),new Rn(Math.round(r.left+r.width),Math.round(r.top+y)),new Rn(Math.round(r.left+r.width),Math.round(C+r.top+y)),new Rn(Math.round(r.left),Math.round(C+r.top+y))];case 3:return[new Rn(Math.round(r.left+p),Math.round(r.top)),new Rn(Math.round(r.left+p+i),Math.round(r.top)),new Rn(Math.round(r.left+p+i),Math.round(r.height+r.top)),new Rn(Math.round(r.left+p),Math.round(r.height+r.top))];case 1:return[new Rn(Math.round(r.left+p),Math.round(r.top+y)),new Rn(Math.round(r.left+p+i),Math.round(r.top+y)),new Rn(Math.round(r.left+p+i),Math.round(r.top+y+C)),new Rn(Math.round(r.left+p),Math.round(r.top+y+C))];default:return[new Rn(Math.round(c.left),Math.round(c.top)),new Rn(Math.round(c.left+c.width),Math.round(c.top)),new Rn(Math.round(c.left+c.width),Math.round(c.height+c.top)),new Rn(Math.round(c.left),Math.round(c.height+c.top))]}},sR="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",DE="Hidden Text",oR=function(){function u(e){this._data={},this._document=e}return u.prototype.parseMetrics=function(e,t){var r=this._document.createElement("div"),c=this._document.createElement("img"),p=this._document.createElement("span"),y=this._document.body;r.style.visibility="hidden",r.style.fontFamily=e,r.style.fontSize=t,r.style.margin="0",r.style.padding="0",r.style.whiteSpace="nowrap",y.appendChild(r),c.src=sR,c.width=1,c.height=1,c.style.margin="0",c.style.padding="0",c.style.verticalAlign="baseline",p.style.fontFamily=e,p.style.fontSize=t,p.style.margin="0",p.style.padding="0",p.appendChild(this._document.createTextNode(DE)),r.appendChild(p),r.appendChild(c);var i=c.offsetTop-p.offsetTop+2;r.removeChild(p),r.appendChild(this._document.createTextNode(DE)),r.style.lineHeight="normal",c.style.verticalAlign="super";var C=c.offsetTop-r.offsetTop+2;return y.removeChild(r),{baseline:i,middle:C}},u.prototype.getMetrics=function(e,t){var r=e+" "+t;return typeof this._data[r]>"u"&&(this._data[r]=this.parseMetrics(e,t)),this._data[r]},u}(),FM=function(){function u(e,t){this.context=e,this.options=t}return u}(),aR=1e4,lR=function(u){uu(e,u);function e(t,r){var c=u.call(this,t,r)||this;return c._activeEffects=[],c.canvas=r.canvas?r.canvas:document.createElement("canvas"),c.ctx=c.canvas.getContext("2d"),r.canvas||(c.canvas.width=Math.floor(r.width*r.scale),c.canvas.height=Math.floor(r.height*r.scale),c.canvas.style.width=r.width+"px",c.canvas.style.height=r.height+"px"),c.fontMetrics=new oR(document),c.ctx.scale(c.options.scale,c.options.scale),c.ctx.translate(-r.x,-r.y),c.ctx.textBaseline="bottom",c._activeEffects=[],c.context.logger.debug("Canvas renderer initialized ("+r.width+"x"+r.height+") with scale "+r.scale),c}return e.prototype.applyEffects=function(t){for(var r=this;this._activeEffects.length;)this.popEffect();t.forEach(function(c){return r.applyEffect(c)})},e.prototype.applyEffect=function(t){this.ctx.save(),Z4(t)&&(this.ctx.globalAlpha=t.opacity),$4(t)&&(this.ctx.translate(t.offsetX,t.offsetY),this.ctx.transform(t.matrix[0],t.matrix[1],t.matrix[2],t.matrix[3],t.matrix[4],t.matrix[5]),this.ctx.translate(-t.offsetX,-t.offsetY)),EM(t)&&(this.path(t.path),this.ctx.clip()),this._activeEffects.push(t)},e.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},e.prototype.renderStack=function(t){return Ml(this,void 0,void 0,function(){var r;return il(this,function(c){switch(c.label){case 0:return r=t.element.container.styles,r.isVisible()?[4,this.renderStackContent(t)]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},e.prototype.renderNode=function(t){return Ml(this,void 0,void 0,function(){return il(this,function(r){switch(r.label){case 0:if(ra(t.container.flags,16))debugger;return t.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(t)]:[3,3];case 1:return r.sent(),[4,this.renderNodeContent(t)];case 2:r.sent(),r.label=3;case 3:return[2]}})})},e.prototype.renderTextWithLetterSpacing=function(t,r,c){var p=this;if(r===0)this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+c);else{var y=S2(t.text);y.reduce(function(i,C){return p.ctx.fillText(C,i,t.bounds.top+c),i+p.ctx.measureText(C).width},t.bounds.left)}},e.prototype.createFontStyle=function(t){var r=t.fontVariant.filter(function(y){return y==="normal"||y==="small-caps"}).join(""),c=dR(t.fontFamily).join(", "),p=cy(t.fontSize)?""+t.fontSize.number+t.fontSize.unit:t.fontSize.number+"px";return[[t.fontStyle,r,t.fontWeight,p,c].join(" "),c,p]},e.prototype.renderTextNode=function(t,r){return Ml(this,void 0,void 0,function(){var c,p,y,i,C,D,U,N,R=this;return il(this,function(G){return c=this.createFontStyle(r),p=c[0],y=c[1],i=c[2],this.ctx.font=p,this.ctx.direction=r.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",C=this.fontMetrics.getMetrics(y,i),D=C.baseline,U=C.middle,N=r.paintOrder,t.textBounds.forEach(function(J){N.forEach(function(Y){switch(Y){case 0:R.ctx.fillStyle=ga(r.color),R.renderTextWithLetterSpacing(J,r.letterSpacing,D);var B=r.textShadow;B.length&&J.text.trim().length&&(B.slice(0).reverse().forEach(function(ae){R.ctx.shadowColor=ga(ae.color),R.ctx.shadowOffsetX=ae.offsetX.number*R.options.scale,R.ctx.shadowOffsetY=ae.offsetY.number*R.options.scale,R.ctx.shadowBlur=ae.blur.number,R.renderTextWithLetterSpacing(J,r.letterSpacing,D)}),R.ctx.shadowColor="",R.ctx.shadowOffsetX=0,R.ctx.shadowOffsetY=0,R.ctx.shadowBlur=0),r.textDecorationLine.length&&(R.ctx.fillStyle=ga(r.textDecorationColor||r.color),r.textDecorationLine.forEach(function(ae){switch(ae){case 1:R.ctx.fillRect(J.bounds.left,Math.round(J.bounds.top+D),J.bounds.width,1);break;case 2:R.ctx.fillRect(J.bounds.left,Math.round(J.bounds.top),J.bounds.width,1);break;case 3:R.ctx.fillRect(J.bounds.left,Math.ceil(J.bounds.top+U),J.bounds.width,1);break}}));break;case 1:r.webkitTextStrokeWidth&&J.text.trim().length&&(R.ctx.strokeStyle=ga(r.webkitTextStrokeColor),R.ctx.lineWidth=r.webkitTextStrokeWidth,R.ctx.lineJoin=window.chrome?"miter":"round",R.ctx.strokeText(J.text,J.bounds.left,J.bounds.top+D)),R.ctx.strokeStyle="",R.ctx.lineWidth=0,R.ctx.lineJoin="miter";break}})}),[2]})})},e.prototype.renderReplacedElement=function(t,r,c){if(c&&t.intrinsicWidth>0&&t.intrinsicHeight>0){var p=hv(t),y=cv(r);this.path(y),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(c,0,0,t.intrinsicWidth,t.intrinsicHeight,p.left,p.top,p.width,p.height),this.ctx.restore()}},e.prototype.renderNodeContent=function(t){return Ml(this,void 0,void 0,function(){var r,c,p,y,i,C,le,le,D,U,N,R,we,G,J,me,Y,B,ae,le,Ae,we,me;return il(this,function(Pe){switch(Pe.label){case 0:this.applyEffects(t.getEffects(4)),r=t.container,c=t.curves,p=r.styles,y=0,i=r.textNodes,Pe.label=1;case 1:return y0&&ce>0&&(Me=p.ctx.createPattern(me,"repeat"),p.renderRepeat(Et,Me,xe,ze))):ZD(U)&&(Ke=xw(t,r,[null,null,null]),Et=Ke[0],oi=Ke[1],Ci=Ke[2],te=Ke[3],ce=Ke[4],ye=U.position.length===0?[C2]:U.position,xe=Gs(ye[0],te),ze=Gs(ye[ye.length-1],ce),Ne=GD(U,xe,ze,te,ce),Ge=Ne[0],Ve=Ne[1],Ge>0&&Ve>0&&(Le=p.ctx.createRadialGradient(oi+xe,Ci+ze,0,oi+xe,Ci+ze,Ge),tE(U.stops,Ge*2).forEach(function(dt){return Le.addColorStop(dt.stop,ga(dt.color))}),p.path(Et),p.ctx.fillStyle=Le,Ge!==Ve?(Ie=t.bounds.left+.5*t.bounds.width,qe=t.bounds.top+.5*t.bounds.height,et=Ve/Ge,vt=1/et,p.ctx.save(),p.ctx.translate(Ie,qe),p.ctx.transform(1,0,0,et,0,0),p.ctx.translate(-Ie,-qe),p.ctx.fillRect(oi,vt*(Ci-qe)+qe,te,ce*vt),p.ctx.restore()):p.ctx.fill())),Be.label=6;case 6:return r--,[2]}})},p=this,y=0,i=t.styles.backgroundImage.slice(0).reverse(),D.label=1;case 1:return y0?U.style!==2?[3,5]:[4,this.renderDashedDottedBorder(U.color,U.width,i,t.curves,2)]:[3,11]):[3,13];case 4:return R.sent(),[3,11];case 5:return U.style!==3?[3,7]:[4,this.renderDashedDottedBorder(U.color,U.width,i,t.curves,3)];case 6:return R.sent(),[3,11];case 7:return U.style!==4?[3,9]:[4,this.renderDoubleBorder(U.color,U.width,i,t.curves)];case 8:return R.sent(),[3,11];case 9:return[4,this.renderSolidBorder(U.color,i,t.curves)];case 10:R.sent(),R.label=11;case 11:i++,R.label=12;case 12:return C++,[3,3];case 13:return[2]}})})},e.prototype.renderDashedDottedBorder=function(t,r,c,p,y){return Ml(this,void 0,void 0,function(){var i,C,D,U,N,R,G,J,Y,B,ae,le,Ae,we,me,Pe,me,Pe;return il(this,function(it){return this.ctx.save(),i=eR(p,c),C=LE(p,c),y===2&&(this.path(C),this.ctx.clip()),vh(C[0])?(D=C[0].start.x,U=C[0].start.y):(D=C[0].x,U=C[0].y),vh(C[1])?(N=C[1].end.x,R=C[1].end.y):(N=C[1].x,R=C[1].y),c===0||c===2?G=Math.abs(D-N):G=Math.abs(U-R),this.ctx.beginPath(),y===3?this.formatPath(i):this.formatPath(C.slice(0,2)),J=r<3?r*3:r*2,Y=r<3?r*2:r,y===3&&(J=r,Y=r),B=!0,G<=J*2?B=!1:G<=J*2+Y?(ae=G/(2*J+Y),J*=ae,Y*=ae):(le=Math.floor((G+Y)/(J+Y)),Ae=(G-le*J)/(le-1),we=(G-(le+1)*J)/le,Y=we<=0||Math.abs(Y-Ae){let e=R_.parse(window.location.search),t=R_.parse(window.location.hash);return this.params=Object.assign(this.params,e,t),nf._instance});zi(this,"Init",()=>{console.dir(this.nativeFns)});zi(this,"IsPC",()=>{let e=navigator.userAgent,t=["Android","iPhone","SymbianOS","Windows Phone","iPad","iPod"],r=!0;for(let c=0;c0){r=!1;break}return r});zi(this,"_OutScreenshot",async function(e=""){$(`#${this.domId} > div`).css("width","100%"),$(`#${this.domId} > div`).css("height","100%"),$(`#${this.domId} > div`).css("overflow","hidden"),$("#bim-cache").css("display","none");let t;if(e!==""&&document.getElementById(e)){let c=document.getElementById(e);t=await PE(c)}t=await PE(document.body);let r=t.toDataURL();return await this._scaleImage(600,r),r});zi(this,"_scaleImage",async function(e=720,t=""){return new Promise((r,c)=>{let p="";if(!t||t==="")r(p);else{let y=document.body.offsetHeight,i=document.body.offsetWidth,C=e,D=e/(i/y),U=document.createElement("canvas");U.width=C,U.height=D;let N=U.getContext("2d"),R=document.createElement("img");R.id="testimg",R.src=t,R.style.width="200px",R.style.position="absolute",R.style.top="0px",R.style.zIndex="9999",R.onload=G=>{console.dir(R),N.drawImage(R,0,0,C,D),U.style.position="absolute",U.style.display="block",U.style.top="0px",U.style.right="0px",U.style.zIndex="10000",U.style.backgroundColor="red",p=U.toDataURL(),r(p)}}})})}static getInstance(){return nf._instance==null&&(nf._instance=new nf),nf._instance}BindFn(e){return this.nativeFns=e,this}};let Nm=nf;zi(Nm,"_instance");const zm=class{constructor(){zi(this,"targetComponentID","")}static getInstance(){return zm._instance==null&&(zm._instance=new zm),zm._instance}BindCbFn(e){return tf.getInstance().Fn,this}};let M_=zm;zi(M_,"_instance");var Ua={exports:{}};(function(u,e){(function({},t){u.exports=t()})(TS,function(){var t,r,c;function p(i,C){if(!t)t=C;else if(!r)r=C;else{var D="var sharedChunk = {}; ("+t+")(sharedChunk); ("+r+")(sharedChunk);",U={};t(U),c=C(U),typeof window<"u"&&(c.workerUrl=window.URL.createObjectURL(new Blob([D],{type:"text/javascript"})))}}p(["exports"],function(i){var C=D;function D(A,l,f,w){this.cx=3*A,this.bx=3*(f-A)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*l,this.by=3*(w-l)-this.cy,this.ay=1-this.cy-this.by,this.p1x=A,this.p1y=l,this.p2x=f,this.p2y=w}function U(A,l,f,w){const I=new C(A,l,f,w);return function(z){return I.solve(z)}}D.prototype={sampleCurveX:function(A){return((this.ax*A+this.bx)*A+this.cx)*A},sampleCurveY:function(A){return((this.ay*A+this.by)*A+this.cy)*A},sampleCurveDerivativeX:function(A){return(3*this.ax*A+2*this.bx)*A+this.cx},solveCurveX:function(A,l){if(l===void 0&&(l=1e-6),A<0)return 0;if(A>1)return 1;for(var f=A,w=0;w<8;w++){var I=this.sampleCurveX(f)-A;if(Math.abs(I)I?Q=f:Z=f,f=.5*(Z-Q)+Q;return f},solve:function(A,l){return this.sampleCurveY(this.solveCurveX(A,l))}};const N=U(.25,.1,.25,1);function R(A,l,f){return Math.min(f,Math.max(l,A))}function G(A,l,f){const w=f-l,I=((A-l)%w+w)%w+l;return I===l?f:I}function J(A,...l){for(const f of l)for(const w in f)A[w]=f[w];return A}let Y=1;function B(A,l){A.forEach(f=>{l[f]&&(l[f]=l[f].bind(l))})}function ae(A,l,f){const w={};for(const I in A)w[I]=l.call(f||this,A[I],I,A);return w}function le(A,l,f){const w={};for(const I in A)l.call(f||this,A[I],I,A)&&(w[I]=A[I]);return w}function Ae(A){return Array.isArray(A)?A.map(Ae):typeof A=="object"&&A?ae(A,Ae):A}const we={};function me(A){we[A]||(typeof console<"u"&&console.warn(A),we[A]=!0)}function Pe(A,l,f){return(f.y-A.y)*(l.x-A.x)>(l.y-A.y)*(f.x-A.x)}function it(A){let l=0;for(let f,w,I=0,z=A.length,Q=z-1;I@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(f,w,I,z)=>{const Q=I||z;return l[w]=!Q||Q.toLowerCase(),""}),l["max-age"]){const f=parseInt(l["max-age"],10);isNaN(f)?delete l["max-age"]:l["max-age"]=f}return l}let Et,oi,Ci=null;function te(A){if(Ci==null){const l=A.navigator?A.navigator.userAgent:null;Ci=!!A.safari||!(!l||!(/\b(iPad|iPhone|iPod)\b/.test(l)||l.match("Safari")&&!l.match("Chrome")))}return Ci}function ce(A){return typeof ImageBitmap<"u"&&A instanceof ImageBitmap}const ye={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(A){const l=requestAnimationFrame(A);return{cancel:()=>cancelAnimationFrame(l)}},getImageData(A,l=0){const f=window.document.createElement("canvas"),w=f.getContext("2d");if(!w)throw new Error("failed to create canvas 2d context");return f.width=A.width,f.height=A.height,w.drawImage(A,0,0,A.width,A.height),w.getImageData(-l,-l,A.width+2*l,A.height+2*l)},resolveURL:A=>(Et||(Et=document.createElement("a")),Et.href=A,Et.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(oi==null&&(oi=matchMedia("(prefers-reduced-motion: reduce)")),oi.matches)}};var xe=ze;function ze(A,l){this.x=A,this.y=l}ze.prototype={clone:function(){return new ze(this.x,this.y)},add:function(A){return this.clone()._add(A)},sub:function(A){return this.clone()._sub(A)},multByPoint:function(A){return this.clone()._multByPoint(A)},divByPoint:function(A){return this.clone()._divByPoint(A)},mult:function(A){return this.clone()._mult(A)},div:function(A){return this.clone()._div(A)},rotate:function(A){return this.clone()._rotate(A)},rotateAround:function(A,l){return this.clone()._rotateAround(A,l)},matMult:function(A){return this.clone()._matMult(A)},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(A){return this.x===A.x&&this.y===A.y},dist:function(A){return Math.sqrt(this.distSqr(A))},distSqr:function(A){var l=A.x-this.x,f=A.y-this.y;return l*l+f*f},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(A){return Math.atan2(this.y-A.y,this.x-A.x)},angleWith:function(A){return this.angleWithSep(A.x,A.y)},angleWithSep:function(A,l){return Math.atan2(this.x*l-this.y*A,this.x*A+this.y*l)},_matMult:function(A){var l=A[2]*this.x+A[3]*this.y;return this.x=A[0]*this.x+A[1]*this.y,this.y=l,this},_add:function(A){return this.x+=A.x,this.y+=A.y,this},_sub:function(A){return this.x-=A.x,this.y-=A.y,this},_mult:function(A){return this.x*=A,this.y*=A,this},_div:function(A){return this.x/=A,this.y/=A,this},_multByPoint:function(A){return this.x*=A.x,this.y*=A.y,this},_divByPoint:function(A){return this.x/=A.x,this.y/=A.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var A=this.y;return this.y=this.x,this.x=-A,this},_rotate:function(A){var l=Math.cos(A),f=Math.sin(A),w=f*this.x+l*this.y;return this.x=l*this.x-f*this.y,this.y=w,this},_rotateAround:function(A,l){var f=Math.cos(A),w=Math.sin(A),I=l.y+w*(this.x-l.x)+f*(this.y-l.y);return this.x=l.x+f*(this.x-l.x)-w*(this.y-l.y),this.y=I,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},ze.convert=function(A){return A instanceof ze?A:Array.isArray(A)?new ze(A[0],A[1]):A};const Ne={MAX_PARALLEL_IMAGE_REQUESTS:16,REGISTERED_PROTOCOLS:{}},Ge="mapbox-tiles";let Ve,Le,Ie=500,qe=50;function et(){typeof caches>"u"||Ve||(Ve=caches.open(Ge))}let vt=1/0;const Be={supported:!1,testSupport:function(A){!Qt&&ut&&(Wt?Nt(A):dt=A)}};let dt,ut,Qt=!1,Wt=!1;function Nt(A){const l=A.createTexture();A.bindTexture(A.TEXTURE_2D,l);try{if(A.texImage2D(A.TEXTURE_2D,0,A.RGBA,A.RGBA,A.UNSIGNED_BYTE,ut),A.isContextLost())return;Be.supported=!0}catch{}A.deleteTexture(l),Qt=!0}typeof document<"u"&&(ut=document.createElement("img"),ut.onload=function(){dt&&Nt(dt),dt=null,Wt=!0},ut.onerror=function(){Qt=!0,dt=null},ut.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ct={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(Ct);class Ft extends Error{constructor(l,f,w,I){super(`AJAXError: ${f} (${l}): ${w}`),this.status=l,this.statusText=f,this.url=w,this.body=I}}const Xt=Me()?()=>self.worker&&self.worker.referrer:()=>(window.location.protocol==="blob:"?window.parent:window).location.href;function mi(A,l){const f=new AbortController,w=new Request(A.url,{method:A.method||"GET",body:A.body,credentials:A.credentials,headers:A.headers,referrer:Xt(),signal:f.signal});let I=!1,z=!1;return A.type==="json"&&w.headers.set("Accept","application/json"),((Q,Z,re)=>{if(z)return;const ge=Date.now();fetch(w).then(Ce=>Ce.ok?((Fe,Oe,je)=>{(A.type==="arrayBuffer"?Fe.arrayBuffer():A.type==="json"?Fe.json():Fe.text()).then($e=>{z||(Oe&&je&&function(Rt,Mt,ri){if(et(),!Ve)return;const gi={status:Mt.status,statusText:Mt.statusText,headers:new Headers};Mt.headers.forEach((ui,Pi)=>gi.headers.set(Pi,ui));const ei=Ke(Mt.headers.get("Cache-Control")||"");ei["no-store"]||(ei["max-age"]&&gi.headers.set("Expires",new Date(ri+1e3*ei["max-age"]).toUTCString()),new Date(gi.headers.get("Expires")).getTime()-ri<42e4||function(ui,Pi){if(Le===void 0)try{new Response(new ReadableStream),Le=!0}catch{Le=!1}Le?Pi(ui.body):ui.blob().then(Pi)}(Mt,ui=>{const Pi=new Response(ui,gi);et(),Ve&&Ve.then(Fi=>Fi.put(function(Sn){const fn=Sn.indexOf("?");return fn<0?Sn:Sn.slice(0,fn)}(Rt.url),Pi)).catch(Fi=>me(Fi.message))}))}(w,Oe,je),I=!0,l(null,$e,Fe.headers.get("Cache-Control"),Fe.headers.get("Expires")))}).catch($e=>{z||l(new Error($e.message))})})(Ce,null,ge):Ce.blob().then(Fe=>l(new Ft(Ce.status,Ce.statusText,A.url,Fe)))).catch(Ce=>{Ce.code!==20&&l(new Error(Ce.message))})})(),{cancel:()=>{z=!0,I||f.abort()}}}const fi=function(A,l){if(/:\/\//.test(A.url)&&!/^https?:|^file:/.test(A.url)){if(Me()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",A,l);if(!Me()){const w=A.url.substring(0,A.url.indexOf("://"));return(Ne.REGISTERED_PROTOCOLS[w]||mi)(A,l)}}if(!(/^file:/.test(f=A.url)||/^file:/.test(Xt())&&!/^\w+:/.test(f))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return mi(A,l);if(Me()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",A,l,void 0,!0)}var f;return function(w,I){const z=new XMLHttpRequest;z.open(w.method||"GET",w.url,!0),w.type==="arrayBuffer"&&(z.responseType="arraybuffer");for(const Q in w.headers)z.setRequestHeader(Q,w.headers[Q]);return w.type==="json"&&(z.responseType="text",z.setRequestHeader("Accept","application/json")),z.withCredentials=w.credentials==="include",z.onerror=()=>{I(new Error(z.statusText))},z.onload=()=>{if((z.status>=200&&z.status<300||z.status===0)&&z.response!==null){let Q=z.response;if(w.type==="json")try{Q=JSON.parse(z.response)}catch(Z){return I(Z)}I(null,Q,z.getResponseHeader("Cache-Control"),z.getResponseHeader("Expires"))}else{const Q=new Blob([z.response],{type:z.getResponseHeader("Content-Type")});I(new Ft(z.status,z.statusText,w.url,Q))}},z.send(w.body),{cancel:()=>z.abort()}}(A,l)},Gi=function(A,l){return fi(J(A,{type:"arrayBuffer"}),l)};function wn(A){const l=window.document.createElement("a");return l.href=A,l.protocol===window.document.location.protocol&&l.host===window.document.location.host}const Qi="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Gn,kn;Gn=[],kn=0;const yt=function(A,l){if(Be.supported&&(A.headers||(A.headers={}),A.headers.accept="image/webp,*/*"),kn>=Ne.MAX_PARALLEL_IMAGE_REQUESTS){const z={requestParameters:A,callback:l,cancelled:!1,cancel(){this.cancelled=!0}};return Gn.push(z),z}kn++;let f=!1;const w=()=>{if(!f)for(f=!0,kn--;Gn.length&&kn{w(),z?l(z):Q&&function(ge,Ce){typeof createImageBitmap=="function"?function(Fe,Oe){const je=new Blob([new Uint8Array(Fe)],{type:"image/png"});createImageBitmap(je).then($e=>{Oe(null,$e)}).catch($e=>{Oe(new Error(`Could not load image because of ${$e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(ge,Ce):function(Fe,Oe){const je=new Image;je.onload=()=>{Oe(null,je),URL.revokeObjectURL(je.src),je.onload=null,window.requestAnimationFrame(()=>{je.src=Qi})},je.onerror=()=>Oe(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 $e=new Blob([new Uint8Array(Fe)],{type:"image/png"});je.src=Fe.byteLength?URL.createObjectURL($e):Qi}(ge,Ce)}(Q,(ge,Ce)=>{ge!=null?l(ge):Ce!=null&&l(null,Ce,{cacheControl:Z,expires:re})})});return{cancel:()=>{I.cancel(),w()}}};function st(A,l,f){f[A]&&f[A].indexOf(l)!==-1||(f[A]=f[A]||[],f[A].push(l))}function ti(A,l,f){if(f&&f[A]){const w=f[A].indexOf(l);w!==-1&&f[A].splice(w,1)}}class Ni{constructor(l,f={}){J(this,f),this.type=l}}class qi extends Ni{constructor(l,f={}){super("error",J({error:l},f))}}class en{on(l,f){return this._listeners=this._listeners||{},st(l,f,this._listeners),this}off(l,f){return ti(l,f,this._listeners),ti(l,f,this._oneTimeListeners),this}once(l,f){return this._oneTimeListeners=this._oneTimeListeners||{},st(l,f,this._oneTimeListeners),this}fire(l,f){typeof l=="string"&&(l=new Ni(l,f||{}));const w=l.type;if(this.listens(w)){l.target=this;const I=this._listeners&&this._listeners[w]?this._listeners[w].slice():[];for(const Z of I)Z.call(this,l);const z=this._oneTimeListeners&&this._oneTimeListeners[w]?this._oneTimeListeners[w].slice():[];for(const Z of z)ti(w,Z,this._oneTimeListeners),Z.call(this,l);const Q=this._eventedParent;Q&&(J(l,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),Q.fire(l))}else l instanceof qi&&console.error(l.error);return this}listens(l){return this._listeners&&this._listeners[l]&&this._listeners[l].length>0||this._oneTimeListeners&&this._oneTimeListeners[l]&&this._oneTimeListeners[l].length>0||this._eventedParent&&this._eventedParent.listens(l)}setEventedParent(l,f){return this._eventedParent=l,this._eventedParentData=f,this}}var $t={$version:8,$root:{version:{required:!0,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"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,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:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","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_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:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1},elevationOffset:{type:"number",default:450}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};class at{constructor(l,f,w,I){this.message=(l?`${l}: `:"")+w,I&&(this.identifier=I),f!=null&&f.__line__&&(this.line=f.__line__)}}function ii(A){const l=A.value;return l?[new at(A.key,l,"constants have been deprecated as of v8")]:[]}function hn(A,...l){for(const f of l)for(const w in f)A[w]=f[w];return A}function Xi(A){return A instanceof Number||A instanceof String||A instanceof Boolean?A.valueOf():A}function on(A){if(Array.isArray(A))return A.map(on);if(A instanceof Object&&!(A instanceof Number||A instanceof String||A instanceof Boolean)){const l={};for(const f in A)l[f]=on(A[f]);return l}return Xi(A)}class Cn extends Error{constructor(l,f){super(f),this.message=f,this.key=l}}class Tn{constructor(l,f=[]){this.parent=l,this.bindings={};for(const[w,I]of f)this.bindings[w]=I}concat(l){return new Tn(this,l)}get(l){if(this.bindings[l])return this.bindings[l];if(this.parent)return this.parent.get(l);throw new Error(`${l} not found in scope.`)}has(l){return!!this.bindings[l]||!!this.parent&&this.parent.has(l)}}const nr={kind:"null"},Ii={kind:"number"},bn={kind:"string"},Ot={kind:"boolean"},vi={kind:"color"},Wi={kind:"object"},Ui={kind:"value"},Pn={kind:"collator"},qn={kind:"formatted"},Hr={kind:"padding"},fr={kind:"resolvedImage"};function kr(A,l){return{kind:"array",itemType:A,N:l}}function Qn(A){if(A.kind==="array"){const l=Qn(A.itemType);return typeof A.N=="number"?`array<${l}, ${A.N}>`:A.itemType.kind==="value"?"array":`array<${l}>`}return A.kind}const zs=[nr,Ii,bn,Ot,vi,qn,Wi,kr(Ui),Hr,fr];function ot(A,l){if(l.kind==="error")return null;if(A.kind==="array"){if(l.kind==="array"&&(l.N===0&&l.itemType.kind==="value"||!ot(A.itemType,l.itemType))&&(typeof A.N!="number"||A.N===l.N))return null}else{if(A.kind===l.kind)return null;if(A.kind==="value"){for(const f of zs)if(!ot(f,l))return null}}return`Expected ${Qn(A)} but found ${Qn(l)} instead.`}function Ee(A,l){return l.some(f=>f.kind===A.kind)}function Ue(A,l){return l.some(f=>f==="null"?A===null:f==="array"?Array.isArray(A):f==="object"?A&&!Array.isArray(A)&&typeof A=="object":f===typeof A)}var ct,wt={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 X(A){return(A=Math.round(A))<0?0:A>255?255:A}function j(A){return X(A[A.length-1]==="%"?parseFloat(A)/100*255:parseInt(A))}function ie(A){return(l=A[A.length-1]==="%"?parseFloat(A)/100:parseFloat(A))<0?0:l>1?1:l;var l}function ne(A,l,f){return f<0?f+=1:f>1&&(f-=1),6*f<1?A+(l-A)*f*6:2*f<1?l:3*f<2?A+(l-A)*(2/3-f)*6:A}try{ct={}.parseCSSColor=function(A){var l,f=A.replace(/ /g,"").toLowerCase();if(f in wt)return wt[f].slice();if(f[0]==="#")return f.length===4?(l=parseInt(f.substr(1),16))>=0&&l<=4095?[(3840&l)>>4|(3840&l)>>8,240&l|(240&l)>>4,15&l|(15&l)<<4,1]:null:f.length===7&&(l=parseInt(f.substr(1),16))>=0&&l<=16777215?[(16711680&l)>>16,(65280&l)>>8,255&l,1]:null;var w=f.indexOf("("),I=f.indexOf(")");if(w!==-1&&I+1===f.length){var z=f.substr(0,w),Q=f.substr(w+1,I-(w+1)).split(","),Z=1;switch(z){case"rgba":if(Q.length!==4)return null;Z=ie(Q.pop());case"rgb":return Q.length!==3?null:[j(Q[0]),j(Q[1]),j(Q[2]),Z];case"hsla":if(Q.length!==4)return null;Z=ie(Q.pop());case"hsl":if(Q.length!==3)return null;var re=(parseFloat(Q[0])%360+360)%360/360,ge=ie(Q[1]),Ce=ie(Q[2]),Fe=Ce<=.5?Ce*(ge+1):Ce+ge-Ce*ge,Oe=2*Ce-Fe;return[X(255*ne(Oe,Fe,re+1/3)),X(255*ne(Oe,Fe,re)),X(255*ne(Oe,Fe,re-1/3)),Z];default:return null}}return null}}catch{}class de{constructor(l,f,w,I=1){this.r=l,this.g=f,this.b=w,this.a=I}static parse(l){if(!l)return;if(l instanceof de)return l;if(typeof l!="string")return;const f=ct(l);return f?new de(f[0]/255*f[3],f[1]/255*f[3],f[2]/255*f[3],f[3]):void 0}toString(){const[l,f,w,I]=this.toArray();return`rgba(${Math.round(l)},${Math.round(f)},${Math.round(w)},${I})`}toArray(){const{r:l,g:f,b:w,a:I}=this;return I===0?[0,0,0,0]:[255*l/I,255*f/I,255*w/I,I]}}de.black=new de(0,0,0,1),de.white=new de(1,1,1,1),de.transparent=new de(0,0,0,0),de.red=new de(1,0,0,1);class Re{constructor(l,f,w){this.sensitivity=l?f?"variant":"case":f?"accent":"base",this.locale=w,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(l,f){return this.collator.compare(l,f)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class tt{constructor(l,f,w,I,z){this.text=l,this.image=f,this.scale=w,this.fontStack=I,this.textColor=z}}class He{constructor(l){this.sections=l}static fromString(l){return new He([new tt(l,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(l=>l.text.length!==0||l.image&&l.image.name.length!==0)}static factory(l){return l instanceof He?l:He.fromString(l)}toString(){return this.sections.length===0?"":this.sections.map(l=>l.text).join("")}}class Je{constructor(l){this.values=l.slice()}static parse(l){if(l instanceof Je)return l;if(typeof l=="number")return new Je([l,l,l,l]);if(Array.isArray(l)&&!(l.length<1||l.length>4)){for(const f of l)if(typeof f!="number")return;switch(l.length){case 1:l=[l[0],l[0],l[0],l[0]];break;case 2:l=[l[0],l[1],l[0],l[1]];break;case 3:l=[l[0],l[1],l[2],l[1]]}return new Je(l)}}toString(){return JSON.stringify(this.values)}}class pt{constructor(l){this.name=l.name,this.available=l.available}toString(){return this.name}static fromString(l){return l?new pt({name:l,available:!1}):null}}function Lt(A,l,f,w){return typeof A=="number"&&A>=0&&A<=255&&typeof l=="number"&&l>=0&&l<=255&&typeof f=="number"&&f>=0&&f<=255?w===void 0||typeof w=="number"&&w>=0&&w<=1?null:`Invalid rgba value [${[A,l,f,w].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof w=="number"?[A,l,f,w]:[A,l,f]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function jt(A){if(A===null||typeof A=="string"||typeof A=="boolean"||typeof A=="number"||A instanceof de||A instanceof Re||A instanceof He||A instanceof Je||A instanceof pt)return!0;if(Array.isArray(A)){for(const l of A)if(!jt(l))return!1;return!0}if(typeof A=="object"){for(const l in A)if(!jt(A[l]))return!1;return!0}return!1}function Gt(A){if(A===null)return nr;if(typeof A=="string")return bn;if(typeof A=="boolean")return Ot;if(typeof A=="number")return Ii;if(A instanceof de)return vi;if(A instanceof Re)return Pn;if(A instanceof He)return qn;if(A instanceof Je)return Hr;if(A instanceof pt)return fr;if(Array.isArray(A)){const l=A.length;let f;for(const w of A){const I=Gt(w);if(f){if(f===I)continue;f=Ui;break}f=I}return kr(f||Ui,l)}return Wi}function ki(A){const l=typeof A;return A===null?"":l==="string"||l==="number"||l==="boolean"?String(A):A instanceof de||A instanceof He||A instanceof Je||A instanceof pt?A.toString():JSON.stringify(A)}class wi{constructor(l,f){this.type=l,this.value=f}static parse(l,f){if(l.length!==2)return f.error(`'literal' expression requires exactly one argument, but found ${l.length-1} instead.`);if(!jt(l[1]))return f.error("invalid value");const w=l[1];let I=Gt(w);const z=f.expectedType;return I.kind!=="array"||I.N!==0||!z||z.kind!=="array"||typeof z.N=="number"&&z.N!==0||(I=z),new wi(I,w)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Oi{constructor(l){this.name="ExpressionEvaluationError",this.message=l}toJSON(){return this.message}}const Yi={string:bn,number:Ii,boolean:Ot,object:Wi};class tn{constructor(l,f){this.type=l,this.args=f}static parse(l,f){if(l.length<2)return f.error("Expected at least one argument.");let w,I=1;const z=l[0];if(z==="array"){let Z,re;if(l.length>2){const ge=l[1];if(typeof ge!="string"||!(ge in Yi)||ge==="object")return f.error('The item type argument of "array" must be one of string, number, boolean',1);Z=Yi[ge],I++}else Z=Ui;if(l.length>3){if(l[2]!==null&&(typeof l[2]!="number"||l[2]<0||l[2]!==Math.floor(l[2])))return f.error('The length argument to "array" must be a positive integer literal',2);re=l[2],I++}w=kr(Z,re)}else{if(!Yi[z])throw new Error(`Types doesn't contain name = ${z}`);w=Yi[z]}const Q=[];for(;Il.outputDefined())}}const rr={"to-boolean":Ot,"to-color":vi,"to-number":Ii,"to-string":bn};class yn{constructor(l,f){this.type=l,this.args=f}static parse(l,f){if(l.length<2)return f.error("Expected at least one argument.");const w=l[0];if(!rr[w])throw new Error(`Can't parse ${w} as it is not part of the known types`);if((w==="to-boolean"||w==="to-string")&&l.length!==2)return f.error("Expected one argument.");const I=rr[w],z=[];for(let Q=1;Q4?`Invalid rbga value ${JSON.stringify(f)}: expected an array containing either three or four numeric values.`:Lt(f[0],f[1],f[2],f[3]),!w))return new de(f[0]/255,f[1]/255,f[2]/255,f[3])}throw new Oi(w||`Could not parse color from value '${typeof f=="string"?f:JSON.stringify(f)}'`)}if(this.type.kind==="padding"){let f;for(const w of this.args){f=w.evaluate(l);const I=Je.parse(f);if(I)return I}throw new Oi(`Could not parse padding from value '${typeof f=="string"?f:JSON.stringify(f)}'`)}if(this.type.kind==="number"){let f=null;for(const w of this.args){if(f=w.evaluate(l),f===null)return 0;const I=Number(f);if(!isNaN(I))return I}throw new Oi(`Could not convert ${JSON.stringify(f)} to number.`)}return this.type.kind==="formatted"?He.fromString(ki(this.args[0].evaluate(l))):this.type.kind==="resolvedImage"?pt.fromString(ki(this.args[0].evaluate(l))):ki(this.args[0].evaluate(l))}eachChild(l){this.args.forEach(l)}outputDefined(){return this.args.every(l=>l.outputDefined())}}const Yt=["Unknown","Point","LineString","Polygon"];class sr{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Yt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(l){let f=this._parseColorCache[l];return f||(f=this._parseColorCache[l]=de.parse(l)),f}}class Yn{constructor(l,f,w,I){this.name=l,this.type=f,this._evaluate=w,this.args=I}evaluate(l){return this._evaluate(l,this.args)}eachChild(l){this.args.forEach(l)}outputDefined(){return!1}static parse(l,f){const w=l[0],I=Yn.definitions[w];if(!I)return f.error(`Unknown expression "${w}". If you wanted a literal array, use ["literal", [...]].`,0);const z=Array.isArray(I)?I[0]:I.type,Q=Array.isArray(I)?[[I[1],I[2]]]:I.overloads,Z=Q.filter(([ge])=>!Array.isArray(ge)||ge.length===l.length-1);let re=null;for(const[ge,Ce]of Z){re=new Ol(f.registry,f.path,null,f.scope);const Fe=[];let Oe=!1;for(let je=1;je{return Oe=Fe,Array.isArray(Oe)?`(${Oe.map(Qn).join(", ")})`:`(${Qn(Oe.type)}...)`;var Oe}).join(" | "),Ce=[];for(let Fe=1;Fe=l[2]||A[1]<=l[1]||A[3]>=l[3])}function ks(A,l){const f=(180+A[0])/360,w=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+A[1]*Math.PI/360)))/360,I=Math.pow(2,l.z);return[Math.round(f*I*mr),Math.round(w*I*mr)]}function or(A,l,f){const w=A[0]-l[0],I=A[1]-l[1],z=A[0]-f[0],Q=A[1]-f[1];return w*Q-z*I==0&&w*z<=0&&I*Q<=0}function rn(A,l){let f=!1;for(let Q=0,Z=l.length;Q(w=A)[1]!=(z=re[ge+1])[1]>w[1]&&w[0]<(z[0]-I[0])*(w[1]-I[1])/(z[1]-I[1])+I[0]&&(f=!f)}}var w,I,z;return f}function cr(A,l){for(let f=0;f0&&Z<0||Q<0&&Z>0}function la(A,l,f){for(const ge of f)for(let Ce=0;Cef[2]){const I=.5*w;let z=A[0]-f[0]>I?-w:f[0]-A[0]>I?w:0;z===0&&(z=A[0]-f[2]>I?-w:f[2]-A[0]>I?w:0),A[0]+=z}Mr(l,A)}function qs(A,l,f,w){const I=Math.pow(2,w.z)*mr,z=[w.x*mr,w.y*mr],Q=[];for(const Z of A)for(const re of Z){const ge=[re.x+z[0],re.y+z[1]];ll(ge,l,f,I),Q.push(ge)}return Q}function hs(A,l,f,w){const I=Math.pow(2,w.z)*mr,z=[w.x*mr,w.y*mr],Q=[];for(const re of A){const ge=[];for(const Ce of re){const Fe=[Ce.x+z[0],Ce.y+z[1]];Mr(l,Fe),ge.push(Fe)}Q.push(ge)}if(l[2]-l[0]<=I/2){(Z=l)[0]=Z[1]=1/0,Z[2]=Z[3]=-1/0;for(const re of Q)for(const ge of re)ll(ge,l,f,I)}var Z;return Q}class ho{constructor(l,f){this.type=Ot,this.geojson=l,this.geometries=f}static parse(l,f){if(l.length!==2)return f.error(`'within' expression requires exactly one argument, but found ${l.length-1} instead.`);if(jt(l[1])){const w=l[1];if(w.type==="FeatureCollection")for(let I=0;I{l&&!cl(f)&&(l=!1)}),l}function Na(A){if(A instanceof Yn&&A.name==="feature-state")return!1;let l=!0;return A.eachChild(f=>{l&&!Na(f)&&(l=!1)}),l}function zl(A,l){if(A instanceof Yn&&l.indexOf(A.name)>=0)return!1;let f=!0;return A.eachChild(w=>{f&&!zl(w,l)&&(f=!1)}),f}class kl{constructor(l,f){this.type=f.type,this.name=l,this.boundExpression=f}static parse(l,f){if(l.length!==2||typeof l[1]!="string")return f.error("'var' expression requires exactly one string literal argument.");const w=l[1];return f.scope.has(w)?new kl(w,f.scope.get(w)):f.error(`Unknown variable "${w}". Make sure "${w}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(l){return this.boundExpression.evaluate(l)}eachChild(){}outputDefined(){return!1}}class Ol{constructor(l,f=[],w,I=new Tn,z=[]){this.registry=l,this.path=f,this.key=f.map(Q=>`[${Q}]`).join(""),this.scope=I,this.errors=z,this.expectedType=w}parse(l,f,w,I,z={}){return f?this.concat(f,w,I)._parse(l,z):this._parse(l,z)}_parse(l,f){function w(I,z,Q){return Q==="assert"?new tn(z,[I]):Q==="coerce"?new yn(z,[I]):I}if(l!==null&&typeof l!="string"&&typeof l!="boolean"&&typeof l!="number"||(l=["literal",l]),Array.isArray(l)){if(l.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const I=l[0];if(typeof I!="string")return this.error(`Expression name must be a string, but found ${typeof I} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const z=this.registry[I];if(z){let Q=z.parse(l,this);if(!Q)return null;if(this.expectedType){const Z=this.expectedType,re=Q.type;if(Z.kind!=="string"&&Z.kind!=="number"&&Z.kind!=="boolean"&&Z.kind!=="object"&&Z.kind!=="array"||re.kind!=="value")if(Z.kind!=="color"&&Z.kind!=="formatted"&&Z.kind!=="resolvedImage"||re.kind!=="value"&&re.kind!=="string")if(Z.kind!=="padding"||re.kind!=="value"&&re.kind!=="number"&&re.kind!=="array"){if(this.checkSubtype(Z,re))return null}else Q=w(Q,Z,f.typeAnnotation||"coerce");else Q=w(Q,Z,f.typeAnnotation||"coerce");else Q=w(Q,Z,f.typeAnnotation||"assert")}if(!(Q instanceof wi)&&Q.type.kind!=="resolvedImage"&&Qa(Q)){const Z=new sr;try{Q=new wi(Q.type,Q.evaluate(Z))}catch(re){return this.error(re.message),null}}return Q}return this.error(`Unknown expression "${I}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(l===void 0?"'undefined' value invalid. Use null instead.":typeof l=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof l} instead.`)}concat(l,f,w){const I=typeof l=="number"?this.path.concat(l):this.path,z=w?this.scope.concat(w):this.scope;return new Ol(this.registry,I,f||null,z,this.errors)}error(l,...f){const w=`${this.key}${f.map(I=>`[${I}]`).join("")}`;this.errors.push(new Cn(w,l))}checkSubtype(l,f){const w=ot(l,f);return w&&this.error(w),w}}function Qa(A){if(A instanceof kl)return Qa(A.boundExpression);if(A instanceof Yn&&A.name==="error"||A instanceof Wr||A instanceof ho)return!1;const l=A instanceof yn||A instanceof tn;let f=!0;return A.eachChild(w=>{f=l?f&&Qa(w):f&&w instanceof wi}),!!f&&cl(A)&&zl(A,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Nl(A,l){const f=A.length-1;let w,I,z=0,Q=f,Z=0;for(;z<=Q;)if(Z=Math.floor((z+Q)/2),w=A[Z],I=A[Z+1],w<=l){if(Z===f||ll))throw new Oi("Input is not a number.");Q=Z-1}return 0}class Ql{constructor(l,f,w){this.type=l,this.input=f,this.labels=[],this.outputs=[];for(const[I,z]of w)this.labels.push(I),this.outputs.push(z)}static parse(l,f){if(l.length-1<4)return f.error(`Expected at least 4 arguments, but found only ${l.length-1}.`);if((l.length-1)%2!=0)return f.error("Expected an even number of arguments.");const w=f.parse(l[1],1,Ii);if(!w)return null;const I=[];let z=null;f.expectedType&&f.expectedType.kind!=="value"&&(z=f.expectedType);for(let Q=1;Q=Z)return f.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',ge);const Fe=f.parse(re,Ce,z);if(!Fe)return null;z=z||Fe.type,I.push([Z,Fe])}return new Ql(z,w,I)}evaluate(l){const f=this.labels,w=this.outputs;if(f.length===1)return w[0].evaluate(l);const I=this.input.evaluate(l);if(I<=f[0])return w[0].evaluate(l);const z=f.length;return I>=f[z-1]?w[z-1].evaluate(l):w[Nl(f,I)].evaluate(l)}eachChild(l){l(this.input);for(const f of this.outputs)l(f)}outputDefined(){return this.outputs.every(l=>l.outputDefined())}}function ns(A,l,f){return A*(1-f)+l*f}var Ys=Object.freeze({__proto__:null,number:ns,color:function(A,l,f){return new de(ns(A.r,l.r,f),ns(A.g,l.g,f),ns(A.b,l.b,f),ns(A.a,l.a,f))},array:function(A,l,f){return A.map((w,I)=>ns(w,l[I],f))},padding:function(A,l,f){const w=A.values,I=l.values;return new Je([ns(w[0],I[0],f),ns(w[1],I[1],f),ns(w[2],I[2],f),ns(w[3],I[3],f)])}});const fs=.95047,Rc=1.08883,Eh=4/29,Os=6/29,No=3*Os*Os,ed=Math.PI/180,pu=180/Math.PI;function Cs(A){return A>.008856451679035631?Math.pow(A,1/3):A/No+Eh}function rc(A){return A>Os?A*A*A:No*(A-Eh)}function Th(A){return 255*(A<=.0031308?12.92*A:1.055*Math.pow(A,1/2.4)-.055)}function sc(A){return(A/=255)<=.04045?A/12.92:Math.pow((A+.055)/1.055,2.4)}function er(A){const l=sc(A.r),f=sc(A.g),w=sc(A.b),I=Cs((.4124564*l+.3575761*f+.1804375*w)/fs),z=Cs((.2126729*l+.7151522*f+.072175*w)/1);return{l:116*z-16,a:500*(I-z),b:200*(z-Cs((.0193339*l+.119192*f+.9503041*w)/Rc)),alpha:A.a}}function oc(A){let l=(A.l+16)/116,f=isNaN(A.a)?l:l+A.a/500,w=isNaN(A.b)?l:l-A.b/200;return l=1*rc(l),f=fs*rc(f),w=Rc*rc(w),new de(Th(3.2404542*f-1.5371385*l-.4985314*w),Th(-.969266*f+1.8760108*l+.041556*w),Th(.0556434*f-.2040259*l+1.0572252*w),A.alpha)}function Ju(A,l,f){const w=l-A;return A+f*(w>180||w<-180?w-360*Math.round(w/360):w)}const Qo={forward:er,reverse:oc,interpolate:function(A,l,f){return{l:ns(A.l,l.l,f),a:ns(A.a,l.a,f),b:ns(A.b,l.b,f),alpha:ns(A.alpha,l.alpha,f)}}},hl={forward:function(A){const{l,a:f,b:w}=er(A),I=Math.atan2(w,f)*pu;return{h:I<0?I+360:I,c:Math.sqrt(f*f+w*w),l,alpha:A.a}},reverse:function(A){const l=A.h*ed,f=A.c;return oc({l:A.l,a:Math.cos(l)*f,b:Math.sin(l)*f,alpha:A.alpha})},interpolate:function(A,l,f){return{h:Ju(A.h,l.h,f),c:ns(A.c,l.c,f),l:ns(A.l,l.l,f),alpha:ns(A.alpha,l.alpha,f)}}};var Sh=Object.freeze({__proto__:null,lab:Qo,hcl:hl});class Vo{constructor(l,f,w,I,z){this.type=l,this.operator=f,this.interpolation=w,this.input=I,this.labels=[],this.outputs=[];for(const[Q,Z]of z)this.labels.push(Q),this.outputs.push(Z)}static interpolationFactor(l,f,w,I){let z=0;if(l.name==="exponential")z=Mh(f,l.base,w,I);else if(l.name==="linear")z=Mh(f,1,w,I);else if(l.name==="cubic-bezier"){const Q=l.controlPoints;z=new C(Q[0],Q[1],Q[2],Q[3]).solve(Mh(f,1,w,I))}return z}static parse(l,f){let[w,I,z,...Q]=l;if(!Array.isArray(I)||I.length===0)return f.error("Expected an interpolation type expression.",1);if(I[0]==="linear")I={name:"linear"};else if(I[0]==="exponential"){const ge=I[1];if(typeof ge!="number")return f.error("Exponential interpolation requires a numeric base.",1,1);I={name:"exponential",base:ge}}else{if(I[0]!=="cubic-bezier")return f.error(`Unknown interpolation type ${String(I[0])}`,1,0);{const ge=I.slice(1);if(ge.length!==4||ge.some(Ce=>typeof Ce!="number"||Ce<0||Ce>1))return f.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);I={name:"cubic-bezier",controlPoints:ge}}}if(l.length-1<4)return f.error(`Expected at least 4 arguments, but found only ${l.length-1}.`);if((l.length-1)%2!=0)return f.error("Expected an even number of arguments.");if(z=f.parse(z,2,Ii),!z)return null;const Z=[];let re=null;w==="interpolate-hcl"||w==="interpolate-lab"?re=vi:f.expectedType&&f.expectedType.kind!=="value"&&(re=f.expectedType);for(let ge=0;ge=Ce)return f.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',Oe);const $e=f.parse(Fe,je,re);if(!$e)return null;re=re||$e.type,Z.push([Ce,$e])}return re.kind==="number"||re.kind==="color"||re.kind==="padding"||re.kind==="array"&&re.itemType.kind==="number"&&typeof re.N=="number"?new Vo(re,w,I,z,Z):f.error(`Type ${Qn(re)} is not interpolatable.`)}evaluate(l){const f=this.labels,w=this.outputs;if(f.length===1)return w[0].evaluate(l);const I=this.input.evaluate(l);if(I<=f[0])return w[0].evaluate(l);const z=f.length;if(I>=f[z-1])return w[z-1].evaluate(l);const Q=Nl(f,I),Z=Vo.interpolationFactor(this.interpolation,I,f[Q],f[Q+1]),re=w[Q].evaluate(l),ge=w[Q+1].evaluate(l);return this.operator==="interpolate"?Ys[this.type.kind.toLowerCase()](re,ge,Z):this.operator==="interpolate-hcl"?hl.reverse(hl.interpolate(hl.forward(re),hl.forward(ge),Z)):Qo.reverse(Qo.interpolate(Qo.forward(re),Qo.forward(ge),Z))}eachChild(l){l(this.input);for(const f of this.outputs)l(f)}outputDefined(){return this.outputs.every(l=>l.outputDefined())}}function Mh(A,l,f,w){const I=w-f,z=A-f;return I===0?0:l===1?z/I:(Math.pow(l,z)-1)/(Math.pow(l,I)-1)}class Va{constructor(l,f){this.type=l,this.args=f}static parse(l,f){if(l.length<2)return f.error("Expectected at least one argument.");let w=null;const I=f.expectedType;I&&I.kind!=="value"&&(w=I);const z=[];for(const Z of l.slice(1)){const re=f.parse(Z,1+z.length,w,void 0,{typeAnnotation:"omit"});if(!re)return null;w=w||re.type,z.push(re)}if(!w)throw new Error("No output type");const Q=I&&z.some(Z=>ot(I,Z.type));return new Va(Q?Ui:w,z)}evaluate(l){let f,w=null,I=0;for(const z of this.args)if(I++,w=z.evaluate(l),w&&w instanceof pt&&!w.available&&(f||(f=w.name),w=null,I===this.args.length&&(w=f)),w!==null)break;return w}eachChild(l){this.args.forEach(l)}outputDefined(){return this.args.every(l=>l.outputDefined())}}class ac{constructor(l,f){this.type=f.type,this.bindings=[].concat(l),this.result=f}evaluate(l){return this.result.evaluate(l)}eachChild(l){for(const f of this.bindings)l(f[1]);l(this.result)}static parse(l,f){if(l.length<4)return f.error(`Expected at least 3 arguments, but found ${l.length-1} instead.`);const w=[];for(let z=1;z=w.length)throw new Oi(`Array index out of bounds: ${f} > ${w.length-1}.`);if(f!==Math.floor(f))throw new Oi(`Array index must be an integer, but found ${f} instead.`);return w[f]}eachChild(l){l(this.index),l(this.input)}outputDefined(){return!1}}class Vl{constructor(l,f){this.type=Ot,this.needle=l,this.haystack=f}static parse(l,f){if(l.length!==3)return f.error(`Expected 2 arguments, but found ${l.length-1} instead.`);const w=f.parse(l[1],1,Ui),I=f.parse(l[2],2,Ui);return w&&I?Ee(w.type,[Ot,bn,Ii,nr,Ui])?new Vl(w,I):f.error(`Expected first argument to be of type boolean, string, number or null, but found ${Qn(w.type)} instead`):null}evaluate(l){const f=this.needle.evaluate(l),w=this.haystack.evaluate(l);if(!w)return!1;if(!Ue(f,["boolean","string","number","null"]))throw new Oi(`Expected first argument to be of type boolean, string, number or null, but found ${Qn(Gt(f))} instead.`);if(!Ue(w,["string","array"]))throw new Oi(`Expected second argument to be of type array or string, but found ${Qn(Gt(w))} instead.`);return w.indexOf(f)>=0}eachChild(l){l(this.needle),l(this.haystack)}outputDefined(){return!0}}class ya{constructor(l,f,w){this.type=Ii,this.needle=l,this.haystack=f,this.fromIndex=w}static parse(l,f){if(l.length<=2||l.length>=5)return f.error(`Expected 3 or 4 arguments, but found ${l.length-1} instead.`);const w=f.parse(l[1],1,Ui),I=f.parse(l[2],2,Ui);if(!w||!I)return null;if(!Ee(w.type,[Ot,bn,Ii,nr,Ui]))return f.error(`Expected first argument to be of type boolean, string, number or null, but found ${Qn(w.type)} instead`);if(l.length===4){const z=f.parse(l[3],3,Ii);return z?new ya(w,I,z):null}return new ya(w,I)}evaluate(l){const f=this.needle.evaluate(l),w=this.haystack.evaluate(l);if(!Ue(f,["boolean","string","number","null"]))throw new Oi(`Expected first argument to be of type boolean, string, number or null, but found ${Qn(Gt(f))} instead.`);if(!Ue(w,["string","array"]))throw new Oi(`Expected second argument to be of type array or string, but found ${Qn(Gt(w))} instead.`);if(this.fromIndex){const I=this.fromIndex.evaluate(l);return w.indexOf(f,I)}return w.indexOf(f)}eachChild(l){l(this.needle),l(this.haystack),this.fromIndex&&l(this.fromIndex)}outputDefined(){return!1}}class zc{constructor(l,f,w,I,z,Q){this.inputType=l,this.type=f,this.input=w,this.cases=I,this.outputs=z,this.otherwise=Q}static parse(l,f){if(l.length<5)return f.error(`Expected at least 4 arguments, but found only ${l.length-1}.`);if(l.length%2!=1)return f.error("Expected an even number of arguments.");let w,I;f.expectedType&&f.expectedType.kind!=="value"&&(I=f.expectedType);const z={},Q=[];for(let ge=2;geNumber.MAX_SAFE_INTEGER)return Oe.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof $e=="number"&&Math.floor($e)!==$e)return Oe.error("Numeric branch labels must be integer values.");if(w){if(Oe.checkSubtype(w,Gt($e)))return null}else w=Gt($e);if(z[String($e)]!==void 0)return Oe.error("Branch labels must be unique.");z[String($e)]=Q.length}const je=f.parse(Fe,ge,I);if(!je)return null;I=I||je.type,Q.push(je)}const Z=f.parse(l[1],1,Ui);if(!Z)return null;const re=f.parse(l[l.length-1],l.length-1,I);return re?Z.type.kind!=="value"&&f.concat(1).checkSubtype(w,Z.type)?null:new zc(w,I,Z,z,Q,re):null}evaluate(l){const f=this.input.evaluate(l);return(Gt(f)===this.inputType&&this.outputs[this.cases[f]]||this.otherwise).evaluate(l)}eachChild(l){l(this.input),this.outputs.forEach(l),l(this.otherwise)}outputDefined(){return this.outputs.every(l=>l.outputDefined())&&this.otherwise.outputDefined()}}class Ws{constructor(l,f,w){this.type=l,this.branches=f,this.otherwise=w}static parse(l,f){if(l.length<4)return f.error(`Expected at least 3 arguments, but found only ${l.length-1}.`);if(l.length%2!=0)return f.error("Expected an odd number of arguments.");let w;f.expectedType&&f.expectedType.kind!=="value"&&(w=f.expectedType);const I=[];for(let Q=1;Qf.outputDefined())&&this.otherwise.outputDefined()}}class lc{constructor(l,f,w,I){this.type=l,this.input=f,this.beginIndex=w,this.endIndex=I}static parse(l,f){if(l.length<=2||l.length>=5)return f.error(`Expected 3 or 4 arguments, but found ${l.length-1} instead.`);const w=f.parse(l[1],1,Ui),I=f.parse(l[2],2,Ii);if(!w||!I)return null;if(!Ee(w.type,[kr(Ui),bn,Ui]))return f.error(`Expected first argument to be of type array or string, but found ${Qn(w.type)} instead`);if(l.length===4){const z=f.parse(l[3],3,Ii);return z?new lc(w.type,w,I,z):null}return new lc(w.type,w,I)}evaluate(l){const f=this.input.evaluate(l),w=this.beginIndex.evaluate(l);if(!Ue(f,["string","array"]))throw new Oi(`Expected first argument to be of type array or string, but found ${Qn(Gt(f))} instead.`);if(this.endIndex){const I=this.endIndex.evaluate(l);return f.slice(w,I)}return f.slice(w)}eachChild(l){l(this.input),l(this.beginIndex),this.endIndex&&l(this.endIndex)}outputDefined(){return!1}}function kc(A,l){return A==="=="||A==="!="?l.kind==="boolean"||l.kind==="string"||l.kind==="number"||l.kind==="null"||l.kind==="value":l.kind==="string"||l.kind==="number"||l.kind==="value"}function eA(A,l,f,w){return w.compare(l,f)===0}function cc(A,l,f){const w=A!=="=="&&A!=="!=";return class LM{constructor(z,Q,Z){this.type=Ot,this.lhs=z,this.rhs=Q,this.collator=Z,this.hasUntypedArgument=z.type.kind==="value"||Q.type.kind==="value"}static parse(z,Q){if(z.length!==3&&z.length!==4)return Q.error("Expected two or three arguments.");const Z=z[0];let re=Q.parse(z[1],1,Ui);if(!re)return null;if(!kc(Z,re.type))return Q.concat(1).error(`"${Z}" comparisons are not supported for type '${Qn(re.type)}'.`);let ge=Q.parse(z[2],2,Ui);if(!ge)return null;if(!kc(Z,ge.type))return Q.concat(2).error(`"${Z}" comparisons are not supported for type '${Qn(ge.type)}'.`);if(re.type.kind!==ge.type.kind&&re.type.kind!=="value"&&ge.type.kind!=="value")return Q.error(`Cannot compare types '${Qn(re.type)}' and '${Qn(ge.type)}'.`);w&&(re.type.kind==="value"&&ge.type.kind!=="value"?re=new tn(ge.type,[re]):re.type.kind!=="value"&&ge.type.kind==="value"&&(ge=new tn(re.type,[ge])));let Ce=null;if(z.length===4){if(re.type.kind!=="string"&&ge.type.kind!=="string"&&re.type.kind!=="value"&&ge.type.kind!=="value")return Q.error("Cannot use collator to compare non-string types.");if(Ce=Q.parse(z[3],3,Pn),!Ce)return null}return new LM(re,ge,Ce)}evaluate(z){const Q=this.lhs.evaluate(z),Z=this.rhs.evaluate(z);if(w&&this.hasUntypedArgument){const re=Gt(Q),ge=Gt(Z);if(re.kind!==ge.kind||re.kind!=="string"&&re.kind!=="number")throw new Oi(`Expected arguments for "${A}" to be (string, string) or (number, number), but found (${re.kind}, ${ge.kind}) instead.`)}if(this.collator&&!w&&this.hasUntypedArgument){const re=Gt(Q),ge=Gt(Z);if(re.kind!=="string"||ge.kind!=="string")return l(z,Q,Z)}return this.collator?f(z,Q,Z,this.collator.evaluate(z)):l(z,Q,Z)}eachChild(z){z(this.lhs),z(this.rhs),this.collator&&z(this.collator)}outputDefined(){return!0}}}const mu=cc("==",function(A,l,f){return l===f},eA),td=cc("!=",function(A,l,f){return l!==f},function(A,l,f,w){return!eA(0,l,f,w)}),gu=cc("<",function(A,l,f){return l",function(A,l,f){return l>f},function(A,l,f,w){return w.compare(l,f)>0}),tA=cc("<=",function(A,l,f){return l<=f},function(A,l,f,w){return w.compare(l,f)<=0}),id=cc(">=",function(A,l,f){return l>=f},function(A,l,f,w){return w.compare(l,f)>=0});class hc{constructor(l,f,w,I,z){this.type=bn,this.number=l,this.locale=f,this.currency=w,this.minFractionDigits=I,this.maxFractionDigits=z}static parse(l,f){if(l.length!==3)return f.error("Expected two arguments.");const w=f.parse(l[1],1,Ii);if(!w)return null;const I=l[2];if(typeof I!="object"||Array.isArray(I))return f.error("NumberFormat options argument must be an object.");let z=null;if(I.locale&&(z=f.parse(I.locale,1,bn),!z))return null;let Q=null;if(I.currency&&(Q=f.parse(I.currency,1,bn),!Q))return null;let Z=null;if(I["min-fraction-digits"]&&(Z=f.parse(I["min-fraction-digits"],1,Ii),!Z))return null;let re=null;return I["max-fraction-digits"]&&(re=f.parse(I["max-fraction-digits"],1,Ii),!re)?null:new hc(w,z,Q,Z,re)}evaluate(l){return new Intl.NumberFormat(this.locale?this.locale.evaluate(l):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(l):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(l):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(l):void 0}).format(this.number.evaluate(l))}eachChild(l){l(this.number),this.locale&&l(this.locale),this.currency&&l(this.currency),this.minFractionDigits&&l(this.minFractionDigits),this.maxFractionDigits&&l(this.maxFractionDigits)}outputDefined(){return!1}}class Oc{constructor(l){this.type=qn,this.sections=l}static parse(l,f){if(l.length<2)return f.error("Expected at least one argument.");const w=l[1];if(!Array.isArray(w)&&typeof w=="object")return f.error("First argument must be an image or text section.");const I=[];let z=!1;for(let Q=1;Q<=l.length-1;++Q){const Z=l[Q];if(z&&typeof Z=="object"&&!Array.isArray(Z)){z=!1;let re=null;if(Z["font-scale"]&&(re=f.parse(Z["font-scale"],1,Ii),!re))return null;let ge=null;if(Z["text-font"]&&(ge=f.parse(Z["text-font"],1,kr(bn)),!ge))return null;let Ce=null;if(Z["text-color"]&&(Ce=f.parse(Z["text-color"],1,vi),!Ce))return null;const Fe=I[I.length-1];Fe.scale=re,Fe.font=ge,Fe.textColor=Ce}else{const re=f.parse(l[Q],1,Ui);if(!re)return null;const ge=re.type.kind;if(ge!=="string"&&ge!=="value"&&ge!=="null"&&ge!=="resolvedImage")return f.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");z=!0,I.push({content:re,scale:null,font:null,textColor:null})}}return new Oc(I)}evaluate(l){return new He(this.sections.map(f=>{const w=f.content.evaluate(l);return Gt(w)===fr?new tt("",w,null,null,null):new tt(ki(w),null,f.scale?f.scale.evaluate(l):null,f.font?f.font.evaluate(l).join(","):null,f.textColor?f.textColor.evaluate(l):null)}))}eachChild(l){for(const f of this.sections)l(f.content),f.scale&&l(f.scale),f.font&&l(f.font),f.textColor&&l(f.textColor)}outputDefined(){return!1}}class ul{constructor(l){this.type=fr,this.input=l}static parse(l,f){if(l.length!==2)return f.error("Expected two arguments.");const w=f.parse(l[1],1,bn);return w?new ul(w):f.error("No image name provided.")}evaluate(l){const f=this.input.evaluate(l),w=pt.fromString(f);return w&&l.availableImages&&(w.available=l.availableImages.indexOf(f)>-1),w}eachChild(l){l(this.input)}outputDefined(){return!1}}class Ir{constructor(l){this.type=Ii,this.input=l}static parse(l,f){if(l.length!==2)return f.error(`Expected 1 argument, but found ${l.length-1} instead.`);const w=f.parse(l[1],1);return w?w.type.kind!=="array"&&w.type.kind!=="string"&&w.type.kind!=="value"?f.error(`Expected argument of type string or array, but found ${Qn(w.type)} instead.`):new Ir(w):null}evaluate(l){const f=this.input.evaluate(l);if(typeof f=="string"||Array.isArray(f))return f.length;throw new Oi(`Expected value to be of type string or array, but found ${Qn(Gt(f))} instead.`)}eachChild(l){l(this.input)}outputDefined(){return!1}}const uc={"==":mu,"!=":td,">":Ih,"<":gu,">=":id,"<=":tA,array:tn,at:fu,boolean:tn,case:Ws,coalesce:Va,collator:Wr,format:Oc,image:ul,in:Vl,"index-of":ya,interpolate:Vo,"interpolate-hcl":Vo,"interpolate-lab":Vo,length:Ir,let:ac,literal:wi,match:zc,number:tn,"number-format":hc,object:tn,slice:lc,step:Ql,string:tn,"to-boolean":yn,"to-color":yn,"to-number":yn,"to-string":yn,var:kl,within:ho};function Nc(A,[l,f,w,I]){l=l.evaluate(A),f=f.evaluate(A),w=w.evaluate(A);const z=I?I.evaluate(A):1,Q=Lt(l,f,w,z);if(Q)throw new Oi(Q);return new de(l/255*z,f/255*z,w/255*z,z)}function _u(A,l){return A in l}function Al(A,l){const f=l[A];return f===void 0?null:f}function Ha(A){return{type:A}}function Qc(A){return{result:"success",value:A}}function dl(A){return{result:"error",value:A}}function qr(A){return A["property-type"]==="data-driven"||A["property-type"]==="cross-faded-data-driven"}function Fh(A){return!!A.expression&&A.expression.parameters.indexOf("zoom")>-1}function hr(A){return!!A.expression&&A.expression.interpolated}function Br(A){return A instanceof Number?"number":A instanceof String?"string":A instanceof Boolean?"boolean":Array.isArray(A)?"array":A===null?"null":typeof A}function jr(A){return typeof A=="object"&&A!==null&&!Array.isArray(A)}function $r(A){return A}function Hl(A,l){const f=l.type==="color",w=A.stops&&typeof A.stops[0][0]=="object",I=w||!(w||A.property!==void 0),z=A.type||(hr(l)?"exponential":"interval");if(f||l.type==="padding"){const ge=f?de.parse:Je.parse;(A=hn({},A)).stops&&(A.stops=A.stops.map(Ce=>[Ce[0],ge(Ce[1])])),A.default=ge(A.default?A.default:l.default)}if(A.colorSpace&&A.colorSpace!=="rgb"&&!Sh[A.colorSpace])throw new Error(`Unknown color space: ${A.colorSpace}`);let Q,Z,re;if(z==="exponential")Q=nA;else if(z==="interval")Q=iA;else if(z==="categorical"){Q=yu,Z=Object.create(null);for(const ge of A.stops)Z[ge[0]]=ge[1];re=typeof A.stops[0][0]}else{if(z!=="identity")throw new Error(`Unknown function type "${z}"`);Q=rA}if(w){const ge={},Ce=[];for(let je=0;jeje[0]),evaluate:({zoom:je},$e)=>nA({stops:Fe,base:A.base},l,je).evaluate(je,$e)}}if(I){const ge=z==="exponential"?{name:"exponential",base:A.base!==void 0?A.base:1}:null;return{kind:"camera",interpolationType:ge,interpolationFactor:Vo.interpolationFactor.bind(void 0,ge),zoomStops:A.stops.map(Ce=>Ce[0]),evaluate:({zoom:Ce})=>Q(A,l,Ce,Z,re)}}return{kind:"source",evaluate(ge,Ce){const Fe=Ce&&Ce.properties?Ce.properties[A.property]:void 0;return Fe===void 0?gr(A.default,l.default):Q(A,l,Fe,Z,re)}}}function gr(A,l,f){return A!==void 0?A:l!==void 0?l:f!==void 0?f:void 0}function yu(A,l,f,w,I){return gr(typeof f===I?w[f]:void 0,A.default,l.default)}function iA(A,l,f){if(Br(f)!=="number")return gr(A.default,l.default);const w=A.stops.length;if(w===1||f<=A.stops[0][0])return A.stops[0][1];if(f>=A.stops[w-1][0])return A.stops[w-1][1];const I=Nl(A.stops.map(z=>z[0]),f);return A.stops[I][1]}function nA(A,l,f){const w=A.base!==void 0?A.base:1;if(Br(f)!=="number")return gr(A.default,l.default);const I=A.stops.length;if(I===1||f<=A.stops[0][0])return A.stops[0][1];if(f>=A.stops[I-1][0])return A.stops[I-1][1];const z=Nl(A.stops.map(Ce=>Ce[0]),f),Q=function(Ce,Fe,Oe,je){const $e=je-Oe,Rt=Ce-Oe;return $e===0?0:Fe===1?Rt/$e:(Math.pow(Fe,Rt)-1)/(Math.pow(Fe,$e)-1)}(f,w,A.stops[z][0],A.stops[z+1][0]),Z=A.stops[z][1],re=A.stops[z+1][1];let ge=Ys[l.type]||$r;if(A.colorSpace&&A.colorSpace!=="rgb"){const Ce=Sh[A.colorSpace];ge=(Fe,Oe)=>Ce.reverse(Ce.interpolate(Ce.forward(Fe),Ce.forward(Oe),Q))}return typeof Z.evaluate=="function"?{evaluate(...Ce){const Fe=Z.evaluate.apply(void 0,Ce),Oe=re.evaluate.apply(void 0,Ce);if(Fe!==void 0&&Oe!==void 0)return ge(Fe,Oe,Q)}}:ge(Z,re,Q)}function rA(A,l,f){switch(l.type){case"color":f=de.parse(f);break;case"formatted":f=He.fromString(f.toString());break;case"resolvedImage":f=pt.fromString(f.toString());break;case"padding":f=Je.parse(f);break;default:Br(f)===l.type||l.type==="enum"&&l.values[f]||(f=void 0)}return gr(f,A.default,l.default)}Yn.register(uc,{error:[{kind:"error"},[bn],(A,[l])=>{throw new Oi(l.evaluate(A))}],typeof:[bn,[Ui],(A,[l])=>Qn(Gt(l.evaluate(A)))],"to-rgba":[kr(Ii,4),[vi],(A,[l])=>l.evaluate(A).toArray()],rgb:[vi,[Ii,Ii,Ii],Nc],rgba:[vi,[Ii,Ii,Ii,Ii],Nc],has:{type:Ot,overloads:[[[bn],(A,[l])=>_u(l.evaluate(A),A.properties())],[[bn,Wi],(A,[l,f])=>_u(l.evaluate(A),f.evaluate(A))]]},get:{type:Ui,overloads:[[[bn],(A,[l])=>Al(l.evaluate(A),A.properties())],[[bn,Wi],(A,[l,f])=>Al(l.evaluate(A),f.evaluate(A))]]},"feature-state":[Ui,[bn],(A,[l])=>Al(l.evaluate(A),A.featureState||{})],properties:[Wi,[],A=>A.properties()],"geometry-type":[bn,[],A=>A.geometryType()],id:[Ui,[],A=>A.id()],zoom:[Ii,[],A=>A.globals.zoom],"heatmap-density":[Ii,[],A=>A.globals.heatmapDensity||0],"line-progress":[Ii,[],A=>A.globals.lineProgress||0],accumulated:[Ui,[],A=>A.globals.accumulated===void 0?null:A.globals.accumulated],"+":[Ii,Ha(Ii),(A,l)=>{let f=0;for(const w of l)f+=w.evaluate(A);return f}],"*":[Ii,Ha(Ii),(A,l)=>{let f=1;for(const w of l)f*=w.evaluate(A);return f}],"-":{type:Ii,overloads:[[[Ii,Ii],(A,[l,f])=>l.evaluate(A)-f.evaluate(A)],[[Ii],(A,[l])=>-l.evaluate(A)]]},"/":[Ii,[Ii,Ii],(A,[l,f])=>l.evaluate(A)/f.evaluate(A)],"%":[Ii,[Ii,Ii],(A,[l,f])=>l.evaluate(A)%f.evaluate(A)],ln2:[Ii,[],()=>Math.LN2],pi:[Ii,[],()=>Math.PI],e:[Ii,[],()=>Math.E],"^":[Ii,[Ii,Ii],(A,[l,f])=>Math.pow(l.evaluate(A),f.evaluate(A))],sqrt:[Ii,[Ii],(A,[l])=>Math.sqrt(l.evaluate(A))],log10:[Ii,[Ii],(A,[l])=>Math.log(l.evaluate(A))/Math.LN10],ln:[Ii,[Ii],(A,[l])=>Math.log(l.evaluate(A))],log2:[Ii,[Ii],(A,[l])=>Math.log(l.evaluate(A))/Math.LN2],sin:[Ii,[Ii],(A,[l])=>Math.sin(l.evaluate(A))],cos:[Ii,[Ii],(A,[l])=>Math.cos(l.evaluate(A))],tan:[Ii,[Ii],(A,[l])=>Math.tan(l.evaluate(A))],asin:[Ii,[Ii],(A,[l])=>Math.asin(l.evaluate(A))],acos:[Ii,[Ii],(A,[l])=>Math.acos(l.evaluate(A))],atan:[Ii,[Ii],(A,[l])=>Math.atan(l.evaluate(A))],min:[Ii,Ha(Ii),(A,l)=>Math.min(...l.map(f=>f.evaluate(A)))],max:[Ii,Ha(Ii),(A,l)=>Math.max(...l.map(f=>f.evaluate(A)))],abs:[Ii,[Ii],(A,[l])=>Math.abs(l.evaluate(A))],round:[Ii,[Ii],(A,[l])=>{const f=l.evaluate(A);return f<0?-Math.round(-f):Math.round(f)}],floor:[Ii,[Ii],(A,[l])=>Math.floor(l.evaluate(A))],ceil:[Ii,[Ii],(A,[l])=>Math.ceil(l.evaluate(A))],"filter-==":[Ot,[bn,Ui],(A,[l,f])=>A.properties()[l.value]===f.value],"filter-id-==":[Ot,[Ui],(A,[l])=>A.id()===l.value],"filter-type-==":[Ot,[bn],(A,[l])=>A.geometryType()===l.value],"filter-<":[Ot,[bn,Ui],(A,[l,f])=>{const w=A.properties()[l.value],I=f.value;return typeof w==typeof I&&w{const f=A.id(),w=l.value;return typeof f==typeof w&&f":[Ot,[bn,Ui],(A,[l,f])=>{const w=A.properties()[l.value],I=f.value;return typeof w==typeof I&&w>I}],"filter-id->":[Ot,[Ui],(A,[l])=>{const f=A.id(),w=l.value;return typeof f==typeof w&&f>w}],"filter-<=":[Ot,[bn,Ui],(A,[l,f])=>{const w=A.properties()[l.value],I=f.value;return typeof w==typeof I&&w<=I}],"filter-id-<=":[Ot,[Ui],(A,[l])=>{const f=A.id(),w=l.value;return typeof f==typeof w&&f<=w}],"filter->=":[Ot,[bn,Ui],(A,[l,f])=>{const w=A.properties()[l.value],I=f.value;return typeof w==typeof I&&w>=I}],"filter-id->=":[Ot,[Ui],(A,[l])=>{const f=A.id(),w=l.value;return typeof f==typeof w&&f>=w}],"filter-has":[Ot,[Ui],(A,[l])=>l.value in A.properties()],"filter-has-id":[Ot,[],A=>A.id()!==null&&A.id()!==void 0],"filter-type-in":[Ot,[kr(bn)],(A,[l])=>l.value.indexOf(A.geometryType())>=0],"filter-id-in":[Ot,[kr(Ui)],(A,[l])=>l.value.indexOf(A.id())>=0],"filter-in-small":[Ot,[bn,kr(Ui)],(A,[l,f])=>f.value.indexOf(A.properties()[l.value])>=0],"filter-in-large":[Ot,[bn,kr(Ui)],(A,[l,f])=>function(w,I,z,Q){for(;z<=Q;){const Z=z+Q>>1;if(I[Z]===w)return!0;I[Z]>w?Q=Z-1:z=Z+1}return!1}(A.properties()[l.value],f.value,0,f.value.length-1)],all:{type:Ot,overloads:[[[Ot,Ot],(A,[l,f])=>l.evaluate(A)&&f.evaluate(A)],[Ha(Ot),(A,l)=>{for(const f of l)if(!f.evaluate(A))return!1;return!0}]]},any:{type:Ot,overloads:[[[Ot,Ot],(A,[l,f])=>l.evaluate(A)||f.evaluate(A)],[Ha(Ot),(A,l)=>{for(const f of l)if(f.evaluate(A))return!0;return!1}]]},"!":[Ot,[Ot],(A,[l])=>!l.evaluate(A)],"is-supported-script":[Ot,[bn],(A,[l])=>{const f=A.globals&&A.globals.isSupportedScript;return!f||f(l.evaluate(A))}],upcase:[bn,[bn],(A,[l])=>l.evaluate(A).toUpperCase()],downcase:[bn,[bn],(A,[l])=>l.evaluate(A).toLowerCase()],concat:[bn,Ha(Ui),(A,l)=>l.map(f=>ki(f.evaluate(A))).join("")],"resolved-locale":[bn,[Pn],(A,[l])=>l.evaluate(A).resolvedLocale()]});class Ac{constructor(l,f){this.expression=l,this._warningHistory={},this._evaluator=new sr,this._defaultValue=f?function(w){return w.type==="color"&&jr(w.default)?new de(0,0,0,0):w.type==="color"?de.parse(w.default)||null:w.type==="padding"?Je.parse(w.default)||null:w.default===void 0?null:w.default}(f):null,this._enumValues=f&&f.type==="enum"?f.values:null}evaluateWithoutErrorHandling(l,f,w,I,z,Q){return this._evaluator.globals=l,this._evaluator.feature=f,this._evaluator.featureState=w,this._evaluator.canonical=I,this._evaluator.availableImages=z||null,this._evaluator.formattedSection=Q,this.expression.evaluate(this._evaluator)}evaluate(l,f,w,I,z,Q){this._evaluator.globals=l,this._evaluator.feature=f||null,this._evaluator.featureState=w||null,this._evaluator.canonical=I,this._evaluator.availableImages=z||null,this._evaluator.formattedSection=Q||null;try{const Z=this.expression.evaluate(this._evaluator);if(Z==null||typeof Z=="number"&&Z!=Z)return this._defaultValue;if(this._enumValues&&!(Z in this._enumValues))throw new Oi(`Expected value to be one of ${Object.keys(this._enumValues).map(re=>JSON.stringify(re)).join(", ")}, but found ${JSON.stringify(Z)} instead.`);return Z}catch(Z){return this._warningHistory[Z.message]||(this._warningHistory[Z.message]=!0,typeof console<"u"&&console.warn(Z.message)),this._defaultValue}}}function Vc(A){return Array.isArray(A)&&A.length>0&&typeof A[0]=="string"&&A[0]in uc}function Hc(A,l){const f=new Ol(uc,[],l?function(I){const z={color:vi,string:bn,number:Ii,enum:bn,boolean:Ot,formatted:qn,padding:Hr,resolvedImage:fr};return I.type==="array"?kr(z[I.value]||Ui,I.length):z[I.type]}(l):void 0),w=f.parse(A,void 0,void 0,void 0,l&&l.type==="string"?{typeAnnotation:"coerce"}:void 0);return w?Qc(new Ac(w,l)):dl(f.errors)}class Lh{constructor(l,f){this.kind=l,this._styleExpression=f,this.isStateDependent=l!=="constant"&&!Na(f.expression)}evaluateWithoutErrorHandling(l,f,w,I,z,Q){return this._styleExpression.evaluateWithoutErrorHandling(l,f,w,I,z,Q)}evaluate(l,f,w,I,z,Q){return this._styleExpression.evaluate(l,f,w,I,z,Q)}}class Gc{constructor(l,f,w,I){this.kind=l,this.zoomStops=w,this._styleExpression=f,this.isStateDependent=l!=="camera"&&!Na(f.expression),this.interpolationType=I}evaluateWithoutErrorHandling(l,f,w,I,z,Q){return this._styleExpression.evaluateWithoutErrorHandling(l,f,w,I,z,Q)}evaluate(l,f,w,I,z,Q){return this._styleExpression.evaluate(l,f,w,I,z,Q)}interpolationFactor(l,f,w){return this.interpolationType?Vo.interpolationFactor(this.interpolationType,l,f,w):0}}function Dh(A,l){const f=Hc(A,l);if(f.result==="error")return f;const w=f.value.expression,I=cl(w);if(!I&&!qr(l))return dl([new Cn("","data expressions not supported")]);const z=zl(w,["zoom"]);if(!z&&!Fh(l))return dl([new Cn("","zoom expressions not supported")]);const Q=jc(w);return Q||z?Q instanceof Cn?dl([Q]):Q instanceof Vo&&!hr(l)?dl([new Cn("",'"interpolate" expressions cannot be used with this property')]):Qc(Q?new Gc(I?"camera":"composite",f.value,Q.labels,Q instanceof Vo?Q.interpolation:void 0):new Lh(I?"constant":"source",f.value)):dl([new Cn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Wc{constructor(l,f){this._parameters=l,this._specification=f,hn(this,Hl(this._parameters,this._specification))}static deserialize(l){return new Wc(l._parameters,l._specification)}static serialize(l){return{_parameters:l._parameters,_specification:l._specification}}}function jc(A){let l=null;if(A instanceof ac)l=jc(A.result);else if(A instanceof Va){for(const f of A.args)if(l=jc(f),l)break}else(A instanceof Ql||A instanceof Vo)&&A.input instanceof Yn&&A.input.name==="zoom"&&(l=A);return l instanceof Cn||A.eachChild(f=>{const w=jc(f);w instanceof Cn?l=w:!l&&w?l=new Cn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):l&&w&&l!==w&&(l=new Cn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),l}function ca(A){const l=A.key,f=A.value,w=A.valueSpec||{},I=A.objectElementValidators||{},z=A.style,Q=A.styleSpec;let Z=[];const re=Br(f);if(re!=="object")return[new at(l,f,`object expected, ${re} found`)];for(const ge in f){const Ce=ge.split(".")[0],Fe=w[Ce]||w["*"];let Oe;if(I[Ce])Oe=I[Ce];else if(w[Ce])Oe=Mo;else if(I["*"])Oe=I["*"];else{if(!w["*"]){Z.push(new at(l,f[ge],`unknown property "${ge}"`));continue}Oe=Mo}Z=Z.concat(Oe({key:(l&&`${l}.`)+ge,value:f[ge],valueSpec:Fe,style:z,styleSpec:Q,object:f,objectKey:ge},f))}for(const ge in w)I[ge]||w[ge].required&&w[ge].default===void 0&&f[ge]===void 0&&Z.push(new at(l,f,`missing required property "${ge}"`));return Z}function sA(A){const l=A.value,f=A.valueSpec,w=A.style,I=A.styleSpec,z=A.key,Q=A.arrayElementValidator||Mo;if(Br(l)!=="array")return[new at(z,l,`array expected, ${Br(l)} found`)];if(f.length&&l.length!==f.length)return[new at(z,l,`array length ${f.length} expected, length ${l.length} found`)];if(f["min-length"]&&l.lengthw.maximum?[new at(l,f,`${f} is greater than the maximum value ${w.maximum}`)]:[]}function Kc(A){const l=A.valueSpec,f=Xi(A.value.type);let w,I,z,Q={};const Z=f!=="categorical"&&A.value.property===void 0,re=!Z,ge=Br(A.value.stops)==="array"&&Br(A.value.stops[0])==="array"&&Br(A.value.stops[0][0])==="object",Ce=ca({key:A.key,value:A.value,valueSpec:A.styleSpec.function,style:A.style,styleSpec:A.styleSpec,objectElementValidators:{stops:function(je){if(f==="identity")return[new at(je.key,je.value,'identity function may not have a "stops" property')];let $e=[];const Rt=je.value;return $e=$e.concat(sA({key:je.key,value:Rt,valueSpec:je.valueSpec,style:je.style,styleSpec:je.styleSpec,arrayElementValidator:Fe})),Br(Rt)==="array"&&Rt.length===0&&$e.push(new at(je.key,Rt,"array must have at least one stop")),$e},default:function(je){return Mo({key:je.key,value:je.value,valueSpec:l,style:je.style,styleSpec:je.styleSpec})}}});return f==="identity"&&Z&&Ce.push(new at(A.key,A.value,'missing required property "property"')),f==="identity"||A.value.stops||Ce.push(new at(A.key,A.value,'missing required property "stops"')),f==="exponential"&&A.valueSpec.expression&&!hr(A.valueSpec)&&Ce.push(new at(A.key,A.value,"exponential functions not supported")),A.styleSpec.$version>=8&&(re&&!qr(A.valueSpec)?Ce.push(new at(A.key,A.value,"property functions not supported")):Z&&!Fh(A.valueSpec)&&Ce.push(new at(A.key,A.value,"zoom functions not supported"))),f!=="categorical"&&!ge||A.value.property!==void 0||Ce.push(new at(A.key,A.value,'"property" property is required')),Ce;function Fe(je){let $e=[];const Rt=je.value,Mt=je.key;if(Br(Rt)!=="array")return[new at(Mt,Rt,`array expected, ${Br(Rt)} found`)];if(Rt.length!==2)return[new at(Mt,Rt,`array length 2 expected, length ${Rt.length} found`)];if(ge){if(Br(Rt[0])!=="object")return[new at(Mt,Rt,`object expected, ${Br(Rt[0])} found`)];if(Rt[0].zoom===void 0)return[new at(Mt,Rt,"object stop key must have zoom")];if(Rt[0].value===void 0)return[new at(Mt,Rt,"object stop key must have value")];if(z&&z>Xi(Rt[0].zoom))return[new at(Mt,Rt[0].zoom,"stop zoom values must appear in ascending order")];Xi(Rt[0].zoom)!==z&&(z=Xi(Rt[0].zoom),I=void 0,Q={}),$e=$e.concat(ca({key:`${Mt}[0]`,value:Rt[0],valueSpec:{zoom:{}},style:je.style,styleSpec:je.styleSpec,objectElementValidators:{zoom:oA,value:Oe}}))}else $e=$e.concat(Oe({key:`${Mt}[0]`,value:Rt[0],valueSpec:{},style:je.style,styleSpec:je.styleSpec},Rt));return Vc(on(Rt[1]))?$e.concat([new at(`${Mt}[1]`,Rt[1],"expressions are not allowed in function stops.")]):$e.concat(Mo({key:`${Mt}[1]`,value:Rt[1],valueSpec:l,style:je.style,styleSpec:je.styleSpec}))}function Oe(je,$e){const Rt=Br(je.value),Mt=Xi(je.value),ri=je.value!==null?je.value:$e;if(w){if(Rt!==w)return[new at(je.key,ri,`${Rt} stop domain type must match previous stop domain type ${w}`)]}else w=Rt;if(Rt!=="number"&&Rt!=="string"&&Rt!=="boolean")return[new at(je.key,ri,"stop domain value must be a number, string, or boolean")];if(Rt!=="number"&&f!=="categorical"){let gi=`number expected, ${Rt} found`;return qr(l)&&f===void 0&&(gi+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new at(je.key,ri,gi)]}return f!=="categorical"||Rt!=="number"||isFinite(Mt)&&Math.floor(Mt)===Mt?f!=="categorical"&&Rt==="number"&&I!==void 0&&Mtnew at(`${A.key}${w.key}`,A.value,w.message));const f=l.value.expression||l.value._styleExpression.expression;if(A.expressionContext==="property"&&A.propertyKey==="text-font"&&!f.outputDefined())return[new at(A.key,A.value,`Invalid data expression for "${A.propertyKey}". Output values must be contained as literals within the expression.`)];if(A.expressionContext==="property"&&A.propertyType==="layout"&&!Na(f))return[new at(A.key,A.value,'"feature-state" data expressions are not supported with layout properties.')];if(A.expressionContext==="filter"&&!Na(f))return[new at(A.key,A.value,'"feature-state" data expressions are not supported with filters.')];if(A.expressionContext&&A.expressionContext.indexOf("cluster")===0){if(!zl(f,["zoom","feature-state"]))return[new at(A.key,A.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(A.expressionContext==="cluster-initial"&&!cl(f))return[new at(A.key,A.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function $c(A){const l=A.key,f=A.value,w=A.valueSpec,I=[];return Array.isArray(w.values)?w.values.indexOf(Xi(f))===-1&&I.push(new at(l,f,`expected one of [${w.values.join(", ")}], ${JSON.stringify(f)} found`)):Object.keys(w.values).indexOf(Xi(f))===-1&&I.push(new at(l,f,`expected one of [${Object.keys(w.values).join(", ")}], ${JSON.stringify(f)} found`)),I}function pl(A){if(A===!0||A===!1)return!0;if(!Array.isArray(A)||A.length===0)return!1;switch(A[0]){case"has":return A.length>=2&&A[1]!=="$id"&&A[1]!=="$type";case"in":return A.length>=3&&(typeof A[1]!="string"||Array.isArray(A[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return A.length!==3||Array.isArray(A[1])||Array.isArray(A[2]);case"any":case"all":for(const l of A.slice(1))if(!pl(l)&&typeof l!="boolean")return!1;return!0;default:return!0}}const aA={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Ho(A){if(A==null)return{filter:()=>!0,needGeometry:!1};pl(A)||(A=Gl(A));const l=Hc(A,aA);if(l.result==="error")throw new Error(l.value.map(f=>`${f.key}: ${f.message}`).join(", "));return{filter:(f,w,I)=>l.value.evaluate(f,w,{},I),needGeometry:xu(A)}}function Ph(A,l){return Al?1:0}function xu(A){if(!Array.isArray(A))return!1;if(A[0]==="within")return!0;for(let l=1;l"||l==="<="||l===">="?vu(A[1],A[2],l):l==="any"?(f=A.slice(1),["any"].concat(f.map(Gl))):l==="all"?["all"].concat(A.slice(1).map(Gl)):l==="none"?["all"].concat(A.slice(1).map(Gl).map(fl)):l==="in"?Zc(A[1],A.slice(2)):l==="!in"?fl(Zc(A[1],A.slice(2))):l==="has"?Xc(A[1]):l==="!has"?fl(Xc(A[1])):l!=="within"||A;var f}function vu(A,l,f){switch(A){case"$type":return[`filter-type-${f}`,l];case"$id":return[`filter-id-${f}`,l];default:return[`filter-${f}`,A,l]}}function Zc(A,l){if(l.length===0)return!1;switch(A){case"$type":return["filter-type-in",["literal",l]];case"$id":return["filter-id-in",["literal",l]];default:return l.length>200&&!l.some(f=>typeof f!=typeof l[0])?["filter-in-large",A,["literal",l.sort(Ph)]]:["filter-in-small",A,["literal",l]]}}function Xc(A){switch(A){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",A]}}function fl(A){return["!",A]}function qc(A){return pl(on(A.value))?ha(hn({},A,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Uh(A)}function Uh(A){const l=A.value,f=A.key;if(Br(l)!=="array")return[new at(f,l,`array expected, ${Br(l)} found`)];const w=A.styleSpec;let I,z=[];if(l.length<1)return[new at(f,l,"filter array must have at least 1 element")];switch(z=z.concat($c({key:`${f}[0]`,value:l[0],valueSpec:w.filter_operator,style:A.style,styleSpec:A.styleSpec})),Xi(l[0])){case"<":case"<=":case">":case">=":l.length>=2&&Xi(l[1])==="$type"&&z.push(new at(f,l,`"$type" cannot be use with operator "${l[0]}"`));case"==":case"!=":l.length!==3&&z.push(new at(f,l,`filter array for operator "${l[0]}" must have 3 elements`));case"in":case"!in":l.length>=2&&(I=Br(l[1]),I!=="string"&&z.push(new at(`${f}[1]`,l[1],`string expected, ${I} found`)));for(let Q=2;Q{ge in f&&l.push(new at(w,f[ge],`"${ge}" is prohibited for ref layers`))}),I.layers.forEach(ge=>{Xi(ge.id)===Z&&(re=ge)}),re?re.ref?l.push(new at(w,f.ref,"ref cannot reference another ref layer")):Q=Xi(re.type):l.push(new at(w,f.ref,`ref layer "${Z}" not found`))}else if(Q!=="background")if(f.source){const re=I.sources&&I.sources[f.source],ge=re&&Xi(re.type);re?ge==="vector"&&Q==="raster"?l.push(new at(w,f.source,`layer "${f.id}" requires a raster source`)):ge==="raster"&&Q!=="raster"?l.push(new at(w,f.source,`layer "${f.id}" requires a vector source`)):ge!=="vector"||f["source-layer"]?ge==="raster-dem"&&Q!=="hillshade"?l.push(new at(w,f.source,"raster-dem source can only be used with layer type 'hillshade'.")):Q!=="line"||!f.paint||!f.paint["line-gradient"]||ge==="geojson"&&re.lineMetrics||l.push(new at(w,f,`layer "${f.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):l.push(new at(w,f,`layer "${f.id}" must specify a "source-layer"`)):l.push(new at(w,f.source,`source "${f.source}" not found`))}else l.push(new at(w,f,'missing required property "source"'));return l=l.concat(ca({key:w,value:f,valueSpec:z.layer,style:A.style,styleSpec:A.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Mo({key:`${w}.type`,value:f.type,valueSpec:z.layer.type,style:A.style,styleSpec:A.styleSpec,object:f,objectKey:"type"}),filter:qc,layout:re=>ca({layer:f,key:re.key,value:re.value,style:re.style,styleSpec:re.styleSpec,objectElementValidators:{"*":ge=>nd(hn({layerType:Q},ge))}}),paint:re=>ca({layer:f,key:re.key,value:re.value,style:re.style,styleSpec:re.styleSpec,objectElementValidators:{"*":ge=>wu(hn({layerType:Q},ge))}})}})),l}function pc(A){const l=A.value,f=A.key,w=Br(l);return w!=="string"?[new at(f,l,`string expected, ${w} found`)]:[]}const Yc={promoteId:function({key:A,value:l}){if(Br(l)==="string")return pc({key:A,value:l});{const f=[];for(const w in l)f.push(...pc({key:`${A}.${w}`,value:l[w]}));return f}}};function zh(A){const l=A.value,f=A.key,w=A.styleSpec,I=A.style;if(!l.type)return[new at(f,l,'"type" is required')];const z=Xi(l.type);let Q;switch(z){case"vector":case"raster":case"raster-dem":return Q=ca({key:f,value:l,valueSpec:w[`source_${z.replace("-","_")}`],style:A.style,styleSpec:w,objectElementValidators:Yc}),Q;case"geojson":if(Q=ca({key:f,value:l,valueSpec:w.source_geojson,style:I,styleSpec:w,objectElementValidators:Yc}),l.cluster)for(const Z in l.clusterProperties){const[re,ge]=l.clusterProperties[Z],Ce=typeof re=="string"?[re,["accumulated"],["get",Z]]:re;Q.push(...ha({key:`${f}.${Z}.map`,value:ge,expressionContext:"cluster-map"})),Q.push(...ha({key:`${f}.${Z}.reduce`,value:Ce,expressionContext:"cluster-reduce"}))}return Q;case"video":return ca({key:f,value:l,valueSpec:w.source_video,style:I,styleSpec:w});case"image":return ca({key:f,value:l,valueSpec:w.source_image,style:I,styleSpec:w});case"canvas":return[new at(f,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return $c({key:`${f}.type`,value:l.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:I,styleSpec:w})}}function Jc(A){const l=A.value,f=A.styleSpec,w=f.light,I=A.style;let z=[];const Q=Br(l);if(l===void 0)return z;if(Q!=="object")return z=z.concat([new at("light",l,`object expected, ${Q} found`)]),z;for(const Z in l){const re=Z.match(/^(.*)-transition$/);z=z.concat(re&&w[re[1]]&&w[re[1]].transition?Mo({key:Z,value:l[Z],valueSpec:f.transition,style:I,styleSpec:f}):w[Z]?Mo({key:Z,value:l[Z],valueSpec:w[Z],style:I,styleSpec:f}):[new at(Z,l[Z],`unknown property "${Z}"`)])}return z}function So(A){const l=A.value,f=A.styleSpec,w=f.terrain,I=A.style;let z=[];const Q=Br(l);if(l===void 0)return z;if(Q!=="object")return z=z.concat([new at("terrain",l,`object expected, ${Q} found`)]),z;for(const Z in l)z=z.concat(w[Z]?Mo({key:Z,value:l[Z],valueSpec:w[Z],style:I,styleSpec:f}):[new at(Z,l[Z],`unknown property "${Z}"`)]);return z}const xa={"*":()=>[],array:sA,boolean:function(A){const l=A.value,f=A.key,w=Br(l);return w!=="boolean"?[new at(f,l,`boolean expected, ${w} found`)]:[]},number:oA,color:function(A){const l=A.key,f=A.value,w=Br(f);return w!=="string"?[new at(l,f,`color expected, ${w} found`)]:ct(f)===null?[new at(l,f,`color expected, "${f}" found`)]:[]},constants:ii,enum:$c,filter:qc,function:Kc,layer:dc,object:ca,source:zh,light:Jc,terrain:So,string:pc,formatted:function(A){return pc(A).length===0?[]:ha(A)},resolvedImage:function(A){return pc(A).length===0?[]:ha(A)},padding:function(A){const l=A.key,f=A.value;if(Br(f)==="array"){if(f.length<1||f.length>4)return[new at(l,f,`padding requires 1 to 4 values; ${f.length} values found`)];const w={type:"number"};let I=[];for(let z=0;z[]}})),A.constants&&(f=f.concat(ii({key:"constants",value:A.constants,style:A,styleSpec:l}))),sd(f)}function sd(A){return[].concat(A).sort((l,f)=>l.line-f.line)}function ml(A){return function(...l){return sd(A.apply(this,l))}}Ga.source=ml(zh),Ga.light=ml(Jc),Ga.terrain=ml(So),Ga.layer=ml(dc),Ga.filter=ml(qc),Ga.paintProperty=ml(wu),Ga.layoutProperty=ml(nd);const kh=Ga,Oh=kh.light,lA=kh.paintProperty,od=kh.layoutProperty;function Nh(A,l){let f=!1;if(l&&l.length)for(const w of l)A.fire(new qi(new Error(w.message))),f=!0;return f}class fc{constructor(l,f,w){const I=this.cells=[];if(l instanceof ArrayBuffer){this.arrayBuffer=l;const Q=new Int32Array(this.arrayBuffer);l=Q[0],this.d=(f=Q[1])+2*(w=Q[2]);for(let re=0;re=Fe[$e+0]&&I>=Fe[$e+1])?(Z[je]=!0,Q.push(Ce[je])):Z[je]=!1}}}}_forEachCell(l,f,w,I,z,Q,Z,re){const ge=this._convertToCellCoord(l),Ce=this._convertToCellCoord(f),Fe=this._convertToCellCoord(w),Oe=this._convertToCellCoord(I);for(let je=ge;je<=Fe;je++)for(let $e=Ce;$e<=Oe;$e++){const Rt=this.d*$e+je;if((!re||re(this._convertFromCellCoord(je),this._convertFromCellCoord($e),this._convertFromCellCoord(je+1),this._convertFromCellCoord($e+1)))&&z.call(this,l,f,w,I,Rt,Q,Z,re))return}}_convertFromCellCoord(l){return(l-this.padding)/this.scale}_convertToCellCoord(l){return Math.max(0,Math.min(this.d-1,Math.floor(l*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const l=this.cells,f=3+this.cells.length+1+1;let w=0;for(let Q=0;Q=0)continue;const Q=A[z];I[z]=ua[w].shallow.indexOf(z)>=0?Q:Wl(Q,l)}A instanceof Error&&(I.message=A.message)}if(I.$name)throw new Error("$name property is reserved for worker serialization logic.");return w!=="Object"&&(I.$name=w),I}throw new Error("can't serialize object of type "+typeof A)}function Ns(A){if(A==null||typeof A=="boolean"||typeof A=="number"||typeof A=="string"||A instanceof Boolean||A instanceof Number||A instanceof String||A instanceof Date||A instanceof RegExp||A instanceof Blob||eh(A)||ce(A)||ArrayBuffer.isView(A)||A instanceof ImageData)return A;if(Array.isArray(A))return A.map(Ns);if(typeof A=="object"){const l=A.$name||"Object";if(!ua[l])throw new Error(`can't deserialize unregistered class ${l}`);const{klass:f}=ua[l];if(!f)throw new Error(`can't deserialize unregistered class ${l}`);if(f.deserialize)return f.deserialize(A);const w=Object.create(f.prototype);for(const I of Object.keys(A)){if(I==="$name")continue;const z=A[I];w[I]=ua[l].shallow.indexOf(I)>=0?z:Ns(z)}return w}throw new Error("can't deserialize object of type "+typeof A)}class gl{constructor(){this.first=!0}update(l,f){const w=Math.floor(l);return this.first?(this.first=!1,this.lastIntegerZoom=w,this.lastIntegerZoomTime=0,this.lastZoom=l,this.lastFloorZoom=w,!0):(this.lastFloorZoom>w?(this.lastIntegerZoom=w+1,this.lastIntegerZoomTime=f):this.lastFloorZoomA>=128&&A<=255,Arabic:A=>A>=1536&&A<=1791,"Arabic Supplement":A=>A>=1872&&A<=1919,"Arabic Extended-A":A=>A>=2208&&A<=2303,"Hangul Jamo":A=>A>=4352&&A<=4607,"Unified Canadian Aboriginal Syllabics":A=>A>=5120&&A<=5759,Khmer:A=>A>=6016&&A<=6143,"Unified Canadian Aboriginal Syllabics Extended":A=>A>=6320&&A<=6399,"General Punctuation":A=>A>=8192&&A<=8303,"Letterlike Symbols":A=>A>=8448&&A<=8527,"Number Forms":A=>A>=8528&&A<=8591,"Miscellaneous Technical":A=>A>=8960&&A<=9215,"Control Pictures":A=>A>=9216&&A<=9279,"Optical Character Recognition":A=>A>=9280&&A<=9311,"Enclosed Alphanumerics":A=>A>=9312&&A<=9471,"Geometric Shapes":A=>A>=9632&&A<=9727,"Miscellaneous Symbols":A=>A>=9728&&A<=9983,"Miscellaneous Symbols and Arrows":A=>A>=11008&&A<=11263,"CJK Radicals Supplement":A=>A>=11904&&A<=12031,"Kangxi Radicals":A=>A>=12032&&A<=12255,"Ideographic Description Characters":A=>A>=12272&&A<=12287,"CJK Symbols and Punctuation":A=>A>=12288&&A<=12351,Hiragana:A=>A>=12352&&A<=12447,Katakana:A=>A>=12448&&A<=12543,Bopomofo:A=>A>=12544&&A<=12591,"Hangul Compatibility Jamo":A=>A>=12592&&A<=12687,Kanbun:A=>A>=12688&&A<=12703,"Bopomofo Extended":A=>A>=12704&&A<=12735,"CJK Strokes":A=>A>=12736&&A<=12783,"Katakana Phonetic Extensions":A=>A>=12784&&A<=12799,"Enclosed CJK Letters and Months":A=>A>=12800&&A<=13055,"CJK Compatibility":A=>A>=13056&&A<=13311,"CJK Unified Ideographs Extension A":A=>A>=13312&&A<=19903,"Yijing Hexagram Symbols":A=>A>=19904&&A<=19967,"CJK Unified Ideographs":A=>A>=19968&&A<=40959,"Yi Syllables":A=>A>=40960&&A<=42127,"Yi Radicals":A=>A>=42128&&A<=42191,"Hangul Jamo Extended-A":A=>A>=43360&&A<=43391,"Hangul Syllables":A=>A>=44032&&A<=55215,"Hangul Jamo Extended-B":A=>A>=55216&&A<=55295,"Private Use Area":A=>A>=57344&&A<=63743,"CJK Compatibility Ideographs":A=>A>=63744&&A<=64255,"Arabic Presentation Forms-A":A=>A>=64336&&A<=65023,"Vertical Forms":A=>A>=65040&&A<=65055,"CJK Compatibility Forms":A=>A>=65072&&A<=65103,"Small Form Variants":A=>A>=65104&&A<=65135,"Arabic Presentation Forms-B":A=>A>=65136&&A<=65279,"Halfwidth and Fullwidth Forms":A=>A>=65280&&A<=65519};function th(A){for(const l of A)if(cA(l.charCodeAt(0)))return!0;return!1}function Ur(A){for(const l of A)if(!mc(l.charCodeAt(0)))return!1;return!0}function mc(A){return!(un.Arabic(A)||un["Arabic Supplement"](A)||un["Arabic Extended-A"](A)||un["Arabic Presentation Forms-A"](A)||un["Arabic Presentation Forms-B"](A))}function cA(A){return!(A!==746&&A!==747&&(A<4352||!(un["Bopomofo Extended"](A)||un.Bopomofo(A)||un["CJK Compatibility Forms"](A)&&!(A>=65097&&A<=65103)||un["CJK Compatibility Ideographs"](A)||un["CJK Compatibility"](A)||un["CJK Radicals Supplement"](A)||un["CJK Strokes"](A)||!(!un["CJK Symbols and Punctuation"](A)||A>=12296&&A<=12305||A>=12308&&A<=12319||A===12336)||un["CJK Unified Ideographs Extension A"](A)||un["CJK Unified Ideographs"](A)||un["Enclosed CJK Letters and Months"](A)||un["Hangul Compatibility Jamo"](A)||un["Hangul Jamo Extended-A"](A)||un["Hangul Jamo Extended-B"](A)||un["Hangul Jamo"](A)||un["Hangul Syllables"](A)||un.Hiragana(A)||un["Ideographic Description Characters"](A)||un.Kanbun(A)||un["Kangxi Radicals"](A)||un["Katakana Phonetic Extensions"](A)||un.Katakana(A)&&A!==12540||!(!un["Halfwidth and Fullwidth Forms"](A)||A===65288||A===65289||A===65293||A>=65306&&A<=65310||A===65339||A===65341||A===65343||A>=65371&&A<=65503||A===65507||A>=65512&&A<=65519)||!(!un["Small Form Variants"](A)||A>=65112&&A<=65118||A>=65123&&A<=65126)||un["Unified Canadian Aboriginal Syllabics"](A)||un["Unified Canadian Aboriginal Syllabics Extended"](A)||un["Vertical Forms"](A)||un["Yijing Hexagram Symbols"](A)||un["Yi Syllables"](A)||un["Yi Radicals"](A))))}function Qh(A){return!(cA(A)||function(l){return!!(un["Latin-1 Supplement"](l)&&(l===167||l===169||l===174||l===177||l===188||l===189||l===190||l===215||l===247)||un["General Punctuation"](l)&&(l===8214||l===8224||l===8225||l===8240||l===8241||l===8251||l===8252||l===8258||l===8263||l===8264||l===8265||l===8273)||un["Letterlike Symbols"](l)||un["Number Forms"](l)||un["Miscellaneous Technical"](l)&&(l>=8960&&l<=8967||l>=8972&&l<=8991||l>=8996&&l<=9e3||l===9003||l>=9085&&l<=9114||l>=9150&&l<=9165||l===9167||l>=9169&&l<=9179||l>=9186&&l<=9215)||un["Control Pictures"](l)&&l!==9251||un["Optical Character Recognition"](l)||un["Enclosed Alphanumerics"](l)||un["Geometric Shapes"](l)||un["Miscellaneous Symbols"](l)&&!(l>=9754&&l<=9759)||un["Miscellaneous Symbols and Arrows"](l)&&(l>=11026&&l<=11055||l>=11088&&l<=11097||l>=11192&&l<=11243)||un["CJK Symbols and Punctuation"](l)||un.Katakana(l)||un["Private Use Area"](l)||un["CJK Compatibility Forms"](l)||un["Small Form Variants"](l)||un["Halfwidth and Fullwidth Forms"](l)||l===8734||l===8756||l===8757||l>=9984&&l<=10087||l>=10102&&l<=10131||l===65532||l===65533)}(A))}function gc(A){return A>=1424&&A<=2303||un["Arabic Presentation Forms-A"](A)||un["Arabic Presentation Forms-B"](A)}function hA(A,l){return!(!l&&gc(A)||A>=2304&&A<=3583||A>=3840&&A<=4255||un.Khmer(A))}function uA(A){for(const l of A)if(gc(l.charCodeAt(0)))return!0;return!1}const Vh="deferred",Hh="loading",ih="loaded";let _c=null,Is="unavailable",fo=null;const Gh=function(A){A&&typeof A=="string"&&A.indexOf("NetworkError")>-1&&(Is="error"),_c&&_c(A)};function jl(){Kl.fire(new Ni("pluginStateChange",{pluginStatus:Is,pluginURL:fo}))}const Kl=new en,_l=function(){return Is},An=function(){if(Is!==Vh||!fo)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Is=Hh,jl(),fo&&Gi({url:fo},A=>{A?Gh(A):(Is=ih,jl())})},vs={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Is===ih||vs.applyArabicShaping!=null,isLoading:()=>Is===Hh,setState(A){if(!Me())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");Is=A.pluginStatus,fo=A.pluginURL},isParsed(){if(!Me())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return vs.applyArabicShaping!=null&&vs.processBidirectionalText!=null&&vs.processStyledBidirectionalText!=null},getPluginURL(){if(!Me())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return fo}};class Zr{constructor(l,f){this.zoom=l,f?(this.now=f.now,this.fadeDuration=f.fadeDuration,this.zoomHistory=f.zoomHistory,this.transition=f.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new gl,this.transition={})}isSupportedScript(l){return function(f,w){for(const I of f)if(!hA(I.charCodeAt(0),w))return!1;return!0}(l,vs.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const l=this.zoom,f=l-Math.floor(l),w=this.crossFadingFactor();return l>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:f+(1-f)*w}:{fromScale:.5,toScale:1,t:1-(1-w)*f}}}class nh{constructor(l,f){this.property=l,this.value=f,this.expression=function(w,I){if(jr(w))return new Wc(w,I);if(Vc(w)){const z=Dh(w,I);if(z.result==="error")throw new Error(z.value.map(Q=>`${Q.key}: ${Q.message}`).join(", "));return z.value}{let z=w;return I.type==="color"&&typeof w=="string"?z=de.parse(w):I.type!=="padding"||typeof w!="number"&&!Array.isArray(w)||(z=Je.parse(w)),{kind:"constant",evaluate:()=>z}}}(f===void 0?l.specification.default:f,l.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(l,f,w){return this.property.possiblyEvaluate(this,l,f,w)}}class Wh{constructor(l){this.property=l,this.value=new nh(l,void 0)}transitioned(l,f){return new AA(this.property,this.value,f,J({},l.transition,this.transition),l.now)}untransitioned(){return new AA(this.property,this.value,null,{},0)}}class yc{constructor(l){this._properties=l,this._values=Object.create(l.defaultTransitionablePropertyValues)}getValue(l){return Ae(this._values[l].value.value)}setValue(l,f){Object.prototype.hasOwnProperty.call(this._values,l)||(this._values[l]=new Wh(this._values[l].property)),this._values[l].value=new nh(this._values[l].property,f===null?void 0:Ae(f))}getTransition(l){return Ae(this._values[l].transition)}setTransition(l,f){Object.prototype.hasOwnProperty.call(this._values,l)||(this._values[l]=new Wh(this._values[l].property)),this._values[l].transition=Ae(f)||void 0}serialize(){const l={};for(const f of Object.keys(this._values)){const w=this.getValue(f);w!==void 0&&(l[f]=w);const I=this.getTransition(f);I!==void 0&&(l[`${f}-transition`]=I)}return l}transitioned(l,f){const w=new jh(this._properties);for(const I of Object.keys(this._values))w._values[I]=this._values[I].transitioned(l,f._values[I]);return w}untransitioned(){const l=new jh(this._properties);for(const f of Object.keys(this._values))l._values[f]=this._values[f].untransitioned();return l}}class AA{constructor(l,f,w,I,z){this.property=l,this.value=f,this.begin=z+I.delay||0,this.end=this.begin+I.duration||0,l.specification.transition&&(I.delay||I.duration)&&(this.prior=w)}possiblyEvaluate(l,f,w){const I=l.now||0,z=this.value.possiblyEvaluate(l,f,w),Q=this.prior;if(Q){if(I>this.end)return this.prior=null,z;if(this.value.isDataDriven())return this.prior=null,z;if(I=1)return 1;const ge=re*re,Ce=ge*re;return 4*(re<.5?Ce:3*(re-ge)+Ce-.75)}(Z))}}return z}}class jh{constructor(l){this._properties=l,this._values=Object.create(l.defaultTransitioningPropertyValues)}possiblyEvaluate(l,f,w){const I=new Js(this._properties);for(const z of Object.keys(this._values))I._values[z]=this._values[z].possiblyEvaluate(l,f,w);return I}hasTransition(){for(const l of Object.keys(this._values))if(this._values[l].prior)return!0;return!1}}class rh{constructor(l){this._properties=l,this._values=Object.create(l.defaultPropertyValues)}getValue(l){return Ae(this._values[l].value)}setValue(l,f){this._values[l]=new nh(this._values[l].property,f===null?void 0:Ae(f))}serialize(){const l={};for(const f of Object.keys(this._values)){const w=this.getValue(f);w!==void 0&&(l[f]=w)}return l}possiblyEvaluate(l,f,w){const I=new Js(this._properties);for(const z of Object.keys(this._values))I._values[z]=this._values[z].possiblyEvaluate(l,f,w);return I}}class uo{constructor(l,f,w){this.property=l,this.value=f,this.parameters=w}isConstant(){return this.value.kind==="constant"}constantOr(l){return this.value.kind==="constant"?this.value.value:l}evaluate(l,f,w,I){return this.property.evaluate(this.value,this.parameters,l,f,w,I)}}class Js{constructor(l){this._properties=l,this._values=Object.create(l.defaultPossiblyEvaluatedValues)}get(l){return this._values[l]}}class Fn{constructor(l){this.specification=l}possiblyEvaluate(l,f){if(l.isDataDriven())throw new Error("Value should not be data driven");return l.expression.evaluate(f)}interpolate(l,f,w){const I=Ys[this.specification.type];return I?I(l,f,w):l}}class Vn{constructor(l,f){this.specification=l,this.overrides=f}possiblyEvaluate(l,f,w,I){return new uo(this,l.expression.kind==="constant"||l.expression.kind==="camera"?{kind:"constant",value:l.expression.evaluate(f,null,{},w,I)}:l.expression,f)}interpolate(l,f,w){if(l.value.kind!=="constant"||f.value.kind!=="constant")return l;if(l.value.value===void 0||f.value.value===void 0)return new uo(this,{kind:"constant",value:void 0},l.parameters);const I=Ys[this.specification.type];return I?new uo(this,{kind:"constant",value:I(l.value.value,f.value.value,w)},l.parameters):l}evaluate(l,f,w,I,z,Q){return l.kind==="constant"?l.value:l.evaluate(f,w,I,z,Q)}}class sh extends Vn{possiblyEvaluate(l,f,w,I){if(l.value===void 0)return new uo(this,{kind:"constant",value:void 0},f);if(l.expression.kind==="constant"){const z=l.expression.evaluate(f,null,{},w,I),Q=l.property.specification.type==="resolvedImage"&&typeof z!="string"?z.name:z,Z=this._calculate(Q,Q,Q,f);return new uo(this,{kind:"constant",value:Z},f)}if(l.expression.kind==="camera"){const z=this._calculate(l.expression.evaluate({zoom:f.zoom-1}),l.expression.evaluate({zoom:f.zoom}),l.expression.evaluate({zoom:f.zoom+1}),f);return new uo(this,{kind:"constant",value:z},f)}return new uo(this,l.expression,f)}evaluate(l,f,w,I,z,Q){if(l.kind==="source"){const Z=l.evaluate(f,w,I,z,Q);return this._calculate(Z,Z,Z,f)}return l.kind==="composite"?this._calculate(l.evaluate({zoom:Math.floor(f.zoom)-1},w,I),l.evaluate({zoom:Math.floor(f.zoom)},w,I),l.evaluate({zoom:Math.floor(f.zoom)+1},w,I),f):l.value}_calculate(l,f,w,I){return I.zoom>I.zoomHistory.lastIntegerZoom?{from:l,to:f}:{from:w,to:f}}interpolate(l){return l}}class dA{constructor(l){this.specification=l}possiblyEvaluate(l,f,w,I){if(l.value!==void 0){if(l.expression.kind==="constant"){const z=l.expression.evaluate(f,null,{},w,I);return this._calculate(z,z,z,f)}return this._calculate(l.expression.evaluate(new Zr(Math.floor(f.zoom-1),f)),l.expression.evaluate(new Zr(Math.floor(f.zoom),f)),l.expression.evaluate(new Zr(Math.floor(f.zoom+1),f)),f)}}_calculate(l,f,w,I){return I.zoom>I.zoomHistory.lastIntegerZoom?{from:l,to:f}:{from:w,to:f}}interpolate(l){return l}}class yl{constructor(l){this.specification=l}possiblyEvaluate(l,f,w,I){return!!l.expression.evaluate(f,null,{},w,I)}interpolate(){return!1}}class Es{constructor(l){this.properties=l,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const f in l){const w=l[f];w.specification.overridable&&this.overridableProperties.push(f);const I=this.defaultPropertyValues[f]=new nh(w,void 0),z=this.defaultTransitionablePropertyValues[f]=new Wh(w);this.defaultTransitioningPropertyValues[f]=z.untransitioned(),this.defaultPossiblyEvaluatedValues[f]=I.possiblyEvaluate({})}}}pn("DataDrivenProperty",Vn),pn("DataConstantProperty",Fn),pn("CrossFadedDataDrivenProperty",sh),pn("CrossFadedProperty",dA),pn("ColorRampProperty",yl);const Wa="-transition";class Go extends en{constructor(l,f){if(super(),this.id=l.id,this.type=l.type,this._featureFilter={filter:()=>!0,needGeometry:!1},l.type!=="custom"&&(this.metadata=l.metadata,this.minzoom=l.minzoom,this.maxzoom=l.maxzoom,l.type!=="background"&&(this.source=l.source,this.sourceLayer=l["source-layer"],this.filter=l.filter),f.layout&&(this._unevaluatedLayout=new rh(f.layout)),f.paint)){this._transitionablePaint=new yc(f.paint);for(const w in l.paint)this.setPaintProperty(w,l.paint[w],{validate:!1});for(const w in l.layout)this.setLayoutProperty(w,l.layout[w],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Js(f.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(l){return l==="visibility"?this.visibility:this._unevaluatedLayout.getValue(l)}setLayoutProperty(l,f,w={}){f!=null&&this._validate(od,`layers.${this.id}.layout.${l}`,l,f,w)||(l!=="visibility"?this._unevaluatedLayout.setValue(l,f):this.visibility=f)}getPaintProperty(l){return l.endsWith(Wa)?this._transitionablePaint.getTransition(l.slice(0,-Wa.length)):this._transitionablePaint.getValue(l)}setPaintProperty(l,f,w={}){if(f!=null&&this._validate(lA,`layers.${this.id}.paint.${l}`,l,f,w))return!1;if(l.endsWith(Wa))return this._transitionablePaint.setTransition(l.slice(0,-Wa.length),f||void 0),!1;{const I=this._transitionablePaint._values[l],z=I.property.specification["property-type"]==="cross-faded-data-driven",Q=I.value.isDataDriven(),Z=I.value;this._transitionablePaint.setValue(l,f),this._handleSpecialPaintPropertyUpdate(l);const re=this._transitionablePaint._values[l].value;return re.isDataDriven()||Q||z||this._handleOverridablePaintPropertyUpdate(l,Z,re)}}_handleSpecialPaintPropertyUpdate(l){}_handleOverridablePaintPropertyUpdate(l,f,w){return!1}isHidden(l){return!!(this.minzoom&&l=this.maxzoom)||this.visibility==="none"}updateTransitions(l){this._transitioningPaint=this._transitionablePaint.transitioned(l,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(l,f){l.getCrossfadeParameters&&(this._crossfadeParameters=l.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(l,void 0,f)),this.paint=this._transitioningPaint.possiblyEvaluate(l,void 0,f)}serialize(){const l={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&&(l.layout=l.layout||{},l.layout.visibility=this.visibility),le(l,(f,w)=>!(f===void 0||w==="layout"&&!Object.keys(f).length||w==="paint"&&!Object.keys(f).length))}_validate(l,f,w,I,z={}){return(!z||z.validate!==!1)&&Nh(this,l.call(kh,{key:f,layerType:this.type,objectKey:w,value:I,styleSpec:$t,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const l in this.paint._values){const f=this.paint.get(l);if(f instanceof uo&&qr(f.property.specification)&&(f.value.kind==="source"||f.value.kind==="composite")&&f.value.isStateDependent)return!0}return!1}}const pA={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class va{constructor(l,f){this._structArray=l,this._pos1=f*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class us{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(l,f){return l._trim(),f&&(l.isTransferred=!0,f.push(l.arrayBuffer)),{length:l.length,arrayBuffer:l.arrayBuffer}}static deserialize(l){const f=Object.create(this.prototype);return f.arrayBuffer=l.arrayBuffer,f.length=l.length,f.capacity=l.arrayBuffer.byteLength/f.bytesPerElement,f._refreshViews(),f}_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(l){this.reserve(l),this.length=l}reserve(l){if(l>this.capacity){this.capacity=Math.max(l,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const f=this.uint8;this._refreshViews(),f&&this.uint8.set(f)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Fs(A,l=1){let f=0,w=0;return{members:A.map(I=>{const z=pA[I.type].BYTES_PER_ELEMENT,Q=f=Kh(f,Math.max(l,z)),Z=I.components||1;return w=Math.max(w,z),f+=z*Z,{name:I.name,type:I.type,components:Z,offset:Q}}),size:Kh(f,Math.max(w,l)),alignment:l}}function Kh(A,l){return Math.ceil(A/l)*l}class xl extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f){const w=this.length;return this.resize(w+1),this.emplace(w,l,f)}emplace(l,f,w){const I=2*l;return this.int16[I+0]=f,this.int16[I+1]=w,l}}xl.prototype.bytesPerElement=4,pn("StructArrayLayout2i4",xl);class M extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w,I){const z=this.length;return this.resize(z+1),this.emplace(z,l,f,w,I)}emplace(l,f,w,I,z){const Q=4*l;return this.int16[Q+0]=f,this.int16[Q+1]=w,this.int16[Q+2]=I,this.int16[Q+3]=z,l}}M.prototype.bytesPerElement=8,pn("StructArrayLayout4i8",M);class h extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,z,Q){const Z=this.length;return this.resize(Z+1),this.emplace(Z,l,f,w,I,z,Q)}emplace(l,f,w,I,z,Q,Z){const re=6*l;return this.int16[re+0]=f,this.int16[re+1]=w,this.int16[re+2]=I,this.int16[re+3]=z,this.int16[re+4]=Q,this.int16[re+5]=Z,l}}h.prototype.bytesPerElement=12,pn("StructArrayLayout2i4i12",h);class _ extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,z,Q){const Z=this.length;return this.resize(Z+1),this.emplace(Z,l,f,w,I,z,Q)}emplace(l,f,w,I,z,Q,Z){const re=4*l,ge=8*l;return this.int16[re+0]=f,this.int16[re+1]=w,this.uint8[ge+4]=I,this.uint8[ge+5]=z,this.uint8[ge+6]=Q,this.uint8[ge+7]=Z,l}}_.prototype.bytesPerElement=8,pn("StructArrayLayout2i4ub8",_);class T extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,f){const w=this.length;return this.resize(w+1),this.emplace(w,l,f)}emplace(l,f,w){const I=2*l;return this.float32[I+0]=f,this.float32[I+1]=w,l}}T.prototype.bytesPerElement=8,pn("StructArrayLayout2f8",T);class F extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,z,Q,Z,re,ge,Ce){const Fe=this.length;return this.resize(Fe+1),this.emplace(Fe,l,f,w,I,z,Q,Z,re,ge,Ce)}emplace(l,f,w,I,z,Q,Z,re,ge,Ce,Fe){const Oe=10*l;return this.uint16[Oe+0]=f,this.uint16[Oe+1]=w,this.uint16[Oe+2]=I,this.uint16[Oe+3]=z,this.uint16[Oe+4]=Q,this.uint16[Oe+5]=Z,this.uint16[Oe+6]=re,this.uint16[Oe+7]=ge,this.uint16[Oe+8]=Ce,this.uint16[Oe+9]=Fe,l}}F.prototype.bytesPerElement=20,pn("StructArrayLayout10ui20",F);class O extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe){const je=this.length;return this.resize(je+1),this.emplace(je,l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe)}emplace(l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe,je){const $e=12*l;return this.int16[$e+0]=f,this.int16[$e+1]=w,this.int16[$e+2]=I,this.int16[$e+3]=z,this.uint16[$e+4]=Q,this.uint16[$e+5]=Z,this.uint16[$e+6]=re,this.uint16[$e+7]=ge,this.int16[$e+8]=Ce,this.int16[$e+9]=Fe,this.int16[$e+10]=Oe,this.int16[$e+11]=je,l}}O.prototype.bytesPerElement=24,pn("StructArrayLayout4i4ui4i24",O);class K extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,f,w){const I=this.length;return this.resize(I+1),this.emplace(I,l,f,w)}emplace(l,f,w,I){const z=3*l;return this.float32[z+0]=f,this.float32[z+1]=w,this.float32[z+2]=I,l}}K.prototype.bytesPerElement=12,pn("StructArrayLayout3f12",K);class oe extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(l){const f=this.length;return this.resize(f+1),this.emplace(f,l)}emplace(l,f){return this.uint32[1*l+0]=f,l}}oe.prototype.bytesPerElement=4,pn("StructArrayLayout1ul4",oe);class ue extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,z,Q,Z,re,ge){const Ce=this.length;return this.resize(Ce+1),this.emplace(Ce,l,f,w,I,z,Q,Z,re,ge)}emplace(l,f,w,I,z,Q,Z,re,ge,Ce){const Fe=10*l,Oe=5*l;return this.int16[Fe+0]=f,this.int16[Fe+1]=w,this.int16[Fe+2]=I,this.int16[Fe+3]=z,this.int16[Fe+4]=Q,this.int16[Fe+5]=Z,this.uint32[Oe+3]=re,this.uint16[Fe+8]=ge,this.uint16[Fe+9]=Ce,l}}ue.prototype.bytesPerElement=20,pn("StructArrayLayout6i1ul2ui20",ue);class ve extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,z,Q){const Z=this.length;return this.resize(Z+1),this.emplace(Z,l,f,w,I,z,Q)}emplace(l,f,w,I,z,Q,Z){const re=6*l;return this.int16[re+0]=f,this.int16[re+1]=w,this.int16[re+2]=I,this.int16[re+3]=z,this.int16[re+4]=Q,this.int16[re+5]=Z,l}}ve.prototype.bytesPerElement=12,pn("StructArrayLayout2i2i2i12",ve);class Te extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,z){const Q=this.length;return this.resize(Q+1),this.emplace(Q,l,f,w,I,z)}emplace(l,f,w,I,z,Q){const Z=4*l,re=8*l;return this.float32[Z+0]=f,this.float32[Z+1]=w,this.float32[Z+2]=I,this.int16[re+6]=z,this.int16[re+7]=Q,l}}Te.prototype.bytesPerElement=16,pn("StructArrayLayout2f1f2i16",Te);class ke extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,f,w,I){const z=this.length;return this.resize(z+1),this.emplace(z,l,f,w,I)}emplace(l,f,w,I,z){const Q=12*l,Z=3*l;return this.uint8[Q+0]=f,this.uint8[Q+1]=w,this.float32[Z+1]=I,this.float32[Z+2]=z,l}}ke.prototype.bytesPerElement=12,pn("StructArrayLayout2ub2f12",ke);class We extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f,w){const I=this.length;return this.resize(I+1),this.emplace(I,l,f,w)}emplace(l,f,w,I){const z=3*l;return this.uint16[z+0]=f,this.uint16[z+1]=w,this.uint16[z+2]=I,l}}We.prototype.bytesPerElement=6,pn("StructArrayLayout3ui6",We);class bt extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe,je,$e,Rt,Mt,ri){const gi=this.length;return this.resize(gi+1),this.emplace(gi,l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe,je,$e,Rt,Mt,ri)}emplace(l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe,je,$e,Rt,Mt,ri,gi){const ei=24*l,ui=12*l,Pi=48*l;return this.int16[ei+0]=f,this.int16[ei+1]=w,this.uint16[ei+2]=I,this.uint16[ei+3]=z,this.uint32[ui+2]=Q,this.uint32[ui+3]=Z,this.uint32[ui+4]=re,this.uint16[ei+10]=ge,this.uint16[ei+11]=Ce,this.uint16[ei+12]=Fe,this.float32[ui+7]=Oe,this.float32[ui+8]=je,this.uint8[Pi+36]=$e,this.uint8[Pi+37]=Rt,this.uint8[Pi+38]=Mt,this.uint32[ui+10]=ri,this.int16[ei+22]=gi,l}}bt.prototype.bytesPerElement=48,pn("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",bt);class mt extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe,je,$e,Rt,Mt,ri,gi,ei,ui,Pi,Fi,Sn,fn,mn,an,nn,vn){const gn=this.length;return this.resize(gn+1),this.emplace(gn,l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe,je,$e,Rt,Mt,ri,gi,ei,ui,Pi,Fi,Sn,fn,mn,an,nn,vn)}emplace(l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe,je,$e,Rt,Mt,ri,gi,ei,ui,Pi,Fi,Sn,fn,mn,an,nn,vn,gn){const Ji=34*l,Wn=17*l;return this.int16[Ji+0]=f,this.int16[Ji+1]=w,this.int16[Ji+2]=I,this.int16[Ji+3]=z,this.int16[Ji+4]=Q,this.int16[Ji+5]=Z,this.int16[Ji+6]=re,this.int16[Ji+7]=ge,this.uint16[Ji+8]=Ce,this.uint16[Ji+9]=Fe,this.uint16[Ji+10]=Oe,this.uint16[Ji+11]=je,this.uint16[Ji+12]=$e,this.uint16[Ji+13]=Rt,this.uint16[Ji+14]=Mt,this.uint16[Ji+15]=ri,this.uint16[Ji+16]=gi,this.uint16[Ji+17]=ei,this.uint16[Ji+18]=ui,this.uint16[Ji+19]=Pi,this.uint16[Ji+20]=Fi,this.uint16[Ji+21]=Sn,this.uint16[Ji+22]=fn,this.uint32[Wn+12]=mn,this.float32[Wn+13]=an,this.float32[Wn+14]=nn,this.float32[Wn+15]=vn,this.float32[Wn+16]=gn,l}}mt.prototype.bytesPerElement=68,pn("StructArrayLayout8i15ui1ul4f68",mt);class gt extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l){const f=this.length;return this.resize(f+1),this.emplace(f,l)}emplace(l,f){return this.float32[1*l+0]=f,l}}gt.prototype.bytesPerElement=4,pn("StructArrayLayout1f4",gt);class Vt extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w){const I=this.length;return this.resize(I+1),this.emplace(I,l,f,w)}emplace(l,f,w,I){const z=3*l;return this.int16[z+0]=f,this.int16[z+1]=w,this.int16[z+2]=I,l}}Vt.prototype.bytesPerElement=6,pn("StructArrayLayout3i6",Vt);class Zt extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f,w){const I=this.length;return this.resize(I+1),this.emplace(I,l,f,w)}emplace(l,f,w,I){const z=4*l;return this.uint32[2*l+0]=f,this.uint16[z+2]=w,this.uint16[z+3]=I,l}}Zt.prototype.bytesPerElement=8,pn("StructArrayLayout1ul2ui8",Zt);class ni extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f){const w=this.length;return this.resize(w+1),this.emplace(w,l,f)}emplace(l,f,w){const I=2*l;return this.uint16[I+0]=f,this.uint16[I+1]=w,l}}ni.prototype.bytesPerElement=4,pn("StructArrayLayout2ui4",ni);class St extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l){const f=this.length;return this.resize(f+1),this.emplace(f,l)}emplace(l,f){return this.uint16[1*l+0]=f,l}}St.prototype.bytesPerElement=2,pn("StructArrayLayout1ui2",St);class zt extends us{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,f,w,I){const z=this.length;return this.resize(z+1),this.emplace(z,l,f,w,I)}emplace(l,f,w,I,z){const Q=4*l;return this.float32[Q+0]=f,this.float32[Q+1]=w,this.float32[Q+2]=I,this.float32[Q+3]=z,l}}zt.prototype.bytesPerElement=16,pn("StructArrayLayout4f16",zt);class li extends va{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new xe(this.anchorPointX,this.anchorPointY)}}li.prototype.size=20;class Ei extends ue{get(l){return new li(this,l)}}pn("CollisionBoxArray",Ei);class bi extends va{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(l){this._structArray.uint8[this._pos1+37]=l}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(l){this._structArray.uint8[this._pos1+38]=l}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(l){this._structArray.uint32[this._pos4+10]=l}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}bi.prototype.size=48;class Hi extends bt{get(l){return new bi(this,l)}}pn("PlacedSymbolArray",Hi);class xi extends va{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(l){this._structArray.uint32[this._pos4+12]=l}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get textOffset0(){return this._structArray.float32[this._pos4+14]}get textOffset1(){return this._structArray.float32[this._pos4+15]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+16]}}xi.prototype.size=68;class xn extends mt{get(l){return new xi(this,l)}}pn("SymbolInstanceArray",xn);class cn extends gt{getoffsetX(l){return this.float32[1*l+0]}}pn("GlyphOffsetArray",cn);class Bn extends Vt{getx(l){return this.int16[3*l+0]}gety(l){return this.int16[3*l+1]}gettileUnitDistanceFromAnchor(l){return this.int16[3*l+2]}}pn("SymbolLineVertexArray",Bn);class tr extends va{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]}}tr.prototype.size=8;class ur extends Zt{get(l){return new tr(this,l)}}pn("FeatureIndexArray",ur);class Un extends xl{}class Lr extends xl{}class Rr extends xl{}class Cr extends h{}class Er extends _{}class Gr extends T{}class js extends F{}class wa extends O{}class Aa extends K{}class ba extends oe{}class ja extends ve{}class Wo extends ke{}class mo extends We{}class Ba extends ni{}const $l=Fs([{name:"a_pos",components:2,type:"Int16"}],4),{members:x}=$l;class a{constructor(l=[]){this.segments=l}prepareSegment(l,f,w,I){let z=this.segments[this.segments.length-1];return l>a.MAX_VERTEX_ARRAY_LENGTH&&me(`Max vertices per segment is ${a.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${l}`),(!z||z.vertexLength+l>a.MAX_VERTEX_ARRAY_LENGTH||z.sortKey!==I)&&(z={vertexOffset:f.length,primitiveOffset:w.length,vertexLength:0,primitiveLength:0},I!==void 0&&(z.sortKey=I),this.segments.push(z)),z}get(){return this.segments}destroy(){for(const l of this.segments)for(const f in l.vaos)l.vaos[f].destroy()}static simpleSegment(l,f,w,I){return new a([{vertexOffset:l,primitiveOffset:f,vertexLength:w,primitiveLength:I,vaos:{},sortKey:0}])}}function m(A,l){return 256*(A=R(Math.floor(A),0,255))+R(Math.floor(l),0,255)}a.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,pn("SegmentVector",a);const b=Fs([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var S={exports:{}},P={exports:{}};P.exports=function(A,l){var f,w,I,z,Q,Z,re,ge;for(w=A.length-(f=3&A.length),I=l,Q=3432918353,Z=461845907,ge=0;ge>>16)*Q&65535)<<16)&4294967295)<<15|re>>>17))*Z+(((re>>>16)*Z&65535)<<16)&4294967295)<<13|I>>>19))+((5*(I>>>16)&65535)<<16)&4294967295))+((58964+(z>>>16)&65535)<<16);switch(re=0,f){case 3:re^=(255&A.charCodeAt(ge+2))<<16;case 2:re^=(255&A.charCodeAt(ge+1))<<8;case 1:I^=re=(65535&(re=(re=(65535&(re^=255&A.charCodeAt(ge)))*Q+(((re>>>16)*Q&65535)<<16)&4294967295)<<15|re>>>17))*Z+(((re>>>16)*Z&65535)<<16)&4294967295}return I^=A.length,I=2246822507*(65535&(I^=I>>>16))+((2246822507*(I>>>16)&65535)<<16)&4294967295,I=3266489909*(65535&(I^=I>>>13))+((3266489909*(I>>>16)&65535)<<16)&4294967295,(I^=I>>>16)>>>0};var H={exports:{}};H.exports=function(A,l){for(var f,w=A.length,I=l^w,z=0;w>=4;)f=1540483477*(65535&(f=255&A.charCodeAt(z)|(255&A.charCodeAt(++z))<<8|(255&A.charCodeAt(++z))<<16|(255&A.charCodeAt(++z))<<24))+((1540483477*(f>>>16)&65535)<<16),I=1540483477*(65535&I)+((1540483477*(I>>>16)&65535)<<16)^(f=1540483477*(65535&(f^=f>>>24))+((1540483477*(f>>>16)&65535)<<16)),w-=4,++z;switch(w){case 3:I^=(255&A.charCodeAt(z+2))<<16;case 2:I^=(255&A.charCodeAt(z+1))<<8;case 1:I=1540483477*(65535&(I^=255&A.charCodeAt(z)))+((1540483477*(I>>>16)&65535)<<16)}return I=1540483477*(65535&(I^=I>>>13))+((1540483477*(I>>>16)&65535)<<16),(I^=I>>>15)>>>0};var W=P.exports,ee=H.exports;S.exports=W,S.exports.murmur3=W,S.exports.murmur2=ee;class pe{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(l,f,w,I){this.ids.push(fe(l)),this.positions.push(f,w,I)}getPositions(l){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const f=fe(l);let w=0,I=this.ids.length-1;for(;w>1;this.ids[Q]>=f?I=Q:w=Q+1}const z=[];for(;this.ids[w]===f;)z.push({index:this.positions[3*w],start:this.positions[3*w+1],end:this.positions[3*w+2]}),w++;return z}static serialize(l,f){const w=new Float64Array(l.ids),I=new Uint32Array(l.positions);return Se(w,I,0,w.length-1),f&&f.push(w.buffer,I.buffer),{ids:w,positions:I}}static deserialize(l){const f=new pe;return f.ids=l.ids,f.positions=l.positions,f.indexed=!0,f}}function fe(A){const l=+A;return!isNaN(l)&&l<=Number.MAX_SAFE_INTEGER?l:S.exports(String(A))}function Se(A,l,f,w){for(;f>1];let z=f-1,Q=w+1;for(;;){do z++;while(A[z]I);if(z>=Q)break;Qe(A,z,Q),Qe(l,3*z,3*Q),Qe(l,3*z+1,3*Q+1),Qe(l,3*z+2,3*Q+2)}Q-f`u_${I}`),this.type=w}setUniform(l,f,w){l.set(w.constantOr(this.value))}getBinding(l,f,w){return this.type==="color"?new Xe(l,f):new nt(l,f)}}class Bt{constructor(l,f){this.uniformNames=f.map(w=>`u_${w}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(l,f){this.pixelRatioFrom=f.pixelRatio,this.pixelRatioTo=l.pixelRatio,this.patternFrom=f.tlbr,this.patternTo=l.tlbr}setUniform(l,f,w,I){const z=I==="u_pattern_to"?this.patternTo:I==="u_pattern_from"?this.patternFrom:I==="u_pixel_ratio_to"?this.pixelRatioTo:I==="u_pixel_ratio_from"?this.pixelRatioFrom:null;z&&l.set(z)}getBinding(l,f,w){return w.substr(0,9)==="u_pattern"?new lt(l,f):new nt(l,f)}}class Pt{constructor(l,f,w,I){this.expression=l,this.type=w,this.maxValue=0,this.paintVertexAttributes=f.map(z=>({name:`a_${z}`,type:"Float32",components:w==="color"?2:1,offset:0})),this.paintVertexArray=new I}populatePaintArray(l,f,w,I,z){const Q=this.paintVertexArray.length,Z=this.expression.evaluate(new Zr(0),f,{},I,[],z);this.paintVertexArray.resize(l),this._setPaintValue(Q,l,Z)}updatePaintArray(l,f,w,I){const z=this.expression.evaluate({zoom:0},w,I);this._setPaintValue(l,f,z)}_setPaintValue(l,f,w){if(this.type==="color"){const I=At(w);for(let z=l;z`u_${Z}_t`),this.type=w,this.useIntegerZoom=I,this.zoom=z,this.maxValue=0,this.paintVertexAttributes=f.map(Z=>({name:`a_${Z}`,type:"Float32",components:w==="color"?4:2,offset:0})),this.paintVertexArray=new Q}populatePaintArray(l,f,w,I,z){const Q=this.expression.evaluate(new Zr(this.zoom),f,{},I,[],z),Z=this.expression.evaluate(new Zr(this.zoom+1),f,{},I,[],z),re=this.paintVertexArray.length;this.paintVertexArray.resize(l),this._setPaintValue(re,l,Q,Z)}updatePaintArray(l,f,w,I){const z=this.expression.evaluate({zoom:this.zoom},w,I),Q=this.expression.evaluate({zoom:this.zoom+1},w,I);this._setPaintValue(l,f,z,Q)}_setPaintValue(l,f,w,I){if(this.type==="color"){const z=At(w),Q=At(I);for(let Z=l;Z`#define HAS_UNIFORM_${I}`))}return l}getBinderAttributes(){const l=[];for(const f in this.binders){const w=this.binders[f];if(w instanceof Pt||w instanceof It)for(let I=0;I!0){this.programConfigurations={};for(const I of l)this.programConfigurations[I.id]=new hi(I,f,w);this.needsUpload=!1,this._featureMap=new pe,this._bufferOffset=0}populatePaintArrays(l,f,w,I,z,Q){for(const Z in this.programConfigurations)this.programConfigurations[Z].populatePaintArrays(l,f,I,z,Q);f.id!==void 0&&this._featureMap.add(f.id,w,this._bufferOffset,l),this._bufferOffset=l,this.needsUpload=!0}updatePaintArrays(l,f,w,I){for(const z of w)this.needsUpload=this.programConfigurations[z.id].updatePaintArrays(l,this._featureMap,f,z,I)||this.needsUpload}get(l){return this.programConfigurations[l]}upload(l){if(this.needsUpload){for(const f in this.programConfigurations)this.programConfigurations[f].upload(l);this.needsUpload=!1}}destroy(){for(const l in this.programConfigurations)this.programConfigurations[l].destroy()}}function qt(A,l){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[A]||[A.replace(`${l}-`,"").replace(/-/g,"_")]}function ji(A,l,f){const w={color:{source:T,composite:zt},number:{source:gt,composite:T}},I=function(z){return{"line-pattern":{source:js,composite:js},"fill-pattern":{source:js,composite:js},"fill-extrusion-pattern":{source:js,composite:js}}[z]}(A);return I&&I[f]||w[l][f]}pn("ConstantBinder",ht),pn("CrossFadedConstantBinder",Bt),pn("SourceExpressionBinder",Pt),pn("CrossFadedCompositeBinder",Ht),pn("CompositeExpressionBinder",It),pn("ProgramConfiguration",hi,{omit:["_buffers"]}),pn("ProgramConfigurationSet",si);var Kt=8192;const Bi=Math.pow(2,14)-1,di=-Bi-1;function Ri(A){const l=Kt/A.extent,f=A.loadGeometry();for(let w=0;wQ.x+1||reQ.y+1)&&me("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return f}function Ai(A,l){return{type:A.type,id:A.id,properties:A.properties,geometry:l?Ri(A):[]}}function Mi(A,l,f,w,I){A.emplaceBack(2*l+(w+1)/2,2*f+(I+1)/2)}class $i{constructor(l){this.zoom=l.zoom,this.overscaling=l.overscaling,this.layers=l.layers,this.layerIds=this.layers.map(f=>f.id),this.index=l.index,this.hasPattern=!1,this.layoutVertexArray=new Lr,this.indexArray=new mo,this.segments=new a,this.programConfigurations=new si(l.layers,l.zoom),this.stateDependentLayerIds=this.layers.filter(f=>f.isStateDependent()).map(f=>f.id)}populate(l,f,w){const I=this.layers[0],z=[];let Q=null,Z=!1;I.type==="circle"&&(Q=I.layout.get("circle-sort-key"),Z=!Q.isConstant());for(const{feature:re,id:ge,index:Ce,sourceLayerIndex:Fe}of l){const Oe=this.layers[0]._featureFilter.needGeometry,je=Ai(re,Oe);if(!this.layers[0]._featureFilter.filter(new Zr(this.zoom),je,w))continue;const $e=Z?Q.evaluate(je,{},w):void 0,Rt={id:ge,properties:re.properties,type:re.type,sourceLayerIndex:Fe,index:Ce,geometry:Oe?je.geometry:Ri(re),patterns:{},sortKey:$e};z.push(Rt)}Z&&z.sort((re,ge)=>re.sortKey-ge.sortKey);for(const re of z){const{geometry:ge,index:Ce,sourceLayerIndex:Fe}=re,Oe=l[Ce].feature;this.addFeature(re,ge,Ce,w),f.featureIndex.insert(Oe,ge,Ce,Fe,this.index)}}update(l,f,w){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(l,f,this.stateDependentLayers,w)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,x),this.indexBuffer=l.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(l),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(l,f,w,I){for(const z of f)for(const Q of z){const Z=Q.x,re=Q.y;if(Z<0||Z>=Kt||re<0||re>=Kt)continue;const ge=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,l.sortKey),Ce=ge.vertexLength;Mi(this.layoutVertexArray,Z,re,-1,-1),Mi(this.layoutVertexArray,Z,re,1,-1),Mi(this.layoutVertexArray,Z,re,1,1),Mi(this.layoutVertexArray,Z,re,-1,1),this.indexArray.emplaceBack(Ce,Ce+1,Ce+2),this.indexArray.emplaceBack(Ce,Ce+3,Ce+2),ge.vertexLength+=4,ge.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,l,w,{},I)}}function Jt(A,l){for(let f=0;f1){if(Mn(A,l))return!0;for(let w=0;w1?f:f.sub(l)._mult(I)._add(l))}function _n(A,l){let f,w,I,z=!1;for(let Q=0;Ql.y!=I.y>l.y&&l.x<(I.x-w.x)*(l.y-w.y)/(I.y-w.y)+w.x&&(z=!z)}return z}function Dr(A,l){let f=!1;for(let w=0,I=A.length-1;wl.y!=Q.y>l.y&&l.x<(Q.x-z.x)*(l.y-z.y)/(Q.y-z.y)+z.x&&(f=!f)}return f}function Or(A,l,f){const w=f[0],I=f[2];if(A.xI.x&&l.x>I.x||A.yI.y&&l.y>I.y)return!1;const z=Pe(A,l,f[0]);return z!==Pe(A,l,f[1])||z!==Pe(A,l,f[2])||z!==Pe(A,l,f[3])}function Nr(A,l,f){const w=l.paint.get(A).value;return w.kind==="constant"?w.value:f.programConfigurations.get(l.id).getMaxValue(A)}function Qr(A){return Math.sqrt(A[0]*A[0]+A[1]*A[1])}function go(A,l,f,w,I){if(!l[0]&&!l[1])return A;const z=xe.convert(l)._mult(I);f==="viewport"&&z._rotate(-w);const Q=[];for(let Z=0;ZA.width||I.height>A.height||f.x>A.width-I.width||f.y>A.height-I.height)throw new RangeError("out of range source coordinates for image copy");if(I.width>l.width||I.height>l.height||w.x>l.width-I.width||w.y>l.height-I.height)throw new RangeError("out of range destination coordinates for image copy");const Q=A.data,Z=l.data;if(Q===Z)throw new Error("srcData equals dstData, so image is already copied");for(let re=0;re{l[A.evaluationKey]=re;const ge=A.expression.evaluate(l);I.data[Q+Z+0]=Math.floor(255*ge.r/ge.a),I.data[Q+Z+1]=Math.floor(255*ge.g/ge.a),I.data[Q+Z+2]=Math.floor(255*ge.b/ge.a),I.data[Q+Z+3]=Math.floor(255*ge.a)};if(A.clips)for(let Q=0,Z=0;Q80*f){w=z=A[0],I=Q=A[1];for(var $e=f;$ez&&(z=Z),re>Q&&(Q=re);ge=(ge=Math.max(z-w,Q-I))!==0?32767/ge:0}return ad(Oe,je,f,w,I,ge,0),je}function ag(A,l,f,w,I){var z,Q;if(I===gA(A,l,f,w)>0)for(z=l;z=l;z-=w)Q=Ry(z,A[z],A[z+1],Q);return Q&&fA(Q,Q.next)&&(mp(Q),Q=Q.next),Q}function Bu(A,l){if(!A)return A;l||(l=A);var f,w=A;do if(f=!1,w.steiner||!fA(w,w.next)&&Ds(w.prev,w,w.next)!==0)w=w.next;else{if(mp(w),(w=l=w.prev)===w.next)break;f=!0}while(f||w!==l);return l}function ad(A,l,f,w,I,z,Q){if(A){!Q&&z&&function(Ce,Fe,Oe,je){var $e=Ce;do $e.z===0&&($e.z=Cf($e.x,$e.y,Fe,Oe,je)),$e.prevZ=$e.prev,$e.nextZ=$e.next,$e=$e.next;while($e!==Ce);$e.prevZ.nextZ=null,$e.prevZ=null,function(Rt){var Mt,ri,gi,ei,ui,Pi,Fi,Sn,fn=1;do{for(ri=Rt,Rt=null,ui=null,Pi=0;ri;){for(Pi++,gi=ri,Fi=0,Mt=0;Mt0||Sn>0&&gi;)Fi!==0&&(Sn===0||!gi||ri.z<=gi.z)?(ei=ri,ri=ri.nextZ,Fi--):(ei=gi,gi=gi.nextZ,Sn--),ui?ui.nextZ=ei:Rt=ei,ei.prevZ=ui,ui=ei;ri=gi}ui.nextZ=null,fn*=2}while(Pi>1)}($e)}(A,w,I,z);for(var Z,re,ge=A;A.prev!==A.next;)if(Z=A.prev,re=A.next,z?Fy(A,w,I,z):Iy(A))l.push(Z.i/f|0),l.push(A.i/f|0),l.push(re.i/f|0),mp(A),A=re.next,ge=re.next;else if((A=re)===ge){Q?Q===1?ad(A=r1(Bu(A),l,f),l,f,w,I,z,2):Q===2&&s1(A,l,f,w,I,z):ad(Bu(A),l,f,w,I,z,1);break}}}function Iy(A){var l=A.prev,f=A,w=A.next;if(Ds(l,f,w)>=0)return!1;for(var I=l.x,z=f.x,Q=w.x,Z=l.y,re=f.y,ge=w.y,Ce=Iz?I>Q?I:Q:z>Q?z:Q,je=Z>re?Z>ge?Z:ge:re>ge?re:ge,$e=w.next;$e!==l;){if($e.x>=Ce&&$e.x<=Oe&&$e.y>=Fe&&$e.y<=je&&qh(I,Z,z,re,Q,ge,$e.x,$e.y)&&Ds($e.prev,$e,$e.next)>=0)return!1;$e=$e.next}return!0}function Fy(A,l,f,w){var I=A.prev,z=A,Q=A.next;if(Ds(I,z,Q)>=0)return!1;for(var Z=I.x,re=z.x,ge=Q.x,Ce=I.y,Fe=z.y,Oe=Q.y,je=Zre?Z>ge?Z:ge:re>ge?re:ge,Mt=Ce>Fe?Ce>Oe?Ce:Oe:Fe>Oe?Fe:Oe,ri=Cf(je,$e,l,f,w),gi=Cf(Rt,Mt,l,f,w),ei=A.prevZ,ui=A.nextZ;ei&&ei.z>=ri&&ui&&ui.z<=gi;){if(ei.x>=je&&ei.x<=Rt&&ei.y>=$e&&ei.y<=Mt&&ei!==I&&ei!==Q&&qh(Z,Ce,re,Fe,ge,Oe,ei.x,ei.y)&&Ds(ei.prev,ei,ei.next)>=0||(ei=ei.prevZ,ui.x>=je&&ui.x<=Rt&&ui.y>=$e&&ui.y<=Mt&&ui!==I&&ui!==Q&&qh(Z,Ce,re,Fe,ge,Oe,ui.x,ui.y)&&Ds(ui.prev,ui,ui.next)>=0))return!1;ui=ui.nextZ}for(;ei&&ei.z>=ri;){if(ei.x>=je&&ei.x<=Rt&&ei.y>=$e&&ei.y<=Mt&&ei!==I&&ei!==Q&&qh(Z,Ce,re,Fe,ge,Oe,ei.x,ei.y)&&Ds(ei.prev,ei,ei.next)>=0)return!1;ei=ei.prevZ}for(;ui&&ui.z<=gi;){if(ui.x>=je&&ui.x<=Rt&&ui.y>=$e&&ui.y<=Mt&&ui!==I&&ui!==Q&&qh(Z,Ce,re,Fe,ge,Oe,ui.x,ui.y)&&Ds(ui.prev,ui,ui.next)>=0)return!1;ui=ui.nextZ}return!0}function r1(A,l,f){var w=A;do{var I=w.prev,z=w.next.next;!fA(I,z)&&oh(I,w,w.next,z)&&cd(I,z)&&cd(z,I)&&(l.push(I.i/f|0),l.push(w.i/f|0),l.push(z.i/f|0),mp(w),mp(w.next),w=A=z),w=w.next}while(w!==A);return Bu(w)}function s1(A,l,f,w,I,z){var Q=A;do{for(var Z=Q.next.next;Z!==Q.prev;){if(Q.i!==Z.i&&Py(Q,Z)){var re=Uy(Q,Z);return Q=Bu(Q,Q.next),re=Bu(re,re.next),ad(Q,l,f,w,I,z,0),void ad(re,l,f,w,I,z,0)}Z=Z.next}Q=Q.next}while(Q!==A)}function ld(A,l){return A.x-l.x}function Ly(A,l){var f=function(I,z){var Q,Z=z,re=I.x,ge=I.y,Ce=-1/0;do{if(ge<=Z.y&&ge>=Z.next.y&&Z.next.y!==Z.y){var Fe=Z.x+(ge-Z.y)*(Z.next.x-Z.x)/(Z.next.y-Z.y);if(Fe<=re&&Fe>Ce&&(Ce=Fe,Q=Z.x=Z.x&&Z.x>=$e&&re!==Z.x&&qh(geQ.x||Z.x===Q.x&&Dy(Q,Z)))&&(Q=Z,Mt=Oe)),Z=Z.next;while(Z!==je);return Q}(A,l);if(!f)return l;var w=Uy(f,A);return Bu(w,w.next),Bu(f,f.next)}function Dy(A,l){return Ds(A.prev,A,l.prev)<0&&Ds(l.next,A,A.next)<0}function Cf(A,l,f,w,I){return(A=1431655765&((A=858993459&((A=252645135&((A=16711935&((A=(A-f)*I|0)|A<<8))|A<<4))|A<<2))|A<<1))|(l=1431655765&((l=858993459&((l=252645135&((l=16711935&((l=(l-w)*I|0)|l<<8))|l<<4))|l<<2))|l<<1))<<1}function o1(A){var l=A,f=A;do(l.x=(A-Q)*(z-Z)&&(A-Q)*(w-Z)>=(f-Q)*(l-Z)&&(f-Q)*(z-Z)>=(I-Q)*(w-Z)}function Py(A,l){return A.next.i!==l.i&&A.prev.i!==l.i&&!function(f,w){var I=f;do{if(I.i!==f.i&&I.next.i!==f.i&&I.i!==w.i&&I.next.i!==w.i&&oh(I,I.next,f,w))return!0;I=I.next}while(I!==f);return!1}(A,l)&&(cd(A,l)&&cd(l,A)&&function(f,w){var I=f,z=!1,Q=(f.x+w.x)/2,Z=(f.y+w.y)/2;do I.y>Z!=I.next.y>Z&&I.next.y!==I.y&&Q<(I.next.x-I.x)*(Z-I.y)/(I.next.y-I.y)+I.x&&(z=!z),I=I.next;while(I!==f);return z}(A,l)&&(Ds(A.prev,A,l.prev)||Ds(A,l.prev,l))||fA(A,l)&&Ds(A.prev,A,A.next)>0&&Ds(l.prev,l,l.next)>0)}function Ds(A,l,f){return(l.y-A.y)*(f.x-l.x)-(l.x-A.x)*(f.y-l.y)}function fA(A,l){return A.x===l.x&&A.y===l.y}function oh(A,l,f,w){var I=fp(Ds(A,l,f)),z=fp(Ds(A,l,w)),Q=fp(Ds(f,w,A)),Z=fp(Ds(f,w,l));return I!==z&&Q!==Z||!(I!==0||!mA(A,f,l))||!(z!==0||!mA(A,w,l))||!(Q!==0||!mA(f,A,w))||!(Z!==0||!mA(f,l,w))}function mA(A,l,f){return l.x<=Math.max(A.x,f.x)&&l.x>=Math.min(A.x,f.x)&&l.y<=Math.max(A.y,f.y)&&l.y>=Math.min(A.y,f.y)}function fp(A){return A>0?1:A<0?-1:0}function cd(A,l){return Ds(A.prev,A,A.next)<0?Ds(A,l,A.next)>=0&&Ds(A,A.prev,l)>=0:Ds(A,l,A.prev)<0||Ds(A,A.next,l)<0}function Uy(A,l){var f=new gp(A.i,A.x,A.y),w=new gp(l.i,l.x,l.y),I=A.next,z=l.prev;return A.next=l,l.prev=A,f.next=I,I.prev=f,w.next=f,f.prev=w,z.next=w,w.prev=z,w}function Ry(A,l,f,w){var I=new gp(A,l,f);return w?(I.next=w.next,I.prev=w,w.next.prev=I,w.next=I):(I.prev=I,I.next=I),I}function mp(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 gp(A,l,f){this.i=A,this.x=l,this.y=f,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function gA(A,l,f,w){for(var I=0,z=l,Q=f-w;zf;){if(w-f>600){var z=w-f+1,Q=l-f+1,Z=Math.log(z),re=.5*Math.exp(2*Z/3),ge=.5*Math.sqrt(Z*re*(z-re)/z)*(Q-z/2<0?-1:1);ah(A,l,Math.max(f,Math.floor(l-Q*re/z+ge)),Math.min(w,Math.floor(l+(z-Q)*re/z+ge)),I)}var Ce=A[l],Fe=f,Oe=w;for(Ta(A,f,l),I(A[w],Ce)>0&&Ta(A,f,w);Fe0;)Oe--}I(A[f],Ce)===0?Ta(A,f,Oe):Ta(A,++Oe,w),Oe<=l&&(f=Oe+1),l<=Oe&&(w=Oe-1)}}function Ta(A,l,f){var w=A[l];A[l]=A[f],A[f]=w}function Cu(A,l){return Al?1:0}function lh(A,l){const f=A.length;if(f<=1)return[A];const w=[];let I,z;for(let Q=0;Q1)for(let Q=0;Q0&&f.holes.push(w+=A[I-1].length)}return f};class hg{constructor(l){this.zoom=l.zoom,this.overscaling=l.overscaling,this.layers=l.layers,this.layerIds=this.layers.map(f=>f.id),this.index=l.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Rr,this.indexArray=new mo,this.indexArray2=new Ba,this.programConfigurations=new si(l.layers,l.zoom),this.segments=new a,this.segments2=new a,this.stateDependentLayerIds=this.layers.filter(f=>f.isStateDependent()).map(f=>f.id)}populate(l,f,w){this.hasPattern=lg("fill",this.layers,f);const I=this.layers[0].layout.get("fill-sort-key"),z=!I.isConstant(),Q=[];for(const{feature:Z,id:re,index:ge,sourceLayerIndex:Ce}of l){const Fe=this.layers[0]._featureFilter.needGeometry,Oe=Ai(Z,Fe);if(!this.layers[0]._featureFilter.filter(new Zr(this.zoom),Oe,w))continue;const je=z?I.evaluate(Oe,{},w,f.availableImages):void 0,$e={id:re,properties:Z.properties,type:Z.type,sourceLayerIndex:Ce,index:ge,geometry:Fe?Oe.geometry:Ri(Z),patterns:{},sortKey:je};Q.push($e)}z&&Q.sort((Z,re)=>Z.sortKey-re.sortKey);for(const Z of Q){const{geometry:re,index:ge,sourceLayerIndex:Ce}=Z;if(this.hasPattern){const Fe=cg("fill",this.layers,Z,this.zoom,f);this.patternFeatures.push(Fe)}else this.addFeature(Z,re,ge,w,{});f.featureIndex.insert(l[ge].feature,re,ge,Ce,this.index)}}update(l,f,w){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(l,f,this.stateDependentLayers,w)}addFeatures(l,f,w){for(const I of this.patternFeatures)this.addFeature(I,I.geometry,I.index,f,w)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,My),this.indexBuffer=l.createIndexBuffer(this.indexArray),this.indexBuffer2=l.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(l),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(l,f,w,I,z){for(const Q of lh(f,500)){let Z=0;for(const je of Q)Z+=je.length;const re=this.segments.prepareSegment(Z,this.layoutVertexArray,this.indexArray),ge=re.vertexLength,Ce=[],Fe=[];for(const je of Q){if(je.length===0)continue;je!==Q[0]&&Fe.push(Ce.length/2);const $e=this.segments2.prepareSegment(je.length,this.layoutVertexArray,this.indexArray2),Rt=$e.vertexLength;this.layoutVertexArray.emplaceBack(je[0].x,je[0].y),this.indexArray2.emplaceBack(Rt+je.length-1,Rt),Ce.push(je[0].x),Ce.push(je[0].y);for(let Mt=1;Mt>3}if(I--,w===1||w===2)z+=A.readSVarint(),Q+=A.readSVarint(),w===1&&(l&&Z.push(l),l=[]),l.push(new to(z,Q));else{if(w!==7)throw new Error("unknown command "+w);l&&l.push(l[0].clone())}}return l&&Z.push(l),Z},wl.prototype.bbox=function(){var A=this._pbf;A.pos=this._geometry;for(var l=A.readVarint()+A.pos,f=1,w=0,I=0,z=0,Q=1/0,Z=-1/0,re=1/0,ge=-1/0;A.pos>3}if(w--,f===1||f===2)(I+=A.readSVarint())Z&&(Z=I),(z+=A.readSVarint())ge&&(ge=z);else if(f!==7)throw new Error("unknown command "+f)}return[Q,re,Z,ge]},wl.prototype.toGeoJSON=function(A,l,f){var w,I,z=this.extent*Math.pow(2,f),Q=this.extent*A,Z=this.extent*l,re=this.loadGeometry(),ge=wl.types[this.type];function Ce(je){for(var $e=0;$e>3;I=Q===1?w.readString():Q===2?w.readFloat():Q===3?w.readDouble():Q===4?w.readVarint64():Q===5?w.readVarint():Q===6?w.readSVarint():Q===7?w.readBoolean():null}return I}(f))}vc.prototype.feature=function(A){if(A<0||A>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[A];var l=this._pbf.readVarint()+this._pbf.pos;return new ky(this._pbf,l,this.extent,this._keys,this._values)};var Xl=Sf;function bl(A,l,f){if(A===3){var w=new Xl(f,f.readVarint()+f.pos);w.length&&(l[w.name]=w)}}Eu.VectorTile=function(A,l){this.layers=A.readFields(bl,{},l)},Eu.VectorTileFeature=Zn,Eu.VectorTileLayer=Sf;const Fo=Eu.VectorTileFeature.types,Mf=Math.pow(2,13);function Za(A,l,f,w,I,z,Q,Z){A.emplaceBack(l,f,2*Math.floor(w*Mf)+Q,I*Mf*2,z*Mf*2,Math.round(Z))}class If{constructor(l){this.zoom=l.zoom,this.overscaling=l.overscaling,this.layers=l.layers,this.layerIds=this.layers.map(f=>f.id),this.index=l.index,this.hasPattern=!1,this.layoutVertexArray=new Cr,this.centroidVertexArray=new Un,this.indexArray=new mo,this.programConfigurations=new si(l.layers,l.zoom),this.segments=new a,this.stateDependentLayerIds=this.layers.filter(f=>f.isStateDependent()).map(f=>f.id)}populate(l,f,w){this.features=[],this.hasPattern=lg("fill-extrusion",this.layers,f);for(const{feature:I,id:z,index:Q,sourceLayerIndex:Z}of l){const re=this.layers[0]._featureFilter.needGeometry,ge=Ai(I,re);if(!this.layers[0]._featureFilter.filter(new Zr(this.zoom),ge,w))continue;const Ce={id:z,sourceLayerIndex:Z,index:Q,geometry:re?ge.geometry:Ri(I),properties:I.properties,type:I.type,patterns:{}};this.hasPattern?this.features.push(cg("fill-extrusion",this.layers,Ce,this.zoom,f)):this.addFeature(Ce,Ce.geometry,Q,w,{}),f.featureIndex.insert(I,Ce.geometry,Q,Z,this.index,!0)}}addFeatures(l,f,w){for(const I of this.features){const{geometry:z}=I;this.addFeature(I,z,I.index,f,w)}}update(l,f,w){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(l,f,this.stateDependentLayers,w)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,l1),this.centroidVertexBuffer=l.createVertexBuffer(this.centroidVertexArray,xc.members,!0),this.indexBuffer=l.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(l),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(l,f,w,I,z){const Q={x:0,y:0,vertexCount:0};for(const Z of lh(f,500)){let re=0;for(const $e of Z)re+=$e.length;let ge=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const $e of Z){if($e.length===0||ug($e))continue;let Rt=0;for(let Mt=0;Mt<$e.length;Mt++){const ri=$e[Mt];if(Mt>=1){const gi=$e[Mt-1];if(!ud(ri,gi)){ge.vertexLength+4>a.MAX_VERTEX_ARRAY_LENGTH&&(ge=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const ei=ri.sub(gi)._perp()._unit(),ui=gi.dist(ri);Rt+ui>32768&&(Rt=0),Za(this.layoutVertexArray,ri.x,ri.y,ei.x,ei.y,0,0,Rt),Za(this.layoutVertexArray,ri.x,ri.y,ei.x,ei.y,0,1,Rt),Q.x+=2*ri.x,Q.y+=2*ri.y,Q.vertexCount+=2,Rt+=ui,Za(this.layoutVertexArray,gi.x,gi.y,ei.x,ei.y,0,0,Rt),Za(this.layoutVertexArray,gi.x,gi.y,ei.x,ei.y,0,1,Rt),Q.x+=2*gi.x,Q.y+=2*gi.y,Q.vertexCount+=2;const Pi=ge.vertexLength;this.indexArray.emplaceBack(Pi,Pi+2,Pi+1),this.indexArray.emplaceBack(Pi+1,Pi+2,Pi+3),ge.vertexLength+=4,ge.primitiveLength+=2}}}}if(ge.vertexLength+re>a.MAX_VERTEX_ARRAY_LENGTH&&(ge=this.segments.prepareSegment(re,this.layoutVertexArray,this.indexArray)),Fo[l.type]!=="Polygon")continue;const Ce=[],Fe=[],Oe=ge.vertexLength;for(const $e of Z)if($e.length!==0){$e!==Z[0]&&Fe.push(Ce.length/2);for(let Rt=0;Rt<$e.length;Rt++){const Mt=$e[Rt];Za(this.layoutVertexArray,Mt.x,Mt.y,0,0,1,1,0),Q.x+=Mt.x,Q.y+=Mt.y,Q.vertexCount+=1,Ce.push(Mt.x),Ce.push(Mt.y)}}const je=dp.exports(Ce,Fe);for(let $e=0;$eKt)||A.y===l.y&&(A.y<0||A.y>Kt)}function ug(A){return A.every(l=>l.x<0)||A.every(l=>l.x>Kt)||A.every(l=>l.y<0)||A.every(l=>l.y>Kt)}pn("FillExtrusionBucket",If,{omit:["layers","features"]});var Oy={paint:new Es({"fill-extrusion-opacity":new Fn($t["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Vn($t["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Fn($t["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Fn($t["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new sh($t["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Vn($t["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Vn($t["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Fn($t["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function yA(A,l){return A.x*l.x+A.y*l.y}function Ny(A,l){if(A.length===1){let f=0;const w=l[f++];let I;for(;!I||w.equals(I);)if(I=l[f++],!I)return 1/0;for(;ff.id),this.index=l.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(f=>{this.gradients[f.id]={}}),this.layoutVertexArray=new Er,this.layoutVertexArray2=new Gr,this.indexArray=new mo,this.programConfigurations=new si(l.layers,l.zoom),this.segments=new a,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(f=>f.isStateDependent()).map(f=>f.id)}populate(l,f,w){this.hasPattern=lg("line",this.layers,f);const I=this.layers[0].layout.get("line-sort-key"),z=!I.isConstant(),Q=[];for(const{feature:Z,id:re,index:ge,sourceLayerIndex:Ce}of l){const Fe=this.layers[0]._featureFilter.needGeometry,Oe=Ai(Z,Fe);if(!this.layers[0]._featureFilter.filter(new Zr(this.zoom),Oe,w))continue;const je=z?I.evaluate(Oe,{},w):void 0,$e={id:re,properties:Z.properties,type:Z.type,sourceLayerIndex:Ce,index:ge,geometry:Fe?Oe.geometry:Ri(Z),patterns:{},sortKey:je};Q.push($e)}z&&Q.sort((Z,re)=>Z.sortKey-re.sortKey);for(const Z of Q){const{geometry:re,index:ge,sourceLayerIndex:Ce}=Z;if(this.hasPattern){const Fe=cg("line",this.layers,Z,this.zoom,f);this.patternFeatures.push(Fe)}else this.addFeature(Z,re,ge,w,{});f.featureIndex.insert(l[ge].feature,re,ge,Ce,this.index)}}update(l,f,w){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(l,f,this.stateDependentLayers,w)}addFeatures(l,f,w){for(const I of this.patternFeatures)this.addFeature(I,I.geometry,I.index,f,w)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=l.createVertexBuffer(this.layoutVertexArray2,Yh)),this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,Qy),this.indexBuffer=l.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(l),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(l){if(l.properties&&Object.prototype.hasOwnProperty.call(l.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(l.properties,"mapbox_clip_end"))return{start:+l.properties.mapbox_clip_start,end:+l.properties.mapbox_clip_end}}addFeature(l,f,w,I,z){const Q=this.layers[0].layout,Z=Q.get("line-join").evaluate(l,{}),re=Q.get("line-cap"),ge=Q.get("line-miter-limit"),Ce=Q.get("line-round-limit");this.lineClips=this.lineFeatureClips(l);for(const Fe of f)this.addLine(Fe,l,Z,re,ge,Ce);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,l,w,z,I)}addLine(l,f,w,I,z,Q){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let ri=0;ri=2&&l[re-1].equals(l[re-2]);)re--;let ge=0;for(;ge0;if(Sn&&ri>ge){const nn=Oe.dist(je);if(nn>2*Ce){const vn=Oe.sub(Oe.sub(je)._mult(Ce/nn)._round());this.updateDistance(je,vn),this.addCurrentVertex(vn,Rt,0,0,Fe),je=vn}}const mn=je&&$e;let an=mn?w:Z?"butt":I;if(mn&&an==="round"&&(Piz&&(an="bevel"),an==="bevel"&&(Pi>2&&(an="flipbevel"),Pi100)gi=Mt.mult(-1);else{const nn=Pi*Rt.add(Mt).mag()/Rt.sub(Mt).mag();gi._perp()._mult(nn*(fn?-1:1))}this.addCurrentVertex(Oe,gi,0,0,Fe),this.addCurrentVertex(Oe,gi.mult(-1),0,0,Fe)}else if(an==="bevel"||an==="fakeround"){const nn=-Math.sqrt(Pi*Pi-1),vn=fn?nn:0,gn=fn?0:nn;if(je&&this.addCurrentVertex(Oe,Rt,vn,gn,Fe),an==="fakeround"){const Ji=Math.round(180*Fi/Math.PI/20);for(let Wn=1;Wn2*Ce){const vn=Oe.add($e.sub(Oe)._mult(Ce/nn)._round());this.updateDistance(Oe,vn),this.addCurrentVertex(vn,Mt,0,0,Fe),Oe=vn}}}}addCurrentVertex(l,f,w,I,z,Q=!1){const Z=f.y*I-f.x,re=-f.y-f.x*I;this.addHalfVertex(l,f.x+f.y*w,f.y-f.x*w,Q,!1,w,z),this.addHalfVertex(l,Z,re,Q,!0,-I,z),this.distance>_p/2&&this.totalDistance===0&&(this.distance=0,this.addCurrentVertex(l,f,w,I,z,Q))}addHalfVertex({x:l,y:f},w,I,z,Q,Z,re){const ge=.5*(this.lineClips?this.scaledDistance*(_p-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((l<<1)+(z?1:0),(f<<1)+(Q?1:0),Math.round(63*w)+128,Math.round(63*I)+128,1+(Z===0?0:Z<0?-1:1)|(63&ge)<<2,ge>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const Ce=re.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,Ce),re.primitiveLength++),Q?this.e2=Ce:this.e1=Ce}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(l,f){this.distance+=l.dist(f),this.updateScaledDistance()}}pn("LineBucket",yp,{omit:["layers","patternFeatures"]});const Vy=new Es({"line-cap":new Fn($t.layout_line["line-cap"]),"line-join":new Vn($t.layout_line["line-join"]),"line-miter-limit":new Fn($t.layout_line["line-miter-limit"]),"line-round-limit":new Fn($t.layout_line["line-round-limit"]),"line-sort-key":new Vn($t.layout_line["line-sort-key"])});var Hy={paint:new Es({"line-opacity":new Vn($t.paint_line["line-opacity"]),"line-color":new Vn($t.paint_line["line-color"]),"line-translate":new Fn($t.paint_line["line-translate"]),"line-translate-anchor":new Fn($t.paint_line["line-translate-anchor"]),"line-width":new Vn($t.paint_line["line-width"]),"line-gap-width":new Vn($t.paint_line["line-gap-width"]),"line-offset":new Vn($t.paint_line["line-offset"]),"line-blur":new Vn($t.paint_line["line-blur"]),"line-dasharray":new dA($t.paint_line["line-dasharray"]),"line-pattern":new sh($t.paint_line["line-pattern"]),"line-gradient":new yl($t.paint_line["line-gradient"])}),layout:Vy};const dg=new class extends Vn{possiblyEvaluate(A,l){return l=new Zr(Math.floor(l.zoom),{now:l.now,fadeDuration:l.fadeDuration,zoomHistory:l.zoomHistory,transition:l.transition}),super.possiblyEvaluate(A,l)}evaluate(A,l,f,w){return l=J({},l,{zoom:Math.floor(l.zoom)}),super.evaluate(A,l,f,w)}}(Hy.paint.properties["line-width"].specification);function Gy(A,l){return l>0?l+2*A:A}dg.useIntegerZoom=!0;const pg=Fs([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),h1=Fs([{name:"a_projected_pos",components:3,type:"Float32"}],4);Fs([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const fg=Fs([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);Fs([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const mg=Fs([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Wy=Fs([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function vA(A,l,f){return A.sections.forEach(w=>{w.text=function(I,z,Q){const Z=z.layout.get("text-transform").evaluate(Q,{});return Z==="uppercase"?I=I.toLocaleUpperCase():Z==="lowercase"&&(I=I.toLocaleLowerCase()),vs.applyArabicShaping&&(I=vs.applyArabicShaping(I)),I}(w.text,l,f)}),A}Fs([{name:"triangle",components:3,type:"Uint16"}]),Fs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Fs([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Fs([{type:"Float32",name:"offsetX"}]),Fs([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const Ad={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};var yo=24,Tu=Yr,xp=function(A,l,f,w,I){var z,Q,Z=8*I-w-1,re=(1<>1,Ce=-7,Fe=f?I-1:0,Oe=f?-1:1,je=A[l+Fe];for(Fe+=Oe,z=je&(1<<-Ce)-1,je>>=-Ce,Ce+=Z;Ce>0;z=256*z+A[l+Fe],Fe+=Oe,Ce-=8);for(Q=z&(1<<-Ce)-1,z>>=-Ce,Ce+=w;Ce>0;Q=256*Q+A[l+Fe],Fe+=Oe,Ce-=8);if(z===0)z=1-ge;else{if(z===re)return Q?NaN:1/0*(je?-1:1);Q+=Math.pow(2,w),z-=ge}return(je?-1:1)*Q*Math.pow(2,z-w)},gg=function(A,l,f,w,I,z){var Q,Z,re,ge=8*z-I-1,Ce=(1<>1,Oe=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,je=w?0:z-1,$e=w?1:-1,Rt=l<0||l===0&&1/l<0?1:0;for(l=Math.abs(l),isNaN(l)||l===1/0?(Z=isNaN(l)?1:0,Q=Ce):(Q=Math.floor(Math.log(l)/Math.LN2),l*(re=Math.pow(2,-Q))<1&&(Q--,re*=2),(l+=Q+Fe>=1?Oe/re:Oe*Math.pow(2,1-Fe))*re>=2&&(Q++,re/=2),Q+Fe>=Ce?(Z=0,Q=Ce):Q+Fe>=1?(Z=(l*re-1)*Math.pow(2,I),Q+=Fe):(Z=l*Math.pow(2,Fe-1)*Math.pow(2,I),Q=0));I>=8;A[f+je]=255&Z,je+=$e,Z/=256,I-=8);for(Q=Q<0;A[f+je]=255&Q,je+=$e,Q/=256,ge-=8);A[f+je-$e]|=128*Rt};function Yr(A){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(A)?A:new Uint8Array(A||0),this.pos=0,this.type=0,this.length=this.buf.length}Yr.Varint=0,Yr.Fixed64=1,Yr.Bytes=2,Yr.Fixed32=5;var Su,_g=4294967296,vp=1/_g,Sa=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function hh(A){return A.type===Yr.Bytes?A.readVarint()+A.pos:A.pos+1}function wA(A,l,f){return f?4294967296*l+(A>>>0):4294967296*(l>>>0)+(A>>>0)}function ql(A,l,f){var w=l<=16383?1:l<=2097151?2:l<=268435455?3:Math.floor(Math.log(l)/(7*Math.LN2));f.realloc(w);for(var I=f.pos-1;I>=A;I--)f.buf[I+w]=f.buf[I]}function yg(A,l){for(var f=0;f>>8,A[f+2]=l>>>16,A[f+3]=l>>>24}function pd(A,l){return(A[l]|A[l+1]<<8|A[l+2]<<16)+(A[l+3]<<24)}function fd(A,l,f){A===1&&f.readMessage(Jh,l)}function Jh(A,l,f){if(A===3){const{id:w,bitmap:I,width:z,height:Q,left:Z,top:re,advance:ge}=f.readMessage(vg,{});l.push({id:w,bitmap:new Xh({width:z+6,height:Q+6},I),metrics:{width:z,height:Q,left:Z,top:re,advance:ge}})}}function vg(A,l,f){A===1?l.id=f.readVarint():A===2?l.bitmap=f.readBytes():A===3?l.width=f.readVarint():A===4?l.height=f.readVarint():A===5?l.left=f.readSVarint():A===6?l.top=f.readSVarint():A===7&&(l.advance=f.readVarint())}function wg(A){let l=0,f=0;for(const Q of A)l+=Q.w*Q.h,f=Math.max(f,Q.w);A.sort((Q,Z)=>Z.h-Q.h);const w=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(l/.95)),f),h:1/0}];let I=0,z=0;for(const Q of A)for(let Z=w.length-1;Z>=0;Z--){const re=w[Z];if(!(Q.w>re.w||Q.h>re.h)){if(Q.x=re.x,Q.y=re.y,z=Math.max(z,Q.y+Q.h),I=Math.max(I,Q.x+Q.w),Q.w===re.w&&Q.h===re.h){const ge=w.pop();Z>3,z=this.pos;this.type=7&w,A(I,l,this),this.pos===z&&this.skip(w)}return l},readMessage:function(A,l){return this.readFields(A,l,this.readVarint()+this.pos)},readFixed32:function(){var A=dd(this.buf,this.pos);return this.pos+=4,A},readSFixed32:function(){var A=pd(this.buf,this.pos);return this.pos+=4,A},readFixed64:function(){var A=dd(this.buf,this.pos)+dd(this.buf,this.pos+4)*_g;return this.pos+=8,A},readSFixed64:function(){var A=dd(this.buf,this.pos)+pd(this.buf,this.pos+4)*_g;return this.pos+=8,A},readFloat:function(){var A=xp(this.buf,this.pos,!0,23,4);return this.pos+=4,A},readDouble:function(){var A=xp(this.buf,this.pos,!0,52,8);return this.pos+=8,A},readVarint:function(A){var l,f,w=this.buf;return l=127&(f=w[this.pos++]),f<128?l:(l|=(127&(f=w[this.pos++]))<<7,f<128?l:(l|=(127&(f=w[this.pos++]))<<14,f<128?l:(l|=(127&(f=w[this.pos++]))<<21,f<128?l:function(I,z,Q){var Z,re,ge=Q.buf;if(Z=(112&(re=ge[Q.pos++]))>>4,re<128||(Z|=(127&(re=ge[Q.pos++]))<<3,re<128)||(Z|=(127&(re=ge[Q.pos++]))<<10,re<128)||(Z|=(127&(re=ge[Q.pos++]))<<17,re<128)||(Z|=(127&(re=ge[Q.pos++]))<<24,re<128)||(Z|=(1&(re=ge[Q.pos++]))<<31,re<128))return wA(I,Z,z);throw new Error("Expected varint not more than 10 bytes")}(l|=(15&(f=w[this.pos]))<<28,A,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var A=this.readVarint();return A%2==1?(A+1)/-2:A/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var A=this.readVarint()+this.pos,l=this.pos;return this.pos=A,A-l>=12&&Sa?function(f,w,I){return Sa.decode(f.subarray(w,I))}(this.buf,l,A):function(f,w,I){for(var z="",Q=w;Q239?4:Ce>223?3:Ce>191?2:1;if(Q+Oe>I)break;Oe===1?Ce<128&&(Fe=Ce):Oe===2?(192&(Z=f[Q+1]))==128&&(Fe=(31&Ce)<<6|63&Z)<=127&&(Fe=null):Oe===3?(re=f[Q+2],(192&(Z=f[Q+1]))==128&&(192&re)==128&&((Fe=(15&Ce)<<12|(63&Z)<<6|63&re)<=2047||Fe>=55296&&Fe<=57343)&&(Fe=null)):Oe===4&&(re=f[Q+2],ge=f[Q+3],(192&(Z=f[Q+1]))==128&&(192&re)==128&&(192&ge)==128&&((Fe=(15&Ce)<<18|(63&Z)<<12|(63&re)<<6|63&ge)<=65535||Fe>=1114112)&&(Fe=null)),Fe===null?(Fe=65533,Oe=1):Fe>65535&&(Fe-=65536,z+=String.fromCharCode(Fe>>>10&1023|55296),Fe=56320|1023&Fe),z+=String.fromCharCode(Fe),Q+=Oe}return z}(this.buf,l,A)},readBytes:function(){var A=this.readVarint()+this.pos,l=this.buf.subarray(this.pos,A);return this.pos=A,l},readPackedVarint:function(A,l){if(this.type!==Yr.Bytes)return A.push(this.readVarint(l));var f=hh(this);for(A=A||[];this.pos127;);else if(l===Yr.Bytes)this.pos=this.readVarint()+this.pos;else if(l===Yr.Fixed32)this.pos+=4;else{if(l!==Yr.Fixed64)throw new Error("Unimplemented type: "+l);this.pos+=8}},writeTag:function(A,l){this.writeVarint(A<<3|l)},realloc:function(A){for(var l=this.length||16;l268435455||A<0?function(l,f){var w,I;if(l>=0?(w=l%4294967296|0,I=l/4294967296|0):(I=~(-l/4294967296),4294967295^(w=~(-l%4294967296))?w=w+1|0:(w=0,I=I+1|0)),l>=18446744073709552e3||l<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");f.realloc(10),function(z,Q,Z){Z.buf[Z.pos++]=127&z|128,z>>>=7,Z.buf[Z.pos++]=127&z|128,z>>>=7,Z.buf[Z.pos++]=127&z|128,z>>>=7,Z.buf[Z.pos++]=127&z|128,Z.buf[Z.pos]=127&(z>>>=7)}(w,0,f),function(z,Q){var Z=(7&z)<<4;Q.buf[Q.pos++]|=Z|((z>>>=3)?128:0),z&&(Q.buf[Q.pos++]=127&z|((z>>>=7)?128:0),z&&(Q.buf[Q.pos++]=127&z|((z>>>=7)?128:0),z&&(Q.buf[Q.pos++]=127&z|((z>>>=7)?128:0),z&&(Q.buf[Q.pos++]=127&z|((z>>>=7)?128:0),z&&(Q.buf[Q.pos++]=127&z)))))}(I,f)}(A,this):(this.realloc(4),this.buf[this.pos++]=127&A|(A>127?128:0),A<=127||(this.buf[this.pos++]=127&(A>>>=7)|(A>127?128:0),A<=127||(this.buf[this.pos++]=127&(A>>>=7)|(A>127?128:0),A<=127||(this.buf[this.pos++]=A>>>7&127))))},writeSVarint:function(A){this.writeVarint(A<0?2*-A-1:2*A)},writeBoolean:function(A){this.writeVarint(Boolean(A))},writeString:function(A){A=String(A),this.realloc(4*A.length),this.pos++;var l=this.pos;this.pos=function(w,I,z){for(var Q,Z,re=0;re55295&&Q<57344){if(!Z){Q>56319||re+1===I.length?(w[z++]=239,w[z++]=191,w[z++]=189):Z=Q;continue}if(Q<56320){w[z++]=239,w[z++]=191,w[z++]=189,Z=Q;continue}Q=Z-55296<<10|Q-56320|65536,Z=null}else Z&&(w[z++]=239,w[z++]=191,w[z++]=189,Z=null);Q<128?w[z++]=Q:(Q<2048?w[z++]=Q>>6|192:(Q<65536?w[z++]=Q>>12|224:(w[z++]=Q>>18|240,w[z++]=Q>>12&63|128),w[z++]=Q>>6&63|128),w[z++]=63&Q|128)}return z}(this.buf,A,this.pos);var f=this.pos-l;f>=128&&ql(l,f,this),this.pos=l-1,this.writeVarint(f),this.pos+=f},writeFloat:function(A){this.realloc(4),gg(this.buf,A,this.pos,!0,23,4),this.pos+=4},writeDouble:function(A){this.realloc(8),gg(this.buf,A,this.pos,!0,52,8),this.pos+=8},writeBytes:function(A){var l=A.length;this.writeVarint(l),this.realloc(l);for(var f=0;f=128&&ql(f,w,this),this.pos=f-1,this.writeVarint(w),this.pos+=w},writeMessage:function(A,l,f){this.writeTag(A,Yr.Bytes),this.writeRawMessage(l,f)},writePackedVarint:function(A,l){l.length&&this.writeMessage(A,yg,l)},writePackedSVarint:function(A,l){l.length&&this.writeMessage(A,bA,l)},writePackedBoolean:function(A,l){l.length&&this.writeMessage(A,xg,l)},writePackedFloat:function(A,l){l.length&&this.writeMessage(A,wp,l)},writePackedDouble:function(A,l){l.length&&this.writeMessage(A,BA,l)},writePackedFixed32:function(A,l){l.length&&this.writeMessage(A,Lf,l)},writePackedSFixed32:function(A,l){l.length&&this.writeMessage(A,jy,l)},writePackedFixed64:function(A,l){l.length&&this.writeMessage(A,Ky,l)},writePackedSFixed64:function(A,l){l.length&&this.writeMessage(A,u1,l)},writeBytesField:function(A,l){this.writeTag(A,Yr.Bytes),this.writeBytes(l)},writeFixed32Field:function(A,l){this.writeTag(A,Yr.Fixed32),this.writeFixed32(l)},writeSFixed32Field:function(A,l){this.writeTag(A,Yr.Fixed32),this.writeSFixed32(l)},writeFixed64Field:function(A,l){this.writeTag(A,Yr.Fixed64),this.writeFixed64(l)},writeSFixed64Field:function(A,l){this.writeTag(A,Yr.Fixed64),this.writeSFixed64(l)},writeVarintField:function(A,l){this.writeTag(A,Yr.Varint),this.writeVarint(l)},writeSVarintField:function(A,l){this.writeTag(A,Yr.Varint),this.writeSVarint(l)},writeStringField:function(A,l){this.writeTag(A,Yr.Bytes),this.writeString(l)},writeFloatField:function(A,l){this.writeTag(A,Yr.Fixed32),this.writeFloat(l)},writeDoubleField:function(A,l){this.writeTag(A,Yr.Fixed64),this.writeDouble(l)},writeBooleanField:function(A,l){this.writeVarintField(A,Boolean(l))}};class EA{constructor(l,{pixelRatio:f,version:w,stretchX:I,stretchY:z,content:Q}){this.paddedRect=l,this.pixelRatio=f,this.stretchX=I,this.stretchY=z,this.content=Q,this.version=w}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class md{constructor(l,f){const w={},I={};this.haveRenderCallbacks=[];const z=[];this.addImages(l,w,z),this.addImages(f,I,z);const{w:Q,h:Z}=wg(z),re=new da({width:Q||1,height:Z||1});for(const ge in l){const Ce=l[ge],Fe=w[ge].paddedRect;da.copy(Ce.data,re,{x:0,y:0},{x:Fe.x+1,y:Fe.y+1},Ce.data)}for(const ge in f){const Ce=f[ge],Fe=I[ge].paddedRect,Oe=Fe.x+1,je=Fe.y+1,$e=Ce.data.width,Rt=Ce.data.height;da.copy(Ce.data,re,{x:0,y:0},{x:Oe,y:je},Ce.data),da.copy(Ce.data,re,{x:0,y:Rt-1},{x:Oe,y:je-1},{width:$e,height:1}),da.copy(Ce.data,re,{x:0,y:0},{x:Oe,y:je+Rt},{width:$e,height:1}),da.copy(Ce.data,re,{x:$e-1,y:0},{x:Oe-1,y:je},{width:1,height:Rt}),da.copy(Ce.data,re,{x:0,y:0},{x:Oe+$e,y:je},{width:1,height:Rt})}this.image=re,this.iconPositions=w,this.patternPositions=I}addImages(l,f,w){for(const I in l){const z=l[I],Q={x:0,y:0,w:z.data.width+2,h:z.data.height+2};w.push(Q),f[I]=new EA(Q,z),z.hasRenderCallback&&this.haveRenderCallbacks.push(I)}}patchUpdatedImages(l,f){l.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const w in l.updatedImages)this.patchUpdatedImage(this.iconPositions[w],l.getImage(w),f),this.patchUpdatedImage(this.patternPositions[w],l.getImage(w),f)}patchUpdatedImage(l,f,w){if(!l||!f||l.version===f.version)return;l.version=f.version;const[I,z]=l.tl;w.update(f.data,void 0,{x:I,y:z})}}pn("ImagePosition",EA),pn("ImageAtlas",md),i.WritingMode=void 0,(Su=i.WritingMode||(i.WritingMode={}))[Su.none=0]="none",Su[Su.horizontal=1]="horizontal",Su[Su.vertical=2]="vertical",Su[Su.horizontalOnly=3]="horizontalOnly";const pa=-17;class eu{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(l,f){const w=new eu;return w.scale=l||1,w.fontStack=f,w}static forImage(l){const f=new eu;return f.imageName=l,f}}class so{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(l,f){const w=new so;for(let I=0;I=0&&w>=l&&gd[this.text.charCodeAt(w)];w--)f--;this.text=this.text.substring(l,f),this.sectionIndex=this.sectionIndex.slice(l,f)}substring(l,f){const w=new so;return w.text=this.text.substring(l,f),w.sectionIndex=this.sectionIndex.slice(l,f),w.sections=this.sections,w}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((l,f)=>Math.max(l,this.sections[f].scale),0)}addTextSection(l,f){this.text+=l.text,this.sections.push(eu.forText(l.scale,l.fontStack||f));const w=this.sections.length-1;for(let I=0;I=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ma(A,l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe,je,$e,Rt){const Mt=so.fromFeature(A,I);let ri;Fe===i.WritingMode.vertical&&Mt.verticalizePunctuation();const{processBidirectionalText:gi,processStyledBidirectionalText:ei}=vs;if(gi&&Mt.sections.length===1){ri=[];const Fi=gi(Mt.toString(),Df(Mt,ge,z,l,w,je,$e));for(const Sn of Fi){const fn=new so;fn.text=Sn,fn.sections=Mt.sections;for(let mn=0;mn0&&dh>Hs&&(Hs=dh)}else{const vr=fn[pr.fontStack],Zo=vr&&vr[Uo];if(Zo&&Zo.rect)Bc=Zo.rect,Jl=Zo.metrics;else{const dh=Sn[pr.fontStack],Sd=dh&&dh[Uo];if(!Sd)continue;Jl=Sd.metrics}ao=(Do-pr.scale)*yo}El?(Fi.verticalizable=!0,Jr.push({glyph:Uo,imageName:Fa,x:ms,y:bs+ao,vertical:El,scale:pr.scale,fontStack:pr.fontStack,sectionIndex:Ya,metrics:Jl,rect:Bc}),ms+=Ah*pr.scale+Wn):(Jr.push({glyph:Uo,imageName:Fa,x:ms,y:bs+ao,vertical:El,scale:pr.scale,fontStack:pr.fontStack,sectionIndex:Ya,metrics:Jl,rect:Bc}),ms+=Jl.advance*pr.scale+Wn)}Jr.length!==0&&(Vs=Math.max(ms-Wn,Vs),TA(Jr,0,Jr.length-1,xo,Hs)),ms=0;const gs=nn*Do+Hs;fa.lineOffset=Math.max(Hs,Po),bs+=gs,Cl=Math.max(gs,Cl),++Ks}var oo;const Lo=bs-pa,{horizontalAlign:$o,verticalAlign:Ia}=Pf(vn);(function(io,Do,Po,fa,Jr,Hs,gs,$s,pr){const Ya=(Do-Po)*Jr;let Uo=0;Uo=Hs!==gs?-$s*fa-pa:(-fa*pr+.5)*gs;for(const ao of io)for(const Jl of ao.positionedGlyphs)Jl.x+=Ya,Jl.y+=Uo})(Fi.positionedLines,xo,$o,Ia,Vs,Cl,nn,Lo,an.length),Fi.top+=-Ia*Lo,Fi.bottom=Fi.top+Lo,Fi.left+=-$o*Vs,Fi.right=Fi.left+Vs}(Pi,l,f,w,ri,Q,Z,re,Fe,ge,Oe,Rt),!function(Fi){for(const Sn of Fi)if(Sn.positionedGlyphs.length!==0)return!1;return!0}(ui)&&Pi}const gd={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Qs={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 bg(A,l,f,w,I,z){if(l.imageName){const Q=w[l.imageName];return Q?Q.displaySize[0]*l.scale*yo/z+I:0}{const Q=f[l.fontStack],Z=Q&&Q[A];return Z?Z.metrics.advance*l.scale+I:0}}function _d(A,l,f,w){const I=Math.pow(A-l,2);return w?A=0;let Ce=0;for(let Oe=0;Oe-f/2;){if(Q--,Q<0)return!1;Z-=A[Q].dist(z),z=A[Q]}Z+=A[Q].dist(A[Q+1]),Q++;const re=[];let ge=0;for(;Zw;)ge-=re.shift().angleDelta;if(ge>I)return!1;Q++,Z+=Ce.dist(Fe)}return!0}function Rf(A){let l=0;for(let f=0;fge){const $e=(ge-re)/je,Rt=ns(Fe.x,Oe.x,$e),Mt=ns(Fe.y,Oe.y,$e),ri=new Mu(Rt,Mt,Oe.angleTo(Fe),Ce);return ri._round(),!Q||Uf(A,ri,Z,Q,l)?ri:void 0}re+=je}}function A1(A,l,f,w,I,z,Q,Z,re){const ge=zf(w,z,Q),Ce=Ko(w,I),Fe=Ce*Q,Oe=A[0].x===0||A[0].x===re||A[0].y===0||A[0].y===re;return l-Fe=0&&ui=0&&Pi=0&&Oe+ge<=Ce){const Fi=new Mu(ui,Pi,gi,$e);Fi._round(),w&&!Uf(A,Fi,z,w,I)||je.push(Fi)}}Fe+=ri}return Z||je.length||Q||(je=Eg(A,Fe/2,f,w,I,z,Q,!0,re)),je}function Yy(A,l,f,w,I){const z=[];for(let Q=0;Q=w&&Fe.x>=w||(Ce.x>=w?Ce=new xe(w,Ce.y+(w-Ce.x)/(Fe.x-Ce.x)*(Fe.y-Ce.y))._round():Fe.x>=w&&(Fe=new xe(w,Ce.y+(w-Ce.x)/(Fe.x-Ce.x)*(Fe.y-Ce.y))._round()),Ce.y>=I&&Fe.y>=I||(Ce.y>=I?Ce=new xe(Ce.x+(I-Ce.y)/(Fe.y-Ce.y)*(Fe.x-Ce.x),I)._round():Fe.y>=I&&(Fe=new xe(Ce.x+(I-Ce.y)/(Fe.y-Ce.y)*(Fe.x-Ce.x),I)._round()),re&&Ce.equals(re[re.length-1])||(re=[Ce],z.push(re)),re.push(Fe)))))}}return z}function Jy(A,l,f,w){const I=[],z=A.image,Q=z.pixelRatio,Z=z.paddedRect.w-2,re=z.paddedRect.h-2,ge=A.right-A.left,Ce=A.bottom-A.top,Fe=z.stretchX||[[0,Z]],Oe=z.stretchY||[[0,re]],je=(nn,vn)=>nn+vn[1]-vn[0],$e=Fe.reduce(je,0),Rt=Oe.reduce(je,0),Mt=Z-$e,ri=re-Rt;let gi=0,ei=$e,ui=0,Pi=Rt,Fi=0,Sn=Mt,fn=0,mn=ri;if(z.content&&w){const nn=z.content;gi=bp(Fe,0,nn[0]),ui=bp(Oe,0,nn[1]),ei=bp(Fe,nn[0],nn[2]),Pi=bp(Oe,nn[1],nn[3]),Fi=nn[0]-gi,fn=nn[1]-ui,Sn=nn[2]-nn[0]-ei,mn=nn[3]-nn[1]-Pi}const an=(nn,vn,gn,Ji)=>{const Wn=Bp(nn.stretch-gi,ei,ge,A.left),zn=yd(nn.fixed-Fi,Sn,nn.stretch,$e),yr=Bp(vn.stretch-ui,Pi,Ce,A.top),ms=yd(vn.fixed-fn,mn,vn.stretch,Rt),bs=Bp(gn.stretch-gi,ei,ge,A.left),Vs=yd(gn.fixed-Fi,Sn,gn.stretch,$e),Cl=Bp(Ji.stretch-ui,Pi,Ce,A.top),xo=yd(Ji.fixed-fn,mn,Ji.stretch,Rt),Ks=new xe(Wn,yr),oo=new xe(bs,yr),Lo=new xe(bs,Cl),$o=new xe(Wn,Cl),Ia=new xe(zn/Q,ms/Q),io=new xe(Vs/Q,xo/Q),Do=l*Math.PI/180;if(Do){const Jr=Math.sin(Do),Hs=Math.cos(Do),gs=[Hs,-Jr,Jr,Hs];Ks._matMult(gs),oo._matMult(gs),$o._matMult(gs),Lo._matMult(gs)}const Po=nn.stretch+nn.fixed,fa=vn.stretch+vn.fixed;return{tl:Ks,tr:oo,bl:$o,br:Lo,tex:{x:z.paddedRect.x+1+Po,y:z.paddedRect.y+1+fa,w:gn.stretch+gn.fixed-Po,h:Ji.stretch+Ji.fixed-fa},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ia,pixelOffsetBR:io,minFontScaleX:Sn/Q/ge,minFontScaleY:mn/Q/Ce,isSDF:f}};if(w&&(z.stretchX||z.stretchY)){const nn=Tg(Fe,Mt,$e),vn=Tg(Oe,ri,Rt);for(let gn=0;gn0&&($e=Math.max(10,$e),this.circleDiameter=$e)}else{let Fe=Q.top*Z-re[0],Oe=Q.bottom*Z+re[2],je=Q.left*Z-re[3],$e=Q.right*Z+re[1];const Rt=Q.collisionPadding;if(Rt&&(je-=Rt[0]*Z,Fe-=Rt[1]*Z,$e+=Rt[2]*Z,Oe+=Rt[3]*Z),Ce){const Mt=new xe(je,Fe),ri=new xe($e,Fe),gi=new xe(je,Oe),ei=new xe($e,Oe),ui=Ce*Math.PI/180;Mt._rotate(ui),ri._rotate(ui),gi._rotate(ui),ei._rotate(ui),je=Math.min(Mt.x,ri.x,gi.x,ei.x),$e=Math.max(Mt.x,ri.x,gi.x,ei.x),Fe=Math.min(Mt.y,ri.y,gi.y,ei.y),Oe=Math.max(Mt.y,ri.y,gi.y,ei.y)}l.emplaceBack(f.x,f.y,je,Fe,$e,Oe,w,I,z)}this.boxEndIndex=l.length}}class Xa{constructor(l=[],f=d1){if(this.data=l,this.length=this.data.length,this.compare=f,this.length>0)for(let w=(this.length>>1)-1;w>=0;w--)this._down(w)}push(l){this.data.push(l),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const l=this.data[0],f=this.data.pop();return this.length--,this.length>0&&(this.data[0]=f,this._down(0)),l}peek(){return this.data[0]}_up(l){const{data:f,compare:w}=this,I=f[l];for(;l>0;){const z=l-1>>1,Q=f[z];if(w(I,Q)>=0)break;f[l]=Q,l=z}f[l]=I}_down(l){const{data:f,compare:w}=this,I=this.length>>1,z=f[l];for(;l=0)break;f[l]=Z,l=Q}f[l]=z}}function d1(A,l){return Al?1:0}function Sg(A,l=1,f=!1){let w=1/0,I=1/0,z=-1/0,Q=-1/0;const Z=A[0];for(let je=0;jez)&&(z=$e.x),(!je||$e.y>Q)&&(Q=$e.y)}const re=Math.min(z-w,Q-I);let ge=re/2;const Ce=new Xa([],p1);if(re===0)return new xe(w,I);for(let je=w;jeFe.d||!Fe.d)&&(Fe=je,f&&console.log("found best %d after %d probes",Math.round(1e4*je.d)/1e4,Oe)),je.max-Fe.d<=l||(ge=je.h/2,Ce.push(new xd(je.p.x-ge,je.p.y-ge,ge,A)),Ce.push(new xd(je.p.x+ge,je.p.y-ge,ge,A)),Ce.push(new xd(je.p.x-ge,je.p.y+ge,ge,A)),Ce.push(new xd(je.p.x+ge,je.p.y+ge,ge,A)),Oe+=4)}return f&&(console.log(`num probes: ${Oe}`),console.log(`best distance: ${Fe.d}`)),Fe.p}function p1(A,l){return l.max-A.max}function xd(A,l,f,w){this.p=new xe(A,l),this.h=f,this.d=function(I,z){let Q=!1,Z=1/0;for(let re=0;reI.y!=$e.y>I.y&&I.x<($e.x-je.x)*(I.y-je.y)/($e.y-je.y)+je.x&&(Q=!Q),Z=Math.min(Z,On(I,je,$e))}}return(Q?1:-1)*Math.sqrt(Z)}(this.p,w),this.max=this.d+this.h*Math.SQRT2}const Mg=Number.POSITIVE_INFINITY;function vd(A,l){return l[1]!==Mg?function(f,w,I){let z=0,Q=0;switch(w=Math.abs(w),I=Math.abs(I),f){case"top-right":case"top-left":case"top":Q=I-7;break;case"bottom-right":case"bottom-left":case"bottom":Q=7-I}switch(f){case"top-right":case"bottom-right":case"right":z=-w;break;case"top-left":case"bottom-left":case"left":z=w}return[z,Q]}(A,l[0],l[1]):function(f,w){let I=0,z=0;w<0&&(w=0);const Q=w/Math.sqrt(2);switch(f){case"top-right":case"top-left":z=Q-7;break;case"bottom-right":case"bottom-left":z=7-Q;break;case"bottom":z=7-w;break;case"top":z=w-7}switch(f){case"top-right":case"bottom-right":I=-Q;break;case"top-left":case"bottom-left":I=Q;break;case"left":I=w;break;case"right":I=-w}return[I,z]}(A,l[0])}function wd(A){switch(A){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function e0(A,l,f,w,I,z,Q,Z,re,ge,Ce){let Fe=z.textMaxSize.evaluate(l,{});Fe===void 0&&(Fe=Q);const Oe=A.layers[0].layout,je=Oe.get("icon-offset").evaluate(l,{},Ce),$e=t0(f.horizontal),Rt=Q/24,Mt=A.tilePixelRatio*Rt,ri=A.tilePixelRatio*Fe/24,gi=A.tilePixelRatio*Z,ei=A.tilePixelRatio*Oe.get("symbol-spacing"),ui=Oe.get("text-padding")*A.tilePixelRatio,Pi=function(Ji,Wn,zn,yr=1){const ms=Ji.get("icon-padding").evaluate(Wn,{},zn),bs=ms&&ms.values;return[bs[0]*yr,bs[1]*yr,bs[2]*yr,bs[3]*yr]}(Oe,l,Ce,A.tilePixelRatio),Fi=Oe.get("text-max-angle")/180*Math.PI,Sn=Oe.get("text-rotation-alignment")!=="viewport"&&Oe.get("symbol-placement")!=="point",fn=Oe.get("icon-rotation-alignment")==="map"&&Oe.get("symbol-placement")!=="point",mn=Oe.get("symbol-placement"),an=ei/2,nn=Oe.get("icon-text-fit");let vn;w&&nn!=="none"&&(A.allowVerticalPlacement&&f.vertical&&(vn=Bg(w,f.vertical,nn,Oe.get("icon-text-fit-padding"),je,Rt)),$e&&(w=Bg(w,$e,nn,Oe.get("icon-text-fit-padding"),je,Rt)));const gn=(Ji,Wn)=>{Wn.x<0||Wn.x>=Kt||Wn.y<0||Wn.y>=Kt||function(zn,yr,ms,bs,Vs,Cl,xo,Ks,oo,Lo,$o,Ia,io,Do,Po,fa,Jr,Hs,gs,$s,pr,Ya,Uo,ao,Jl){const Bc=zn.addToLineVertexArray(yr,ms);let Fa,Ah,El,vr,Zo=0,dh=0,Sd=0,ph=0,Iu=-1,Gf=-1;const tu={};let h0=S.exports(""),Rg=0,zg=0;if(Ks._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Rg,zg]=Ks.layout.get("text-offset").evaluate(pr,{},ao).map(Xo=>Xo*yo):(Rg=Ks.layout.get("text-radial-offset").evaluate(pr,{},ao)*yo,zg=Mg),zn.allowVerticalPlacement&&bs.vertical){const Xo=Ks.layout.get("text-rotate").evaluate(pr,{},ao)+90;El=new Yl(oo,yr,Lo,$o,Ia,bs.vertical,io,Do,Po,Xo),xo&&(vr=new Yl(oo,yr,Lo,$o,Ia,xo,Jr,Hs,Po,Xo))}if(Vs){const Xo=Ks.layout.get("icon-rotate").evaluate(pr,{}),Ec=Ks.layout.get("icon-text-fit")!=="none",qo=Jy(Vs,Xo,Uo,Ec),iu=xo?Jy(xo,Xo,Uo,Ec):void 0;Ah=new Yl(oo,yr,Lo,$o,Ia,Vs,Jr,Hs,!1,Xo),Zo=4*qo.length;const IA=zn.iconSizeData;let nu=null;IA.kind==="source"?(nu=[uh*Ks.layout.get("icon-size").evaluate(pr,{})],nu[0]>qa&&me(`${zn.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):IA.kind==="composite"&&(nu=[uh*Ya.compositeIconSizes[0].evaluate(pr,{},ao),uh*Ya.compositeIconSizes[1].evaluate(pr,{},ao)],(nu[0]>qa||nu[1]>qa)&&me(`${zn.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),zn.addSymbols(zn.icon,qo,nu,$s,gs,pr,i.WritingMode.none,yr,Bc.lineStartIndex,Bc.lineLength,-1,ao),Iu=zn.icon.placedSymbolArray.length-1,iu&&(dh=4*iu.length,zn.addSymbols(zn.icon,iu,nu,$s,gs,pr,i.WritingMode.vertical,yr,Bc.lineStartIndex,Bc.lineLength,-1,ao),Gf=zn.icon.placedSymbolArray.length-1)}const u0=Object.keys(bs.horizontal);for(const Xo of u0){const Ec=bs.horizontal[Xo];if(!Fa){h0=S.exports(Ec.text);const iu=Ks.layout.get("text-rotate").evaluate(pr,{},ao);Fa=new Yl(oo,yr,Lo,$o,Ia,Ec,io,Do,Po,iu)}const qo=Ec.positionedLines.length===1;if(Sd+=bd(zn,yr,Ec,Cl,Ks,Po,pr,fa,Bc,bs.vertical?i.WritingMode.horizontal:i.WritingMode.horizontalOnly,qo?u0:[Xo],tu,Iu,Ya,ao),qo)break}bs.vertical&&(ph+=bd(zn,yr,bs.vertical,Cl,Ks,Po,pr,fa,Bc,i.WritingMode.vertical,["vertical"],tu,Gf,Ya,ao));const w1=Fa?Fa.boxStartIndex:zn.collisionBoxArray.length,b1=Fa?Fa.boxEndIndex:zn.collisionBoxArray.length,B1=El?El.boxStartIndex:zn.collisionBoxArray.length,C1=El?El.boxEndIndex:zn.collisionBoxArray.length,Wf=Ah?Ah.boxStartIndex:zn.collisionBoxArray.length,Md=Ah?Ah.boxEndIndex:zn.collisionBoxArray.length,A0=vr?vr.boxStartIndex:zn.collisionBoxArray.length,E1=vr?vr.boxEndIndex:zn.collisionBoxArray.length;let Cc=-1;const jf=(Xo,Ec)=>Xo&&Xo.circleDiameter?Math.max(Xo.circleDiameter,Ec):Ec;Cc=jf(Fa,Cc),Cc=jf(El,Cc),Cc=jf(Ah,Cc),Cc=jf(vr,Cc);const Kf=Cc>-1?1:0;Kf&&(Cc*=Jl/yo),zn.glyphOffsetArray.length>=bc.MAX_GLYPHS&&me("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),pr.sortKey!==void 0&&zn.addToSortKeyRanges(zn.symbolInstances.length,pr.sortKey),zn.symbolInstances.emplaceBack(yr.x,yr.y,tu.right>=0?tu.right:-1,tu.center>=0?tu.center:-1,tu.left>=0?tu.left:-1,tu.vertical||-1,Iu,Gf,h0,w1,b1,B1,C1,Wf,Md,A0,E1,Lo,Sd,ph,Zo,dh,Kf,0,io,Rg,zg,Cc)}(A,Wn,Ji,f,w,I,vn,A.layers[0],A.collisionBoxArray,l.index,l.sourceLayerIndex,A.index,Mt,[ui,ui,ui,ui],Sn,re,gi,Pi,fn,je,l,z,ge,Ce,Q)};if(mn==="line")for(const Ji of Yy(l.geometry,0,0,Kt,Kt)){const Wn=A1(Ji,ei,Fi,f.vertical||$e,w,24,ri,A.overscaling,Kt);for(const zn of Wn){const yr=$e;yr&&f1(A,yr.text,an,zn)||gn(Ji,zn)}}else if(mn==="line-center"){for(const Ji of l.geometry)if(Ji.length>1){const Wn=qy(Ji,Fi,f.vertical||$e,w,24,ri);Wn&&gn(Ji,Wn)}}else if(l.type==="Polygon")for(const Ji of lh(l.geometry,0)){const Wn=Sg(Ji,16);gn(Ji[0],new Mu(Wn.x,Wn.y,0))}else if(l.type==="LineString")for(const Ji of l.geometry)gn(Ji,new Mu(Ji[0].x,Ji[0].y,0));else if(l.type==="Point")for(const Ji of l.geometry)for(const Wn of Ji)gn([Wn],new Mu(Wn.x,Wn.y,0))}const qa=32640;function bd(A,l,f,w,I,z,Q,Z,re,ge,Ce,Fe,Oe,je,$e){const Rt=function(gi,ei,ui,Pi,Fi,Sn,fn,mn){const an=Pi.layout.get("text-rotate").evaluate(Sn,{})*Math.PI/180,nn=[];for(const vn of ei.positionedLines)for(const gn of vn.positionedGlyphs){if(!gn.rect)continue;const Ji=gn.rect||{};let Wn=4,zn=!0,yr=1,ms=0;const bs=(Fi||mn)&&gn.vertical,Vs=gn.metrics.advance*gn.scale/2;if(mn&&ei.verticalizable){const gs=(gn.scale-1)*yo,$s=(yo-gn.metrics.width*gn.scale)/2;ms=vn.lineOffset/2-(gn.imageName?-$s:gs)}if(gn.imageName){const gs=fn[gn.imageName];zn=gs.sdf,yr=gs.pixelRatio,Wn=1/yr}const Cl=Fi?[gn.x+Vs,gn.y]:[0,0];let xo=Fi?[0,0]:[gn.x+Vs+ui[0],gn.y+ui[1]-ms],Ks=[0,0];bs&&(Ks=xo,xo=[0,0]);const oo=(gn.metrics.left-Wn)*gn.scale-Vs+xo[0],Lo=(-gn.metrics.top-Wn)*gn.scale+xo[1],$o=oo+Ji.w*gn.scale/yr,Ia=Lo+Ji.h*gn.scale/yr,io=new xe(oo,Lo),Do=new xe($o,Lo),Po=new xe(oo,Ia),fa=new xe($o,Ia);if(bs){const gs=new xe(-Vs,Vs-pa),$s=-Math.PI/2,pr=12-Vs,Ya=new xe(22-pr,-(gn.imageName?pr:0)),Uo=new xe(...Ks);io._rotateAround($s,gs)._add(Ya)._add(Uo),Do._rotateAround($s,gs)._add(Ya)._add(Uo),Po._rotateAround($s,gs)._add(Ya)._add(Uo),fa._rotateAround($s,gs)._add(Ya)._add(Uo)}if(an){const gs=Math.sin(an),$s=Math.cos(an),pr=[$s,-gs,gs,$s];io._matMult(pr),Do._matMult(pr),Po._matMult(pr),fa._matMult(pr)}const Jr=new xe(0,0),Hs=new xe(0,0);nn.push({tl:io,tr:Do,bl:Po,br:fa,tex:Ji,writingMode:ei.writingMode,glyphOffset:Cl,sectionIndex:gn.sectionIndex,isSDF:zn,pixelOffsetTL:Jr,pixelOffsetBR:Hs,minFontScaleX:0,minFontScaleY:0})}return nn}(0,f,Z,I,z,Q,w,A.allowVerticalPlacement),Mt=A.textSizeData;let ri=null;Mt.kind==="source"?(ri=[uh*I.layout.get("text-size").evaluate(Q,{})],ri[0]>qa&&me(`${A.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):Mt.kind==="composite"&&(ri=[uh*je.compositeTextSizes[0].evaluate(Q,{},$e),uh*je.compositeTextSizes[1].evaluate(Q,{},$e)],(ri[0]>qa||ri[1]>qa)&&me(`${A.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),A.addSymbols(A.text,Rt,ri,Z,z,Q,ge,l,re.lineStartIndex,re.lineLength,Oe,$e);for(const gi of Ce)Fe[gi]=A.text.placedSymbolArray.length-1;return 4*Rt.length}function t0(A){for(const l in A)return A[l];return null}function f1(A,l,f,w){const I=A.compareText;if(l in I){const z=I[l];for(let Q=z.length-1;Q>=0;Q--)if(w.dist(z[Q])Q.id),this.index=l.index,this.pixelRatio=l.pixelRatio,this.sourceLayerIndex=l.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Fr([]),this.placementViewportMatrix=Fr([]);const f=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Cg(this.zoom,f["text-size"]),this.iconSizeData=Cg(this.zoom,f["icon-size"]);const w=this.layers[0].layout,I=w.get("symbol-sort-key"),z=w.get("symbol-z-order");this.canOverlap=Bd(w,"text-overlap","text-allow-overlap")!=="never"||Bd(w,"icon-overlap","icon-allow-overlap")!=="never"||w.get("text-ignore-placement")||w.get("icon-ignore-placement"),this.sortFeaturesByKey=z!=="viewport-y"&&!I.isConstant(),this.sortFeaturesByY=(z==="viewport-y"||z==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,w.get("symbol-placement")==="point"&&(this.writingModes=w.get("text-writing-mode").map(Q=>i.WritingMode[Q])),this.stateDependentLayerIds=this.layers.filter(Q=>Q.isStateDependent()).map(Q=>Q.id),this.sourceID=l.sourceID}createArrays(){this.text=new Cp(new si(this.layers,this.zoom,l=>/^text/.test(l))),this.icon=new Cp(new si(this.layers,this.zoom,l=>/^icon/.test(l))),this.glyphOffsetArray=new cn,this.lineVertexArray=new Bn,this.symbolInstances=new xn}calculateGlyphDependencies(l,f,w,I,z){for(let Q=0;Q0)&&(Q.value.kind!=="constant"||Q.value.value.length>0),Ce=re.value.kind!=="constant"||!!re.value.value||Object.keys(re.parameters).length>0,Fe=z.get("symbol-sort-key");if(this.features=[],!ge&&!Ce)return;const Oe=f.iconDependencies,je=f.glyphDependencies,$e=f.availableImages,Rt=new Zr(this.zoom);for(const{feature:Mt,id:ri,index:gi,sourceLayerIndex:ei}of l){const ui=I._featureFilter.needGeometry,Pi=Ai(Mt,ui);if(!I._featureFilter.filter(Rt,Pi,w))continue;let Fi,Sn;if(ui||(Pi.geometry=Ri(Mt)),ge){const mn=I.getValueAndResolveTokens("text-field",Pi,w,$e),an=He.factory(mn);_1(an)&&(this.hasRTLText=!0),(!this.hasRTLText||_l()==="unavailable"||this.hasRTLText&&vs.isParsed())&&(Fi=vA(an,I,Pi))}if(Ce){const mn=I.getValueAndResolveTokens("icon-image",Pi,w,$e);Sn=mn instanceof pt?mn:pt.fromString(mn)}if(!Fi&&!Sn)continue;const fn=this.sortFeaturesByKey?Fe.evaluate(Pi,{},w):void 0;if(this.features.push({id:ri,text:Fi,icon:Sn,index:gi,sourceLayerIndex:ei,geometry:Pi.geometry,properties:Mt.properties,type:m1[Mt.type],sortKey:fn}),Sn&&(Oe[Sn.name]=!0),Fi){const mn=Q.evaluate(Pi,{},w).join(","),an=z.get("text-rotation-alignment")!=="viewport"&&z.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(i.WritingMode.vertical)>=0;for(const nn of Fi.sections)if(nn.image)Oe[nn.image.name]=!0;else{const vn=th(Fi.toString()),gn=nn.fontStack||mn,Ji=je[gn]=je[gn]||{};this.calculateGlyphDependencies(nn.text,Ji,an,this.allowVerticalPlacement,vn)}}}z.get("symbol-placement")==="line"&&(this.features=function(Mt){const ri={},gi={},ei=[];let ui=0;function Pi(mn){ei.push(Mt[mn]),ui++}function Fi(mn,an,nn){const vn=gi[mn];return delete gi[mn],gi[an]=vn,ei[vn].geometry[0].pop(),ei[vn].geometry[0]=ei[vn].geometry[0].concat(nn[0]),vn}function Sn(mn,an,nn){const vn=ri[an];return delete ri[an],ri[mn]=vn,ei[vn].geometry[0].shift(),ei[vn].geometry[0]=nn[0].concat(ei[vn].geometry[0]),vn}function fn(mn,an,nn){const vn=nn?an[0][an[0].length-1]:an[0][0];return`${mn}:${vn.x}:${vn.y}`}for(let mn=0;mnmn.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((Mt,ri)=>Mt.sortKey-ri.sortKey)}update(l,f,w){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(l,f,this.layers,w),this.icon.programConfigurations.updatePaintArrays(l,f,this.layers,w))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(l){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(l),this.iconCollisionBox.upload(l)),this.text.upload(l,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(l,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(l,f){const w=this.lineVertexArray.length;if(l.segment!==void 0){let I=l.dist(f[l.segment+1]),z=l.dist(f[l.segment]);const Q={};for(let Z=l.segment+1;Z=0;Z--)Q[Z]={x:f[Z].x,y:f[Z].y,tileUnitDistanceFromAnchor:z},Z>0&&(z+=f[Z-1].dist(f[Z]));for(let Z=0;Z0}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(l,f){const w=l.placedSymbolArray.get(f),I=w.vertexStartIndex+4*w.numGlyphs;for(let z=w.vertexStartIndex;zI[Z]-I[re]||z[re]-z[Z]),Q}addToSortKeyRanges(l,f){const w=this.sortKeyRanges[this.sortKeyRanges.length-1];w&&w.sortKey===f?w.symbolInstanceEnd=l+1:this.sortKeyRanges.push({sortKey:f,symbolInstanceStart:l,symbolInstanceEnd:l+1})}sortFeatures(l){if(this.sortFeaturesByY&&this.sortedAngle!==l&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(l),this.sortedAngle=l,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const f of this.symbolInstanceIndexes){const w=this.symbolInstances.get(f);this.featureSortOrder.push(w.featureIndex),[w.rightJustifiedTextSymbolIndex,w.centerJustifiedTextSymbolIndex,w.leftJustifiedTextSymbolIndex].forEach((I,z,Q)=>{I>=0&&Q.indexOf(I)===z&&this.addIndicesForPlacedSymbol(this.text,I)}),w.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,w.verticalPlacedTextSymbolIndex),w.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,w.placedIconSymbolIndex),w.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,w.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}pn("SymbolBucket",bc,{omit:["layers","collisionBoxArray","features","compareText"]}),bc.MAX_GLYPHS=65535,bc.addDynamicAttributes=Ig;const y1=new Es({"symbol-placement":new Fn($t.layout_symbol["symbol-placement"]),"symbol-spacing":new Fn($t.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Fn($t.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Vn($t.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Fn($t.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Fn($t.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Fn($t.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Fn($t.layout_symbol["icon-ignore-placement"]),"icon-optional":new Fn($t.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Fn($t.layout_symbol["icon-rotation-alignment"]),"icon-size":new Vn($t.layout_symbol["icon-size"]),"icon-text-fit":new Fn($t.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Fn($t.layout_symbol["icon-text-fit-padding"]),"icon-image":new Vn($t.layout_symbol["icon-image"]),"icon-rotate":new Vn($t.layout_symbol["icon-rotate"]),"icon-padding":new Vn($t.layout_symbol["icon-padding"]),"icon-keep-upright":new Fn($t.layout_symbol["icon-keep-upright"]),"icon-offset":new Vn($t.layout_symbol["icon-offset"]),"icon-anchor":new Vn($t.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Fn($t.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Fn($t.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Fn($t.layout_symbol["text-rotation-alignment"]),"text-field":new Vn($t.layout_symbol["text-field"]),"text-font":new Vn($t.layout_symbol["text-font"]),"text-size":new Vn($t.layout_symbol["text-size"]),"text-max-width":new Vn($t.layout_symbol["text-max-width"]),"text-line-height":new Fn($t.layout_symbol["text-line-height"]),"text-letter-spacing":new Vn($t.layout_symbol["text-letter-spacing"]),"text-justify":new Vn($t.layout_symbol["text-justify"]),"text-radial-offset":new Vn($t.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Fn($t.layout_symbol["text-variable-anchor"]),"text-anchor":new Vn($t.layout_symbol["text-anchor"]),"text-max-angle":new Fn($t.layout_symbol["text-max-angle"]),"text-writing-mode":new Fn($t.layout_symbol["text-writing-mode"]),"text-rotate":new Vn($t.layout_symbol["text-rotate"]),"text-padding":new Fn($t.layout_symbol["text-padding"]),"text-keep-upright":new Fn($t.layout_symbol["text-keep-upright"]),"text-transform":new Vn($t.layout_symbol["text-transform"]),"text-offset":new Vn($t.layout_symbol["text-offset"]),"text-allow-overlap":new Fn($t.layout_symbol["text-allow-overlap"]),"text-overlap":new Fn($t.layout_symbol["text-overlap"]),"text-ignore-placement":new Fn($t.layout_symbol["text-ignore-placement"]),"text-optional":new Fn($t.layout_symbol["text-optional"])});var Ps={paint:new Es({"icon-opacity":new Vn($t.paint_symbol["icon-opacity"]),"icon-color":new Vn($t.paint_symbol["icon-color"]),"icon-halo-color":new Vn($t.paint_symbol["icon-halo-color"]),"icon-halo-width":new Vn($t.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Vn($t.paint_symbol["icon-halo-blur"]),"icon-translate":new Fn($t.paint_symbol["icon-translate"]),"icon-translate-anchor":new Fn($t.paint_symbol["icon-translate-anchor"]),"text-opacity":new Vn($t.paint_symbol["text-opacity"]),"text-color":new Vn($t.paint_symbol["text-color"],{runtimeType:vi,getOverride:A=>A.textColor,hasOverride:A=>!!A.textColor}),"text-halo-color":new Vn($t.paint_symbol["text-halo-color"]),"text-halo-width":new Vn($t.paint_symbol["text-halo-width"]),"text-halo-blur":new Vn($t.paint_symbol["text-halo-blur"]),"text-translate":new Fn($t.paint_symbol["text-translate"]),"text-translate-anchor":new Fn($t.paint_symbol["text-translate-anchor"])}),layout:y1};class Ep{constructor(l){if(l.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=l.property.overrides?l.property.overrides.runtimeType:nr,this.defaultValue=l}evaluate(l){if(l.formattedSection){const f=this.defaultValue.property.overrides;if(f&&f.hasOverride(l.formattedSection))return f.getOverride(l.formattedSection)}return l.feature&&l.featureState?this.defaultValue.evaluate(l.feature,l.featureState):this.defaultValue.property.specification.default}eachChild(l){this.defaultValue.isConstant()||l(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}pn("FormatSectionOverride",Ep,{omit:["defaultValue"]});class Tp extends Go{constructor(l){super(l,Ps)}recalculate(l,f){if(super.recalculate(l,f),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")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const w=this.layout.get("text-writing-mode");if(w){const I=[];for(const z of w)I.indexOf(z)<0&&I.push(z);this.layout._values["text-writing-mode"]=I}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(l,f,w,I){const z=this.layout.get(l).evaluate(f,{},w,I),Q=this._unevaluatedLayout._values[l];return Q.isDataDriven()||Vc(Q.value)||!z?z:function(Z,re){return re.replace(/{([^{}]+)}/g,(ge,Ce)=>Ce in Z?String(Z[Ce]):"")}(f.properties,z)}createBucket(l){return new bc(l)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const l of Ps.paint.overridableProperties){if(!Tp.hasPaintOverride(this.layout,l))continue;const f=this.paint.get(l),w=new Ep(f),I=new Ac(w,f.property.specification);let z=null;z=f.value.kind==="constant"||f.value.kind==="source"?new Lh("source",I):new Gc("composite",I,f.value.zoomStops),this.paint._values[l]=new uo(f.property,z,f.parameters)}}_handleOverridablePaintPropertyUpdate(l,f,w){return!(!this.layout||f.isDataDriven()||w.isDataDriven())&&Tp.hasPaintOverride(this.layout,l)}static hasPaintOverride(l,f){const w=l.get("text-field"),I=Ps.paint.properties[f];let z=!1;const Q=Z=>{for(const re of Z)if(I.overrides&&I.overrides.hasOverride(re))return void(z=!0)};if(w.value.kind==="constant"&&w.value.value instanceof He)Q(w.value.value.sections);else if(w.value.kind==="source"){const Z=ge=>{z||(ge instanceof wi&&Gt(ge.value)===qn?Q(ge.value.sections):ge instanceof Oc?Q(ge.sections):ge.eachChild(Z))},re=w.value;re._styleExpression&&Z(re._styleExpression.expression)}return z}}function Bd(A,l,f){let w="never";const I=A.get(l);return I?w=I:A.get(f)&&(w="always"),w}var Of={paint:new Es({"background-color":new Fn($t.paint_background["background-color"]),"background-pattern":new dA($t.paint_background["background-pattern"]),"background-opacity":new Fn($t.paint_background["background-opacity"])})},Sp={paint:new Es({"raster-opacity":new Fn($t.paint_raster["raster-opacity"]),"raster-hue-rotate":new Fn($t.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Fn($t.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Fn($t.paint_raster["raster-brightness-max"]),"raster-saturation":new Fn($t.paint_raster["raster-saturation"]),"raster-contrast":new Fn($t.paint_raster["raster-contrast"]),"raster-resampling":new Fn($t.paint_raster["raster-resampling"]),"raster-fade-duration":new Fn($t.paint_raster["raster-fade-duration"])})};class i0 extends Go{constructor(l){super(l,{}),this.onAdd=f=>{this.implementation.onAdd&&this.implementation.onAdd(f,f.painter.context.gl)},this.onRemove=f=>{this.implementation.onRemove&&this.implementation.onRemove(f,f.painter.context.gl)},this.implementation=l}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}const n0={circle:class extends Go{constructor(A){super(A,jo)}createBucket(A){return new $i(A)}queryRadius(A){const l=A;return Nr("circle-radius",this,l)+Nr("circle-stroke-width",this,l)+Qr(this.paint.get("circle-translate"))}queryIntersectsFeature(A,l,f,w,I,z,Q,Z){const re=go(A,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),z.angle,Q),ge=this.paint.get("circle-radius").evaluate(l,f)+this.paint.get("circle-stroke-width").evaluate(l,f),Ce=this.paint.get("circle-pitch-alignment")==="map",Fe=Ce?re:function(je,$e){return je.map(Rt=>Ea(Rt,$e))}(re,Z),Oe=Ce?ge*Q:ge;for(const je of w)for(const $e of je){const Rt=Ce?$e:Ea($e,Z);let Mt=Oe;const ri=Ka([],[$e.x,$e.y,0,1],Z);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?Mt*=ri[3]/z.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(Mt*=z.cameraToCenterDistance/ri[3]),pi(Fe,Rt,Mt))return!0}return!1}},heatmap:class extends Go{constructor(A){super(A,Zl),this._updateColorRamp()}createBucket(A){return new vl(A)}_handleSpecialPaintPropertyUpdate(A){A==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sg({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(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}},hillshade:class extends Go{constructor(A){super(A,og)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}},fill:class extends Go{constructor(A){super(A,zy)}recalculate(A,l){super.recalculate(A,l);const f=this.paint._values["fill-outline-color"];f.value.kind==="constant"&&f.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(A){return new hg(A)}queryRadius(){return Qr(this.paint.get("fill-translate"))}queryIntersectsFeature(A,l,f,w,I,z,Q){return In(go(A,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),z.angle,Q),w)}isTileClipped(){return!0}},"fill-extrusion":class extends Go{constructor(A){super(A,Oy)}createBucket(A){return new If(A)}queryRadius(){return Qr(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(A,l,f,w,I,z,Q,Z){const re=go(A,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),z.angle,Q),ge=this.paint.get("fill-extrusion-height").evaluate(l,f),Ce=this.paint.get("fill-extrusion-base").evaluate(l,f),Fe=function(je,$e,Rt,Mt){const ri=[];for(const gi of je){const ei=[gi.x,gi.y,0,1];Ka(ei,ei,$e),ri.push(new xe(ei[0]/ei[3],ei[1]/ei[3]))}return ri}(re,Z),Oe=function(je,$e,Rt,Mt){const ri=[],gi=[],ei=Mt[8]*$e,ui=Mt[9]*$e,Pi=Mt[10]*$e,Fi=Mt[11]*$e,Sn=Mt[8]*Rt,fn=Mt[9]*Rt,mn=Mt[10]*Rt,an=Mt[11]*Rt;for(const nn of je){const vn=[],gn=[];for(const Ji of nn){const Wn=Ji.x,zn=Ji.y,yr=Mt[0]*Wn+Mt[4]*zn+Mt[12],ms=Mt[1]*Wn+Mt[5]*zn+Mt[13],bs=Mt[2]*Wn+Mt[6]*zn+Mt[14],Vs=Mt[3]*Wn+Mt[7]*zn+Mt[15],Cl=bs+Pi,xo=Vs+Fi,Ks=yr+Sn,oo=ms+fn,Lo=bs+mn,$o=Vs+an,Ia=new xe((yr+ei)/xo,(ms+ui)/xo);Ia.z=Cl/xo,vn.push(Ia);const io=new xe(Ks/$o,oo/$o);io.z=Lo/$o,gn.push(io)}ri.push(vn),gi.push(gn)}return[ri,gi]}(w,Ce,ge,Z);return function(je,$e,Rt){let Mt=1/0;In(Rt,$e)&&(Mt=Ny(Rt,$e[0]));for(let ri=0;ri<$e.length;ri++){const gi=$e[ri],ei=je[ri];for(let ui=0;ui=3){for(let Rt=0;Rt<$e.length;Rt++)if(Dr(Ce,$e[Rt]))return!0}if(Hn(Ce,$e,Oe))return!0}return!1}(Z,w,re)}isTileClipped(){return!0}},symbol:Tp,background:class extends Go{constructor(A){super(A,Of)}},raster:class extends Go{constructor(A){super(A,Sp)}}};class Mp{constructor(l){this._callback=l,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(){delete this._channel,this._callback=()=>{}}}const Nf=63710088e-1;class Ts{constructor(l,f){if(isNaN(l)||isNaN(f))throw new Error(`Invalid LngLat object: (${l}, ${f})`);if(this.lng=+l,this.lat=+f,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Ts(G(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(l){const f=Math.PI/180,w=this.lat*f,I=l.lat*f,z=Math.sin(w)*Math.sin(I)+Math.cos(w)*Math.cos(I)*Math.cos((l.lng-this.lng)*f);return Nf*Math.acos(Math.min(z,1))}toBounds(l=0){const f=360*l/40075017,w=f/Math.cos(Math.PI/180*this.lat);return new SA(new Ts(this.lng-w,this.lat-f),new Ts(this.lng+w,this.lat+f))}static convert(l){if(l instanceof Ts)return l;if(Array.isArray(l)&&(l.length===2||l.length===3))return new Ts(Number(l[0]),Number(l[1]));if(!Array.isArray(l)&&typeof l=="object"&&l!==null)return new Ts(Number("lng"in l?l.lng:l.lon),Number(l.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class SA{constructor(l,f){l&&(f?this.setSouthWest(l).setNorthEast(f):l.length===4?this.setSouthWest([l[0],l[1]]).setNorthEast([l[2],l[3]]):this.setSouthWest(l[0]).setNorthEast(l[1]))}setNorthEast(l){return this._ne=l instanceof Ts?new Ts(l.lng,l.lat):Ts.convert(l),this}setSouthWest(l){return this._sw=l instanceof Ts?new Ts(l.lng,l.lat):Ts.convert(l),this}extend(l){const f=this._sw,w=this._ne;let I,z;if(l instanceof Ts)I=l,z=l;else{if(!(l instanceof SA))return Array.isArray(l)?l.length===4||l.every(Array.isArray)?this.extend(SA.convert(l)):this.extend(Ts.convert(l)):this;if(I=l._sw,z=l._ne,!I||!z)return this}return f||w?(f.lng=Math.min(I.lng,f.lng),f.lat=Math.min(I.lat,f.lat),w.lng=Math.max(z.lng,w.lng),w.lat=Math.max(z.lat,w.lat)):(this._sw=new Ts(I.lng,I.lat),this._ne=new Ts(z.lng,z.lat)),this}getCenter(){return new Ts((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 Ts(this.getWest(),this.getNorth())}getSouthEast(){return new Ts(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(l){const{lng:f,lat:w}=Ts.convert(l);let I=this._sw.lng<=f&&f<=this._ne.lng;return this._sw.lng>this._ne.lng&&(I=this._sw.lng>=f&&f>=this._ne.lng),this._sw.lat<=w&&w<=this._ne.lat&&I}static convert(l){return l instanceof SA?l:l&&new SA(l)}}const Lg=2*Math.PI*Nf;function Cd(A){return Lg*Math.cos(A*Math.PI/180)}function r0(A){return(180+A)/360}function Qf(A){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+A*Math.PI/360)))/360}function s0(A,l){return A/Cd(l)}function Ip(A){return 360/Math.PI*Math.atan(Math.exp((180-360*A)*Math.PI/180))-90}class Ed{constructor(l,f,w=0){this.x=+l,this.y=+f,this.z=+w}static fromLngLat(l,f=0){const w=Ts.convert(l);return new Ed(r0(w.lng),Qf(w.lat),s0(f,w.lat))}toLngLat(){return new Ts(360*this.x-180,Ip(this.y))}toAltitude(){return this.z*Cd(Ip(this.y))}meterInMercatorCoordinateUnits(){return 1/Lg*(l=Ip(this.y),1/Math.cos(l*Math.PI/180));var l}}function Fp(A,l,f){var w=2*Math.PI*6378137/256/Math.pow(2,f);return[A*w-2*Math.PI*6378137/2,l*w-2*Math.PI*6378137/2]}class Dg{constructor(l,f,w){if(l<0||l>25||w<0||w>=Math.pow(2,l)||f<0||f>=Math.pow(2,l))throw new Error(`x=${f}, y=${w}, z=${l} outside of bounds. 0<=x<${Math.pow(2,l)}, 0<=y<${Math.pow(2,l)} 0<=z<=25 `);this.z=l,this.x=f,this.y=w,this.key=Lp(0,l,l,f,w)}equals(l){return this.z===l.z&&this.x===l.x&&this.y===l.y}url(l,f,w){const I=(Q=this.y,Z=this.z,re=Fp(256*(z=this.x),256*(Q=Math.pow(2,Z)-Q-1),Z),ge=Fp(256*(z+1),256*(Q+1),Z),re[0]+","+re[1]+","+ge[0]+","+ge[1]);var z,Q,Z,re,ge;const Ce=function(Fe,Oe,je){let $e,Rt="";for(let Mt=Fe;Mt>0;Mt--)$e=1<1?"@2x":"").replace(/{quadkey}/g,Ce).replace(/{bbox-epsg-3857}/g,I)}isChildOf(l){const f=this.z-l.z;return f>0&&l.x===this.x>>f&&l.y===this.y>>f}getTilePoint(l){const f=Math.pow(2,this.z);return new xe((l.x*f-this.x)*Kt,(l.y*f-this.y)*Kt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class o0{constructor(l,f){this.wrap=l,this.canonical=f,this.key=Lp(l,f.z,f.z,f.x,f.y)}}class Bl{constructor(l,f,w,I,z){if(l= z; overscaledZ = ${l}; z = ${w}`);this.overscaledZ=l,this.wrap=f,this.canonical=new Dg(w,+I,+z),this.key=Lp(f,l,w,I,z)}clone(){return new Bl(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(l){return this.overscaledZ===l.overscaledZ&&this.wrap===l.wrap&&this.canonical.equals(l.canonical)}scaledTo(l){if(l>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${l}; overscaledZ = ${this.overscaledZ}`);const f=this.canonical.z-l;return l>this.canonical.z?new Bl(l,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Bl(l,this.wrap,l,this.canonical.x>>f,this.canonical.y>>f)}calculateScaledKey(l,f){if(l>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${l}; overscaledZ = ${this.overscaledZ}`);const w=this.canonical.z-l;return l>this.canonical.z?Lp(this.wrap*+f,l,this.canonical.z,this.canonical.x,this.canonical.y):Lp(this.wrap*+f,l,l,this.canonical.x>>w,this.canonical.y>>w)}isChildOf(l){if(l.wrap!==this.wrap)return!1;const f=this.canonical.z-l.canonical.z;return l.overscaledZ===0||l.overscaledZ>f&&l.canonical.y===this.canonical.y>>f}children(l){if(this.overscaledZ>=l)return[new Bl(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const f=this.canonical.z+1,w=2*this.canonical.x,I=2*this.canonical.y;return[new Bl(f,this.wrap,f,w,I),new Bl(f,this.wrap,f,w+1,I),new Bl(f,this.wrap,f,w,I+1),new Bl(f,this.wrap,f,w+1,I+1)]}isLessThan(l){return this.wrapl.wrap)&&(this.overscaledZl.overscaledZ)&&(this.canonical.xl.canonical.x)&&this.canonical.ythis.max&&(this.max=Z),Z=this.dim+1||f<-1||f>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(f+1)*this.stride+(l+1)}_unpackMapbox(l,f,w){return(256*l*256+256*f+w)/10-1e4}_unpackTerrarium(l,f,w){return 256*l+f+w/256-32768}getPixels(){return new da({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(l,f,w){if(this.dim!==l.dim)throw new Error("dem dimension mismatch");let I=f*this.dim,z=f*this.dim+this.dim,Q=w*this.dim,Z=w*this.dim+this.dim;switch(f){case-1:I=z-1;break;case 1:z=I+1}switch(w){case-1:Q=Z-1;break;case 1:Z=Q+1}const re=-f*this.dim,ge=-w*this.dim;for(let Ce=Q;Ce=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${l} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[l]}}class Dp{constructor(l,f,w,I,z){this.type="Feature",this._vectorTileFeature=l,l._z=f,l._x=w,l._y=I,this.properties=l.properties,this.id=z}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(l){this._geometry=l}toJSON(){const l={geometry:this.geometry};for(const f in this)f!=="_geometry"&&f!=="_vectorTileFeature"&&(l[f]=this[f]);return l}}class c0{constructor(l,f){this.tileID=l,this.x=l.canonical.x,this.y=l.canonical.y,this.z=l.canonical.z,this.grid=new fc(Kt,16,0),this.grid3D=new fc(Kt,16,0),this.featureIndexArray=new ur,this.promoteId=f}insert(l,f,w,I,z,Q){const Z=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(w,I,z);const re=Q?this.grid3D:this.grid;for(let ge=0;ge=0&&Fe[3]>=0&&re.insert(Z,Fe[0],Fe[1],Fe[2],Fe[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Eu.VectorTile(new Tu(this.rawTileData)).layers,this.sourceLayerCoder=new l0(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(l,f,w,I){this.loadVTLayers();const z=l.params||{},Q=Kt/l.tileSize/l.scale,Z=Ho(z.filter),re=l.queryGeometry,ge=l.queryPadding*Q,Ce=MA(re),Fe=this.grid.query(Ce.minX-ge,Ce.minY-ge,Ce.maxX+ge,Ce.maxY+ge),Oe=MA(l.cameraQueryGeometry),je=this.grid3D.query(Oe.minX-ge,Oe.minY-ge,Oe.maxX+ge,Oe.maxY+ge,(Mt,ri,gi,ei)=>function(ui,Pi,Fi,Sn,fn){for(const an of ui)if(Pi<=an.x&&Fi<=an.y&&Sn>=an.x&&fn>=an.y)return!0;const mn=[new xe(Pi,Fi),new xe(Pi,fn),new xe(Sn,fn),new xe(Sn,Fi)];if(ui.length>2){for(const an of mn)if(Dr(ui,an))return!0}for(let an=0;an(ei||(ei=Ri(ui)),Pi.queryIntersectsFeature(re,ui,Fi,ei,this.z,l.transform,Q,l.pixelPosMatrix)))}return $e}loadMatchingFeature(l,f,w,I,z,Q,Z,re,ge,Ce,Fe){const Oe=this.bucketLayerIDs[f];if(Q&&!function(Mt,ri){for(let gi=0;gi=0)return!0;return!1}(Q,Oe))return;const je=this.sourceLayerCoder.decode(w),$e=this.vtLayers[je].feature(I);if(z.needGeometry){const Mt=Ai($e,!0);if(!z.filter(new Zr(this.tileID.overscaledZ),Mt,this.tileID.canonical))return}else if(!z.filter(new Zr(this.tileID.overscaledZ),$e))return;const Rt=this.getId($e,je);for(let Mt=0;Mt{const Z=l instanceof Js?l.get(Q):null;return Z&&Z.evaluate?Z.evaluate(f,w,I):Z})}function MA(A){let l=1/0,f=1/0,w=-1/0,I=-1/0;for(const z of A)l=Math.min(l,z.x),f=Math.min(f,z.y),w=Math.max(w,z.x),I=Math.max(I,z.y);return{minX:l,minY:f,maxX:w,maxY:I}}function x1(A,l){return l-A}var Ug;pn("FeatureIndex",c0,{omit:["rawTileData","sourceLayerCoder"]}),i.PerformanceMarkers=void 0,(Ug=i.PerformanceMarkers||(i.PerformanceMarkers={})).create="create",Ug.load="load",Ug.fullLoad="fullLoad";let Vf=null,Td=[];const Hf=1e3/30,v1={mark(A){performance.mark(A)},frame(A){const l=A;Vf!=null&&Td.push(l-Vf),Vf=l},clearMetrics(){Vf=null,Td=[],performance.clearMeasures("loadTime"),performance.clearMeasures("fullLoadTime");for(const A in i.PerformanceMarkers)performance.clearMarks(i.PerformanceMarkers[A])},getPerformanceMetrics(){performance.measure("loadTime",i.PerformanceMarkers.create,i.PerformanceMarkers.load),performance.measure("fullLoadTime",i.PerformanceMarkers.create,i.PerformanceMarkers.fullLoad);const A=performance.getEntriesByName("loadTime")[0].duration,l=performance.getEntriesByName("fullLoadTime")[0].duration,f=Td.length,w=1/(Td.reduce((z,Q)=>z+Q,0)/f/1e3),I=Td.filter(z=>z>Hf).reduce((z,Q)=>z+(Q-Hf)/Hf,0);return{loadTime:A,fullLoadTime:l,fps:w,percentDroppedFrames:I/(f+I)*100}}};i.AJAXError=Ft,i.ARRAY_TYPE=_r,i.Actor=class{constructor(A,l,f){this.target=A,this.parent=l,this.mapId=f,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},B(["receive","process"],this),this.invoker=new Mp(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=Me()?A:window}send(A,l,f,w,I=!1){const z=Math.round(1e18*Math.random()).toString(36).substring(0,10);f&&(this.callbacks[z]=f);const Q=te(this.globalScope)?void 0:[];return this.target.postMessage({id:z,type:A,hasCallback:!!f,targetMapId:w,mustQueue:I,sourceMapId:this.mapId,data:Wl(l,Q)},Q),{cancel:()=>{f&&delete this.callbacks[z],this.target.postMessage({id:z,type:"",targetMapId:w,sourceMapId:this.mapId})}}}receive(A){const l=A.data,f=l.id;if(f&&(!l.targetMapId||this.mapId===l.targetMapId))if(l.type===""){delete this.tasks[f];const w=this.cancelCallbacks[f];delete this.cancelCallbacks[f],w&&w()}else Me()||l.mustQueue?(this.tasks[f]=l,this.taskQueue.push(f),this.invoker.trigger()):this.processTask(f,l)}process(){if(!this.taskQueue.length)return;const A=this.taskQueue.shift(),l=this.tasks[A];delete this.tasks[A],this.taskQueue.length&&this.invoker.trigger(),l&&this.processTask(A,l)}processTask(A,l){if(l.type===""){const f=this.callbacks[A];delete this.callbacks[A],f&&(l.error?f(Ns(l.error)):f(null,Ns(l.data)))}else{let f=!1;const w=te(this.globalScope)?void 0:[],I=l.hasCallback?(Z,re)=>{f=!0,delete this.cancelCallbacks[A],this.target.postMessage({id:A,type:"",sourceMapId:this.mapId,error:Z?Wl(Z):null,data:Wl(re,w)},w)}:Z=>{f=!0};let z=null;const Q=Ns(l.data);if(this.parent[l.type])z=this.parent[l.type](l.sourceMapId,Q,I);else if(this.parent.getWorkerSource){const Z=l.type.split(".");z=this.parent.getWorkerSource(l.sourceMapId,Z[0],Q.source)[Z[1]](Q,I)}else I(new Error(`Could not find function ${l.type}`));!f&&z&&z.cancel&&(this.cancelCallbacks[A]=z.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.AlphaImage=Xh,i.CanonicalTileID=Dg,i.CollisionBoxArray=Ei,i.CollisionCircleLayoutArray=class extends Te{},i.Color=de,i.DEMData=a0,i.DataConstantProperty=Fn,i.DictionaryCoder=l0,i.EXTENT=Kt,i.ErrorEvent=qi,i.EvaluationParameters=Zr,i.Event=Ni,i.Evented=en,i.FeatureIndex=c0,i.FillBucket=hg,i.FillExtrusionBucket=If,i.GeoJSONFeature=Dp,i.ImageAtlas=md,i.ImagePosition=EA,i.LineBucket=yp,i.LineStripIndexArray=class extends St{},i.LngLat=Ts,i.LngLatBounds=SA,i.MercatorCoordinate=Ed,i.ONE_EM=yo,i.OverscaledTileID=Bl,i.PerformanceUtils=v1,i.PosArray=Un,i.Properties=Es,i.QuadTriangleArray=class extends We{},i.RGBAImage=da,i.RasterBoundsArray=class extends M{},i.RequestPerformance=class{constructor(A){this._marks={start:[A.url,"start"].join("#"),end:[A.url,"end"].join("#"),measure:A.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let A=performance.getEntriesByName(this._marks.measure);return A.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),A=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),A}},i.ResourceType=Ct,i.SegmentVector=a,i.SymbolBucket=bc,i.Transitionable=yc,i.TriangleIndexArray=mo,i.Uniform1f=nt,i.Uniform1i=class extends rt{constructor(A,l){super(A,l),this.current=0}set(A){this.current!==A&&(this.current=A,this.gl.uniform1i(this.location,A))}},i.Uniform2f=class extends rt{constructor(A,l){super(A,l),this.current=[0,0]}set(A){A[0]===this.current[0]&&A[1]===this.current[1]||(this.current=A,this.gl.uniform2f(this.location,A[0],A[1]))}},i.Uniform3f=class extends rt{constructor(A,l){super(A,l),this.current=[0,0,0]}set(A){A[0]===this.current[0]&&A[1]===this.current[1]&&A[2]===this.current[2]||(this.current=A,this.gl.uniform3f(this.location,A[0],A[1],A[2]))}},i.Uniform4f=lt,i.UniformColor=Xe,i.UniformMatrix4f=class extends rt{constructor(A,l){super(A,l),this.current=Ye}set(A){if(A[12]!==this.current[12]||A[0]!==this.current[0])return this.current=A,void this.gl.uniformMatrix4fv(this.location,!1,A);for(let l=1;l<16;l++)if(A[l]!==this.current[l]){this.current=A,this.gl.uniformMatrix4fv(this.location,!1,A);break}}},i.UnwrappedTileID=o0,i.ValidationError=at,i.ZoomHistory=gl,i.add=function(A,l,f){return A[0]=l[0]+f[0],A[1]=l[1]+f[1],A[2]=l[2]+f[2],A},i.addDynamicAttributes=Ig,i.asyncAll=function(A,l,f){if(!A.length)return f(null,[]);let w=A.length;const I=new Array(A.length);let z=null;A.forEach((Q,Z)=>{l(Q,(re,ge)=>{re&&(z=re),I[Z]=ge,--w==0&&f(z,I)})})},i.bezier=U,i.bindAll=B,i.cacheEntryPossiblyAdded=function(A){vt++,vt>qe&&(A.getActor().send("enforceCacheSizeLimit",Ie),vt=0)},i.clamp=R,i.clearTileCache=function(A){const l=caches.delete(Ge);A&&l.catch(A).then(()=>A())},i.clipLine=Yy,i.clone=function(A){var l=new _r(16);return l[0]=A[0],l[1]=A[1],l[2]=A[2],l[3]=A[3],l[4]=A[4],l[5]=A[5],l[6]=A[6],l[7]=A[7],l[8]=A[8],l[9]=A[9],l[10]=A[10],l[11]=A[11],l[12]=A[12],l[13]=A[13],l[14]=A[14],l[15]=A[15],l},i.clone$1=Ae,i.clone$2=function(A){var l=new _r(3);return l[0]=A[0],l[1]=A[1],l[2]=A[2],l},i.collisionCircleLayout=Wy,i.config=Ne,i.copy=function(A,l){return A[0]=l[0],A[1]=l[1],A[2]=l[2],A[3]=l[3],A[4]=l[4],A[5]=l[5],A[6]=l[6],A[7]=l[7],A[8]=l[8],A[9]=l[9],A[10]=l[10],A[11]=l[11],A[12]=l[12],A[13]=l[13],A[14]=l[14],A[15]=l[15],A},i.create=function(){var A=new _r(16);return _r!=Float32Array&&(A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[11]=0,A[12]=0,A[13]=0,A[14]=0),A[0]=1,A[5]=1,A[10]=1,A[15]=1,A},i.create$1=Xr,i.createExpression=Hc,i.createFilter=Ho,i.createLayout=Fs,i.createStyleLayer=function(A){return A.type==="custom"?new i0(A):new n0[A.type](A)},i.cross=function(A,l,f){var w=l[0],I=l[1],z=l[2],Q=f[0],Z=f[1],re=f[2];return A[0]=I*re-z*Z,A[1]=z*Q-w*re,A[2]=w*Z-I*Q,A},i.dot=function(A,l){return A[0]*l[0]+A[1]*l[1]+A[2]*l[2]},i.dot$1=function(A,l){return A[0]*l[0]+A[1]*l[1]+A[2]*l[2]+A[3]*l[3]},i.ease=N,i.emitValidationErrors=Nh,i.enforceCacheSizeLimit=function(A){et(),Ve&&Ve.then(l=>{l.keys().then(f=>{for(let w=0;w{}}},i.identity=Fr,i.invert=function(A,l){var f=l[0],w=l[1],I=l[2],z=l[3],Q=l[4],Z=l[5],re=l[6],ge=l[7],Ce=l[8],Fe=l[9],Oe=l[10],je=l[11],$e=l[12],Rt=l[13],Mt=l[14],ri=l[15],gi=f*Z-w*Q,ei=f*re-I*Q,ui=f*ge-z*Q,Pi=w*re-I*Z,Fi=w*ge-z*Z,Sn=I*ge-z*re,fn=Ce*Rt-Fe*$e,mn=Ce*Mt-Oe*$e,an=Ce*ri-je*$e,nn=Fe*Mt-Oe*Rt,vn=Fe*ri-je*Rt,gn=Oe*ri-je*Mt,Ji=gi*gn-ei*vn+ui*nn+Pi*an-Fi*mn+Sn*fn;return Ji?(A[0]=(Z*gn-re*vn+ge*nn)*(Ji=1/Ji),A[1]=(I*vn-w*gn-z*nn)*Ji,A[2]=(Rt*Sn-Mt*Fi+ri*Pi)*Ji,A[3]=(Oe*Fi-Fe*Sn-je*Pi)*Ji,A[4]=(re*an-Q*gn-ge*mn)*Ji,A[5]=(f*gn-I*an+z*mn)*Ji,A[6]=(Mt*ui-$e*Sn-ri*ei)*Ji,A[7]=(Ce*Sn-Oe*ui+je*ei)*Ji,A[8]=(Q*vn-Z*an+ge*fn)*Ji,A[9]=(w*an-f*vn-z*fn)*Ji,A[10]=($e*Fi-Rt*ui+ri*gi)*Ji,A[11]=(Fe*ui-Ce*Fi-je*gi)*Ji,A[12]=(Z*mn-Q*nn-re*fn)*Ji,A[13]=(f*nn-w*mn+I*fn)*Ji,A[14]=(Rt*ei-$e*Pi-Mt*gi)*Ji,A[15]=(Ce*Pi-Fe*ei+Oe*gi)*Ji,A):null},i.isImageBitmap=ce,i.isSafari=te,i.isWorker=Me,i.keysDifference=function(A,l){const f=[];for(const w in A)w in l||f.push(w);return f},i.lazyLoadRTLTextPlugin=function(){vs.isLoading()||vs.isLoaded()||_l()!=="deferred"||An()},i.makeRequest=fi,i.mapObject=ae,i.mercatorXfromLng=r0,i.mercatorYfromLat=Qf,i.mercatorZfromAltitude=s0,i.mul=rs,i.mul$1=function(A,l,f){return A[0]=l[0]*f[0],A[1]=l[1]*f[1],A[2]=l[2]*f[2],A[3]=l[3]*f[3],A},i.multiply=Ls,i.nextPowerOfTwo=function(A){return A<=1?1:Math.pow(2,Math.ceil(Math.log(A)/Math.LN2))},i.normalize=function(A,l){var f=l[0],w=l[1],I=l[2],z=f*f+w*w+I*I;return z>0&&(z=1/Math.sqrt(z)),A[0]=l[0]*z,A[1]=l[1]*z,A[2]=l[2]*z,A},i.number=ns,i.ortho=function(A,l,f,w,I,z,Q){var Z=1/(l-f),re=1/(w-I),ge=1/(z-Q);return A[0]=-2*Z,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=-2*re,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[10]=2*ge,A[11]=0,A[12]=(l+f)*Z,A[13]=(I+w)*re,A[14]=(Q+z)*ge,A[15]=1,A},i.parseCacheControl=Ke,i.parseGlyphPbf=function(A){return new Tu(A).readFields(fd,[])},i.pbf=Tu,i.performSymbolLayout=function(A){A.bucket.createArrays(),A.bucket.tilePixelRatio=Kt/(512*A.bucket.overscaling),A.bucket.compareText={},A.bucket.iconsNeedLinear=!1;const l=A.bucket.layers[0].layout,f=A.bucket.layers[0]._unevaluatedLayout._values,w={layoutIconSize:f["icon-size"].possiblyEvaluate(new Zr(A.bucket.zoom+1),A.canonical),layoutTextSize:f["text-size"].possiblyEvaluate(new Zr(A.bucket.zoom+1),A.canonical),textMaxSize:f["text-size"].possiblyEvaluate(new Zr(18))};if(A.bucket.textSizeData.kind==="composite"){const{minZoom:re,maxZoom:ge}=A.bucket.textSizeData;w.compositeTextSizes=[f["text-size"].possiblyEvaluate(new Zr(re),A.canonical),f["text-size"].possiblyEvaluate(new Zr(ge),A.canonical)]}if(A.bucket.iconSizeData.kind==="composite"){const{minZoom:re,maxZoom:ge}=A.bucket.iconSizeData;w.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new Zr(re),A.canonical),f["icon-size"].possiblyEvaluate(new Zr(ge),A.canonical)]}const I=l.get("text-line-height")*yo,z=l.get("text-rotation-alignment")!=="viewport"&&l.get("symbol-placement")!=="point",Q=l.get("text-keep-upright"),Z=l.get("text-size");for(const re of A.bucket.features){const ge=l.get("text-font").evaluate(re,{},A.canonical).join(","),Ce=Z.evaluate(re,{},A.canonical),Fe=w.layoutTextSize.evaluate(re,{},A.canonical),Oe=w.layoutIconSize.evaluate(re,{},A.canonical),je={horizontal:{},vertical:void 0},$e=re.text;let Rt,Mt=[0,0];if($e){const ei=$e.toString(),ui=l.get("text-letter-spacing").evaluate(re,{},A.canonical)*yo,Pi=Ur(ei)?ui:0,Fi=l.get("text-anchor").evaluate(re,{},A.canonical),Sn=l.get("text-variable-anchor");if(!Sn){const vn=l.get("text-radial-offset").evaluate(re,{},A.canonical);Mt=vn?vd(Fi,[vn*yo,Mg]):l.get("text-offset").evaluate(re,{},A.canonical).map(gn=>gn*yo)}let fn=z?"center":l.get("text-justify").evaluate(re,{},A.canonical);const mn=l.get("symbol-placement"),an=mn==="point"?l.get("text-max-width").evaluate(re,{},A.canonical)*yo:0,nn=()=>{A.bucket.allowVerticalPlacement&&th(ei)&&(je.vertical=Ma($e,A.glyphMap,A.glyphPositions,A.imagePositions,ge,an,I,Fi,"left",Pi,Mt,i.WritingMode.vertical,!0,mn,Fe,Ce))};if(!z&&Sn){const vn=fn==="auto"?Sn.map(Ji=>wd(Ji)):[fn];let gn=!1;for(let Ji=0;Jithis._layers[jt.id]),tt=Re[0];if(tt.visibility==="none")continue;const He=tt.source||"";let Je=this.familiesBySource[He];Je||(Je=this.familiesBySource[He]={});const pt=tt.sourceLayer||"_geojsonTileLayer";let Lt=Je[pt];Lt||(Lt=Je[pt]=[]),Lt.push(Re)}}}class N{constructor(j){const ie={},ne=[];for(const He in j){const Je=j[He],pt=ie[He]={};for(const Lt in Je){const jt=Je[+Lt];if(!jt||jt.bitmap.width===0||jt.bitmap.height===0)continue;const Gt={x:0,y:0,w:jt.bitmap.width+2,h:jt.bitmap.height+2};ne.push(Gt),pt[Lt]={rect:Gt,metrics:jt.metrics}}}const{w:de,h:Re}=i.potpack(ne),tt=new i.AlphaImage({width:de||1,height:Re||1});for(const He in j){const Je=j[He];for(const pt in Je){const Lt=Je[+pt];if(!Lt||Lt.bitmap.width===0||Lt.bitmap.height===0)continue;const jt=ie[He][pt].rect;i.AlphaImage.copy(Lt.bitmap,tt,{x:0,y:0},{x:jt.x+1,y:jt.y+1},Lt.bitmap)}}this.image=tt,this.positions=ie}}i.register("GlyphAtlas",N);class R{constructor(j){this.tileID=new i.OverscaledTileID(j.tileID.overscaledZ,j.tileID.wrap,j.tileID.canonical.z,j.tileID.canonical.x,j.tileID.canonical.y),this.uid=j.uid,this.zoom=j.zoom,this.pixelRatio=j.pixelRatio,this.tileSize=j.tileSize,this.source=j.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=j.showCollisionBoxes,this.collectResourceTiming=!!j.collectResourceTiming,this.returnDependencies=!!j.returnDependencies,this.promoteId=j.promoteId}parse(j,ie,ne,de,Re){this.status="parsing",this.data=j,this.collisionBoxArray=new i.CollisionBoxArray;const tt=new i.DictionaryCoder(Object.keys(j.layers).sort()),He=new i.FeatureIndex(this.tileID,this.promoteId);He.bucketLayerIDs=[];const Je={},pt={featureIndex:He,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:ne},Lt=ie.familiesBySource[this.source];for(const yn in Lt){const Yt=j.layers[yn];if(!Yt)continue;Yt.version===1&&i.warnOnce(`Vector tile source "${this.source}" layer "${yn}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const sr=tt.encode(yn),Yn=[];for(let Wr=0;Wr=mr.maxzoom||mr.visibility!=="none"&&(G(Wr,this.zoom,ne),(Je[mr.id]=mr.createBucket({index:He.bucketLayerIDs.length,layers:Wr,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:sr,sourceID:this.source})).populate(Yn,pt,this.tileID.canonical),He.bucketLayerIDs.push(Wr.map(Mr=>Mr.id)))}}let jt,Gt,ki,wi;const Oi=i.mapObject(pt.glyphDependencies,yn=>Object.keys(yn).map(Number));Object.keys(Oi).length?de.send("getGlyphs",{uid:this.uid,stacks:Oi},(yn,Yt)=>{jt||(jt=yn,Gt=Yt,rr.call(this))}):Gt={};const Yi=Object.keys(pt.iconDependencies);Yi.length?de.send("getImages",{icons:Yi,source:this.source,tileID:this.tileID,type:"icons"},(yn,Yt)=>{jt||(jt=yn,ki=Yt,rr.call(this))}):ki={};const tn=Object.keys(pt.patternDependencies);function rr(){if(jt)return Re(jt);if(Gt&&ki&&wi){const yn=new N(Gt),Yt=new i.ImageAtlas(ki,wi);for(const sr in Je){const Yn=Je[sr];Yn instanceof i.SymbolBucket?(G(Yn.layers,this.zoom,ne),i.performSymbolLayout({bucket:Yn,glyphMap:Gt,glyphPositions:yn.positions,imageMap:ki,imagePositions:Yt.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):Yn.hasPattern&&(Yn instanceof i.LineBucket||Yn instanceof i.FillBucket||Yn instanceof i.FillExtrusionBucket)&&(G(Yn.layers,this.zoom,ne),Yn.addFeatures(pt,this.tileID.canonical,Yt.patternPositions))}this.status="done",Re(null,{buckets:Object.values(Je).filter(sr=>!sr.isEmpty()),featureIndex:He,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:yn.image,imageAtlas:Yt,glyphMap:this.returnDependencies?Gt:null,iconMap:this.returnDependencies?ki:null,glyphPositions:this.returnDependencies?yn.positions:null})}}tn.length?de.send("getImages",{icons:tn,source:this.source,tileID:this.tileID,type:"patterns"},(yn,Yt)=>{jt||(jt=yn,wi=Yt,rr.call(this))}):wi={},rr.call(this)}}function G(X,j,ie){const ne=new i.EvaluationParameters(j);for(const de of X)de.recalculate(ne,ie)}function J(X,j){const ie=i.getArrayBuffer(X.request,(ne,de,Re,tt)=>{ne?j(ne):de&&j(null,{vectorTile:new i.vectorTile.VectorTile(new i.pbf(de)),rawData:de,cacheControl:Re,expires:tt})});return()=>{ie.cancel(),j()}}class Y{constructor(j,ie,ne,de){this.actor=j,this.layerIndex=ie,this.availableImages=ne,this.loadVectorData=de||J,this.loading={},this.loaded={}}loadTile(j,ie){const ne=j.uid;this.loading||(this.loading={});const de=!!(j&&j.request&&j.request.collectResourceTiming)&&new i.RequestPerformance(j.request),Re=this.loading[ne]=new R(j);Re.abort=this.loadVectorData(j,(tt,He)=>{if(delete this.loading[ne],tt||!He)return Re.status="done",this.loaded[ne]=Re,ie(tt);const Je=He.rawData,pt={};He.expires&&(pt.expires=He.expires),He.cacheControl&&(pt.cacheControl=He.cacheControl);const Lt={};if(de){const jt=de.finish();jt&&(Lt.resourceTiming=JSON.parse(JSON.stringify(jt)))}Re.vectorTile=He.vectorTile,Re.parse(He.vectorTile,this.layerIndex,this.availableImages,this.actor,(jt,Gt)=>{if(jt||!Gt)return ie(jt);ie(null,i.extend({rawTileData:Je.slice(0)},Gt,pt,Lt))}),this.loaded=this.loaded||{},this.loaded[ne]=Re})}reloadTile(j,ie){const ne=this.loaded,de=j.uid,Re=this;if(ne&&ne[de]){const tt=ne[de];tt.showCollisionBoxes=j.showCollisionBoxes;const He=(Je,pt)=>{const Lt=tt.reloadCallback;Lt&&(delete tt.reloadCallback,tt.parse(tt.vectorTile,Re.layerIndex,this.availableImages,Re.actor,Lt)),ie(Je,pt)};tt.status==="parsing"?tt.reloadCallback=He:tt.status==="done"&&(tt.vectorTile?tt.parse(tt.vectorTile,this.layerIndex,this.availableImages,this.actor,He):He())}}abortTile(j,ie){const ne=this.loading,de=j.uid;ne&&ne[de]&&ne[de].abort&&(ne[de].abort(),delete ne[de]),ie()}removeTile(j,ie){const ne=this.loaded,de=j.uid;ne&&ne[de]&&delete ne[de],ie()}}class B{constructor(){this.loaded={}}loadTile(j,ie){const{uid:ne,encoding:de,rawImageData:Re}=j,tt=i.isImageBitmap(Re)?this.getImageData(Re):Re,He=new i.DEMData(ne,tt,de);this.loaded=this.loaded||{},this.loaded[ne]=He,ie(null,He)}getImageData(j){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(j.width,j.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=j.width,this.offscreenCanvas.height=j.height,this.offscreenCanvasContext.drawImage(j,0,0,j.width,j.height);const ie=this.offscreenCanvasContext.getImageData(-1,-1,j.width+2,j.height+2);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:ie.width,height:ie.height},ie.data)}removeTile(j){const ie=this.loaded,ne=j.uid;ie&&ie[ne]&&delete ie[ne]}}var ae=function X(j,ie){var ne,de=j&&j.type;if(de==="FeatureCollection")for(ne=0;ne=Math.abs(He)?ie-Je+He:He-Je+ie,ie=Je}ie+ne>=0!=!!j&&X.reverse()}const we=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class me{constructor(j){this._feature=j,this.extent=i.EXTENT,this.type=j.type,this.properties=j.tags,"id"in j&&!isNaN(j.id)&&(this.id=parseInt(j.id,10))}loadGeometry(){if(this._feature.type===1){const j=[];for(const ie of this._feature.geometry)j.push([new i.pointGeometry(ie[0],ie[1])]);return j}{const j=[];for(const ie of this._feature.geometry){const ne=[];for(const de of ie)ne.push(new i.pointGeometry(de[0],de[1]));j.push(ne)}return j}}toGeoJSON(j,ie,ne){return we.call(this,j,ie,ne)}}class Pe{constructor(j){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=j.length,this._features=j}feature(j){return new me(this._features[j])}}var it={exports:{}},Me=i.pointGeometry,Ke=i.vectorTile.VectorTileFeature,Et=oi;function oi(X,j){this.options=j||{},this.features=X,this.length=X.length}function Ci(X,j){this.id=typeof X.id=="number"?X.id:void 0,this.type=X.type,this.rawGeometry=X.type===1?[X.geometry]:X.geometry,this.properties=X.tags,this.extent=j||4096}oi.prototype.feature=function(X){return new Ci(this.features[X],this.options.extent)},Ci.prototype.loadGeometry=function(){var X=this.rawGeometry;this.geometry=[];for(var j=0;j>31}function Le(X,j){for(var ie=X.loadGeometry(),ne=X.type,de=0,Re=0,tt=ie.length,He=0;He>1;et(X,j,tt,ne,de,Re%2),qe(X,j,ie,ne,tt-1,Re+1),qe(X,j,ie,tt+1,de,Re+1)}function et(X,j,ie,ne,de,Re){for(;de>ne;){if(de-ne>600){const pt=de-ne+1,Lt=ie-ne+1,jt=Math.log(pt),Gt=.5*Math.exp(2*jt/3),ki=.5*Math.sqrt(jt*Gt*(pt-Gt)/pt)*(Lt-pt/2<0?-1:1);et(X,j,ie,Math.max(ne,Math.floor(ie-Lt*Gt/pt+ki)),Math.min(de,Math.floor(ie+(pt-Lt)*Gt/pt+ki)),Re)}const tt=j[2*ie+Re];let He=ne,Je=de;for(vt(X,j,ne,ie),j[2*de+Re]>tt&&vt(X,j,ne,de);Hett;)Je--}j[2*ne+Re]===tt?vt(X,j,ne,Je):(Je++,vt(X,j,Je,de)),Je<=ie&&(ne=Je+1),ie<=Je&&(de=Je-1)}}function vt(X,j,ie,ne){Be(X,ie,ne),Be(j,2*ie,2*ne),Be(j,2*ie+1,2*ne+1)}function Be(X,j,ie){const ne=X[j];X[j]=X[ie],X[ie]=ne}function dt(X,j,ie,ne){const de=X-ie,Re=j-ne;return de*de+Re*Re}it.exports=ye,it.exports.fromVectorTileJs=ye,it.exports.fromGeojsonVt=function(X,j){j=j||{};var ie={};for(var ne in X)ie[ne]=new ce(X[ne].features,j),ie[ne].name=ne,ie[ne].version=j.version,ie[ne].extent=j.extent;return ye({layers:ie})},it.exports.GeoJSONWrapper=ce;const ut=X=>X[0],Qt=X=>X[1];class Wt{constructor(j,ie=ut,ne=Qt,de=64,Re=Float64Array){this.nodeSize=de,this.points=j;const tt=j.length<65536?Uint16Array:Uint32Array,He=this.ids=new tt(j.length),Je=this.coords=new Re(2*j.length);for(let pt=0;pt=He&&wi<=pt&&Oi>=Je&&Oi<=Lt&&ki.push(Re[sr]);continue}const yn=Math.floor((rr+tn)/2);wi=tt[2*yn],Oi=tt[2*yn+1],wi>=He&&wi<=pt&&Oi>=Je&&Oi<=Lt&&ki.push(Re[yn]);const Yt=(Yi+1)%2;(Yi===0?He<=wi:Je<=Oi)&&(Gt.push(rr),Gt.push(yn-1),Gt.push(Yt)),(Yi===0?pt>=wi:Lt>=Oi)&&(Gt.push(yn+1),Gt.push(tn),Gt.push(Yt))}return ki}(this.ids,this.coords,j,ie,ne,de,this.nodeSize)}within(j,ie,ne){return function(de,Re,tt,He,Je,pt){const Lt=[0,de.length-1,0],jt=[],Gt=Je*Je;for(;Lt.length;){const ki=Lt.pop(),wi=Lt.pop(),Oi=Lt.pop();if(wi-Oi<=pt){for(let Yt=Oi;Yt<=wi;Yt++)dt(Re[2*Yt],Re[2*Yt+1],tt,He)<=Gt&&jt.push(de[Yt]);continue}const Yi=Math.floor((Oi+wi)/2),tn=Re[2*Yi],rr=Re[2*Yi+1];dt(tn,rr,tt,He)<=Gt&&jt.push(de[Yi]);const yn=(ki+1)%2;(ki===0?tt-Je<=tn:He-Je<=rr)&&(Lt.push(Oi),Lt.push(Yi-1),Lt.push(yn)),(ki===0?tt+Je>=tn:He+Je>=rr)&&(Lt.push(Yi+1),Lt.push(wi),Lt.push(yn))}return jt}(this.ids,this.coords,j,ie,ne,this.nodeSize)}}const Nt={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:X=>X},Ct=Math.fround||(Ft=new Float32Array(1),X=>(Ft[0]=+X,Ft[0]));var Ft;class Xt{constructor(j){this.options=yt(Object.create(Nt),j),this.trees=new Array(this.options.maxZoom+1)}load(j){const{log:ie,minZoom:ne,maxZoom:de,nodeSize:Re}=this.options;ie&&console.time("total time");const tt=`prepare ${j.length} points`;ie&&console.time(tt),this.points=j;let He=[];for(let Je=0;Je=ne;Je--){const pt=+Date.now();He=this._cluster(He,Je),this.trees[Je]=new Wt(He,st,ti,Re,Float32Array),ie&&console.log("z%d: %d clusters in %dms",Je,He.length,+Date.now()-pt)}return ie&&console.timeEnd("total time"),this}getClusters(j,ie){let ne=((j[0]+180)%360+360)%360-180;const de=Math.max(-90,Math.min(90,j[1]));let Re=j[2]===180?180:((j[2]+180)%360+360)%360-180;const tt=Math.max(-90,Math.min(90,j[3]));if(j[2]-j[0]>=360)ne=-180,Re=180;else if(ne>Re){const Lt=this.getClusters([ne,de,180,tt],ie),jt=this.getClusters([-180,de,Re,tt],ie);return Lt.concat(jt)}const He=this.trees[this._limitZoom(ie)],Je=He.range(Qi(ne),Gn(tt),Qi(Re),Gn(de)),pt=[];for(const Lt of Je){const jt=He.points[Lt];pt.push(jt.numPoints?Gi(jt):this.points[jt.index])}return pt}getChildren(j){const ie=this._getOriginId(j),ne=this._getOriginZoom(j),de="No cluster with the specified id.",Re=this.trees[ne];if(!Re)throw new Error(de);const tt=Re.points[ie];if(!tt)throw new Error(de);const He=this.options.radius/(this.options.extent*Math.pow(2,ne-1)),Je=Re.within(tt.x,tt.y,He),pt=[];for(const Lt of Je){const jt=Re.points[Lt];jt.parentId===j&&pt.push(jt.numPoints?Gi(jt):this.points[jt.index])}if(pt.length===0)throw new Error(de);return pt}getLeaves(j,ie,ne){const de=[];return this._appendLeaves(de,j,ie=ie||10,ne=ne||0,0),de}getTile(j,ie,ne){const de=this.trees[this._limitZoom(j)],Re=Math.pow(2,j),{extent:tt,radius:He}=this.options,Je=He/tt,pt=(ne-Je)/Re,Lt=(ne+1+Je)/Re,jt={features:[]};return this._addTileFeatures(de.range((ie-Je)/Re,pt,(ie+1+Je)/Re,Lt),de.points,ie,ne,Re,jt),ie===0&&this._addTileFeatures(de.range(1-Je/Re,pt,1,Lt),de.points,Re,ne,Re,jt),ie===Re-1&&this._addTileFeatures(de.range(0,pt,Je/Re,Lt),de.points,-1,ne,Re,jt),jt.features.length?jt:null}getClusterExpansionZoom(j){let ie=this._getOriginZoom(j)-1;for(;ie<=this.options.maxZoom;){const ne=this.getChildren(j);if(ie++,ne.length!==1)break;j=ne[0].properties.cluster_id}return ie}_appendLeaves(j,ie,ne,de,Re){const tt=this.getChildren(ie);for(const He of tt){const Je=He.properties;if(Je&&Je.cluster?Re+Je.point_count<=de?Re+=Je.point_count:Re=this._appendLeaves(j,Je.cluster_id,ne,de,Re):Reie&&(wi+=Yi.numPoints||1)}if(wi>ki&&wi>=He){let Oi=Lt.x*ki,Yi=Lt.y*ki,tn=tt&&ki>1?this._map(Lt,!0):null;const rr=(pt<<5)+(ie+1)+this.points.length;for(const yn of Gt){const Yt=jt.points[yn];if(Yt.zoom<=ie)continue;Yt.zoom=ie;const sr=Yt.numPoints||1;Oi+=Yt.x*sr,Yi+=Yt.y*sr,Yt.parentId=rr,tt&&(tn||(tn=this._map(Lt,!0)),tt(tn,this._map(Yt)))}Lt.parentId=rr,ne.push(mi(Oi/wi,Yi/wi,rr,wi,tn))}else if(ne.push(Lt),wi>1)for(const Oi of Gt){const Yi=jt.points[Oi];Yi.zoom<=ie||(Yi.zoom=ie,ne.push(Yi))}}return ne}_getOriginId(j){return j-this.points.length>>5}_getOriginZoom(j){return(j-this.points.length)%32}_map(j,ie){if(j.numPoints)return ie?yt({},j.properties):j.properties;const ne=this.points[j.index].properties,de=this.options.map(ne);return ie&&de===ne?yt({},de):de}}function mi(X,j,ie,ne,de){return{x:Ct(X),y:Ct(j),zoom:1/0,id:ie,parentId:-1,numPoints:ne,properties:de}}function fi(X,j){const[ie,ne]=X.geometry.coordinates;return{x:Ct(Qi(ie)),y:Ct(Gn(ne)),zoom:1/0,index:j,parentId:-1}}function Gi(X){return{type:"Feature",id:X.id,properties:wn(X),geometry:{type:"Point",coordinates:[(j=X.x,360*(j-.5)),kn(X.y)]}};var j}function wn(X){const j=X.numPoints,ie=j>=1e4?`${Math.round(j/1e3)}k`:j>=1e3?Math.round(j/100)/10+"k":j;return yt(yt({},X.properties),{cluster:!0,cluster_id:X.id,point_count:j,point_count_abbreviated:ie})}function Qi(X){return X/360+.5}function Gn(X){const j=Math.sin(X*Math.PI/180),ie=.5-.25*Math.log((1+j)/(1-j))/Math.PI;return ie<0?0:ie>1?1:ie}function kn(X){const j=(180-360*X)*Math.PI/180;return 360*Math.atan(Math.exp(j))/Math.PI-90}function yt(X,j){for(const ie in j)X[ie]=j[ie];return X}function st(X){return X.x}function ti(X){return X.y}function Ni(X,j,ie,ne){for(var de,Re=ne,tt=ie-j>>1,He=ie-j,Je=X[j],pt=X[j+1],Lt=X[ie],jt=X[ie+1],Gt=j+3;GtRe)de=Gt,Re=ki;else if(ki===Re){var wi=Math.abs(Gt-tt);wine&&(de-j>3&&Ni(X,j,de,ne),X[de+2]=Re,ie-de>3&&Ni(X,de,ie,ne))}function qi(X,j,ie,ne,de,Re){var tt=de-ie,He=Re-ne;if(tt!==0||He!==0){var Je=((X-ie)*tt+(j-ne)*He)/(tt*tt+He*He);Je>1?(ie=de,ne=Re):Je>0&&(ie+=tt*Je,ne+=He*Je)}return(tt=X-ie)*tt+(He=j-ne)*He}function en(X,j,ie,ne){var de={id:X===void 0?null:X,type:j,geometry:ie,tags:ne,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(Re){var tt=Re.geometry,He=Re.type;if(He==="Point"||He==="MultiPoint"||He==="LineString")$t(Re,tt);else if(He==="Polygon"||He==="MultiLineString")for(var Je=0;Je0&&(tt+=ne?(de*pt-Je*Re)/2:Math.sqrt(Math.pow(Je-de,2)+Math.pow(pt-Re,2))),de=Je,Re=pt}var Lt=j.length-3;j[2]=1,Ni(j,0,Lt,ie),j[Lt+2]=1,j.size=Math.abs(tt),j.start=0,j.end=j.size}function Xi(X,j,ie,ne){for(var de=0;de1?1:ie}function Tn(X,j,ie,ne,de,Re,tt,He){if(ne/=j,Re>=(ie/=j)&&tt=ne)return null;for(var Je=[],pt=0;pt=ie&&wi=ne)){var Oi=[];if(Gt==="Point"||Gt==="MultiPoint")nr(jt,Oi,ie,ne,de);else if(Gt==="LineString")Ii(jt,Oi,ie,ne,de,!1,He.lineMetrics);else if(Gt==="MultiLineString")Ot(jt,Oi,ie,ne,de,!1);else if(Gt==="Polygon")Ot(jt,Oi,ie,ne,de,!0);else if(Gt==="MultiPolygon")for(var Yi=0;Yi=ie&&tt<=ne&&(j.push(X[Re]),j.push(X[Re+1]),j.push(X[Re+2]))}}function Ii(X,j,ie,ne,de,Re,tt){for(var He,Je,pt=bn(X),Lt=de===0?Wi:Ui,jt=X.start,Gt=0;Gtie&&(Je=Lt(pt,ki,wi,Yi,tn,ie),tt&&(pt.start=jt+He*Je)):rr>ne?yn=ie&&(Je=Lt(pt,ki,wi,Yi,tn,ie),Yt=!0),yn>ne&&rr<=ne&&(Je=Lt(pt,ki,wi,Yi,tn,ne),Yt=!0),!Re&&Yt&&(tt&&(pt.end=jt+He*Je),j.push(pt),pt=bn(X)),tt&&(jt+=He)}var sr=X.length-3;ki=X[sr],wi=X[sr+1],Oi=X[sr+2],(rr=de===0?ki:wi)>=ie&&rr<=ne&&vi(pt,ki,wi,Oi),sr=pt.length-3,Re&&sr>=3&&(pt[sr]!==pt[0]||pt[sr+1]!==pt[1])&&vi(pt,pt[0],pt[1],pt[2]),pt.length&&j.push(pt)}function bn(X){var j=[];return j.size=X.size,j.start=X.start,j.end=X.end,j}function Ot(X,j,ie,ne,de,Re){for(var tt=0;tttt.maxX&&(tt.maxX=Lt),jt>tt.maxY&&(tt.maxY=jt)}return tt}function Qn(X,j,ie,ne){var de=j.geometry,Re=j.type,tt=[];if(Re==="Point"||Re==="MultiPoint")for(var He=0;He0&&j.size<(de?tt:ne))ie.numPoints+=j.length/3;else{for(var He=[],Je=0;Jett)&&(ie.numSimplified++,He.push(j[Je]),He.push(j[Je+1])),ie.numPoints++;de&&function(pt,Lt){for(var jt=0,Gt=0,ki=pt.length,wi=ki-2;Gt0===Lt)for(Gt=0,ki=pt.length;Gt24)throw new Error("maxZoom should be in the 0-24 range");if(j.promoteId&&j.generateId)throw new Error("promoteId and generateId cannot be used together.");var ne=function(de,Re){var tt=[];if(de.type==="FeatureCollection")for(var He=0;He1&&console.time("creation"),Gt=this.tiles[jt]=kr(X,j,ie,ne,Je),this.tileCoords.push({z:j,x:ie,y:ne}),pt)){pt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",j,ie,ne,Gt.numFeatures,Gt.numPoints,Gt.numSimplified),console.timeEnd("creation"));var ki="z"+j;this.stats[ki]=(this.stats[ki]||0)+1,this.total++}if(Gt.source=X,de){if(j===Je.maxZoom||j===de)continue;var wi=1<1&&console.time("clipping");var Oi,Yi,tn,rr,yn,Yt,sr=.5*Je.buffer/Je.extent,Yn=.5-sr,Wr=.5+sr,mr=1+sr;Oi=Yi=tn=rr=null,yn=Tn(X,Lt,ie-sr,ie+Wr,0,Gt.minX,Gt.maxX,Je),Yt=Tn(X,Lt,ie+Yn,ie+mr,0,Gt.minX,Gt.maxX,Je),X=null,yn&&(Oi=Tn(yn,Lt,ne-sr,ne+Wr,1,Gt.minY,Gt.maxY,Je),Yi=Tn(yn,Lt,ne+Yn,ne+mr,1,Gt.minY,Gt.maxY,Je),yn=null),Yt&&(tn=Tn(Yt,Lt,ne-sr,ne+Wr,1,Gt.minY,Gt.maxY,Je),rr=Tn(Yt,Lt,ne+Yn,ne+mr,1,Gt.minY,Gt.maxY,Je),Yt=null),pt>1&&console.timeEnd("clipping"),He.push(Oi||[],j+1,2*ie,2*ne),He.push(Yi||[],j+1,2*ie,2*ne+1),He.push(tn||[],j+1,2*ie+1,2*ne),He.push(rr||[],j+1,2*ie+1,2*ne+1)}}},ot.prototype.getTile=function(X,j,ie){var ne=this.options,de=ne.extent,Re=ne.debug;if(X<0||X>24)return null;var tt=1<1&&console.log("drilling down to z%d-%d-%d",X,j,ie);for(var Je,pt=X,Lt=j,jt=ie;!Je&&pt>0;)pt--,Lt=Math.floor(Lt/2),jt=Math.floor(jt/2),Je=this.tiles[Ee(pt,Lt,jt)];return Je&&Je.source?(Re>1&&console.log("found parent tile z%d-%d-%d",pt,Lt,jt),Re>1&&console.time("drilling down"),this.splitTile(Je.source,pt,Lt,jt,X,j,ie),Re>1&&console.timeEnd("drilling down"),this.tiles[He]?Hr(this.tiles[He],de):null):null};class ct extends Y{constructor(j,ie,ne,de){super(j,ie,ne,Ue),de&&(this.loadGeoJSON=de)}loadData(j,ie){var ne;(ne=this._pendingRequest)===null||ne===void 0||ne.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const de=!!(j&&j.request&&j.request.collectResourceTiming)&&new i.RequestPerformance(j.request);this._pendingCallback=ie,this._pendingRequest=this.loadGeoJSON(j,(Re,tt)=>{if(delete this._pendingCallback,delete this._pendingRequest,Re||!tt)return ie(Re);if(typeof tt!="object")return ie(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`));{ae(tt,!0);try{if(j.filter){const Je=i.createExpression(j.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Je.result==="error")throw new Error(Je.value.map(Lt=>`${Lt.key}: ${Lt.message}`).join(", "));tt={type:"FeatureCollection",features:tt.features.filter(Lt=>Je.value.evaluate({zoom:0},Lt))}}this._geoJSONIndex=j.cluster?new Xt(function({superclusterOptions:Je,clusterProperties:pt}){if(!pt||!Je)return Je;const Lt={},jt={},Gt={accumulated:null,zoom:0},ki={properties:null},wi=Object.keys(pt);for(const Oi of wi){const[Yi,tn]=pt[Oi],rr=i.createExpression(tn),yn=i.createExpression(typeof Yi=="string"?[Yi,["accumulated"],["get",Oi]]:Yi);Lt[Oi]=rr.value,jt[Oi]=yn.value}return Je.map=Oi=>{ki.properties=Oi;const Yi={};for(const tn of wi)Yi[tn]=Lt[tn].evaluate(Gt,ki);return Yi},Je.reduce=(Oi,Yi)=>{ki.properties=Yi;for(const tn of wi)Gt.accumulated=Oi[tn],Oi[tn]=jt[tn].evaluate(Gt,ki)},Je}(j)).load(tt.features):function(Je,pt){return new ot(Je,pt)}(tt,j.geojsonVtOptions)}catch(Je){return ie(Je)}this.loaded={};const He={};if(de){const Je=de.finish();Je&&(He.resourceTiming={},He.resourceTiming[j.source]=JSON.parse(JSON.stringify(Je)))}ie(null,He)}})}reloadTile(j,ie){const ne=this.loaded;return ne&&ne[j.uid]?super.reloadTile(j,ie):this.loadTile(j,ie)}loadGeoJSON(j,ie){if(j.request)return i.getJSON(j.request,ie);if(typeof j.data=="string")try{ie(null,JSON.parse(j.data))}catch{ie(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`))}else ie(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}}removeSource(j,ie){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),ie()}getClusterExpansionZoom(j,ie){try{ie(null,this._geoJSONIndex.getClusterExpansionZoom(j.clusterId))}catch(ne){ie(ne)}}getClusterChildren(j,ie){try{ie(null,this._geoJSONIndex.getChildren(j.clusterId))}catch(ne){ie(ne)}}getClusterLeaves(j,ie){try{ie(null,this._geoJSONIndex.getLeaves(j.clusterId,j.limit,j.offset))}catch(ne){ie(ne)}}}class wt{constructor(j){this.self=j,this.actor=new i.Actor(j,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:Y,geojson:ct},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(ie,ne)=>{if(this.workerSourceTypes[ie])throw new Error(`Worker source with name "${ie}" already registered.`);this.workerSourceTypes[ie]=ne},this.self.registerRTLTextPlugin=ie=>{if(i.plugin.isParsed())throw new Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=ie.applyArabicShaping,i.plugin.processBidirectionalText=ie.processBidirectionalText,i.plugin.processStyledBidirectionalText=ie.processStyledBidirectionalText}}setReferrer(j,ie){this.referrer=ie}setImages(j,ie,ne){this.availableImages[j]=ie;for(const de in this.workerSources[j]){const Re=this.workerSources[j][de];for(const tt in Re)Re[tt].availableImages=ie}ne()}setLayers(j,ie,ne){this.getLayerIndex(j).replace(ie),ne()}updateLayers(j,ie,ne){this.getLayerIndex(j).update(ie.layers,ie.removedIds),ne()}loadTile(j,ie,ne){this.getWorkerSource(j,ie.type,ie.source).loadTile(ie,ne)}loadDEMTile(j,ie,ne){this.getDEMWorkerSource(j,ie.source).loadTile(ie,ne)}reloadTile(j,ie,ne){this.getWorkerSource(j,ie.type,ie.source).reloadTile(ie,ne)}abortTile(j,ie,ne){this.getWorkerSource(j,ie.type,ie.source).abortTile(ie,ne)}removeTile(j,ie,ne){this.getWorkerSource(j,ie.type,ie.source).removeTile(ie,ne)}removeDEMTile(j,ie){this.getDEMWorkerSource(j,ie.source).removeTile(ie)}removeSource(j,ie,ne){if(!this.workerSources[j]||!this.workerSources[j][ie.type]||!this.workerSources[j][ie.type][ie.source])return;const de=this.workerSources[j][ie.type][ie.source];delete this.workerSources[j][ie.type][ie.source],de.removeSource!==void 0?de.removeSource(ie,ne):ne()}loadWorkerSource(j,ie,ne){try{this.self.importScripts(ie.url),ne()}catch(de){ne(de.toString())}}syncRTLPluginState(j,ie,ne){try{i.plugin.setState(ie);const de=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&de!=null){this.self.importScripts(de);const Re=i.plugin.isParsed();ne(Re?void 0:new Error(`RTL Text Plugin failed to import scripts from ${de}`),Re)}}catch(de){ne(de.toString())}}getAvailableImages(j){let ie=this.availableImages[j];return ie||(ie=[]),ie}getLayerIndex(j){let ie=this.layerIndexes[j];return ie||(ie=this.layerIndexes[j]=new U),ie}getWorkerSource(j,ie,ne){if(this.workerSources[j]||(this.workerSources[j]={}),this.workerSources[j][ie]||(this.workerSources[j][ie]={}),!this.workerSources[j][ie][ne]){const de={send:(Re,tt,He)=>{this.actor.send(Re,tt,He,j)}};this.workerSources[j][ie][ne]=new this.workerSourceTypes[ie](de,this.getLayerIndex(j),this.getAvailableImages(j))}return this.workerSources[j][ie][ne]}getDEMWorkerSource(j,ie){return this.demWorkerSources[j]||(this.demWorkerSources[j]={}),this.demWorkerSources[j][ie]||(this.demWorkerSources[j][ie]=new B),this.demWorkerSources[j][ie]}enforceCacheSizeLimit(j,ie){i.enforceCacheSizeLimit(ie)}}return i.isWorker()&&(self.worker=new wt(self)),wt}),p(["./shared"],function(i){var C=D;function D(M){return!function(h){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 T,F,O=new Blob([""],{type:"text/javascript"}),K=URL.createObjectURL(O);try{F=new Worker(K),T=!0}catch{T=!1}return F&&F.terminate(),URL.revokeObjectURL(K),T}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var T=document.createElement("canvas");T.width=T.height=1;var F=T.getContext("2d");if(!F)return!1;var O=F.getImageData(0,0,1,1);return O&&O.width===T.width}()?(U[_=h&&h.failIfMajorPerformanceCaveat]===void 0&&(U[_]=function(T){var F,O=function(K){var oe=document.createElement("canvas"),ue=Object.create(D.webGLContextAttributes);return ue.failIfMajorPerformanceCaveat=K,oe.getContext("webgl",ue)||oe.getContext("experimental-webgl",ue)}(T);if(!O)return!1;try{F=O.createShader(O.VERTEX_SHADER)}catch{return!1}return!(!F||O.isContextLost())&&(O.shaderSource(F,"void main() {}"),O.compileShader(F),O.getShaderParameter(F,O.COMPILE_STATUS)===!0)}(_)),U[_]?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 _}(M)}var U={};function N(M,h){if(Array.isArray(M)){if(!Array.isArray(h)||M.length!==h.length)return!1;for(let _=0;_{window.removeEventListener("click",R.suppressClickInternal,!0)},0)}static mousePos(h,_){const T=h.getBoundingClientRect();return new i.pointGeometry(_.clientX-T.left-h.clientLeft,_.clientY-T.top-h.clientTop)}static touchPos(h,_){const T=h.getBoundingClientRect(),F=[];for(let O=0;O<_.length;O++)F.push(new i.pointGeometry(_[O].clientX-T.left-h.clientLeft,_[O].clientY-T.top-h.clientTop));return F}static mouseButton(h){return h.button}static remove(h){h.parentNode&&h.parentNode.removeChild(h)}}R.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,R.selectProp=R.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),R.transformProp=R.testProp(["transform","WebkitTransform"]);class G{constructor(h){this._transformRequestFn=h}transformRequest(h,_){return this._transformRequestFn&&this._transformRequestFn(h,_)||{url:h}}normalizeSpriteURL(h,_,T){const F=function(O){const K=O.match(J);if(!K)throw new Error(`Unable to parse URL "${O}"`);return{protocol:K[1],authority:K[2],path:K[3]||"/",params:K[4]?K[4].split("&"):[]}}(h);return F.path+=`${_}${T}`,function(O){const K=O.params.length?`?${O.params.join("&")}`:"";return`${O.protocol}://${O.authority}${O.path}${K}`}(F)}setTransformRequest(h){this._transformRequestFn=h}}const J=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;class Y{constructor(h,_,T,F){this.context=h,this.format=T,this.texture=h.gl.createTexture(),this.update(_,F)}update(h,_,T){const{width:F,height:O}=h,K=!(this.size&&this.size[0]===F&&this.size[1]===O||T),{context:oe}=this,{gl:ue}=oe;if(this.useMipmap=Boolean(_&&_.useMipmap),ue.bindTexture(ue.TEXTURE_2D,this.texture),oe.pixelStoreUnpackFlipY.set(!1),oe.pixelStoreUnpack.set(1),oe.pixelStoreUnpackPremultiplyAlpha.set(this.format===ue.RGBA&&(!_||_.premultiply!==!1)),K)this.size=[F,O],h instanceof HTMLImageElement||h instanceof HTMLCanvasElement||h instanceof HTMLVideoElement||h instanceof ImageData||i.isImageBitmap(h)?ue.texImage2D(ue.TEXTURE_2D,0,this.format,this.format,ue.UNSIGNED_BYTE,h):ue.texImage2D(ue.TEXTURE_2D,0,this.format,F,O,0,this.format,ue.UNSIGNED_BYTE,h.data);else{const{x:ve,y:Te}=T||{x:0,y:0};h instanceof HTMLImageElement||h instanceof HTMLCanvasElement||h instanceof HTMLVideoElement||h instanceof ImageData||i.isImageBitmap(h)?ue.texSubImage2D(ue.TEXTURE_2D,0,ve,Te,ue.RGBA,ue.UNSIGNED_BYTE,h):ue.texSubImage2D(ue.TEXTURE_2D,0,ve,Te,F,O,ue.RGBA,ue.UNSIGNED_BYTE,h.data)}this.useMipmap&&this.isSizePowerOfTwo()&&ue.generateMipmap(ue.TEXTURE_2D)}bind(h,_,T){const{context:F}=this,{gl:O}=F;O.bindTexture(O.TEXTURE_2D,this.texture),T!==O.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(T=O.LINEAR),h!==this.filter&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MAG_FILTER,h),O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,T||h),this.filter=h),_!==this.wrap&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,_),O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,_),this.wrap=_)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:h}=this.context;h.deleteTexture(this.texture),this.texture=null}}function B(M){const{userImage:h}=M;return!!(h&&h.render&&h.render())&&(M.data.replace(new Uint8Array(h.data.buffer)),!0)}class ae extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(h){if(this.loaded!==h&&(this.loaded=h,h)){for(const{ids:_,callback:T}of this.requestors)this._notify(_,T);this.requestors=[]}}getImage(h){return this.images[h]}addImage(h,_){if(this.images[h])throw new Error(`Image id ${h} already exist, use updateImage instead`);this._validate(h,_)&&(this.images[h]=_)}_validate(h,_){let T=!0;return this._validateStretch(_.stretchX,_.data&&_.data.width)||(this.fire(new i.ErrorEvent(new Error(`Image "${h}" has invalid "stretchX" value`))),T=!1),this._validateStretch(_.stretchY,_.data&&_.data.height)||(this.fire(new i.ErrorEvent(new Error(`Image "${h}" has invalid "stretchY" value`))),T=!1),this._validateContent(_.content,_)||(this.fire(new i.ErrorEvent(new Error(`Image "${h}" has invalid "content" value`))),T=!1),T}_validateStretch(h,_){if(!h)return!0;let T=0;for(const F of h){if(F[0]-1);ue++,O[ue]=oe,K[ue]=ve,K[ue+1]=le}for(let oe=0,ue=0;oe{let oe=this.entries[F];oe||(oe=this.entries[F]={glyphs:{},requests:{},ranges:{}});let ue=oe.glyphs[O];if(ue!==void 0)return void K(null,{stack:F,id:O,glyph:ue});if(ue=this._tinySDF(oe,F,O),ue)return oe.glyphs[O]=ue,void K(null,{stack:F,id:O,glyph:ue});const ve=Math.floor(O/256);if(256*ve>65535)return void K(new Error("glyphs > 65535 not supported"));if(oe.ranges[ve])return void K(null,{stack:F,id:O,glyph:ue});let Te=oe.requests[ve];Te||(Te=oe.requests[ve]=[],me.loadGlyphRange(F,ve,this.url,this.requestManager,(ke,We)=>{if(We){for(const bt in We)this._doesCharSupportLocalGlyph(+bt)||(oe.glyphs[+bt]=We[+bt]);oe.ranges[ve]=!0}for(const bt of Te)bt(ke,We);delete oe.requests[ve]})),Te.push((ke,We)=>{ke?K(ke):We&&K(null,{stack:F,id:O,glyph:We[O]||null})})},(F,O)=>{if(F)_(F);else if(O){const K={};for(const{stack:oe,id:ue,glyph:ve}of O)(K[oe]||(K[oe]={}))[ue]=ve&&{id:ve.id,bitmap:ve.bitmap.clone(),metrics:ve.metrics};_(null,K)}})}_doesCharSupportLocalGlyph(h){return!!this.localIdeographFontFamily&&(i.unicodeBlockLookup["CJK Unified Ideographs"](h)||i.unicodeBlockLookup["Hangul Syllables"](h)||i.unicodeBlockLookup.Hiragana(h)||i.unicodeBlockLookup.Katakana(h))}_tinySDF(h,_,T){const F=this.localIdeographFontFamily;if(!F||!this._doesCharSupportLocalGlyph(T))return;let O=h.tinySDF;if(!O){let oe="400";/bold/i.test(_)?oe="900":/medium/i.test(_)?oe="500":/light/i.test(_)&&(oe="200"),O=h.tinySDF=new me.TinySDF({fontSize:24,buffer:3,radius:8,cutoff:.25,fontFamily:F,fontWeight:oe})}const K=O.draw(String.fromCharCode(T));return{id:T,bitmap:new i.AlphaImage({width:K.width||30,height:K.height||30},K.data),metrics:{width:K.glyphWidth||24,height:K.glyphHeight||24,left:K.glyphLeft||0,top:K.glyphTop-27||-8,advance:K.glyphAdvance||24}}}}me.loadGlyphRange=function(M,h,_,T,F){const O=256*h,K=O+255,oe=T.transformRequest(_.replace("{fontstack}",M).replace("{range}",`${O}-${K}`),i.ResourceType.Glyphs);i.getArrayBuffer(oe,(ue,ve)=>{if(ue)F(ue);else if(ve){const Te={};for(const ke of i.parseGlyphPbf(ve))Te[ke.id]=ke;F(null,Te)}})},me.TinySDF=class{constructor({fontSize:M=24,buffer:h=3,radius:_=8,cutoff:T=.25,fontFamily:F="sans-serif",fontWeight:O="normal",fontStyle:K="normal"}={}){this.buffer=h,this.cutoff=T,this.radius=_;const oe=this.size=M+4*h,ue=this._createCanvas(oe),ve=this.ctx=ue.getContext("2d",{willReadFrequently:!0});ve.font=`${K} ${O} ${M}px ${F}`,ve.textBaseline="alphabetic",ve.textAlign="left",ve.fillStyle="black",this.gridOuter=new Float64Array(oe*oe),this.gridInner=new Float64Array(oe*oe),this.f=new Float64Array(oe),this.z=new Float64Array(oe+1),this.v=new Uint16Array(oe)}_createCanvas(M){const h=document.createElement("canvas");return h.width=h.height=M,h}draw(M){const{width:h,actualBoundingBoxAscent:_,actualBoundingBoxDescent:T,actualBoundingBoxLeft:F,actualBoundingBoxRight:O}=this.ctx.measureText(M),K=Math.ceil(_),oe=Math.min(this.size-this.buffer,Math.ceil(O-F)),ue=Math.min(this.size-this.buffer,K+Math.ceil(T)),ve=oe+2*this.buffer,Te=ue+2*this.buffer,ke=Math.max(ve*Te,0),We=new Uint8ClampedArray(ke),bt={data:We,width:ve,height:Te,glyphWidth:oe,glyphHeight:ue,glyphTop:K,glyphLeft:0,glyphAdvance:h};if(oe===0||ue===0)return bt;const{ctx:mt,buffer:gt,gridInner:Vt,gridOuter:Zt}=this;mt.clearRect(gt,gt,oe,ue),mt.fillText(M,gt,gt+K);const ni=mt.getImageData(gt,gt,oe,ue);Zt.fill(le,0,ke),Vt.fill(0,0,ke);for(let St=0;St0?bi*bi:0,Vt[Ei]=bi<0?bi*bi:0}}Ae(Zt,0,0,ve,Te,ve,this.f,this.v,this.z),Ae(Vt,gt,gt,oe,ue,ve,this.f,this.v,this.z);for(let St=0;St1&&(ue=h[++oe]);const Te=Math.abs(ve-ue.left),ke=Math.abs(ve-ue.right),We=Math.min(Te,ke);let bt;const mt=O/T*(F+1);if(ue.isDash){const gt=F-Math.abs(mt);bt=Math.sqrt(We*We+gt*gt)}else bt=F-Math.sqrt(We*We+mt*mt);this.data[K+ve]=Math.max(0,Math.min(255,bt+128))}}}addRegularDash(h){for(let oe=h.length-1;oe>=0;--oe){const ue=h[oe],ve=h[oe+1];ue.zeroLength?h.splice(oe,1):ve&&ve.isDash===ue.isDash&&(ve.left=ue.left,h.splice(oe,1))}const _=h[0],T=h[h.length-1];_.isDash===T.isDash&&(_.left=T.left-this.width,T.right=_.right+this.width);const F=this.width*this.nextRow;let O=0,K=h[O];for(let oe=0;oe1&&(K=h[++O]);const ue=Math.abs(oe-K.left),ve=Math.abs(oe-K.right),Te=Math.min(ue,ve);this.data[F+oe]=Math.max(0,Math.min(255,(K.isDash?Te:-Te)+128))}}addDash(h,_){const T=_?7:0,F=2*T+1;if(this.nextRow+F>this.height)return i.warnOnce("LineAtlas out of space"),null;let O=0;for(let oe=0;oe{F.send(h,_,O)},T=T||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(h=>{h.remove()}),this.actors=[],this.workerPool.release(this.id)}}function oi(M,h,_){const T=function(F,O){if(F)return _(F);if(O){const K=i.pick(i.extend(O,M),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);O.vector_layers&&(K.vectorLayers=O.vector_layers,K.vectorLayerIds=K.vectorLayers.map(oe=>oe.id)),_(null,K)}};return M.url?i.getJSON(h.transformRequest(M.url,i.ResourceType.Source),T):i.exported.frame(()=>T(null,M))}Et.Actor=i.Actor;class Ci{constructor(h,_,T){this.bounds=i.LngLatBounds.convert(this.validateBounds(h)),this.minzoom=_||0,this.maxzoom=T||24}validateBounds(h){return Array.isArray(h)&&h.length===4?[Math.max(-180,h[0]),Math.max(-90,h[1]),Math.min(180,h[2]),Math.min(90,h[3])]:[-180,-90,180,90]}contains(h){const _=Math.pow(2,h.z),T=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*_),F=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*_),O=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*_),K=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*_);return h.x>=T&&h.x=F&&h.y{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),h?this.fire(new i.ErrorEvent(h)):_&&(i.extend(this,_),_.bounds&&(this.tileBounds=new Ci(_.bounds,this.minzoom,this.maxzoom)),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}onAdd(h){this.map=h,this.load()}setSourceProperty(h){this._tileJSONRequest&&this._tileJSONRequest.cancel(),h(),this.load()}setTiles(h){return this.setSourceProperty(()=>{this._options.tiles=h}),this}setUrl(h){return this.setSourceProperty(()=>{this.url=h,this._options.url=h}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(h,_){const T=h.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),F={request:this.map._requestManager.transformRequest(T,i.ResourceType.Tile),uid:h.uid,tileID:h.tileID,zoom:h.tileID.overscaledZ,tileSize:this.tileSize*h.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function O(K,oe){return delete h.request,h.aborted?_(null):K&&K.status!==404?_(K):(oe&&oe.resourceTiming&&(h.resourceTiming=oe.resourceTiming),this.map._refreshExpiredTiles&&oe&&h.setExpiryData(oe),h.loadVectorData(oe,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),_(null),void(h.reloadCallback&&(this.loadTile(h,h.reloadCallback),h.reloadCallback=null)))}F.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired"?h.state==="loading"?h.reloadCallback=_:h.request=h.actor.send("reloadTile",F,O.bind(this)):(h.actor=this.dispatcher.getActor(),h.request=h.actor.send("loadTile",F,O.bind(this)))}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id},void 0)}unloadTile(h){h.unloadVectorData(),h.actor&&h.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class ce extends i.Evented{constructor(h,_,T,F){super(),this.id=h,this.dispatcher=T,this.setEventedParent(F),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=i.extend({type:"raster"},_),i.extend(this,i.pick(_,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=oi(this._options,this.map._requestManager,(h,_)=>{this._tileJSONRequest=null,this._loaded=!0,h?this.fire(new i.ErrorEvent(h)):_&&(i.extend(this,_),_.bounds&&(this.tileBounds=new Ci(_.bounds,this.minzoom,this.maxzoom)),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(h){this.map=h,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}loadTile(h,_){const T=h.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);h.request=i.getImage(this.map._requestManager.transformRequest(T,i.ResourceType.Tile),(F,O,K)=>{if(delete h.request,h.aborted)h.state="unloaded",_(null);else if(F)h.state="errored",_(F);else if(O){this.map._refreshExpiredTiles&&h.setExpiryData(K);const oe=this.map.painter.context,ue=oe.gl;h.texture=this.map.painter.getTileTexture(O.width),h.texture?h.texture.update(O,{useMipmap:!0}):(h.texture=new Y(oe,O,ue.RGBA,{useMipmap:!0}),h.texture.bind(ue.LINEAR,ue.CLAMP_TO_EDGE,ue.LINEAR_MIPMAP_NEAREST),oe.extTextureFilterAnisotropic&&ue.texParameterf(ue.TEXTURE_2D,oe.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,oe.extTextureFilterAnisotropicMax)),h.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),_(null)}})}abortTile(h,_){h.request&&(h.request.cancel(),delete h.request),_()}unloadTile(h,_){h.texture&&this.map.painter.saveTileTexture(h.texture),_()}hasTransition(){return!1}}let ye;class xe extends ce{constructor(h,_,T,F){super(h,_,T,F),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},_),this.encoding=_.encoding||"mapbox"}serialize(){return{type:"raster-dem",url:this.url,tileSize:this.tileSize,tiles:this.tiles,bounds:this.bounds,encoding:this.encoding}}loadTile(h,_){const T=h.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);function F(O,K){O&&(h.state="errored",_(O)),K&&(h.dem=K,h.needsHillshadePrepare=!0,h.needsTerrainPrepare=!0,h.state="loaded",_(null))}h.request=i.getImage(this.map._requestManager.transformRequest(T,i.ResourceType.Tile),function(O,K){if(delete h.request,h.aborted)h.state="unloaded",_(null);else if(O)h.state="errored",_(O);else if(K){this.map._refreshExpiredTiles&&h.setExpiryData(K),delete K.cacheControl,delete K.expires;const oe=i.isImageBitmap(K)&&(ye==null&&(ye=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),ye)?K:i.exported.getImageData(K,1),ue={uid:h.uid,coord:h.tileID,source:this.id,rawImageData:oe,encoding:this.encoding};h.actor&&h.state!=="expired"||(h.actor=this.dispatcher.getActor(),h.actor.send("loadDEMTile",ue,F.bind(this)))}}.bind(this)),h.neighboringTiles=this._getNeighboringTiles(h.tileID)}_getNeighboringTiles(h){const _=h.canonical,T=Math.pow(2,_.z),F=(_.x-1+T)%T,O=_.x===0?h.wrap-1:h.wrap,K=(_.x+1+T)%T,oe=_.x+1===T?h.wrap+1:h.wrap,ue={};return ue[new i.OverscaledTileID(h.overscaledZ,O,_.z,F,_.y).key]={backfilled:!1},ue[new i.OverscaledTileID(h.overscaledZ,oe,_.z,K,_.y).key]={backfilled:!1},_.y>0&&(ue[new i.OverscaledTileID(h.overscaledZ,O,_.z,F,_.y-1).key]={backfilled:!1},ue[new i.OverscaledTileID(h.overscaledZ,h.wrap,_.z,_.x,_.y-1).key]={backfilled:!1},ue[new i.OverscaledTileID(h.overscaledZ,oe,_.z,K,_.y-1).key]={backfilled:!1}),_.y+1{if(this._pendingLoads--,this._removed||O&&O.abandoned)return void this.fire(new i.Event("dataabort",{dataType:"source",sourceDataType:h}));let K=null;if(O&&O.resourceTiming&&O.resourceTiming[this.id]&&(K=O.resourceTiming[this.id].slice(0)),F)return void this.fire(new i.ErrorEvent(F));const oe={dataType:"source",sourceDataType:h};this._collectResourceTiming&&K&&K.length>0&&i.extend(oe,{resourceTiming:K}),this.fire(new i.Event("data",oe))})}loaded(){return this._pendingLoads===0}loadTile(h,_){const T=h.actor?"reloadTile":"loadTile";h.actor=this.actor;const F={type:this.type,uid:h.uid,tileID:h.tileID,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};h.request=this.actor.send(T,F,(O,K)=>(delete h.request,h.unloadVectorData(),h.aborted?_(null):O?_(O):(h.loadVectorData(K,this.map.painter,T==="reloadTile"),_(null))))}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.aborted=!0}unloadTile(h){h.unloadVectorData(),this.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var Ne=i.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Ge extends i.Evented{constructor(h,_,T,F){super(),this.id=h,this.dispatcher=T,this.coordinates=_.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(F),this.options=_}load(h,_){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(T,F)=>{this._loaded=!0,T?this.fire(new i.ErrorEvent(T)):F&&(this.image=F,h&&(this.coordinates=h),_&&_(),this._finishLoading())})}loaded(){return this._loaded}updateImage(h){return this.image&&h.url?(this.options.url=h.url,this.load(h.coordinates,()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(h){this.map=h,this.load()}setCoordinates(h){this.coordinates=h;const _=h.map(i.MercatorCoordinate.fromLngLat);this.tileID=function(F){let O=1/0,K=1/0,oe=-1/0,ue=-1/0;for(const We of F)O=Math.min(O,We.x),K=Math.min(K,We.y),oe=Math.max(oe,We.x),ue=Math.max(ue,We.y);const ve=Math.max(oe-O,ue-K),Te=Math.max(0,Math.floor(-Math.log(ve)/Math.LN2)),ke=Math.pow(2,Te);return new i.CanonicalTileID(Te,Math.floor((O+oe)/2*ke),Math.floor((K+ue)/2*ke))}(_),this.minzoom=this.maxzoom=this.tileID.z;const T=_.map(F=>this.tileID.getTilePoint(F)._round());return this._boundsArray=new i.RasterBoundsArray,this._boundsArray.emplaceBack(T[0].x,T[0].y,0,0),this._boundsArray.emplaceBack(T[1].x,T[1].y,i.EXTENT,0),this._boundsArray.emplaceBack(T[3].x,T[3].y,0,i.EXTENT),this._boundsArray.emplaceBack(T[2].x,T[2].y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const h=this.map.painter.context,_=h.gl;this.boundsBuffer||(this.boundsBuffer=h.createVertexBuffer(this._boundsArray,Ne.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new Y(h,this.image,_.RGBA),this.texture.bind(_.LINEAR,_.CLAMP_TO_EDGE));for(const T in this.tiles){const F=this.tiles[T];F.state!=="loaded"&&(F.state="loaded",F.texture=this.texture)}}loadTile(h,_){this.tileID&&this.tileID.equals(h.tileID.canonical)?(this.tiles[String(h.tileID.wrap)]=h,h.buckets={},_(null)):(h.state="errored",_(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class Ve extends Ge{constructor(h,_,T,F){super(h,_,T,F),this.roundZoom=!0,this.type="video",this.options=_}load(){this._loaded=!1;const h=this.options;this.urls=[];for(const _ of h.urls)this.urls.push(this.map._requestManager.transformRequest(_,i.ResourceType.Source).url);i.getVideo(this.urls,(_,T)=>{this._loaded=!0,_?this.fire(new i.ErrorEvent(_)):T&&(this.video=T,this.video.loop=!0,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(h){if(this.video){const _=this.video.seekable;h<_.start(0)||h>_.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${_.start(0)} and ${_.end(0)}-second mark.`))):this.video.currentTime=h}}getVideo(){return this.video}onAdd(h){this.map||(this.map=h,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 h=this.map.painter.context,_=h.gl;this.boundsBuffer||(this.boundsBuffer=h.createVertexBuffer(this._boundsArray,Ne.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(_.LINEAR,_.CLAMP_TO_EDGE),_.texSubImage2D(_.TEXTURE_2D,0,0,0,_.RGBA,_.UNSIGNED_BYTE,this.video)):(this.texture=new Y(h,this.video,_.RGBA),this.texture.bind(_.LINEAR,_.CLAMP_TO_EDGE));for(const T in this.tiles){const F=this.tiles[T];F.state!=="loaded"&&(F.state="loaded",F.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Le extends Ge{constructor(h,_,T,F){super(h,_,T,F),_.coordinates?Array.isArray(_.coordinates)&&_.coordinates.length===4&&!_.coordinates.some(O=>!Array.isArray(O)||O.length!==2||O.some(K=>typeof K!="number"))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${h}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${h}`,null,'missing required property "coordinates"'))),_.animate&&typeof _.animate!="boolean"&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${h}`,null,'optional "animate" property must be a boolean value'))),_.canvas?typeof _.canvas=="string"||_.canvas instanceof HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${h}`,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 i.ErrorEvent(new i.ValidationError(`sources.${h}`,null,'missing required property "canvas"'))),this.options=_,this.animate=_.animate===void 0||_.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.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(h){this.map=h,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let h=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,h=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,h=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const _=this.map.painter.context,T=_.gl;this.boundsBuffer||(this.boundsBuffer=_.createVertexBuffer(this._boundsArray,Ne.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(h||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Y(_,this.canvas,T.RGBA,{premultiply:!0});for(const F in this.tiles){const O=this.tiles[F];O.state!=="loaded"&&(O.state="loaded",O.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const h of[this.canvas.width,this.canvas.height])if(isNaN(h)||h<=0)return!0;return!1}}const Ie={vector:te,raster:ce,"raster-dem":xe,geojson:ze,video:Ve,image:Ge,canvas:Le};function qe(M,h){const _=i.create();return i.translate(_,_,[1,1,0]),i.scale(_,_,[.5*M.width,.5*M.height,1]),i.multiply(_,_,M.calculatePosMatrix(h.toUnwrapped()))}function et(M,h,_,T,F,O){const K=function(ke,We,bt){if(ke)for(const mt of ke){const gt=We[mt];if(gt&>.source===bt&>.type==="fill-extrusion")return!0}else for(const mt in We){const gt=We[mt];if(gt.source===bt&>.type==="fill-extrusion")return!0}return!1}(F&&F.layers,h,M.id),oe=O.maxPitchScaleFactor(),ue=M.tilesIn(T,oe,K);ue.sort(vt);const ve=[];for(const ke of ue)ve.push({wrappedTileID:ke.tileID.wrapped().key,queryResults:ke.tile.queryRenderedFeatures(h,_,M._state,ke.queryGeometry,ke.cameraQueryGeometry,ke.scale,F,O,oe,qe(M.transform,ke.tileID))});const Te=function(ke){const We={},bt={};for(const mt of ke){const gt=mt.queryResults,Vt=mt.wrappedTileID,Zt=bt[Vt]=bt[Vt]||{};for(const ni in gt){const St=gt[ni],zt=Zt[ni]=Zt[ni]||{},li=We[ni]=We[ni]||[];for(const Ei of St)zt[Ei.featureIndex]||(zt[Ei.featureIndex]=!0,li.push(Ei))}}return We}(ve);for(const ke in Te)Te[ke].forEach(We=>{const bt=We.feature,mt=M.getFeatureState(bt.layer["source-layer"],bt.id);bt.source=bt.layer.source,bt.layer["source-layer"]&&(bt.sourceLayer=bt.layer["source-layer"]),bt.state=mt});return Te}function vt(M,h){const _=M.tileID,T=h.tileID;return _.overscaledZ-T.overscaledZ||_.canonical.y-T.canonical.y||_.wrap-T.wrap||_.canonical.x-T.canonical.x}class Be{constructor(h,_){this.tileID=h,this.uid=i.uniqueId(),this.uses=0,this.tileSize=_,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.textures=[],this.textureCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(h){const _=h+this.timeAdded;_h.saveTileTexture(_)),this.demTexture=null,this.textures=[],this.textureCoords={}}loadVectorData(h,_,T){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",h){h.featureIndex&&(this.latestFeatureIndex=h.featureIndex,h.rawTileData?(this.latestRawTileData=h.rawTileData,this.latestFeatureIndex.rawTileData=h.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=h.collisionBoxArray,this.buckets=function(F,O){const K={};if(!O)return K;for(const oe of F){const ue=oe.layerIds.map(ve=>O.getLayer(ve)).filter(Boolean);if(ue.length!==0){oe.layers=ue,oe.stateDependentLayerIds&&(oe.stateDependentLayers=oe.stateDependentLayerIds.map(ve=>ue.filter(Te=>Te.id===ve)[0]));for(const ve of ue)K[ve.id]=oe}}return K}(h.buckets,_.style),this.hasSymbolBuckets=!1;for(const F in this.buckets){const O=this.buckets[F];if(O instanceof i.SymbolBucket){if(this.hasSymbolBuckets=!0,!T)break;O.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const F in this.buckets){const O=this.buckets[F];if(O instanceof i.SymbolBucket&&O.hasRTLText){this.hasRTLText=!0,i.lazyLoadRTLTextPlugin();break}}this.queryPadding=0;for(const F in this.buckets){const O=this.buckets[F];this.queryPadding=Math.max(this.queryPadding,_.style.getLayer(F).queryRadius(O))}h.imageAtlas&&(this.imageAtlas=h.imageAtlas),h.glyphAtlasImage&&(this.glyphAtlasImage=h.glyphAtlasImage)}else this.collisionBoxArray=new i.CollisionBoxArray}unloadVectorData(){for(const h in this.buckets)this.buckets[h].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(h){return this.buckets[h.id]}upload(h){for(const T in this.buckets){const F=this.buckets[T];F.uploadPending()&&F.upload(h)}const _=h.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Y(h,this.imageAtlas.image,_.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Y(h,this.glyphAtlasImage,_.ALPHA),this.glyphAtlasImage=null)}prepare(h){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(h,this.imageAtlasTexture)}queryRenderedFeatures(h,_,T,F,O,K,oe,ue,ve,Te){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:F,cameraQueryGeometry:O,scale:K,tileSize:this.tileSize,pixelPosMatrix:Te,transform:ue,params:oe,queryPadding:this.queryPadding*ve},h,_,T):{}}querySourceFeatures(h,_){const T=this.latestFeatureIndex;if(!T||!T.rawTileData)return;const F=T.loadVTLayers(),O=_?_.sourceLayer:"",K=F._geojsonTileLayer||F[O];if(!K)return;const oe=i.createFilter(_&&_.filter),{z:ue,x:ve,y:Te}=this.tileID.canonical,ke={z:ue,x:ve,y:Te};for(let We=0;WeT)F=!1;else if(_)if(this.expirationTime<_)F=!0;else{const O=this.expirationTime-_;O?this.expirationTime=T+Math.max(O,3e4):F=!0}else F=!0;F?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<{this.remove(h,O)},T)),this.data[F].push(O),this.order.push(F),this.order.length>this.max){const K=this._getAndRemoveByKey(this.order[0]);K&&this.onRemove(K)}return this}has(h){return h.wrapped().key in this.data}getAndRemove(h){return this.has(h)?this._getAndRemoveByKey(h.wrapped().key):null}_getAndRemoveByKey(h){const _=this.data[h].shift();return _.timeout&&clearTimeout(_.timeout),this.data[h].length===0&&delete this.data[h],this.order.splice(this.order.indexOf(h),1),_.value}getByKey(h){const _=this.data[h];return _?_[0].value:null}get(h){return this.has(h)?this.data[h.wrapped().key][0].value:null}remove(h,_){if(!this.has(h))return this;const T=h.wrapped().key,F=_===void 0?0:this.data[T].indexOf(_),O=this.data[T][F];return this.data[T].splice(F,1),O.timeout&&clearTimeout(O.timeout),this.data[T].length===0&&delete this.data[T],this.onRemove(O.value),this.order.splice(this.order.indexOf(T),1),this}setMaxSize(h){for(this.max=h;this.order.length>this.max;){const _=this._getAndRemoveByKey(this.order[0]);_&&this.onRemove(_)}return this}filter(h){const _=[];for(const T in this.data)for(const F of this.data[T])h(F.value)||_.push(F);for(const T of _)this.remove(T.value.tileID,T)}}class ut{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(h,_,T){const F=String(_);if(this.stateChanges[h]=this.stateChanges[h]||{},this.stateChanges[h][F]=this.stateChanges[h][F]||{},i.extend(this.stateChanges[h][F],T),this.deletedStates[h]===null){this.deletedStates[h]={};for(const O in this.state[h])O!==F&&(this.deletedStates[h][O]=null)}else if(this.deletedStates[h]&&this.deletedStates[h][F]===null){this.deletedStates[h][F]={};for(const O in this.state[h][F])T[O]||(this.deletedStates[h][F][O]=null)}else for(const O in T)this.deletedStates[h]&&this.deletedStates[h][F]&&this.deletedStates[h][F][O]===null&&delete this.deletedStates[h][F][O]}removeFeatureState(h,_,T){if(this.deletedStates[h]===null)return;const F=String(_);if(this.deletedStates[h]=this.deletedStates[h]||{},T&&_!==void 0)this.deletedStates[h][F]!==null&&(this.deletedStates[h][F]=this.deletedStates[h][F]||{},this.deletedStates[h][F][T]=null);else if(_!==void 0)if(this.stateChanges[h]&&this.stateChanges[h][F])for(T in this.deletedStates[h][F]={},this.stateChanges[h][F])this.deletedStates[h][F][T]=null;else this.deletedStates[h][F]=null;else this.deletedStates[h]=null}getState(h,_){const T=String(_),F=i.extend({},(this.state[h]||{})[T],(this.stateChanges[h]||{})[T]);if(this.deletedStates[h]===null)return{};if(this.deletedStates[h]){const O=this.deletedStates[h][_];if(O===null)return{};for(const K in O)delete F[K]}return F}initializeTileState(h,_){h.setFeatureState(this.state,_)}coalesceChanges(h,_){const T={};for(const F in this.stateChanges){this.state[F]=this.state[F]||{};const O={};for(const K in this.stateChanges[F])this.state[F][K]||(this.state[F][K]={}),i.extend(this.state[F][K],this.stateChanges[F][K]),O[K]=this.state[F][K];T[F]=O}for(const F in this.deletedStates){this.state[F]=this.state[F]||{};const O={};if(this.deletedStates[F]===null)for(const K in this.state[F])O[K]={},this.state[F][K]={};else for(const K in this.deletedStates[F]){if(this.deletedStates[F][K]===null)this.state[F][K]={};else for(const oe of Object.keys(this.deletedStates[F][K]))delete this.state[F][K][oe];O[K]=this.state[F][K]}T[F]=T[F]||{},i.extend(T[F],O)}if(this.stateChanges={},this.deletedStates={},Object.keys(T).length!==0)for(const F in h)h[F].setFeatureState(T,_)}}class Qt extends i.Evented{constructor(h,_,T){super(),this.id=h,this.dispatcher=T,this.on("data",F=>{F.dataType==="source"&&F.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&F.dataType==="source"&&F.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain))}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=function(F,O,K,oe){const ue=new Ie[O.type](F,O,K,oe);if(ue.id!==F)throw new Error(`Expected Source id to be ${F} instead of ${ue.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],ue),ue}(h,_,T,this),this._tiles={},this._cache=new dt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new ut}onAdd(h){this.map=h,this._maxTileCacheSize=h?h._maxTileCacheSize:null,this._source&&this._source.onAdd&&this._source.onAdd(h)}onRemove(h){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(h)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const h in this._tiles){const _=this._tiles[h];if(_.state!=="loaded"&&_.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const h=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,h&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(h,_){return this._source.loadTile(h,_)}_unloadTile(h){if(this._source.unloadTile)return this._source.unloadTile(h,()=>{})}_abortTile(h){this._source.abortTile&&this._source.abortTile(h,()=>{}),this._source.fire(new i.Event("dataabort",{tile:h,coord:h.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(h){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const _ in this._tiles){const T=this._tiles[_];T.upload(h),T.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(h=>h.tileID).sort(Wt).map(h=>h.key)}getRenderableIds(h){const _=[];for(const T in this._tiles)this._isIdRenderable(T,h)&&_.push(this._tiles[T]);return h?_.sort((T,F)=>{const O=T.tileID,K=F.tileID,oe=new i.pointGeometry(O.canonical.x,O.canonical.y)._rotate(this.transform.angle),ue=new i.pointGeometry(K.canonical.x,K.canonical.y)._rotate(this.transform.angle);return O.overscaledZ-K.overscaledZ||ue.y-oe.y||ue.x-oe.x}).map(T=>T.tileID.key):_.map(T=>T.tileID).sort(Wt).map(T=>T.key)}hasRenderableParent(h){const _=this.findLoadedParent(h,0);return!!_&&this._isIdRenderable(_.tileID.key)}_isIdRenderable(h,_){return this._tiles[h]&&this._tiles[h].hasData()&&!this._coveredTiles[h]&&(_||!this._tiles[h].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const h in this._tiles)this._tiles[h].state!=="errored"&&this._reloadTile(h,"reloading")}}_reloadTile(h,_){const T=this._tiles[h];T&&(T.state!=="loading"&&(T.state=_),this._loadTile(T,this._tileLoaded.bind(this,T,h,_)))}_tileLoaded(h,_,T,F){if(F)return h.state="errored",void(F.status!==404?this._source.fire(new i.ErrorEvent(F,{tile:h})):this.update(this.transform,this.terrain));h.timeAdded=i.exported.now(),T==="expired"&&(h.refreshedUponExpiration=!0),this._setTileReloadTimer(_,h),this.getSource().type==="raster-dem"&&h.dem&&this._backfillDEM(h),this._state.initializeTileState(h,this.map?this.map.painter:null),h.aborted||this._source.fire(new i.Event("data",{dataType:"source",tile:h,coord:h.tileID}))}_backfillDEM(h){const _=this.getRenderableIds();for(let F=0;F<_.length;F++){const O=_[F];if(h.neighboringTiles&&h.neighboringTiles[O]){const K=this.getTileByID(O);T(h,K),T(K,h)}}function T(F,O){F.needsHillshadePrepare=!0,F.needsTerrainPrepare=!0;let K=O.tileID.canonical.x-F.tileID.canonical.x;const oe=O.tileID.canonical.y-F.tileID.canonical.y,ue=Math.pow(2,F.tileID.canonical.z),ve=O.tileID.key;K===0&&oe===0||Math.abs(oe)>1||(Math.abs(K)>1&&(Math.abs(K+ue)===1?K+=ue:Math.abs(K-ue)===1&&(K-=ue)),O.dem&&F.dem&&(F.dem.backfillBorder(O.dem,K,oe),F.neighboringTiles&&F.neighboringTiles[ve]&&(F.neighboringTiles[ve].backfilled=!0)))}}getTile(h){return this.getTileByID(h.key)}getTileByID(h){return this._tiles[h]}_retainLoadedChildren(h,_,T,F){for(const O in this._tiles){let K=this._tiles[O];if(F[O]||!K.hasData()||K.tileID.overscaledZ<=_||K.tileID.overscaledZ>T)continue;let oe=K.tileID;for(;K&&K.tileID.overscaledZ>_+1;){const ve=K.tileID.scaledTo(K.tileID.overscaledZ-1);K=this._tiles[ve.key],K&&K.hasData()&&(oe=ve)}let ue=oe;for(;ue.overscaledZ>_;)if(ue=ue.scaledTo(ue.overscaledZ-1),h[ue.key]){F[oe.key]=oe;break}}}findLoadedParent(h,_){if(h.key in this._loadedParentTiles){const T=this._loadedParentTiles[h.key];return T&&T.tileID.overscaledZ>=_?T:null}for(let T=h.overscaledZ-1;T>=_;T--){const F=h.scaledTo(T),O=this._getLoadedTile(F);if(O)return O}}_getLoadedTile(h){const _=this._tiles[h.key];return _&&_.hasData()?_:this._cache.getByKey(h.wrapped().key)}updateCacheSize(h){const _=Math.ceil(h.width/this._source.tileSize)+1,T=Math.ceil(h.height/this._source.tileSize)+1,F=Math.floor(_*T*5),O=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,F):F;this._cache.setMaxSize(O)}handleWrapJump(h){const _=Math.round((h-(this._prevLng===void 0?h:this._prevLng))/360);if(this._prevLng=h,_){const T={};for(const F in this._tiles){const O=this._tiles[F];O.tileID=O.tileID.unwrapTo(O.tileID.wrap+_),T[O.tileID.key]=O}this._tiles=T;for(const F in this._timers)clearTimeout(this._timers[F]),delete this._timers[F];for(const F in this._tiles)this._setTileReloadTimer(F,this._tiles[F])}}update(h,_){if(this.transform=h,this.terrain=_,!this._sourceLoaded||this._paused)return;let T;this.updateCacheSize(h),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?T=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(ve=>new i.OverscaledTileID(ve.canonical.z,ve.wrap,ve.canonical.z,ve.canonical.x,ve.canonical.y)):(T=h.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:_}),this._source.hasTile&&(T=T.filter(ve=>this._source.hasTile(ve)))):T=[];const F=h.coveringZoomLevel(this._source),O=Math.max(F-Qt.maxOverzooming,this._source.minzoom),K=Math.max(F+Qt.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const ve={};for(const Te of T)if(Te.canonical.z>this._source.minzoom){const ke=Te.scaledTo(Te.canonical.z-1);ve[ke.key]=ke;const We=Te.scaledTo(Math.max(this._source.minzoom,Math.min(Te.canonical.z,5)));ve[We.key]=We}T=T.concat(Object.values(ve))}const oe=this._updateRetainedTiles(T,F);if(Nt(this._source.type)){const ve={},Te={},ke=Object.keys(oe);for(const We of ke){const bt=oe[We],mt=this._tiles[We];if(!mt||mt.fadeEndTime&&mt.fadeEndTime<=i.exported.now())continue;const gt=this.findLoadedParent(bt,O);gt&&(this._addTile(gt.tileID),ve[gt.tileID.key]=gt.tileID),Te[We]=bt}this._retainLoadedChildren(Te,F,K,oe);for(const We in ve)oe[We]||(this._coveredTiles[We]=!0,oe[We]=ve[We]);if(_){const We={},bt={};for(const mt of T)this._tiles[mt.key].hasData()?We[mt.key]=mt:bt[mt.key]=mt;for(const mt in bt){const gt=bt[mt].children(this._source.maxzoom);this._tiles[gt[0].key]&&this._tiles[gt[1].key]&&this._tiles[gt[2].key]&&this._tiles[gt[3].key]&&(We[gt[0].key]=oe[gt[0].key]=gt[0],We[gt[1].key]=oe[gt[1].key]=gt[1],We[gt[2].key]=oe[gt[2].key]=gt[2],We[gt[3].key]=oe[gt[3].key]=gt[3],delete bt[mt])}for(const mt in bt){const gt=this.findLoadedParent(bt[mt],this._source.minzoom);if(gt){We[gt.tileID.key]=oe[gt.tileID.key]=gt.tileID;for(const Vt in We)We[Vt].isChildOf(gt.tileID)&&delete We[Vt]}}for(const mt in this._tiles)We[mt]||(this._coveredTiles[mt]=!0)}}for(const ve in oe)this._tiles[ve].clearFadeHold();const ue=i.keysDifference(this._tiles,oe);for(const ve of ue){const Te=this._tiles[ve];Te.hasSymbolBuckets&&!Te.holdingForFade()?Te.setHoldDuration(this.map._fadeDuration):Te.hasSymbolBuckets&&!Te.symbolFadeFinished()||this._removeTile(ve)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const h in this._tiles)this._tiles[h].holdingForFade()&&this._removeTile(h)}_updateRetainedTiles(h,_){const T={},F={},O=Math.max(_-Qt.maxOverzooming,this._source.minzoom),K=Math.max(_+Qt.maxUnderzooming,this._source.minzoom),oe={};for(const ue of h){const ve=this._addTile(ue);T[ue.key]=ue,ve.hasData()||_this._source.maxzoom){const ke=ue.children(this._source.maxzoom)[0],We=this.getTile(ke);if(We&&We.hasData()){T[ke.key]=ke;continue}}else{const ke=ue.children(this._source.maxzoom);if(T[ke[0].key]&&T[ke[1].key]&&T[ke[2].key]&&T[ke[3].key])continue}let Te=ve.wasRequested();for(let ke=ue.overscaledZ-1;ke>=O;--ke){const We=ue.scaledTo(ke);if(F[We.key]||(F[We.key]=!0,ve=this.getTile(We),!ve&&Te&&(ve=this._addTile(We)),ve&&(T[We.key]=We,Te=ve.wasRequested(),ve.hasData())))break}}return T}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const h in this._tiles){const _=[];let T,F=this._tiles[h].tileID;for(;F.overscaledZ>0;){if(F.key in this._loadedParentTiles){T=this._loadedParentTiles[F.key];break}_.push(F.key);const O=F.scaledTo(F.overscaledZ-1);if(T=this._getLoadedTile(O),T)break;F=O}for(const O of _)this._loadedParentTiles[O]=T}}_addTile(h){let _=this._tiles[h.key];if(_)return _;_=this._cache.getAndRemove(h),_&&(this._setTileReloadTimer(h.key,_),_.tileID=h,this._state.initializeTileState(_,this.map?this.map.painter:null),this._cacheTimers[h.key]&&(clearTimeout(this._cacheTimers[h.key]),delete this._cacheTimers[h.key],this._setTileReloadTimer(h.key,_)));const T=_;return _||(_=new Be(h,this._source.tileSize*h.overscaleFactor()),this._loadTile(_,this._tileLoaded.bind(this,_,h.key,_.state))),_.uses++,this._tiles[h.key]=_,T||this._source.fire(new i.Event("dataloading",{tile:_,coord:_.tileID,dataType:"source"})),_}_setTileReloadTimer(h,_){h in this._timers&&(clearTimeout(this._timers[h]),delete this._timers[h]);const T=_.getExpiryTimeout();T&&(this._timers[h]=setTimeout(()=>{this._reloadTile(h,"expired"),delete this._timers[h]},T))}_removeTile(h){const _=this._tiles[h];_&&(_.uses--,delete this._tiles[h],this._timers[h]&&(clearTimeout(this._timers[h]),delete this._timers[h]),_.uses>0||(_.hasData()&&_.state!=="reloading"?this._cache.add(_.tileID,_,_.getExpiryTimeout()):(_.aborted=!0,this._abortTile(_),this._unloadTile(_))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const h in this._tiles)this._removeTile(h);this._cache.reset()}tilesIn(h,_,T){const F=[],O=this.transform;if(!O)return F;const K=T?O.getCameraQueryGeometry(h):h,oe=h.map(mt=>O.pointCoordinate(mt,this.terrain)),ue=K.map(mt=>O.pointCoordinate(mt,this.terrain)),ve=this.getIds();let Te=1/0,ke=1/0,We=-1/0,bt=-1/0;for(const mt of ue)Te=Math.min(Te,mt.x),ke=Math.min(ke,mt.y),We=Math.max(We,mt.x),bt=Math.max(bt,mt.y);for(let mt=0;mt=0&&St[1].y+ni>=0){const zt=oe.map(Ei=>Vt.getTilePoint(Ei)),li=ue.map(Ei=>Vt.getTilePoint(Ei));F.push({tile:gt,tileID:Vt,queryGeometry:zt,cameraQueryGeometry:li,scale:Zt})}}return F}getVisibleCoordinates(h){const _=this.getRenderableIds(h).map(T=>this._tiles[T].tileID);for(const T of _)T.posMatrix=this.transform.calculatePosMatrix(T.toUnwrapped());return _}hasTransition(){if(this._source.hasTransition())return!0;if(Nt(this._source.type))for(const h in this._tiles){const _=this._tiles[h];if(_.fadeEndTime!==void 0&&_.fadeEndTime>=i.exported.now())return!0}return!1}setFeatureState(h,_,T){this._state.updateState(h=h||"_geojsonTileLayer",_,T)}removeFeatureState(h,_,T){this._state.removeFeatureState(h=h||"_geojsonTileLayer",_,T)}getFeatureState(h,_){return this._state.getState(h=h||"_geojsonTileLayer",_)}setDependencies(h,_,T){const F=this._tiles[h];F&&F.setDependencies(_,T)}reloadTilesForDependencies(h,_){for(const T in this._tiles)this._tiles[T].hasDependency(h,_)&&this._reloadTile(T,"reloading");this._cache.filter(T=>!T.hasDependency(h,_))}}function Wt(M,h){const _=Math.abs(2*M.wrap)-+(M.wrap<0),T=Math.abs(2*h.wrap)-+(h.wrap<0);return M.overscaledZ-h.overscaledZ||T-_||h.canonical.y-M.canonical.y||h.canonical.x-M.canonical.x}function Nt(M){return M==="raster"||M==="image"||M==="video"}Qt.maxOverzooming=10,Qt.maxUnderzooming=3;const Ct="mapboxgl_preloaded_worker_pool";class Ft{constructor(){this.active={}}acquire(h){if(!this.workers)for(this.workers=[];this.workers.length{_.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Ct]}numActive(){return Object.keys(this.active).length}}const Xt=Math.floor(i.exported.hardwareConcurrency/2);let mi;function fi(){return mi||(mi=new Ft),mi}function Gi(M,h){const _={};for(const T in M)T!=="ref"&&(_[T]=M[T]);return i.refProperties.forEach(T=>{T in h&&(_[T]=h[T])}),_}function wn(M){M=M.slice();const h=Object.create(null);for(let _=0;_0?(F-K)/oe:0;return this.points[O].mult(1-ue).add(this.points[_].mult(ue))}}function $t(M,h){let _=!0;return M==="always"||M!=="never"&&h!=="never"||(_=!1),_}class at{constructor(h,_,T){const F=this.boxCells=[],O=this.circleCells=[];this.xCellCount=Math.ceil(h/T),this.yCellCount=Math.ceil(_/T);for(let K=0;Kthis.width||F<0||_>this.height)return[];const ue=[];if(h<=0&&_<=0&&this.width<=T&&this.height<=F){if(O)return[{key:null,x1:h,y1:_,x2:T,y2:F}];for(let ve=0;ve0}hitTestCircle(h,_,T,F,O){const K=h-T,oe=h+T,ue=_-T,ve=_+T;if(oe<0||K>this.width||ve<0||ue>this.height)return!1;const Te=[];return this._forEachCell(K,ue,oe,ve,this._queryCellCircle,Te,{hitTest:!0,overlapMode:F,circle:{x:h,y:_,radius:T},seenUids:{box:{},circle:{}}},O),Te.length>0}_queryCell(h,_,T,F,O,K,oe,ue){const{seenUids:ve,hitTest:Te,overlapMode:ke}=oe,We=this.boxCells[O];if(We!==null){const mt=this.bboxes;for(const gt of We)if(!ve.box[gt]){ve.box[gt]=!0;const Vt=4*gt,Zt=this.boxKeys[gt];if(h<=mt[Vt+2]&&_<=mt[Vt+3]&&T>=mt[Vt+0]&&F>=mt[Vt+1]&&(!ue||ue(Zt))&&(!Te||!$t(ke,Zt.overlapMode))&&(K.push({key:Zt,x1:mt[Vt],y1:mt[Vt+1],x2:mt[Vt+2],y2:mt[Vt+3]}),Te))return!0}}const bt=this.circleCells[O];if(bt!==null){const mt=this.circles;for(const gt of bt)if(!ve.circle[gt]){ve.circle[gt]=!0;const Vt=3*gt,Zt=this.circleKeys[gt];if(this._circleAndRectCollide(mt[Vt],mt[Vt+1],mt[Vt+2],h,_,T,F)&&(!ue||ue(Zt))&&(!Te||!$t(ke,Zt.overlapMode))){const ni=mt[Vt],St=mt[Vt+1],zt=mt[Vt+2];if(K.push({key:Zt,x1:ni-zt,y1:St-zt,x2:ni+zt,y2:St+zt}),Te)return!0}}}return!1}_queryCellCircle(h,_,T,F,O,K,oe,ue){const{circle:ve,seenUids:Te,overlapMode:ke}=oe,We=this.boxCells[O];if(We!==null){const mt=this.bboxes;for(const gt of We)if(!Te.box[gt]){Te.box[gt]=!0;const Vt=4*gt,Zt=this.boxKeys[gt];if(this._circleAndRectCollide(ve.x,ve.y,ve.radius,mt[Vt+0],mt[Vt+1],mt[Vt+2],mt[Vt+3])&&(!ue||ue(Zt))&&!$t(ke,Zt.overlapMode))return K.push(!0),!0}}const bt=this.circleCells[O];if(bt!==null){const mt=this.circles;for(const gt of bt)if(!Te.circle[gt]){Te.circle[gt]=!0;const Vt=3*gt,Zt=this.circleKeys[gt];if(this._circlesCollide(mt[Vt],mt[Vt+1],mt[Vt+2],ve.x,ve.y,ve.radius)&&(!ue||ue(Zt))&&!$t(ke,Zt.overlapMode))return K.push(!0),!0}}}_forEachCell(h,_,T,F,O,K,oe,ue){const ve=this._convertToXCellCoord(h),Te=this._convertToYCellCoord(_),ke=this._convertToXCellCoord(T),We=this._convertToYCellCoord(F);for(let bt=ve;bt<=ke;bt++)for(let mt=Te;mt<=We;mt++)if(O.call(this,h,_,T,F,this.xCellCount*mt+bt,K,oe,ue))return}_convertToXCellCoord(h){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(h*this.xScale)))}_convertToYCellCoord(h){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(h*this.yScale)))}_circlesCollide(h,_,T,F,O,K){const oe=F-h,ue=O-_,ve=T+K;return ve*ve>oe*oe+ue*ue}_circleAndRectCollide(h,_,T,F,O,K,oe){const ue=(K-F)/2,ve=Math.abs(h-(F+ue));if(ve>ue+T)return!1;const Te=(oe-O)/2,ke=Math.abs(_-(O+Te));if(ke>Te+T)return!1;if(ve<=ue||ke<=Te)return!0;const We=ve-ue,bt=ke-Te;return We*We+bt*bt<=T*T}}function ii(M,h,_,T,F){const O=i.create();return h?(i.scale(O,O,[1/F,1/F,1]),_||i.rotateZ(O,O,T.angle)):i.multiply(O,T.labelPlaneMatrix,M),O}function hn(M,h,_,T,F){if(h){const O=i.clone(M);return i.scale(O,O,[F,F,1]),_||i.rotateZ(O,O,-T.angle),O}return T.glCoordMatrix}function Xi(M,h,_){let T;_?(T=[M.x,M.y,_(M.x,M.y),1],i.transformMat4(T,T,h)):(T=[M.x,M.y,0,1],Pn(T,T,h));const F=T[3];return{point:new i.pointGeometry(T[0]/F,T[1]/F),signedDistanceFromCamera:F}}function on(M,h){return .5+M/h*.5}function Cn(M,h){const _=M[0]/M[3],T=M[1]/M[3];return _>=-h[0]&&_<=h[0]&&T>=-h[1]&&T<=h[1]}function Tn(M,h,_,T,F,O,K,oe,ue,ve){const Te=T?M.textSizeData:M.iconSizeData,ke=i.evaluateSizeForZoom(Te,_.transform.zoom),We=[256/_.width*2+1,256/_.height*2+1],bt=T?M.text.dynamicLayoutVertexArray:M.icon.dynamicLayoutVertexArray;bt.clear();const mt=M.lineVertexArray,gt=T?M.text.placedSymbolArray:M.icon.placedSymbolArray,Vt=_.transform.width/_.transform.height;let Zt=!1;for(let ni=0;niMath.abs(_.x-h.x)*T?{useVertical:!0}:(M===i.WritingMode.vertical?h.y<_.y:h.x>_.x)?{needsFlipping:!0}:null}function bn(M,h,_,T,F,O,K,oe,ue,ve,Te,ke,We,bt,mt,gt){const Vt=h/24,Zt=M.lineOffsetX*Vt,ni=M.lineOffsetY*Vt;let St;if(M.numGlyphs>1){const zt=M.glyphStartIndex+M.numGlyphs,li=M.lineStartIndex,Ei=M.lineStartIndex+M.lineLength,bi=nr(Vt,oe,Zt,ni,_,Te,ke,M,ue,O,We,mt,gt);if(!bi)return{notEnoughRoom:!0};const Hi=Xi(bi.first.point,K,gt).point,xi=Xi(bi.last.point,K,gt).point;if(T&&!_){const xn=Ii(M.writingMode,Hi,xi,bt);if(xn)return xn}St=[bi.first];for(let xn=M.glyphStartIndex+1;xn0?Hi.point:Ot(ke,bi,li,1,F,gt),xn=Ii(M.writingMode,li,xi,bt);if(xn)return xn}const zt=vi(Vt*oe.getoffsetX(M.glyphStartIndex),Zt,ni,_,Te,ke,M.segment,M.lineStartIndex,M.lineStartIndex+M.lineLength,ue,O,We,mt,gt);if(!zt)return{notEnoughRoom:!0};St=[zt]}for(const zt of St)i.addDynamicAttributes(ve,zt.point,zt.angle);return{}}function Ot(M,h,_,T,F,O){const K=Xi(M.add(M.sub(h)._unit()),F,O).point,oe=_.sub(K);return _.add(oe._mult(T/oe.mag()))}function vi(M,h,_,T,F,O,K,oe,ue,ve,Te,ke,We,bt){const mt=T?M-h:M+h;let gt=mt>0?1:-1,Vt=0;T&&(gt*=-1,Vt=Math.PI),gt<0&&(Vt+=Math.PI);let Zt=gt>0?oe+K:oe+K+1,ni=F,St=F,zt=0,li=0;const Ei=Math.abs(mt),bi=[];for(;zt+li<=Ei;){if(Zt+=gt,Zt=ue)return null;if(St=ni,bi.push(ni),ni=ke[Zt],ni===void 0){const Bn=new i.pointGeometry(ve.getx(Zt),ve.gety(Zt)),tr=Xi(Bn,Te,bt);if(tr.signedDistanceFromCamera>0)ni=ke[Zt]=tr.point;else{const ur=Zt-gt;ni=Ot(zt===0?O:new i.pointGeometry(ve.getx(ur),ve.gety(ur)),Bn,St,Ei-zt+1,Te,bt)}}zt+=li,li=St.dist(ni)}const Hi=(Ei-zt)/li,xi=ni.sub(St),xn=xi.mult(Hi)._add(St);xn._add(xi._unit()._perp()._mult(_*gt));const cn=Vt+Math.atan2(ni.y-St.y,ni.x-St.x);return bi.push(xn),{point:xn,angle:We?cn:0,path:bi}}const Wi=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ui(M,h){for(let _=0;_=1;Cr--)Un.push(tr.path[Cr]);for(let Cr=1;CrXi(Er,ue,mt));Un=Cr.some(Er=>Er.signedDistanceFromCamera<=0)?[]:Cr.map(Er=>Er.point)}let Rr=[];if(Un.length>0){const Cr=Un[0].clone(),Er=Un[0].clone();for(let Gr=1;Gr=xn.x&&Er.x<=cn.x&&Cr.y>=xn.y&&Er.y<=cn.y?[Un]:Er.xcn.x||Er.ycn.y?[]:i.clipLine([Un],xn.x,xn.y,cn.x,cn.y)}for(const Cr of Rr){Bn.reset(Cr,.25*xi);let Er=0;Er=Bn.length<=.5*xi?1:Math.ceil(Bn.paddedLength/Lr)+1;for(let Gr=0;Gr=this.screenRightBoundary||Fthis.screenBottomBoundary}isInsideGrid(h,_,T,F){return T>=0&&h=0&&_T.collisionGroupID===_}}return this.collisionGroups[h]}}function ct(M,h,_,T,F){const{horizontalAlign:O,verticalAlign:K}=i.getAnchorAlignment(M),oe=-(O-.5)*h,ue=-(K-.5)*_,ve=i.evaluateVariableOffset(M,T);return new i.pointGeometry(oe+ve[0]*F,ue+ve[1]*F)}function wt(M,h,_,T,F,O){const{x1:K,x2:oe,y1:ue,y2:ve,anchorPointX:Te,anchorPointY:ke}=M,We=new i.pointGeometry(h,_);return T&&We._rotate(F?O:-O),{x1:K+We.x,y1:ue+We.y,x2:oe+We.x,y2:ve+We.y,anchorPointX:Te,anchorPointY:ke}}class X{constructor(h,_,T,F,O){this.transform=h.clone(),this.terrain=_,this.collisionIndex=new Hr(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=T,this.retainedQueryData={},this.collisionGroups=new Ue(F),this.collisionCircleArrays={},this.prevPlacement=O,O&&(O.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(h,_,T,F){const O=T.getBucket(_),K=T.latestFeatureIndex;if(!O||!K||_.id!==O.layerIds[0])return;const oe=T.collisionBoxArray,ue=O.layers[0].layout,ve=Math.pow(2,this.transform.zoom-T.tileID.overscaledZ),Te=T.tileSize/i.EXTENT,ke=this.transform.calculatePosMatrix(T.tileID.toUnwrapped()),We=ue.get("text-pitch-alignment")==="map",bt=ue.get("text-rotation-alignment")==="map",mt=fr(T,1,this.transform.zoom),gt=ii(ke,We,bt,this.transform,mt);let Vt=null;if(We){const ni=hn(ke,We,bt,this.transform,mt);Vt=i.multiply([],this.transform.labelPlaneMatrix,ni)}this.retainedQueryData[O.bucketInstanceId]=new Ee(O.bucketInstanceId,K,O.sourceLayerIndex,O.index,T.tileID);const Zt={bucket:O,layout:ue,posMatrix:ke,textLabelPlaneMatrix:gt,labelToScreenMatrix:Vt,scale:ve,textPixelRatio:Te,holdingForFade:T.holdingForFade(),collisionBoxArray:oe,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(O.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(O.sourceID)};if(F)for(const ni of O.sortKeyRanges){const{sortKey:St,symbolInstanceStart:zt,symbolInstanceEnd:li}=ni;h.push({sortKey:St,symbolInstanceStart:zt,symbolInstanceEnd:li,parameters:Zt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:O.symbolInstances.length,parameters:Zt})}attemptAnchorPlacement(h,_,T,F,O,K,oe,ue,ve,Te,ke,We,bt,mt,gt,Vt){const Zt=[We.textOffset0,We.textOffset1],ni=ct(h,T,F,Zt,O),St=this.collisionIndex.placeCollisionBox(wt(_,ni.x,ni.y,K,oe,this.transform.angle),ke,ue,ve,Te.predicate,Vt);if((!gt||this.collisionIndex.placeCollisionBox(wt(gt,ni.x,ni.y,K,oe,this.transform.angle),ke,ue,ve,Te.predicate,Vt).box.length!==0)&&St.box.length>0){let zt;if(this.prevPlacement&&this.prevPlacement.variableOffsets[We.crossTileID]&&this.prevPlacement.placements[We.crossTileID]&&this.prevPlacement.placements[We.crossTileID].text&&(zt=this.prevPlacement.variableOffsets[We.crossTileID].anchor),We.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[We.crossTileID]={textOffset:Zt,width:T,height:F,anchor:h,textBoxScale:O,prevAnchor:zt},this.markUsedJustification(bt,h,We,mt),bt.allowVerticalPlacement&&(this.markUsedOrientation(bt,mt,We),this.placedOrientations[We.crossTileID]=mt),{shift:ni,placedGlyphBoxes:St}}}placeLayerBucketPart(h,_,T){const{bucket:F,layout:O,posMatrix:K,textLabelPlaneMatrix:oe,labelToScreenMatrix:ue,textPixelRatio:ve,holdingForFade:Te,collisionBoxArray:ke,partiallyEvaluatedTextSize:We,collisionGroup:bt}=h.parameters,mt=O.get("text-optional"),gt=O.get("icon-optional"),Vt=i.getOverlapMode(O,"text-overlap","text-allow-overlap"),Zt=Vt==="always",ni=i.getOverlapMode(O,"icon-overlap","icon-allow-overlap"),St=ni==="always",zt=O.get("text-rotation-alignment")==="map",li=O.get("text-pitch-alignment")==="map",Ei=O.get("icon-text-fit")!=="none",bi=O.get("symbol-z-order")==="viewport-y",Hi=Zt&&(St||!F.hasIconData()||gt),xi=St&&(Zt||!F.hasTextData()||mt);!F.collisionArrays&&ke&&F.deserializeCollisionBoxes(ke);const xn=(cn,Bn)=>{if(_[cn.crossTileID])return;if(Te)return void(this.placements[cn.crossTileID]=new zs(!1,!1,!1));let tr=!1,ur=!1,Un=!0,Lr=null,Rr={box:null,offscreen:null},Cr={box:null,offscreen:null},Er=null,Gr=null,js=null,wa=0,Aa=0,ba=0;Bn.textFeatureIndex?wa=Bn.textFeatureIndex:cn.useRuntimeCollisionCircles&&(wa=cn.featureIndex),Bn.verticalTextFeatureIndex&&(Aa=Bn.verticalTextFeatureIndex);const ja=this.retainedQueryData[F.bucketInstanceId].tileID,Wo=this.terrain?(x,a)=>this.terrain.getElevation(ja,x,a):null;for(const x of["textBox","verticalTextBox","iconBox","verticalIconBox"]){const a=Bn[x];a&&(a.elevation=Wo?Wo(a.anchorPointX,a.anchorPointY):0)}const mo=Bn.textBox;if(mo){const x=m=>{let b=i.WritingMode.horizontal;if(F.allowVerticalPlacement&&!m&&this.prevPlacement){const S=this.prevPlacement.placedOrientations[cn.crossTileID];S&&(this.placedOrientations[cn.crossTileID]=S,b=S,this.markUsedOrientation(F,b,cn))}return b},a=(m,b)=>{if(F.allowVerticalPlacement&&cn.numVerticalGlyphVertices>0&&Bn.verticalTextBox){for(const S of F.writingModes)if(S===i.WritingMode.vertical?(Rr=b(),Cr=Rr):Rr=m(),Rr&&Rr.box&&Rr.box.length)break}else Rr=m()};if(O.get("text-variable-anchor")){let m=O.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[cn.crossTileID]){const P=this.prevPlacement.variableOffsets[cn.crossTileID];m.indexOf(P.anchor)>0&&(m=m.filter(H=>H!==P.anchor),m.unshift(P.anchor))}const b=(P,H,W)=>{const ee=P.x2-P.x1,pe=P.y2-P.y1,fe=cn.textBoxScale,Se=Ei&&ni==="never"?H:null;let Qe={box:[],offscreen:!1};const rt=Vt!=="never"?2*m.length:m.length;for(let nt=0;nt=m.length?Vt:"never",cn,F,W,Se,Wo);if(lt&&(Qe=lt.placedGlyphBoxes,Qe&&Qe.box&&Qe.box.length)){tr=!0,Lr=lt.shift;break}}return Qe};a(()=>b(mo,Bn.iconBox,i.WritingMode.horizontal),()=>{const P=Bn.verticalTextBox;return F.allowVerticalPlacement&&!(Rr&&Rr.box&&Rr.box.length)&&cn.numVerticalGlyphVertices>0&&P?b(P,Bn.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),Rr&&(tr=Rr.box,Un=Rr.offscreen);const S=x(Rr&&Rr.box);if(!tr&&this.prevPlacement){const P=this.prevPlacement.variableOffsets[cn.crossTileID];P&&(this.variableOffsets[cn.crossTileID]=P,this.markUsedJustification(F,P.anchor,cn,S))}}else{const m=(b,S)=>{const P=this.collisionIndex.placeCollisionBox(b,Vt,ve,K,bt.predicate,Wo);return P&&P.box&&P.box.length&&(this.markUsedOrientation(F,S,cn),this.placedOrientations[cn.crossTileID]=S),P};a(()=>m(mo,i.WritingMode.horizontal),()=>{const b=Bn.verticalTextBox;return F.allowVerticalPlacement&&cn.numVerticalGlyphVertices>0&&b?m(b,i.WritingMode.vertical):{box:null,offscreen:null}}),x(Rr&&Rr.box&&Rr.box.length)}}if(Er=Rr,tr=Er&&Er.box&&Er.box.length>0,Un=Er&&Er.offscreen,cn.useRuntimeCollisionCircles){const x=F.text.placedSymbolArray.get(cn.centerJustifiedTextSymbolIndex),a=i.evaluateSizeForFeature(F.textSizeData,We,x),m=O.get("text-padding");Gr=this.collisionIndex.placeCollisionCircles(Vt,x,F.lineVertexArray,F.glyphOffsetArray,a,K,oe,ue,T,li,bt.predicate,cn.collisionCircleDiameter,m,Wo),Gr.circles.length&&Gr.collisionDetected&&!T&&i.warnOnce("Collisions detected, but collision boxes are not shown"),tr=Zt||Gr.circles.length>0&&!Gr.collisionDetected,Un=Un&&Gr.offscreen}if(Bn.iconFeatureIndex&&(ba=Bn.iconFeatureIndex),Bn.iconBox){const x=a=>{const m=Ei&&Lr?wt(a,Lr.x,Lr.y,zt,li,this.transform.angle):a;return this.collisionIndex.placeCollisionBox(m,ni,ve,K,bt.predicate,Wo)};Cr&&Cr.box&&Cr.box.length&&Bn.verticalIconBox?(js=x(Bn.verticalIconBox),ur=js.box.length>0):(js=x(Bn.iconBox),ur=js.box.length>0),Un=Un&&js.offscreen}const Ba=mt||cn.numHorizontalGlyphVertices===0&&cn.numVerticalGlyphVertices===0,$l=gt||cn.numIconVertices===0;if(Ba||$l?$l?Ba||(ur=ur&&tr):tr=ur&&tr:ur=tr=ur&&tr,tr&&Er&&Er.box&&this.collisionIndex.insertCollisionBox(Er.box,Vt,O.get("text-ignore-placement"),F.bucketInstanceId,Cr&&Cr.box&&Aa?Aa:wa,bt.ID),ur&&js&&this.collisionIndex.insertCollisionBox(js.box,ni,O.get("icon-ignore-placement"),F.bucketInstanceId,ba,bt.ID),Gr&&(tr&&this.collisionIndex.insertCollisionCircles(Gr.circles,Vt,O.get("text-ignore-placement"),F.bucketInstanceId,wa,bt.ID),T)){const x=F.bucketInstanceId;let a=this.collisionCircleArrays[x];a===void 0&&(a=this.collisionCircleArrays[x]=new ot);for(let m=0;m=0;--Bn){const tr=cn[Bn];xn(F.symbolInstances.get(tr),F.collisionArrays[tr])}}else for(let cn=h.symbolInstanceStart;cn=0&&(h.text.placedSymbolArray.get(oe).crossTileID=O>=0&&oe!==O?0:T.crossTileID)}markUsedOrientation(h,_,T){const F=_===i.WritingMode.horizontal||_===i.WritingMode.horizontalOnly?_:0,O=_===i.WritingMode.vertical?_:0,K=[T.leftJustifiedTextSymbolIndex,T.centerJustifiedTextSymbolIndex,T.rightJustifiedTextSymbolIndex];for(const oe of K)h.text.placedSymbolArray.get(oe).placedOrientation=F;T.verticalPlacedTextSymbolIndex&&(h.text.placedSymbolArray.get(T.verticalPlacedTextSymbolIndex).placedOrientation=O)}commit(h){this.commitTime=h,this.zoomAtLastRecencyCheck=this.transform.zoom;const _=this.prevPlacement;let T=!1;this.prevZoomAdjustment=_?_.zoomAdjustment(this.transform.zoom):0;const F=_?_.symbolFadeChange(h):1,O=_?_.opacities:{},K=_?_.variableOffsets:{},oe=_?_.placedOrientations:{};for(const ue in this.placements){const ve=this.placements[ue],Te=O[ue];Te?(this.opacities[ue]=new Qn(Te,F,ve.text,ve.icon),T=T||ve.text!==Te.text.placed||ve.icon!==Te.icon.placed):(this.opacities[ue]=new Qn(null,F,ve.text,ve.icon,ve.skipFade),T=T||ve.text||ve.icon)}for(const ue in O){const ve=O[ue];if(!this.opacities[ue]){const Te=new Qn(ve,F,!1,!1);Te.isHidden()||(this.opacities[ue]=Te,T=T||ve.text.placed||ve.icon.placed)}}for(const ue in K)this.variableOffsets[ue]||!this.opacities[ue]||this.opacities[ue].isHidden()||(this.variableOffsets[ue]=K[ue]);for(const ue in oe)this.placedOrientations[ue]||!this.opacities[ue]||this.opacities[ue].isHidden()||(this.placedOrientations[ue]=oe[ue]);if(_&&_.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");T?this.lastPlacementChangeTime=h:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=_?_.lastPlacementChangeTime:h)}updateLayerOpacities(h,_){const T={};for(const F of _){const O=F.getBucket(h);O&&F.latestFeatureIndex&&h.id===O.layerIds[0]&&this.updateBucketOpacities(O,T,F.collisionBoxArray)}}updateBucketOpacities(h,_,T){h.hasTextData()&&h.text.opacityVertexArray.clear(),h.hasIconData()&&h.icon.opacityVertexArray.clear(),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexArray.clear(),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexArray.clear();const F=h.layers[0].layout,O=new Qn(null,0,!1,!1,!0),K=F.get("text-allow-overlap"),oe=F.get("icon-allow-overlap"),ue=F.get("text-variable-anchor"),ve=F.get("text-rotation-alignment")==="map",Te=F.get("text-pitch-alignment")==="map",ke=F.get("icon-text-fit")!=="none",We=new Qn(null,0,K&&(oe||!h.hasIconData()||F.get("icon-optional")),oe&&(K||!h.hasTextData()||F.get("text-optional")),!0);!h.collisionArrays&&T&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(T);const bt=(mt,gt,Vt)=>{for(let Zt=0;Zt0,li=this.placedOrientations[gt.crossTileID],Ei=li===i.WritingMode.vertical,bi=li===i.WritingMode.horizontal||li===i.WritingMode.horizontalOnly;if(Vt>0||Zt>0){const Hi=pt(St.text);bt(h.text,Vt,Ei?Lt:Hi),bt(h.text,Zt,bi?Lt:Hi);const xi=St.text.isHidden();[gt.rightJustifiedTextSymbolIndex,gt.centerJustifiedTextSymbolIndex,gt.leftJustifiedTextSymbolIndex].forEach(Bn=>{Bn>=0&&(h.text.placedSymbolArray.get(Bn).hidden=xi||Ei?1:0)}),gt.verticalPlacedTextSymbolIndex>=0&&(h.text.placedSymbolArray.get(gt.verticalPlacedTextSymbolIndex).hidden=xi||bi?1:0);const xn=this.variableOffsets[gt.crossTileID];xn&&this.markUsedJustification(h,xn.anchor,gt,li);const cn=this.placedOrientations[gt.crossTileID];cn&&(this.markUsedJustification(h,"left",gt,cn),this.markUsedOrientation(h,cn,gt))}if(zt){const Hi=pt(St.icon),xi=!(ke&>.verticalPlacedIconSymbolIndex&&Ei);gt.placedIconSymbolIndex>=0&&(bt(h.icon,gt.numIconVertices,xi?Hi:Lt),h.icon.placedSymbolArray.get(gt.placedIconSymbolIndex).hidden=St.icon.isHidden()),gt.verticalPlacedIconSymbolIndex>=0&&(bt(h.icon,gt.numVerticalIconVertices,xi?Lt:Hi),h.icon.placedSymbolArray.get(gt.verticalPlacedIconSymbolIndex).hidden=St.icon.isHidden())}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const Hi=h.collisionArrays[mt];if(Hi){let xi=new i.pointGeometry(0,0);if(Hi.textBox||Hi.verticalTextBox){let cn=!0;if(ue){const Bn=this.variableOffsets[ni];Bn?(xi=ct(Bn.anchor,Bn.width,Bn.height,Bn.textOffset,Bn.textBoxScale),ve&&xi._rotate(Te?this.transform.angle:-this.transform.angle)):cn=!1}Hi.textBox&&j(h.textCollisionBox.collisionVertexArray,St.text.placed,!cn||Ei,xi.x,xi.y),Hi.verticalTextBox&&j(h.textCollisionBox.collisionVertexArray,St.text.placed,!cn||bi,xi.x,xi.y)}const xn=Boolean(!bi&&Hi.verticalIconBox);Hi.iconBox&&j(h.iconCollisionBox.collisionVertexArray,St.icon.placed,xn,ke?xi.x:0,ke?xi.y:0),Hi.verticalIconBox&&j(h.iconCollisionBox.collisionVertexArray,St.icon.placed,!xn,ke?xi.x:0,ke?xi.y:0)}}}if(h.sortFeatures(this.transform.angle),this.retainedQueryData[h.bucketInstanceId]&&(this.retainedQueryData[h.bucketInstanceId].featureSortOrder=h.featureSortOrder),h.hasTextData()&&h.text.opacityVertexBuffer&&h.text.opacityVertexBuffer.updateData(h.text.opacityVertexArray),h.hasIconData()&&h.icon.opacityVertexBuffer&&h.icon.opacityVertexBuffer.updateData(h.icon.opacityVertexArray),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexBuffer&&h.iconCollisionBox.collisionVertexBuffer.updateData(h.iconCollisionBox.collisionVertexArray),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexBuffer&&h.textCollisionBox.collisionVertexBuffer.updateData(h.textCollisionBox.collisionVertexArray),h.text.opacityVertexArray.length!==h.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${h.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${h.text.layoutVertexArray.length}) / 4`);if(h.icon.opacityVertexArray.length!==h.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${h.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${h.icon.layoutVertexArray.length}) / 4`);if(h.bucketInstanceId in this.collisionCircleArrays){const mt=this.collisionCircleArrays[h.bucketInstanceId];h.placementInvProjMatrix=mt.invProjMatrix,h.placementViewportMatrix=mt.viewportMatrix,h.collisionCircleArray=mt.circles,delete this.collisionCircleArrays[h.bucketInstanceId]}}symbolFadeChange(h){return this.fadeDuration===0?1:(h-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(h){return Math.max(0,(this.transform.zoom-h)/1.5)}hasTransitions(h){return this.stale||h-this.lastPlacementChangeTimeh}setStale(){this.stale=!0}}function j(M,h,_,T,F){M.emplaceBack(h?1:0,_?1:0,T||0,F||0),M.emplaceBack(h?1:0,_?1:0,T||0,F||0),M.emplaceBack(h?1:0,_?1:0,T||0,F||0),M.emplaceBack(h?1:0,_?1:0,T||0,F||0)}const ie=Math.pow(2,25),ne=Math.pow(2,24),de=Math.pow(2,17),Re=Math.pow(2,16),tt=Math.pow(2,9),He=Math.pow(2,8),Je=Math.pow(2,1);function pt(M){if(M.opacity===0&&!M.placed)return 0;if(M.opacity===1&&M.placed)return 4294967295;const h=M.placed?1:0,_=Math.floor(127*M.opacity);return _*ie+h*ne+_*de+h*Re+_*tt+h*He+_*Je+h}const Lt=0;class jt{constructor(h){this._sortAcrossTiles=h.layout.get("symbol-z-order")!=="viewport-y"&&!h.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(h,_,T,F,O){const K=this._bucketParts;for(;this._currentTileIndexoe.sortKey-ue.sortKey));this._currentPartIndex{const K=i.exported.now()-F;return!this._forceFullPlacement&&K>2};for(;this._currentPlacementIndex>=0;){const K=_[h[this._currentPlacementIndex]],oe=this.placement.collisionIndex.transform.zoom;if(K.type==="symbol"&&(!K.minzoom||K.minzoom<=oe)&&(!K.maxzoom||K.maxzoom>oe)){if(this._inProgressLayer||(this._inProgressLayer=new jt(K)),this._inProgressLayer.continuePlacement(T[K.source],this.placement,this._showCollisionBoxes,K,O))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const ki=512/i.EXTENT/2;class wi{constructor(h,_,T){this.tileID=h,this.indexedSymbolInstances={},this.bucketInstanceId=T;for(let F=0;F<_.length;F++){const O=_.get(F),K=O.key;this.indexedSymbolInstances[K]||(this.indexedSymbolInstances[K]=[]),this.indexedSymbolInstances[K].push({crossTileID:O.crossTileID,coord:this.getScaledCoordinates(O,h)})}}getScaledCoordinates(h,_){const T=ki/Math.pow(2,_.canonical.z-this.tileID.canonical.z);return{x:Math.floor((_.canonical.x*i.EXTENT+h.anchorX)*T),y:Math.floor((_.canonical.y*i.EXTENT+h.anchorY)*T)}}findMatches(h,_,T){const F=this.tileID.canonical.z<_.canonical.z?1:Math.pow(2,this.tileID.canonical.z-_.canonical.z);for(let O=0;Oh.overscaledZ)for(const oe in K){const ue=K[oe];ue.tileID.isChildOf(h)&&ue.findMatches(_.symbolInstances,h,F)}else{const oe=K[h.scaledTo(Number(O)).key];oe&&oe.findMatches(_.symbolInstances,h,F)}}for(let O=0;O<_.symbolInstances.length;O++){const K=_.symbolInstances.get(O);K.crossTileID||(K.crossTileID=T.generate(),F[K.crossTileID]=!0)}return this.indexes[h.overscaledZ]===void 0&&(this.indexes[h.overscaledZ]={}),this.indexes[h.overscaledZ][h.key]=new wi(h,_.symbolInstances,_.bucketInstanceId),!0}removeBucketCrossTileIDs(h,_){for(const T in _.indexedSymbolInstances)for(const F of _.indexedSymbolInstances[T])delete this.usedCrossTileIDs[h][F.crossTileID]}removeStaleBuckets(h){let _=!1;for(const T in this.indexes){const F=this.indexes[T];for(const O in F)h[F[O].bucketInstanceId]||(this.removeBucketCrossTileIDs(T,F[O]),delete F[O],_=!0)}return _}}class tn{constructor(){this.layerIndexes={},this.crossTileIDs=new Oi,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(h,_,T){let F=this.layerIndexes[h.id];F===void 0&&(F=this.layerIndexes[h.id]=new Yi);let O=!1;const K={};F.handleWrapJump(T);for(const oe of _){const ue=oe.getBucket(h);ue&&h.id===ue.layerIds[0]&&(ue.bucketInstanceId||(ue.bucketInstanceId=++this.maxBucketInstanceId),F.addBucket(oe.tileID,ue,this.crossTileIDs)&&(O=!0),K[ue.bucketInstanceId]=!0)}return F.removeStaleBuckets(K)&&(O=!0),O}pruneUnusedLayers(h){const _={};h.forEach(T=>{_[T]=!0});for(const T in this.layerIndexes)_[T]||delete this.layerIndexes[T]}}var rr=i.createLayout([{name:"a_pos",type:"Int16",components:2}]);class yn extends i.Evented{constructor(h){super(),this.sourceCache=h,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.renderHistory=[],this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,this.renderHistorySize=h._cache.max,h.usedForTerrain=!0,h.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;for(const h in this._tiles){const _=this._tiles[h];_.textures.forEach(T=>T.destroy()),_.textures=[]}}update(h,_){this.sourceCache.update(h,_),this._renderableTilesKeys=[];for(const T of h.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:_}))this._renderableTilesKeys.push(T.key),this._tiles[T.key]||(T.posMatrix=new Float64Array(16),i.ortho(T.posMatrix,0,i.EXTENT,0,i.EXTENT,0,1),this._tiles[T.key]=new Be(T,this.tileSize))}removeOutdated(h){const _={};this.renderHistory=this.renderHistory.filter((T,F)=>this.renderHistory.indexOf(T)===F).slice(0,this.renderHistorySize);for(const T of this._renderableTilesKeys)_[T]=!0;for(const T of this.renderHistory)_[T]=!0;for(const T in this._tiles)_[T]||(this._tiles[T].clearTextures(h),delete this._tiles[T])}getRenderableTiles(){return this._renderableTilesKeys.map(h=>this.getTileByID(h))}getTileByID(h){return this._tiles[h]}getTerrainCoords(h){const _={};for(const T of this._renderableTilesKeys){const F=this._tiles[T].tileID;if(F.canonical.equals(h.canonical)){const O=h.clone();O.posMatrix=new Float64Array(16),i.ortho(O.posMatrix,0,i.EXTENT,0,i.EXTENT,0,1),_[T]=O}else if(F.canonical.isChildOf(h.canonical)){const O=h.clone();O.posMatrix=new Float64Array(16);const K=F.canonical.z-h.canonical.z,oe=F.canonical.x-(F.canonical.x>>K<>K<>K;i.ortho(O.posMatrix,0,ve,0,ve,0,1),i.translate(O.posMatrix,O.posMatrix,[-oe*ve,-ue*ve,0]),_[T]=O}else if(h.canonical.isChildOf(F.canonical)){const O=h.clone();O.posMatrix=new Float64Array(16);const K=h.canonical.z-F.canonical.z,oe=h.canonical.x-(h.canonical.x>>K<>K<>K;i.ortho(O.posMatrix,0,i.EXTENT,0,i.EXTENT,0,1),i.translate(O.posMatrix,O.posMatrix,[oe*ve,ue*ve,0]),i.scale(O.posMatrix,O.posMatrix,[1/2**K,1/2**K,0]),_[T]=O}}return _}getSourceTile(h,_){const T=this.sourceCache._source;let F=h.overscaledZ-this.deltaZoom;if(F>T.maxzoom&&(F=T.maxzoom),F=T.minzoom&&(!O||!O.dem);)O=this.sourceCache.getTileByID(h.scaledTo(F--).key);return O}tilesAfterTime(h=Date.now()){return Object.values(this._tiles).filter(_=>_.timeLoaded>=h)}}class Yt{constructor(h,_,T){this.style=h,this.sourceCache=new yn(_),this.options=T,this.exaggeration=typeof T.exaggeration=="number"?T.exaggeration:1,this.elevationOffset=typeof T.elevationOffset=="number"?T.elevationOffset:450,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024,this.clearRerenderCache()}getDEMElevation(h,_,T,F=i.EXTENT){if(!(_>=0&&_=0&&Th.canonical.z&&(h.canonical.z>=F?O=h.canonical.z-F:i.warnOnce("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const K=h.canonical.x-(h.canonical.x>>O<>O<>8<<4|O>>8,_[K+3]=0;const T=new i.RGBAImage({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(_.buffer)),F=new Y(h,T,h.gl.RGBA,{premultiply:!1});return F.bind(h.gl.NEAREST,h.gl.CLAMP_TO_EDGE),this._coordsTexture=F,F}pointCoordinate(h){const _=new Uint8Array(4),T=this.style.map.painter,F=T.context,O=F.gl;F.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),O.readPixels(h.x,T.height/devicePixelRatio-h.y-1,1,1,O.RGBA,O.UNSIGNED_BYTE,_),F.bindFramebuffer.set(null);const K=_[0]+(_[2]>>4<<8),oe=_[1]+((15&_[2])<<8),ue=this.coordsIndex[255-_[3]],ve=ue&&this.sourceCache.getTileByID(ue);if(!ve)return null;const Te=this._coordsTextureSize,ke=(1<i.emitValidationErrors(M,h&&h.filter(_=>_.identifier!=="source.canvas")),Yn=i.pick(Qi,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData"]),Wr=i.pick(Qi,["setCenter","setZoom","setBearing","setPitch"]),mr=function(){const M={},h=i.spec.$version;for(const _ in i.spec.$root){const T=i.spec.$root[_];if(T.required){let F=null;F=_==="version"?h:T.type==="array"?[]:{},F!=null&&(M[_]=F)}}return M}();class Mr extends i.Evented{constructor(h,_={}){super(),this.map=h,this.dispatcher=new Et(fi(),this),this.imageManager=new ae,this.imageManager.setEventedParent(this),this.glyphManager=new me(h._requestManager,_.localIdeographFontFamily),this.lineAtlas=new Ke(256,512),this.crossTileSymbolIndex=new tn,this._layers={},this._serializedLayers={},this._order=[],this.sourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const T=this;this._rtlTextPluginCallback=Mr.registerForPluginStateChange(F=>{T.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:F.pluginStatus,pluginURL:F.pluginURL},(O,K)=>{if(i.triggerPluginCompletionEvent(O),K&&K.every(oe=>oe))for(const oe in T.sourceCaches)T.sourceCaches[oe].reload()})}),this.on("data",F=>{if(F.dataType!=="source"||F.sourceDataType!=="metadata")return;const O=this.sourceCaches[F.sourceId];if(!O)return;const K=O.getSource();if(K&&K.vectorLayerIds)for(const oe in this._layers){const ue=this._layers[oe];ue.source===K.id&&this._validateLayer(ue)}})}loadURL(h,_={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const T=typeof _.validate!="boolean"||_.validate,F=this.map._requestManager.transformRequest(h,i.ResourceType.Style);this._request=i.getJSON(F,(O,K)=>{this._request=null,O?this.fire(new i.ErrorEvent(O)):K&&this._load(K,T)})}loadJSON(h,_={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(h,_.validate!==!1)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(mr,!1)}_load(h,_){if(_&&sr(this,i.validateStyle(h)))return;this._loaded=!0,this.stylesheet=h;for(const F in h.sources)this.addSource(F,h.sources[F],{validate:!1});h.sprite?this._loadSprite(h.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(h.glyphs);const T=wn(this.stylesheet.layers);this._order=T.map(F=>F.id),this._layers={},this._serializedLayers={};for(let F of T)F=i.createStyleLayer(F),F.setEventedParent(this,{layer:{id:F.id}}),this._layers[F.id]=F,this._serializedLayers[F.id]=F.serialize();this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Me(this.stylesheet.light),this.setTerrain(this.stylesheet.terrain),this.fire(new i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}_loadSprite(h){this._spriteRequest=function(_,T,F,O){let K,oe,ue;const ve=F>1?"@2x":"";let Te=i.getJSON(T.transformRequest(T.normalizeSpriteURL(_,ve,".json"),i.ResourceType.SpriteJSON),(bt,mt)=>{Te=null,ue||(ue=bt,K=mt,We())}),ke=i.getImage(T.transformRequest(T.normalizeSpriteURL(_,ve,".png"),i.ResourceType.SpriteImage),(bt,mt)=>{ke=null,ue||(ue=bt,oe=mt,We())});function We(){if(ue)O(ue);else if(K&&oe){const bt=i.exported.getImageData(oe),mt={};for(const gt in K){const{width:Vt,height:Zt,x:ni,y:St,sdf:zt,pixelRatio:li,stretchX:Ei,stretchY:bi,content:Hi}=K[gt],xi=new i.RGBAImage({width:Vt,height:Zt});i.RGBAImage.copy(bt,xi,{x:ni,y:St},{x:0,y:0},{width:Vt,height:Zt}),mt[gt]={data:xi,pixelRatio:li,sdf:zt,stretchX:Ei,stretchY:bi,content:Hi}}O(null,mt)}}return{cancel(){Te&&(Te.cancel(),Te=null),ke&&(ke.cancel(),ke=null)}}}(h,this.map._requestManager,this.map.getPixelRatio(),(_,T)=>{if(this._spriteRequest=null,_)this.fire(new i.ErrorEvent(_));else if(T)for(const F in T)this.imageManager.addImage(F,T[F]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(h){const _=this.sourceCaches[h.source];if(!_)return;const T=h.sourceLayer;if(!T)return;const F=_.getSource();(F.type==="geojson"||F.vectorLayerIds&&F.vectorLayerIds.indexOf(T)===-1)&&this.fire(new i.ErrorEvent(new Error(`Source layer "${T}" does not exist on source "${F.id}" as specified by style layer "${h.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const h in this.sourceCaches)if(!this.sourceCaches[h].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(h){const _=[];for(const T of h){const F=this._layers[T];F.type!=="custom"&&_.push(F.serialize())}return _}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const h in this.sourceCaches)if(this.sourceCaches[h].hasTransition())return!0;for(const h in this._layers)if(this._layers[h].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(h){if(!this._loaded)return;const _=this._changed;if(this._changed){const F=Object.keys(this._updatedLayers),O=Object.keys(this._removedLayers);(F.length||O.length)&&this._updateWorkerLayers(F,O);for(const K in this._updatedSources){const oe=this._updatedSources[K];if(oe==="reload")this._reloadSource(K);else{if(oe!=="clear")throw new Error(`Invalid action ${oe}`);this._clearSource(K)}}this._updateTilesForChangedImages();for(const K in this._updatedPaintProps)this._layers[K].updateTransitions(h);this.light.updateTransitions(h),this._resetUpdates()}const T={};for(const F in this.sourceCaches){const O=this.sourceCaches[F];T[F]=O.used,O.used=!1}for(const F of this._order){const O=this._layers[F];O.recalculate(h,this._availableImages),!O.isHidden(h.zoom)&&O.source&&(this.sourceCaches[O.source].used=!0)}for(const F in T){const O=this.sourceCaches[F];T[F]!==O.used&&O.fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:F}))}this.light.recalculate(h),this.z=h.zoom,_&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const h=Object.keys(this._changedImages);if(h.length){for(const _ in this.sourceCaches)this.sourceCaches[_].reloadTilesForDependencies(["icons","patterns"],h);this._changedImages={}}}_updateWorkerLayers(h,_){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(h),removedIds:_})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setTerrain(h){if(this._checkLoaded(),this._terrainDataCallback&&this.off("data",this._terrainDataCallback),this._terrainfreezeElevationCallback&&this.map.off("freezeElevation",this._terrainfreezeElevationCallback),h){const _=this.sourceCaches[h.source];if(!_)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain=new Yt(this,_,h),this.map.transform.updateElevation(this.terrain),this._terrainfreezeElevationCallback=T=>{T.freeze?this.map.transform.freezeElevation=!0:(this.map.transform.freezeElevation=!1,this.map.transform.recalculateZoom(this.terrain))},this._terrainDataCallback=T=>{T.tile&&(T.sourceId===h.source?(this.map.transform.updateElevation(this.terrain),this.terrain.rememberForRerender(T.sourceId,T.tile.tileID)):T.source.type==="geojson"&&this.terrain.rememberForRerender(T.sourceId,T.tile.tileID))},this.on("data",this._terrainDataCallback),this.map.on("freezeElevation",this._terrainfreezeElevationCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.map.transform.updateElevation(this.terrain);this.map.fire(new i.Event("terrain",{terrain:h}))}setState(h){if(this._checkLoaded(),sr(this,i.validateStyle(h)))return!1;(h=i.clone$1(h)).layers=wn(h.layers);const _=function(F,O){if(!F)return[{command:Qi.setStyle,args:[O]}];let K=[];try{if(!N(F.version,O.version))return[{command:Qi.setStyle,args:[O]}];N(F.center,O.center)||K.push({command:Qi.setCenter,args:[O.center]}),N(F.zoom,O.zoom)||K.push({command:Qi.setZoom,args:[O.zoom]}),N(F.bearing,O.bearing)||K.push({command:Qi.setBearing,args:[O.bearing]}),N(F.pitch,O.pitch)||K.push({command:Qi.setPitch,args:[O.pitch]}),N(F.sprite,O.sprite)||K.push({command:Qi.setSprite,args:[O.sprite]}),N(F.glyphs,O.glyphs)||K.push({command:Qi.setGlyphs,args:[O.glyphs]}),N(F.transition,O.transition)||K.push({command:Qi.setTransition,args:[O.transition]}),N(F.light,O.light)||K.push({command:Qi.setLight,args:[O.light]});const oe={},ue=[];(function(Te,ke,We,bt){let mt;for(mt in ke=ke||{},Te=Te||{})Object.prototype.hasOwnProperty.call(Te,mt)&&(Object.prototype.hasOwnProperty.call(ke,mt)||kn(mt,We,bt));for(mt in ke)Object.prototype.hasOwnProperty.call(ke,mt)&&(Object.prototype.hasOwnProperty.call(Te,mt)?N(Te[mt],ke[mt])||(Te[mt].type==="geojson"&&ke[mt].type==="geojson"&&st(Te,ke,mt)?We.push({command:Qi.setGeoJSONSourceData,args:[mt,ke[mt].data]}):yt(mt,ke,We,bt)):Gn(mt,ke,We))})(F.sources,O.sources,ue,oe);const ve=[];F.layers&&F.layers.forEach(Te=>{oe[Te.source]?K.push({command:Qi.removeLayer,args:[Te.id]}):ve.push(Te)}),K=K.concat(ue),function(Te,ke,We){ke=ke||[];const bt=(Te=Te||[]).map(Ni),mt=ke.map(Ni),gt=Te.reduce(qi,{}),Vt=ke.reduce(qi,{}),Zt=bt.slice(),ni=Object.create(null);let St,zt,li,Ei,bi,Hi,xi;for(St=0,zt=0;St!(F.command in Wr));if(_.length===0)return!1;const T=_.filter(F=>!(F.command in Yn));if(T.length>0)throw new Error(`Unimplemented: ${T.map(F=>F.command).join(", ")}.`);return _.forEach(F=>{F.command!=="setTransition"&&this[F.command].apply(this,F.args)}),this.stylesheet=h,!0}addImage(h,_){if(this.getImage(h))return this.fire(new i.ErrorEvent(new Error(`An image named "${h}" already exists.`)));this.imageManager.addImage(h,_),this._afterImageUpdated(h)}updateImage(h,_){this.imageManager.updateImage(h,_)}getImage(h){return this.imageManager.getImage(h)}removeImage(h){if(!this.getImage(h))return this.fire(new i.ErrorEvent(new Error(`An image named "${h}" does not exist.`)));this.imageManager.removeImage(h),this._afterImageUpdated(h)}_afterImageUpdated(h){this._availableImages=this.imageManager.listImages(),this._changedImages[h]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(h,_,T={}){if(this._checkLoaded(),this.sourceCaches[h]!==void 0)throw new Error(`Source "${h}" already exists.`);if(!_.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(_).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(_.type)>=0&&this._validate(i.validateStyle.source,`sources.${h}`,_,null,T))return;this.map&&this.map._collectResourceTiming&&(_.collectResourceTiming=!0);const F=this.sourceCaches[h]=new Qt(h,_,this.dispatcher);F.style=this,F.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:F.serialize(),sourceId:h})),F.onAdd(this.map),this._changed=!0}removeSource(h){if(this._checkLoaded(),this.sourceCaches[h]===void 0)throw new Error("There is no source with this ID");for(const T in this._layers)if(this._layers[T].source===h)return this.fire(new i.ErrorEvent(new Error(`Source "${h}" cannot be removed while layer "${T}" is using it.`)));const _=this.sourceCaches[h];delete this.sourceCaches[h],delete this._updatedSources[h],_.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:h})),_.setEventedParent(null),_.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(h,_){if(this._checkLoaded(),this.sourceCaches[h]===void 0)throw new Error(`There is no source with this ID=${h}`);const T=this.sourceCaches[h].getSource();if(T.type!=="geojson")throw new Error(`geojsonSource.type is ${T.type}, which is !== 'geojson`);T.setData(_),this._changed=!0}getSource(h){return this.sourceCaches[h]&&this.sourceCaches[h].getSource()}addLayer(h,_,T={}){this._checkLoaded();const F=h.id;if(this.getLayer(F))return void this.fire(new i.ErrorEvent(new Error(`Layer "${F}" already exists on this map.`)));let O;if(h.type==="custom"){if(sr(this,i.validateCustomStyleLayer(h)))return;O=i.createStyleLayer(h)}else{if(typeof h.source=="object"&&(this.addSource(F,h.source),h=i.clone$1(h),h=i.extend(h,{source:F})),this._validate(i.validateStyle.layer,`layers.${F}`,h,{arrayIndex:-1},T))return;O=i.createStyleLayer(h),this._validateLayer(O),O.setEventedParent(this,{layer:{id:F}}),this._serializedLayers[O.id]=O.serialize()}const K=_?this._order.indexOf(_):this._order.length;if(_&&K===-1)this.fire(new i.ErrorEvent(new Error(`Cannot add layer "${F}" before non-existing layer "${_}".`)));else{if(this._order.splice(K,0,F),this._layerOrderChanged=!0,this._layers[F]=O,this._removedLayers[F]&&O.source&&O.type!=="custom"){const oe=this._removedLayers[F];delete this._removedLayers[F],oe.type!==O.type?this._updatedSources[O.source]="clear":(this._updatedSources[O.source]="reload",this.sourceCaches[O.source].pause())}this._updateLayer(O),O.onAdd&&O.onAdd(this.map)}}moveLayer(h,_){if(this._checkLoaded(),this._changed=!0,!this._layers[h])return void this.fire(new i.ErrorEvent(new Error(`The layer '${h}' does not exist in the map's style and cannot be moved.`)));if(h===_)return;const T=this._order.indexOf(h);this._order.splice(T,1);const F=_?this._order.indexOf(_):this._order.length;_&&F===-1?this.fire(new i.ErrorEvent(new Error(`Cannot move layer "${h}" before non-existing layer "${_}".`))):(this._order.splice(F,0,h),this._layerOrderChanged=!0)}removeLayer(h){this._checkLoaded();const _=this._layers[h];if(!_)return void this.fire(new i.ErrorEvent(new Error(`Cannot remove non-existing layer "${h}".`)));_.setEventedParent(null);const T=this._order.indexOf(h);this._order.splice(T,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[h]=_,delete this._layers[h],delete this._serializedLayers[h],delete this._updatedLayers[h],delete this._updatedPaintProps[h],_.onRemove&&_.onRemove(this.map)}getLayer(h){return this._layers[h]}hasLayer(h){return h in this._layers}setLayerZoomRange(h,_,T){this._checkLoaded();const F=this.getLayer(h);F?F.minzoom===_&&F.maxzoom===T||(_!=null&&(F.minzoom=_),T!=null&&(F.maxzoom=T),this._updateLayer(F)):this.fire(new i.ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer "${h}".`)))}setFilter(h,_,T={}){this._checkLoaded();const F=this.getLayer(h);if(F){if(!N(F.filter,_))return _==null?(F.filter=void 0,void this._updateLayer(F)):void(this._validate(i.validateStyle.filter,`layers.${F.id}.filter`,_,null,T)||(F.filter=i.clone$1(_),this._updateLayer(F)))}else this.fire(new i.ErrorEvent(new Error(`Cannot filter non-existing layer "${h}".`)))}getFilter(h){return i.clone$1(this.getLayer(h).filter)}setLayoutProperty(h,_,T,F={}){this._checkLoaded();const O=this.getLayer(h);O?N(O.getLayoutProperty(_),T)||(O.setLayoutProperty(_,T,F),this._updateLayer(O)):this.fire(new i.ErrorEvent(new Error(`Cannot style non-existing layer "${h}".`)))}getLayoutProperty(h,_){const T=this.getLayer(h);if(T)return T.getLayoutProperty(_);this.fire(new i.ErrorEvent(new Error(`Cannot get style of non-existing layer "${h}".`)))}setPaintProperty(h,_,T,F={}){this._checkLoaded();const O=this.getLayer(h);O?N(O.getPaintProperty(_),T)||(O.setPaintProperty(_,T,F)&&this._updateLayer(O),this._changed=!0,this._updatedPaintProps[h]=!0):this.fire(new i.ErrorEvent(new Error(`Cannot style non-existing layer "${h}".`)))}getPaintProperty(h,_){return this.getLayer(h).getPaintProperty(_)}setFeatureState(h,_){this._checkLoaded();const T=h.source,F=h.sourceLayer,O=this.sourceCaches[T];if(O===void 0)return void this.fire(new i.ErrorEvent(new Error(`The source '${T}' does not exist in the map's style.`)));const K=O.getSource().type;K==="geojson"&&F?this.fire(new i.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):K!=="vector"||F?(h.id===void 0&&this.fire(new i.ErrorEvent(new Error("The feature id parameter must be provided."))),O.setFeatureState(F,h.id,_)):this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(h,_){this._checkLoaded();const T=h.source,F=this.sourceCaches[T];if(F===void 0)return void this.fire(new i.ErrorEvent(new Error(`The source '${T}' does not exist in the map's style.`)));const O=F.getSource().type,K=O==="vector"?h.sourceLayer:void 0;O!=="vector"||K?_&&typeof h.id!="string"&&typeof h.id!="number"?this.fire(new i.ErrorEvent(new Error("A feature id is required to remove its specific state property."))):F.removeFeatureState(K,h.id,_):this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(h){this._checkLoaded();const _=h.source,T=h.sourceLayer,F=this.sourceCaches[_];if(F!==void 0)return F.getSource().type!=="vector"||T?(h.id===void 0&&this.fire(new i.ErrorEvent(new Error("The feature id parameter must be provided."))),F.getFeatureState(T,h.id)):void this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new i.ErrorEvent(new Error(`The source '${_}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){return i.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,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,sources:i.mapObject(this.sourceCaches,h=>h.serialize()),layers:this._serializeLayers(this._order)},h=>h!==void 0)}_updateLayer(h){this._updatedLayers[h.id]=!0,h.source&&!this._updatedSources[h.source]&&this.sourceCaches[h.source].getSource().type!=="raster"&&(this._updatedSources[h.source]="reload",this.sourceCaches[h.source].pause()),this._changed=!0}_flattenAndSortRenderedFeatures(h){const _=K=>this._layers[K].type==="fill-extrusion",T={},F=[];for(let K=this._order.length-1;K>=0;K--){const oe=this._order[K];if(_(oe)){T[oe]=K;for(const ue of h){const ve=ue[oe];if(ve)for(const Te of ve)F.push(Te)}}}F.sort((K,oe)=>oe.intersectionZ-K.intersectionZ);const O=[];for(let K=this._order.length-1;K>=0;K--){const oe=this._order[K];if(_(oe))for(let ue=F.length-1;ue>=0;ue--){const ve=F[ue].feature;if(T[ve.layer.id]{const bi=Vt.featureSortOrder;if(bi){const Hi=bi.indexOf(li.featureIndex);return bi.indexOf(Ei.featureIndex)-Hi}return Ei.featureIndex-li.featureIndex});for(const li of zt)St.push(li)}}for(const Vt in bt)bt[Vt].forEach(Zt=>{const ni=Zt.feature,St=ue[K[Vt].source].getFeatureState(ni.layer["source-layer"],ni.id);ni.source=ni.layer.source,ni.layer["source-layer"]&&(ni.sourceLayer=ni.layer["source-layer"]),ni.state=St});return bt}(this._layers,this._serializedLayers,this.sourceCaches,h,_,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(O)}querySourceFeatures(h,_){_&&_.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",_.filter,null,_);const T=this.sourceCaches[h];return T?function(F,O){const K=F.getRenderableIds().map(ve=>F.getTileByID(ve)),oe=[],ue={};for(let ve=0;veWe.getTileByID(bt)).sort((bt,mt)=>mt.tileID.overscaledZ-bt.tileID.overscaledZ||(bt.tileID.isLessThan(mt.tileID)?-1:1))}const ke=this.crossTileSymbolIndex.addLayer(Te,ue[Te.source],h.center.lng);K=K||ke}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((O=O||this._layerOrderChanged||T===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),h.zoom))&&(this.pauseablePlacement=new Gt(h,this.terrain,this._order,O,_,T,F,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,ue),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),oe=!0),K&&this.pauseablePlacement.placement.setStale()),oe||K)for(const ve of this._order){const Te=this._layers[ve];Te.type==="symbol"&&this.placement.updateLayerOpacities(Te,ue[Te.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const h in this.sourceCaches)this.sourceCaches[h].releaseSymbolFadeTiles()}getImages(h,_,T){this.imageManager.getImages(_.icons,T),this._updateTilesForChangedImages();const F=this.sourceCaches[_.source];F&&F.setDependencies(_.tileID.key,_.type,_.icons)}getGlyphs(h,_,T){this.glyphManager.getGlyphs(_.stacks,T)}getResource(h,_,T){return i.makeRequest(_,T)}}Mr.getSourceType=function(M){return Ie[M]},Mr.setSourceType=function(M,h){Ie[M]=h},Mr.registerForPluginStateChange=i.registerForPluginStateChange;var Oo="attribute vec2 a_pos;uniform mat4 u_matrix;varying vec2 v_texture_pos;varying float v_depth;void main() {v_texture_pos=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);v_depth=gl_Position.z/gl_Position.w;}";const ks={prelude:or(`#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`,`#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 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;} #ifdef TERRAIN3D uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_offset;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth; #endif const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) { #ifdef TERRAIN3D highp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0)); #else return 1.0; #endif }float calculate_visibility(vec4 pos) { #ifdef TERRAIN3D vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0; #else return 1.0; #endif }float ele(vec2 pos) { #ifdef TERRAIN3D vec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a; #else return 0.0; #endif }float get_elevation(vec2 pos) { #ifdef TERRAIN3D vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return (elevation+u_terrain_offset)*u_terrain_exaggeration; #else return 0.0; #endif }`),background:or(`uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:or(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:or(`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));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;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(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);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:or("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:or(`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 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;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;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}`),heatmapTexture:or(`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 }`,"uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:or("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;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_anchor_pos,0,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,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:or("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;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;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:or("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;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:or(`#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_FragColor=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);}`),fillOutline:or(`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);gl_FragColor=outline_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;}`),fillOutlinePattern:or(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*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 vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillPattern:or(`#ifdef GL_ES precision highp float; #endif uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*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 vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:or(`varying vec4 v_color;void main() {gl_FragColor=v_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;attribute vec2 a_pos;attribute vec4 a_normal_ed; #ifdef TERRAIN3D attribute vec2 a_centroid; #endif varying vec4 v_color; #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 vec3 normal=a_normal_ed.xyz; #ifdef TERRAIN3D float baseDelta=10.0;float ele=get_elevation(a_centroid); #else float baseDelta=0.0;float ele=0.0; #endif base=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:or(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting; #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 vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed; #ifdef TERRAIN3D attribute vec2 a_centroid; #endif varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to; #ifdef TERRAIN3D float baseDelta=10.0;float ele=get_elevation(a_centroid); #else float baseDelta=0.0;float ele=0.0; #endif base=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0 ? a_pos : vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:or(`#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,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/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:or(`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; #define PI 3.141592653589793 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 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;}"),line:or(`uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #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);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;uniform mat4 u_matrix;uniform mediump float u_ratio;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 float v_linesofar; #pragma mapbox: define highp vec4 color #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 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;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else 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; #endif v_width2=vec2(outset,inset);}`),lineGradient:or(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #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);vec4 color=texture2D(u_image,v_uv);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_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv; #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 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;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else 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; #endif v_width2=vec2(outset,inset);}`),linePattern:or(`#ifdef GL_ES precision highp float; #endif uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;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_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to 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_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to 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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else 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; #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:or(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth 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 sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #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 #pragma mapbox: define lowp float floorwidth void main() { #pragma mapbox: initialize highp vec4 color #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 #pragma mapbox: initialize lowp float floorwidth 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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else 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; #endif v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:or(`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);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*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 float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:or(`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 }`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_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;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_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.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,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:or(`#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 }`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;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_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.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,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:or(`#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 }`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;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_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.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,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:or("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",Oo),terrainDepth:or("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",Oo),terrainCoords:or("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",Oo)};function or(M,h){const _=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,T=h.match(/attribute ([\w]+) ([\w]+)/g),F=M.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),O=h.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),K=O?O.concat(F):F,oe={};return{fragmentSource:M=M.replace(_,(ue,ve,Te,ke,We)=>(oe[We]=!0,ve==="define"?` #ifndef HAS_UNIFORM_u_${We} varying ${Te} ${ke} ${We}; #else uniform ${Te} ${ke} u_${We}; #endif `:` #ifdef HAS_UNIFORM_u_${We} ${Te} ${ke} ${We} = u_${We}; #endif `)),vertexSource:h=h.replace(_,(ue,ve,Te,ke,We)=>{const bt=ke==="float"?"vec2":"vec4",mt=We.match(/color/)?"color":bt;return oe[We]?ve==="define"?` #ifndef HAS_UNIFORM_u_${We} uniform lowp float u_${We}_t; attribute ${Te} ${bt} a_${We}; varying ${Te} ${ke} ${We}; #else uniform ${Te} ${ke} u_${We}; #endif `:mt==="vec4"?` #ifndef HAS_UNIFORM_u_${We} ${We} = a_${We}; #else ${Te} ${ke} ${We} = u_${We}; #endif `:` #ifndef HAS_UNIFORM_u_${We} ${We} = unpack_mix_${mt}(a_${We}, u_${We}_t); #else ${Te} ${ke} ${We} = u_${We}; #endif `:ve==="define"?` #ifndef HAS_UNIFORM_u_${We} uniform lowp float u_${We}_t; attribute ${Te} ${bt} a_${We}; #else uniform ${Te} ${ke} u_${We}; #endif `:mt==="vec4"?` #ifndef HAS_UNIFORM_u_${We} ${Te} ${ke} ${We} = a_${We}; #else ${Te} ${ke} ${We} = u_${We}; #endif `:` #ifndef HAS_UNIFORM_u_${We} ${Te} ${ke} ${We} = unpack_mix_${mt}(a_${We}, u_${We}_t); #else ${Te} ${ke} ${We} = u_${We}; #endif `}),staticAttributes:T,staticUniforms:K}}class rn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(h,_,T,F,O,K,oe,ue,ve){this.context=h;let Te=this.boundPaintVertexBuffers.length!==F.length;for(let ke=0;!Te&&ke({u_depth:new i.Uniform1i(bi,Hi.u_depth),u_terrain:new i.Uniform1i(bi,Hi.u_terrain),u_terrain_dim:new i.Uniform1f(bi,Hi.u_terrain_dim),u_terrain_matrix:new i.UniformMatrix4f(bi,Hi.u_terrain_matrix),u_terrain_unpack:new i.Uniform4f(bi,Hi.u_terrain_unpack),u_terrain_offset:new i.Uniform1f(bi,Hi.u_terrain_offset),u_terrain_exaggeration:new i.Uniform1f(bi,Hi.u_terrain_exaggeration)}))(h,Ei),this.binderUniforms=F?F.getUniforms(h,Ei):[]}draw(h,_,T,F,O,K,oe,ue,ve,Te,ke,We,bt,mt,gt,Vt,Zt,ni){const St=h.gl;if(this.failedToCreate)return;if(h.program.set(this.program),h.setDepthMode(T),h.setStencilMode(F),h.setColorMode(O),h.setCullFace(K),ue){h.activeTexture.set(St.TEXTURE2),St.bindTexture(St.TEXTURE_2D,ue.depthTexture),h.activeTexture.set(St.TEXTURE3),St.bindTexture(St.TEXTURE_2D,ue.texture);for(const li in this.terrainUniforms)this.terrainUniforms[li].set(ue[li])}for(const li in this.fixedUniforms)this.fixedUniforms[li].set(oe[li]);gt&>.setUniforms(h,this.binderUniforms,bt,{zoom:mt});let zt=0;switch(_){case St.LINES:zt=2;break;case St.TRIANGLES:zt=3;break;case St.LINE_STRIP:zt=1}for(const li of We.get()){const Ei=li.vaos||(li.vaos={});(Ei[ve]||(Ei[ve]=new rn)).bind(h,this,Te,gt?gt.getPaintVertexBuffers():[],ke,li.vertexOffset,Vt,Zt,ni),St.drawElements(_,li.primitiveLength*zt,St.UNSIGNED_SHORT,li.primitiveOffset*zt*2)}}}function la(M,h,_){const T=1/fr(_,1,h.transform.tileZoom),F=Math.pow(2,_.tileID.overscaledZ),O=_.tileSize*Math.pow(2,h.transform.tileZoom)/F,K=O*(_.tileID.canonical.x+_.tileID.wrap*F),oe=O*_.tileID.canonical.y;return{u_image:0,u_texsize:_.imageAtlasTexture.size,u_scale:[T,M.fromScale,M.toScale],u_fade:M.t,u_pixel_coord_upper:[K>>16,oe>>16],u_pixel_coord_lower:[65535&K,65535&oe]}}const al=(M,h,_,T)=>{const F=h.style.light,O=F.properties.get("position"),K=[O.x,O.y,O.z],oe=i.create$1();F.properties.get("anchor")==="viewport"&&i.fromRotation(oe,-h.transform.angle),i.transformMat3(K,K,oe);const ue=F.properties.get("color");return{u_matrix:M,u_lightpos:K,u_lightintensity:F.properties.get("intensity"),u_lightcolor:[ue.r,ue.g,ue.b],u_vertical_gradient:+_,u_opacity:T}},dr=(M,h,_,T,F,O,K)=>i.extend(al(M,h,_,T),la(O,h,K),{u_height_factor:-Math.pow(2,F.overscaledZ)/K.tileSize/8}),Ul=M=>({u_matrix:M}),Rl=(M,h,_,T)=>i.extend(Ul(M),la(_,h,T)),ll=(M,h)=>({u_matrix:M,u_world:h}),qs=(M,h,_,T,F)=>i.extend(Rl(M,h,_,T),{u_world:F}),hs=(M,h,_,T)=>{const F=M.transform;let O,K;if(T.paint.get("circle-pitch-alignment")==="map"){const oe=fr(_,1,F.zoom);O=!0,K=[oe,oe]}else O=!1,K=F.pixelsToGLUnits;return{u_camera_to_center_distance:F.cameraToCenterDistance,u_scale_with_map:+(T.paint.get("circle-pitch-scale")==="map"),u_matrix:M.translatePosMatrix(h.posMatrix,_,T.paint.get("circle-translate"),T.paint.get("circle-translate-anchor")),u_pitch_with_map:+O,u_device_pixel_ratio:M.pixelRatio,u_extrude_scale:K}},ho=(M,h,_)=>{const T=fr(_,1,h.zoom),F=Math.pow(2,h.zoom-_.tileID.overscaledZ),O=_.tileID.overscaleFactor();return{u_matrix:M,u_camera_to_center_distance:h.cameraToCenterDistance,u_pixels_to_tile_units:T,u_extrude_scale:[h.pixelsToGLUnits[0]/(T*F),h.pixelsToGLUnits[1]/(T*F)],u_overscale_factor:O}},cl=(M,h,_=1)=>({u_matrix:M,u_color:h,u_overlay:0,u_overlay_scale:_}),Na=M=>({u_matrix:M}),zl=(M,h,_,T)=>({u_matrix:M,u_extrude_scale:fr(h,1,_),u_intensity:T});function kl(M,h){const _=Math.pow(2,h.canonical.z),T=h.canonical.y;return[new i.MercatorCoordinate(0,T/_).toLngLat().lat,new i.MercatorCoordinate(0,(T+1)/_).toLngLat().lat]}const Ol=(M,h,_,T)=>{const F=M.transform;return{u_matrix:Ys(M,h,_,T),u_ratio:1/fr(h,1,F.zoom),u_device_pixel_ratio:M.pixelRatio,u_units_to_pixels:[1/F.pixelsToGLUnits[0],1/F.pixelsToGLUnits[1]]}},Qa=(M,h,_,T,F)=>i.extend(Ol(M,h,_,F),{u_image:0,u_image_height:T}),Nl=(M,h,_,T,F)=>{const O=M.transform,K=ns(h,O);return{u_matrix:Ys(M,h,_,F),u_texsize:h.imageAtlasTexture.size,u_ratio:1/fr(h,1,O.zoom),u_device_pixel_ratio:M.pixelRatio,u_image:0,u_scale:[K,T.fromScale,T.toScale],u_fade:T.t,u_units_to_pixels:[1/O.pixelsToGLUnits[0],1/O.pixelsToGLUnits[1]]}},Ql=(M,h,_,T,F,O)=>{const K=M.lineAtlas,oe=ns(h,M.transform),ue=_.layout.get("line-cap")==="round",ve=K.getDash(T.from,ue),Te=K.getDash(T.to,ue),ke=ve.width*F.fromScale,We=Te.width*F.toScale;return i.extend(Ol(M,h,_,O),{u_patternscale_a:[oe/ke,-ve.height/2],u_patternscale_b:[oe/We,-Te.height/2],u_sdfgamma:K.width/(256*Math.min(ke,We)*M.pixelRatio)/2,u_image:0,u_tex_y_a:ve.y,u_tex_y_b:Te.y,u_mix:F.t})};function ns(M,h){return 1/fr(M,1,h.tileZoom)}function Ys(M,h,_,T){return M.translatePosMatrix(T?T.posMatrix:h.tileID.posMatrix,h,_.paint.get("line-translate"),_.paint.get("line-translate-anchor"))}const fs=(M,h,_,T,F)=>{return{u_matrix:M,u_tl_parent:h,u_scale_parent:_,u_buffer_scale:1,u_fade_t:T.mix,u_opacity:T.opacity*F.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:F.paint.get("raster-brightness-min"),u_brightness_high:F.paint.get("raster-brightness-max"),u_saturation_factor:(K=F.paint.get("raster-saturation"),K>0?1-1/(1.001-K):-K),u_contrast_factor:(O=F.paint.get("raster-contrast"),O>0?1/(1-O):1+O),u_spin_weights:Rc(F.paint.get("raster-hue-rotate"))};var O,K};function Rc(M){M*=Math.PI/180;const h=Math.sin(M),_=Math.cos(M);return[(2*_+1)/3,(-Math.sqrt(3)*h-_+1)/3,(Math.sqrt(3)*h-_+1)/3]}const Eh=(M,h,_,T,F,O,K,oe,ue,ve)=>{const Te=F.transform;return{u_is_size_zoom_constant:+(M==="constant"||M==="source"),u_is_size_feature_constant:+(M==="constant"||M==="camera"),u_size_t:h?h.uSizeT:0,u_size:h?h.uSize:0,u_camera_to_center_distance:Te.cameraToCenterDistance,u_pitch:Te.pitch/360*2*Math.PI,u_rotate_symbol:+_,u_aspect_ratio:Te.width/Te.height,u_fade_change:F.options.fadeDuration?F.symbolFadeChange:1,u_matrix:O,u_label_plane_matrix:K,u_coord_matrix:oe,u_is_text:+ue,u_pitch_with_map:+T,u_texsize:ve,u_texture:0}},Os=(M,h,_,T,F,O,K,oe,ue,ve,Te)=>{const ke=F.transform;return i.extend(Eh(M,h,_,T,F,O,K,oe,ue,ve),{u_gamma_scale:T?Math.cos(ke._pitch)*ke.cameraToCenterDistance:1,u_device_pixel_ratio:F.pixelRatio,u_is_halo:+Te})},No=(M,h,_,T,F,O,K,oe,ue,ve)=>i.extend(Os(M,h,_,T,F,O,K,oe,!0,ue,!0),{u_texsize_icon:ve,u_texture_icon:1}),ed=(M,h,_)=>({u_matrix:M,u_opacity:h,u_color:_}),pu=(M,h,_,T,F,O)=>i.extend(function(K,oe,ue,ve){const Te=ue.imageManager.getPattern(K.from.toString()),ke=ue.imageManager.getPattern(K.to.toString()),{width:We,height:bt}=ue.imageManager.getPixelSize(),mt=Math.pow(2,ve.tileID.overscaledZ),gt=ve.tileSize*Math.pow(2,ue.transform.tileZoom)/mt,Vt=gt*(ve.tileID.canonical.x+ve.tileID.wrap*mt),Zt=gt*ve.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:Te.tl,u_pattern_br_a:Te.br,u_pattern_tl_b:ke.tl,u_pattern_br_b:ke.br,u_texsize:[We,bt],u_mix:oe.t,u_pattern_size_a:Te.displaySize,u_pattern_size_b:ke.displaySize,u_scale_a:oe.fromScale,u_scale_b:oe.toScale,u_tile_units_to_pixels:1/fr(ve,1,ue.transform.tileZoom),u_pixel_coord_upper:[Vt>>16,Zt>>16],u_pixel_coord_lower:[65535&Vt,65535&Zt]}}(T,O,_,F),{u_matrix:M,u_opacity:h}),Cs={fillExtrusion:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_lightpos:new i.Uniform3f(M,h.u_lightpos),u_lightintensity:new i.Uniform1f(M,h.u_lightintensity),u_lightcolor:new i.Uniform3f(M,h.u_lightcolor),u_vertical_gradient:new i.Uniform1f(M,h.u_vertical_gradient),u_opacity:new i.Uniform1f(M,h.u_opacity)}),fillExtrusionPattern:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_lightpos:new i.Uniform3f(M,h.u_lightpos),u_lightintensity:new i.Uniform1f(M,h.u_lightintensity),u_lightcolor:new i.Uniform3f(M,h.u_lightcolor),u_vertical_gradient:new i.Uniform1f(M,h.u_vertical_gradient),u_height_factor:new i.Uniform1f(M,h.u_height_factor),u_image:new i.Uniform1i(M,h.u_image),u_texsize:new i.Uniform2f(M,h.u_texsize),u_pixel_coord_upper:new i.Uniform2f(M,h.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(M,h.u_pixel_coord_lower),u_scale:new i.Uniform3f(M,h.u_scale),u_fade:new i.Uniform1f(M,h.u_fade),u_opacity:new i.Uniform1f(M,h.u_opacity)}),fill:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix)}),fillPattern:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_image:new i.Uniform1i(M,h.u_image),u_texsize:new i.Uniform2f(M,h.u_texsize),u_pixel_coord_upper:new i.Uniform2f(M,h.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(M,h.u_pixel_coord_lower),u_scale:new i.Uniform3f(M,h.u_scale),u_fade:new i.Uniform1f(M,h.u_fade)}),fillOutline:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_world:new i.Uniform2f(M,h.u_world)}),fillOutlinePattern:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_world:new i.Uniform2f(M,h.u_world),u_image:new i.Uniform1i(M,h.u_image),u_texsize:new i.Uniform2f(M,h.u_texsize),u_pixel_coord_upper:new i.Uniform2f(M,h.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(M,h.u_pixel_coord_lower),u_scale:new i.Uniform3f(M,h.u_scale),u_fade:new i.Uniform1f(M,h.u_fade)}),circle:(M,h)=>({u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_scale_with_map:new i.Uniform1i(M,h.u_scale_with_map),u_pitch_with_map:new i.Uniform1i(M,h.u_pitch_with_map),u_extrude_scale:new i.Uniform2f(M,h.u_extrude_scale),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_matrix:new i.UniformMatrix4f(M,h.u_matrix)}),collisionBox:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_pixels_to_tile_units:new i.Uniform1f(M,h.u_pixels_to_tile_units),u_extrude_scale:new i.Uniform2f(M,h.u_extrude_scale),u_overscale_factor:new i.Uniform1f(M,h.u_overscale_factor)}),collisionCircle:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_inv_matrix:new i.UniformMatrix4f(M,h.u_inv_matrix),u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_viewport_size:new i.Uniform2f(M,h.u_viewport_size)}),debug:(M,h)=>({u_color:new i.UniformColor(M,h.u_color),u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_overlay:new i.Uniform1i(M,h.u_overlay),u_overlay_scale:new i.Uniform1f(M,h.u_overlay_scale)}),clippingMask:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix)}),heatmap:(M,h)=>({u_extrude_scale:new i.Uniform1f(M,h.u_extrude_scale),u_intensity:new i.Uniform1f(M,h.u_intensity),u_matrix:new i.UniformMatrix4f(M,h.u_matrix)}),heatmapTexture:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_world:new i.Uniform2f(M,h.u_world),u_image:new i.Uniform1i(M,h.u_image),u_color_ramp:new i.Uniform1i(M,h.u_color_ramp),u_opacity:new i.Uniform1f(M,h.u_opacity)}),hillshade:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_image:new i.Uniform1i(M,h.u_image),u_latrange:new i.Uniform2f(M,h.u_latrange),u_light:new i.Uniform2f(M,h.u_light),u_shadow:new i.UniformColor(M,h.u_shadow),u_highlight:new i.UniformColor(M,h.u_highlight),u_accent:new i.UniformColor(M,h.u_accent)}),hillshadePrepare:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_image:new i.Uniform1i(M,h.u_image),u_dimension:new i.Uniform2f(M,h.u_dimension),u_zoom:new i.Uniform1f(M,h.u_zoom),u_unpack:new i.Uniform4f(M,h.u_unpack)}),line:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_ratio:new i.Uniform1f(M,h.u_ratio),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_units_to_pixels:new i.Uniform2f(M,h.u_units_to_pixels)}),lineGradient:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_ratio:new i.Uniform1f(M,h.u_ratio),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_units_to_pixels:new i.Uniform2f(M,h.u_units_to_pixels),u_image:new i.Uniform1i(M,h.u_image),u_image_height:new i.Uniform1f(M,h.u_image_height)}),linePattern:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_texsize:new i.Uniform2f(M,h.u_texsize),u_ratio:new i.Uniform1f(M,h.u_ratio),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_image:new i.Uniform1i(M,h.u_image),u_units_to_pixels:new i.Uniform2f(M,h.u_units_to_pixels),u_scale:new i.Uniform3f(M,h.u_scale),u_fade:new i.Uniform1f(M,h.u_fade)}),lineSDF:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_ratio:new i.Uniform1f(M,h.u_ratio),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_units_to_pixels:new i.Uniform2f(M,h.u_units_to_pixels),u_patternscale_a:new i.Uniform2f(M,h.u_patternscale_a),u_patternscale_b:new i.Uniform2f(M,h.u_patternscale_b),u_sdfgamma:new i.Uniform1f(M,h.u_sdfgamma),u_image:new i.Uniform1i(M,h.u_image),u_tex_y_a:new i.Uniform1f(M,h.u_tex_y_a),u_tex_y_b:new i.Uniform1f(M,h.u_tex_y_b),u_mix:new i.Uniform1f(M,h.u_mix)}),raster:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_tl_parent:new i.Uniform2f(M,h.u_tl_parent),u_scale_parent:new i.Uniform1f(M,h.u_scale_parent),u_buffer_scale:new i.Uniform1f(M,h.u_buffer_scale),u_fade_t:new i.Uniform1f(M,h.u_fade_t),u_opacity:new i.Uniform1f(M,h.u_opacity),u_image0:new i.Uniform1i(M,h.u_image0),u_image1:new i.Uniform1i(M,h.u_image1),u_brightness_low:new i.Uniform1f(M,h.u_brightness_low),u_brightness_high:new i.Uniform1f(M,h.u_brightness_high),u_saturation_factor:new i.Uniform1f(M,h.u_saturation_factor),u_contrast_factor:new i.Uniform1f(M,h.u_contrast_factor),u_spin_weights:new i.Uniform3f(M,h.u_spin_weights)}),symbolIcon:(M,h)=>({u_is_size_zoom_constant:new i.Uniform1i(M,h.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(M,h.u_is_size_feature_constant),u_size_t:new i.Uniform1f(M,h.u_size_t),u_size:new i.Uniform1f(M,h.u_size),u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_pitch:new i.Uniform1f(M,h.u_pitch),u_rotate_symbol:new i.Uniform1i(M,h.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(M,h.u_aspect_ratio),u_fade_change:new i.Uniform1f(M,h.u_fade_change),u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(M,h.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(M,h.u_coord_matrix),u_is_text:new i.Uniform1i(M,h.u_is_text),u_pitch_with_map:new i.Uniform1i(M,h.u_pitch_with_map),u_texsize:new i.Uniform2f(M,h.u_texsize),u_texture:new i.Uniform1i(M,h.u_texture)}),symbolSDF:(M,h)=>({u_is_size_zoom_constant:new i.Uniform1i(M,h.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(M,h.u_is_size_feature_constant),u_size_t:new i.Uniform1f(M,h.u_size_t),u_size:new i.Uniform1f(M,h.u_size),u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_pitch:new i.Uniform1f(M,h.u_pitch),u_rotate_symbol:new i.Uniform1i(M,h.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(M,h.u_aspect_ratio),u_fade_change:new i.Uniform1f(M,h.u_fade_change),u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(M,h.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(M,h.u_coord_matrix),u_is_text:new i.Uniform1i(M,h.u_is_text),u_pitch_with_map:new i.Uniform1i(M,h.u_pitch_with_map),u_texsize:new i.Uniform2f(M,h.u_texsize),u_texture:new i.Uniform1i(M,h.u_texture),u_gamma_scale:new i.Uniform1f(M,h.u_gamma_scale),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_is_halo:new i.Uniform1i(M,h.u_is_halo)}),symbolTextAndIcon:(M,h)=>({u_is_size_zoom_constant:new i.Uniform1i(M,h.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(M,h.u_is_size_feature_constant),u_size_t:new i.Uniform1f(M,h.u_size_t),u_size:new i.Uniform1f(M,h.u_size),u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_pitch:new i.Uniform1f(M,h.u_pitch),u_rotate_symbol:new i.Uniform1i(M,h.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(M,h.u_aspect_ratio),u_fade_change:new i.Uniform1f(M,h.u_fade_change),u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(M,h.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(M,h.u_coord_matrix),u_is_text:new i.Uniform1i(M,h.u_is_text),u_pitch_with_map:new i.Uniform1i(M,h.u_pitch_with_map),u_texsize:new i.Uniform2f(M,h.u_texsize),u_texsize_icon:new i.Uniform2f(M,h.u_texsize_icon),u_texture:new i.Uniform1i(M,h.u_texture),u_texture_icon:new i.Uniform1i(M,h.u_texture_icon),u_gamma_scale:new i.Uniform1f(M,h.u_gamma_scale),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_is_halo:new i.Uniform1i(M,h.u_is_halo)}),background:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_opacity:new i.Uniform1f(M,h.u_opacity),u_color:new i.UniformColor(M,h.u_color)}),backgroundPattern:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_opacity:new i.Uniform1f(M,h.u_opacity),u_image:new i.Uniform1i(M,h.u_image),u_pattern_tl_a:new i.Uniform2f(M,h.u_pattern_tl_a),u_pattern_br_a:new i.Uniform2f(M,h.u_pattern_br_a),u_pattern_tl_b:new i.Uniform2f(M,h.u_pattern_tl_b),u_pattern_br_b:new i.Uniform2f(M,h.u_pattern_br_b),u_texsize:new i.Uniform2f(M,h.u_texsize),u_mix:new i.Uniform1f(M,h.u_mix),u_pattern_size_a:new i.Uniform2f(M,h.u_pattern_size_a),u_pattern_size_b:new i.Uniform2f(M,h.u_pattern_size_b),u_scale_a:new i.Uniform1f(M,h.u_scale_a),u_scale_b:new i.Uniform1f(M,h.u_scale_b),u_pixel_coord_upper:new i.Uniform2f(M,h.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(M,h.u_pixel_coord_lower),u_tile_units_to_pixels:new i.Uniform1f(M,h.u_tile_units_to_pixels)}),terrain:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_texture:new i.Uniform1i(M,h.u_texture)}),terrainDepth:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix)}),terrainCoords:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_texture:new i.Uniform1i(M,h.u_texture),u_terrain_coords_id:new i.Uniform1f(M,h.u_terrain_coords_id)})};class rc{constructor(h,_,T){this.context=h;const F=h.gl;this.buffer=F.createBuffer(),this.dynamicDraw=Boolean(T),this.context.unbindVAO(),h.bindElementBuffer.set(this.buffer),F.bufferData(F.ELEMENT_ARRAY_BUFFER,_.arrayBuffer,this.dynamicDraw?F.DYNAMIC_DRAW:F.STATIC_DRAW),this.dynamicDraw||delete _.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(h){const _=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),_.bufferSubData(_.ELEMENT_ARRAY_BUFFER,0,h.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Th={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class sc{constructor(h,_,T,F){this.length=_.length,this.attributes=T,this.itemSize=_.bytesPerElement,this.dynamicDraw=F,this.context=h;const O=h.gl;this.buffer=O.createBuffer(),h.bindVertexBuffer.set(this.buffer),O.bufferData(O.ARRAY_BUFFER,_.arrayBuffer,this.dynamicDraw?O.DYNAMIC_DRAW:O.STATIC_DRAW),this.dynamicDraw||delete _.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(h){if(h.length!==this.length)throw new Error(`Length of new data is ${h.length}, which doesn't match current length of ${this.length}`);const _=this.context.gl;this.bind(),_.bufferSubData(_.ARRAY_BUFFER,0,h.arrayBuffer)}enableAttributes(h,_){for(let T=0;T0){const xn=i.create(),cn=bi;i.mul(xn,Ei.placementInvProjMatrix,M.transform.glCoordMatrix),i.mul(xn,xn,Ei.placementViewportMatrix),Te.push({circleArray:xi,circleOffset:We,transform:cn,invTransform:xn,coord:zt}),ke+=xi.length/4,We=ke}Hi&&ve.draw(oe,ue.LINES,hr.disabled,jr.disabled,M.colorModeForRenderPass(),$r.disabled,ho(bi,M.transform,li),M.style.terrain&&M.style.terrain.getTerrainData(zt),_.id,Hi.layoutVertexBuffer,Hi.indexBuffer,Hi.segments,null,M.transform.zoom,null,null,Hi.collisionVertexBuffer)}if(!K||!Te.length)return;const bt=M.useProgram("collisionCircle"),mt=new i.CollisionCircleLayoutArray;mt.resize(4*ke),mt._trim();let gt=0;for(const St of Te)for(let zt=0;zt=0&&(mt[Vt.associatedIconIndex]={shiftedAnchor:tr,angle:ur})}else Ui(Vt.numGlyphs,We)}if(ve){bt.clear();const gt=M.icon.placedSymbolArray;for(let Vt=0;VtM.style.terrain.getElevation(Hi,ee,pe):null,W=_.layout.get("text-rotation-alignment")==="map";Tn(xn,Hi.posMatrix,M,F,Wo,mo,Vt,ve,W,H)}const x=M.translatePosMatrix(Hi.posMatrix,xi,O,K),a=Zt||F&&Ei||$l?yu:Wo,m=M.translatePosMatrix(mo,xi,O,K,!0),b=tr&&_.paint.get(F?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let S;S=tr?xn.iconsInText?No(ur.kind,Rr,ni,Vt,M,x,a,m,Er,Aa):Os(ur.kind,Rr,ni,Vt,M,x,a,m,F,Er,!0):Eh(ur.kind,Rr,ni,Vt,M,x,a,m,F,Er);const P={program:Lr,buffers:cn,uniformValues:S,atlasTexture:Gr,atlasTextureIcon:ba,atlasInterpolation:js,atlasInterpolationIcon:wa,isSDF:tr,hasHalo:b};if(St&&xn.canOverlap){zt=!0;const H=cn.segments.get();for(const W of H)bi.push({segments:new i.SegmentVector([W]),sortKey:W.sortKey,state:P,terrainData:Cr})}else bi.push({segments:cn.segments,sortKey:0,state:P,terrainData:Cr})}zt&&bi.sort((Hi,xi)=>Hi.sortKey-xi.sortKey);for(const Hi of bi){const xi=Hi.state;if(We.activeTexture.set(bt.TEXTURE0),xi.atlasTexture.bind(xi.atlasInterpolation,bt.CLAMP_TO_EDGE),xi.atlasTextureIcon&&(We.activeTexture.set(bt.TEXTURE1),xi.atlasTextureIcon&&xi.atlasTextureIcon.bind(xi.atlasInterpolationIcon,bt.CLAMP_TO_EDGE)),xi.isSDF){const xn=xi.uniformValues;xi.hasHalo&&(xn.u_is_halo=1,Vc(xi.buffers,Hi.segments,_,M,xi.program,li,Te,ke,xn,Hi.terrainData)),xn.u_is_halo=0}Vc(xi.buffers,Hi.segments,_,M,xi.program,li,Te,ke,xi.uniformValues,Hi.terrainData)}}function Vc(M,h,_,T,F,O,K,oe,ue,ve){const Te=T.context;F.draw(Te,Te.gl.TRIANGLES,O,K,oe,$r.disabled,ue,ve,_.id,M.layoutVertexBuffer,M.indexBuffer,h,_.paint,T.transform.zoom,M.programConfigurations.get(_.id),M.dynamicLayoutVertexBuffer,M.opacityVertexBuffer)}function Hc(M,h,_,T,F,O,K){const oe=M.context.gl,ue=_.paint.get("fill-pattern"),ve=ue&&ue.constantOr(1),Te=_.getCrossfadeParameters();let ke,We,bt,mt,gt;K?(We=ve&&!_.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ke=oe.LINES):(We=ve?"fillPattern":"fill",ke=oe.TRIANGLES);for(const Vt of T){const Zt=h.getTile(Vt);if(ve&&!Zt.patternsLoaded())continue;const ni=Zt.getBucket(_);if(!ni)continue;const St=ni.programConfigurations.get(_.id),zt=M.useProgram(We,St),li=M.style.terrain&&M.style.terrain.getTerrainData(Vt);ve&&(M.context.activeTexture.set(oe.TEXTURE0),Zt.imageAtlasTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE),St.updatePaintBuffers(Te));const Ei=ue.constantOr(null);if(Ei&&Zt.imageAtlas){const xi=Zt.imageAtlas,xn=xi.patternPositions[Ei.to.toString()],cn=xi.patternPositions[Ei.from.toString()];xn&&cn&&St.setConstantPatternPositions(xn,cn)}const bi=li?Vt:null,Hi=M.translatePosMatrix(bi?bi.posMatrix:Vt.posMatrix,Zt,_.paint.get("fill-translate"),_.paint.get("fill-translate-anchor"));if(K){mt=ni.indexBuffer2,gt=ni.segments2;const xi=[oe.drawingBufferWidth,oe.drawingBufferHeight];bt=We==="fillOutlinePattern"&&ve?qs(Hi,M,Te,Zt,xi):ll(Hi,xi)}else mt=ni.indexBuffer,gt=ni.segments,bt=ve?Rl(Hi,M,Te,Zt):Ul(Hi);zt.draw(M.context,ke,F,M.stencilModeForClipping(Vt),O,$r.disabled,bt,li,_.id,ni.layoutVertexBuffer,mt,gt,_.paint,M.transform.zoom,St)}}function Lh(M,h,_,T,F,O,K){const oe=M.context,ue=oe.gl,ve=_.paint.get("fill-extrusion-pattern"),Te=ve.constantOr(1),ke=_.getCrossfadeParameters(),We=_.paint.get("fill-extrusion-opacity");for(const bt of T){const mt=h.getTile(bt),gt=mt.getBucket(_);if(!gt)continue;const Vt=M.style.terrain&&M.style.terrain.getTerrainData(bt),Zt=gt.programConfigurations.get(_.id),ni=M.useProgram(Te?"fillExtrusionPattern":"fillExtrusion",Zt);Te&&(M.context.activeTexture.set(ue.TEXTURE0),mt.imageAtlasTexture.bind(ue.LINEAR,ue.CLAMP_TO_EDGE),Zt.updatePaintBuffers(ke));const St=ve.constantOr(null);if(St&&mt.imageAtlas){const bi=mt.imageAtlas,Hi=bi.patternPositions[St.to.toString()],xi=bi.patternPositions[St.from.toString()];Hi&&xi&&Zt.setConstantPatternPositions(Hi,xi)}const zt=M.translatePosMatrix(bt.posMatrix,mt,_.paint.get("fill-extrusion-translate"),_.paint.get("fill-extrusion-translate-anchor")),li=_.paint.get("fill-extrusion-vertical-gradient"),Ei=Te?dr(zt,M,li,We,bt,ke,mt):al(zt,M,li,We);ni.draw(oe,oe.gl.TRIANGLES,F,O,K,$r.backCCW,Ei,Vt,_.id,gt.layoutVertexBuffer,gt.indexBuffer,gt.segments,_.paint,M.transform.zoom,Zt,M.style.terrain&>.centroidVertexBuffer)}}function Gc(M,h,_,T,F,O,K){const oe=M.context,ue=oe.gl,ve=_.fbo;if(!ve)return;const Te=M.useProgram("hillshade"),ke=M.style.terrain&&M.style.terrain.getTerrainData(h);oe.activeTexture.set(ue.TEXTURE0),ue.bindTexture(ue.TEXTURE_2D,ve.colorAttachment.get()),Te.draw(oe,ue.TRIANGLES,F,O,K,$r.disabled,((We,bt,mt,gt)=>{const Vt=mt.paint.get("hillshade-shadow-color"),Zt=mt.paint.get("hillshade-highlight-color"),ni=mt.paint.get("hillshade-accent-color");let St=mt.paint.get("hillshade-illumination-direction")*(Math.PI/180);mt.paint.get("hillshade-illumination-anchor")==="viewport"&&(St-=We.transform.angle);const zt=!We.options.moving;return{u_matrix:gt?gt.posMatrix:We.transform.calculatePosMatrix(bt.tileID.toUnwrapped(),zt),u_image:0,u_latrange:kl(0,bt.tileID),u_light:[mt.paint.get("hillshade-exaggeration"),St],u_shadow:Vt,u_highlight:Zt,u_accent:ni}})(M,_,T,ke?h:null),ke,T.id,M.rasterBoundsBuffer,M.quadTriangleIndexBuffer,M.rasterBoundsSegments)}function Dh(M,h,_,T,F,O){const K=M.context,oe=K.gl,ue=h.dem;if(ue&&ue.data){const ve=ue.dim,Te=ue.stride,ke=ue.getPixels();if(K.activeTexture.set(oe.TEXTURE1),K.pixelStoreUnpackPremultiplyAlpha.set(!1),h.demTexture=h.demTexture||M.getTileTexture(Te),h.demTexture){const bt=h.demTexture;bt.update(ke,{premultiply:!1}),bt.bind(oe.NEAREST,oe.CLAMP_TO_EDGE)}else h.demTexture=new Y(K,ke,oe.RGBA,{premultiply:!1}),h.demTexture.bind(oe.NEAREST,oe.CLAMP_TO_EDGE);K.activeTexture.set(oe.TEXTURE0);let We=h.fbo;if(!We){const bt=new Y(K,{width:ve,height:ve,data:null},oe.RGBA);bt.bind(oe.LINEAR,oe.CLAMP_TO_EDGE),We=h.fbo=K.createFramebuffer(ve,ve,!0),We.colorAttachment.set(bt.texture)}K.bindFramebuffer.set(We.framebuffer),K.viewport.set([0,0,ve,ve]),M.useProgram("hillshadePrepare").draw(K,oe.TRIANGLES,T,F,O,$r.disabled,((bt,mt)=>{const gt=mt.stride,Vt=i.create();return i.ortho(Vt,0,i.EXTENT,-i.EXTENT,0,0,1),i.translate(Vt,Vt,[0,-i.EXTENT,0]),{u_matrix:Vt,u_image:1,u_dimension:[gt,gt],u_zoom:bt.overscaledZ,u_unpack:mt.getUnpackVector()}})(h.tileID,ue),null,_.id,M.rasterBoundsBuffer,M.quadTriangleIndexBuffer,M.rasterBoundsSegments),h.needsHillshadePrepare=!1}}function Wc(M,h,_,T,F,O){const K=T.paint.get("raster-fade-duration");if(!O&&K>0){const oe=i.exported.now(),ue=(oe-M.timeAdded)/K,ve=h?(oe-h.timeAdded)/K:-1,Te=_.getSource(),ke=F.coveringZoomLevel({tileSize:Te.tileSize,roundZoom:Te.roundZoom}),We=!h||Math.abs(h.tileID.overscaledZ-ke)>Math.abs(M.tileID.overscaledZ-ke),bt=We&&M.refreshedUponExpiration?1:i.clamp(We?ue:1-ve,0,1);return M.refreshedUponExpiration&&ue>=1&&(M.refreshedUponExpiration=!1),h?{opacity:1,mix:1-bt}:{opacity:bt,mix:0}}return{opacity:1,mix:0}}const jc=new i.Color(1,0,0,1),ca=new i.Color(0,1,0,1),sA=new i.Color(0,0,1,1),oA=new i.Color(1,0,1,1),Kc=new i.Color(0,1,1,1);function ha(M,h,_,T){pl(M,0,h+_/2,M.transform.width,_,T)}function $c(M,h,_,T){pl(M,h-_/2,0,_,M.transform.height,T)}function pl(M,h,_,T,F,O){const K=M.context,oe=K.gl;oe.enable(oe.SCISSOR_TEST),oe.scissor(h*M.pixelRatio,_*M.pixelRatio,T*M.pixelRatio,F*M.pixelRatio),K.clear({color:O}),oe.disable(oe.SCISSOR_TEST)}function aA(M,h,_){const T=M.context,F=T.gl,O=_.posMatrix,K=M.useProgram("debug"),oe=hr.disabled,ue=jr.disabled,ve=M.colorModeForRenderPass(),Te="$debug",ke=M.style.terrain&&M.style.terrain.getTerrainData(_);T.activeTexture.set(F.TEXTURE0),M.emptyTexture.bind(F.LINEAR,F.CLAMP_TO_EDGE);const We=h.getTileByID(_.key).latestRawTileData,bt=Math.floor((We&&We.byteLength||0)/1024),mt=h.getTile(_).tileSize,gt=512/Math.min(mt,512)*(_.overscaledZ/M.transform.zoom)*.5;let Vt=_.canonical.toString();_.overscaledZ!==_.canonical.z&&(Vt+=` => ${_.overscaledZ}`),function(Zt,ni){Zt.initDebugOverlayCanvas();const St=Zt.debugOverlayCanvas,zt=Zt.context.gl,li=Zt.debugOverlayCanvas.getContext("2d");li.clearRect(0,0,St.width,St.height),li.shadowColor="white",li.shadowBlur=2,li.lineWidth=1.5,li.strokeStyle="white",li.textBaseline="top",li.font="bold 36px Open Sans, sans-serif",li.fillText(ni,5,5),li.strokeText(ni,5,5),Zt.debugOverlayTexture.update(St),Zt.debugOverlayTexture.bind(zt.LINEAR,zt.CLAMP_TO_EDGE)}(M,`${Vt} ${bt}kB`),K.draw(T,F.TRIANGLES,oe,ue,qr.alphaBlended,$r.disabled,cl(O,i.Color.transparent,gt),null,Te,M.debugBuffer,M.quadTriangleIndexBuffer,M.debugSegments),K.draw(T,F.LINE_STRIP,oe,ue,ve,$r.disabled,cl(O,i.Color.red),ke,Te,M.debugBuffer,M.tileBorderIndexBuffer,M.debugSegments)}function Ho(M,h,_){const T=M.context,F=T.gl,O=M.colorModeForRenderPass(),K=new hr(F.LEQUAL,hr.ReadWrite,M.depthRangeFor3D),oe=M.useProgram("terrain"),ue=h.getTerrainMesh(),ve=h.getTerrainData(_.tileID);T.bindFramebuffer.set(null),T.viewport.set([0,0,M.width,M.height]),T.activeTexture.set(F.TEXTURE0),F.bindTexture(F.TEXTURE_2D,h.getRTTFramebuffer().colorAttachment.get());const Te=M.transform.calculatePosMatrix(_.tileID.toUnwrapped());oe.draw(T,F.TRIANGLES,K,jr.disabled,O,$r.backCCW,{u_matrix:Te,u_texture:0},ve,"terrain",ue.vertexBuffer,ue.indexBuffer,ue.segments)}function Ph(M,h,_,T){const F=M.context,O=_.tileSize*h.qualityFactor;_.textures[T]||(_.textures[T]=M.getTileTexture(O)||new Y(F,{width:O,height:O,data:null},F.gl.RGBA),_.textures[T].bind(F.gl.LINEAR,F.gl.CLAMP_TO_EDGE),T===0&&h.sourceCache.renderHistory.unshift(_.tileID.key));const K=h.getRTTFramebuffer();K.colorAttachment.set(_.textures[T].texture),F.bindFramebuffer.set(K.framebuffer),F.viewport.set([0,0,O,O])}class xu{constructor(h){this._coordsDescendingInv={},this._coordsDescendingInvStr={},this.painter=h,this._renderToTexture={background:!0,fill:!0,line:!0,raster:!0},this._coordsDescendingInv={},this._coordsDescendingInvStr={},this._stacks=[],this._prevType=null,this._rerender={},this._renderableTiles=h.style.terrain.sourceCache.getRenderableTiles(),this._init()}_init(){const h=this.painter.style,_=h.terrain;for(const T in h.sourceCaches){this._coordsDescendingInv[T]={};const F=h.sourceCaches[T].getVisibleCoordinates();for(const O of F){const K=_.sourceCache.getTerrainCoords(O);for(const oe in K)this._coordsDescendingInv[T][oe]||(this._coordsDescendingInv[T][oe]=[]),this._coordsDescendingInv[T][oe].push(K[oe])}}for(const T of h._order){const F=h._layers[T],O=F.source;if(this._renderToTexture[F.type]&&!this._coordsDescendingInvStr[O]){this._coordsDescendingInvStr[O]={};for(const K in this._coordsDescendingInv[O])this._coordsDescendingInvStr[O][K]=this._coordsDescendingInv[O][K].map(oe=>oe.key).sort().join()}}return this._renderableTiles.forEach(T=>{for(const F in this._coordsDescendingInvStr){const O=this._coordsDescendingInvStr[F][T.tileID.key];O&&O!==T.textureCoords[F]&&T.clearTextures(this.painter),_.needsRerender(F,T.tileID)&&T.clearTextures(this.painter)}this._rerender[T.tileID.key]=!T.textures.length}),_.clearRerenderCache(),_.sourceCache.removeOutdated(this.painter),this}renderLayer(h){const _=h.type,T=this.painter,F=T.style._order,O=T.currentLayer,K=O+1===F.length;if(this._renderToTexture[_]&&(this._prevType&&this._renderToTexture[this._prevType]||this._stacks.push([]),this._prevType=_,this._stacks[this._stacks.length-1].push(F[O]),!K))return!0;if(this._renderToTexture[this._prevType]||_==="hillshade"||this._renderToTexture[_]&&K){this._prevType=_;const oe=this._stacks.length-1,ue=this._stacks[oe]||[];for(const ve of this._renderableTiles){if(Ph(T,T.style.terrain,ve,oe),this._rerender[ve.tileID.key]){T.context.clear({color:i.Color.transparent});for(let Te=0;Teue.style.terrain.getElevation(Zt,xi,xn):null)}}}(T,M,_,h,_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),F),_.paint.get("icon-opacity").constantOr(1)!==0&&Ac(M,h,_,T,!1,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),_.layout.get("icon-rotation-alignment"),_.layout.get("icon-pitch-alignment"),_.layout.get("icon-keep-upright"),O,K),_.paint.get("text-opacity").constantOr(1)!==0&&Ac(M,h,_,T,!0,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.layout.get("text-keep-upright"),O,K),h.map.showCollisionBoxes&&(gr(M,h,_,T,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),!0),gr(M,h,_,T,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),!1))},circle:function(M,h,_,T){if(M.renderPass!=="translucent")return;const F=_.paint.get("circle-opacity"),O=_.paint.get("circle-stroke-width"),K=_.paint.get("circle-stroke-opacity"),oe=!_.layout.get("circle-sort-key").isConstant();if(F.constantOr(1)===0&&(O.constantOr(1)===0||K.constantOr(1)===0))return;const ue=M.context,ve=ue.gl,Te=M.depthModeForSublayer(0,hr.ReadOnly),ke=jr.disabled,We=M.colorModeForRenderPass(),bt=[];for(let mt=0;mtmt.sortKey-gt.sortKey);for(const mt of bt){const{programConfiguration:gt,program:Vt,layoutVertexBuffer:Zt,indexBuffer:ni,uniformValues:St,terrainData:zt}=mt.state;Vt.draw(ue,ve.TRIANGLES,Te,ke,We,$r.disabled,St,zt,_.id,Zt,ni,mt.segments,_.paint,M.transform.zoom,gt)}},heatmap:function(M,h,_,T){if(_.paint.get("heatmap-opacity")!==0)if(M.renderPass==="offscreen"){const F=M.context,O=F.gl,K=jr.disabled,oe=new qr([O.ONE,O.ONE],i.Color.transparent,[!0,!0,!0,!0]);(function(ue,ve,Te){const ke=ue.gl;ue.activeTexture.set(ke.TEXTURE1),ue.viewport.set([0,0,ve.width/4,ve.height/4]);let We=Te.heatmapFbo;if(We)ke.bindTexture(ke.TEXTURE_2D,We.colorAttachment.get()),ue.bindFramebuffer.set(We.framebuffer);else{const bt=ke.createTexture();ke.bindTexture(ke.TEXTURE_2D,bt),ke.texParameteri(ke.TEXTURE_2D,ke.TEXTURE_WRAP_S,ke.CLAMP_TO_EDGE),ke.texParameteri(ke.TEXTURE_2D,ke.TEXTURE_WRAP_T,ke.CLAMP_TO_EDGE),ke.texParameteri(ke.TEXTURE_2D,ke.TEXTURE_MIN_FILTER,ke.LINEAR),ke.texParameteri(ke.TEXTURE_2D,ke.TEXTURE_MAG_FILTER,ke.LINEAR),We=Te.heatmapFbo=ue.createFramebuffer(ve.width/4,ve.height/4,!1),function(mt,gt,Vt,Zt){const ni=mt.gl;ni.texImage2D(ni.TEXTURE_2D,0,ni.RGBA,gt.width/4,gt.height/4,0,ni.RGBA,mt.extRenderToTextureHalfFloat?mt.extTextureHalfFloat.HALF_FLOAT_OES:ni.UNSIGNED_BYTE,null),Zt.colorAttachment.set(Vt)}(ue,ve,bt,We)}})(F,M,_),F.clear({color:i.Color.transparent});for(let ue=0;ue{const mt=i.create();i.ortho(mt,0,Te.width,Te.height,0,0,1);const gt=Te.context.gl;return{u_matrix:mt,u_world:[gt.drawingBufferWidth,gt.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:ke.paint.get("heatmap-opacity")}})(F,O),null,O.id,F.viewportBuffer,F.quadTriangleIndexBuffer,F.viewportSegments,O.paint,F.transform.zoom)}(M,_))},line:function(M,h,_,T){if(M.renderPass!=="translucent")return;const F=_.paint.get("line-opacity"),O=_.paint.get("line-width");if(F.constantOr(1)===0||O.constantOr(1)===0)return;const K=M.depthModeForSublayer(0,hr.ReadOnly),oe=M.colorModeForRenderPass(),ue=_.paint.get("line-dasharray"),ve=_.paint.get("line-pattern"),Te=ve.constantOr(1),ke=_.paint.get("line-gradient"),We=_.getCrossfadeParameters(),bt=Te?"linePattern":ue?"lineSDF":ke?"lineGradient":"line",mt=M.context,gt=mt.gl;let Vt=!0;for(const Zt of T){const ni=h.getTile(Zt);if(Te&&!ni.patternsLoaded())continue;const St=ni.getBucket(_);if(!St)continue;const zt=St.programConfigurations.get(_.id),li=M.context.program.get(),Ei=M.useProgram(bt,zt),bi=Vt||Ei.program!==li,Hi=M.style.terrain&&M.style.terrain.getTerrainData(Zt),xi=ve.constantOr(null);if(xi&&ni.imageAtlas){const Bn=ni.imageAtlas,tr=Bn.patternPositions[xi.to.toString()],ur=Bn.patternPositions[xi.from.toString()];tr&&ur&&zt.setConstantPatternPositions(tr,ur)}const xn=Hi?Zt:null,cn=Te?Nl(M,ni,_,We,xn):ue?Ql(M,ni,_,ue,We,xn):ke?Qa(M,ni,_,St.lineClipsArray.length,xn):Ol(M,ni,_,xn);if(Te)mt.activeTexture.set(gt.TEXTURE0),ni.imageAtlasTexture.bind(gt.LINEAR,gt.CLAMP_TO_EDGE),zt.updatePaintBuffers(We);else if(ue&&(bi||M.lineAtlas.dirty))mt.activeTexture.set(gt.TEXTURE0),M.lineAtlas.bind(mt);else if(ke){const Bn=St.gradients[_.id];let tr=Bn.texture;if(_.gradientVersion!==Bn.version){let ur=256;if(_.stepInterpolant){const Un=h.getSource().maxzoom,Lr=Zt.canonical.z===Un?Math.ceil(1<256&&this.clearStencil(),T.setColorMode(qr.disabled),T.setDepthMode(hr.disabled);const O=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const K of _){const oe=this._tileClippingMaskIDs[K.key]=this.nextStencilID++,ue=this.style.terrain&&this.style.terrain.getTerrainData(K);O.draw(T,F.TRIANGLES,hr.disabled,new jr({func:F.ALWAYS,mask:0},oe,255,F.KEEP,F.KEEP,F.REPLACE),qr.disabled,$r.disabled,Na(K.posMatrix),ue,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,_=this.context.gl;return new jr({func:_.NOTEQUAL,mask:255},h,255,_.KEEP,_.KEEP,_.REPLACE)}stencilModeForClipping(h){const _=this.context.gl;return new jr({func:_.EQUAL,mask:255},this._tileClippingMaskIDs[h.key],0,_.KEEP,_.KEEP,_.REPLACE)}stencilConfigForOverlap(h){const _=this.context.gl,T=h.sort((K,oe)=>oe.overscaledZ-K.overscaledZ),F=T[T.length-1].overscaledZ,O=T[0].overscaledZ-F+1;if(O>1){this.currentStencilSource=void 0,this.nextStencilID+O>256&&this.clearStencil();const K={};for(let oe=0;oe=0;this.currentLayer--){const ve=this.style._layers[T[this.currentLayer]],Te=F[ve.source],ke=K[ve.source];this._renderTileClippingMasks(ve,ke),this.renderLayer(this,Te,ve,ke)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer{ke.source&&!ke.isHidden(this.transform.zoom)&&(ke.source!==(Te&&Te.id)&&(Te=this.style.sourceCaches[ke.source]),(!ve||ve.getSource().maxzoom0?_.pop():null}isPatternMissing(h){if(!h)return!1;if(!h.from||!h.to)return!0;const _=this.imageManager.getPattern(h.from.toString()),T=this.imageManager.getPattern(h.to.toString());return!_||!T}useProgram(h,_){this.cache=this.cache||{};const T=h+(_?_.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.terrain?"/terrain":"");return this.cache[T]||(this.cache[T]=new Ar(this.context,h,ks[h],_,Cs[h],this._showOverdrawInspector,this.style.terrain)),this.cache[T]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const h=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(h.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Y(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}}class Zc{constructor(h,_){this.points=h,this.planes=_}static fromInvProjectionMatrix(h,_,T){const F=Math.pow(2,T),O=[[-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(oe=>{const ue=1/(oe=i.transformMat4([],oe,h))[3]/_*F;return i.mul$1(oe,oe,[ue,ue,1/oe[3],ue])}),K=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(oe=>{const ue=i.sub([],O[oe[0]],O[oe[1]]),ve=i.sub([],O[oe[2]],O[oe[1]]),Te=i.normalize([],i.cross([],ue,ve)),ke=-i.dot(Te,O[oe[1]]);return Te.concat(ke)});return new Zc(O,K)}}class Xc{constructor(h,_){this.min=h,this.max=_,this.center=i.scale$1([],i.add([],this.min,this.max),.5)}quadrant(h){const _=[h%2==0,h<2],T=i.clone$2(this.min),F=i.clone$2(this.max);for(let O=0;O<_.length;O++)T[O]=_[O]?this.min[O]:this.center[O],F[O]=_[O]?this.center[O]:this.max[O];return F[2]=this.max[2],new Xc(T,F)}distanceX(h){return Math.max(Math.min(this.max[0],h[0]),this.min[0])-h[0]}distanceY(h){return Math.max(Math.min(this.max[1],h[1]),this.min[1])-h[1]}intersects(h){const _=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]];let T=!0;for(let F=0;F=0&&K++;if(K===0)return 0;K!==_.length&&(T=!1)}if(T)return 2;for(let F=0;F<3;F++){let O=Number.MAX_VALUE,K=-Number.MAX_VALUE;for(let oe=0;oethis.max[F]-this.min[F])return 0}return 1}}class fl{constructor(h=0,_=0,T=0,F=0){if(isNaN(h)||h<0||isNaN(_)||_<0||isNaN(T)||T<0||isNaN(F)||F<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=h,this.bottom=_,this.left=T,this.right=F}interpolate(h,_,T){return _.top!=null&&h.top!=null&&(this.top=i.number(h.top,_.top,T)),_.bottom!=null&&h.bottom!=null&&(this.bottom=i.number(h.bottom,_.bottom,T)),_.left!=null&&h.left!=null&&(this.left=i.number(h.left,_.left,T)),_.right!=null&&h.right!=null&&(this.right=i.number(h.right,_.right,T)),this}getCenter(h,_){const T=i.clamp((this.left+h-this.right)/2,0,h),F=i.clamp((this.top+_-this.bottom)/2,0,_);return new i.pointGeometry(T,F)}equals(h){return this.top===h.top&&this.bottom===h.bottom&&this.left===h.left&&this.right===h.right}clone(){return new fl(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class qc{constructor(h,_,T,F,O){this.tileSize=512,this.maxValidLatitude=85.051129,this.freezeElevation=!1,this._renderWorldCopies=O===void 0||!!O,this._minZoom=h||0,this._maxZoom=_||22,this._minPitch=T==null?0:T,this._maxPitch=F==null?60:F,this.setMaxBounds(),this.width=0,this.height=0,this._center=new i.LngLat(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new fl,this._posMatrixCache={},this._alignedPosMatrixCache={}}clone(){const h=new qc(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return h.tileSize=this.tileSize,h.latRange=this.latRange,h.width=this.width,h.height=this.height,h._center=this._center,h._elevation=this._elevation,h.zoom=this.zoom,h.angle=this.angle,h._fov=this._fov,h._pitch=this._pitch,h._unmodified=this._unmodified,h._edgeInsets=this._edgeInsets.clone(),h._calcMatrices(),h}get minZoom(){return this._minZoom}set minZoom(h){this._minZoom!==h&&(this._minZoom=h,this.zoom=Math.max(this.zoom,h))}get maxZoom(){return this._maxZoom}set maxZoom(h){this._maxZoom!==h&&(this._maxZoom=h,this.zoom=Math.min(this.zoom,h))}get minPitch(){return this._minPitch}set minPitch(h){this._minPitch!==h&&(this._minPitch=h,this.pitch=Math.max(this.pitch,h))}get maxPitch(){return this._maxPitch}set maxPitch(h){this._maxPitch!==h&&(this._maxPitch=h,this.pitch=Math.min(this.pitch,h))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(h){h===void 0?h=!0:h===null&&(h=!1),this._renderWorldCopies=h}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new i.pointGeometry(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(h){const _=-i.wrap(h,-180,180)*Math.PI/180;var T;this.angle!==_&&(this._unmodified=!1,this.angle=_,this._calcMatrices(),this.rotationMatrix=(T=new i.ARRAY_TYPE(4),i.ARRAY_TYPE!=Float32Array&&(T[1]=0,T[2]=0),T[0]=1,T[3]=1,T),function(F,O,K){var oe=O[0],ue=O[1],ve=O[2],Te=O[3],ke=Math.sin(K),We=Math.cos(K);F[0]=oe*We+ve*ke,F[1]=ue*We+Te*ke,F[2]=oe*-ke+ve*We,F[3]=ue*-ke+Te*We}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(h){const _=i.clamp(h,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==_&&(this._unmodified=!1,this._pitch=_,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(h){h=Math.max(.01,Math.min(60,h)),this._fov!==h&&(this._unmodified=!1,this._fov=h/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(h){const _=Math.min(Math.max(h,this.minZoom),this.maxZoom);this._zoom!==_&&(this._unmodified=!1,this._zoom=_,this.scale=this.zoomScale(_),this.tileZoom=Math.floor(_),this.zoomFraction=_-this.tileZoom,this._constrain(),this._calcMatrices())}get center(){return this._center}set center(h){h.lat===this._center.lat&&h.lng===this._center.lng||(this._unmodified=!1,this._center=h,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(h){h!==this._elevation&&(this._elevation=h,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(h){this._edgeInsets.equals(h)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,h,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(h){return this._edgeInsets.equals(h)}interpolatePadding(h,_,T){this._unmodified=!1,this._edgeInsets.interpolate(h,_,T),this._constrain(),this._calcMatrices()}coveringZoomLevel(h){const _=(h.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/h.tileSize));return Math.max(0,_)}getVisibleUnwrappedCoordinates(h){const _=[new i.UnwrappedTileID(0,h)];if(this._renderWorldCopies){const T=this.pointCoordinate(new i.pointGeometry(0,0)),F=this.pointCoordinate(new i.pointGeometry(this.width,0)),O=this.pointCoordinate(new i.pointGeometry(this.width,this.height)),K=this.pointCoordinate(new i.pointGeometry(0,this.height)),oe=Math.floor(Math.min(T.x,F.x,O.x,K.x)),ue=Math.floor(Math.max(T.x,F.x,O.x,K.x)),ve=1;for(let Te=oe-ve;Te<=ue+ve;Te++)Te!==0&&_.push(new i.UnwrappedTileID(Te,h))}return _}coveringTiles(h){var _,T;let F=this.coveringZoomLevel(h);const O=F;if(h.minzoom!==void 0&&Fh.maxzoom&&(F=h.maxzoom);const K=this.pointCoordinate(this.getCameraPoint()),oe=i.MercatorCoordinate.fromLngLat(this.center),ue=Math.pow(2,F),ve=[ue*K.x,ue*K.y,0],Te=[ue*oe.x,ue*oe.y,0],ke=Zc.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,F);let We=h.minzoom||0;!h.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(We=F);const bt=h.terrain?2/Math.min(this.tileSize,h.tileSize)*this.tileSize:3,mt=St=>({aabb:new Xc([St*ue,0,0],[(St+1)*ue,ue,0]),zoom:0,x:0,y:0,wrap:St,fullyVisible:!1}),gt=[],Vt=[],Zt=F,ni=h.reparseOverscaled?O:F;if(this._renderWorldCopies)for(let St=1;St<=3;St++)gt.push(mt(-St)),gt.push(mt(St));for(gt.push(mt(0));gt.length>0;){const St=gt.pop(),zt=St.x,li=St.y;let Ei=St.fullyVisible;if(!Ei){const Bn=St.aabb.intersects(ke);if(Bn===0)continue;Ei=Bn===2}const bi=h.terrain?ve:Te,Hi=St.aabb.distanceX(bi),xi=St.aabb.distanceY(bi),xn=Math.max(Math.abs(Hi),Math.abs(xi)),cn=bt+(1<cn&&St.zoom>=We){const Bn=Zt-St.zoom,tr=ve[0]-.5-(zt<>1),Un=St.zoom+1;let Lr=St.aabb.quadrant(Bn);if(h.terrain){const Rr=new i.OverscaledTileID(Un,St.wrap,Un,tr,ur),Cr=h.terrain.getMinMaxElevation(Rr),Er=(_=Cr.minElevation)!==null&&_!==void 0?_:this.elevation,Gr=(T=Cr.maxElevation)!==null&&T!==void 0?T:this.elevation;Lr=new Xc([Lr.min[0],Lr.min[1],Er],[Lr.max[0],Lr.max[1],Gr])}gt.push({aabb:Lr,zoom:Un,x:tr,y:ur,wrap:St.wrap,fullyVisible:Ei})}}return Vt.sort((St,zt)=>St.distanceSq-zt.distanceSq).map(St=>St.tileID)}resize(h,_){this.width=h,this.height=_,this.pixelsToGLUnits=[2/h,-2/_],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(h){return Math.pow(2,h)}scaleZoom(h){return Math.log(h)/Math.LN2}project(h){const _=i.clamp(h.lat,-this.maxValidLatitude,this.maxValidLatitude);return new i.pointGeometry(i.mercatorXfromLng(h.lng)*this.worldSize,i.mercatorYfromLat(_)*this.worldSize)}unproject(h){return new i.MercatorCoordinate(h.x/this.worldSize,h.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}updateElevation(h){this.freezeElevation||(this.elevation=h?this.getElevation(this._center,h):0)}getElevation(h,_){const T=i.MercatorCoordinate.fromLngLat(h),F=(1<K&&(F=K-mt)}if(this.lngRange){const bt=(oe+ue)/2,mt=i.wrap(ke.x,bt-this.worldSize/2,bt+this.worldSize/2),gt=ve.x/2;mt-gtue&&(T=ue-gt)}T===void 0&&F===void 0||(this.center=this.unproject(new i.pointGeometry(T!==void 0?T:ke.x,F!==void 0?F:ke.y)).wrap()),this._unmodified=Te,this._constraining=!1}_calcMatrices(){if(!this.height)return;const h=this.centerOffset,_=this.point.x,T=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=i.mercatorZfromAltitude(1,this.center.lat)*this.worldSize;let F=i.identity(new Float64Array(16));i.scale(F,F,[this.width/2,-this.height/2,1]),i.translate(F,F,[1,-1,0]),this.labelPlaneMatrix=F,F=i.identity(new Float64Array(16)),i.scale(F,F,[1,-1,1]),i.translate(F,F,[-1,-1,0]),i.scale(F,F,[2/this.width,2/this.height,1]),this.glCoordMatrix=F,this.cameraToSeaLevelDistance=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch);const O=Math.PI/2+this._pitch,K=this._fov*(.5+h.y/this.height),oe=Math.sin(K)*this.cameraToSeaLevelDistance/Math.sin(i.clamp(Math.PI-O-K,.01,Math.PI-.01)),ue=this.getHorizon(),ve=2*Math.atan(ue/this.cameraToCenterDistance)*(.5+h.y/(2*ue)),Te=Math.sin(ve)*this.cameraToSeaLevelDistance/Math.sin(i.clamp(Math.PI-O-ve,.01,Math.PI-.01)),ke=Math.cos(Math.PI/2-this._pitch)*oe+this.cameraToSeaLevelDistance,We=Math.cos(Math.PI/2-this._pitch)*Te+this.cameraToSeaLevelDistance,bt=1.01*Math.min(ke,We),mt=this.height/50;F=new Float64Array(16),i.perspective(F,this._fov,this.width/this.height,mt,bt),F[8]=2*-h.x/this.width,F[9]=2*h.y/this.height,i.scale(F,F,[1,-1,1]),i.translate(F,F,[0,0,-this.cameraToCenterDistance]),i.rotateX(F,F,this._pitch),i.rotateZ(F,F,this.angle),i.translate(F,F,[-_,-T,0]),this.mercatorMatrix=i.scale([],F,[this.worldSize,this.worldSize,this.worldSize]),i.scale(F,F,[1,1,this._pixelPerMeter]),this.pixelMatrix=i.multiply(new Float64Array(16),this.labelPlaneMatrix,F),i.translate(F,F,[0,0,-this.elevation]),this.projMatrix=F,this.invProjMatrix=i.invert([],F),this.pixelMatrix3D=i.multiply(new Float64Array(16),this.labelPlaneMatrix,F);const gt=this.width%2/2,Vt=this.height%2/2,Zt=Math.cos(this.angle),ni=Math.sin(this.angle),St=_-Math.round(_)+Zt*gt+ni*Vt,zt=T-Math.round(T)+Zt*Vt+ni*gt,li=new Float64Array(F);if(i.translate(li,li,[St>.5?St-1:St,zt>.5?zt-1:zt,0]),this.alignedProjMatrix=li,F=i.invert(new Float64Array(16),this.pixelMatrix),!F)throw new Error("failed to invert matrix");this.pixelMatrixInverse=F,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const h=this.pointCoordinate(new i.pointGeometry(0,0)),_=[h.x*this.worldSize,h.y*this.worldSize,0,1];return i.transformMat4(_,_,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const h=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.pointGeometry(0,h))}getCameraQueryGeometry(h){const _=this.getCameraPoint();if(h.length===1)return[h[0],_];{let T=_.x,F=_.y,O=_.x,K=_.y;for(const oe of h)T=Math.min(T,oe.x),F=Math.min(F,oe.y),O=Math.max(O,oe.x),K=Math.max(K,oe.y);return[new i.pointGeometry(T,F),new i.pointGeometry(O,F),new i.pointGeometry(O,K),new i.pointGeometry(T,K),new i.pointGeometry(T,F)]}}}class Uh{constructor(h){this._hashName=h&&encodeURIComponent(h),i.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=function(_,T){let F=!1,O=null;const K=()=>{O=null,F&&(_(),O=setTimeout(K,300),F=!1)};return()=>(F=!0,O||K(),O)}(this._updateHashUnthrottled.bind(this))}addTo(h){return this._map=h,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(h){const _=this._map.getCenter(),T=Math.round(100*this._map.getZoom())/100,F=Math.ceil((T*Math.LN2+Math.log(512/360/.5))/Math.LN10),O=Math.pow(10,F),K=Math.round(_.lng*O)/O,oe=Math.round(_.lat*O)/O,ue=this._map.getBearing(),ve=this._map.getPitch();let Te="";if(Te+=h?`/${K}/${oe}/${T}`:`${T}/${oe}/${K}`,(ue||ve)&&(Te+="/"+Math.round(10*ue)/10),ve&&(Te+=`/${Math.round(ve)}`),this._hashName){const ke=this._hashName;let We=!1;const bt=window.location.hash.slice(1).split("&").map(mt=>{const gt=mt.split("=")[0];return gt===ke?(We=!0,`${gt}=${Te}`):mt}).filter(mt=>mt);return We||bt.push(`${ke}=${Te}`),`#${bt.join("&")}`}return`#${Te}`}_getCurrentHash(){const h=window.location.hash.replace("#","");if(this._hashName){let _;return h.split("&").map(T=>T.split("=")).forEach(T=>{T[0]===this._hashName&&(_=T)}),(_&&_[1]||"").split("/")}return h.split("/")}_onHashChange(){const h=this._getCurrentHash();if(h.length>=3&&!h.some(_=>isNaN(_))){const _=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(h[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+h[2],+h[1]],zoom:+h[0],bearing:_,pitch:+(h[4]||0)}),!0}return!1}_updateHashUnthrottled(){const h=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,h)}catch{}}}const Rh={linearity:.3,easing:i.bezier(0,0,.3,1)},wu=i.extend({deceleration:2500,maxSpeed:1400},Rh),nd=i.extend({deceleration:20,maxSpeed:1400},Rh),dc=i.extend({deceleration:1e3,maxSpeed:360},Rh),pc=i.extend({deceleration:1e3,maxSpeed:90},Rh);class Yc{constructor(h){this._map=h,this.clear()}clear(){this._inertiaBuffer=[]}record(h){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.exported.now(),settings:h})}_drainInertiaBuffer(){const h=this._inertiaBuffer,_=i.exported.now();for(;h.length>0&&_-h[0].time>160;)h.shift()}_onMoveEnd(h){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const _={zoom:0,bearing:0,pitch:0,pan:new i.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:O}of this._inertiaBuffer)_.zoom+=O.zoomDelta||0,_.bearing+=O.bearingDelta||0,_.pitch+=O.pitchDelta||0,O.panDelta&&_.pan._add(O.panDelta),O.around&&(_.around=O.around),O.pinchAround&&(_.pinchAround=O.pinchAround);const T=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,F={};if(_.pan.mag()){const O=Jc(_.pan.mag(),T,i.extend({},wu,h||{}));F.offset=_.pan.mult(O.amount/_.pan.mag()),F.center=this._map.transform.center,zh(F,O)}if(_.zoom){const O=Jc(_.zoom,T,nd);F.zoom=this._map.transform.zoom+O.amount,zh(F,O)}if(_.bearing){const O=Jc(_.bearing,T,dc);F.bearing=this._map.transform.bearing+i.clamp(O.amount,-179,179),zh(F,O)}if(_.pitch){const O=Jc(_.pitch,T,pc);F.pitch=this._map.transform.pitch+O.amount,zh(F,O)}if(F.zoom||F.bearing){const O=_.pinchAround===void 0?_.around:_.pinchAround;F.around=O?this._map.unproject(O):this._map.getCenter()}return this.clear(),i.extend(F,{noMoveStart:!0})}}function zh(M,h){(!M.duration||M.duration_.unproject(ue)),oe=O.reduce((ue,ve,Te,ke)=>ue.add(ve.div(ke.length)),new i.pointGeometry(0,0));super(h,{points:O,point:oe,lngLats:K,lngLat:_.unproject(oe),originalEvent:T}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class Mo extends i.Event{constructor(h,_,T){super(h,{originalEvent:T}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class rd{constructor(h,_){this._map=h,this._clickTolerance=_.clickTolerance}reset(){delete this._mousedownPos}wheel(h){return this._firePreventable(new Mo(h.type,this._map,h))}mousedown(h,_){return this._mousedownPos=_,this._firePreventable(new So(h.type,this._map,h))}mouseup(h){this._map.fire(new So(h.type,this._map,h))}click(h,_){this._mousedownPos&&this._mousedownPos.dist(_)>=this._clickTolerance||this._map.fire(new So(h.type,this._map,h))}dblclick(h){return this._firePreventable(new So(h.type,this._map,h))}mouseover(h){this._map.fire(new So(h.type,this._map,h))}mouseout(h){this._map.fire(new So(h.type,this._map,h))}touchstart(h){return this._firePreventable(new xa(h.type,this._map,h))}touchmove(h){this._map.fire(new xa(h.type,this._map,h))}touchend(h){this._map.fire(new xa(h.type,this._map,h))}touchcancel(h){this._map.fire(new xa(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ga{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(h){this._map.fire(new So(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new So("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._ignoreContextMenu||this._map.fire(new So(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class sd{constructor(h,_){this._map=h,this._el=h.getCanvasContainer(),this._container=h.getContainer(),this._clickTolerance=_.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(h,_){this.isEnabled()&&h.shiftKey&&h.button===0&&(R.disableDrag(),this._startPos=this._lastPos=_,this._active=!0)}mousemoveWindow(h,_){if(!this._active)return;const T=_;if(this._lastPos.equals(T)||!this._box&&T.dist(this._startPos)O.fitScreenCoordinates(T,F,this._map.getBearing(),{linear:!0})};this._fireEvent("boxzoomcancel",h)}keydown(h){this._active&&h.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",h))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair","mapboxgl-crosshair"),this._box&&(R.remove(this._box),this._box=null),R.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(h,_){return this._map.fire(new i.Event(h,{originalEvent:_}))}}function ml(M,h){if(M.length!==h.length)throw new Error(`The number of touches and points are not equal - touches ${M.length}, points ${h.length}`);const _={};for(let T=0;Tthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=h.timeStamp),T.length===this.numTouches&&(this.centroid=function(F){const O=new i.pointGeometry(0,0);for(const K of F)O._add(K);return O.div(F.length)}(_),this.touches=ml(T,_)))}touchmove(h,_,T){if(this.aborted||!this.centroid)return;const F=ml(T,_);for(const O in this.touches){const K=this.touches[O],oe=F[O];(!oe||oe.dist(K)>30)&&(this.aborted=!0)}}touchend(h,_,T){if((!this.centroid||h.timeStamp-this.startTime>500)&&(this.aborted=!0),T.length===0){const F=!this.aborted&&this.centroid;if(this.reset(),F)return F}}}class Oh{constructor(h){this.singleTap=new kh(h),this.numTaps=h.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(h,_,T){this.singleTap.touchstart(h,_,T)}touchmove(h,_,T){this.singleTap.touchmove(h,_,T)}touchend(h,_,T){const F=this.singleTap.touchend(h,_,T);if(F){const O=h.timeStamp-this.lastTime<500,K=!this.lastTap||this.lastTap.dist(F)<30;if(O&&K||this.reset(),this.count++,this.lastTime=h.timeStamp,this.lastTap=F,this.count===this.numTaps)return this.reset(),F}}}class lA{constructor(){this._zoomIn=new Oh({numTouches:1,numTaps:2}),this._zoomOut=new Oh({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(h,_,T){this._zoomIn.touchstart(h,_,T),this._zoomOut.touchstart(h,_,T)}touchmove(h,_,T){this._zoomIn.touchmove(h,_,T),this._zoomOut.touchmove(h,_,T)}touchend(h,_,T){const F=this._zoomIn.touchend(h,_,T),O=this._zoomOut.touchend(h,_,T);return F?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:K=>K.easeTo({duration:300,zoom:K.getZoom()+1,around:K.unproject(F)},{originalEvent:h})}):O?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:K=>K.easeTo({duration:300,zoom:K.getZoom()-1,around:K.unproject(O)},{originalEvent:h})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const od={0:1,2:2};class Nh{constructor(h){this.reset(),this._clickTolerance=h.clickTolerance||1}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(h,_){return!1}_move(h,_){return{}}mousedown(h,_){if(this._lastPoint)return;const T=R.mouseButton(h);this._correctButton(h,T)&&(this._lastPoint=_,this._eventButton=T)}mousemoveWindow(h,_){const T=this._lastPoint;if(T){if(h.preventDefault(),function(F,O){const K=od[O];return F.buttons===void 0||(F.buttons&K)!==K}(h,this._eventButton))this.reset();else if(this._moved||!(_.dist(T){this._cancelCooperativeMessage=!1},200)}touchstart(h,_,T){return this._calculateTransform(h,_,T)}touchmove(h,_,T){if(this._map._cooperativeGestures&&(this._minTouches===2&&T.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(h,!1,T.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(T.length0&&(this._active=!0);const F=ml(T,_),O=new i.pointGeometry(0,0),K=new i.pointGeometry(0,0);let oe=0;for(const ve in F){const Te=F[ve],ke=this._touches[ve];ke&&(O._add(Te),K._add(Te.sub(ke)),oe++,F[ve]=Te)}if(this._touches=F,oeMath.abs(M.x)}class cA extends Wl{constructor(h){super(),this._map=h}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(h,_,T){super.touchstart(h,_,T),this._currentTouchCount=T.length}_start(h){this._lastPoints=h,mc(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,_,T){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const F=h[0].sub(this._lastPoints[0]),O=h[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(F,O,T.timeStamp),this._valid?(this._lastPoints=h,this._active=!0,{pitchDelta:(F.y+O.y)/2*-.5}):void 0}gestureBeginsVertically(h,_,T){if(this._valid!==void 0)return this._valid;const F=h.mag()>=2,O=_.mag()>=2;if(!F&&!O)return;if(!F||!O)return this._firstMove===void 0&&(this._firstMove=T),T-this._firstMove<100&&void 0;const K=h.y>0==_.y>0;return mc(h)&&mc(_)&&K}}const Qh={panStep:100,bearingStep:15,pitchStep:10};class gc{constructor(){const h=Qh;this._panStep=h.panStep,this._bearingStep=h.bearingStep,this._pitchStep=h.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(h){if(h.altKey||h.ctrlKey||h.metaKey)return;let _=0,T=0,F=0,O=0,K=0;switch(h.keyCode){case 61:case 107:case 171:case 187:_=1;break;case 189:case 109:case 173:_=-1;break;case 37:h.shiftKey?T=-1:(h.preventDefault(),O=-1);break;case 39:h.shiftKey?T=1:(h.preventDefault(),O=1);break;case 38:h.shiftKey?F=1:(h.preventDefault(),K=-1);break;case 40:h.shiftKey?F=-1:(h.preventDefault(),K=1);break;default:return}return this._rotationDisabled&&(T=0,F=0),{cameraAnimation:oe=>{const ue=oe.getZoom();oe.easeTo({duration:300,easeId:"keyboardHandler",easing:hA,zoom:_?Math.round(ue)+_*(h.shiftKey?2:1):ue,bearing:oe.getBearing()+T*this._bearingStep,pitch:oe.getPitch()+F*this._pitchStep,offset:[-O*this._panStep,-K*this._panStep],center:oe.getCenter()},{originalEvent:h})}}}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 hA(M){return M*(2-M)}const uA=4.000244140625;class Vh{constructor(h,_){this._map=h,this._el=h.getCanvasContainer(),this._handler=_,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,i.bindAll(["_onTimeout"],this)}setZoomRate(h){this._defaultZoomRate=h}setWheelZoomRate(h){this._wheelZoomRate=h}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(h){this.isEnabled()||(this._enabled=!0,this._aroundCenter=h&&h.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(h){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!this._map._metaPress)return;h.preventDefault()}let _=h.deltaMode===WheelEvent.DOM_DELTA_LINE?40*h.deltaY:h.deltaY;const T=i.exported.now(),F=T-(this._lastWheelEventTime||0);this._lastWheelEventTime=T,_!==0&&_%uA==0?this._type="wheel":_!==0&&Math.abs(_)<4?this._type="trackpad":F>400?(this._type=null,this._lastValue=_,this._timeout=setTimeout(this._onTimeout,40,h)):this._type||(this._type=Math.abs(F*_)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,_+=this._lastValue)),h.shiftKey&&_&&(_/=4),this._type&&(this._lastWheelEvent=h,this._delta-=_,this._active||this._start(h)),h.preventDefault()}_onTimeout(h){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(h)}_start(h){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 _=R.mousePos(this._el,h);this._around=i.LngLat.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(_)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const h=this._map.transform;if(this._delta!==0){const oe=this._type==="wheel"&&Math.abs(this._delta)>uA?this._wheelZoomRate:this._defaultZoomRate;let ue=2/(1+Math.exp(-Math.abs(this._delta*oe)));this._delta<0&&ue!==0&&(ue=1/ue);const ve=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):h.scale;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(ve*ue))),this._type==="wheel"&&(this._startZoom=h.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const _=typeof this._targetZoom=="number"?this._targetZoom:h.zoom,T=this._startZoom,F=this._easing;let O,K=!1;if(this._type==="wheel"&&T&&F){const oe=Math.min((i.exported.now()-this._lastWheelEventTime)/200,1),ue=F(oe);O=i.number(T,_,ue),oe<1?this._frameId||(this._frameId=!0):K=!0}else O=_,K=!0;return this._active=!0,K&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!K,zoomDelta:O-h.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(h){let _=i.ease;if(this._prevEase){const T=this._prevEase,F=(i.exported.now()-T.start)/T.duration,O=T.easing(F+.01)-T.easing(F),K=.27/Math.sqrt(O*O+1e-4)*.01,oe=Math.sqrt(.0729-K*K);_=i.bezier(K,oe,.25,1)}return this._prevEase={start:i.exported.now(),duration:h,easing:_},_}reset(){this._active=!1}}class Hh{constructor(h,_){this._clickZoom=h,this._tapZoom=_}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 ih{constructor(){this.reset()}reset(){this._active=!1}dblclick(h,_){return h.preventDefault(),{cameraAnimation:T=>{T.easeTo({duration:300,zoom:T.getZoom()+(h.shiftKey?-1:1),around:T.unproject(_)},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class _c{constructor(){this._tap=new Oh({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(h,_,T){this._swipePoint||(this._tapTime&&h.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?T.length>0&&(this._swipePoint=_[0],this._swipeTouch=T[0].identifier):this._tap.touchstart(h,_,T))}touchmove(h,_,T){if(this._tapTime){if(this._swipePoint){if(T[0].identifier!==this._swipeTouch)return;const F=_[0],O=F.y-this._swipePoint.y;return this._swipePoint=F,h.preventDefault(),this._active=!0,{zoomDelta:O/128}}}else this._tap.touchmove(h,_,T)}touchend(h,_,T){this._tapTime?this._swipePoint&&T.length===0&&this.reset():this._tap.touchend(h,_,T)&&(this._tapTime=h.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Is{constructor(h,_,T){this._el=h,this._mousePan=_,this._touchPan=T}enable(h){this._inertiaOptions=h||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class fo{constructor(h,_,T){this._pitchWithRotate=h.pitchWithRotate,this._mouseRotate=_,this._mousePitch=T}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 Gh{constructor(h,_,T,F){this._el=h,this._touchZoom=_,this._touchRotate=T,this._tapDragZoom=F,this._rotationDisabled=!1,this._enabled=!0}enable(h){this._touchZoom.enable(h),this._rotationDisabled||this._touchRotate.enable(h),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate","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 jl=M=>M.zoom||M.drag||M.pitch||M.rotate;class Kl extends i.Event{}function _l(M){return M.panDelta&&M.panDelta.mag()||M.zoomDelta||M.bearingDelta||M.pitchDelta}class An{constructor(h,_){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Yc(h),this._bearingSnap=_.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(_),i.bindAll(["handleEvent","handleWindowEvent"],this);const T=this._el;this._listeners=[[T,"touchstart",{passive:!0}],[T,"touchmove",{passive:!1}],[T,"touchend",void 0],[T,"touchcancel",void 0],[T,"mousedown",void 0],[T,"mousemove",void 0],[T,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[T,"mouseover",void 0],[T,"mouseout",void 0],[T,"dblclick",void 0],[T,"click",void 0],[T,"keydown",{capture:!1}],[T,"keyup",void 0],[T,"wheel",{passive:!1}],[T,"contextmenu",void 0],[window,"blur",void 0]];for(const[F,O,K]of this._listeners)R.addEventListener(F,O,F===document?this.handleWindowEvent:this.handleEvent,K)}destroy(){for(const[h,_,T]of this._listeners)R.removeEventListener(h,_,h===document?this.handleWindowEvent:this.handleEvent,T)}_addDefaultHandlers(h){const _=this._map,T=_.getCanvasContainer();this._add("mapEvent",new rd(_,h));const F=_.boxZoom=new sd(_,h);this._add("boxZoom",F);const O=new lA,K=new ih;_.doubleClickZoom=new Hh(K,O),this._add("tapZoom",O),this._add("clickZoom",K);const oe=new _c;this._add("tapDragZoom",oe);const ue=_.touchPitch=new cA(_);this._add("touchPitch",ue);const ve=new ua(h),Te=new pn(h);_.dragRotate=new fo(h,ve,Te),this._add("mouseRotate",ve,["mousePitch"]),this._add("mousePitch",Te,["mouseRotate"]);const ke=new fc(h),We=new eh(h,_);_.dragPan=new Is(T,ke,We),this._add("mousePan",ke),this._add("touchPan",We,["touchZoom","touchRotate"]);const bt=new Ur,mt=new un;_.touchZoomRotate=new Gh(T,mt,bt,oe),this._add("touchRotate",bt,["touchPan","touchZoom"]),this._add("touchZoom",mt,["touchPan","touchRotate"]);const gt=_.scrollZoom=new Vh(_,this);this._add("scrollZoom",gt,["mousePan"]);const Vt=_.keyboard=new gc;this._add("keyboard",Vt),this._add("blockableMapEvent",new Ga(_));for(const Zt of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])h.interactive&&h[Zt]&&_[Zt].enable(h[Zt])}_add(h,_,T){this._handlers.push({handlerName:h,handler:_,allowed:T}),this._handlersById[h]=_}stop(h){if(!this._updatingCamera){for(const{handler:_}of this._handlers)_.reset();this._inertia.clear(),this._fireEvents({},{},h),this._changes=[]}}isActive(){for(const{handler:h}of this._handlers)if(h.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(jl(this._eventsInProgress))||this.isZooming()}_blockedByActive(h,_,T){for(const F in h)if(F!==T&&(!_||_.indexOf(F)<0))return!0;return!1}handleWindowEvent(h){this.handleEvent(h,`${h.type}Window`)}_getMapTouches(h){const _=[];for(const T of h)this._el.contains(T.target)&&_.push(T);return _}handleEvent(h,_){if(h.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const T=h.type==="renderFrame"?void 0:h,F={needsRenderFrame:!1},O={},K={},oe=h.touches,ue=oe?this._getMapTouches(oe):void 0,ve=ue?R.touchPos(this._el,ue):R.mousePos(this._el,h);for(const{handlerName:We,handler:bt,allowed:mt}of this._handlers){if(!bt.isEnabled())continue;let gt;this._blockedByActive(K,mt,We)?bt.reset():bt[_||h.type]&&(gt=bt[_||h.type](h,ve,ue),this.mergeHandlerResult(F,O,gt,We,T),gt&>.needsRenderFrame&&this._triggerRenderFrame()),(gt||bt.isActive())&&(K[We]=bt)}const Te={};for(const We in this._previousActiveHandlers)K[We]||(Te[We]=T);this._previousActiveHandlers=K,(Object.keys(Te).length||_l(F))&&(this._changes.push([F,O,Te]),this._triggerRenderFrame()),(Object.keys(K).length||_l(F))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ke}=F;ke&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ke(this._map))}mergeHandlerResult(h,_,T,F,O){if(!T)return;i.extend(h,T);const K={handlerName:F,originalEvent:T.originalEvent||O};T.zoomDelta!==void 0&&(_.zoom=K),T.panDelta!==void 0&&(_.drag=K),T.pitchDelta!==void 0&&(_.pitch=K),T.bearingDelta!==void 0&&(_.rotate=K)}_applyChanges(){const h={},_={},T={};for(const[F,O,K]of this._changes)F.panDelta&&(h.panDelta=(h.panDelta||new i.pointGeometry(0,0))._add(F.panDelta)),F.zoomDelta&&(h.zoomDelta=(h.zoomDelta||0)+F.zoomDelta),F.bearingDelta&&(h.bearingDelta=(h.bearingDelta||0)+F.bearingDelta),F.pitchDelta&&(h.pitchDelta=(h.pitchDelta||0)+F.pitchDelta),F.around!==void 0&&(h.around=F.around),F.pinchAround!==void 0&&(h.pinchAround=F.pinchAround),F.noInertia&&(h.noInertia=F.noInertia),i.extend(_,O),i.extend(T,K);this._updateMapTransform(h,_,T),this._changes=[]}_updateMapTransform(h,_,T){const F=this._map,O=F.transform,K=F.style&&F.style.terrain;if(!(_l(h)||K&&this._drag))return this._fireEvents(_,T,!0);let{panDelta:oe,zoomDelta:ue,bearingDelta:ve,pitchDelta:Te,around:ke,pinchAround:We}=h;We!==void 0&&(ke=We),F._stop(!0),ke=ke||F.transform.centerPoint;const bt=O.pointLocation(oe?ke.sub(oe):ke);ve&&(O.bearing+=ve),Te&&(O.pitch+=Te),ue&&(O.zoom+=ue),K?_.drag&&!this._drag?(this._drag={center:O.centerPoint,lngLat:O.pointLocation(ke),point:ke,handlerName:_.drag.handlerName},F.fire(new i.Event("freezeElevation",{freeze:!0}))):this._drag&&T[this._drag.handlerName]?(F.fire(new i.Event("freezeElevation",{freeze:!1})),this._drag=null):_.drag&&this._drag&&(O.center=O.pointLocation(O.centerPoint.sub(oe))):O.setLocationAtPoint(bt,ke),this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(_,T,!0)}_fireEvents(h,_,T){const F=jl(this._eventsInProgress),O=jl(h),K={};for(const Te in h){const{originalEvent:ke}=h[Te];this._eventsInProgress[Te]||(K[`${Te}start`]=ke),this._eventsInProgress[Te]=h[Te]}!F&&O&&this._fireEvent("movestart",O.originalEvent);for(const Te in K)this._fireEvent(Te,K[Te]);O&&this._fireEvent("move",O.originalEvent);for(const Te in h){const{originalEvent:ke}=h[Te];this._fireEvent(Te,ke)}const oe={};let ue;for(const Te in this._eventsInProgress){const{handlerName:ke,originalEvent:We}=this._eventsInProgress[Te];this._handlersById[ke].isActive()||(delete this._eventsInProgress[Te],ue=_[ke]||We,oe[`${Te}end`]=ue)}for(const Te in oe)this._fireEvent(Te,oe[Te]);const ve=jl(this._eventsInProgress);if(T&&(F||O)&&!ve){this._updatingCamera=!0;const Te=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),ke=We=>We!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Kl("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const vs={extend:(M,...h)=>i.extend(M,...h),run(M){M()},logToElement(M,h=!1,_="log"){const T=window.document.getElementById(_);T&&(h&&(T.innerHTML=""),T.innerHTML+=`
${M}`)}};class Zr extends i.Evented{constructor(h,_){super(),this._moving=!1,this._zooming=!1,this.transform=h,this._bearingSnap=_.bearingSnap,i.bindAll(["_renderFrameCallback"],this)}getCenter(){return new i.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(h,_){return this.jumpTo({center:h},_)}panBy(h,_,T){return h=i.pointGeometry.convert(h).mult(-1),this.panTo(this.transform.center,i.extend({offset:h},_),T)}panTo(h,_,T){return this.easeTo(i.extend({center:h},_),T)}getZoom(){return this.transform.zoom}setZoom(h,_){return this.jumpTo({zoom:h},_),this}zoomTo(h,_,T){return this.easeTo(i.extend({zoom:h},_),T)}zoomIn(h,_){return this.zoomTo(this.getZoom()+1,h,_),this}zoomOut(h,_){return this.zoomTo(this.getZoom()-1,h,_),this}getBearing(){return this.transform.bearing}setBearing(h,_){return this.jumpTo({bearing:h},_),this}getPadding(){return this.transform.padding}setPadding(h,_){return this.jumpTo({padding:h},_),this}rotateTo(h,_,T){return this.easeTo(i.extend({bearing:h},_),T)}resetNorth(h,_){return this.rotateTo(0,i.extend({duration:1e3},h),_),this}resetNorthPitch(h,_){return this.easeTo(i.extend({bearing:0,pitch:0,duration:1e3},h),_),this}snapToNorth(h,_){return Math.abs(this.getBearing()){if(this._zooming&&(T.zoom=i.number(F,ue,Ei)),this._rotating&&(T.bearing=i.number(O,ve,Ei)),this._pitching&&(T.pitch=i.number(K,Te,Ei)),this._padding&&(T.interpolatePadding(oe,ke,Ei),bt=T.centerPoint.add(We)),St)T.setLocationAtPoint(St,zt);else{const bi=T.zoomScale(T.zoom-F),Hi=ue>F?Math.min(2,ni):Math.max(.5,ni),xi=Math.pow(Hi,1-Ei),xn=T.unproject(Vt.add(Zt.mult(Ei*xi)).mult(bi));T.setLocationAtPoint(T.renderWorldCopies?xn.wrap():xn,bt)}this._fireMoveEvents(_)},Ei=>{this._afterEase(_,Ei)},h),this}_prepareEase(h,_,T={}){this._moving=!0,this.fire(new i.Event("freezeElevation",{freeze:!0})),_||T.moving||this.fire(new i.Event("movestart",h)),this._zooming&&!T.zooming&&this.fire(new i.Event("zoomstart",h)),this._rotating&&!T.rotating&&this.fire(new i.Event("rotatestart",h)),this._pitching&&!T.pitching&&this.fire(new i.Event("pitchstart",h))}_fireMoveEvents(h){this.fire(new i.Event("move",h)),this._zooming&&this.fire(new i.Event("zoom",h)),this._rotating&&this.fire(new i.Event("rotate",h)),this._pitching&&this.fire(new i.Event("pitch",h))}_afterEase(h,_){if(this._easeId&&_&&this._easeId===_)return;delete this._easeId,this.fire(new i.Event("freezeElevation",{freeze:!1}));const T=this._zooming,F=this._rotating,O=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,T&&this.fire(new i.Event("zoomend",h)),F&&this.fire(new i.Event("rotateend",h)),O&&this.fire(new i.Event("pitchend",h)),this.fire(new i.Event("moveend",h))}flyTo(h,_){if(!h.essential&&i.exported.prefersReducedMotion){const Un=i.pick(h,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Un,_)}this.stop(),h=i.extend({offset:[0,0],speed:1.2,curve:1.42,easing:i.ease},h);const T=this.transform,F=this.getZoom(),O=this.getBearing(),K=this.getPitch(),oe=this.getPadding(),ue="zoom"in h?i.clamp(+h.zoom,T.minZoom,T.maxZoom):F,ve="bearing"in h?this._normalizeBearing(h.bearing,O):O,Te="pitch"in h?+h.pitch:K,ke="padding"in h?h.padding:T.padding,We=T.zoomScale(ue-F),bt=i.pointGeometry.convert(h.offset);let mt=T.centerPoint.add(bt);const gt=T.pointLocation(mt),Vt=i.LngLat.convert(h.center||gt);this._normalizeCenter(Vt);const Zt=T.project(gt),ni=T.project(Vt).sub(Zt);let St=h.curve;const zt=Math.max(T.width,T.height),li=zt/We,Ei=ni.mag();if("minZoom"in h){const Un=i.clamp(Math.min(h.minZoom,F,ue),T.minZoom,T.maxZoom),Lr=zt/T.zoomScale(Un-F);St=Math.sqrt(Lr/Ei*2)}const bi=St*St;function Hi(Un){const Lr=(li*li-zt*zt+(Un?-1:1)*bi*bi*Ei*Ei)/(2*(Un?li:zt)*bi*Ei);return Math.log(Math.sqrt(Lr*Lr+1)-Lr)}function xi(Un){return(Math.exp(Un)-Math.exp(-Un))/2}function xn(Un){return(Math.exp(Un)+Math.exp(-Un))/2}const cn=Hi(0);let Bn=function(Un){return xn(cn)/xn(cn+St*Un)},tr=function(Un){return zt*((xn(cn)*(xi(Lr=cn+St*Un)/xn(Lr))-xi(cn))/bi)/Ei;var Lr},ur=(Hi(1)-cn)/St;if(Math.abs(Ei)<1e-6||!isFinite(ur)){if(Math.abs(zt-li)<1e-6)return this.easeTo(h,_);const Un=lih.maxDuration&&(h.duration=0),this._zooming=!0,this._rotating=O!==ve,this._pitching=Te!==K,this._padding=!T.isPaddingEqual(ke),this._prepareEase(_,!1),this._ease(Un=>{const Lr=Un*ur,Rr=1/Bn(Lr);T.zoom=Un===1?ue:F+T.scaleZoom(Rr),this._rotating&&(T.bearing=i.number(O,ve,Un)),this._pitching&&(T.pitch=i.number(K,Te,Un)),this._padding&&(T.interpolatePadding(oe,ke,Un),mt=T.centerPoint.add(bt));const Cr=Un===1?Vt:T.unproject(Zt.add(ni.mult(tr(Lr))).mult(Rr));T.setLocationAtPoint(T.renderWorldCopies?Cr.wrap():Cr,mt),this._fireMoveEvents(_)},()=>this._afterEase(_),h),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(h,_){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const T=this._onEaseEnd;delete this._onEaseEnd,T.call(this,_)}if(!h){const T=this.handlers;T&&T.stop(!1)}return this}_ease(h,_,T){T.animate===!1||T.duration===0?(h(1),_()):(this._easeStart=i.exported.now(),this._easeOptions=T,this._onEaseFrame=h,this._onEaseEnd=_,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const h=Math.min((i.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(h)),h<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(h,_){h=i.wrap(h,-180,180);const T=Math.abs(h-_);return Math.abs(h-360-_)180?-360:T<-180?360:0}}class nh{constructor(h={}){this.options=h,i.bindAll(["_toggleAttribution","_updateData","_updateCompact","_updateCompactMinimize"],this)}getDefaultPosition(){return"bottom-right"}onAdd(h){return this._map=h,this._compact=this.options&&this.options.compact,this._container=R.create("details","maplibregl-ctrl maplibregl-ctrl-attrib mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=R.create("summary","maplibregl-ctrl-attrib-button mapboxgl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=R.create("div","maplibregl-ctrl-attrib-inner mapboxgl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){R.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(h,_){const T=this._map._getUIString(`AttributionControl.${_}`);h.title=T,h.setAttribute("aria-label",T)}_toggleAttribution(){this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show")):(this._container.classList.add("maplibregl-compact-show","mapboxgl-compact-show"),this._container.removeAttribute("open")))}_updateData(h){!h||h.sourceDataType!=="metadata"&&h.sourceDataType!=="visibility"&&h.dataType!=="style"&&h.type!=="terrain"||this._updateAttributions()}_updateAttributions(){if(!this._map.style)return;let h=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?h=h.concat(this.options.customAttribution.map(F=>typeof F!="string"?"":F)):typeof this.options.customAttribution=="string"&&h.push(this.options.customAttribution)),this._map.style.stylesheet){const F=this._map.style.stylesheet;this.styleOwner=F.owner,this.styleId=F.id}const _=this._map.style.sourceCaches;for(const F in _){const O=_[F];if(O.used||O.usedForTerrain){const K=O.getSource();K.attribution&&h.indexOf(K.attribution)<0&&h.push(K.attribution)}}h=h.filter(F=>String(F).trim()),h.sort((F,O)=>F.length-O.length),h=h.filter((F,O)=>{for(let K=O+1;K=0)return!1;return!0});const T=h.join(" | ");T!==this._attribHTML&&(this._attribHTML=T,h.length?(this._innerContainer.innerHTML=T,this._container.classList.remove("maplibregl-attrib-empty","mapboxgl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty","mapboxgl-attrib-empty"),this._updateCompact(),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","mapboxgl-compact","maplibregl-compact-show","mapboxgl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show","mapboxgl-compact","mapboxgl-compact-show"))}_updateCompactMinimize(){this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show")}}class Wh{constructor(h={}){this.options=h,i.bindAll(["_updateCompact"],this)}getDefaultPosition(){return"bottom-left"}onAdd(h){this._map=h,this._compact=this.options&&this.options.compact,this._container=R.create("div","maplibregl-ctrl mapboxgl-ctrl");const _=R.create("a","maplibregl-ctrl-logo mapboxgl-ctrl-logo");return _.target="_blank",_.rel="noopener nofollow",_.href="https://maplibre.org/",_.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),_.setAttribute("rel","noopener nofollow"),this._container.appendChild(_),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){R.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}_updateCompact(){const h=this._container.children;if(h.length){const _=h[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&_.classList.add("maplibregl-compact","mapboxgl-compact"):_.classList.remove("maplibregl-compact","mapboxgl-compact")}}}class yc{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(h){const _=++this._id;return this._queue.push({callback:h,id:_,cancelled:!1}),_}remove(h){const _=this._currentlyRunning,T=_?this._queue.concat(_):this._queue;for(const F of T)if(F.id===h)return void(F.cancelled=!0)}run(h=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const _=this._currentlyRunning=this._queue;this._queue=[];for(const T of _)if(!T.cancelled&&(T.callback(h),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}const AA={"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","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"},jh={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:void 0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",transformRequest:null,fadeDuration:300,crossSourceCollisions:!0},rh={showCompass:!0,showZoom:!0,visualizePitch:!1};class uo{constructor(h,_,T=!1){this._clickTolerance=10,this.element=_,this.mouseRotate=new ua({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,T&&(this.mousePitch=new pn({clickTolerance:h.dragRotate._mousePitch._clickTolerance})),i.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),R.addEventListener(_,"mousedown",this.mousedown),R.addEventListener(_,"touchstart",this.touchstart,{passive:!1}),R.addEventListener(_,"touchmove",this.touchmove),R.addEventListener(_,"touchend",this.touchend),R.addEventListener(_,"touchcancel",this.reset)}down(h,_){this.mouseRotate.mousedown(h,_),this.mousePitch&&this.mousePitch.mousedown(h,_),R.disableDrag()}move(h,_){const T=this.map,F=this.mouseRotate.mousemoveWindow(h,_);if(F&&F.bearingDelta&&T.setBearing(T.getBearing()+F.bearingDelta),this.mousePitch){const O=this.mousePitch.mousemoveWindow(h,_);O&&O.pitchDelta&&T.setPitch(T.getPitch()+O.pitchDelta)}}off(){const h=this.element;R.removeEventListener(h,"mousedown",this.mousedown),R.removeEventListener(h,"touchstart",this.touchstart,{passive:!1}),R.removeEventListener(h,"touchmove",this.touchmove),R.removeEventListener(h,"touchend",this.touchend),R.removeEventListener(h,"touchcancel",this.reset),this.offTemp()}offTemp(){R.enableDrag(),R.removeEventListener(window,"mousemove",this.mousemove),R.removeEventListener(window,"mouseup",this.mouseup)}mousedown(h){this.down(i.extend({},h,{ctrlKey:!0,preventDefault:()=>h.preventDefault()}),R.mousePos(this.element,h)),R.addEventListener(window,"mousemove",this.mousemove),R.addEventListener(window,"mouseup",this.mouseup)}mousemove(h){this.move(h,R.mousePos(this.element,h))}mouseup(h){this.mouseRotate.mouseupWindow(h),this.mousePitch&&this.mousePitch.mouseupWindow(h),this.offTemp()}touchstart(h){h.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=R.touchPos(this.element,h.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>h.preventDefault()},this._startPos))}touchmove(h){h.targetTouches.length!==1?this.reset():(this._lastPos=R.touchPos(this.element,h.targetTouches)[0],this.move({preventDefault:()=>h.preventDefault()},this._lastPos))}touchend(h){h.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)180;){const T=_.locationPoint(M);if(T.x>=0&&T.y>=0&&T.x<=_.width&&T.y<=_.height)break;M.lng>_.center.lng?M.lng-=360:M.lng+=360}return M}const Fn={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Vn(M,h,_){const T=M.classList;for(const F in Fn)T.remove(`maplibregl-${_}-anchor-${F}`,`mapboxgl-${_}-anchor-${F}`);T.add(`maplibregl-${_}-anchor-${h}`,`mapboxgl-${_}-anchor-${h}`)}class sh extends i.Evented{constructor(h,_){if(super(),(h instanceof HTMLElement||_)&&(h=i.extend({element:h},_)),i.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress"],this),this._anchor=h&&h.anchor||"center",this._color=h&&h.color||"#3FB1CE",this._scale=h&&h.scale||1,this._draggable=h&&h.draggable||!1,this._clickTolerance=h&&h.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=h&&h.rotation||0,this._rotationAlignment=h&&h.rotationAlignment||"auto",this._pitchAlignment=h&&h.pitchAlignment&&h.pitchAlignment!=="auto"?h.pitchAlignment:this._rotationAlignment,h&&h.element)this._element=h.element,this._offset=i.pointGeometry.convert(h&&h.offset||[0,0]);else{this._defaultMarker=!0,this._element=R.create("div"),this._element.setAttribute("aria-label","Map marker");const T=R.createNS("http://www.w3.org/2000/svg","svg"),F=41,O=27;T.setAttributeNS(null,"display","block"),T.setAttributeNS(null,"height",`${F}px`),T.setAttributeNS(null,"width",`${O}px`),T.setAttributeNS(null,"viewBox",`0 0 ${O} ${F}`);const K=R.createNS("http://www.w3.org/2000/svg","g");K.setAttributeNS(null,"stroke","none"),K.setAttributeNS(null,"stroke-width","1"),K.setAttributeNS(null,"fill","none"),K.setAttributeNS(null,"fill-rule","evenodd");const oe=R.createNS("http://www.w3.org/2000/svg","g");oe.setAttributeNS(null,"fill-rule","nonzero");const ue=R.createNS("http://www.w3.org/2000/svg","g");ue.setAttributeNS(null,"transform","translate(3.0, 29.0)"),ue.setAttributeNS(null,"fill","#000000");const ve=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const ni of ve){const St=R.createNS("http://www.w3.org/2000/svg","ellipse");St.setAttributeNS(null,"opacity","0.04"),St.setAttributeNS(null,"cx","10.5"),St.setAttributeNS(null,"cy","5.80029008"),St.setAttributeNS(null,"rx",ni.rx),St.setAttributeNS(null,"ry",ni.ry),ue.appendChild(St)}const Te=R.createNS("http://www.w3.org/2000/svg","g");Te.setAttributeNS(null,"fill",this._color);const ke=R.createNS("http://www.w3.org/2000/svg","path");ke.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),Te.appendChild(ke);const We=R.createNS("http://www.w3.org/2000/svg","g");We.setAttributeNS(null,"opacity","0.25"),We.setAttributeNS(null,"fill","#000000");const bt=R.createNS("http://www.w3.org/2000/svg","path");bt.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),We.appendChild(bt);const mt=R.createNS("http://www.w3.org/2000/svg","g");mt.setAttributeNS(null,"transform","translate(6.0, 7.0)"),mt.setAttributeNS(null,"fill","#FFFFFF");const gt=R.createNS("http://www.w3.org/2000/svg","g");gt.setAttributeNS(null,"transform","translate(8.0, 8.0)");const Vt=R.createNS("http://www.w3.org/2000/svg","circle");Vt.setAttributeNS(null,"fill","#000000"),Vt.setAttributeNS(null,"opacity","0.25"),Vt.setAttributeNS(null,"cx","5.5"),Vt.setAttributeNS(null,"cy","5.5"),Vt.setAttributeNS(null,"r","5.4999962");const Zt=R.createNS("http://www.w3.org/2000/svg","circle");Zt.setAttributeNS(null,"fill","#FFFFFF"),Zt.setAttributeNS(null,"cx","5.5"),Zt.setAttributeNS(null,"cy","5.5"),Zt.setAttributeNS(null,"r","5.4999962"),gt.appendChild(Vt),gt.appendChild(Zt),oe.appendChild(ue),oe.appendChild(Te),oe.appendChild(We),oe.appendChild(mt),oe.appendChild(gt),T.appendChild(oe),T.setAttributeNS(null,"height",F*this._scale+"px"),T.setAttributeNS(null,"width",O*this._scale+"px"),this._element.appendChild(T),this._offset=i.pointGeometry.convert(h&&h.offset||[0,-14])}this._element.classList.add("maplibregl-marker","mapboxgl-marker"),this._element.addEventListener("dragstart",T=>{T.preventDefault()}),this._element.addEventListener("mousedown",T=>{T.preventDefault()}),Vn(this._element,this._anchor,"marker"),this._popup=null}addTo(h){return this.remove(),this._map=h,h.getCanvasContainer().appendChild(this._element),h.on("move",this._update),h.on("moveend",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),R.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=i.LngLat.convert(h),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(h){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),h){if(!("offset"in h.options)){const F=Math.sqrt(Math.pow(13.5,2)/2);h.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[F,-1*(38.1-13.5+F)],"bottom-right":[-F,-1*(38.1-13.5+F)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=h,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}_onKeyPress(h){const _=h.code,T=h.charCode||h.keyCode;_!=="Space"&&_!=="Enter"&&T!==32&&T!==13||this.togglePopup()}_onMapClick(h){const _=h.originalEvent.target,T=this._element;this._popup&&(_===T||T.contains(_))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const h=this._popup;return h?(h.isOpen()?h.remove():h.addTo(this._map),this):this}_update(h){if(!this._map)return;this._map.transform.renderWorldCopies&&(this._lngLat=Js(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let _="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?_=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(_=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let T="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?T="rotateX(0deg)":this._pitchAlignment==="map"&&(T=`rotateX(${this._map.getPitch()}deg)`),h&&h.type!=="moveend"||(this._pos=this._pos.round()),R.setTransform(this._element,`${Fn[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${T} ${_}`),this._map.style&&this._map.style.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout(()=>{const F=this._map.unproject(this._pos),O=40075016686e-3*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=F.distanceTo(this._lngLat)>20*O?"0.2":"1.0",this._opacityTimeout=null},100))}getOffset(){return this._offset}setOffset(h){return this._offset=i.pointGeometry.convert(h),this._update(),this}_onMove(h){if(!this._isDragging){const _=this._clickTolerance||this._map._clickTolerance;this._isDragging=h.point.dist(this._pointerdownPos)>=_}this._isDragging&&(this._pos=h.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new i.Event("dragstart"))),this.fire(new i.Event("drag")))}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new i.Event("dragend")),this._state="inactive"}_addDragHandler(h){this._element.contains(h.originalEvent.target)&&(h.preventDefault(),this._positionDelta=h.point.sub(this._pos).add(this._offset),this._pointerdownPos=h.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))}setDraggable(h){return this._draggable=!!h,this._map&&(h?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(h){return this._rotation=h||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(h){return this._rotationAlignment=h||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(h){return this._pitchAlignment=h&&h!=="auto"?h:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const dA={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let yl,Es=0,Wa=!1;const Go={maxWidth:100,unit:"metric"};function pA(M,h,_){const T=_&&_.maxWidth||100,F=M._container.clientHeight/2,O=M.unproject([0,F]),K=M.unproject([T,F]),oe=O.distanceTo(K);if(_&&_.unit==="imperial"){const ue=3.2808*oe;ue>5280?va(h,T,ue/5280,M._getUIString("ScaleControl.Miles")):va(h,T,ue,M._getUIString("ScaleControl.Feet"))}else _&&_.unit==="nautical"?va(h,T,oe/1852,M._getUIString("ScaleControl.NauticalMiles")):oe>=1e3?va(h,T,oe/1e3,M._getUIString("ScaleControl.Kilometers")):va(h,T,oe,M._getUIString("ScaleControl.Meters"))}function va(M,h,_,T){const F=function(O){const K=Math.pow(10,`${Math.floor(O)}`.length-1);let oe=O/K;return oe=oe>=10?10:oe>=5?5:oe>=3?3:oe>=2?2:oe>=1?1:function(ue){const ve=Math.pow(10,Math.ceil(-Math.log(ue)/Math.LN10));return Math.round(ue*ve)/ve}(oe),K*oe}(_);M.style.width=h*(F/_)+"px",M.innerHTML=`${F} ${T}`}const us={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Fs=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Kh(M){if(M){if(typeof M=="number"){const h=Math.round(Math.sqrt(.5*Math.pow(M,2)));return{center:new i.pointGeometry(0,0),top:new i.pointGeometry(0,M),"top-left":new i.pointGeometry(h,h),"top-right":new i.pointGeometry(-h,h),bottom:new i.pointGeometry(0,-M),"bottom-left":new i.pointGeometry(h,-h),"bottom-right":new i.pointGeometry(-h,-h),left:new i.pointGeometry(M,0),right:new i.pointGeometry(-M,0)}}if(M instanceof i.pointGeometry||Array.isArray(M)){const h=i.pointGeometry.convert(M);return{center:h,top:h,"top-left":h,"top-right":h,bottom:h,"bottom-left":h,"bottom-right":h,left:h,right:h}}return{center:i.pointGeometry.convert(M.center||[0,0]),top:i.pointGeometry.convert(M.top||[0,0]),"top-left":i.pointGeometry.convert(M["top-left"]||[0,0]),"top-right":i.pointGeometry.convert(M["top-right"]||[0,0]),bottom:i.pointGeometry.convert(M.bottom||[0,0]),"bottom-left":i.pointGeometry.convert(M["bottom-left"]||[0,0]),"bottom-right":i.pointGeometry.convert(M["bottom-right"]||[0,0]),left:i.pointGeometry.convert(M.left||[0,0]),right:i.pointGeometry.convert(M.right||[0,0])}}return Kh(new i.pointGeometry(0,0))}const xl={supported:C,setRTLTextPlugin:i.setRTLTextPlugin,getRTLTextPluginStatus:i.getRTLTextPluginStatus,Map:class extends Zr{constructor(M){var h;if(i.PerformanceUtils.mark(i.PerformanceMarkers.create),(M=i.extend({},jh,M)).minZoom!=null&&M.maxZoom!=null&&M.minZoom>M.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(M.minPitch!=null&&M.maxPitch!=null&&M.minPitch>M.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(M.minPitch!=null&&M.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(M.maxPitch!=null&&M.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new qc(M.minZoom,M.maxZoom,M.minPitch,M.maxPitch,M.renderWorldCopies),{bearingSnap:M.bearingSnap}),this._interactive=M.interactive,this._cooperativeGestures=M.cooperativeGestures,this._maxTileCacheSize=M.maxTileCacheSize,this._failIfMajorPerformanceCaveat=M.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=M.preserveDrawingBuffer,this._antialias=M.antialias,this._trackResize=M.trackResize,this._bearingSnap=M.bearingSnap,this._refreshExpiredTiles=M.refreshExpiredTiles,this._fadeDuration=M.fadeDuration,this._crossSourceCollisions=M.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=M.collectResourceTiming,this._renderTaskQueue=new yc,this._controls=[],this._mapId=i.uniqueId(),this._locale=i.extend({},AA,M.locale),this._clickTolerance=M.clickTolerance,this._pixelRatio=(h=M.pixelRatio)!==null&&h!==void 0?h:devicePixelRatio,this._requestManager=new G(M.transformRequest),typeof M.container=="string"){if(this._container=document.getElementById(M.container),!this._container)throw new Error(`Container '${M.container}' not found.`)}else{if(!(M.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=M.container}if(M.maxBounds&&this.setMaxBounds(M.maxBounds),i.bindAll(["_onWindowOnline","_onWindowResize","_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)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),typeof window<"u"&&(addEventListener("online",this._onWindowOnline,!1),addEventListener("resize",this._onWindowResize,!1),addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new An(this,M),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=M.hash&&new Uh(typeof M.hash=="string"&&M.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:M.center,zoom:M.zoom,bearing:M.bearing,pitch:M.pitch}),M.bounds&&(this.resize(),this.fitBounds(M.bounds,i.extend({},M.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=M.localIdeographFontFamily,M.style&&this.setStyle(M.style,{localIdeographFontFamily:M.localIdeographFontFamily}),M.attributionControl&&this.addControl(new nh({customAttribution:M.customAttribution})),M.maplibreLogo&&this.addControl(new Wh,M.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",_=>{this._update(_.dataType==="style"),this.fire(new i.Event(`${_.dataType}data`,_))}),this.on("dataloading",_=>{this.fire(new i.Event(`${_.dataType}dataloading`,_))}),this.on("dataabort",_=>{this.fire(new i.Event("sourcedataabort",_))})}_getMapId(){return this._mapId}addControl(M,h){if(h===void 0&&(h=M.getDefaultPosition?M.getDefaultPosition():"top-right"),!M||!M.onAdd)return this.fire(new i.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const _=M.onAdd(this);this._controls.push(M);const T=this._controlPositions[h];return h.indexOf("bottom")!==-1?T.insertBefore(_,T.firstChild):T.appendChild(_),this}removeControl(M){if(!M||!M.onRemove)return this.fire(new i.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const h=this._controls.indexOf(M);return h>-1&&this._controls.splice(h,1),M.onRemove(this),this}hasControl(M){return this._controls.indexOf(M)>-1}calculateCameraOptionsFromTo(M,h,_,T){return T==null&&this.style.terrain&&(T=this.transform.getElevation(_,this.style.terrain)),super.calculateCameraOptionsFromTo(M,h,_,T)}resize(M){const h=this._containerDimensions(),_=h[0],T=h[1];this._resizeCanvas(_,T,this.getPixelRatio()),this.transform.resize(_,T),this.painter.resize(_,T,this.getPixelRatio());const F=!this._moving;return F&&(this.stop(),this.fire(new i.Event("movestart",M)).fire(new i.Event("move",M))),this.fire(new i.Event("resize",M)),F&&this.fire(new i.Event("moveend",M)),this}getPixelRatio(){return this._pixelRatio}setPixelRatio(M){const[h,_]=this._containerDimensions();this._pixelRatio=M,this._resizeCanvas(h,_,M),this.painter.resize(h,_,M)}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(M){return this.transform.setMaxBounds(i.LngLatBounds.convert(M)),this._update()}setMinZoom(M){if((M=M==null?-2:M)>=-2&&M<=this.transform.maxZoom)return this.transform.minZoom=M,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=M,this._update(),this.getZoom()>M&&this.setZoom(M),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(M){if((M=M==null?0:M)<0)throw new Error("minPitch must be greater than or equal to 0");if(M>=0&&M<=this.transform.maxPitch)return this.transform.minPitch=M,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(M>=this.transform.minPitch)return this.transform.maxPitch=M,this._update(),this.getPitch()>M&&this.setPitch(M),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(M){return this.transform.renderWorldCopies=M,this._update()}project(M){return this.transform.locationPoint(i.LngLat.convert(M),this.style&&this.style.terrain)}unproject(M){return this.transform.pointLocation(i.pointGeometry.convert(M),this.style&&this.style.terrain)}isMoving(){return this._moving||this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers.isRotating()}_createDelegatedListener(M,h,_){if(M==="mouseenter"||M==="mouseover"){let T=!1;return{layer:h,listener:_,delegates:{mousemove:O=>{const K=this.getLayer(h)?this.queryRenderedFeatures(O.point,{layers:[h]}):[];K.length?T||(T=!0,_.call(this,new So(M,this,O.originalEvent,{features:K}))):T=!1},mouseout:()=>{T=!1}}}}if(M==="mouseleave"||M==="mouseout"){let T=!1;return{layer:h,listener:_,delegates:{mousemove:K=>{(this.getLayer(h)?this.queryRenderedFeatures(K.point,{layers:[h]}):[]).length?T=!0:T&&(T=!1,_.call(this,new So(M,this,K.originalEvent)))},mouseout:K=>{T&&(T=!1,_.call(this,new So(M,this,K.originalEvent)))}}}}{const T=F=>{const O=this.getLayer(h)?this.queryRenderedFeatures(F.point,{layers:[h]}):[];O.length&&(F.features=O,_.call(this,F),delete F.features)};return{layer:h,listener:_,delegates:{[M]:T}}}}on(M,h,_){if(_===void 0)return super.on(M,h);const T=this._createDelegatedListener(M,h,_);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[M]=this._delegatedListeners[M]||[],this._delegatedListeners[M].push(T);for(const F in T.delegates)this.on(F,T.delegates[F]);return this}once(M,h,_){if(_===void 0)return super.once(M,h);const T=this._createDelegatedListener(M,h,_);for(const F in T.delegates)this.once(F,T.delegates[F]);return this}off(M,h,_){return _===void 0?super.off(M,h):(this._delegatedListeners&&this._delegatedListeners[M]&&(T=>{const F=this._delegatedListeners[M];for(let O=0;O{T?this.fire(new i.ErrorEvent(T)):F&&this._updateDiff(F,h)})}else typeof M=="object"&&this._updateDiff(M,h)}_updateDiff(M,h){try{this.style.setState(M)&&this._update(!0)}catch(_){i.warnOnce(`Unable to perform style diff: ${_.message||_.error||_}. Rebuilding the style from scratch.`),this._updateStyle(M,h)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():i.warnOnce("There is no style added to the map.")}addSource(M,h){return this._lazyInitEmptyStyle(),this.style.addSource(M,h),this._update(!0)}isSourceLoaded(M){const h=this.style&&this.style.sourceCaches[M];if(h!==void 0)return h.loaded();this.fire(new i.ErrorEvent(new Error(`There is no source with ID '${M}'`)))}setTerrain(M){return this.style.setTerrain(M),this}getTerrain(){return this.style.terrain&&this.style.terrain.options}areTilesLoaded(){const M=this.style&&this.style.sourceCaches;for(const h in M){const _=M[h]._tiles;for(const T in _){const F=_[T];if(F.state!=="loaded"&&F.state!=="errored")return!1}}return!0}addSourceType(M,h,_){return this._lazyInitEmptyStyle(),this.style.addSourceType(M,h,_)}removeSource(M){return this.style.removeSource(M),this._update(!0)}getSource(M){return this.style.getSource(M)}addImage(M,h,{pixelRatio:_=1,sdf:T=!1,stretchX:F,stretchY:O,content:K}={}){if(this._lazyInitEmptyStyle(),h instanceof HTMLImageElement||i.isImageBitmap(h)){const{width:oe,height:ue,data:ve}=i.exported.getImageData(h);this.style.addImage(M,{data:new i.RGBAImage({width:oe,height:ue},ve),pixelRatio:_,stretchX:F,stretchY:O,content:K,sdf:T,version:0})}else{if(h.width===void 0||h.height===void 0)return this.fire(new i.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`")));{const{width:oe,height:ue,data:ve}=h,Te=h;this.style.addImage(M,{data:new i.RGBAImage({width:oe,height:ue},new Uint8Array(ve)),pixelRatio:_,stretchX:F,stretchY:O,content:K,sdf:T,version:0,userImage:Te}),Te.onAdd&&Te.onAdd(this,M)}}}updateImage(M,h){const _=this.style.getImage(M);if(!_)return this.fire(new i.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const T=h instanceof HTMLImageElement||i.isImageBitmap(h)?i.exported.getImageData(h):h,{width:F,height:O,data:K}=T;if(F===void 0||O===void 0)return this.fire(new i.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`")));if(F!==_.data.width||O!==_.data.height)return this.fire(new i.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image")));const oe=!(h instanceof HTMLImageElement||i.isImageBitmap(h));_.data.replace(K,oe),this.style.updateImage(M,_)}hasImage(M){return M?!!this.style.getImage(M):(this.fire(new i.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(M){this.style.removeImage(M)}loadImage(M,h){i.getImage(this._requestManager.transformRequest(M,i.ResourceType.Image),h)}listImages(){return this.style.listImages()}addLayer(M,h){return this._lazyInitEmptyStyle(),this.style.addLayer(M,h),this._update(!0)}moveLayer(M,h){return this.style.moveLayer(M,h),this._update(!0)}removeLayer(M){return this.style.removeLayer(M),this._update(!0)}getLayer(M){return this.style.getLayer(M)}setLayerZoomRange(M,h,_){return this.style.setLayerZoomRange(M,h,_),this._update(!0)}setFilter(M,h,_={}){return this.style.setFilter(M,h,_),this._update(!0)}getFilter(M){return this.style.getFilter(M)}setPaintProperty(M,h,_,T={}){return this.style.setPaintProperty(M,h,_,T),this._update(!0)}getPaintProperty(M,h){return this.style.getPaintProperty(M,h)}setLayoutProperty(M,h,_,T={}){return this.style.setLayoutProperty(M,h,_,T),this._update(!0)}getLayoutProperty(M,h){return this.style.getLayoutProperty(M,h)}setLight(M,h={}){return this._lazyInitEmptyStyle(),this.style.setLight(M,h),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(M,h){return this.style.setFeatureState(M,h),this._update()}removeFeatureState(M,h){return this.style.removeFeatureState(M,h),this._update()}getFeatureState(M){return this.style.getFeatureState(M)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let M=0,h=0;return this._container&&(M=this._container.clientWidth||400,h=this._container.clientHeight||300),[M,h]}_setupContainer(){const M=this._container;M.classList.add("maplibregl-map","mapboxgl-map");const h=this._canvasContainer=R.create("div","maplibregl-canvas-container mapboxgl-canvas-container",M);this._interactive&&h.classList.add("maplibregl-interactive","mapboxgl-interactive"),this._canvas=R.create("canvas","maplibregl-canvas mapboxgl-canvas",h),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const _=this._containerDimensions();this._resizeCanvas(_[0],_[1],this.getPixelRatio());const T=this._controlContainer=R.create("div","maplibregl-control-container mapboxgl-control-container",M),F=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(O=>{F[O]=R.create("div",`maplibregl-ctrl-${O} mapboxgl-ctrl-${O}`,T)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){const M=this._container;this._metaPress=!1,this._cooperativeGesturesScreen=R.create("div","maplibregl-cooperative-gesture-screen",M);let h="Control",_=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";navigator.platform.indexOf("Mac")===0&&(_=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use \u2318 + scroll to zoom the map",h="Meta"),this._cooperativeGesturesScreen.innerHTML=`
${_}
${typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.mobileHelpText?this._cooperativeGestures.mobileHelpText:"Use two fingers to move the map"}
`,document.addEventListener("keydown",T=>{T.key===h&&(this._metaPress=!0)}),document.addEventListener("keyup",T=>{T.key===h&&(this._metaPress=!1)}),this._canvasContainer.addEventListener("wheel",T=>{this._onCooperativeGesture(T,this._metaPress,1)},!1),this._canvasContainer.classList.remove("mapboxgl-touch-drag-pan","maplibregl-touch-drag-pan")}_resizeCanvas(M,h,_){this._canvas.width=_*M,this._canvas.height=_*h,this._canvas.style.width=`${M}px`,this._canvas.style.height=`${h}px`}_setupPainter(){const M=i.extend({},C.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),h=this._canvas.getContext("webgl",M)||this._canvas.getContext("experimental-webgl",M);h?(this.painter=new vu(h,this.transform),i.exported$1.testSupport(h)):this.fire(new i.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(M){M.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.Event("webglcontextlost",{originalEvent:M}))}_contextRestored(M){this._setupPainter(),this.resize(),this._update(),this.fire(new i.Event("webglcontextrestored",{originalEvent:M}))}_onMapScroll(M){if(M.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}_onCooperativeGesture(M,h,_){return!h&&_<2&&(this._cooperativeGesturesScreen.classList.add("maplibregl-show"),setTimeout(()=>{this._cooperativeGesturesScreen.classList.remove("maplibregl-show")},100)),!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(M){return this.style?(this._styleDirty=this._styleDirty||M,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(M){return this._update(),this._renderTaskQueue.add(M)}_cancelRenderFrame(M){this._renderTaskQueue.remove(M)}_render(M){let h,_=0;const T=this.painter.context.extTimerQuery;if(this.listens("gpu-timing-frame")&&(h=T.createQueryEXT(),T.beginQueryEXT(T.TIME_ELAPSED_EXT,h),_=i.exported.now()),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(M),this._removed)return;let F=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const K=this.transform.zoom,oe=i.exported.now();this.style.zoomHistory.update(K,oe);const ue=new i.EvaluationParameters(K,{now:oe,fadeDuration:this._fadeDuration,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),ve=ue.crossFadingFactor();ve===1&&ve===this._crossFadingFactor||(F=!0,this._crossFadingFactor=ve),this.style.update(ue)}if(this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.style.terrain&&this.style.terrain.sourceCache.update(this.transform,this.style.terrain),this.transform.updateElevation(this.style.terrain),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,this._fadeDuration,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:this._fadeDuration,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer")}),this.fire(new i.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,i.PerformanceUtils.mark(i.PerformanceMarkers.load),this.fire(new i.Event("load"))),this.style&&(this.style.hasTransitions()||F)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const K=i.exported.now()-_;T.endQueryEXT(T.TIME_ELAPSED_EXT,h),setTimeout(()=>{const oe=T.getQueryObjectEXT(h,T.QUERY_RESULT_EXT)/1e6;T.deleteQueryEXT(h),this.fire(new i.Event("gpu-timing-frame",{cpuTime:K,gpuTime:oe}))},50)}if(this.listens("gpu-timing-layer")){const K=this.painter.collectGpuTimers();setTimeout(()=>{const oe=this.painter.queryGpuTimers(K);this.fire(new i.Event("gpu-timing-layer",{layerTimes:oe}))},50)}const O=this._sourcesDirty||this._styleDirty||this._placementDirty;return O||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new i.Event("idle")),!this._loaded||this._fullyLoaded||O||(this._fullyLoaded=!0,i.PerformanceUtils.mark(i.PerformanceMarkers.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(const h of this._controls)h.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&(removeEventListener("resize",this._onWindowResize,!1),removeEventListener("orientationchange",this._onWindowResize,!1),removeEventListener("online",this._onWindowOnline,!1));const M=this.painter.context.gl.getExtension("WEBGL_lose_context");M&&M.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),R.remove(this._canvasContainer),R.remove(this._controlContainer),this._cooperativeGestures&&R.remove(this._cooperativeGesturesScreen),this._container.classList.remove("maplibregl-map","mapboxgl-map"),i.PerformanceUtils.clearMetrics(),this._removed=!0,this.fire(new i.Event("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=i.exported.frame(M=>{i.PerformanceUtils.frame(M),this._frame=null,this._render(M)}))}_onWindowOnline(){this._update()}_onWindowResize(M){this._trackResize&&this.resize({originalEvent:M})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(M){this._showTileBoundaries!==M&&(this._showTileBoundaries=M,this._update())}get showPadding(){return!!this._showPadding}set showPadding(M){this._showPadding!==M&&(this._showPadding=M,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(M){this._showCollisionBoxes!==M&&(this._showCollisionBoxes=M,M?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(M){this._showOverdrawInspector!==M&&(this._showOverdrawInspector=M,this._update())}get repaint(){return!!this._repaint}set repaint(M){this._repaint!==M&&(this._repaint=M,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(M){this._vertices=M,this._update()}_setCacheLimits(M,h){i.setCacheLimits(M,h)}get version(){return"2.4.0"}},NavigationControl:class{constructor(M){this.options=i.extend({},rh,M),this._container=R.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",h=>h.preventDefault()),this.options.showZoom&&(i.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in mapboxgl-ctrl-zoom-in",h=>this._map.zoomIn({},{originalEvent:h})),R.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out mapboxgl-ctrl-zoom-out",h=>this._map.zoomOut({},{originalEvent:h})),R.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("maplibregl-ctrl-compass mapboxgl-ctrl-compass",h=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:h}):this._map.resetNorth({},{originalEvent:h})}),this._compassIcon=R.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const M=this._map.getZoom(),h=M===this._map.getMaxZoom(),_=M===this._map.getMinZoom();this._zoomInButton.disabled=h,this._zoomOutButton.disabled=_,this._zoomInButton.setAttribute("aria-disabled",h.toString()),this._zoomOutButton.setAttribute("aria-disabled",_.toString())}_rotateCompassArrow(){const M=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=M}onAdd(M){return this._map=M,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new uo(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){R.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(M,h){const _=R.create("button",M,this._container);return _.type="button",_.addEventListener("click",h),_}_setButtonTitle(M,h){const _=this._map._getUIString(`NavigationControl.${h}`);M.title=_,M.setAttribute("aria-label",_)}},GeolocateControl:class extends i.Evented{constructor(M){super(),this.options=i.extend({},dA,M),i.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}onAdd(M){var h;return this._map=M,this._container=R.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),h=this._setupUI,yl!==void 0?h(yl):window.navigator.permissions!==void 0?window.navigator.permissions.query({name:"geolocation"}).then(_=>{yl=_.state!=="denied",h(yl)}):(yl=!!window.navigator.geolocation,h(yl)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),R.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Es=0,Wa=!1}_isOutOfMapMaxBounds(M){const h=this._map.getMaxBounds(),_=M.coords;return h&&(_.longitudeh.getEast()||_.latitudeh.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_onSuccess(M){if(this._map){if(this._isOutOfMapMaxBounds(M))return this._setErrorState(),this.fire(new i.Event("outofmaxbounds",M)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=M,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(M),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(M),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new i.Event("geolocate",M)),this._finish()}}_updateCamera(M){const h=new i.LngLat(M.coords.longitude,M.coords.latitude),_=M.coords.accuracy,T=this._map.getBearing(),F=i.extend({bearing:T},this.options.fitBoundsOptions);this._map.fitBounds(h.toBounds(_),F,{geolocateSource:!0})}_updateMarker(M){if(M){const h=new i.LngLat(M.coords.longitude,M.coords.latitude);this._accuracyCircleMarker.setLngLat(h).addTo(this._map),this._userLocationDotMarker.setLngLat(h).addTo(this._map),this._accuracy=M.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const M=this._map._container.clientHeight/2,h=this._map.unproject([0,M]),_=this._map.unproject([1,M]),T=h.distanceTo(_),F=Math.ceil(2*this._accuracy/T);this._circleElement.style.width=`${F}px`,this._circleElement.style.height=`${F}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_onError(M){if(this._map){if(this.options.trackUserLocation)if(M.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=h,this._geolocateButton.setAttribute("aria-label",h),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(M.code===3&&Wa)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new i.Event("error",M)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(M){if(this._container.addEventListener("contextmenu",h=>h.preventDefault()),this._geolocateButton=R.create("button","maplibregl-ctrl-geolocate mapboxgl-ctrl-geolocate",this._container),R.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",M===!1){i.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=h,this._geolocateButton.setAttribute("aria-label",h)}else{const h=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=h,this._geolocateButton.setAttribute("aria-label",h)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=R.create("div","maplibregl-user-location-dot mapboxgl-user-location-dot"),this._userLocationDotMarker=new sh(this._dotElement),this._circleElement=R.create("div","maplibregl-user-location-accuracy-circle mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new sh({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",h=>{h.geolocateSource||this._watchState!=="ACTIVE_LOCK"||h.originalEvent&&h.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this.fire(new i.Event("trackuserlocationend")))})}trigger(){if(!this._setup)return i.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 i.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Es--,Wa=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this.fire(new i.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.Event("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let M;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Es++,Es>1?(M={maximumAge:6e5,timeout:0},Wa=!0):(M=this.options.positionOptions,Wa=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,M)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:nh,LogoControl:Wh,ScaleControl:class{constructor(M){this.options=i.extend({},Go,M),i.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){pA(this._map,this._container,this.options)}onAdd(M){return this._map=M,this._container=R.create("div","maplibregl-ctrl maplibregl-ctrl-scale mapboxgl-ctrl mapboxgl-ctrl-scale",M.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){R.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}setUnit(M){this.options.unit=M,pA(this._map,this._container,this.options)}},FullscreenControl:class{constructor(M){this._fullscreen=!1,M&&M.container&&(M.container instanceof HTMLElement?this._container=M.container:i.warnOnce("Full screen control 'container' must be a DOM element.")),i.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(M){return this._map=M,this._container||(this._container=this._map.getContainer()),this._controlContainer=R.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){R.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled||document.webkitFullscreenEnabled)}_setupUI(){const M=this._fullscreenButton=R.create("button","maplibregl-ctrl-fullscreen mapboxgl-ctrl-fullscreen",this._controlContainer);R.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",M).setAttribute("aria-hidden","true"),M.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const M=this._getTitle();this._fullscreenButton.setAttribute("aria-label",M),this._fullscreenButton.title=M}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen&&window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},TerrainControl:class{constructor(M){this.options=M,i.bindAll(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(M){return this._map=M,this._container=R.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._terrainButton=R.create("button","maplibregl-ctrl-terrain mapboxgl-ctrl-terrain",this._container),R.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){R.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain","mapboxgl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled","mapboxgl-ctrl-terrain-enabled"),this._map.style.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled","mapboxgl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain","mapboxgl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}},Popup:class extends i.Evented{constructor(M){super(),this.options=i.extend(Object.create(us),M),i.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}addTo(M){return this._map&&this.remove(),this._map=M,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new i.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&R.remove(this._content),this._container&&(R.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new i.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(M){return this._lngLat=i.LngLat.convert(M),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer","mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")),this}getElement(){return this._container}setText(M){return this.setDOMContent(document.createTextNode(M))}setHTML(M){const h=document.createDocumentFragment(),_=document.createElement("body");let T;for(_.innerHTML=M;T=_.firstChild,T;)h.appendChild(T);return this.setDOMContent(h)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(M){return this.options.maxWidth=M,this._update(),this}setDOMContent(M){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=R.create("div","maplibregl-popup-content mapboxgl-popup-content",this._container);return this._content.appendChild(M),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(M){this._container&&this._container.classList.add(M)}removeClassName(M){this._container&&this._container.classList.remove(M)}setOffset(M){return this.options.offset=M,this._update(),this}toggleClassName(M){if(this._container)return this._container.classList.toggle(M)}_createCloseButton(){this.options.closeButton&&(this._closeButton=R.create("button","maplibregl-popup-close-button mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(M){this._update(M.point)}_onMouseMove(M){this._update(M.point)}_onDrag(M){this._update(M.point)}_update(M){if(!this._map||!this._lngLat&&!this._trackPointer||!this._content||(this._container||(this._container=R.create("div","maplibregl-popup mapboxgl-popup",this._map.getContainer()),this._tip=R.create("div","maplibregl-popup-tip mapboxgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach(O=>this._container.classList.add(O)),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer")),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Js(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!M))return;const h=this._pos=this._trackPointer&&M?M:this._map.project(this._lngLat);let _=this.options.anchor;const T=Kh(this.options.offset);if(!_){const O=this._container.offsetWidth,K=this._container.offsetHeight;let oe;oe=h.y+T.bottom.ythis._map.transform.height-K?["bottom"]:[],h.xthis._map.transform.width-O/2&&oe.push("right"),_=oe.length===0?"bottom":oe.join("-")}const F=h.add(T[_]).round();R.setTransform(this._container,`${Fn[_]} translate(${F.x}px,${F.y}px)`),Vn(this._container,_,"popup")}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const M=this._container.querySelector(Fs);M&&M.focus()}_onClose(){this.remove()}},Marker:sh,Style:Mr,LngLat:i.LngLat,LngLatBounds:i.LngLatBounds,Point:i.pointGeometry,MercatorCoordinate:i.MercatorCoordinate,Evented:i.Evented,AJAXError:i.AJAXError,config:i.config,CanvasSource:Le,GeoJSONSource:ze,ImageSource:Ge,RasterDEMTileSource:xe,RasterTileSource:ce,VectorTileSource:te,VideoSource:Ve,prewarm:function(){fi().acquire(Ct)},clearPrewarmedResources:function(){const M=mi;M&&(M.isPreloaded()&&M.numActive()===1?(M.release(Ct),mi=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 version(){return"2.4.0"},get workerCount(){return Ft.workerCount},set workerCount(M){Ft.workerCount=M},get maxParallelImageRequests(){return i.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(M){i.config.MAX_PARALLEL_IMAGE_REQUESTS=M},clearStorage(M){i.clearTileCache(M)},workerUrl:"",addProtocol(M,h){i.config.REGISTERED_PROTOCOLS[M]=h},removeProtocol(M){delete i.config.REGISTERED_PROTOCOLS[M]}};return vs.extend(xl,{isSafari:i.isSafari,getPerformanceMetrics:i.PerformanceUtils.getPerformanceMetrics}),xl});var y=c;return y})})(Ua);const xR=Ua.exports,vR=ES({__proto__:null,default:xR},[Ua.exports]);var I_={Linear:{None:function(u){return u}},Quadratic:{In:function(u){return u*u},Out:function(u){return u*(2-u)},InOut:function(u){return(u*=2)<1?.5*u*u:-.5*(--u*(u-2)-1)}},Cubic:{In:function(u){return u*u*u},Out:function(u){return--u*u*u+1},InOut:function(u){return(u*=2)<1?.5*u*u*u:.5*((u-=2)*u*u+2)}},Quartic:{In:function(u){return u*u*u*u},Out:function(u){return 1- --u*u*u*u},InOut:function(u){return(u*=2)<1?.5*u*u*u*u:-.5*((u-=2)*u*u*u-2)}},Quintic:{In:function(u){return u*u*u*u*u},Out:function(u){return--u*u*u*u*u+1},InOut:function(u){return(u*=2)<1?.5*u*u*u*u*u:.5*((u-=2)*u*u*u*u+2)}},Sinusoidal:{In:function(u){return 1-Math.cos(u*Math.PI/2)},Out:function(u){return Math.sin(u*Math.PI/2)},InOut:function(u){return .5*(1-Math.cos(Math.PI*u))}},Exponential:{In:function(u){return u===0?0:Math.pow(1024,u-1)},Out:function(u){return u===1?1:1-Math.pow(2,-10*u)},InOut:function(u){return u===0?0:u===1?1:(u*=2)<1?.5*Math.pow(1024,u-1):.5*(-Math.pow(2,-10*(u-1))+2)}},Circular:{In:function(u){return 1-Math.sqrt(1-u*u)},Out:function(u){return Math.sqrt(1- --u*u)},InOut:function(u){return(u*=2)<1?-.5*(Math.sqrt(1-u*u)-1):.5*(Math.sqrt(1-(u-=2)*u)+1)}},Elastic:{In:function(u){return u===0?0:u===1?1:-Math.pow(2,10*(u-1))*Math.sin((u-1.1)*5*Math.PI)},Out:function(u){return u===0?0:u===1?1:Math.pow(2,-10*u)*Math.sin((u-.1)*5*Math.PI)+1},InOut:function(u){return u===0?0:u===1?1:(u*=2,u<1?-.5*Math.pow(2,10*(u-1))*Math.sin((u-1.1)*5*Math.PI):.5*Math.pow(2,-10*(u-1))*Math.sin((u-1.1)*5*Math.PI)+1)}},Back:{In:function(u){var e=1.70158;return u*u*((e+1)*u-e)},Out:function(u){var e=1.70158;return--u*u*((e+1)*u+e)+1},InOut:function(u){var e=2.5949095;return(u*=2)<1?.5*(u*u*((e+1)*u-e)):.5*((u-=2)*u*((e+1)*u+e)+2)}},Bounce:{In:function(u){return 1-I_.Bounce.Out(1-u)},Out:function(u){return u<1/2.75?7.5625*u*u:u<2/2.75?7.5625*(u-=1.5/2.75)*u+.75:u<2.5/2.75?7.5625*(u-=2.25/2.75)*u+.9375:7.5625*(u-=2.625/2.75)*u+.984375},InOut:function(u){return u<.5?I_.Bounce.In(u*2)*.5:I_.Bounce.Out(u*2-1)*.5+.5}}},v_;typeof self>"u"&&typeof process<"u"&&process.hrtime?v_=function(){var u=process.hrtime();return u[0]*1e3+u[1]/1e6}:typeof self<"u"&&self.performance!==void 0&&self.performance.now!==void 0?v_=self.performance.now.bind(self.performance):Date.now!==void 0?v_=Date.now:v_=function(){return new Date().getTime()};var Yp=v_,DM=function(){function u(){this._tweens={},this._tweensAddedDuringUpdate={}}return u.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},u.prototype.removeAll=function(){this._tweens={}},u.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},u.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},u.prototype.update=function(e,t){e===void 0&&(e=Yp()),t===void 0&&(t=!1);var r=Object.keys(this._tweens);if(r.length===0)return!1;for(;r.length>0;){this._tweensAddedDuringUpdate={};for(var c=0;c1?p(u[t],u[t-1],t-r):p(u[c],u[c+1>t?t:c+1],r-c)},Bezier:function(u,e){for(var t=0,r=u.length-1,c=Math.pow,p=Lm.Utils.Bernstein,y=0;y<=r;y++)t+=c(1-e,r-y)*c(e,y)*u[y]*p(r,y);return t},CatmullRom:function(u,e){var t=u.length-1,r=t*e,c=Math.floor(r),p=Lm.Utils.CatmullRom;return u[0]===u[t]?(e<0&&(c=Math.floor(r=t*(1+e))),p(u[(c-1+t)%t],u[c],u[(c+1)%t],u[(c+2)%t],r-c)):e<0?u[0]-(p(u[0],u[0],u[1],u[1],-r)-u[0]):e>1?u[t]-(p(u[t],u[t],u[t-1],u[t-1],r-t)-u[t]):p(u[c?c-1:0],u[c],u[t1;r--)t*=r;return u[e]=t,t}}(),CatmullRom:function(u,e,t,r,c){var p=(t-u)*.5,y=(r-e)*.5,i=c*c,C=c*i;return(2*e-2*t+p+y)*C+(-3*e+3*t-2*p-y)*i+p*c+e}}},F2=function(){function u(){}return u.nextId=function(){return u._nextId++},u._nextId=0,u}(),PM=new DM,wR=function(){function u(e,t){t===void 0&&(t=PM),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=I_.Linear.None,this._interpolationFunction=Lm.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=F2.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return u.prototype.getId=function(){return this._id},u.prototype.isPlaying=function(){return this._isPlaying},u.prototype.isPaused=function(){return this._isPaused},u.prototype.to=function(e,t){return this._valuesEnd=Object.create(e),t!==void 0&&(this._duration=t),this},u.prototype.duration=function(e){return this._duration=e,this},u.prototype.start=function(e){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var t in this._valuesStartRepeat)this._swapEndStartRepeatValues(t),this._valuesStart[t]=this._valuesStartRepeat[t]}return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e!==void 0?typeof e=="string"?Yp()+parseFloat(e):e:Yp(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},u.prototype._setupProperties=function(e,t,r,c){for(var p in r){var y=e[p],i=Array.isArray(y),C=i?"array":typeof y,D=!i&&Array.isArray(r[p]);if(!(C==="undefined"||C==="function")){if(D){var U=r[p];if(U.length===0)continue;U=U.map(this._handleRelativeValue.bind(this,y)),r[p]=[y].concat(U)}if((C==="object"||i)&&y&&!D){t[p]=i?[]:{};for(var N in y)t[p][N]=y[N];c[p]=i?[]:{},this._setupProperties(y,t[p],r[p],c[p])}else typeof t[p]>"u"&&(t[p]=y),i||(t[p]*=1),D?c[p]=r[p].slice().reverse():c[p]=t[p]||0}}},u.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},u.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},u.prototype.pause=function(e){return e===void 0&&(e=Yp()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},u.prototype.resume=function(e){return e===void 0&&(e=Yp()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},u.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;ep)return!1;t&&this.start(e)}if(this._goToEnd=!1,e1?1:c;var y=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,y),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),c===1)if(this._repeat>0){isFinite(this._repeat)&&this._repeat--;for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._repeatDelayTime!==void 0?this._startTime=e+this._repeatDelayTime:this._startTime=e+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var i=0,C=this._chainedTweens.length;i>8&255]+el[u>>16&255]+el[u>>24&255]+"-"+el[e&255]+el[e>>8&255]+"-"+el[e>>16&15|64]+el[e>>24&255]+"-"+el[t&63|128]+el[t>>8&255]+"-"+el[t>>16&255]+el[t>>24&255]+el[r&255]+el[r>>8&255]+el[r>>16&255]+el[r>>24&255]).toLowerCase()}function Eo(u,e,t){return Math.max(e,Math.min(t,u))}function O2(u,e){return(u%e+e)%e}function cz(u,e,t,r,c){return r+(u-e)*(c-r)/(t-e)}function hz(u,e,t){return u!==e?(t-u)/(e-u):0}function L_(u,e,t){return(1-t)*u+t*e}function uz(u,e,t,r){return L_(u,e,1-Math.exp(-t*r))}function Az(u,e=1){return e-Math.abs(O2(u,e*2)-e)}function dz(u,e,t){return u<=e?0:u>=t?1:(u=(u-e)/(t-e),u*u*(3-2*u))}function pz(u,e,t){return u<=e?0:u>=t?1:(u=(u-e)/(t-e),u*u*u*(u*(u*6-15)+10))}function fz(u,e){return u+Math.floor(Math.random()*(e-u+1))}function mz(u,e){return u+Math.random()*(e-u)}function gz(u){return u*(.5-Math.random())}function _z(u){u!==void 0&&(UE=u);let e=UE+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function yz(u){return u*pf}function xz(u){return u*$_}function o2(u){return(u&u-1)===0&&u!==0}function FI(u){return Math.pow(2,Math.ceil(Math.log(u)/Math.LN2))}function fv(u){return Math.pow(2,Math.floor(Math.log(u)/Math.LN2))}function vz(u,e,t,r,c){const p=Math.cos,y=Math.sin,i=p(t/2),C=y(t/2),D=p((e+r)/2),U=y((e+r)/2),N=p((e-r)/2),R=y((e-r)/2),G=p((r-e)/2),J=y((r-e)/2);switch(c){case"XYX":u.set(i*U,C*N,C*R,i*D);break;case"YZY":u.set(C*R,i*U,C*N,i*D);break;case"ZXZ":u.set(C*N,C*R,i*U,i*D);break;case"XZX":u.set(i*U,C*J,C*G,i*D);break;case"YXY":u.set(C*G,i*U,C*J,i*D);break;case"ZYZ":u.set(C*J,C*G,i*U,i*D);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+c)}}function WA(u,e){switch(e.constructor){case Float32Array:return u;case Uint16Array:return u/65535;case Uint8Array:return u/255;case Int16Array:return Math.max(u/32767,-1);case Int8Array:return Math.max(u/127,-1);default:throw new Error("Invalid component type.")}}function Rs(u,e){switch(e.constructor){case Float32Array:return u;case Uint16Array:return Math.round(u*65535);case Uint8Array:return Math.round(u*255);case Int16Array:return Math.round(u*32767);case Int8Array:return Math.round(u*127);default:throw new Error("Invalid component type.")}}var LI=Object.freeze({__proto__:null,DEG2RAD:pf,RAD2DEG:$_,generateUUID:Pc,clamp:Eo,euclideanModulo:O2,mapLinear:cz,inverseLerp:hz,lerp:L_,damp:uz,pingpong:Az,smoothstep:dz,smootherstep:pz,randInt:fz,randFloat:mz,randFloatSpread:gz,seededRandom:_z,degToRad:yz,radToDeg:xz,isPowerOfTwo:o2,ceilPowerOfTwo:FI,floorPowerOfTwo:fv,setQuaternionFromProperEuler:vz,normalize:Rs,denormalize:WA});class Di{constructor(e=0,t=0){Di.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,r=this.y,c=e.elements;return this.x=c[0]*t+c[3]*r+c[6],this.y=c[1]*t+c[4]*r+c[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const r=Math.cos(t),c=Math.sin(t),p=this.x-e.x,y=this.y-e.y;return this.x=p*r-y*c+e.x,this.y=p*c+y*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Pl{constructor(){Pl.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,r,c,p,y,i,C,D){const U=this.elements;return U[0]=e,U[1]=c,U[2]=i,U[3]=t,U[4]=p,U[5]=C,U[6]=r,U[7]=y,U[8]=D,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,c=t.elements,p=this.elements,y=r[0],i=r[3],C=r[6],D=r[1],U=r[4],N=r[7],R=r[2],G=r[5],J=r[8],Y=c[0],B=c[3],ae=c[6],le=c[1],Ae=c[4],we=c[7],me=c[2],Pe=c[5],it=c[8];return p[0]=y*Y+i*le+C*me,p[3]=y*B+i*Ae+C*Pe,p[6]=y*ae+i*we+C*it,p[1]=D*Y+U*le+N*me,p[4]=D*B+U*Ae+N*Pe,p[7]=D*ae+U*we+N*it,p[2]=R*Y+G*le+J*me,p[5]=R*B+G*Ae+J*Pe,p[8]=R*ae+G*we+J*it,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],r=e[1],c=e[2],p=e[3],y=e[4],i=e[5],C=e[6],D=e[7],U=e[8];return t*y*U-t*i*D-r*p*U+r*i*C+c*p*D-c*y*C}invert(){const e=this.elements,t=e[0],r=e[1],c=e[2],p=e[3],y=e[4],i=e[5],C=e[6],D=e[7],U=e[8],N=U*y-i*D,R=i*C-U*p,G=D*p-y*C,J=t*N+r*R+c*G;if(J===0)return this.set(0,0,0,0,0,0,0,0,0);const Y=1/J;return e[0]=N*Y,e[1]=(c*D-U*r)*Y,e[2]=(i*r-c*y)*Y,e[3]=R*Y,e[4]=(U*t-c*C)*Y,e[5]=(c*p-i*t)*Y,e[6]=G*Y,e[7]=(r*C-D*t)*Y,e[8]=(y*t-r*p)*Y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,r,c,p,y,i){const C=Math.cos(p),D=Math.sin(p);return this.set(r*C,r*D,-r*(C*y+D*i)+y+e,-c*D,c*C,-c*(-D*y+C*i)+i+t,0,0,1),this}scale(e,t){return this.premultiply(vw.makeScale(e,t)),this}rotate(e){return this.premultiply(vw.makeRotation(-e)),this}translate(e,t){return this.premultiply(vw.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,r,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,r=e.elements;for(let c=0;c<9;c++)if(t[c]!==r[c])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const vw=new Pl;function DI(u){for(let e=u.length-1;e>=0;--e)if(u[e]>=65535)return!0;return!1}const wz={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Pm(u,e){return new wz[u](e)}function Z_(u){return document.createElementNS("http://www.w3.org/1999/xhtml",u)}function ff(u){return u<.04045?u*.0773993808:Math.pow(u*.9478672986+.0521327014,2.4)}function Yx(u){return u<.0031308?u*12.92:1.055*Math.pow(u,.41666)-.055}const ww={[cu]:{[Wm]:ff},[Wm]:{[cu]:Yx}},tl={legacyMode:!0,get workingColorSpace(){return Wm},set workingColorSpace(u){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(u,e,t){if(this.legacyMode||e===t||!e||!t)return u;if(ww[e]&&ww[e][t]!==void 0){const r=ww[e][t];return u.r=r(u.r),u.g=r(u.g),u.b=r(u.b),u}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(u,e){return this.convert(u,this.workingColorSpace,e)},toWorkingColorSpace:function(u,e){return this.convert(u,e,this.workingColorSpace)}},PI={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ia={r:0,g:0,b:0},su={h:0,s:0,l:0},Y0={h:0,s:0,l:0};function bw(u,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?u+(e-u)*6*t:t<1/2?e:t<2/3?u+(e-u)*6*(2/3-t):u}function J0(u,e){return e.r=u.r,e.g=u.g,e.b=u.b,e}class Dn{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&r===void 0?this.set(e):this.setRGB(e,t,r)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=cu){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,tl.toWorkingColorSpace(this,t),this}setRGB(e,t,r,c=tl.workingColorSpace){return this.r=e,this.g=t,this.b=r,tl.toWorkingColorSpace(this,c),this}setHSL(e,t,r,c=tl.workingColorSpace){if(e=O2(e,1),t=Eo(t,0,1),r=Eo(r,0,1),t===0)this.r=this.g=this.b=r;else{const p=r<=.5?r*(1+t):r+t-r*t,y=2*r-p;this.r=bw(y,p,e+1/3),this.g=bw(y,p,e),this.b=bw(y,p,e-1/3)}return tl.toWorkingColorSpace(this,c),this}setStyle(e,t=cu){function r(p){p!==void 0&&parseFloat(p)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let c;if(c=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let p;const y=c[1],i=c[2];switch(y){case"rgb":case"rgba":if(p=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(255,parseInt(p[1],10))/255,this.g=Math.min(255,parseInt(p[2],10))/255,this.b=Math.min(255,parseInt(p[3],10))/255,tl.toWorkingColorSpace(this,t),r(p[4]),this;if(p=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(100,parseInt(p[1],10))/100,this.g=Math.min(100,parseInt(p[2],10))/100,this.b=Math.min(100,parseInt(p[3],10))/100,tl.toWorkingColorSpace(this,t),r(p[4]),this;break;case"hsl":case"hsla":if(p=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const C=parseFloat(p[1])/360,D=parseFloat(p[2])/100,U=parseFloat(p[3])/100;return r(p[4]),this.setHSL(C,D,U,t)}break}}else if(c=/^\#([A-Fa-f\d]+)$/.exec(e)){const p=c[1],y=p.length;if(y===3)return this.r=parseInt(p.charAt(0)+p.charAt(0),16)/255,this.g=parseInt(p.charAt(1)+p.charAt(1),16)/255,this.b=parseInt(p.charAt(2)+p.charAt(2),16)/255,tl.toWorkingColorSpace(this,t),this;if(y===6)return this.r=parseInt(p.charAt(0)+p.charAt(1),16)/255,this.g=parseInt(p.charAt(2)+p.charAt(3),16)/255,this.b=parseInt(p.charAt(4)+p.charAt(5),16)/255,tl.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=cu){const r=PI[e.toLowerCase()];return r!==void 0?this.setHex(r,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ff(e.r),this.g=ff(e.g),this.b=ff(e.b),this}copyLinearToSRGB(e){return this.r=Yx(e.r),this.g=Yx(e.g),this.b=Yx(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=cu){return tl.fromWorkingColorSpace(J0(this,ia),e),Eo(ia.r*255,0,255)<<16^Eo(ia.g*255,0,255)<<8^Eo(ia.b*255,0,255)<<0}getHexString(e=cu){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=tl.workingColorSpace){tl.fromWorkingColorSpace(J0(this,ia),t);const r=ia.r,c=ia.g,p=ia.b,y=Math.max(r,c,p),i=Math.min(r,c,p);let C,D;const U=(i+y)/2;if(i===y)C=0,D=0;else{const N=y-i;switch(D=U<=.5?N/(y+i):N/(2-y-i),y){case r:C=(c-p)/N+(c"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{cm===void 0&&(cm=Z_("canvas")),cm.width=e.width,cm.height=e.height;const r=cm.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),t=cm}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Z_("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const c=r.getImageData(0,0,e.width,e.height),p=c.data;for(let y=0;y0&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Nv)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case HA:e.x=e.x-Math.floor(e.x);break;case rl:e.x=e.x<0?0:1;break;case H_:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case HA:e.y=e.y-Math.floor(e.y);break;case rl:e.y=e.y<0?0:1;break;case H_:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}To.DEFAULT_IMAGE=null;To.DEFAULT_MAPPING=Nv;To.DEFAULT_ANISOTROPY=1;class ls{constructor(e=0,t=0,r=0,c=1){ls.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,this.w=c}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,r,c){return this.x=e,this.y=t,this.z=r,this.w=c,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,r=this.y,c=this.z,p=this.w,y=e.elements;return this.x=y[0]*t+y[4]*r+y[8]*c+y[12]*p,this.y=y[1]*t+y[5]*r+y[9]*c+y[13]*p,this.z=y[2]*t+y[6]*r+y[10]*c+y[14]*p,this.w=y[3]*t+y[7]*r+y[11]*c+y[15]*p,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,r,c,p;const C=e.elements,D=C[0],U=C[4],N=C[8],R=C[1],G=C[5],J=C[9],Y=C[2],B=C[6],ae=C[10];if(Math.abs(U-R)<.01&&Math.abs(N-Y)<.01&&Math.abs(J-B)<.01){if(Math.abs(U+R)<.1&&Math.abs(N+Y)<.1&&Math.abs(J+B)<.1&&Math.abs(D+G+ae-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const Ae=(D+1)/2,we=(G+1)/2,me=(ae+1)/2,Pe=(U+R)/4,it=(N+Y)/4,Me=(J+B)/4;return Ae>we&&Ae>me?Ae<.01?(r=0,c=.707106781,p=.707106781):(r=Math.sqrt(Ae),c=Pe/r,p=it/r):we>me?we<.01?(r=.707106781,c=0,p=.707106781):(c=Math.sqrt(we),r=Pe/c,p=Me/c):me<.01?(r=.707106781,c=.707106781,p=0):(p=Math.sqrt(me),r=it/p,c=Me/p),this.set(r,c,p,t),this}let le=Math.sqrt((B-J)*(B-J)+(N-Y)*(N-Y)+(R-U)*(R-U));return Math.abs(le)<.001&&(le=1),this.x=(B-J)/le,this.y=(N-Y)/le,this.z=(R-U)/le,this.w=Math.acos((D+G+ae-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Oa extends Xu{constructor(e=1,t=1,r={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ls(0,0,e,t),this.scissorTest=!1,this.viewport=new ls(0,0,e,t);const c={width:e,height:t,depth:1};this.texture=new To(c,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps!==void 0?r.generateMipmaps:!1,this.texture.internalFormat=r.internalFormat!==void 0?r.internalFormat:null,this.texture.minFilter=r.minFilter!==void 0?r.minFilter:Xs,this.depthBuffer=r.depthBuffer!==void 0?r.depthBuffer:!0,this.stencilBuffer=r.stencilBuffer!==void 0?r.stencilBuffer:!1,this.depthTexture=r.depthTexture!==void 0?r.depthTexture:null,this.samples=r.samples!==void 0?r.samples:0}setSize(e,t,r=1){(this.width!==e||this.height!==t||this.depth!==r)&&(this.width=e,this.height=t,this.depth=r,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new lf(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class uy extends To{constructor(e=null,t=1,r=1,c=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:c},this.magFilter=Co,this.minFilter=Co,this.wrapR=rl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Bz extends Oa{constructor(e=1,t=1,r=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=r,this.texture=new uy(null,e,t,r),this.texture.isRenderTargetTexture=!0}}class Vv extends To{constructor(e=null,t=1,r=1,c=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:r,depth:c},this.magFilter=Co,this.minFilter=Co,this.wrapR=rl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Cz extends Oa{constructor(e=1,t=1,r=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=r,this.texture=new Vv(null,e,t,r),this.texture.isRenderTargetTexture=!0}}class Ez extends Oa{constructor(e=1,t=1,r=1,c={}){super(e,t,c),this.isWebGLMultipleRenderTargets=!0;const p=this.texture;this.texture=[];for(let y=0;y=0?1:-1,Ae=1-ae*ae;if(Ae>Number.EPSILON){const me=Math.sqrt(Ae),Pe=Math.atan2(me,ae*le);B=Math.sin(B*Pe)/me,i=Math.sin(i*Pe)/me}const we=i*le;if(C=C*B+R*we,D=D*B+G*we,U=U*B+J*we,N=N*B+Y*we,B===1-i){const me=1/Math.sqrt(C*C+D*D+U*U+N*N);C*=me,D*=me,U*=me,N*=me}}e[t]=C,e[t+1]=D,e[t+2]=U,e[t+3]=N}static multiplyQuaternionsFlat(e,t,r,c,p,y){const i=r[c],C=r[c+1],D=r[c+2],U=r[c+3],N=p[y],R=p[y+1],G=p[y+2],J=p[y+3];return e[t]=i*J+U*N+C*G-D*R,e[t+1]=C*J+U*R+D*N-i*G,e[t+2]=D*J+U*G+i*R-C*N,e[t+3]=U*J-i*N-C*R-D*G,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,r,c){return this._x=e,this._y=t,this._z=r,this._w=c,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const r=e._x,c=e._y,p=e._z,y=e._order,i=Math.cos,C=Math.sin,D=i(r/2),U=i(c/2),N=i(p/2),R=C(r/2),G=C(c/2),J=C(p/2);switch(y){case"XYZ":this._x=R*U*N+D*G*J,this._y=D*G*N-R*U*J,this._z=D*U*J+R*G*N,this._w=D*U*N-R*G*J;break;case"YXZ":this._x=R*U*N+D*G*J,this._y=D*G*N-R*U*J,this._z=D*U*J-R*G*N,this._w=D*U*N+R*G*J;break;case"ZXY":this._x=R*U*N-D*G*J,this._y=D*G*N+R*U*J,this._z=D*U*J+R*G*N,this._w=D*U*N-R*G*J;break;case"ZYX":this._x=R*U*N-D*G*J,this._y=D*G*N+R*U*J,this._z=D*U*J-R*G*N,this._w=D*U*N+R*G*J;break;case"YZX":this._x=R*U*N+D*G*J,this._y=D*G*N+R*U*J,this._z=D*U*J-R*G*N,this._w=D*U*N-R*G*J;break;case"XZY":this._x=R*U*N-D*G*J,this._y=D*G*N-R*U*J,this._z=D*U*J+R*G*N,this._w=D*U*N+R*G*J;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+y)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,c=Math.sin(r);return this._x=e.x*c,this._y=e.y*c,this._z=e.z*c,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],c=t[4],p=t[8],y=t[1],i=t[5],C=t[9],D=t[2],U=t[6],N=t[10],R=r+i+N;if(R>0){const G=.5/Math.sqrt(R+1);this._w=.25/G,this._x=(U-C)*G,this._y=(p-D)*G,this._z=(y-c)*G}else if(r>i&&r>N){const G=2*Math.sqrt(1+r-i-N);this._w=(U-C)/G,this._x=.25*G,this._y=(c+y)/G,this._z=(p+D)/G}else if(i>N){const G=2*Math.sqrt(1+i-r-N);this._w=(p-D)/G,this._x=(c+y)/G,this._y=.25*G,this._z=(C+U)/G}else{const G=2*Math.sqrt(1+N-r-i);this._w=(y-c)/G,this._x=(p+D)/G,this._y=(C+U)/G,this._z=.25*G}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return rMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Eo(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(r===0)return this;const c=Math.min(1,t/r);return this.slerp(e,c),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const r=e._x,c=e._y,p=e._z,y=e._w,i=t._x,C=t._y,D=t._z,U=t._w;return this._x=r*U+y*i+c*D-p*C,this._y=c*U+y*C+p*i-r*D,this._z=p*U+y*D+r*C-c*i,this._w=y*U-r*i-c*C-p*D,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const r=this._x,c=this._y,p=this._z,y=this._w;let i=y*e._w+r*e._x+c*e._y+p*e._z;if(i<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,i=-i):this.copy(e),i>=1)return this._w=y,this._x=r,this._y=c,this._z=p,this;const C=1-i*i;if(C<=Number.EPSILON){const G=1-t;return this._w=G*y+t*this._w,this._x=G*r+t*this._x,this._y=G*c+t*this._y,this._z=G*p+t*this._z,this.normalize(),this._onChangeCallback(),this}const D=Math.sqrt(C),U=Math.atan2(D,i),N=Math.sin((1-t)*U)/D,R=Math.sin(t*U)/D;return this._w=y*N+this._w*R,this._x=r*N+this._x*R,this._y=c*N+this._y*R,this._z=p*N+this._z*R,this._onChangeCallback(),this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=Math.random(),t=Math.sqrt(1-e),r=Math.sqrt(e),c=2*Math.PI*Math.random(),p=2*Math.PI*Math.random();return this.set(t*Math.cos(c),r*Math.sin(p),r*Math.cos(p),t*Math.sin(c))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ft{constructor(e=0,t=0,r=0){ft.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return r===void 0&&(r=this.z),this.x=e,this.y=t,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(RE.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(RE.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,c=this.z,p=e.elements;return this.x=p[0]*t+p[3]*r+p[6]*c,this.y=p[1]*t+p[4]*r+p[7]*c,this.z=p[2]*t+p[5]*r+p[8]*c,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,c=this.z,p=e.elements,y=1/(p[3]*t+p[7]*r+p[11]*c+p[15]);return this.x=(p[0]*t+p[4]*r+p[8]*c+p[12])*y,this.y=(p[1]*t+p[5]*r+p[9]*c+p[13])*y,this.z=(p[2]*t+p[6]*r+p[10]*c+p[14])*y,this}applyQuaternion(e){const t=this.x,r=this.y,c=this.z,p=e.x,y=e.y,i=e.z,C=e.w,D=C*t+y*c-i*r,U=C*r+i*t-p*c,N=C*c+p*r-y*t,R=-p*t-y*r-i*c;return this.x=D*C+R*-p+U*-i-N*-y,this.y=U*C+R*-y+N*-p-D*-i,this.z=N*C+R*-i+D*-y-U*-p,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,r=this.y,c=this.z,p=e.elements;return this.x=p[0]*t+p[4]*r+p[8]*c,this.y=p[1]*t+p[5]*r+p[9]*c,this.z=p[2]*t+p[6]*r+p[10]*c,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,c=e.y,p=e.z,y=t.x,i=t.y,C=t.z;return this.x=c*C-p*i,this.y=p*y-r*C,this.z=r*i-c*y,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return Cw.copy(this).projectOnVector(e),this.sub(Cw)}reflect(e){return this.sub(Cw.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(Eo(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,c=this.z-e.z;return t*t+r*r+c*c}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,r){const c=Math.sin(t)*e;return this.x=c*Math.sin(r),this.y=Math.cos(t)*e,this.z=c*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),c=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=c,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(t),this.y=r*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Cw=new ft,RE=new sl;class qu{constructor(e=new ft(1/0,1/0,1/0),t=new ft(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,r=1/0,c=1/0,p=-1/0,y=-1/0,i=-1/0;for(let C=0,D=e.length;Cp&&(p=U),N>y&&(y=N),R>i&&(i=R)}return this.min.set(t,r,c),this.max.set(p,y,i),this}setFromBufferAttribute(e){let t=1/0,r=1/0,c=1/0,p=-1/0,y=-1/0,i=-1/0;for(let C=0,D=e.count;Cp&&(p=U),N>y&&(y=N),R>i&&(i=R)}return this.min.set(t,r,c),this.max.set(p,y,i),this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Np),Np.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(i_),ex.subVectors(this.max,i_),hm.subVectors(e.a,i_),um.subVectors(e.b,i_),Am.subVectors(e.c,i_),zd.subVectors(um,hm),kd.subVectors(Am,um),Qp.subVectors(hm,Am);let t=[0,-zd.z,zd.y,0,-kd.z,kd.y,0,-Qp.z,Qp.y,zd.z,0,-zd.x,kd.z,0,-kd.x,Qp.z,0,-Qp.x,-zd.y,zd.x,0,-kd.y,kd.x,0,-Qp.y,Qp.x,0];return!Tw(t,hm,um,Am,ex)||(t=[1,0,0,0,1,0,0,0,1],!Tw(t,hm,um,Am,ex))?!1:(tx.crossVectors(zd,kd),t=[tx.x,tx.y,tx.z],Tw(t,hm,um,Am,ex))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Np.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(Np).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(RA[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),RA[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),RA[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),RA[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),RA[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),RA[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),RA[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),RA[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(RA),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const RA=[new ft,new ft,new ft,new ft,new ft,new ft,new ft,new ft],Np=new ft,Ew=new qu,hm=new ft,um=new ft,Am=new ft,zd=new ft,kd=new ft,Qp=new ft,i_=new ft,ex=new ft,tx=new ft,Vp=new ft;function Tw(u,e,t,r,c){for(let p=0,y=u.length-3;p<=y;p+=3){Vp.fromArray(u,p);const i=c.x*Math.abs(Vp.x)+c.y*Math.abs(Vp.y)+c.z*Math.abs(Vp.z),C=e.dot(Vp),D=t.dot(Vp),U=r.dot(Vp);if(Math.max(-Math.max(C,D,U),Math.min(C,D,U))>i)return!1}return!0}const Tz=new qu,n_=new ft,Sw=new ft;class qA{constructor(e=new ft,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const r=this.center;t!==void 0?r.copy(t):Tz.setFromPoints(e).getCenter(r);let c=0;for(let p=0,y=e.length;pthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;n_.subVectors(e,this.center);const t=n_.lengthSq();if(t>this.radius*this.radius){const r=Math.sqrt(t),c=(r-this.radius)*.5;this.center.addScaledVector(n_,c/r),this.radius+=c}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Sw.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(n_.copy(e.center).add(Sw)),this.expandByPoint(n_.copy(e.center).sub(Sw))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const zA=new ft,Mw=new ft,ix=new ft,Od=new ft,Iw=new ft,nx=new ft,Fw=new ft;class Ay{constructor(e=new ft,t=new ft(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,zA)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=zA.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(zA.copy(this.direction).multiplyScalar(t).add(this.origin),zA.distanceToSquared(e))}distanceSqToSegment(e,t,r,c){Mw.copy(e).add(t).multiplyScalar(.5),ix.copy(t).sub(e).normalize(),Od.copy(this.origin).sub(Mw);const p=e.distanceTo(t)*.5,y=-this.direction.dot(ix),i=Od.dot(this.direction),C=-Od.dot(ix),D=Od.lengthSq(),U=Math.abs(1-y*y);let N,R,G,J;if(U>0)if(N=y*C-i,R=y*i-C,J=p*U,N>=0)if(R>=-J)if(R<=J){const Y=1/U;N*=Y,R*=Y,G=N*(N+y*R+2*i)+R*(y*N+R+2*C)+D}else R=p,N=Math.max(0,-(y*R+i)),G=-N*N+R*(R+2*C)+D;else R=-p,N=Math.max(0,-(y*R+i)),G=-N*N+R*(R+2*C)+D;else R<=-J?(N=Math.max(0,-(-y*p+i)),R=N>0?-p:Math.min(Math.max(-p,-C),p),G=-N*N+R*(R+2*C)+D):R<=J?(N=0,R=Math.min(Math.max(-p,-C),p),G=R*(R+2*C)+D):(N=Math.max(0,-(y*p+i)),R=N>0?p:Math.min(Math.max(-p,-C),p),G=-N*N+R*(R+2*C)+D);else R=y>0?-p:p,N=Math.max(0,-(y*R+i)),G=-N*N+R*(R+2*C)+D;return r&&r.copy(this.direction).multiplyScalar(N).add(this.origin),c&&c.copy(ix).multiplyScalar(R).add(Mw),G}intersectSphere(e,t){zA.subVectors(e.center,this.origin);const r=zA.dot(this.direction),c=zA.dot(zA)-r*r,p=e.radius*e.radius;if(c>p)return null;const y=Math.sqrt(p-c),i=r-y,C=r+y;return i<0&&C<0?null:i<0?this.at(C,t):this.at(i,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return r===null?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,c,p,y,i,C;const D=1/this.direction.x,U=1/this.direction.y,N=1/this.direction.z,R=this.origin;return D>=0?(r=(e.min.x-R.x)*D,c=(e.max.x-R.x)*D):(r=(e.max.x-R.x)*D,c=(e.min.x-R.x)*D),U>=0?(p=(e.min.y-R.y)*U,y=(e.max.y-R.y)*U):(p=(e.max.y-R.y)*U,y=(e.min.y-R.y)*U),r>y||p>c||((p>r||isNaN(r))&&(r=p),(y=0?(i=(e.min.z-R.z)*N,C=(e.max.z-R.z)*N):(i=(e.max.z-R.z)*N,C=(e.min.z-R.z)*N),r>C||i>c)||((i>r||r!==r)&&(r=i),(C=0?r:c,t)}intersectsBox(e){return this.intersectBox(e,zA)!==null}intersectTriangle(e,t,r,c,p){Iw.subVectors(t,e),nx.subVectors(r,e),Fw.crossVectors(Iw,nx);let y=this.direction.dot(Fw),i;if(y>0){if(c)return null;i=1}else if(y<0)i=-1,y=-y;else return null;Od.subVectors(this.origin,e);const C=i*this.direction.dot(nx.crossVectors(Od,nx));if(C<0)return null;const D=i*this.direction.dot(Iw.cross(Od));if(D<0||C+D>y)return null;const U=-i*Od.dot(Fw);return U<0?null:this.at(U/y,p)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class lr{constructor(){lr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,r,c,p,y,i,C,D,U,N,R,G,J,Y,B){const ae=this.elements;return ae[0]=e,ae[4]=t,ae[8]=r,ae[12]=c,ae[1]=p,ae[5]=y,ae[9]=i,ae[13]=C,ae[2]=D,ae[6]=U,ae[10]=N,ae[14]=R,ae[3]=G,ae[7]=J,ae[11]=Y,ae[15]=B,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new lr().fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,c=1/dm.setFromMatrixColumn(e,0).length(),p=1/dm.setFromMatrixColumn(e,1).length(),y=1/dm.setFromMatrixColumn(e,2).length();return t[0]=r[0]*c,t[1]=r[1]*c,t[2]=r[2]*c,t[3]=0,t[4]=r[4]*p,t[5]=r[5]*p,t[6]=r[6]*p,t[7]=0,t[8]=r[8]*y,t[9]=r[9]*y,t[10]=r[10]*y,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,c=e.y,p=e.z,y=Math.cos(r),i=Math.sin(r),C=Math.cos(c),D=Math.sin(c),U=Math.cos(p),N=Math.sin(p);if(e.order==="XYZ"){const R=y*U,G=y*N,J=i*U,Y=i*N;t[0]=C*U,t[4]=-C*N,t[8]=D,t[1]=G+J*D,t[5]=R-Y*D,t[9]=-i*C,t[2]=Y-R*D,t[6]=J+G*D,t[10]=y*C}else if(e.order==="YXZ"){const R=C*U,G=C*N,J=D*U,Y=D*N;t[0]=R+Y*i,t[4]=J*i-G,t[8]=y*D,t[1]=y*N,t[5]=y*U,t[9]=-i,t[2]=G*i-J,t[6]=Y+R*i,t[10]=y*C}else if(e.order==="ZXY"){const R=C*U,G=C*N,J=D*U,Y=D*N;t[0]=R-Y*i,t[4]=-y*N,t[8]=J+G*i,t[1]=G+J*i,t[5]=y*U,t[9]=Y-R*i,t[2]=-y*D,t[6]=i,t[10]=y*C}else if(e.order==="ZYX"){const R=y*U,G=y*N,J=i*U,Y=i*N;t[0]=C*U,t[4]=J*D-G,t[8]=R*D+Y,t[1]=C*N,t[5]=Y*D+R,t[9]=G*D-J,t[2]=-D,t[6]=i*C,t[10]=y*C}else if(e.order==="YZX"){const R=y*C,G=y*D,J=i*C,Y=i*D;t[0]=C*U,t[4]=Y-R*N,t[8]=J*N+G,t[1]=N,t[5]=y*U,t[9]=-i*U,t[2]=-D*U,t[6]=G*N+J,t[10]=R-Y*N}else if(e.order==="XZY"){const R=y*C,G=y*D,J=i*C,Y=i*D;t[0]=C*U,t[4]=-N,t[8]=D*U,t[1]=R*N+Y,t[5]=y*U,t[9]=G*N-J,t[2]=J*N-G,t[6]=i*U,t[10]=Y*N+R}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Sz,e,Mz)}lookAt(e,t,r){const c=this.elements;return Tc.subVectors(e,t),Tc.lengthSq()===0&&(Tc.z=1),Tc.normalize(),Nd.crossVectors(r,Tc),Nd.lengthSq()===0&&(Math.abs(r.z)===1?Tc.x+=1e-4:Tc.z+=1e-4,Tc.normalize(),Nd.crossVectors(r,Tc)),Nd.normalize(),rx.crossVectors(Tc,Nd),c[0]=Nd.x,c[4]=rx.x,c[8]=Tc.x,c[1]=Nd.y,c[5]=rx.y,c[9]=Tc.y,c[2]=Nd.z,c[6]=rx.z,c[10]=Tc.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,c=t.elements,p=this.elements,y=r[0],i=r[4],C=r[8],D=r[12],U=r[1],N=r[5],R=r[9],G=r[13],J=r[2],Y=r[6],B=r[10],ae=r[14],le=r[3],Ae=r[7],we=r[11],me=r[15],Pe=c[0],it=c[4],Me=c[8],Ke=c[12],Et=c[1],oi=c[5],Ci=c[9],te=c[13],ce=c[2],ye=c[6],xe=c[10],ze=c[14],Ne=c[3],Ge=c[7],Ve=c[11],Le=c[15];return p[0]=y*Pe+i*Et+C*ce+D*Ne,p[4]=y*it+i*oi+C*ye+D*Ge,p[8]=y*Me+i*Ci+C*xe+D*Ve,p[12]=y*Ke+i*te+C*ze+D*Le,p[1]=U*Pe+N*Et+R*ce+G*Ne,p[5]=U*it+N*oi+R*ye+G*Ge,p[9]=U*Me+N*Ci+R*xe+G*Ve,p[13]=U*Ke+N*te+R*ze+G*Le,p[2]=J*Pe+Y*Et+B*ce+ae*Ne,p[6]=J*it+Y*oi+B*ye+ae*Ge,p[10]=J*Me+Y*Ci+B*xe+ae*Ve,p[14]=J*Ke+Y*te+B*ze+ae*Le,p[3]=le*Pe+Ae*Et+we*ce+me*Ne,p[7]=le*it+Ae*oi+we*ye+me*Ge,p[11]=le*Me+Ae*Ci+we*xe+me*Ve,p[15]=le*Ke+Ae*te+we*ze+me*Le,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],r=e[4],c=e[8],p=e[12],y=e[1],i=e[5],C=e[9],D=e[13],U=e[2],N=e[6],R=e[10],G=e[14],J=e[3],Y=e[7],B=e[11],ae=e[15];return J*(+p*C*N-c*D*N-p*i*R+r*D*R+c*i*G-r*C*G)+Y*(+t*C*G-t*D*R+p*y*R-c*y*G+c*D*U-p*C*U)+B*(+t*D*N-t*i*G-p*y*N+r*y*G+p*i*U-r*D*U)+ae*(-c*i*U-t*C*N+t*i*R+c*y*N-r*y*R+r*C*U)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,r){const c=this.elements;return e.isVector3?(c[12]=e.x,c[13]=e.y,c[14]=e.z):(c[12]=e,c[13]=t,c[14]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],c=e[2],p=e[3],y=e[4],i=e[5],C=e[6],D=e[7],U=e[8],N=e[9],R=e[10],G=e[11],J=e[12],Y=e[13],B=e[14],ae=e[15],le=N*B*D-Y*R*D+Y*C*G-i*B*G-N*C*ae+i*R*ae,Ae=J*R*D-U*B*D-J*C*G+y*B*G+U*C*ae-y*R*ae,we=U*Y*D-J*N*D+J*i*G-y*Y*G-U*i*ae+y*N*ae,me=J*N*C-U*Y*C-J*i*R+y*Y*R+U*i*B-y*N*B,Pe=t*le+r*Ae+c*we+p*me;if(Pe===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const it=1/Pe;return e[0]=le*it,e[1]=(Y*R*p-N*B*p-Y*c*G+r*B*G+N*c*ae-r*R*ae)*it,e[2]=(i*B*p-Y*C*p+Y*c*D-r*B*D-i*c*ae+r*C*ae)*it,e[3]=(N*C*p-i*R*p-N*c*D+r*R*D+i*c*G-r*C*G)*it,e[4]=Ae*it,e[5]=(U*B*p-J*R*p+J*c*G-t*B*G-U*c*ae+t*R*ae)*it,e[6]=(J*C*p-y*B*p-J*c*D+t*B*D+y*c*ae-t*C*ae)*it,e[7]=(y*R*p-U*C*p+U*c*D-t*R*D-y*c*G+t*C*G)*it,e[8]=we*it,e[9]=(J*N*p-U*Y*p-J*r*G+t*Y*G+U*r*ae-t*N*ae)*it,e[10]=(y*Y*p-J*i*p+J*r*D-t*Y*D-y*r*ae+t*i*ae)*it,e[11]=(U*i*p-y*N*p-U*r*D+t*N*D+y*r*G-t*i*G)*it,e[12]=me*it,e[13]=(U*Y*c-J*N*c+J*r*R-t*Y*R-U*r*B+t*N*B)*it,e[14]=(J*i*c-y*Y*c-J*r*C+t*Y*C+y*r*B-t*i*B)*it,e[15]=(y*N*c-U*i*c+U*r*C-t*N*C-y*r*R+t*i*R)*it,this}scale(e){const t=this.elements,r=e.x,c=e.y,p=e.z;return t[0]*=r,t[4]*=c,t[8]*=p,t[1]*=r,t[5]*=c,t[9]*=p,t[2]*=r,t[6]*=c,t[10]*=p,t[3]*=r,t[7]*=c,t[11]*=p,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],c=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,c))}makeTranslation(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),c=Math.sin(t),p=1-r,y=e.x,i=e.y,C=e.z,D=p*y,U=p*i;return this.set(D*y+r,D*i-c*C,D*C+c*i,0,D*i+c*C,U*i+r,U*C-c*y,0,D*C-c*i,U*C+c*y,p*C*C+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,c,p,y){return this.set(1,r,p,0,e,1,y,0,t,c,1,0,0,0,0,1),this}compose(e,t,r){const c=this.elements,p=t._x,y=t._y,i=t._z,C=t._w,D=p+p,U=y+y,N=i+i,R=p*D,G=p*U,J=p*N,Y=y*U,B=y*N,ae=i*N,le=C*D,Ae=C*U,we=C*N,me=r.x,Pe=r.y,it=r.z;return c[0]=(1-(Y+ae))*me,c[1]=(G+we)*me,c[2]=(J-Ae)*me,c[3]=0,c[4]=(G-we)*Pe,c[5]=(1-(R+ae))*Pe,c[6]=(B+le)*Pe,c[7]=0,c[8]=(J+Ae)*it,c[9]=(B-le)*it,c[10]=(1-(R+Y))*it,c[11]=0,c[12]=e.x,c[13]=e.y,c[14]=e.z,c[15]=1,this}decompose(e,t,r){const c=this.elements;let p=dm.set(c[0],c[1],c[2]).length();const y=dm.set(c[4],c[5],c[6]).length(),i=dm.set(c[8],c[9],c[10]).length();this.determinant()<0&&(p=-p),e.x=c[12],e.y=c[13],e.z=c[14],ou.copy(this);const D=1/p,U=1/y,N=1/i;return ou.elements[0]*=D,ou.elements[1]*=D,ou.elements[2]*=D,ou.elements[4]*=U,ou.elements[5]*=U,ou.elements[6]*=U,ou.elements[8]*=N,ou.elements[9]*=N,ou.elements[10]*=N,t.setFromRotationMatrix(ou),r.x=p,r.y=y,r.z=i,this}makePerspective(e,t,r,c,p,y){const i=this.elements,C=2*p/(t-e),D=2*p/(r-c),U=(t+e)/(t-e),N=(r+c)/(r-c),R=-(y+p)/(y-p),G=-2*y*p/(y-p);return i[0]=C,i[4]=0,i[8]=U,i[12]=0,i[1]=0,i[5]=D,i[9]=N,i[13]=0,i[2]=0,i[6]=0,i[10]=R,i[14]=G,i[3]=0,i[7]=0,i[11]=-1,i[15]=0,this}makeOrthographic(e,t,r,c,p,y){const i=this.elements,C=1/(t-e),D=1/(r-c),U=1/(y-p),N=(t+e)*C,R=(r+c)*D,G=(y+p)*U;return i[0]=2*C,i[4]=0,i[8]=0,i[12]=-N,i[1]=0,i[5]=2*D,i[9]=0,i[13]=-R,i[2]=0,i[6]=0,i[10]=-2*U,i[14]=-G,i[3]=0,i[7]=0,i[11]=0,i[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let c=0;c<16;c++)if(t[c]!==r[c])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const dm=new ft,ou=new lr,Sz=new ft(0,0,0),Mz=new ft(1,1,1),Nd=new ft,rx=new ft,Tc=new ft,zE=new lr,kE=new sl;class Ym{constructor(e=0,t=0,r=0,c=Ym.DefaultOrder){this.isEuler=!0,this._x=e,this._y=t,this._z=r,this._order=c}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,r,c=this._order){return this._x=e,this._y=t,this._z=r,this._order=c,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,r=!0){const c=e.elements,p=c[0],y=c[4],i=c[8],C=c[1],D=c[5],U=c[9],N=c[2],R=c[6],G=c[10];switch(t){case"XYZ":this._y=Math.asin(Eo(i,-1,1)),Math.abs(i)<.9999999?(this._x=Math.atan2(-U,G),this._z=Math.atan2(-y,p)):(this._x=Math.atan2(R,D),this._z=0);break;case"YXZ":this._x=Math.asin(-Eo(U,-1,1)),Math.abs(U)<.9999999?(this._y=Math.atan2(i,G),this._z=Math.atan2(C,D)):(this._y=Math.atan2(-N,p),this._z=0);break;case"ZXY":this._x=Math.asin(Eo(R,-1,1)),Math.abs(R)<.9999999?(this._y=Math.atan2(-N,G),this._z=Math.atan2(-y,D)):(this._y=0,this._z=Math.atan2(C,p));break;case"ZYX":this._y=Math.asin(-Eo(N,-1,1)),Math.abs(N)<.9999999?(this._x=Math.atan2(R,G),this._z=Math.atan2(C,p)):(this._x=0,this._z=Math.atan2(-y,D));break;case"YZX":this._z=Math.asin(Eo(C,-1,1)),Math.abs(C)<.9999999?(this._x=Math.atan2(-U,D),this._y=Math.atan2(-N,p)):(this._x=0,this._y=Math.atan2(i,G));break;case"XZY":this._z=Math.asin(-Eo(y,-1,1)),Math.abs(y)<.9999999?(this._x=Math.atan2(R,D),this._y=Math.atan2(i,p)):(this._x=Math.atan2(-U,G),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return zE.makeRotationFromQuaternion(e),this.setFromRotationMatrix(zE,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return kE.setFromEuler(this),this.setFromQuaternion(kE,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}Ym.DefaultOrder="XYZ";Ym.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class dy{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let r=0;r0&&(r=r.concat(y))}return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(r_,e,Fz),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(r_,Lz,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let r=0,c=t.length;r0&&(c.userData=this.userData),c.layers=this.layers.mask,c.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(c.matrixAutoUpdate=!1),this.isInstancedMesh&&(c.type="InstancedMesh",c.count=this.count,c.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(c.instanceColor=this.instanceColor.toJSON()));function p(i,C){return i[C.uuid]===void 0&&(i[C.uuid]=C.toJSON(e)),C.uuid}if(this.isScene)this.background&&(this.background.isColor?c.background=this.background.toJSON():this.background.isTexture&&(c.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(c.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){c.geometry=p(e.geometries,this.geometry);const i=this.geometry.parameters;if(i!==void 0&&i.shapes!==void 0){const C=i.shapes;if(Array.isArray(C))for(let D=0,U=C.length;D0){c.children=[];for(let i=0;i0){c.animations=[];for(let i=0;i0&&(r.geometries=i),C.length>0&&(r.materials=C),D.length>0&&(r.textures=D),U.length>0&&(r.images=U),N.length>0&&(r.shapes=N),R.length>0&&(r.skeletons=R),G.length>0&&(r.animations=G),J.length>0&&(r.nodes=J)}return r.object=c,r;function y(i){const C=[];for(const D in i){const U=i[D];delete U.metadata,C.push(U)}return C}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let r=0;r0?c.multiplyScalar(1/Math.sqrt(p)):c.set(0,0,0)}static getBarycoord(e,t,r,c,p){au.subVectors(c,t),OA.subVectors(r,t),Lw.subVectors(e,t);const y=au.dot(au),i=au.dot(OA),C=au.dot(Lw),D=OA.dot(OA),U=OA.dot(Lw),N=y*D-i*i;if(N===0)return p.set(-2,-1,-1);const R=1/N,G=(D*C-i*U)*R,J=(y*U-i*C)*R;return p.set(1-G-J,J,G)}static containsPoint(e,t,r,c){return this.getBarycoord(e,t,r,c,NA),NA.x>=0&&NA.y>=0&&NA.x+NA.y<=1}static getUV(e,t,r,c,p,y,i,C){return this.getBarycoord(e,t,r,c,NA),C.set(0,0),C.addScaledVector(p,NA.x),C.addScaledVector(y,NA.y),C.addScaledVector(i,NA.z),C}static isFrontFacing(e,t,r,c){return au.subVectors(r,t),OA.subVectors(e,t),au.cross(OA).dot(c)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,c){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[c]),this}setFromAttributeAndIndices(e,t,r,c){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,c),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return au.subVectors(this.c,this.b),OA.subVectors(this.a,this.b),au.cross(OA).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return wh.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return wh.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,r,c,p){return wh.getUV(e,this.a,this.b,this.c,t,r,c,p)}containsPoint(e){return wh.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return wh.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,c=this.b,p=this.c;let y,i;fm.subVectors(c,r),mm.subVectors(p,r),Dw.subVectors(e,r);const C=fm.dot(Dw),D=mm.dot(Dw);if(C<=0&&D<=0)return t.copy(r);Pw.subVectors(e,c);const U=fm.dot(Pw),N=mm.dot(Pw);if(U>=0&&N<=U)return t.copy(c);const R=C*N-U*D;if(R<=0&&C>=0&&U<=0)return y=C/(C-U),t.copy(r).addScaledVector(fm,y);Uw.subVectors(e,p);const G=fm.dot(Uw),J=mm.dot(Uw);if(J>=0&&G<=J)return t.copy(p);const Y=G*D-C*J;if(Y<=0&&D>=0&&J<=0)return i=D/(D-J),t.copy(r).addScaledVector(mm,i);const B=U*J-G*N;if(B<=0&&N-U>=0&&G-J>=0)return GE.subVectors(p,c),i=(N-U)/(N-U+(G-J)),t.copy(c).addScaledVector(GE,i);const ae=1/(B+Y+R);return y=Y*ae,i=R*ae,t.copy(r).addScaledVector(fm,y).addScaledVector(mm,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Pz=0;class ol extends Xu{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Pz++}),this.uuid=Pc(),this.name="",this.type="Material",this.blending=Af,this.side=ju,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=D2,this.blendDst=P2,this.blendEquation=Jp,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Av,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=II,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qx,this.stencilZFail=qx,this.stencilZPass=qx,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const r=e[t];if(r===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}const c=this[t];if(c===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}c&&c.isColor?c.set(r):c&&c.isVector3&&r&&r.isVector3?c.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==Af&&(r.blending=this.blending),this.side!==ju&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(r.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=this.flatShading),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function c(p){const y=[];for(const i in p){const C=p[i];delete C.metadata,y.push(C)}return y}if(t){const p=c(e.textures),y=c(e.images);p.length>0&&(r.textures=p),y.length>0&&(r.images=y)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let r=null;if(t!==null){const c=t.length;r=new Array(c);for(let p=0;p!==c;++p)r[p]=t[p].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class na extends ol{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Dn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=hy,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ro=new ft,ox=new Di;class ds{constructor(e,t,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=r,this.usage=K_,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,r){e*=this.itemSize,r*=t.itemSize;for(let c=0,p=this.itemSize;c0&&(e.userData=this.userData),this.parameters!==void 0){const C=this.parameters;for(const D in C)C[D]!==void 0&&(e[D]=C[D]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const r=this.attributes;for(const C in r){const D=r[C];e.data.attributes[C]=D.toJSON(e.data)}const c={};let p=!1;for(const C in this.morphAttributes){const D=this.morphAttributes[C],U=[];for(let N=0,R=D.length;N0&&(c[C]=U,p=!0)}p&&(e.data.morphAttributes=c,e.data.morphTargetsRelative=this.morphTargetsRelative);const y=this.groups;y.length>0&&(e.data.groups=JSON.parse(JSON.stringify(y)));const i=this.boundingSphere;return i!==null&&(e.data.boundingSphere={center:i.center.toArray(),radius:i.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(t));const c=e.attributes;for(const D in c){const U=c[D];this.setAttribute(D,U.clone(t))}const p=e.morphAttributes;for(const D in p){const U=[],N=p[D];for(let R=0,G=N.length;R0){const c=t[r[0]];if(c!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let p=0,y=c.length;pt.far?null:{distance:D,point:ux.clone(),object:u}}function Ax(u,e,t,r,c,p,y,i,C){u.getVertexPosition(y,o_),u.getVertexPosition(i,a_),u.getVertexPosition(C,l_);const D=Hz(u,e,t,r,o_,a_,l_,Ow);if(D){c&&(lx.fromBufferAttribute(c,y),cx.fromBufferAttribute(c,i),hx.fromBufferAttribute(c,C),D.uv=wh.getUV(Ow,o_,a_,l_,lx,cx,hx,new Di)),p&&(lx.fromBufferAttribute(p,y),cx.fromBufferAttribute(p,i),hx.fromBufferAttribute(p,C),D.uv2=wh.getUV(Ow,o_,a_,l_,lx,cx,hx,new Di));const U={a:y,b:i,c:C,normal:new ft,materialIndex:0};wh.getNormal(o_,a_,l_,U.normal),D.face=U}return D}class YA extends br{constructor(e=1,t=1,r=1,c=1,p=1,y=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:c,heightSegments:p,depthSegments:y};const i=this;c=Math.floor(c),p=Math.floor(p),y=Math.floor(y);const C=[],D=[],U=[],N=[];let R=0,G=0;J("z","y","x",-1,-1,r,t,e,y,p,0),J("z","y","x",1,-1,r,t,-e,y,p,1),J("x","z","y",1,1,e,r,t,c,y,2),J("x","z","y",1,-1,e,r,-t,c,y,3),J("x","y","z",1,-1,e,t,r,c,p,4),J("x","y","z",-1,-1,e,t,-r,c,p,5),this.setIndex(C),this.setAttribute("position",new jn(D,3)),this.setAttribute("normal",new jn(U,3)),this.setAttribute("uv",new jn(N,2));function J(Y,B,ae,le,Ae,we,me,Pe,it,Me,Ke){const Et=we/it,oi=me/Me,Ci=we/2,te=me/2,ce=Pe/2,ye=it+1,xe=Me+1;let ze=0,Ne=0;const Ge=new ft;for(let Ve=0;Ve0?1:-1,U.push(Ge.x,Ge.y,Ge.z),N.push(Ie/it),N.push(1-Ve/Me),ze+=1}}for(let Ve=0;Ve0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const r={};for(const c in this.extensions)this.extensions[c]===!0&&(r[c]=!0);return Object.keys(r).length>0&&(t.extensions=r),t}}class Hv extends cs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new lr,this.projectionMatrix=new lr,this.projectionMatrixInverse=new lr}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class _a extends Hv{constructor(e=50,t=1,r=.1,c=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=c,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=$_*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(pf*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return $_*2*Math.atan(Math.tan(pf*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,r,c,p,y){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=c,this.view.width=p,this.view.height=y,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(pf*.5*this.fov)/this.zoom,r=2*t,c=this.aspect*r,p=-.5*c;const y=this.view;if(this.view!==null&&this.view.enabled){const C=y.fullWidth,D=y.fullHeight;p+=y.offsetX*c/C,t-=y.offsetY*r/D,c*=y.width/C,r*=y.height/D}const i=this.filmOffset;i!==0&&(p+=e*i/this.getFilmWidth()),this.projectionMatrix.makePerspective(p,p+c,t,t-r,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const ym=-90,xm=1;class RI extends cs{constructor(e,t,r){super(),this.type="CubeCamera",this.renderTarget=r;const c=new _a(ym,xm,e,t);c.layers=this.layers,c.up.set(0,1,0),c.lookAt(1,0,0),this.add(c);const p=new _a(ym,xm,e,t);p.layers=this.layers,p.up.set(0,1,0),p.lookAt(-1,0,0),this.add(p);const y=new _a(ym,xm,e,t);y.layers=this.layers,y.up.set(0,0,-1),y.lookAt(0,1,0),this.add(y);const i=new _a(ym,xm,e,t);i.layers=this.layers,i.up.set(0,0,1),i.lookAt(0,-1,0),this.add(i);const C=new _a(ym,xm,e,t);C.layers=this.layers,C.up.set(0,1,0),C.lookAt(0,0,1),this.add(C);const D=new _a(ym,xm,e,t);D.layers=this.layers,D.up.set(0,1,0),D.lookAt(0,0,-1),this.add(D)}update(e,t){this.parent===null&&this.updateMatrixWorld();const r=this.renderTarget,[c,p,y,i,C,D]=this.children,U=e.getRenderTarget(),N=e.toneMapping,R=e.xr.enabled;e.toneMapping=Vu,e.xr.enabled=!1;const G=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0),e.render(t,c),e.setRenderTarget(r,1),e.render(t,p),e.setRenderTarget(r,2),e.render(t,y),e.setRenderTarget(r,3),e.render(t,i),e.setRenderTarget(r,4),e.render(t,C),r.texture.generateMipmaps=G,e.setRenderTarget(r,5),e.render(t,D),e.setRenderTarget(U),e.toneMapping=N,e.xr.enabled=R,r.texture.needsPMREMUpdate=!0}}class py extends To{constructor(e,t,r,c,p,y,i,C,D,U){e=e!==void 0?e:[],t=t!==void 0?t:op,super(e,t,r,c,p,y,i,C,D,U),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class zI extends Oa{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},c=[r,r,r,r,r,r];this.texture=new py(c,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Xs}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},c=new YA(5,5,5),p=new ko({name:"CubemapFromEquirect",uniforms:jm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Dc,blending:KA});p.uniforms.tEquirect.value=t;const y=new is(c,p),i=t.minFilter;return t.minFilter===lp&&(t.minFilter=Xs),new RI(1,10,this).update(e,y),t.minFilter=i,y.geometry.dispose(),y.material.dispose(),this}clear(e,t,r,c){const p=e.getRenderTarget();for(let y=0;y<6;y++)e.setRenderTarget(this,y),e.clear(t,r,c);e.setRenderTarget(p)}}const Nw=new ft,Kz=new ft,$z=new Pl;class $d{constructor(e=new ft(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,r,c){return this.normal.set(e,t,r),this.constant=c,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){const c=Nw.subVectors(r,t).cross(Kz.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(c,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const r=e.delta(Nw),c=this.normal.dot(r);if(c===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const p=-(e.start.dot(this.normal)+this.constant)/c;return p<0||p>1?null:t.copy(r).multiplyScalar(p).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const r=t||$z.getNormalMatrix(e),c=this.coplanarPoint(Nw).applyMatrix4(e),p=this.normal.applyMatrix3(r).normalize();return this.constant=-c.dot(p),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const vm=new qA,dx=new ft;class Gv{constructor(e=new $d,t=new $d,r=new $d,c=new $d,p=new $d,y=new $d){this.planes=[e,t,r,c,p,y]}set(e,t,r,c,p,y){const i=this.planes;return i[0].copy(e),i[1].copy(t),i[2].copy(r),i[3].copy(c),i[4].copy(p),i[5].copy(y),this}copy(e){const t=this.planes;for(let r=0;r<6;r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e){const t=this.planes,r=e.elements,c=r[0],p=r[1],y=r[2],i=r[3],C=r[4],D=r[5],U=r[6],N=r[7],R=r[8],G=r[9],J=r[10],Y=r[11],B=r[12],ae=r[13],le=r[14],Ae=r[15];return t[0].setComponents(i-c,N-C,Y-R,Ae-B).normalize(),t[1].setComponents(i+c,N+C,Y+R,Ae+B).normalize(),t[2].setComponents(i+p,N+D,Y+G,Ae+ae).normalize(),t[3].setComponents(i-p,N-D,Y-G,Ae-ae).normalize(),t[4].setComponents(i-y,N-U,Y-J,Ae-le).normalize(),t[5].setComponents(i+y,N+U,Y+J,Ae+le).normalize(),this}intersectsObject(e){const t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),vm.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(vm)}intersectsSprite(e){return vm.center.set(0,0,0),vm.radius=.7071067811865476,vm.applyMatrix4(e.matrixWorld),this.intersectsSphere(vm)}intersectsSphere(e){const t=this.planes,r=e.center,c=-e.radius;for(let p=0;p<6;p++)if(t[p].distanceToPoint(r)0?e.max.x:e.min.x,dx.y=c.normal.y>0?e.max.y:e.min.y,dx.z=c.normal.z>0?e.max.z:e.min.z,c.distanceToPoint(dx)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function kI(){let u=null,e=!1,t=null,r=null;function c(p,y){t(p,y),r=u.requestAnimationFrame(c)}return{start:function(){e!==!0&&t!==null&&(r=u.requestAnimationFrame(c),e=!0)},stop:function(){u.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(p){t=p},setContext:function(p){u=p}}}function Zz(u,e){const t=e.isWebGL2,r=new WeakMap;function c(D,U){const N=D.array,R=D.usage,G=u.createBuffer();u.bindBuffer(U,G),u.bufferData(U,N,R),D.onUploadCallback();let J;if(N instanceof Float32Array)J=5126;else if(N instanceof Uint16Array)if(D.isFloat16BufferAttribute)if(t)J=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else J=5123;else if(N instanceof Int16Array)J=5122;else if(N instanceof Uint32Array)J=5125;else if(N instanceof Int32Array)J=5124;else if(N instanceof Int8Array)J=5120;else if(N instanceof Uint8Array)J=5121;else if(N instanceof Uint8ClampedArray)J=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+N);return{buffer:G,type:J,bytesPerElement:N.BYTES_PER_ELEMENT,version:D.version}}function p(D,U,N){const R=U.array,G=U.updateRange;u.bindBuffer(N,D),G.count===-1?u.bufferSubData(N,0,R):(t?u.bufferSubData(N,G.offset*R.BYTES_PER_ELEMENT,R,G.offset,G.count):u.bufferSubData(N,G.offset*R.BYTES_PER_ELEMENT,R.subarray(G.offset,G.offset+G.count)),G.count=-1),U.onUploadCallback()}function y(D){return D.isInterleavedBufferAttribute&&(D=D.data),r.get(D)}function i(D){D.isInterleavedBufferAttribute&&(D=D.data);const U=r.get(D);U&&(u.deleteBuffer(U.buffer),r.delete(D))}function C(D,U){if(D.isGLBufferAttribute){const R=r.get(D);(!R||R.version 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( specularColor, 1.0, dotVH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif`,sk=`#ifdef USE_IRIDESCENCE const mat3 XYZ_TO_REC709 = mat3( 3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.0415560, 1.0572252 ); vec3 Fresnel0ToIor( vec3 fresnel0 ) { vec3 sqrtF0 = sqrt( fresnel0 ); return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); } vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); } float IorToFresnel0( float transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); } vec3 evalSensitivity( float OPD, vec3 shift ) { float phase = 2.0 * PI * OPD * 1.0e-9; vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); xyz /= 1.0685e-7; vec3 rgb = XYZ_TO_REC709 * xyz; return rgb; } vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { vec3 I; float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); float cosTheta2Sq = 1.0 - sinTheta2Sq; if ( cosTheta2Sq < 0.0 ) { return vec3( 1.0 ); } float cosTheta2 = sqrt( cosTheta2Sq ); float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); float R12 = F_Schlick( R0, 1.0, cosTheta1 ); float R21 = R12; float T121 = 1.0 - R12; float phi12 = 0.0; if ( iridescenceIOR < outsideIOR ) phi12 = PI; float phi21 = PI - phi12; vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); vec3 phi23 = vec3( 0.0 ); if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; vec3 phi = vec3( phi21 ) + phi23; vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); vec3 r123 = sqrt( R123 ); vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); vec3 C0 = R12 + Rs; I = C0; vec3 Cm = Rs - T121; for ( int m = 1; m <= 2; ++ m ) { Cm *= r123; vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); I += Cm * Sm; } return max( I, vec3( 0.0 ) ); } #endif`,ok=`#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vUv ); vec2 dSTdy = dFdy( vUv ); float Hll = bumpScale * texture2D( bumpMap, vUv ).x; float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { vec3 vSigmaX = dFdx( surf_pos.xyz ); vec3 vSigmaY = dFdy( surf_pos.xyz ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`,ak=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif`,lk=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,ck=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,hk=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,uk=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,Ak=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,dk=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,pk=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif`,fk=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; #ifdef USE_CLEARCOAT vec3 clearcoatNormal; #endif }; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } float luminance( const in vec3 rgb ) { const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); return dot( weights, rgb ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); }`,mk=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_v0 0.339 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_v1 0.276 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_v4 0.046 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_v5 0.016 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_v6 0.0038 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,gk=`vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 m = mat3( instanceMatrix ); transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); transformedNormal = m * transformedNormal; #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,_k=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,yk=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`,xk=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,vk=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,wk="gl_FragColor = linearToOutputTexel( gl_FragColor );",bk=`vec4 LinearToLinear( in vec4 value ) { return value; } vec4 LinearTosRGB( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`,Bk=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,Ck=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,Ek=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,Tk=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,Sk=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,Mk=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,Ik=`#ifdef USE_FOG varying float vFogDepth; #endif`,Fk=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,Lk=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,Dk=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,Pk=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,Uk=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,Rk=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,zk=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,kk=`uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { #if defined ( PHYSICALLY_CORRECT_LIGHTS ) float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; #else if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); } return 1.0; #endif } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = pointLight.position - geometry.position; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = spotLight.position - geometry.position; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`,Ok=`#if defined( USE_ENVMAP ) vec3 getIBLIrradiance( const in vec3 normal ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #endif`,Nk=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,Qk=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Vk=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,Hk=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Gk=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULARINTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; #endif #ifdef USE_SPECULARCOLORMAP specularColorFactor *= texture2D( specularColorMap, vUv ).rgb; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEENCOLORMAP material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEENROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; #endif #endif`,Wk=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif }; vec3 clearcoatSpecular = vec3( 0.0 ); vec3 sheenSpecular = vec3( 0.0 ); float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometry.normal; vec3 viewDir = geometry.viewDir; vec3 position = geometry.position; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); #endif #ifdef USE_IRIDESCENCE reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness ); #else reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); #endif reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,jk=` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef USE_CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometry.viewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometry, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,Kk=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometry.normal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); #endif #endif`,$k=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,Zk=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,Xk=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,qk=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,Yk=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #else if ( isPerspectiveMatrix( projectionMatrix ) ) { gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; gl_Position.z *= gl_Position.w; } #endif #endif`,Jk=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; #endif`,e5=`#ifdef USE_MAP uniform sampler2D map; #endif`,t5=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,i5=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,n5=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`,r5=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,s5=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,o5=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #else objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif #endif`,a5=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #else #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif #endif`,l5=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #else transformed += morphTarget0 * morphTargetInfluences[ 0 ]; transformed += morphTarget1 * morphTargetInfluences[ 1 ]; transformed += morphTarget2 * morphTargetInfluences[ 2 ]; transformed += morphTarget3 * morphTargetInfluences[ 3 ]; #ifndef USE_MORPHNORMALS transformed += morphTarget4 * morphTargetInfluences[ 4 ]; transformed += morphTarget5 * morphTargetInfluences[ 5 ]; transformed += morphTarget6 * morphTargetInfluences[ 6 ]; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif #endif`,c5=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif #ifdef USE_TANGENT vec3 tangent = normalize( vTangent ); vec3 bitangent = normalize( vBitangent ); #ifdef DOUBLE_SIDED tangent = tangent * faceDirection; bitangent = bitangent * faceDirection; #endif #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) mat3 vTBN = mat3( tangent, bitangent, normal ); #endif #endif #endif vec3 geometryNormal = normal;`,h5=`#ifdef OBJECTSPACE_NORMALMAP normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( TANGENTSPACE_NORMALMAP ) vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; #ifdef USE_TANGENT normal = normalize( vTBN * mapN ); #else normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection ); #endif #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,u5=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,A5=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,d5=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,p5=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef OBJECTSPACE_NORMALMAP uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( vUv.st ); vec2 st1 = dFdy( vUv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); } #endif`,f5=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,m5=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; #ifdef USE_TANGENT clearcoatNormal = normalize( vTBN * clearcoatMapN ); #else clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); #endif #endif`,g5=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif`,_5=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,y5=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha + 0.1; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,x5=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); const float ShiftRight8 = 1. / 256.; vec4 packDepthToRGBA( const in float v ) { vec4 r = vec4( fract( v * PackFactors ), v ); r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors ); } vec2 packDepthToRG( in highp float v ) { return packDepthToRGBA( v ).yx; } float unpackRGToDepth( const in highp vec2 v ) { return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); } vec4 pack2HalfToRGBA( vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { return linearClipZ * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * invClipZ - far ); }`,v5=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,w5=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,b5=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,B5=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,C5=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`,E5=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,T5=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); vec3 lightToPosition = shadowCoord.xyz; float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; return ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } #endif`,S5=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,M5=`#if defined( USE_SHADOWMAP ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) #if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_COORDS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif`,I5=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,F5=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,L5=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; uniform int boneTextureSize; mat4 getBoneMatrix( const in float i ) { float j = i * 4.0; float x = mod( j, float( boneTextureSize ) ); float y = floor( j / float( boneTextureSize ) ); float dx = 1.0 / float( boneTextureSize ); float dy = 1.0 / float( boneTextureSize ); y = dy * ( y + 0.5 ); vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); mat4 bone = mat4( v1, v2, v3, v4 ); return bone; } #endif`,D5=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,P5=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,U5=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,R5=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,z5=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,k5=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return toneMappingExposure * color; } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 OptimizedCineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,O5=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmission = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission ); #endif`,N5=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); #ifdef texture2DLodEXT return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #else return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #endif } vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return radiance; } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); } #endif`,Q5=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`,V5=`#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`,H5=`#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`,G5=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`,W5=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`,j5=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`,K5=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const $5=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,Z5=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,X5=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,q5=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,Y5=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,J5=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,eO=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,tO=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif }`,iO=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,nO=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,rO=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,sO=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,oO=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include }`,aO=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,lO=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,cO=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,hO=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,uO=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,AO=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,dO=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,pO=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,fO=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,mO=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,gO=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,_O=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,yO=`#define STANDARD #ifdef PHYSICAL #define IOR #define SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULARINTENSITYMAP uniform sampler2D specularIntensityMap; #endif #ifdef USE_SPECULARCOLORMAP uniform sampler2D specularColorMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEENCOLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEENROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; #endif #include #include #include #include #include #include }`,xO=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,vO=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,wO=`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,bO=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,BO=`#include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include }`,CO=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,EO=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,TO=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,zr={alphamap_fragment:Xz,alphamap_pars_fragment:qz,alphatest_fragment:Yz,alphatest_pars_fragment:Jz,aomap_fragment:ek,aomap_pars_fragment:tk,begin_vertex:ik,beginnormal_vertex:nk,bsdfs:rk,iridescence_fragment:sk,bumpmap_pars_fragment:ok,clipping_planes_fragment:ak,clipping_planes_pars_fragment:lk,clipping_planes_pars_vertex:ck,clipping_planes_vertex:hk,color_fragment:uk,color_pars_fragment:Ak,color_pars_vertex:dk,color_vertex:pk,common:fk,cube_uv_reflection_fragment:mk,defaultnormal_vertex:gk,displacementmap_pars_vertex:_k,displacementmap_vertex:yk,emissivemap_fragment:xk,emissivemap_pars_fragment:vk,encodings_fragment:wk,encodings_pars_fragment:bk,envmap_fragment:Bk,envmap_common_pars_fragment:Ck,envmap_pars_fragment:Ek,envmap_pars_vertex:Tk,envmap_physical_pars_fragment:Ok,envmap_vertex:Sk,fog_vertex:Mk,fog_pars_vertex:Ik,fog_fragment:Fk,fog_pars_fragment:Lk,gradientmap_pars_fragment:Dk,lightmap_fragment:Pk,lightmap_pars_fragment:Uk,lights_lambert_fragment:Rk,lights_lambert_pars_fragment:zk,lights_pars_begin:kk,lights_toon_fragment:Nk,lights_toon_pars_fragment:Qk,lights_phong_fragment:Vk,lights_phong_pars_fragment:Hk,lights_physical_fragment:Gk,lights_physical_pars_fragment:Wk,lights_fragment_begin:jk,lights_fragment_maps:Kk,lights_fragment_end:$k,logdepthbuf_fragment:Zk,logdepthbuf_pars_fragment:Xk,logdepthbuf_pars_vertex:qk,logdepthbuf_vertex:Yk,map_fragment:Jk,map_pars_fragment:e5,map_particle_fragment:t5,map_particle_pars_fragment:i5,metalnessmap_fragment:n5,metalnessmap_pars_fragment:r5,morphcolor_vertex:s5,morphnormal_vertex:o5,morphtarget_pars_vertex:a5,morphtarget_vertex:l5,normal_fragment_begin:c5,normal_fragment_maps:h5,normal_pars_fragment:u5,normal_pars_vertex:A5,normal_vertex:d5,normalmap_pars_fragment:p5,clearcoat_normal_fragment_begin:f5,clearcoat_normal_fragment_maps:m5,clearcoat_pars_fragment:g5,iridescence_pars_fragment:_5,output_fragment:y5,packing:x5,premultiplied_alpha_fragment:v5,project_vertex:w5,dithering_fragment:b5,dithering_pars_fragment:B5,roughnessmap_fragment:C5,roughnessmap_pars_fragment:E5,shadowmap_pars_fragment:T5,shadowmap_pars_vertex:S5,shadowmap_vertex:M5,shadowmask_pars_fragment:I5,skinbase_vertex:F5,skinning_pars_vertex:L5,skinning_vertex:D5,skinnormal_vertex:P5,specularmap_fragment:U5,specularmap_pars_fragment:R5,tonemapping_fragment:z5,tonemapping_pars_fragment:k5,transmission_fragment:O5,transmission_pars_fragment:N5,uv_pars_fragment:Q5,uv_pars_vertex:V5,uv_vertex:H5,uv2_pars_fragment:G5,uv2_pars_vertex:W5,uv2_vertex:j5,worldpos_vertex:K5,background_vert:$5,background_frag:Z5,backgroundCube_vert:X5,backgroundCube_frag:q5,cube_vert:Y5,cube_frag:J5,depth_vert:eO,depth_frag:tO,distanceRGBA_vert:iO,distanceRGBA_frag:nO,equirect_vert:rO,equirect_frag:sO,linedashed_vert:oO,linedashed_frag:aO,meshbasic_vert:lO,meshbasic_frag:cO,meshlambert_vert:hO,meshlambert_frag:uO,meshmatcap_vert:AO,meshmatcap_frag:dO,meshnormal_vert:pO,meshnormal_frag:fO,meshphong_vert:mO,meshphong_frag:gO,meshphysical_vert:_O,meshphysical_frag:yO,meshtoon_vert:xO,meshtoon_frag:vO,points_vert:wO,points_frag:bO,shadow_vert:BO,shadow_frag:CO,sprite_vert:EO,sprite_frag:TO},En={common:{diffuse:{value:new Dn(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Pl},uv2Transform:{value:new Pl},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Di(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Dn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Dn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Pl}},sprite:{diffuse:{value:new Dn(16777215)},opacity:{value:1},center:{value:new Di(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Pl}}},Fl={basic:{uniforms:Sl([En.common,En.specularmap,En.envmap,En.aomap,En.lightmap,En.fog]),vertexShader:zr.meshbasic_vert,fragmentShader:zr.meshbasic_frag},lambert:{uniforms:Sl([En.common,En.specularmap,En.envmap,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.fog,En.lights,{emissive:{value:new Dn(0)}}]),vertexShader:zr.meshlambert_vert,fragmentShader:zr.meshlambert_frag},phong:{uniforms:Sl([En.common,En.specularmap,En.envmap,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.fog,En.lights,{emissive:{value:new Dn(0)},specular:{value:new Dn(1118481)},shininess:{value:30}}]),vertexShader:zr.meshphong_vert,fragmentShader:zr.meshphong_frag},standard:{uniforms:Sl([En.common,En.envmap,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.roughnessmap,En.metalnessmap,En.fog,En.lights,{emissive:{value:new Dn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:zr.meshphysical_vert,fragmentShader:zr.meshphysical_frag},toon:{uniforms:Sl([En.common,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.gradientmap,En.fog,En.lights,{emissive:{value:new Dn(0)}}]),vertexShader:zr.meshtoon_vert,fragmentShader:zr.meshtoon_frag},matcap:{uniforms:Sl([En.common,En.bumpmap,En.normalmap,En.displacementmap,En.fog,{matcap:{value:null}}]),vertexShader:zr.meshmatcap_vert,fragmentShader:zr.meshmatcap_frag},points:{uniforms:Sl([En.points,En.fog]),vertexShader:zr.points_vert,fragmentShader:zr.points_frag},dashed:{uniforms:Sl([En.common,En.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:zr.linedashed_vert,fragmentShader:zr.linedashed_frag},depth:{uniforms:Sl([En.common,En.displacementmap]),vertexShader:zr.depth_vert,fragmentShader:zr.depth_frag},normal:{uniforms:Sl([En.common,En.bumpmap,En.normalmap,En.displacementmap,{opacity:{value:1}}]),vertexShader:zr.meshnormal_vert,fragmentShader:zr.meshnormal_frag},sprite:{uniforms:Sl([En.sprite,En.fog]),vertexShader:zr.sprite_vert,fragmentShader:zr.sprite_frag},background:{uniforms:{uvTransform:{value:new Pl},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:zr.background_vert,fragmentShader:zr.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:zr.backgroundCube_vert,fragmentShader:zr.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:zr.cube_vert,fragmentShader:zr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:zr.equirect_vert,fragmentShader:zr.equirect_frag},distanceRGBA:{uniforms:Sl([En.common,En.displacementmap,{referencePosition:{value:new ft},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:zr.distanceRGBA_vert,fragmentShader:zr.distanceRGBA_frag},shadow:{uniforms:Sl([En.lights,En.fog,{color:{value:new Dn(0)},opacity:{value:1}}]),vertexShader:zr.shadow_vert,fragmentShader:zr.shadow_frag}};Fl.physical={uniforms:Sl([Fl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Di(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Dn(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new Di},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Dn(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Dn(1,1,1)},specularColorMap:{value:null}}]),vertexShader:zr.meshphysical_vert,fragmentShader:zr.meshphysical_frag};const px={r:0,b:0,g:0};function SO(u,e,t,r,c,p,y){const i=new Dn(0);let C=p===!0?0:1,D,U,N=null,R=0,G=null;function J(B,ae){let le=!1,Ae=ae.isScene===!0?ae.background:null;Ae&&Ae.isTexture&&(Ae=(ae.backgroundBlurriness>0?t:e).get(Ae));const we=u.xr,me=we.getSession&&we.getSession();me&&me.environmentBlendMode==="additive"&&(Ae=null),Ae===null?Y(i,C):Ae&&Ae.isColor&&(Y(Ae,1),le=!0),(u.autoClear||le)&&u.clear(u.autoClearColor,u.autoClearDepth,u.autoClearStencil),Ae&&(Ae.isCubeTexture||Ae.mapping===qm)?(U===void 0&&(U=new is(new YA(1,1,1),new ko({name:"BackgroundCubeMaterial",uniforms:jm(Fl.backgroundCube.uniforms),vertexShader:Fl.backgroundCube.vertexShader,fragmentShader:Fl.backgroundCube.fragmentShader,side:Dc,depthTest:!1,depthWrite:!1,fog:!1})),U.geometry.deleteAttribute("normal"),U.geometry.deleteAttribute("uv"),U.onBeforeRender=function(Pe,it,Me){this.matrixWorld.copyPosition(Me.matrixWorld)},Object.defineProperty(U.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),c.update(U)),U.material.uniforms.envMap.value=Ae,U.material.uniforms.flipEnvMap.value=Ae.isCubeTexture&&Ae.isRenderTargetTexture===!1?-1:1,U.material.uniforms.backgroundBlurriness.value=ae.backgroundBlurriness,U.material.uniforms.backgroundIntensity.value=ae.backgroundIntensity,U.material.toneMapped=Ae.encoding!==Ss,(N!==Ae||R!==Ae.version||G!==u.toneMapping)&&(U.material.needsUpdate=!0,N=Ae,R=Ae.version,G=u.toneMapping),U.layers.enableAll(),B.unshift(U,U.geometry,U.material,0,0,null)):Ae&&Ae.isTexture&&(D===void 0&&(D=new is(new $A(2,2),new ko({name:"BackgroundMaterial",uniforms:jm(Fl.background.uniforms),vertexShader:Fl.background.vertexShader,fragmentShader:Fl.background.fragmentShader,side:ju,depthTest:!1,depthWrite:!1,fog:!1})),D.geometry.deleteAttribute("normal"),Object.defineProperty(D.material,"map",{get:function(){return this.uniforms.t2D.value}}),c.update(D)),D.material.uniforms.t2D.value=Ae,D.material.uniforms.backgroundIntensity.value=ae.backgroundIntensity,D.material.toneMapped=Ae.encoding!==Ss,Ae.matrixAutoUpdate===!0&&Ae.updateMatrix(),D.material.uniforms.uvTransform.value.copy(Ae.matrix),(N!==Ae||R!==Ae.version||G!==u.toneMapping)&&(D.material.needsUpdate=!0,N=Ae,R=Ae.version,G=u.toneMapping),D.layers.enableAll(),B.unshift(D,D.geometry,D.material,0,0,null))}function Y(B,ae){B.getRGB(px,UI(u)),r.buffers.color.setClear(px.r,px.g,px.b,ae,y)}return{getClearColor:function(){return i},setClearColor:function(B,ae=1){i.set(B),C=ae,Y(i,C)},getClearAlpha:function(){return C},setClearAlpha:function(B){C=B,Y(i,C)},render:J}}function MO(u,e,t,r){const c=u.getParameter(34921),p=r.isWebGL2?null:e.get("OES_vertex_array_object"),y=r.isWebGL2||p!==null,i={},C=B(null);let D=C,U=!1;function N(ce,ye,xe,ze,Ne){let Ge=!1;if(y){const Ve=Y(ze,xe,ye);D!==Ve&&(D=Ve,G(D.object)),Ge=ae(ce,ze,xe,Ne),Ge&&le(ce,ze,xe,Ne)}else{const Ve=ye.wireframe===!0;(D.geometry!==ze.id||D.program!==xe.id||D.wireframe!==Ve)&&(D.geometry=ze.id,D.program=xe.id,D.wireframe=Ve,Ge=!0)}Ne!==null&&t.update(Ne,34963),(Ge||U)&&(U=!1,Me(ce,ye,xe,ze),Ne!==null&&u.bindBuffer(34963,t.get(Ne).buffer))}function R(){return r.isWebGL2?u.createVertexArray():p.createVertexArrayOES()}function G(ce){return r.isWebGL2?u.bindVertexArray(ce):p.bindVertexArrayOES(ce)}function J(ce){return r.isWebGL2?u.deleteVertexArray(ce):p.deleteVertexArrayOES(ce)}function Y(ce,ye,xe){const ze=xe.wireframe===!0;let Ne=i[ce.id];Ne===void 0&&(Ne={},i[ce.id]=Ne);let Ge=Ne[ye.id];Ge===void 0&&(Ge={},Ne[ye.id]=Ge);let Ve=Ge[ze];return Ve===void 0&&(Ve=B(R()),Ge[ze]=Ve),Ve}function B(ce){const ye=[],xe=[],ze=[];for(let Ne=0;Ne=0){const et=Ne[Ie];let vt=Ge[Ie];if(vt===void 0&&(Ie==="instanceMatrix"&&ce.instanceMatrix&&(vt=ce.instanceMatrix),Ie==="instanceColor"&&ce.instanceColor&&(vt=ce.instanceColor)),et===void 0||et.attribute!==vt||vt&&et.data!==vt.data)return!0;Ve++}return D.attributesNum!==Ve||D.index!==ze}function le(ce,ye,xe,ze){const Ne={},Ge=ye.attributes;let Ve=0;const Le=xe.getAttributes();for(const Ie in Le)if(Le[Ie].location>=0){let et=Ge[Ie];et===void 0&&(Ie==="instanceMatrix"&&ce.instanceMatrix&&(et=ce.instanceMatrix),Ie==="instanceColor"&&ce.instanceColor&&(et=ce.instanceColor));const vt={};vt.attribute=et,et&&et.data&&(vt.data=et.data),Ne[Ie]=vt,Ve++}D.attributes=Ne,D.attributesNum=Ve,D.index=ze}function Ae(){const ce=D.newAttributes;for(let ye=0,xe=ce.length;ye=0){let qe=Ne[Le];if(qe===void 0&&(Le==="instanceMatrix"&&ce.instanceMatrix&&(qe=ce.instanceMatrix),Le==="instanceColor"&&ce.instanceColor&&(qe=ce.instanceColor)),qe!==void 0){const et=qe.normalized,vt=qe.itemSize,Be=t.get(qe);if(Be===void 0)continue;const dt=Be.buffer,ut=Be.type,Qt=Be.bytesPerElement;if(qe.isInterleavedBufferAttribute){const Wt=qe.data,Nt=Wt.stride,Ct=qe.offset;if(Wt.isInstancedInterleavedBuffer){for(let Ft=0;Ft0&&u.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";it="mediump"}return it==="mediump"&&u.getShaderPrecisionFormat(35633,36337).precision>0&&u.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const y=typeof WebGL2RenderingContext<"u"&&u instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&u instanceof WebGL2ComputeRenderingContext;let i=t.precision!==void 0?t.precision:"highp";const C=p(i);C!==i&&(console.warn("THREE.WebGLRenderer:",i,"not supported, using",C,"instead."),i=C);const D=y||e.has("WEBGL_draw_buffers"),U=t.logarithmicDepthBuffer===!0,N=u.getParameter(34930),R=u.getParameter(35660),G=u.getParameter(3379),J=u.getParameter(34076),Y=u.getParameter(34921),B=u.getParameter(36347),ae=u.getParameter(36348),le=u.getParameter(36349),Ae=R>0,we=y||e.has("OES_texture_float"),me=Ae&&we,Pe=y?u.getParameter(36183):0;return{isWebGL2:y,drawBuffers:D,getMaxAnisotropy:c,getMaxPrecision:p,precision:i,logarithmicDepthBuffer:U,maxTextures:N,maxVertexTextures:R,maxTextureSize:G,maxCubemapSize:J,maxAttributes:Y,maxVertexUniforms:B,maxVaryings:ae,maxFragmentUniforms:le,vertexTextures:Ae,floatFragmentTextures:we,floatVertexTextures:me,maxSamples:Pe}}function LO(u){const e=this;let t=null,r=0,c=!1,p=!1;const y=new $d,i=new Pl,C={value:null,needsUpdate:!1};this.uniform=C,this.numPlanes=0,this.numIntersection=0,this.init=function(N,R,G){const J=N.length!==0||R||r!==0||c;return c=R,t=U(N,G,0),r=N.length,J},this.beginShadows=function(){p=!0,U(null)},this.endShadows=function(){p=!1,D()},this.setState=function(N,R,G){const J=N.clippingPlanes,Y=N.clipIntersection,B=N.clipShadows,ae=u.get(N);if(!c||J===null||J.length===0||p&&!B)p?U(null):D();else{const le=p?0:r,Ae=le*4;let we=ae.clippingState||null;C.value=we,we=U(J,R,Ae,G);for(let me=0;me!==Ae;++me)we[me]=t[me];ae.clippingState=we,this.numIntersection=Y?this.numPlanes:0,this.numPlanes+=le}};function D(){C.value!==t&&(C.value=t,C.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function U(N,R,G,J){const Y=N!==null?N.length:0;let B=null;if(Y!==0){if(B=C.value,J!==!0||B===null){const ae=G+Y*4,le=R.matrixWorldInverse;i.getNormalMatrix(le),(B===null||B.length0){const D=new zI(C.height/2);return D.fromEquirectangularTexture(u,y),e.set(y,D),y.addEventListener("dispose",c),t(D.texture,y.mapping)}else return null}}return y}function c(y){const i=y.target;i.removeEventListener("dispose",c);const C=e.get(i);C!==void 0&&(e.delete(i),C.dispose())}function p(){e=new WeakMap}return{get:r,dispose:p}}class fy extends Hv{constructor(e=-1,t=1,r=1,c=-1,p=.1,y=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=c,this.near=p,this.far=y,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,r,c,p,y){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=c,this.view.width=p,this.view.height=y,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,c=(this.top+this.bottom)/2;let p=r-e,y=r+e,i=c+t,C=c-t;if(this.view!==null&&this.view.enabled){const D=(this.right-this.left)/this.view.fullWidth/this.zoom,U=(this.top-this.bottom)/this.view.fullHeight/this.zoom;p+=D*this.view.offsetX,y=p+D*this.view.width,i-=U*this.view.offsetY,C=i-U*this.view.height}this.projectionMatrix.makeOrthographic(p,y,i,C,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Um=4,jE=[.125,.215,.35,.446,.526,.582],ef=20,Qw=new fy,KE=new Dn;let Vw=null;const Xp=(1+Math.sqrt(5))/2,wm=1/Xp,$E=[new ft(1,1,1),new ft(-1,1,1),new ft(1,1,-1),new ft(-1,1,-1),new ft(0,Xp,wm),new ft(0,Xp,-wm),new ft(wm,0,Xp),new ft(-wm,0,Xp),new ft(Xp,wm,0),new ft(-Xp,wm,0)];class a2{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,r=.1,c=100){Vw=this._renderer.getRenderTarget(),this._setSize(256);const p=this._allocateTargets();return p.depthBuffer=!0,this._sceneToCubeUV(e,r,c,p),t>0&&this._blur(p,0,0,t),this._applyPMREM(p),this._cleanup(p),p}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=qE(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=XE(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?Ae:0,Ae,Ae),U.setRenderTarget(c),Y&&U.render(J,i),U.render(e,i)}J.geometry.dispose(),J.material.dispose(),U.toneMapping=R,U.autoClear=N,e.background=B}_textureToCubeUV(e,t){const r=this._renderer,c=e.mapping===op||e.mapping===ap;c?(this._cubemapMaterial===null&&(this._cubemapMaterial=qE()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=XE());const p=c?this._cubemapMaterial:this._equirectMaterial,y=new is(this._lodPlanes[0],p),i=p.uniforms;i.envMap.value=e;const C=this._cubeSize;fx(t,0,0,3*C,2*C),r.setRenderTarget(t),r.render(y,Qw)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;for(let c=1;cef&&console.warn(`sigmaRadians, ${p}, is too large and will clip, as it requested ${B} samples when the maximum is set to ${ef}`);const ae=[];let le=0;for(let it=0;itAe-Um?c-Ae+Um:0),Pe=4*(this._cubeSize-we);fx(t,me,Pe,3*we,2*we),C.setRenderTarget(t),C.render(N,Qw)}}function PO(u){const e=[],t=[],r=[];let c=u;const p=u-Um+1+jE.length;for(let y=0;yu-Um?C=jE[y-u+Um-1]:y===0&&(C=0),r.push(C);const D=1/(i-2),U=-D,N=1+D,R=[U,U,N,U,N,N,U,U,N,N,U,N],G=6,J=6,Y=3,B=2,ae=1,le=new Float32Array(Y*J*G),Ae=new Float32Array(B*J*G),we=new Float32Array(ae*J*G);for(let Pe=0;Pe2?0:-1,Ke=[it,Me,0,it+2/3,Me,0,it+2/3,Me+1,0,it,Me,0,it+2/3,Me+1,0,it,Me+1,0];le.set(Ke,Y*J*Pe),Ae.set(R,B*J*Pe);const Et=[Pe,Pe,Pe,Pe,Pe,Pe];we.set(Et,ae*J*Pe)}const me=new br;me.setAttribute("position",new ds(le,Y)),me.setAttribute("uv",new ds(Ae,B)),me.setAttribute("faceIndex",new ds(we,ae)),e.push(me),c>Um&&c--}return{lodPlanes:e,sizeLods:t,sigmas:r}}function ZE(u,e,t){const r=new Oa(u,e,t);return r.texture.mapping=qm,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function fx(u,e,t,r,c){u.viewport.set(e,t,r,c),u.scissor.set(e,t,r,c)}function UO(u,e,t){const r=new Float32Array(ef),c=new ft(0,1,0);return new ko({name:"SphericalGaussianBlur",defines:{n:ef,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${u}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:c}},vertexShader:H2(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:KA,depthTest:!1,depthWrite:!1})}function XE(){return new ko({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:H2(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:KA,depthTest:!1,depthWrite:!1})}function qE(){return new ko({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:H2(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:KA,depthTest:!1,depthWrite:!1})}function H2(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function RO(u){let e=new WeakMap,t=null;function r(i){if(i&&i.isTexture){const C=i.mapping,D=C===Q_||C===V_,U=C===op||C===ap;if(D||U)if(i.isRenderTargetTexture&&i.needsPMREMUpdate===!0){i.needsPMREMUpdate=!1;let N=e.get(i);return t===null&&(t=new a2(u)),N=D?t.fromEquirectangular(i,N):t.fromCubemap(i,N),e.set(i,N),N.texture}else{if(e.has(i))return e.get(i).texture;{const N=i.image;if(D&&N&&N.height>0||U&&N&&c(N)){t===null&&(t=new a2(u));const R=D?t.fromEquirectangular(i):t.fromCubemap(i);return e.set(i,R),i.addEventListener("dispose",p),R.texture}else return null}}}return i}function c(i){let C=0;const D=6;for(let U=0;Ue.maxTextureSize&&(Ci=Math.ceil(oi/e.maxTextureSize),oi=e.maxTextureSize);const te=new Float32Array(oi*Ci*4*B),ce=new uy(te,oi,Ci,B);ce.type=GA,ce.needsUpdate=!0;const ye=Et*4;for(let ze=0;ze0)return u;const c=e*t;let p=YE[c];if(p===void 0&&(p=new Float32Array(c),YE[c]=p),e!==0){r.toArray(p,0);for(let y=1,i=0;y!==e;++y)i+=t,u[y].toArray(p,i)}return p}function oa(u,e){if(u.length!==e.length)return!1;for(let t=0,r=u.length;t":" "} ${i}: ${t[y]}`)}return r.join(` `)}function z6(u){switch(u){case hp:return["Linear","( value )"];case Ss:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",u),["Linear","( value )"]}}function sT(u,e,t){const r=u.getShaderParameter(e,35713),c=u.getShaderInfoLog(e).trim();if(r&&c==="")return"";const p=/ERROR: 0:(\d+)/.exec(c);if(p){const y=parseInt(p[1]);return t.toUpperCase()+` `+c+` `+R6(u.getShaderSource(e),y)}else return c}function k6(u,e){const t=z6(e);return"vec4 "+u+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function O6(u,e){let t;switch(e){case U2:t="Linear";break;case sI:t="Reinhard";break;case oI:t="OptimizedCineon";break;case aI:t="ACESFilmic";break;case lI:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+u+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function N6(u){return[u.extensionDerivatives||!!u.envMapCubeUVHeight||u.bumpMap||u.tangentSpaceNormalMap||u.clearcoatNormalMap||u.flatShading||u.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(u.extensionFragDepth||u.logarithmicDepthBuffer)&&u.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",u.extensionDrawBuffers&&u.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(u.extensionShaderTextureLOD||u.envMap||u.transmission)&&u.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(b_).join(` `)}function Q6(u){const e=[];for(const t in u){const r=u[t];r!==!1&&e.push("#define "+t+" "+r)}return e.join(` `)}function V6(u,e){const t={},r=u.getProgramParameter(e,35721);for(let c=0;c/gm;function l2(u){return u.replace(H6,G6)}function G6(u,e){const t=zr[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return l2(t)}const W6=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function lT(u){return u.replace(W6,j6)}function j6(u,e,t,r){let c="";for(let p=parseInt(e);p0&&(B+=` `),ae=[G,J].filter(b_).join(` `),ae.length>0&&(ae+=` `)):(B=[cT(t),"#define SHADER_NAME "+t.shaderName,J,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+U:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+C:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(b_).join(` `),ae=[G,cT(t),"#define SHADER_NAME "+t.shaderName,J,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+D:"",t.envMap?"#define "+U:"",t.envMap?"#define "+N:"",R?"#define CUBEUV_TEXEL_WIDTH "+R.texelWidth:"",R?"#define CUBEUV_TEXEL_HEIGHT "+R.texelHeight:"",R?"#define CUBEUV_MAX_MIP "+R.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+C:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Vu?"#define TONE_MAPPING":"",t.toneMapping!==Vu?zr.tonemapping_pars_fragment:"",t.toneMapping!==Vu?O6("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",zr.encodings_pars_fragment,k6("linearToOutputTexel",t.outputEncoding),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(b_).join(` `)),y=l2(y),y=oT(y,t),y=aT(y,t),i=l2(i),i=oT(i,t),i=aT(i,t),y=lT(y),i=lT(i),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(le=`#version 300 es `,B=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+B,ae=["#define varying in",t.glslVersion===s2?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===s2?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` `+ae);const Ae=le+B+y,we=le+ae+i,me=rT(c,35633,Ae),Pe=rT(c,35632,we);if(c.attachShader(Y,me),c.attachShader(Y,Pe),t.index0AttributeName!==void 0?c.bindAttribLocation(Y,0,t.index0AttributeName):t.morphTargets===!0&&c.bindAttribLocation(Y,0,"position"),c.linkProgram(Y),u.debug.checkShaderErrors){const Ke=c.getProgramInfoLog(Y).trim(),Et=c.getShaderInfoLog(me).trim(),oi=c.getShaderInfoLog(Pe).trim();let Ci=!0,te=!0;if(c.getProgramParameter(Y,35714)===!1){Ci=!1;const ce=sT(c,me,"vertex"),ye=sT(c,Pe,"fragment");console.error("THREE.WebGLProgram: Shader Error "+c.getError()+" - VALIDATE_STATUS "+c.getProgramParameter(Y,35715)+` Program Info Log: `+Ke+` `+ce+` `+ye)}else Ke!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Ke):(Et===""||oi==="")&&(te=!1);te&&(this.diagnostics={runnable:Ci,programLog:Ke,vertexShader:{log:Et,prefix:B},fragmentShader:{log:oi,prefix:ae}})}c.deleteShader(me),c.deleteShader(Pe);let it;this.getUniforms=function(){return it===void 0&&(it=new Jx(c,Y)),it};let Me;return this.getAttributes=function(){return Me===void 0&&(Me=V6(c,Y)),Me},this.destroy=function(){r.releaseStatesOfProgram(this),c.deleteProgram(Y),this.program=void 0},this.name=t.shaderName,this.id=U6++,this.cacheKey=e,this.usedTimes=1,this.program=Y,this.vertexShader=me,this.fragmentShader=Pe,this}let J6=0;class eN{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,r=e.fragmentShader,c=this._getShaderStage(t),p=this._getShaderStage(r),y=this._getShaderCacheForMaterial(e);return y.has(c)===!1&&(y.add(c),c.usedTimes++),y.has(p)===!1&&(y.add(p),p.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const r of t)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let r=t.get(e);return r===void 0&&(r=new Set,t.set(e,r)),r}_getShaderStage(e){const t=this.shaderCache;let r=t.get(e);return r===void 0&&(r=new tN(e),t.set(e,r)),r}}class tN{constructor(e){this.id=J6++,this.code=e,this.usedTimes=0}}function iN(u,e,t,r,c,p,y){const i=new dy,C=new eN,D=[],U=c.isWebGL2,N=c.logarithmicDepthBuffer,R=c.vertexTextures;let G=c.precision;const J={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function Y(Me,Ke,Et,oi,Ci){const te=oi.fog,ce=Ci.geometry,ye=Me.isMeshStandardMaterial?oi.environment:null,xe=(Me.isMeshStandardMaterial?t:e).get(Me.envMap||ye),ze=!!xe&&xe.mapping===qm?xe.image.height:null,Ne=J[Me.type];Me.precision!==null&&(G=c.getMaxPrecision(Me.precision),G!==Me.precision&&console.warn("THREE.WebGLProgram.getParameters:",Me.precision,"not supported, using",G,"instead."));const Ge=ce.morphAttributes.position||ce.morphAttributes.normal||ce.morphAttributes.color,Ve=Ge!==void 0?Ge.length:0;let Le=0;ce.morphAttributes.position!==void 0&&(Le=1),ce.morphAttributes.normal!==void 0&&(Le=2),ce.morphAttributes.color!==void 0&&(Le=3);let Ie,qe,et,vt;if(Ne){const Nt=Fl[Ne];Ie=Nt.vertexShader,qe=Nt.fragmentShader}else Ie=Me.vertexShader,qe=Me.fragmentShader,C.update(Me),et=C.getVertexShaderID(Me),vt=C.getFragmentShaderID(Me);const Be=u.getRenderTarget(),dt=Me.alphaTest>0,ut=Me.clearcoat>0,Qt=Me.iridescence>0;return{isWebGL2:U,shaderID:Ne,shaderName:Me.type,vertexShader:Ie,fragmentShader:qe,defines:Me.defines,customVertexShaderID:et,customFragmentShaderID:vt,isRawShaderMaterial:Me.isRawShaderMaterial===!0,glslVersion:Me.glslVersion,precision:G,instancing:Ci.isInstancedMesh===!0,instancingColor:Ci.isInstancedMesh===!0&&Ci.instanceColor!==null,supportsVertexTextures:R,outputEncoding:Be===null?u.outputEncoding:Be.isXRRenderTarget===!0?Be.texture.encoding:hp,map:!!Me.map,matcap:!!Me.matcap,envMap:!!xe,envMapMode:xe&&xe.mapping,envMapCubeUVHeight:ze,lightMap:!!Me.lightMap,aoMap:!!Me.aoMap,emissiveMap:!!Me.emissiveMap,bumpMap:!!Me.bumpMap,normalMap:!!Me.normalMap,objectSpaceNormalMap:Me.normalMapType===MI,tangentSpaceNormalMap:Me.normalMapType===up,decodeVideoTexture:!!Me.map&&Me.map.isVideoTexture===!0&&Me.map.encoding===Ss,clearcoat:ut,clearcoatMap:ut&&!!Me.clearcoatMap,clearcoatRoughnessMap:ut&&!!Me.clearcoatRoughnessMap,clearcoatNormalMap:ut&&!!Me.clearcoatNormalMap,iridescence:Qt,iridescenceMap:Qt&&!!Me.iridescenceMap,iridescenceThicknessMap:Qt&&!!Me.iridescenceThicknessMap,displacementMap:!!Me.displacementMap,roughnessMap:!!Me.roughnessMap,metalnessMap:!!Me.metalnessMap,specularMap:!!Me.specularMap,specularIntensityMap:!!Me.specularIntensityMap,specularColorMap:!!Me.specularColorMap,opaque:Me.transparent===!1&&Me.blending===Af,alphaMap:!!Me.alphaMap,alphaTest:dt,gradientMap:!!Me.gradientMap,sheen:Me.sheen>0,sheenColorMap:!!Me.sheenColorMap,sheenRoughnessMap:!!Me.sheenRoughnessMap,transmission:Me.transmission>0,transmissionMap:!!Me.transmissionMap,thicknessMap:!!Me.thicknessMap,combine:Me.combine,vertexTangents:!!Me.normalMap&&!!ce.attributes.tangent,vertexColors:Me.vertexColors,vertexAlphas:Me.vertexColors===!0&&!!ce.attributes.color&&ce.attributes.color.itemSize===4,vertexUvs:!!Me.map||!!Me.bumpMap||!!Me.normalMap||!!Me.specularMap||!!Me.alphaMap||!!Me.emissiveMap||!!Me.roughnessMap||!!Me.metalnessMap||!!Me.clearcoatMap||!!Me.clearcoatRoughnessMap||!!Me.clearcoatNormalMap||!!Me.iridescenceMap||!!Me.iridescenceThicknessMap||!!Me.displacementMap||!!Me.transmissionMap||!!Me.thicknessMap||!!Me.specularIntensityMap||!!Me.specularColorMap||!!Me.sheenColorMap||!!Me.sheenRoughnessMap,uvsVertexOnly:!(!!Me.map||!!Me.bumpMap||!!Me.normalMap||!!Me.specularMap||!!Me.alphaMap||!!Me.emissiveMap||!!Me.roughnessMap||!!Me.metalnessMap||!!Me.clearcoatNormalMap||!!Me.iridescenceMap||!!Me.iridescenceThicknessMap||Me.transmission>0||!!Me.transmissionMap||!!Me.thicknessMap||!!Me.specularIntensityMap||!!Me.specularColorMap||Me.sheen>0||!!Me.sheenColorMap||!!Me.sheenRoughnessMap)&&!!Me.displacementMap,fog:!!te,useFog:Me.fog===!0,fogExp2:te&&te.isFogExp2,flatShading:!!Me.flatShading,sizeAttenuation:Me.sizeAttenuation,logarithmicDepthBuffer:N,skinning:Ci.isSkinnedMesh===!0,morphTargets:ce.morphAttributes.position!==void 0,morphNormals:ce.morphAttributes.normal!==void 0,morphColors:ce.morphAttributes.color!==void 0,morphTargetsCount:Ve,morphTextureStride:Le,numDirLights:Ke.directional.length,numPointLights:Ke.point.length,numSpotLights:Ke.spot.length,numSpotLightMaps:Ke.spotLightMap.length,numRectAreaLights:Ke.rectArea.length,numHemiLights:Ke.hemi.length,numDirLightShadows:Ke.directionalShadowMap.length,numPointLightShadows:Ke.pointShadowMap.length,numSpotLightShadows:Ke.spotShadowMap.length,numSpotLightShadowsWithMaps:Ke.numSpotLightShadowsWithMaps,numClippingPlanes:y.numPlanes,numClipIntersection:y.numIntersection,dithering:Me.dithering,shadowMapEnabled:u.shadowMap.enabled&&Et.length>0,shadowMapType:u.shadowMap.type,toneMapping:Me.toneMapped?u.toneMapping:Vu,physicallyCorrectLights:u.physicallyCorrectLights,premultipliedAlpha:Me.premultipliedAlpha,doubleSided:Me.side===Il,flipSided:Me.side===Dc,useDepthPacking:!!Me.depthPacking,depthPacking:Me.depthPacking||0,index0AttributeName:Me.index0AttributeName,extensionDerivatives:Me.extensions&&Me.extensions.derivatives,extensionFragDepth:Me.extensions&&Me.extensions.fragDepth,extensionDrawBuffers:Me.extensions&&Me.extensions.drawBuffers,extensionShaderTextureLOD:Me.extensions&&Me.extensions.shaderTextureLOD,rendererExtensionFragDepth:U||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:U||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:U||r.has("EXT_shader_texture_lod"),customProgramCacheKey:Me.customProgramCacheKey()}}function B(Me){const Ke=[];if(Me.shaderID?Ke.push(Me.shaderID):(Ke.push(Me.customVertexShaderID),Ke.push(Me.customFragmentShaderID)),Me.defines!==void 0)for(const Et in Me.defines)Ke.push(Et),Ke.push(Me.defines[Et]);return Me.isRawShaderMaterial===!1&&(ae(Ke,Me),le(Ke,Me),Ke.push(u.outputEncoding)),Ke.push(Me.customProgramCacheKey),Ke.join()}function ae(Me,Ke){Me.push(Ke.precision),Me.push(Ke.outputEncoding),Me.push(Ke.envMapMode),Me.push(Ke.envMapCubeUVHeight),Me.push(Ke.combine),Me.push(Ke.vertexUvs),Me.push(Ke.fogExp2),Me.push(Ke.sizeAttenuation),Me.push(Ke.morphTargetsCount),Me.push(Ke.morphAttributeCount),Me.push(Ke.numDirLights),Me.push(Ke.numPointLights),Me.push(Ke.numSpotLights),Me.push(Ke.numSpotLightMaps),Me.push(Ke.numHemiLights),Me.push(Ke.numRectAreaLights),Me.push(Ke.numDirLightShadows),Me.push(Ke.numPointLightShadows),Me.push(Ke.numSpotLightShadows),Me.push(Ke.numSpotLightShadowsWithMaps),Me.push(Ke.shadowMapType),Me.push(Ke.toneMapping),Me.push(Ke.numClippingPlanes),Me.push(Ke.numClipIntersection),Me.push(Ke.depthPacking)}function le(Me,Ke){i.disableAll(),Ke.isWebGL2&&i.enable(0),Ke.supportsVertexTextures&&i.enable(1),Ke.instancing&&i.enable(2),Ke.instancingColor&&i.enable(3),Ke.map&&i.enable(4),Ke.matcap&&i.enable(5),Ke.envMap&&i.enable(6),Ke.lightMap&&i.enable(7),Ke.aoMap&&i.enable(8),Ke.emissiveMap&&i.enable(9),Ke.bumpMap&&i.enable(10),Ke.normalMap&&i.enable(11),Ke.objectSpaceNormalMap&&i.enable(12),Ke.tangentSpaceNormalMap&&i.enable(13),Ke.clearcoat&&i.enable(14),Ke.clearcoatMap&&i.enable(15),Ke.clearcoatRoughnessMap&&i.enable(16),Ke.clearcoatNormalMap&&i.enable(17),Ke.iridescence&&i.enable(18),Ke.iridescenceMap&&i.enable(19),Ke.iridescenceThicknessMap&&i.enable(20),Ke.displacementMap&&i.enable(21),Ke.specularMap&&i.enable(22),Ke.roughnessMap&&i.enable(23),Ke.metalnessMap&&i.enable(24),Ke.gradientMap&&i.enable(25),Ke.alphaMap&&i.enable(26),Ke.alphaTest&&i.enable(27),Ke.vertexColors&&i.enable(28),Ke.vertexAlphas&&i.enable(29),Ke.vertexUvs&&i.enable(30),Ke.vertexTangents&&i.enable(31),Ke.uvsVertexOnly&&i.enable(32),Me.push(i.mask),i.disableAll(),Ke.fog&&i.enable(0),Ke.useFog&&i.enable(1),Ke.flatShading&&i.enable(2),Ke.logarithmicDepthBuffer&&i.enable(3),Ke.skinning&&i.enable(4),Ke.morphTargets&&i.enable(5),Ke.morphNormals&&i.enable(6),Ke.morphColors&&i.enable(7),Ke.premultipliedAlpha&&i.enable(8),Ke.shadowMapEnabled&&i.enable(9),Ke.physicallyCorrectLights&&i.enable(10),Ke.doubleSided&&i.enable(11),Ke.flipSided&&i.enable(12),Ke.useDepthPacking&&i.enable(13),Ke.dithering&&i.enable(14),Ke.specularIntensityMap&&i.enable(15),Ke.specularColorMap&&i.enable(16),Ke.transmission&&i.enable(17),Ke.transmissionMap&&i.enable(18),Ke.thicknessMap&&i.enable(19),Ke.sheen&&i.enable(20),Ke.sheenColorMap&&i.enable(21),Ke.sheenRoughnessMap&&i.enable(22),Ke.decodeVideoTexture&&i.enable(23),Ke.opaque&&i.enable(24),Me.push(i.mask)}function Ae(Me){const Ke=J[Me.type];let Et;if(Ke){const oi=Fl[Ke];Et=_f.clone(oi.uniforms)}else Et=Me.uniforms;return Et}function we(Me,Ke){let Et;for(let oi=0,Ci=D.length;oi0?r.push(ae):G.transparent===!0?c.push(ae):t.push(ae)}function C(N,R,G,J,Y,B){const ae=y(N,R,G,J,Y,B);G.transmission>0?r.unshift(ae):G.transparent===!0?c.unshift(ae):t.unshift(ae)}function D(N,R){t.length>1&&t.sort(N||rN),r.length>1&&r.sort(R||hT),c.length>1&&c.sort(R||hT)}function U(){for(let N=e,R=u.length;N=p.length?(y=new uT,p.push(y)):y=p[c],y}function t(){u=new WeakMap}return{get:e,dispose:t}}function oN(){const u={};return{get:function(e){if(u[e.id]!==void 0)return u[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new ft,color:new Dn};break;case"SpotLight":t={position:new ft,direction:new ft,color:new Dn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new ft,color:new Dn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new ft,skyColor:new Dn,groundColor:new Dn};break;case"RectAreaLight":t={color:new Dn,position:new ft,halfWidth:new ft,halfHeight:new ft};break}return u[e.id]=t,t}}}function aN(){const u={};return{get:function(e){if(u[e.id]!==void 0)return u[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Di};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Di};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Di,shadowCameraNear:1,shadowCameraFar:1e3};break}return u[e.id]=t,t}}}let lN=0;function cN(u,e){return(e.castShadow?2:0)-(u.castShadow?2:0)+(e.map?1:0)-(u.map?1:0)}function hN(u,e){const t=new oN,r=aN(),c={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let U=0;U<9;U++)c.probe.push(new ft);const p=new ft,y=new lr,i=new lr;function C(U,N){let R=0,G=0,J=0;for(let oi=0;oi<9;oi++)c.probe[oi].set(0,0,0);let Y=0,B=0,ae=0,le=0,Ae=0,we=0,me=0,Pe=0,it=0,Me=0;U.sort(cN);const Ke=N!==!0?Math.PI:1;for(let oi=0,Ci=U.length;oi0&&(e.isWebGL2||u.has("OES_texture_float_linear")===!0?(c.rectAreaLTC1=En.LTC_FLOAT_1,c.rectAreaLTC2=En.LTC_FLOAT_2):u.has("OES_texture_half_float_linear")===!0?(c.rectAreaLTC1=En.LTC_HALF_1,c.rectAreaLTC2=En.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),c.ambient[0]=R,c.ambient[1]=G,c.ambient[2]=J;const Et=c.hash;(Et.directionalLength!==Y||Et.pointLength!==B||Et.spotLength!==ae||Et.rectAreaLength!==le||Et.hemiLength!==Ae||Et.numDirectionalShadows!==we||Et.numPointShadows!==me||Et.numSpotShadows!==Pe||Et.numSpotMaps!==it)&&(c.directional.length=Y,c.spot.length=ae,c.rectArea.length=le,c.point.length=B,c.hemi.length=Ae,c.directionalShadow.length=we,c.directionalShadowMap.length=we,c.pointShadow.length=me,c.pointShadowMap.length=me,c.spotShadow.length=Pe,c.spotShadowMap.length=Pe,c.directionalShadowMatrix.length=we,c.pointShadowMatrix.length=me,c.spotLightMatrix.length=Pe+it-Me,c.spotLightMap.length=it,c.numSpotLightShadowsWithMaps=Me,Et.directionalLength=Y,Et.pointLength=B,Et.spotLength=ae,Et.rectAreaLength=le,Et.hemiLength=Ae,Et.numDirectionalShadows=we,Et.numPointShadows=me,Et.numSpotShadows=Pe,Et.numSpotMaps=it,c.version=lN++)}function D(U,N){let R=0,G=0,J=0,Y=0,B=0;const ae=N.matrixWorldInverse;for(let le=0,Ae=U.length;le=i.length?(C=new AT(u,e),i.push(C)):C=i[y],C}function c(){t=new WeakMap}return{get:r,dispose:c}}class G2 extends ol{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=TI,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class W2 extends ol{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new ft,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const AN=`void main() { gl_Position = vec4( position, 1.0 ); }`,dN=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function pN(u,e,t){let r=new Gv;const c=new Di,p=new Di,y=new ls,i=new G2({depthPacking:SI}),C=new W2,D={},U=t.maxTextureSize,N={0:Dc,1:ju,2:Il},R=new ko({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Di},radius:{value:4}},vertexShader:AN,fragmentShader:dN}),G=R.clone();G.defines.HORIZONTAL_PASS=1;const J=new br;J.setAttribute("position",new ds(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const Y=new is(J,R),B=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=L2,this.render=function(we,me,Pe){if(B.enabled===!1||B.autoUpdate===!1&&B.needsUpdate===!1||we.length===0)return;const it=u.getRenderTarget(),Me=u.getActiveCubeFace(),Ke=u.getActiveMipmapLevel(),Et=u.state;Et.setBlending(KA),Et.buffers.color.setClear(1,1,1,1),Et.buffers.depth.setTest(!0),Et.setScissorTest(!1);for(let oi=0,Ci=we.length;oiU||c.y>U)&&(c.x>U&&(p.x=Math.floor(U/ye.x),c.x=p.x*ye.x,ce.mapSize.x=p.x),c.y>U&&(p.y=Math.floor(U/ye.y),c.y=p.y*ye.y,ce.mapSize.y=p.y)),ce.map===null){const ze=this.type!==Dm?{minFilter:Co,magFilter:Co}:{};ce.map=new Oa(c.x,c.y,ze),ce.map.texture.name=te.name+".shadowMap",ce.camera.updateProjectionMatrix()}u.setRenderTarget(ce.map),u.clear();const xe=ce.getViewportCount();for(let ze=0;ze0||me.map&&me.alphaTest>0){const Ci=Et.uuid,te=me.uuid;let ce=D[Ci];ce===void 0&&(ce={},D[Ci]=ce);let ye=ce[te];ye===void 0&&(ye=Et.clone(),ce[te]=ye),Et=ye}return Et.visible=me.visible,Et.wireframe=me.wireframe,Ke===Dm?Et.side=me.shadowSide!==null?me.shadowSide:me.side:Et.side=me.shadowSide!==null?me.shadowSide:N[me.side],Et.alphaMap=me.alphaMap,Et.alphaTest=me.alphaTest,Et.map=me.map,Et.clipShadows=me.clipShadows,Et.clippingPlanes=me.clippingPlanes,Et.clipIntersection=me.clipIntersection,Et.displacementMap=me.displacementMap,Et.displacementScale=me.displacementScale,Et.displacementBias=me.displacementBias,Et.wireframeLinewidth=me.wireframeLinewidth,Et.linewidth=me.linewidth,Pe.isPointLight===!0&&Et.isMeshDistanceMaterial===!0&&(Et.referencePosition.setFromMatrixPosition(Pe.matrixWorld),Et.nearDistance=it,Et.farDistance=Me),Et}function Ae(we,me,Pe,it,Me){if(we.visible===!1)return;if(we.layers.test(me.layers)&&(we.isMesh||we.isLine||we.isPoints)&&(we.castShadow||we.receiveShadow&&Me===Dm)&&(!we.frustumCulled||r.intersectsObject(we))){we.modelViewMatrix.multiplyMatrices(Pe.matrixWorldInverse,we.matrixWorld);const oi=e.update(we),Ci=we.material;if(Array.isArray(Ci)){const te=oi.groups;for(let ce=0,ye=te.length;ce=1):Ne.indexOf("OpenGL ES")!==-1&&(ze=parseFloat(/^OpenGL ES (\d)/.exec(Ne)[1]),xe=ze>=2);let Ge=null,Ve={};const Le=u.getParameter(3088),Ie=u.getParameter(2978),qe=new ls().fromArray(Le),et=new ls().fromArray(Ie);function vt(Ot,vi,Wi){const Ui=new Uint8Array(4),Pn=u.createTexture();u.bindTexture(Ot,Pn),u.texParameteri(Ot,10241,9728),u.texParameteri(Ot,10240,9728);for(let qn=0;qn"u"?!1:/OculusBrowser/g.test(navigator.userAgent),J=new WeakMap;let Y;const B=new WeakMap;let ae=!1;try{ae=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function le(yt,st){return ae?new OffscreenCanvas(yt,st):Z_("canvas")}function Ae(yt,st,ti,Ni){let qi=1;if((yt.width>Ni||yt.height>Ni)&&(qi=Ni/Math.max(yt.width,yt.height)),qi<1||st===!0)if(typeof HTMLImageElement<"u"&&yt instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&yt instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&yt instanceof ImageBitmap){const en=st?fv:Math.floor,$t=en(qi*yt.width),at=en(qi*yt.height);Y===void 0&&(Y=le($t,at));const ii=ti?le($t,at):Y;return ii.width=$t,ii.height=at,ii.getContext("2d").drawImage(yt,0,0,$t,at),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+yt.width+"x"+yt.height+") to ("+$t+"x"+at+")."),ii}else return"data"in yt&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+yt.width+"x"+yt.height+")."),yt;return yt}function we(yt){return o2(yt.width)&&o2(yt.height)}function me(yt){return i?!1:yt.wrapS!==rl||yt.wrapT!==rl||yt.minFilter!==Co&&yt.minFilter!==Xs}function Pe(yt,st){return yt.generateMipmaps&&st&&yt.minFilter!==Co&&yt.minFilter!==Xs}function it(yt){u.generateMipmap(yt)}function Me(yt,st,ti,Ni,qi=!1){if(i===!1)return st;if(yt!==null){if(u[yt]!==void 0)return u[yt];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+yt+"'")}let en=st;return st===6403&&(ti===5126&&(en=33326),ti===5131&&(en=33325),ti===5121&&(en=33321)),st===33319&&(ti===5126&&(en=33328),ti===5131&&(en=33327),ti===5121&&(en=33323)),st===6408&&(ti===5126&&(en=34836),ti===5131&&(en=34842),ti===5121&&(en=Ni===Ss&&qi===!1?35907:32856),ti===32819&&(en=32854),ti===32820&&(en=32855)),(en===33325||en===33326||en===33327||en===33328||en===34842||en===34836)&&e.get("EXT_color_buffer_float"),en}function Ke(yt,st,ti){return Pe(yt,ti)===!0||yt.isFramebufferTexture&&yt.minFilter!==Co&&yt.minFilter!==Xs?Math.log2(Math.max(st.width,st.height))+1:yt.mipmaps!==void 0&&yt.mipmaps.length>0?yt.mipmaps.length:yt.isCompressedTexture&&Array.isArray(yt.image)?st.mipmaps.length:1}function Et(yt){return yt===Co||yt===dv||yt===F_?9728:9729}function oi(yt){const st=yt.target;st.removeEventListener("dispose",oi),te(st),st.isVideoTexture&&J.delete(st)}function Ci(yt){const st=yt.target;st.removeEventListener("dispose",Ci),ye(st)}function te(yt){const st=r.get(yt);if(st.__webglInit===void 0)return;const ti=yt.source,Ni=B.get(ti);if(Ni){const qi=Ni[st.__cacheKey];qi.usedTimes--,qi.usedTimes===0&&ce(yt),Object.keys(Ni).length===0&&B.delete(ti)}r.remove(yt)}function ce(yt){const st=r.get(yt);u.deleteTexture(st.__webglTexture);const ti=yt.source,Ni=B.get(ti);delete Ni[st.__cacheKey],y.memory.textures--}function ye(yt){const st=yt.texture,ti=r.get(yt),Ni=r.get(st);if(Ni.__webglTexture!==void 0&&(u.deleteTexture(Ni.__webglTexture),y.memory.textures--),yt.depthTexture&&yt.depthTexture.dispose(),yt.isWebGLCubeRenderTarget)for(let qi=0;qi<6;qi++)u.deleteFramebuffer(ti.__webglFramebuffer[qi]),ti.__webglDepthbuffer&&u.deleteRenderbuffer(ti.__webglDepthbuffer[qi]);else{if(u.deleteFramebuffer(ti.__webglFramebuffer),ti.__webglDepthbuffer&&u.deleteRenderbuffer(ti.__webglDepthbuffer),ti.__webglMultisampledFramebuffer&&u.deleteFramebuffer(ti.__webglMultisampledFramebuffer),ti.__webglColorRenderbuffer)for(let qi=0;qi=C&&console.warn("THREE.WebGLTextures: Trying to use "+yt+" texture units while this GPU supports only "+C),xe+=1,yt}function Ge(yt){const st=[];return st.push(yt.wrapS),st.push(yt.wrapT),st.push(yt.wrapR||0),st.push(yt.magFilter),st.push(yt.minFilter),st.push(yt.anisotropy),st.push(yt.internalFormat),st.push(yt.format),st.push(yt.type),st.push(yt.generateMipmaps),st.push(yt.premultiplyAlpha),st.push(yt.flipY),st.push(yt.unpackAlignment),st.push(yt.encoding),st.join()}function Ve(yt,st){const ti=r.get(yt);if(yt.isVideoTexture&&Gn(yt),yt.isRenderTargetTexture===!1&&yt.version>0&&ti.__version!==yt.version){const Ni=yt.image;if(Ni===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Ni.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ut(ti,yt,st);return}}t.bindTexture(3553,ti.__webglTexture,33984+st)}function Le(yt,st){const ti=r.get(yt);if(yt.version>0&&ti.__version!==yt.version){ut(ti,yt,st);return}t.bindTexture(35866,ti.__webglTexture,33984+st)}function Ie(yt,st){const ti=r.get(yt);if(yt.version>0&&ti.__version!==yt.version){ut(ti,yt,st);return}t.bindTexture(32879,ti.__webglTexture,33984+st)}function qe(yt,st){const ti=r.get(yt);if(yt.version>0&&ti.__version!==yt.version){Qt(ti,yt,st);return}t.bindTexture(34067,ti.__webglTexture,33984+st)}const et={[HA]:10497,[rl]:33071,[H_]:33648},vt={[Co]:9728,[dv]:9984,[F_]:9986,[Xs]:9729,[R2]:9985,[lp]:9987};function Be(yt,st,ti){if(ti?(u.texParameteri(yt,10242,et[st.wrapS]),u.texParameteri(yt,10243,et[st.wrapT]),(yt===32879||yt===35866)&&u.texParameteri(yt,32882,et[st.wrapR]),u.texParameteri(yt,10240,vt[st.magFilter]),u.texParameteri(yt,10241,vt[st.minFilter])):(u.texParameteri(yt,10242,33071),u.texParameteri(yt,10243,33071),(yt===32879||yt===35866)&&u.texParameteri(yt,32882,33071),(st.wrapS!==rl||st.wrapT!==rl)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),u.texParameteri(yt,10240,Et(st.magFilter)),u.texParameteri(yt,10241,Et(st.minFilter)),st.minFilter!==Co&&st.minFilter!==Xs&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const Ni=e.get("EXT_texture_filter_anisotropic");if(st.magFilter===Co||st.minFilter!==F_&&st.minFilter!==lp||st.type===GA&&e.has("OES_texture_float_linear")===!1||i===!1&&st.type===Gm&&e.has("OES_texture_half_float_linear")===!1)return;(st.anisotropy>1||r.get(st).__currentAnisotropy)&&(u.texParameterf(yt,Ni.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(st.anisotropy,c.getMaxAnisotropy())),r.get(st).__currentAnisotropy=st.anisotropy)}}function dt(yt,st){let ti=!1;yt.__webglInit===void 0&&(yt.__webglInit=!0,st.addEventListener("dispose",oi));const Ni=st.source;let qi=B.get(Ni);qi===void 0&&(qi={},B.set(Ni,qi));const en=Ge(st);if(en!==yt.__cacheKey){qi[en]===void 0&&(qi[en]={texture:u.createTexture(),usedTimes:0},y.memory.textures++,ti=!0),qi[en].usedTimes++;const $t=qi[yt.__cacheKey];$t!==void 0&&(qi[yt.__cacheKey].usedTimes--,$t.usedTimes===0&&ce(st)),yt.__cacheKey=en,yt.__webglTexture=qi[en].texture}return ti}function ut(yt,st,ti){let Ni=3553;(st.isDataArrayTexture||st.isCompressedArrayTexture)&&(Ni=35866),st.isData3DTexture&&(Ni=32879);const qi=dt(yt,st),en=st.source;t.bindTexture(Ni,yt.__webglTexture,33984+ti);const $t=r.get(en);if(en.version!==$t.__version||qi===!0){t.activeTexture(33984+ti),u.pixelStorei(37440,st.flipY),u.pixelStorei(37441,st.premultiplyAlpha),u.pixelStorei(3317,st.unpackAlignment),u.pixelStorei(37443,0);const at=me(st)&&we(st.image)===!1;let ii=Ae(st.image,at,!1,U);ii=kn(st,ii);const hn=we(ii)||i,Xi=p.convert(st.format,st.encoding);let on=p.convert(st.type),Cn=Me(st.internalFormat,Xi,on,st.encoding,st.isVideoTexture);Be(Ni,st,hn);let Tn;const nr=st.mipmaps,Ii=i&&st.isVideoTexture!==!0,bn=$t.__version===void 0||qi===!0,Ot=Ke(st,ii,hn);if(st.isDepthTexture)Cn=6402,i?st.type===GA?Cn=36012:st.type===Yd?Cn=33190:st.type===df?Cn=35056:Cn=33189:st.type===GA&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),st.format===ip&&Cn===6402&&st.type!==z2&&st.type!==Yd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),st.type=Yd,on=p.convert(st.type)),st.format===gf&&Cn===6402&&(Cn=34041,st.type!==df&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),st.type=df,on=p.convert(st.type))),bn&&(Ii?t.texStorage2D(3553,1,Cn,ii.width,ii.height):t.texImage2D(3553,0,Cn,ii.width,ii.height,0,Xi,on,null));else if(st.isDataTexture)if(nr.length>0&&hn){Ii&&bn&&t.texStorage2D(3553,Ot,Cn,nr[0].width,nr[0].height);for(let vi=0,Wi=nr.length;vi>=1,Wi>>=1}}else if(nr.length>0&&hn){Ii&&bn&&t.texStorage2D(3553,Ot,Cn,nr[0].width,nr[0].height);for(let vi=0,Wi=nr.length;vi0&&bn++,t.texStorage2D(34067,bn,Tn,ii[0].width,ii[0].height));for(let vi=0;vi<6;vi++)if(at){nr?t.texSubImage2D(34069+vi,0,0,0,ii[vi].width,ii[vi].height,on,Cn,ii[vi].data):t.texImage2D(34069+vi,0,Tn,ii[vi].width,ii[vi].height,0,on,Cn,ii[vi].data);for(let Wi=0;Wi=34069&&qi<=34074)&&u.framebufferTexture2D(36160,Ni,qi,r.get(ti).__webglTexture,0),t.bindFramebuffer(36160,null)}function Nt(yt,st,ti){if(u.bindRenderbuffer(36161,yt),st.depthBuffer&&!st.stencilBuffer){let Ni=33189;if(ti||Qi(st)){const qi=st.depthTexture;qi&&qi.isDepthTexture&&(qi.type===GA?Ni=36012:qi.type===Yd&&(Ni=33190));const en=wn(st);Qi(st)?R.renderbufferStorageMultisampleEXT(36161,en,Ni,st.width,st.height):u.renderbufferStorageMultisample(36161,en,Ni,st.width,st.height)}else u.renderbufferStorage(36161,Ni,st.width,st.height);u.framebufferRenderbuffer(36160,36096,36161,yt)}else if(st.depthBuffer&&st.stencilBuffer){const Ni=wn(st);ti&&Qi(st)===!1?u.renderbufferStorageMultisample(36161,Ni,35056,st.width,st.height):Qi(st)?R.renderbufferStorageMultisampleEXT(36161,Ni,35056,st.width,st.height):u.renderbufferStorage(36161,34041,st.width,st.height),u.framebufferRenderbuffer(36160,33306,36161,yt)}else{const Ni=st.isWebGLMultipleRenderTargets===!0?st.texture:[st.texture];for(let qi=0;qi0&&Qi(yt)===!1){const at=en?st:[st];ti.__webglMultisampledFramebuffer=u.createFramebuffer(),ti.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,ti.__webglMultisampledFramebuffer);for(let ii=0;ii0&&Qi(yt)===!1){const st=yt.isWebGLMultipleRenderTargets?yt.texture:[yt.texture],ti=yt.width,Ni=yt.height;let qi=16384;const en=[],$t=yt.stencilBuffer?33306:36096,at=r.get(yt),ii=yt.isWebGLMultipleRenderTargets===!0;if(ii)for(let hn=0;hn0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&st.__useRenderToTexture!==!1}function Gn(yt){const st=y.render.frame;J.get(yt)!==st&&(J.set(yt,st),yt.update())}function kn(yt,st){const ti=yt.encoding,Ni=yt.format,qi=yt.type;return yt.isCompressedTexture===!0||yt.isVideoTexture===!0||yt.format===pv||ti!==hp&&(ti===Ss?i===!1?e.has("EXT_sRGB")===!0&&Ni===Dl?(yt.format=pv,yt.minFilter=Xs,yt.generateMipmaps=!1):st=N2.sRGBToLinear(st):(Ni!==Dl||qi!==cp)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ti)),st}this.allocateTextureUnit=Ne,this.resetTextureUnits=ze,this.setTexture2D=Ve,this.setTexture2DArray=Le,this.setTexture3D=Ie,this.setTextureCube=qe,this.rebindTextures=Xt,this.setupRenderTarget=mi,this.updateRenderTargetMipmap=fi,this.updateMultisampleRenderTarget=Gi,this.setupDepthRenderbuffer=Ft,this.setupFrameBufferTexture=Wt,this.useMultisampledRTT=Qi}function HI(u,e,t){const r=t.isWebGL2;function c(p,y=null){let i;if(p===cp)return 5121;if(p===AI)return 32819;if(p===dI)return 32820;if(p===cI)return 5120;if(p===hI)return 5122;if(p===z2)return 5123;if(p===uI)return 5124;if(p===Yd)return 5125;if(p===GA)return 5126;if(p===Gm)return r?5131:(i=e.get("OES_texture_half_float"),i!==null?i.HALF_FLOAT_OES:null);if(p===pI)return 6406;if(p===Dl)return 6408;if(p===mI)return 6409;if(p===gI)return 6410;if(p===ip)return 6402;if(p===gf)return 34041;if(p===fI)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(p===pv)return i=e.get("EXT_sRGB"),i!==null?i.SRGB_ALPHA_EXT:null;if(p===_I)return 6403;if(p===yI)return 36244;if(p===xI)return 33319;if(p===vI)return 33320;if(p===wI)return 36249;if(p===jx||p===Kx||p===$x||p===Zx)if(y===Ss)if(i=e.get("WEBGL_compressed_texture_s3tc_srgb"),i!==null){if(p===jx)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(p===Kx)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(p===$x)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(p===Zx)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=e.get("WEBGL_compressed_texture_s3tc"),i!==null){if(p===jx)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(p===Kx)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(p===$x)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(p===Zx)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(p===kb||p===Ob||p===Nb||p===Qb)if(i=e.get("WEBGL_compressed_texture_pvrtc"),i!==null){if(p===kb)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(p===Ob)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(p===Nb)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(p===Qb)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(p===bI)return i=e.get("WEBGL_compressed_texture_etc1"),i!==null?i.COMPRESSED_RGB_ETC1_WEBGL:null;if(p===Vb||p===Hb)if(i=e.get("WEBGL_compressed_texture_etc"),i!==null){if(p===Vb)return y===Ss?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(p===Hb)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(p===Gb||p===Wb||p===jb||p===Kb||p===$b||p===Zb||p===Xb||p===qb||p===Yb||p===Jb||p===e2||p===t2||p===i2||p===n2)if(i=e.get("WEBGL_compressed_texture_astc"),i!==null){if(p===Gb)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(p===Wb)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(p===jb)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(p===Kb)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(p===$b)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(p===Zb)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(p===Xb)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(p===qb)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(p===Yb)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(p===Jb)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(p===e2)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(p===t2)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(p===i2)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(p===n2)return y===Ss?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(p===r2)if(i=e.get("EXT_texture_compression_bptc"),i!==null){if(p===r2)return y===Ss?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return p===df?r?34042:(i=e.get("WEBGL_depth_texture"),i!==null?i.UNSIGNED_INT_24_8_WEBGL:null):u[p]!==void 0?u[p]:null}return{convert:c}}class GI extends _a{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class As extends cs{constructor(){super(),this.isGroup=!0,this.type="Group"}}const gN={type:"move"};class Gw{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new As,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new As,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ft,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ft),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new As,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ft,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ft),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const r of e.hand.values())this._getHandJoint(t,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,r){let c=null,p=null,y=null;const i=this._targetRay,C=this._grip,D=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(D&&e.hand){y=!0;for(const Y of e.hand.values()){const B=t.getJointPose(Y,r),ae=this._getHandJoint(D,Y);B!==null&&(ae.matrix.fromArray(B.transform.matrix),ae.matrix.decompose(ae.position,ae.rotation,ae.scale),ae.jointRadius=B.radius),ae.visible=B!==null}const U=D.joints["index-finger-tip"],N=D.joints["thumb-tip"],R=U.position.distanceTo(N.position),G=.02,J=.005;D.inputState.pinching&&R>G+J?(D.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!D.inputState.pinching&&R<=G-J&&(D.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else C!==null&&e.gripSpace&&(p=t.getPose(e.gripSpace,r),p!==null&&(C.matrix.fromArray(p.transform.matrix),C.matrix.decompose(C.position,C.rotation,C.scale),p.linearVelocity?(C.hasLinearVelocity=!0,C.linearVelocity.copy(p.linearVelocity)):C.hasLinearVelocity=!1,p.angularVelocity?(C.hasAngularVelocity=!0,C.angularVelocity.copy(p.angularVelocity)):C.hasAngularVelocity=!1));i!==null&&(c=t.getPose(e.targetRaySpace,r),c===null&&p!==null&&(c=p),c!==null&&(i.matrix.fromArray(c.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),c.linearVelocity?(i.hasLinearVelocity=!0,i.linearVelocity.copy(c.linearVelocity)):i.hasLinearVelocity=!1,c.angularVelocity?(i.hasAngularVelocity=!0,i.angularVelocity.copy(c.angularVelocity)):i.hasAngularVelocity=!1,this.dispatchEvent(gN)))}return i!==null&&(i.visible=c!==null),C!==null&&(C.visible=p!==null),D!==null&&(D.visible=y!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const r=new As;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}class WI extends To{constructor(e,t,r,c,p,y,i,C,D,U){if(U=U!==void 0?U:ip,U!==ip&&U!==gf)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&U===ip&&(r=Yd),r===void 0&&U===gf&&(r=df),super(null,c,p,y,i,C,U,r,D),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=i!==void 0?i:Co,this.minFilter=C!==void 0?C:Co,this.flipY=!1,this.generateMipmaps=!1}}class _N extends Xu{constructor(e,t){super();const r=this;let c=null,p=1,y=null,i="local-floor",C=null,D=null,U=null,N=null,R=null,G=null;const J=t.getContextAttributes();let Y=null,B=null;const ae=[],le=[],Ae=new Set,we=new Map,me=new _a;me.layers.enable(1),me.viewport=new ls;const Pe=new _a;Pe.layers.enable(2),Pe.viewport=new ls;const it=[me,Pe],Me=new GI;Me.layers.enable(1),Me.layers.enable(2);let Ke=null,Et=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Le){let Ie=ae[Le];return Ie===void 0&&(Ie=new Gw,ae[Le]=Ie),Ie.getTargetRaySpace()},this.getControllerGrip=function(Le){let Ie=ae[Le];return Ie===void 0&&(Ie=new Gw,ae[Le]=Ie),Ie.getGripSpace()},this.getHand=function(Le){let Ie=ae[Le];return Ie===void 0&&(Ie=new Gw,ae[Le]=Ie),Ie.getHandSpace()};function oi(Le){const Ie=le.indexOf(Le.inputSource);if(Ie===-1)return;const qe=ae[Ie];qe!==void 0&&qe.dispatchEvent({type:Le.type,data:Le.inputSource})}function Ci(){c.removeEventListener("select",oi),c.removeEventListener("selectstart",oi),c.removeEventListener("selectend",oi),c.removeEventListener("squeeze",oi),c.removeEventListener("squeezestart",oi),c.removeEventListener("squeezeend",oi),c.removeEventListener("end",Ci),c.removeEventListener("inputsourceschange",te);for(let Le=0;Le=0&&(le[et]=null,ae[et].disconnect(qe))}for(let Ie=0;Ie=le.length){le.push(qe),et=Be;break}else if(le[Be]===null){le[Be]=qe,et=Be;break}if(et===-1)break}const vt=ae[et];vt&&vt.connect(qe)}}const ce=new ft,ye=new ft;function xe(Le,Ie,qe){ce.setFromMatrixPosition(Ie.matrixWorld),ye.setFromMatrixPosition(qe.matrixWorld);const et=ce.distanceTo(ye),vt=Ie.projectionMatrix.elements,Be=qe.projectionMatrix.elements,dt=vt[14]/(vt[10]-1),ut=vt[14]/(vt[10]+1),Qt=(vt[9]+1)/vt[5],Wt=(vt[9]-1)/vt[5],Nt=(vt[8]-1)/vt[0],Ct=(Be[8]+1)/Be[0],Ft=dt*Nt,Xt=dt*Ct,mi=et/(-Nt+Ct),fi=mi*-Nt;Ie.matrixWorld.decompose(Le.position,Le.quaternion,Le.scale),Le.translateX(fi),Le.translateZ(mi),Le.matrixWorld.compose(Le.position,Le.quaternion,Le.scale),Le.matrixWorldInverse.copy(Le.matrixWorld).invert();const Gi=dt+mi,wn=ut+mi,Qi=Ft-fi,Gn=Xt+(et-fi),kn=Qt*ut/wn*Gi,yt=Wt*ut/wn*Gi;Le.projectionMatrix.makePerspective(Qi,Gn,kn,yt,Gi,wn)}function ze(Le,Ie){Ie===null?Le.matrixWorld.copy(Le.matrix):Le.matrixWorld.multiplyMatrices(Ie.matrixWorld,Le.matrix),Le.matrixWorldInverse.copy(Le.matrixWorld).invert()}this.updateCamera=function(Le){if(c===null)return;Me.near=Pe.near=me.near=Le.near,Me.far=Pe.far=me.far=Le.far,(Ke!==Me.near||Et!==Me.far)&&(c.updateRenderState({depthNear:Me.near,depthFar:Me.far}),Ke=Me.near,Et=Me.far);const Ie=Le.parent,qe=Me.cameras;ze(Me,Ie);for(let vt=0;vtvt&&(we.set(et,et.lastChangedTime),r.dispatchEvent({type:"planechanged",data:et}))}}G=null}const Ve=new kI;Ve.setAnimationLoop(Ge),this.setAnimationLoop=function(Le){Ne=Le},this.dispose=function(){}}}function yN(u,e){function t(Y,B){B.color.getRGB(Y.fogColor.value,UI(u)),B.isFog?(Y.fogNear.value=B.near,Y.fogFar.value=B.far):B.isFogExp2&&(Y.fogDensity.value=B.density)}function r(Y,B,ae,le,Ae){B.isMeshBasicMaterial||B.isMeshLambertMaterial?c(Y,B):B.isMeshToonMaterial?(c(Y,B),U(Y,B)):B.isMeshPhongMaterial?(c(Y,B),D(Y,B)):B.isMeshStandardMaterial?(c(Y,B),N(Y,B),B.isMeshPhysicalMaterial&&R(Y,B,Ae)):B.isMeshMatcapMaterial?(c(Y,B),G(Y,B)):B.isMeshDepthMaterial?c(Y,B):B.isMeshDistanceMaterial?(c(Y,B),J(Y,B)):B.isMeshNormalMaterial?c(Y,B):B.isLineBasicMaterial?(p(Y,B),B.isLineDashedMaterial&&y(Y,B)):B.isPointsMaterial?i(Y,B,ae,le):B.isSpriteMaterial?C(Y,B):B.isShadowMaterial?(Y.color.value.copy(B.color),Y.opacity.value=B.opacity):B.isShaderMaterial&&(B.uniformsNeedUpdate=!1)}function c(Y,B){Y.opacity.value=B.opacity,B.color&&Y.diffuse.value.copy(B.color),B.emissive&&Y.emissive.value.copy(B.emissive).multiplyScalar(B.emissiveIntensity),B.map&&(Y.map.value=B.map),B.alphaMap&&(Y.alphaMap.value=B.alphaMap),B.bumpMap&&(Y.bumpMap.value=B.bumpMap,Y.bumpScale.value=B.bumpScale,B.side===Dc&&(Y.bumpScale.value*=-1)),B.displacementMap&&(Y.displacementMap.value=B.displacementMap,Y.displacementScale.value=B.displacementScale,Y.displacementBias.value=B.displacementBias),B.emissiveMap&&(Y.emissiveMap.value=B.emissiveMap),B.normalMap&&(Y.normalMap.value=B.normalMap,Y.normalScale.value.copy(B.normalScale),B.side===Dc&&Y.normalScale.value.negate()),B.specularMap&&(Y.specularMap.value=B.specularMap),B.alphaTest>0&&(Y.alphaTest.value=B.alphaTest);const ae=e.get(B).envMap;if(ae&&(Y.envMap.value=ae,Y.flipEnvMap.value=ae.isCubeTexture&&ae.isRenderTargetTexture===!1?-1:1,Y.reflectivity.value=B.reflectivity,Y.ior.value=B.ior,Y.refractionRatio.value=B.refractionRatio),B.lightMap){Y.lightMap.value=B.lightMap;const we=u.physicallyCorrectLights!==!0?Math.PI:1;Y.lightMapIntensity.value=B.lightMapIntensity*we}B.aoMap&&(Y.aoMap.value=B.aoMap,Y.aoMapIntensity.value=B.aoMapIntensity);let le;B.map?le=B.map:B.specularMap?le=B.specularMap:B.displacementMap?le=B.displacementMap:B.normalMap?le=B.normalMap:B.bumpMap?le=B.bumpMap:B.roughnessMap?le=B.roughnessMap:B.metalnessMap?le=B.metalnessMap:B.alphaMap?le=B.alphaMap:B.emissiveMap?le=B.emissiveMap:B.clearcoatMap?le=B.clearcoatMap:B.clearcoatNormalMap?le=B.clearcoatNormalMap:B.clearcoatRoughnessMap?le=B.clearcoatRoughnessMap:B.iridescenceMap?le=B.iridescenceMap:B.iridescenceThicknessMap?le=B.iridescenceThicknessMap:B.specularIntensityMap?le=B.specularIntensityMap:B.specularColorMap?le=B.specularColorMap:B.transmissionMap?le=B.transmissionMap:B.thicknessMap?le=B.thicknessMap:B.sheenColorMap?le=B.sheenColorMap:B.sheenRoughnessMap&&(le=B.sheenRoughnessMap),le!==void 0&&(le.isWebGLRenderTarget&&(le=le.texture),le.matrixAutoUpdate===!0&&le.updateMatrix(),Y.uvTransform.value.copy(le.matrix));let Ae;B.aoMap?Ae=B.aoMap:B.lightMap&&(Ae=B.lightMap),Ae!==void 0&&(Ae.isWebGLRenderTarget&&(Ae=Ae.texture),Ae.matrixAutoUpdate===!0&&Ae.updateMatrix(),Y.uv2Transform.value.copy(Ae.matrix))}function p(Y,B){Y.diffuse.value.copy(B.color),Y.opacity.value=B.opacity}function y(Y,B){Y.dashSize.value=B.dashSize,Y.totalSize.value=B.dashSize+B.gapSize,Y.scale.value=B.scale}function i(Y,B,ae,le){Y.diffuse.value.copy(B.color),Y.opacity.value=B.opacity,Y.size.value=B.size*ae,Y.scale.value=le*.5,B.map&&(Y.map.value=B.map),B.alphaMap&&(Y.alphaMap.value=B.alphaMap),B.alphaTest>0&&(Y.alphaTest.value=B.alphaTest);let Ae;B.map?Ae=B.map:B.alphaMap&&(Ae=B.alphaMap),Ae!==void 0&&(Ae.matrixAutoUpdate===!0&&Ae.updateMatrix(),Y.uvTransform.value.copy(Ae.matrix))}function C(Y,B){Y.diffuse.value.copy(B.color),Y.opacity.value=B.opacity,Y.rotation.value=B.rotation,B.map&&(Y.map.value=B.map),B.alphaMap&&(Y.alphaMap.value=B.alphaMap),B.alphaTest>0&&(Y.alphaTest.value=B.alphaTest);let ae;B.map?ae=B.map:B.alphaMap&&(ae=B.alphaMap),ae!==void 0&&(ae.matrixAutoUpdate===!0&&ae.updateMatrix(),Y.uvTransform.value.copy(ae.matrix))}function D(Y,B){Y.specular.value.copy(B.specular),Y.shininess.value=Math.max(B.shininess,1e-4)}function U(Y,B){B.gradientMap&&(Y.gradientMap.value=B.gradientMap)}function N(Y,B){Y.roughness.value=B.roughness,Y.metalness.value=B.metalness,B.roughnessMap&&(Y.roughnessMap.value=B.roughnessMap),B.metalnessMap&&(Y.metalnessMap.value=B.metalnessMap),e.get(B).envMap&&(Y.envMapIntensity.value=B.envMapIntensity)}function R(Y,B,ae){Y.ior.value=B.ior,B.sheen>0&&(Y.sheenColor.value.copy(B.sheenColor).multiplyScalar(B.sheen),Y.sheenRoughness.value=B.sheenRoughness,B.sheenColorMap&&(Y.sheenColorMap.value=B.sheenColorMap),B.sheenRoughnessMap&&(Y.sheenRoughnessMap.value=B.sheenRoughnessMap)),B.clearcoat>0&&(Y.clearcoat.value=B.clearcoat,Y.clearcoatRoughness.value=B.clearcoatRoughness,B.clearcoatMap&&(Y.clearcoatMap.value=B.clearcoatMap),B.clearcoatRoughnessMap&&(Y.clearcoatRoughnessMap.value=B.clearcoatRoughnessMap),B.clearcoatNormalMap&&(Y.clearcoatNormalScale.value.copy(B.clearcoatNormalScale),Y.clearcoatNormalMap.value=B.clearcoatNormalMap,B.side===Dc&&Y.clearcoatNormalScale.value.negate())),B.iridescence>0&&(Y.iridescence.value=B.iridescence,Y.iridescenceIOR.value=B.iridescenceIOR,Y.iridescenceThicknessMinimum.value=B.iridescenceThicknessRange[0],Y.iridescenceThicknessMaximum.value=B.iridescenceThicknessRange[1],B.iridescenceMap&&(Y.iridescenceMap.value=B.iridescenceMap),B.iridescenceThicknessMap&&(Y.iridescenceThicknessMap.value=B.iridescenceThicknessMap)),B.transmission>0&&(Y.transmission.value=B.transmission,Y.transmissionSamplerMap.value=ae.texture,Y.transmissionSamplerSize.value.set(ae.width,ae.height),B.transmissionMap&&(Y.transmissionMap.value=B.transmissionMap),Y.thickness.value=B.thickness,B.thicknessMap&&(Y.thicknessMap.value=B.thicknessMap),Y.attenuationDistance.value=B.attenuationDistance,Y.attenuationColor.value.copy(B.attenuationColor)),Y.specularIntensity.value=B.specularIntensity,Y.specularColor.value.copy(B.specularColor),B.specularIntensityMap&&(Y.specularIntensityMap.value=B.specularIntensityMap),B.specularColorMap&&(Y.specularColorMap.value=B.specularColorMap)}function G(Y,B){B.matcap&&(Y.matcap.value=B.matcap)}function J(Y,B){Y.referencePosition.value.copy(B.referencePosition),Y.nearDistance.value=B.nearDistance,Y.farDistance.value=B.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:r}}function xN(u,e,t,r){let c={},p={},y=[];const i=t.isWebGL2?u.getParameter(35375):0;function C(le,Ae){const we=Ae.program;r.uniformBlockBinding(le,we)}function D(le,Ae){let we=c[le.id];we===void 0&&(J(le),we=U(le),c[le.id]=we,le.addEventListener("dispose",B));const me=Ae.program;r.updateUBOMapping(le,me);const Pe=e.render.frame;p[le.id]!==Pe&&(R(le),p[le.id]=Pe)}function U(le){const Ae=N();le.__bindingPointIndex=Ae;const we=u.createBuffer(),me=le.__size,Pe=le.usage;return u.bindBuffer(35345,we),u.bufferData(35345,me,Pe),u.bindBuffer(35345,null),u.bindBufferBase(35345,Ae,we),we}function N(){for(let le=0;le0){Pe=we%me;const Ci=me-Pe;Pe!==0&&Ci-Et.boundary<0&&(we+=me-Pe,Ke.__offset=we)}we+=Et.storage}return Pe=we%me,Pe>0&&(we+=me-Pe),le.__size=we,le.__cache={},this}function Y(le){const Ae={boundary:0,storage:0};return typeof le=="number"?(Ae.boundary=4,Ae.storage=4):le.isVector2?(Ae.boundary=8,Ae.storage=8):le.isVector3||le.isColor?(Ae.boundary=16,Ae.storage=12):le.isVector4?(Ae.boundary=16,Ae.storage=16):le.isMatrix3?(Ae.boundary=48,Ae.storage=48):le.isMatrix4?(Ae.boundary=64,Ae.storage=64):le.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",le),Ae}function B(le){const Ae=le.target;Ae.removeEventListener("dispose",B);const we=y.indexOf(Ae.__bindingPointIndex);y.splice(we,1),u.deleteBuffer(c[Ae.id]),delete c[Ae.id],delete p[Ae.id]}function ae(){for(const le in c)u.deleteBuffer(c[le]);y=[],c={},p={}}return{bind:C,update:D,dispose:ae}}function vN(){const u=Z_("canvas");return u.style.display="block",u}function mv(u={}){this.isWebGLRenderer=!0;const e=u.canvas!==void 0?u.canvas:vN(),t=u.context!==void 0?u.context:null,r=u.depth!==void 0?u.depth:!0,c=u.stencil!==void 0?u.stencil:!0,p=u.antialias!==void 0?u.antialias:!1,y=u.premultipliedAlpha!==void 0?u.premultipliedAlpha:!0,i=u.preserveDrawingBuffer!==void 0?u.preserveDrawingBuffer:!1,C=u.powerPreference!==void 0?u.powerPreference:"default",D=u.failIfMajorPerformanceCaveat!==void 0?u.failIfMajorPerformanceCaveat:!1;let U;t!==null?U=t.getContextAttributes().alpha:U=u.alpha!==void 0?u.alpha:!1;let N=null,R=null;const G=[],J=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=hp,this.physicallyCorrectLights=!1,this.toneMapping=Vu,this.toneMappingExposure=1;const Y=this;let B=!1,ae=0,le=0,Ae=null,we=-1,me=null;const Pe=new ls,it=new ls;let Me=null,Ke=e.width,Et=e.height,oi=1,Ci=null,te=null;const ce=new ls(0,0,Ke,Et),ye=new ls(0,0,Ke,Et);let xe=!1;const ze=new Gv;let Ne=!1,Ge=!1,Ve=null;const Le=new lr,Ie=new Di,qe=new ft,et={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function vt(){return Ae===null?oi:1}let Be=t;function dt(X,j){for(let ie=0;ie0?R=J[J.length-1]:R=null,G.pop(),G.length>0?N=G[G.length-1]:N=null};function Hr(X,j,ie,ne){if(X.visible===!1)return;if(X.layers.test(j.layers)){if(X.isGroup)ie=X.renderOrder;else if(X.isLOD)X.autoUpdate===!0&&X.update(j);else if(X.isLight)R.pushLight(X),X.castShadow&&R.pushShadow(X);else if(X.isSprite){if(!X.frustumCulled||ze.intersectsSprite(X)){ne&&qe.setFromMatrixPosition(X.matrixWorld).applyMatrix4(Le);const tt=wn.update(X),He=X.material;He.visible&&N.push(X,tt,He,ie,qe.z,null)}}else if((X.isMesh||X.isLine||X.isPoints)&&(X.isSkinnedMesh&&X.skeleton.frame!==Nt.render.frame&&(X.skeleton.update(),X.skeleton.frame=Nt.render.frame),!X.frustumCulled||ze.intersectsObject(X))){ne&&qe.setFromMatrixPosition(X.matrixWorld).applyMatrix4(Le);const tt=wn.update(X),He=X.material;if(Array.isArray(He)){const Je=tt.groups;for(let pt=0,Lt=Je.length;pt0&&kr(de,j,ie),ne&&Wt.viewport(Pe.copy(ne)),de.length>0&&Qn(de,j,ie),Re.length>0&&Qn(Re,j,ie),tt.length>0&&Qn(tt,j,ie),Wt.buffers.depth.setTest(!0),Wt.buffers.depth.setMask(!0),Wt.buffers.color.setMask(!0),Wt.setPolygonOffset(!1)}function kr(X,j,ie){const ne=Qt.isWebGL2;Ve===null&&(Ve=new Oa(1,1,{generateMipmaps:!0,type:ut.has("EXT_color_buffer_half_float")?Gm:cp,minFilter:lp,samples:ne&&p===!0?4:0})),Y.getDrawingBufferSize(Ie),ne?Ve.setSize(Ie.x,Ie.y):Ve.setSize(fv(Ie.x),fv(Ie.y));const de=Y.getRenderTarget();Y.setRenderTarget(Ve),Y.clear();const Re=Y.toneMapping;Y.toneMapping=Vu,Qn(X,j,ie),Y.toneMapping=Re,Ft.updateMultisampleRenderTarget(Ve),Ft.updateRenderTargetMipmap(Ve),Y.setRenderTarget(de)}function Qn(X,j,ie){const ne=j.isScene===!0?j.overrideMaterial:null;for(let de=0,Re=X.length;de0&&Ft.useMultisampledRTT(X)===!1?de=Ct.get(X).__webglMultisampledFramebuffer:de=Lt,Pe.copy(X.viewport),it.copy(X.scissor),Me=X.scissorTest}else Pe.copy(ce).multiplyScalar(oi).floor(),it.copy(ye).multiplyScalar(oi).floor(),Me=xe;if(Wt.bindFramebuffer(36160,de)&&Qt.drawBuffers&&ne&&Wt.drawBuffers(X,de),Wt.viewport(Pe),Wt.scissor(it),Wt.setScissorTest(Me),Re){const Je=Ct.get(X.texture);Be.framebufferTexture2D(36160,36064,34069+j,Je.__webglTexture,ie)}else if(tt){const Je=Ct.get(X.texture),pt=j||0;Be.framebufferTextureLayer(36160,36064,Je.__webglTexture,ie||0,pt)}we=-1},this.readRenderTargetPixels=function(X,j,ie,ne,de,Re,tt){if(!(X&&X.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let He=Ct.get(X).__webglFramebuffer;if(X.isWebGLCubeRenderTarget&&tt!==void 0&&(He=He[tt]),He){Wt.bindFramebuffer(36160,He);try{const Je=X.texture,pt=Je.format,Lt=Je.type;if(pt!==Dl&&at.convert(pt)!==Be.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const jt=Lt===Gm&&(ut.has("EXT_color_buffer_half_float")||Qt.isWebGL2&&ut.has("EXT_color_buffer_float"));if(Lt!==cp&&at.convert(Lt)!==Be.getParameter(35738)&&!(Lt===GA&&(Qt.isWebGL2||ut.has("OES_texture_float")||ut.has("WEBGL_color_buffer_float")))&&!jt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}j>=0&&j<=X.width-ne&&ie>=0&&ie<=X.height-de&&Be.readPixels(j,ie,ne,de,at.convert(pt),at.convert(Lt),Re)}finally{const Je=Ae!==null?Ct.get(Ae).__webglFramebuffer:null;Wt.bindFramebuffer(36160,Je)}}},this.copyFramebufferToTexture=function(X,j,ie=0){const ne=Math.pow(2,-ie),de=Math.floor(j.image.width*ne),Re=Math.floor(j.image.height*ne);Ft.setTexture2D(j,0),Be.copyTexSubImage2D(3553,ie,0,0,X.x,X.y,de,Re),Wt.unbindTexture()},this.copyTextureToTexture=function(X,j,ie,ne=0){const de=j.image.width,Re=j.image.height,tt=at.convert(ie.format),He=at.convert(ie.type);Ft.setTexture2D(ie,0),Be.pixelStorei(37440,ie.flipY),Be.pixelStorei(37441,ie.premultiplyAlpha),Be.pixelStorei(3317,ie.unpackAlignment),j.isDataTexture?Be.texSubImage2D(3553,ne,X.x,X.y,de,Re,tt,He,j.image.data):j.isCompressedTexture?Be.compressedTexSubImage2D(3553,ne,X.x,X.y,j.mipmaps[0].width,j.mipmaps[0].height,tt,j.mipmaps[0].data):Be.texSubImage2D(3553,ne,X.x,X.y,tt,He,j.image),ne===0&&ie.generateMipmaps&&Be.generateMipmap(3553),Wt.unbindTexture()},this.copyTextureToTexture3D=function(X,j,ie,ne,de=0){if(Y.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Re=X.max.x-X.min.x+1,tt=X.max.y-X.min.y+1,He=X.max.z-X.min.z+1,Je=at.convert(ne.format),pt=at.convert(ne.type);let Lt;if(ne.isData3DTexture)Ft.setTexture3D(ne,0),Lt=32879;else if(ne.isDataArrayTexture)Ft.setTexture2DArray(ne,0),Lt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Be.pixelStorei(37440,ne.flipY),Be.pixelStorei(37441,ne.premultiplyAlpha),Be.pixelStorei(3317,ne.unpackAlignment);const jt=Be.getParameter(3314),Gt=Be.getParameter(32878),ki=Be.getParameter(3316),wi=Be.getParameter(3315),Oi=Be.getParameter(32877),Yi=ie.isCompressedTexture?ie.mipmaps[0]:ie.image;Be.pixelStorei(3314,Yi.width),Be.pixelStorei(32878,Yi.height),Be.pixelStorei(3316,X.min.x),Be.pixelStorei(3315,X.min.y),Be.pixelStorei(32877,X.min.z),ie.isDataTexture||ie.isData3DTexture?Be.texSubImage3D(Lt,de,j.x,j.y,j.z,Re,tt,He,Je,pt,Yi.data):ie.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Be.compressedTexSubImage3D(Lt,de,j.x,j.y,j.z,Re,tt,He,Je,Yi.data)):Be.texSubImage3D(Lt,de,j.x,j.y,j.z,Re,tt,He,Je,pt,Yi),Be.pixelStorei(3314,jt),Be.pixelStorei(32878,Gt),Be.pixelStorei(3316,ki),Be.pixelStorei(3315,wi),Be.pixelStorei(32877,Oi),de===0&&ne.generateMipmaps&&Be.generateMipmap(Lt),Wt.unbindTexture()},this.initTexture=function(X){X.isCubeTexture?Ft.setTextureCube(X,0):X.isData3DTexture?Ft.setTexture3D(X,0):X.isDataArrayTexture||X.isCompressedArrayTexture?Ft.setTexture2DArray(X,0):Ft.setTexture2D(X,0),Wt.unbindTexture()},this.resetState=function(){ae=0,le=0,Ae=null,Wt.reset(),ii.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class jI extends mv{}jI.prototype.isWebGL1Renderer=!0;class jv{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Dn(e),this.density=t}clone(){return new jv(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Kv{constructor(e,t=1,r=1e3){this.isFog=!0,this.name="",this.color=new Dn(e),this.near=t,this.far=r}clone(){return new Kv(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class j2 extends cs{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}class $v{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=K_,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Pc()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,r){e*=this.stride,r*=t.stride;for(let c=0,p=this.stride;ce.far||t.push({distance:C,point:c_.clone(),uv:wh.getUV(c_,mx,u_,gx,dT,Ww,pT,new Di),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function _x(u,e,t,r,c,p){Em.subVectors(u,t).addScalar(.5).multiply(r),c!==void 0?(h_.x=p*Em.x-c*Em.y,h_.y=c*Em.x+p*Em.y):h_.copy(Em),u.copy(e),u.x+=h_.x,u.y+=h_.y,u.applyMatrix4(KI)}const yx=new ft,fT=new ft;class $I extends cs{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let r=0,c=t.length;r0){let r,c;for(r=1,c=t.length;r0){yx.setFromMatrixPosition(this.matrixWorld);const c=e.ray.origin.distanceTo(yx);this.getObjectForDistance(c).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){yx.setFromMatrixPosition(e.matrixWorld),fT.setFromMatrixPosition(this.matrixWorld);const r=yx.distanceTo(fT)/e.zoom;t[0].object.visible=!0;let c,p;for(c=1,p=t.length;c=y)t[c-1].object.visible=!1,t[c].object.visible=!0;else break}for(this._currentLevel=c-1;cC)continue;R.applyMatrix4(this.matrixWorld);const Me=e.ray.origin.distanceTo(R);Mee.far||t.push({distance:Me,point:N.clone().applyMatrix4(this.matrixWorld),index:Ae,face:null,faceIndex:null,object:this})}}else{const ae=Math.max(0,y.start),le=Math.min(B.count,y.start+y.count);for(let Ae=ae,we=le-1;AeC)continue;R.applyMatrix4(this.matrixWorld);const Pe=e.ray.origin.distanceTo(R);Pee.far||t.push({distance:Pe,point:N.clone().applyMatrix4(this.matrixWorld),index:Ae,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const c=t[r[0]];if(c!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let p=0,y=c.length;p0){const c=t[r[0]];if(c!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let p=0,y=c.length;pc.far)return;p.push({distance:D,distanceToRay:Math.sqrt(i),point:C,index:e,face:null,object:y})}}class CN extends To{constructor(e,t,r,c,p,y,i,C,D){super(e,t,r,c,p,y,i,C,D),this.isVideoTexture=!0,this.minFilter=y!==void 0?y:Xs,this.magFilter=p!==void 0?p:Xs,this.generateMipmaps=!1;const U=this;function N(){U.needsUpdate=!0,e.requestVideoFrameCallback(N)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(N)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class EN extends To{constructor(e,t,r){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=r,this.magFilter=Co,this.minFilter=Co,this.generateMipmaps=!1,this.needsUpdate=!0}}class X2 extends To{constructor(e,t,r,c,p,y,i,C,D,U,N,R){super(null,y,i,C,D,U,c,p,N,R),this.isCompressedTexture=!0,this.image={width:t,height:r},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class TN extends X2{constructor(e,t,r,c,p,y){super(e,t,r,p,y),this.isCompressedArrayTexture=!0,this.image.depth=c,this.wrapR=rl}}class qI extends To{constructor(e,t,r,c,p,y,i,C,D){super(e,t,r,c,p,y,i,C,D),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Au{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const r=this.getUtoTmapping(e);return this.getPoint(r,t)}getPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return t}getSpacedPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPointAt(r/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let r,c=this.getPoint(0),p=0;t.push(0);for(let y=1;y<=e;y++)r=this.getPoint(y/e),p+=r.distanceTo(c),t.push(p),c=r;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const r=this.getLengths();let c=0;const p=r.length;let y;t?y=t:y=e*r[p-1];let i=0,C=p-1,D;for(;i<=C;)if(c=Math.floor(i+(C-i)/2),D=r[c]-y,D<0)i=c+1;else if(D>0)C=c-1;else{C=c;break}if(c=C,r[c]===y)return c/(p-1);const U=r[c],R=r[c+1]-U,G=(y-U)/R;return(c+G)/(p-1)}getTangent(e,t){let c=e-1e-4,p=e+1e-4;c<0&&(c=0),p>1&&(p=1);const y=this.getPoint(c),i=this.getPoint(p),C=t||(y.isVector2?new Di:new ft);return C.copy(i).sub(y).normalize(),C}getTangentAt(e,t){const r=this.getUtoTmapping(e);return this.getTangent(r,t)}computeFrenetFrames(e,t){const r=new ft,c=[],p=[],y=[],i=new ft,C=new lr;for(let G=0;G<=e;G++){const J=G/e;c[G]=this.getTangentAt(J,new ft)}p[0]=new ft,y[0]=new ft;let D=Number.MAX_VALUE;const U=Math.abs(c[0].x),N=Math.abs(c[0].y),R=Math.abs(c[0].z);U<=D&&(D=U,r.set(1,0,0)),N<=D&&(D=N,r.set(0,1,0)),R<=D&&r.set(0,0,1),i.crossVectors(c[0],r).normalize(),p[0].crossVectors(c[0],i),y[0].crossVectors(c[0],p[0]);for(let G=1;G<=e;G++){if(p[G]=p[G-1].clone(),y[G]=y[G-1].clone(),i.crossVectors(c[G-1],c[G]),i.length()>Number.EPSILON){i.normalize();const J=Math.acos(Eo(c[G-1].dot(c[G]),-1,1));p[G].applyMatrix4(C.makeRotationAxis(i,J))}y[G].crossVectors(c[G],p[G])}if(t===!0){let G=Math.acos(Eo(p[0].dot(p[e]),-1,1));G/=e,c[0].dot(i.crossVectors(p[0],p[e]))>0&&(G=-G);for(let J=1;J<=e;J++)p[J].applyMatrix4(C.makeRotationAxis(c[J],G*J)),y[J].crossVectors(c[J],p[J])}return{tangents:c,normals:p,binormals:y}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Xv extends Au{constructor(e=0,t=0,r=1,c=1,p=0,y=Math.PI*2,i=!1,C=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=c,this.aStartAngle=p,this.aEndAngle=y,this.aClockwise=i,this.aRotation=C}getPoint(e,t){const r=t||new Di,c=Math.PI*2;let p=this.aEndAngle-this.aStartAngle;const y=Math.abs(p)c;)p-=c;p0?0:(Math.floor(Math.abs(i)/p)+1)*p:C===0&&i===p-1&&(i=p-2,C=1);let D,U;this.closed||i>0?D=c[(i-1)%p]:(Bx.subVectors(c[0],c[1]).add(c[0]),D=Bx);const N=c[i%p],R=c[(i+1)%p];if(this.closed||i+2c.length-2?c.length-1:y+1],N=c[y>c.length-3?c.length-1:y+2];return r.set(IT(i,C.x,D.x,U.x,N.x),IT(i,C.y,D.y,U.y,N.y)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t=r){const y=c[p]-r,i=this.curves[p],C=i.getLength(),D=C===0?0:1-y/C;return i.getPointAt(D,t)}p++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let r=0,c=this.curves.length;r1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,r=e.curves.length;t0){const N=D.getPoint(0);N.equals(this.currentPoint)||this.lineTo(N.x,N.y)}this.curves.push(D);const U=D.getPoint(1);return this.currentPoint.copy(U),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class eg extends br{constructor(e=[new Di(0,-.5),new Di(.5,0),new Di(0,.5)],t=12,r=0,c=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:r,phiLength:c},t=Math.floor(t),c=Eo(c,0,Math.PI*2);const p=[],y=[],i=[],C=[],D=[],U=1/t,N=new ft,R=new Di,G=new ft,J=new ft,Y=new ft;let B=0,ae=0;for(let le=0;le<=e.length-1;le++)switch(le){case 0:B=e[le+1].x-e[le].x,ae=e[le+1].y-e[le].y,G.x=ae*1,G.y=-B,G.z=ae*0,Y.copy(G),G.normalize(),C.push(G.x,G.y,G.z);break;case e.length-1:C.push(Y.x,Y.y,Y.z);break;default:B=e[le+1].x-e[le].x,ae=e[le+1].y-e[le].y,G.x=ae*1,G.y=-B,G.z=ae*0,J.copy(G),G.x+=Y.x,G.y+=Y.y,G.z+=Y.z,G.normalize(),C.push(G.x,G.y,G.z),Y.copy(J)}for(let le=0;le<=t;le++){const Ae=r+le*U*c,we=Math.sin(Ae),me=Math.cos(Ae);for(let Pe=0;Pe<=e.length-1;Pe++){N.x=e[Pe].x*we,N.y=e[Pe].y,N.z=e[Pe].x*me,y.push(N.x,N.y,N.z),R.x=le/t,R.y=Pe/(e.length-1),i.push(R.x,R.y);const it=C[3*Pe+0]*we,Me=C[3*Pe+1],Ke=C[3*Pe+0]*me;D.push(it,Me,Ke)}}for(let le=0;le0&&Ae(!0),t>0&&Ae(!1)),this.setIndex(U),this.setAttribute("position",new jn(N,3)),this.setAttribute("normal",new jn(R,3)),this.setAttribute("uv",new jn(G,2));function le(){const we=new ft,me=new ft;let Pe=0;const it=(t-e)/r;for(let Me=0;Me<=p;Me++){const Ke=[],Et=Me/p,oi=Et*(t-e)+e;for(let Ci=0;Ci<=c;Ci++){const te=Ci/c,ce=te*C+i,ye=Math.sin(ce),xe=Math.cos(ce);me.x=oi*ye,me.y=-Et*r+B,me.z=oi*xe,N.push(me.x,me.y,me.z),we.set(ye,it,xe).normalize(),R.push(we.x,we.y,we.z),G.push(te,1-Et),Ke.push(J++)}Y.push(Ke)}for(let Me=0;Me.9&&it<.1&&(Ae<.2&&(y[le+0]+=1),we<.2&&(y[le+2]+=1),me<.2&&(y[le+4]+=1))}}function R(le){p.push(le.x,le.y,le.z)}function G(le,Ae){const we=le*3;Ae.x=e[we+0],Ae.y=e[we+1],Ae.z=e[we+2]}function J(){const le=new ft,Ae=new ft,we=new ft,me=new ft,Pe=new Di,it=new Di,Me=new Di;for(let Ke=0,Et=0;Ke80*t){i=D=u[0],C=U=u[1];for(let J=t;JD&&(D=N),R>U&&(U=R);G=Math.max(D-i,U-C),G=G!==0?32767/G:0}return Y_(p,y,t,i,C,G,0),y}};function nF(u,e,t,r,c){let p,y;if(c===qN(u,e,t,r)>0)for(p=e;p=e;p-=r)y=FT(p,u[p],u[p+1],y);return y&&Yv(y,y.next)&&(ey(y),y=y.next),y}function xf(u,e){if(!u)return u;e||(e=u);let t=u,r;do if(r=!1,!t.steiner&&(Yv(t,t.next)||co(t.prev,t,t.next)===0)){if(ey(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function Y_(u,e,t,r,c,p,y){if(!u)return;!y&&p&&WN(u,r,c,p);let i=u,C,D;for(;u.prev!==u.next;){if(C=u.prev,D=u.next,p?zN(u,r,c,p):RN(u)){e.push(C.i/t|0),e.push(u.i/t|0),e.push(D.i/t|0),ey(u),u=D.next,i=D.next;continue}if(u=D,u===i){y?y===1?(u=kN(xf(u),e,t),Y_(u,e,t,r,c,p,2)):y===2&&ON(u,e,t,r,c,p):Y_(xf(u),e,t,r,c,p,1);break}}}function RN(u){const e=u.prev,t=u,r=u.next;if(co(e,t,r)>=0)return!1;const c=e.x,p=t.x,y=r.x,i=e.y,C=t.y,D=r.y,U=cp?c>y?c:y:p>y?p:y,G=i>C?i>D?i:D:C>D?C:D;let J=r.next;for(;J!==e;){if(J.x>=U&&J.x<=R&&J.y>=N&&J.y<=G&&Rm(c,i,p,C,y,D,J.x,J.y)&&co(J.prev,J,J.next)>=0)return!1;J=J.next}return!0}function zN(u,e,t,r){const c=u.prev,p=u,y=u.next;if(co(c,p,y)>=0)return!1;const i=c.x,C=p.x,D=y.x,U=c.y,N=p.y,R=y.y,G=iC?i>D?i:D:C>D?C:D,B=U>N?U>R?U:R:N>R?N:R,ae=h2(G,J,e,t,r),le=h2(Y,B,e,t,r);let Ae=u.prevZ,we=u.nextZ;for(;Ae&&Ae.z>=ae&&we&&we.z<=le;){if(Ae.x>=G&&Ae.x<=Y&&Ae.y>=J&&Ae.y<=B&&Ae!==c&&Ae!==y&&Rm(i,U,C,N,D,R,Ae.x,Ae.y)&&co(Ae.prev,Ae,Ae.next)>=0||(Ae=Ae.prevZ,we.x>=G&&we.x<=Y&&we.y>=J&&we.y<=B&&we!==c&&we!==y&&Rm(i,U,C,N,D,R,we.x,we.y)&&co(we.prev,we,we.next)>=0))return!1;we=we.nextZ}for(;Ae&&Ae.z>=ae;){if(Ae.x>=G&&Ae.x<=Y&&Ae.y>=J&&Ae.y<=B&&Ae!==c&&Ae!==y&&Rm(i,U,C,N,D,R,Ae.x,Ae.y)&&co(Ae.prev,Ae,Ae.next)>=0)return!1;Ae=Ae.prevZ}for(;we&&we.z<=le;){if(we.x>=G&&we.x<=Y&&we.y>=J&&we.y<=B&&we!==c&&we!==y&&Rm(i,U,C,N,D,R,we.x,we.y)&&co(we.prev,we,we.next)>=0)return!1;we=we.nextZ}return!0}function kN(u,e,t){let r=u;do{const c=r.prev,p=r.next.next;!Yv(c,p)&&rF(c,r,r.next,p)&&J_(c,p)&&J_(p,c)&&(e.push(c.i/t|0),e.push(r.i/t|0),e.push(p.i/t|0),ey(r),ey(r.next),r=u=p),r=r.next}while(r!==u);return xf(r)}function ON(u,e,t,r,c,p){let y=u;do{let i=y.next.next;for(;i!==y.prev;){if(y.i!==i.i&&$N(y,i)){let C=sF(y,i);y=xf(y,y.next),C=xf(C,C.next),Y_(y,e,t,r,c,p,0),Y_(C,e,t,r,c,p,0);return}i=i.next}y=y.next}while(y!==u)}function NN(u,e,t,r){const c=[];let p,y,i,C,D;for(p=0,y=e.length;p=t.next.y&&t.next.y!==t.y){const R=t.x+(y-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(R<=p&&R>r&&(r=R,c=t.x=t.x&&t.x>=C&&p!==t.x&&Rm(yc.x||t.x===c.x&&GN(c,t)))&&(c=t,U=N)),t=t.next;while(t!==i);return c}function GN(u,e){return co(u.prev,u,e.prev)<0&&co(e.next,u,u.next)<0}function WN(u,e,t,r){let c=u;do c.z===0&&(c.z=h2(c.x,c.y,e,t,r)),c.prevZ=c.prev,c.nextZ=c.next,c=c.next;while(c!==u);c.prevZ.nextZ=null,c.prevZ=null,jN(c)}function jN(u){let e,t,r,c,p,y,i,C,D=1;do{for(t=u,u=null,p=null,y=0;t;){for(y++,r=t,i=0,e=0;e0||C>0&&r;)i!==0&&(C===0||!r||t.z<=r.z)?(c=t,t=t.nextZ,i--):(c=r,r=r.nextZ,C--),p?p.nextZ=c:u=c,c.prevZ=p,p=c;t=r}p.nextZ=null,D*=2}while(y>1);return u}function h2(u,e,t,r,c){return u=(u-t)*c|0,e=(e-r)*c|0,u=(u|u<<8)&16711935,u=(u|u<<4)&252645135,u=(u|u<<2)&858993459,u=(u|u<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,u|e<<1}function KN(u){let e=u,t=u;do(e.x=(u-y)*(p-i)&&(u-y)*(r-i)>=(t-y)*(e-i)&&(t-y)*(p-i)>=(c-y)*(r-i)}function $N(u,e){return u.next.i!==e.i&&u.prev.i!==e.i&&!ZN(u,e)&&(J_(u,e)&&J_(e,u)&&XN(u,e)&&(co(u.prev,u,e.prev)||co(u,e.prev,e))||Yv(u,e)&&co(u.prev,u,u.next)>0&&co(e.prev,e,e.next)>0)}function co(u,e,t){return(e.y-u.y)*(t.x-e.x)-(e.x-u.x)*(t.y-e.y)}function Yv(u,e){return u.x===e.x&&u.y===e.y}function rF(u,e,t,r){const c=Mx(co(u,e,t)),p=Mx(co(u,e,r)),y=Mx(co(t,r,u)),i=Mx(co(t,r,e));return!!(c!==p&&y!==i||c===0&&Sx(u,t,e)||p===0&&Sx(u,r,e)||y===0&&Sx(t,u,r)||i===0&&Sx(t,e,r))}function Sx(u,e,t){return e.x<=Math.max(u.x,t.x)&&e.x>=Math.min(u.x,t.x)&&e.y<=Math.max(u.y,t.y)&&e.y>=Math.min(u.y,t.y)}function Mx(u){return u>0?1:u<0?-1:0}function ZN(u,e){let t=u;do{if(t.i!==u.i&&t.next.i!==u.i&&t.i!==e.i&&t.next.i!==e.i&&rF(t,t.next,u,e))return!0;t=t.next}while(t!==u);return!1}function J_(u,e){return co(u.prev,u,u.next)<0?co(u,e,u.next)>=0&&co(u,u.prev,e)>=0:co(u,e,u.prev)<0||co(u,u.next,e)<0}function XN(u,e){let t=u,r=!1;const c=(u.x+e.x)/2,p=(u.y+e.y)/2;do t.y>p!=t.next.y>p&&t.next.y!==t.y&&c<(t.next.x-t.x)*(p-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==u);return r}function sF(u,e){const t=new u2(u.i,u.x,u.y),r=new u2(e.i,e.x,e.y),c=u.next,p=e.prev;return u.next=e,e.prev=u,t.next=c,c.prev=t,r.next=t,t.prev=r,p.next=r,r.prev=p,r}function FT(u,e,t,r){const c=new u2(u,e,t);return r?(c.next=r.next,c.prev=r,r.next.prev=c,r.next=c):(c.prev=c,c.next=c),c}function ey(u){u.next.prev=u.prev,u.prev.next=u.next,u.prevZ&&(u.prevZ.nextZ=u.nextZ),u.nextZ&&(u.nextZ.prevZ=u.prevZ)}function u2(u,e,t){this.i=u,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qN(u,e,t,r){let c=0;for(let p=e,y=t-r;p2&&u[e-1].equals(u[0])&&u.pop()}function DT(u,e){for(let t=0;tNumber.EPSILON){const ti=Math.sqrt(yt),Ni=Math.sqrt(Gn*Gn+kn*kn),qi=Ft.x-Qi/ti,en=Ft.y+wn/ti,$t=Xt.x-kn/Ni,at=Xt.y+Gn/Ni,ii=(($t-qi)*kn-(at-en)*Gn)/(wn*kn-Qi*Gn);mi=qi+wn*ii-Ct.x,fi=en+Qi*ii-Ct.y;const hn=mi*mi+fi*fi;if(hn<=2)return new Di(mi,fi);Gi=Math.sqrt(hn/2)}else{let ti=!1;wn>Number.EPSILON?Gn>Number.EPSILON&&(ti=!0):wn<-Number.EPSILON?Gn<-Number.EPSILON&&(ti=!0):Math.sign(Qi)===Math.sign(kn)&&(ti=!0),ti?(mi=-Qi,fi=wn,Gi=Math.sqrt(yt)):(mi=wn,fi=Qi,Gi=Math.sqrt(yt/2))}return new Di(mi/Gi,fi/Gi)}const Ge=[];for(let Ct=0,Ft=ce.length,Xt=Ft-1,mi=Ct+1;Ct=0;Ct--){const Ft=Ct/B,Xt=G*Math.cos(Ft*Math.PI/2),mi=J*Math.sin(Ft*Math.PI/2)+Y;for(let fi=0,Gi=ce.length;fi=0;){const mi=Xt;let fi=Xt-1;fi<0&&(fi=Ct.length-1);for(let Gi=0,wn=U+B*2;Gi0)&&G.push(Ae,we,Pe),(ae!==r-1||C0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class sB extends ol{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Dn(16777215),this.specular=new Dn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=up,this.normalScale=new Di(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=hy,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class lF extends ol{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Dn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=up,this.normalScale=new Di(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class cF extends ol{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=up,this.normalScale=new Di(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class yv extends ol{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Dn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=up,this.normalScale=new Di(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=hy,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class hF extends ol{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Dn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=up,this.normalScale=new Di(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class uF extends sa{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function xh(u,e,t){return oB(u)?new u.constructor(u.subarray(e,t!==void 0?t:u.length)):u.slice(e,t)}function cf(u,e,t){return!u||!t&&u.constructor===e?u:typeof e.BYTES_PER_ELEMENT=="number"?new e(u):Array.prototype.slice.call(u)}function oB(u){return ArrayBuffer.isView(u)&&!(u instanceof DataView)}function AF(u){function e(c,p){return u[c]-u[p]}const t=u.length,r=new Array(t);for(let c=0;c!==t;++c)r[c]=c;return r.sort(e),r}function A2(u,e,t){const r=u.length,c=new u.constructor(r);for(let p=0,y=0;y!==r;++p){const i=t[p]*e;for(let C=0;C!==e;++C)c[y++]=u[i+C]}return c}function aB(u,e,t,r){let c=1,p=u[0];for(;p!==void 0&&p[r]===void 0;)p=u[c++];if(p===void 0)return;let y=p[r];if(y!==void 0)if(Array.isArray(y))do y=p[r],y!==void 0&&(e.push(p.time),t.push.apply(t,y)),p=u[c++];while(p!==void 0);else if(y.toArray!==void 0)do y=p[r],y!==void 0&&(e.push(p.time),y.toArray(t,t.length)),p=u[c++];while(p!==void 0);else do y=p[r],y!==void 0&&(e.push(p.time),t.push(y)),p=u[c++];while(p!==void 0)}function tQ(u,e,t,r,c=30){const p=u.clone();p.name=e;const y=[];for(let C=0;C=r)){N.push(D.times[G]);for(let Y=0;Yp.tracks[C].times[0]&&(i=p.tracks[C].times[0]);for(let C=0;C=i.times[J]){const ae=J*N+U,le=ae+N-U;Y=xh(i.values,ae,le)}else{const ae=i.createInterpolant(),le=U,Ae=N-U;ae.evaluate(p),Y=xh(ae.resultBuffer,le,Ae)}C==="quaternion"&&new sl().fromArray(Y).normalize().conjugate().toArray(Y);const B=D.times.length;for(let ae=0;ae=p)){const i=t[1];e=p)break t}y=r,r=0;break i}break e}for(;r>>1;et;)--y;if(++y,p!==0||y!==c){p>=y&&(y=Math.max(y,1),p=y-1);const i=this.getValueSize();this.times=xh(r,p,y),this.values=xh(this.values,p*i,y*i)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const r=this.times,c=this.values,p=r.length;p===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let y=null;for(let i=0;i!==p;i++){const C=r[i];if(typeof C=="number"&&isNaN(C)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,i,C),e=!1;break}if(y!==null&&y>C){console.error("THREE.KeyframeTrack: Out of order keys.",this,i,C,y),e=!1;break}y=C}if(c!==void 0&&oB(c))for(let i=0,C=c.length;i!==C;++i){const D=c[i];if(isNaN(D)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,i,D),e=!1;break}}return e}optimize(){const e=xh(this.times),t=xh(this.values),r=this.getValueSize(),c=this.getInterpolation()===Xx,p=e.length-1;let y=1;for(let i=1;i0){e[y]=e[p];for(let i=p*r,C=y*r,D=0;D!==r;++D)t[C+D]=t[i+D];++y}return y!==e.length?(this.times=xh(e,0,y),this.values=xh(t,0,y*r)):(this.times=e,this.values=t),this}clone(){const e=xh(this.times,0),t=xh(this.values,0),r=this.constructor,c=new r(this.name,e,t);return c.createInterpolant=this.createInterpolant,c}}du.prototype.TimeBufferType=Float32Array;du.prototype.ValueBufferType=Float32Array;du.prototype.DefaultInterpolation=W_;class bf extends du{}bf.prototype.ValueTypeName="bool";bf.prototype.ValueBufferType=Array;bf.prototype.DefaultInterpolation=G_;bf.prototype.InterpolantFactoryMethodLinear=void 0;bf.prototype.InterpolantFactoryMethodSmooth=void 0;class cB extends du{}cB.prototype.ValueTypeName="color";class iy extends du{}iy.prototype.ValueTypeName="number";class fF extends Ey{constructor(e,t,r,c){super(e,t,r,c)}interpolate_(e,t,r,c){const p=this.resultBuffer,y=this.sampleValues,i=this.valueSize,C=(r-t)/(c-t);let D=e*i;for(let U=D+i;D!==U;D+=4)sl.slerpFlat(p,0,y,D-i,y,D,C);return p}}class rg extends du{InterpolantFactoryMethodLinear(e){return new fF(this.times,this.values,this.getValueSize(),e)}}rg.prototype.ValueTypeName="quaternion";rg.prototype.DefaultInterpolation=W_;rg.prototype.InterpolantFactoryMethodSmooth=void 0;class Bf extends du{}Bf.prototype.ValueTypeName="string";Bf.prototype.ValueBufferType=Array;Bf.prototype.DefaultInterpolation=G_;Bf.prototype.InterpolantFactoryMethodLinear=void 0;Bf.prototype.InterpolantFactoryMethodSmooth=void 0;class ny extends du{}ny.prototype.ValueTypeName="vector";class ry{constructor(e,t=-1,r,c=Qv){this.name=e,this.tracks=r,this.duration=t,this.blendMode=c,this.uuid=Pc(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],r=e.tracks,c=1/(e.fps||1);for(let y=0,i=r.length;y!==i;++y)t.push(sQ(r[y]).scale(c));const p=new this(e.name,e.duration,t,e.blendMode);return p.uuid=e.uuid,p}static toJSON(e){const t=[],r=e.tracks,c={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let p=0,y=r.length;p!==y;++p)t.push(du.toJSON(r[p]));return c}static CreateFromMorphTargetSequence(e,t,r,c){const p=t.length,y=[];for(let i=0;i1){const N=U[1];let R=c[N];R||(c[N]=R=[]),R.push(D)}}const y=[];for(const i in c)y.push(this.CreateFromMorphTargetSequence(i,c[i],t,r));return y}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const r=function(N,R,G,J,Y){if(G.length!==0){const B=[],ae=[];aB(G,B,ae,J),B.length!==0&&Y.push(new N(R,B,ae))}},c=[],p=e.name||"default",y=e.fps||30,i=e.blendMode;let C=e.length||-1;const D=e.hierarchy||[];for(let N=0;N{t&&t(p),this.manager.itemEnd(e)},0),p;if(QA[e]!==void 0){QA[e].push({onLoad:t,onProgress:r,onError:c});return}QA[e]=[],QA[e].push({onLoad:t,onProgress:r,onError:c});const y=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),i=this.mimeType,C=this.responseType;fetch(y).then(D=>{if(D.status===200||D.status===0){if(D.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||D.body===void 0||D.body.getReader===void 0)return D;const U=QA[e],N=D.body.getReader(),R=D.headers.get("Content-Length")||D.headers.get("X-File-Size"),G=R?parseInt(R):0,J=G!==0;let Y=0;const B=new ReadableStream({start(ae){le();function le(){N.read().then(({done:Ae,value:we})=>{if(Ae)ae.close();else{Y+=we.byteLength;const me=new ProgressEvent("progress",{lengthComputable:J,loaded:Y,total:G});for(let Pe=0,it=U.length;Pe{switch(C){case"arraybuffer":return D.arrayBuffer();case"blob":return D.blob();case"document":return D.text().then(U=>new DOMParser().parseFromString(U,i));case"json":return D.json();default:if(i===void 0)return D.text();{const N=/charset="?([^;"\s]*)"?/i.exec(i),R=N&&N[1]?N[1].toLowerCase():void 0,G=new TextDecoder(R);return D.arrayBuffer().then(J=>G.decode(J))}}}).then(D=>{vf.add(e,D);const U=QA[e];delete QA[e];for(let N=0,R=U.length;N{const U=QA[e];if(U===void 0)throw this.manager.itemError(e),D;delete QA[e];for(let N=0,R=U.length;N{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class aQ extends Uc{constructor(e){super(e)}load(e,t,r,c){const p=this,y=new XA(this.manager);y.setPath(this.path),y.setRequestHeader(this.requestHeader),y.setWithCredentials(this.withCredentials),y.load(e,function(i){try{t(p.parse(JSON.parse(i)))}catch(C){c?c(C):console.error(C),p.manager.itemError(e)}},r,c)}parse(e){const t=[];for(let r=0;r0:c.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const p in e.uniforms){const y=e.uniforms[p];switch(c.uniforms[p]={},y.type){case"t":c.uniforms[p].value=r(y.value);break;case"c":c.uniforms[p].value=new Dn().setHex(y.value);break;case"v2":c.uniforms[p].value=new Di().fromArray(y.value);break;case"v3":c.uniforms[p].value=new ft().fromArray(y.value);break;case"v4":c.uniforms[p].value=new ls().fromArray(y.value);break;case"m3":c.uniforms[p].value=new Pl().fromArray(y.value);break;case"m4":c.uniforms[p].value=new lr().fromArray(y.value);break;default:c.uniforms[p].value=y.value}}if(e.defines!==void 0&&(c.defines=e.defines),e.vertexShader!==void 0&&(c.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(c.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(c.glslVersion=e.glslVersion),e.extensions!==void 0)for(const p in e.extensions)c.extensions[p]=e.extensions[p];if(e.size!==void 0&&(c.size=e.size),e.sizeAttenuation!==void 0&&(c.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(c.map=r(e.map)),e.matcap!==void 0&&(c.matcap=r(e.matcap)),e.alphaMap!==void 0&&(c.alphaMap=r(e.alphaMap)),e.bumpMap!==void 0&&(c.bumpMap=r(e.bumpMap)),e.bumpScale!==void 0&&(c.bumpScale=e.bumpScale),e.normalMap!==void 0&&(c.normalMap=r(e.normalMap)),e.normalMapType!==void 0&&(c.normalMapType=e.normalMapType),e.normalScale!==void 0){let p=e.normalScale;Array.isArray(p)===!1&&(p=[p,p]),c.normalScale=new Di().fromArray(p)}return e.displacementMap!==void 0&&(c.displacementMap=r(e.displacementMap)),e.displacementScale!==void 0&&(c.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(c.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(c.roughnessMap=r(e.roughnessMap)),e.metalnessMap!==void 0&&(c.metalnessMap=r(e.metalnessMap)),e.emissiveMap!==void 0&&(c.emissiveMap=r(e.emissiveMap)),e.emissiveIntensity!==void 0&&(c.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(c.specularMap=r(e.specularMap)),e.specularIntensityMap!==void 0&&(c.specularIntensityMap=r(e.specularIntensityMap)),e.specularColorMap!==void 0&&(c.specularColorMap=r(e.specularColorMap)),e.envMap!==void 0&&(c.envMap=r(e.envMap)),e.envMapIntensity!==void 0&&(c.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(c.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(c.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(c.lightMap=r(e.lightMap)),e.lightMapIntensity!==void 0&&(c.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(c.aoMap=r(e.aoMap)),e.aoMapIntensity!==void 0&&(c.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(c.gradientMap=r(e.gradientMap)),e.clearcoatMap!==void 0&&(c.clearcoatMap=r(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(c.clearcoatRoughnessMap=r(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(c.clearcoatNormalMap=r(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(c.clearcoatNormalScale=new Di().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(c.iridescenceMap=r(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(c.iridescenceThicknessMap=r(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(c.transmissionMap=r(e.transmissionMap)),e.thicknessMap!==void 0&&(c.thicknessMap=r(e.thicknessMap)),e.sheenColorMap!==void 0&&(c.sheenColorMap=r(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(c.sheenRoughnessMap=r(e.sheenRoughnessMap)),c}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:oF,SpriteMaterial:my,RawShaderMaterial:aF,ShaderMaterial:ko,PointsMaterial:$2,MeshPhysicalMaterial:rB,MeshStandardMaterial:ty,MeshPhongMaterial:sB,MeshToonMaterial:lF,MeshNormalMaterial:cF,MeshLambertMaterial:yv,MeshDepthMaterial:G2,MeshDistanceMaterial:W2,MeshBasicMaterial:na,MeshMatcapMaterial:hF,LineDashedMaterial:uF,LineBasicMaterial:sa,Material:ol};return new t[e]}}class d2{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let r=0,c=e.length;r0){const C=new hB(t);p=new sy(C),p.setCrossOrigin(this.crossOrigin);for(let D=0,U=e.length;D0){c=new sy(this.manager),c.setCrossOrigin(this.crossOrigin);for(let y=0,i=e.length;y"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,r,c){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const p=this,y=vf.get(e);if(y!==void 0)return p.manager.itemStart(e),setTimeout(function(){t&&t(y),p.manager.itemEnd(e)},0),y;const i={};i.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",i.headers=this.requestHeader,fetch(e,i).then(function(C){return C.blob()}).then(function(C){return createImageBitmap(C,Object.assign(p.options,{colorSpaceConversion:"none"}))}).then(function(C){vf.add(e,C),t&&t(C),p.manager.itemEnd(e)}).catch(function(C){c&&c(C),p.manager.itemError(e),p.manager.itemEnd(e)}),p.manager.itemStart(e)}}let Ix;class gB{static getContext(){return Ix===void 0&&(Ix=new(window.AudioContext||window.webkitAudioContext)),Ix}static setContext(e){Ix=e}}class gQ extends Uc{constructor(e){super(e)}load(e,t,r,c){const p=this,y=new XA(this.manager);y.setResponseType("arraybuffer"),y.setPath(this.path),y.setRequestHeader(this.requestHeader),y.setWithCredentials(this.withCredentials),y.load(e,function(i){try{const C=i.slice(0);gB.getContext().decodeAudioData(C,function(U){t(U)})}catch(C){c?c(C):console.error(C),p.manager.itemError(e)}},r,c)}}class _Q extends Jv{constructor(e,t,r=1){super(void 0,r),this.isHemisphereLightProbe=!0;const c=new Dn().set(e),p=new Dn().set(t),y=new ft(c.r,c.g,c.b),i=new ft(p.r,p.g,p.b),C=Math.sqrt(Math.PI),D=C*Math.sqrt(.75);this.sh.coefficients[0].copy(y).add(i).multiplyScalar(C),this.sh.coefficients[1].copy(y).sub(i).multiplyScalar(D)}}class vF extends Jv{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const r=new Dn().set(e);this.sh.coefficients[0].set(r.r,r.g,r.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const QT=new lr,VT=new lr,Hp=new lr;class yQ{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new _a,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new _a,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Hp.copy(e.projectionMatrix);const c=t.eyeSep/2,p=c*t.near/t.focus,y=t.near*Math.tan(pf*t.fov*.5)/t.zoom;let i,C;VT.elements[12]=-c,QT.elements[12]=c,i=-y*t.aspect+p,C=y*t.aspect+p,Hp.elements[0]=2*t.near/(C-i),Hp.elements[8]=(C+i)/(C-i),this.cameraL.projectionMatrix.copy(Hp),i=-y*t.aspect-p,C=y*t.aspect-p,Hp.elements[0]=2*t.near/(C-i),Hp.elements[8]=(C+i)/(C-i),this.cameraR.projectionMatrix.copy(Hp)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(VT),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(QT)}}class t1{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=HT(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=HT();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function HT(){return(typeof performance>"u"?Date:performance).now()}const Gp=new ft,GT=new sl,xQ=new ft,Wp=new ft;class vQ extends cs{constructor(){super(),this.type="AudioListener",this.context=gB.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new t1}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,r=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Gp,GT,xQ),Wp.set(0,0,-1).applyQuaternion(GT),t.positionX){const c=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Gp.x,c),t.positionY.linearRampToValueAtTime(Gp.y,c),t.positionZ.linearRampToValueAtTime(Gp.z,c),t.forwardX.linearRampToValueAtTime(Wp.x,c),t.forwardY.linearRampToValueAtTime(Wp.y,c),t.forwardZ.linearRampToValueAtTime(Wp.z,c),t.upX.linearRampToValueAtTime(r.x,c),t.upY.linearRampToValueAtTime(r.y,c),t.upZ.linearRampToValueAtTime(r.z,c)}else t.setPosition(Gp.x,Gp.y,Gp.z),t.setOrientation(Wp.x,Wp.y,Wp.z,r.x,r.y,r.z)}}class wF extends cs{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(r,c,this._addIndex*t,1,t);for(let C=t,D=t+t;C!==D;++C)if(r[C]!==r[C+t]){i.setValue(r,c);break}}saveOriginalState(){const e=this.binding,t=this.buffer,r=this.valueSize,c=r*this._origIndex;e.getValue(t,c);for(let p=r,y=c;p!==y;++p)t[p]=t[c+p%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let r=e;r=.5)for(let y=0;y!==p;++y)e[t+y]=e[r+y]}_slerp(e,t,r,c){sl.slerpFlat(e,t,e,t,e,r,c)}_slerpAdditive(e,t,r,c,p){const y=this._workIndex*p;sl.multiplyQuaternionsFlat(e,y,e,t,e,r),sl.slerpFlat(e,t,e,t,e,y,c)}_lerp(e,t,r,c,p){const y=1-c;for(let i=0;i!==p;++i){const C=t+i;e[C]=e[C]*y+e[r+i]*c}}_lerpAdditive(e,t,r,c,p){for(let y=0;y!==p;++y){const i=t+y;e[i]=e[i]+e[r+y]*c}}}const _B="\\[\\]\\.:\\/",CQ=new RegExp("["+_B+"]","g"),yB="[^"+_B+"]",EQ="[^"+_B.replace("\\.","")+"]",TQ=/((?:WC+[\/:])*)/.source.replace("WC",yB),SQ=/(WCOD+)?/.source.replace("WCOD",EQ),MQ=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",yB),IQ=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",yB),FQ=new RegExp("^"+TQ+SQ+MQ+IQ+"$"),LQ=["material","materials","bones","map"];class DQ{constructor(e,t,r){const c=r||as.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,c)}getValue(e,t){this.bind();const r=this._targetGroup.nCachedObjects_,c=this._bindings[r];c!==void 0&&c.getValue(e,t)}setValue(e,t){const r=this._bindings;for(let c=this._targetGroup.nCachedObjects_,p=r.length;c!==p;++c)r[c].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}}class as{constructor(e,t,r){this.path=t,this.parsedPath=r||as.parseTrackName(t),this.node=as.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new as.Composite(e,t,r):new as(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(CQ,"")}static parseTrackName(e){const t=FQ.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},c=r.nodeName&&r.nodeName.lastIndexOf(".");if(c!==void 0&&c!==-1){const p=r.nodeName.substring(c+1);LQ.indexOf(p)!==-1&&(r.nodeName=r.nodeName.substring(0,c),r.objectName=p)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const r=e.skeleton.getBoneByName(t);if(r!==void 0)return r}if(e.children){const r=function(p){for(let y=0;y=p){const N=p++,R=e[N];t[R.uuid]=U,e[U]=R,t[D]=N,e[N]=C;for(let G=0,J=c;G!==J;++G){const Y=r[G],B=Y[N],ae=Y[U];Y[U]=B,Y[N]=ae}}}this.nCachedObjects_=p}uncache(){const e=this._objects,t=this._indicesByUUID,r=this._bindings,c=r.length;let p=this.nCachedObjects_,y=e.length;for(let i=0,C=arguments.length;i!==C;++i){const D=arguments[i],U=D.uuid,N=t[U];if(N!==void 0)if(delete t[U],N0&&(t[G.uuid]=N),e[N]=G,e.pop();for(let J=0,Y=c;J!==Y;++J){const B=r[J];B[N]=B[R],B.pop()}}}this.nCachedObjects_=p}subscribe_(e,t){const r=this._bindingsIndicesByPath;let c=r[e];const p=this._bindings;if(c!==void 0)return p[c];const y=this._paths,i=this._parsedPaths,C=this._objects,D=C.length,U=this.nCachedObjects_,N=new Array(D);c=p.length,r[e]=c,y.push(e),i.push(t),p.push(N);for(let R=U,G=C.length;R!==G;++R){const J=C[R];N[R]=new as(J,e,t)}return N}unsubscribe_(e){const t=this._bindingsIndicesByPath,r=t[e];if(r!==void 0){const c=this._paths,p=this._parsedPaths,y=this._bindings,i=y.length-1,C=y[i],D=e[i];t[D]=r,y[r]=C,y.pop(),p[r]=p[i],p.pop(),c[r]=c[i],c.pop()}}}class UQ{constructor(e,t,r=null,c=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=r,this.blendMode=c;const p=t.tracks,y=p.length,i=new Array(y),C={endingStart:of,endingEnd:of};for(let D=0;D!==y;++D){const U=p[D].createInterpolant(null);i[D]=U,U.settings=C}this._interpolantSettings=C,this._interpolants=i,this._propertyBindings=new Array(y),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=CI,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,r){if(e.fadeOut(t),this.fadeIn(t),r){const c=this._clip.duration,p=e._clip.duration,y=p/c,i=c/p;e.warp(1,y,t),this.warp(i,1,t)}return this}crossFadeTo(e,t,r){return e.crossFadeFrom(this,t,r)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,r){const c=this._mixer,p=c.time,y=this.timeScale;let i=this._timeScaleInterpolant;i===null&&(i=c._lendControlInterpolant(),this._timeScaleInterpolant=i);const C=i.parameterPositions,D=i.sampleValues;return C[0]=p,C[1]=p+r,D[0]=e/y,D[1]=t/y,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,r,c){if(!this.enabled){this._updateWeight(e);return}const p=this._startTime;if(p!==null){const C=(e-p)*r;C<0||r===0?t=0:(this._startTime=null,t=r*C)}t*=this._updateTimeScale(e);const y=this._updateTime(t),i=this._updateWeight(e);if(i>0){const C=this._interpolants,D=this._propertyBindings;switch(this.blendMode){case k2:for(let U=0,N=C.length;U!==N;++U)C[U].evaluate(y),D[U].accumulateAdditive(i);break;case Qv:default:for(let U=0,N=C.length;U!==N;++U)C[U].evaluate(y),D[U].accumulate(c,i)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const r=this._weightInterpolant;if(r!==null){const c=r.evaluate(e)[0];t*=c,e>r.parameterPositions[1]&&(this.stopFading(),c===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const r=this._timeScaleInterpolant;if(r!==null){const c=r.evaluate(e)[0];t*=c,e>r.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,r=this.loop;let c=this.time+e,p=this._loopCount;const y=r===EI;if(e===0)return p===-1?c:y&&(p&1)===1?t-c:c;if(r===BI){p===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(c>=t)c=t;else if(c<0)c=0;else{this.time=c;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=c,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(p===-1&&(e>=0?(p=0,this._setEndings(!0,this.repetitions===0,y)):this._setEndings(this.repetitions===0,!0,y)),c>=t||c<0){const i=Math.floor(c/t);c-=t*i,p+=Math.abs(i);const C=this.repetitions-p;if(C<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,c=e>0?t:0,this.time=c,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(C===1){const D=e<0;this._setEndings(D,!D,y)}else this._setEndings(!1,!1,y);this._loopCount=p,this.time=c,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=c;if(y&&(p&1)===1)return t-c}return c}_setEndings(e,t,r){const c=this._interpolantSettings;r?(c.endingStart=af,c.endingEnd=af):(e?c.endingStart=this.zeroSlopeAtStart?af:of:c.endingStart=j_,t?c.endingEnd=this.zeroSlopeAtEnd?af:of:c.endingEnd=j_)}_scheduleFading(e,t,r){const c=this._mixer,p=c.time;let y=this._weightInterpolant;y===null&&(y=c._lendControlInterpolant(),this._weightInterpolant=y);const i=y.parameterPositions,C=y.sampleValues;return i[0]=p,C[0]=t,i[1]=p+e,C[1]=r,this}}const RQ=new Float32Array(1);class zQ extends Xu{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const r=e._localRoot||this._root,c=e._clip.tracks,p=c.length,y=e._propertyBindings,i=e._interpolants,C=r.uuid,D=this._bindingsByRootAndName;let U=D[C];U===void 0&&(U={},D[C]=U);for(let N=0;N!==p;++N){const R=c[N],G=R.name;let J=U[G];if(J!==void 0)++J.referenceCount,y[N]=J;else{if(J=y[N],J!==void 0){J._cacheIndex===null&&(++J.referenceCount,this._addInactiveBinding(J,C,G));continue}const Y=t&&t._propertyBindings[N].binding.parsedPath;J=new bF(as.create(r,G,Y),R.ValueTypeName,R.getValueSize()),++J.referenceCount,this._addInactiveBinding(J,C,G),y[N]=J}i[N].resultBuffer=J.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const r=(e._localRoot||this._root).uuid,c=e._clip.uuid,p=this._actionsByClip[c];this._bindAction(e,p&&p.knownActions[0]),this._addInactiveAction(e,c,r)}const t=e._propertyBindings;for(let r=0,c=t.length;r!==c;++r){const p=t[r];p.useCount++===0&&(this._lendBinding(p),p.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let r=0,c=t.length;r!==c;++r){const p=t[r];--p.useCount===0&&(p.restoreOriginalState(),this._takeBackBinding(p))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--r)e[r].stop();return this}update(e){e*=this.timeScale;const t=this._actions,r=this._nActiveActions,c=this.time+=e,p=Math.sign(e),y=this._accuIndex^=1;for(let D=0;D!==r;++D)t[D]._update(c,e,p,y);const i=this._bindings,C=this._nActiveBindings;for(let D=0;D!==C;++D)i[D].apply(y);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return KT.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const $T=new ft,Fx=new ft;class BF{constructor(e=new ft,t=new ft){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){$T.subVectors(e,this.start),Fx.subVectors(this.end,this.start);const r=Fx.dot(Fx);let p=Fx.dot($T)/r;return t&&(p=Eo(p,0,1)),p}closestPointToPoint(e,t,r){const c=this.closestPointToPointParameter(e,t);return this.delta(r).multiplyScalar(c).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const ZT=new ft;class HQ extends cs{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const r=new br,c=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let y=0,i=1,C=32;y1)for(let N=0;N.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{eS.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(eS,t)}}setLength(e,t=e*.2,r=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(r,t,r),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class IF extends Yu{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],c=new br;c.setAttribute("position",new jn(t,3)),c.setAttribute("color",new jn(r,3));const p=new sa({vertexColors:!0,toneMapped:!1});super(c,p),this.type="AxesHelper"}setColors(e,t,r){const c=new Dn,p=this.geometry.attributes.color.array;return c.set(e),c.toArray(p,0),c.toArray(p,3),c.set(t),c.toArray(p,6),c.toArray(p,9),c.set(r),c.toArray(p,12),c.toArray(p,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class qQ{constructor(){this.type="ShapePath",this.color=new Dn,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new q_,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,r,c){return this.currentPath.quadraticCurveTo(e,t,r,c),this}bezierCurveTo(e,t,r,c,p,y){return this.currentPath.bezierCurveTo(e,t,r,c,p,y),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(ae){const le=[];for(let Ae=0,we=ae.length;AeNumber.EPSILON){if(Et<0&&(it=le[Pe],Ke=-Ke,Me=le[me],Et=-Et),ae.yMe.y)continue;if(ae.y===it.y){if(ae.x===it.x)return!0}else{const oi=Et*(ae.x-it.x)-Ke*(ae.y-it.y);if(oi===0)return!0;if(oi<0)continue;we=!we}}else{if(ae.y!==it.y)continue;if(Me.x<=ae.x&&ae.x<=it.x||it.x<=ae.x&&ae.x<=Me.x)return!0}}return we}const c=Hu.isClockWise,p=this.subPaths;if(p.length===0)return[];let y,i,C;const D=[];if(p.length===1)return i=p[0],C=new np,C.curves=i.curves,D.push(C),D;let U=!c(p[0].getPoints());U=e?!U:U;const N=[],R=[];let G=[],J=0,Y;R[J]=void 0,G[J]=[];for(let ae=0,le=p.length;ae1){let ae=!1,le=0;for(let Ae=0,we=R.length;Ae0&&ae===!1&&(G=N)}let B;for(let ae=0,le=R.length;ae>-D-14,r[C|256]=1024>>-D-14|32768,c[C]=-D-1,c[C|256]=-D-1):D<=15?(r[C]=D+15<<10,r[C|256]=D+15<<10|32768,c[C]=13,c[C|256]=13):D<128?(r[C]=31744,r[C|256]=64512,c[C]=24,c[C|256]=24):(r[C]=31744,r[C|256]=64512,c[C]=13,c[C|256]=13)}const p=new Uint32Array(2048),y=new Uint32Array(64),i=new Uint32Array(64);for(let C=1;C<1024;++C){let D=C<<13,U=0;for(;(D&8388608)===0;)D<<=1,U-=8388608;D&=-8388609,U+=947912704,p[C]=D|U}for(let C=1024;C<2048;++C)p[C]=939524096+(C-1024<<13);for(let C=1;C<31;++C)y[C]=C<<23;y[31]=1199570944,y[32]=2147483648;for(let C=33;C<63;++C)y[C]=2147483648+(C-32<<23);y[63]=3347054592;for(let C=1;C<64;++C)C!==32&&(i[C]=1024);return{floatView:e,uint32View:t,baseTable:r,shiftTable:c,mantissaTable:p,exponentTable:y,offsetTable:i}}function JQ(u){Math.abs(u)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),u=Eo(u,-65504,65504),VA.floatView[0]=u;const e=VA.uint32View[0],t=e>>23&511;return VA.baseTable[t]+((e&8388607)>>VA.shiftTable[t])}function eV(u){const e=u>>10;return VA.uint32View[0]=VA.mantissaTable[VA.offsetTable[e]+(u&1023)]+VA.exponentTable[e],VA.floatView[0]}var tV=Object.freeze({__proto__:null,toHalfFloat:JQ,fromHalfFloat:eV});function iV(){console.error("THREE.ImmediateRenderObject has been removed.")}class nV extends Oa{constructor(e,t,r){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,r),this.samples=4}}class rV extends uy{constructor(e,t,r,c){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,r,c)}}class sV extends Vv{constructor(e,t,r,c){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,t,r,c)}}class oV extends YA{constructor(e,t,r,c,p,y){console.warn("THREE.BoxBufferGeometry has been renamed to THREE.BoxGeometry."),super(e,t,r,c,p,y)}}class aV extends gy{constructor(e,t,r,c){console.warn("THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry."),super(e,t,r,c)}}class lV extends _y{constructor(e,t,r,c){console.warn("THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry."),super(e,t,r,c)}}class cV extends yf{constructor(e,t,r,c,p,y,i){console.warn("THREE.ConeBufferGeometry has been renamed to THREE.ConeGeometry."),super(e,t,r,c,p,y,i)}}class hV extends wf{constructor(e,t,r,c,p,y,i,C){console.warn("THREE.CylinderBufferGeometry has been renamed to THREE.CylinderGeometry."),super(e,t,r,c,p,y,i,C)}}class uV extends yy{constructor(e,t){console.warn("THREE.DodecahedronBufferGeometry has been renamed to THREE.DodecahedronGeometry."),super(e,t)}}class AV extends xy{constructor(e,t){console.warn("THREE.ExtrudeBufferGeometry has been renamed to THREE.ExtrudeGeometry."),super(e,t)}}class dV extends vy{constructor(e,t){console.warn("THREE.IcosahedronBufferGeometry has been renamed to THREE.IcosahedronGeometry."),super(e,t)}}class pV extends eg{constructor(e,t,r,c){console.warn("THREE.LatheBufferGeometry has been renamed to THREE.LatheGeometry."),super(e,t,r,c)}}class fV extends tg{constructor(e,t){console.warn("THREE.OctahedronBufferGeometry has been renamed to THREE.OctahedronGeometry."),super(e,t)}}class FF extends $A{constructor(e,t,r,c){console.warn("THREE.PlaneBufferGeometry has been renamed to THREE.PlaneGeometry."),super(e,t,r,c)}}class mV extends JA{constructor(e,t,r,c){console.warn("THREE.PolyhedronBufferGeometry has been renamed to THREE.PolyhedronGeometry."),super(e,t,r,c)}}class gV extends wy{constructor(e,t,r,c,p,y){console.warn("THREE.RingBufferGeometry has been renamed to THREE.RingGeometry."),super(e,t,r,c,p,y)}}class _V extends ig{constructor(e,t){console.warn("THREE.ShapeBufferGeometry has been renamed to THREE.ShapeGeometry."),super(e,t)}}class yV extends Qu{constructor(e,t,r,c,p,y,i){console.warn("THREE.SphereBufferGeometry has been renamed to THREE.SphereGeometry."),super(e,t,r,c,p,y,i)}}class xV extends by{constructor(e,t){console.warn("THREE.TetrahedronBufferGeometry has been renamed to THREE.TetrahedronGeometry."),super(e,t)}}class vV extends By{constructor(e,t,r,c,p){console.warn("THREE.TorusBufferGeometry has been renamed to THREE.TorusGeometry."),super(e,t,r,c,p)}}class wV extends Cy{constructor(e,t,r,c,p,y){console.warn("THREE.TorusKnotBufferGeometry has been renamed to THREE.TorusKnotGeometry."),super(e,t,r,c,p,y)}}class bV extends ng{constructor(e,t,r,c,p){console.warn("THREE.TubeBufferGeometry has been renamed to THREE.TubeGeometry."),super(e,t,r,c,p)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ov}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ov);const LF=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:aI,AddEquation:Jp,AddOperation:rI,AdditiveAnimationBlendMode:k2,AdditiveBlending:uv,AlphaFormat:pI,AlwaysDepth:qM,AlwaysStencilFunc:II,AmbientLight:fB,AmbientLightProbe:vF,AnimationClip:ry,AnimationLoader:aQ,AnimationMixer:zQ,AnimationObjectGroup:PQ,AnimationUtils:nQ,ArcCurve:YI,ArrayCamera:GI,ArrowHelper:MF,Audio:wF,AudioAnalyser:BQ,AudioContext:gB,AudioListener:vQ,AudioLoader:gQ,AxesHelper:IF,BackSide:Dc,BasicDepthPacking:TI,BasicShadowMap:FR,Bone:K2,BooleanKeyframeTrack:bf,Box2:VQ,Box3:qu,Box3Helper:ZQ,BoxBufferGeometry:oV,BoxGeometry:YA,BoxHelper:g2,BufferAttribute:ds,BufferGeometry:br,BufferGeometryLoader:xF,ByteType:cI,Cache:vf,Camera:Hv,CameraHelper:SF,CanvasTexture:qI,CapsuleBufferGeometry:aV,CapsuleGeometry:gy,CatmullRomCurve3:X_,CineonToneMapping:oI,CircleBufferGeometry:lV,CircleGeometry:_y,ClampToEdgeWrapping:rl,Clock:t1,Color:Dn,ColorKeyframeTrack:cB,ColorManagement:tl,CompressedArrayTexture:TN,CompressedTexture:X2,CompressedTextureLoader:lQ,ConeBufferGeometry:cV,ConeGeometry:yf,CubeCamera:RI,CubeReflectionMapping:op,CubeRefractionMapping:ap,CubeTexture:py,CubeTextureLoader:cQ,CubeUVReflectionMapping:qm,CubicBezierCurve:Y2,CubicBezierCurve3:JI,CubicInterpolant:dF,CullFaceBack:Db,CullFaceFront:RM,CullFaceFrontBack:IR,CullFaceNone:UM,Curve:Au,CurvePath:tF,CustomBlending:kM,CustomToneMapping:lI,CylinderBufferGeometry:hV,CylinderGeometry:wf,Cylindrical:QQ,Data3DTexture:Vv,DataArrayTexture:uy,DataTexture:Qm,DataTexture2DArray:rV,DataTexture3D:sV,DataTextureLoader:hQ,DataUtils:tV,DecrementStencilOp:HR,DecrementWrapStencilOp:WR,DefaultLoadingManager:mF,DepthFormat:ip,DepthStencilFormat:gf,DepthTexture:WI,DirectionalLight:pB,DirectionalLightHelper:TF,DiscreteInterpolant:pF,DodecahedronBufferGeometry:uV,DodecahedronGeometry:yy,DoubleSide:Il,DstAlphaFactor:WM,DstColorFactor:KM,DynamicCopyUsage:oz,DynamicDrawUsage:ez,DynamicReadUsage:nz,EdgesGeometry:iF,EllipseCurve:Xv,EqualDepth:JM,EqualStencilFunc:ZR,EquirectangularReflectionMapping:Q_,EquirectangularRefractionMapping:V_,Euler:Ym,EventDispatcher:Xu,ExtrudeBufferGeometry:AV,ExtrudeGeometry:xy,FileLoader:XA,Float16BufferAttribute:Nz,Float32BufferAttribute:jn,Float64BufferAttribute:Qz,FloatType:GA,Fog:Kv,FogExp2:jv,FramebufferTexture:EN,FrontSide:ju,Frustum:Gv,GLBufferAttribute:NQ,GLSL1:lz,GLSL3:s2,GreaterDepth:tI,GreaterEqualDepth:eI,GreaterEqualStencilFunc:JR,GreaterStencilFunc:qR,GridHelper:KQ,Group:As,HalfFloatType:Gm,HemisphereLight:uB,HemisphereLightHelper:EF,HemisphereLightProbe:_Q,IcosahedronBufferGeometry:dV,IcosahedronGeometry:vy,ImageBitmapLoader:mQ,ImageLoader:sy,ImageUtils:N2,ImmediateRenderObject:iV,IncrementStencilOp:VR,IncrementWrapStencilOp:GR,InstancedBufferAttribute:Km,InstancedBufferGeometry:mB,InstancedInterleavedBuffer:xv,InstancedMesh:XI,Int16BufferAttribute:kz,Int32BufferAttribute:Oz,Int8BufferAttribute:Uz,IntType:uI,InterleavedBuffer:$v,InterleavedBufferAttribute:Lc,Interpolant:Ey,InterpolateDiscrete:G_,InterpolateLinear:W_,InterpolateSmooth:Xx,InvertStencilOp:jR,KeepStencilOp:qx,KeyframeTrack:du,LOD:$I,LatheBufferGeometry:pV,LatheGeometry:eg,Layers:dy,LessDepth:YM,LessEqualDepth:Av,LessEqualStencilFunc:XR,LessStencilFunc:$R,Light:Ap,LightProbe:Jv,Line:Ku,Line3:BF,LineBasicMaterial:sa,LineCurve:qv,LineCurve3:eF,LineDashedMaterial:uF,LineLoop:_v,LineSegments:Yu,LinearEncoding:hp,LinearFilter:Xs,LinearInterpolant:lB,LinearMipMapLinearFilter:UR,LinearMipMapNearestFilter:PR,LinearMipmapLinearFilter:lp,LinearMipmapNearestFilter:R2,LinearSRGBColorSpace:Wm,LinearToneMapping:U2,Loader:Uc,LoaderUtils:d2,LoadingManager:hB,LoopOnce:BI,LoopPingPong:EI,LoopRepeat:CI,LuminanceAlphaFormat:gI,LuminanceFormat:mI,MOUSE:$p,Material:ol,MaterialLoader:e1,MathUtils:LI,Matrix3:Pl,Matrix4:lr,MaxEquation:zb,Mesh:is,MeshBasicMaterial:na,MeshDepthMaterial:G2,MeshDistanceMaterial:W2,MeshLambertMaterial:yv,MeshMatcapMaterial:hF,MeshNormalMaterial:cF,MeshPhongMaterial:sB,MeshPhysicalMaterial:rB,MeshStandardMaterial:ty,MeshToonMaterial:lF,MinEquation:Rb,MirroredRepeatWrapping:H_,MixOperation:nI,MultiplyBlending:Ub,MultiplyOperation:hy,NearestFilter:Co,NearestMipMapLinearFilter:DR,NearestMipMapNearestFilter:LR,NearestMipmapLinearFilter:F_,NearestMipmapNearestFilter:dv,NeverDepth:XM,NeverStencilFunc:KR,NoBlending:KA,NoColorSpace:OR,NoToneMapping:Vu,NormalAnimationBlendMode:Qv,NormalBlending:Af,NotEqualDepth:iI,NotEqualStencilFunc:YR,NumberKeyframeTrack:iy,Object3D:cs,ObjectLoader:pQ,ObjectSpaceNormalMap:MI,OctahedronBufferGeometry:fV,OctahedronGeometry:tg,OneFactor:VM,OneMinusDstAlphaFactor:jM,OneMinusDstColorFactor:$M,OneMinusSrcAlphaFactor:P2,OneMinusSrcColorFactor:GM,OrthographicCamera:fy,PCFShadowMap:L2,PCFSoftShadowMap:zM,PMREMGenerator:a2,Path:q_,PerspectiveCamera:_a,Plane:$d,PlaneBufferGeometry:FF,PlaneGeometry:$A,PlaneHelper:XQ,PointLight:dB,PointLightHelper:WQ,Points:Z2,PointsMaterial:$2,PolarGridHelper:$Q,PolyhedronBufferGeometry:mV,PolyhedronGeometry:JA,PositionalAudio:bQ,PropertyBinding:as,PropertyMixer:bF,QuadraticBezierCurve:J2,QuadraticBezierCurve3:eB,Quaternion:sl,QuaternionKeyframeTrack:rg,QuaternionLinearInterpolant:fF,REVISION:Ov,RGBADepthPacking:SI,RGBAFormat:Dl,RGBAIntegerFormat:wI,RGBA_ASTC_10x10_Format:t2,RGBA_ASTC_10x5_Format:Yb,RGBA_ASTC_10x6_Format:Jb,RGBA_ASTC_10x8_Format:e2,RGBA_ASTC_12x10_Format:i2,RGBA_ASTC_12x12_Format:n2,RGBA_ASTC_4x4_Format:Gb,RGBA_ASTC_5x4_Format:Wb,RGBA_ASTC_5x5_Format:jb,RGBA_ASTC_6x5_Format:Kb,RGBA_ASTC_6x6_Format:$b,RGBA_ASTC_8x5_Format:Zb,RGBA_ASTC_8x6_Format:Xb,RGBA_ASTC_8x8_Format:qb,RGBA_BPTC_Format:r2,RGBA_ETC2_EAC_Format:Hb,RGBA_PVRTC_2BPPV1_Format:Qb,RGBA_PVRTC_4BPPV1_Format:Nb,RGBA_S3TC_DXT1_Format:Kx,RGBA_S3TC_DXT3_Format:$x,RGBA_S3TC_DXT5_Format:Zx,RGBFormat:fI,RGB_ETC1_Format:bI,RGB_ETC2_Format:Vb,RGB_PVRTC_2BPPV1_Format:Ob,RGB_PVRTC_4BPPV1_Format:kb,RGB_S3TC_DXT1_Format:jx,RGFormat:xI,RGIntegerFormat:vI,RawShaderMaterial:aF,Ray:Ay,Raycaster:p2,RectAreaLight:_F,RedFormat:_I,RedIntegerFormat:yI,ReinhardToneMapping:sI,RepeatWrapping:HA,ReplaceStencilOp:QR,ReverseSubtractEquation:NM,RingBufferGeometry:gV,RingGeometry:wy,SRGBColorSpace:cu,Scene:j2,ShaderChunk:zr,ShaderLib:Fl,ShaderMaterial:ko,ShadowMaterial:oF,Shape:np,ShapeBufferGeometry:_V,ShapeGeometry:ig,ShapePath:qQ,ShapeUtils:Hu,ShortType:hI,Skeleton:Zv,SkeletonHelper:GQ,SkinnedMesh:ZI,Source:lf,Sphere:qA,SphereBufferGeometry:yV,SphereGeometry:Qu,Spherical:m2,SphericalHarmonics3:yF,SplineCurve:tB,SpotLight:gF,SpotLightHelper:HQ,Sprite:gv,SpriteMaterial:my,SrcAlphaFactor:D2,SrcAlphaSaturateFactor:ZM,SrcColorFactor:HM,StaticCopyUsage:sz,StaticDrawUsage:K_,StaticReadUsage:iz,StereoCamera:yQ,StreamCopyUsage:az,StreamDrawUsage:tz,StreamReadUsage:rz,StringKeyframeTrack:Bf,SubtractEquation:OM,SubtractiveBlending:Pb,TOUCH:Zp,TangentSpaceNormalMap:up,TetrahedronBufferGeometry:xV,TetrahedronGeometry:by,Texture:To,TextureLoader:jd,TorusBufferGeometry:vV,TorusGeometry:By,TorusKnotBufferGeometry:wV,TorusKnotGeometry:Cy,Triangle:wh,TriangleFanDrawMode:kR,TriangleStripDrawMode:zR,TrianglesDrawMode:RR,TubeBufferGeometry:bV,TubeGeometry:ng,TwoPassDoubleSide:w_,UVMapping:Nv,Uint16BufferAttribute:Q2,Uint32BufferAttribute:V2,Uint8BufferAttribute:Rz,Uint8ClampedBufferAttribute:zz,Uniform:xB,UniformsGroup:OQ,UniformsLib:En,UniformsUtils:_f,UnsignedByteType:cp,UnsignedInt248Type:df,UnsignedIntType:Yd,UnsignedShort4444Type:AI,UnsignedShort5551Type:dI,UnsignedShortType:z2,VSMShadowMap:Dm,Vector2:Di,Vector3:ft,Vector4:ls,VectorKeyframeTrack:ny,VideoTexture:CN,WebGL1Renderer:jI,WebGL3DRenderTarget:Cz,WebGLArrayRenderTarget:Bz,WebGLCubeRenderTarget:zI,WebGLMultipleRenderTargets:Ez,WebGLMultisampleRenderTarget:nV,WebGLRenderTarget:Oa,WebGLRenderer:mv,WebGLUtils:HI,WireframeGeometry:nB,WrapAroundEnding:j_,ZeroCurvatureEnding:of,ZeroFactor:QM,ZeroSlopeEnding:af,ZeroStencilOp:NR,_SRGBAFormat:pv,sRGBEncoding:Ss},Symbol.toStringTag,{value:"Module"}));var DF={exports:{}};(function(u,e){(function({},t){u.exports=t()})(TS,function(){var t,r,c;function p(i,C){if(!t)t=C;else if(!r)r=C;else{var D="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 = {}; ("+t+")(sharedChunk); ("+r+")(sharedChunk); self.onerror = null;",U={};t(U),c=C(U),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(c.workerUrl=window.URL.createObjectURL(new Blob([D],{type:"text/javascript"})))}}p(["exports"],function(i){var C=typeof self<"u"?self:{},D="2.12.0";let U;const N={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(U==null){const s=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{U={}.API_URL_REGEX!=null?new RegExp({}.API_URL_REGEX):s}catch{U=s}}return U},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(){return this.API_URL?this.API_URL.indexOf("https://api.mapbox.cn")===0?"https://events.mapbox.cn/events/v2":this.API_URL.indexOf("https://api.mapbox.com")===0?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},R={supported:!1,testSupport:function(s){!Y&&J&&(B?ae(s):G=s)}};let G,J,Y=!1,B=!1;function ae(s){const n=s.createTexture();s.bindTexture(s.TEXTURE_2D,n);try{if(s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,J),s.isContextLost())return;R.supported=!0}catch{}s.deleteTexture(n),Y=!0}C.document&&(J=C.document.createElement("img"),J.onload=function(){G&&ae(G),G=null,B=!0},J.onerror=function(){Y=!0,G=null},J.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const le="01";var Ae=we;function we(s,n,o,d){this.cx=3*s,this.bx=3*(o-s)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*n,this.by=3*(d-n)-this.cy,this.ay=1-this.cy-this.by,this.p1x=s,this.p1y=n,this.p2x=o,this.p2y=d}we.prototype={sampleCurveX:function(s){return((this.ax*s+this.bx)*s+this.cx)*s},sampleCurveY:function(s){return((this.ay*s+this.by)*s+this.cy)*s},sampleCurveDerivativeX:function(s){return(3*this.ax*s+2*this.bx)*s+this.cx},solveCurveX:function(s,n){if(n===void 0&&(n=1e-6),s<0)return 0;if(s>1)return 1;for(var o=s,d=0;d<8;d++){var g=this.sampleCurveX(o)-s;if(Math.abs(g)g?E=o:L=o,o=.5*(L-E)+E;return o},solve:function(s,n){return this.sampleCurveY(this.solveCurveX(s,n))}};var me=Pe;function Pe(s,n){this.x=s,this.y=n}Pe.prototype={clone:function(){return new Pe(this.x,this.y)},add:function(s){return this.clone()._add(s)},sub:function(s){return this.clone()._sub(s)},multByPoint:function(s){return this.clone()._multByPoint(s)},divByPoint:function(s){return this.clone()._divByPoint(s)},mult:function(s){return this.clone()._mult(s)},div:function(s){return this.clone()._div(s)},rotate:function(s){return this.clone()._rotate(s)},rotateAround:function(s,n){return this.clone()._rotateAround(s,n)},matMult:function(s){return this.clone()._matMult(s)},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(s){return this.x===s.x&&this.y===s.y},dist:function(s){return Math.sqrt(this.distSqr(s))},distSqr:function(s){var n=s.x-this.x,o=s.y-this.y;return n*n+o*o},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(s){return Math.atan2(this.y-s.y,this.x-s.x)},angleWith:function(s){return this.angleWithSep(s.x,s.y)},angleWithSep:function(s,n){return Math.atan2(this.x*n-this.y*s,this.x*s+this.y*n)},_matMult:function(s){var n=s[2]*this.x+s[3]*this.y;return this.x=s[0]*this.x+s[1]*this.y,this.y=n,this},_add:function(s){return this.x+=s.x,this.y+=s.y,this},_sub:function(s){return this.x-=s.x,this.y-=s.y,this},_mult:function(s){return this.x*=s,this.y*=s,this},_div:function(s){return this.x/=s,this.y/=s,this},_multByPoint:function(s){return this.x*=s.x,this.y*=s.y,this},_divByPoint:function(s){return this.x/=s.x,this.y/=s.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var s=this.y;return this.y=this.x,this.x=-s,this},_rotate:function(s){var n=Math.cos(s),o=Math.sin(s),d=o*this.x+n*this.y;return this.x=n*this.x-o*this.y,this.y=d,this},_rotateAround:function(s,n){var o=Math.cos(s),d=Math.sin(s),g=n.y+d*(this.x-n.x)+o*(this.y-n.y);return this.x=n.x+o*(this.x-n.x)-d*(this.y-n.y),this.y=g,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Pe.convert=function(s){return s instanceof Pe?s:Array.isArray(s)?new Pe(s[0],s[1]):s};const it=Math.PI/180,Me=180/Math.PI;function Ke(s){return s*it}function Et(s){return s*Me}const oi=[[0,0],[1,0],[1,1],[0,1]];function Ci(s){if(s<=0)return 0;if(s>=1)return 1;const n=s*s,o=n*s;return 4*(s<.5?o:3*(s-n)+o-.75)}function te(s,n,o,d){const g=new Ae(s,n,o,d);return function(v){return g.solve(v)}}const ce=te(.25,.1,.25,1);function ye(s,n,o){return Math.min(o,Math.max(n,s))}function xe(s,n,o){return(o=ye((o-s)/(n-s),0,1))*o*(3-2*o)}function ze(s,n,o){const d=o-n,g=((s-n)%d+d)%d+n;return g===n?o:g}function Ne(s,n,o){if(!s.length)return o(null,[]);let d=s.length;const g=new Array(s.length);let v=null;s.forEach((E,L)=>{n(E,(k,V)=>{k&&(v=k),g[L]=V,--d==0&&o(v,g)})})}function Ge(s){const n=[];for(const o in s)n.push(s[o]);return n}function Ve(s,...n){for(const o of n)for(const d in o)s[d]=o[d];return s}let Le=1;function Ie(){return Le++}function qe(){return function s(n){return n?(n^Math.random()*(16>>n/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,s)}()}function et(s){return s<=1?1:Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function vt(s){return!!s&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(s)}function Be(s,n){s.forEach(o=>{n[o]&&(n[o]=n[o].bind(n))})}function dt(s,n){return s.indexOf(n,s.length-n.length)!==-1}function ut(s,n,o){const d={};for(const g in s)d[g]=n.call(o||this,s[g],g,s);return d}function Qt(s,n,o){const d={};for(const g in s)n.call(o||this,s[g],g,s)&&(d[g]=s[g]);return d}function Wt(s){return Array.isArray(s)?s.map(Wt):typeof s=="object"&&s?ut(s,Wt):s}const Nt={};function Ct(s){Nt[s]||(typeof console<"u"&&console.warn(s),Nt[s]=!0)}function Ft(s,n,o){return(o.y-s.y)*(n.x-s.x)>(n.y-s.y)*(o.x-s.x)}function Xt(s){let n=0;for(let o,d,g=0,v=s.length,E=v-1;g@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(o,d,g,v)=>{const E=g||v;return n[d]=!E||E.toLowerCase(),""}),n["max-age"]){const o=parseInt(n["max-age"],10);isNaN(o)?delete n["max-age"]:n["max-age"]=o}return n}let Gi=null;function wn(s){if(Gi==null){const n=s.navigator?s.navigator.userAgent:null;Gi=!!s.safari||!(!n||!(/\b(iPad|iPhone|iPod)\b/.test(n)||n.match("Safari")&&!n.match("Chrome")))}return Gi}function Qi(s){try{const n=C[s];return n.setItem("_mapbox_test_",1),n.removeItem("_mapbox_test_"),!0}catch{return!1}}function Gn(s,n){return[s[4*n],s[4*n+1],s[4*n+2],s[4*n+3]]}const kn="mapbox-tiles";let yt,st,ti=500,Ni=50;function qi(){try{return C.caches}catch{}}function en(){qi()&&!yt&&(yt=C.caches.open(kn))}function $t(s){const n=s.indexOf("?");if(n<0)return s;const o=function(g){const v=g.indexOf("?");return v>0?g.slice(v+1).split("&"):[]}(s),d=o.filter(g=>{const v=g.split("=");return v[0]==="language"||v[0]==="worldview"});return d.length?`${s.slice(0,n)}?${d.join("&")}`:s.slice(0,n)}let at=1/0;const ii={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(ii);class hn extends Error{constructor(n,o,d){o===401&&Ui(d)&&(n+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(n),this.status=o,this.url=d}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Xi=mi()?()=>self.worker&&self.worker.referrer:()=>(C.location.protocol==="blob:"?C.parent:C).location.href,on=function(s,n){if(!(/^file:/.test(o=s.url)||/^file:/.test(Xi())&&!/^\w+:/.test(o))){if(C.fetch&&C.Request&&C.AbortController&&C.Request.prototype.hasOwnProperty("signal"))return function(d,g){const v=new C.AbortController,E=new C.Request(d.url,{method:d.method||"GET",body:d.body,credentials:d.credentials,headers:d.headers,referrer:Xi(),signal:v.signal});let L=!1,k=!1;const V=(q=E.url).indexOf("sku=")>0&&Ui(q);var q;d.type==="json"&&E.headers.set("Accept","application/json");const se=(_e,be,De)=>{if(k)return;if(_e&&_e.message!=="SecurityError"&&Ct(_e),be&&De)return he(be);const Ze=Date.now();C.fetch(E).then(xt=>{if(xt.ok){const Dt=V?xt.clone():null;return he(xt,Dt,Ze)}return g(new hn(xt.statusText,xt.status,d.url))}).catch(xt=>{xt.code!==20&&g(new Error(xt.message))})},he=(_e,be,De)=>{(d.type==="arrayBuffer"?_e.arrayBuffer():d.type==="json"?_e.json():_e.text()).then(Ze=>{k||(be&&De&&function(xt,Dt,_t){if(en(),!yt)return;const Tt={status:Dt.status,statusText:Dt.statusText,headers:new C.Headers};Dt.headers.forEach((ci,ai)=>Tt.headers.set(ai,ci));const kt=fi(Dt.headers.get("Cache-Control")||"");if(kt["no-store"])return;kt["max-age"]&&Tt.headers.set("Expires",new Date(_t+1e3*kt["max-age"]).toUTCString());const Ut=Tt.headers.get("Expires");Ut&&(new Date(Ut).getTime()-_t<42e4||function(ci,ai){if(st===void 0)try{new Response(new ReadableStream),st=!0}catch{st=!1}st?ai(ci.body):ci.blob().then(ai)}(Dt,ci=>{const ai=new C.Response(ci,Tt);en(),yt&&yt.then(Ti=>Ti.put($t(xt.url),ai)).catch(Ti=>Ct(Ti.message))}))}(E,be,De),L=!0,g(null,Ze,_e.headers.get("Cache-Control"),_e.headers.get("Expires")))}).catch(Ze=>{k||g(new Error(Ze.message))})};return V?function(_e,be){if(en(),!yt)return be(null);const De=$t(_e.url);yt.then(Ze=>{Ze.match(De).then(xt=>{const Dt=function(_t){if(!_t)return!1;const Tt=new Date(_t.headers.get("Expires")||0),kt=fi(_t.headers.get("Cache-Control")||"");return Tt>Date.now()&&!kt["no-cache"]}(xt);Ze.delete(De),Dt&&Ze.put(De,xt.clone()),be(null,xt,Dt)}).catch(be)}).catch(be)}(E,se):se(null,null),{cancel:()=>{k=!0,L||v.abort()}}}(s,n);if(mi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",s,n,void 0,!0)}var o;return function(d,g){const v=new C.XMLHttpRequest;v.open(d.method||"GET",d.url,!0),d.type==="arrayBuffer"&&(v.responseType="arraybuffer");for(const E in d.headers)v.setRequestHeader(E,d.headers[E]);return d.type==="json"&&(v.responseType="text",v.setRequestHeader("Accept","application/json")),v.withCredentials=d.credentials==="include",v.onerror=()=>{g(new Error(v.statusText))},v.onload=()=>{if((v.status>=200&&v.status<300||v.status===0)&&v.response!==null){let E=v.response;if(d.type==="json")try{E=JSON.parse(v.response)}catch(L){return g(L)}g(null,E,v.getResponseHeader("Cache-Control"),v.getResponseHeader("Expires"))}else g(new hn(v.statusText,v.status,d.url))},v.send(d.body),{cancel:()=>v.abort()}}(s,n)},Cn=function(s,n){return on(Ve(s,{type:"arrayBuffer"}),n)};function Tn(s){const n=C.document.createElement("a");return n.href=s,n.protocol===C.document.location.protocol&&n.host===C.document.location.host}const nr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Ii,bn;Ii=[],bn=0;const Ot=function(s,n){if(R.supported&&(s.headers||(s.headers={}),s.headers.accept="image/webp,*/*"),bn>=N.MAX_PARALLEL_IMAGE_REQUESTS){const v={requestParameters:s,callback:n,cancelled:!1,cancel(){this.cancelled=!0}};return Ii.push(v),v}bn++;let o=!1;const d=()=>{if(!o)for(o=!0,bn--;Ii.length&&bn{d(),v?n(v):E&&(C.createImageBitmap?function(V,q){const se=new C.Blob([new Uint8Array(V)],{type:"image/png"});C.createImageBitmap(se).then(he=>{q(null,he)}).catch(he=>{q(new Error(`Could not load image because of ${he.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(E,(V,q)=>n(V,q,L,k)):function(V,q){const se=new C.Image,he=C.URL;se.onload=()=>{q(null,se),he.revokeObjectURL(se.src),se.onload=null,C.requestAnimationFrame(()=>{se.src=nr})},se.onerror=()=>q(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 _e=new C.Blob([new Uint8Array(V)],{type:"image/png"});se.src=V.byteLength?he.createObjectURL(_e):nr}(E,(V,q)=>n(V,q,L,k)))});return{cancel:()=>{g.cancel(),d()}}},vi="NO_ACCESS_TOKEN";function Wi(s){return s.indexOf("mapbox:")===0}function Ui(s){return N.API_URL_REGEX.test(s)}function Pn(s){return N.API_CDN_URL_REGEX.test(s)}function qn(s){return N.API_STYLE_REGEX.test(s)&&!Hr(s)}function Hr(s){return N.API_SPRITE_REGEX.test(s)}const fr=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function kr(s){const n=s.match(fr);if(!n)throw new Error("Unable to parse URL object");return{protocol:n[1],authority:n[2],path:n[3]||"/",params:n[4]?n[4].split("&"):[]}}function Qn(s){const n=s.params.length?`?${s.params.join("&")}`:"";return`${s.protocol}://${s.authority}${s.path}${n}`}function zs(s){if(!s)return null;const n=s.split(".");if(!n||n.length!==3)return null;try{return JSON.parse(decodeURIComponent(C.atob(n[1]).split("").map(o=>"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class ot{constructor(n){this.type=n,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(n){const o=zs(N.ACCESS_TOKEN);let d="";return d=o&&o.u?C.btoa(encodeURIComponent(o.u).replace(/%([0-9A-F]{2})/g,(g,v)=>String.fromCharCode(Number("0x"+v)))):N.ACCESS_TOKEN||"",n?`mapbox.eventData.${n}:${d}`:`mapbox.eventData:${d}`}fetchEventData(){const n=Qi("localStorage"),o=this.getStorageKey(),d=this.getStorageKey("uuid");if(n)try{const g=C.localStorage.getItem(o);g&&(this.eventData=JSON.parse(g));const v=C.localStorage.getItem(d);v&&(this.anonId=v)}catch{Ct("Unable to read from LocalStorage")}}saveEventData(){const n=Qi("localStorage"),o=this.getStorageKey(),d=this.getStorageKey("uuid");if(n)try{C.localStorage.setItem(d,this.anonId),Object.keys(this.eventData).length>=1&&C.localStorage.setItem(o,JSON.stringify(this.eventData))}catch{Ct("Unable to write to LocalStorage")}}processRequests(n){}postEvent(n,o,d,g){if(!N.EVENTS_URL)return;const v=kr(N.EVENTS_URL);v.params.push(`access_token=${g||N.ACCESS_TOKEN||""}`);const E={event:this.type,created:new Date(n).toISOString()},L=o?Ve(E,o):E,k={url:Qn(v),headers:{"Content-Type":"text/plain"},body:JSON.stringify([L])};this.pendingRequest=function(V,q){return on(Ve(V,{method:"POST"}),q)}(k,V=>{this.pendingRequest=null,d(V),this.saveEventData(),this.processRequests(g)})}queueRequest(n,o){this.queue.push(n),this.processRequests(o)}}const Ee=new class extends ot{constructor(s){super("appUserTurnstile"),this._customAccessToken=s}postTurnstileEvent(s,n){N.EVENTS_URL&&N.ACCESS_TOKEN&&Array.isArray(s)&&s.some(o=>Wi(o)||Ui(o))&&this.queueRequest(Date.now(),n)}processRequests(s){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const n=zs(N.ACCESS_TOKEN),o=n?n.u:N.ACCESS_TOKEN;let d=o!==this.eventData.tokenU;vt(this.anonId)||(this.anonId=qe(),d=!0);const g=this.queue.shift();if(this.eventData.lastSuccess){const v=new Date(this.eventData.lastSuccess),E=new Date(g),L=(g-this.eventData.lastSuccess)/864e5;d=d||L>=1||L<-1||v.getDate()!==E.getDate()}else d=!0;d?this.postEvent(g,{sdkIdentifier:"mapbox-gl-js",sdkVersion:D,skuId:le,"enabled.telemetry":!1,userId:this.anonId},v=>{v||(this.eventData.lastSuccess=g,this.eventData.tokenU=o)},s):this.processRequests()}},Ue=Ee.postTurnstileEvent.bind(Ee),ct=new class extends ot{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(s,n,o,d){this.skuToken=n,this.errorCb=d,N.EVENTS_URL&&(o||N.ACCESS_TOKEN?this.queueRequest({id:s,timestamp:Date.now()},o):this.errorCb(new Error(vi)))}processRequests(s){if(this.pendingRequest||this.queue.length===0)return;const{id:n,timestamp:o}=this.queue.shift();n&&this.success[n]||(this.anonId||this.fetchEventData(),vt(this.anonId)||(this.anonId=qe()),this.postEvent(o,{sdkIdentifier:"mapbox-gl-js",sdkVersion:D,skuId:le,skuToken:this.skuToken,userId:this.anonId},d=>{d?this.errorCb(d):n&&(this.success[n]=!0)},s))}},wt=ct.postMapLoadEvent.bind(ct),X=new class extends ot{constructor(){super("gljs.performance")}postPerformanceEvent(s,n){N.EVENTS_URL&&(s||N.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:n},s)}processRequests(s){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:n,performanceData:o}=this.queue.shift(),d=function(g){const v=C.performance.getEntriesByType("resource"),E=C.performance.getEntriesByType("mark"),L=function(he){const _e={};if(he){for(const be in he)if(be!=="other")for(const De of he[be]){const Ze=`${be}ResolveRangeMin`,xt=`${be}ResolveRangeMax`,Dt=`${be}RequestCount`,_t=`${be}RequestCachedCount`;_e[Ze]=Math.min(_e[Ze]||1/0,De.startTime),_e[xt]=Math.max(_e[xt]||-1/0,De.responseEnd);const Tt=kt=>{_e[kt]===void 0&&(_e[kt]=0),++_e[kt]};De.transferSize!==void 0&&De.transferSize===0&&Tt(_t),Tt(Dt)}}return _e}(function(he,_e){const be={};if(he)for(const De of he){const Ze=_e(De);be[Ze]===void 0&&(be[Ze]=[]),be[Ze].push(De)}return be}(v,He)),k=C.devicePixelRatio,V=C.navigator.connection||C.navigator.mozConnection||C.navigator.webkitConnection,q={counters:[],metadata:[],attributes:[]},se=(he,_e,be)=>{be!=null&&he.push({name:_e,value:be.toString()})};for(const he in L)se(q.counters,he,L[he]);if(g.interactionRange[0]!==1/0&&g.interactionRange[1]!==-1/0&&(se(q.counters,"interactionRangeMin",g.interactionRange[0]),se(q.counters,"interactionRangeMax",g.interactionRange[1])),E)for(const he of Object.keys(Re)){const _e=Re[he],be=E.find(De=>De.name===_e);be&&se(q.counters,_e,be.startTime)}return se(q.counters,"visibilityHidden",g.visibilityHidden),se(q.attributes,"style",function(he){if(he)for(const _e of he){const be=_e.name.split("?")[0];if(qn(be)){const De=be.split("/").slice(-2);if(De.length===2)return`mapbox://styles/${De[0]}/${De[1]}`}}}(v)),se(q.attributes,"terrainEnabled",g.terrainEnabled?"true":"false"),se(q.attributes,"fogEnabled",g.fogEnabled?"true":"false"),se(q.attributes,"projection",g.projection),se(q.attributes,"zoom",g.zoom),se(q.metadata,"devicePixelRatio",k),se(q.metadata,"connectionEffectiveType",V?V.effectiveType:void 0),se(q.metadata,"navigatorUserAgent",C.navigator.userAgent),se(q.metadata,"screenWidth",C.screen.width),se(q.metadata,"screenHeight",C.screen.height),se(q.metadata,"windowWidth",C.innerWidth),se(q.metadata,"windowHeight",C.innerHeight),se(q.metadata,"mapWidth",g.width/k),se(q.metadata,"mapHeight",g.height/k),se(q.metadata,"webglRenderer",g.renderer),se(q.metadata,"webglVendor",g.vendor),se(q.metadata,"sdkVersion",D),se(q.metadata,"sdkIdentifier","mapbox-gl-js"),q}(o);for(const g of d.metadata);for(const g of d.counters);for(const g of d.attributes);this.postEvent(n,d,()=>{},s)}},j=X.postPerformanceEvent.bind(X),ie=new class extends ot{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(s,n,o,d){if(!N.API_URL||!N.SESSION_PATH)return;const g=kr(N.API_URL+N.SESSION_PATH);g.params.push(`sku=${n||""}`),g.params.push(`access_token=${d||N.ACCESS_TOKEN||""}`);const v={url:Qn(g),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(E,L){return on(Ve(E,{method:"GET"}),L)}(v,E=>{this.pendingRequest=null,o(E),this.saveEventData(),this.processRequests(d)})}getSessionAPI(s,n,o,d){this.skuToken=n,this.errorCb=d,N.SESSION_PATH&&N.API_URL&&(o||N.ACCESS_TOKEN?this.queueRequest({id:s,timestamp:Date.now()},o):this.errorCb(new Error(vi)))}processRequests(s){if(this.pendingRequest||this.queue.length===0)return;const{id:n,timestamp:o}=this.queue.shift();n&&this.success[n]||this.getSession(o,this.skuToken,d=>{d?this.errorCb(d):n&&(this.success[n]=!0)},s)}},ne=ie.getSessionAPI.bind(ie),de=new Set,Re={create:"create",load:"load",fullLoad:"fullLoad"},tt={mark(s){C.performance.mark(s)},measure(s,n,o){C.performance.measure(s,n,o)}};function He(s){const n=s.name.split("?")[0];return Pn(n)&&n.includes("mapbox-gl.js")?"javascript":Pn(n)&&n.includes("mapbox-gl.css")?"css":function(o){return N.API_FONTS_REGEX.test(o)}(n)?"fontRange":Hr(n)?"sprite":qn(n)?"style":function(o){return N.API_TILEJSON_REGEX.test(o)}(n)?"tilejson":"other"}const Je=C.performance;function pt(s){const n=s?s.url.toString():void 0;return Je.getEntriesByName(n)}let Lt,jt,Gt,ki;const wi={now:()=>Gt!==void 0?Gt:C.performance.now(),setNow(s){Gt=s},restoreNow(){Gt=void 0},frame(s){const n=C.requestAnimationFrame(s);return{cancel:()=>C.cancelAnimationFrame(n)}},getImageData(s,n=0){const{width:o,height:d}=s;ki||(ki=C.document.createElement("canvas"));const g=ki.getContext("2d",{willReadFrequently:!0});if(!g)throw new Error("failed to create canvas 2d context");return(o>ki.width||d>ki.height)&&(ki.width=o,ki.height=d),g.clearRect(-n,-n,o+2*n,d+2*n),g.drawImage(s,0,0,o,d),g.getImageData(-n,-n,o+2*n,d+2*n)},resolveURL:s=>(Lt||(Lt=C.document.createElement("a")),Lt.href=s,Lt.href),get devicePixelRatio(){return C.devicePixelRatio},get prefersReducedMotion(){return!!C.matchMedia&&(jt==null&&(jt=C.matchMedia("(prefers-reduced-motion: reduce)")),jt.matches)}};function Oi(s,n,o){o[s]&&o[s].indexOf(n)!==-1||(o[s]=o[s]||[],o[s].push(n))}function Yi(s,n,o){if(o&&o[s]){const d=o[s].indexOf(n);d!==-1&&o[s].splice(d,1)}}class tn{constructor(n,o={}){Ve(this,o),this.type=n}}class rr extends tn{constructor(n,o={}){super("error",Ve({error:n},o))}}class yn{on(n,o){return this._listeners=this._listeners||{},Oi(n,o,this._listeners),this}off(n,o){return Yi(n,o,this._listeners),Yi(n,o,this._oneTimeListeners),this}once(n,o){return o?(this._oneTimeListeners=this._oneTimeListeners||{},Oi(n,o,this._oneTimeListeners),this):new Promise(d=>this.once(n,d))}fire(n,o){typeof n=="string"&&(n=new tn(n,o||{}));const d=n.type;if(this.listens(d)){n.target=this;const g=this._listeners&&this._listeners[d]?this._listeners[d].slice():[];for(const L of g)L.call(this,n);const v=this._oneTimeListeners&&this._oneTimeListeners[d]?this._oneTimeListeners[d].slice():[];for(const L of v)Yi(d,L,this._oneTimeListeners),L.call(this,n);const E=this._eventedParent;E&&(Ve(n,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),E.fire(n))}else n instanceof rr&&console.error(n.error);return this}listens(n){return!!(this._listeners&&this._listeners[n]&&this._listeners[n].length>0||this._oneTimeListeners&&this._oneTimeListeners[n]&&this._oneTimeListeners[n].length>0||this._eventedParent&&this._eventedParent.listens(n))}setEventedParent(n,o){return this._eventedParent=n,this._eventedParentData=o,this}}var Yt=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"]}},"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 sr(s,...n){for(const o of n)for(const d in o)s[d]=o[d];return s}function Yn(s){return s instanceof Number||s instanceof String||s instanceof Boolean?s.valueOf():s}function Wr(s){if(Array.isArray(s))return s.map(Wr);if(s instanceof Object&&!(s instanceof Number||s instanceof String||s instanceof Boolean)){const n={};for(const o in s)n[o]=Wr(s[o]);return n}return Yn(s)}class mr extends Error{constructor(n,o){super(o),this.message=o,this.key=n}}var Mr=mr;class Oo{constructor(n,o=[]){this.parent=n,this.bindings={};for(const[d,g]of o)this.bindings[d]=g}concat(n){return new Oo(this,n)}get(n){if(this.bindings[n])return this.bindings[n];if(this.parent)return this.parent.get(n);throw new Error(`${n} not found in scope.`)}has(n){return!!this.bindings[n]||!!this.parent&&this.parent.has(n)}}var ks=Oo;const or={kind:"null"},rn={kind:"number"},cr={kind:"string"},Ar={kind:"boolean"},la={kind:"color"},al={kind:"object"},dr={kind:"value"},Ul={kind:"collator"},Rl={kind:"formatted"},ll={kind:"resolvedImage"};function qs(s,n){return{kind:"array",itemType:s,N:n}}function hs(s){if(s.kind==="array"){const n=hs(s.itemType);return typeof s.N=="number"?`array<${n}, ${s.N}>`:s.itemType.kind==="value"?"array":`array<${n}>`}return s.kind}const ho=[or,rn,cr,Ar,la,Rl,al,qs(dr),ll];function cl(s,n){if(n.kind==="error")return null;if(s.kind==="array"){if(n.kind==="array"&&(n.N===0&&n.itemType.kind==="value"||!cl(s.itemType,n.itemType))&&(typeof s.N!="number"||s.N===n.N))return null}else{if(s.kind===n.kind)return null;if(s.kind==="value"){for(const o of ho)if(!cl(o,n))return null}}return`Expected ${hs(s)} but found ${hs(n)} instead.`}function Na(s,n){return n.some(o=>o.kind===s.kind)}function zl(s,n){return n.some(o=>o==="null"?s===null:o==="array"?Array.isArray(s):o==="object"?s&&!Array.isArray(s)&&typeof s=="object":o===typeof s)}var kl,Ol={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 Qa(s){return(s=Math.round(s))<0?0:s>255?255:s}function Nl(s){return Qa(s[s.length-1]==="%"?parseFloat(s)/100*255:parseInt(s))}function Ql(s){return(n=s[s.length-1]==="%"?parseFloat(s)/100:parseFloat(s))<0?0:n>1?1:n;var n}function ns(s,n,o){return o<0?o+=1:o>1&&(o-=1),6*o<1?s+(n-s)*o*6:2*o<1?n:3*o<2?s+(n-s)*(2/3-o)*6:s}try{kl={}.parseCSSColor=function(s){var n,o=s.replace(/ /g,"").toLowerCase();if(o in Ol)return Ol[o].slice();if(o[0]==="#")return o.length===4?(n=parseInt(o.substr(1),16))>=0&&n<=4095?[(3840&n)>>4|(3840&n)>>8,240&n|(240&n)>>4,15&n|(15&n)<<4,1]:null:o.length===7&&(n=parseInt(o.substr(1),16))>=0&&n<=16777215?[(16711680&n)>>16,(65280&n)>>8,255&n,1]:null;var d=o.indexOf("("),g=o.indexOf(")");if(d!==-1&&g+1===o.length){var v=o.substr(0,d),E=o.substr(d+1,g-(d+1)).split(","),L=1;switch(v){case"rgba":if(E.length!==4)return null;L=Ql(E.pop());case"rgb":return E.length!==3?null:[Nl(E[0]),Nl(E[1]),Nl(E[2]),L];case"hsla":if(E.length!==4)return null;L=Ql(E.pop());case"hsl":if(E.length!==3)return null;var k=(parseFloat(E[0])%360+360)%360/360,V=Ql(E[1]),q=Ql(E[2]),se=q<=.5?q*(V+1):q+V-q*V,he=2*q-se;return[Qa(255*ns(he,se,k+1/3)),Qa(255*ns(he,se,k)),Qa(255*ns(he,se,k-1/3)),L];default:return null}}return null}}catch{}class Ys{constructor(n,o,d,g=1){this.r=n,this.g=o,this.b=d,this.a=g}static parse(n){if(!n)return;if(n instanceof Ys)return n;if(typeof n!="string")return;const o=kl(n);return o?new Ys(o[0]/255*o[3],o[1]/255*o[3],o[2]/255*o[3],o[3]):void 0}toString(){const[n,o,d,g]=this.toArray();return`rgba(${Math.round(n)},${Math.round(o)},${Math.round(d)},${g})`}toArray(){const{r:n,g:o,b:d,a:g}=this;return g===0?[0,0,0,0]:[255*n/g,255*o/g,255*d/g,g]}toArray01(){const{r:n,g:o,b:d,a:g}=this;return g===0?[0,0,0,0]:[n/g,o/g,d/g,g]}toArray01PremultipliedAlpha(){const{r:n,g:o,b:d,a:g}=this;return[n,o,d,g]}}Ys.black=new Ys(0,0,0,1),Ys.white=new Ys(1,1,1,1),Ys.transparent=new Ys(0,0,0,0),Ys.red=new Ys(1,0,0,1),Ys.blue=new Ys(0,0,1,1);var fs=Ys;class Rc{constructor(n,o,d){this.sensitivity=n?o?"variant":"case":o?"accent":"base",this.locale=d,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(n,o){return this.collator.compare(n,o)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Eh{constructor(n,o,d,g,v){this.text=n.normalize?n.normalize():n,this.image=o,this.scale=d,this.fontStack=g,this.textColor=v}}class Os{constructor(n){this.sections=n}static fromString(n){return new Os([new Eh(n,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(n=>n.text.length!==0||n.image&&n.image.name.length!==0)}static factory(n){return n instanceof Os?n:Os.fromString(n)}toString(){return this.sections.length===0?"":this.sections.map(n=>n.text).join("")}serialize(){const n=["format"];for(const o of this.sections){if(o.image){n.push(["image",o.image.name]);continue}n.push(o.text);const d={};o.fontStack&&(d["text-font"]=["literal",o.fontStack.split(",")]),o.scale&&(d["font-scale"]=o.scale),o.textColor&&(d["text-color"]=["rgba"].concat(o.textColor.toArray())),n.push(d)}return n}}class No{constructor(n){this.name=n.name,this.available=n.available}toString(){return this.name}static fromString(n){return n?new No({name:n,available:!1}):null}serialize(){return["image",this.name]}}function ed(s,n,o,d){return typeof s=="number"&&s>=0&&s<=255&&typeof n=="number"&&n>=0&&n<=255&&typeof o=="number"&&o>=0&&o<=255?d===void 0||typeof d=="number"&&d>=0&&d<=1?null:`Invalid rgba value [${[s,n,o,d].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof d=="number"?[s,n,o,d]:[s,n,o]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function pu(s){if(s===null||typeof s=="string"||typeof s=="boolean"||typeof s=="number"||s instanceof fs||s instanceof Rc||s instanceof Os||s instanceof No)return!0;if(Array.isArray(s)){for(const n of s)if(!pu(n))return!1;return!0}if(typeof s=="object"){for(const n in s)if(!pu(s[n]))return!1;return!0}return!1}function Cs(s){if(s===null)return or;if(typeof s=="string")return cr;if(typeof s=="boolean")return Ar;if(typeof s=="number")return rn;if(s instanceof fs)return la;if(s instanceof Rc)return Ul;if(s instanceof Os)return Rl;if(s instanceof No)return ll;if(Array.isArray(s)){const n=s.length;let o;for(const d of s){const g=Cs(d);if(o){if(o===g)continue;o=dr;break}o=g}return qs(o||dr,n)}return al}function rc(s){const n=typeof s;return s===null?"":n==="string"||n==="number"||n==="boolean"?String(s):s instanceof fs||s instanceof Os||s instanceof No?s.toString():JSON.stringify(s)}class Th{constructor(n,o){this.type=n,this.value=o}static parse(n,o){if(n.length!==2)return o.error(`'literal' expression requires exactly one argument, but found ${n.length-1} instead.`);if(!pu(n[1]))return o.error("invalid value");const d=n[1];let g=Cs(d);const v=o.expectedType;return g.kind!=="array"||g.N!==0||!v||v.kind!=="array"||typeof v.N=="number"&&v.N!==0||(g=v),new Th(g,d)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof fs?["rgba"].concat(this.value.toArray()):this.value instanceof Os?this.value.serialize():this.value}}var sc=Th,er=class{constructor(s){this.name="ExpressionEvaluationError",this.message=s}toJSON(){return this.message}};const oc={string:cr,number:rn,boolean:Ar,object:al};class Ju{constructor(n,o){this.type=n,this.args=o}static parse(n,o){if(n.length<2)return o.error("Expected at least one argument.");let d,g=1;const v=n[0];if(v==="array"){let L,k;if(n.length>2){const V=n[1];if(typeof V!="string"||!(V in oc)||V==="object")return o.error('The item type argument of "array" must be one of string, number, boolean',1);L=oc[V],g++}else L=dr;if(n.length>3){if(n[2]!==null&&(typeof n[2]!="number"||n[2]<0||n[2]!==Math.floor(n[2])))return o.error('The length argument to "array" must be a positive integer literal',2);k=n[2],g++}d=qs(L,k)}else d=oc[v];const E=[];for(;gn.outputDefined())}serialize(){const n=this.type,o=[n.kind];if(n.kind==="array"){const d=n.itemType;if(d.kind==="string"||d.kind==="number"||d.kind==="boolean"){o.push(d.kind);const g=n.N;(typeof g=="number"||this.args.length>1)&&o.push(g)}}return o.concat(this.args.map(d=>d.serialize()))}}var Qo=Ju;class hl{constructor(n){this.type=Rl,this.sections=n}static parse(n,o){if(n.length<2)return o.error("Expected at least one argument.");const d=n[1];if(!Array.isArray(d)&&typeof d=="object")return o.error("First argument must be an image or text section.");const g=[];let v=!1;for(let E=1;E<=n.length-1;++E){const L=n[E];if(v&&typeof L=="object"&&!Array.isArray(L)){v=!1;let k=null;if(L["font-scale"]&&(k=o.parse(L["font-scale"],1,rn),!k))return null;let V=null;if(L["text-font"]&&(V=o.parse(L["text-font"],1,qs(cr)),!V))return null;let q=null;if(L["text-color"]&&(q=o.parse(L["text-color"],1,la),!q))return null;const se=g[g.length-1];se.scale=k,se.font=V,se.textColor=q}else{const k=o.parse(n[E],1,dr);if(!k)return null;const V=k.type.kind;if(V!=="string"&&V!=="value"&&V!=="null"&&V!=="resolvedImage")return o.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");v=!0,g.push({content:k,scale:null,font:null,textColor:null})}}return new hl(g)}evaluate(n){return new Os(this.sections.map(o=>{const d=o.content.evaluate(n);return Cs(d)===ll?new Eh("",d,null,null,null):new Eh(rc(d),null,o.scale?o.scale.evaluate(n):null,o.font?o.font.evaluate(n).join(","):null,o.textColor?o.textColor.evaluate(n):null)}))}eachChild(n){for(const o of this.sections)n(o.content),o.scale&&n(o.scale),o.font&&n(o.font),o.textColor&&n(o.textColor)}outputDefined(){return!1}serialize(){const n=["format"];for(const o of this.sections){n.push(o.content.serialize());const d={};o.scale&&(d["font-scale"]=o.scale.serialize()),o.font&&(d["text-font"]=o.font.serialize()),o.textColor&&(d["text-color"]=o.textColor.serialize()),n.push(d)}return n}}class Sh{constructor(n){this.type=ll,this.input=n}static parse(n,o){if(n.length!==2)return o.error("Expected two arguments.");const d=o.parse(n[1],1,cr);return d?new Sh(d):o.error("No image name provided.")}evaluate(n){const o=this.input.evaluate(n),d=No.fromString(o);return d&&n.availableImages&&(d.available=n.availableImages.indexOf(o)>-1),d}eachChild(n){n(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Vo={"to-boolean":Ar,"to-color":la,"to-number":rn,"to-string":cr};class Mh{constructor(n,o){this.type=n,this.args=o}static parse(n,o){if(n.length<2)return o.error("Expected at least one argument.");const d=n[0];if((d==="to-boolean"||d==="to-string")&&n.length!==2)return o.error("Expected one argument.");const g=Vo[d],v=[];for(let E=1;E4?`Invalid rbga value ${JSON.stringify(o)}: expected an array containing either three or four numeric values.`:ed(o[0],o[1],o[2],o[3]),!d))return new fs(o[0]/255,o[1]/255,o[2]/255,o[3])}throw new er(d||`Could not parse color from value '${typeof o=="string"?o:String(JSON.stringify(o))}'`)}if(this.type.kind==="number"){let o=null;for(const d of this.args){if(o=d.evaluate(n),o===null)return 0;const g=Number(o);if(!isNaN(g))return g}throw new er(`Could not convert ${JSON.stringify(o)} to number.`)}return this.type.kind==="formatted"?Os.fromString(rc(this.args[0].evaluate(n))):this.type.kind==="resolvedImage"?No.fromString(rc(this.args[0].evaluate(n))):rc(this.args[0].evaluate(n))}eachChild(n){this.args.forEach(n)}outputDefined(){return this.args.every(n=>n.outputDefined())}serialize(){if(this.type.kind==="formatted")return new hl([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Sh(this.args[0]).serialize();const n=[`to-${this.type.kind}`];return this.eachChild(o=>{n.push(o.serialize())}),n}}var Va=Mh;const ac=["Unknown","Point","LineString","Polygon"];var fu=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"?ac[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 s=this.featureDistanceData.center,n=this.featureDistanceData.scale,{x:o,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(o*n-s[0])+this.featureDistanceData.bearing[1]*(d*n-s[1])}return 0}parseColor(s){let n=this._parseColorCache[s];return n||(n=this._parseColorCache[s]=fs.parse(s)),n}};class Vl{constructor(n,o,d,g){this.name=n,this.type=o,this._evaluate=d,this.args=g}evaluate(n){return this._evaluate(n,this.args)}eachChild(n){this.args.forEach(n)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(n=>n.serialize()))}static parse(n,o){const d=n[0],g=Vl.definitions[d];if(!g)return o.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0);const v=Array.isArray(g)?g[0]:g.type,E=Array.isArray(g)?[[g[1],g[2]]]:g.overloads,L=E.filter(([V])=>!Array.isArray(V)||V.length===n.length-1);let k=null;for(const[V,q]of L){k=new hr(o.registry,o.path,null,o.scope);const se=[];let he=!1;for(let _e=1;_e{return he=se,Array.isArray(he)?`(${he.map(hs).join(", ")})`:`(${hs(he.type)}...)`;var he}).join(" | "),q=[];for(let se=1;se=n[2]||s[1]<=n[1]||s[3]>=n[3])}function eA(s,n){const o=(180+s[0])/360,d=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+s[1]*Math.PI/360)))/360,g=Math.pow(2,n.z);return[Math.round(o*g*Ws),Math.round(d*g*Ws)]}function cc(s,n,o){const d=s[0]-n[0],g=s[1]-n[1],v=s[0]-o[0],E=s[1]-o[1];return d*E-v*g==0&&d*v<=0&&g*E<=0}function mu(s,n){let o=!1;for(let E=0,L=n.length;E(d=s)[1]!=(v=k[V+1])[1]>d[1]&&d[0]<(v[0]-g[0])*(d[1]-g[1])/(v[1]-g[1])+g[0]&&(o=!o)}}var d,g,v;return o}function td(s,n){for(let o=0;o0&&L<0||E<0&&L>0}function Ih(s,n,o){for(const V of o)for(let q=0;qo[2]){const g=.5*d;let v=s[0]-o[0]>g?-d:o[0]-s[0]>g?d:0;v===0&&(v=s[0]-o[2]>g?-d:o[2]-s[0]>g?d:0),s[0]+=v}lc(n,s)}function Ir(s,n,o,d){const g=Math.pow(2,d.z)*Ws,v=[d.x*Ws,d.y*Ws],E=[];if(!s)return E;for(const L of s)for(const k of L){const V=[k.x+v[0],k.y+v[1]];ul(V,n,o,g),E.push(V)}return E}function uc(s,n,o,d){const g=Math.pow(2,d.z)*Ws,v=[d.x*Ws,d.y*Ws],E=[];if(!s)return E;for(const k of s){const V=[];for(const q of k){const se=[q.x+v[0],q.y+v[1]];lc(n,se),V.push(se)}E.push(V)}if(n[2]-n[0]<=g/2){(L=n)[0]=L[1]=1/0,L[2]=L[3]=-1/0;for(const k of E)for(const V of k)ul(V,n,o,g)}var L;return E}class Nc{constructor(n,o){this.type=Ar,this.geojson=n,this.geometries=o}static parse(n,o){if(n.length!==2)return o.error(`'within' expression requires exactly one argument, but found ${n.length-1} instead.`);if(pu(n[1])){const d=n[1];if(d.type==="FeatureCollection")for(let g=0;g{n&&!Al(o)&&(n=!1)}),n}function Ha(s){if(s instanceof ya&&s.name==="feature-state")return!1;let n=!0;return s.eachChild(o=>{n&&!Ha(o)&&(n=!1)}),n}function Qc(s,n){if(s instanceof ya&&n.indexOf(s.name)>=0)return!1;let o=!0;return s.eachChild(d=>{o&&!Qc(d,n)&&(o=!1)}),o}class dl{constructor(n,o){this.type=o.type,this.name=n,this.boundExpression=o}static parse(n,o){if(n.length!==2||typeof n[1]!="string")return o.error("'var' expression requires exactly one string literal argument.");const d=n[1];return o.scope.has(d)?new dl(d,o.scope.get(d)):o.error(`Unknown variable "${d}". Make sure "${d}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(n){return this.boundExpression.evaluate(n)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var qr=dl;class Fh{constructor(n,o=[],d,g=new ks,v=[]){this.registry=n,this.path=o,this.key=o.map(E=>`[${E}]`).join(""),this.scope=g,this.errors=v,this.expectedType=d}parse(n,o,d,g,v={}){return o?this.concat(o,d,g)._parse(n,v):this._parse(n,v)}_parse(n,o){function d(g,v,E){return E==="assert"?new Qo(v,[g]):E==="coerce"?new Va(v,[g]):g}if(n!==null&&typeof n!="string"&&typeof n!="boolean"&&typeof n!="number"||(n=["literal",n]),Array.isArray(n)){if(n.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const g=n[0];if(typeof g!="string")return this.error(`Expression name must be a string, but found ${typeof g} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const v=this.registry[g];if(v){let E=v.parse(n,this);if(!E)return null;if(this.expectedType){const L=this.expectedType,k=E.type;if(L.kind!=="string"&&L.kind!=="number"&&L.kind!=="boolean"&&L.kind!=="object"&&L.kind!=="array"||k.kind!=="value")if(L.kind!=="color"&&L.kind!=="formatted"&&L.kind!=="resolvedImage"||k.kind!=="value"&&k.kind!=="string"){if(this.checkSubtype(L,k))return null}else E=d(E,L,o.typeAnnotation||"coerce");else E=d(E,L,o.typeAnnotation||"assert")}if(!(E instanceof sc)&&E.type.kind!=="resolvedImage"&&Br(E)){const L=new fu;try{E=new sc(E.type,E.evaluate(L))}catch(k){return this.error(k.message),null}}return E}return this.error(`Unknown expression "${g}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(n===void 0?"'undefined' value invalid. Use null instead.":typeof n=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof n} instead.`)}concat(n,o,d){const g=typeof n=="number"?this.path.concat(n):this.path,v=d?this.scope.concat(d):this.scope;return new Fh(this.registry,g,o||null,v,this.errors)}error(n,...o){const d=`${this.key}${o.map(g=>`[${g}]`).join("")}`;this.errors.push(new Mr(d,n))}checkSubtype(n,o){const d=cl(n,o);return d&&this.error(d),d}}var hr=Fh;function Br(s){if(s instanceof qr)return Br(s.boundExpression);if(s instanceof ya&&s.name==="error"||s instanceof zc||s instanceof _u)return!1;const n=s instanceof Va||s instanceof Qo;let o=!0;return s.eachChild(d=>{o=n?o&&Br(d):o&&d instanceof sc}),!!o&&Al(s)&&Qc(s,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function jr(s,n){const o=s.length-1;let d,g,v=0,E=o,L=0;for(;v<=E;)if(L=Math.floor((v+E)/2),d=s[L],g=s[L+1],d<=n){if(L===o||nn))throw new er("Input is not a number.");E=L-1}return 0}class $r{constructor(n,o,d){this.type=n,this.input=o,this.labels=[],this.outputs=[];for(const[g,v]of d)this.labels.push(g),this.outputs.push(v)}static parse(n,o){if(n.length-1<4)return o.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if((n.length-1)%2!=0)return o.error("Expected an even number of arguments.");const d=o.parse(n[1],1,rn);if(!d)return null;const g=[];let v=null;o.expectedType&&o.expectedType.kind!=="value"&&(v=o.expectedType);for(let E=1;E=L)return o.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',V);const se=o.parse(k,q,v);if(!se)return null;v=v||se.type,g.push([L,se])}return new $r(v,d,g)}evaluate(n){const o=this.labels,d=this.outputs;if(o.length===1)return d[0].evaluate(n);const g=this.input.evaluate(n);if(g<=o[0])return d[0].evaluate(n);const v=o.length;return g>=o[v-1]?d[v-1].evaluate(n):d[jr(o,g)].evaluate(n)}eachChild(n){n(this.input);for(const o of this.outputs)n(o)}outputDefined(){return this.outputs.every(n=>n.outputDefined())}serialize(){const n=["step",this.input.serialize()];for(let o=0;o0&&n.push(this.labels[o]),n.push(this.outputs[o].serialize());return n}}var Hl=$r;function gr(s,n,o){return s*(1-o)+n*o}var yu=Object.freeze({__proto__:null,number:gr,color:function(s,n,o){return new fs(gr(s.r,n.r,o),gr(s.g,n.g,o),gr(s.b,n.b,o),gr(s.a,n.a,o))},array:function(s,n,o){return s.map((d,g)=>gr(d,n[g],o))}});const iA=.95047,nA=1.08883,rA=4/29,Ac=6/29,Vc=3*Ac*Ac,Hc=Math.PI/180,Lh=180/Math.PI;function Gc(s){return s>.008856451679035631?Math.pow(s,1/3):s/Vc+rA}function Dh(s){return s>Ac?s*s*s:Vc*(s-rA)}function Wc(s){return 255*(s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055)}function jc(s){return(s/=255)<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function ca(s){const n=jc(s.r),o=jc(s.g),d=jc(s.b),g=Gc((.4124564*n+.3575761*o+.1804375*d)/iA),v=Gc((.2126729*n+.7151522*o+.072175*d)/1);return{l:116*v-16,a:500*(g-v),b:200*(v-Gc((.0193339*n+.119192*o+.9503041*d)/nA)),alpha:s.a}}function sA(s){let n=(s.l+16)/116,o=isNaN(s.a)?n:n+s.a/500,d=isNaN(s.b)?n:n-s.b/200;return n=1*Dh(n),o=iA*Dh(o),d=nA*Dh(d),new fs(Wc(3.2404542*o-1.5371385*n-.4985314*d),Wc(-.969266*o+1.8760108*n+.041556*d),Wc(.0556434*o-.2040259*n+1.0572252*d),s.alpha)}function oA(s,n,o){const d=n-s;return s+o*(d>180||d<-180?d-360*Math.round(d/360):d)}const Kc={forward:ca,reverse:sA,interpolate:function(s,n,o){return{l:gr(s.l,n.l,o),a:gr(s.a,n.a,o),b:gr(s.b,n.b,o),alpha:gr(s.alpha,n.alpha,o)}}},ha={forward:function(s){const{l:n,a:o,b:d}=ca(s),g=Math.atan2(d,o)*Lh;return{h:g<0?g+360:g,c:Math.sqrt(o*o+d*d),l:n,alpha:s.a}},reverse:function(s){const n=s.h*Hc,o=s.c;return sA({l:s.l,a:Math.cos(n)*o,b:Math.sin(n)*o,alpha:s.alpha})},interpolate:function(s,n,o){return{h:oA(s.h,n.h,o),c:gr(s.c,n.c,o),l:gr(s.l,n.l,o),alpha:gr(s.alpha,n.alpha,o)}}};var $c=Object.freeze({__proto__:null,lab:Kc,hcl:ha});class pl{constructor(n,o,d,g,v){this.type=n,this.operator=o,this.interpolation=d,this.input=g,this.labels=[],this.outputs=[];for(const[E,L]of v)this.labels.push(E),this.outputs.push(L)}static interpolationFactor(n,o,d,g){let v=0;if(n.name==="exponential")v=aA(o,n.base,d,g);else if(n.name==="linear")v=aA(o,1,d,g);else if(n.name==="cubic-bezier"){const E=n.controlPoints;v=new Ae(E[0],E[1],E[2],E[3]).solve(aA(o,1,d,g))}return v}static parse(n,o){let[d,g,v,...E]=n;if(!Array.isArray(g)||g.length===0)return o.error("Expected an interpolation type expression.",1);if(g[0]==="linear")g={name:"linear"};else if(g[0]==="exponential"){const V=g[1];if(typeof V!="number")return o.error("Exponential interpolation requires a numeric base.",1,1);g={name:"exponential",base:V}}else{if(g[0]!=="cubic-bezier")return o.error(`Unknown interpolation type ${String(g[0])}`,1,0);{const V=g.slice(1);if(V.length!==4||V.some(q=>typeof q!="number"||q<0||q>1))return o.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);g={name:"cubic-bezier",controlPoints:V}}}if(n.length-1<4)return o.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if((n.length-1)%2!=0)return o.error("Expected an even number of arguments.");if(v=o.parse(v,2,rn),!v)return null;const L=[];let k=null;d==="interpolate-hcl"||d==="interpolate-lab"?k=la:o.expectedType&&o.expectedType.kind!=="value"&&(k=o.expectedType);for(let V=0;V=q)return o.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',he);const be=o.parse(se,_e,k);if(!be)return null;k=k||be.type,L.push([q,be])}return k.kind==="number"||k.kind==="color"||k.kind==="array"&&k.itemType.kind==="number"&&typeof k.N=="number"?new pl(k,d,g,v,L):o.error(`Type ${hs(k)} is not interpolatable.`)}evaluate(n){const o=this.labels,d=this.outputs;if(o.length===1)return d[0].evaluate(n);const g=this.input.evaluate(n);if(g<=o[0])return d[0].evaluate(n);const v=o.length;if(g>=o[v-1])return d[v-1].evaluate(n);const E=jr(o,g),L=pl.interpolationFactor(this.interpolation,g,o[E],o[E+1]),k=d[E].evaluate(n),V=d[E+1].evaluate(n);return this.operator==="interpolate"?yu[this.type.kind.toLowerCase()](k,V,L):this.operator==="interpolate-hcl"?ha.reverse(ha.interpolate(ha.forward(k),ha.forward(V),L)):Kc.reverse(Kc.interpolate(Kc.forward(k),Kc.forward(V),L))}eachChild(n){n(this.input);for(const o of this.outputs)n(o)}outputDefined(){return this.outputs.every(n=>n.outputDefined())}serialize(){let n;n=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 o=[this.operator,n,this.input.serialize()];for(let d=0;dcl(g,L.type));return new Ph(E?dr:d,v)}evaluate(n){let o,d=null,g=0;for(const v of this.args){if(g++,d=v.evaluate(n),d&&d instanceof No&&!d.available&&(o||(o=d),d=null,g===this.args.length))return o;if(d!==null)break}return d}eachChild(n){this.args.forEach(n)}outputDefined(){return this.args.every(n=>n.outputDefined())}serialize(){const n=["coalesce"];return this.eachChild(o=>{n.push(o.serialize())}),n}}var xu=Ph;class Gl{constructor(n,o){this.type=o.type,this.bindings=[].concat(n),this.result=o}evaluate(n){return this.result.evaluate(n)}eachChild(n){for(const o of this.bindings)n(o[1]);n(this.result)}static parse(n,o){if(n.length<4)return o.error(`Expected at least 3 arguments, but found ${n.length-1} instead.`);const d=[];for(let v=1;v=d.length)throw new er(`Array index out of bounds: ${o} > ${d.length-1}.`);if(o!==Math.floor(o))throw new er(`Array index must be an integer, but found ${o} instead.`);return d[o]}eachChild(n){n(this.index),n(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Xc=Zc;class fl{constructor(n,o){this.type=Ar,this.needle=n,this.haystack=o}static parse(n,o){if(n.length!==3)return o.error(`Expected 2 arguments, but found ${n.length-1} instead.`);const d=o.parse(n[1],1,dr),g=o.parse(n[2],2,dr);return d&&g?Na(d.type,[Ar,cr,rn,or,dr])?new fl(d,g):o.error(`Expected first argument to be of type boolean, string, number or null, but found ${hs(d.type)} instead`):null}evaluate(n){const o=this.needle.evaluate(n),d=this.haystack.evaluate(n);if(d==null)return!1;if(!zl(o,["boolean","string","number","null"]))throw new er(`Expected first argument to be of type boolean, string, number or null, but found ${hs(Cs(o))} instead.`);if(!zl(d,["string","array"]))throw new er(`Expected second argument to be of type array or string, but found ${hs(Cs(d))} instead.`);return d.indexOf(o)>=0}eachChild(n){n(this.needle),n(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var qc=fl;class Uh{constructor(n,o,d){this.type=rn,this.needle=n,this.haystack=o,this.fromIndex=d}static parse(n,o){if(n.length<=2||n.length>=5)return o.error(`Expected 3 or 4 arguments, but found ${n.length-1} instead.`);const d=o.parse(n[1],1,dr),g=o.parse(n[2],2,dr);if(!d||!g)return null;if(!Na(d.type,[Ar,cr,rn,or,dr]))return o.error(`Expected first argument to be of type boolean, string, number or null, but found ${hs(d.type)} instead`);if(n.length===4){const v=o.parse(n[3],3,rn);return v?new Uh(d,g,v):null}return new Uh(d,g)}evaluate(n){const o=this.needle.evaluate(n),d=this.haystack.evaluate(n);if(!zl(o,["boolean","string","number","null"]))throw new er(`Expected first argument to be of type boolean, string, number or null, but found ${hs(Cs(o))} instead.`);if(!zl(d,["string","array"]))throw new er(`Expected second argument to be of type array or string, but found ${hs(Cs(d))} instead.`);if(this.fromIndex){const g=this.fromIndex.evaluate(n);return d.indexOf(o,g)}return d.indexOf(o)}eachChild(n){n(this.needle),n(this.haystack),this.fromIndex&&n(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const n=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),n]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Rh=Uh;class wu{constructor(n,o,d,g,v,E){this.inputType=n,this.type=o,this.input=d,this.cases=g,this.outputs=v,this.otherwise=E}static parse(n,o){if(n.length<5)return o.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if(n.length%2!=1)return o.error("Expected an even number of arguments.");let d,g;o.expectedType&&o.expectedType.kind!=="value"&&(g=o.expectedType);const v={},E=[];for(let V=2;VNumber.MAX_SAFE_INTEGER)return he.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof be=="number"&&Math.floor(be)!==be)return he.error("Numeric branch labels must be integer values.");if(d){if(he.checkSubtype(d,Cs(be)))return null}else d=Cs(be);if(v[String(be)]!==void 0)return he.error("Branch labels must be unique.");v[String(be)]=E.length}const _e=o.parse(se,V,g);if(!_e)return null;g=g||_e.type,E.push(_e)}const L=o.parse(n[1],1,dr);if(!L)return null;const k=o.parse(n[n.length-1],n.length-1,g);return k?L.type.kind!=="value"&&o.concat(1).checkSubtype(d,L.type)?null:new wu(d,g,L,v,E,k):null}evaluate(n){const o=this.input.evaluate(n);return(Cs(o)===this.inputType&&this.outputs[this.cases[o]]||this.otherwise).evaluate(n)}eachChild(n){n(this.input),this.outputs.forEach(n),n(this.otherwise)}outputDefined(){return this.outputs.every(n=>n.outputDefined())&&this.otherwise.outputDefined()}serialize(){const n=["match",this.input.serialize()],o=Object.keys(this.cases).sort(),d=[],g={};for(const E of o){const L=g[this.cases[E]];L===void 0?(g[this.cases[E]]=d.length,d.push([this.cases[E],[E]])):d[L][1].push(E)}const v=E=>this.inputType.kind==="number"?Number(E):E;for(const[E,L]of d)n.push(L.length===1?v(L[0]):L.map(v)),n.push(this.outputs[E].serialize());return n.push(this.otherwise.serialize()),n}}var nd=wu;class dc{constructor(n,o,d){this.type=n,this.branches=o,this.otherwise=d}static parse(n,o){if(n.length<4)return o.error(`Expected at least 3 arguments, but found only ${n.length-1}.`);if(n.length%2!=0)return o.error("Expected an odd number of arguments.");let d;o.expectedType&&o.expectedType.kind!=="value"&&(d=o.expectedType);const g=[];for(let E=1;Eo.outputDefined())&&this.otherwise.outputDefined()}serialize(){const n=["case"];return this.eachChild(o=>{n.push(o.serialize())}),n}}var pc=dc;class Yc{constructor(n,o,d,g){this.type=n,this.input=o,this.beginIndex=d,this.endIndex=g}static parse(n,o){if(n.length<=2||n.length>=5)return o.error(`Expected 3 or 4 arguments, but found ${n.length-1} instead.`);const d=o.parse(n[1],1,dr),g=o.parse(n[2],2,rn);if(!d||!g)return null;if(!Na(d.type,[qs(dr),cr,dr]))return o.error(`Expected first argument to be of type array or string, but found ${hs(d.type)} instead`);if(n.length===4){const v=o.parse(n[3],3,rn);return v?new Yc(d.type,d,g,v):null}return new Yc(d.type,d,g)}evaluate(n){const o=this.input.evaluate(n),d=this.beginIndex.evaluate(n);if(!zl(o,["string","array"]))throw new er(`Expected first argument to be of type array or string, but found ${hs(Cs(o))} instead.`);if(this.endIndex){const g=this.endIndex.evaluate(n);return o.slice(d,g)}return o.slice(d)}eachChild(n){n(this.input),n(this.beginIndex),this.endIndex&&n(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const n=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),n]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var zh=Yc;function Jc(s,n){return s==="=="||s==="!="?n.kind==="boolean"||n.kind==="string"||n.kind==="number"||n.kind==="null"||n.kind==="value":n.kind==="string"||n.kind==="number"||n.kind==="value"}function So(s,n,o,d){return d.compare(n,o)===0}function xa(s,n,o){const d=s!=="=="&&s!=="!=";return class PF{constructor(v,E,L){this.type=Ar,this.lhs=v,this.rhs=E,this.collator=L,this.hasUntypedArgument=v.type.kind==="value"||E.type.kind==="value"}static parse(v,E){if(v.length!==3&&v.length!==4)return E.error("Expected two or three arguments.");const L=v[0];let k=E.parse(v[1],1,dr);if(!k)return null;if(!Jc(L,k.type))return E.concat(1).error(`"${L}" comparisons are not supported for type '${hs(k.type)}'.`);let V=E.parse(v[2],2,dr);if(!V)return null;if(!Jc(L,V.type))return E.concat(2).error(`"${L}" comparisons are not supported for type '${hs(V.type)}'.`);if(k.type.kind!==V.type.kind&&k.type.kind!=="value"&&V.type.kind!=="value")return E.error(`Cannot compare types '${hs(k.type)}' and '${hs(V.type)}'.`);d&&(k.type.kind==="value"&&V.type.kind!=="value"?k=new Qo(V.type,[k]):k.type.kind!=="value"&&V.type.kind==="value"&&(V=new Qo(k.type,[V])));let q=null;if(v.length===4){if(k.type.kind!=="string"&&V.type.kind!=="string"&&k.type.kind!=="value"&&V.type.kind!=="value")return E.error("Cannot use collator to compare non-string types.");if(q=E.parse(v[3],3,Ul),!q)return null}return new PF(k,V,q)}evaluate(v){const E=this.lhs.evaluate(v),L=this.rhs.evaluate(v);if(d&&this.hasUntypedArgument){const k=Cs(E),V=Cs(L);if(k.kind!==V.kind||k.kind!=="string"&&k.kind!=="number")throw new er(`Expected arguments for "${s}" to be (string, string) or (number, number), but found (${k.kind}, ${V.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const k=Cs(E),V=Cs(L);if(k.kind!=="string"||V.kind!=="string")return n(v,E,L)}return this.collator?o(v,E,L,this.collator.evaluate(v)):n(v,E,L)}eachChild(v){v(this.lhs),v(this.rhs),this.collator&&v(this.collator)}outputDefined(){return!0}serialize(){const v=[s];return this.eachChild(E=>{v.push(E.serialize())}),v}}}const Mo=xa("==",function(s,n,o){return n===o},So),rd=xa("!=",function(s,n,o){return n!==o},function(s,n,o,d){return!So(0,n,o,d)}),Ga=xa("<",function(s,n,o){return n",function(s,n,o){return n>o},function(s,n,o,d){return d.compare(n,o)>0}),ml=xa("<=",function(s,n,o){return n<=o},function(s,n,o,d){return d.compare(n,o)<=0}),kh=xa(">=",function(s,n,o){return n>=o},function(s,n,o,d){return d.compare(n,o)>=0});class Oh{constructor(n,o,d,g,v,E){this.type=cr,this.number=n,this.locale=o,this.currency=d,this.unit=g,this.minFractionDigits=v,this.maxFractionDigits=E}static parse(n,o){if(n.length!==3)return o.error("Expected two arguments.");const d=o.parse(n[1],1,rn);if(!d)return null;const g=n[2];if(typeof g!="object"||Array.isArray(g))return o.error("NumberFormat options argument must be an object.");let v=null;if(g.locale&&(v=o.parse(g.locale,1,cr),!v))return null;let E=null;if(g.currency&&(E=o.parse(g.currency,1,cr),!E))return null;let L=null;if(g.unit&&(L=o.parse(g.unit,1,cr),!L))return null;let k=null;if(g["min-fraction-digits"]&&(k=o.parse(g["min-fraction-digits"],1,rn),!k))return null;let V=null;return g["max-fraction-digits"]&&(V=o.parse(g["max-fraction-digits"],1,rn),!V)?null:new Oh(d,v,E,L,k,V)}evaluate(n){return new Intl.NumberFormat(this.locale?this.locale.evaluate(n):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(n):void 0,unit:this.unit?this.unit.evaluate(n):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(n):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(n):void 0}).format(this.number.evaluate(n))}eachChild(n){n(this.number),this.locale&&n(this.locale),this.currency&&n(this.currency),this.unit&&n(this.unit),this.minFractionDigits&&n(this.minFractionDigits),this.maxFractionDigits&&n(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const n={};return this.locale&&(n.locale=this.locale.serialize()),this.currency&&(n.currency=this.currency.serialize()),this.unit&&(n.unit=this.unit.serialize()),this.minFractionDigits&&(n["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(n["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),n]}}class lA{constructor(n){this.type=rn,this.input=n}static parse(n,o){if(n.length!==2)return o.error(`Expected 1 argument, but found ${n.length-1} instead.`);const d=o.parse(n[1],1);return d?d.type.kind!=="array"&&d.type.kind!=="string"&&d.type.kind!=="value"?o.error(`Expected argument of type string or array, but found ${hs(d.type)} instead.`):new lA(d):null}evaluate(n){const o=this.input.evaluate(n);if(typeof o=="string"||Array.isArray(o))return o.length;throw new er(`Expected value to be of type string or array, but found ${hs(Cs(o))} instead.`)}eachChild(n){n(this.input)}outputDefined(){return!1}serialize(){const n=["length"];return this.eachChild(o=>{n.push(o.serialize())}),n}}const od={"==":Mo,"!=":rd,">":sd,"<":Ga,">=":kh,"<=":ml,array:Qo,at:Xc,boolean:Qo,case:pc,coalesce:xu,collator:zc,format:hl,image:Sh,in:qc,"index-of":Rh,interpolate:Ho,"interpolate-hcl":Ho,"interpolate-lab":Ho,length:lA,let:vu,literal:sc,match:nd,number:Qo,"number-format":Oh,object:Qo,slice:zh,step:Hl,string:Qo,"to-boolean":Va,"to-color":Va,"to-number":Va,"to-string":Va,var:qr,within:_u};function Nh(s,[n,o,d,g]){n=n.evaluate(s),o=o.evaluate(s),d=d.evaluate(s);const v=g?g.evaluate(s):1,E=ed(n,o,d,v);if(E)throw new er(E);return new fs(n/255*v,o/255*v,d/255*v,v)}function fc(s,n){return s in n}function ua(s,n){const o=n[s];return o===void 0?null:o}function pn(s){return{type:s}}ya.register(od,{error:[{kind:"error"},[cr],(s,[n])=>{throw new er(n.evaluate(s))}],typeof:[cr,[dr],(s,[n])=>hs(Cs(n.evaluate(s)))],"to-rgba":[qs(rn,4),[la],(s,[n])=>n.evaluate(s).toArray()],rgb:[la,[rn,rn,rn],Nh],rgba:[la,[rn,rn,rn,rn],Nh],has:{type:Ar,overloads:[[[cr],(s,[n])=>fc(n.evaluate(s),s.properties())],[[cr,al],(s,[n,o])=>fc(n.evaluate(s),o.evaluate(s))]]},get:{type:dr,overloads:[[[cr],(s,[n])=>ua(n.evaluate(s),s.properties())],[[cr,al],(s,[n,o])=>ua(n.evaluate(s),o.evaluate(s))]]},"feature-state":[dr,[cr],(s,[n])=>ua(n.evaluate(s),s.featureState||{})],properties:[al,[],s=>s.properties()],"geometry-type":[cr,[],s=>s.geometryType()],id:[dr,[],s=>s.id()],zoom:[rn,[],s=>s.globals.zoom],pitch:[rn,[],s=>s.globals.pitch||0],"distance-from-center":[rn,[],s=>s.distanceFromCenter()],"heatmap-density":[rn,[],s=>s.globals.heatmapDensity||0],"line-progress":[rn,[],s=>s.globals.lineProgress||0],"sky-radial-progress":[rn,[],s=>s.globals.skyRadialProgress||0],accumulated:[dr,[],s=>s.globals.accumulated===void 0?null:s.globals.accumulated],"+":[rn,pn(rn),(s,n)=>{let o=0;for(const d of n)o+=d.evaluate(s);return o}],"*":[rn,pn(rn),(s,n)=>{let o=1;for(const d of n)o*=d.evaluate(s);return o}],"-":{type:rn,overloads:[[[rn,rn],(s,[n,o])=>n.evaluate(s)-o.evaluate(s)],[[rn],(s,[n])=>-n.evaluate(s)]]},"/":[rn,[rn,rn],(s,[n,o])=>n.evaluate(s)/o.evaluate(s)],"%":[rn,[rn,rn],(s,[n,o])=>n.evaluate(s)%o.evaluate(s)],ln2:[rn,[],()=>Math.LN2],pi:[rn,[],()=>Math.PI],e:[rn,[],()=>Math.E],"^":[rn,[rn,rn],(s,[n,o])=>Math.pow(n.evaluate(s),o.evaluate(s))],sqrt:[rn,[rn],(s,[n])=>Math.sqrt(n.evaluate(s))],log10:[rn,[rn],(s,[n])=>Math.log(n.evaluate(s))/Math.LN10],ln:[rn,[rn],(s,[n])=>Math.log(n.evaluate(s))],log2:[rn,[rn],(s,[n])=>Math.log(n.evaluate(s))/Math.LN2],sin:[rn,[rn],(s,[n])=>Math.sin(n.evaluate(s))],cos:[rn,[rn],(s,[n])=>Math.cos(n.evaluate(s))],tan:[rn,[rn],(s,[n])=>Math.tan(n.evaluate(s))],asin:[rn,[rn],(s,[n])=>Math.asin(n.evaluate(s))],acos:[rn,[rn],(s,[n])=>Math.acos(n.evaluate(s))],atan:[rn,[rn],(s,[n])=>Math.atan(n.evaluate(s))],min:[rn,pn(rn),(s,n)=>Math.min(...n.map(o=>o.evaluate(s)))],max:[rn,pn(rn),(s,n)=>Math.max(...n.map(o=>o.evaluate(s)))],abs:[rn,[rn],(s,[n])=>Math.abs(n.evaluate(s))],round:[rn,[rn],(s,[n])=>{const o=n.evaluate(s);return o<0?-Math.round(-o):Math.round(o)}],floor:[rn,[rn],(s,[n])=>Math.floor(n.evaluate(s))],ceil:[rn,[rn],(s,[n])=>Math.ceil(n.evaluate(s))],"filter-==":[Ar,[cr,dr],(s,[n,o])=>s.properties()[n.value]===o.value],"filter-id-==":[Ar,[dr],(s,[n])=>s.id()===n.value],"filter-type-==":[Ar,[cr],(s,[n])=>s.geometryType()===n.value],"filter-<":[Ar,[cr,dr],(s,[n,o])=>{const d=s.properties()[n.value],g=o.value;return typeof d==typeof g&&d{const o=s.id(),d=n.value;return typeof o==typeof d&&o":[Ar,[cr,dr],(s,[n,o])=>{const d=s.properties()[n.value],g=o.value;return typeof d==typeof g&&d>g}],"filter-id->":[Ar,[dr],(s,[n])=>{const o=s.id(),d=n.value;return typeof o==typeof d&&o>d}],"filter-<=":[Ar,[cr,dr],(s,[n,o])=>{const d=s.properties()[n.value],g=o.value;return typeof d==typeof g&&d<=g}],"filter-id-<=":[Ar,[dr],(s,[n])=>{const o=s.id(),d=n.value;return typeof o==typeof d&&o<=d}],"filter->=":[Ar,[cr,dr],(s,[n,o])=>{const d=s.properties()[n.value],g=o.value;return typeof d==typeof g&&d>=g}],"filter-id->=":[Ar,[dr],(s,[n])=>{const o=s.id(),d=n.value;return typeof o==typeof d&&o>=d}],"filter-has":[Ar,[dr],(s,[n])=>n.value in s.properties()],"filter-has-id":[Ar,[],s=>s.id()!==null&&s.id()!==void 0],"filter-type-in":[Ar,[qs(cr)],(s,[n])=>n.value.indexOf(s.geometryType())>=0],"filter-id-in":[Ar,[qs(dr)],(s,[n])=>n.value.indexOf(s.id())>=0],"filter-in-small":[Ar,[cr,qs(dr)],(s,[n,o])=>o.value.indexOf(s.properties()[n.value])>=0],"filter-in-large":[Ar,[cr,qs(dr)],(s,[n,o])=>function(d,g,v,E){for(;v<=E;){const L=v+E>>1;if(g[L]===d)return!0;g[L]>d?E=L-1:v=L+1}return!1}(s.properties()[n.value],o.value,0,o.value.length-1)],all:{type:Ar,overloads:[[[Ar,Ar],(s,[n,o])=>n.evaluate(s)&&o.evaluate(s)],[pn(Ar),(s,n)=>{for(const o of n)if(!o.evaluate(s))return!1;return!0}]]},any:{type:Ar,overloads:[[[Ar,Ar],(s,[n,o])=>n.evaluate(s)||o.evaluate(s)],[pn(Ar),(s,n)=>{for(const o of n)if(o.evaluate(s))return!0;return!1}]]},"!":[Ar,[Ar],(s,[n])=>!n.evaluate(s)],"is-supported-script":[Ar,[cr],(s,[n])=>{const o=s.globals&&s.globals.isSupportedScript;return!o||o(n.evaluate(s))}],upcase:[cr,[cr],(s,[n])=>n.evaluate(s).toUpperCase()],downcase:[cr,[cr],(s,[n])=>n.evaluate(s).toLowerCase()],concat:[cr,pn(dr),(s,n)=>n.map(o=>rc(o.evaluate(s))).join("")],"resolved-locale":[cr,[Ul],(s,[n])=>n.evaluate(s).resolvedLocale()]});var eh=od;function Wl(s){return{result:"success",value:s}}function Ns(s){return{result:"error",value:s}}function gl(s){return s["property-type"]==="data-driven"}function un(s){return!!s.expression&&s.expression.parameters.indexOf("zoom")>-1}function th(s){return!!s.expression&&s.expression.interpolated}function Ur(s){return s instanceof Number?"number":s instanceof String?"string":s instanceof Boolean?"boolean":Array.isArray(s)?"array":s===null?"null":typeof s}function mc(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function cA(s){return s}function Qh(s,n){const o=n.type==="color",d=s.stops&&typeof s.stops[0][0]=="object",g=d||!(d||s.property!==void 0),v=s.type||(th(n)?"exponential":"interval");if(o&&((s=sr({},s)).stops&&(s.stops=s.stops.map(V=>[V[0],fs.parse(V[1])])),s.default=fs.parse(s.default?s.default:n.default)),s.colorSpace&&s.colorSpace!=="rgb"&&!$c[s.colorSpace])throw new Error(`Unknown color space: ${s.colorSpace}`);let E,L,k;if(v==="exponential")E=Vh;else if(v==="interval")E=uA;else if(v==="categorical"){E=hA,L=Object.create(null);for(const V of s.stops)L[V[0]]=V[1];k=typeof s.stops[0][0]}else{if(v!=="identity")throw new Error(`Unknown function type "${v}"`);E=Hh}if(d){const V={},q=[];for(let _e=0;_e_e[0]),evaluate:({zoom:_e},be)=>Vh({stops:se,base:s.base},n,_e).evaluate(_e,be)}}if(g){const V=v==="exponential"?{name:"exponential",base:s.base!==void 0?s.base:1}:null;return{kind:"camera",interpolationType:V,interpolationFactor:Ho.interpolationFactor.bind(void 0,V),zoomStops:s.stops.map(q=>q[0]),evaluate:({zoom:q})=>E(s,n,q,L,k)}}return{kind:"source",evaluate(V,q){const se=q&&q.properties?q.properties[s.property]:void 0;return se===void 0?gc(s.default,n.default):E(s,n,se,L,k)}}}function gc(s,n,o){return s!==void 0?s:n!==void 0?n:o!==void 0?o:void 0}function hA(s,n,o,d,g){return gc(typeof o===g?d[o]:void 0,s.default,n.default)}function uA(s,n,o){if(Ur(o)!=="number")return gc(s.default,n.default);const d=s.stops.length;if(d===1||o<=s.stops[0][0])return s.stops[0][1];if(o>=s.stops[d-1][0])return s.stops[d-1][1];const g=jr(s.stops.map(v=>v[0]),o);return s.stops[g][1]}function Vh(s,n,o){const d=s.base!==void 0?s.base:1;if(Ur(o)!=="number")return gc(s.default,n.default);const g=s.stops.length;if(g===1||o<=s.stops[0][0])return s.stops[0][1];if(o>=s.stops[g-1][0])return s.stops[g-1][1];const v=jr(s.stops.map(q=>q[0]),o),E=function(q,se,he,_e){const be=_e-he,De=q-he;return be===0?0:se===1?De/be:(Math.pow(se,De)-1)/(Math.pow(se,be)-1)}(o,d,s.stops[v][0],s.stops[v+1][0]),L=s.stops[v][1],k=s.stops[v+1][1];let V=yu[n.type]||cA;if(s.colorSpace&&s.colorSpace!=="rgb"){const q=$c[s.colorSpace];V=(se,he)=>q.reverse(q.interpolate(q.forward(se),q.forward(he),E))}return typeof L.evaluate=="function"?{evaluate(...q){const se=L.evaluate.apply(void 0,q),he=k.evaluate.apply(void 0,q);if(se!==void 0&&he!==void 0)return V(se,he,E)}}:V(L,k,E)}function Hh(s,n,o){return n.type==="color"?o=fs.parse(o):n.type==="formatted"?o=Os.fromString(o.toString()):n.type==="resolvedImage"?o=No.fromString(o.toString()):Ur(o)===n.type||n.type==="enum"&&n.values[o]||(o=void 0),gc(o,s.default,n.default)}class ih{constructor(n,o){this.expression=n,this._warningHistory={},this._evaluator=new fu,this._defaultValue=o?function(d){return d.type==="color"&&(mc(d.default)||Array.isArray(d.default))?new fs(0,0,0,0):d.type==="color"?fs.parse(d.default)||null:d.default===void 0?null:d.default}(o):null,this._enumValues=o&&o.type==="enum"?o.values:null}evaluateWithoutErrorHandling(n,o,d,g,v,E,L,k){return this._evaluator.globals=n,this._evaluator.feature=o,this._evaluator.featureState=d,this._evaluator.canonical=g||null,this._evaluator.availableImages=v||null,this._evaluator.formattedSection=E,this._evaluator.featureTileCoord=L||null,this._evaluator.featureDistanceData=k||null,this.expression.evaluate(this._evaluator)}evaluate(n,o,d,g,v,E,L,k){this._evaluator.globals=n,this._evaluator.feature=o||null,this._evaluator.featureState=d||null,this._evaluator.canonical=g||null,this._evaluator.availableImages=v||null,this._evaluator.formattedSection=E||null,this._evaluator.featureTileCoord=L||null,this._evaluator.featureDistanceData=k||null;try{const V=this.expression.evaluate(this._evaluator);if(V==null||typeof V=="number"&&V!=V)return this._defaultValue;if(this._enumValues&&!(V in this._enumValues))throw new er(`Expected value to be one of ${Object.keys(this._enumValues).map(q=>JSON.stringify(q)).join(", ")}, but found ${JSON.stringify(V)} instead.`);return V}catch(V){return this._warningHistory[V.message]||(this._warningHistory[V.message]=!0,typeof console<"u"&&console.warn(V.message)),this._defaultValue}}}function _c(s){return Array.isArray(s)&&s.length>0&&typeof s[0]=="string"&&s[0]in eh}function Is(s,n){const o=new hr(eh,[],n?function(g){const v={color:la,string:cr,number:rn,enum:cr,boolean:Ar,formatted:Rl,resolvedImage:ll};return g.type==="array"?qs(v[g.value]||dr,g.length):v[g.type]}(n):void 0),d=o.parse(s,void 0,void 0,void 0,n&&n.type==="string"?{typeAnnotation:"coerce"}:void 0);return d?Wl(new ih(d,n)):Ns(o.errors)}class fo{constructor(n,o){this.kind=n,this._styleExpression=o,this.isStateDependent=n!=="constant"&&!Ha(o.expression)}evaluateWithoutErrorHandling(n,o,d,g,v,E){return this._styleExpression.evaluateWithoutErrorHandling(n,o,d,g,v,E)}evaluate(n,o,d,g,v,E){return this._styleExpression.evaluate(n,o,d,g,v,E)}}class Gh{constructor(n,o,d,g){this.kind=n,this.zoomStops=d,this._styleExpression=o,this.isStateDependent=n!=="camera"&&!Ha(o.expression),this.interpolationType=g}evaluateWithoutErrorHandling(n,o,d,g,v,E){return this._styleExpression.evaluateWithoutErrorHandling(n,o,d,g,v,E)}evaluate(n,o,d,g,v,E){return this._styleExpression.evaluate(n,o,d,g,v,E)}interpolationFactor(n,o,d){return this.interpolationType?Ho.interpolationFactor(this.interpolationType,n,o,d):0}}function jl(s,n){if((s=Is(s,n)).result==="error")return s;const o=s.value.expression,d=Al(o);if(!d&&!gl(n))return Ns([new Mr("","data expressions not supported")]);const g=Qc(o,["zoom","pitch","distance-from-center"]);if(!g&&!un(n))return Ns([new Mr("","zoom expressions not supported")]);const v=_l(o);return v||g?v instanceof Mr?Ns([v]):v instanceof Ho&&!th(n)?Ns([new Mr("",'"interpolate" expressions cannot be used with this property')]):Wl(v?new Gh(d?"camera":"composite",s.value,v.labels,v instanceof Ho?v.interpolation:void 0):new fo(d?"constant":"source",s.value)):Ns([new Mr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Kl{constructor(n,o){this._parameters=n,this._specification=o,sr(this,Qh(this._parameters,this._specification))}static deserialize(n){return new Kl(n._parameters,n._specification)}static serialize(n){return{_parameters:n._parameters,_specification:n._specification}}}function _l(s){let n=null;if(s instanceof vu)n=_l(s.result);else if(s instanceof xu){for(const o of s.args)if(n=_l(o),n)break}else(s instanceof Hl||s instanceof Ho)&&s.input instanceof ya&&s.input.name==="zoom"&&(n=s);return n instanceof Mr||s.eachChild(o=>{const d=_l(o);d instanceof Mr?n=d:!n&&d?n=new Mr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):n&&d&&n!==d&&(n=new Mr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),n}class An{constructor(n,o,d,g){this.message=(n?`${n}: `:"")+d,g&&(this.identifier=g),o!=null&&o.__line__&&(this.line=o.__line__)}}function vs(s){const n=s.key,o=s.value,d=s.valueSpec||{},g=s.objectElementValidators||{},v=s.style,E=s.styleSpec;let L=[];const k=Ur(o);if(k!=="object")return[new An(n,o,`object expected, ${k} found`)];for(const V in o){const q=V.split(".")[0],se=d[q]||d["*"];let he;g[q]?he=g[q]:d[q]?he=Te:g["*"]?he=g["*"]:d["*"]&&(he=Te),he?L=L.concat(he({key:(n&&`${n}.`)+V,value:o[V],valueSpec:se,style:v,styleSpec:E,object:o,objectKey:V},o)):L.push(new An(n,o[V],`unknown property "${V}"`))}for(const V in d)g[V]||d[V].required&&d[V].default===void 0&&o[V]===void 0&&L.push(new An(n,o,`missing required property "${V}"`));return L}function Zr(s){const n=s.value,o=s.valueSpec,d=s.style,g=s.styleSpec,v=s.key,E=s.arrayElementValidator||Te;if(Ur(n)!=="array")return[new An(v,n,`array expected, ${Ur(n)} found`)];if(o.length&&n.length!==o.length)return[new An(v,n,`array length ${o.length} expected, length ${n.length} found`)];if(o["min-length"]&&n.lengthv)return[new An(n,o,`${o} is greater than the maximum value ${v}`)]}return[]}function Wh(s){const n=s.valueSpec,o=Yn(s.value.type);let d,g,v,E={};const L=o!=="categorical"&&s.value.property===void 0,k=!L,V=Ur(s.value.stops)==="array"&&Ur(s.value.stops[0])==="array"&&Ur(s.value.stops[0][0])==="object",q=vs({key:s.key,value:s.value,valueSpec:s.styleSpec.function,style:s.style,styleSpec:s.styleSpec,objectElementValidators:{stops:function(_e){if(o==="identity")return[new An(_e.key,_e.value,'identity function may not have a "stops" property')];let be=[];const De=_e.value;return be=be.concat(Zr({key:_e.key,value:De,valueSpec:_e.valueSpec,style:_e.style,styleSpec:_e.styleSpec,arrayElementValidator:se})),Ur(De)==="array"&&De.length===0&&be.push(new An(_e.key,De,"array must have at least one stop")),be},default:function(_e){return Te({key:_e.key,value:_e.value,valueSpec:n,style:_e.style,styleSpec:_e.styleSpec})}}});return o==="identity"&&L&&q.push(new An(s.key,s.value,'missing required property "property"')),o==="identity"||s.value.stops||q.push(new An(s.key,s.value,'missing required property "stops"')),o==="exponential"&&s.valueSpec.expression&&!th(s.valueSpec)&&q.push(new An(s.key,s.value,"exponential functions not supported")),s.styleSpec.$version>=8&&(k&&!gl(s.valueSpec)?q.push(new An(s.key,s.value,"property functions not supported")):L&&!un(s.valueSpec)&&q.push(new An(s.key,s.value,"zoom functions not supported"))),o!=="categorical"&&!V||s.value.property!==void 0||q.push(new An(s.key,s.value,'"property" property is required')),q;function se(_e){let be=[];const De=_e.value,Ze=_e.key;if(Ur(De)!=="array")return[new An(Ze,De,`array expected, ${Ur(De)} found`)];if(De.length!==2)return[new An(Ze,De,`array length 2 expected, length ${De.length} found`)];if(V){if(Ur(De[0])!=="object")return[new An(Ze,De,`object expected, ${Ur(De[0])} found`)];if(De[0].zoom===void 0)return[new An(Ze,De,"object stop key must have zoom")];if(De[0].value===void 0)return[new An(Ze,De,"object stop key must have value")];const xt=Yn(De[0].zoom);if(typeof xt!="number")return[new An(Ze,De[0].zoom,"stop zoom values must be numbers")];if(v&&v>xt)return[new An(Ze,De[0].zoom,"stop zoom values must appear in ascending order")];xt!==v&&(v=xt,g=void 0,E={}),be=be.concat(vs({key:`${Ze}[0]`,value:De[0],valueSpec:{zoom:{}},style:_e.style,styleSpec:_e.styleSpec,objectElementValidators:{zoom:nh,value:he}}))}else be=be.concat(he({key:`${Ze}[0]`,value:De[0],valueSpec:{},style:_e.style,styleSpec:_e.styleSpec},De));return _c(Wr(De[1]))?be.concat([new An(`${Ze}[1]`,De[1],"expressions are not allowed in function stops.")]):be.concat(Te({key:`${Ze}[1]`,value:De[1],valueSpec:n,style:_e.style,styleSpec:_e.styleSpec}))}function he(_e,be){const De=Ur(_e.value),Ze=Yn(_e.value),xt=_e.value!==null?_e.value:be;if(d){if(De!==d)return[new An(_e.key,xt,`${De} stop domain type must match previous stop domain type ${d}`)]}else d=De;if(De!=="number"&&De!=="string"&&De!=="boolean"&&typeof Ze!="number"&&typeof Ze!="string"&&typeof Ze!="boolean")return[new An(_e.key,xt,"stop domain value must be a number, string, or boolean")];if(De!=="number"&&o!=="categorical"){let Dt=`number expected, ${De} found`;return gl(n)&&o===void 0&&(Dt+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new An(_e.key,xt,Dt)]}return o!=="categorical"||De!=="number"||typeof Ze=="number"&&isFinite(Ze)&&Math.floor(Ze)===Ze?o!=="categorical"&&De==="number"&&typeof Ze=="number"&&typeof g=="number"&&g!==void 0&&Zenew An(`${s.key}${d.key}`,s.value,d.message));const o=n.value.expression||n.value._styleExpression.expression;if(s.expressionContext==="property"&&s.propertyKey==="text-font"&&!o.outputDefined())return[new An(s.key,s.value,`Invalid data expression for "${s.propertyKey}". Output values must be contained as literals within the expression.`)];if(s.expressionContext==="property"&&s.propertyType==="layout"&&!Ha(o))return[new An(s.key,s.value,'"feature-state" data expressions are not supported with layout properties.')];if(s.expressionContext==="filter")return AA(o,s);if(s.expressionContext&&s.expressionContext.indexOf("cluster")===0){if(!Qc(o,["zoom","feature-state"]))return[new An(s.key,s.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(s.expressionContext==="cluster-initial"&&!Al(o))return[new An(s.key,s.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function AA(s,n){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(n.valueSpec&&n.valueSpec.expression)for(const g of n.valueSpec.expression.parameters)o.delete(g);if(o.size===0)return[];const d=[];return s instanceof ya&&o.has(s.name)?[new An(n.key,n.value,`["${s.name}"] expression is not supported in a filter for a ${n.object.type} layer with id: ${n.object.id}`)]:(s.eachChild(g=>{d.push(...AA(g,n))}),d)}function jh(s){const n=s.key,o=s.value,d=s.valueSpec,g=[];return Array.isArray(d.values)?d.values.indexOf(Yn(o))===-1&&g.push(new An(n,o,`expected one of [${d.values.join(", ")}], ${JSON.stringify(o)} found`)):Object.keys(d.values).indexOf(Yn(o))===-1&&g.push(new An(n,o,`expected one of [${Object.keys(d.values).join(", ")}], ${JSON.stringify(o)} found`)),g}function rh(s){if(s===!0||s===!1)return!0;if(!Array.isArray(s)||s.length===0)return!1;switch(s[0]){case"has":return s.length>=2&&s[1]!=="$id"&&s[1]!=="$type";case"in":return s.length>=3&&(typeof s[1]!="string"||Array.isArray(s[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return s.length!==3||Array.isArray(s[1])||Array.isArray(s[2]);case"any":case"all":for(const n of s.slice(1))if(!rh(n)&&typeof n!="boolean")return!1;return!0;default:return!0}}function uo(s,n="fill"){if(s==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};rh(s)||(s=Es(s));const o=s;let d=!0;try{d=function(V){if(!Vn(V))return V;let q=Wr(V);return Fn(q),q=Js(q),q}(o)}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(o,null,2)} `)}const g=Yt[`filter_${n}`],v=Is(d,g);let E=null;if(v.result==="error")throw new Error(v.value.map(V=>`${V.key}: ${V.message}`).join(", "));E=(V,q,se)=>v.value.evaluate(V,q,{},se);let L=null,k=null;if(d!==o){const V=Is(o,g);if(V.result==="error")throw new Error(V.value.map(q=>`${q.key}: ${q.message}`).join(", "));L=(q,se,he,_e,be)=>V.value.evaluate(q,se,{},he,void 0,void 0,_e,be),k=!Al(V.value.expression)}return{filter:E,dynamicFilter:L||void 0,needGeometry:yl(d),needFeature:!!k}}function Js(s){if(!Array.isArray(s))return s;const n=function(o){if(sh.has(o[0])){for(let d=1;dJs(o))}function Fn(s){let n=!1;const o=[];if(s[0]==="case"){for(let d=1;d",">=","<","<=","to-boolean"]);function dA(s,n){return sn?1:0}function yl(s){if(!Array.isArray(s))return!1;if(s[0]==="within")return!0;for(let n=1;n"||n==="<="||n===">="?Wa(s[1],s[2],n):n==="any"?(o=s.slice(1),["any"].concat(o.map(Es))):n==="all"?["all"].concat(s.slice(1).map(Es)):n==="none"?["all"].concat(s.slice(1).map(Es).map(va)):n==="in"?Go(s[1],s.slice(2)):n==="!in"?va(Go(s[1],s.slice(2))):n==="has"?pA(s[1]):n==="!has"?va(pA(s[1])):n!=="within"||s;var o}function Wa(s,n,o){switch(s){case"$type":return[`filter-type-${o}`,n];case"$id":return[`filter-id-${o}`,n];default:return[`filter-${o}`,s,n]}}function Go(s,n){if(n.length===0)return!1;switch(s){case"$type":return["filter-type-in",["literal",n]];case"$id":return["filter-id-in",["literal",n]];default:return n.length>200&&!n.some(o=>typeof o!=typeof n[0])?["filter-in-large",s,["literal",n.sort(dA)]]:["filter-in-small",s,["literal",n]]}}function pA(s){switch(s){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",s]}}function va(s){return["!",s]}function us(s){return rh(Wr(s.value))?yc(sr({},s,{expressionContext:"filter",valueSpec:s.styleSpec[`filter_${s.layerType||"fill"}`]})):Fs(s)}function Fs(s){const n=s.value,o=s.key;if(Ur(n)!=="array")return[new An(o,n,`array expected, ${Ur(n)} found`)];const d=s.styleSpec;let g,v=[];if(n.length<1)return[new An(o,n,"filter array must have at least 1 element")];switch(v=v.concat(jh({key:`${o}[0]`,value:n[0],valueSpec:d.filter_operator,style:s.style,styleSpec:s.styleSpec})),Yn(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&Yn(n[1])==="$type"&&v.push(new An(o,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":n.length!==3&&v.push(new An(o,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&(g=Ur(n[1]),g!=="string"&&v.push(new An(`${o}[1]`,n[1],`string expected, ${g} found`)));for(let E=2;E{V in o&&n.push(new An(d,o[V],`"${V}" is prohibited for ref layers`))}),g.layers.forEach(V=>{Yn(V.id)===L&&(k=V)}),k?k.ref?n.push(new An(d,o.ref,"ref cannot reference another ref layer")):E=Yn(k.type):typeof L=="string"&&n.push(new An(d,o.ref,`ref layer "${L}" not found`))}else if(E!=="background"&&E!=="sky")if(o.source){const k=g.sources&&g.sources[o.source],V=k&&Yn(k.type);k?V==="vector"&&E==="raster"?n.push(new An(d,o.source,`layer "${o.id}" requires a raster source`)):V==="raster"&&E!=="raster"?n.push(new An(d,o.source,`layer "${o.id}" requires a vector source`)):V!=="vector"||o["source-layer"]?V==="raster-dem"&&E!=="hillshade"?n.push(new An(d,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):E!=="line"||!o.paint||!o.paint["line-gradient"]&&!o.paint["line-trim-offset"]||V==="geojson"&&k.lineMetrics||n.push(new An(d,o,`layer "${o.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):n.push(new An(d,o,`layer "${o.id}" must specify a "source-layer"`)):n.push(new An(d,o.source,`source "${o.source}" not found`))}else n.push(new An(d,o,'missing required property "source"'));return n=n.concat(vs({key:d,value:o,valueSpec:v.layer,style:s.style,styleSpec:s.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Te({key:`${d}.type`,value:o.type,valueSpec:v.layer.type,style:s.style,styleSpec:s.styleSpec,object:o,objectKey:"type"}),filter:k=>us(sr({layerType:E},k)),layout:k=>vs({layer:o,key:k.key,value:k.value,valueSpec:{},style:k.style,styleSpec:k.styleSpec,objectElementValidators:{"*":V=>M(sr({layerType:E},V))}}),paint:k=>vs({layer:o,key:k.key,value:k.value,valueSpec:{},style:k.style,styleSpec:k.styleSpec,objectElementValidators:{"*":V=>xl(sr({layerType:E},V))}})}})),n}function _(s){const n=s.value,o=s.key,d=Ur(n);return d!=="string"?[new An(o,n,`string expected, ${d} found`)]:[]}const T={promoteId:function({key:s,value:n}){if(Ur(n)==="string")return _({key:s,value:n});{const o=[];for(const d in n)o.push(..._({key:`${s}.${d}`,value:n[d]}));return o}}};function F(s){const n=s.value,o=s.key,d=s.styleSpec,g=s.style;if(!n.type)return[new An(o,n,'"type" is required')];const v=Yn(n.type);let E;switch(v){case"vector":case"raster":case"raster-dem":return E=vs({key:o,value:n,valueSpec:d[`source_${v.replace("-","_")}`],style:s.style,styleSpec:d,objectElementValidators:T}),E;case"geojson":if(E=vs({key:o,value:n,valueSpec:d.source_geojson,style:g,styleSpec:d,objectElementValidators:T}),n.cluster)for(const L in n.clusterProperties){const[k,V]=n.clusterProperties[L],q=typeof k=="string"?[k,["accumulated"],["get",L]]:k;E.push(...yc({key:`${o}.${L}.map`,value:V,expressionContext:"cluster-map"})),E.push(...yc({key:`${o}.${L}.reduce`,value:q,expressionContext:"cluster-reduce"}))}return E;case"video":return vs({key:o,value:n,valueSpec:d.source_video,style:g,styleSpec:d});case"image":return vs({key:o,value:n,valueSpec:d.source_image,style:g,styleSpec:d});case"canvas":return[new An(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return jh({key:`${o}.type`,value:n.type,valueSpec:{values:O(d)},style:g,styleSpec:d})}}function O(s){return s.source.reduce((n,o)=>{const d=s[o];return d.type.type==="enum"&&(n=n.concat(Object.keys(d.type.values))),n},[])}function K(s){const n=s.value,o=s.styleSpec,d=o.light,g=s.style;let v=[];const E=Ur(n);if(n===void 0)return v;if(E!=="object")return v=v.concat([new An("light",n,`object expected, ${E} found`)]),v;for(const L in n){const k=L.match(/^(.*)-transition$/);v=v.concat(k&&d[k[1]]&&d[k[1]].transition?Te({key:L,value:n[L],valueSpec:o.transition,style:g,styleSpec:o}):d[L]?Te({key:L,value:n[L],valueSpec:d[L],style:g,styleSpec:o}):[new An(L,n[L],`unknown property "${L}"`)])}return v}function oe(s){const n=s.value,o=s.key,d=s.style,g=s.styleSpec,v=g.terrain;let E=[];const L=Ur(n);if(n===void 0)return E;if(L!=="object")return E=E.concat([new An("terrain",n,`object expected, ${L} found`)]),E;for(const k in n){const V=k.match(/^(.*)-transition$/);E=E.concat(V&&v[V[1]]&&v[V[1]].transition?Te({key:k,value:n[k],valueSpec:g.transition,style:d,styleSpec:g}):v[k]?Te({key:k,value:n[k],valueSpec:v[k],style:d,styleSpec:g}):[new An(k,n[k],`unknown property "${k}"`)])}if(n.source){const k=d.sources&&d.sources[n.source],V=k&&Yn(k.type);k?V!=="raster-dem"&&E.push(new An(o,n.source,`terrain cannot be used with a source of type ${String(V)}, it only be used with a "raster-dem" source type`)):E.push(new An(o,n.source,`source "${n.source}" not found`))}else E.push(new An(o,n,'terrain is missing required property "source"'));return E}function ue(s){const n=s.value,o=s.style,d=s.styleSpec,g=d.fog;let v=[];const E=Ur(n);if(n===void 0)return v;if(E!=="object")return v=v.concat([new An("fog",n,`object expected, ${E} found`)]),v;for(const L in n){const k=L.match(/^(.*)-transition$/);v=v.concat(k&&g[k[1]]&&g[k[1]].transition?Te({key:L,value:n[L],valueSpec:d.transition,style:o,styleSpec:d}):g[L]?Te({key:L,value:n[L],valueSpec:g[L],style:o,styleSpec:d}):[new An(L,n[L],`unknown property "${L}"`)])}return v}const ve={"*":()=>[],array:Zr,boolean:function(s){const n=s.value,o=s.key,d=Ur(n);return d!=="boolean"?[new An(o,n,`boolean expected, ${d} found`)]:[]},number:nh,color:function(s){const n=s.key,o=s.value,d=Ur(o);return d!=="string"?[new An(n,o,`color expected, ${d} found`)]:kl(o)===null?[new An(n,o,`color expected, "${o}" found`)]:[]},enum:jh,filter:us,function:Wh,layer:h,object:vs,source:F,light:K,terrain:oe,fog:ue,string:_,formatted:function(s){return _(s).length===0?[]:yc(s)},resolvedImage:function(s){return _(s).length===0?[]:yc(s)},projection:function(s){const n=s.value,o=s.styleSpec,d=o.projection,g=s.style;let v=[];const E=Ur(n);if(E==="object")for(const L in n)v=v.concat(Te({key:L,value:n[L],valueSpec:d[L],style:g,styleSpec:o}));else E!=="string"&&(v=v.concat([new An("projection",n,`object or string expected, ${E} found`)]));return v}};function Te(s){const n=s.value,o=s.valueSpec,d=s.styleSpec;return o.expression&&mc(Yn(n))?Wh(s):o.expression&&_c(Wr(n))?yc(s):o.type&&ve[o.type]?ve[o.type](s):vs(sr({},s,{valueSpec:o.type?d[o.type]:o}))}function ke(s){const n=s.value,o=s.key,d=_(s);return d.length||(n.indexOf("{fontstack}")===-1&&d.push(new An(o,n,'"glyphs" url must include a "{fontstack}" token')),n.indexOf("{range}")===-1&&d.push(new An(o,n,'"glyphs" url must include a "{range}" token'))),d}function We(s,n=Yt){return gt(Te({key:"",value:s,valueSpec:n.$root,styleSpec:n,style:s,objectElementValidators:{glyphs:ke,"*":()=>[]}}))}const bt=s=>gt(xl(s)),mt=s=>gt(M(s));function gt(s){return s.slice().sort((n,o)=>n.line&&o.line?n.line-o.line:0)}function Vt(s,n){let o=!1;if(n&&n.length)for(const d of n)s.fire(new rr(new Error(d.message))),o=!0;return o}var Zt=ni;function ni(s,n,o){var d=this.cells=[];if(s instanceof ArrayBuffer){this.arrayBuffer=s;var g=new Int32Array(this.arrayBuffer);s=g[0],this.d=(n=g[1])+2*(o=g[2]);for(var v=0;v=q[_e+0]&&d>=q[_e+1])?(E[he]=!0,v.push(V[he])):E[he]=!1}}},ni.prototype._forEachCell=function(s,n,o,d,g,v,E,L){for(var k=this._convertToCellCoord(s),V=this._convertToCellCoord(n),q=this._convertToCellCoord(o),se=this._convertToCellCoord(d),he=k;he<=q;he++)for(var _e=V;_e<=se;_e++){var be=this.d*_e+he;if((!L||L(this._convertFromCellCoord(he),this._convertFromCellCoord(_e),this._convertFromCellCoord(he+1),this._convertFromCellCoord(_e+1)))&&g.call(this,s,n,o,d,be,v,E,L))return}},ni.prototype._convertFromCellCoord=function(s){return(s-this.padding)/this.scale},ni.prototype._convertToCellCoord=function(s){return Math.max(0,Math.min(this.d-1,Math.floor(s*this.scale)+this.padding))},ni.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var s=this.cells,n=3+this.cells.length+1+1,o=0,d=0;d=0||(g[v]=bi(s[v],n)));s instanceof Error&&(g.message=s.message)}if(g.$name)throw new Error("$name property is reserved for worker serialization logic.");return d!=="Object"&&(g.$name=d),g}throw new Error("can't serialize object of type "+typeof s)}function Hi(s){if(s==null||typeof s=="boolean"||typeof s=="number"||typeof s=="string"||s instanceof Boolean||s instanceof Number||s instanceof String||s instanceof Date||s instanceof RegExp||li(s)||Ei(s)||ArrayBuffer.isView(s)||s instanceof C.ImageData)return s;if(Array.isArray(s))return s.map(Hi);if(typeof s=="object"){const n=s.$name||"Object",{klass:o}=St[n];if(!o)throw new Error(`can't deserialize unregistered class ${n}`);if(o.deserialize)return o.deserialize(s);const d=Object.create(o.prototype);for(const g of Object.keys(s))g!=="$name"&&(d[g]=Hi(s[g]));return d}throw new Error("can't deserialize object of type "+typeof s)}const xi=s=>s>=1536&&s<=1791,xn=s=>s>=1872&&s<=1919,cn=s=>s>=2208&&s<=2303,Bn=s=>s>=11904&&s<=12031,tr=s=>s>=12032&&s<=12255,ur=s=>s>=12272&&s<=12287,Un=s=>s>=12288&&s<=12351,Lr=s=>s>=12352&&s<=12447,Rr=s=>s>=12448&&s<=12543,Cr=s=>s>=12544&&s<=12591,Er=s=>s>=12704&&s<=12735,Gr=s=>s>=12736&&s<=12783,js=s=>s>=12784&&s<=12799,wa=s=>s>=12800&&s<=13055,Aa=s=>s>=13056&&s<=13311,ba=s=>s>=13312&&s<=19903,ja=s=>s>=19968&&s<=40959,Wo=s=>s>=40960&&s<=42127,mo=s=>s>=42128&&s<=42191,Ba=s=>s>=44032&&s<=55215,$l=s=>s>=63744&&s<=64255,x=s=>s>=64336&&s<=65023,a=s=>s>=65040&&s<=65055,m=s=>s>=65072&&s<=65103,b=s=>s>=65104&&s<=65135,S=s=>s>=65136&&s<=65279,P=s=>s>=65280&&s<=65519;function H(s){for(const n of s)if(pe(n.charCodeAt(0)))return!0;return!1}function W(s){for(const n of s)if(!ee(n.charCodeAt(0)))return!1;return!0}function ee(s){return!(xi(s)||xn(s)||cn(s)||x(s)||S(s))}function pe(s){return!(s!==746&&s!==747&&(s<4352||!(Er(s)||Cr(s)||m(s)&&!(s>=65097&&s<=65103)||$l(s)||Aa(s)||Bn(s)||Gr(s)||!(!Un(s)||s>=12296&&s<=12305||s>=12308&&s<=12319||s===12336)||ba(s)||ja(s)||wa(s)||(n=>n>=12592&&n<=12687)(s)||(n=>n>=43360&&n<=43391)(s)||(n=>n>=55216&&n<=55295)(s)||(n=>n>=4352&&n<=4607)(s)||Ba(s)||Lr(s)||ur(s)||(n=>n>=12688&&n<=12703)(s)||tr(s)||js(s)||Rr(s)&&s!==12540||!(!P(s)||s===65288||s===65289||s===65293||s>=65306&&s<=65310||s===65339||s===65341||s===65343||s>=65371&&s<=65503||s===65507||s>=65512&&s<=65519)||!(!b(s)||s>=65112&&s<=65118||s>=65123&&s<=65126)||(n=>n>=5120&&n<=5759)(s)||(n=>n>=6320&&n<=6399)(s)||a(s)||(n=>n>=19904&&n<=19967)(s)||Wo(s)||mo(s))))}function fe(s){return!(pe(s)||function(n){return!!((o=>o>=128&&o<=255)(n)&&(n===167||n===169||n===174||n===177||n===188||n===189||n===190||n===215||n===247)||(o=>o>=8192&&o<=8303)(n)&&(n===8214||n===8224||n===8225||n===8240||n===8241||n===8251||n===8252||n===8258||n===8263||n===8264||n===8265||n===8273)||(o=>o>=8448&&o<=8527)(n)||(o=>o>=8528&&o<=8591)(n)||(o=>o>=8960&&o<=9215)(n)&&(n>=8960&&n<=8967||n>=8972&&n<=8991||n>=8996&&n<=9e3||n===9003||n>=9085&&n<=9114||n>=9150&&n<=9165||n===9167||n>=9169&&n<=9179||n>=9186&&n<=9215)||(o=>o>=9216&&o<=9279)(n)&&n!==9251||(o=>o>=9280&&o<=9311)(n)||(o=>o>=9312&&o<=9471)(n)||(o=>o>=9632&&o<=9727)(n)||(o=>o>=9728&&o<=9983)(n)&&!(n>=9754&&n<=9759)||(o=>o>=11008&&o<=11263)(n)&&(n>=11026&&n<=11055||n>=11088&&n<=11097||n>=11192&&n<=11243)||Un(n)||Rr(n)||(o=>o>=57344&&o<=63743)(n)||m(n)||b(n)||P(n)||n===8734||n===8756||n===8757||n>=9984&&n<=10087||n>=10102&&n<=10131||n===65532||n===65533)}(s))}function Se(s){return s>=1424&&s<=2303||x(s)||S(s)}function Qe(s,n){return!(!n&&Se(s)||s>=2304&&s<=3583||s>=3840&&s<=4255||(o=>o>=6016&&o<=6143)(s))}function rt(s){for(const n of s)if(Se(n.charCodeAt(0)))return!0;return!1}const nt="deferred",lt="loading",Xe="loaded";let Ye=null,At="unavailable",ht=null;const Bt=function(s){s&&typeof s=="string"&&s.indexOf("NetworkError")>-1&&(At="error"),Ye&&Ye(s)};function Pt(){It.fire(new tn("pluginStateChange",{pluginStatus:At,pluginURL:ht}))}const It=new yn,Ht=function(){return At},hi=function(){if(At!==nt||!ht)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");At=lt,Pt(),ht&&Cn({url:ht},s=>{s?Bt(s):(At=Xe,Pt())})},si={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>At===Xe||si.applyArabicShaping!=null,isLoading:()=>At===lt,setState(s){At=s.pluginStatus,ht=s.pluginURL},isParsed:()=>si.applyArabicShaping!=null&&si.processBidirectionalText!=null&&si.processStyledBidirectionalText!=null,getPluginURL:()=>ht};class qt{constructor(n,o){this.zoom=n,o?(this.now=o.now,this.fadeDuration=o.fadeDuration,this.transition=o.transition,this.pitch=o.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(n){return function(o,d){for(const g of o)if(!Qe(g.charCodeAt(0),d))return!1;return!0}(n,si.isLoaded())}}class ji{constructor(n,o){this.property=n,this.value=o,this.expression=function(d,g){if(mc(d))return new Kl(d,g);if(_c(d)){const v=jl(d,g);if(v.result==="error")throw new Error(v.value.map(E=>`${E.key}: ${E.message}`).join(", "));return v.value}{let v=d;return typeof d=="string"&&g.type==="color"&&(v=fs.parse(d)),{kind:"constant",evaluate:()=>v}}}(o===void 0?n.specification.default:o,n.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(n,o,d){return this.property.possiblyEvaluate(this,n,o,d)}}class Kt{constructor(n){this.property=n,this.value=new ji(n,void 0)}transitioned(n,o){return new di(this.property,this.value,o,Ve({},n.transition,this.transition),n.now)}untransitioned(){return new di(this.property,this.value,null,{},0)}}class Bi{constructor(n){this._properties=n,this._values=Object.create(n.defaultTransitionablePropertyValues)}getValue(n){return Wt(this._values[n].value.value)}setValue(n,o){this._values.hasOwnProperty(n)||(this._values[n]=new Kt(this._values[n].property)),this._values[n].value=new ji(this._values[n].property,o===null?void 0:Wt(o))}getTransition(n){return Wt(this._values[n].transition)}setTransition(n,o){this._values.hasOwnProperty(n)||(this._values[n]=new Kt(this._values[n].property)),this._values[n].transition=Wt(o)||void 0}serialize(){const n={};for(const o of Object.keys(this._values)){const d=this.getValue(o);d!==void 0&&(n[o]=d);const g=this.getTransition(o);g!==void 0&&(n[`${o}-transition`]=g)}return n}transitioned(n,o){const d=new Ri(this._properties);for(const g of Object.keys(this._values))d._values[g]=this._values[g].transitioned(n,o._values[g]);return d}untransitioned(){const n=new Ri(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].untransitioned();return n}}class di{constructor(n,o,d,g,v){const E=g.delay||0,L=g.duration||0;v=v||0,this.property=n,this.value=o,this.begin=v+E,this.end=this.begin+L,n.specification.transition&&(g.delay||g.duration)&&(this.prior=d)}possiblyEvaluate(n,o,d){const g=n.now||0,v=this.value.possiblyEvaluate(n,o,d),E=this.prior;if(E){if(g>this.end)return this.prior=null,v;if(this.value.isDataDriven())return this.prior=null,v;if(gthis.capacity){this.capacity=Math.max(n,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const o=this.uint8;this._refreshViews(),o&&this.uint8.set(o)}}_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 _n(s,n=1){let o=0,d=0;return{members:s.map(g=>{const v=$n[g.type].BYTES_PER_ELEMENT,E=o=Dr(o,Math.max(n,v)),L=g.components||1;return d=Math.max(d,v),o+=v*L,{name:g.name,type:g.type,components:L,offset:E}}),size:Dr(o,Math.max(d,n)),alignment:n}}function Dr(s,n){return Math.ceil(s/n)*n}class Or extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o){const d=this.length;return this.resize(d+1),this.emplace(d,n,o)}emplace(n,o,d){const g=2*n;return this.int16[g+0]=o,this.int16[g+1]=d,n}}Or.prototype.bytesPerElement=4,zt(Or,"StructArrayLayout2i4");class Nr extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o,d){const g=this.length;return this.resize(g+1),this.emplace(g,n,o,d)}emplace(n,o,d,g){const v=3*n;return this.int16[v+0]=o,this.int16[v+1]=d,this.int16[v+2]=g,n}}Nr.prototype.bytesPerElement=6,zt(Nr,"StructArrayLayout3i6");class Qr extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o,d,g){const v=this.length;return this.resize(v+1),this.emplace(v,n,o,d,g)}emplace(n,o,d,g,v){const E=4*n;return this.int16[E+0]=o,this.int16[E+1]=d,this.int16[E+2]=g,this.int16[E+3]=v,n}}Qr.prototype.bytesPerElement=8,zt(Qr,"StructArrayLayout4i8");class go extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E,L){const k=this.length;return this.resize(k+1),this.emplace(k,n,o,d,g,v,E,L)}emplace(n,o,d,g,v,E,L,k){const V=6*n,q=12*n,se=3*n;return this.int16[V+0]=o,this.int16[V+1]=d,this.uint8[q+4]=g,this.uint8[q+5]=v,this.uint8[q+6]=E,this.uint8[q+7]=L,this.float32[se+2]=k,n}}go.prototype.bytesPerElement=12,zt(go,"StructArrayLayout2i4ub1f12");class Ca extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g){const v=this.length;return this.resize(v+1),this.emplace(v,n,o,d,g)}emplace(n,o,d,g,v){const E=4*n;return this.float32[E+0]=o,this.float32[E+1]=d,this.float32[E+2]=g,this.float32[E+3]=v,n}}Ca.prototype.bytesPerElement=16,zt(Ca,"StructArrayLayout4f16");class jo extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v){const E=this.length;return this.resize(E+1),this.emplace(E,n,o,d,g,v)}emplace(n,o,d,g,v,E){const L=6*n,k=3*n;return this.uint16[L+0]=o,this.uint16[L+1]=d,this.uint16[L+2]=g,this.uint16[L+3]=v,this.float32[k+2]=E,n}}jo.prototype.bytesPerElement=12,zt(jo,"StructArrayLayout4ui1f12");class ws extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o,d,g){const v=this.length;return this.resize(v+1),this.emplace(v,n,o,d,g)}emplace(n,o,d,g,v){const E=4*n;return this.uint16[E+0]=o,this.uint16[E+1]=d,this.uint16[E+2]=g,this.uint16[E+3]=v,n}}ws.prototype.bytesPerElement=8,zt(ws,"StructArrayLayout4ui8");class _r extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E){const L=this.length;return this.resize(L+1),this.emplace(L,n,o,d,g,v,E)}emplace(n,o,d,g,v,E,L){const k=6*n;return this.int16[k+0]=o,this.int16[k+1]=d,this.int16[k+2]=g,this.int16[k+3]=v,this.int16[k+4]=E,this.int16[k+5]=L,n}}_r.prototype.bytesPerElement=12,zt(_r,"StructArrayLayout6i12");class Xr extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E,L,k,V,q,se,he){const _e=this.length;return this.resize(_e+1),this.emplace(_e,n,o,d,g,v,E,L,k,V,q,se,he)}emplace(n,o,d,g,v,E,L,k,V,q,se,he,_e){const be=12*n;return this.int16[be+0]=o,this.int16[be+1]=d,this.int16[be+2]=g,this.int16[be+3]=v,this.uint16[be+4]=E,this.uint16[be+5]=L,this.uint16[be+6]=k,this.uint16[be+7]=V,this.int16[be+8]=q,this.int16[be+9]=se,this.int16[be+10]=he,this.int16[be+11]=_e,n}}Xr.prototype.bytesPerElement=24,zt(Xr,"StructArrayLayout4i4ui4i24");class Fr extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E){const L=this.length;return this.resize(L+1),this.emplace(L,n,o,d,g,v,E)}emplace(n,o,d,g,v,E,L){const k=10*n,V=5*n;return this.int16[k+0]=o,this.int16[k+1]=d,this.int16[k+2]=g,this.float32[V+2]=v,this.float32[V+3]=E,this.float32[V+4]=L,n}}Fr.prototype.bytesPerElement=20,zt(Fr,"StructArrayLayout3i3f20");class Ls extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(n){const o=this.length;return this.resize(o+1),this.emplace(o,n)}emplace(n,o){return this.uint32[1*n+0]=o,n}}Ls.prototype.bytesPerElement=4,zt(Ls,"StructArrayLayout1ul4");class eo extends On{_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(n,o,d,g,v,E,L,k,V,q,se,he,_e){const be=this.length;return this.resize(be+1),this.emplace(be,n,o,d,g,v,E,L,k,V,q,se,he,_e)}emplace(n,o,d,g,v,E,L,k,V,q,se,he,_e,be){const De=20*n,Ze=10*n;return this.int16[De+0]=o,this.int16[De+1]=d,this.int16[De+2]=g,this.int16[De+3]=v,this.int16[De+4]=E,this.float32[Ze+3]=L,this.float32[Ze+4]=k,this.float32[Ze+5]=V,this.float32[Ze+6]=q,this.int16[De+14]=se,this.uint32[Ze+8]=he,this.uint16[De+18]=_e,this.uint16[De+19]=be,n}}eo.prototype.bytesPerElement=40,zt(eo,"StructArrayLayout5i4f1i1ul2ui40");class rs extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E,L){const k=this.length;return this.resize(k+1),this.emplace(k,n,o,d,g,v,E,L)}emplace(n,o,d,g,v,E,L,k){const V=8*n;return this.int16[V+0]=o,this.int16[V+1]=d,this.int16[V+2]=g,this.int16[V+4]=v,this.int16[V+5]=E,this.int16[V+6]=L,this.int16[V+7]=k,n}}rs.prototype.bytesPerElement=16,zt(rs,"StructArrayLayout3i2i2i16");class Io extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v){const E=this.length;return this.resize(E+1),this.emplace(E,n,o,d,g,v)}emplace(n,o,d,g,v,E){const L=4*n,k=8*n;return this.float32[L+0]=o,this.float32[L+1]=d,this.float32[L+2]=g,this.int16[k+6]=v,this.int16[k+7]=E,n}}Io.prototype.bytesPerElement=16,zt(Io,"StructArrayLayout2f1f2i16");class bu extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g){const v=this.length;return this.resize(v+1),this.emplace(v,n,o,d,g)}emplace(n,o,d,g,v){const E=12*n,L=3*n;return this.uint8[E+0]=o,this.uint8[E+1]=d,this.float32[L+1]=g,this.float32[L+2]=v,n}}bu.prototype.bytesPerElement=12,zt(bu,"StructArrayLayout2ub2f12");class Ka extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d){const g=this.length;return this.resize(g+1),this.emplace(g,n,o,d)}emplace(n,o,d,g){const v=3*n;return this.float32[v+0]=o,this.float32[v+1]=d,this.float32[v+2]=g,n}}Ka.prototype.bytesPerElement=12,zt(Ka,"StructArrayLayout3f12");class _o extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o,d){const g=this.length;return this.resize(g+1),this.emplace(g,n,o,d)}emplace(n,o,d,g){const v=3*n;return this.uint16[v+0]=o,this.uint16[v+1]=d,this.uint16[v+2]=g,n}}_o.prototype.bytesPerElement=6,zt(_o,"StructArrayLayout3ui6");class Ea extends On{_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(n,o,d,g,v,E,L,k,V,q,se,he,_e,be,De,Ze,xt,Dt,_t,Tt,kt){const Ut=this.length;return this.resize(Ut+1),this.emplace(Ut,n,o,d,g,v,E,L,k,V,q,se,he,_e,be,De,Ze,xt,Dt,_t,Tt,kt)}emplace(n,o,d,g,v,E,L,k,V,q,se,he,_e,be,De,Ze,xt,Dt,_t,Tt,kt,Ut){const ci=30*n,ai=15*n,Ti=60*n;return this.int16[ci+0]=o,this.int16[ci+1]=d,this.int16[ci+2]=g,this.float32[ai+2]=v,this.float32[ai+3]=E,this.uint16[ci+8]=L,this.uint16[ci+9]=k,this.uint32[ai+5]=V,this.uint32[ai+6]=q,this.uint32[ai+7]=se,this.uint16[ci+16]=he,this.uint16[ci+17]=_e,this.uint16[ci+18]=be,this.float32[ai+10]=De,this.float32[ai+11]=Ze,this.uint8[Ti+48]=xt,this.uint8[Ti+49]=Dt,this.uint8[Ti+50]=_t,this.uint32[ai+13]=Tt,this.int16[ci+28]=kt,this.uint8[Ti+58]=Ut,n}}Ea.prototype.bytesPerElement=60,zt(Ea,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class vl extends On{_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(n,o,d,g,v,E,L,k,V,q,se,he,_e,be,De,Ze,xt,Dt,_t,Tt,kt,Ut,ci,ai,Ti,Ki,_i,Si,Li,Vi){const Zi=this.length;return this.resize(Zi+1),this.emplace(Zi,n,o,d,g,v,E,L,k,V,q,se,he,_e,be,De,Ze,xt,Dt,_t,Tt,kt,Ut,ci,ai,Ti,Ki,_i,Si,Li,Vi)}emplace(n,o,d,g,v,E,L,k,V,q,se,he,_e,be,De,Ze,xt,Dt,_t,Tt,kt,Ut,ci,ai,Ti,Ki,_i,Si,Li,Vi,Zi){const yi=38*n,sn=19*n;return this.int16[yi+0]=o,this.int16[yi+1]=d,this.int16[yi+2]=g,this.float32[sn+2]=v,this.float32[sn+3]=E,this.int16[yi+8]=L,this.int16[yi+9]=k,this.int16[yi+10]=V,this.int16[yi+11]=q,this.int16[yi+12]=se,this.int16[yi+13]=he,this.uint16[yi+14]=_e,this.uint16[yi+15]=be,this.uint16[yi+16]=De,this.uint16[yi+17]=Ze,this.uint16[yi+18]=xt,this.uint16[yi+19]=Dt,this.uint16[yi+20]=_t,this.uint16[yi+21]=Tt,this.uint16[yi+22]=kt,this.uint16[yi+23]=Ut,this.uint16[yi+24]=ci,this.uint16[yi+25]=ai,this.uint16[yi+26]=Ti,this.uint16[yi+27]=Ki,this.uint16[yi+28]=_i,this.uint32[sn+15]=Si,this.float32[sn+16]=Li,this.float32[sn+17]=Vi,this.float32[sn+18]=Zi,n}}vl.prototype.bytesPerElement=76,zt(vl,"StructArrayLayout3i2f6i15ui1ul3f76");class Zl extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n){const o=this.length;return this.resize(o+1),this.emplace(o,n)}emplace(n,o){return this.float32[1*n+0]=o,n}}Zl.prototype.bytesPerElement=4,zt(Zl,"StructArrayLayout1f4");class $h extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v){const E=this.length;return this.resize(E+1),this.emplace(E,n,o,d,g,v)}emplace(n,o,d,g,v,E){const L=5*n;return this.float32[L+0]=o,this.float32[L+1]=d,this.float32[L+2]=g,this.float32[L+3]=v,this.float32[L+4]=E,n}}$h.prototype.bytesPerElement=20,zt($h,"StructArrayLayout5f20");class Zh extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o,d,g){const v=this.length;return this.resize(v+1),this.emplace(v,n,o,d,g)}emplace(n,o,d,g,v){const E=6*n;return this.uint32[3*n+0]=o,this.uint16[E+2]=d,this.uint16[E+3]=g,this.uint16[E+4]=v,n}}Zh.prototype.bytesPerElement=12,zt(Zh,"StructArrayLayout1ul3ui12");class $a extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o){const d=this.length;return this.resize(d+1),this.emplace(d,n,o)}emplace(n,o,d){const g=2*n;return this.uint16[g+0]=o,this.uint16[g+1]=d,n}}$a.prototype.bytesPerElement=4,zt($a,"StructArrayLayout2ui4");class Xh extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n){const o=this.length;return this.resize(o+1),this.emplace(o,n)}emplace(n,o){return this.uint16[1*n+0]=o,n}}Xh.prototype.bytesPerElement=2,zt(Xh,"StructArrayLayout1ui2");class da extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o){const d=this.length;return this.resize(d+1),this.emplace(d,n,o)}emplace(n,o,d){const g=2*n;return this.float32[g+0]=o,this.float32[g+1]=d,n}}da.prototype.bytesPerElement=8,zt(da,"StructArrayLayout2f8");class sg extends ar{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]}}sg.prototype.size=40;class og extends eo{get(n){return new sg(this,n)}}zt(og,"CollisionBoxArray");class Sy extends ar{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(n){this._structArray.uint8[this._pos1+49]=n}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(n){this._structArray.uint8[this._pos1+50]=n}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(n){this._structArray.uint32[this._pos4+13]=n}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(n){this._structArray.uint8[this._pos1+58]=n}}Sy.prototype.size=60;class My extends Ea{get(n){return new Sy(this,n)}}zt(My,"PlacedSymbolArray");class dp extends ar{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(n){this._structArray.uint32[this._pos4+15]=n}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]}}dp.prototype.size=76;class pp extends vl{get(n){return new dp(this,n)}}zt(pp,"SymbolInstanceArray");class ag extends Zl{getoffsetX(n){return this.float32[1*n+0]}}zt(ag,"GlyphOffsetArray");class Bu extends Or{getx(n){return this.int16[2*n+0]}gety(n){return this.int16[2*n+1]}}zt(Bu,"SymbolLineVertexArray");class ad extends ar{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]}}ad.prototype.size=12;class Iy extends Zh{get(n){return new ad(this,n)}}zt(Iy,"FeatureIndexArray");class Fy extends $a{geta_centroid_pos0(n){return this.uint16[2*n+0]}geta_centroid_pos1(n){return this.uint16[2*n+1]}}zt(Fy,"FillExtrusionCentroidArray");const r1=_n([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),s1=_n([{name:"a_dash",components:4,type:"Uint16"}]);var ld={exports:{}},Ly={exports:{}};Ly.exports=function(s,n){var o,d,g,v,E,L,k,V;for(d=s.length-(o=3&s.length),g=n,E=3432918353,L=461845907,V=0;V>>16)*E&65535)<<16)&4294967295)<<15|k>>>17))*L+(((k>>>16)*L&65535)<<16)&4294967295)<<13|g>>>19))+((5*(g>>>16)&65535)<<16)&4294967295))+((58964+(v>>>16)&65535)<<16);switch(k=0,o){case 3:k^=(255&s.charCodeAt(V+2))<<16;case 2:k^=(255&s.charCodeAt(V+1))<<8;case 1:g^=k=(65535&(k=(k=(65535&(k^=255&s.charCodeAt(V)))*E+(((k>>>16)*E&65535)<<16)&4294967295)<<15|k>>>17))*L+(((k>>>16)*L&65535)<<16)&4294967295}return g^=s.length,g=2246822507*(65535&(g^=g>>>16))+((2246822507*(g>>>16)&65535)<<16)&4294967295,g=3266489909*(65535&(g^=g>>>13))+((3266489909*(g>>>16)&65535)<<16)&4294967295,(g^=g>>>16)>>>0};var Dy={exports:{}};Dy.exports=function(s,n){for(var o,d=s.length,g=n^d,v=0;d>=4;)o=1540483477*(65535&(o=255&s.charCodeAt(v)|(255&s.charCodeAt(++v))<<8|(255&s.charCodeAt(++v))<<16|(255&s.charCodeAt(++v))<<24))+((1540483477*(o>>>16)&65535)<<16),g=1540483477*(65535&g)+((1540483477*(g>>>16)&65535)<<16)^(o=1540483477*(65535&(o^=o>>>24))+((1540483477*(o>>>16)&65535)<<16)),d-=4,++v;switch(d){case 3:g^=(255&s.charCodeAt(v+2))<<16;case 2:g^=(255&s.charCodeAt(v+1))<<8;case 1:g=1540483477*(65535&(g^=255&s.charCodeAt(v)))+((1540483477*(g>>>16)&65535)<<16)}return g=1540483477*(65535&(g^=g>>>13))+((1540483477*(g>>>16)&65535)<<16),(g^=g>>>15)>>>0};var Cf=Ly.exports,o1=Dy.exports;ld.exports=Cf,ld.exports.murmur3=Cf,ld.exports.murmur2=o1;class qh{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(n,o,d,g){this.ids.push(Py(n)),this.positions.push(o,d,g)}getPositions(n){const o=Py(n);let d=0,g=this.ids.length-1;for(;d>1;this.ids[E]>=o?g=E:d=E+1}const v=[];for(;this.ids[d]===o;)v.push({index:this.positions[3*d],start:this.positions[3*d+1],end:this.positions[3*d+2]}),d++;return v}static serialize(n,o){const d=new Float64Array(n.ids),g=new Uint32Array(n.positions);return Ds(d,g,0,d.length-1),o&&o.push(d.buffer,g.buffer),{ids:d,positions:g}}static deserialize(n){const o=new qh;return o.ids=n.ids,o.positions=n.positions,o.indexed=!0,o}}function Py(s){const n=+s;return!isNaN(n)&&Number.MIN_SAFE_INTEGER<=n&&n<=Number.MAX_SAFE_INTEGER?n:ld.exports(String(s))}function Ds(s,n,o,d){for(;o>1];let v=o-1,E=d+1;for(;;){do v++;while(s[v]g);if(v>=E)break;fA(s,v,E),fA(n,3*v,3*E),fA(n,3*v+1,3*E+1),fA(n,3*v+2,3*E+2)}E-o`u_${g}`),this.type=d}setUniform(n,o,d,g,v){o.set(n,v,g.constantOr(this.value))}getBinding(n,o){return this.type==="color"?new cd(n):new mA(n)}}class hd{constructor(n,o){this.uniformNames=o.map(d=>`u_${d}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(n){this.pixelRatio=n.pixelRatio||1,this.pattern=n.tl.concat(n.br)}setUniform(n,o,d,g,v){const E=v==="u_pattern"||v==="u_dash"?this.pattern:v==="u_pixel_ratio"?this.pixelRatio:null;E&&o.set(n,v,E)}getBinding(n,o){return o==="u_pattern"||o==="u_dash"?new fp(n):new mA(n)}}class ah{constructor(n,o,d,g){this.expression=n,this.type=d,this.maxValue=0,this.paintVertexAttributes=o.map(v=>({name:`a_${v}`,type:"Float32",components:d==="color"?2:1,offset:0})),this.paintVertexArray=new g}populatePaintArray(n,o,d,g,v,E){const L=this.paintVertexArray.length,k=this.expression.evaluate(new qt(0),o,{},v,g,E);this.paintVertexArray.resize(n),this._setPaintValue(L,n,k)}updatePaintArray(n,o,d,g,v){const E=this.expression.evaluate({zoom:0},d,g,void 0,v);this._setPaintValue(n,o,E)}_setPaintValue(n,o,d){if(this.type==="color"){const g=gp(d);for(let v=n;v`u_${L}_t`),this.type=d,this.useIntegerZoom=g,this.zoom=v,this.maxValue=0,this.paintVertexAttributes=o.map(L=>({name:`a_${L}`,type:"Float32",components:d==="color"?4:2,offset:0})),this.paintVertexArray=new E}populatePaintArray(n,o,d,g,v,E){const L=this.expression.evaluate(new qt(this.zoom),o,{},v,g,E),k=this.expression.evaluate(new qt(this.zoom+1),o,{},v,g,E),V=this.paintVertexArray.length;this.paintVertexArray.resize(n),this._setPaintValue(V,n,L,k)}updatePaintArray(n,o,d,g,v){const E=this.expression.evaluate({zoom:this.zoom},d,g,void 0,v),L=this.expression.evaluate({zoom:this.zoom+1},d,g,void 0,v);this._setPaintValue(n,o,E,L)}_setPaintValue(n,o,d,g){if(this.type==="color"){const v=gp(d),E=gp(g);for(let L=n;L!0){this.binders={},this._buffers=[];const g=[];for(const v in n.paint._values){if(!d(v))continue;const E=n.paint.get(v);if(!(E instanceof Mi&&gl(E.property.specification)))continue;const L=cg(v,n.type),k=E.value,V=E.property.specification.type,q=E.property.useIntegerZoom,se=v==="line-dasharray"||v.endsWith("pattern"),he=v==="line-dasharray"&&n.layout.get("line-cap").value.kind!=="constant";if(k.kind!=="constant"||he)if(k.kind==="source"||he||se){const _e=zy(v,V,"source");this.binders[v]=se?new Cu(k,L,V,_e,n.id):new ah(k,L,V,_e),g.push(`/a_${v}`)}else{const _e=zy(v,V,"composite");this.binders[v]=new Ta(k,L,V,q,o,_e),g.push(`/z_${v}`)}else this.binders[v]=se?new hd(k.value,L):new gA(k.value,L,V),g.push(`/u_${v}`)}this.cacheKey=g.sort().join("")}getMaxValue(n){const o=this.binders[n];return o instanceof ah||o instanceof Ta?o.maxValue:0}populatePaintArrays(n,o,d,g,v,E){for(const L in this.binders){const k=this.binders[L];(k instanceof ah||k instanceof Ta||k instanceof Cu)&&k.populatePaintArray(n,o,d,g,v,E)}}setConstantPatternPositions(n){for(const o in this.binders){const d=this.binders[o];d instanceof hd&&d.setConstantPatternPositions(n)}}updatePaintArrays(n,o,d,g,v,E){let L=!1;for(const k in n){const V=o.getPositions(k);for(const q of V){const se=d.feature(q.index);for(const he in this.binders){const _e=this.binders[he];if((_e instanceof ah||_e instanceof Ta||_e instanceof Cu)&&_e.expression.isStateDependent===!0){const be=g.paint.get(he);_e.expression=be.value,_e.updatePaintArray(q.start,q.end,se,n[k],v,E),L=!0}}}}return L}defines(){const n=[];for(const o in this.binders){const d=this.binders[o];(d instanceof gA||d instanceof hd)&&n.push(...d.uniformNames.map(g=>`#define HAS_UNIFORM_${g}`))}return n}getBinderAttributes(){const n=[];for(const o in this.binders){const d=this.binders[o];if(d instanceof ah||d instanceof Ta||d instanceof Cu)for(let g=0;g!0){this.programConfigurations={};for(const g of n)this.programConfigurations[g.id]=new lh(g,o,d);this.needsUpload=!1,this._featureMap=new qh,this._bufferOffset=0}populatePaintArrays(n,o,d,g,v,E,L){for(const k in this.programConfigurations)this.programConfigurations[k].populatePaintArrays(n,o,g,v,E,L);o.id!==void 0&&this._featureMap.add(o.id,d,this._bufferOffset,n),this._bufferOffset=n,this.needsUpload=!0}updatePaintArrays(n,o,d,g,v){for(const E of d)this.needsUpload=this.programConfigurations[E.id].updatePaintArrays(n,this._featureMap,o,E,g,v)||this.needsUpload}get(n){return this.programConfigurations[n]}upload(n){if(this.needsUpload){for(const o in this.programConfigurations)this.programConfigurations[o].upload(n);this.needsUpload=!1}}destroy(){for(const n in this.programConfigurations)this.programConfigurations[n].destroy()}}const lg={"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 cg(s,n){return lg[s]||[s.replace(`${n}-`,"").replace(/-/g,"_")]}const hg={"line-pattern":{source:jo,composite:jo},"fill-pattern":{source:jo,composite:jo},"fill-extrusion-pattern":{source:jo,composite:jo},"line-dasharray":{source:ws,composite:ws}},a1={color:{source:da,composite:Ca},number:{source:Zl,composite:da}};function zy(s,n,o){const d=hg[s];return d&&d[o]||a1[n][o]}zt(gA,"ConstantBinder"),zt(hd,"PatternConstantBinder"),zt(ah,"SourceExpressionBinder"),zt(Cu,"PatternCompositeBinder"),zt(Ta,"CompositeExpressionBinder"),zt(lh,"ProgramConfiguration",{omit:["_buffers"]}),zt(_A,"ProgramConfigurationSet");const Ef="-transition";class xc extends yn{constructor(n,o){if(super(),this.id=n.id,this.type=n.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,n.type!=="custom"&&(this.metadata=n.metadata,this.minzoom=n.minzoom,this.maxzoom=n.maxzoom,n.type!=="background"&&n.type!=="sky"&&(this.source=n.source,this.sourceLayer=n["source-layer"],this.filter=n.filter),o.layout&&(this._unevaluatedLayout=new Ai(o.layout)),o.paint)){this._transitionablePaint=new Bi(o.paint);for(const d in n.paint)this.setPaintProperty(d,n.paint[d],{validate:!1});for(const d in n.layout)this.setLayoutProperty(d,n.layout[d],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new $i(o.paint)}}getLayoutProperty(n){return n==="visibility"?this.visibility:this._unevaluatedLayout.getValue(n)}setLayoutProperty(n,o,d={}){o!=null&&this._validate(mt,`layers.${this.id}.layout.${n}`,n,o,d)||(n!=="visibility"?this._unevaluatedLayout.setValue(n,o):this.visibility=o)}getPaintProperty(n){return dt(n,Ef)?this._transitionablePaint.getTransition(n.slice(0,-Ef.length)):this._transitionablePaint.getValue(n)}setPaintProperty(n,o,d={}){if(o!=null&&this._validate(bt,`layers.${this.id}.paint.${n}`,n,o,d))return!1;if(dt(n,Ef))return this._transitionablePaint.setTransition(n.slice(0,-Ef.length),o||void 0),!1;{const g=this._transitionablePaint._values[n],v=g.value.isDataDriven(),E=g.value;this._transitionablePaint.setValue(n,o),this._handleSpecialPaintPropertyUpdate(n);const L=this._transitionablePaint._values[n].value,k=L.isDataDriven(),V=dt(n,"pattern")||n==="line-dasharray";return k||v||V||this._handleOverridablePaintPropertyUpdate(n,E,L)}}_handleSpecialPaintPropertyUpdate(n){}getProgramIds(){return null}getProgramConfiguration(n){return null}_handleOverridablePaintPropertyUpdate(n,o,d){return!1}isHidden(n){return!!(this.minzoom&&n=this.maxzoom)||this.visibility==="none"}updateTransitions(n){this._transitioningPaint=this._transitionablePaint.transitioned(n,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(n,o){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(n,void 0,o)),this.paint=this._transitioningPaint.possiblyEvaluate(n,void 0,o)}serialize(){const n={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&&(n.layout=n.layout||{},n.layout.visibility=this.visibility),Qt(n,(o,d)=>!(o===void 0||d==="layout"&&!Object.keys(o).length||d==="paint"&&!Object.keys(o).length))}_validate(n,o,d,g,v={}){return(!v||v.validate!==!1)&&Vt(this,n.call(We,{key:o,layerType:this.type,objectKey:d,value:g,styleSpec:Yt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const n in this.paint._values){const o=this.paint.get(n);if(o instanceof Mi&&gl(o.property.specification)&&(o.value.kind==="source"||o.value.kind==="composite")&&o.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=uo(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const l1=_n([{name:"a_pos",components:2,type:"Int16"}],4),Eu=_n([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class to{constructor(n=[]){this.segments=n}prepareSegment(n,o,d,g){let v=this.segments[this.segments.length-1];return n>to.MAX_VERTEX_ARRAY_LENGTH&&Ct(`Max vertices per segment is ${to.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${n}`),(!v||v.vertexLength+n>to.MAX_VERTEX_ARRAY_LENGTH||v.sortKey!==g)&&(v={vertexOffset:o.length,primitiveOffset:d.length,vertexLength:0,primitiveLength:0},g!==void 0&&(v.sortKey=g),this.segments.push(v)),v}get(){return this.segments}destroy(){for(const n of this.segments)for(const o in n.vaos)n.vaos[o].destroy()}static simpleSegment(n,o,d,g){return new to([{vertexOffset:n,primitiveOffset:o,vertexLength:d,primitiveLength:g,vaos:{},sortKey:0}])}}to.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,zt(to,"SegmentVector");var Zn=8192;class wl{constructor(n,o){n&&(o?this.setSouthWest(n).setNorthEast(o):n.length===4?this.setSouthWest([n[0],n[1]]).setNorthEast([n[2],n[3]]):this.setSouthWest(n[0]).setNorthEast(n[1]))}setNorthEast(n){return this._ne=n instanceof Pr?new Pr(n.lng,n.lat):Pr.convert(n),this}setSouthWest(n){return this._sw=n instanceof Pr?new Pr(n.lng,n.lat):Pr.convert(n),this}extend(n){const o=this._sw,d=this._ne;let g,v;if(n instanceof Pr)g=n,v=n;else{if(!(n instanceof wl))return Array.isArray(n)?n.length===4||n.every(Array.isArray)?this.extend(wl.convert(n)):this.extend(Pr.convert(n)):typeof n=="object"&&n!==null&&n.hasOwnProperty("lat")&&n.hasOwnProperty("lon")?this.extend(Pr.convert(n)):this;if(g=n._sw,v=n._ne,!g||!v)return this}return o||d?(o.lng=Math.min(g.lng,o.lng),o.lat=Math.min(g.lat,o.lat),d.lng=Math.max(v.lng,d.lng),d.lat=Math.max(v.lat,d.lat)):(this._sw=new Pr(g.lng,g.lat),this._ne=new Pr(v.lng,v.lat)),this}getCenter(){return new Pr((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 Pr(this.getWest(),this.getNorth())}getSouthEast(){return new Pr(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(n){const{lng:o,lat:d}=Pr.convert(n);let g=this._sw.lng<=o&&o<=this._ne.lng;return this._sw.lng>this._ne.lng&&(g=this._sw.lng>=o&&o>=this._ne.lng),this._sw.lat<=d&&d<=this._ne.lat&&g}static convert(n){return!n||n instanceof wl?n:new wl(n)}}const Tf=63710088e-1;class Pr{constructor(n,o){if(isNaN(n)||isNaN(o))throw new Error(`Invalid LngLat object: (${n}, ${o})`);if(this.lng=+n,this.lat=+o,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Pr(ze(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(n){const o=Math.PI/180,d=this.lat*o,g=n.lat*o,v=Math.sin(d)*Math.sin(g)+Math.cos(d)*Math.cos(g)*Math.cos((n.lng-this.lng)*o);return Tf*Math.acos(Math.min(v,1))}toBounds(n=0){const o=360*n/40075017,d=o/Math.cos(Math.PI/180*this.lat);return new wl(new Pr(this.lng-d,this.lat-o),new Pr(this.lng+d,this.lat+o))}static convert(n){if(n instanceof Pr)return n;if(Array.isArray(n)&&(n.length===2||n.length===3))return new Pr(Number(n[0]),Number(n[1]));if(!Array.isArray(n)&&typeof n=="object"&&n!==null)return new Pr(Number("lng"in n?n.lng:n.lon),Number(n.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const ky=2*Math.PI*Tf;function Sf(s){return ky*Math.cos(s*Math.PI/180)}function vc(s){return(180+s)/360}function ch(s){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+s*Math.PI/360)))/360}function Xl(s,n){return s/Sf(n)}function bl(s){return 360*s-180}function Fo(s){return 360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90}function Mf(s,n){return s*Sf(Fo(n))}const Za=85.051129;function If(s){return 1/Math.cos(s*Math.PI/180)}class ud{constructor(n,o,d=0){this.x=+n,this.y=+o,this.z=+d}static fromLngLat(n,o=0){const d=Pr.convert(n);return new ud(vc(d.lng),ch(d.lat),Xl(o,d.lat))}toLngLat(){return new Pr(bl(this.x),Fo(this.y))}toAltitude(){return Mf(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ky*If(Fo(this.y))}}function ug(s,n,o,d,g,v,E,L,k){const V=(n+d)/2,q=(o+g)/2,se=new me(V,q);L(se),function(he,_e,be,De,Ze,xt){const Dt=be-Ze,_t=De-xt;return Math.abs((De-_e)*Dt-(be-he)*_t)/Math.hypot(Dt,_t)}(se.x,se.y,v.x,v.y,E.x,E.y)>=k?(ug(s,n,o,V,q,v,se,L,k),ug(s,V,q,d,g,se,E,L,k)):s.push(E)}function Oy(s,n,o){let d=s[0],g=d.x,v=d.y;n(d);const E=[d];for(let L=1;Ls.x+1||ds.y+1)&&Ct("Geometry exceeds allowed extent, reduce your vector tile buffer size"),s}function Yh(s,n,o){const d=s.loadGeometry(),g=s.extent,v=Zn/g;if(n&&o&&o.projection.isReprojectedInTileSpace){const E=1<{const _e=bl((n.x+he.x/g)/E),be=Fo((n.y+he.y/g)/E),De=q.project(_e,be);he.x=(De.x*L-k)*g,he.y=(De.y*L-V)*g};for(let he=0;he=g||be.y<0||be.y>=g||(se(be),_e.push(be));d[he]=_e}}for(const E of d)for(const L of E)c1(L,v);return d}function xA(s,n){return{type:s.type,id:s.id,properties:s.properties,geometry:n?Yh(s):[]}}function Ff(s,n,o,d,g){s.emplaceBack(2*n+(d+1)/2,2*o+(g+1)/2)}function _p(s,n,o){s.emplaceBack(n.x,n.y,n.z,o[0]*16384,o[1]*16384,o[2]*16384)}class yp{constructor(n){this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(o=>o.id),this.index=n.index,this.hasPattern=!1,this.projection=n.projection,this.layoutVertexArray=new Or,this.indexArray=new _o,this.segments=new to,this.programConfigurations=new _A(n.layers,n.zoom),this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id)}populate(n,o,d,g){const v=this.layers[0],E=[];let L=null;v.type==="circle"&&(L=v.layout.get("circle-sort-key"));for(const{feature:V,id:q,index:se,sourceLayerIndex:he}of n){const _e=this.layers[0]._featureFilter.needGeometry,be=xA(V,_e);if(!this.layers[0]._featureFilter.filter(new qt(this.zoom),be,d))continue;const De=L?L.evaluate(be,{},d):void 0,Ze={id:q,properties:V.properties,type:V.type,sourceLayerIndex:he,index:se,geometry:_e?be.geometry:Yh(V,d,g),patterns:{},sortKey:De};E.push(Ze)}L&&E.sort((V,q)=>V.sortKey-q.sortKey);let k=null;g.projection.name==="globe"&&(this.globeExtVertexArray=new _r,k=g.projection);for(const V of E){const{geometry:q,index:se,sourceLayerIndex:he}=V,_e=n[se].feature;this.addFeature(V,q,se,o.availableImages,d,k),o.featureIndex.insert(_e,q,se,he,this.index)}}update(n,o,d,g){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,o,this.stateDependentLayers,d,g)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,l1.members),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=n.createVertexBuffer(this.globeExtVertexArray,Eu.members))),this.programConfigurations.upload(n),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(n,o,d,g,v,E){for(const L of o)for(const k of L){const V=k.x,q=k.y;if(V<0||V>=Zn||q<0||q>=Zn)continue;if(E){const _e=E.projectTilePoint(V,q,v),be=E.upVector(v,V,q),De=this.globeExtVertexArray;_p(De,_e,be),_p(De,_e,be),_p(De,_e,be),_p(De,_e,be)}const se=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,n.sortKey),he=se.vertexLength;Ff(this.layoutVertexArray,V,q,-1,-1),Ff(this.layoutVertexArray,V,q,1,-1),Ff(this.layoutVertexArray,V,q,1,1),Ff(this.layoutVertexArray,V,q,-1,1),this.indexArray.emplaceBack(he,he+1,he+2),this.indexArray.emplaceBack(he,he+2,he+3),se.vertexLength+=4,se.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,d,{},g,v)}}function Vy(s,n){for(let o=0;o1){if(pg(s,n))return!0;for(let d=0;d1?o:o.sub(n)._mult(g)._add(n))}function Wy(s,n){let o,d,g,v=!1;for(let E=0;En.y!=g.y>n.y&&n.x<(g.x-d.x)*(n.y-d.y)/(g.y-d.y)+d.x&&(v=!v)}return v}function vA(s,n){let o=!1;for(let d=0,g=s.length-1;dn.y!=E.y>n.y&&n.x<(E.x-v.x)*(n.y-v.y)/(E.y-v.y)+v.x&&(o=!o)}return o}function Ad(s,n,o,d,g){for(const E of s)if(n<=E.x&&o<=E.y&&d>=E.x&&g>=E.y)return!0;const v=[new me(n,o),new me(n,g),new me(d,g),new me(d,o)];if(s.length>2){for(const E of v)if(vA(s,E))return!0}for(let E=0;Eg.x&&n.x>g.x||s.yg.y&&n.y>g.y)return!1;const v=Ft(s,n,o[0]);return v!==Ft(s,n,o[1])||v!==Ft(s,n,o[2])||v!==Ft(s,n,o[3])}function Tu(s,n,o){const d=n.paint.get(s).value;return d.kind==="constant"?d.value:o.programConfigurations.get(n.id).getMaxValue(s)}function xp(s){return Math.sqrt(s[0]*s[0]+s[1]*s[1])}function gg(s,n,o,d,g){if(!n[0]&&!n[1])return s;const v=me.convert(n)._mult(g);o==="viewport"&&v._rotate(-d);const E=[];for(let L=0;L0&&(v=1/Math.sqrt(v)),s[0]=n[0]*v,s[1]=n[1]*v,s[2]=n[2]*v,s}function Ma(s,n){return s[0]*n[0]+s[1]*n[1]+s[2]*n[2]}function gd(s,n,o){var d=n[0],g=n[1],v=n[2],E=o[0],L=o[1],k=o[2];return s[0]=g*k-v*L,s[1]=v*E-d*k,s[2]=d*L-g*E,s}function Qs(s,n,o){var d=n[0],g=n[1],v=n[2],E=o[3]*d+o[7]*g+o[11]*v+o[15];return s[0]=(o[0]*d+o[4]*g+o[8]*v+o[12])/(E=E||1),s[1]=(o[1]*d+o[5]*g+o[9]*v+o[13])/E,s[2]=(o[2]*d+o[6]*g+o[10]*v+o[14])/E,s}function bg(s,n,o){var d=o[0],g=o[1],v=o[2],E=n[0],L=n[1],k=n[2],V=g*k-v*L,q=v*E-d*k,se=d*L-g*E,he=g*se-v*q,_e=v*V-d*se,be=d*q-g*V,De=2*o[3];return q*=De,se*=De,_e*=2,be*=2,s[0]=E+(V*=De)+(he*=2),s[1]=L+q+_e,s[2]=k+se+be,s}var _d,wc=vg,$y=wg,Zy=pd;function Df(s,n,o){return s[0]=n[0]*o,s[1]=n[1]*o,s[2]=n[2]*o,s[3]=n[3]*o,s}function Pf(s,n){var o=n[0],d=n[1],g=n[2],v=n[3],E=o*o+d*d+g*g+v*v;return E>0&&(E=1/Math.sqrt(E)),s[0]=o*E,s[1]=d*E,s[2]=g*E,s[3]=v*E,s}function TA(s,n,o){var d=n[0],g=n[1],v=n[2],E=n[3];return s[0]=o[0]*d+o[4]*g+o[8]*v+o[12]*E,s[1]=o[1]*d+o[5]*g+o[9]*v+o[13]*E,s[2]=o[2]*d+o[6]*g+o[10]*v+o[14]*E,s[3]=o[3]*d+o[7]*g+o[11]*v+o[15]*E,s}function Xy(){var s=new Sa(4);return Sa!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s[3]=1,s}function Bg(s){return s[0]=0,s[1]=0,s[2]=0,s[3]=1,s}function uh(s,n,o){o*=.5;var d=n[0],g=n[1],v=n[2],E=n[3],L=Math.sin(o),k=Math.cos(o);return s[0]=d*k+E*L,s[1]=g*k+v*L,s[2]=v*k-g*L,s[3]=E*k-d*L,s}function Cg(s,n,o){o*=.5;var d=n[0],g=n[1],v=n[2],E=n[3],L=Math.sin(o),k=Math.cos(o);return s[0]=d*k-v*L,s[1]=g*k+E*L,s[2]=v*k+d*L,s[3]=E*k-g*L,s}dd(),_d=new Sa(4),Sa!=Float32Array&&(_d[0]=0,_d[1]=0,_d[2]=0,_d[3]=0);var Mu=Pf;dd(),fd(1,0,0),fd(0,1,0),Xy(),Xy(),hh();class Uf{constructor(n,o){this.pos=n,this.dir=o}intersectsPlane(n,o,d){const g=Ma(o,this.dir);if(Math.abs(g)<1e-6)return!1;const v=((n[0]-this.pos[0])*o[0]+(n[1]-this.pos[1])*o[1]+(n[2]-this.pos[2])*o[2])/g;return d[0]=this.pos[0]+this.dir[0]*v,d[1]=this.pos[1]+this.dir[1]*v,d[2]=this.pos[2]+this.dir[2]*v,!0}closestPointOnSphere(n,o,d){if(function(_e,be){var De=_e[0],Ze=_e[1],xt=_e[2],Dt=be[0],_t=be[1],Tt=be[2];return Math.abs(De-Dt)<=vp*Math.max(1,Math.abs(De),Math.abs(Dt))&&Math.abs(Ze-_t)<=vp*Math.max(1,Math.abs(Ze),Math.abs(_t))&&Math.abs(xt-Tt)<=vp*Math.max(1,Math.abs(xt),Math.abs(Tt))}(this.pos,n)||o===0)return d[0]=d[1]=d[2]=0,!1;const[g,v,E]=this.dir,L=this.pos[0]-n[0],k=this.pos[1]-n[1],V=this.pos[2]-n[2],q=g*g+v*v+E*E,se=2*(L*g+k*v+V*E),he=se*se-4*q*(L*L+k*k+V*V-o*o);if(he<0){const _e=Math.max(-se/2,0),be=L+g*_e,De=k+v*_e,Ze=V+E*_e,xt=Math.hypot(be,De,Ze);return d[0]=be*o/xt,d[1]=De*o/xt,d[2]=Ze*o/xt,!1}{const _e=(-se-Math.sqrt(he))/(2*q);if(_e<0){const be=Math.hypot(L,k,V);return d[0]=L*o/be,d[1]=k*o/be,d[2]=V*o/be,!1}return d[0]=L+g*_e,d[1]=k+v*_e,d[2]=V+E*_e,!0}}}class Rf{constructor(n,o,d,g,v){this.TL=n,this.TR=o,this.BR=d,this.BL=g,this.horizon=v}static fromInvProjectionMatrix(n,o,d){const g=[-1,1,1],v=[1,1,1],E=[1,-1,1],L=[-1,-1,1],k=Qs(g,g,n),V=Qs(v,v,n),q=Qs(E,E,n),se=Qs(L,L,n);return new Rf(k,V,q,se,o/d)}}class zf{constructor(n,o){this.points=n,this.planes=o}static fromInvProjectionMatrix(n,o,d,g){const v=Math.pow(2,d),E=[[-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(k=>{const V=TA([],k,n),q=1/V[3]/o*v;return function(se,he,_e){return se[0]=he[0]*_e[0],se[1]=he[1]*_e[1],se[2]=he[2]*_e[2],se[3]=he[3]*_e[3],se}(V,V,[q,q,g?1/V[3]:q,q])}),L=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(k=>{const V=so([],gd([],wc([],E[k[0]],E[k[1]]),wc([],E[k[2]],E[k[1]]))),q=-Ma(V,E[k[1]]);return V.concat(q)});return new zf(E,L)}}class Ko{static fromPoints(n){const o=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(const g of n)EA(o,o,g),md(d,d,g);return new Ko(o,d)}static applyTransform(n,o){const d=n.getCorners();for(let g=0;g=0;if(E===0)return 0;E!==o.length&&(d=!1)}if(d)return 2;for(let g=0;g<3;g++){let v=Number.MAX_VALUE,E=-Number.MAX_VALUE;for(let L=0;Lthis.max[g]-this.min[g])return 0}return 1}}function qy(s,n,o,d,g,v,E,L,k){if(v&&s.queryGeometry.isAboveHorizon)return!1;v&&(k*=s.pixelToTileUnitsFactor);const V=s.tileID.canonical,q=o.projection.upVectorScale(V,o.center.lat,o.worldSize).metersToTile;for(const se of n)for(const he of se){const _e=he.add(L),be=g&&o.elevation?o.elevation.exaggeration()*g.getElevationAt(_e.x,_e.y,!0):0,De=o.projection.projectTilePoint(_e.x,_e.y,V);if(be>0){const _t=o.projection.upVector(V,_e.x,_e.y);De.x+=_t[0]*q*be,De.y+=_t[1]*q*be,De.z+=_t[2]*q*be}const Ze=v?_e:A1(De.x,De.y,De.z,d),xt=v?s.tilespaceRays.map(_t=>Jy(_t,be)):s.queryGeometry.screenGeometry,Dt=TA([],[De.x,De.y,De.z,1],d);if(!E&&v?k*=Dt[3]/o.cameraToCenterDistance:E&&!v&&(k*=o.cameraToCenterDistance/Dt[3]),v){const _t=Fo((he.y/Zn+V.y)/(1<s.width||g.height>s.height||o.x>s.width-g.width||o.y>s.height-g.height)throw new RangeError("out of range source coordinates for image copy");if(g.width>n.width||g.height>n.height||d.x>n.width-g.width||d.y>n.height-g.height)throw new RangeError("out of range destination coordinates for image copy");const E=s.data,L=n.data;for(let k=0;k{n[s.evaluationKey]=k;const V=s.expression.evaluate(n);g.data[E+L+0]=Math.floor(255*V.r/V.a),g.data[E+L+1]=Math.floor(255*V.g/V.a),g.data[E+L+2]=Math.floor(255*V.b/V.a),g.data[E+L+3]=Math.floor(255*V.a)};if(s.clips)for(let E=0,L=0;E80*o){d=v=s[0],g=E=s[1];for(var be=o;bev&&(v=L),k>E&&(E=k);V=(V=Math.max(v-d,E-g))!==0?32767/V:0}return bd(he,_e,o,d,g,V,0),_e}function e0(s,n,o,d,g){var v,E;if(g===Ts(s,n,o,d)>0)for(v=n;v=n;v-=d)E=n0(v,s[v],s[v+1],E);return E&&Ep(E,E.next)&&(Mp(E),E=E.next),E}function qa(s,n){if(!s)return s;n||(n=s);var o,d=s;do if(o=!1,d.steiner||!Ep(d,d.next)&&Ps(d.prev,d,d.next)!==0)d=d.next;else{if(Mp(d),(d=n=d.prev)===d.next)break;o=!0}while(o||d!==n);return n}function bd(s,n,o,d,g,v,E){if(s){!E&&v&&function(q,se,he,_e){var be=q;do be.z===0&&(be.z=Cp(be.x,be.y,se,he,_e)),be.prevZ=be.prev,be.nextZ=be.next,be=be.next;while(be!==q);be.prevZ.nextZ=null,be.prevZ=null,function(De){var Ze,xt,Dt,_t,Tt,kt,Ut,ci,ai=1;do{for(xt=De,De=null,Tt=null,kt=0;xt;){for(kt++,Dt=xt,Ut=0,Ze=0;Ze0||ci>0&&Dt;)Ut!==0&&(ci===0||!Dt||xt.z<=Dt.z)?(_t=xt,xt=xt.nextZ,Ut--):(_t=Dt,Dt=Dt.nextZ,ci--),Tt?Tt.nextZ=_t:De=_t,_t.prevZ=Tt,Tt=_t;xt=Dt}Tt.nextZ=null,ai*=2}while(kt>1)}(be)}(s,d,g,v);for(var L,k,V=s;s.prev!==s.next;)if(L=s.prev,k=s.next,v?f1(s,d,g,v):t0(s))n.push(L.i/o|0),n.push(s.i/o|0),n.push(k.i/o|0),Mp(s),s=k.next,V=k.next;else if((s=k)===V){E?E===1?bd(s=m1(qa(s),n,o),n,o,d,g,v,2):E===2&&g1(s,n,o,d,g,v):bd(qa(s),n,o,d,g,v,1);break}}}function t0(s){var n=s.prev,o=s,d=s.next;if(Ps(n,o,d)>=0)return!1;for(var g=n.x,v=o.x,E=d.x,L=n.y,k=o.y,V=d.y,q=gv?g>E?g:E:v>E?v:E,_e=L>k?L>V?L:V:k>V?k:V,be=d.next;be!==n;){if(be.x>=q&&be.x<=he&&be.y>=se&&be.y<=_e&&bc(g,L,v,k,E,V,be.x,be.y)&&Ps(be.prev,be,be.next)>=0)return!1;be=be.next}return!0}function f1(s,n,o,d){var g=s.prev,v=s,E=s.next;if(Ps(g,v,E)>=0)return!1;for(var L=g.x,k=v.x,V=E.x,q=g.y,se=v.y,he=E.y,_e=Lk?L>V?L:V:k>V?k:V,Ze=q>se?q>he?q:he:se>he?se:he,xt=Cp(_e,be,n,o,d),Dt=Cp(De,Ze,n,o,d),_t=s.prevZ,Tt=s.nextZ;_t&&_t.z>=xt&&Tt&&Tt.z<=Dt;){if(_t.x>=_e&&_t.x<=De&&_t.y>=be&&_t.y<=Ze&&_t!==g&&_t!==E&&bc(L,q,k,se,V,he,_t.x,_t.y)&&Ps(_t.prev,_t,_t.next)>=0||(_t=_t.prevZ,Tt.x>=_e&&Tt.x<=De&&Tt.y>=be&&Tt.y<=Ze&&Tt!==g&&Tt!==E&&bc(L,q,k,se,V,he,Tt.x,Tt.y)&&Ps(Tt.prev,Tt,Tt.next)>=0))return!1;Tt=Tt.nextZ}for(;_t&&_t.z>=xt;){if(_t.x>=_e&&_t.x<=De&&_t.y>=be&&_t.y<=Ze&&_t!==g&&_t!==E&&bc(L,q,k,se,V,he,_t.x,_t.y)&&Ps(_t.prev,_t,_t.next)>=0)return!1;_t=_t.prevZ}for(;Tt&&Tt.z<=Dt;){if(Tt.x>=_e&&Tt.x<=De&&Tt.y>=be&&Tt.y<=Ze&&Tt!==g&&Tt!==E&&bc(L,q,k,se,V,he,Tt.x,Tt.y)&&Ps(Tt.prev,Tt,Tt.next)>=0)return!1;Tt=Tt.nextZ}return!0}function m1(s,n,o){var d=s;do{var g=d.prev,v=d.next.next;!Ep(g,v)&&Tp(g,d,d.next,v)&&Sp(g,v)&&Sp(v,g)&&(n.push(g.i/o|0),n.push(d.i/o|0),n.push(v.i/o|0),Mp(d),Mp(d.next),d=s=v),d=d.next}while(d!==s);return qa(d)}function g1(s,n,o,d,g,v){var E=s;do{for(var L=E.next.next;L!==E.prev;){if(E.i!==L.i&&y1(E,L)){var k=i0(E,L);return E=qa(E,E.next),k=qa(k,k.next),bd(E,n,o,d,g,v,0),void bd(k,n,o,d,g,v,0)}L=L.next}E=E.next}while(E!==s)}function kf(s,n){return s.x-n.x}function Ig(s,n){var o=function(g,v){var E,L=v,k=g.x,V=g.y,q=-1/0;do{if(V<=L.y&&V>=L.next.y&&L.next.y!==L.y){var se=L.x+(V-L.y)*(L.next.x-L.x)/(L.next.y-L.y);if(se<=k&&se>q&&(q=se,E=L.x=L.x&&L.x>=be&&k!==L.x&&bc(VE.x||L.x===E.x&&_1(E,L)))&&(E=L,Ze=he)),L=L.next;while(L!==_e);return E}(s,n);if(!o)return n;var d=i0(o,s);return qa(d,d.next),qa(o,o.next)}function _1(s,n){return Ps(s.prev,s,n.prev)<0&&Ps(n.next,s,s.next)<0}function Cp(s,n,o,d,g){return(s=1431655765&((s=858993459&((s=252645135&((s=16711935&((s=(s-o)*g|0)|s<<8))|s<<4))|s<<2))|s<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-d)*g|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function Fg(s){var n=s,o=s;do(n.x=(s-E)*(v-L)&&(s-E)*(d-L)>=(o-E)*(n-L)&&(o-E)*(v-L)>=(g-E)*(d-L)}function y1(s,n){return s.next.i!==n.i&&s.prev.i!==n.i&&!function(o,d){var g=o;do{if(g.i!==o.i&&g.next.i!==o.i&&g.i!==d.i&&g.next.i!==d.i&&Tp(g,g.next,o,d))return!0;g=g.next}while(g!==o);return!1}(s,n)&&(Sp(s,n)&&Sp(n,s)&&function(o,d){var g=o,v=!1,E=(o.x+d.x)/2,L=(o.y+d.y)/2;do g.y>L!=g.next.y>L&&g.next.y!==g.y&&E<(g.next.x-g.x)*(L-g.y)/(g.next.y-g.y)+g.x&&(v=!v),g=g.next;while(g!==o);return v}(s,n)&&(Ps(s.prev,s,n.prev)||Ps(s,n.prev,n))||Ep(s,n)&&Ps(s.prev,s,s.next)>0&&Ps(n.prev,n,n.next)>0)}function Ps(s,n,o){return(n.y-s.y)*(o.x-n.x)-(n.x-s.x)*(o.y-n.y)}function Ep(s,n){return s.x===n.x&&s.y===n.y}function Tp(s,n,o,d){var g=Of(Ps(s,n,o)),v=Of(Ps(s,n,d)),E=Of(Ps(o,d,s)),L=Of(Ps(o,d,n));return g!==v&&E!==L||!(g!==0||!Bd(s,o,n))||!(v!==0||!Bd(s,d,n))||!(E!==0||!Bd(o,s,d))||!(L!==0||!Bd(o,n,d))}function Bd(s,n,o){return n.x<=Math.max(s.x,o.x)&&n.x>=Math.min(s.x,o.x)&&n.y<=Math.max(s.y,o.y)&&n.y>=Math.min(s.y,o.y)}function Of(s){return s>0?1:s<0?-1:0}function Sp(s,n){return Ps(s.prev,s,s.next)<0?Ps(s,n,s.next)>=0&&Ps(s,s.prev,n)>=0:Ps(s,n,s.prev)<0||Ps(s,s.next,n)<0}function i0(s,n){var o=new Nf(s.i,s.x,s.y),d=new Nf(n.i,n.x,n.y),g=s.next,v=n.prev;return s.next=n,n.prev=s,o.next=g,g.prev=o,d.next=o,o.prev=d,v.next=d,d.prev=v,d}function n0(s,n,o,d){var g=new Nf(s,n,o);return d?(g.next=d.next,g.prev=d,d.next.prev=g,d.next=g):(g.prev=g,g.next=g),g}function Mp(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Nf(s,n,o){this.i=s,this.x=n,this.y=o,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ts(s,n,o,d){for(var g=0,v=n,E=o-d;vo;){if(d-o>600){var v=d-o+1,E=n-o+1,L=Math.log(v),k=.5*Math.exp(2*L/3),V=.5*Math.sqrt(L*k*(v-k)/v)*(E-v/2<0?-1:1);Lg(s,n,Math.max(o,Math.floor(n-E*k/v+V)),Math.min(d,Math.floor(n+(v-E)*k/v+V)),g)}var q=s[n],se=o,he=d;for(Cd(s,o,n),g(s[d],q)>0&&Cd(s,o,d);se0;)he--}g(s[o],q)===0?Cd(s,o,he):Cd(s,++he,d),he<=n&&(o=he+1),n<=he&&(d=he-1)}}function Cd(s,n,o){var d=s[n];s[n]=s[o],s[o]=d}function r0(s,n){return sn?1:0}function Qf(s,n){const o=s.length;if(o<=1)return[s];const d=[];let g,v;for(let E=0;E1)for(let E=0;E0&&o.holes.push(d+=s[g-1].length)}return o};class Fp{constructor(n){this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(o=>o.id),this.index=n.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Or,this.indexArray=new _o,this.indexArray2=new $a,this.programConfigurations=new _A(n.layers,n.zoom),this.segments=new to,this.segments2=new to,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id),this.projection=n.projection}populate(n,o,d,g){this.hasPattern=Ip("fill",this.layers,o);const v=this.layers[0].layout.get("fill-sort-key"),E=[];for(const{feature:L,id:k,index:V,sourceLayerIndex:q}of n){const se=this.layers[0]._featureFilter.needGeometry,he=xA(L,se);if(!this.layers[0]._featureFilter.filter(new qt(this.zoom),he,d))continue;const _e=v?v.evaluate(he,{},d,o.availableImages):void 0,be={id:k,properties:L.properties,type:L.type,sourceLayerIndex:q,index:V,geometry:se?he.geometry:Yh(L,d,g),patterns:{},sortKey:_e};E.push(be)}v&&E.sort((L,k)=>L.sortKey-k.sortKey);for(const L of E){const{geometry:k,index:V,sourceLayerIndex:q}=L;if(this.hasPattern){const se=Ed("fill",this.layers,L,this.zoom,o);this.patternFeatures.push(se)}else this.addFeature(L,k,V,d,{},o.availableImages);o.featureIndex.insert(n[V].feature,k,V,q,this.index)}}update(n,o,d,g){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,o,this.stateDependentLayers,d,g)}addFeatures(n,o,d,g,v){for(const E of this.patternFeatures)this.addFeature(E,E.geometry,E.index,o,d,g)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Mg),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.indexBuffer2=n.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(n),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(n,o,d,g,v,E=[]){for(const L of Qf(o,500)){let k=0;for(const be of L)k+=be.length;const V=this.segments.prepareSegment(k,this.layoutVertexArray,this.indexArray),q=V.vertexLength,se=[],he=[];for(const be of L){if(be.length===0)continue;be!==L[0]&&he.push(se.length/2);const De=this.segments2.prepareSegment(be.length,this.layoutVertexArray,this.indexArray2),Ze=De.vertexLength;this.layoutVertexArray.emplaceBack(be[0].x,be[0].y),this.indexArray2.emplaceBack(Ze+be.length-1,Ze),se.push(be[0].x),se.push(be[0].y);for(let xt=1;xt>3}if(g--,d===1||d===2)v+=s.readSVarint(),E+=s.readSVarint(),d===1&&(n&&L.push(n),n=[]),n.push(new c0(v,E));else{if(d!==7)throw new Error("unknown command "+d);n&&n.push(n[0].clone())}}return n&&L.push(n),L},MA.prototype.bbox=function(){var s=this._pbf;s.pos=this._geometry;for(var n=s.readVarint()+s.pos,o=1,d=0,g=0,v=0,E=1/0,L=-1/0,k=1/0,V=-1/0;s.pos>3}if(d--,o===1||o===2)(g+=s.readSVarint())L&&(L=g),(v+=s.readSVarint())V&&(V=v);else if(o!==7)throw new Error("unknown command "+o)}return[E,k,L,V]},MA.prototype.toGeoJSON=function(s,n,o){var d,g,v=this.extent*Math.pow(2,o),E=this.extent*s,L=this.extent*n,k=this.loadGeometry(),V=MA.types[this.type];function q(_e){for(var be=0;be<_e.length;be++){var De=_e[be];_e[be]=[360*(De.x+E)/v-180,360/Math.PI*Math.atan(Math.exp((180-360*(De.y+L)/v)*Math.PI/180))-90]}}switch(this.type){case 1:var se=[];for(d=0;d>3;g=E===1?d.readString():E===2?d.readFloat():E===3?d.readDouble():E===4?d.readVarint64():E===5?d.readVarint():E===6?d.readSVarint():E===7?d.readBoolean():null}return g}(o))}Hf.prototype.feature=function(s){if(s<0||s>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[s];var n=this._pbf.readVarint()+this._pbf.pos;return new Vf(this._pbf,n,this.extent,this._keys,this._values)};var A=Td;function l(s,n,o){if(s===3){var d=new A(o,o.readVarint()+o.pos);d.length&&(n[d.name]=d)}}var f=Dp.VectorTile=function(s,n){this.layers=s.readFields(l,{},n)},w=Dp.VectorTileFeature=Pg;function I(s,n,o,d){const g=[],v=d===0?(E,L,k,V,q,se)=>{E.push(new me(se,k+(se-L)/(V-L)*(q-k)))}:(E,L,k,V,q,se)=>{E.push(new me(L+(se-k)/(q-k)*(V-L),se))};for(const E of s){const L=[];for(const k of E){if(k.length<=2)continue;const V=[];for(let he=0;hen&&v(V,_e,be,De,Ze,n):xt>o?Dt=n&&v(V,_e,be,De,Ze,n),Dt>o&&xt<=o&&v(V,_e,be,De,Ze,o)}let q=k[k.length-1];const se=d===0?q.x:q.y;se>=n&&se<=o&&V.push(q),V.length&&(q=V[V.length-1],V[0].x===q.x&&V[0].y===q.y||V.push(V[0]),L.push(V))}L.length&&g.push(L)}return g}Dp.VectorTileLayer=Td;const z=w.types,Q=Math.pow(2,13);function Z(s,n,o,d,g,v,E,L){s.emplaceBack((n<<1)+E,(o<<1)+v,(Math.floor(d*Q)<<1)+g,Math.round(L))}function re(s,n,o){s.emplaceBack(n.x,n.y,n.z,o[0]*16384,o[1]*16384,o[2]*16384)}class ge{constructor(){this.acc=new me(0,0),this.polyCount=[]}startRing(n){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new me(n.x,n.y),this.max=new me(n.x,n.y))}append(n,o){this.currentPolyCount.edges++,this.acc._add(n);const d=this.min,g=this.max;n.xg.x&&(g.x=n.x),n.yg.y&&(g.y=n.y),((n.x===0||n.x===Zn)&&n.x===o.x)!=((n.y===0||n.y===Zn)&&n.y===o.y)&&this.processBorderOverlap(n,o),o.x<0!=n.x<0&&this.addBorderIntersection(0,gr(o.y,n.y,(0-o.x)/(n.x-o.x))),o.x>Zn!=n.x>Zn&&this.addBorderIntersection(1,gr(o.y,n.y,(Zn-o.x)/(n.x-o.x))),o.y<0!=n.y<0&&this.addBorderIntersection(2,gr(o.x,n.x,(0-o.y)/(n.y-o.y))),o.y>Zn!=n.y>Zn&&this.addBorderIntersection(3,gr(o.x,n.x,(Zn-o.y)/(n.y-o.y)))}addBorderIntersection(n,o){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 d=this.borders[n];od[1]&&(d[1]=o)}processBorderOverlap(n,o){if(n.x===o.x){if(n.y===o.y)return;const d=n.x===0?0:1;this.addBorderIntersection(d,o.y),this.addBorderIntersection(d,n.y)}else{const d=n.y===0?2:3;this.addBorderIntersection(d,o.x),this.addBorderIntersection(d,n.x)}}centroid(){const n=this.polyCount.reduce((o,d)=>o+d.edges,0);return n!==0?this.acc.div(n)._round():new me(0,0)}span(){return new me(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((n,o)=>n+ +(o[0]!==Number.MAX_VALUE),0)}}class Ce{constructor(n){this.zoom=n.zoom,this.canonical=n.canonical,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(o=>o.id),this.index=n.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=n.projection,this.layoutVertexArray=new Qr,this.centroidVertexArray=new Fy,this.indexArray=new _o,this.programConfigurations=new _A(n.layers,n.zoom),this.segments=new to,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id),this.enableTerrain=n.enableTerrain}populate(n,o,d,g){this.features=[],this.hasPattern=Ip("fill-extrusion",this.layers,o),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(v){const E=Math.exp(Math.PI*(1-v.y/(1<=0;xt--){const Dt=_e[xt];(Dt.length===0||(be=Dt[0]).every(_t=>_t.x<=0)||be.every(_t=>_t.x>=Zn)||be.every(_t=>_t.y<=0)||be.every(_t=>_t.y>=Zn))&&_e.splice(xt,1)}var be;let De;if(q)De=gi(_e,k,g);else{De=[];for(const xt of _e)De.push({polygon:xt,bounds:k})}const Ze=he?this.edgeRadius:0;for(const{polygon:xt,bounds:Dt}of De){let _t=0,Tt=0;for(const Ut of xt)he&&!Ut[0].equals(Ut[Ut.length-1])&&Ut.push(Ut[0]),Tt+=he?Ut.length-1:Ut.length;const kt=this.segments.prepareSegment((he?5:4)*Tt,this.layoutVertexArray,this.indexArray);if(he){const Ut=[],ci=[];_t=kt.vertexLength;for(const Ti of xt){let Ki,_i;Ti.length&&Ti!==xt[0]&&ci.push(Ut.length/2),Ki=Ti[1].sub(Ti[0])._perp()._unit();for(let Si=1;Si4&&Rt(Ut[Ut.length-2],Ut[0],Ut[1]),_i=Ze?Oe(Ut[Ut.length-2],Ut[0],Ut[1],Ze):0;ai=Ut[1].sub(Ut[0])._perp()._unit();let Si=!0;for(let Li=1,Vi=0;Li0?1:0,ln=Zi.dist(yi);if(Vi+ln>32768&&(Vi=0),Ze){Ti=sn.sub(yi)._perp()._unit();let xr=je(Zi,yi,sn,Fe(ai,Ti),Ze);isNaN(xr)&&(xr=0);const Jn=yi.sub(Zi)._unit();Zi=Zi.add(Jn.mult(_i))._round(),yi=yi.add(Jn.mult(-xr))._round(),_i=xr,ai=Ti}const Xn=kt.vertexLength,Tr=Ut.length>4&&Rt(Zi,yi,sn);let wr=Mt(Vi,Ki,Si);if(Z(this.layoutVertexArray,Zi.x,Zi.y,dn,Ln,0,0,wr),Z(this.layoutVertexArray,Zi.x,Zi.y,dn,Ln,0,1,wr),Vi+=ln,wr=Mt(Vi,Tr,!Si),Ki=Tr,Z(this.layoutVertexArray,yi.x,yi.y,dn,Ln,0,0,wr),Z(this.layoutVertexArray,yi.x,yi.y,dn,Ln,0,1,wr),kt.vertexLength+=4,this.indexArray.emplaceBack(Xn+0,Xn+1,Xn+2),this.indexArray.emplaceBack(Xn+1,Xn+3,Xn+2),kt.primitiveLength+=2,Ze){const xr=_t+(Li===1?Ut.length-2:Li-2),Jn=Li===1?_t:xr+1;if(this.indexArray.emplaceBack(Xn+1,xr,Xn+3),this.indexArray.emplaceBack(xr,Jn,Xn+3),kt.primitiveLength+=2,ci===void 0&&(ci=Xn),!$e(sn,Ut[Li],Dt)){const es=Li===Ut.length-1?ci:kt.vertexLength;this.indexArray.emplaceBack(Xn+2,Xn+3,es),this.indexArray.emplaceBack(Xn+3,es+1,es),this.indexArray.emplaceBack(Xn+3,Jn,es+1),kt.primitiveLength+=3}Si=!Si}if(q){const xr=this.layoutVertexExtArray,Jn=V.projectTilePoint(Zi.x,Zi.y,g),es=V.projectTilePoint(yi.x,yi.y,g),ir=V.upVector(g,Zi.x,Zi.y),Sr=V.upVector(g,yi.x,yi.y);re(xr,Jn,ir),re(xr,Jn,ir),re(xr,es,Sr),re(xr,es,Sr)}}he&&(_t+=Ut.length-1)}}if(se&&se.polyCount.length>0){if(se.borders){se.vertexArrayOffset=this.centroidVertexArray.length;const xt=se.borders,Dt=this.featuresOnBorder.push(se)-1;for(let _t=0;_t<4;_t++)xt[_t][0]!==Number.MAX_VALUE&&this.borders[_t].push(Dt)}this.encodeCentroid(se.borders?void 0:se.centroid(),se)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,d,v,E,g)}sortBorders(){for(let n=0;n<4;n++)this.borders[n].sort((o,d)=>this.featuresOnBorder[o].borders[n][0]-this.featuresOnBorder[d].borders[n][0])}encodeCentroid(n,o,d=!0){let g,v;if(n)if(n.y!==0){const L=o.span()._mult(this.tileToMeter);g=(Math.max(n.x,1)<<3)+Math.min(7,Math.round(L.x/10)),v=(Math.max(n.y,1)<<3)+Math.min(7,Math.round(L.y/10))}else g=Math.ceil(7*(n.x+450)),v=0;else g=0,v=+d;let E=d?this.centroidVertexArray.length:o.vertexArrayOffset;for(const L of o.polyCount){d&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*L.edges+L.top);for(let k=0;ko[1].x&&n.x>o[1].x||s.yo[1].y&&n.y>o[1].y}function Rt(s,n,o){if(s.x<0||s.x>=Zn||n.x<0||n.x>=Zn||o.x<0||o.x>=Zn)return!1;const d=o.sub(n),g=d.perp(),v=s.sub(n);return(d.x*v.x+d.y*v.y)/Math.sqrt((d.x*d.x+d.y*d.y)*(v.x*v.x+v.y*v.y))>-.866&&g.x*v.x+g.y*v.y<0}function Mt(s,n,o){const d=n?2|s:-3&s;return o?1|d:-2&d}function ri(){const s=Math.PI/32,n=Math.tan(s),o=Tf;return o*Math.sqrt(1+2*n*n)-o}function gi(s,n,o){const d=1<{for(const ai of Ut)be.push({polygon:ai,bounds:ci})},Ze=Math.ceil(Math.log2(q)),xt=Math.ceil(Math.log2(se)),Dt=Ze-xt,_t=[];for(let Ut=0;Ut0?0:1);for(let Ut=0;Utci+1?kt.push({polygons:Vi,bounds:yi,depth:ci+1}):De(Vi,yi)}if(Zi.length){const yi=[new me(ai===0?Li:Ti.x,ai===1?Li:Ti.y),Ki];_t.length>ci+1?kt.push({polygons:Zi,bounds:yi,depth:ci+1}):De(Zi,yi)}}return be}(s,n,Math.ceil((v-g)/11.25),Math.ceil((E-L)/11.25),1,(k,V,q)=>{if(k===0)return .5*(V+q);{const se=Fo((o.y+V/Zn)/d);return(ch(.5*(Fo((o.y+q/Zn)/d)+se))*d-o.y)*Zn}})}zt(Ce,"FillExtrusionBucket",{omit:["layers","features"]}),zt(ge,"PartMetadata");const ei=new Hn({"fill-extrusion-edge-radius":new Jt(Yt["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var ui={paint:new Hn({"fill-extrusion-opacity":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new pi(Yt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new pi(Yt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new pi(Yt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new pi(Yt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"])}),layout:ei};function Pi(s,n,o){var d=2*Math.PI*6378137/256/Math.pow(2,o);return[s*d-2*Math.PI*6378137/2,n*d-2*Math.PI*6378137/2]}class Fi{constructor(n,o,d){this.z=n,this.x=o,this.y=d,this.key=mn(0,n,n,o,d)}equals(n){return this.z===n.z&&this.x===n.x&&this.y===n.y}url(n,o){const d=function(v,E,L){var k=Pi(256*v,256*(E=Math.pow(2,L)-E-1),L),V=Pi(256*(v+1),256*(E+1),L);return k[0]+","+k[1]+","+V[0]+","+V[1]}(this.x,this.y,this.z),g=function(v,E,L){let k,V="";for(let q=v;q>0;q--)k=1<this.canonical.z?new fn(n,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new fn(n,this.wrap,n,this.canonical.x>>o,this.canonical.y>>o)}calculateScaledKey(n,o=!0){if(this.overscaledZ===n&&o)return this.key;if(n>this.canonical.z)return mn(this.wrap*+o,n,this.canonical.z,this.canonical.x,this.canonical.y);{const d=this.canonical.z-n;return mn(this.wrap*+o,n,n,this.canonical.x>>d,this.canonical.y>>d)}}isChildOf(n){if(n.wrap!==this.wrap)return!1;const o=this.canonical.z-n.canonical.z;return n.overscaledZ===0||n.overscaledZ>o&&n.canonical.y===this.canonical.y>>o}children(n){if(this.overscaledZ>=n)return[new fn(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const o=this.canonical.z+1,d=2*this.canonical.x,g=2*this.canonical.y;return[new fn(o,this.wrap,o,d,g),new fn(o,this.wrap,o,d+1,g),new fn(o,this.wrap,o,d,g+1),new fn(o,this.wrap,o,d+1,g+1)]}isLessThan(n){return this.wrapn.wrap)&&(this.overscaledZn.overscaledZ)&&(this.canonical.xn.canonical.x)&&this.canonical.yo.id),this.index=n.index,this.projection=n.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(o=>{this.gradients[o.id]={}}),this.layoutVertexArray=new go,this.layoutVertexArray2=new Ca,this.indexArray=new _o,this.programConfigurations=new _A(n.layers,n.zoom),this.segments=new to,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id)}populate(n,o,d,g){this.hasPattern=Ip("line",this.layers,o);const v=this.layers[0].layout.get("line-sort-key"),E=[];for(const{feature:q,id:se,index:he,sourceLayerIndex:_e}of n){const be=this.layers[0]._featureFilter.needGeometry,De=xA(q,be);if(!this.layers[0]._featureFilter.filter(new qt(this.zoom),De,d))continue;const Ze=v?v.evaluate(De,{},d):void 0,xt={id:se,properties:q.properties,type:q.type,sourceLayerIndex:_e,index:he,geometry:be?De.geometry:Yh(q,d,g),patterns:{},sortKey:Ze};E.push(xt)}v&&E.sort((q,se)=>q.sortKey-se.sortKey);const{lineAtlas:L,featureIndex:k}=o,V=this.addConstantDashes(L);for(const q of E){const{geometry:se,index:he,sourceLayerIndex:_e}=q;if(V&&this.addFeatureDashes(q,L),this.hasPattern){const be=Ed("line",this.layers,q,this.zoom,o);this.patternFeatures.push(be)}else this.addFeature(q,se,he,d,L.positions,o.availableImages);k.insert(n[he].feature,se,he,_e,this.index)}}addConstantDashes(n){let o=!1;for(const d of this.layers){const g=d.paint.get("line-dasharray").value,v=d.layout.get("line-cap").value;if(g.kind!=="constant"||v.kind!=="constant")o=!0;else{const E=v.value,L=g.value;if(!L)continue;n.addDash(L,E)}}return o}addFeatureDashes(n,o){const d=this.zoom;for(const g of this.layers){const v=g.paint.get("line-dasharray").value,E=g.layout.get("line-cap").value;if(v.kind==="constant"&&E.kind==="constant")continue;let L,k;if(v.kind==="constant"){if(L=v.value,!L)continue}else L=v.evaluate({zoom:d},n);k=E.kind==="constant"?E.value:E.evaluate({zoom:d},n),o.addDash(L,k),n.patterns[g.id]=o.getKey(L,k)}}update(n,o,d,g){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,o,this.stateDependentLayers,d,g)}addFeatures(n,o,d,g,v){for(const E of this.patternFeatures)this.addFeature(E,E.geometry,E.index,o,d,g)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=n.createVertexBuffer(this.layoutVertexArray2,yr)),this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Wn),this.indexBuffer=n.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(n),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(n){if(n.properties&&n.properties.hasOwnProperty("mapbox_clip_start")&&n.properties.hasOwnProperty("mapbox_clip_end"))return{start:+n.properties.mapbox_clip_start,end:+n.properties.mapbox_clip_end}}addFeature(n,o,d,g,v,E){const L=this.layers[0].layout,k=L.get("line-join").evaluate(n,{}),V=L.get("line-cap").evaluate(n,{}),q=L.get("line-miter-limit"),se=L.get("line-round-limit");this.lineClips=this.lineFeatureClips(n);for(const he of o)this.addLine(he,n,k,V,q,se);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,d,v,E,g)}addLine(n,o,d,g,v,E){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let xt=0;xt=2&&n[k-1].equals(n[k-2]);)k--;let V=0;for(;V0;if(ci&&xt>V){const _i=he.dist(_e);if(_i>2*q){const Si=he.sub(he.sub(_e)._mult(q/_i)._round());this.updateDistance(_e,Si),this.addCurrentVertex(Si,De,0,0,se),_e=Si}}const Ti=_e&&be;let Ki=Ti?d:L?"butt":g;if(Ti&&Ki==="round"&&(ktv&&(Ki="bevel"),Ki==="bevel"&&(kt>2&&(Ki="flipbevel"),kt100)Dt=Ze.mult(-1);else{const _i=kt*De.add(Ze).mag()/De.sub(Ze).mag();Dt._perp()._mult(_i*(ai?-1:1))}this.addCurrentVertex(he,Dt,0,0,se),this.addCurrentVertex(he,Dt.mult(-1),0,0,se)}else if(Ki==="bevel"||Ki==="fakeround"){const _i=-Math.sqrt(kt*kt-1),Si=ai?_i:0,Li=ai?0:_i;if(_e&&this.addCurrentVertex(he,De,Si,Li,se),Ki==="fakeround"){const Vi=Math.round(180*Ut/Math.PI/20);for(let Zi=1;Zi2*q){const Si=he.add(be.sub(he)._mult(q/_i)._round());this.updateDistance(he,Si),this.addCurrentVertex(Si,Ze,0,0,se),he=Si}}}}addCurrentVertex(n,o,d,g,v,E=!1){const L=o.y*g-o.x,k=-o.y-o.x*g;this.addHalfVertex(n,o.x+o.y*d,o.y-o.x*d,E,!1,d,v),this.addHalfVertex(n,L,k,E,!0,-g,v)}addHalfVertex({x:n,y:o},d,g,v,E,L,k){this.layoutVertexArray.emplaceBack((n<<1)+(v?1:0),(o<<1)+(E?1:0),Math.round(63*d)+128,Math.round(63*g)+128,1+(L===0?0:L<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const V=k.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,V),k.primitiveLength++),E?this.e2=V:this.e1=V}updateScaledDistance(){if(this.lineClips){const n=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=n*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(n,o){this.distance+=n.dist(o),this.updateScaledDistance()}}zt(Vs,"LineBucket",{omit:["layers","patternFeatures"]});const Cl=new Hn({"line-cap":new pi(Yt.layout_line["line-cap"]),"line-join":new pi(Yt.layout_line["line-join"]),"line-miter-limit":new Jt(Yt.layout_line["line-miter-limit"]),"line-round-limit":new Jt(Yt.layout_line["line-round-limit"]),"line-sort-key":new pi(Yt.layout_line["line-sort-key"])});var xo={paint:new Hn({"line-opacity":new pi(Yt.paint_line["line-opacity"]),"line-color":new pi(Yt.paint_line["line-color"]),"line-translate":new Jt(Yt.paint_line["line-translate"]),"line-translate-anchor":new Jt(Yt.paint_line["line-translate-anchor"]),"line-width":new pi(Yt.paint_line["line-width"]),"line-gap-width":new pi(Yt.paint_line["line-gap-width"]),"line-offset":new pi(Yt.paint_line["line-offset"]),"line-blur":new pi(Yt.paint_line["line-blur"]),"line-dasharray":new pi(Yt.paint_line["line-dasharray"]),"line-pattern":new pi(Yt.paint_line["line-pattern"]),"line-gradient":new In(Yt.paint_line["line-gradient"]),"line-trim-offset":new Jt(Yt.paint_line["line-trim-offset"])}),layout:Cl};const Ks=new class extends pi{possiblyEvaluate(s,n){return n=new qt(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,transition:n.transition}),super.possiblyEvaluate(s,n)}evaluate(s,n,o,d){return n=Ve({},n,{zoom:Math.floor(n.zoom)}),super.evaluate(s,n,o,d)}}(xo.paint.properties["line-width"].specification);function oo(s,n){return n>0?n+2*s:s}Ks.useIntegerZoom=!0;const Lo=_n([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),$o=_n([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Ia=_n([{name:"a_projected_pos",components:4,type:"Float32"}],4);_n([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const io=_n([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Do=_n([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);_n([{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 Po=_n([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),fa=_n([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);_n([{name:"triangle",components:3,type:"Uint16"}]),_n([{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"}]),_n([{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"}]),_n([{type:"Float32",name:"offsetX"}]),_n([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Jr=24;const Hs=128;function gs(s,n){const{expression:o}=n;if(o.kind==="constant")return{kind:"constant",layoutSize:o.evaluate(new qt(s+1))};if(o.kind==="source")return{kind:"source"};{const{zoomStops:d,interpolationType:g}=o;let v=0;for(;v{d.text=function(g,v,E){const L=v.layout.get("text-transform").evaluate(E,{});return L==="uppercase"?g=g.toLocaleUpperCase():L==="lowercase"&&(g=g.toLocaleLowerCase()),si.applyArabicShaping&&(g=si.applyArabicShaping(g)),g}(d.text,n,o)}),s}const ao={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};function Jl(s){return s==="\uFE36"||s==="\uFE48"||s==="\uFE38"||s==="\uFE44"||s==="\uFE42"||s==="\uFE3E"||s==="\uFE3C"||s==="\uFE3A"||s==="\uFE18"||s==="\uFE40"||s==="\uFE10"||s==="\uFE13"||s==="\uFE14"||s==="\uFF40"||s==="\uFFE3"||s==="\uFE11"||s==="\uFE12"}function Bc(s){return s==="\uFE35"||s==="\uFE47"||s==="\uFE37"||s==="\uFE43"||s==="\uFE41"||s==="\uFE3D"||s==="\uFE3B"||s==="\uFE39"||s==="\uFE17"||s==="\uFE3F"}var Fa=vr,Ah=function(s,n,o,d,g){var v,E,L=8*g-d-1,k=(1<>1,q=-7,se=o?g-1:0,he=o?-1:1,_e=s[n+se];for(se+=he,v=_e&(1<<-q)-1,_e>>=-q,q+=L;q>0;v=256*v+s[n+se],se+=he,q-=8);for(E=v&(1<<-q)-1,v>>=-q,q+=d;q>0;E=256*E+s[n+se],se+=he,q-=8);if(v===0)v=1-V;else{if(v===k)return E?NaN:1/0*(_e?-1:1);E+=Math.pow(2,d),v-=V}return(_e?-1:1)*E*Math.pow(2,v-d)},El=function(s,n,o,d,g,v){var E,L,k,V=8*v-g-1,q=(1<>1,he=g===23?Math.pow(2,-24)-Math.pow(2,-77):0,_e=d?0:v-1,be=d?1:-1,De=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(L=isNaN(n)?1:0,E=q):(E=Math.floor(Math.log(n)/Math.LN2),n*(k=Math.pow(2,-E))<1&&(E--,k*=2),(n+=E+se>=1?he/k:he*Math.pow(2,1-se))*k>=2&&(E++,k/=2),E+se>=q?(L=0,E=q):E+se>=1?(L=(n*k-1)*Math.pow(2,g),E+=se):(L=n*Math.pow(2,se-1)*Math.pow(2,g),E=0));g>=8;s[o+_e]=255&L,_e+=be,L/=256,g-=8);for(E=E<0;s[o+_e]=255&E,_e+=be,E/=256,V-=8);s[o+_e-be]|=128*De};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */function vr(s){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(s)?s:new Uint8Array(s||0),this.pos=0,this.type=0,this.length=this.buf.length}vr.Varint=0,vr.Fixed64=1,vr.Bytes=2,vr.Fixed32=5;var Zo=4294967296,dh=1/Zo,Sd=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function ph(s){return s.type===vr.Bytes?s.readVarint()+s.pos:s.pos+1}function Iu(s,n,o){return o?4294967296*n+(s>>>0):4294967296*(n>>>0)+(s>>>0)}function Gf(s,n,o){var d=n<=16383?1:n<=2097151?2:n<=268435455?3:Math.floor(Math.log(n)/(7*Math.LN2));o.realloc(d);for(var g=o.pos-1;g>=s;g--)o.buf[g+d]=o.buf[g]}function tu(s,n){for(var o=0;o>>8,s[o+2]=n>>>16,s[o+3]=n>>>24}function A0(s,n){return(s[n]|s[n+1]<<8|s[n+2]<<16)+(s[n+3]<<24)}function E1(s,n,o){n.glyphs=[],s===1&&o.readMessage(Cc,n)}function Cc(s,n,o){if(s===3){const{id:d,bitmap:g,width:v,height:E,left:L,top:k,advance:V}=o.readMessage(jf,{});n.glyphs.push({id:d,bitmap:new Yl({width:v+6,height:E+6},g),metrics:{width:v,height:E,left:L,top:k,advance:V}})}else s===4?n.ascender=o.readSVarint():s===5&&(n.descender=o.readSVarint())}function jf(s,n,o){s===1?n.id=o.readVarint():s===2?n.bitmap=o.readBytes():s===3?n.width=o.readVarint():s===4?n.height=o.readVarint():s===5?n.left=o.readSVarint():s===6?n.top=o.readSVarint():s===7&&(n.advance=o.readVarint())}function Kf(s){let n=0,o=0;for(const E of s)n+=E.w*E.h,o=Math.max(o,E.w);s.sort((E,L)=>L.h-E.h);const d=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(n/.95)),o),h:1/0}];let g=0,v=0;for(const E of s)for(let L=d.length-1;L>=0;L--){const k=d[L];if(!(E.w>k.w||E.h>k.h)){if(E.x=k.x,E.y=k.y,v=Math.max(v,E.y+E.h),g=Math.max(g,E.x+E.w),E.w===k.w&&E.h===k.h){const V=d.pop();L>3,v=this.pos;this.type=7&d,s(g,n,this),this.pos===v&&this.skip(d)}return n},readMessage:function(s,n){return this.readFields(s,n,this.readVarint()+this.pos)},readFixed32:function(){var s=Wf(this.buf,this.pos);return this.pos+=4,s},readSFixed32:function(){var s=A0(this.buf,this.pos);return this.pos+=4,s},readFixed64:function(){var s=Wf(this.buf,this.pos)+Wf(this.buf,this.pos+4)*Zo;return this.pos+=8,s},readSFixed64:function(){var s=Wf(this.buf,this.pos)+A0(this.buf,this.pos+4)*Zo;return this.pos+=8,s},readFloat:function(){var s=Ah(this.buf,this.pos,!0,23,4);return this.pos+=4,s},readDouble:function(){var s=Ah(this.buf,this.pos,!0,52,8);return this.pos+=8,s},readVarint:function(s){var n,o,d=this.buf;return n=127&(o=d[this.pos++]),o<128?n:(n|=(127&(o=d[this.pos++]))<<7,o<128?n:(n|=(127&(o=d[this.pos++]))<<14,o<128?n:(n|=(127&(o=d[this.pos++]))<<21,o<128?n:function(g,v,E){var L,k,V=E.buf;if(L=(112&(k=V[E.pos++]))>>4,k<128||(L|=(127&(k=V[E.pos++]))<<3,k<128)||(L|=(127&(k=V[E.pos++]))<<10,k<128)||(L|=(127&(k=V[E.pos++]))<<17,k<128)||(L|=(127&(k=V[E.pos++]))<<24,k<128)||(L|=(1&(k=V[E.pos++]))<<31,k<128))return Iu(g,L,v);throw new Error("Expected varint not more than 10 bytes")}(n|=(15&(o=d[this.pos]))<<28,s,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var s=this.readVarint();return s%2==1?(s+1)/-2:s/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var s=this.readVarint()+this.pos,n=this.pos;return this.pos=s,s-n>=12&&Sd?function(o,d,g){return Sd.decode(o.subarray(d,g))}(this.buf,n,s):function(o,d,g){for(var v="",E=d;E239?4:q>223?3:q>191?2:1;if(E+he>g)break;he===1?q<128&&(se=q):he===2?(192&(L=o[E+1]))==128&&(se=(31&q)<<6|63&L)<=127&&(se=null):he===3?(k=o[E+2],(192&(L=o[E+1]))==128&&(192&k)==128&&((se=(15&q)<<12|(63&L)<<6|63&k)<=2047||se>=55296&&se<=57343)&&(se=null)):he===4&&(k=o[E+2],V=o[E+3],(192&(L=o[E+1]))==128&&(192&k)==128&&(192&V)==128&&((se=(15&q)<<18|(63&L)<<12|(63&k)<<6|63&V)<=65535||se>=1114112)&&(se=null)),se===null?(se=65533,he=1):se>65535&&(se-=65536,v+=String.fromCharCode(se>>>10&1023|55296),se=56320|1023&se),v+=String.fromCharCode(se),E+=he}return v}(this.buf,n,s)},readBytes:function(){var s=this.readVarint()+this.pos,n=this.buf.subarray(this.pos,s);return this.pos=s,n},readPackedVarint:function(s,n){if(this.type!==vr.Bytes)return s.push(this.readVarint(n));var o=ph(this);for(s=s||[];this.pos127;);else if(n===vr.Bytes)this.pos=this.readVarint()+this.pos;else if(n===vr.Fixed32)this.pos+=4;else{if(n!==vr.Fixed64)throw new Error("Unimplemented type: "+n);this.pos+=8}},writeTag:function(s,n){this.writeVarint(s<<3|n)},realloc:function(s){for(var n=this.length||16;n268435455||s<0?function(n,o){var d,g;if(n>=0?(d=n%4294967296|0,g=n/4294967296|0):(g=~(-n/4294967296),4294967295^(d=~(-n%4294967296))?d=d+1|0:(d=0,g=g+1|0)),n>=18446744073709552e3||n<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");o.realloc(10),function(v,E,L){L.buf[L.pos++]=127&v|128,v>>>=7,L.buf[L.pos++]=127&v|128,v>>>=7,L.buf[L.pos++]=127&v|128,v>>>=7,L.buf[L.pos++]=127&v|128,L.buf[L.pos]=127&(v>>>=7)}(d,0,o),function(v,E){var L=(7&v)<<4;E.buf[E.pos++]|=L|((v>>>=3)?128:0),v&&(E.buf[E.pos++]=127&v|((v>>>=7)?128:0),v&&(E.buf[E.pos++]=127&v|((v>>>=7)?128:0),v&&(E.buf[E.pos++]=127&v|((v>>>=7)?128:0),v&&(E.buf[E.pos++]=127&v|((v>>>=7)?128:0),v&&(E.buf[E.pos++]=127&v)))))}(g,o)}(s,this):(this.realloc(4),this.buf[this.pos++]=127&s|(s>127?128:0),s<=127||(this.buf[this.pos++]=127&(s>>>=7)|(s>127?128:0),s<=127||(this.buf[this.pos++]=127&(s>>>=7)|(s>127?128:0),s<=127||(this.buf[this.pos++]=s>>>7&127))))},writeSVarint:function(s){this.writeVarint(s<0?2*-s-1:2*s)},writeBoolean:function(s){this.writeVarint(Boolean(s))},writeString:function(s){s=String(s),this.realloc(4*s.length),this.pos++;var n=this.pos;this.pos=function(d,g,v){for(var E,L,k=0;k55295&&E<57344){if(!L){E>56319||k+1===g.length?(d[v++]=239,d[v++]=191,d[v++]=189):L=E;continue}if(E<56320){d[v++]=239,d[v++]=191,d[v++]=189,L=E;continue}E=L-55296<<10|E-56320|65536,L=null}else L&&(d[v++]=239,d[v++]=191,d[v++]=189,L=null);E<128?d[v++]=E:(E<2048?d[v++]=E>>6|192:(E<65536?d[v++]=E>>12|224:(d[v++]=E>>18|240,d[v++]=E>>12&63|128),d[v++]=E>>6&63|128),d[v++]=63&E|128)}return v}(this.buf,s,this.pos);var o=this.pos-n;o>=128&&Gf(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeFloat:function(s){this.realloc(4),El(this.buf,s,this.pos,!0,23,4),this.pos+=4},writeDouble:function(s){this.realloc(8),El(this.buf,s,this.pos,!0,52,8),this.pos+=8},writeBytes:function(s){var n=s.length;this.writeVarint(n),this.realloc(n);for(var o=0;o=128&&Gf(o,d,this),this.pos=o-1,this.writeVarint(d),this.pos+=d},writeMessage:function(s,n,o){this.writeTag(s,vr.Bytes),this.writeRawMessage(n,o)},writePackedVarint:function(s,n){n.length&&this.writeMessage(s,tu,n)},writePackedSVarint:function(s,n){n.length&&this.writeMessage(s,h0,n)},writePackedBoolean:function(s,n){n.length&&this.writeMessage(s,u0,n)},writePackedFloat:function(s,n){n.length&&this.writeMessage(s,Rg,n)},writePackedDouble:function(s,n){n.length&&this.writeMessage(s,zg,n)},writePackedFixed32:function(s,n){n.length&&this.writeMessage(s,w1,n)},writePackedSFixed32:function(s,n){n.length&&this.writeMessage(s,b1,n)},writePackedFixed64:function(s,n){n.length&&this.writeMessage(s,B1,n)},writePackedSFixed64:function(s,n){n.length&&this.writeMessage(s,C1,n)},writeBytesField:function(s,n){this.writeTag(s,vr.Bytes),this.writeBytes(n)},writeFixed32Field:function(s,n){this.writeTag(s,vr.Fixed32),this.writeFixed32(n)},writeSFixed32Field:function(s,n){this.writeTag(s,vr.Fixed32),this.writeSFixed32(n)},writeFixed64Field:function(s,n){this.writeTag(s,vr.Fixed64),this.writeFixed64(n)},writeSFixed64Field:function(s,n){this.writeTag(s,vr.Fixed64),this.writeSFixed64(n)},writeVarintField:function(s,n){this.writeTag(s,vr.Varint),this.writeVarint(n)},writeSVarintField:function(s,n){this.writeTag(s,vr.Varint),this.writeSVarint(n)},writeStringField:function(s,n){this.writeTag(s,vr.Bytes),this.writeString(n)},writeFloatField:function(s,n){this.writeTag(s,vr.Fixed32),this.writeFloat(n)},writeDoubleField:function(s,n){this.writeTag(s,vr.Fixed64),this.writeDouble(n)},writeBooleanField:function(s,n){this.writeVarintField(s,Boolean(n))}};class Xo{constructor(n,{pixelRatio:o,version:d,stretchX:g,stretchY:v,content:E}){this.paddedRect=n,this.pixelRatio=o,this.stretchX=g,this.stretchY=v,this.content=E,this.version=d}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Ec{constructor(n,o){const d={},g={};this.haveRenderCallbacks=[];const v=[];this.addImages(n,d,v),this.addImages(o,g,v);const{w:E,h:L}=Kf(v),k=new Xa({width:E||1,height:L||1});for(const V in n){const q=n[V],se=d[V].paddedRect;Xa.copy(q.data,k,{x:0,y:0},{x:se.x+1,y:se.y+1},q.data)}for(const V in o){const q=o[V],se=g[V].paddedRect,he=se.x+1,_e=se.y+1,be=q.data.width,De=q.data.height;Xa.copy(q.data,k,{x:0,y:0},{x:he,y:_e},q.data),Xa.copy(q.data,k,{x:0,y:De-1},{x:he,y:_e-1},{width:be,height:1}),Xa.copy(q.data,k,{x:0,y:0},{x:he,y:_e+De},{width:be,height:1}),Xa.copy(q.data,k,{x:be-1,y:0},{x:he-1,y:_e},{width:1,height:De}),Xa.copy(q.data,k,{x:0,y:0},{x:he+be,y:_e},{width:1,height:De})}this.image=k,this.iconPositions=d,this.patternPositions=g}addImages(n,o,d){for(const g in n){const v=n[g],E={x:0,y:0,w:v.data.width+2,h:v.data.height+2};d.push(E),o[g]=new Xo(E,v),v.hasRenderCallback&&this.haveRenderCallbacks.push(g)}}patchUpdatedImages(n,o){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(d=>n.hasImage(d)),n.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const d in n.updatedImages)this.patchUpdatedImage(this.iconPositions[d],n.getImage(d),o),this.patchUpdatedImage(this.patternPositions[d],n.getImage(d),o)}patchUpdatedImage(n,o,d){if(!n||!o||n.version===o.version)return;n.version=o.version;const[g,v]=n.tl;d.update(o.data,void 0,{x:g,y:v})}}zt(Xo,"ImagePosition"),zt(Ec,"ImageAtlas");const qo={horizontal:1,vertical:2,horizontalOnly:3};class iu{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(n,o){const d=new iu;return d.scale=n||1,d.fontStack=o,d}static forImage(n){const o=new iu;return o.imageName=n,o}}class IA{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(n,o){const d=new IA;for(let g=0;g=0&&d>=n&&d0[this.text.charCodeAt(d)];d--)o--;this.text=this.text.substring(n,o),this.sectionIndex=this.sectionIndex.slice(n,o)}substring(n,o){const d=new IA;return d.text=this.text.substring(n,o),d.sectionIndex=this.sectionIndex.slice(n,o),d.sections=this.sections,d}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((n,o)=>Math.max(n,this.sections[o].scale),0)}addTextSection(n,o){this.text+=n.text,this.sections.push(iu.forText(n.scale,n.fontStack||o));const d=this.sections.length-1;for(let g=0;g=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function nu(s,n,o,d,g,v,E,L,k,V,q,se,he,_e,be){const De=IA.fromFeature(s,g);se===qo.vertical&&De.verticalizePunctuation(he);let Ze=[];const xt=function(Ut,ci,ai,Ti,Ki,_i){if(!Ut)return[];const Si=[],Li=function(sn,Kn,dn,Ln,ln,Xn){let Tr=0;for(let wr=0;wr=0;let Zi=0;for(let sn=0;sn0&&DA>ys&&(ys=DA)}else{const Ja=ai[Ao.fontStack];if(!Ja)continue;Ja[Vr]&&(os=Ja[Vr]);const ta=ci[Ao.fontStack];if(!ta)continue;const DA=ta.glyphs[Vr];if(!DA)continue;if(vo=DA.metrics,La=Vr!==8203?Jr:0,Xn){const im=ta.ascender!==void 0?Math.abs(ta.ascender):0,Zg=ta.descender!==void 0?Math.abs(ta.descender):0,Xg=(im+Zg)*Us;Bs-o/2;){if(E--,E<0)return!1;L-=s[E].dist(v),v=s[E]}L+=s[E].dist(s[E+1]),E++;const k=[];let V=0;for(;Ld;)V-=k.shift().angleDelta;if(V>g)return!1;E++,L+=q.dist(se)}return!0}function DB(s){let n=0;for(let o=0;oV){const be=(V-k)/_e,De=gr(se.x,he.x,be),Ze=gr(se.y,he.y,be),xt=new FA(De,Ze,0,he.angleTo(se),q);return!E||LB(s,xt,L,E,n)?xt:void 0}k+=_e}}function XF(s,n,o,d,g,v,E,L,k){const V=PB(d,v,E),q=UB(d,g),se=q*E,he=s[0].x===0||s[0].x===k||s[0].y===0||s[0].y===k;return n-se=0&&Tt=0&&kt=0&&he+V<=q){const Ut=new FA(Tt,kt,0,Dt,be);Ut._round(),d&&!LB(s,Ut,v,d,g)||_e.push(Ut)}}se+=xt}return L||_e.length||E||(_e=RB(s,se/2,o,d,g,v,E,!0,k)),_e}function zB(s,n,o,d,g){const v=[];for(let E=0;E=d&&se.x>=d||(q.x>=d?q=new me(d,q.y+(d-q.x)/(se.x-q.x)*(se.y-q.y))._round():se.x>=d&&(se=new me(d,q.y+(d-q.x)/(se.x-q.x)*(se.y-q.y))._round()),q.y>=g&&se.y>=g||(q.y>=g?q=new me(q.x+(g-q.y)/(se.y-q.y)*(se.x-q.x),g)._round():se.y>=g&&(se=new me(q.x+(g-q.y)/(se.y-q.y)*(se.x-q.x),g)._round()),k&&q.equals(k[k.length-1])||(k=[q],v.push(k)),k.push(se)))))}}return v}zt(FA,"Anchor");const kg=1e20;function kB(s,n,o,d,g,v,E,L,k){for(let V=n;V-1);k++,v[k]=L,E[k]=V,E[k+1]=kg}for(let L=0,k=0;L{let L=this.entries[g];L||(L=this.entries[g]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let k=L.glyphs[v];if(k!==void 0)return void E(null,{stack:g,id:v,glyph:k});if(k=this._tinySDF(L,g,v),k)return L.glyphs[v]=k,void E(null,{stack:g,id:v,glyph:k});const V=Math.floor(v/256);if(256*V>65535)return void E(new Error("glyphs > 65535 not supported"));if(L.ranges[V])return void E(null,{stack:g,id:v,glyph:k});let q=L.requests[V];q||(q=L.requests[V]=[],$f.loadGlyphRange(g,V,this.url,this.requestManager,(se,he)=>{if(he){L.ascender=he.ascender,L.descender=he.descender;for(const _e in he.glyphs)this._doesCharSupportLocalGlyph(+_e)||(L.glyphs[+_e]=he.glyphs[+_e]);L.ranges[V]=!0}for(const _e of q)_e(se,he);delete L.requests[V]})),q.push((se,he)=>{se?E(se):he&&E(null,{stack:g,id:v,glyph:he.glyphs[v]||null})})},(g,v)=>{if(g)o(g);else if(v){const E={};for(const{stack:L,id:k,glyph:V}of v)E[L]===void 0&&(E[L]={}),E[L].glyphs===void 0&&(E[L].glyphs={}),E[L].glyphs[k]=V&&{id:V.id,bitmap:V.bitmap.clone(),metrics:V.metrics},E[L].ascender=this.entries[L].ascender,E[L].descender=this.entries[L].descender;o(null,E)}})}_doesCharSupportLocalGlyph(n){return this.localGlyphMode!==S1.none&&(this.localGlyphMode===S1.all?!!this.localFontFamily:!!this.localFontFamily&&(ja(n)||Ba(n)||Lr(n)||Rr(n)||Un(n)))}_tinySDF(n,o,d){const g=this.localFontFamily;if(!g||!this._doesCharSupportLocalGlyph(d))return;let v=n.tinySDF;if(!v){let De="400";/bold/i.test(o)?De="900":/medium/i.test(o)?De="500":/light/i.test(o)&&(De="200"),v=n.tinySDF=new $f.TinySDF({fontFamily:g,fontWeight:De,fontSize:48,buffer:6,radius:16}),v.fontWeight=De}if(this.localGlyphs[v.fontWeight][d])return this.localGlyphs[v.fontWeight][d];const E=String.fromCharCode(d),{data:L,width:k,height:V,glyphWidth:q,glyphHeight:se,glyphLeft:he,glyphTop:_e,glyphAdvance:be}=v.draw(E);return this.localGlyphs[v.fontWeight][d]={id:d,bitmap:new Yl({width:k,height:V},L),metrics:{width:q/2,height:se/2,left:he/2,top:_e/2-27,advance:be/2,localGlyph:!0}}}}function NB(s,n,o,d){const g=[],v=s.image,E=v.pixelRatio,L=v.paddedRect.w-2,k=v.paddedRect.h-2,V=s.right-s.left,q=s.bottom-s.top,se=v.stretchX||[[0,L]],he=v.stretchY||[[0,k]],_e=(_i,Si)=>_i+Si[1]-Si[0],be=se.reduce(_e,0),De=he.reduce(_e,0),Ze=L-be,xt=k-De;let Dt=0,_t=be,Tt=0,kt=De,Ut=0,ci=Ze,ai=0,Ti=xt;if(v.content&&d){const _i=v.content;Dt=p0(se,0,_i[0]),Tt=p0(he,0,_i[1]),_t=p0(se,_i[0],_i[2]),kt=p0(he,_i[1],_i[3]),Ut=_i[0]-Dt,ai=_i[1]-Tt,ci=_i[2]-_i[0]-_t,Ti=_i[3]-_i[1]-kt}const Ki=(_i,Si,Li,Vi)=>{const Zi=f0(_i.stretch-Dt,_t,V,s.left),yi=m0(_i.fixed-Ut,ci,_i.stretch,be),sn=f0(Si.stretch-Tt,kt,q,s.top),Kn=m0(Si.fixed-ai,Ti,Si.stretch,De),dn=f0(Li.stretch-Dt,_t,V,s.left),Ln=m0(Li.fixed-Ut,ci,Li.stretch,be),ln=f0(Vi.stretch-Tt,kt,q,s.top),Xn=m0(Vi.fixed-ai,Ti,Vi.stretch,De),Tr=new me(Zi,sn),wr=new me(dn,sn),xr=new me(dn,ln),Jn=new me(Zi,ln),es=new me(yi/E,Kn/E),ir=new me(Ln/E,Xn/E),Sr=n*Math.PI/180;if(Sr){const ps=Math.sin(Sr),ys=Math.cos(Sr),Bs=[ys,-ps,ps,ys];Tr._matMult(Bs),wr._matMult(Bs),Jn._matMult(Bs),xr._matMult(Bs)}const ss=_i.stretch+_i.fixed,_s=Si.stretch+Si.fixed;return{tl:Tr,tr:wr,bl:Jn,br:xr,tex:{x:v.paddedRect.x+1+ss,y:v.paddedRect.y+1+_s,w:Li.stretch+Li.fixed-ss,h:Vi.stretch+Vi.fixed-_s},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:es,pixelOffsetBR:ir,minFontScaleX:ci/E/V,minFontScaleY:Ti/E/q,isSDF:o}};if(d&&(v.stretchX||v.stretchY)){const _i=QB(se,Ze,be),Si=QB(he,xt,De);for(let Li=0;Li<_i.length-1;Li++){const Vi=_i[Li],Zi=_i[Li+1];for(let yi=0;yi{if(k)g(k);else if(V){const q={},se=function(he){return new Fa(he).readFields(E1,{})}(V);for(const he of se.glyphs)q[he.id]=he;g(null,{glyphs:q,ascender:se.ascender,descender:se.descender})}})},$f.TinySDF=class{constructor({fontSize:s=24,buffer:n=3,radius:o=8,cutoff:d=.25,fontFamily:g="sans-serif",fontWeight:v="normal",fontStyle:E="normal"}={}){this.buffer=n,this.cutoff=d,this.radius=o;const L=this.size=s+4*n,k=this._createCanvas(L),V=this.ctx=k.getContext("2d",{willReadFrequently:!0});V.font=`${E} ${v} ${s}px ${g}`,V.textBaseline="alphabetic",V.textAlign="left",V.fillStyle="black",this.gridOuter=new Float64Array(L*L),this.gridInner=new Float64Array(L*L),this.f=new Float64Array(L),this.z=new Float64Array(L+1),this.v=new Uint16Array(L)}_createCanvas(s){const n=document.createElement("canvas");return n.width=n.height=s,n}draw(s){const{width:n,actualBoundingBoxAscent:o,actualBoundingBoxDescent:d,actualBoundingBoxLeft:g,actualBoundingBoxRight:v}=this.ctx.measureText(s),E=Math.ceil(o),L=Math.min(this.size-this.buffer,Math.ceil(v-g)),k=Math.min(this.size-this.buffer,E+Math.ceil(d)),V=L+2*this.buffer,q=k+2*this.buffer,se=Math.max(V*q,0),he=new Uint8ClampedArray(se),_e={data:he,width:V,height:q,glyphWidth:L,glyphHeight:k,glyphTop:E,glyphLeft:0,glyphAdvance:n};if(L===0||k===0)return _e;const{ctx:be,buffer:De,gridInner:Ze,gridOuter:xt}=this;be.clearRect(De,De,L,k),be.fillText(s,De,De+E);const Dt=be.getImageData(De,De,L,k);xt.fill(kg,0,se),Ze.fill(0,0,se);for(let _t=0;_t0?ci*ci:0,Ze[Ut]=ci<0?ci*ci:0}}kB(xt,0,0,V,q,V,this.f,this.v,this.z),kB(Ze,De,De,L,k,V,this.f,this.v,this.z);for(let _t=0;_t0)for(let d=(this.length>>1)-1;d>=0;d--)this._down(d)}push(n){this.data.push(n),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const n=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),n}peek(){return this.data[0]}_up(n){const{data:o,compare:d}=this,g=o[n];for(;n>0;){const v=n-1>>1,E=o[v];if(d(g,E)>=0)break;o[n]=E,n=v}o[n]=g}_down(n){const{data:o,compare:d}=this,g=this.length>>1,v=o[n];for(;n=0)break;o[n]=L,n=E}o[n]=v}}function JF(s,n){return sn?1:0}function e3(s,n=1,o=!1){let d=1/0,g=1/0,v=-1/0,E=-1/0;const L=s[0];for(let _e=0;_ev)&&(v=be.x),(!_e||be.y>E)&&(E=be.y)}const k=Math.min(v-d,E-g);let V=k/2;const q=new YF([],t3);if(k===0)return new me(d,g);for(let _e=d;_ese.d||!se.d)&&(se=_e,o&&console.log("found best %d after %d probes",Math.round(1e4*_e.d)/1e4,he)),_e.max-se.d<=n||(V=_e.h/2,q.push(new Zf(_e.p.x-V,_e.p.y-V,V,s)),q.push(new Zf(_e.p.x+V,_e.p.y-V,V,s)),q.push(new Zf(_e.p.x-V,_e.p.y+V,V,s)),q.push(new Zf(_e.p.x+V,_e.p.y+V,V,s)),he+=4)}return o&&(console.log(`num probes: ${he}`),console.log(`best distance: ${se.d}`)),se.p}function t3(s,n){return n.max-s.max}function Zf(s,n,o,d){this.p=new me(s,n),this.h=o,this.d=function(g,v){let E=!1,L=1/0;for(let k=0;kg.y!=be.y>g.y&&g.x<(be.x-_e.x)*(g.y-_e.y)/(be.y-_e.y)+_e.x&&(E=!E),L=Math.min(L,mg(g,_e,be))}}return(E?1:-1)*Math.sqrt(L)}(this.p,d),this.max=this.d+this.h*Math.SQRT2}const M1=Number.POSITIVE_INFINITY,i3=Math.sqrt(2);function VB(s,[n,o]){let d=0,g=0;if(o===M1){n<0&&(n=0);const v=n/i3;switch(s){case"top-right":case"top-left":g=v-7;break;case"bottom-right":case"bottom-left":g=7-v;break;case"bottom":g=7-n;break;case"top":g=n-7}switch(s){case"top-right":case"bottom-right":d=-v;break;case"top-left":case"bottom-left":d=v;break;case"left":d=n;break;case"right":d=-n}}else{switch(n=Math.abs(n),o=Math.abs(o),s){case"top-right":case"top-left":case"top":g=o-7;break;case"bottom-right":case"bottom-left":case"bottom":g=7-o}switch(s){case"top-right":case"bottom-right":case"right":d=-n;break;case"top-left":case"bottom-left":case"left":d=n}}return[d,g]}function n3(s,n,o,d,g,v,E,L,k,V){s.createArrays(),s.tilePixelRatio=Zn/(512*s.overscaling),s.compareText={},s.iconsNeedLinear=!1;const q=s.layers[0].layout,se=s.layers[0]._unevaluatedLayout._values,he={};if(s.textSizeData.kind==="composite"){const{minZoom:De,maxZoom:Ze}=s.textSizeData;he.compositeTextSizes=[se["text-size"].possiblyEvaluate(new qt(De),L),se["text-size"].possiblyEvaluate(new qt(Ze),L)]}if(s.iconSizeData.kind==="composite"){const{minZoom:De,maxZoom:Ze}=s.iconSizeData;he.compositeIconSizes=[se["icon-size"].possiblyEvaluate(new qt(De),L),se["icon-size"].possiblyEvaluate(new qt(Ze),L)]}he.layoutTextSize=se["text-size"].possiblyEvaluate(new qt(k+1),L),he.layoutIconSize=se["icon-size"].possiblyEvaluate(new qt(k+1),L),he.textMaxSize=se["text-size"].possiblyEvaluate(new qt(18),L);const _e=q.get("text-rotation-alignment")==="map"&&q.get("symbol-placement")!=="point",be=q.get("text-size");for(const De of s.features){const Ze=q.get("text-font").evaluate(De,{},L).join(","),xt=be.evaluate(De,{},L),Dt=he.layoutTextSize.evaluate(De,{},L),_t=(he.layoutIconSize.evaluate(De,{},L),{horizontal:{},vertical:void 0}),Tt=De.text;let kt,Ut=[0,0];if(Tt){const Ti=Tt.toString(),Ki=q.get("text-letter-spacing").evaluate(De,{},L)*Jr,_i=q.get("text-line-height").evaluate(De,{},L)*Jr,Si=W(Ti)?Ki:0,Li=q.get("text-anchor").evaluate(De,{},L),Vi=q.get("text-variable-anchor");if(!Vi){const dn=q.get("text-radial-offset").evaluate(De,{},L);Ut=dn?VB(Li,[dn*Jr,M1]):q.get("text-offset").evaluate(De,{},L).map(Ln=>Ln*Jr)}let Zi=_e?"center":q.get("text-justify").evaluate(De,{},L);const yi=q.get("symbol-placement")==="point",sn=yi?q.get("text-max-width").evaluate(De,{},L)*Jr:1/0,Kn=dn=>{s.allowVerticalPlacement&&H(Ti)&&(_t.vertical=nu(Tt,n,o,g,Ze,sn,_i,Li,dn,Si,Ut,qo.vertical,!0,Dt,xt))};if(!_e&&Vi){const dn=Zi==="auto"?Vi.map(ln=>I1(ln)):[Zi];let Ln=!1;for(let ln=0;ln=0||!H(Ti)){const dn=nu(Tt,n,o,g,Ze,sn,_i,Li,Zi,Si,Ut,qo.horizontal,!1,Dt,xt);dn&&(_t.horizontal[Zi]=dn)}Kn(yi?"left":Zi)}}let ci=!1;if(De.icon&&De.icon.name){const Ti=d[De.icon.name];Ti&&(kt=$F(g[De.icon.name],q.get("icon-offset").evaluate(De,{},L),q.get("icon-anchor").evaluate(De,{},L)),ci=Ti.sdf,s.sdfIcons===void 0?s.sdfIcons=Ti.sdf:s.sdfIcons!==Ti.sdf&&Ct("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Ti.pixelRatio!==s.pixelRatio||q.get("icon-rotate").constantOr(1)!==0)&&(s.iconsNeedLinear=!0))}const ai=GB(_t.horizontal)||_t.vertical;s.iconsInText||(s.iconsInText=!!ai&&ai.iconsInText),(ai||kt)&&r3(s,De,_t,kt,d,he,Dt,0,Ut,ci,E,L,V)}v&&s.generateCollisionDebugBuffers(k,s.collisionBoxArray)}function I1(s){switch(s){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function r3(s,n,o,d,g,v,E,L,k,V,q,se,he){let _e=v.textMaxSize.evaluate(n,{},se);_e===void 0&&(_e=E);const be=s.layers[0].layout,De=be.get("icon-offset").evaluate(n,{},se),Ze=GB(o.horizontal)||o.vertical,xt=he.name==="globe",Dt=E/24,_t=s.tilePixelRatio*_e/24,Tt=(Si=s.overscaling,s.zoom>18&&Si>2&&(Si>>=1),Math.max(Zn/(512*Si),1)*be.get("symbol-spacing")),kt=be.get("text-padding")*s.tilePixelRatio,Ut=be.get("icon-padding")*s.tilePixelRatio,ci=Ke(be.get("text-max-angle")),ai=be.get("text-rotation-alignment")==="map"&&be.get("symbol-placement")!=="point",Ti=be.get("icon-rotation-alignment")==="map"&&be.get("symbol-placement")!=="point",Ki=be.get("symbol-placement"),_i=Tt/2;var Si;const Li=be.get("icon-text-fit");let Vi;d&&Li!=="none"&&(s.allowVerticalPlacement&&o.vertical&&(Vi=FB(d,o.vertical,Li,be.get("icon-text-fit-padding"),De,Dt)),Ze&&(d=FB(d,Ze,Li,be.get("icon-text-fit-padding"),De,Dt)));const Zi=(yi,sn,Kn)=>{if(sn.x<0||sn.x>=Zn||sn.y<0||sn.y>=Zn)return;let dn=null;if(xt){const{x:Ln,y:ln,z:Xn}=he.projectTilePoint(sn.x,sn.y,Kn);dn={anchor:new FA(Ln,ln,Xn,0,void 0),up:he.upVector(Kn,sn.x,sn.y)}}(function(Ln,ln,Xn,Tr,wr,xr,Jn,es,ir,Sr,ss,_s,ps,ys,Bs,Zs,Yo,ts,Ao,lo,Vr,Us,vo,os,no){const La=Ln.addToLineVertexArray(ln,Tr);let Jo,ea,Ja,ta,DA,im,Zg,Xg=0,SC=0,MC=0,IC=0,K1=-1,$1=-1;const Uu={};let FC=ld.exports("");const zp=Xn?Xn.anchor:ln;let Z1=0,X1=0;if(ir._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Z1,X1]=ir.layout.get("text-offset").evaluate(Vr,{},no).map(ec=>ec*Jr):(Z1=ir.layout.get("text-radial-offset").evaluate(Vr,{},no)*Jr,X1=M1),Ln.allowVerticalPlacement&&wr.vertical){const ec=wr.vertical;if(Bs)im=F1(ec),es&&(Zg=F1(es));else{const tc=ir.layout.get("text-rotate").evaluate(Vr,{},no)+90;Ja=g0(Sr,zp,ln,ss,_s,ps,ec,ys,tc,Zs),es&&(ta=g0(Sr,zp,ln,ss,_s,ps,es,ts,tc))}}if(xr){const ec=ir.layout.get("icon-rotate").evaluate(Vr,{},no),tc=ir.layout.get("icon-text-fit")!=="none",qg=NB(xr,ec,vo,tc),Y1=es?NB(es,ec,vo,tc):void 0;ea=g0(Sr,zp,ln,ss,_s,ps,xr,ts,ec),Xg=4*qg.length;const LC=Ln.iconSizeData;let kp=null;LC.kind==="source"?(kp=[Hs*ir.layout.get("icon-size").evaluate(Vr,{},no)],kp[0]>Id&&Ct(`${Ln.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):LC.kind==="composite"&&(kp=[Hs*Us.compositeIconSizes[0].evaluate(Vr,{},no),Hs*Us.compositeIconSizes[1].evaluate(Vr,{},no)],(kp[0]>Id||kp[1]>Id)&&Ct(`${Ln.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Ln.addSymbols(Ln.icon,qg,kp,lo,Ao,Vr,!1,Xn,ln,La.lineStartIndex,La.lineLength,-1,os,no),K1=Ln.icon.placedSymbolArray.length-1,Y1&&(SC=4*Y1.length,Ln.addSymbols(Ln.icon,Y1,kp,lo,Ao,Vr,qo.vertical,Xn,ln,La.lineStartIndex,La.lineLength,-1,os,no),$1=Ln.icon.placedSymbolArray.length-1)}for(const ec in wr.horizontal){const tc=wr.horizontal[ec];Jo||(FC=ld.exports(tc.text),Bs?DA=F1(tc):Jo=g0(Sr,zp,ln,ss,_s,ps,tc,ys,ir.layout.get("text-rotate").evaluate(Vr,{},no),Zs));const qg=tc.positionedLines.length===1;if(MC+=HB(Ln,Xn,ln,tc,Jn,ir,Bs,Vr,Zs,La,wr.vertical?qo.horizontal:qo.horizontalOnly,qg?Object.keys(wr.horizontal):[ec],Uu,K1,Us,os,no),qg)break}wr.vertical&&(IC+=HB(Ln,Xn,ln,wr.vertical,Jn,ir,Bs,Vr,Zs,La,qo.vertical,["vertical"],Uu,$1,Us,os,no));let Rd=-1;const q1=(ec,tc)=>ec?Math.max(ec,tc):tc;Rd=q1(DA,Rd),Rd=q1(im,Rd),Rd=q1(Zg,Rd);const R3=Rd>-1?1:0;Ln.glyphOffsetArray.length>=Ld.MAX_GLYPHS&&Ct("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Vr.sortKey!==void 0&&Ln.addToSortKeyRanges(Ln.symbolInstances.length,Vr.sortKey),Ln.symbolInstances.emplaceBack(zp.x,zp.y,zp.z,ln.x,ln.y,Uu.right>=0?Uu.right:-1,Uu.center>=0?Uu.center:-1,Uu.left>=0?Uu.left:-1,Uu.vertical>=0?Uu.vertical:-1,K1,$1,FC,Jo!==void 0?Jo:Ln.collisionBoxArray.length,Jo!==void 0?Jo+1:Ln.collisionBoxArray.length,Ja!==void 0?Ja:Ln.collisionBoxArray.length,Ja!==void 0?Ja+1:Ln.collisionBoxArray.length,ea!==void 0?ea:Ln.collisionBoxArray.length,ea!==void 0?ea+1:Ln.collisionBoxArray.length,ta||Ln.collisionBoxArray.length,ta?ta+1:Ln.collisionBoxArray.length,ss,MC,IC,Xg,SC,R3,0,Z1,X1,Rd)})(s,sn,dn,yi,o,d,g,Vi,s.layers[0],s.collisionBoxArray,n.index,n.sourceLayerIndex,s.index,kt,ai,k,0,Ut,Ti,De,n,v,V,q,se)};if(Ki==="line")for(const yi of zB(n.geometry,0,0,Zn,Zn)){const sn=XF(yi,Tt,ci,o.vertical||Ze,d,24,_t,s.overscaling,Zn);for(const Kn of sn){const dn=Ze;dn&&s3(s,dn.text,_i,Kn)||Zi(yi,Kn,se)}}else if(Ki==="line-center"){for(const yi of n.geometry)if(yi.length>1){const sn=ZF(yi,ci,o.vertical||Ze,d,24,_t);sn&&Zi(yi,sn,se)}}else if(n.type==="Polygon")for(const yi of Qf(n.geometry,0)){const sn=e3(yi,16);Zi(yi[0],new FA(sn.x,sn.y,0,0,void 0),se)}else if(n.type==="LineString")for(const yi of n.geometry)Zi(yi,new FA(yi[0].x,yi[0].y,0,0,void 0),se);else if(n.type==="Point")for(const yi of n.geometry)for(const sn of yi)Zi([sn],new FA(sn.x,sn.y,0,0,void 0),se)}const Id=32640;function HB(s,n,o,d,g,v,E,L,k,V,q,se,he,_e,be,De,Ze){const xt=function(Tt,kt,Ut,ci,ai,Ti,Ki,_i){const Si=[];if(kt.positionedLines.length===0)return Si;const Li=ci.layout.get("text-rotate").evaluate(Ti,{})*Math.PI/180,Vi=function(dn){const Ln=dn[0],ln=dn[1],Xn=Ln*ln;return Xn>0?[Ln,-ln]:Xn<0?[-Ln,ln]:Ln===0?[ln,Ln]:[ln,-Ln]}(Ut);let Zi=Math.abs(kt.top-kt.bottom);for(const dn of kt.positionedLines)Zi-=dn.lineOffset;const yi=kt.positionedLines.length,sn=Zi/yi;let Kn=kt.top-Ut[1];for(let dn=0;dnId&&Ct(`${s.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):Dt.kind==="composite"&&(_t=[Hs*be.compositeTextSizes[0].evaluate(L,{},Ze),Hs*be.compositeTextSizes[1].evaluate(L,{},Ze)],(_t[0]>Id||_t[1]>Id)&&Ct(`${s.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),s.addSymbols(s.text,xt,_t,k,E,L,q,n,o,V.lineStartIndex,V.lineLength,_e,De,Ze);for(const Tt of se)he[Tt]=s.text.placedSymbolArray.length-1;return 4*xt.length}function GB(s){for(const n in s)return s[n];return null}function g0(s,n,o,d,g,v,E,L,k,V){let q=E.top,se=E.bottom,he=E.left,_e=E.right;const be=E.collisionPadding;if(be&&(he-=be[0],q-=be[1],_e+=be[2],se+=be[3]),k){const De=new me(he,q),Ze=new me(_e,q),xt=new me(he,se),Dt=new me(_e,se),_t=Ke(k);let Tt=new me(0,0);V&&(Tt=new me(V[0],V[1])),De._rotateAround(_t,Tt),Ze._rotateAround(_t,Tt),xt._rotateAround(_t,Tt),Dt._rotateAround(_t,Tt),he=Math.min(De.x,Ze.x,xt.x,Dt.x),_e=Math.max(De.x,Ze.x,xt.x,Dt.x),q=Math.min(De.y,Ze.y,xt.y,Dt.y),se=Math.max(De.y,Ze.y,xt.y,Dt.y)}return s.emplaceBack(n.x,n.y,n.z,o.x,o.y,he,q,_e,se,L,d,g,v),s.length-1}function F1(s){s.collisionPadding&&(s.top-=s.collisionPadding[1],s.bottom+=s.collisionPadding[3]);const n=s.bottom-s.top;return n>0?Math.max(10,n):null}function s3(s,n,o,d){const g=s.compareText;if(n in g){const v=g[n];for(let E=v.length-1;E>=0;E--)if(d.dist(v[E])1?null:function(d,g,v,E){const L=Math.sin(v);return d*(Math.sin((1-E)*v)/L)+g*(Math.sin(E*v)/L)}(s.a[n],s.b[n],s.angle,ye(o,0,1))+s.center[n]}function Fu(s){if(s.z<=1)return a3[s.z+2*s.y+s.x];const n=P1(_0(s));return Ko.fromPoints(n)}function Pp(s,n,o){return pa(s,s,1-o),eu(s,s,n,o)}function $B(s,n){const o=Jf(n.zoom);if(o===0)return Fu(s);const d=_0(s),g=P1(d),v=vc(d.getWest())*n.worldSize,E=vc(d.getEast())*n.worldSize,L=ch(d.getNorth())*n.worldSize,k=ch(d.getSouth())*n.worldSize,V=[v,L,0],q=[E,L,0],se=[v,k,0],he=[E,k,0],_e=yg([],n.globeMatrix);return Qs(V,V,_e),Qs(q,q,_e),Qs(se,se,_e),Qs(he,he,_e),g[0]=Pp(g[0],se,o),g[1]=Pp(g[1],he,o),g[2]=Pp(g[2],q,o),g[3]=Pp(g[3],V,o),Ko.fromPoints(g)}function ZB(s,n,o){for(const d of s)Qs(d,d,n),pa(d,d,o)}function c3(s,n,o){const d=n/s.worldSize,g=s.globeMatrix;if(o.z<=1){const ai=Fu(o).getCorners();return ZB(ai,g,d),Ko.fromPoints(ai)}const v=_0(o),E=P1(v);ZB(E,g,d);const L=Number.MAX_VALUE,k=[-L,-L,-L],V=[L,L,L];if(v.contains(s.center)){for(const Ki of E)EA(V,V,Ki),md(k,k,Ki);k[2]=0;const ai=s.point,Ti=[ai.x*d,ai.y*d,0];return EA(V,V,Ti),md(k,k,Ti),new Ko(V,k)}const q=[g[12]*d,g[13]*d,g[14]*d],se=v.getCenter(),he=ye(s.center.lat,-85.051129,Za),_e=ye(se.lat,-85.051129,Za),be=vc(s.center.lng),De=ch(he);let Ze=be-vc(se.lng);const xt=De-ch(_e);Ze>.5?Ze-=1:Ze<-.5&&(Ze+=1);let Dt=0;Math.abs(Ze)>Math.abs(xt)?Dt=Ze>=0?1:3:(Dt=xt>=0?0:2,eu(q,q,[g[4]*d,g[5]*d,g[6]*d],-Math.sin(Ke(xt>=0?v.getSouth():v.getNorth()))*LA));const _t=E[Dt],Tt=E[(Dt+1)%4],kt=new l3(_t,Tt,q),Ut=[D1(kt,0)||_t[0],D1(kt,1)||_t[1],D1(kt,2)||_t[2]],ci=Jf(s.zoom);if(ci>0){const ai=function({x:Ki,y:_i,z:Si},Li,Vi,Zi,yi){const sn=1/(1<.5?Xn=-1:Tr<-.5&&(Xn=1),Kn=((Kn+Xn)*Li-(Zi*=Li))*Vi+Zi,dn=((dn+Xn)*Li-Zi)*Vi+Zi,Ln=(Ln*Li-(yi*=Li))*Vi+yi,ln=(ln*Li-yi)*Vi+yi,[[Kn,ln,0],[dn,ln,0],[dn,Ln,0],[Kn,Ln,0]]}(o,n,s._pixelsPerMercatorPixel,be,De);for(let Ki=0;KiMath.PI/2*1.01}const JB=Ke(85),h3=Math.cos(JB),u3=Math.sin(JB);function eC(s,n){const o=s.fovAboveCenter,d=s.elevation?s.elevation.getMinElevationBelowMSL()*n:0,g=(s._camera.position[2]*s.worldSize-d)/Math.cos(s._pitch),v=Math.sin(o)*g/Math.sin(Math.max(Math.PI/2-s._pitch-o,.01)),E=Math.sin(s._pitch)*v+g;return Math.min(1.01*E,g*(1/s._horizonShift))}function Up(s,n){if(!n.isReprojectedInTileSpace)return{scale:1<_t&&(Tt(Ut,Vi,ai,Ti,Si,Li),Tt(Vi,ci,Si,Li,Ki,_i))}Tt(se,he,d,v,g,v),Tt(he,_e,g,v,g,E),Tt(_e,be,g,E,d,E),Tt(be,se,d,E,d,v),De-=_t,Ze-=_t,xt+=_t,Dt+=_t;const kt=1/Math.max(xt-De,Dt-Ze);return{scale:kt,x:De*kt,y:Ze*kt,x2:xt*kt,y2:Dt*kt,projection:n}}const A3=ql(new Float32Array(16));class Fd{constructor(n){this.spec=n,this.name=n.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(n,o){return{x:0,y:0,z:0}}unproject(n,o){return new Pr(0,0)}projectTilePoint(n,o,d){return{x:n,y:o,z:0}}locationPoint(n,o,d=!0){return n._coordinatePoint(n.locationCoordinate(o),d)}pixelsPerMeter(n,o){return Xl(1,n)*o}pixelSpaceConversion(n,o,d){return 1}farthestPixelDistance(n){return eC(n,n.pixelsPerMeter)}pointCoordinate(n,o,d,g){const v=n.horizonLineFromTop(!1),E=new me(o,Math.max(v,d));return n.rayIntersectionCoordinate(n.pointRayIntersection(E,g))}pointCoordinate3D(n,o,d){const g=new me(o,d);if(n.elevation)return n.elevation.pointCoordinate(g);{const v=this.pointCoordinate(n,g.x,g.y,0);return[v.x,v.y,v.z]}}isPointAboveHorizon(n,o){if(n.elevation)return!this.pointCoordinate3D(n,o.x,o.y);const d=n.horizonLineFromTop();return o.y0?o<-em+d&&(o=-em+d):o>em-d&&(o=em-d);const E=v/Math.pow(v0(o),g);let L=E*Math.sin(g*n),k=v-E*Math.cos(g*n);return L=.5*(L/Math.PI+.5),k=.5*(k/Math.PI+.5),{x:L,y:this.southernCenter?k:1-k,z:0}}unproject(n,o){n=(2*n-.5)*Math.PI,this.southernCenter&&(o=1-o),o=(2*(1-o)-.5)*Math.PI;const{n:d,f:g}=this,v=g-o,E=Math.sign(v),L=Math.sign(d)*Math.sqrt(n*n+v*v);let k=Math.atan2(n,Math.abs(v))*E;v*d<0&&(k-=Math.PI*Math.sign(n)*E);const V=ye(Et(k/d)+this.center[0],-180,180),q=ye(Et(2*Math.atan(Math.pow(g/L,1/d))-em),-85.051129,Za);return new Pr(V,this.southernCenter?-q:q)}}class tC extends Fd{constructor(n){super(n),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(n,o){return{x:vc(n),y:ch(o),z:0}}unproject(n,o){const d=bl(n),g=Fo(o);return new Pr(d,g)}}const iC=Ke(Za);class g3 extends Fd{project(n,o){const d=(o=Ke(o))*o,g=d*d;return{x:.5*((n=Ke(n))*(.8707-.131979*d+g*(g*(.003971*d-.001529*g)-.013791))/Math.PI+.5),y:1-.5*(o*(1.007226+d*(.015085+g*(.028874*d-.044475-.005916*g)))/Math.PI+1),z:0}}unproject(n,o){n=(2*n-.5)*Math.PI;let d=o=(2*(1-o)-1)*Math.PI,g=25,v=0,E=d*d;do{E=d*d;const V=E*E;v=(d*(1.007226+E*(.015085+V*(.028874*E-.044475-.005916*V)))-o)/(1.007226+E*(.045255+V*(.259866*E-.311325-.005916*11*V))),d=ye(d-v,-iC,iC)}while(Math.abs(v)>1e-6&&--g>0);E=d*d;const L=ye(Et(n/(.8707+E*(E*(E*E*E*(.003971-.001529*E)-.013791)-.131979))),-180,180),k=Et(d);return new Pr(L,k)}}const nC=Ke(Za);class _3 extends Fd{project(n,o){o=Ke(o),n=Ke(n);const d=Math.cos(o),g=2/Math.PI,v=Math.acos(d*Math.cos(n/2)),E=Math.sin(v)/v,L=.5*(n*g+2*d*Math.sin(n/2)/E)||0,k=.5*(o+Math.sin(o)/E)||0;return{x:.5*(L/Math.PI+.5),y:1-.5*(k/Math.PI+1),z:0}}unproject(n,o){let d=n=(2*n-.5)*Math.PI,g=o=(2*(1-o)-1)*Math.PI,v=25;const E=1e-6;let L=0,k=0;do{const V=Math.cos(g),q=Math.sin(g),se=2*q*V,he=q*q,_e=V*V,be=Math.cos(d/2),De=Math.sin(d/2),Ze=2*be*De,xt=De*De,Dt=1-_e*be*be,_t=Dt?1/Dt:0,Tt=Dt?Math.acos(V*be)*Math.sqrt(1/Dt):0,kt=.5*(2*Tt*V*De+2*d/Math.PI)-n,Ut=.5*(Tt*q+g)-o,ci=.5*_t*(_e*xt+Tt*V*be*he)+1/Math.PI,ai=_t*(Ze*se/4-Tt*q*De),Ti=.125*_t*(se*De-Tt*q*_e*Ze),Ki=.5*_t*(he*be+Tt*xt*V)+.5,_i=ai*Ti-Ki*ci;L=(Ut*ai-kt*Ki)/_i,k=(kt*Ti-Ut*ci)/_i,d=ye(d-L,-Math.PI,Math.PI),g=ye(g-k,-nC,nC)}while((Math.abs(L)>E||Math.abs(k)>E)&&--v>0);return new Pr(Et(d),Et(g))}}class rC extends Fd{constructor(n){super(n),this.center=n.center||[0,0],this.parallels=n.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ke(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(n,o){const{scale:d,cosPhi:g}=this;return{x:Ke(n)*g*d+.5,y:-Math.sin(Ke(o))/g*d+.5,z:0}}unproject(n,o){const{scale:d,cosPhi:g}=this,v=-(o-.5)/d,E=ye(Et((n-.5)/d)/g,-180,180),L=Math.asin(ye(v*g,-1,1)),k=ye(Et(L),-85.051129,Za);return new Pr(E,k)}}class y3 extends tC{constructor(n){super(n),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(n,o,d){const g=Qg(n,o,d);return Qs(g,g,Vg(Fu(d))),{x:g[0],y:g[1],z:g[2]}}locationPoint(n,o){const d=Ng(o.lat,o.lng),g=so([],d),v=n.elevation?n.elevation.getAtPointOrZero(n.locationCoordinate(o),n._centerAltitude):n._centerAltitude;eu(d,d,g,Xl(1,0)*Zn*v);const E=ql(new Float64Array(16));return bA(E,n.pixelMatrix,n.globeMatrix),Qs(d,d,E),new me(d[0],d[1])}pixelsPerMeter(n,o){return Xl(1,0)*o}pixelSpaceConversion(n,o,d){const g=Xl(1,n)*o,v=gr(Xl(1,45)*o,g,d);return this.pixelsPerMeter(n,o)/v}createTileMatrix(n,o,d){const g=U1(Fu(d.canonical));return bA(new Float64Array(16),n.globeMatrix,g)}createInversionMatrix(n,o){const{center:d}=n,g=Vg(Fu(o));return Lf(g,g,Ke(d.lng)),xg(g,g,Ke(d.lat)),BA(g,g,[n._pixelsPerMercatorPixel,n._pixelsPerMercatorPixel,1]),Float32Array.from(g)}pointCoordinate(n,o,d,g){return KB(n,o,d,!0)||new ud(0,0)}pointCoordinate3D(n,o,d){const g=this.pointCoordinate(n,o,d,0);return[g.x,g.y,g.z]}isPointAboveHorizon(n,o){return!KB(n,o.x,o.y,!1)}farthestPixelDistance(n){const o=function(g,v){const E=g.cameraToCenterDistance,L=g._centerAltitude*v,k=g._camera,V=g._camera.forward(),q=Jh([],pa([],V,-E),[0,0,L]),se=g.worldSize/(2*Math.PI),he=[0,0,-se],_e=g.width/g.height,be=Math.tan(g.fovAboveCenter),De=pa([],k.up(),be),Ze=pa([],k.right(),be*_e),xt=so([],Jh([],Jh([],V,De),Ze)),Dt=[];let _t;if(new Uf(q,xt).closestPointOnSphere(he,se,Dt)){const Tt=Jh([],Dt,he),kt=wc([],Tt,q);_t=Math.cos(g.fovAboveCenter)*pd(kt)}else{const Tt=wc([],q,he),kt=wc([],he,q);so(kt,kt);const Ut=pd(Tt)-se;_t=Math.sqrt(Ut*(Ut+2*se));const ci=Math.acos(_t/(se+Ut))-Math.acos(Ma(V,kt));_t*=Math.cos(ci)}return 1.01*_t}(n,this.pixelsPerMeter(n.center.lat,n.worldSize)),d=Jf(n.zoom);if(d>0){const g=eC(n,Xl(1,n.center.lat)*n.worldSize),v=n.worldSize/(2*Math.PI),E=Math.max(n.width,n.height)/n.worldSize*Math.PI;return gr(o,g+v*(1-Math.cos(E)),Math.pow(d,10))}return o}upVector(n,o,d){return Qg(o,d,n,1)}upVectorScale(n){return{metersToTile:L1*y0(Fu(n))}}}function sC(s){const n=s.parallels,o=!!n&&Math.abs(n[0]+n[1])<.01;switch(s.name){case"mercator":return new tC(s);case"equirectangular":return new f3(s);case"naturalEarth":return new g3(s);case"equalEarth":return new p3(s);case"winkelTripel":return new _3(s);case"albers":return o?new rC(s):new d3(s);case"lambertConformalConic":return o?new rC(s):new m3(s);case"globe":return new y3(s)}throw new Error(`Invalid projection name: ${s.name}`)}const x3=w.types,v3=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function w0(s,n,o,d,g,v,E,L,k,V,q,se,he){const _e=L?Math.min(Id,Math.round(L[0])):0,be=L?Math.min(Id,Math.round(L[1])):0;s.emplaceBack(n,o,Math.round(32*d),Math.round(32*g),v,E,(_e<<1)+(k?1:0),be,16*V,16*q,256*se,256*he)}function b0(s,n,o,d,g,v,E){s.emplaceBack(n,o,d,g,v,E)}function B0(s,n,o,d,g){s.emplaceBack(n,o,d,g),s.emplaceBack(n,o,d,g),s.emplaceBack(n,o,d,g),s.emplaceBack(n,o,d,g)}function w3(s){for(const n of s.sections)if(rt(n.text))return!0;return!1}class z1{constructor(n){this.layoutVertexArray=new Xr,this.indexArray=new _o,this.programConfigurations=n,this.segments=new to,this.dynamicLayoutVertexArray=new Ca,this.opacityVertexArray=new Ls,this.placedSymbolArray=new My,this.globeExtVertexArray=new Fr}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(n,o,d,g){this.isEmpty()||(d&&(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Lo.members),this.indexBuffer=n.createIndexBuffer(this.indexArray,o),this.dynamicLayoutVertexBuffer=n.createVertexBuffer(this.dynamicLayoutVertexArray,Ia.members,!0),this.opacityVertexBuffer=n.createVertexBuffer(this.opacityVertexArray,v3,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=n.createVertexBuffer(this.globeExtVertexArray,$o.members,!0)),this.opacityVertexBuffer.itemSize=1),(d||g)&&this.programConfigurations.upload(n))}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())}}zt(z1,"SymbolBuffers");class k1{constructor(n,o,d){this.layoutVertexArray=new n,this.layoutAttributes=o,this.indexArray=new d,this.segments=new to,this.collisionVertexArray=new bu,this.collisionVertexArrayExt=new Ka}upload(n){this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=n.createVertexBuffer(this.collisionVertexArray,io.members,!0),this.collisionVertexBufferExt=n.createVertexBuffer(this.collisionVertexArrayExt,Do.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}zt(k1,"CollisionBuffers");class Ld{constructor(n){this.collisionBoxArray=n.collisionBoxArray,this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(E=>E.id),this.index=n.index,this.pixelRatio=n.pixelRatio,this.sourceLayerIndex=n.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ql([]),this.placementViewportMatrix=ql([]);const o=this.layers[0]._unevaluatedLayout._values;this.textSizeData=gs(this.zoom,o["text-size"]),this.iconSizeData=gs(this.zoom,o["icon-size"]);const d=this.layers[0].layout,g=d.get("symbol-sort-key"),v=d.get("symbol-z-order");this.canOverlap=d.get("text-allow-overlap")||d.get("icon-allow-overlap")||d.get("text-ignore-placement")||d.get("icon-ignore-placement"),this.sortFeaturesByKey=v!=="viewport-y"&&g.constantOr(1)!==void 0,this.sortFeaturesByY=(v==="viewport-y"||v==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=d.get("text-writing-mode").map(E=>qo[E]),this.stateDependentLayerIds=this.layers.filter(E=>E.isStateDependent()).map(E=>E.id),this.sourceID=n.sourceID,this.projection=n.projection}createArrays(){this.text=new z1(new _A(this.layers,this.zoom,n=>/^text/.test(n))),this.icon=new z1(new _A(this.layers,this.zoom,n=>/^icon/.test(n))),this.glyphOffsetArray=new ag,this.lineVertexArray=new Bu,this.symbolInstances=new pp}calculateGlyphDependencies(n,o,d,g,v){for(let E=0;E0)&&(k.value.kind!=="constant"||k.value.value.length>0),he=q.value.kind!=="constant"||!!q.value.value||Object.keys(q.parameters).length>0,_e=E.get("symbol-sort-key");if(this.features=[],!se&&!he)return;const be=o.iconDependencies,De=o.glyphDependencies,Ze=o.availableImages,xt=new qt(this.zoom);for(const{feature:Dt,id:_t,index:Tt,sourceLayerIndex:kt}of n){const Ut=v._featureFilter.needGeometry,ci=xA(Dt,Ut);if(!v._featureFilter.filter(xt,ci,d))continue;if(Ut||(ci.geometry=Yh(Dt,d,g)),L&&Dt.type!==1&&d.z<=5){const _i=ci.geometry,Si=.98078528056,Li=(Vi,Zi)=>Ma(Qg(Vi.x,Vi.y,d,1),Qg(Zi.x,Zi.y,d,1))=0;for(const Li of ai.sections)if(Li.image)be[Li.image.name]=!0;else{const Vi=H(ai.toString()),Zi=Li.fontStack||_i,yi=De[Zi]=De[Zi]||{};this.calculateGlyphDependencies(Li.text,yi,Si,this.allowVerticalPlacement,Vi)}}}E.get("symbol-placement")==="line"&&(this.features=function(Dt){const _t={},Tt={},kt=[];let Ut=0;function ci(_i){kt.push(Dt[_i]),Ut++}function ai(_i,Si,Li){const Vi=Tt[_i];return delete Tt[_i],Tt[Si]=Vi,kt[Vi].geometry[0].pop(),kt[Vi].geometry[0]=kt[Vi].geometry[0].concat(Li[0]),Vi}function Ti(_i,Si,Li){const Vi=_t[Si];return delete _t[Si],_t[_i]=Vi,kt[Vi].geometry[0].shift(),kt[Vi].geometry[0]=Li[0].concat(kt[Vi].geometry[0]),Vi}function Ki(_i,Si,Li){const Vi=Li?Si[0][Si[0].length-1]:Si[0][0];return`${_i}:${Vi.x}:${Vi.y}`}for(let _i=0;_i_i.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((Dt,_t)=>Dt.sortKey-_t.sortKey)}update(n,o,d,g){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(n,o,this.layers,d,g),this.icon.programConfigurations.updatePaintArrays(n,o,this.layers,d,g))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(n){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(n),this.iconCollisionBox.upload(n)),this.text.upload(n,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(n,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=sC(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(n,o){const d=this.lineVertexArray.length;if(n.segment!==void 0)for(const{x:g,y:v}of o)this.lineVertexArray.emplaceBack(g,v);return{lineStartIndex:d,lineLength:this.lineVertexArray.length-d}}addSymbols(n,o,d,g,v,E,L,k,V,q,se,he,_e,be){const De=n.indexArray,Ze=n.layoutVertexArray,xt=n.globeExtVertexArray,Dt=n.segments.prepareSegment(4*o.length,Ze,De,this.canOverlap?E.sortKey:void 0),_t=this.glyphOffsetArray.length,Tt=Dt.vertexLength,kt=this.allowVerticalPlacement&&L===qo.vertical?Math.PI/2:0,Ut=E.text&&E.text.sections;for(let ai=0;ai=0?o.rightJustifiedTextSymbolIndex:o.centerJustifiedTextSymbolIndex>=0?o.centerJustifiedTextSymbolIndex:o.leftJustifiedTextSymbolIndex>=0?o.leftJustifiedTextSymbolIndex:o.verticalPlacedTextSymbolIndex>=0?o.verticalPlacedTextSymbolIndex:g),E=$s(this.textSizeData,n,v)/Jr;return this.tilePixelRatio*E}getSymbolInstanceIconSize(n,o,d){const g=this.icon.placedSymbolArray.get(d),v=$s(this.iconSizeData,n,g);return this.tilePixelRatio*v}_commitDebugCollisionVertexUpdate(n,o,d){n.emplaceBack(o,-d,-d),n.emplaceBack(o,d,-d),n.emplaceBack(o,d,d),n.emplaceBack(o,-d,d)}_updateTextDebugCollisionBoxes(n,o,d,g,v,E){for(let L=g;L0}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(n,o){const d=n.placedSymbolArray.get(o),g=d.vertexStartIndex+4*d.numGlyphs;for(let v=d.vertexStartIndex;vg[L]-g[k]||v[k]-v[L]),E}addToSortKeyRanges(n,o){const d=this.sortKeyRanges[this.sortKeyRanges.length-1];d&&d.sortKey===o?d.symbolInstanceEnd=n+1:this.sortKeyRanges.push({sortKey:o,symbolInstanceStart:n,symbolInstanceEnd:n+1})}sortFeatures(n){if(this.sortFeaturesByY&&this.sortedAngle!==n&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(n),this.sortedAngle=n,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const o of this.symbolInstanceIndexes){const d=this.symbolInstances.get(o);this.featureSortOrder.push(d.featureIndex);const{rightJustifiedTextSymbolIndex:g,centerJustifiedTextSymbolIndex:v,leftJustifiedTextSymbolIndex:E,verticalPlacedTextSymbolIndex:L,placedIconSymbolIndex:k,verticalPlacedIconSymbolIndex:V}=d;g>=0&&this.addIndicesForPlacedSymbol(this.text,g),v>=0&&v!==g&&this.addIndicesForPlacedSymbol(this.text,v),E>=0&&E!==v&&E!==g&&this.addIndicesForPlacedSymbol(this.text,E),L>=0&&this.addIndicesForPlacedSymbol(this.text,L),k>=0&&this.addIndicesForPlacedSymbol(this.icon,k),V>=0&&this.addIndicesForPlacedSymbol(this.icon,V)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}zt(Ld,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Ld.MAX_GLYPHS=65535,Ld.addDynamicAttributes=B0;const b3=new Hn({"symbol-placement":new Jt(Yt.layout_symbol["symbol-placement"]),"symbol-spacing":new Jt(Yt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Jt(Yt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new pi(Yt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Jt(Yt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Jt(Yt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Jt(Yt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Jt(Yt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Jt(Yt.layout_symbol["icon-rotation-alignment"]),"icon-size":new pi(Yt.layout_symbol["icon-size"]),"icon-text-fit":new Jt(Yt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Jt(Yt.layout_symbol["icon-text-fit-padding"]),"icon-image":new pi(Yt.layout_symbol["icon-image"]),"icon-rotate":new pi(Yt.layout_symbol["icon-rotate"]),"icon-padding":new Jt(Yt.layout_symbol["icon-padding"]),"icon-keep-upright":new Jt(Yt.layout_symbol["icon-keep-upright"]),"icon-offset":new pi(Yt.layout_symbol["icon-offset"]),"icon-anchor":new pi(Yt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Jt(Yt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Jt(Yt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Jt(Yt.layout_symbol["text-rotation-alignment"]),"text-field":new pi(Yt.layout_symbol["text-field"]),"text-font":new pi(Yt.layout_symbol["text-font"]),"text-size":new pi(Yt.layout_symbol["text-size"]),"text-max-width":new pi(Yt.layout_symbol["text-max-width"]),"text-line-height":new pi(Yt.layout_symbol["text-line-height"]),"text-letter-spacing":new pi(Yt.layout_symbol["text-letter-spacing"]),"text-justify":new pi(Yt.layout_symbol["text-justify"]),"text-radial-offset":new pi(Yt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Jt(Yt.layout_symbol["text-variable-anchor"]),"text-anchor":new pi(Yt.layout_symbol["text-anchor"]),"text-max-angle":new Jt(Yt.layout_symbol["text-max-angle"]),"text-writing-mode":new Jt(Yt.layout_symbol["text-writing-mode"]),"text-rotate":new pi(Yt.layout_symbol["text-rotate"]),"text-padding":new Jt(Yt.layout_symbol["text-padding"]),"text-keep-upright":new Jt(Yt.layout_symbol["text-keep-upright"]),"text-transform":new pi(Yt.layout_symbol["text-transform"]),"text-offset":new pi(Yt.layout_symbol["text-offset"]),"text-allow-overlap":new Jt(Yt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Jt(Yt.layout_symbol["text-ignore-placement"]),"text-optional":new Jt(Yt.layout_symbol["text-optional"])});var O1={paint:new Hn({"icon-opacity":new pi(Yt.paint_symbol["icon-opacity"]),"icon-color":new pi(Yt.paint_symbol["icon-color"]),"icon-halo-color":new pi(Yt.paint_symbol["icon-halo-color"]),"icon-halo-width":new pi(Yt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new pi(Yt.paint_symbol["icon-halo-blur"]),"icon-translate":new Jt(Yt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Jt(Yt.paint_symbol["icon-translate-anchor"]),"text-opacity":new pi(Yt.paint_symbol["text-opacity"]),"text-color":new pi(Yt.paint_symbol["text-color"],{runtimeType:la,getOverride:s=>s.textColor,hasOverride:s=>!!s.textColor}),"text-halo-color":new pi(Yt.paint_symbol["text-halo-color"]),"text-halo-width":new pi(Yt.paint_symbol["text-halo-width"]),"text-halo-blur":new pi(Yt.paint_symbol["text-halo-blur"]),"text-translate":new Jt(Yt.paint_symbol["text-translate"]),"text-translate-anchor":new Jt(Yt.paint_symbol["text-translate-anchor"])}),layout:b3};class oC{constructor(n){this.type=n.property.overrides?n.property.overrides.runtimeType:or,this.defaultValue=n}evaluate(n){if(n.formattedSection){const o=this.defaultValue.property.overrides;if(o&&o.hasOverride(n.formattedSection))return o.getOverride(n.formattedSection)}return n.feature&&n.featureState?this.defaultValue.evaluate(n.feature,n.featureState):this.defaultValue.property.specification.default}eachChild(n){this.defaultValue.isConstant()||n(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}zt(oC,"FormatSectionOverride",{omit:["defaultValue"]});class C0 extends xc{constructor(n){super(n,O1)}recalculate(n,o){super.recalculate(n,o),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 d=this.layout.get("text-writing-mode");if(d){const g=[];for(const v of d)g.indexOf(v)<0&&g.push(v);this.layout._values["text-writing-mode"]=g}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(n,o,d,g){const v=this.layout.get(n).evaluate(o,{},d,g),E=this._unevaluatedLayout._values[n];return E.isDataDriven()||_c(E.value)||!v?v:function(L,k){return k.replace(/{([^{}]+)}/g,(V,q)=>q in L?String(L[q]):"")}(o.properties,v)}createBucket(n){return new Ld(n)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const n of O1.paint.overridableProperties){if(!C0.hasPaintOverride(this.layout,n))continue;const o=this.paint.get(n),d=new oC(o),g=new ih(d,o.property.specification);let v=null;v=o.value.kind==="constant"||o.value.kind==="source"?new fo("source",g):new Gh("composite",g,o.value.zoomStops,o.value._interpolationType),this.paint._values[n]=new Mi(o.property,v,o.parameters)}}_handleOverridablePaintPropertyUpdate(n,o,d){return!(!this.layout||o.isDataDriven()||d.isDataDriven())&&C0.hasPaintOverride(this.layout,n)}static hasPaintOverride(n,o){const d=n.get("text-field"),g=O1.paint.properties[o];let v=!1;const E=L=>{for(const k of L)if(g.overrides&&g.overrides.hasOverride(k))return void(v=!0)};if(d.value.kind==="constant"&&d.value.value instanceof Os)E(d.value.value.sections);else if(d.value.kind==="source"){const L=V=>{v||(V instanceof sc&&Cs(V.value)===Rl?E(V.value.sections):V instanceof hl?E(V.sections):V.eachChild(L))},k=d.value;k._styleExpression&&L(k._styleExpression.expression)}return v}getProgramConfiguration(n){return new lh(this,n)}}var B3={paint:new Hn({"background-color":new Jt(Yt.paint_background["background-color"]),"background-pattern":new Jt(Yt.paint_background["background-pattern"]),"background-opacity":new Jt(Yt.paint_background["background-opacity"])})},C3={paint:new Hn({"raster-opacity":new Jt(Yt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Jt(Yt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Jt(Yt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Jt(Yt.paint_raster["raster-brightness-max"]),"raster-saturation":new Jt(Yt.paint_raster["raster-saturation"]),"raster-contrast":new Jt(Yt.paint_raster["raster-contrast"]),"raster-resampling":new Jt(Yt.paint_raster["raster-resampling"]),"raster-fade-duration":new Jt(Yt.paint_raster["raster-fade-duration"])})};class E3 extends xc{constructor(n){super(n,{}),this.implementation=n}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(n){this.implementation.onAdd&&this.implementation.onAdd(n,n.painter.context.gl)}onRemove(n){this.implementation.onRemove&&this.implementation.onRemove(n,n.painter.context.gl)}}var T3={paint:new Hn({"sky-type":new Jt(Yt.paint_sky["sky-type"]),"sky-atmosphere-sun":new Jt(Yt.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Jt(Yt.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Jt(Yt.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Jt(Yt.paint_sky["sky-gradient-radius"]),"sky-gradient":new In(Yt.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Jt(Yt.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Jt(Yt.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Jt(Yt.paint_sky["sky-opacity"])})};function N1(s,n,o){const d=[0,0,1],g=Bg([]);return Cg(g,g,o?-Ke(s)+Math.PI:Ke(s)),uh(g,g,-Ke(n)),bg(d,d,g),so(d,d)}const S3={circle:class extends xc{constructor(s){super(s,_g)}createBucket(s){return new yp(s)}queryRadius(s){const n=s;return Tu("circle-radius",this,n)+Tu("circle-stroke-width",this,n)+xp(this.paint.get("circle-translate"))}queryIntersectsFeature(s,n,o,d,g,v,E,L){const k=Yr(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),v.angle,s.pixelToTileUnitsFactor),V=this.paint.get("circle-radius").evaluate(n,o)+this.paint.get("circle-stroke-width").evaluate(n,o);return qy(s,d,v,E,L,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",k,V)}getProgramIds(){return["circle"]}getProgramConfiguration(s){return new lh(this,s)}},heatmap:class extends xc{createBucket(s){return new bp(s)}constructor(s){super(s,d1),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(s){s==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Sg({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(s){return Tu("heatmap-radius",this,s)}queryIntersectsFeature(s,n,o,d,g,v,E,L){const k=this.paint.get("heatmap-radius").evaluate(n,o);return qy(s,d,v,E,L,!0,!0,new me(0,0),k)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(s){return new lh(this,s)}},hillshade:class extends xc{constructor(s){super(s,p1)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends xc{constructor(s){super(s,o0)}getProgramIds(){const s=this.paint.get("fill-pattern"),n=s&&s.constantOr(1),o=[n?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&o.push(n&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),o}getProgramConfiguration(s){return new lh(this,s)}recalculate(s,n){super.recalculate(s,n);const o=this.paint._values["fill-outline-color"];o.value.kind==="constant"&&o.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(s){return new Fp(s)}queryRadius(){return xp(this.paint.get("fill-translate"))}queryIntersectsFeature(s,n,o,d,g,v){return!s.queryGeometry.isAboveHorizon&&dg(gg(s.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),v.angle,s.pixelToTileUnitsFactor),d)}isTileClipped(){return!0}},"fill-extrusion":class extends xc{constructor(s){super(s,ui)}createBucket(s){return new Ce(s)}queryRadius(){return xp(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(s){return new lh(this,s)}queryIntersectsFeature(s,n,o,d,g,v,E,L,k){const V=Yr(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),v.angle,s.pixelToTileUnitsFactor),q=this.paint.get("fill-extrusion-height").evaluate(n,o),se=this.paint.get("fill-extrusion-base").evaluate(n,o),he=[0,0],_e=L&&v.elevation,be=v.elevation?v.elevation.exaggeration():1,De=s.tile.getBucket(this);if(_e&&De instanceof Ce){const Tt=De.centroidVertexArray,kt=k+1;ktTt.polygon).flat());const Ze=_e?L:null,[xt,Dt]=function(Tt,kt,Ut,ci,ai,Ti,Ki,_i,Si,Li,Vi){return Tt.projection.name==="globe"?function(Zi,yi,sn,Kn,dn,Ln,ln,Xn,Tr,wr,xr){const Jn=[],es=[],ir=Zi.projection.upVectorScale(xr,Zi.center.lat,Zi.worldSize).metersToTile,Sr=[0,0,0,1],ss=[0,0,0,1],_s=(ys,Bs,Zs,Yo)=>{ys[0]=Bs,ys[1]=Zs,ys[2]=Yo,ys[3]=1},ps=ri();sn>0&&(sn+=ps),Kn+=ps;for(const ys of yi){const Bs=[],Zs=[];for(const Yo of ys){const ts=Yo.x+dn.x,Ao=Yo.y+dn.y,lo=Zi.projection.projectTilePoint(ts,Ao,xr),Vr=Zi.projection.upVector(xr,Yo.x,Yo.y);let Us=sn,vo=Kn;if(ln){const os=gn(ts,Ao,sn,Kn,ln,Xn,Tr,wr);Us+=os.base,vo+=os.top}sn!==0?_s(Sr,lo.x+Vr[0]*ir*Us,lo.y+Vr[1]*ir*Us,lo.z+Vr[2]*ir*Us):_s(Sr,lo.x,lo.y,lo.z),_s(ss,lo.x+Vr[0]*ir*vo,lo.y+Vr[1]*ir*vo,lo.z+Vr[2]*ir*vo),Qs(Sr,Sr,Ln),Qs(ss,ss,Ln),Bs.push(new an(Sr[0],Sr[1],Sr[2])),Zs.push(new an(ss[0],ss[1],ss[2]))}Jn.push(Bs),es.push(Zs)}return[Jn,es]}(Tt,kt,Ut,ci,ai,Ti,Ki,_i,Si,Li,Vi):Ki?function(Zi,yi,sn,Kn,dn,Ln,ln,Xn,Tr){const wr=[],xr=[],Jn=[0,0,0,1];for(const es of Zi){const ir=[],Sr=[];for(const ss of es){const _s=ss.x+Kn.x,ps=ss.y+Kn.y,ys=gn(_s,ps,yi,sn,Ln,ln,Xn,Tr);Jn[0]=_s,Jn[1]=ps,Jn[2]=ys.base,Jn[3]=1,TA(Jn,Jn,dn),Jn[3]=Math.max(Jn[3],1e-5);const Bs=new an(Jn[0]/Jn[3],Jn[1]/Jn[3],Jn[2]/Jn[3]);Jn[0]=_s,Jn[1]=ps,Jn[2]=ys.top,Jn[3]=1,TA(Jn,Jn,dn),Jn[3]=Math.max(Jn[3],1e-5);const Zs=new an(Jn[0]/Jn[3],Jn[1]/Jn[3],Jn[2]/Jn[3]);ir.push(Bs),Sr.push(Zs)}wr.push(ir),xr.push(Sr)}return[wr,xr]}(kt,Ut,ci,ai,Ti,Ki,_i,Si,Li):function(Zi,yi,sn,Kn,dn){const Ln=[],ln=[],Xn=dn[8]*yi,Tr=dn[9]*yi,wr=dn[10]*yi,xr=dn[11]*yi,Jn=dn[8]*sn,es=dn[9]*sn,ir=dn[10]*sn,Sr=dn[11]*sn;for(const ss of Zi){const _s=[],ps=[];for(const ys of ss){const Bs=ys.x+Kn.x,Zs=ys.y+Kn.y,Yo=dn[0]*Bs+dn[4]*Zs+dn[12],ts=dn[1]*Bs+dn[5]*Zs+dn[13],Ao=dn[2]*Bs+dn[6]*Zs+dn[14],lo=dn[3]*Bs+dn[7]*Zs+dn[15],Vr=Yo+Xn,Us=ts+Tr,vo=Ao+wr,os=Math.max(lo+xr,1e-5),no=Yo+Jn,La=ts+es,Jo=Ao+ir,ea=Math.max(lo+Sr,1e-5);_s.push(new an(Vr/os,Us/os,vo/os)),ps.push(new an(no/ea,La/ea,Jo/ea))}Ln.push(_s),ln.push(ps)}return[Ln,ln]}(kt,Ut,ci,ai,Ti)}(v,d,se,q,V,E,Ze,he,be,v.center.lat,s.tileID.canonical),_t=s.queryGeometry;return function(Tt,kt,Ut){let ci=1/0;dg(Ut,kt)&&(ci=vn(Ut,kt[0]));for(let ai=0;ai=3){for(let be=0;be<_e.length;be++)if(vA(V,_e[be]))return!0}if(Gy(V,_e,se))return!0}return!1}(E,d,L)}isTileClipped(){return!0}},symbol:C0,background:class extends xc{constructor(s){super(s,B3)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends xc{constructor(s){super(s,C3)}getProgramIds(){return["raster"]}},sky:class extends xc{constructor(s){super(s,T3),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(s){s==="sky-gradient"?this._updateColorRamp():s!=="sky-atmosphere-sun"&&s!=="sky-atmosphere-halo-color"&&s!=="sky-atmosphere-color"&&s!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Sg({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(s){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const n=s.style.light.properties.get("position");return this._lightPosition.azimuthal!==n.azimuthal||this._lightPosition.polar!==n.polar}return!1}getCenter(s,n){if(this.paint.get("sky-type")==="atmosphere"){const d=this.paint.get("sky-atmosphere-sun"),g=!d,v=s.style.light,E=v.properties.get("position");return g&&v.properties.get("anchor")==="viewport"&&Ct("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),g?N1(E.azimuthal,90-E.polar,n):N1(d[0],90-d[1],n)}const o=this.paint.get("sky-gradient-center");return N1(o[0],90-o[1],n)}is3D(){return!1}isSky(){return!0}markSkyboxValid(s){this._skyboxInvalidated=!1,this._lightPosition=s.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const s=this.paint.get("sky-type");return s==="atmosphere"?["skyboxCapture","skybox"]:s==="gradient"?["skyboxGradient"]:null}}};class Kg{constructor(n,o,d,g){this.context=n,this.format=d,this.texture=n.gl.createTexture(),this.update(o,g)}update(n,o,d){const{width:g,height:v}=n,{context:E}=this,{gl:L}=E,{HTMLImageElement:k,HTMLCanvasElement:V,HTMLVideoElement:q,ImageData:se,ImageBitmap:he}=C;if(L.bindTexture(L.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===L.RGBA&&(!o||o.premultiply!==!1)),d||this.size&&this.size[0]===g&&this.size[1]===v){const{x:_e,y:be}=d||{x:0,y:0};n instanceof k||n instanceof V||n instanceof q||n instanceof se||he&&n instanceof he?L.texSubImage2D(L.TEXTURE_2D,0,_e,be,L.RGBA,L.UNSIGNED_BYTE,n):L.texSubImage2D(L.TEXTURE_2D,0,_e,be,g,v,L.RGBA,L.UNSIGNED_BYTE,n.data)}else this.size=[g,v],n instanceof k||n instanceof V||n instanceof q||n instanceof se||he&&n instanceof he?L.texImage2D(L.TEXTURE_2D,0,this.format,this.format,L.UNSIGNED_BYTE,n):L.texImage2D(L.TEXTURE_2D,0,this.format,g,v,0,this.format,L.UNSIGNED_BYTE,n.data);this.useMipmap=Boolean(o&&o.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&L.generateMipmap(L.TEXTURE_2D)}bind(n,o){const{context:d}=this,{gl:g}=d;g.bindTexture(g.TEXTURE_2D,this.texture),n!==this.filter&&(g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MAG_FILTER,n),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MIN_FILTER,this.useMipmap?n===g.NEAREST?g.NEAREST_MIPMAP_NEAREST:g.LINEAR_MIPMAP_NEAREST:n),this.filter=n),o!==this.wrap&&(g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_S,o),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_T,o),this.wrap=o)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:n}=this.context;n.deleteTexture(this.texture),this.texture=null}}class M3{constructor(n){this._callback=n,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 I3{constructor(){this.tasks={},this.taskQueue=[],Be(["process"],this),this.invoker=new M3(this.process),this.nextId=0}add(n,o){const d=this.nextId++,g=function({type:v,isSymbolTile:E,zoom:L}){return L=L||0,v==="message"?0:v!=="maybePrepare"||E?v!=="parseTile"||E?v==="parseTile"&&E?300-L:v==="maybePrepare"&&E?400-L:500:200-L:100-L}(o);if(g===0){mi();try{n()}finally{}return{cancel:()=>{}}}return this.tasks[d]={fn:n,metadata:o,priority:g,id:d},this.taskQueue.push(d),this.invoker.trigger(),{cancel:()=>{delete this.tasks[d]}}}process(){mi();try{if(this.taskQueue=this.taskQueue.filter(d=>!!this.tasks[d]),!this.taskQueue.length)return;const n=this.pick();if(n===null)return;const o=this.tasks[n];if(delete this.tasks[n],this.taskQueue.length&&this.invoker.trigger(),!o)return;o.fn()}finally{}}pick(){let n=null,o=1/0;for(let g=0;g>=1)>1;){const V=o+g>>1,q=d+v>>1;1&n?(g=o,v=d,o=E,d=L):(o=g,d=v,g=E,v=L),E=V,L=q}const k=4*s;Dd[k+0]=o,Dd[k+1]=d,Dd[k+2]=g,Dd[k+3]=v}const Du=new Uint16Array(2178),Pd=new Uint8Array(1089),E0=new Uint16Array(1089);function cC(s){return s===0?-.03125:s===32?.03125:0}var hC=_n([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const uC={type:2,extent:Zn,loadGeometry:()=>[[new me(0,0),new me(8193,0),new me(8193,8193),new me(0,8193),new me(0,0)]]};class Q1{constructor(n,o,d,g,v){this.tileID=n,this.uid=Ie(),this.uses=0,this.tileSize=o,this.tileZoom=d,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=v,this.expiredRequestCount=0,this.state="loading",g&&g.transform&&(this.projection=g.transform.projection)}registerFadeDuration(n){const o=n+this.timeAdded;ov.getLayer(V)).filter(Boolean);if(k.length!==0){L.layers=k,L.stateDependentLayerIds&&(L.stateDependentLayers=L.stateDependentLayerIds.map(V=>k.filter(q=>q.id===V)[0]));for(const V of k)E[V.id]=L}}return E}(n.buckets,o.style),this.hasSymbolBuckets=!1;for(const g in this.buckets){const v=this.buckets[g];if(v instanceof Ld){if(this.hasSymbolBuckets=!0,!d)break;v.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const g in this.buckets){const v=this.buckets[g];if(v instanceof Ld&&v.hasRTLText){this.hasRTLText=!0,si.isLoading()||si.isLoaded()||Ht()!=="deferred"||hi();break}}this.queryPadding=0;for(const g in this.buckets){const v=this.buckets[g];this.queryPadding=Math.max(this.queryPadding,o.style.getLayer(g).queryRadius(v))}n.imageAtlas&&(this.imageAtlas=n.imageAtlas),n.glyphAtlasImage&&(this.glyphAtlasImage=n.glyphAtlasImage),n.lineAtlas&&(this.lineAtlas=n.lineAtlas)}else this.collisionBoxArray=new og}unloadVectorData(){if(this.hasData()){for(const n in this.buckets)this.buckets[n].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(n){return this.buckets[n.id]}upload(n){for(const d in this.buckets){const g=this.buckets[d];g.uploadPending()&&g.upload(n)}const o=n.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Kg(n,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Kg(n,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Kg(n,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(n){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(n,this.imageAtlasTexture)}queryRenderedFeatures(n,o,d,g,v,E,L,k){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:g,pixelPosMatrix:L,transform:E,params:v,tileTransform:this.tileTransform},n,o,d):{}}querySourceFeatures(n,o){const d=this.latestFeatureIndex;if(!d||!d.rawTileData)return;const g=d.loadVTLayers(),v=o?o.sourceLayer:"",E=g._geojsonTileLayer||g[v];if(!E)return;const L=uo(o&&o.filter),{z:k,x:V,y:q}=this.tileID.canonical,se={z:k,x:V,y:q};for(let he=0;hed)g=!1;else if(o)if(this.expirationTime=0;Ze--){const xt=4*Ze,Dt=Dd[xt+0],_t=Dd[xt+1],Tt=Dd[xt+2],kt=Dd[xt+3],Ut=Dt+Tt>>1,ci=_t+kt>>1,ai=Ut+ci-_t,Ti=ci+Dt-Ut,Ki=_t*Lu+Dt,_i=kt*Lu+Tt,Si=ci*Lu+Ut,Li=Math.hypot((Du[2*Ki+0]+Du[2*_i+0])/2-Du[2*Si+0],(Du[2*Ki+1]+Du[2*_i+1])/2-Du[2*Si+1])>=16;if(Pd[Si]=Pd[Si]||(Li?1:0),Ze<1022){const Vi=(_t+Ti>>1)*Lu+(Dt+ai>>1),Zi=(kt+Ti>>1)*Lu+(Tt+ai>>1);Pd[Si]=Pd[Si]||Pd[Vi]||Pd[Zi]}}const se=new Qr,he=new _o;let _e=0;function be(Ze,xt){const Dt=xt*Lu+Ze;return E0[Dt]===0&&(se.emplaceBack(Du[2*Dt+0],Du[2*Dt+1],Ze*Zn/gh,xt*Zn/gh),E0[Dt]=++_e),E0[Dt]-1}function De(Ze,xt,Dt,_t,Tt,kt){const Ut=Ze+Dt>>1,ci=xt+_t>>1;if(Math.abs(Ze-Tt)+Math.abs(xt-kt)>1&&Pd[ci*Lu+Ut])De(Tt,kt,Ze,xt,Ut,ci),De(Dt,_t,Tt,kt,Ut,ci);else{const ai=be(Ze,xt),Ti=be(Dt,_t),Ki=be(Tt,kt);he.emplaceBack(ai,Ti,Ki)}}return De(0,0,gh,gh,gh,0),De(gh,gh,0,0,0,gh),{vertices:se,indices:he}}(this.tileID.canonical,o);g=E.vertices,v=E.indices}else{g=new Qr,v=new _o;for(const{x:L,y:k}of d)g.emplaceBack(L,k,0,0);const E=vd.exports(g.int16,void 0,4);for(let L=0;L0&&(L=yg(new Float64Array(16),o.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(n,g,o,v,L,E),this._makeGlobeTileDebugTextBuffer(n,g,o,v,L,E)}_globePoint(n,o,d,g,v,E,L){let k=Qg(n,o,d);if(E){const V=1<.5?_e=-1:he<-.5&&(_e=1);let be=(n/Zn+d.x)/V+_e,De=(o/Zn+d.y)/V;be=(be-q)*g._pixelsPerMercatorPixel+q,De=(De-se)*g._pixelsPerMercatorPixel+se;const Ze=[be*g.worldSize,De*g.worldSize,0];Qs(Ze,Ze,E),k=Pp(k,Ze,L)}return Qs(k,k,v)}_makeGlobeTileDebugBorderBuffer(n,o,d,g,v,E){const L=new Or,k=new Xh,V=new Nr,q=(he,_e,be,De,Ze)=>{const xt=(be-he)/(Ze-1),Dt=(De-_e)/(Ze-1),_t=L.length;for(let Tt=0;Ttq*he+_e;for(let he=0;hen[E])return null}else{const L=1/d[E];let k=(s[E]-o[E])*L,V=(n[E]-o[E])*L;if(k>V){const q=k;k=V,V=q}if(k>g&&(g=k),Vv)return null}return g}function pC(s,n,o,d,g,v,E,L,k,V,q){const se=d-s,he=g-n,_e=v-o,be=E-s,De=L-n,Ze=k-o,xt=q[1]*Ze-q[2]*De,Dt=q[2]*be-q[0]*Ze,_t=q[0]*De-q[1]*be,Tt=se*xt+he*Dt+_e*_t;if(Math.abs(Tt)<1e-15)return null;const kt=1/Tt,Ut=V[0]-s,ci=V[1]-n,ai=V[2]-o,Ti=(Ut*xt+ci*Dt+ai*_t)*kt;if(Ti<0||Ti>1)return null;const Ki=ci*_e-ai*he,_i=ai*se-Ut*_e,Si=Ut*he-ci*se,Li=(q[0]*Ki+q[1]*_i+q[2]*Si)*kt;return Li<0||Ti+Li>1?null:(be*Ki+De*_i+Ze*Si)*kt}function fC(s,n,o){return(s-n)/(o-n)}function mC(s,n,o,d,g,v,E,L,k){const V=1<{const Dt=Ze?1:0,_t=(_e+1)*De-Dt,Tt=be*De,kt=(be+1)*De-Dt;xt[0]=_e*De,xt[1]=Tt,xt[2]=_t,xt[3]=kt};let se=new AC(k);const he=[];for(let _e=0;_e=1;k/=2){const _e=L[L.length-1];se=new AC(k);for(let be=0;be0;){const{idx:be,t:De,nodex:Ze,nodey:xt,depth:Dt}=_e.pop();if(this.leaves[be]){mC(Ze,xt,Dt,n,o,d,g,se,he);const Tt=1<=yi[2])return De}continue}let _t=0;for(let Tt=0;Tt=V[q[ai]]&&(q.splice(ai,0,Tt),ci=!0);ci||(q[_t]=Tt),_t++}}for(let Tt=0;Tt<_t;Tt++){const kt=q[Tt];_e.push({idx:this.childOffsets[be]+kt,t:V[kt],nodex:(Ze<<1)+this._siblingOffset[kt][0],nodey:(xt<<1)+this._siblingOffset[kt][1],depth:Dt+1})}}return null}_addNode(n,o,d){return this.minimums.push(n),this.maximums.push(o),this.leaves.push(d),this.childOffsets.push(0),this.nodeCount++}_construct(n,o,d,g,v){if(n[g].isLeaf(o,d)===1)return;this.childOffsets[v]||(this.childOffsets[v]=this.nodeCount);const E=g-1,L=n[E];let k=0,V=0;for(let q=0;q=this.dim+1||o<-1||o>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(o+1)*this.stride+(n+1)}_unpackMapbox(n,o,d){return(256*n*256+256*o+d)/10-1e4}_unpackTerrarium(n,o,d){return 256*n+o+d/256-32768}static pack(n,o){const d=[0,0,0,0],g=T0.getUnpackVector(o);let v=Math.floor((n+g[3])/g[2]);return d[2]=v%256,v=Math.floor(v/256),d[1]=v%256,v=Math.floor(v/256),d[0]=v,d}getPixels(){return new Xa({width:this.stride,height:this.stride},this.pixels)}backfillBorder(n,o,d){if(this.dim!==n.dim)throw new Error("dem dimension mismatch");let g=o*this.dim,v=o*this.dim+this.dim,E=d*this.dim,L=d*this.dim+this.dim;switch(o){case-1:g=v-1;break;case 1:v=g+1}switch(d){case-1:E=L-1;break;case 1:L=E+1}const k=-o*this.dim,V=-d*this.dim;for(let q=E;q{this.remove(n,v)},d)),this.data[g].push(v),this.order.push(g),this.order.length>this.max){const E=this._getAndRemoveByKey(this.order[0]);E&&this.onRemove(E)}return this}has(n){return n.wrapped().key in this.data}getAndRemove(n){return this.has(n)?this._getAndRemoveByKey(n.wrapped().key):null}_getAndRemoveByKey(n){const o=this.data[n].shift();return o.timeout&&clearTimeout(o.timeout),this.data[n].length===0&&delete this.data[n],this.order.splice(this.order.indexOf(n),1),o.value}getByKey(n){const o=this.data[n];return o?o[0].value:null}get(n){return this.has(n)?this.data[n.wrapped().key][0].value:null}remove(n,o){if(!this.has(n))return this;const d=n.wrapped().key,g=o===void 0?0:this.data[d].indexOf(o),v=this.data[d][g];return this.data[d].splice(g,1),v.timeout&&clearTimeout(v.timeout),this.data[d].length===0&&delete this.data[d],this.onRemove(v.value),this.order.splice(this.order.indexOf(d),1),this}setMaxSize(n){for(this.max=n;this.order.length>this.max;){const o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}filter(n){const o=[];for(const d in this.data)for(const g of this.data[d])n(g.value)||o.push(g);for(const d of o)this.remove(d.value.tileID,d)}}class tm{constructor(n,o,d){this.func=n,this.mask=o,this.range=d}}tm.ReadOnly=!1,tm.ReadWrite=!0,tm.disabled=new tm(519,tm.ReadOnly,[0,1]);const V1=7680;class H1{constructor(n,o,d,g,v,E){this.test=n,this.ref=o,this.mask=d,this.fail=g,this.depthFail=v,this.pass=E}}H1.disabled=new H1({func:519,mask:0},0,0,V1,V1,V1);class Pu{constructor(n,o,d){this.blendFunction=n,this.blendColor=o,this.mask=d}}Pu.Replace=[1,0],Pu.disabled=new Pu(Pu.Replace,fs.transparent,[!1,!1,!1,!1]),Pu.unblended=new Pu(Pu.Replace,fs.transparent,[!0,!0,!0,!0]),Pu.alphaBlended=new Pu([1,771],fs.transparent,[!0,!0,!0,!0]);const G1=1029,W1=2305;class ru{constructor(n,o,d){this.enable=n,this.mode=o,this.frontFace=d}}ru.disabled=new ru(!1,G1,W1),ru.backCCW=new ru(!0,G1,W1),ru.backCW=new ru(!0,G1,2304),ru.frontCW=new ru(!0,1028,2304),ru.frontCCW=new ru(!0,1028,W1);class Rp extends yn{constructor(n,o,d){super(),this.id=n,this._onlySymbols=d,o.on("data",g=>{g.dataType==="source"&&g.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&g.dataType==="source"&&g.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),o.on("error",()=>{this._sourceErrored=!0}),this._source=o,this._tiles={},this._cache=new D3(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=o.minTileCacheSize,this._maxTileCacheSize=o.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new L3,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(n){this.map=n,this._minTileCacheSize=this._minTileCacheSize===void 0&&n?n._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&n?n._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const n in this._tiles){const o=this._tiles[n];if(o.state!=="loaded"&&o.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const n=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,n&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(n,o){return n.isSymbolTile=this._onlySymbols,this._source.loadTile(n,o)}_unloadTile(n){if(this._source.unloadTile)return this._source.unloadTile(n,()=>{})}_abortTile(n){if(this._source.abortTile)return this._source.abortTile(n,()=>{})}serialize(){return this._source.serialize()}prepare(n){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const o in this._tiles){const d=this._tiles[o];d.upload(n),d.prepare(this.map.style.imageManager)}}getIds(){return Ge(this._tiles).map(n=>n.tileID).sort(xC).map(n=>n.key)}getRenderableIds(n){const o=[];for(const d in this._tiles)this._isIdRenderable(+d,n)&&o.push(this._tiles[d]);return n?o.sort((d,g)=>{const v=d.tileID,E=g.tileID,L=new me(v.canonical.x,v.canonical.y)._rotate(this.transform.angle),k=new me(E.canonical.x,E.canonical.y)._rotate(this.transform.angle);return v.overscaledZ-E.overscaledZ||k.y-L.y||k.x-L.x}).map(d=>d.tileID.key):o.map(d=>d.tileID).sort(xC).map(d=>d.key)}hasRenderableParent(n){const o=this.findLoadedParent(n,0);return!!o&&this._isIdRenderable(o.tileID.key)}_isIdRenderable(n,o){return this._tiles[n]&&this._tiles[n].hasData()&&!this._coveredTiles[n]&&(o||!this._tiles[n].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const n in this._tiles)this._tiles[n].state!=="errored"&&this._reloadTile(+n,"reloading")}}_reloadTile(n,o){const d=this._tiles[n];d&&(d.state!=="loading"&&(d.state=o),this._loadTile(d,this._tileLoaded.bind(this,d,n,o)))}_tileLoaded(n,o,d,g){if(g)if(n.state="errored",g.status!==404)this._source.fire(new rr(g,{tile:n}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const v=this.map.painter.terrain;this.update(this.transform,v.getScaledDemTileSize(),!0),v.resetTileLookupCache(this.id)}else this.update(this.transform);else n.timeAdded=wi.now(),d==="expired"&&(n.refreshedUponExpiration=!0),this._setTileReloadTimer(o,n),this._source.type==="raster-dem"&&n.dem&&this._backfillDEM(n),this._state.initializeTileState(n,this.map?this.map.painter:null),this._source.fire(new tn("data",{dataType:"source",tile:n,coord:n.tileID,sourceCacheId:this.id}))}_backfillDEM(n){const o=this.getRenderableIds();for(let g=0;g1||(Math.abs(E)>1&&(Math.abs(E+k)===1?E+=k:Math.abs(E-k)===1&&(E-=k)),v.dem&&g.dem&&(g.dem.backfillBorder(v.dem,E,L),g.neighboringTiles&&g.neighboringTiles[V]&&(g.neighboringTiles[V].backfilled=!0)))}}getTile(n){return this.getTileByID(n.key)}getTileByID(n){return this._tiles[n]}_retainLoadedChildren(n,o,d,g){for(const v in this._tiles){let E=this._tiles[v];if(g[v]||!E.hasData()||E.tileID.overscaledZ<=o||E.tileID.overscaledZ>d)continue;let L=E.tileID;for(;E&&E.tileID.overscaledZ>o+1;){const V=E.tileID.scaledTo(E.tileID.overscaledZ-1);E=this._tiles[V.key],E&&E.hasData()&&(L=V)}let k=L;for(;k.overscaledZ>o;)if(k=k.scaledTo(k.overscaledZ-1),n[k.key]){g[L.key]=L;break}}}findLoadedParent(n,o){if(n.key in this._loadedParentTiles){const d=this._loadedParentTiles[n.key];return d&&d.tileID.overscaledZ>=o?d:null}for(let d=n.overscaledZ-1;d>=o;d--){const g=n.scaledTo(d),v=this._getLoadedTile(g);if(v)return v}}_getLoadedTile(n){const o=this._tiles[n.key];return o&&o.hasData()?o:this._cache.getByKey(this._source.reparseOverscaled?n.wrapped().key:n.canonical.key)}updateCacheSize(n,o){o=o||this._source.tileSize;const d=Math.ceil(n.width/o)+1,g=Math.ceil(n.height/o)+1,v=Math.floor(d*g*5),E=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,v):v,L=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,E):E;this._cache.setMaxSize(L)}handleWrapJump(n){const o=Math.round((n-(this._prevLng===void 0?n:this._prevLng))/360);if(this._prevLng=n,o){const d={};for(const g in this._tiles){const v=this._tiles[g];v.tileID=v.tileID.unwrapTo(v.tileID.wrap+o),d[v.tileID.key]=v}this._tiles=d;for(const g in this._timers)clearTimeout(this._timers[g]),delete this._timers[g];for(const g in this._tiles)this._setTileReloadTimer(+g,this._tiles[g])}}update(n,o,d){if(this.transform=n,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!d)return;let g;this.updateCacheSize(n,o),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?g=n.getVisibleUnwrappedCoordinates(this._source.tileID).map(L=>new fn(L.canonical.z,L.wrap,L.canonical.z,L.canonical.x,L.canonical.y)):(g=n.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!d,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(g=g.filter(L=>this._source.hasTile(L)))):g=[];const v=this._updateRetainedTiles(g);if(vC(this._source.type)&&g.length!==0){const L={},k={},V=Object.keys(v);for(const se of V){const he=v[se],_e=this._tiles[se];if(!_e||_e.fadeEndTime&&_e.fadeEndTime<=wi.now())continue;const be=this.findLoadedParent(he,Math.max(he.overscaledZ-Rp.maxOverzooming,this._source.minzoom));be&&(this._addTile(be.tileID),L[be.tileID.key]=be.tileID),k[se]=he}const q=g[g.length-1].overscaledZ;for(const se in this._tiles){const he=this._tiles[se];if(v[se]||!he.hasData())continue;let _e=he.tileID;for(;_e.overscaledZ>q;){_e=_e.scaledTo(_e.overscaledZ-1);const be=this._tiles[_e.key];if(be&&be.hasData()&&k[_e.key]){v[se]=he.tileID;break}}}for(const se in L)v[se]||(this._coveredTiles[se]=!0,v[se]=L[se])}for(const L in v)this._tiles[L].clearFadeHold();const E=function(L,k){const V=[];for(const q in L)q in k||V.push(q);return V}(this._tiles,v);for(const L of E){const k=this._tiles[L];k.hasSymbolBuckets&&!k.holdingForFade()?k.setHoldDuration(this.map._fadeDuration):k.hasSymbolBuckets&&!k.symbolFadeFinished()||this._removeTile(+L)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const n in this._tiles)this._tiles[n].holdingForFade()&&this._removeTile(+n)}_updateRetainedTiles(n){const o={};if(n.length===0)return o;const d={},g=n.reduce((V,q)=>Math.min(V,q.overscaledZ),1/0),v=n[0].overscaledZ,E=Math.max(v-Rp.maxOverzooming,this._source.minzoom),L=Math.max(v+Rp.maxUnderzooming,this._source.minzoom),k={};for(const V of n){const q=this._addTile(V);o[V.key]=V,q.hasData()||g=this._source.maxzoom){const he=V.children(this._source.maxzoom)[0],_e=this.getTile(he);if(_e&&_e.hasData()){o[he.key]=he;continue}}else{const he=V.children(this._source.maxzoom);if(o[he[0].key]&&o[he[1].key]&&o[he[2].key]&&o[he[3].key])continue}let se=q.wasRequested();for(let he=V.overscaledZ-1;he>=E;--he){const _e=V.scaledTo(he);if(d[_e.key]||(d[_e.key]=!0,q=this.getTile(_e),!q&&se&&(q=this._addTile(_e)),q&&(o[_e.key]=_e,se=q.wasRequested(),q.hasData())))break}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const n in this._tiles){const o=[];let d,g=this._tiles[n].tileID;for(;g.overscaledZ>0;){if(g.key in this._loadedParentTiles){d=this._loadedParentTiles[g.key];break}o.push(g.key);const v=g.scaledTo(g.overscaledZ-1);if(d=this._getLoadedTile(v),d)break;g=v}for(const v of o)this._loadedParentTiles[v]=d}}_addTile(n){let o=this._tiles[n.key];if(o)return o;o=this._cache.getAndRemove(n),o&&(this._setTileReloadTimer(n.key,o),o.tileID=n,this._state.initializeTileState(o,this.map?this.map.painter:null),this._cacheTimers[n.key]&&(clearTimeout(this._cacheTimers[n.key]),delete this._cacheTimers[n.key],this._setTileReloadTimer(n.key,o)));const d=Boolean(o);if(!d){const g=this.map?this.map.painter:null;o=new Q1(n,this._source.tileSize*n.overscaleFactor(),this.transform.tileZoom,g,this._isRaster),this._loadTile(o,this._tileLoaded.bind(this,o,n.key,o.state))}return o?(o.uses++,this._tiles[n.key]=o,d||this._source.fire(new tn("dataloading",{tile:o,coord:o.tileID,dataType:"source"})),o):null}_setTileReloadTimer(n,o){n in this._timers&&(clearTimeout(this._timers[n]),delete this._timers[n]);const d=o.getExpiryTimeout();d&&(this._timers[n]=setTimeout(()=>{this._reloadTile(n,"expired"),delete this._timers[n]},d))}_removeTile(n){const o=this._tiles[n];o&&(o.uses--,delete this._tiles[n],this._timers[n]&&(clearTimeout(this._timers[n]),delete this._timers[n]),o.uses>0||(o.hasData()&&o.state!=="reloading"?this._cache.add(o.tileID,o,o.getExpiryTimeout()):(o.aborted=!0,this._abortTile(o),this._unloadTile(o))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const n in this._tiles)this._removeTile(+n);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(n,o,d){const g=[],v=this.transform;if(!v)return g;const E=v.projection.name==="globe",L=vc(v.center.lng);for(const k in this._tiles){const V=this._tiles[k];if(d&&V.clearQueryDebugViz(),V.holdingForFade())continue;let q;if(E){const se=V.tileID.canonical;if(se.z===0){const he=[Math.abs(ye(L,...$g(se,-1))-L),Math.abs(ye(L,...$g(se,1))-L)];q=[0,2*he.indexOf(Math.min(...he))-1]}else{const he=[Math.abs(ye(L,...$g(se,-1))-L),Math.abs(ye(L,...$g(se,0))-L),Math.abs(ye(L,...$g(se,1))-L)];q=[he.indexOf(Math.min(...he))-1]}}else q=[0];for(const se of q){const he=n.containsTile(V,v,o,se);he&&g.push(he)}}return g}getVisibleCoordinates(n){const o=this.getRenderableIds(n).map(d=>this._tiles[d].tileID);for(const d of o)d.projMatrix=this.transform.calculateProjMatrix(d.toUnwrapped());return o}hasTransition(){if(this._source.hasTransition())return!0;if(vC(this._source.type))for(const n in this._tiles){const o=this._tiles[n];if(o.fadeEndTime!==void 0&&o.fadeEndTime>=wi.now())return!0}return!1}setFeatureState(n,o,d){this._state.updateState(n=n||"_geojsonTileLayer",o,d)}removeFeatureState(n,o,d){this._state.removeFeatureState(n=n||"_geojsonTileLayer",o,d)}getFeatureState(n,o){return this._state.getState(n=n||"_geojsonTileLayer",o)}setDependencies(n,o,d){const g=this._tiles[n];g&&g.setDependencies(o,d)}reloadTilesForDependencies(n,o){for(const d in this._tiles)this._tiles[d].hasDependency(n,o)&&this._reloadTile(+d,"reloading");this._cache.filter(d=>!d.hasDependency(n,o))}_preloadTiles(n,o){const d=new Map,g=Array.isArray(n)?n:[n],v=this.map.painter.terrain,E=this.usedForTerrain&&v?v.getScaledDemTileSize():this._source.tileSize;for(const L of g){const k=L.coveringTiles({tileSize:E,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const V of k)d.set(V.key,V);this.usedForTerrain&&L.updateElevation(!1)}Ne(Array.from(d.values()),(L,k)=>{const V=new Q1(L,this._source.tileSize*L.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(V,q=>{this._source.type==="raster-dem"&&V.dem&&this._backfillDEM(V),k(q,V)})},o)}}function xC(s,n){const o=Math.abs(2*s.wrap)-+(s.wrap<0),d=Math.abs(2*n.wrap)-+(n.wrap<0);return s.overscaledZ-n.overscaledZ||d-o||n.canonical.y-s.canonical.y||n.canonical.x-s.canonical.x}function vC(s){return s==="raster"||s==="image"||s==="video"||s==="custom"}function $g(s,n){const o=1<=0&&se[3]>=0&&k.insert(L,se[0],se[1],se[2],se[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new f(new Fa(this.rawTileData)).layers,this.sourceLayerCoder=new aC(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const n in this.vtLayers)this.vtFeatures[n]=[]}return this.vtLayers}query(n,o,d,g){this.loadVTLayers();const v=n.params||{},E=uo(v.filter),L=n.tileResult,k=n.transform,V=L.bufferedTilespaceBounds,q=this.grid.query(V.min.x,V.min.y,V.max.x,V.max.y,(be,De,Ze,xt)=>Ad(L.bufferedTilespaceGeometry,be,De,Ze,xt));q.sort(P3);let se=null;k.elevation&&q.length>0&&(se=S0.create(k.elevation,this.tileID));const he={};let _e;for(let be=0;be(xt||(xt=Yh(Dt,this.tileID.canonical,n.tileTransform)),_t.queryIntersectsFeature(L,Dt,Tt,xt,this.z,n.transform,n.pixelPosMatrix,se,kt)))}return he}loadMatchingFeature(n,o,d,g,v,E,L,k,V){const{featureIndex:q,bucketIndex:se,sourceLayerIndex:he,layoutVertexArrayOffset:_e}=o,be=this.bucketLayerIDs[se];if(g&&!function(Dt,_t){for(let Tt=0;Tt=0)return!0;return!1}(g,be))return;const De=this.sourceLayerCoder.decode(he),Ze=this.vtLayers[De].feature(q);if(d.needGeometry){const Dt=xA(Ze,!0);if(!d.filter(new qt(this.tileID.overscaledZ),Dt,this.tileID.canonical))return}else if(!d.filter(new qt(this.tileID.overscaledZ),Ze))return;const xt=this.getId(Ze,De);for(let Dt=0;Dt{const L=n instanceof $i?n.get(E):null;return L&&L.evaluate?L.evaluate(o,d,g):L})}function P3(s,n){return n-s}zt(wC,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class BC{constructor(n,o){this.width=n,this.height=o,this.nextRow=0,this.image=new Yl({width:n,height:o}),this.positions={},this.uploaded=!1}getDash(n,o){const d=this.getKey(n,o);return this.positions[d]}trim(){const n=this.width,o=this.height=et(this.nextRow);this.image.resize({width:n,height:o})}getKey(n,o){return n.join(",")+o}getDashRanges(n,o,d){const g=[];let v=n.length%2==1?-n[n.length-1]*d:0,E=n[0]*d,L=!0;g.push({left:v,right:E,isDash:L,zeroLength:n[0]===0});let k=n[0];for(let V=1;V1&&(k=n[++L]);const q=Math.abs(V-k.left),se=Math.abs(V-k.right),he=Math.min(q,se);let _e;const be=v/d*(g+1);if(k.isDash){const De=g-Math.abs(be);_e=Math.sqrt(he*he+De*De)}else _e=g-Math.sqrt(he*he+be*be);this.image.data[E+V]=Math.max(0,Math.min(255,_e+128))}}}addRegularDash(n,o){for(let k=n.length-1;k>=0;--k){const V=n[k],q=n[k+1];V.zeroLength?n.splice(k,1):q&&q.isDash===V.isDash&&(q.left=V.left,n.splice(k,1))}const d=n[0],g=n[n.length-1];d.isDash===g.isDash&&(d.left=g.left-this.width,g.right=d.right+this.width);const v=this.width*this.nextRow;let E=0,L=n[E];for(let k=0;k1&&(L=n[++E]);const V=Math.abs(k-L.left),q=Math.abs(k-L.right),se=Math.min(V,q);this.image.data[v+k]=Math.max(0,Math.min(255,(L.isDash?se:-se)+o+128))}}addDash(n,o){const d=this.getKey(n,o);if(this.positions[d])return this.positions[d];const g=o==="round",v=g?7:0,E=2*v+1;if(this.nextRow+E>this.height)return Ct("LineAtlas out of space"),null;n.length===0&&n.push(1);let L=0;for(let q=0;q=Si.maxzoom||Si.visibility!=="none"&&(j1(_i,this.zoom,d),(k[Si.id]=Si.createBucket({index:L.bucketLayerIDs.length,layers:_i,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ti,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:d})).populate(Ki,q,this.tileID.canonical,this.tileTransform),L.bucketLayerIDs.push(_i.map(Li=>Li.id)))}}let he,_e,be,De;V.trim();const Ze={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},xt=ut(q.glyphDependencies,kt=>Object.keys(kt).map(Number));Object.keys(xt).length?g.send("getGlyphs",{uid:this.uid,stacks:xt},(kt,Ut)=>{he||(he=kt,_e=Ut,Tt.call(this))},void 0,!1,Ze):_e={};const Dt=Object.keys(q.iconDependencies);Dt.length?g.send("getImages",{icons:Dt,source:this.source,tileID:this.tileID,type:"icons"},(kt,Ut)=>{he||(he=kt,be=Ut,Tt.call(this))},void 0,!1,Ze):be={};const _t=Object.keys(q.patternDependencies);function Tt(){if(he)return v(he);if(_e&&be&&De){const kt=new CC(_e),Ut=new Ec(be,De);for(const ci in k){const ai=k[ci];ai instanceof Ld?(j1(ai.layers,this.zoom,d),n3(ai,_e,kt.positions,be,Ut.iconPositions,this.showCollisionBoxes,d,this.tileID.canonical,this.tileZoom,this.projection)):ai.hasPattern&&(ai instanceof Vs||ai instanceof Fp||ai instanceof Ce)&&(j1(ai.layers,this.zoom,d),ai.addFeatures(q,this.tileID.canonical,Ut.patternPositions,d,this.tileTransform))}this.status="done",v(null,{buckets:Ge(k).filter(ci=>!ci.isEmpty()),featureIndex:L,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:kt.image,lineAtlas:V,imageAtlas:Ut,glyphMap:this.returnDependencies?_e:null,iconMap:this.returnDependencies?be:null,glyphPositions:this.returnDependencies?kt.positions:null})}}_t.length?g.send("getImages",{icons:_t,source:this.source,tileID:this.tileID,type:"patterns"},(kt,Ut)=>{he||(he=kt,De=Ut,Tt.call(this))},void 0,!1,Ze):De={},Tt.call(this)}}function j1(s,n,o){const d=new qt(n);for(const g of s)g.recalculate(d,o)}class EC{constructor(n){this.entries={},this.scheduler=n}request(n,o,d,g){const v=this.entries[n]=this.entries[n]||{callbacks:[]};if(v.result){const[E,L]=v.result;return this.scheduler?this.scheduler.add(()=>{g(E,L)},o):g(E,L),()=>{}}return v.callbacks.push(g),v.cancel||(v.cancel=d((E,L)=>{v.result=[E,L];for(const k of v.callbacks)this.scheduler?this.scheduler.add(()=>{k(E,L)},o):k(E,L);setTimeout(()=>delete this.entries[n],3e3)})),()=>{v.result||(v.callbacks=v.callbacks.filter(E=>E!==g),v.callbacks.length||(v.cancel(),delete this.entries[n]))}}}function TC(s,n,o){const d=JSON.stringify(s.request);return s.data&&(this.deduped.entries[d]={result:[null,s.data]}),this.deduped.request(d,{type:"parseTile",isSymbolTile:s.isSymbolTile,zoom:s.tileZoom},g=>{const v=Cn(s.request,(E,L,k,V)=>{E?g(E):L&&g(null,{vectorTile:o?void 0:new f(new Fa(L)),rawData:L,cacheControl:k,expires:V})});return()=>{v.cancel(),g()}},n)}i.ARRAY_TYPE=Sa,i.AUTH_ERR_MSG=vi,i.Aabb=Ko,i.Actor=class{constructor(s,n,o){this.target=s,this.parent=n,this.mapId=o,this.callbacks={},this.cancelCallbacks={},Be(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=mi()?s:C,this.scheduler=new I3}send(s,n,o,d,g=!1,v){const E=Math.round(1e18*Math.random()).toString(36).substring(0,10);o&&(o.metadata=v,this.callbacks[E]=o);const L=wn(this.globalScope)?void 0:[];return this.target.postMessage({id:E,type:s,hasCallback:!!o,targetMapId:d,mustQueue:g,sourceMapId:this.mapId,data:bi(n,L)},L),{cancel:()=>{o&&delete this.callbacks[E],this.target.postMessage({id:E,type:"",targetMapId:d,sourceMapId:this.mapId})}}}receive(s){const n=s.data,o=n.id;if(o&&(!n.targetMapId||this.mapId===n.targetMapId))if(n.type===""){const d=this.cancelCallbacks[o];delete this.cancelCallbacks[o],d&&d.cancel()}else if(n.mustQueue||mi()){const d=this.callbacks[o];this.cancelCallbacks[o]=this.scheduler.add(()=>this.processTask(o,n),d&&d.metadata||{type:"message"})}else this.processTask(o,n)}processTask(s,n){if(n.type===""){const o=this.callbacks[s];delete this.callbacks[s],o&&(n.error?o(Hi(n.error)):o(null,Hi(n.data)))}else{const o=wn(this.globalScope)?void 0:[],d=n.hasCallback?(v,E)=>{delete this.cancelCallbacks[s],this.target.postMessage({id:s,type:"",sourceMapId:this.mapId,error:v?bi(v):null,data:bi(E,o)},o)}:v=>{},g=Hi(n.data);if(this.parent[n.type])this.parent[n.type](n.sourceMapId,g,d);else if(this.parent.getWorkerSource){const v=n.type.split(".");this.parent.getWorkerSource(n.sourceMapId,v[0],g.source)[v[1]](g,d)}else d(new Error(`Could not find function ${n.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=Fi,i.Color=fs,i.ColorMode=Pu,i.CullFaceMode=ru,i.DEMData=T0,i.DataConstantProperty=Jt,i.DedupedRequest=EC,i.DepthMode=tm,i.EXTENT=Zn,i.Elevation=class{isDataAvailableAtPoint(s){const n=this._source();if(this.isUsingMockSource()||!n||s.y<0||s.y>1)return!1;const o=n.getSource().maxzoom,d=1<1)return n;const g=d.getSource().maxzoom,v=1<{const v=this.getAtTileOffset(s,g.x,g.y),E=d.upVector(s.canonical,g.x,g.y);return pa(E,E,v*d.upVectorScale(s.canonical,n,o).metersToTile),E}}getForTilePoints(s,n,o,d){if(this.isUsingMockSource())return!1;const g=S0.create(this,s,d);return!!g&&(n.forEach(v=>{v[2]=this.exaggeration()*g.getElevationAt(v[0],v[1],o)}),!0)}getMinMaxForTile(s){if(this.isUsingMockSource())return null;const n=this.findDEMTileFor(s);if(!n||!n.dem)return null;const o=n.dem.tree,d=n.tileID,g=1<this._skuTokenExpiresAt}transformRequest(s,n){return this._transformRequestFn&&this._transformRequestFn(s,n)||{url:s}}normalizeStyleURL(s,n){if(!Wi(s))return s;const o=kr(s);return o.path=`/styles/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||n)}normalizeGlyphsURL(s,n){if(!Wi(s))return s;const o=kr(s);return o.path=`/fonts/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||n)}normalizeSourceURL(s,n,o,d){if(!Wi(s))return s;const g=kr(s);return g.path=`/v4/${g.authority}.json`,g.params.push("secure"),o&&g.params.push(`language=${o}`),d&&g.params.push(`worldview=${d}`),this._makeAPIURL(g,this._customAccessToken||n)}normalizeSpriteURL(s,n,o,d){const g=kr(s);return Wi(s)?(g.path=`/styles/v1${g.path}/sprite${n}${o}`,this._makeAPIURL(g,this._customAccessToken||d)):(g.path+=`${n}${o}`,Qn(g))}normalizeTileURL(s,n,o){if(this._isSkuTokenExpired()&&this._createSkuToken(),s&&!Wi(s))return s;const d=kr(s);d.path=d.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${n||o&&d.authority!=="raster"&&o===512?"@2x":""}${R.supported?".webp":"$1"}`),d.authority==="raster"?d.path=`/${N.RASTER_URL_PREFIX}${d.path}`:(d.path=d.path.replace(/^.+\/v4\//,"/"),d.path=`/${N.TILE_URL_VERSION}${d.path}`);const g=this._customAccessToken||function(v){for(const E of v){const L=E.match(/^access_token=(.*)$/);if(L)return L[1]}return null}(d.params)||N.ACCESS_TOKEN;return N.REQUIRE_ACCESS_TOKEN&&g&&this._skuToken&&d.params.push(`sku=${this._skuToken}`),this._makeAPIURL(d,g)}canonicalizeTileURL(s,n){const o=kr(s);if(!o.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!o.path.match(/\.[\w]+$/))return s;let d="mapbox://";o.path.match(/^\/raster\/v1\//)?d+=`raster/${o.path.replace(`/${N.RASTER_URL_PREFIX}/`,"")}`:d+=`tiles/${o.path.replace(`/${N.TILE_URL_VERSION}/`,"")}`;let g=o.params;return n&&(g=g.filter(v=>!v.match(/^access_token=/))),g.length&&(d+=`?${g.join("&")}`),d}canonicalizeTileset(s,n){const o=!!n&&Wi(n),d=[];for(const g of s.tiles||[])Ui(g)?d.push(this.canonicalizeTileURL(g,o)):d.push(g);return d}_makeAPIURL(s,n){const o="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",d=kr(N.API_URL);if(s.protocol=d.protocol,s.authority=d.authority,s.protocol==="http"){const g=s.params.indexOf("secure");g>=0&&s.params.splice(g,1)}if(d.path!=="/"&&(s.path=`${d.path}${s.path}`),!N.REQUIRE_ACCESS_TOKEN)return Qn(s);if(n=n||N.ACCESS_TOKEN,!this._silenceAuthErrors){if(!n)throw new Error(`An API access token is required to use Mapbox GL. ${o}`);if(n[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${o}`)}return s.params=s.params.filter(g=>g.indexOf("access_token")===-1),s.params.push(`access_token=${n||""}`),Qn(s)}},i.ResourceType=ii,i.SegmentVector=to,i.SourceCache=Rp,i.StencilMode=H1,i.StructArrayLayout1ui2=Xh,i.StructArrayLayout2f1f2i16=Io,i.StructArrayLayout2i4=Or,i.StructArrayLayout2ui4=$a,i.StructArrayLayout3f12=Ka,i.StructArrayLayout3ui6=_o,i.StructArrayLayout4i8=Qr,i.StructArrayLayout5f20=$h,i.Texture=Kg,i.Tile=Q1,i.Transitionable=Bi,i.Uniform1f=mA,i.Uniform1i=class extends oh{constructor(s){super(s),this.current=0}set(s,n,o){this.fetchUniformLocation(s,n)&&this.current!==o&&(this.current=o,this.gl.uniform1i(this.location,o))}},i.Uniform2f=class extends oh{constructor(s){super(s),this.current=[0,0]}set(s,n,o){this.fetchUniformLocation(s,n)&&(o[0]===this.current[0]&&o[1]===this.current[1]||(this.current=o,this.gl.uniform2f(this.location,o[0],o[1])))}},i.Uniform3f=class extends oh{constructor(s){super(s),this.current=[0,0,0]}set(s,n,o){this.fetchUniformLocation(s,n)&&(o[0]===this.current[0]&&o[1]===this.current[1]&&o[2]===this.current[2]||(this.current=o,this.gl.uniform3f(this.location,o[0],o[1],o[2])))}},i.Uniform4f=fp,i.UniformColor=cd,i.UniformMatrix2f=class extends oh{constructor(s){super(s),this.current=mp}set(s,n,o){if(this.fetchUniformLocation(s,n)){for(let d=0;d<4;d++)if(o[d]!==this.current[d]){this.current=o,this.gl.uniformMatrix2fv(this.location,!1,o);break}}}},i.UniformMatrix3f=class extends oh{constructor(s){super(s),this.current=Ry}set(s,n,o){if(this.fetchUniformLocation(s,n)){for(let d=0;d<9;d++)if(o[d]!==this.current[d]){this.current=o,this.gl.uniformMatrix3fv(this.location,!1,o);break}}}},i.UniformMatrix4f=class extends oh{constructor(s){super(s),this.current=Uy}set(s,n,o){if(this.fetchUniformLocation(s,n)){if(o[12]!==this.current[12]||o[0]!==this.current[0])return this.current=o,void this.gl.uniformMatrix4fv(this.location,!1,o);for(let d=1;d<16;d++)if(o[d]!==this.current[d]){this.current=o,this.gl.uniformMatrix4fv(this.location,!1,o);break}}}},i.UnwrappedTileID=Sn,i.ValidationError=An,i.VectorTileFeature=w,i.VectorTileWorkerSource=class extends yn{constructor(s,n,o,d,g){super(),this.actor=s,this.layerIndex=n,this.availableImages=o,this.loadVectorData=g||TC,this.loading={},this.loaded={},this.deduped=new EC(s.scheduler),this.isSpriteLoaded=d,this.scheduler=s.scheduler}loadTile(s,n){const o=s.uid,d=s&&s.request,g=d&&d.collectResourceTiming,v=this.loading[o]=new U3(s);v.abort=this.loadVectorData(s,(E,L)=>{const k=!this.loading[o];if(delete this.loading[o],k||E||!L)return v.status="done",k||(this.loaded[o]=v),n(E);const V=L.rawData,q={};L.expires&&(q.expires=L.expires),L.cacheControl&&(q.cacheControl=L.cacheControl),v.vectorTile=L.vectorTile||new f(new Fa(V));const se=()=>{v.parse(v.vectorTile,this.layerIndex,this.availableImages,this.actor,(he,_e)=>{if(he||!_e)return n(he);const be={};if(g){const De=pt(d);De.length>0&&(be.resourceTiming=JSON.parse(JSON.stringify(De)))}n(null,Ve({rawTileData:V.slice(0)},_e,q,be))})};this.isSpriteLoaded?se():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(se,{type:"parseTile",isSymbolTile:s.isSymbolTile,zoom:s.tileZoom}):se()}),this.loaded=this.loaded||{},this.loaded[o]=v})}reloadTile(s,n){const o=this.loaded,d=s.uid,g=this;if(o&&o[d]){const v=o[d];v.showCollisionBoxes=s.showCollisionBoxes,v.enableTerrain=!!s.enableTerrain,v.projection=s.projection,v.tileTransform=Up(s.tileID.canonical,s.projection);const E=(L,k)=>{const V=v.reloadCallback;V&&(delete v.reloadCallback,v.parse(v.vectorTile,g.layerIndex,this.availableImages,g.actor,V)),n(L,k)};v.status==="parsing"?v.reloadCallback=E:v.status==="done"&&(v.vectorTile?v.parse(v.vectorTile,this.layerIndex,this.availableImages,this.actor,E):E())}}abortTile(s,n){const o=s.uid,d=this.loading[o];d&&(d.abort&&d.abort(),delete this.loading[o]),n()}removeTile(s,n){const o=this.loaded,d=s.uid;o&&o[d]&&delete o[d],n()}},i.WritingMode=qo,i.add=Jh,i.addDynamicAttributes=B0,i.adjoint=function(s,n){var o=n[0],d=n[1],g=n[2],v=n[3],E=n[4],L=n[5],k=n[6],V=n[7],q=n[8];return s[0]=E*q-L*V,s[1]=g*V-d*q,s[2]=d*L-g*E,s[3]=L*k-v*q,s[4]=o*q-g*k,s[5]=g*v-o*L,s[6]=v*V-E*k,s[7]=d*k-o*V,s[8]=o*E-d*v,s},i.asyncAll=Ne,i.bezier=te,i.bindAll=Be,i.boundsAttributes=hC,i.bufferConvexPolygon=function(s,n){const o=[];for(let d=0;dNi&&(s.getActor().send("enforceCacheSizeLimit",ti),at=0)},i.calculateGlobeLabelMatrix=function(s,n){const{x:o,y:d}=s.point,g=qB(o,d,s.worldSize/s._pixelsPerMercatorPixel,0,0);return bA(g,g,U1(Fu(n)))},i.calculateGlobeMatrix=function(s){const{x:n,y:o}=s.point,{lng:d,lat:g}=s._center;return qB(n,o,s.worldSize,d,g)},i.calculateGlobeMercatorMatrix=function(s){const n=s.pixelsPerMeter,o=n/Xl(1,s.center.lat),d=ql(new Float64Array(16));return wp(d,d,[s.point.x,s.point.y,0]),BA(d,d,[o,o,n]),Float32Array.from(d)},i.circumferenceAtLatitude=Sf,i.clamp=ye,i.clearTileCache=function(s){if(!qi())return;const n=C.caches.delete(kn);s&&n.catch(s).then(()=>s())},i.clipLine=zB,i.clone=function(s){var n=new Sa(16);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],n[9]=s[9],n[10]=s[10],n[11]=s[11],n[12]=s[12],n[13]=s[13],n[14]=s[14],n[15]=s[15],n},i.clone$1=Wt,i.collisionCircleLayout=fa,i.config=N,i.conjugate=function(s,n){return s[0]=-n[0],s[1]=-n[1],s[2]=-n[2],s[3]=n[3],s},i.create=function(){var s=new Sa(16);return Sa!=Float32Array&&(s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0),s[0]=1,s[5]=1,s[10]=1,s[15]=1,s},i.create$1=hh,i.createExpression=Is,i.createLayout=_n,i.createStyleLayer=function(s){return s.type==="custom"?new E3(s):new S3[s.type](s)},i.cross=gd,i.degToRad=Ke,i.distance=function(s,n){return Math.hypot(n[0]-s[0],n[1]-s[1],n[2]-s[2])},i.div=function(s,n,o){return s[0]=n[0]/o[0],s[1]=n[1]/o[1],s[2]=n[2]/o[2],s},i.dot=Ma,i.earthRadius=Tf,i.ease=ce,i.easeCubicInOut=Ci,i.ecefToLatLng=function([s,n,o]){const d=Math.hypot(s,n,o),g=Math.atan2(s,o),v=.5*Math.PI-Math.acos(-n/d);return new Pr(Et(g),Et(v))},i.emitValidationErrors=Vt,i.endsWith=dt,i.enforceCacheSizeLimit=function(s){en(),yt&&yt.then(n=>{n.keys().then(o=>{for(let d=0;dv&&(d+=(s[g]-v)*(s[g]-v)),n[g]0){const be=180/d;wA(_e,_e,[be/V+1,0,0,0,be/q+1,0,-.5*be/se,.5*be/he,1])}return _e[2]=k,_e[5]=s.x,_e[8]=s.y,_e},i.getImage=Ot,i.getJSON=function(s,n){return on(Ve(s,{type:"json"}),n)},i.getLatitudinalLod=function(s){const n=80.051129;s=ye(s,-80.051129,n)/n*90;const o=Math.pow(Math.abs(Math.sin(Ke(s))),3);return Math.round(o*(qf.length-1))},i.getMapSessionAPI=ne,i.getPerformanceMeasurement=pt,i.getProjection=sC,i.getRTLTextPluginStatus=Ht,i.getReferrer=Xi,i.getTilePoint=function(s,{x:n,y:o},d=0){return new me(((n-d)*s.scale-s.x)*Zn,(o*s.scale-s.y)*Zn)},i.getTileVec3=function(s,n,o=0){return fd(((n.x-o)*s.scale-s.x)*Zn,(n.y*s.scale-s.y)*Zn,Mf(n.z,n.y))},i.getVideo=function(s,n){const o=C.document.createElement("video");o.muted=!0,o.onloadstart=function(){n(null,o)};for(let d=0;d{}}},i.globeCenterToScreenPoint=function(s){const n=[0,0,0],o=ql(new Float64Array(16));return bA(o,s.pixelMatrix,s.globeMatrix),Qs(n,n,o),new me(n[0],n[1])},i.globeDenormalizeECEF=U1,i.globeECEFOrigin=function(s,n){const o=[0,0,0];return Qs(o,o,Vg(Fu(n.canonical))),Qs(o,o,s),o},i.globeNormalizeECEF=Vg,i.globePixelsToTileUnits=function(s,n){return Zn/(512*Math.pow(2,s))*y0(Fu(n))},i.globePoleMatrixForTile=function(s,n,o){const d=ql(new Float64Array(16)),g=(n/(1<0;return d===0&&!g&&!E&&v},i.identity=ql,i.identity$1=Bg,i.invert=yg,i.isFullscreen=function(){return!!C.document.fullscreenElement||!!C.document.webkitFullscreenElement},i.isLngLatBehindGlobe=R1,i.isMapAuthenticated=function(s){return de.has(s)},i.isMapboxURL=Wi,i.isSafariWithAntialiasingBug=function(s){const n=s.navigator?s.navigator.userAgent:null;return!!wn(s)&&n&&(n.match("Version/15.4")||n.match("Version/15.5")||n.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},i.latFromMercatorY=Fo,i.latLngToECEF=Ng,i.len=Zy,i.length=pd,i.length$1=function(s){return Math.hypot(s[0],s[1],s[2],s[3])},i.lngFromMercatorX=bl,i.loadVectorTile=TC,i.makeRequest=on,i.mapValue=function(s,n,o,d,g){return ye((s-n)/(o-n)*(g-d)+d,d,g)},i.mercatorScale=If,i.mercatorXfromLng=vc,i.mercatorYfromLat=ch,i.mercatorZfromAltitude=Xl,i.mul=u1,i.mul$1=$y,i.multiply=bA,i.multiply$1=wA,i.multiply$2=wg,i.nextPowerOfTwo=et,i.normalize=so,i.normalize$1=Mu,i.normalize$2=Pf,i.number=gr,i.ortho=function(s,n,o,d,g,v,E){var L=1/(n-o),k=1/(d-g),V=1/(v-E);return s[0]=-2*L,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*k,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*V,s[11]=0,s[12]=(n+o)*L,s[13]=(g+d)*k,s[14]=(E+v)*V,s[15]=1,s},i.pbf=Fa,i.perspective=function(s,n,o,d,g){var v,E=1/Math.tan(n/2);return s[0]=E/o,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=E,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,g!=null&&g!==1/0?(s[10]=(g+d)*(v=1/(d-g)),s[14]=2*g*d*v):(s[10]=-1,s[14]=-2*d),s},i.pick=function(s,n){const o={};for(let d=0;d0&&o[0]<=s.width&&o[1]>0&&o[1]<=s.height&&!R1(s,new Pr(s.center.lat,90)),d[0]>0&&d[0]<=s.width&&d[1]>0&&d[1]<=s.height&&!R1(s,new Pr(s.center.lat,-90))]},i.polygonContainsPoint=vA,i.polygonIntersectsBox=Ad,i.polygonIntersectsPolygon=Vy,i.polygonizeBounds=function(s,n,o=0,d=!0){const g=new me(o,o),v=s.sub(g),E=n.add(g),L=[v,new me(E.x,v.y),E,new me(v.x,E.y)];return d&&L.push(v.clone()),L},i.posAttributes=Og,i.postMapLoadEvent=wt,i.postPerformanceEvent=j,i.postTurnstileEvent=Ue,i.potpack=Kf,i.prevPowerOfTwo=function(s){return s<=1?1:Math.pow(2,Math.floor(Math.log(s)/Math.LN2))},i.radToDeg=Et,i.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],i.registerForPluginStateChange=function(s){return s({pluginStatus:At,pluginURL:ht}),It.on("pluginStateChange",s),s},i.removeAuthState=function(s){de.delete(s)},i.renderColorRamp=Sg,i.resample=Oy,i.rotateX=xg,i.rotateX$1=uh,i.rotateY=Lf,i.rotateY$1=Cg,i.rotateZ=function(s,n,o){var d=Math.sin(o),g=Math.cos(o),v=n[0],E=n[1],L=n[2],k=n[3],V=n[4],q=n[5],se=n[6],he=n[7];return n!==s&&(s[8]=n[8],s[9]=n[9],s[10]=n[10],s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[0]=v*g+V*d,s[1]=E*g+q*d,s[2]=L*g+se*d,s[3]=k*g+he*d,s[4]=V*g-v*d,s[5]=q*g-E*d,s[6]=se*g-L*d,s[7]=he*g-k*d,s},i.rotateZ$1=function(s,n,o){o*=.5;var d=n[0],g=n[1],v=n[2],E=n[3],L=Math.sin(o),k=Math.cos(o);return s[0]=d*k+g*L,s[1]=g*k-d*L,s[2]=v*k+E*L,s[3]=E*k-v*L,s},i.scale=BA,i.scale$1=Df,i.scale$2=pa,i.scaleAndAdd=eu,i.set=function(s,n,o,d){return s[0]=n,s[1]=o,s[2]=d,s},i.setCacheLimits=function(s,n){ti=s,Ni=n},i.setColumn=function(s,n,o){s[4*n+0]=o[0],s[4*n+1]=o[1],s[4*n+2]=o[2],s[4*n+3]=o[3]},i.setRTLTextPlugin=function(s,n,o=!1){if(At===nt||At===lt||At===Xe)throw new Error("setRTLTextPlugin cannot be called multiple times.");ht=wi.resolveURL(s),At=nt,Ye=n,Pt(),o||hi()},i.smoothstep=xe,i.spec=Yt,i.squaredLength=function(s){var n=s[0],o=s[1],d=s[2];return n*n+o*o+d*d},i.storeAuthState=function(s,n){n?de.add(s):de.delete(s)},i.sub=wc,i.subtract=vg,i.symbolSize=Ya,i.tileAABB=function(s,n,o,d,g,v,E,L,k){if(k.name==="globe")return c3(s,n,new Fi(o,d,g));const V=Up({z:o,x:d,y:g},k);return new Ko([(v+V.x/V.scale)*n,n*(V.y/V.scale),E],[(v+V.x2/V.scale)*n,n*(V.y2/V.scale),L])},i.tileCornersToBounds=_0,i.tileTransform=Up,i.transformMat3=function(s,n,o){var d=n[0],g=n[1],v=n[2];return s[0]=d*o[0]+g*o[3]+v*o[6],s[1]=d*o[1]+g*o[4]+v*o[7],s[2]=d*o[2]+g*o[5]+v*o[8],s},i.transformMat4=Qs,i.transformMat4$1=TA,i.transformQuat=bg,i.transitionTileAABBinECEF=$B,i.translate=wp,i.transpose=function(s,n){if(s===n){var o=n[1],d=n[2],g=n[5];s[1]=n[3],s[2]=n[6],s[3]=o,s[5]=n[7],s[6]=d,s[7]=g}else s[0]=n[0],s[1]=n[3],s[2]=n[6],s[3]=n[1],s[4]=n[4],s[5]=n[7],s[6]=n[2],s[7]=n[5],s[8]=n[8];return s},i.triggerPluginCompletionEvent=Bt,i.uniqueId=Ie,i.updateGlobeVertexNormal=function(s,n,o,d,g){const v=5*n+2;s.float32[v+0]=o,s.float32[v+1]=d,s.float32[v+2]=g},i.validateCustomStyleLayer=function(s){const n=[],o=s.id;return o===void 0&&n.push({message:`layers.${o}: missing required property "id"`}),s.render===void 0&&n.push({message:`layers.${o}: missing required method "render"`}),s.renderingMode&&s.renderingMode!=="2d"&&s.renderingMode!=="3d"&&n.push({message:`layers.${o}: property "renderingMode" must be either "2d" or "3d"`}),n},i.validateFilter=s=>gt(us(s)),i.validateFog=s=>gt(ue(s)),i.validateLayer=s=>gt(h(s)),i.validateLight=s=>gt(K(s)),i.validateSource=s=>gt(F(s)),i.validateStyle=We,i.validateTerrain=s=>gt(oe(s)),i.values=Ge,i.vectorTile=Dp,i.version=D,i.warnOnce=Ct,i.window=C,i.wrap=ze}),p(["./shared"],function(i){function C(ot){if(typeof ot=="number"||typeof ot=="boolean"||typeof ot=="string"||ot==null)return JSON.stringify(ot);if(Array.isArray(ot)){let Ue="[";for(const ct of ot)Ue+=`${C(ct)},`;return`${Ue}]`}let Ee="{";for(const Ue of Object.keys(ot).sort())Ee+=`${Ue}:${C(ot[Ue])},`;return`${Ee}}`}function D(ot){let Ee="";for(const Ue of i.refProperties)Ee+=`/${C(ot[Ue])}`;return Ee}class U{constructor(Ee){this.keyCache={},Ee&&this.replace(Ee)}replace(Ee){this._layerConfigs={},this._layers={},this.update(Ee,[])}update(Ee,Ue){for(const wt of Ee)this._layerConfigs[wt.id]=wt,(this._layers[wt.id]=i.createStyleLayer(wt)).compileFilter(),this.keyCache[wt.id]&&delete this.keyCache[wt.id];for(const wt of Ue)delete this.keyCache[wt],delete this._layerConfigs[wt],delete this._layers[wt];this.familiesBySource={};const ct=function(wt,X){const j={};for(let ne=0;nethis._layers[tt.id]),j=X[0];if(j.visibility==="none")continue;const ie=j.source||"";let ne=this.familiesBySource[ie];ne||(ne=this.familiesBySource[ie]={});const de=j.sourceLayer||"_geojsonTileLayer";let Re=ne[de];Re||(Re=ne[de]=[]),Re.push(X)}}}class N{loadTile(Ee,Ue){const{uid:ct,encoding:wt,rawImageData:X,padding:j,buildQuadTree:ie}=Ee,ne=i.window.ImageBitmap&&X instanceof i.window.ImageBitmap?this.getImageData(X,j):X;Ue(null,new i.DEMData(ct,ne,wt,j<1,ie))}getImageData(Ee,Ue){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 ct=this.offscreenCanvasContext.getImageData(-Ue,-Ue,Ee.width+2*Ue,Ee.height+2*Ue);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),ct}}var R=function ot(Ee,Ue){var ct,wt=Ee&&Ee.type;if(wt==="FeatureCollection")for(ct=0;ct=Math.abs(ie)?Ue-ne+ie:ie-ne+Ue,Ue=ne}Ue+ct>=0!=!!Ee&&ot.reverse()}const Y=i.VectorTileFeature.prototype.toGeoJSON;class B{constructor(Ee){this._feature=Ee,this.extent=i.EXTENT,this.type=Ee.type,this.properties=Ee.tags,"id"in Ee&&!isNaN(Ee.id)&&(this.id=parseInt(Ee.id,10))}loadGeometry(){if(this._feature.type===1){const Ee=[];for(const Ue of this._feature.geometry)Ee.push([new i.pointGeometry(Ue[0],Ue[1])]);return Ee}{const Ee=[];for(const Ue of this._feature.geometry){const ct=[];for(const wt of Ue)ct.push(new i.pointGeometry(wt[0],wt[1]));Ee.push(ct)}return Ee}}toGeoJSON(Ee,Ue,ct){return Y.call(this,Ee,Ue,ct)}}class ae{constructor(Ee){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=Ee.length,this._features=Ee}feature(Ee){return new B(this._features[Ee])}}var le={exports:{}},Ae=i.pointGeometry,we=i.vectorTile.VectorTileFeature,me=Pe;function Pe(ot,Ee){this.options=Ee||{},this.features=ot,this.length=ot.length}function it(ot,Ee){this.id=typeof ot.id=="number"?ot.id:void 0,this.type=ot.type,this.rawGeometry=ot.type===1?[ot.geometry]:ot.geometry,this.properties=ot.tags,this.extent=Ee||4096}Pe.prototype.feature=function(ot){return new it(this.features[ot],this.options.extent)},it.prototype.loadGeometry=function(){var ot=this.rawGeometry;this.geometry=[];for(var Ee=0;Ee>31}function xe(ot,Ee){for(var Ue=ot.loadGeometry(),ct=ot.type,wt=0,X=0,j=Ue.length,ie=0;ie>1;Ge(ot,Ee,j,ct,wt,X%2),Ne(ot,Ee,Ue,ct,j-1,X+1),Ne(ot,Ee,Ue,j+1,wt,X+1)}function Ge(ot,Ee,Ue,ct,wt,X){for(;wt>ct;){if(wt-ct>600){const de=wt-ct+1,Re=Ue-ct+1,tt=Math.log(de),He=.5*Math.exp(2*tt/3),Je=.5*Math.sqrt(tt*He*(de-He)/de)*(Re-de/2<0?-1:1);Ge(ot,Ee,Ue,Math.max(ct,Math.floor(Ue-Re*He/de+Je)),Math.min(wt,Math.floor(Ue+(de-Re)*He/de+Je)),X)}const j=Ee[2*Ue+X];let ie=ct,ne=wt;for(Ve(ot,Ee,ct,Ue),Ee[2*wt+X]>j&&Ve(ot,Ee,ct,wt);iej;)ne--}Ee[2*ct+X]===j?Ve(ot,Ee,ct,ne):(ne++,Ve(ot,Ee,ne,wt)),ne<=Ue&&(ct=ne+1),Ue<=ne&&(wt=ne-1)}}function Ve(ot,Ee,Ue,ct){Le(ot,Ue,ct),Le(Ee,2*Ue,2*ct),Le(Ee,2*Ue+1,2*ct+1)}function Le(ot,Ee,Ue){const ct=ot[Ee];ot[Ee]=ot[Ue],ot[Ue]=ct}function Ie(ot,Ee,Ue,ct){const wt=ot-Ue,X=Ee-ct;return wt*wt+X*X}le.exports=Et,le.exports.fromVectorTileJs=Et,le.exports.fromGeojsonVt=function(ot,Ee){Ee=Ee||{};var Ue={};for(var ct in ot)Ue[ct]=new Ke(ot[ct].features,Ee),Ue[ct].name=ct,Ue[ct].version=Ee.version,Ue[ct].extent=Ee.extent;return Et({layers:Ue})},le.exports.GeoJSONWrapper=Ke;const qe=ot=>ot[0],et=ot=>ot[1];class vt{constructor(Ee,Ue=qe,ct=et,wt=64,X=Float64Array){this.nodeSize=wt,this.points=Ee;const j=Ee.length<65536?Uint16Array:Uint32Array,ie=this.ids=new j(Ee.length),ne=this.coords=new X(2*Ee.length);for(let de=0;de=ie&&pt<=de&&Lt>=ne&&Lt<=Re&&Je.push(X[Yi]);continue}const wi=Math.floor((ki+Gt)/2);pt=j[2*wi],Lt=j[2*wi+1],pt>=ie&&pt<=de&&Lt>=ne&&Lt<=Re&&Je.push(X[wi]);const Oi=(jt+1)%2;(jt===0?ie<=pt:ne<=Lt)&&(He.push(ki),He.push(wi-1),He.push(Oi)),(jt===0?de>=pt:Re>=Lt)&&(He.push(wi+1),He.push(Gt),He.push(Oi))}return Je}(this.ids,this.coords,Ee,Ue,ct,wt,this.nodeSize)}within(Ee,Ue,ct){return function(wt,X,j,ie,ne,de){const Re=[0,wt.length-1,0],tt=[],He=ne*ne;for(;Re.length;){const Je=Re.pop(),pt=Re.pop(),Lt=Re.pop();if(pt-Lt<=de){for(let Oi=Lt;Oi<=pt;Oi++)Ie(X[2*Oi],X[2*Oi+1],j,ie)<=He&&tt.push(wt[Oi]);continue}const jt=Math.floor((Lt+pt)/2),Gt=X[2*jt],ki=X[2*jt+1];Ie(Gt,ki,j,ie)<=He&&tt.push(wt[jt]);const wi=(Je+1)%2;(Je===0?j-ne<=Gt:ie-ne<=ki)&&(Re.push(Lt),Re.push(jt-1),Re.push(wi)),(Je===0?j+ne>=Gt:ie+ne>=ki)&&(Re.push(jt+1),Re.push(pt),Re.push(wi))}return tt}(this.ids,this.coords,Ee,Ue,ct,this.nodeSize)}}const Be={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:ot=>ot},dt=Math.fround||(ut=new Float32Array(1),ot=>(ut[0]=+ot,ut[0]));var ut;class Qt{constructor(Ee){this.options=Gi(Object.create(Be),Ee),this.trees=new Array(this.options.maxZoom+1)}load(Ee){const{log:Ue,minZoom:ct,maxZoom:wt,nodeSize:X}=this.options;Ue&&console.time("total time");const j=`prepare ${Ee.length} points`;Ue&&console.time(j),this.points=Ee;let ie=[];for(let ne=0;ne=ct;ne--){const de=+Date.now();ie=this._cluster(ie,ne),this.trees[ne]=new vt(ie,wn,Qi,X,Float32Array),Ue&&console.log("z%d: %d clusters in %dms",ne,ie.length,+Date.now()-de)}return Ue&&console.timeEnd("total time"),this}getClusters(Ee,Ue){let ct=((Ee[0]+180)%360+360)%360-180;const wt=Math.max(-90,Math.min(90,Ee[1]));let X=Ee[2]===180?180:((Ee[2]+180)%360+360)%360-180;const j=Math.max(-90,Math.min(90,Ee[3]));if(Ee[2]-Ee[0]>=360)ct=-180,X=180;else if(ct>X){const Re=this.getClusters([ct,wt,180,j],Ue),tt=this.getClusters([-180,wt,X,j],Ue);return Re.concat(tt)}const ie=this.trees[this._limitZoom(Ue)],ne=ie.range(Xt(ct),mi(j),Xt(X),mi(wt)),de=[];for(const Re of ne){const tt=ie.points[Re];de.push(tt.numPoints?Ct(tt):this.points[tt.index])}return de}getChildren(Ee){const Ue=this._getOriginId(Ee),ct=this._getOriginZoom(Ee),wt="No cluster with the specified id.",X=this.trees[ct];if(!X)throw new Error(wt);const j=X.points[Ue];if(!j)throw new Error(wt);const ie=this.options.radius/(this.options.extent*Math.pow(2,ct-1)),ne=X.within(j.x,j.y,ie),de=[];for(const Re of ne){const tt=X.points[Re];tt.parentId===Ee&&de.push(tt.numPoints?Ct(tt):this.points[tt.index])}if(de.length===0)throw new Error(wt);return de}getLeaves(Ee,Ue,ct){const wt=[];return this._appendLeaves(wt,Ee,Ue=Ue||10,ct=ct||0,0),wt}getTile(Ee,Ue,ct){const wt=this.trees[this._limitZoom(Ee)],X=Math.pow(2,Ee),{extent:j,radius:ie}=this.options,ne=ie/j,de=(ct-ne)/X,Re=(ct+1+ne)/X,tt={features:[]};return this._addTileFeatures(wt.range((Ue-ne)/X,de,(Ue+1+ne)/X,Re),wt.points,Ue,ct,X,tt),Ue===0&&this._addTileFeatures(wt.range(1-ne/X,de,1,Re),wt.points,X,ct,X,tt),Ue===X-1&&this._addTileFeatures(wt.range(0,de,ne/X,Re),wt.points,-1,ct,X,tt),tt.features.length?tt:null}getClusterExpansionZoom(Ee){let Ue=this._getOriginZoom(Ee)-1;for(;Ue<=this.options.maxZoom;){const ct=this.getChildren(Ee);if(Ue++,ct.length!==1)break;Ee=ct[0].properties.cluster_id}return Ue}_appendLeaves(Ee,Ue,ct,wt,X){const j=this.getChildren(Ue);for(const ie of j){const ne=ie.properties;if(ne&&ne.cluster?X+ne.point_count<=wt?X+=ne.point_count:X=this._appendLeaves(Ee,ne.cluster_id,ct,wt,X):XUe&&(pt+=jt.numPoints||1)}if(pt>Je&&pt>=ie){let Lt=Re.x*Je,jt=Re.y*Je,Gt=j&&Je>1?this._map(Re,!0):null;const ki=(de<<5)+(Ue+1)+this.points.length;for(const wi of He){const Oi=tt.points[wi];if(Oi.zoom<=Ue)continue;Oi.zoom=Ue;const Yi=Oi.numPoints||1;Lt+=Oi.x*Yi,jt+=Oi.y*Yi,Oi.parentId=ki,j&&(Gt||(Gt=this._map(Re,!0)),j(Gt,this._map(Oi)))}Re.parentId=ki,ct.push(Wt(Lt/pt,jt/pt,ki,pt,Gt))}else if(ct.push(Re),pt>1)for(const Lt of He){const jt=tt.points[Lt];jt.zoom<=Ue||(jt.zoom=Ue,ct.push(jt))}}return ct}_getOriginId(Ee){return Ee-this.points.length>>5}_getOriginZoom(Ee){return(Ee-this.points.length)%32}_map(Ee,Ue){if(Ee.numPoints)return Ue?Gi({},Ee.properties):Ee.properties;const ct=this.points[Ee.index].properties,wt=this.options.map(ct);return Ue&&wt===ct?Gi({},wt):wt}}function Wt(ot,Ee,Ue,ct,wt){return{x:dt(ot),y:dt(Ee),zoom:1/0,id:Ue,parentId:-1,numPoints:ct,properties:wt}}function Nt(ot,Ee){const[Ue,ct]=ot.geometry.coordinates;return{x:dt(Xt(Ue)),y:dt(mi(ct)),zoom:1/0,index:Ee,parentId:-1}}function Ct(ot){return{type:"Feature",id:ot.id,properties:Ft(ot),geometry:{type:"Point",coordinates:[(Ee=ot.x,360*(Ee-.5)),fi(ot.y)]}};var Ee}function Ft(ot){const Ee=ot.numPoints,Ue=Ee>=1e4?`${Math.round(Ee/1e3)}k`:Ee>=1e3?Math.round(Ee/100)/10+"k":Ee;return Gi(Gi({},ot.properties),{cluster:!0,cluster_id:ot.id,point_count:Ee,point_count_abbreviated:Ue})}function Xt(ot){return ot/360+.5}function mi(ot){const Ee=Math.sin(ot*Math.PI/180),Ue=.5-.25*Math.log((1+Ee)/(1-Ee))/Math.PI;return Ue<0?0:Ue>1?1:Ue}function fi(ot){const Ee=(180-360*ot)*Math.PI/180;return 360*Math.atan(Math.exp(Ee))/Math.PI-90}function Gi(ot,Ee){for(const Ue in Ee)ot[Ue]=Ee[Ue];return ot}function wn(ot){return ot.x}function Qi(ot){return ot.y}function Gn(ot,Ee,Ue,ct){for(var wt,X=ct,j=Ue-Ee>>1,ie=Ue-Ee,ne=ot[Ee],de=ot[Ee+1],Re=ot[Ue],tt=ot[Ue+1],He=Ee+3;HeX)wt=He,X=Je;else if(Je===X){var pt=Math.abs(He-j);ptct&&(wt-Ee>3&&Gn(ot,Ee,wt,ct),ot[wt+2]=X,Ue-wt>3&&Gn(ot,wt,Ue,ct))}function kn(ot,Ee,Ue,ct,wt,X){var j=wt-Ue,ie=X-ct;if(j!==0||ie!==0){var ne=((ot-Ue)*j+(Ee-ct)*ie)/(j*j+ie*ie);ne>1?(Ue=wt,ct=X):ne>0&&(Ue+=j*ne,ct+=ie*ne)}return(j=ot-Ue)*j+(ie=Ee-ct)*ie}function yt(ot,Ee,Ue,ct){var wt={id:ot===void 0?null:ot,type:Ee,geometry:Ue,tags:ct,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(X){var j=X.geometry,ie=X.type;if(ie==="Point"||ie==="MultiPoint"||ie==="LineString")st(X,j);else if(ie==="Polygon"||ie==="MultiLineString")for(var ne=0;ne0&&(j+=ct?(wt*de-ne*X)/2:Math.sqrt(Math.pow(ne-wt,2)+Math.pow(de-X,2))),wt=ne,X=de}var Re=Ee.length-3;Ee[2]=1,Gn(Ee,0,Re,Ue),Ee[Re+2]=1,Ee.size=Math.abs(j),Ee.start=0,Ee.end=Ee.size}function en(ot,Ee,Ue,ct){for(var wt=0;wt1?1:Ue}function ii(ot,Ee,Ue,ct,wt,X,j,ie){if(ct/=Ee,X>=(Ue/=Ee)&&j=ct)return null;for(var ne=[],de=0;de=Ue&&pt=ct)){var Lt=[];if(He==="Point"||He==="MultiPoint")hn(tt,Lt,Ue,ct,wt);else if(He==="LineString")Xi(tt,Lt,Ue,ct,wt,!1,ie.lineMetrics);else if(He==="MultiLineString")Cn(tt,Lt,Ue,ct,wt,!1);else if(He==="Polygon")Cn(tt,Lt,Ue,ct,wt,!0);else if(He==="MultiPolygon")for(var jt=0;jt=Ue&&j<=ct&&(Ee.push(ot[X]),Ee.push(ot[X+1]),Ee.push(ot[X+2]))}}function Xi(ot,Ee,Ue,ct,wt,X,j){for(var ie,ne,de=on(ot),Re=wt===0?nr:Ii,tt=ot.start,He=0;HeUe&&(ne=Re(de,Je,pt,jt,Gt,Ue),j&&(de.start=tt+ie*ne)):ki>ct?wi=Ue&&(ne=Re(de,Je,pt,jt,Gt,Ue),Oi=!0),wi>ct&&ki<=ct&&(ne=Re(de,Je,pt,jt,Gt,ct),Oi=!0),!X&&Oi&&(j&&(de.end=tt+ie*ne),Ee.push(de),de=on(ot)),j&&(tt+=ie)}var Yi=ot.length-3;Je=ot[Yi],pt=ot[Yi+1],Lt=ot[Yi+2],(ki=wt===0?Je:pt)>=Ue&&ki<=ct&&Tn(de,Je,pt,Lt),Yi=de.length-3,X&&Yi>=3&&(de[Yi]!==de[0]||de[Yi+1]!==de[1])&&Tn(de,de[0],de[1],de[2]),de.length&&Ee.push(de)}function on(ot){var Ee=[];return Ee.size=ot.size,Ee.start=ot.start,Ee.end=ot.end,Ee}function Cn(ot,Ee,Ue,ct,wt,X){for(var j=0;jj.maxX&&(j.maxX=Re),tt>j.maxY&&(j.maxY=tt)}return j}function Pn(ot,Ee,Ue,ct){var wt=Ee.geometry,X=Ee.type,j=[];if(X==="Point"||X==="MultiPoint")for(var ie=0;ie0&&Ee.size<(wt?j:ct))Ue.numPoints+=Ee.length/3;else{for(var ie=[],ne=0;nej)&&(Ue.numSimplified++,ie.push(Ee[ne]),ie.push(Ee[ne+1])),Ue.numPoints++;wt&&function(de,Re){for(var tt=0,He=0,Je=de.length,pt=Je-2;He0===Re)for(He=0,Je=de.length;He24)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 ct=function(wt,X){var j=[];if(wt.type==="FeatureCollection")for(var ie=0;ie1&&console.time("creation"),He=this.tiles[tt]=Ui(ot,Ee,Ue,ct,ne),this.tileCoords.push({z:Ee,x:Ue,y:ct}),de)){de>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Ee,Ue,ct,He.numFeatures,He.numPoints,He.numSimplified),console.timeEnd("creation"));var Je="z"+Ee;this.stats[Je]=(this.stats[Je]||0)+1,this.total++}if(He.source=ot,wt){if(Ee===ne.maxZoom||Ee===wt)continue;var pt=1<1&&console.time("clipping");var Lt,jt,Gt,ki,wi,Oi,Yi=.5*ne.buffer/ne.extent,tn=.5-Yi,rr=.5+Yi,yn=1+Yi;Lt=jt=Gt=ki=null,wi=ii(ot,Re,Ue-Yi,Ue+rr,0,He.minX,He.maxX,ne),Oi=ii(ot,Re,Ue+tn,Ue+yn,0,He.minX,He.maxX,ne),ot=null,wi&&(Lt=ii(wi,Re,ct-Yi,ct+rr,1,He.minY,He.maxY,ne),jt=ii(wi,Re,ct+tn,ct+yn,1,He.minY,He.maxY,ne),wi=null),Oi&&(Gt=ii(Oi,Re,ct-Yi,ct+rr,1,He.minY,He.maxY,ne),ki=ii(Oi,Re,ct+tn,ct+yn,1,He.minY,He.maxY,ne),Oi=null),de>1&&console.timeEnd("clipping"),ie.push(Lt||[],Ee+1,2*Ue,2*ct),ie.push(jt||[],Ee+1,2*Ue,2*ct+1),ie.push(Gt||[],Ee+1,2*Ue+1,2*ct),ie.push(ki||[],Ee+1,2*Ue+1,2*ct+1)}}},Hr.prototype.getTile=function(ot,Ee,Ue){var ct=this.options,wt=ct.extent,X=ct.debug;if(ot<0||ot>24)return null;var j=1<1&&console.log("drilling down to z%d-%d-%d",ot,Ee,Ue);for(var ne,de=ot,Re=Ee,tt=Ue;!ne&&de>0;)de--,Re=Math.floor(Re/2),tt=Math.floor(tt/2),ne=this.tiles[fr(de,Re,tt)];return ne&&ne.source?(X>1&&console.log("found parent tile z%d-%d-%d",de,Re,tt),X>1&&console.time("drilling down"),this.splitTile(ne.source,de,Re,tt,ot,Ee,Ue),X>1&&console.timeEnd("drilling down"),this.tiles[ie]?vi(this.tiles[ie],wt):null):null};class Qn extends i.VectorTileWorkerSource{constructor(Ee,Ue,ct,wt,X){super(Ee,Ue,ct,wt,kr),X&&(this.loadGeoJSON=X)}loadData(Ee,Ue){const ct=Ee&&Ee.request,wt=ct&&ct.collectResourceTiming;this.loadGeoJSON(Ee,(X,j)=>{if(X||!j)return Ue(X);if(typeof j!="object")return Ue(new Error(`Input data given to '${Ee.source}' is not a valid GeoJSON object.`));{R(j,!0);try{if(Ee.filter){const ne=i.createExpression(Ee.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(ne.result==="error")throw new Error(ne.value.map(Re=>`${Re.key}: ${Re.message}`).join(", "));j={type:"FeatureCollection",features:j.features.filter(Re=>ne.value.evaluate({zoom:0},Re))}}this._geoJSONIndex=Ee.cluster?new Qt(function({superclusterOptions:ne,clusterProperties:de}){if(!de||!ne)return ne;const Re={},tt={},He={accumulated:null,zoom:0},Je={properties:null},pt=Object.keys(de);for(const Lt of pt){const[jt,Gt]=de[Lt],ki=i.createExpression(Gt),wi=i.createExpression(typeof jt=="string"?[jt,["accumulated"],["get",Lt]]:jt);Re[Lt]=ki.value,tt[Lt]=wi.value}return ne.map=Lt=>{Je.properties=Lt;const jt={};for(const Gt of pt)jt[Gt]=Re[Gt].evaluate(He,Je);return jt},ne.reduce=(Lt,jt)=>{Je.properties=jt;for(const Gt of pt)He.accumulated=Lt[Gt],Lt[Gt]=tt[Gt].evaluate(He,Je)},ne}(Ee)).load(j.features):function(ne,de){return new Hr(ne,de)}(j,Ee.geojsonVtOptions)}catch(ne){return Ue(ne)}this.loaded={};const ie={};if(wt){const ne=i.getPerformanceMeasurement(ct);ne&&(ie.resourceTiming={},ie.resourceTiming[Ee.source]=JSON.parse(JSON.stringify(ne)))}Ue(null,ie)}})}reloadTile(Ee,Ue){const ct=this.loaded;return ct&&ct[Ee.uid]?super.reloadTile(Ee,Ue):this.loadTile(Ee,Ue)}loadGeoJSON(Ee,Ue){if(Ee.request)i.getJSON(Ee.request,Ue);else{if(typeof Ee.data!="string")return Ue(new Error(`Input data given to '${Ee.source}' is not a valid GeoJSON object.`));try{return Ue(null,JSON.parse(Ee.data))}catch{return Ue(new Error(`Input data given to '${Ee.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(Ee,Ue){try{Ue(null,this._geoJSONIndex.getClusterExpansionZoom(Ee.clusterId))}catch(ct){Ue(ct)}}getClusterChildren(Ee,Ue){try{Ue(null,this._geoJSONIndex.getChildren(Ee.clusterId))}catch(ct){Ue(ct)}}getClusterLeaves(Ee,Ue){try{Ue(null,this._geoJSONIndex.getLeaves(Ee.clusterId,Ee.limit,Ee.offset))}catch(ct){Ue(ct)}}}class zs{constructor(Ee){this.self=Ee,this.actor=new i.Actor(Ee,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:Qn},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(Ue,ct)=>{if(this.workerSourceTypes[Ue])throw new Error(`Worker source with name "${Ue}" already registered.`);this.workerSourceTypes[Ue]=ct},this.self.registerRTLTextPlugin=Ue=>{if(i.plugin.isParsed())throw new Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=Ue.applyArabicShaping,i.plugin.processBidirectionalText=Ue.processBidirectionalText,i.plugin.processStyledBidirectionalText=Ue.processStyledBidirectionalText}}clearCaches(Ee,Ue,ct){delete this.layerIndexes[Ee],delete this.availableImages[Ee],delete this.workerSources[Ee],delete this.demWorkerSources[Ee],ct()}checkIfReady(Ee,Ue,ct){ct()}setReferrer(Ee,Ue){this.referrer=Ue}spriteLoaded(Ee,Ue){this.isSpriteLoaded[Ee]=Ue;for(const ct in this.workerSources[Ee]){const wt=this.workerSources[Ee][ct];for(const X in wt)wt[X]instanceof i.VectorTileWorkerSource&&(wt[X].isSpriteLoaded=Ue,wt[X].fire(new i.Event("isSpriteLoaded")))}}setImages(Ee,Ue,ct){this.availableImages[Ee]=Ue;for(const wt in this.workerSources[Ee]){const X=this.workerSources[Ee][wt];for(const j in X)X[j].availableImages=Ue}ct()}enableTerrain(Ee,Ue,ct){this.terrain=Ue,ct()}setProjection(Ee,Ue){this.projections[Ee]=i.getProjection(Ue)}setLayers(Ee,Ue,ct){this.getLayerIndex(Ee).replace(Ue),ct()}updateLayers(Ee,Ue,ct){this.getLayerIndex(Ee).update(Ue.layers,Ue.removedIds),ct()}loadTile(Ee,Ue,ct){const wt=this.enableTerrain?i.extend({enableTerrain:this.terrain},Ue):Ue;wt.projection=this.projections[Ee]||this.defaultProjection,this.getWorkerSource(Ee,Ue.type,Ue.source).loadTile(wt,ct)}loadDEMTile(Ee,Ue,ct){const wt=this.enableTerrain?i.extend({buildQuadTree:this.terrain},Ue):Ue;this.getDEMWorkerSource(Ee,Ue.source).loadTile(wt,ct)}reloadTile(Ee,Ue,ct){const wt=this.enableTerrain?i.extend({enableTerrain:this.terrain},Ue):Ue;wt.projection=this.projections[Ee]||this.defaultProjection,this.getWorkerSource(Ee,Ue.type,Ue.source).reloadTile(wt,ct)}abortTile(Ee,Ue,ct){this.getWorkerSource(Ee,Ue.type,Ue.source).abortTile(Ue,ct)}removeTile(Ee,Ue,ct){this.getWorkerSource(Ee,Ue.type,Ue.source).removeTile(Ue,ct)}removeSource(Ee,Ue,ct){if(!this.workerSources[Ee]||!this.workerSources[Ee][Ue.type]||!this.workerSources[Ee][Ue.type][Ue.source])return;const wt=this.workerSources[Ee][Ue.type][Ue.source];delete this.workerSources[Ee][Ue.type][Ue.source],wt.removeSource!==void 0?wt.removeSource(Ue,ct):ct()}loadWorkerSource(Ee,Ue,ct){try{this.self.importScripts(Ue.url),ct()}catch(wt){ct(wt.toString())}}syncRTLPluginState(Ee,Ue,ct){try{i.plugin.setState(Ue);const wt=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&wt!=null){this.self.importScripts(wt);const X=i.plugin.isParsed();ct(X?void 0:new Error(`RTL Text Plugin failed to import scripts from ${wt}`),X)}}catch(wt){ct(wt.toString())}}getAvailableImages(Ee){let Ue=this.availableImages[Ee];return Ue||(Ue=[]),Ue}getLayerIndex(Ee){let Ue=this.layerIndexes[Ee];return Ue||(Ue=this.layerIndexes[Ee]=new U),Ue}getWorkerSource(Ee,Ue,ct){if(this.workerSources[Ee]||(this.workerSources[Ee]={}),this.workerSources[Ee][Ue]||(this.workerSources[Ee][Ue]={}),!this.workerSources[Ee][Ue][ct]){const wt={send:(X,j,ie,ne,de,Re)=>{this.actor.send(X,j,ie,Ee,de,Re)},scheduler:this.actor.scheduler};this.workerSources[Ee][Ue][ct]=new this.workerSourceTypes[Ue](wt,this.getLayerIndex(Ee),this.getAvailableImages(Ee),this.isSpriteLoaded[Ee])}return this.workerSources[Ee][Ue][ct]}getDEMWorkerSource(Ee,Ue){return this.demWorkerSources[Ee]||(this.demWorkerSources[Ee]={}),this.demWorkerSources[Ee][Ue]||(this.demWorkerSources[Ee][Ue]=new N),this.demWorkerSources[Ee][Ue]}enforceCacheSizeLimit(Ee,Ue){i.enforceCacheSizeLimit(Ue)}getWorkerPerformanceMetrics(Ee,Ue,ct){ct(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new zs(self)),zs}),p(["./shared"],function(i){function C(x,a){if(Array.isArray(x)){if(!Array.isArray(a)||x.length!==a.length)return!1;for(let m=0;m"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 b,S,P=new Blob([""],{type:"text/javascript"}),H=URL.createObjectURL(P);try{S=new Worker(H),b=!0}catch{b=!1}return S&&S.terminate(),URL.revokeObjectURL(H),b}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var b=document.createElement("canvas");b.width=b.height=1;var S=b.getContext("2d");if(!S)return!1;var P=S.getImageData(0,0,1,1);return P&&P.width===b.width}()?(N[m=a&&a.failIfMajorPerformanceCaveat]===void 0&&(N[m]=function(b){var S,P=function(H){var W=document.createElement("canvas"),ee=Object.create(U.webGLContextAttributes);return ee.failIfMajorPerformanceCaveat=H,W.getContext("webgl",ee)||W.getContext("experimental-webgl",ee)}(b);if(!P)return!1;try{S=P.createShader(P.VERTEX_SHADER)}catch{return!1}return!(!S||P.isContextLost())&&(P.shaderSource(S,"void main() {}"),P.compileShader(S),P.getShaderParameter(S,P.COMPILE_STATUS)===!0)}(m)),N[m]?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 m}(x)}var N={};function R(x,a,m){const b=i.window.document.createElement(x);return a!==void 0&&(b.className=a),m&&m.appendChild(b),b}function G(x,a,m){const b=i.window.document.createElementNS("http://www.w3.org/2000/svg",x);for(const S of Object.keys(a))b.setAttributeNS(null,S,a[S]);return m&&m.appendChild(b),b}U.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const J=i.window.document&&i.window.document.documentElement.style,Y=J&&J.userSelect!==void 0?"userSelect":"WebkitUserSelect";let B;function ae(){J&&Y&&(B=J[Y],J[Y]="none")}function le(){J&&Y&&(J[Y]=B)}function Ae(x){x.preventDefault(),x.stopPropagation(),i.window.removeEventListener("click",Ae,!0)}function we(){i.window.addEventListener("click",Ae,!0),i.window.setTimeout(()=>{i.window.removeEventListener("click",Ae,!0)},0)}function me(x,a){const m=x.getBoundingClientRect();return Me(x,m,a)}function Pe(x,a){const m=x.getBoundingClientRect(),b=[];for(let S=0;S=0?0:x.button}function Me(x,a,m){const b=x.offsetWidth===a.width?1:x.offsetWidth/a.width;return new i.pointGeometry((m.clientX-a.left)*b,(m.clientY-a.top)*b)}function Ke(x,a){var m=a[0],b=a[1],S=a[2],P=a[3],H=m*P-S*b;return H?(x[0]=P*(H=1/H),x[1]=-b*H,x[2]=-S*H,x[3]=m*H,x):null}function Et(x){const{userImage:a}=x;return!!(a&&a.render&&a.render())&&(x.data.replace(new Uint8Array(a.data.buffer)),!0)}class oi extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(a){if(this.loaded!==a&&(this.loaded=a,a)){for(const{ids:m,callback:b}of this.requestors)this._notify(m,b);this.requestors=[]}}hasImage(a){return!!this.getImage(a)}getImage(a){return this.images[a]}addImage(a,m){this._validate(a,m)&&(this.images[a]=m)}_validate(a,m){let b=!0;return this._validateStretch(m.stretchX,m.data&&m.data.width)||(this.fire(new i.ErrorEvent(new Error(`Image "${a}" has invalid "stretchX" value`))),b=!1),this._validateStretch(m.stretchY,m.data&&m.data.height)||(this.fire(new i.ErrorEvent(new Error(`Image "${a}" has invalid "stretchY" value`))),b=!1),this._validateContent(m.content,m)||(this.fire(new i.ErrorEvent(new Error(`Image "${a}" has invalid "content" value`))),b=!1),b}_validateStretch(a,m){if(!a)return!0;let b=0;for(const S of a){if(S[0]{this.ready=!0})}broadcast(a,m,b){i.asyncAll(this.actors,(S,P)=>{S.send(a,m,P)},b=b||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(a=>{a.remove()}),this.actors=[],this.workerPool.release(this.id)}}function et(x,a,m){return a*(i.EXTENT/(x.tileSize*Math.pow(2,m-x.tileID.overscaledZ)))}qe.Actor=i.Actor;class vt{constructor(a,m,b,S){this.screenBounds=a,this.cameraPoint=m,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=b,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,S)}static createFromScreenPoints(a,m){let b,S;if(a instanceof i.pointGeometry||typeof a[0]=="number"){const P=i.pointGeometry.convert(a);b=[P],S=m.isPointAboveHorizon(P)}else{const P=i.pointGeometry.convert(a[0]),H=i.pointGeometry.convert(a[1]);b=[P,H],S=i.polygonizeBounds(P,H).every(W=>m.isPointAboveHorizon(W))}return new vt(b,m.getCameraPoint(),S,m)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(a){return i.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],a)}bufferedCameraGeometry(a){const m=this.screenBounds[0],b=this.screenBounds.length===1?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],S=i.polygonizeBounds(m,b,0,!1);return this.cameraPoint.y>b.y&&(this.cameraPoint.x>m.x&&this.cameraPoint.x=b.x?S[2]=this.cameraPoint:this.cameraPoint.x<=m.x&&(S[3]=this.cameraPoint)),i.bufferConvexPolygon(S,a)}bufferedCameraGeometryGlobe(a){const m=this.screenBounds[0],b=this.screenBounds.length===1?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],S=i.polygonizeBounds(m,b,a),P=this.cameraPoint.clone();switch(3*((P.y>m.y)+(P.y>b.y))+((P.x>m.x)+(P.x>b.x))){case 0:S[0]=P,S[4]=P.clone();break;case 1:S.splice(1,0,P);break;case 2:S[1]=P;break;case 3:S.splice(4,0,P);break;case 5:S.splice(2,0,P);break;case 6:S[3]=P;break;case 7:S.splice(3,0,P);break;case 8:S[2]=P}return S}containsTile(a,m,b,S=0){const P=a.queryPadding/m._pixelsPerMercatorPixel+1,H=b?this._bufferedCameraMercator(P,m):this._bufferedScreenMercator(P,m);let W=a.tileID.wrap+(H.unwrapped?S:0);const ee=H.polygon.map(Xe=>i.getTilePoint(a.tileTransform,Xe,W));if(!i.polygonIntersectsBox(ee,0,0,i.EXTENT,i.EXTENT))return;W=a.tileID.wrap+(this.screenGeometryMercator.unwrapped?S:0);const pe=this.screenGeometryMercator.polygon.map(Xe=>i.getTileVec3(a.tileTransform,Xe,W)),fe=pe.map(Xe=>new i.pointGeometry(Xe[0],Xe[1])),Se=m.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),Qe=i.getTileVec3(a.tileTransform,Se,W),rt=pe.map(Xe=>{const Ye=i.sub(Xe,Xe,Qe);return i.normalize(Ye,Ye),new i.Ray(Qe,Ye)}),nt=et(a,1,m.zoom)*m._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:fe,tilespaceRays:rt,bufferedTilespaceGeometry:ee,bufferedTilespaceBounds:(lt=i.getBounds(ee),lt.min.x=i.clamp(lt.min.x,0,i.EXTENT),lt.min.y=i.clamp(lt.min.y,0,i.EXTENT),lt.max.x=i.clamp(lt.max.x,0,i.EXTENT),lt.max.y=i.clamp(lt.max.y,0,i.EXTENT),lt),tile:a,tileID:a.tileID,pixelToTileUnitsFactor:nt};var lt}_bufferedScreenMercator(a,m){const b=ut(a);if(this._screenRaycastCache[b])return this._screenRaycastCache[b];{let S;return S=m.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(a),m):{polygon:this.bufferedScreenGeometry(a).map(P=>m.pointCoordinate3D(P)),unwrapped:!0},this._screenRaycastCache[b]=S,S}}_bufferedCameraMercator(a,m){const b=ut(a);if(this._cameraRaycastCache[b])return this._cameraRaycastCache[b];{let S;return S=m.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(a),m):{polygon:this.bufferedCameraGeometry(a).map(P=>m.pointCoordinate3D(P)),unwrapped:!0},this._cameraRaycastCache[b]=S,S}}_projectAndResample(a,m){const b=function(P,H){const W=i.multiply([],H.pixelMatrix,H.globeMatrix),ee=[0,-i.GLOBE_RADIUS,0,1],pe=[0,i.GLOBE_RADIUS,0,1],fe=[0,0,0,1];i.transformMat4$1(ee,ee,W),i.transformMat4$1(pe,pe,W),i.transformMat4$1(fe,fe,W);const Se=new i.pointGeometry(ee[0]/ee[3],ee[1]/ee[3]),Qe=new i.pointGeometry(pe[0]/pe[3],pe[1]/pe[3]),rt=i.polygonContainsPoint(P,Se)&&ee[3]1?Be(P.slice(0,Xe),H):[],ht=Xenew i.pointGeometry(dt(Ht.x),Ht.y)),ht=ht.map(Ht=>new i.pointGeometry(dt(Ht.x),Ht.y));const Bt=[...At];Bt.length===0&&Bt.push(ht[ht.length-1]);const Pt=i.number(Bt[Bt.length-1].y,(ht.length===0?At[0]:ht[0]).y,Ye);let It;return It=rt?[new i.pointGeometry(0,Pt),new i.pointGeometry(0,0),new i.pointGeometry(1,0),new i.pointGeometry(1,Pt)]:[new i.pointGeometry(1,Pt),new i.pointGeometry(1,1),new i.pointGeometry(0,1),new i.pointGeometry(0,Pt)],Bt.push(...It),ht.length===0?Bt.push(At[0]):Bt.push(...ht),{polygon:Bt.map(Ht=>new i.MercatorCoordinate(Ht.x,Ht.y)),unwrapped:!1}}(a,m);if(b)return b;const S=function(P,H){let W=!1,ee=-1/0,pe=0;for(let Se=0;Seee&&(ee=P[Se].x,pe=Se);for(let Se=0;Se.5&&(rt.x{Se.x-=1}),{polygon:P,unwrapped:W}}(Be(a,m).map(P=>new i.pointGeometry(dt(P.x),P.y)),m);return{polygon:S.polygon.map(P=>new i.MercatorCoordinate(P.x,P.y)),unwrapped:S.unwrapped}}}function Be(x,a){return i.resample(x,m=>{const b=a.pointCoordinate3D(m);m.x=b.x,m.y=b.y},1/256)}function dt(x){return x<0?1+x%1:x%1}function ut(x){return 100*x|0}function Qt(x,a,m,b,S){const P=function(H,W){if(H)return S(H);if(W){x.url&&W.tiles&&x.tiles&&delete x.tiles;const ee=i.pick(i.extend(W,x),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);W.vector_layers&&(ee.vectorLayers=W.vector_layers,ee.vectorLayerIds=ee.vectorLayers.map(pe=>pe.id)),ee.tiles=a.canonicalizeTileset(ee,x.url),S(null,ee)}};return x.url?i.getJSON(a.transformRequest(a.normalizeSourceURL(x.url,null,m,b),i.ResourceType.Source),P):i.exported.frame(()=>P(null,x))}class Wt{constructor(a,m,b){this.bounds=i.LngLatBounds.convert(this.validateBounds(a)),this.minzoom=m||0,this.maxzoom=b||24}validateBounds(a){return Array.isArray(a)&&a.length===4?[Math.max(-180,a[0]),Math.max(-90,a[1]),Math.min(180,a[2]),Math.min(90,a[3])]:[-180,-90,180,90]}contains(a){const m=Math.pow(2,a.z),b=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*m),S=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*m),P=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*m),H=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*m);return a.x>=b&&a.x=S&&a.y{this._tileJSONRequest=null,this._loaded=!0,a?this.fire(new i.ErrorEvent(a)):m&&(i.extend(this,m),m.bounds&&(this.tileBounds=new Wt(m.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(m.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(a){this.map=a,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}loadTile(a,m){const b=i.exported.devicePixelRatio>=2,S=this.map._requestManager.normalizeTileURL(a.tileID.canonical.url(this.tiles,this.scheme),b,this.tileSize);a.request=i.getImage(this.map._requestManager.transformRequest(S,i.ResourceType.Tile),(P,H,W,ee)=>(delete a.request,a.aborted?(a.state="unloaded",m(null)):P?(a.state="errored",m(P)):H?(this.map._refreshExpiredTiles&&a.setExpiryData({cacheControl:W,expires:ee}),a.setTexture(H,this.map.painter),a.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),void m(null)):m(null)))}static loadTileData(a,m,b){a.setTexture(m,b)}static unloadTileData(a,m){a.texture&&m.saveTileTexture(a.texture)}abortTile(a,m){a.request&&(a.request.cancel(),delete a.request),m()}unloadTile(a,m){a.texture&&this.map.painter.saveTileTexture(a.texture),m()}hasTransition(){return!1}}let ct;function wt(x,a,m,b,S,P,H,W){const ee=[x,m,S,a,b,P,1,1,1],pe=[H,W,1],fe=i.adjoint([],ee),[Se,Qe,rt]=i.transformMat3(pe,pe,i.transpose(fe,fe));return i.multiply$1(ee,[Se,0,0,0,Qe,0,0,0,rt],ee)}class X extends i.Evented{constructor(a,m,b,S){super(),this.id=a,this.dispatcher=b,this.coordinates=m.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(S),this.options=m,this._dirty=!1}load(a,m){this._loaded=m||!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(b,S)=>{if(this._imageRequest=null,this._loaded=!0,b)this.fire(new i.ErrorEvent(b));else if(S){const{HTMLImageElement:P}=i.window;this.image=S instanceof P?i.exported.getImageData(S):S,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,a&&(this.coordinates=a),this._finishLoading()}})}loaded(){return this._loaded}updateImage(a){return this.image&&a.url?(this._imageRequest&&a.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=a.url,this.load(a.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(a){this.map=a,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(a){this.coordinates=a,this._boundsArray=void 0;const m=a.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(b){let S=1/0,P=1/0,H=-1/0,W=-1/0;for(const Se of b)S=Math.min(S,Se.x),P=Math.min(P,Se.y),H=Math.max(H,Se.x),W=Math.max(W,Se.y);const ee=Math.max(H-S,W-P),pe=Math.max(0,Math.floor(-Math.log(ee)/Math.LN2)),fe=Math.pow(2,pe);return new i.CanonicalTileID(pe,Math.floor((S+H)/2*fe),Math.floor((P+W)/2*fe))}(m),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(a){for(const ee in this.tiles){const pe=this.tiles[ee];pe.state!=="loaded"&&(pe.state="loaded",pe.texture=this.texture)}if(this._boundsArray)return;const m=i.tileTransform(this.tileID,this.map.transform.projection),[b,S,P,H]=this.coordinates.map(ee=>{const pe=m.projection.project(ee[0],ee[1]);return i.getTilePoint(m,pe)._round()});this.perspectiveTransform=function(ee,pe,fe,Se,Qe,rt,nt,lt,Xe,Ye){const At=wt(0,0,ee,0,0,pe,ee,pe),ht=wt(fe,Se,Qe,rt,nt,lt,Xe,Ye);return i.multiply$1(ht,i.adjoint(At,At),ht),[ht[6]/ht[8]*ee/i.EXTENT,ht[7]/ht[8]*pe/i.EXTENT]}(this.width,this.height,b.x,b.y,S.x,S.y,H.x,H.y,P.x,P.y);const W=this._boundsArray=new i.StructArrayLayout4i8;W.emplaceBack(b.x,b.y,0,0),W.emplaceBack(S.x,S.y,i.EXTENT,0),W.emplaceBack(H.x,H.y,0,i.EXTENT),W.emplaceBack(P.x,P.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=a.createVertexBuffer(W,i.boundsAttributes.members),this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const a=this.map.painter.context,m=a.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new i.Texture(a,this.image,m.RGBA),this.texture.bind(m.LINEAR,m.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(a)}loadTile(a,m){this.tileID&&this.tileID.equals(a.tileID.canonical)?(this.tiles[String(a.tileID.wrap)]=a,a.buckets={},m(null)):(a.state="errored",m(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const j={vector:class extends i.Evented{constructor(x,a,m,b){if(super(),this.id=x,this.dispatcher=m,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(a,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},a),this._collectResourceTiming=a.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(b),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(x){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"}));const a=Array.isArray(this.map._language)?this.map._language.join():this.map._language,m=this.map._worldview;this._tileJSONRequest=Qt(this._options,this.map._requestManager,a,m,(b,S)=>{this._tileJSONRequest=null,this._loaded=!0,b?(a&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${a}`),m&&m.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${m}`),this.fire(new i.ErrorEvent(b))):S&&(i.extend(this,S),S.bounds&&(this.tileBounds=new Wt(S.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(S.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"}))),x&&x(b)})}loaded(){return this._loaded}hasTile(x){return!this.tileBounds||this.tileBounds.contains(x.canonical)}onAdd(x){this.map=x,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>{const x=this.map.style._getSourceCaches(this.id);for(const a of x)a.clearTiles()})}setSourceProperty(x){x(),this.reload()}setTiles(x){return this._options.tiles=x,this.reload(),this}setUrl(x){return this.url=x,this._options.url=x,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return i.extend({},this._options)}loadTile(x,a){const m=this.map._requestManager.normalizeTileURL(x.tileID.canonical.url(this.tiles,this.scheme)),b={request:this.map._requestManager.transformRequest(m,i.ResourceType.Tile),data:void 0,uid:x.uid,tileID:x.tileID,tileZoom:x.tileZoom,zoom:x.tileID.overscaledZ,tileSize:this.tileSize*x.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:x.isSymbolTile};if(b.request.collectResourceTiming=this._collectResourceTiming,x.actor&&x.state!=="expired")x.state==="loading"?x.reloadCallback=a:x.request=x.actor.send("reloadTile",b,S.bind(this));else if(x.actor=this._tileWorkers[m]=this._tileWorkers[m]||this.dispatcher.getActor(),this.dispatcher.ready)x.request=x.actor.send("loadTile",b,S.bind(this),void 0,!0);else{const P=i.loadVectorTile.call({deduped:this._deduped},b,(H,W)=>{H||!W?S.call(this,H):(b.data={cacheControl:W.cacheControl,expires:W.expires,rawData:W.rawData.slice(0)},x.actor&&x.actor.send("loadTile",b,S.bind(this),void 0,!0))},!0);x.request={cancel:P}}function S(P,H){return delete x.request,x.aborted?a(null):P&&P.status!==404?a(P):(H&&H.resourceTiming&&(x.resourceTiming=H.resourceTiming),this.map._refreshExpiredTiles&&H&&x.setExpiryData(H),x.loadVectorData(H,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),a(null),void(x.reloadCallback&&(this.loadTile(x,x.reloadCallback),x.reloadCallback=null)))}}abortTile(x){x.request&&(x.request.cancel(),delete x.request),x.actor&&x.actor.send("abortTile",{uid:x.uid,type:this.type,source:this.id})}unloadTile(x){x.unloadVectorData(),x.actor&&x.actor.send("removeTile",{uid:x.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}},raster:Ue,"raster-dem":class extends Ue{constructor(x,a,m,b){super(x,a,m,b),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},a),this.encoding=a.encoding||"mapbox"}loadTile(x,a){const m=this.map._requestManager.normalizeTileURL(x.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function b(S,P){S&&(x.state="errored",a(S)),P&&(x.dem=P,x.dem.onDeserialize(),x.needsHillshadePrepare=!0,x.needsDEMTextureUpload=!0,x.state="loaded",a(null))}x.request=i.getImage(this.map._requestManager.transformRequest(m,i.ResourceType.Tile),function(S,P,H,W){if(delete x.request,x.aborted)x.state="unloaded",a(null);else if(S)x.state="errored",a(S);else if(P){this.map._refreshExpiredTiles&&x.setExpiryData({cacheControl:H,expires:W});const ee=i.window.ImageBitmap&&P instanceof i.window.ImageBitmap&&(ct==null&&(ct=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&typeof i.window.createImageBitmap=="function"),ct),pe=1-(P.width-i.prevPowerOfTwo(P.width))/2;pe<1||x.neighboringTiles||(x.neighboringTiles=this._getNeighboringTiles(x.tileID));const fe=ee?P:i.exported.getImageData(P,pe),Se={uid:x.uid,coord:x.tileID,source:this.id,rawImageData:fe,encoding:this.encoding,padding:pe};x.actor&&x.state!=="expired"||(x.actor=this.dispatcher.getActor(),x.actor.send("loadDEMTile",Se,b.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(x){const a=x.canonical,m=Math.pow(2,a.z),b=(a.x-1+m)%m,S=a.x===0?x.wrap-1:x.wrap,P=(a.x+1+m)%m,H=a.x+1===m?x.wrap+1:x.wrap,W={};return W[new i.OverscaledTileID(x.overscaledZ,S,a.z,b,a.y).key]={backfilled:!1},W[new i.OverscaledTileID(x.overscaledZ,H,a.z,P,a.y).key]={backfilled:!1},a.y>0&&(W[new i.OverscaledTileID(x.overscaledZ,S,a.z,b,a.y-1).key]={backfilled:!1},W[new i.OverscaledTileID(x.overscaledZ,x.wrap,a.z,a.x,a.y-1).key]={backfilled:!1},W[new i.OverscaledTileID(x.overscaledZ,H,a.z,P,a.y-1).key]={backfilled:!1}),a.y+1{if(this._loaded=!0,this._pendingLoad=null,m)this.fire(new i.ErrorEvent(m));else{const S={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&b&&b.resourceTiming&&b.resourceTiming[this.id]&&(S.resourceTiming=b.resourceTiming[this.id]),this.fire(new i.Event("data",S)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(x,a){const m=x.actor?"reloadTile":"loadTile";x.actor=this.actor,x.request=this.actor.send(m,{type:this.type,uid:x.uid,tileID:x.tileID,tileZoom:x.tileZoom,zoom:x.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(b,S)=>(delete x.request,x.unloadVectorData(),x.aborted?a(null):b?a(b):(x.loadVectorData(S,this.map.painter,m==="reloadTile"),a(null))),void 0,m==="loadTile")}abortTile(x){x.request&&(x.request.cancel(),delete x.request),x.aborted=!0}unloadTile(x){x.unloadVectorData(),this.actor.send("removeTile",{uid:x.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends X{constructor(x,a,m,b){super(x,a,m,b),this.roundZoom=!0,this.type="video",this.options=a}load(){this._loaded=!1;const x=this.options;this.urls=[];for(const a of x.urls)this.urls.push(this.map._requestManager.transformRequest(a,i.ResourceType.Source).url);i.getVideo(this.urls,(a,m)=>{this._loaded=!0,a?this.fire(new i.ErrorEvent(a)):m&&(this.video=m,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(x){if(this.video){const a=this.video.seekable;xa.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${a.start(0)} and ${a.end(0)}-second mark.`))):this.video.currentTime=x}}getVideo(){return this.video}onAdd(x){this.map||(this.map=x,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 x=this.map.painter.context,a=x.gl;this.texture?this.video.paused||(this.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.texSubImage2D(a.TEXTURE_2D,0,0,0,a.RGBA,a.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(x,this.video,a.RGBA),this.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(x)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:X,canvas:class extends X{constructor(x,a,m,b){super(x,a,m,b),a.coordinates?Array.isArray(a.coordinates)&&a.coordinates.length===4&&!a.coordinates.some(S=>!Array.isArray(S)||S.length!==2||S.some(P=>typeof P!="number"))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${x}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${x}`,null,'missing required property "coordinates"'))),a.animate&&typeof a.animate!="boolean"&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${x}`,null,'optional "animate" property must be a boolean value'))),a.canvas?typeof a.canvas=="string"||a.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${x}`,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 i.ErrorEvent(new i.ValidationError(`sources.${x}`,null,'missing required property "canvas"'))),this.options=a,this.animate=a.animate===void 0||a.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.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(x){this.map=x,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let x=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,x=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,x=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const a=this.map.painter.context;this.texture?(x||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(a,this.canvas,a.gl.RGBA,{premultiply:!0}),this._prepareData(a)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const x of[this.canvas.width,this.canvas.height])if(isNaN(x)||x<=0)return!0;return!1}},custom:class extends i.Evented{constructor(x,a,m,b){super(),this.id=x,this.type="custom",this._dataType="raster",this._dispatcher=m,this._implementation=a,this.setEventedParent(b),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new i.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new i.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Wt(this._implementation.bounds,this.minzoom,this.maxzoom)),a.update=this._update.bind(this),a.clearTiles=this._clearTiles.bind(this),a.coveringTiles=this._coveringTiles.bind(this),i.extend(this,i.pick(a,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return i.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(x){this._map=x,this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(x),this.load()}onRemove(x){this._implementation.onRemove&&this._implementation.onRemove(x)}hasTile(x){if(this._implementation.hasTile){const{x:a,y:m,z:b}=x.canonical;return this._implementation.hasTile({x:a,y:m,z:b})}return!this.tileBounds||this.tileBounds.contains(x.canonical)}loadTile(x,a){const{x:m,y:b,z:S}=x.tileID.canonical,P=new i.window.AbortController;x.request=Promise.resolve(this._implementation.loadTile({x:m,y:b,z:S},{signal:P.signal})).then(function(H){return delete x.request,x.aborted?(x.state="unloaded",a(null)):H===void 0?(x.state="errored",a(null)):H===null?(this.loadTileData(x,{width:this.tileSize,height:this.tileSize,data:null}),x.state="loaded",a(null)):function(W){return W instanceof i.window.ImageData||W instanceof i.window.HTMLCanvasElement||W instanceof i.window.ImageBitmap||W instanceof i.window.HTMLImageElement}(H)?(this.loadTileData(x,H),x.state="loaded",void a(null)):(x.state="errored",a(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(H=>{H.code!==20&&(x.state="errored",a(H))}),x.request.cancel=()=>P.abort()}loadTileData(x,a){Ue.loadTileData(x,a,this._map.painter)}unloadTileData(x){Ue.unloadTileData(x,this._map.painter)}unloadTile(x,a){if(this.unloadTileData(x),this._implementation.unloadTile){const{x:m,y:b,z:S}=x.tileID.canonical;this._implementation.unloadTile({x:m,y:b,z:S})}a()}abortTile(x,a){x.request&&x.request.cancel&&(x.request.cancel(),delete x.request),a()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(x=>({x:x.canonical.x,y:x.canonical.y,z:x.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"}))}}},ie=function(x,a,m,b){const S=new j[a.type](x,a,m,b);if(S.id!==x)throw new Error(`Expected Source id to be ${x} instead of ${S.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],S),S};function ne(x,a){const m=i.identity([]);return i.scale(m,m,[.5*x.width,.5*-x.height,1]),i.translate(m,m,[1,-1,0]),i.multiply(m,m,x.calculateProjMatrix(a.toUnwrapped())),Float32Array.from(m)}function de(x,a,m,b,S,P,H,W=!1){const ee=x.tilesIn(b,H,W);ee.sort(tt);const pe=[];for(const Se of ee)pe.push({wrappedTileID:Se.tile.tileID.wrapped().key,queryResults:Se.tile.queryRenderedFeatures(a,m,x._state,Se,S,P,ne(x.transform,Se.tile.tileID),W)});const fe=function(Se){const Qe={},rt={};for(const nt of Se){const lt=nt.queryResults,Xe=nt.wrappedTileID,Ye=rt[Xe]=rt[Xe]||{};for(const At in lt){const ht=lt[At],Bt=Ye[At]=Ye[At]||{},Pt=Qe[At]=Qe[At]||[];for(const It of ht)Bt[It.featureIndex]||(Bt[It.featureIndex]=!0,Pt.push(It))}}return Qe}(pe);for(const Se in fe)fe[Se].forEach(Qe=>{const rt=Qe.feature,nt=rt.layer;nt&&nt.type!=="background"&&nt.type!=="sky"&&(rt.source=nt.source,nt["source-layer"]&&(rt.sourceLayer=nt["source-layer"]),rt.state=rt.id!==void 0?x.getFeatureState(nt["source-layer"],rt.id):{})});return fe}function Re(x,a){const m=x.getRenderableIds().map(P=>x.getTileByID(P)),b=[],S={};for(let P=0;P{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Je]}numActive(){return Object.keys(this.active).length}}let Lt;function jt(){return Lt||(Lt=new pt),Lt}function Gt(x,a){const m={};for(const b in x)b!=="ref"&&(m[b]=x[b]);return i.refProperties.forEach(b=>{b in a&&(m[b]=a[b])}),m}function ki(x){x=x.slice();const a=Object.create(null);for(let m=0;m0?(S-H)/W:0;return this.points[P].mult(1-ee).add(this.points[m].mult(ee))}}class Wr{constructor(a,m,b){const S=this.boxCells=[],P=this.circleCells=[];this.xCellCount=Math.ceil(a/b),this.yCellCount=Math.ceil(m/b);for(let H=0;Hthis.width||S<0||m>this.height)return!P&&[];const W=[];if(a<=0&&m<=0&&this.width<=b&&this.height<=S){if(P)return!0;for(let ee=0;ee0:W}_queryCircle(a,m,b,S,P){const H=a-b,W=a+b,ee=m-b,pe=m+b;if(W<0||H>this.width||pe<0||ee>this.height)return!S&&[];const fe=[];return this._forEachCell(H,ee,W,pe,this._queryCellCircle,fe,{hitTest:S,circle:{x:a,y:m,radius:b},seenUids:{box:{},circle:{}}},P),S?fe.length>0:fe}query(a,m,b,S,P){return this._query(a,m,b,S,!1,P)}hitTest(a,m,b,S,P){return this._query(a,m,b,S,!0,P)}hitTestCircle(a,m,b,S){return this._queryCircle(a,m,b,!0,S)}_queryCell(a,m,b,S,P,H,W,ee){const pe=W.seenUids,fe=this.boxCells[P];if(fe!==null){const Qe=this.bboxes;for(const rt of fe)if(!pe.box[rt]){pe.box[rt]=!0;const nt=4*rt;if(a<=Qe[nt+2]&&m<=Qe[nt+3]&&b>=Qe[nt+0]&&S>=Qe[nt+1]&&(!ee||ee(this.boxKeys[rt]))){if(W.hitTest)return H.push(!0),!0;H.push({key:this.boxKeys[rt],x1:Qe[nt],y1:Qe[nt+1],x2:Qe[nt+2],y2:Qe[nt+3]})}}}const Se=this.circleCells[P];if(Se!==null){const Qe=this.circles;for(const rt of Se)if(!pe.circle[rt]){pe.circle[rt]=!0;const nt=3*rt;if(this._circleAndRectCollide(Qe[nt],Qe[nt+1],Qe[nt+2],a,m,b,S)&&(!ee||ee(this.circleKeys[rt]))){if(W.hitTest)return H.push(!0),!0;{const lt=Qe[nt],Xe=Qe[nt+1],Ye=Qe[nt+2];H.push({key:this.circleKeys[rt],x1:lt-Ye,y1:Xe-Ye,x2:lt+Ye,y2:Xe+Ye})}}}}}_queryCellCircle(a,m,b,S,P,H,W,ee){const pe=W.circle,fe=W.seenUids,Se=this.boxCells[P];if(Se!==null){const rt=this.bboxes;for(const nt of Se)if(!fe.box[nt]){fe.box[nt]=!0;const lt=4*nt;if(this._circleAndRectCollide(pe.x,pe.y,pe.radius,rt[lt+0],rt[lt+1],rt[lt+2],rt[lt+3])&&(!ee||ee(this.boxKeys[nt])))return H.push(!0),!0}}const Qe=this.circleCells[P];if(Qe!==null){const rt=this.circles;for(const nt of Qe)if(!fe.circle[nt]){fe.circle[nt]=!0;const lt=3*nt;if(this._circlesCollide(rt[lt],rt[lt+1],rt[lt+2],pe.x,pe.y,pe.radius)&&(!ee||ee(this.circleKeys[nt])))return H.push(!0),!0}}}_forEachCell(a,m,b,S,P,H,W,ee){const pe=this._convertToXCellCoord(a),fe=this._convertToYCellCoord(m),Se=this._convertToXCellCoord(b),Qe=this._convertToYCellCoord(S);for(let rt=pe;rt<=Se;rt++)for(let nt=fe;nt<=Qe;nt++)if(P.call(this,a,m,b,S,this.xCellCount*nt+rt,H,W,ee))return}_convertToXCellCoord(a){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(a*this.xScale)))}_convertToYCellCoord(a){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(a*this.yScale)))}_circlesCollide(a,m,b,S,P,H){const W=S-a,ee=P-m,pe=b+H;return pe*pe>W*W+ee*ee}_circleAndRectCollide(a,m,b,S,P,H,W){const ee=(H-S)/2,pe=Math.abs(a-(S+ee));if(pe>ee+b)return!1;const fe=(W-P)/2,Se=Math.abs(m-(P+fe));if(Se>fe+b)return!1;if(pe<=ee||Se<=fe)return!0;const Qe=pe-ee,rt=Se-fe;return Qe*Qe+rt*rt<=b*b}}const mr=Math.tan(85*Math.PI/180);function Mr(x,a,m,b,S,P,H){const W=i.create();if(m)if(P.name==="globe"){const ee=i.calculateGlobeLabelMatrix(S,a);i.multiply(W,W,ee)}else{const ee=Ke([],H);W[0]=ee[0],W[1]=ee[1],W[4]=ee[2],W[5]=ee[3],b||i.rotateZ(W,W,S.angle)}else i.multiply(W,S.labelPlaneMatrix,x);return W}function Oo(x,a,m,b,S,P,H){const W=Mr(x,a,m,b,S,P,H);return P.name==="globe"&&m||(W[2]=W[6]=W[10]=W[14]=0),W}function ks(x,a,m,b,S,P,H){if(m){if(P.name==="globe"){const W=Mr(x,a,m,b,S,P,H);return i.invert(W,W),i.multiply(W,x,W),W}{const W=i.clone(x),ee=i.identity([]);return ee[0]=H[0],ee[1]=H[1],ee[4]=H[2],ee[5]=H[3],i.multiply(W,W,ee),b||i.rotateZ(W,W,-S.angle),W}}return S.glCoordMatrix}function or(x,a,m,b){const S=[x,a,m,1];m?i.transformMat4$1(S,S,b):hs(S,S,b);const P=S[3];return S[0]/=P,S[1]/=P,S[2]/=P,S}function rn(x,a){return Math.min(.5+x/a*.5,1.5)}function cr(x,a){const m=x[0]/x[3],b=x[1]/x[3];return m>=-a[0]&&m<=a[0]&&b>=-a[1]&&b<=a[1]}function Ar(x,a,m,b,S,P,H,W,ee,pe){const fe=m.transform,Se=b?x.textSizeData:x.iconSizeData,Qe=i.evaluateSizeForZoom(Se,m.transform.zoom),rt=fe.projection.name==="globe",nt=[256/m.width*2+1,256/m.height*2+1],lt=b?x.text.dynamicLayoutVertexArray:x.icon.dynamicLayoutVertexArray;lt.clear();let Xe=null;rt&&(Xe=b?x.text.globeExtVertexArray:x.icon.globeExtVertexArray);const Ye=x.lineVertexArray,At=b?x.text.placedSymbolArray:x.icon.placedSymbolArray,ht=m.transform.width/m.transform.height;let Bt,Pt=!1;for(let It=0;ItMath.abs(m)?{useVertical:!0}:x===i.WritingMode.vertical?b>0?{needsFlipping:!0}:null:a!==0&&function(S,P){return S===0||Math.abs(P/S)>mr}(m,b)?a===1?{needsFlipping:!0}:null:m<0?{needsFlipping:!0}:null}function dr(x,a,m,b,S,P,H,W,ee,pe,fe,Se,Qe,rt,nt,lt,Xe,Ye,At){const ht=a/24,Bt=x.lineOffsetX*ht,Pt=x.lineOffsetY*ht,{lineStartIndex:It,glyphStartIndex:Ht,numGlyphs:hi,segment:si,writingMode:qt,flipState:ji}=x,Kt=It+x.lineLength,Bi=di=>{if(fe){const[$i,Jt,pi]=di.up,In=pe.length;i.updateGlobeVertexNormal(fe,In+0,$i,Jt,pi),i.updateGlobeVertexNormal(fe,In+1,$i,Jt,pi),i.updateGlobeVertexNormal(fe,In+2,$i,Jt,pi),i.updateGlobeVertexNormal(fe,In+3,$i,Jt,pi)}const[Ri,Ai,Mi]=di.point;i.addDynamicAttributes(pe,Ri,Ai,Mi,di.angle)};if(hi>1){const di=la(ht,W,Bt,Pt,m,Se,Qe,x,ee,P,rt,lt,!1,Xe,Ye,At);if(!di)return{notEnoughRoom:!0};if(b&&!m){let[Ri,Ai,Mi]=di.first.point,[$i,Jt,pi]=di.last.point;[Ri,Ai]=or(Ri,Ai,Mi,H),[$i,Jt]=or($i,Jt,pi,H);const In=al(qt,ji,($i-Ri)*nt,Jt-Ai);if(x.flipState=In&&In.needsFlipping?1:2,In)return In}Bi(di.first);for(let Ri=Ht+1;Ri0?$i:Rl(Qe,Mi,Ri,1,S,void 0,Xe,Ye.canonical),pi=al(qt,ji,(Jt[0]-Ri[0])*nt,Jt[1]-Ri[1]);if(x.flipState=pi&&pi.needsFlipping?1:2,pi)return pi}const di=ll(ht*W.getoffsetX(Ht),Bt,Pt,m,Se,Qe,si,It,Kt,ee,P,rt,lt,!1,!1,Xe,Ye,At);if(!di)return{notEnoughRoom:!0};Bi(di)}return{}}function Ul(x,a,m,b,S){const{x:P,y:H,z:W}=b.projectTilePoint(x.x,x.y,a);if(!S)return or(P,H,W,m);const[ee,pe,fe]=S(x);return or(P+ee,H+pe,W+fe,m)}function Rl(x,a,m,b,S,P,H,W){const ee=Ul(x.sub(a)._unit()._add(x),W,S,H,P);return i.sub(ee,m,ee),i.normalize(ee,ee),i.scaleAndAdd(ee,m,ee,b)}function ll(x,a,m,b,S,P,H,W,ee,pe,fe,Se,Qe,rt,nt,lt,Xe,Ye){const At=b?x-a:x+a;let ht=At>0?1:-1,Bt=0;b&&(ht*=-1,Bt=Math.PI),ht<0&&(Bt+=Math.PI);let Pt=W+H+(ht>0?0:1)|0,It=S,Ht=S,hi=0,si=0;const qt=Math.abs(At),ji=[],Kt=[];let Bi=P,di=Bi;const Ri=()=>Rl(di,Bi,Ht,qt-hi+1,fe,Qe,lt,Xe.canonical);for(;hi+si<=qt;){if(Pt+=ht,Pt=ee)return null;if(Ht=It,di=Bi,ji.push(Ht),rt&&Kt.push(di),Bi=new i.pointGeometry(pe.getx(Pt),pe.gety(Pt)),It=Se[Pt],!It){const $n=Ul(Bi,Xe.canonical,fe,lt,Qe);It=$n[3]>0?Se[Pt]=$n:Ri()}hi+=si,si=i.distance(Ht,It)}nt&&Qe&&(Se[Pt]&&(It=Ri(),si=i.distance(Ht,It)),Se[Pt]=It);const Ai=(qt-hi)/si,Mi=Bi.sub(di)._mult(Ai)._add(di),$i=i.sub([],It,Ht),Jt=i.scaleAndAdd([],Ht,$i,Ai);let pi=[0,0,1],In=$i[0],Hn=$i[1];if(Ye&&(pi=lt.upVector(Xe.canonical,Mi.x,Mi.y),pi[0]!==0||pi[1]!==0||pi[2]!==1)){const $n=[pi[2],0,-pi[0]],ar=i.cross([],pi,$n);i.normalize($n,$n),i.normalize(ar,ar),In=i.dot($i,$n),Hn=i.dot($i,ar)}if(m){const $n=i.cross([],pi,$i);i.normalize($n,$n),i.scaleAndAdd(Jt,Jt,$n,m*ht)}const Mn=Bt+Math.atan2(Hn,In);return ji.push(Jt),rt&&Kt.push(Mi),{point:Jt,angle:Mn,path:ji,tilePath:Kt,up:pi}}function qs(x,a){const m=a.length,b=m+4*x;a.resize(b),a.float32.fill(-1/0,4*m,4*b)}function hs(x,a,m){const b=a[0],S=a[1];return x[0]=m[0]*b+m[4]*S+m[12],x[1]=m[1]*b+m[5]*S+m[13],x[3]=m[3]*b+m[7]*S+m[15],x}const ho=100;class cl{constructor(a,m,b=new Wr(a.width+200,a.height+200,25),S=new Wr(a.width+200,a.height+200,25)){this.transform=a,this.grid=b,this.ignoredGrid=S,this.pitchfactor=Math.cos(a._pitch)*a.cameraToCenterDistance,this.screenRightBoundary=a.width+ho,this.screenBottomBoundary=a.height+ho,this.gridRightBoundary=a.width+200,this.gridBottomBoundary=a.height+200,this.fogState=m}placeCollisionBox(a,m,b,S,P,H,W,ee){let pe=b.projectedAnchorX,fe=b.projectedAnchorY,Se=b.projectedAnchorZ;const Qe=b.elevation,rt=b.tileID,nt=a.getProjection();if(Qe&&rt){const[It,Ht,hi]=nt.upVector(rt.canonical,b.tileAnchorX,b.tileAnchorY),si=nt.upVectorScale(rt.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;pe+=It*Qe*si,fe+=Ht*Qe*si,Se+=hi*Qe*si}const lt=this.projectAndGetPerspectiveRatio(W,pe,fe,Se,b.tileID,nt.name==="globe"||!!Qe||this.transform.pitch>0,nt),Xe=H*lt.perspectiveRatio,Ye=(b.x1*m+S.x-b.padding)*Xe+lt.point.x,At=(b.y1*m+S.y-b.padding)*Xe+lt.point.y,ht=(b.x2*m+S.x+b.padding)*Xe+lt.point.x,Bt=(b.y2*m+S.y+b.padding)*Xe+lt.point.y,Pt=lt.perspectiveRatio<=.55||lt.occluded;return!this.isInsideGrid(Ye,At,ht,Bt)||!P&&this.grid.hitTest(Ye,At,ht,Bt,ee)||Pt?{box:[],offscreen:!1,occluded:lt.occluded}:{box:[Ye,At,ht,Bt],offscreen:this.isOffscreen(Ye,At,ht,Bt),occluded:!1}}placeCollisionCircles(a,m,b,S,P,H,W,ee,pe,fe,Se,Qe,rt,nt,lt){const Xe=[],Ye=this.transform.elevation,At=a.getProjection(),ht=Ye?Ye.getAtTileOffsetFunc(lt,this.transform.center.lat,this.transform.worldSize,At):null,Bt=new i.pointGeometry(b.tileAnchorX,b.tileAnchorY);let{x:Pt,y:It,z:Ht}=At.projectTilePoint(Bt.x,Bt.y,lt.canonical);if(ht){const[Mi,$i,Jt]=ht(Bt);Pt+=Mi,It+=$i,Ht+=Jt}const hi=At.name==="globe",si=this.projectAndGetPerspectiveRatio(W,Pt,It,Ht,lt,hi||!!Ye||this.transform.pitch>0,At),{perspectiveRatio:qt}=si,ji=(Se?H/qt:H*qt)/i.ONE_EM,Kt=or(Pt,It,Ht,ee),Bi=si.signedDistanceFromCamera>0?la(ji,P,b.lineOffsetX*ji,b.lineOffsetY*ji,!1,Kt,Bt,b,S,ee,{},Ye&&!Se?ht:null,Se&&!!Ye,At,lt,Se):null;let di=!1,Ri=!1,Ai=!0;if(Bi&&!si.occluded){const Mi=.5*rt*qt+nt,$i=new i.pointGeometry(-100,-100),Jt=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),pi=new Yn,{first:In,last:Hn}=Bi,Mn=In.path.length;let $n=[];for(let _n=Mn-1;_n>=1;_n--)$n.push(In.path[_n]);for(let _n=1;_n(ht&&!hi&&(Or=ht(Nr_n[3]<=0)&&($n=[]));let On=[];if($n.length>0){let _n=1/0,Dr=-1/0,Or=1/0,Nr=-1/0;for(const Qr of $n)_n=Math.min(_n,Qr[0]),Or=Math.min(Or,Qr[1]),Dr=Math.max(Dr,Qr[0]),Nr=Math.max(Nr,Qr[1]);Dr>=$i.x&&_n<=Jt.x&&Nr>=$i.y&&Or<=Jt.y&&(On=[$n.map(Qr=>new i.pointGeometry(Qr[0],Qr[1]))],(_n<$i.x||Dr>Jt.x||Or<$i.y||Nr>Jt.y)&&(On=i.clipLine(On,$i.x,$i.y,Jt.x,Jt.y)))}for(const _n of On){pi.reset(_n,.25*Mi);let Dr=0;Dr=pi.length<=.5*Mi?1:Math.ceil(pi.paddedLength/ar)+1;for(let Or=0;Or0){i.transformMat4$1(ee,ee,a);const Se=W.name==="globe";this.fogState&&P&&!Se&&(pe=function(rt,nt,lt,Xe,Ye,At){const ht=At.calculateFogTileMatrix(Ye),Bt=[nt,lt,Xe];return i.transformMat4(Bt,Bt,ht),Ne(rt,Bt,At.pitch,At._fov)}(this.fogState,m,b,S,P.toUnwrapped(),this.transform)>.9)}else hs(ee,ee,a);const fe=ee[3];return{point:new i.pointGeometry((ee[0]/fe+1)/2*this.transform.width+ho,(-ee[1]/fe+1)/2*this.transform.height+ho),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(W)/fe*.5,1.5),signedDistanceFromCamera:fe,occluded:H&&ee[2]>fe||pe}}isOffscreen(a,m,b,S){return b=this.screenRightBoundary||Sthis.screenBottomBoundary}isInsideGrid(a,m,b,S){return b>=0&&a=0&&mb.collisionGroupID===m}}return this.collisionGroups[a]}}function fs(x,a,m,b,S){const{horizontalAlign:P,verticalAlign:H}=i.getAnchorAlignment(x),W=-(P-.5)*a,ee=-(H-.5)*m,pe=i.evaluateVariableOffset(x,b);return new i.pointGeometry(W+pe[0]*S,ee+pe[1]*S)}function Rc(x,a,m,b,S){const P=new i.pointGeometry(x,a);return m&&P._rotate(b?S:-S),P}class Eh{constructor(a,m,b,S,P){this.transform=a.clone(),this.projection=a.projection.name,this.collisionIndex=new cl(this.transform,P),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=m,this.retainedQueryData={},this.collisionGroups=new Ys(b),this.collisionCircleArrays={},this.prevPlacement=S,S&&(S.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(a,m,b,S){const P=b.getBucket(m),H=b.latestFeatureIndex;if(!P||!H||m.id!==P.layerIds[0])return;const W=P.layers[0].layout,ee=b.collisionBoxArray,pe=Math.pow(2,this.transform.zoom-b.tileID.overscaledZ),fe=b.tileSize/i.EXTENT,Se=b.tileID.toUnwrapped();this.transform.setProjection(P.projection);const Qe=(rt=b.tileID,nt=P.getProjection(),lt=this.transform,nt.name===this.projection?lt.calculateProjMatrix(rt.toUnwrapped()):Na(lt,nt,rt));var rt,nt,lt;const Xe=W.get("text-pitch-alignment")==="map",Ye=W.get("text-rotation-alignment")==="map";m.compileFilter();const At=m.dynamicFilter(),ht=m.dynamicFilterNeedsFeature(),Bt=this.transform.calculatePixelsToTileUnitsMatrix(b),Pt=Oo(Qe,b.tileID.canonical,Xe,Ye,this.transform,P.getProjection(),Bt);let It=null;if(Xe){const si=ks(Qe,b.tileID.canonical,Xe,Ye,this.transform,P.getProjection(),Bt);It=i.multiply([],this.transform.labelPlaneMatrix,si)}let Ht=null;At&&b.latestFeatureIndex&&(Ht={unwrappedTileID:Se,dynamicFilter:At,dynamicFilterNeedsFeature:ht,featureIndex:b.latestFeatureIndex}),this.retainedQueryData[P.bucketInstanceId]=new ns(P.bucketInstanceId,H,P.sourceLayerIndex,P.index,b.tileID);const hi={bucket:P,layout:W,posMatrix:Qe,textLabelPlaneMatrix:Pt,labelToScreenMatrix:It,clippingData:Ht,scale:pe,textPixelRatio:fe,holdingForFade:b.holdingForFade(),collisionBoxArray:ee,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(P.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(P.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(P.sourceID)};if(S)for(const si of P.sortKeyRanges){const{sortKey:qt,symbolInstanceStart:ji,symbolInstanceEnd:Kt}=si;a.push({sortKey:qt,symbolInstanceStart:ji,symbolInstanceEnd:Kt,parameters:hi})}else a.push({symbolInstanceStart:0,symbolInstanceEnd:P.symbolInstances.length,parameters:hi})}attemptAnchorPlacement(a,m,b,S,P,H,W,ee,pe,fe,Se,Qe,rt,nt,lt,Xe,Ye,At){const{textOffset0:ht,textOffset1:Bt,crossTileID:Pt}=Qe,It=[ht,Bt],Ht=fs(a,b,S,It,P),hi=this.collisionIndex.placeCollisionBox(nt,P,m,Rc(Ht.x,Ht.y,H,W,this.transform.angle),Se,ee,pe,fe.predicate);if(Xe){const si=nt.getSymbolInstanceIconSize(At,this.transform.zoom,Qe.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(nt,si,Xe,Rc(Ht.x,Ht.y,H,W,this.transform.angle),Se,ee,pe,fe.predicate).box.length===0)return}if(hi.box.length>0){let si;return this.prevPlacement&&this.prevPlacement.variableOffsets[Pt]&&this.prevPlacement.placements[Pt]&&this.prevPlacement.placements[Pt].text&&(si=this.prevPlacement.variableOffsets[Pt].anchor),this.variableOffsets[Pt]={textOffset:It,width:b,height:S,anchor:a,textScale:P,prevAnchor:si},this.markUsedJustification(nt,a,Qe,lt),nt.allowVerticalPlacement&&(this.markUsedOrientation(nt,lt,Qe),this.placedOrientations[Pt]=lt),{shift:Ht,placedGlyphBoxes:hi}}}placeLayerBucketPart(a,m,b,S){const{bucket:P,layout:H,posMatrix:W,textLabelPlaneMatrix:ee,labelToScreenMatrix:pe,clippingData:fe,textPixelRatio:Se,holdingForFade:Qe,collisionBoxArray:rt,partiallyEvaluatedTextSize:nt,partiallyEvaluatedIconSize:lt,collisionGroup:Xe}=a.parameters,Ye=H.get("text-optional"),At=H.get("icon-optional"),ht=H.get("text-allow-overlap"),Bt=H.get("icon-allow-overlap"),Pt=H.get("text-rotation-alignment")==="map",It=H.get("text-pitch-alignment")==="map",Ht=H.get("icon-text-fit")!=="none",hi=H.get("symbol-z-order")==="viewport-y";this.transform.setProjection(P.projection);let si=ht&&(Bt||!P.hasIconData()||At),qt=Bt&&(ht||!P.hasTextData()||Ye);!P.collisionArrays&&rt&&P.deserializeCollisionBoxes(rt),b&&S&&P.updateCollisionDebugBuffers(this.transform.zoom,rt);const ji=(Kt,Bi,di)=>{const{crossTileID:Ri,numVerticalGlyphVertices:Ai}=Kt;if(fe){const _r={zoom:this.transform.zoom,pitch:this.transform.pitch};let Xr=null;if(fe.dynamicFilterNeedsFeature){const Fr=this.retainedQueryData[P.bucketInstanceId];Xr=fe.featureIndex.loadFeature({featureIndex:Kt.featureIndex,bucketIndex:Fr.bucketIndex,sourceLayerIndex:Fr.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,fe.dynamicFilter)(_r,Xr,this.retainedQueryData[P.bucketInstanceId].tileID.canonical,new i.pointGeometry(Kt.tileAnchorX,Kt.tileAnchorY),this.transform.calculateDistanceTileData(fe.unwrappedTileID)))return this.placements[Ri]=new Nl(!1,!1,!1,!0),void(m[Ri]=!0)}if(m[Ri])return;if(Qe)return void(this.placements[Ri]=new Nl(!1,!1,!1));let Mi=!1,$i=!1,Jt=!0,pi=!1,In=!1,Hn=null,Mn={box:null,offscreen:null,occluded:null},$n={box:null,offscreen:null,occluded:null},ar=null,On=null,_n=null,Dr=0,Or=0,Nr=0;di.textFeatureIndex?Dr=di.textFeatureIndex:Kt.useRuntimeCollisionCircles&&(Dr=Kt.featureIndex),di.verticalTextFeatureIndex&&(Or=di.verticalTextFeatureIndex);const Qr=_r=>{_r.tileID=this.retainedQueryData[P.bucketInstanceId].tileID;const Xr=this.transform.elevation;(Xr||_r.elevation)&&(_r.elevation=Xr?Xr.getAtTileOffset(_r.tileID,_r.tileAnchorX,_r.tileAnchorY):0)},go=di.textBox;if(go){Qr(go);const _r=Fr=>{let Ls=i.WritingMode.horizontal;if(P.allowVerticalPlacement&&!Fr&&this.prevPlacement){const eo=this.prevPlacement.placedOrientations[Ri];eo&&(this.placedOrientations[Ri]=eo,Ls=eo,this.markUsedOrientation(P,Ls,Kt))}return Ls},Xr=(Fr,Ls)=>{if(P.allowVerticalPlacement&&Ai>0&&di.verticalTextBox){for(const eo of P.writingModes)if(eo===i.WritingMode.vertical?(Mn=Ls(),$n=Mn):Mn=Fr(),Mn&&Mn.box&&Mn.box.length)break}else Mn=Fr()};if(H.get("text-variable-anchor")){let Fr=H.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[Ri]){const rs=this.prevPlacement.variableOffsets[Ri];Fr.indexOf(rs.anchor)>0&&(Fr=Fr.filter(Io=>Io!==rs.anchor),Fr.unshift(rs.anchor))}const Ls=(rs,Io,bu)=>{const Ka=P.getSymbolInstanceTextSize(nt,Kt,this.transform.zoom,Bi),_o=(rs.x2-rs.x1)*Ka+2*rs.padding,Ea=(rs.y2-rs.y1)*Ka+2*rs.padding,vl=Ht&&!Bt?Io:null;vl&&Qr(vl);let Zl={box:[],offscreen:!1,occluded:!1};const $h=ht?2*Fr.length:Fr.length;for(let Zh=0;Zh<$h;++Zh){const $a=this.attemptAnchorPlacement(Fr[Zh%Fr.length],rs,_o,Ea,Ka,Pt,It,Se,W,Xe,Zh>=Fr.length,Kt,Bi,P,bu,vl,nt,lt);if($a&&(Zl=$a.placedGlyphBoxes,Zl&&Zl.box&&Zl.box.length)){Mi=!0,Hn=$a.shift;break}}return Zl};Xr(()=>Ls(go,di.iconBox,i.WritingMode.horizontal),()=>{const rs=di.verticalTextBox;return rs&&Qr(rs),P.allowVerticalPlacement&&!(Mn&&Mn.box&&Mn.box.length)&&Ai>0&&rs?Ls(rs,di.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),Mn&&(Mi=Mn.box,Jt=Mn.offscreen,pi=Mn.occluded);const eo=_r(Mn&&Mn.box);if(!Mi&&this.prevPlacement){const rs=this.prevPlacement.variableOffsets[Ri];rs&&(this.variableOffsets[Ri]=rs,this.markUsedJustification(P,rs.anchor,Kt,eo))}}else{const Fr=(Ls,eo)=>{const rs=P.getSymbolInstanceTextSize(nt,Kt,this.transform.zoom,Bi),Io=this.collisionIndex.placeCollisionBox(P,rs,Ls,new i.pointGeometry(0,0),ht,Se,W,Xe.predicate);return Io&&Io.box&&Io.box.length&&(this.markUsedOrientation(P,eo,Kt),this.placedOrientations[Ri]=eo),Io};Xr(()=>Fr(go,i.WritingMode.horizontal),()=>{const Ls=di.verticalTextBox;return P.allowVerticalPlacement&&Ai>0&&Ls?(Qr(Ls),Fr(Ls,i.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),_r(Mn&&Mn.box&&Mn.box.length)}}if(ar=Mn,Mi=ar&&ar.box&&ar.box.length>0,Jt=ar&&ar.offscreen,pi=ar&&ar.occluded,Kt.useRuntimeCollisionCircles){const _r=P.text.placedSymbolArray.get(Kt.centerJustifiedTextSymbolIndex>=0?Kt.centerJustifiedTextSymbolIndex:Kt.verticalPlacedTextSymbolIndex),Xr=i.evaluateSizeForFeature(P.textSizeData,nt,_r),Fr=H.get("text-padding");On=this.collisionIndex.placeCollisionCircles(P,ht,_r,P.lineVertexArray,P.glyphOffsetArray,Xr,W,ee,pe,b,It,Xe.predicate,Kt.collisionCircleDiameter*Xr/i.ONE_EM,Fr,this.retainedQueryData[P.bucketInstanceId].tileID),Mi=ht||On.circles.length>0&&!On.collisionDetected,Jt=Jt&&On.offscreen,pi=On.occluded}if(di.iconFeatureIndex&&(Nr=di.iconFeatureIndex),di.iconBox){const _r=Xr=>{Qr(Xr);const Fr=Ht&&Hn?Rc(Hn.x,Hn.y,Pt,It,this.transform.angle):new i.pointGeometry(0,0),Ls=P.getSymbolInstanceIconSize(lt,this.transform.zoom,Kt.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(P,Ls,Xr,Fr,Bt,Se,W,Xe.predicate)};$n&&$n.box&&$n.box.length&&di.verticalIconBox?(_n=_r(di.verticalIconBox),$i=_n.box.length>0):(_n=_r(di.iconBox),$i=_n.box.length>0),Jt=Jt&&_n.offscreen,In=_n.occluded}const Ca=Ye||Kt.numHorizontalGlyphVertices===0&&Ai===0,jo=At||Kt.numIconVertices===0;if(Ca||jo?jo?Ca||($i=$i&&Mi):Mi=$i&&Mi:$i=Mi=$i&&Mi,Mi&&ar&&ar.box&&this.collisionIndex.insertCollisionBox(ar.box,H.get("text-ignore-placement"),P.bucketInstanceId,$n&&$n.box&&Or?Or:Dr,Xe.ID),$i&&_n&&this.collisionIndex.insertCollisionBox(_n.box,H.get("icon-ignore-placement"),P.bucketInstanceId,Nr,Xe.ID),On&&(Mi&&this.collisionIndex.insertCollisionCircles(On.circles,H.get("text-ignore-placement"),P.bucketInstanceId,Dr,Xe.ID),b)){const _r=P.bucketInstanceId;let Xr=this.collisionCircleArrays[_r];Xr===void 0&&(Xr=this.collisionCircleArrays[_r]=new Ql);for(let Fr=0;Fr=0;--Bi){const di=Kt[Bi];ji(P.symbolInstances.get(di),di,P.collisionArrays[di])}}else for(let Kt=a.symbolInstanceStart;Kt=0&&(a.text.placedSymbolArray.get(P).crossTileID=Se>=0&&P!==Se?0:pe),H>=0&&(a.text.placedSymbolArray.get(H).crossTileID=Se>=0&&H!==Se?0:pe),W>=0&&(a.text.placedSymbolArray.get(W).crossTileID=Se>=0&&W!==Se?0:pe),ee>=0&&(a.text.placedSymbolArray.get(ee).crossTileID=Se>=0&&ee!==Se?0:pe)}markUsedOrientation(a,m,b){const S=m===i.WritingMode.horizontal||m===i.WritingMode.horizontalOnly?m:0,P=m===i.WritingMode.vertical?m:0,{leftJustifiedTextSymbolIndex:H,centerJustifiedTextSymbolIndex:W,rightJustifiedTextSymbolIndex:ee,verticalPlacedTextSymbolIndex:pe}=b,fe=a.text.placedSymbolArray;H>=0&&(fe.get(H).placedOrientation=S),W>=0&&(fe.get(W).placedOrientation=S),ee>=0&&(fe.get(ee).placedOrientation=S),pe>=0&&(fe.get(pe).placedOrientation=P)}commit(a){this.commitTime=a,this.zoomAtLastRecencyCheck=this.transform.zoom;const m=this.prevPlacement;let b=!1;this.prevZoomAdjustment=m?m.zoomAdjustment(this.transform.zoom):0;const S=m?m.symbolFadeChange(a):1,P=m?m.opacities:{},H=m?m.variableOffsets:{},W=m?m.placedOrientations:{};for(const ee in this.placements){const pe=this.placements[ee],fe=P[ee];fe?(this.opacities[ee]=new Qa(fe,S,pe.text,pe.icon,null,pe.clipped),b=b||pe.text!==fe.text.placed||pe.icon!==fe.icon.placed):(this.opacities[ee]=new Qa(null,S,pe.text,pe.icon,pe.skipFade,pe.clipped),b=b||pe.text||pe.icon)}for(const ee in P){const pe=P[ee];if(!this.opacities[ee]){const fe=new Qa(pe,S,!1,!1);fe.isHidden()||(this.opacities[ee]=fe,b=b||pe.text.placed||pe.icon.placed)}}for(const ee in H)this.variableOffsets[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.variableOffsets[ee]=H[ee]);for(const ee in W)this.placedOrientations[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.placedOrientations[ee]=W[ee]);b?this.lastPlacementChangeTime=a:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=m?m.lastPlacementChangeTime:a)}updateLayerOpacities(a,m){const b={};for(const S of m){const P=S.getBucket(a);P&&S.latestFeatureIndex&&a.id===P.layerIds[0]&&this.updateBucketOpacities(P,b,S.collisionBoxArray)}}updateBucketOpacities(a,m,b){a.hasTextData()&&a.text.opacityVertexArray.clear(),a.hasIconData()&&a.icon.opacityVertexArray.clear(),a.hasIconCollisionBoxData()&&a.iconCollisionBox.collisionVertexArray.clear(),a.hasTextCollisionBoxData()&&a.textCollisionBox.collisionVertexArray.clear();const S=a.layers[0].layout,P=!!a.layers[0].dynamicFilter(),H=new Qa(null,0,!1,!1,!0),W=S.get("text-allow-overlap"),ee=S.get("icon-allow-overlap"),pe=S.get("text-variable-anchor"),fe=S.get("text-rotation-alignment")==="map",Se=S.get("text-pitch-alignment")==="map",Qe=S.get("icon-text-fit")!=="none",rt=new Qa(null,0,W&&(ee||!a.hasIconData()||S.get("icon-optional")),ee&&(W||!a.hasTextData()||S.get("text-optional")),!0);!a.collisionArrays&&b&&(a.hasIconCollisionBoxData()||a.hasTextCollisionBoxData())&&a.deserializeCollisionBoxes(b);const nt=(Xe,Ye,At)=>{for(let ht=0;ht0||ht>0,hi=Pt>0,si=this.placedOrientations[Bt],qt=si===i.WritingMode.vertical,ji=si===i.WritingMode.horizontal||si===i.WritingMode.horizontalOnly;if(!Ht&&!hi||It.isHidden()||lt++,Ht){const Kt=er(It.text);nt(a.text,At,qt?oc:Kt),nt(a.text,ht,ji?oc:Kt);const Bi=It.text.isHidden(),{leftJustifiedTextSymbolIndex:di,centerJustifiedTextSymbolIndex:Ri,rightJustifiedTextSymbolIndex:Ai,verticalPlacedTextSymbolIndex:Mi}=Ye,$i=a.text.placedSymbolArray,Jt=Bi||qt?1:0;di>=0&&($i.get(di).hidden=Jt),Ri>=0&&($i.get(Ri).hidden=Jt),Ai>=0&&($i.get(Ai).hidden=Jt),Mi>=0&&($i.get(Mi).hidden=Bi||ji?1:0);const pi=this.variableOffsets[Bt];pi&&this.markUsedJustification(a,pi.anchor,Ye,si);const In=this.placedOrientations[Bt];In&&(this.markUsedJustification(a,"left",Ye,In),this.markUsedOrientation(a,In,Ye))}if(hi){const Kt=er(It.icon),{placedIconSymbolIndex:Bi,verticalPlacedIconSymbolIndex:di}=Ye,Ri=a.icon.placedSymbolArray,Ai=It.icon.isHidden()?1:0;Bi>=0&&(nt(a.icon,Pt,qt?oc:Kt),Ri.get(Bi).hidden=Ai),di>=0&&(nt(a.icon,Ye.numVerticalIconVertices,ji?oc:Kt),Ri.get(di).hidden=Ai)}if(a.hasIconCollisionBoxData()||a.hasTextCollisionBoxData()){const Kt=a.collisionArrays[Xe];if(Kt){let Bi=new i.pointGeometry(0,0),di=!0;if(Kt.textBox||Kt.verticalTextBox){if(pe){const Ai=this.variableOffsets[Bt];Ai?(Bi=fs(Ai.anchor,Ai.width,Ai.height,Ai.textOffset,Ai.textScale),fe&&Bi._rotate(Se?this.transform.angle:-this.transform.angle)):di=!1}P&&(di=!It.clipped),Kt.textBox&&Os(a.textCollisionBox.collisionVertexArray,It.text.placed,!di||qt,Bi.x,Bi.y),Kt.verticalTextBox&&Os(a.textCollisionBox.collisionVertexArray,It.text.placed,!di||ji,Bi.x,Bi.y)}const Ri=di&&Boolean(!ji&&Kt.verticalIconBox);Kt.iconBox&&Os(a.iconCollisionBox.collisionVertexArray,It.icon.placed,Ri,Qe?Bi.x:0,Qe?Bi.y:0),Kt.verticalIconBox&&Os(a.iconCollisionBox.collisionVertexArray,It.icon.placed,!Ri,Qe?Bi.x:0,Qe?Bi.y:0)}}}if(a.fullyClipped=lt===0,a.sortFeatures(this.transform.angle),this.retainedQueryData[a.bucketInstanceId]&&(this.retainedQueryData[a.bucketInstanceId].featureSortOrder=a.featureSortOrder),a.hasTextData()&&a.text.opacityVertexBuffer&&a.text.opacityVertexBuffer.updateData(a.text.opacityVertexArray),a.hasIconData()&&a.icon.opacityVertexBuffer&&a.icon.opacityVertexBuffer.updateData(a.icon.opacityVertexArray),a.hasIconCollisionBoxData()&&a.iconCollisionBox.collisionVertexBuffer&&a.iconCollisionBox.collisionVertexBuffer.updateData(a.iconCollisionBox.collisionVertexArray),a.hasTextCollisionBoxData()&&a.textCollisionBox.collisionVertexBuffer&&a.textCollisionBox.collisionVertexBuffer.updateData(a.textCollisionBox.collisionVertexArray),a.bucketInstanceId in this.collisionCircleArrays){const Xe=this.collisionCircleArrays[a.bucketInstanceId];a.placementInvProjMatrix=Xe.invProjMatrix,a.placementViewportMatrix=Xe.viewportMatrix,a.collisionCircleArray=Xe.circles,delete this.collisionCircleArrays[a.bucketInstanceId]}}symbolFadeChange(a){return this.fadeDuration===0?1:(a-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(a){return Math.max(0,(this.transform.zoom-a)/1.5)}hasTransitions(a){return this.stale||a-this.lastPlacementChangeTimea}setStale(){this.stale=!0}}function Os(x,a,m,b,S){x.emplaceBack(a?1:0,m?1:0,b||0,S||0),x.emplaceBack(a?1:0,m?1:0,b||0,S||0),x.emplaceBack(a?1:0,m?1:0,b||0,S||0),x.emplaceBack(a?1:0,m?1:0,b||0,S||0)}const No=Math.pow(2,25),ed=Math.pow(2,24),pu=Math.pow(2,17),Cs=Math.pow(2,16),rc=Math.pow(2,9),Th=Math.pow(2,8),sc=Math.pow(2,1);function er(x){if(x.opacity===0&&!x.placed)return 0;if(x.opacity===1&&x.placed)return 4294967295;const a=x.placed?1:0,m=Math.floor(127*x.opacity);return m*No+a*ed+m*pu+a*Cs+m*rc+a*Th+m*sc+a}const oc=0;class Ju{constructor(a){this._sortAcrossTiles=a.layout.get("symbol-z-order")!=="viewport-y"&&a.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(a,m,b,S,P){const H=this._bucketParts;for(;this._currentTileIndexW.sortKey-ee.sortKey));this._currentPartIndex{const H=i.exported.now()-S;return!this._forceFullPlacement&&H>2};for(;this._currentPlacementIndex>=0;){const H=m[a[this._currentPlacementIndex]],W=this.placement.collisionIndex.transform.zoom;if(H.type==="symbol"&&(!H.minzoom||H.minzoom<=W)&&(!H.maxzoom||H.maxzoom>W)){if(this._inProgressLayer||(this._inProgressLayer=new Ju(H)),this._inProgressLayer.continuePlacement(b[H.source],this.placement,this._showCollisionBoxes,H,P))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(a){return this.placement.commit(a),this.placement}}const hl=512/i.EXTENT/2;class Sh{constructor(a,m,b){this.tileID=a,this.indexedSymbolInstances={},this.bucketInstanceId=b;for(let S=0;Sa.overscaledZ)for(const W in H){const ee=H[W];ee.tileID.isChildOf(a)&&ee.findMatches(m.symbolInstances,a,S)}else{const W=H[a.scaledTo(Number(P)).key];W&&W.findMatches(m.symbolInstances,a,S)}}for(let P=0;P{m[b]=!0});for(const b in this.layerIndexes)m[b]||delete this.layerIndexes[b]}}const ac=(x,a)=>i.emitValidationErrors(x,a&&a.filter(m=>m.identifier!=="source.canvas")),fu=i.pick(wi,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Vl=i.pick(wi,["setCenter","setZoom","setBearing","setPitch"]),ya={version:8,layers:[],sources:{}},zc={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Ws extends i.Evented{constructor(a,m={}){super(),this.map=a,this.dispatcher=new qe(jt(),this),this.imageManager=new oi,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(a._requestManager,m.localFontFamily?i.LocalGlyphMode.all:m.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,m.localFontFamily||m.localIdeographFontFamily),this.crossTileSymbolIndex=new Va,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",i.getReferrer());const b=this;this._rtlTextPluginCallback=Ws.registerForPluginStateChange(S=>{b.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:S.pluginStatus,pluginURL:S.pluginURL},(P,H)=>{if(i.triggerPluginCompletionEvent(P),H&&H.every(W=>W))for(const W in b._sourceCaches){const ee=b._sourceCaches[W],pe=ee.getSource().type;pe!=="vector"&&pe!=="geojson"||ee.reload()}})}),this.on("data",S=>{if(S.dataType!=="source"||S.sourceDataType!=="metadata")return;const P=this.getSource(S.sourceId);if(P&&P.vectorLayerIds)for(const H in this._layers){const W=this._layers[H];W.source===P.id&&this._validateLayer(W)}})}loadURL(a,m={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const b=typeof m.validate=="boolean"?m.validate:!i.isMapboxURL(a);a=this.map._requestManager.normalizeStyleURL(a,m.accessToken);const S=this.map._requestManager.transformRequest(a,i.ResourceType.Style);this._request=i.getJSON(S,(P,H)=>{this._request=null,P?this.fire(new i.ErrorEvent(P)):H&&this._load(H,b)})}loadJSON(a,m={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(a,m.validate!==!1)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(ya,!1)}_updateLayerCount(a,m){const b=m?1:-1;a.is3D()&&(this._num3DLayers+=b),a.type==="circle"&&(this._numCircleLayers+=b),a.type==="symbol"&&(this._numSymbolLayers+=b)}_load(a,m){if(m&&ac(this,i.validateStyle(a)))return;this._loaded=!0,this.stylesheet=i.clone$1(a),this._updateMapProjection();for(const S in a.sources)this.addSource(S,a.sources[S],{validate:!1});this._changed=!1,a.sprite?this._loadSprite(a.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(a.glyphs);const b=ki(this.stylesheet.layers);this._order=b.map(S=>S.id),this._layers={},this._serializedLayers={};for(let S of b)S=i.createStyleLayer(S),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 ce(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 i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(a){a?this.stylesheet.projection=a: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(a){this._spriteRequest=function(m,b,S){let P,H,W;const ee=i.exported.devicePixelRatio>1?"@2x":"";let pe=i.getJSON(b.transformRequest(b.normalizeSpriteURL(m,ee,".json"),i.ResourceType.SpriteJSON),(Qe,rt)=>{pe=null,W||(W=Qe,P=rt,Se())}),fe=i.getImage(b.transformRequest(b.normalizeSpriteURL(m,ee,".png"),i.ResourceType.SpriteImage),(Qe,rt)=>{fe=null,W||(W=Qe,H=rt,Se())});function Se(){if(W)S(W);else if(P&&H){const Qe=i.exported.getImageData(H),rt={};for(const nt in P){const{width:lt,height:Xe,x:Ye,y:At,sdf:ht,pixelRatio:Bt,stretchX:Pt,stretchY:It,content:Ht}=P[nt],hi=new i.RGBAImage({width:lt,height:Xe});i.RGBAImage.copy(Qe,hi,{x:Ye,y:At},{x:0,y:0},{width:lt,height:Xe}),rt[nt]={data:hi,pixelRatio:Bt,sdf:ht,stretchX:Pt,stretchY:It,content:Ht}}S(null,rt)}}return{cancel(){pe&&(pe.cancel(),pe=null),fe&&(fe.cancel(),fe=null)}}}(a,this.map._requestManager,(m,b)=>{if(this._spriteRequest=null,m)this.fire(new i.ErrorEvent(m));else if(b)for(const S in b)this.imageManager.addImage(S,b[S]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(a){const m=this.getSource(a.source);if(!m)return;const b=a.sourceLayer;b&&(m.type==="geojson"||m.vectorLayerIds&&m.vectorLayerIds.indexOf(b)===-1)&&this.fire(new i.ErrorEvent(new Error(`Source layer "${b}" does not exist on source "${m.id}" as specified by style layer "${a.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const a in this._sourceCaches)if(!this._sourceCaches[a].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(a){const m=[];for(const b of a){const S=this._layers[b];S.type!=="custom"&&m.push(S.serialize())}return m}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const a in this._sourceCaches)if(this._sourceCaches[a].hasTransition())return!0;for(const a in this._layers)if(this._layers[a].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(a){return!!this.terrain&&zc[a.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(a){if(!this._loaded)return;const m=this._changed;if(this._changed){const S=Object.keys(this._updatedLayers),P=Object.keys(this._removedLayers);(S.length||P.length)&&this._updateWorkerLayers(S,P);for(const H in this._updatedSources){const W=this._updatedSources[H];W==="reload"?this._reloadSource(H):W==="clear"&&this._clearSource(H)}this._updateTilesForChangedImages();for(const H in this._updatedPaintProps)this._layers[H].updateTransitions(a);this.light.updateTransitions(a),this.fog&&this.fog.updateTransitions(a),this._resetUpdates()}const b={};for(const S in this._sourceCaches){const P=this._sourceCaches[S];b[S]=P.used,P.used=!1}for(const S of this._order){const P=this._layers[S];if(P.recalculate(a,this._availableImages),!P.isHidden(a.zoom)){const W=this._getLayerSourceCache(P);W&&(W.used=!0)}const H=this.map.painter;if(H){const W=P.getProgramIds();if(!W)continue;const ee=P.getProgramConfiguration(a.zoom);for(const pe of W)H.useProgram(pe,ee)}}for(const S in b){const P=this._sourceCaches[S];b[S]!==P.used&&P.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:P.getSource().id}))}this.light.recalculate(a),this.terrain&&this.terrain.recalculate(a),this.fog&&this.fog.recalculate(a),this.z=a.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),m&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const a=Object.keys(this._changedImages);if(a.length){for(const m in this._sourceCaches)this._sourceCaches[m].reloadTilesForDependencies(["icons","patterns"],a);this._changedImages={}}}_updateWorkerLayers(a,m){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(a),removedIds:m})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(a){if(this._checkLoaded(),ac(this,i.validateStyle(a)))return!1;(a=i.clone$1(a)).layers=ki(a.layers);const m=function(S,P){if(!S)return[{command:wi.setStyle,args:[P]}];let H=[];try{if(!C(S.version,P.version))return[{command:wi.setStyle,args:[P]}];C(S.center,P.center)||H.push({command:wi.setCenter,args:[P.center]}),C(S.zoom,P.zoom)||H.push({command:wi.setZoom,args:[P.zoom]}),C(S.bearing,P.bearing)||H.push({command:wi.setBearing,args:[P.bearing]}),C(S.pitch,P.pitch)||H.push({command:wi.setPitch,args:[P.pitch]}),C(S.sprite,P.sprite)||H.push({command:wi.setSprite,args:[P.sprite]}),C(S.glyphs,P.glyphs)||H.push({command:wi.setGlyphs,args:[P.glyphs]}),C(S.transition,P.transition)||H.push({command:wi.setTransition,args:[P.transition]}),C(S.light,P.light)||H.push({command:wi.setLight,args:[P.light]}),C(S.fog,P.fog)||H.push({command:wi.setFog,args:[P.fog]}),C(S.projection,P.projection)||H.push({command:wi.setProjection,args:[P.projection]});const W={},ee=[];(function(Se,Qe,rt,nt){let lt;for(lt in Qe=Qe||{},Se=Se||{})Se.hasOwnProperty(lt)&&(Qe.hasOwnProperty(lt)||Yi(lt,rt,nt));for(lt in Qe)Qe.hasOwnProperty(lt)&&(Se.hasOwnProperty(lt)?C(Se[lt],Qe[lt])||(Se[lt].type==="geojson"&&Qe[lt].type==="geojson"&&rr(Se,Qe,lt)?rt.push({command:wi.setGeoJSONSourceData,args:[lt,Qe[lt].data]}):tn(lt,Qe,rt,nt)):Oi(lt,Qe,rt))})(S.sources,P.sources,ee,W);const pe=[];S.layers&&S.layers.forEach(Se=>{Se.source&&W[Se.source]?H.push({command:wi.removeLayer,args:[Se.id]}):pe.push(Se)});let fe=S.terrain;fe&&W[fe.source]&&(H.push({command:wi.setTerrain,args:[void 0]}),fe=void 0),H=H.concat(ee),C(fe,P.terrain)||H.push({command:wi.setTerrain,args:[P.terrain]}),function(Se,Qe,rt){Qe=Qe||[];const nt=(Se=Se||[]).map(Yt),lt=Qe.map(Yt),Xe=Se.reduce(sr,{}),Ye=Qe.reduce(sr,{}),At=nt.slice(),ht=Object.create(null);let Bt,Pt,It,Ht,hi,si,qt;for(Bt=0,Pt=0;Bt!(S.command in Vl));if(m.length===0)return!1;const b=m.filter(S=>!(S.command in fu));if(b.length>0)throw new Error(`Unimplemented: ${b.map(S=>S.command).join(", ")}.`);return m.forEach(S=>{S.command!=="setTransition"&&S.command!=="setProjection"&&this[S.command].apply(this,S.args)}),this.stylesheet=a,this._updateMapProjection(),!0}addImage(a,m){return this.getImage(a)?this.fire(new i.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(a,m),this._afterImageUpdated(a),this)}updateImage(a,m){this.imageManager.updateImage(a,m)}getImage(a){return this.imageManager.getImage(a)}removeImage(a){return this.getImage(a)?(this.imageManager.removeImage(a),this._afterImageUpdated(a),this):this.fire(new i.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(a){this._availableImages=this.imageManager.listImages(),this._changedImages[a]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(a,m,b={}){if(this._checkLoaded(),this.getSource(a)!==void 0)throw new Error("There is already a source with this ID");if(!m.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(m).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(m.type)>=0&&this._validate(i.validateSource,`sources.${a}`,m,null,b))return;this.map&&this.map._collectResourceTiming&&(m.collectResourceTiming=!0);const S=ie(a,m,this.dispatcher,this);S.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(a),source:S.serialize(),sourceId:a}));const P=H=>{const W=(H?"symbol:":"other:")+a,ee=this._sourceCaches[W]=new i.SourceCache(W,S,H);(H?this._symbolSourceCaches:this._otherSourceCaches)[a]=ee,ee.style=this,ee.onAdd(this.map)};P(!1),m.type!=="vector"&&m.type!=="geojson"||P(!0),S.onAdd&&S.onAdd(this.map),this._changed=!0}removeSource(a){this._checkLoaded();const m=this.getSource(a);if(!m)throw new Error("There is no source with this ID");for(const S in this._layers)if(this._layers[S].source===a)return this.fire(new i.ErrorEvent(new Error(`Source "${a}" cannot be removed while layer "${S}" is using it.`)));if(this.terrain&&this.terrain.get().source===a)return this.fire(new i.ErrorEvent(new Error(`Source "${a}" cannot be removed while terrain is using it.`)));const b=this._getSourceCaches(a);for(const S of b)delete this._sourceCaches[S.id],delete this._updatedSources[S.id],S.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:S.getSource().id})),S.setEventedParent(null),S.clearTiles();return delete this._otherSourceCaches[a],delete this._symbolSourceCaches[a],m.setEventedParent(null),m.onRemove&&m.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(a,m){this._checkLoaded(),this.getSource(a).setData(m),this._changed=!0}getSource(a){const m=this._getSourceCache(a);return m&&m.getSource()}_getSources(){const a=[];for(const m in this._otherSourceCaches){const b=this._getSourceCache(m);b&&a.push(b.getSource())}return a}addLayer(a,m,b={}){this._checkLoaded();const S=a.id;if(this.getLayer(S))return void this.fire(new i.ErrorEvent(new Error(`Layer with id "${S}" already exists on this map`)));let P;if(a.type==="custom"){if(ac(this,i.validateCustomStyleLayer(a)))return;P=i.createStyleLayer(a)}else{if(typeof a.source=="object"&&(this.addSource(S,a.source),a=i.clone$1(a),a=i.extend(a,{source:S})),this._validate(i.validateLayer,`layers.${S}`,a,{arrayIndex:-1},b))return;P=i.createStyleLayer(a),this._validateLayer(P),P.setEventedParent(this,{layer:{id:S}}),this._serializedLayers[P.id]=P.serialize(),this._updateLayerCount(P,!0)}const H=m?this._order.indexOf(m):this._order.length;if(m&&H===-1)return void this.fire(new i.ErrorEvent(new Error(`Layer with id "${m}" does not exist on this map.`)));this._order.splice(H,0,S),this._layerOrderChanged=!0,this._layers[S]=P;const W=this._getLayerSourceCache(P);if(this._removedLayers[S]&&P.source&&W&&P.type!=="custom"){const ee=this._removedLayers[S];delete this._removedLayers[S],ee.type!==P.type?this._updatedSources[P.source]="clear":(this._updatedSources[P.source]="reload",W.pause())}this._updateLayer(P),P.onAdd&&P.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(a,m){if(this._checkLoaded(),this._changed=!0,!this._layers[a])return void this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot be moved.`)));if(a===m)return;const b=this._order.indexOf(a);this._order.splice(b,1);const S=m?this._order.indexOf(m):this._order.length;m&&S===-1?this.fire(new i.ErrorEvent(new Error(`Layer with id "${m}" does not exist on this map.`))):(this._order.splice(S,0,a),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(a){this._checkLoaded();const m=this._layers[a];if(!m)return void this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot be removed.`)));m.setEventedParent(null),this._updateLayerCount(m,!1);const b=this._order.indexOf(a);this._order.splice(b,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[a]=m,delete this._layers[a],delete this._serializedLayers[a],delete this._updatedLayers[a],delete this._updatedPaintProps[a],m.onRemove&&m.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(a){return this._layers[a]}hasLayer(a){return a in this._layers}hasLayerType(a){for(const m in this._layers)if(this._layers[m].type===a)return!0;return!1}setLayerZoomRange(a,m,b){this._checkLoaded();const S=this.getLayer(a);S?S.minzoom===m&&S.maxzoom===b||(m!=null&&(S.minzoom=m),b!=null&&(S.maxzoom=b),this._updateLayer(S)):this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(a,m,b={}){this._checkLoaded();const S=this.getLayer(a);if(S){if(!C(S.filter,m))return m==null?(S.filter=void 0,void this._updateLayer(S)):void(this._validate(i.validateFilter,`layers.${S.id}.filter`,m,{layerType:S.type},b)||(S.filter=i.clone$1(m),this._updateLayer(S)))}else this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot be filtered.`)))}getFilter(a){const m=this.getLayer(a);return m&&i.clone$1(m.filter)}setLayoutProperty(a,m,b,S={}){this._checkLoaded();const P=this.getLayer(a);P?C(P.getLayoutProperty(m),b)||(P.setLayoutProperty(m,b,S),this._updateLayer(P)):this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(a,m){const b=this.getLayer(a);if(b)return b.getLayoutProperty(m);this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style.`)))}setPaintProperty(a,m,b,S={}){this._checkLoaded();const P=this.getLayer(a);P?C(P.getPaintProperty(m),b)||(P.setPaintProperty(m,b,S)&&this._updateLayer(P),this._changed=!0,this._updatedPaintProps[a]=!0):this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(a,m){const b=this.getLayer(a);return b&&b.getPaintProperty(m)}setFeatureState(a,m){this._checkLoaded();const b=a.source,S=a.sourceLayer,P=this.getSource(b);if(!P)return void this.fire(new i.ErrorEvent(new Error(`The source '${b}' does not exist in the map's style.`)));const H=P.type;if(H==="geojson"&&S)return void this.fire(new i.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(H==="vector"&&!S)return void this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));a.id===void 0&&this.fire(new i.ErrorEvent(new Error("The feature id parameter must be provided.")));const W=this._getSourceCaches(b);for(const ee of W)ee.setFeatureState(S,a.id,m)}removeFeatureState(a,m){this._checkLoaded();const b=a.source,S=this.getSource(b);if(!S)return void this.fire(new i.ErrorEvent(new Error(`The source '${b}' does not exist in the map's style.`)));const P=S.type,H=P==="vector"?a.sourceLayer:void 0;if(P==="vector"&&!H)return void this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(m&&typeof a.id!="string"&&typeof a.id!="number")return void this.fire(new i.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const W=this._getSourceCaches(b);for(const ee of W)ee.removeFeatureState(H,a.id,m)}getFeatureState(a){this._checkLoaded();const m=a.source,b=a.sourceLayer,S=this.getSource(m);if(S){if(S.type!=="vector"||b)return a.id===void 0&&this.fire(new i.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(m)[0].getFeatureState(b,a.id);this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(new Error(`The source '${m}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const a={};for(const m in this._sourceCaches){const b=this._sourceCaches[m].getSource();a[b.id]||(a[b.id]=b.serialize())}return i.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:a,layers:this._serializeLayers(this._order)},m=>m!==void 0)}_updateLayer(a){this._updatedLayers[a.id]=!0;const m=this._getLayerSourceCache(a);a.source&&!this._updatedSources[a.source]&&m&&m.getSource().type!=="raster"&&(this._updatedSources[a.source]="reload",m.pause()),this._changed=!0,a.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(a){const m=H=>this._layers[H].type==="fill-extrusion",b={},S=[];for(let H=this._order.length-1;H>=0;H--){const W=this._order[H];if(m(W)){b[W]=H;for(const ee of a){const pe=ee[W];if(pe)for(const fe of pe)S.push(fe)}}}S.sort((H,W)=>W.intersectionZ-H.intersectionZ);const P=[];for(let H=this._order.length-1;H>=0;H--){const W=this._order[H];if(m(W))for(let ee=S.length-1;ee>=0;ee--){const pe=S[ee].feature;if(b[pe.layer.id]{const pe=this.getLayer(ee);return pe&&pe.is3D()}):this.has3DLayers(),W=vt.createFromScreenPoints(a,b);for(const ee in this._sourceCaches){const pe=this._sourceCaches[ee].getSource().id;m.layers&&!S[pe]||P.push(de(this._sourceCaches[ee],this._layers,this._serializedLayers,W,m,b,H,!!this.map._showQueryGeometry))}return this.placement&&P.push(function(ee,pe,fe,Se,Qe,rt,nt){const lt={},Xe=rt.queryRenderedSymbols(Se),Ye=[];for(const At of Object.keys(Xe).map(Number))Ye.push(nt[At]);Ye.sort(tt);for(const At of Ye){const ht=At.featureIndex.lookupSymbolFeatures(Xe[At.bucketInstanceId],pe,At.bucketIndex,At.sourceLayerIndex,Qe.filter,Qe.layers,Qe.availableImages,ee);for(const Bt in ht){const Pt=lt[Bt]=lt[Bt]||[],It=ht[Bt];It.sort((Ht,hi)=>{const si=At.featureSortOrder;if(si){const qt=si.indexOf(Ht.featureIndex);return si.indexOf(hi.featureIndex)-qt}return hi.featureIndex-Ht.featureIndex});for(const Ht of It)Pt.push(Ht)}}for(const At in lt)lt[At].forEach(ht=>{const Bt=ht.feature,Pt=fe(ee[At]).getFeatureState(Bt.layer["source-layer"],Bt.id);Bt.source=Bt.layer.source,Bt.layer["source-layer"]&&(Bt.sourceLayer=Bt.layer["source-layer"]),Bt.state=Pt});return lt}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),W.screenGeometry,m,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(P)}querySourceFeatures(a,m){m&&m.filter&&this._validate(i.validateFilter,"querySourceFeatures.filter",m.filter,null,m);const b=this._getSourceCaches(a);let S=[];for(const P of b)S=S.concat(Re(P,m));return S}addSourceType(a,m,b){return Ws.getSourceType(a)?b(new Error(`A source type called "${a}" already exists.`)):(Ws.setSourceType(a,m),m.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:a,url:m.workerSourceURL},b):b(null,null))}getLight(){return this.light.getLight()}setLight(a,m={}){this._checkLoaded();const b=this.light.getLight();let S=!1;for(const H in a)if(!C(a[H],b[H])){S=!0;break}if(!S)return;const P=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(a,m),this.light.updateTransitions(P)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(a,m=1){if(this._checkLoaded(),!a)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(m===1){if(typeof a.source=="object"){const b="terrain-dem-src";this.addSource(b,a.source),a=i.clone$1(a),a=i.extend(a,{source:b})}if(this._validate(i.validateTerrain,"terrain",a))return}if(!this.terrain||this.terrain&&m!==this.terrain.drapeRenderMode)this._createTerrain(a,m);else{const b=this.terrain,S=b.get();for(const P of Object.keys(i.spec.terrain))!a.hasOwnProperty(P)&&i.spec.terrain[P].default&&(a[P]=i.spec.terrain[P].default);for(const P in a)if(!C(a[P],S[P])){b.set(a),this.stylesheet.terrain=a;const H=this._setTransitionParameters({duration:0});b.updateTransitions(H);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(a){const m=this.fog=new Ie(a,this.map.transform);this.stylesheet.fog=a;const b=this._setTransitionParameters({duration:0});m.updateTransitions(b)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const a of this.map._markers)a._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(a){if(this._checkLoaded(),!a)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const m=this.fog,b=m.get();Object.keys(a).length===0&&m.set(a);for(const S in a)if(!C(a[S],b[S])){m.set(a),this.stylesheet.fog=a;const P=this._setTransitionParameters({duration:0});m.updateTransitions(P);break}}else this._createFog(a);this._markersNeedUpdate=!0}_setTransitionParameters(a){return{now:i.exported.now(),transition:i.extend(a,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const a=this._order.filter(b=>this.isLayerDraped(this._layers[b])),m=this._order.filter(b=>!this.isLayerDraped(this._layers[b]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...a),this._drapedFirstOrder.push(...m)}_createTerrain(a,m){const b=this.terrain=new ze(a,m);this.stylesheet.terrain=a,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const S=this._setTransitionParameters({duration:0});b.updateTransitions(S)}_force3DLayerUpdate(){for(const a in this._layers){const m=this._layers[a];m.type==="fill-extrusion"&&this._updateLayer(m)}}_forceSymbolLayerUpdate(){for(const a in this._layers){const m=this._layers[a];m.type==="symbol"&&this._updateLayer(m)}}_validate(a,m,b,S,P={}){return(!P||P.validate!==!1)&&ac(this,a.call(i.validateStyle,i.extend({key:m,style:this.serialize(),value:b,styleSpec:i.spec},S)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const a in this._layers)this._layers[a].setEventedParent(null);for(const a in this._sourceCaches)this._sourceCaches[a].clearTiles(),this._sourceCaches[a].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(a){const m=this._getSourceCaches(a);for(const b of m)b.clearTiles()}_reloadSource(a){const m=this._getSourceCaches(a);for(const b of m)b.resume(),b.reload()}_reloadSources(){for(const a of this._getSources())a.reload&&a.reload()}_updateSources(a){for(const m in this._sourceCaches)this._sourceCaches[m].update(a)}_generateCollisionBoxes(){for(const a in this._sourceCaches){const m=this._sourceCaches[a];m.resume(),m.reload()}}_updatePlacement(a,m,b,S,P=!1){let H=!1,W=!1;const ee={};for(const pe of this._order){const fe=this._layers[pe];if(fe.type!=="symbol")continue;if(!ee[fe.source]){const Qe=this._getLayerSourceCache(fe);if(!Qe)continue;ee[fe.source]=Qe.getRenderableIds(!0).map(rt=>Qe.getTileByID(rt)).sort((rt,nt)=>nt.tileID.overscaledZ-rt.tileID.overscaledZ||(rt.tileID.isLessThan(nt.tileID)?-1:1))}const Se=this.crossTileSymbolIndex.addLayer(fe,ee[fe.source],a.center.lng,a.projection);H=H||Se}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),P=P||this._layerOrderChanged||b===0,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(P||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),a.zoom))&&(this.pauseablePlacement=new Qo(a,this._order,P,m,b,S,this.placement,this.fog&&a.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,ee),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),W=!0),H&&this.pauseablePlacement.placement.setStale()),W||H)for(const pe of this._order){const fe=this._layers[pe];fe.type==="symbol"&&this.placement.updateLayerOpacities(fe,ee[fe.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const a in this._sourceCaches)this._sourceCaches[a].releaseSymbolFadeTiles()}getImages(a,m,b){this.imageManager.getImages(m.icons,b),this._updateTilesForChangedImages();const S=P=>{P&&P.setDependencies(m.tileID.key,m.type,m.icons)};S(this._otherSourceCaches[m.source]),S(this._symbolSourceCaches[m.source])}getGlyphs(a,m,b){this.glyphManager.getGlyphs(m.stacks,b)}getResource(a,m,b){return i.makeRequest(m,b)}_getSourceCache(a){return this._otherSourceCaches[a]}_getLayerSourceCache(a){return a.type==="symbol"?this._symbolSourceCaches[a.source]:this._otherSourceCaches[a.source]}_getSourceCaches(a){const m=[];return this._otherSourceCaches[a]&&m.push(this._otherSourceCaches[a]),this._symbolSourceCaches[a]&&m.push(this._symbolSourceCaches[a]),m}_isSourceCacheLoaded(a){const m=this._getSourceCaches(a);return m.length===0?(this.fire(new i.ErrorEvent(new Error(`There is no source with ID '${a}'`))),!1):m.every(b=>b.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)}}Ws.getSourceType=function(x){return j[x]},Ws.setSourceType=function(x,a){j[x]=a},Ws.registerForPluginStateChange=i.registerForPluginStateChange;var lc=` #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`,kc="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;}",eA=` #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 #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`,cc=`#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`,mu=`#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 td={},gu={};const Ih=[];ul(lc,Ih),ul(eA,Ih),ul(cc,Ih),ul(mu,Ih),td=Ir("",eA),gu=Ir(mu,cc);const tA=Ir(` 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;}`,` 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.`),id=lc,hc=` #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 Oc={background:Ir(`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:Ir(`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:Ir(`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:Ir("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:Ir(`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:Ir(`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:Ir("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:Ir("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:Ir("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:Ir(`#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:Ir(`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:Ir(`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:Ir(`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:Ir(`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:Ir(`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:Ir(`#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:Ir(`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:Ir(`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 #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);}} #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,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:Ir(`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:Ir(`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:Ir(`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:Ir(`#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:Ir(`#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:Ir(`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;attribute vec2 a_texture_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 skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height; #ifdef TERRAIN_WIREFRAME elevation+=u_skirt_height*u_skirt_height*wireframeOffset; #endif vec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.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:Ir(`#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;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:Ir(` 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 }`,kc),skyboxGradient:Ir(`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 }`,kc),skyboxCapture:Ir(` 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:Ir(`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; #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 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=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; #ifdef GLOBE_POLES vec3 up_vector=normalize(globe_pos)*u_tile_up_scale; #else vec3 up_vector=elevationVector(tile_pos); #endif float height=elevation(tile_pos); #ifdef TERRAIN_WIREFRAME height+=wireframeOffset; #endif globe_pos+=up_vector*height; #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,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:Ir(`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 ul(x,a){const m=x.replace(/\s*\/\/[^\n]*\n/g,` `).split(` `);for(let b of m)if(b=b.trim(),b[0]==="#"&&b.includes("if")&&!b.includes("endif")){b=b.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const S=b.split(" ");for(const P of S)a.includes(P)||a.push(P)}}function Ir(x,a){const m=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,b=a.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),S={},P=[...Ih];return ul(x,P),ul(a,P),{fragmentSource:x=x.replace(m,(H,W,ee,pe,fe)=>(S[fe]=!0,W==="define"?` #ifndef HAS_UNIFORM_u_${fe} varying ${ee} ${pe} ${fe}; #else uniform ${ee} ${pe} u_${fe}; #endif `:` #ifdef HAS_UNIFORM_u_${fe} ${ee} ${pe} ${fe} = u_${fe}; #endif `)),vertexSource:a=a.replace(m,(H,W,ee,pe,fe)=>{const Se=pe==="float"?"vec2":"vec4",Qe=fe.match(/color/)?"color":Se;return S[fe]?W==="define"?` #ifndef HAS_UNIFORM_u_${fe} uniform lowp float u_${fe}_t; attribute ${ee} ${Se} a_${fe}; varying ${ee} ${pe} ${fe}; #else uniform ${ee} ${pe} u_${fe}; #endif `:Qe==="vec4"?` #ifndef HAS_UNIFORM_u_${fe} ${fe} = a_${fe}; #else ${ee} ${pe} ${fe} = u_${fe}; #endif `:` #ifndef HAS_UNIFORM_u_${fe} ${fe} = unpack_mix_${Qe}(a_${fe}, u_${fe}_t); #else ${ee} ${pe} ${fe} = u_${fe}; #endif `:W==="define"?` #ifndef HAS_UNIFORM_u_${fe} uniform lowp float u_${fe}_t; attribute ${ee} ${Se} a_${fe}; #else uniform ${ee} ${pe} u_${fe}; #endif `:Qe==="vec4"?` #ifndef HAS_UNIFORM_u_${fe} ${ee} ${pe} ${fe} = a_${fe}; #else ${ee} ${pe} ${fe} = u_${fe}; #endif `:` #ifndef HAS_UNIFORM_u_${fe} ${ee} ${pe} ${fe} = unpack_mix_${Qe}(a_${fe}, u_${fe}_t); #else ${ee} ${pe} ${fe} = u_${fe}; #endif `}),staticAttributes:b,usedDefines:P}}class uc{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(a,m,b,S,P,H,W){this.context=a;let ee=this.boundPaintVertexBuffers.length!==S.length;for(let fe=0;!ee&&fe{const ht=Ye.paint.get("hillshade-shadow-color"),Bt=Ye.paint.get("hillshade-highlight-color"),Pt=Ye.paint.get("hillshade-accent-color");let It=Ye.paint.get("hillshade-illumination-direction")*(Math.PI/180);Ye.paint.get("hillshade-illumination-anchor")==="viewport"&&(It-=lt.transform.angle);const Ht=!lt.options.moving;return{u_matrix:At||lt.transform.calculateProjMatrix(Xe.tileID.toUnwrapped(),Ht),u_image:0,u_latrange:Nc(0,Xe.tileID),u_light:[Ye.paint.get("hillshade-exaggeration"),It],u_shadow:ht,u_highlight:Bt,u_accent:Pt}})(x,m,b,x.terrain?a.projMatrix:null);x.prepareDrawProgram(W,fe,a.toUnwrapped());const{tileBoundsBuffer:Qe,tileBoundsIndexBuffer:rt,tileBoundsSegments:nt}=x.getTileBoundsBuffers(m);fe.draw(W,ee.TRIANGLES,S,P,H,i.CullFaceMode.disabled,Se,b.id,Qe,rt,nt)}function Al(x,a,m){if(!a.needsDEMTextureUpload)return;const b=x.context,S=b.gl;b.pixelStoreUnpackPremultiplyAlpha.set(!1),a.demTexture=a.demTexture||x.getTileTexture(m.stride);const P=m.getPixels();a.demTexture?a.demTexture.update(P,{premultiply:!1}):a.demTexture=new i.Texture(b,P,S.RGBA,{premultiply:!1}),a.needsDEMTextureUpload=!1}function Ha(x,a,m,b,S,P){const H=x.context,W=H.gl;if(!a.dem)return;const ee=a.dem;if(H.activeTexture.set(W.TEXTURE1),Al(x,a,ee),!a.demTexture)return;a.demTexture.bind(W.NEAREST,W.CLAMP_TO_EDGE);const pe=ee.dim;H.activeTexture.set(W.TEXTURE0);let fe=a.fbo;if(!fe){const nt=new i.Texture(H,{width:pe,height:pe,data:null},W.RGBA);nt.bind(W.LINEAR,W.CLAMP_TO_EDGE),fe=a.fbo=H.createFramebuffer(pe,pe,!0),fe.colorAttachment.set(nt.texture)}H.bindFramebuffer.set(fe.framebuffer),H.viewport.set([0,0,pe,pe]);const{tileBoundsBuffer:Se,tileBoundsIndexBuffer:Qe,tileBoundsSegments:rt}=x.getMercatorTileBoundsBuffers();x.useProgram("hillshadePrepare").draw(H,W.TRIANGLES,b,S,P,i.CullFaceMode.disabled,((nt,lt)=>{const Xe=lt.stride,Ye=i.create();return i.ortho(Ye,0,i.EXTENT,-i.EXTENT,0,0,1),i.translate(Ye,Ye,[0,-i.EXTENT,0]),{u_matrix:Ye,u_image:1,u_dimension:[Xe,Xe],u_zoom:nt.overscaledZ,u_unpack:lt.unpackVector}})(a.tileID,ee),m.id,Se,Qe,rt),a.needsHillshadePrepare=!1}const Qc=x=>({u_matrix:new i.UniformMatrix4f(x),u_image0:new i.Uniform1i(x),u_skirt_height:new i.Uniform1f(x)}),dl=(x,a)=>({u_matrix:x,u_image0:0,u_skirt_height:a}),qr=(x,a,m,b,S,P,H,W,ee,pe,fe,Se,Qe,rt)=>({u_proj_matrix:Float32Array.from(x),u_globe_matrix:a,u_normalize_matrix:Float32Array.from(b),u_merc_matrix:m,u_zoom_transition:S,u_merc_center:P,u_image0:0,u_frustum_tl:H,u_frustum_tr:W,u_frustum_br:ee,u_frustum_bl:pe,u_globe_pos:fe,u_globe_radius:Se,u_viewport:Qe,u_grid_matrix:rt?Float32Array.from(rt):new Float32Array(9)});function Fh(x,a){return x!=null&&a!=null&&!(!x.hasData()||!a.hasData())&&x.demTexture!=null&&a.demTexture!=null&&x.tileID.key!==a.tileID.key}const hr=new class{constructor(){this.operations={}}newMorphing(x,a,m,b,S){if(x in this.operations){const P=this.operations[x];P.to.tileID.key!==m.tileID.key&&(P.queued=m)}else this.operations[x]={startTime:b,phase:0,duration:S,from:a,to:m,queued:null}}getMorphValuesForProxy(x){if(!(x in this.operations))return null;const a=this.operations[x];return{from:a.from,to:a.to,phase:a.phase}}update(x){for(const a in this.operations){const m=this.operations[a];for(m.phase=(x-m.startTime)/m.duration;m.phase>=1||!this._validOp(m);)if(!this._nextOp(m,x)){delete this.operations[a];break}}}_nextOp(x,a){return!!x.queued&&(x.from=x.to,x.to=x.queued,x.queued=null,x.phase=0,x.startTime=a,!0)}_validOp(x){return x.from.hasData()&&x.to.hasData()}},Br={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function jr(x,a){const m=1<({u_matrix:x});function Hl(x,a,m,b,S){if(S>0){const P=i.exported.now(),H=(P-x.timeAdded)/S,W=a?(P-a.timeAdded)/S:-1,ee=m.getSource(),pe=b.coveringZoomLevel({tileSize:ee.tileSize,roundZoom:ee.roundZoom}),fe=!a||Math.abs(a.tileID.overscaledZ-pe)>Math.abs(x.tileID.overscaledZ-pe),Se=fe&&x.refreshedUponExpiration?1:i.clamp(fe?H:1-W,0,1);return x.refreshedUponExpiration&&H>=1&&(x.refreshedUponExpiration=!1),a?{opacity:1,mix:1-Se}:{opacity:Se,mix:0}}return{opacity:1,mix:0}}class gr extends i.SourceCache{constructor(a){const m={type:"raster-dem",maxzoom:a.transform.maxZoom},b=new qe(jt(),null),S=ie("mock-dem",m,b,a.style);super("mock-dem",S,!1),S.setEventedParent(this),this._sourceLoaded=!0}_loadTile(a,m){a.state="loaded",m(null)}}class yu extends i.SourceCache{constructor(a){const m=ie("proxy",{type:"geojson",maxzoom:a.transform.maxZoom},new qe(jt(),null),a.style);super("proxy",m,!1),m.setEventedParent(this),this.map=this.getSource().map=a,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(a,m,b){if(a.freezeTileCoverage)return;this.transform=a;const S=a.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((P,H)=>{if(P[H.key]="",!this._tiles[H.key]){const W=new i.Tile(H,this._source.tileSize*H.overscaleFactor(),a.tileZoom);W.state="loaded",this._tiles[H.key]=W}return P},{});for(const P in this._tiles)P in S||(this.freeFBO(P),this._tiles[P].unloadVectorData(),delete this._tiles[P])}freeFBO(a){const m=this.proxyCachedFBO[a];if(m!==void 0){const b=Object.values(m);this.renderCachePool.push(...b),delete this.proxyCachedFBO[a]}}deallocRenderCache(){this.renderCache.forEach(a=>a.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class iA extends i.OverscaledTileID{constructor(a,m,b){super(a.overscaledZ,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y),this.proxyTileKey=m,this.projMatrix=b}}class nA extends i.Elevation{constructor(a,m){super(),this.painter=a,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[b,S,P]=function(ee){const pe=new i.StructArrayLayout4i8,fe=new i.StructArrayLayout3ui6,Se=131;pe.reserve(17161),fe.reserve(33800);const Qe=i.EXTENT/128,rt=i.EXTENT+Qe/2,nt=rt+Qe;for(let Xe=-Qe;Xert||Xe<0||Xe>rt?24575:0,ht=i.clamp(Math.round(Ye),0,i.EXTENT),Bt=i.clamp(Math.round(Xe),0,i.EXTENT);pe.emplaceBack(ht+At,Bt,ht,Bt)}const lt=(Xe,Ye)=>{const At=Ye*Se+Xe;fe.emplaceBack(At+1,At,At+Se),fe.emplaceBack(At+Se,At+Se+1,At+1)};for(let Xe=1;Xe<129;Xe++)for(let Ye=1;Ye<129;Ye++)lt(Ye,Xe);return[0,129].forEach(Xe=>{for(let Ye=0;Ye<130;Ye++)lt(Ye,Xe),lt(Xe,Ye)}),[pe,fe,32768]}(),H=a.context;this.gridBuffer=H.createVertexBuffer(b,i.boundsAttributes.members),this.gridIndexBuffer=H.createIndexBuffer(S),this.gridSegments=i.SegmentVector.simpleSegment(0,0,b.length,S.length),this.gridNoSkirtSegments=i.SegmentVector.simpleSegment(0,0,b.length,P),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new yu(m.map),this.orthoMatrix=i.create(),i.ortho(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,i.EXTENT,0,i.EXTENT,0,1);const W=H.gl;this._overlapStencilMode=new i.StencilMode({func:W.GEQUAL,mask:255},0,255,W.KEEP,W.KEEP,W.REPLACE),this._previousZoom=a.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=m,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new gr(m.map)}set style(a){a.on("data",this._onStyleDataEvent.bind(this)),a.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=a,this._checkRenderCacheEfficiency()}update(a,m,b){if(a&&a.terrain){this._style!==a&&(this.style=a),this.enabled=!0;const S=a.terrain.properties;this.sourceCache=a.terrain.drapeRenderMode===0?this._mockSourceCache:a._getSourceCache(S.get("source")),this._exaggeration=S.get("exaggeration");const P=()=>{this.sourceCache.used&&i.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 H=this.getScaledDemTileSize();this.sourceCache.update(m,H,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,P(),this._initializing=!0),P(),m.updateElevation(!0,b),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(m),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(a){this._findCoveringTileCache[a]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const a=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||a.efficiency!==100&&i.warnOnce(`Terrain render cache efficiency is not optimal (${a.efficiency}%) and performance may be affected negatively, consider placing all background, fill and line layers before layer with id '${a.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(a){a.coord&&a.dataType==="source"?this._clearRenderCacheForTile(a.sourceCacheId,a.coord):a.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const a in this._style._sourceCaches)this._style._sourceCaches[a].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(a=>a.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 a=2*this.proxySourceCache.getSource().tileSize;return[a,a]}set useVertexMorphing(a){this._useVertexMorphing=a}updateTileBinding(a){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const m=this.proxySourceCache,b=this.painter.transform;this._initializing&&(this._initializing=b._centerAltitude===0&&this.getAtPointOrZero(i.MercatorCoordinate.fromLngLat(b.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const S=this.proxyCoords=m.getIds().map(ee=>{const pe=m.getTileByID(ee).tileID;return pe.projMatrix=b.calculateProjMatrix(pe.toUnwrapped()),pe});(function(ee,pe){const fe=pe.transform.pointCoordinate(pe.transform.getCameraPoint()),Se=new i.pointGeometry(fe.x,fe.y);ee.sort((Qe,rt)=>{if(rt.overscaledZ-Qe.overscaledZ)return rt.overscaledZ-Qe.overscaledZ;const nt=new i.pointGeometry(Qe.canonical.x+(1<{this.proxyToSource[ee.key]={}}),this.terrainTileForTile={};const H=this._style._sourceCaches;for(const ee in H){const pe=H[ee];if(!pe.used||(pe!==this.sourceCache&&this.resetTileLookupCache(pe.id),this._setupProxiedCoordsForOrtho(pe,a[ee],P),pe.usedForTerrain))continue;const fe=a[ee];pe.getSource().reparseOverscaled&&this._assignTerrainTiles(fe)}this.proxiedCoords[m.id]=S.map(ee=>new iA(ee,ee.key,this.orthoMatrix)),this._assignTerrainTiles(S),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(P),this.renderingToTexture=!1,this._updateTimestamp=i.exported.now();const W={};this._visibleDemTiles=[];for(const ee of this.proxyCoords){const pe=this.terrainTileForTile[ee.key];if(!pe)continue;const fe=pe.tileID.key;fe in W||(this._visibleDemTiles.push(pe),W[fe]=fe)}}_assignTerrainTiles(a){this._initializing||a.forEach(m=>{if(this.terrainTileForTile[m.key])return;const b=this._findTileCoveringTileID(m,this.sourceCache);b&&(this.terrainTileForTile[m.key]=b)})}_prepareDEMTextures(){const a=this.painter.context,m=a.gl;for(const b in this.terrainTileForTile){const S=this.terrainTileForTile[b],P=S.dem;!P||S.demTexture&&!S.needsDEMTextureUpload||(a.activeTexture.set(m.TEXTURE1),Al(this.painter,S,P))}}_prepareDemTileUniforms(a,m,b,S){if(!m||m.demTexture==null)return!1;const P=a.tileID.canonical,H=Math.pow(2,m.tileID.canonical.z-P.z),W=S||"";return b[`u_dem_tl${W}`]=[P.x*H%1,P.y*H%1],b[`u_dem_scale${W}`]=H,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const a=this.painter.context,m=a.gl;if(!this._emptyDepthBufferTexture){const b=new i.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new i.Texture(a,b,m.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let a=0;const m=this._visibleDemTiles.reduce((b,S)=>{if(!S.dem)return b;const P=S.dem.tree.minimums[0];return P>0&&a++,b+P},0);return a?m/a:0}_updateEmptyDEMTexture(){const a=this.painter.context,m=a.gl;a.activeTexture.set(m.TEXTURE2);const b=this._getLoadedAreaMinimum(),S=new i.RGBAImage({width:1,height:1},new Uint8Array(i.DEMData.pack(b,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let P=this._emptyDEMTexture;return P?P.update(S,{premultiply:!1}):P=this._emptyDEMTexture=new i.Texture(a,S,m.RGBA,{premultiply:!1}),P}setupElevationDraw(a,m,b){const S=this.painter.context,P=S.gl,H=(W=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:i.DEMData.getUnpackVector(W),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 W;H.u_dem_size=this.sourceCache.getSource().tileSize,H.u_exaggeration=this.exaggeration();let ee=null,pe=null,fe=1;if(b&&b.morphing&&this._useVertexMorphing){const Se=b.morphing.srcDemTile,Qe=b.morphing.dstDemTile;fe=b.morphing.phase,Se&&Qe&&(this._prepareDemTileUniforms(a,Se,H,"_prev")&&(pe=Se),this._prepareDemTileUniforms(a,Qe,H)&&(ee=Qe))}if(pe&&ee?(S.activeTexture.set(P.TEXTURE2),ee.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE,P.NEAREST),S.activeTexture.set(P.TEXTURE4),pe.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE,P.NEAREST),H.u_dem_lerp=fe):(ee=this.terrainTileForTile[a.tileID.key],S.activeTexture.set(P.TEXTURE2),(this._prepareDemTileUniforms(a,ee,H)?ee.demTexture:this.emptyDEMTexture).bind(P.NEAREST,P.CLAMP_TO_EDGE)),S.activeTexture.set(P.TEXTURE3),b&&b.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE),this._depthFBO&&(H.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE),H.u_depth_size_inv=[1,1]),b&&b.useMeterToDem&&ee){const Se=(1<{if(Ye===Ri)return;const Mi=[Br[Ri],"PROJECTION_GLOBE_VIEW"];Bt&&Mi.push("CUSTOM_ANTIALIASING"),Ai&&Mi.push(Br[At]),Xe=pe.useProgram("globeRaster",null,Mi),Ye=Ri},It=pe.colorModeForRenderPass(),Ht=new i.DepthMode(lt.LEQUAL,i.DepthMode.ReadWrite,pe.depthRangeFor3D);hr.update(rt);const hi=i.calculateGlobeMercatorMatrix(ht),si=[i.mercatorXfromLng(ht.center.lng),i.mercatorYfromLat(ht.center.lat)],qt=At?[!1,!0]:[!1],ji=pe.globeSharedBuffers,Kt=[ht.width*i.exported.devicePixelRatio,ht.height*i.exported.devicePixelRatio],Bi=Float32Array.from(ht.globeMatrix),di={useDenormalizedUpVectorScale:!0};if(qt.forEach(Ri=>{Ye=-1;const Ai=Ri?lt.LINES:lt.TRIANGLES;for(const Mi of Qe){const $i=Se.getTile(Mi),Jt=i.StencilMode.disabled,pi=fe.prevTerrainTileForTile[Mi.key],In=fe.terrainTileForTile[Mi.key];Fh(pi,In)&&hr.newMorphing(Mi.key,pi,In,rt,250),nt.activeTexture.set(lt.TEXTURE0),$i.texture.bind(lt.LINEAR,lt.CLAMP_TO_EDGE);const Hn=hr.getMorphValuesForProxy(Mi.key),Mn=Hn?1:0;Hn&&i.extend$1(di,{morphing:{srcDemTile:Hn.from,dstDemTile:Hn.to,phase:i.easeCubicInOut(Hn.phase)}});const $n=i.tileCornersToBounds(Mi.canonical),ar=i.getLatitudinalLod($n.getCenter().lat),On=i.getGridMatrix(Mi.canonical,$n,ar,ht.worldSize/ht._pixelsPerMercatorPixel),_n=i.globeNormalizeECEF(i.globeTileBounds(Mi.canonical)),Dr=qr(ht.projMatrix,Bi,hi,_n,i.globeToMercatorTransition(ht.zoom),si,ht.frustumCorners.TL,ht.frustumCorners.TR,ht.frustumCorners.BR,ht.frustumCorners.BL,ht.globeCenterInViewSpace,ht.globeRadius,Kt,On);if(Pt(Mn,Ri),fe.setupElevationDraw($i,Xe,di),pe.prepareDrawProgram(nt,Xe,Mi.toUnwrapped()),ji){const[Or,Nr,Qr]=Ri?ji.getWirefameBuffers(pe.context,ar):ji.getGridBuffers(ar);Xe.draw(nt,Ai,Ht,Jt,It,i.CullFaceMode.backCCW,Dr,"globe_raster",Or,Nr,Qr)}}}),ji){const Ri=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];Bt&&Ri.push("CUSTOM_ANTIALIASING"),Xe=pe.useProgram("globeRaster",null,Ri);for(const Ai of Qe){const{x:Mi,y:$i,z:Jt}=Ai.canonical,pi=$i===0,In=$i===(1<Nr.draw(nt,lt.TRIANGLES,Ht,i.StencilMode.disabled,It,i.CullFaceMode.disabled,qr(ht.projMatrix,_n,_n,Dr,0,si,ht.frustumCorners.TL,ht.frustumCorners.TR,ht.frustumCorners.BR,ht.frustumCorners.BL,ht.globeCenterInViewSpace,ht.globeRadius,Kt),"globe_pole_raster",Qr,$n,ar);fe.setupElevationDraw(On,Xe,di),pe.prepareDrawProgram(nt,Xe,Ai.toUnwrapped()),pi&&Or(Xe,Hn),In&&(_n=i.scale(i.create(),_n,[1,-1,1]),Or(Xe,Mn))}}}})(S,P,H,W,ee);else{const pe=S.context,fe=pe.gl;let Se,Qe;const rt=S.options.showTerrainWireframe?2:0,nt=(ht,Bt)=>{if(Qe===ht)return;const Pt=[Br[ht]];Bt&&Pt.push(Br[rt]),Se=S.useProgram("terrainRaster",null,Pt),Qe=ht},lt=S.colorModeForRenderPass(),Xe=new i.DepthMode(fe.LEQUAL,i.DepthMode.ReadWrite,S.depthRangeFor3D);hr.update(ee);const Ye=S.transform,At=6*Math.pow(1.5,22-Ye.zoom)*P.exaggeration();(rt?[!1,!0]:[!1]).forEach(ht=>{Qe=-1;const Bt=ht?fe.LINES:fe.TRIANGLES,[Pt,It]=ht?P.getWirefameBuffer():[P.gridIndexBuffer,P.gridSegments];for(const Ht of W){const hi=H.getTile(Ht),si=i.StencilMode.disabled,qt=P.prevTerrainTileForTile[Ht.key],ji=P.terrainTileForTile[Ht.key];Fh(qt,ji)&&hr.newMorphing(Ht.key,qt,ji,ee,250),pe.activeTexture.set(fe.TEXTURE0),hi.texture.bind(fe.LINEAR,fe.CLAMP_TO_EDGE,fe.LINEAR_MIPMAP_NEAREST);const Kt=hr.getMorphValuesForProxy(Ht.key),Bi=Kt?1:0;let di;Kt&&(di={morphing:{srcDemTile:Kt.from,dstDemTile:Kt.to,phase:i.easeCubicInOut(Kt.phase)}});const Ri=dl(Ht.projMatrix,jr(Ht.canonical,Ye.renderWorldCopies)?At/10:At);nt(Bi,ht),P.setupElevationDraw(hi,Se,di),S.prepareDrawProgram(pe,Se,Ht.toUnwrapped()),Se.draw(pe,Bt,Xe,si,lt,i.CullFaceMode.backCCW,Ri,"terrain_raster",P.gridBuffer,Pt,It)}})}}(m,this,this.proxySourceCache,a,this._updateTimestamp),this.renderingToTexture=!0,m.gpuTimingDeferredRenderEnd(),a.splice(0,a.length))}renderBatch(a){if(this._drapedRenderBatches.length===0)return a+1;this.renderingToTexture=!0;const m=this.painter,b=this.painter.context,S=this.proxySourceCache,P=this.proxiedCoords[S.id],H=this._drapedRenderBatches.shift(),W=[],ee=m.style.order;let pe=0;for(const fe of P){const Se=S.getTileByID(fe.proxyTileKey),Qe=S.proxyCachedFBO[fe.key]?S.proxyCachedFBO[fe.key][a]:void 0,rt=Qe!==void 0?S.renderCache[Qe]:this.pool[pe++],nt=Qe!==void 0;if(Se.texture=rt.tex,nt&&!rt.dirty){W.push(Se.tileID);continue}let lt;b.bindFramebuffer.set(rt.fb.framebuffer),this.renderedToTile=!1,rt.dirty&&(b.clear({color:i.Color.transparent,stencil:0}),rt.dirty=!1);for(let Xe=H.start;Xe<=H.end;++Xe){const Ye=m.style._layers[ee[Xe]];if(Ye.isHidden(m.transform.zoom))continue;const At=m.style._getLayerSourceCache(Ye),ht=At?this.proxyToSource[fe.key][At.id]:[fe];if(!ht)continue;const Bt=ht;b.viewport.set([0,0,rt.fb.width,rt.fb.height]),lt!==(At?At.id:null)&&(this._setupStencil(rt,ht,Ye,At),lt=At?At.id:null),m.renderLayer(m,At,Ye,Bt)}this.renderedToTile?(rt.dirty=!0,W.push(Se.tileID)):nt||--pe,pe===5&&(pe=0,this.renderToBackBuffer(W))}return this.renderToBackBuffer(W),this.renderingToTexture=!1,b.bindFramebuffer.set(null),b.viewport.set([0,0,m.width,m.height]),H.end+1}postRender(){}renderCacheEfficiency(a){const m=a.order.length;if(m===0)return{efficiency:100};let b,S=0,P=0,H=!1;for(let W=0;Wm.dem).forEach(m=>{a=Math.min(a,m.dem.tree.minimums[0])}),a===0?a:(a-30)*this._exaggeration}raycast(a,m,b){if(!this._visibleDemTiles)return null;const S=this._visibleDemTiles.filter(P=>P.dem).map(P=>{const H=P.tileID,W=1<(P.t!==null?P.t:Number.MAX_VALUE)-(H.t!==null?H.t:Number.MAX_VALUE));for(const P of S){if(P.t==null)return null;const H=P.tile.dem.tree.raycast(P.minx,P.miny,P.maxx,P.maxy,a,m,b);if(H!=null)return H}return null}_createFBO(){const a=this.painter.context,m=a.gl,b=this.drapeBufferSize;a.activeTexture.set(m.TEXTURE0);const S=new i.Texture(a,{width:b[0],height:b[1],data:null},m.RGBA);S.bind(m.LINEAR,m.CLAMP_TO_EDGE);const P=a.createFramebuffer(b[0],b[1],!1);return P.colorAttachment.set(S.texture),P.depthAttachment=new zs(a,P.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=a.createRenderbuffer(a.gl.DEPTH_STENCIL,b[0],b[1]),this._stencilRef=0,P.depthAttachment.set(this._sharedDepthStencil),a.clear({stencil:0})):P.depthAttachment.set(this._sharedDepthStencil),a.extTextureFilterAnisotropic&&!a.extTextureFilterAnisotropicForceOff&&m.texParameterf(m.TEXTURE_2D,a.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a.extTextureFilterAnisotropicMax),{fb:P,tex:S,dirty:!1}}_initFBOPool(){for(;this.pool.length{const m=this._style._layers[a],b=m.isHidden(this.painter.transform.zoom);return m.type!=="custom"&&!b&&m.hasTransition()})}_clearRasterFadeFromRenderCache(){let a=!1;for(const m in this._style._sourceCaches)if(this._style._sourceCaches[m]._source instanceof Ue){a=!0;break}if(a)for(let m=0;mm.renderCachePool.length){const H=Object.values(m.proxyCachedFBO);m.proxyCachedFBO={};for(let W=0;W=0;H--){const W=b[H];if(m.getTileByID(W.key),m.proxyCachedFBO[W.key]!==void 0){const ee=a[W.key],pe=this.proxyToSource[W.key];let fe=0;for(const Se in pe){const Qe=pe[Se],rt=ee[Se];if(!rt||rt.length!==Qe.length||Qe.some((nt,lt)=>nt!==rt[lt]||S[Se]&&S[Se].hasOwnProperty(nt.key))){fe=-1;break}++fe}for(const Se in m.proxyCachedFBO[W.key])m.renderCache[m.proxyCachedFBO[W.key][Se]].dirty=fe<0||fe!==Object.values(ee).length}}const P=[...this._drapedRenderBatches];P.sort((H,W)=>W.end-W.start-(H.end-H.start));for(const H of P)for(const W of b){if(m.proxyCachedFBO[W.key])continue;let ee=m.renderCachePool.pop();ee===void 0&&m.renderCache.length<50&&(ee=m.renderCache.length,m.renderCache.push(this._createFBO())),ee!==void 0&&(m.proxyCachedFBO[W.key]={},m.proxyCachedFBO[W.key][H.start]=ee,m.renderCache[ee].dirty=!0)}this._tilesDirty={}}_setupStencil(a,m,b,S){if(!S||!this._sourceTilesOverlap[S.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const P=this.painter.context,H=P.gl;if(m.length<=1)return void(this._overlapStencilType=!1);let W;if(b.isTileClipped())W=m.length,this._overlapStencilMode.test={func:H.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(m[0].overscaledZ>m[m.length-1].overscaledZ))return void(this._overlapStencilType=!1);W=1,this._overlapStencilMode.test={func:H.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+W>255&&(P.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=W,this._overlapStencilMode.ref=this._stencilRef,b.isTileClipped()&&this._renderTileClippingMasks(m,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(a){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[a.key]),this._overlapStencilMode):i.StencilMode.disabled}_renderTileClippingMasks(a,m){const b=this.painter,S=this.painter.context,P=S.gl;b._tileClippingMaskIDs={},S.setColorMode(i.ColorMode.disabled),S.setDepthMode(i.DepthMode.disabled);const H=b.useProgram("clippingMask");for(const W of a){const ee=b._tileClippingMaskIDs[W.key]=--m;H.draw(S,P.TRIANGLES,i.DepthMode.disabled,new i.StencilMode({func:P.ALWAYS,mask:0},ee,255,P.KEEP,P.KEEP,P.REPLACE),i.ColorMode.disabled,i.CullFaceMode.disabled,$r(W.projMatrix),"$clipping",b.tileExtentBuffer,b.quadTriangleIndexBuffer,b.tileExtentSegments)}}pointCoordinate(a){const m=this.painter.transform;if(a.x<0||a.x>m.width||a.y<0||a.y>m.height)return null;const b=[a.x,a.y,1,1];i.transformMat4$1(b,b,m.pixelMatrixInverse),i.scale$1(b,b,1/b[3]),b[0]/=m.worldSize,b[1]/=m.worldSize;const S=m._camera.position,P=i.mercatorZfromAltitude(1,m.center.lat),H=[S[0],S[1],S[2]/P,0],W=i.subtract([],b.slice(0,3),H);i.normalize(W,W);const ee=this.raycast(H,W,this._exaggeration);return ee!==null&&ee?(i.scaleAndAdd(H,H,W,ee),H[3]=H[2],H[2]*=P,H):null}drawDepth(){const a=this.painter,m=a.context,b=this.proxySourceCache,S=Math.ceil(a.width),P=Math.ceil(a.height);if(!this._depthFBO||this._depthFBO.width===S&&this._depthFBO.height===P||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const H=m.gl,W=m.createFramebuffer(S,P,!0);m.activeTexture.set(H.TEXTURE0);const ee=new i.Texture(m,{width:S,height:P,data:null},H.RGBA);ee.bind(H.NEAREST,H.CLAMP_TO_EDGE),W.colorAttachment.set(ee.texture);const pe=m.createRenderbuffer(m.gl.DEPTH_COMPONENT16,S,P);W.depthAttachment.set(pe),this._depthFBO=W,this._depthTexture=ee}m.bindFramebuffer.set(this._depthFBO.framebuffer),m.viewport.set([0,0,S,P]),function(H,W,ee,pe){if(H.transform.projection.name==="globe")return;const fe=H.context,Se=fe.gl;fe.clear({depth:1});const Qe=H.useProgram("terrainDepth"),rt=new i.DepthMode(Se.LESS,i.DepthMode.ReadWrite,H.depthRangeFor3D);for(const nt of pe){const lt=ee.getTile(nt),Xe=dl(nt.projMatrix,0);W.setupElevationDraw(lt,Qe),Qe.draw(fe,Se.TRIANGLES,rt,i.StencilMode.disabled,i.ColorMode.unblended,i.CullFaceMode.backCCW,Xe,"terrain_depth",W.gridBuffer,W.gridIndexBuffer,W.gridNoSkirtSegments)}}(a,this,b,this.proxyCoords)}_setupProxiedCoordsForOrtho(a,m,b){if(a.getSource()instanceof X)return this._setupProxiedCoordsForImageSource(a,m,b);this._findCoveringTileCache[a.id]=this._findCoveringTileCache[a.id]||{};const S=this.proxiedCoords[a.id]=[],P=this.proxyCoords;for(let W=0;W(fe.min.x=Math.min(fe.min.x,Se.x-W.x),fe.min.y=Math.min(fe.min.y,Se.y-W.y),fe.max.x=Math.max(fe.max.x,Se.x-W.x),fe.max.y=Math.max(fe.max.y,Se.y-W.y),fe),{min:new i.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),pe=(fe,Se)=>{const Qe=fe.wrap+fe.canonical.x/(1<lt+ee.max.x||rt+ntXe+ee.max.y};for(let fe=0;feH.key===m.tileID.key);if(P)return P}if(m.tileID.key!==a.key){const P=a.canonical.z-m.tileID.canonical.z;let H,W,ee;S=i.create();const pe=m.tileID.wrap-a.wrap<0?(H=i.EXTENT>>P,W=H*((m.tileID.canonical.x<=Se){const Qe=a.canonical.z-Se;m.getSource().reparseOverscaled?(W=Math.max(a.canonical.z+2,m.transform.tileZoom),H=new i.OverscaledTileID(W,a.wrap,Se,a.canonical.x>>Qe,a.canonical.y>>Qe)):Qe!==0&&(W=Se,H=new i.OverscaledTileID(W,a.wrap,Se,a.canonical.x>>Qe,a.canonical.y>>Qe))}H.key!==a.key&&(pe.push(H.key),b=m.getTile(H))}const fe=Se=>{pe.forEach(Qe=>{S[Qe]=Se}),pe.length=0};for(W-=1;W>=ee&&(!b||!b.hasData());W--){b&&fe(b.tileID.key);const Se=H.calculateScaledKey(W);if(b=m.getTileByID(Se),b&&b.hasData())break;const Qe=S[Se];if(Qe===null)break;Qe===void 0?pe.push(Se):b=m.getTileByID(Qe)}return fe(b?b.tileID.key:null),b&&b.hasData()?b:null}findDEMTileFor(a){return this.enabled?this._findTileCoveringTileID(a,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(a,m){let b=this._tilesDirty[a];b||(b=this._tilesDirty[a]={}),b[m.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const a=function(m){let b=0;const S=new i.StructArrayLayout2ui4,P=131;for(let H=1;H<129;H++){for(let W=1;W<129;W++)b=H*P+W,S.emplaceBack(b,b+1),S.emplaceBack(b,b+P),S.emplaceBack(b+1,b+P),H===128&&S.emplaceBack(b+P,b+P+1);S.emplaceBack(b+1,b+1+P)}return S}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(a),this.wireframeSegments=i.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,a.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class rA{static cacheKey(a,m,b,S){let P=`${m}${S?S.cacheKey:""}`;for(const H of b)a.usedDefines.includes(H)&&(P+=`/${H}`);return P}constructor(a,m,b,S,P,H){const W=a.gl;this.program=W.createProgram();const ee=function(Xe){const Ye=[];for(let At=0;At`#define ${Xe}`));const Qe=Se.concat(a.extStandardDerivatives?`#extension GL_OES_standard_derivatives : enable `.concat(hc):hc,hc,id,tA.fragmentSource,gu.fragmentSource,b.fragmentSource).join(` `),rt=Se.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`,id,tA.vertexSource,gu.vertexSource,td.vertexSource,b.vertexSource).join(` `),nt=W.createShader(W.FRAGMENT_SHADER);if(W.isContextLost())return void(this.failedToCreate=!0);W.shaderSource(nt,Qe),W.compileShader(nt),W.attachShader(this.program,nt);const lt=W.createShader(W.VERTEX_SHADER);if(W.isContextLost())this.failedToCreate=!0;else{W.shaderSource(lt,rt),W.compileShader(lt),W.attachShader(this.program,lt),this.attributes={},this.numAttributes=fe.length;for(let Xe=0;Xe({u_dem:new i.Uniform1i(Xe),u_dem_prev:new i.Uniform1i(Xe),u_dem_unpack:new i.Uniform4f(Xe),u_dem_tl:new i.Uniform2f(Xe),u_dem_scale:new i.Uniform1f(Xe),u_dem_tl_prev:new i.Uniform2f(Xe),u_dem_scale_prev:new i.Uniform1f(Xe),u_dem_size:new i.Uniform1f(Xe),u_dem_lerp:new i.Uniform1f(Xe),u_exaggeration:new i.Uniform1f(Xe),u_depth:new i.Uniform1i(Xe),u_depth_size_inv:new i.Uniform2f(Xe),u_meter_to_dem:new i.Uniform1f(Xe),u_label_plane_matrix_inv:new i.UniformMatrix4f(Xe)}))(a)),H.includes("GLOBE")&&(this.globeUniforms=(Xe=>({u_tile_tl_up:new i.Uniform3f(Xe),u_tile_tr_up:new i.Uniform3f(Xe),u_tile_br_up:new i.Uniform3f(Xe),u_tile_bl_up:new i.Uniform3f(Xe),u_tile_up_scale:new i.Uniform1f(Xe)}))(a)),H.includes("FOG")&&(this.fogUniforms=(Xe=>({u_fog_matrix:new i.UniformMatrix4f(Xe),u_fog_range:new i.Uniform2f(Xe),u_fog_color:new i.Uniform4f(Xe),u_fog_horizon_blend:new i.Uniform1f(Xe),u_fog_temporal_offset:new i.Uniform1f(Xe),u_frustum_tl:new i.Uniform3f(Xe),u_frustum_tr:new i.Uniform3f(Xe),u_frustum_br:new i.Uniform3f(Xe),u_frustum_bl:new i.Uniform3f(Xe),u_globe_pos:new i.Uniform3f(Xe),u_globe_radius:new i.Uniform1f(Xe),u_globe_transition:new i.Uniform1f(Xe),u_is_globe:new i.Uniform1i(Xe),u_viewport:new i.Uniform2f(Xe)}))(a))}}setTerrainUniformValues(a,m){if(!this.terrainUniforms)return;const b=this.terrainUniforms;if(!this.failedToCreate){a.program.set(this.program);for(const S in m)b[S]&&b[S].set(this.program,S,m[S])}}setGlobeUniformValues(a,m){if(!this.globeUniforms)return;const b=this.globeUniforms;if(!this.failedToCreate){a.program.set(this.program);for(const S in m)b[S]&&b[S].set(this.program,S,m[S])}}setFogUniformValues(a,m){if(!this.fogUniforms)return;const b=this.fogUniforms;if(!this.failedToCreate){a.program.set(this.program);for(const S in m)b[S].set(this.program,S,m[S])}}draw(a,m,b,S,P,H,W,ee,pe,fe,Se,Qe,rt,nt,lt){const Xe=a.gl;if(this.failedToCreate)return;a.program.set(this.program),a.setDepthMode(b),a.setStencilMode(S),a.setColorMode(P),a.setCullFace(H);for(const At of Object.keys(this.fixedUniforms))this.fixedUniforms[At].set(this.program,At,W[At]);nt&&nt.setUniforms(this.program,a,this.binderUniforms,Qe,{zoom:rt});const Ye={[Xe.LINES]:2,[Xe.TRIANGLES]:3,[Xe.LINE_STRIP]:1}[m];for(const At of Se.get()){const ht=At.vaos||(At.vaos={});(ht[ee]||(ht[ee]=new uc)).bind(a,this,pe,nt?nt.getPaintVertexBuffers():[],fe,At.vertexOffset,lt||[]),Xe.drawElements(m,At.primitiveLength*Ye,Xe.UNSIGNED_SHORT,At.primitiveOffset*Ye*2)}}}function Ac(x,a){const m=Math.pow(2,a.tileID.overscaledZ),b=a.tileSize*Math.pow(2,x.transform.tileZoom)/m,S=b*(a.tileID.canonical.x+a.tileID.wrap*m),P=b*a.tileID.canonical.y;return{u_image:0,u_texsize:a.imageAtlasTexture.size,u_tile_units_to_pixels:1/et(a,1,x.transform.tileZoom),u_pixel_coord_upper:[S>>16,P>>16],u_pixel_coord_lower:[65535&S,65535&P]}}const Vc=i.create(),Hc=(x,a,m,b,S,P,H,W,ee,pe,fe)=>{const Se=a.style.light,Qe=Se.properties.get("position"),rt=[Qe.x,Qe.y,Qe.z],nt=i.create$1();Se.properties.get("anchor")==="viewport"&&(i.fromRotation(nt,-a.transform.angle),i.transformMat3(rt,rt,nt));const lt=Se.properties.get("color"),Xe=a.transform,Ye={u_matrix:x,u_lightpos:rt,u_lightintensity:Se.properties.get("intensity"),u_lightcolor:[lt.r,lt.g,lt.b],u_vertical_gradient:+m,u_opacity:b,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Vc,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:S,u_edge_radius:P};return Xe.projection.name==="globe"&&(Ye.u_tile_id=[H.canonical.x,H.canonical.y,1<{const Qe=Hc(x,a,m,b,S,P,H,ee,pe,fe,Se),rt={u_height_factor:-Math.pow(2,H.overscaledZ)/W.tileSize/8};return i.extend(Qe,Ac(a,W),rt)},Gc=x=>({u_matrix:x}),Dh=(x,a,m)=>i.extend(Gc(x),Ac(a,m)),Wc=(x,a)=>({u_matrix:x,u_world:a}),jc=(x,a,m,b)=>i.extend(Dh(x,a,m),{u_world:b}),ca=i.create(),sA=(x,a,m,b,S,P)=>{const H=x.transform,W=H.projection.name==="globe";let ee;if(P.paint.get("circle-pitch-alignment")==="map")if(W){const fe=i.globePixelsToTileUnits(H.zoom,a.canonical)*H._pixelsPerMercatorPixel;ee=Float32Array.from([fe,0,0,fe])}else ee=H.calculatePixelsToTileUnitsMatrix(m);else ee=new Float32Array([H.pixelsToGLUnits[0],0,0,H.pixelsToGLUnits[1]]);const pe={u_camera_to_center_distance:H.cameraToCenterDistance,u_matrix:x.translatePosMatrix(a.projMatrix,m,P.paint.get("circle-translate"),P.paint.get("circle-translate-anchor")),u_device_pixel_ratio:i.exported.devicePixelRatio,u_extrude_scale:ee,u_inv_rot_matrix:ca,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(W){pe.u_inv_rot_matrix=b,pe.u_merc_center=S,pe.u_tile_id=[a.canonical.x,a.canonical.y,1<{const a=[];return x.paint.get("circle-pitch-alignment")==="map"&&a.push("PITCH_WITH_MAP"),x.paint.get("circle-pitch-scale")==="map"&&a.push("SCALE_WITH_MAP"),a},Kc=(x,a,m,b)=>{const S=i.EXTENT/m.tileSize;return{u_matrix:x,u_camera_to_center_distance:a.getCameraToCenterDistance(b),u_extrude_scale:[a.pixelsToGLUnits[0]/S,a.pixelsToGLUnits[1]/S]}},ha=(x,a,m=1)=>({u_matrix:x,u_color:a,u_overlay:0,u_overlay_scale:m}),$c=i.create(),pl=(x,a,m,b,S,P,H)=>{const W=x.transform,ee=W.projection.name==="globe",pe=ee?i.globePixelsToTileUnits(W.zoom,a.canonical)*W._pixelsPerMercatorPixel:et(m,1,P),fe={u_matrix:a.projMatrix,u_extrude_scale:pe,u_intensity:H,u_inv_rot_matrix:$c,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(ee){fe.u_inv_rot_matrix=b,fe.u_merc_center=S,fe.u_tile_id=[a.canonical.x,a.canonical.y,1<{const W=x.transform,ee=W.calculatePixelsToTileUnitsMatrix(a);return{u_matrix:xu(x,a,m,b),u_pixels_to_tile_units:ee,u_device_pixel_ratio:P,u_units_to_pixels:[1/W.pixelsToGLUnits[0],1/W.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:S,u_texsize:Gl(m)?a.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Ph(a,x.transform),u_alpha_discard_threshold:0,u_trim_offset:H}},Ho=(x,a,m,b,S)=>{const P=x.transform;return{u_matrix:xu(x,a,m,b),u_texsize:a.imageAtlasTexture.size,u_pixels_to_tile_units:P.calculatePixelsToTileUnitsMatrix(a),u_device_pixel_ratio:S,u_image:0,u_tile_units_to_pixels:Ph(a,P),u_units_to_pixels:[1/P.pixelsToGLUnits[0],1/P.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Ph(x,a){return 1/et(x,1,a.tileZoom)}function xu(x,a,m,b){return x.translatePosMatrix(b||a.tileID.projMatrix,a,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}function Gl(x){const a=x.paint.get("line-dasharray").value;return a.value||a.kind!=="constant"}const vu=(x,a,m,b,S,P)=>{return{u_matrix:x,u_tl_parent:a,u_scale_parent:m,u_fade_t:b.mix,u_opacity:b.opacity*S.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:S.paint.get("raster-brightness-min"),u_brightness_high:S.paint.get("raster-brightness-max"),u_saturation_factor:(W=S.paint.get("raster-saturation"),W>0?1-1/(1.001-W):-W),u_contrast_factor:(H=S.paint.get("raster-contrast"),H>0?1/(1-H):1+H),u_spin_weights:Zc(S.paint.get("raster-hue-rotate")),u_perspective_transform:P};var H,W};function Zc(x){x*=Math.PI/180;const a=Math.sin(x),m=Math.cos(x);return[(2*m+1)/3,(-Math.sqrt(3)*a-m+1)/3,(Math.sqrt(3)*a-m+1)/3]}const Xc=i.create(),fl=(x,a,m,b,S,P,H,W,ee,pe,fe,Se,Qe,rt,nt,lt)=>{const Xe=S.transform,Ye={u_is_size_zoom_constant:+(x==="constant"||x==="source"),u_is_size_feature_constant:+(x==="constant"||x==="camera"),u_size_t:a?a.uSizeT:0,u_size:a?a.uSize:0,u_camera_to_center_distance:Xe.cameraToCenterDistance,u_rotate_symbol:+m,u_aspect_ratio:Xe.width/Xe.height,u_fade_change:S.options.fadeDuration?S.symbolFadeChange:1,u_matrix:P,u_label_plane_matrix:H,u_coord_matrix:W,u_is_text:+ee,u_pitch_with_map:+b,u_texsize:pe,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Xc,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Xc,u_up_vector:[0,-1,0]};return lt.name==="globe"&&(Ye.u_tile_id=[fe.canonical.x,fe.canonical.y,1<i.extend(fl(x,a,m,b,S,P,H,W,ee,pe,Se,Qe,rt,nt,lt,Xe),{u_gamma_scale:b?S.transform.cameraToCenterDistance*Math.cos(S.terrain?0:S.transform._pitch):1,u_device_pixel_ratio:i.exported.devicePixelRatio,u_is_halo:+fe}),Uh=(x,a,m,b,S,P,H,W,ee,pe,fe,Se,Qe,rt,nt,lt)=>i.extend(qc(x,a,m,b,S,P,H,W,!0,ee,!0,fe,Se,Qe,rt,nt,lt),{u_texsize_icon:pe,u_texture_icon:1}),Rh=(x,a,m)=>({u_matrix:x,u_opacity:a,u_color:m}),wu=(x,a,m,b,S)=>i.extend(function(P,H,W){const ee=H.imageManager.getPattern(P.toString()),{width:pe,height:fe}=H.imageManager.getPixelSize(),Se=Math.pow(2,W.tileID.overscaledZ),Qe=W.tileSize*Math.pow(2,H.transform.tileZoom)/Se,rt=Qe*(W.tileID.canonical.x+W.tileID.wrap*Se),nt=Qe*W.tileID.canonical.y;return{u_image:0,u_pattern_tl:ee.tl,u_pattern_br:ee.br,u_texsize:[pe,fe],u_pattern_size:ee.displaySize,u_tile_units_to_pixels:1/et(W,1,H.transform.tileZoom),u_pixel_coord_upper:[rt>>16,nt>>16],u_pixel_coord_lower:[65535&rt,65535&nt]}}(b,m,S),{u_matrix:x,u_opacity:a}),nd={fillExtrusion:x=>({u_matrix:new i.UniformMatrix4f(x),u_lightpos:new i.Uniform3f(x),u_lightintensity:new i.Uniform1f(x),u_lightcolor:new i.Uniform3f(x),u_vertical_gradient:new i.Uniform1f(x),u_opacity:new i.Uniform1f(x),u_edge_radius:new i.Uniform1f(x),u_ao:new i.Uniform2f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_up_dir:new i.Uniform3f(x),u_height_lift:new i.Uniform1f(x)}),fillExtrusionPattern:x=>({u_matrix:new i.UniformMatrix4f(x),u_lightpos:new i.Uniform3f(x),u_lightintensity:new i.Uniform1f(x),u_lightcolor:new i.Uniform3f(x),u_vertical_gradient:new i.Uniform1f(x),u_height_factor:new i.Uniform1f(x),u_edge_radius:new i.Uniform1f(x),u_ao:new i.Uniform2f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_up_dir:new i.Uniform3f(x),u_height_lift:new i.Uniform1f(x),u_image:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_pixel_coord_upper:new i.Uniform2f(x),u_pixel_coord_lower:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x),u_opacity:new i.Uniform1f(x)}),fill:x=>({u_matrix:new i.UniformMatrix4f(x)}),fillPattern:x=>({u_matrix:new i.UniformMatrix4f(x),u_image:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_pixel_coord_upper:new i.Uniform2f(x),u_pixel_coord_lower:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x)}),fillOutline:x=>({u_matrix:new i.UniformMatrix4f(x),u_world:new i.Uniform2f(x)}),fillOutlinePattern:x=>({u_matrix:new i.UniformMatrix4f(x),u_world:new i.Uniform2f(x),u_image:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_pixel_coord_upper:new i.Uniform2f(x),u_pixel_coord_lower:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x)}),circle:x=>({u_camera_to_center_distance:new i.Uniform1f(x),u_extrude_scale:new i.UniformMatrix2f(x),u_device_pixel_ratio:new i.Uniform1f(x),u_matrix:new i.UniformMatrix4f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_up_dir:new i.Uniform3f(x)}),collisionBox:x=>({u_matrix:new i.UniformMatrix4f(x),u_camera_to_center_distance:new i.Uniform1f(x),u_extrude_scale:new i.Uniform2f(x)}),collisionCircle:x=>({u_matrix:new i.UniformMatrix4f(x),u_inv_matrix:new i.UniformMatrix4f(x),u_camera_to_center_distance:new i.Uniform1f(x),u_viewport_size:new i.Uniform2f(x)}),debug:x=>({u_color:new i.UniformColor(x),u_matrix:new i.UniformMatrix4f(x),u_overlay:new i.Uniform1i(x),u_overlay_scale:new i.Uniform1f(x)}),clippingMask:x=>({u_matrix:new i.UniformMatrix4f(x)}),heatmap:x=>({u_extrude_scale:new i.Uniform1f(x),u_intensity:new i.Uniform1f(x),u_matrix:new i.UniformMatrix4f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_up_dir:new i.Uniform3f(x)}),heatmapTexture:x=>({u_image:new i.Uniform1i(x),u_color_ramp:new i.Uniform1i(x),u_opacity:new i.Uniform1f(x)}),hillshade:x=>({u_matrix:new i.UniformMatrix4f(x),u_image:new i.Uniform1i(x),u_latrange:new i.Uniform2f(x),u_light:new i.Uniform2f(x),u_shadow:new i.UniformColor(x),u_highlight:new i.UniformColor(x),u_accent:new i.UniformColor(x)}),hillshadePrepare:x=>({u_matrix:new i.UniformMatrix4f(x),u_image:new i.Uniform1i(x),u_dimension:new i.Uniform2f(x),u_zoom:new i.Uniform1f(x),u_unpack:new i.Uniform4f(x)}),line:x=>({u_matrix:new i.UniformMatrix4f(x),u_pixels_to_tile_units:new i.UniformMatrix2f(x),u_device_pixel_ratio:new i.Uniform1f(x),u_units_to_pixels:new i.Uniform2f(x),u_dash_image:new i.Uniform1i(x),u_gradient_image:new i.Uniform1i(x),u_image_height:new i.Uniform1f(x),u_texsize:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x),u_alpha_discard_threshold:new i.Uniform1f(x),u_trim_offset:new i.Uniform2f(x)}),linePattern:x=>({u_matrix:new i.UniformMatrix4f(x),u_texsize:new i.Uniform2f(x),u_pixels_to_tile_units:new i.UniformMatrix2f(x),u_device_pixel_ratio:new i.Uniform1f(x),u_image:new i.Uniform1i(x),u_units_to_pixels:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x),u_alpha_discard_threshold:new i.Uniform1f(x)}),raster:x=>({u_matrix:new i.UniformMatrix4f(x),u_tl_parent:new i.Uniform2f(x),u_scale_parent:new i.Uniform1f(x),u_fade_t:new i.Uniform1f(x),u_opacity:new i.Uniform1f(x),u_image0:new i.Uniform1i(x),u_image1:new i.Uniform1i(x),u_brightness_low:new i.Uniform1f(x),u_brightness_high:new i.Uniform1f(x),u_saturation_factor:new i.Uniform1f(x),u_contrast_factor:new i.Uniform1f(x),u_spin_weights:new i.Uniform3f(x),u_perspective_transform:new i.Uniform2f(x)}),symbolIcon:x=>({u_is_size_zoom_constant:new i.Uniform1i(x),u_is_size_feature_constant:new i.Uniform1i(x),u_size_t:new i.Uniform1f(x),u_size:new i.Uniform1f(x),u_camera_to_center_distance:new i.Uniform1f(x),u_rotate_symbol:new i.Uniform1i(x),u_aspect_ratio:new i.Uniform1f(x),u_fade_change:new i.Uniform1f(x),u_matrix:new i.UniformMatrix4f(x),u_label_plane_matrix:new i.UniformMatrix4f(x),u_coord_matrix:new i.UniformMatrix4f(x),u_is_text:new i.Uniform1i(x),u_pitch_with_map:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_camera_forward:new i.Uniform3f(x),u_tile_matrix:new i.UniformMatrix4f(x),u_up_vector:new i.Uniform3f(x),u_ecef_origin:new i.Uniform3f(x),u_texture:new i.Uniform1i(x)}),symbolSDF:x=>({u_is_size_zoom_constant:new i.Uniform1i(x),u_is_size_feature_constant:new i.Uniform1i(x),u_size_t:new i.Uniform1f(x),u_size:new i.Uniform1f(x),u_camera_to_center_distance:new i.Uniform1f(x),u_rotate_symbol:new i.Uniform1i(x),u_aspect_ratio:new i.Uniform1f(x),u_fade_change:new i.Uniform1f(x),u_matrix:new i.UniformMatrix4f(x),u_label_plane_matrix:new i.UniformMatrix4f(x),u_coord_matrix:new i.UniformMatrix4f(x),u_is_text:new i.Uniform1i(x),u_pitch_with_map:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_texture:new i.Uniform1i(x),u_gamma_scale:new i.Uniform1f(x),u_device_pixel_ratio:new i.Uniform1f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_camera_forward:new i.Uniform3f(x),u_tile_matrix:new i.UniformMatrix4f(x),u_up_vector:new i.Uniform3f(x),u_ecef_origin:new i.Uniform3f(x),u_is_halo:new i.Uniform1i(x)}),symbolTextAndIcon:x=>({u_is_size_zoom_constant:new i.Uniform1i(x),u_is_size_feature_constant:new i.Uniform1i(x),u_size_t:new i.Uniform1f(x),u_size:new i.Uniform1f(x),u_camera_to_center_distance:new i.Uniform1f(x),u_rotate_symbol:new i.Uniform1i(x),u_aspect_ratio:new i.Uniform1f(x),u_fade_change:new i.Uniform1f(x),u_matrix:new i.UniformMatrix4f(x),u_label_plane_matrix:new i.UniformMatrix4f(x),u_coord_matrix:new i.UniformMatrix4f(x),u_is_text:new i.Uniform1i(x),u_pitch_with_map:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_texsize_icon:new i.Uniform2f(x),u_texture:new i.Uniform1i(x),u_texture_icon:new i.Uniform1i(x),u_gamma_scale:new i.Uniform1f(x),u_device_pixel_ratio:new i.Uniform1f(x),u_is_halo:new i.Uniform1i(x)}),background:x=>({u_matrix:new i.UniformMatrix4f(x),u_opacity:new i.Uniform1f(x),u_color:new i.UniformColor(x)}),backgroundPattern:x=>({u_matrix:new i.UniformMatrix4f(x),u_opacity:new i.Uniform1f(x),u_image:new i.Uniform1i(x),u_pattern_tl:new i.Uniform2f(x),u_pattern_br:new i.Uniform2f(x),u_texsize:new i.Uniform2f(x),u_pattern_size:new i.Uniform2f(x),u_pixel_coord_upper:new i.Uniform2f(x),u_pixel_coord_lower:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x)}),terrainRaster:Qc,terrainDepth:Qc,skybox:x=>({u_matrix:new i.UniformMatrix4f(x),u_sun_direction:new i.Uniform3f(x),u_cubemap:new i.Uniform1i(x),u_opacity:new i.Uniform1f(x),u_temporal_offset:new i.Uniform1f(x)}),skyboxGradient:x=>({u_matrix:new i.UniformMatrix4f(x),u_color_ramp:new i.Uniform1i(x),u_center_direction:new i.Uniform3f(x),u_radius:new i.Uniform1f(x),u_opacity:new i.Uniform1f(x),u_temporal_offset:new i.Uniform1f(x)}),skyboxCapture:x=>({u_matrix_3f:new i.UniformMatrix3f(x),u_sun_direction:new i.Uniform3f(x),u_sun_intensity:new i.Uniform1f(x),u_color_tint_r:new i.Uniform4f(x),u_color_tint_m:new i.Uniform4f(x),u_luminance:new i.Uniform1f(x)}),globeRaster:x=>({u_proj_matrix:new i.UniformMatrix4f(x),u_globe_matrix:new i.UniformMatrix4f(x),u_normalize_matrix:new i.UniformMatrix4f(x),u_merc_matrix:new i.UniformMatrix4f(x),u_zoom_transition:new i.Uniform1f(x),u_merc_center:new i.Uniform2f(x),u_image0:new i.Uniform1i(x),u_grid_matrix:new i.UniformMatrix3f(x),u_frustum_tl:new i.Uniform3f(x),u_frustum_tr:new i.Uniform3f(x),u_frustum_br:new i.Uniform3f(x),u_frustum_bl:new i.Uniform3f(x),u_globe_pos:new i.Uniform3f(x),u_globe_radius:new i.Uniform1f(x),u_viewport:new i.Uniform2f(x)}),globeAtmosphere:x=>({u_frustum_tl:new i.Uniform3f(x),u_frustum_tr:new i.Uniform3f(x),u_frustum_br:new i.Uniform3f(x),u_frustum_bl:new i.Uniform3f(x),u_horizon:new i.Uniform1f(x),u_transition:new i.Uniform1f(x),u_fadeout_range:new i.Uniform1f(x),u_color:new i.Uniform4f(x),u_high_color:new i.Uniform4f(x),u_space_color:new i.Uniform4f(x),u_star_intensity:new i.Uniform1f(x),u_star_density:new i.Uniform1f(x),u_star_size:new i.Uniform1f(x),u_temporal_offset:new i.Uniform1f(x),u_horizon_angle:new i.Uniform1f(x),u_rotation_matrix:new i.UniformMatrix4f(x)})};let dc;function pc(x,a,m,b,S,P,H){const W=x.context,ee=W.gl,pe=x.transform,fe=x.useProgram("collisionBox"),Se=[];let Qe=0,rt=0;for(let Bt=0;Bt0){const Kt=i.create(),Bi=si;i.mul(Kt,Ht.placementInvProjMatrix,pe.glCoordMatrix),i.mul(Kt,Kt,Ht.placementViewportMatrix),Se.push({circleArray:ji,circleOffset:rt,transform:Bi,invTransform:Kt,projection:Ht.getProjection()}),Qe+=ji.length/4,rt=Qe}qt&&(x.terrain&&x.terrain.setupElevationDraw(It,fe),fe.draw(W,ee.LINES,i.DepthMode.disabled,i.StencilMode.disabled,x.colorModeForRenderPass(),i.CullFaceMode.disabled,Kc(si,pe,It,Ht.getProjection()),m.id,qt.layoutVertexBuffer,qt.indexBuffer,qt.segments,null,pe.zoom,null,[qt.collisionVertexBuffer,qt.collisionVertexBufferExt]))}if(!H||!Se.length)return;const nt=x.useProgram("collisionCircle"),lt=new i.StructArrayLayout2f1f2i16;lt.resize(4*Qe),lt._trim();let Xe=0;for(const Bt of Se)for(let Pt=0;Pt=0&&(nt[Bt.associatedIconIndex]={x:Bi,y:di,z:Ri,angle:pi})}else qs(Ht,Qe)}if(fe){rt.clear();const ht=x.icon.placedSymbolArray;for(let Bt=0;BtKt.sortKey-Bi.sortKey);for(const Kt of si){const Bi=Kt.state;if(x.terrain&&x.terrain.setupElevationDraw(Bi.tile,Bi.program,{useDepthForOcclusion:!hi,labelPlaneMatrixInv:Bi.labelPlaneMatrixInv}),Qe.activeTexture.set(rt.TEXTURE0),Bi.atlasTexture.bind(Bi.atlasInterpolation,rt.CLAMP_TO_EDGE),Bi.atlasTextureIcon&&(Qe.activeTexture.set(rt.TEXTURE1),Bi.atlasTextureIcon&&Bi.atlasTextureIcon.bind(Bi.atlasInterpolationIcon,rt.CLAMP_TO_EDGE)),Bi.isSDF){const di=Bi.uniformValues;Bi.hasHalo&&(di.u_is_halo=1,Mo(Bi.buffers,Kt.segments,m,x,Bi.program,Pt,fe,Se,di)),di.u_is_halo=0}Mo(Bi.buffers,Kt.segments,m,x,Bi.program,Pt,fe,Se,Bi.uniformValues)}}function Mo(x,a,m,b,S,P,H,W,ee){const pe=b.context,fe=[x.dynamicLayoutVertexBuffer,x.opacityVertexBuffer,x.globeExtVertexBuffer];S.draw(pe,pe.gl.TRIANGLES,P,H,W,i.CullFaceMode.disabled,ee,m.id,x.layoutVertexBuffer,x.indexBuffer,a,m.paint,b.transform.zoom,x.programConfigurations.get(m.id),fe)}function rd(x,a,m,b,S,P,H){const W=x.context.gl,ee=m.paint.get("fill-pattern"),pe=ee&&ee.constantOr(1);let fe,Se,Qe,rt,nt;H?(Se=pe&&!m.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",fe=W.LINES):(Se=pe?"fillPattern":"fill",fe=W.TRIANGLES);for(const lt of b){const Xe=a.getTile(lt);if(pe&&!Xe.patternsLoaded())continue;const Ye=Xe.getBucket(m);if(!Ye)continue;x.prepareDrawTile();const At=Ye.programConfigurations.get(m.id),ht=x.useProgram(Se,At);pe&&(x.context.activeTexture.set(W.TEXTURE0),Xe.imageAtlasTexture.bind(W.LINEAR,W.CLAMP_TO_EDGE),At.updatePaintBuffers());const Bt=ee.constantOr(null);if(Bt&&Xe.imageAtlas){const It=Xe.imageAtlas.patternPositions[Bt.toString()];It&&At.setConstantPatternPositions(It)}const Pt=x.translatePosMatrix(lt.projMatrix,Xe,m.paint.get("fill-translate"),m.paint.get("fill-translate-anchor"));if(H){rt=Ye.indexBuffer2,nt=Ye.segments2;const It=x.terrain&&x.terrain.renderingToTexture?x.terrain.drapeBufferSize:[W.drawingBufferWidth,W.drawingBufferHeight];Qe=Se==="fillOutlinePattern"&&pe?jc(Pt,x,Xe,It):Wc(Pt,It)}else rt=Ye.indexBuffer,nt=Ye.segments,Qe=pe?Dh(Pt,x,Xe):Gc(Pt);x.prepareDrawProgram(x.context,ht,lt.toUnwrapped()),ht.draw(x.context,fe,S,x.stencilModeForClipping(lt),P,i.CullFaceMode.disabled,Qe,m.id,Ye.layoutVertexBuffer,rt,nt,m.paint,x.transform.zoom,At)}}function Ga(x,a,m,b,S,P,H){const W=x.context,ee=W.gl,pe=x.transform,fe=m.paint.get("fill-extrusion-pattern"),Se=fe.constantOr(1),Qe=m.paint.get("fill-extrusion-opacity"),rt=[m.paint.get("fill-extrusion-ambient-occlusion-intensity"),m.paint.get("fill-extrusion-ambient-occlusion-radius")],nt=m.layout.get("fill-extrusion-edge-radius"),lt=pe.projection.name==="globe"?i.fillExtrusionHeightLift():0,Xe=pe.projection.name==="globe",Ye=Xe?i.globeToMercatorTransition(pe.zoom):0,At=[i.mercatorXfromLng(pe.center.lng),i.mercatorYfromLat(pe.center.lat)],ht=[];Xe&&(ht.push("PROJECTION_GLOBE_VIEW"),x.style.terrainSetForDrapingOnly()&&ht.push("TERRAIN")),rt[0]>0&&ht.push("FAUX_AO");for(const Bt of b){const Pt=a.getTile(Bt),It=Pt.getBucket(m);if(!It||It.projection.name!==pe.projection.name)continue;const Ht=It.programConfigurations.get(m.id),hi=x.useProgram(Se?"fillExtrusionPattern":"fillExtrusion",Ht,ht);if(x.terrain){const Ri=x.terrain;if(x.style.terrainSetForDrapingOnly())Ri.setupElevationDraw(Pt,hi,{useMeterToDem:!0});else{if(!It.enableTerrain)continue;if(Ri.setupElevationDraw(Pt,hi,{useMeterToDem:!0}),sd(W,a,Bt,It,m,Ri),!It.centroidVertexBuffer){const Ai=hi.attributes.a_centroid_pos;Ai!==void 0&&ee.vertexAttrib2f(Ai,0,0)}}}Se&&(x.context.activeTexture.set(ee.TEXTURE0),Pt.imageAtlasTexture.bind(ee.LINEAR,ee.CLAMP_TO_EDGE),Ht.updatePaintBuffers());const si=fe.constantOr(null);if(si&&Pt.imageAtlas){const Ri=Pt.imageAtlas.patternPositions[si.toString()];Ri&&Ht.setConstantPatternPositions(Ri)}const qt=x.translatePosMatrix(Bt.projMatrix,Pt,m.paint.get("fill-extrusion-translate"),m.paint.get("fill-extrusion-translate-anchor")),ji=pe.projection.createInversionMatrix(pe,Bt.canonical),Kt=m.paint.get("fill-extrusion-vertical-gradient"),Bi=Se?Lh(qt,x,Kt,Qe,rt,nt,Bt,Pt,lt,Ye,At,ji):Hc(qt,x,Kt,Qe,rt,nt,Bt,lt,Ye,At,ji);x.prepareDrawProgram(W,hi,Bt.toUnwrapped());const di=[];x.terrain&&di.push(It.centroidVertexBuffer),Xe&&di.push(It.layoutVertexExtBuffer),hi.draw(W,W.gl.TRIANGLES,S,P,H,i.CullFaceMode.backCCW,Bi,m.id,It.layoutVertexBuffer,It.indexBuffer,It.segments,m.paint,x.transform.zoom,Ht,di)}}function sd(x,a,m,b,S,P){const H=[Ye=>{let At=Ye.canonical.x-1,ht=Ye.wrap;return At<0&&(At=(1<{let At=Ye.canonical.x+1,ht=Ye.wrap;return At===1<new i.OverscaledTileID(Ye.overscaledZ,Ye.wrap,Ye.canonical.z,Ye.canonical.x,(Ye.canonical.y===0?1<new i.OverscaledTileID(Ye.overscaledZ,Ye.wrap,Ye.canonical.z,Ye.canonical.x,Ye.canonical.y===(1<{const At=a.getSource().minzoom,ht=Pt=>{const It=a.getTileByID(Pt);if(It&&It.hasData())return It.getBucket(S)},Bt=[0,-1,1];for(const Pt of Bt){if(Ye.overscaledZ+Pt(ee[0]=Math.min(Ye.min.y,At.min.y),ee[1]=Math.max(Ye.max.y,At.max.y),ee[2]=i.EXTENT-At.min.x>Ye.max.x?At.min.x-i.EXTENT:Ye.max.x,ee),fe=(Ye,At)=>(ee[0]=Math.min(Ye.min.x,At.min.x),ee[1]=Math.max(Ye.max.x,At.max.x),ee[2]=i.EXTENT-At.min.y>Ye.max.y?At.min.y-i.EXTENT:Ye.max.y,ee),Se=[(Ye,At)=>pe(Ye,At),(Ye,At)=>pe(At,Ye),(Ye,At)=>fe(Ye,At),(Ye,At)=>fe(At,Ye)],Qe=new i.pointGeometry(0,0);let rt,nt,lt;const Xe=(Ye,At,ht,Bt,Pt)=>{const It=[[Bt?ht:Ye,Bt?Ye:ht,0],[Bt?ht:At,Bt?At:ht,0]],Ht=Pt<0?i.EXTENT+Pt:Pt,hi=[Bt?Ht:(Ye+At)/2,Bt?(Ye+At)/2:Ht,0];return ht===0&&Pt<0||ht!==0&&Pt>0?P.getForTilePoints(lt,[hi],!0,nt):It.push(hi),P.getForTilePoints(m,It,!0,rt),Math.max(It[0][2],It[1][2],hi[2])/P.exaggeration()};for(let Ye=0;Ye<4;Ye++){const At=(Ye<2?1:5)-Ye,ht=b.borders[Ye];if(ht.length===0)continue;const Bt=lt=H[Ye](m),Pt=W(Bt);if(!(Pt&&Pt instanceof i.FillExtrusionBucket&&Pt.enableTerrain)||b.borderDoneWithNeighborZ[Ye]===Pt.canonical.z&&Pt.borderDoneWithNeighborZ[At]===b.canonical.z||(nt=P.findDEMTileFor(Bt),!nt||!nt.dem))continue;if(!rt){const si=P.findDEMTileFor(m);if(!si||!si.dem)return;rt=si}const It=Pt.borders[At];let Ht=0;const hi=Pt.borderDoneWithNeighborZ[At]!==b.canonical.z;if(b.canonical.z===Pt.canonical.z){for(let si=0;siji[0]+3));)hi&&Pt.encodeCentroid(void 0,Kt,!1),Ht++;if(Kt&&Htji[1]-3)&&(di++,++Ht!==It.length);)Kt=Pt.featuresOnBorder[It[Ht]];if(Kt=Pt.featuresOnBorder[It[Bi]],qt.intersectsCount()>1||Kt.intersectsCount()>1||di!==1){di!==1&&(Ht=Bi),b.encodeCentroid(void 0,qt,!1),hi&&Pt.encodeCentroid(void 0,Kt,!1);continue}const Ri=Se[Ye](qt,Kt),Ai=Ye%2?i.EXTENT-1:0;Qe.x=Xe(Ri[0],Math.min(i.EXTENT-1,Ri[1]),Ai,Ye<2,Ri[2]),Qe.y=0,b.encodeCentroid(Qe,qt,!1),hi&&Pt.encodeCentroid(Qe,Kt,!1)}else b.encodeCentroid(void 0,qt,!1)}b.borderDoneWithNeighborZ[Ye]=Pt.canonical.z,b.needsCentroidUpdate=!0,hi&&(Pt.borderDoneWithNeighborZ[At]=b.canonical.z,Pt.needsCentroidUpdate=!0)}else{for(const si of ht)b.encodeCentroid(void 0,b.featuresOnBorder[si],!1);if(hi){for(const si of It)Pt.encodeCentroid(void 0,Pt.featuresOnBorder[si],!1);Pt.borderDoneWithNeighborZ[At]=b.canonical.z,Pt.needsCentroidUpdate=!0}b.borderDoneWithNeighborZ[Ye]=Pt.canonical.z,b.needsCentroidUpdate=!0}}(b.needsCentroidUpdate||!b.centroidVertexBuffer&&b.centroidVertexArray.length!==0)&&b.uploadCentroid(x)}const ml=new i.Color(1,0,0,1),kh=new i.Color(0,1,0,1),Oh=new i.Color(0,0,1,1),lA=new i.Color(1,0,1,1),od=new i.Color(0,1,1,1);function Nh(x,a,m){const b=x.context,S=x.transform,P=b.gl,H=S.projection.name==="globe",W=H?["PROJECTION_GLOBE_VIEW"]:null;let ee=m.projMatrix;if(H&&i.globeToMercatorTransition(S.zoom)>0){const qt=i.transitionTileAABBinECEF(m.canonical,S),ji=i.globeDenormalizeECEF(qt);ee=i.multiply(new Float32Array(16),S.globeMatrix,ji),i.multiply(ee,S.projMatrix,ee)}const pe=x.useProgram("debug",null,W),fe=a.getTileByID(m.key);x.terrain&&x.terrain.setupElevationDraw(fe,pe);const Se=i.DepthMode.disabled,Qe=i.StencilMode.disabled,rt=x.colorModeForRenderPass(),nt="$debug";b.activeTexture.set(P.TEXTURE0),x.emptyTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),H?fe._makeGlobeTileDebugBuffers(x.context,S):fe._makeDebugTileBoundsBuffers(x.context,S.projection);const lt=fe._tileDebugBuffer||x.debugBuffer,Xe=fe._tileDebugIndexBuffer||x.debugIndexBuffer,Ye=fe._tileDebugSegments||x.debugSegments;pe.draw(b,P.LINE_STRIP,Se,Qe,rt,i.CullFaceMode.disabled,ha(ee,i.Color.red),nt,lt,Xe,Ye,null,null,null,[fe._globeTileDebugBorderBuffer]);const At=fe.latestRawTileData,ht=Math.floor((At&&At.byteLength||0)/1024),Bt=a.getTile(m).tileSize,Pt=512/Math.min(Bt,512)*(m.overscaledZ/S.zoom)*.5;let It=m.canonical.toString();m.overscaledZ!==m.canonical.z&&(It+=` => ${m.overscaledZ}`),It+=` ${ht}kb`,function(qt,ji){qt.initDebugOverlayCanvas();const Kt=qt.debugOverlayCanvas,Bi=qt.context.gl,di=qt.debugOverlayCanvas.getContext("2d");di.clearRect(0,0,Kt.width,Kt.height),di.shadowColor="white",di.shadowBlur=2,di.lineWidth=1.5,di.strokeStyle="white",di.textBaseline="top",di.font="bold 36px Open Sans, sans-serif",di.fillText(ji,5,5),di.strokeText(ji,5,5),qt.debugOverlayTexture.update(Kt),qt.debugOverlayTexture.bind(Bi.LINEAR,Bi.CLAMP_TO_EDGE)}(x,It);const Ht=fe._tileDebugTextBuffer||x.debugBuffer,hi=fe._tileDebugTextIndexBuffer||x.quadTriangleIndexBuffer,si=fe._tileDebugTextSegments||x.debugSegments;pe.draw(b,P.TRIANGLES,Se,Qe,i.ColorMode.alphaBlended,i.CullFaceMode.disabled,ha(ee,i.Color.transparent,Pt),nt,Ht,hi,si,null,null,null,[fe._globeTileDebugTextBuffer])}function fc(x,a,m,b){pn(x,0,a+m/2,x.transform.width,m,b)}function ua(x,a,m,b){pn(x,a-m/2,0,m,x.transform.height,b)}function pn(x,a,m,b,S,P){const H=x.context,W=H.gl;W.enable(W.SCISSOR_TEST),W.scissor(a*i.exported.devicePixelRatio,m*i.exported.devicePixelRatio,b*i.exported.devicePixelRatio,S*i.exported.devicePixelRatio),H.clear({color:P}),W.disable(W.SCISSOR_TEST)}const eh=i.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Wl}=eh;function Ns(x,a,m,b){x.emplaceBack(a,m,b)}class gl{constructor(a){this.vertexArray=new i.StructArrayLayout3f12,this.indices=new i.StructArrayLayout3ui6,Ns(this.vertexArray,-1,-1,1),Ns(this.vertexArray,1,-1,1),Ns(this.vertexArray,-1,1,1),Ns(this.vertexArray,1,1,1),Ns(this.vertexArray,-1,-1,-1),Ns(this.vertexArray,1,-1,-1),Ns(this.vertexArray,-1,1,-1),Ns(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=a.createVertexBuffer(this.vertexArray,Wl),this.indexBuffer=a.createIndexBuffer(this.indices),this.segment=i.SegmentVector.simpleSegment(0,0,36,12)}}function un(x,a,m,b,S,P){const H=x.gl,W=a.paint.get("sky-atmosphere-color"),ee=a.paint.get("sky-atmosphere-halo-color"),pe=a.paint.get("sky-atmosphere-sun-intensity"),fe=((Se,Qe,rt,nt,lt)=>({u_matrix_3f:Se,u_sun_direction:Qe,u_sun_intensity:rt,u_color_tint_r:[nt.r,nt.g,nt.b,nt.a],u_color_tint_m:[lt.r,lt.g,lt.b,lt.a],u_luminance:5e-5}))(i.fromMat4(i.create$1(),b),S,pe,W,ee);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+P,a.skyboxTexture,0),m.draw(x,H.TRIANGLES,i.DepthMode.disabled,i.StencilMode.disabled,i.ColorMode.unblended,i.CullFaceMode.frontCW,fe,"skyboxCapture",a.skyboxGeometry.vertexBuffer,a.skyboxGeometry.indexBuffer,a.skyboxGeometry.segment)}const th=i.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Ur{constructor(a){const m=new i.StructArrayLayout5f20;m.emplaceBack(-1,1,1,0,0),m.emplaceBack(1,1,1,1,0),m.emplaceBack(1,-1,1,1,1),m.emplaceBack(-1,-1,1,0,1);const b=new i.StructArrayLayout3ui6;b.emplaceBack(0,1,2),b.emplaceBack(2,3,0),this.vertexBuffer=a.createVertexBuffer(m,th.members),this.indexBuffer=a.createIndexBuffer(b),this.segments=i.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const mc={symbol:function(x,a,m,b,S){if(x.renderPass!=="translucent")return;const P=i.StencilMode.disabled,H=x.colorModeForRenderPass();m.layout.get("text-variable-anchor")&&function(W,ee,pe,fe,Se,Qe,rt){const nt=ee.transform,lt=Se==="map",Xe=Qe==="map";for(const Ye of W){const At=fe.getTile(Ye),ht=At.getBucket(pe);if(!ht||!ht.text||!ht.text.segments.get().length)continue;const Bt=i.evaluateSizeForZoom(ht.textSizeData,nt.zoom),Pt=kl(Ye,ht.getProjection(),nt),It=nt.calculatePixelsToTileUnitsMatrix(At),Ht=Mr(Pt,At.tileID.canonical,Xe,lt,nt,ht.getProjection(),It),hi=pe.layout.get("icon-text-fit")!=="none"&&ht.hasIconData();if(Bt){const si=Math.pow(2,nt.zoom-At.tileID.overscaledZ);Jc(ht,lt,Xe,rt,i.symbolSize,nt,Ht,Ye,si,Bt,hi)}}}(b,x,m,a,m.layout.get("text-rotation-alignment"),m.layout.get("text-pitch-alignment"),S),m.paint.get("icon-opacity").constantOr(1)!==0&&xa(x,a,m,b,!1,m.paint.get("icon-translate"),m.paint.get("icon-translate-anchor"),m.layout.get("icon-rotation-alignment"),m.layout.get("icon-pitch-alignment"),m.layout.get("icon-keep-upright"),P,H),m.paint.get("text-opacity").constantOr(1)!==0&&xa(x,a,m,b,!0,m.paint.get("text-translate"),m.paint.get("text-translate-anchor"),m.layout.get("text-rotation-alignment"),m.layout.get("text-pitch-alignment"),m.layout.get("text-keep-upright"),P,H),a.map.showCollisionBoxes&&(pc(x,a,m,b,m.paint.get("text-translate"),m.paint.get("text-translate-anchor"),!0),pc(x,a,m,b,m.paint.get("icon-translate"),m.paint.get("icon-translate-anchor"),!1))},circle:function(x,a,m,b){if(x.renderPass!=="translucent")return;const S=m.paint.get("circle-opacity"),P=m.paint.get("circle-stroke-width"),H=m.paint.get("circle-stroke-opacity"),W=m.layout.get("circle-sort-key").constantOr(1)!==void 0;if(S.constantOr(1)===0&&(P.constantOr(1)===0||H.constantOr(1)===0))return;const ee=x.context,pe=ee.gl,fe=x.transform,Se=x.depthModeForSublayer(0,i.DepthMode.ReadOnly),Qe=i.StencilMode.disabled,rt=x.colorModeForRenderPass(),nt=fe.projection.name==="globe",lt=[i.mercatorXfromLng(fe.center.lng),i.mercatorYfromLat(fe.center.lat)],Xe=[];for(let At=0;AtAt.sortKey-ht.sortKey);const Ye={useDepthForOcclusion:!nt};for(const At of Xe){const{programConfiguration:ht,program:Bt,layoutVertexBuffer:Pt,globeExtVertexBuffer:It,indexBuffer:Ht,uniformValues:hi,tile:si}=At.state,qt=At.segments;x.terrain&&x.terrain.setupElevationDraw(si,Bt,Ye),x.prepareDrawProgram(ee,Bt,si.tileID.toUnwrapped()),Bt.draw(ee,pe.TRIANGLES,Se,Qe,rt,i.CullFaceMode.disabled,hi,m.id,Pt,Ht,qt,m.paint,fe.zoom,ht,[It])}},heatmap:function(x,a,m,b){if(m.paint.get("heatmap-opacity")!==0)if(x.renderPass==="offscreen"){const S=x.context,P=S.gl,H=i.StencilMode.disabled,W=new i.ColorMode([P.ONE,P.ONE],i.Color.transparent,[!0,!0,!0,!0]);(function(rt,nt,lt,Xe){const Ye=rt.gl,At=nt.width*Xe,ht=nt.height*Xe;rt.activeTexture.set(Ye.TEXTURE1),rt.viewport.set([0,0,At,ht]);let Bt=lt.heatmapFbo;if(!Bt||Bt&&(Bt.width!==At||Bt.height!==ht)){Bt&&Bt.destroy();const Pt=Ye.createTexture();Ye.bindTexture(Ye.TEXTURE_2D,Pt),Ye.texParameteri(Ye.TEXTURE_2D,Ye.TEXTURE_WRAP_S,Ye.CLAMP_TO_EDGE),Ye.texParameteri(Ye.TEXTURE_2D,Ye.TEXTURE_WRAP_T,Ye.CLAMP_TO_EDGE),Ye.texParameteri(Ye.TEXTURE_2D,Ye.TEXTURE_MIN_FILTER,Ye.LINEAR),Ye.texParameteri(Ye.TEXTURE_2D,Ye.TEXTURE_MAG_FILTER,Ye.LINEAR),Bt=lt.heatmapFbo=rt.createFramebuffer(At,ht,!1),function(It,Ht,hi,si,qt,ji){const Kt=It.gl;Kt.texImage2D(Kt.TEXTURE_2D,0,Kt.RGBA,qt,ji,0,Kt.RGBA,It.extRenderToTextureHalfFloat?It.extTextureHalfFloat.HALF_FLOAT_OES:Kt.UNSIGNED_BYTE,null),si.colorAttachment.set(hi)}(rt,0,Pt,Bt,At,ht)}else Ye.bindTexture(Ye.TEXTURE_2D,Bt.colorAttachment.get()),rt.bindFramebuffer.set(Bt.framebuffer)})(S,x,m,x.transform.projection.name==="globe"?.5:.25),S.clear({color:i.Color.transparent});const ee=x.transform,pe=ee.projection.name==="globe",fe=pe?["PROJECTION_GLOBE_VIEW"]:null,Se=pe?i.CullFaceMode.frontCCW:i.CullFaceMode.disabled,Qe=[i.mercatorXfromLng(ee.center.lng),i.mercatorYfromLat(ee.center.lat)];for(let rt=0;rt({u_image:0,u_color_ramp:1,u_opacity:Se.paint.get("heatmap-opacity")}))(0,P),P.id,S.viewportBuffer,S.quadTriangleIndexBuffer,S.viewportSegments,P.paint,S.transform.zoom)}(x,m))},line:function(x,a,m,b){if(x.renderPass!=="translucent")return;const S=m.paint.get("line-opacity"),P=m.paint.get("line-width");if(S.constantOr(1)===0||P.constantOr(1)===0)return;const H=x.depthModeForSublayer(0,i.DepthMode.ReadOnly),W=x.colorModeForRenderPass(),ee=x.terrain&&x.terrain.renderingToTexture?1:i.exported.devicePixelRatio,pe=m.paint.get("line-dasharray"),fe=pe.constantOr(1),Se=m.layout.get("line-cap"),Qe=m.paint.get("line-pattern"),rt=Qe.constantOr(1),nt=m.paint.get("line-gradient"),lt=rt?"linePattern":"line",Xe=x.context,Ye=Xe.gl,At=(Bt=>{const Pt=[];Gl(Bt)&&Pt.push("RENDER_LINE_DASH"),Bt.paint.get("line-gradient")&&Pt.push("RENDER_LINE_GRADIENT");const It=Bt.paint.get("line-trim-offset");It[0]===0&&It[1]===0||Pt.push("RENDER_LINE_TRIM_OFFSET");const Ht=Bt.paint.get("line-pattern").constantOr(1),hi=Bt.paint.get("line-opacity").constantOr(1)!==1;return!Ht&&hi&&Pt.push("RENDER_LINE_ALPHA_DISCARD"),Pt})(m);let ht=At.includes("RENDER_LINE_ALPHA_DISCARD");x.terrain&&x.terrain.clipOrMaskOverlapStencilType()&&(ht=!1);for(const Bt of b){const Pt=a.getTile(Bt);if(rt&&!Pt.patternsLoaded())continue;const It=Pt.getBucket(m);if(!It)continue;x.prepareDrawTile();const Ht=It.programConfigurations.get(m.id),hi=x.useProgram(lt,Ht,At),si=Qe.constantOr(null);if(si&&Pt.imageAtlas){const Mi=Pt.imageAtlas.patternPositions[si.toString()];Mi&&Ht.setConstantPatternPositions(Mi)}const qt=pe.constantOr(null),ji=Se.constantOr(null);if(!rt&&qt&&ji&&Pt.lineAtlas){const Mi=Pt.lineAtlas.getDash(qt,ji);Mi&&Ht.setConstantPatternPositions(Mi)}let[Kt,Bi]=m.paint.get("line-trim-offset");(ji==="round"||ji==="square")&&Kt!==Bi&&(Kt===0&&(Kt-=1),Bi===1&&(Bi+=1));const di=x.terrain?Bt.projMatrix:null,Ri=rt?Ho(x,Pt,m,di,ee):aA(x,Pt,m,di,It.lineClipsArray.length,ee,[Kt,Bi]);if(nt){const Mi=It.gradients[m.id];let $i=Mi.texture;if(m.gradientVersion!==Mi.version){let Jt=256;if(m.stepInterpolant){const pi=a.getSource().maxzoom,In=Bt.canonical.z===pi?Math.ceil(1<{hi.draw(Xe,Ye.TRIANGLES,H,Mi,W,i.CullFaceMode.disabled,Ri,m.id,It.layoutVertexBuffer,It.indexBuffer,It.segments,m.paint,x.transform.zoom,Ht,[It.layoutVertexBuffer2])};if(ht){const Mi=x.stencilModeForClipping(Bt).ref;Mi===0&&x.terrain&&Xe.clear({stencil:0});const $i={func:Ye.EQUAL,mask:255};Ri.u_alpha_discard_threshold=.8,Ai(new i.StencilMode($i,Mi,255,Ye.KEEP,Ye.KEEP,Ye.INVERT)),Ri.u_alpha_discard_threshold=0,Ai(new i.StencilMode($i,Mi,255,Ye.KEEP,Ye.KEEP,Ye.KEEP))}else Ai(x.stencilModeForClipping(Bt))}ht&&(x.resetStencilClippingMasks(),x.terrain&&Xe.clear({stencil:0}))},fill:function(x,a,m,b){const S=m.paint.get("fill-color"),P=m.paint.get("fill-opacity");if(P.constantOr(1)===0)return;const H=x.colorModeForRenderPass(),W=m.paint.get("fill-pattern"),ee=x.opaquePassEnabledForLayer()&&!W.constantOr(1)&&S.constantOr(i.Color.transparent).a===1&&P.constantOr(0)===1?"opaque":"translucent";if(x.renderPass===ee){const pe=x.depthModeForSublayer(1,x.renderPass==="opaque"?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly);rd(x,a,m,b,pe,H,!1)}if(x.renderPass==="translucent"&&m.paint.get("fill-antialias")){const pe=x.depthModeForSublayer(m.getPaintProperty("fill-outline-color")?2:0,i.DepthMode.ReadOnly);rd(x,a,m,b,pe,H,!0)}},"fill-extrusion":function(x,a,m,b){const S=m.paint.get("fill-extrusion-opacity");if(S!==0&&x.renderPass==="translucent"){const P=new i.DepthMode(x.context.gl.LEQUAL,i.DepthMode.ReadWrite,x.depthRangeFor3D);if(S!==1||m.paint.get("fill-extrusion-pattern").constantOr(1))Ga(x,a,m,b,P,i.StencilMode.disabled,i.ColorMode.disabled),Ga(x,a,m,b,P,x.stencilModeFor3D(),x.colorModeForRenderPass()),x.resetStencilClippingMasks();else{const H=x.colorModeForRenderPass();Ga(x,a,m,b,P,i.StencilMode.disabled,H)}}},hillshade:function(x,a,m,b){if(x.renderPass!=="offscreen"&&x.renderPass!=="translucent")return;const S=x.context,P=x.depthModeForSublayer(0,i.DepthMode.ReadOnly),H=x.colorModeForRenderPass(),W=x.terrain&&x.terrain.renderingToTexture,[ee,pe]=x.renderPass!=="translucent"||W?[{},b]:x.stencilConfigForOverlap(b);for(const fe of pe){const Se=a.getTile(fe);if(Se.needsHillshadePrepare&&x.renderPass==="offscreen")Ha(x,Se,m,P,i.StencilMode.disabled,H);else if(x.renderPass==="translucent"){const Qe=W&&x.terrain?x.terrain.stencilModeForRTTOverlap(fe):ee[fe.overscaledZ];_u(x,fe,Se,m,P,Qe,H)}}S.viewport.set([0,0,x.width,x.height]),x.resetStencilClippingMasks()},raster:function(x,a,m,b,S,P){if(x.renderPass!=="translucent"||m.paint.get("raster-opacity")===0||!b.length)return;const H=x.context,W=H.gl,ee=a.getSource(),pe=x.useProgram("raster"),fe=x.colorModeForRenderPass(),Se=x.terrain&&x.terrain.renderingToTexture,[Qe,rt]=ee instanceof X||Se?[{},b]:x.stencilConfigForOverlap(b),nt=rt[rt.length-1].overscaledZ,lt=!x.options.moving;for(const Xe of rt){const Ye=Se?i.DepthMode.disabled:x.depthModeForSublayer(Xe.overscaledZ-nt,m.paint.get("raster-opacity")===1?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly,W.LESS),At=Xe.toUnwrapped(),ht=a.getTile(Xe);if(Se&&(!ht||!ht.hasData()))continue;const Bt=Se?Xe.projMatrix:x.transform.calculateProjMatrix(At,lt),Pt=x.terrain&&Se?x.terrain.stencilModeForRTTOverlap(Xe):Qe[Xe.overscaledZ],It=P?0:m.paint.get("raster-fade-duration");ht.registerFadeDuration(It);const Ht=a.findLoadedParent(Xe,0),hi=Hl(ht,Ht,a,x.transform,It);let si,qt;x.terrain&&x.terrain.prepareDrawTile();const ji=m.paint.get("raster-resampling")==="nearest"?W.NEAREST:W.LINEAR;H.activeTexture.set(W.TEXTURE0),ht.texture.bind(ji,W.CLAMP_TO_EDGE),H.activeTexture.set(W.TEXTURE1),Ht?(Ht.texture.bind(ji,W.CLAMP_TO_EDGE),si=Math.pow(2,Ht.tileID.overscaledZ-ht.tileID.overscaledZ),qt=[ht.tileID.canonical.x*si%1,ht.tileID.canonical.y*si%1]):ht.texture.bind(ji,W.CLAMP_TO_EDGE);const Kt=vu(Bt,qt||[0,0],si||1,hi,m,ee instanceof X?ee.perspectiveTransform:[0,0]);if(x.prepareDrawProgram(H,pe,At),ee instanceof X)ee.boundsBuffer&&ee.boundsSegments&&pe.draw(H,W.TRIANGLES,Ye,i.StencilMode.disabled,fe,i.CullFaceMode.disabled,Kt,m.id,ee.boundsBuffer,x.quadTriangleIndexBuffer,ee.boundsSegments);else{const{tileBoundsBuffer:Bi,tileBoundsIndexBuffer:di,tileBoundsSegments:Ri}=x.getTileBoundsBuffers(ht);pe.draw(H,W.TRIANGLES,Ye,Pt,fe,i.CullFaceMode.disabled,Kt,m.id,Bi,di,Ri)}}x.resetStencilClippingMasks()},background:function(x,a,m,b){const S=m.paint.get("background-color"),P=m.paint.get("background-opacity");if(P===0)return;const H=x.context,W=H.gl,ee=x.transform,pe=ee.tileSize,fe=m.paint.get("background-pattern");if(x.isPatternMissing(fe))return;const Se=!fe&&S.a===1&&P===1&&x.opaquePassEnabledForLayer()?"opaque":"translucent";if(x.renderPass!==Se)return;const Qe=i.StencilMode.disabled,rt=x.depthModeForSublayer(0,Se==="opaque"?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly),nt=x.colorModeForRenderPass(),lt=x.useProgram(fe?"backgroundPattern":"background");let Xe,Ye=b;Ye||(Xe=x.getBackgroundTiles(),Ye=Object.values(Xe).map(At=>At.tileID)),fe&&(H.activeTexture.set(W.TEXTURE0),x.imageManager.bind(x.context));for(const At of Ye){const ht=At.toUnwrapped(),Bt=b?At.projMatrix:x.transform.calculateProjMatrix(ht);x.prepareDrawTile();const Pt=a?a.getTile(At):Xe?Xe[At.key]:new i.Tile(At,pe,ee.zoom,x),It=fe?wu(Bt,P,x,fe,{tileID:At,tileSize:pe}):Rh(Bt,P,S);x.prepareDrawProgram(H,lt,ht);const{tileBoundsBuffer:Ht,tileBoundsIndexBuffer:hi,tileBoundsSegments:si}=x.getTileBoundsBuffers(Pt);lt.draw(H,W.TRIANGLES,rt,Qe,nt,i.CullFaceMode.disabled,It,m.id,Ht,hi,si)}},sky:function(x,a,m){const b=x.transform,S=b.projection.name==="mercator"||b.projection.name==="globe"?1:i.smoothstep(7,8,b.zoom),P=m.paint.get("sky-opacity")*S;if(P===0)return;const H=x.context,W=m.paint.get("sky-type"),ee=new i.DepthMode(H.gl.LEQUAL,i.DepthMode.ReadOnly,[0,1]),pe=x.frameCounter/1e3%1;W==="atmosphere"?x.renderPass==="offscreen"?m.needsSkyboxCapture(x)&&(function(fe,Se,Qe,rt){const nt=fe.context,lt=nt.gl;let Xe=Se.skyboxFbo;if(!Xe){Xe=Se.skyboxFbo=nt.createFramebuffer(32,32,!1),Se.skyboxGeometry=new gl(nt),Se.skyboxTexture=nt.gl.createTexture(),lt.bindTexture(lt.TEXTURE_CUBE_MAP,Se.skyboxTexture),lt.texParameteri(lt.TEXTURE_CUBE_MAP,lt.TEXTURE_WRAP_S,lt.CLAMP_TO_EDGE),lt.texParameteri(lt.TEXTURE_CUBE_MAP,lt.TEXTURE_WRAP_T,lt.CLAMP_TO_EDGE),lt.texParameteri(lt.TEXTURE_CUBE_MAP,lt.TEXTURE_MIN_FILTER,lt.LINEAR),lt.texParameteri(lt.TEXTURE_CUBE_MAP,lt.TEXTURE_MAG_FILTER,lt.LINEAR);for(let Bt=0;Bt<6;++Bt)lt.texImage2D(lt.TEXTURE_CUBE_MAP_POSITIVE_X+Bt,0,lt.RGBA,32,32,0,lt.RGBA,lt.UNSIGNED_BYTE,null)}nt.bindFramebuffer.set(Xe.framebuffer),nt.viewport.set([0,0,32,32]);const Ye=Se.getCenter(fe,!0),At=fe.useProgram("skyboxCapture"),ht=new Float64Array(16);i.identity(ht),i.rotateY(ht,ht,.5*-Math.PI),un(nt,Se,At,ht,Ye,0),i.identity(ht),i.rotateY(ht,ht,.5*Math.PI),un(nt,Se,At,ht,Ye,1),i.identity(ht),i.rotateX(ht,ht,.5*-Math.PI),un(nt,Se,At,ht,Ye,2),i.identity(ht),i.rotateX(ht,ht,.5*Math.PI),un(nt,Se,At,ht,Ye,3),i.identity(ht),un(nt,Se,At,ht,Ye,4),i.identity(ht),i.rotateY(ht,ht,Math.PI),un(nt,Se,At,ht,Ye,5),nt.viewport.set([0,0,fe.width,fe.height])}(x,m),m.markSkyboxValid(x)):x.renderPass==="sky"&&function(fe,Se,Qe,rt,nt){const lt=fe.context,Xe=lt.gl,Ye=fe.transform,At=fe.useProgram("skybox");lt.activeTexture.set(Xe.TEXTURE0),Xe.bindTexture(Xe.TEXTURE_CUBE_MAP,Se.skyboxTexture);const ht=((Bt,Pt,It,Ht,hi)=>({u_matrix:Bt,u_sun_direction:Pt,u_cubemap:0,u_opacity:Ht,u_temporal_offset:hi}))(Ye.skyboxMatrix,Se.getCenter(fe,!1),0,rt,nt);fe.prepareDrawProgram(lt,At),At.draw(lt,Xe.TRIANGLES,Qe,i.StencilMode.disabled,fe.colorModeForRenderPass(),i.CullFaceMode.backCW,ht,"skybox",Se.skyboxGeometry.vertexBuffer,Se.skyboxGeometry.indexBuffer,Se.skyboxGeometry.segment)}(x,m,ee,P,pe):W==="gradient"&&x.renderPass==="sky"&&function(fe,Se,Qe,rt,nt){const lt=fe.context,Xe=lt.gl,Ye=fe.transform,At=fe.useProgram("skyboxGradient");Se.skyboxGeometry||(Se.skyboxGeometry=new gl(lt)),lt.activeTexture.set(Xe.TEXTURE0);let ht=Se.colorRampTexture;ht||(ht=Se.colorRampTexture=new i.Texture(lt,Se.colorRamp,Xe.RGBA)),ht.bind(Xe.LINEAR,Xe.CLAMP_TO_EDGE);const Bt=((Pt,It,Ht,hi,si)=>({u_matrix:Pt,u_color_ramp:0,u_center_direction:It,u_radius:i.degToRad(Ht),u_opacity:hi,u_temporal_offset:si}))(Ye.skyboxMatrix,Se.getCenter(fe,!1),Se.paint.get("sky-gradient-radius"),rt,nt);fe.prepareDrawProgram(lt,At),At.draw(lt,Xe.TRIANGLES,Qe,i.StencilMode.disabled,fe.colorModeForRenderPass(),i.CullFaceMode.backCW,Bt,"skyboxGradient",Se.skyboxGeometry.vertexBuffer,Se.skyboxGeometry.indexBuffer,Se.skyboxGeometry.segment)}(x,m,ee,P,pe)},debug:function(x,a,m){for(let b=0;bS)return void(this.transform.fogCullDistSq=null);const P=b+.78*(S-b);this.transform.fogCullDistSq=P*P}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(a,m){if(this.width=a*i.exported.devicePixelRatio,this.height=m*i.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const b of this.style.order)this.style._layers[b].resize()}setup(){const a=this.context,m=new i.StructArrayLayout2i4;m.emplaceBack(0,0),m.emplaceBack(i.EXTENT,0),m.emplaceBack(0,i.EXTENT),m.emplaceBack(i.EXTENT,i.EXTENT),this.tileExtentBuffer=a.createVertexBuffer(m,i.posAttributes.members),this.tileExtentSegments=i.SegmentVector.simpleSegment(0,0,4,2);const b=new i.StructArrayLayout2i4;b.emplaceBack(0,0),b.emplaceBack(i.EXTENT,0),b.emplaceBack(0,i.EXTENT),b.emplaceBack(i.EXTENT,i.EXTENT),this.debugBuffer=a.createVertexBuffer(b,i.posAttributes.members),this.debugSegments=i.SegmentVector.simpleSegment(0,0,4,5);const S=new i.StructArrayLayout2i4;S.emplaceBack(-1,-1),S.emplaceBack(1,-1),S.emplaceBack(-1,1),S.emplaceBack(1,1),this.viewportBuffer=a.createVertexBuffer(S,i.posAttributes.members),this.viewportSegments=i.SegmentVector.simpleSegment(0,0,4,2);const P=new i.StructArrayLayout4i8;P.emplaceBack(0,0,0,0),P.emplaceBack(i.EXTENT,0,i.EXTENT,0),P.emplaceBack(0,i.EXTENT,0,i.EXTENT),P.emplaceBack(i.EXTENT,i.EXTENT,i.EXTENT,i.EXTENT),this.mercatorBoundsBuffer=a.createVertexBuffer(P,i.boundsAttributes.members),this.mercatorBoundsSegments=i.SegmentVector.simpleSegment(0,0,4,2);const H=new i.StructArrayLayout3ui6;H.emplaceBack(0,1,2),H.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=a.createIndexBuffer(H);const W=new i.StructArrayLayout1ui2;for(const pe of[0,1,3,2,0])W.emplaceBack(pe);this.debugIndexBuffer=a.createIndexBuffer(W),this.emptyTexture=new i.Texture(a,new i.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),a.gl.RGBA),this.identityMat=i.create();const ee=this.context.gl;this.stencilClearMode=new i.StencilMode({func:ee.ALWAYS,mask:0},0,255,ee.ZERO,ee.ZERO,ee.ZERO),this.loadTimeStamps.push(i.window.performance.now()),this.atmosphereBuffer=new Ur(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(a){return a._makeTileBoundsBuffers(this.context,this.transform.projection),a._tileBoundsBuffer?{tileBoundsBuffer:a._tileBoundsBuffer,tileBoundsIndexBuffer:a._tileBoundsIndexBuffer,tileBoundsSegments:a._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const a=this.context,m=a.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(a,m.TRIANGLES,i.DepthMode.disabled,this.stencilClearMode,i.ColorMode.disabled,i.CullFaceMode.disabled,$r(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(a,m,b){if(!m||this.currentStencilSource===m.id||!a.isTileClipped()||!b||b.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let W=!1;for(const ee of b)if(this._tileClippingMaskIDs[ee.key]===void 0){W=!0;break}if(!W)return}this.currentStencilSource=m.id;const S=this.context,P=S.gl;this.nextStencilID+b.length>256&&this.clearStencil(),S.setColorMode(i.ColorMode.disabled),S.setDepthMode(i.DepthMode.disabled);const H=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const W of b){const ee=m.getTile(W),pe=this._tileClippingMaskIDs[W.key]=this.nextStencilID++,{tileBoundsBuffer:fe,tileBoundsIndexBuffer:Se,tileBoundsSegments:Qe}=this.getTileBoundsBuffers(ee);H.draw(S,P.TRIANGLES,i.DepthMode.disabled,new i.StencilMode({func:P.ALWAYS,mask:0},pe,255,P.KEEP,P.KEEP,P.REPLACE),i.ColorMode.disabled,i.CullFaceMode.disabled,$r(W.projMatrix),"$clipping",fe,Se,Qe)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const a=this.nextStencilID++,m=this.context.gl;return new i.StencilMode({func:m.NOTEQUAL,mask:255},a,255,m.KEEP,m.KEEP,m.REPLACE)}stencilModeForClipping(a){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(a);const m=this.context.gl;return new i.StencilMode({func:m.EQUAL,mask:255},this._tileClippingMaskIDs[a.key],0,m.KEEP,m.KEEP,m.REPLACE)}stencilConfigForOverlap(a){const m=this.context.gl,b=a.sort((H,W)=>W.overscaledZ-H.overscaledZ),S=b[b.length-1].overscaledZ,P=b[0].overscaledZ-S+1;if(P>1){this.currentStencilSource=void 0,this.nextStencilID+P>256&&this.clearStencil();const H={};for(let W=0;W=0;this.currentLayer--){const ee=this.style._layers[b[this.currentLayer]],pe=a._getLayerSourceCache(ee);if(ee.isSky())continue;const fe=pe?H[pe.id]:void 0;this._renderTileClippingMasks(ee,pe,fe),this.renderLayer(this,pe,ee,fe)}if(this.style.fog&&this.transform.projection.supportsFog&&function(ee,pe){const fe=ee.context,Se=fe.gl,Qe=ee.transform,rt=new i.DepthMode(Se.LEQUAL,i.DepthMode.ReadOnly,[0,1]),nt=ee.useProgram("globeAtmosphere",null,Qe.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),lt=i.globeToMercatorTransition(Qe.zoom),Xe=pe.properties.get("color").toArray01(),Ye=pe.properties.get("high-color").toArray01(),At=pe.properties.get("space-color").toArray01PremultipliedAlpha(),ht=i.identity$1([]);i.rotateY$1(ht,ht,-i.degToRad(Qe._center.lng)),i.rotateX$1(ht,ht,i.degToRad(Qe._center.lat)),i.rotateZ$1(ht,ht,Qe.angle),i.rotateX$1(ht,ht,-Qe._pitch);const Bt=i.fromQuat(new Float32Array(16),ht),Pt=i.mapValue(pe.properties.get("star-intensity"),0,1,0,.25),It=5e-4,Ht=i.mapValue(pe.properties.get("horizon-blend"),0,1,It,.25),hi=i.globeUseCustomAntiAliasing(ee,fe,Qe)&&Ht===It?Qe.worldSize/(2*Math.PI*1.025)-1:Qe.globeRadius,si=ee.frameCounter/1e3%1,qt=i.length(Qe.globeCenterInViewSpace),ji=Math.sqrt(Math.pow(qt,2)-Math.pow(hi,2)),Kt=Math.acos(ji/qt),Bi=((Ri,Ai,Mi,$i,Jt,pi,In,Hn,Mn,$n,ar,On,_n,Dr)=>({u_frustum_tl:Ri,u_frustum_tr:Ai,u_frustum_br:Mi,u_frustum_bl:$i,u_horizon:Jt,u_transition:pi,u_fadeout_range:In,u_color:Hn,u_high_color:Mn,u_space_color:$n,u_star_intensity:ar,u_star_size:5*i.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:On,u_horizon_angle:_n,u_rotation_matrix:Dr}))(Qe.frustumCorners.TL,Qe.frustumCorners.TR,Qe.frustumCorners.BR,Qe.frustumCorners.BL,Qe.frustumCorners.horizon,lt,Ht,Xe,Ye,At,Pt,si,Kt,Bt);ee.prepareDrawProgram(fe,nt);const di=ee.atmosphereBuffer;di&&nt.draw(fe,Se.TRIANGLES,rt,i.StencilMode.disabled,i.ColorMode.alphaBlended,i.CullFaceMode.backCW,Bi,"skybox",di.vertexBuffer,di.indexBuffer,di.segments)}(this,this.style.fog),this.renderPass="sky",(i.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const fe=a._getLayerSourceCache(pe);fe&&!pe.isHidden(this.transform.zoom)&&(!ee||ee.getSource().maxzoom0?m.pop():null}isPatternMissing(a){return a===null||a!==void 0&&!this.imageManager.getPattern(a.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const a=this.terrain&&this.terrain.renderingToTexture,m=this.terrain&&this.terrain.exaggeration()===0,b=this.style&&this.style.fog,S=[];return this.terrainRenderModeElevated()&&S.push("TERRAIN"),this.transform.projection.name==="globe"&&S.push("GLOBE"),m&&S.push("ZERO_EXAGGERATION"),b&&!a&&b.getOpacity(this.transform.pitch)!==0&&S.push("FOG"),a&&S.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&S.push("OVERDRAW_INSPECTOR"),S}useProgram(a,m,b){this.cache=this.cache||{};const S=b||[],P=this.currentGlobalDefines().concat(S),H=rA.cacheKey(Oc[a],a,P,m);return this.cache[H]||(this.cache[H]=new rA(this.context,a,Oc[a],m,nd[a],P)),this.cache[H]}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 a=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(a.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=i.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.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(a,m,b){if(this.terrain&&this.terrain.renderingToTexture)return;const S=this.style.fog;if(S){const P=S.getOpacity(this.transform.pitch),H=((W,ee,pe,fe,Se,Qe,rt,nt,lt,Xe,Ye)=>{const At=W.transform,ht=ee.properties.get("color").toArray01();ht[3]=fe;const Bt=W.frameCounter/1e3%1;return{u_fog_matrix:pe?At.calculateFogTileMatrix(pe):W.identityMat,u_fog_range:ee.getFovAdjustedRange(At._fov),u_fog_color:ht,u_fog_horizon_blend:ee.properties.get("horizon-blend"),u_fog_temporal_offset:Bt,u_frustum_tl:Se,u_frustum_tr:Qe,u_frustum_br:rt,u_frustum_bl:nt,u_globe_pos:lt,u_globe_radius:Xe,u_viewport:Ye,u_globe_transition:i.globeToMercatorTransition(At.zoom),u_is_globe:+(At.projection.name==="globe")}})(this,S,b,P,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*i.exported.devicePixelRatio,this.transform.height*i.exported.devicePixelRatio]);m.setFogUniformValues(a,H)}}setTileLoadedFlag(a){this.tileLoaded=a}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const a=this.context.gl,m=a.createTexture();return a.bindTexture(a.TEXTURE_2D,m),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,a.drawingBufferWidth,a.drawingBufferHeight,0),m}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const a=this.style&&this.style.fog;return!!a&&a.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const a=this._backgroundTiles,m=this._backgroundTiles={},b=this.transform.coveringTiles({tileSize:512});for(const S of b)m[S.key]=a[S.key]||new i.Tile(S,512,this.transform.tileZoom,this);return m}clearBackgroundTiles(){this._backgroundTiles={}}}class Qh{constructor(a=0,m=0,b=0,S=0){if(isNaN(a)||a<0||isNaN(m)||m<0||isNaN(b)||b<0||isNaN(S)||S<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=a,this.bottom=m,this.left=b,this.right=S}interpolate(a,m,b){return m.top!=null&&a.top!=null&&(this.top=i.number(a.top,m.top,b)),m.bottom!=null&&a.bottom!=null&&(this.bottom=i.number(a.bottom,m.bottom,b)),m.left!=null&&a.left!=null&&(this.left=i.number(a.left,m.left,b)),m.right!=null&&a.right!=null&&(this.right=i.number(a.right,m.right,b)),this}getCenter(a,m){const b=i.clamp((this.left+a-this.right)/2,0,a),S=i.clamp((this.top+m-this.bottom)/2,0,m);return new i.pointGeometry(b,S)}equals(a){return this.top===a.top&&this.bottom===a.bottom&&this.left===a.left&&this.right===a.right}clone(){return new Qh(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function gc(x,a){const m=i.getColumn(x,3);i.fromQuat(x,a),i.setColumn(x,3,m)}function hA(x,a){const m=i.identity$1([]);return i.rotateZ$1(m,m,-a),i.rotateX$1(m,m,-x),m}function uA(x,a){const m=[x[0],x[1],0],b=[a[0],a[1],0];if(i.length(m)>=1e-15){const H=i.normalize([],m);i.scale$2(b,H,i.dot(b,H)),a[0]=b[0],a[1]=b[1]}const S=i.cross([],a,x);if(i.len(S)<1e-15)return null;const P=Math.atan2(-S[1],S[0]);return hA(Math.atan2(Math.sqrt(x[0]*x[0]+x[1]*x[1]),-x[2]),P)}class Vh{constructor(a,m){this.position=a,this.orientation=m}get position(){return this._position}set position(a){if(a){const m=a instanceof i.MercatorCoordinate?a:new i.MercatorCoordinate(a[0],a[1],a[2]);this._renderWorldCopies&&(m.x=i.wrap(m.x,0,1)),this._position=m}else this._position=null}lookAtPoint(a,m){if(this.orientation=null,!this.position)return;const b=this._elevation?this._elevation.getAtPointOrZero(i.MercatorCoordinate.fromLngLat(a)):0,S=this.position,P=i.MercatorCoordinate.fromLngLat(a,b),H=[P.x-S.x,P.y-S.y,P.z-S.z];m||(m=[0,0,1]),m[2]=Math.abs(m[2]),this.orientation=uA(H,m)}setPitchBearing(a,m){this.orientation=hA(i.degToRad(a),i.degToRad(-m))}}class Hh{constructor(a,m){this._transform=i.identity([]),this.orientation=m,this.position=a}get mercatorPosition(){const a=this.position;return new i.MercatorCoordinate(a[0],a[1],a[2])}get position(){const a=i.getColumn(this._transform,3);return[a[0],a[1],a[2]]}set position(a){var m;a&&i.setColumn(this._transform,3,[(m=a)[0],m[1],m[2],1])}get orientation(){return this._orientation}set orientation(a){this._orientation=a||i.identity$1([]),a&&gc(this._transform,this._orientation)}getPitchBearing(){const a=this.forward(),m=this.right();return{bearing:Math.atan2(-m[1],m[0]),pitch:Math.atan2(Math.sqrt(a[0]*a[0]+a[1]*a[1]),-a[2])}}setPitchBearing(a,m){this._orientation=hA(a,m),gc(this._transform,this._orientation)}forward(){const a=i.getColumn(this._transform,2);return[-a[0],-a[1],-a[2]]}up(){const a=i.getColumn(this._transform,1);return[-a[0],-a[1],-a[2]]}right(){const a=i.getColumn(this._transform,0);return[a[0],a[1],a[2]]}getCameraToWorld(a,m){const b=new Float64Array(16);return i.invert(b,this.getWorldToCamera(a,m)),b}getWorldToCameraPosition(a,m,b){const S=this.position;i.scale$2(S,S,-a);const P=new Float64Array(16);return i.fromScaling(P,[b,b,b]),i.translate(P,P,S),P[10]*=m,P}getWorldToCamera(a,m){const b=new Float64Array(16),S=new Float64Array(4),P=this.position;return i.conjugate(S,this._orientation),i.scale$2(P,P,-a),i.fromQuat(b,S),i.translate(b,b,P),b[1]*=-1,b[5]*=-1,b[9]*=-1,b[13]*=-1,b[8]*=m,b[9]*=m,b[10]*=m,b[11]*=m,b}getCameraToClipPerspective(a,m,b,S){const P=new Float64Array(16);return i.perspective(P,a,m,b,S),P}getDistanceToElevation(a,m=!1){const b=a===0?0:i.mercatorZfromAltitude(a,m?i.latFromMercatorY(this.position[1]):this.position[1]),S=this.forward();return(b-this.position[2])/S[2]}clone(){return new Hh([...this.position],[...this.orientation])}}function ih(x,a){const m=Is(x.projection,x.zoom,x.width,x.height),b=function(P,H,W,ee,pe){const fe=new i.LngLat(W.lng-180*fo,W.lat),Se=new i.LngLat(W.lng+180*fo,W.lat),Qe=P.project(fe.lng,fe.lat),rt=P.project(Se.lng,Se.lat),nt=-Math.atan2(rt.y-Qe.y,rt.x-Qe.x),lt=i.MercatorCoordinate.fromLngLat(W);lt.y=i.clamp(lt.y,-.999975,.999975);const Xe=lt.toLngLat(),Ye=P.project(Xe.lng,Xe.lat),At=i.MercatorCoordinate.fromLngLat(Xe);At.x+=fo;const ht=At.toLngLat(),Bt=P.project(ht.lng,ht.lat),Pt=jl(Bt.x-Ye.x,Bt.y-Ye.y,nt),It=i.MercatorCoordinate.fromLngLat(Xe);It.y+=fo;const Ht=It.toLngLat(),hi=P.project(Ht.lng,Ht.lat),si=jl(hi.x-Ye.x,hi.y-Ye.y,nt),qt=Math.abs(Pt.x)/Math.abs(si.y),ji=i.identity([]);i.rotateZ(ji,ji,-nt*(1-(pe?0:ee)));const Kt=i.identity([]);return i.scale(Kt,Kt,[1,1-(1-qt)*ee,1]),Kt[4]=-si.x/si.y*ee,i.rotateZ(Kt,Kt,nt),i.multiply(Kt,ji,Kt),Kt}(x.projection,0,x.center,m,a),S=_c(x);return i.scale(b,b,[S,S,1]),b}function _c(x){const a=x.projection,m=Is(x.projection,x.zoom,x.width,x.height),b=Gh(a,x.center),S=Gh(a,i.LngLat.convert(a.center));return Math.pow(2,b*m+(1-m)*S)}function Is(x,a,m,b,S=1/0){const P=x.range;if(!P)return 0;const H=Math.min(S,Math.max(m,b)),W=Math.log(H/1024)/Math.LN2;return i.smoothstep(P[0]+W,P[1]+W,a)}const fo=1/4e4;function Gh(x,a){const m=i.clamp(a.lat,-i.MAX_MERCATOR_LATITUDE,i.MAX_MERCATOR_LATITUDE),b=new i.LngLat(a.lng-180*fo,m),S=new i.LngLat(a.lng+180*fo,m),P=x.project(b.lng,m),H=x.project(S.lng,m),W=i.MercatorCoordinate.fromLngLat(b),ee=i.MercatorCoordinate.fromLngLat(S),pe=H.x-P.x,fe=H.y-P.y,Se=ee.x-W.x,Qe=ee.y-W.y,rt=Math.sqrt((Se*Se+Qe*Qe)/(pe*pe+fe*fe));return Math.log(rt)/Math.LN2}function jl(x,a,m){const b=Math.cos(m),S=Math.sin(m);return{x:x*b-a*S,y:x*S+a*b}}class Kl{constructor(a,m,b,S,P,H,W){this.tileSize=512,this._renderWorldCopies=P===void 0||P,this._minZoom=a||0,this._maxZoom=m||22,this._minPitch=b==null?0:b,this._maxPitch=S==null?60:S,this.setProjection(H),this.setMaxBounds(W),this.width=0,this.height=0,this._center=new i.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 Qh,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Hh,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 a=new Kl(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return a._elevation=this._elevation,a._centerAltitude=this._centerAltitude,a._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,a.tileSize=this.tileSize,a.mercatorFromTransition=this.mercatorFromTransition,a.width=this.width,a.height=this.height,a.cameraElevationReference=this.cameraElevationReference,a._center=this._center,a._setZoom(this.zoom),a._seaLevelZoom=this._seaLevelZoom,a.angle=this.angle,a._fov=this._fov,a._pitch=this._pitch,a._nearZ=this._nearZ,a._farZ=this._farZ,a._averageElevation=this._averageElevation,a._unmodified=this._unmodified,a._edgeInsets=this._edgeInsets.clone(),a._camera=this._camera.clone(),a._calcMatrices(),a.freezeTileCoverage=this.freezeTileCoverage,a.frustumCorners=this.frustumCorners,a}get elevation(){return this._elevation}set elevation(a){this._elevation!==a&&(this._elevation=a,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(a,m=!1){const b=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||b)&&this._updateCameraOnTerrain(),(a||b)&&this._constrainCamera(m),this._calcMatrices()}getProjection(){return i.pick(this.projection,["name","center","parallels"])}setProjection(a){this.projectionOptions=a||{name:"mercator"};const m=this.projection?this.getProjection():void 0;this.projection=i.getProjection(this.projectionOptions);const b=!C(m,this.getProjection());return b&&this._calcMatrices(),this.mercatorFromTransition=!1,b}setMercatorFromTransition(){const a=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=i.getProjection({name:"mercator"});const m=a!==this.projection.name;return m&&this._calcMatrices(),m}get minZoom(){return this._minZoom}set minZoom(a){this._minZoom!==a&&(this._minZoom=a,this.zoom=Math.max(this.zoom,a))}get maxZoom(){return this._maxZoom}set maxZoom(a){this._maxZoom!==a&&(this._maxZoom=a,this.zoom=Math.min(this.zoom,a))}get minPitch(){return this._minPitch}set minPitch(a){this._minPitch!==a&&(this._minPitch=a,this.pitch=Math.max(this.pitch,a))}get maxPitch(){return this._maxPitch}set maxPitch(a){this._maxPitch!==a&&(this._maxPitch=a,this.pitch=Math.min(this.pitch,a))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(a){a===void 0?a=!0:a===null&&(a=!1),this._renderWorldCopies=a}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const a=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(a))}get cameraWorldSize(){const a=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(a))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return i.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new i.pointGeometry(this.width,this.height)}get bearing(){return i.wrap(this.rotation,-180,180)}set bearing(a){this.rotation=a}get rotation(){return-this.angle/Math.PI*180}set rotation(a){const m=-a*Math.PI/180;var b;this.angle!==m&&(this._unmodified=!1,this.angle=m,this._calcMatrices(),this.rotationMatrix=(b=new i.ARRAY_TYPE(4),i.ARRAY_TYPE!=Float32Array&&(b[1]=0,b[2]=0),b[0]=1,b[3]=1,b),function(S,P,H){var W=P[0],ee=P[1],pe=P[2],fe=P[3],Se=Math.sin(H),Qe=Math.cos(H);S[0]=W*Qe+pe*Se,S[1]=ee*Qe+fe*Se,S[2]=W*-Se+pe*Qe,S[3]=ee*-Se+fe*Qe}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(a){const m=i.clamp(a,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==m&&(this._unmodified=!1,this._pitch=m,this._calcMatrices())}get aspect(){return this.width/this.height}get fovX(){return this._fov}get fovY(){const a=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/a)}set fov(a){a=Math.max(.01,Math.min(60,a)),this._fov!==a&&(this._unmodified=!1,this._fov=i.degToRad(a),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(a){this._averageElevation=a,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(a){const m=Math.min(Math.max(a,this.minZoom),this.maxZoom);this._zoom!==m&&(this._unmodified=!1,this._setZoom(m),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(a){this._zoom=a,this.scale=this.zoomScale(a),this.tileZoom=Math.floor(a),this.zoomFraction=a-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 a=this._elevation;this._centerAltitude=a.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=a.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 a=this._elevation,m=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],b=this.horizonLineFromTop();let S=0,P=0;for(let H=0;Ha.maxzoom&&(m=a.maxzoom);const H=this.locationCoordinate(this.center),W=this.center.lat,ee=1<{const $i=new i.MercatorCoordinate(Ai.x+25e-6,Ai.y,Ai.z),Jt=new i.MercatorCoordinate(Ai.x,Ai.y+25e-6,Ai.z),pi=Ai.toLngLat(),In=$i.toLngLat(),Hn=Jt.toLngLat(),Mn=this.locationCoordinate(pi),$n=this.locationCoordinate(In),ar=this.locationCoordinate(Hn),On=Math.hypot($n.x-Mn.x,$n.y-Mn.y),_n=Math.hypot(ar.x-Mn.x,ar.y-Mn.y);return Math.sqrt(On*_n)*Pt/25e-6},Ht=Ai=>{const Mi=ht,$i=Bt;return{aabb:i.tileAABB(this,ee,0,0,0,Ai,$i,Mi,this.projection),zoom:0,x:0,y:0,minZ:$i,maxZ:Mi,wrap:Ai,fullyVisible:!1}},hi=[];let si=[];const qt=m,ji=a.reparseOverscaled?b:m,Kt=Ai=>Ai*Ai,Bi=Kt((lt-this._centerAltitude)*nt),di=Ai=>{if(!this._elevation||!Ai.tileID||!P)return;const Mi=this._elevation.getMinMaxForTile(Ai.tileID),$i=Ai.aabb;Mi?($i.min[2]=Mi.min,$i.max[2]=Mi.max,$i.center[2]=($i.min[2]+$i.max[2])/2):(Ai.shouldSplit=Ri(Ai),Ai.shouldSplit||($i.min[2]=$i.max[2]=$i.center[2]=this._centerAltitude))},Ri=Ai=>{if(Ai.zoom=.9)return!0}else if(S&&(Jt=Kt(Ai.aabb.distanceZ(Xe)*nt)),this.projection.isReprojectedInTileSpace&&b<=5){const Mn=Math.pow(2,Ai.zoom),$n=It(new i.MercatorCoordinate((Ai.x+.5)/Mn,(Ai.y+.5)/Mn));pi=$n>.85?1:$n}const In=Mi*Mi+$i*$i+Jt,Hn=Kt((1<{if($n*Kt(.707)0;){const Ai=hi.pop(),Mi=Ai.x,$i=Ai.y;let Jt=Ai.fullyVisible;if(!Jt){const pi=Ai.aabb.intersects(Qe);if(pi===0)continue;Jt=pi===2}if(Ai.zoom!==qt&&Ri(Ai))for(let pi=0;pi<4;pi++){const In=(Mi<<1)+pi%2,Hn=($i<<1)+(pi>>1),Mn={aabb:P?Ai.aabb.quadrant(pi):i.tileAABB(this,ee,Ai.zoom+1,In,Hn,Ai.wrap,Ai.minZ,Ai.maxZ,this.projection),zoom:Ai.zoom+1,x:In,y:Hn,wrap:Ai.wrap,fullyVisible:Jt,tileID:void 0,shouldSplit:void 0,minZ:Ai.minZ,maxZ:Ai.maxZ};S&&!fe&&(Mn.tileID=new i.OverscaledTileID(Ai.zoom+1===qt?ji:Ai.zoom+1,Ai.wrap,Ai.zoom+1,In,Hn),di(Mn)),hi.push(Mn)}else{const pi=Ai.zoom===qt?ji:Ai.zoom;if(a.minzoom&&a.minzoom>pi)continue;const In=pe[0]-(.5+Mi+(Ai.wrap<{const Jt=[0,0,0,1],pi=[i.EXTENT,i.EXTENT,0,1],In=this.calculateFogTileMatrix($i.tileID.toUnwrapped());i.transformMat4$1(Jt,Jt,In),i.transformMat4$1(pi,pi,In);const Hn=i.getAABBPointSquareDist(Jt,pi);if(Hn===0)return!0;let Mn=!1;const $n=this._elevation;if($n&&Hn>Ai&&Mi!==0){const ar=this.calculateProjMatrix($i.tileID.toUnwrapped());let On;a.isTerrainDEM||(On=$n.getMinMaxForTile($i.tileID)),On||(On={min:Bt,max:ht});const _n=i.furthestTileCorner(this.rotation),Dr=[_n[0]*i.EXTENT,_n[1]*i.EXTENT,On.max];i.transformMat4(Dr,Dr,ar),Mn=(1-Dr[1])*this.height*.5Ai.distanceSq-Mi.distanceSq).map(Ai=>Ai.tileID)}resize(a,m){this.width=a,this.height=m,this.pixelsToGLUnits=[2/a,-2/m],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(a){return Math.pow(2,a)}scaleZoom(a){return Math.log(a)/Math.LN2}project(a){const m=i.clamp(a.lat,-i.MAX_MERCATOR_LATITUDE,i.MAX_MERCATOR_LATITUDE),b=this.projection.project(a.lng,m);return new i.pointGeometry(b.x*this.worldSize,b.y*this.worldSize)}unproject(a){return this.projection.unproject(a.x/this.worldSize,a.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(a,m){let b,S;const P=this.centerPoint;if(this.projection.name==="globe"){const W=this.worldSize;b=(m.x-P.x)/W,S=(m.y-P.y)/W}else{const W=this.pointCoordinate(m),ee=this.pointCoordinate(P);b=W.x-ee.x,S=W.y-ee.y}const H=this.locationCoordinate(a);this.setLocation(new i.MercatorCoordinate(H.x-b,H.y-S))}setLocation(a){this.center=this.coordinateLocation(a),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(a){return this.projection.locationPoint(this,a)}locationPoint3D(a){return this.projection.locationPoint(this,a,!0)}pointLocation(a){return this.coordinateLocation(this.pointCoordinate(a))}pointLocation3D(a){return this.coordinateLocation(this.pointCoordinate3D(a))}locationCoordinate(a,m){const b=m?i.mercatorZfromAltitude(m,a.lat):void 0,S=this.projection.project(a.lng,a.lat);return new i.MercatorCoordinate(S.x,S.y,b)}coordinateLocation(a){return this.projection.unproject(a.x,a.y)}pointRayIntersection(a,m){const b=m!=null?m:this._centerAltitude,S=[a.x,a.y,0,1],P=[a.x,a.y,1,1];i.transformMat4$1(S,S,this.pixelMatrixInverse),i.transformMat4$1(P,P,this.pixelMatrixInverse);const H=P[3];i.scale$1(S,S,1/S[3]),i.scale$1(P,P,1/H);const W=S[2],ee=P[2];return{p0:S,p1:P,t:W===ee?0:(b-W)/(ee-W)}}screenPointToMercatorRay(a){const m=[a.x,a.y,0,1],b=[a.x,a.y,1,1];return i.transformMat4$1(m,m,this.pixelMatrixInverse),i.transformMat4$1(b,b,this.pixelMatrixInverse),i.scale$1(m,m,1/m[3]),i.scale$1(b,b,1/b[3]),m[2]=i.mercatorZfromAltitude(m[2],this._center.lat)*this.worldSize,b[2]=i.mercatorZfromAltitude(b[2],this._center.lat)*this.worldSize,i.scale$1(m,m,1/this.worldSize),i.scale$1(b,b,1/this.worldSize),new i.Ray([m[0],m[1],m[2]],i.normalize([],i.sub([],b,m)))}rayIntersectionCoordinate(a){const{p0:m,p1:b,t:S}=a,P=i.mercatorZfromAltitude(m[2],this._center.lat),H=i.mercatorZfromAltitude(b[2],this._center.lat);return new i.MercatorCoordinate(i.number(m[0],b[0],S)/this.worldSize,i.number(m[1],b[1],S)/this.worldSize,i.number(P,H,S))}pointCoordinate(a,m=this._centerAltitude){return this.projection.pointCoordinate(this,a.x,a.y,m)}pointCoordinate3D(a){if(!this.elevation)return this.pointCoordinate(a);let m=this.projection.pointCoordinate3D(this,a.x,a.y);if(m)return new i.MercatorCoordinate(m[0],m[1],m[2]);let b=0,S=this.horizonLineFromTop();if(a.y>S)return this.pointCoordinate(a);const P=.02*S,H=a.clone();for(let W=0;W<10&&S-b>P;W++){H.y=i.number(b,S,.66);const ee=this.projection.pointCoordinate3D(this,H.x,H.y);ee?(S=H.y,m=ee):b=H.y}return m?new i.MercatorCoordinate(m[0],m[1],m[2]):this.pointCoordinate(a)}isPointAboveHorizon(a){return this.projection.isPointAboveHorizon(this,a)}_coordinatePoint(a,m){const b=m&&this.elevation?this.elevation.getAtPointOrZero(a,this._centerAltitude):this._centerAltitude,S=[a.x*this.worldSize,a.y*this.worldSize,b+a.toAltitude(),1];return i.transformMat4$1(S,S,this.pixelMatrix),S[3]>0?new i.pointGeometry(S[0]/S[3],S[1]/S[3]):new i.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getGlobeBounds(){const{top:a,left:m}=this._edgeInsets,b=this.height-this._edgeInsets.bottom,S=this.width-this._edgeInsets.right,P=this.pointCoordinate3D(new i.pointGeometry(m,a)),H=this.pointCoordinate3D(new i.pointGeometry(S,a)),W=this.pointCoordinate3D(new i.pointGeometry(S,b)),ee=this.pointCoordinate3D(new i.pointGeometry(m,b));let pe=Math.min(P.x,ee.x),fe=Math.max(H.x,W.x),Se=Math.min(P.y,H.y),Qe=Math.max(ee.y,W.y);const rt=Math.pow(2,-this.zoom)/16,nt=(It,Ht,hi,si)=>{const qt=(It+hi)/2,ji=(Ht+si)/2,Kt=new i.pointGeometry(qt,ji),Bi=this.pointCoordinate3D(Kt),di=Math.max(0,pe-Bi.x,Se-Bi.y,Bi.x-fe,Bi.y-Qe);pe=Math.min(pe,Bi.x),fe=Math.max(fe,Bi.x),Se=Math.min(Se,Bi.y),Qe=Math.max(Qe,Bi.y),di>rt&&(nt(It,Ht,qt,ji),nt(qt,ji,hi,si))};nt(m,a,S,a),nt(S,a,S,b),nt(S,b,m,b),nt(m,b,m,a);const[lt,Xe]=i.polesInViewport(this),Ye=lt||Xe,At=lt?90:i.latFromMercatorY(Se),ht=Ye?180:i.lngFromMercatorX(fe),Bt=Xe?-90:i.latFromMercatorY(Qe),Pt=Ye?-180:i.lngFromMercatorX(pe);return new i.LngLatBounds(new i.LngLat(Pt,Bt),new i.LngLat(ht,At))}_getBounds(a,m){if(this.projection.name==="globe")return this._getGlobeBounds();const b=new i.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),S=new i.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),P=new i.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),H=new i.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let W=this.pointCoordinate(b,a),ee=this.pointCoordinate(S,a);const pe=this.pointCoordinate(P,m),fe=this.pointCoordinate(H,m),Se=(Qe,rt)=>(rt.y-Qe.y)/(rt.x-Qe.x);return W.y>1&&ee.y>=0?W=new i.MercatorCoordinate((1-fe.y)/Se(fe,W)+fe.x,1):W.y<0&&ee.y<=1&&(W=new i.MercatorCoordinate(-fe.y/Se(fe,W)+fe.x,0)),ee.y>1&&W.y>=0?ee=new i.MercatorCoordinate((1-pe.y)/Se(pe,ee)+pe.x,1):ee.y<0&&W.y<=1&&(ee=new i.MercatorCoordinate(-pe.y/Se(pe,ee)+pe.x,0)),new i.LngLatBounds().extend(this.coordinateLocation(W)).extend(this.coordinateLocation(ee)).extend(this.coordinateLocation(fe)).extend(this.coordinateLocation(pe))}_getBounds3D(){const a=this.elevation;if(!a.visibleDemTiles.length||a.isUsingMockSource())return this._getBounds(0,0);const m=a.visibleDemTiles.reduce((b,S)=>{if(S.dem){const P=S.dem.tree;b.min=Math.min(b.min,P.minimums[0]),b.max=Math.max(b.max,P.maximums[0])}return b},{min:Number.MAX_VALUE,max:0});return this._getBounds(m.min*a.exaggeration(),m.max*a.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(a=!0){const m=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,b=this.height/2-m*(1-this._horizonShift);return a?Math.max(0,b):b}getMaxBounds(){return this.maxBounds}setMaxBounds(a){this.maxBounds=a,this.minLat=-i.MAX_MERCATOR_LATITUDE,this.maxLat=i.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,a&&(this.minLat=a.getSouth(),this.maxLat=a.getNorth(),this.minLng=a.getWest(),this.maxLng=a.getEast(),this.maxLngSe&&(W=Se-pe),Se-fert&&(H=rt-ee),rt-Qe.5?At-1:At,ht>.5?ht-1:ht,0]),this.alignedProjMatrix=Bt,H=i.create(),i.scale(H,H,[this.width/2,-this.height/2,1]),i.translate(H,H,[1,-1,0]),this.labelPlaneMatrix=H,H=i.create(),i.scale(H,H,[1,-1,1]),i.translate(H,H,[-1,-1,0]),i.scale(H,H,[2/this.width,2/this.height,1]),this.glCoordMatrix=H,this.pixelMatrix=i.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},H=i.invert(new Float64Array(16),this.pixelMatrix),!H)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=H,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.calculateGlobeMatrix(this);const Pt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.transformMat4(Pt,Pt,S),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=H;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const a=this.cameraWorldSizeForFog,m=this.cameraPixelsPerMeter,b=this._camera.position,S=1/this.height/this._pixelsPerMercatorPixel,P=[a,a,m];i.scale$2(P,P,S),i.scale$2(b,b,-1),i.multiply$2(b,b,P);const H=i.create();i.translate(H,H,b),i.scale(H,H,P),this.mercatorFogMatrix=H,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(a,m,S)}_computeCameraPosition(a){const m=(a=a||this.pixelsPerMeter)/this.pixelsPerMeter,b=this._camera.forward(),S=this.point,P=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*m-a/this.worldSize*this._centerAltitude;return[S.x/this.worldSize-b[0]*P,S.y/this.worldSize-b[1]*P,a/this.worldSize*this._centerAltitude-b[2]*P]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(a){const m=this._maxCameraBoundsDistance()*Math.cos(this._pitch),b=this._camera.position[2],S=a[2];let P=1;this.projection.wrap&&(this.center=this.center.wrap()),S>0&&(P=Math.min((m-b)/S,1)),this._camera.position=i.scaleAndAdd([],this._camera.position,a,P),this._updateStateFromCamera()}_updateStateFromCamera(){const a=this._camera.position,m=this._camera.forward(),{pitch:b,bearing:S}=this._camera.getPitchBearing(),P=i.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,H=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.degToRad(this._maxPitch)),W=Math.max((a[2]-P)/Math.cos(b),H),ee=this._zoomFromMercatorZ(W);i.scaleAndAdd(a,a,m,W),this._pitch=i.clamp(b,i.degToRad(this.minPitch),i.degToRad(this.maxPitch)),this.angle=i.wrap(S,-Math.PI,Math.PI),this._setZoom(i.clamp(ee,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.MercatorCoordinate(a[0],a[1],a[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(a){return Math.pow(2,a)*this.tileSize}_mercatorZfromZoom(a){return this.cameraToCenterDistance/this._worldSizeFromZoom(a)}_minimumHeightOverTerrain(){const a=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(a)}_zoomFromMercatorZ(a){return this.scaleZoom(this.cameraToCenterDistance/(a*this.tileSize))}zoomFromMercatorZAdjusted(a){const m=H=>{const W=this.getCameraToCenterDistance(this.projection,H);return this.scaleZoom(W/(a*this.tileSize))};let b,S=m(this.zoom),P=Math.abs(S-m(S));for(;b!==P;)S=m(S),b=P,P=Math.abs(S-m(S));return S}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(i.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(a,m){const b=Math.min(a.x,m.x),S=Math.max(a.x,m.x),P=Math.min(a.y,m.y),H=Math.max(a.y,m.y);if(Ppe||Qe.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.pointGeometry(0,0),new i.pointGeometry(this.width,this.height))}zoomDeltaToMovement(a,m){const b=i.length(i.sub([],this._camera.position,a)),S=this._zoomFromMercatorZ(b)+m;return b-this._mercatorZfromZoom(S)}getCameraPoint(){if(this.projection.name==="globe"){const a=function([m,b,S],P){const H=[m,b,S,1];i.transformMat4$1(H,H,P);const W=H[3]=Math.max(H[3],1e-6);return H[0]/=W,H[1]/=W,H[2]/=W,H}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.pointGeometry(a[0],a[1])}{const a=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.pointGeometry(0,a))}}getCameraToCenterDistance(a,m=this.zoom){const b=Is(a,m,this.width,this.height,1024),S=a.pixelSpaceConversion(this.center.lat,this.worldSize,b);return .5/Math.tan(.5*this._fov)*this.height*S}getWorldToCameraMatrix(){const a=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&i.multiply(a,a,this.globeMatrix),a}}function _l(x,a){let m=!1,b=null;const S=()=>{b=null,m&&(x(),b=setTimeout(S,a),m=!1)};return()=>(m=!0,b||S(),b)}class An{constructor(a){this._hashName=a&&encodeURIComponent(a),i.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=_l(this._updateHashUnthrottled.bind(this),300)}addTo(a){return this._map=a,i.window.addEventListener("hashchange",this._onHashChange,!1),a.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),i.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const a=this._map;if(!a)return"";const m=vs(a);if(this._hashName){const b=this._hashName;let S=!1;const P=i.window.location.hash.slice(1).split("&").map(H=>{const W=H.split("=")[0];return W===b?(S=!0,`${W}=${m}`):H}).filter(H=>H);return S||P.push(`${b}=${m}`),`#${P.join("&")}`}return`#${m}`}_getCurrentHash(){const a=i.window.location.hash.replace("#","");if(this._hashName){let m;return a.split("&").map(b=>b.split("=")).forEach(b=>{b[0]===this._hashName&&(m=b)}),(m&&m[1]||"").split("/")}return a.split("/")}_onHashChange(){const a=this._map;if(!a)return!1;const m=this._getCurrentHash();if(m.length>=3&&!m.some(b=>isNaN(b))){const b=a.dragRotate.isEnabled()&&a.touchZoomRotate.isEnabled()?+(m[3]||0):a.getBearing();return a.jumpTo({center:[+m[2],+m[1]],zoom:+m[0],bearing:b,pitch:+(m[4]||0)}),!0}return!1}_updateHashUnthrottled(){const a=i.window.location.href.replace(/(#.+)?$/,this.getHashString());i.window.history.replaceState(i.window.history.state,null,a)}}function vs(x,a){const m=x.getCenter(),b=Math.round(100*x.getZoom())/100,S=Math.ceil((b*Math.LN2+Math.log(512/360/.5))/Math.LN10),P=Math.pow(10,S),H=Math.round(m.lng*P)/P,W=Math.round(m.lat*P)/P,ee=x.getBearing(),pe=x.getPitch();let fe=a?`/${H}/${W}/${b}`:`${b}/${W}/${H}`;return(ee||pe)&&(fe+="/"+Math.round(10*ee)/10),pe&&(fe+=`/${Math.round(pe)}`),fe}const Zr={linearity:.3,easing:i.bezier(0,0,.3,1)},nh=i.extend({deceleration:2500,maxSpeed:1400},Zr),Wh=i.extend({deceleration:20,maxSpeed:1400},Zr),yc=i.extend({deceleration:1e3,maxSpeed:360},Zr),AA=i.extend({deceleration:1e3,maxSpeed:90},Zr);class jh{constructor(a){this._map=a,this.clear()}clear(){this._inertiaBuffer=[]}record(a){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.exported.now(),settings:a})}_drainInertiaBuffer(){const a=this._inertiaBuffer,m=i.exported.now();for(;a.length>0&&m-a[0].time>160;)a.shift()}_onMoveEnd(a){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const m={zoom:0,bearing:0,pitch:0,pan:new i.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:P}of this._inertiaBuffer)m.zoom+=P.zoomDelta||0,m.bearing+=P.bearingDelta||0,m.pitch+=P.pitchDelta||0,P.panDelta&&m.pan._add(P.panDelta),P.around&&(m.around=P.around),P.pinchAround&&(m.pinchAround=P.pinchAround);const b=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,S={};if(m.pan.mag()){const P=uo(m.pan.mag(),b,i.extend({},nh,a||{}));S.offset=m.pan.mult(P.amount/m.pan.mag()),S.center=this._map.transform.center,rh(S,P)}if(m.zoom){const P=uo(m.zoom,b,Wh);S.zoom=this._map.transform.zoom+P.amount,rh(S,P)}if(m.bearing){const P=uo(m.bearing,b,yc);S.bearing=this._map.transform.bearing+i.clamp(P.amount,-179,179),rh(S,P)}if(m.pitch){const P=uo(m.pitch,b,AA);S.pitch=this._map.transform.pitch+P.amount,rh(S,P)}if(S.zoom||S.bearing){const P=m.pinchAround===void 0?m.around:m.pinchAround;S.around=P?this._map.unproject(P):this._map.getCenter()}return this.clear(),S.noMoveStart=!0,S}}function rh(x,a){(!x.duration||x.durationm.unproject(ee)),W=P.reduce((ee,pe,fe,Se)=>ee.add(pe.div(Se.length)),new i.pointGeometry(0,0));super(a,{points:P,point:W,lngLats:H,lngLat:m.unproject(W),originalEvent:b}),this._defaultPrevented=!1}}class Vn extends i.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(a,m,b){super(a,{originalEvent:b}),this._defaultPrevented=!1}}class sh{constructor(a,m){this._map=a,this._clickTolerance=m.clickTolerance}reset(){this._mousedownPos=void 0}wheel(a){return this._firePreventable(new Vn(a.type,this._map,a))}mousedown(a,m){return this._mousedownPos=m,this._firePreventable(new Js(a.type,this._map,a))}mouseup(a){this._map.fire(new Js(a.type,this._map,a))}preclick(a){const m=i.extend({},a);m.type="preclick",this._map.fire(new Js(m.type,this._map,m))}click(a,m){this._mousedownPos&&this._mousedownPos.dist(m)>=this._clickTolerance||(this.preclick(a),this._map.fire(new Js(a.type,this._map,a)))}dblclick(a){return this._firePreventable(new Js(a.type,this._map,a))}mouseover(a){this._map.fire(new Js(a.type,this._map,a))}mouseout(a){this._map.fire(new Js(a.type,this._map,a))}touchstart(a){return this._firePreventable(new Fn(a.type,this._map,a))}touchmove(a){this._map.fire(new Fn(a.type,this._map,a))}touchend(a){this._map.fire(new Fn(a.type,this._map,a))}touchcancel(a){this._map.fire(new Fn(a.type,this._map,a))}_firePreventable(a){if(this._map.fire(a),a.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class dA{constructor(a){this._map=a}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(a){this._map.fire(new Js(a.type,this._map,a))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Js("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(a){this._delayContextMenu?this._contextMenuEvent=a:this._map.fire(new Js(a.type,this._map,a)),this._map.listens("contextmenu")&&a.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class yl{constructor(a,m){this._map=a,this._el=a.getCanvasContainer(),this._container=a.getContainer(),this._clickTolerance=m.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(a,m){this.isEnabled()&&a.shiftKey&&a.button===0&&(ae(),this._startPos=this._lastPos=m,this._active=!0)}mousemoveWindow(a,m){if(!this._active)return;const b=m,S=this._startPos,P=this._lastPos;if(!S||!P||P.equals(b)||!this._box&&b.dist(S){this._box&&(this._box.style.transform=`translate(${H}px,${ee}px)`,this._box.style.width=W-H+"px",this._box.style.height=pe-ee+"px")})}mouseupWindow(a,m){if(!this._active)return;const b=this._startPos,S=m;if(b&&a.button===0){if(this.reset(),we(),b.x!==S.x||b.y!==S.y)return this._map.fire(new i.Event("boxzoomend",{originalEvent:a})),{cameraAnimation:P=>P.fitScreenCoordinates(b,S,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",a)}}keydown(a){this._active&&a.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",a))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),le(),delete this._startPos,delete this._lastPos}_fireEvent(a,m){return this._map.fire(new i.Event(a,{originalEvent:m}))}}function Es(x,a){const m={};for(let b=0;bthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=a.timeStamp),b.length===this.numTouches&&(this.centroid=function(S){const P=new i.pointGeometry(0,0);for(const H of S)P._add(H);return P.div(S.length)}(m),this.touches=Es(b,m)))}touchmove(a,m,b){if(this.aborted||!this.centroid)return;const S=Es(b,m);for(const P in this.touches){const H=this.touches[P],W=S[P];(!W||W.dist(H)>30)&&(this.aborted=!0)}}touchend(a,m,b){if((!this.centroid||a.timeStamp-this.startTime>500)&&(this.aborted=!0),b.length===0){const S=!this.aborted&&this.centroid;if(this.reset(),S)return S}}}class Go{constructor(a){this.singleTap=new Wa(a),this.numTaps=a.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(a,m,b){this.singleTap.touchstart(a,m,b)}touchmove(a,m,b){this.singleTap.touchmove(a,m,b)}touchend(a,m,b){const S=this.singleTap.touchend(a,m,b);if(S){const P=a.timeStamp-this.lastTime<500,H=!this.lastTap||this.lastTap.dist(S)<30;if(P&&H||this.reset(),this.count++,this.lastTime=a.timeStamp,this.lastTap=S,this.count===this.numTaps)return this.reset(),S}}}class pA{constructor(){this._zoomIn=new Go({numTouches:1,numTaps:2}),this._zoomOut=new Go({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(a,m,b){this._zoomIn.touchstart(a,m,b),this._zoomOut.touchstart(a,m,b)}touchmove(a,m,b){this._zoomIn.touchmove(a,m,b),this._zoomOut.touchmove(a,m,b)}touchend(a,m,b){const S=this._zoomIn.touchend(a,m,b),P=this._zoomOut.touchend(a,m,b);return S?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:H=>H.easeTo({duration:300,zoom:H.getZoom()+1,around:H.unproject(S)},{originalEvent:a})}):P?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:H=>H.easeTo({duration:300,zoom:H.getZoom()-1,around:H.unproject(P)},{originalEvent:a})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const va={0:1,2:2};class us{constructor(a){this.reset(),this._clickTolerance=a.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(a,m){return!1}_move(a,m){return{}}mousedown(a,m){if(this._lastPoint)return;const b=it(a);this._correctButton(a,b)&&(this._lastPoint=m,this._eventButton=b)}mousemoveWindow(a,m){const b=this._lastPoint;if(b){if(a.preventDefault(),this._eventButton!=null&&function(S,P){const H=va[P];return S.buttons===void 0||(S.buttons&H)!==H}(a,this._eventButton))this.reset();else if(this._moved||!(m.dist(b)0&&(this._active=!0);const S=Es(b,m),P=new i.pointGeometry(0,0),H=new i.pointGeometry(0,0);let W=0;for(const pe in S){const fe=S[pe],Se=this._touches[pe];Se&&(P._add(fe),H._add(fe.sub(Se)),W++,S[pe]=fe)}if(this._touches=S,W{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class h{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(a){}_move(a,m,b){return{}}touchstart(a,m,b){this._firstTwoTouches||b.length<2||(this._firstTwoTouches=[b[0].identifier,b[1].identifier],this._start([m[0],m[1]]))}touchmove(a,m,b){const S=this._firstTwoTouches;if(!S)return;a.preventDefault();const[P,H]=S,W=_(b,m,P),ee=_(b,m,H);if(!W||!ee)return;const pe=this._aroundCenter?null:W.add(ee).div(2);return this._move([W,ee],pe,a)}touchend(a,m,b){if(!this._firstTwoTouches)return;const[S,P]=this._firstTwoTouches,H=_(b,m,S),W=_(b,m,P);H&&W||(this._active&&we(),this.reset())}touchcancel(){this.reset()}enable(a){this._enabled=!0,this._aroundCenter=!!a&&a.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function _(x,a,m){for(let b=0;bMath.abs(x.x)}class ue extends h{constructor(a){super(),this._map=a}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(a){this._lastPoints=a,oe(a[0].sub(a[1]))&&(this._valid=!1)}_move(a,m,b){const S=this._lastPoints;if(!S)return;const P=a[0].sub(S[0]),H=a[1].sub(S[1]);return this._map._cooperativeGestures&&!i.isFullscreen()&&b.touches.length<3||(this._valid=this.gestureBeginsVertically(P,H,b.timeStamp),!this._valid)?void 0:(this._lastPoints=a,this._active=!0,{pitchDelta:(P.y+H.y)/2*-.5})}gestureBeginsVertically(a,m,b){if(this._valid!==void 0)return this._valid;const S=a.mag()>=2,P=m.mag()>=2;if(!S&&!P)return;if(!S||!P)return this._firstMove==null&&(this._firstMove=b),b-this._firstMove<100&&void 0;const H=a.y>0==m.y>0;return oe(a)&&oe(m)&&H}}const ve={panStep:100,bearingStep:15,pitchStep:10};class Te{constructor(){const a=ve;this._panStep=a.panStep,this._bearingStep=a.bearingStep,this._pitchStep=a.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(a){if(a.altKey||a.ctrlKey||a.metaKey)return;let m=0,b=0,S=0,P=0,H=0;switch(a.keyCode){case 61:case 107:case 171:case 187:m=1;break;case 189:case 109:case 173:m=-1;break;case 37:a.shiftKey?b=-1:(a.preventDefault(),P=-1);break;case 39:a.shiftKey?b=1:(a.preventDefault(),P=1);break;case 38:a.shiftKey?S=1:(a.preventDefault(),H=-1);break;case 40:a.shiftKey?S=-1:(a.preventDefault(),H=1);break;default:return}return this._rotationDisabled&&(b=0,S=0),{cameraAnimation:W=>{const ee=W.getZoom();W.easeTo({duration:300,easeId:"keyboardHandler",easing:ke,zoom:m?Math.round(ee)+m*(a.shiftKey?2:1):ee,bearing:W.getBearing()+b*this._bearingStep,pitch:W.getPitch()+S*this._pitchStep,offset:[-P*this._panStep,-H*this._panStep],center:W.getCenter()},{originalEvent:a})}}}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 ke(x){return x*(2-x)}const We=4.000244140625;class bt{constructor(a,m){this._map=a,this._el=a.getCanvasContainer(),this._handler=m,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,i.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(a){this._defaultZoomRate=a}setWheelZoomRate(a){this._wheelZoomRate=a}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(a){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!a&&a.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(a){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(a.ctrlKey||a.metaKey||this.isZooming()||i.isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let m=a.deltaMode===i.window.WheelEvent.DOM_DELTA_LINE?40*a.deltaY:a.deltaY;const b=i.exported.now(),S=b-(this._lastWheelEventTime||0);this._lastWheelEventTime=b,m!==0&&m%We==0?this._type="wheel":m!==0&&Math.abs(m)<4?this._type="trackpad":S>400?(this._type=null,this._lastValue=m,this._timeout=setTimeout(this._onTimeout,40,a)):this._type||(this._type=Math.abs(S*m)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,m+=this._lastValue)),a.shiftKey&&m&&(m/=4),this._type&&(this._lastWheelEvent=a,this._delta-=m,this._active||this._start(a)),a.preventDefault()}_onTimeout(a){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)}_start(a){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 m=me(this._el,a);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:m,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 a=this._map.transform;this._type==="wheel"&&a.projection.wrap&&(a._center.lng>=180||a._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const m=()=>a._terrainEnabled()&&this._aroundCoord?a.computeZoomRelativeTo(this._aroundCoord):a.zoom;if(this._delta!==0){const ee=this._type==="wheel"&&Math.abs(this._delta)>We?this._wheelZoomRate:this._defaultZoomRate;let pe=2/(1+Math.exp(-Math.abs(this._delta*ee)));this._delta<0&&pe!==0&&(pe=1/pe);const fe=m(),Se=Math.pow(2,fe),Qe=typeof this._targetZoom=="number"?a.zoomScale(this._targetZoom):Se;this._targetZoom=Math.min(a.maxZoom,Math.max(a.minZoom,a.scaleZoom(Qe*pe))),this._type==="wheel"&&(this._startZoom=fe,this._easing=this._smoothOutEasing(200)),this._delta=0}const b=typeof this._targetZoom=="number"?this._targetZoom:m(),S=this._startZoom,P=this._easing;let H,W=!1;if(this._type==="wheel"&&S&&P){const ee=Math.min((i.exported.now()-this._lastWheelEventTime)/200,1),pe=P(ee);H=i.number(S,b,pe),ee<1?this._frameId||(this._frameId=!0):W=!0}else H=b,W=!0;return this._active=!0,W&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!W,zoomDelta:H-m(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(a){let m=i.ease;if(this._prevEase){const b=this._prevEase,S=(i.exported.now()-b.start)/b.duration,P=b.easing(S+.01)-b.easing(S),H=.27/Math.sqrt(P*P+1e-4)*.01,W=Math.sqrt(.0729-H*H);m=i.bezier(H,W,.25,1)}return this._prevEase={start:i.exported.now(),duration:a,easing:m},m}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=R("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(i.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 mt{constructor(a,m){this._clickZoom=a,this._tapZoom=m}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 gt{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(a,m){return a.preventDefault(),{cameraAnimation:b=>{b.easeTo({duration:300,zoom:b.getZoom()+(a.shiftKey?-1:1),around:b.unproject(m)},{originalEvent:a})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Vt{constructor(){this._tap=new Go({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(a,m,b){this._swipePoint||(this._tapTime&&a.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?b.length>0&&(this._swipePoint=m[0],this._swipeTouch=b[0].identifier):this._tap.touchstart(a,m,b))}touchmove(a,m,b){if(this._tapTime){if(this._swipePoint){if(b[0].identifier!==this._swipeTouch)return;const S=m[0],P=S.y-this._swipePoint.y;return this._swipePoint=S,a.preventDefault(),this._active=!0,{zoomDelta:P/128}}}else this._tap.touchmove(a,m,b)}touchend(a,m,b){this._tapTime?this._swipePoint&&b.length===0&&this.reset():this._tap.touchend(a,m,b)&&(this._tapTime=a.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zt{constructor(a,m,b){this._el=a,this._mousePan=m,this._touchPan=b}enable(a){this._inertiaOptions=a||{},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 ni{constructor(a,m,b){this._pitchWithRotate=a.pitchWithRotate,this._mouseRotate=m,this._mousePitch=b}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 St{constructor(a,m,b,S){this._el=a,this._touchZoom=m,this._touchRotate=b,this._tapDragZoom=S,this._rotationDisabled=!1,this._enabled=!0}enable(a){this._touchZoom.enable(a),this._rotationDisabled||this._touchRotate.enable(a),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 zt=x=>x.zoom||x.drag||x.pitch||x.rotate;class li extends i.Event{}class Ei{constructor(){this.constants=[1,1,.01],this.radius=0}setup(a,m){const b=i.sub([],m,a);this.radius=i.length(b[2]<0?i.div([],b,this.constants):[b[0],b[1],0])}projectRay(a){i.div(a,a,this.constants),i.normalize(a,a),i.mul$1(a,a,this.constants);const m=i.scale$2([],a,this.radius);if(m[2]>0){const b=i.scale$2([],[0,0,1],i.dot(m,[0,0,1])),S=i.scale$2([],i.normalize([],[m[0],m[1],0]),this.radius),P=i.add([],m,i.scale$2([],i.sub([],i.add([],S,b),m),2));m[0]=P[0],m[1]=P[1]}return m}}function bi(x){return x.panDelta&&x.panDelta.mag()||x.zoomDelta||x.bearingDelta||x.pitchDelta}class Hi{constructor(a,m){this._map=a,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new jh(a),this._bearingSnap=m.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Ei,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(m),i.bindAll(["handleEvent","handleWindowEvent"],this);const b=this._el;this._listeners=[[b,"touchstart",{passive:!0}],[b,"touchmove",{passive:!1}],[b,"touchend",void 0],[b,"touchcancel",void 0],[b,"mousedown",void 0],[b,"mousemove",void 0],[b,"mouseup",void 0],[i.window.document,"mousemove",{capture:!0}],[i.window.document,"mouseup",void 0],[b,"mouseover",void 0],[b,"mouseout",void 0],[b,"dblclick",void 0],[b,"click",void 0],[b,"keydown",{capture:!1}],[b,"keyup",void 0],[b,"wheel",{passive:!1}],[b,"contextmenu",void 0],[i.window,"blur",void 0]];for(const[S,P,H]of this._listeners)S.addEventListener(P,S===i.window.document?this.handleWindowEvent:this.handleEvent,H)}destroy(){for(const[a,m,b]of this._listeners)a.removeEventListener(m,a===i.window.document?this.handleWindowEvent:this.handleEvent,b)}_addDefaultHandlers(a){const m=this._map,b=m.getCanvasContainer();this._add("mapEvent",new sh(m,a));const S=m.boxZoom=new yl(m,a);this._add("boxZoom",S);const P=new pA,H=new gt;m.doubleClickZoom=new mt(H,P),this._add("tapZoom",P),this._add("clickZoom",H);const W=new Vt;this._add("tapDragZoom",W);const ee=m.touchPitch=new ue(m);this._add("touchPitch",ee);const pe=new Kh(a),fe=new xl(a);m.dragRotate=new ni(a,pe,fe),this._add("mouseRotate",pe,["mousePitch"]),this._add("mousePitch",fe,["mouseRotate"]);const Se=new Fs(a),Qe=new M(m,a);m.dragPan=new Zt(b,Se,Qe),this._add("mousePan",Se),this._add("touchPan",Qe,["touchZoom","touchRotate"]);const rt=new K,nt=new F;m.touchZoomRotate=new St(b,nt,rt,W),this._add("touchRotate",rt,["touchPan","touchZoom"]),this._add("touchZoom",nt,["touchPan","touchRotate"]),this._add("blockableMapEvent",new dA(m));const lt=m.scrollZoom=new bt(m,this);this._add("scrollZoom",lt,["mousePan"]);const Xe=m.keyboard=new Te;this._add("keyboard",Xe);for(const Ye of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])a.interactive&&a[Ye]&&m[Ye].enable(a[Ye])}_add(a,m,b){this._handlers.push({handlerName:a,handler:m,allowed:b}),this._handlersById[a]=m}stop(a){if(!this._updatingCamera){for(const{handler:m}of this._handlers)m.reset();this._inertia.clear(),this._fireEvents({},{},a),this._changes=[]}}isActive(){for(const{handler:a}of this._handlers)if(a.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!zt(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(a,m,b){for(const S in a)if(S!==b&&(!m||m.indexOf(S)<0))return!0;return!1}handleWindowEvent(a){this.handleEvent(a,`${a.type}Window`)}_getMapTouches(a){const m=[];for(const b of a)this._el.contains(b.target)&&m.push(b);return m}handleEvent(a,m){this._updatingCamera=!0;const b=a.type==="renderFrame",S=b?void 0:a,P={needsRenderFrame:!1},H={},W={},ee=a.touches?this._getMapTouches(a.touches):void 0,pe=ee?Pe(this._el,ee):b?void 0:me(this._el,a);for(const{handlerName:Qe,handler:rt,allowed:nt}of this._handlers){if(!rt.isEnabled())continue;let lt;this._blockedByActive(W,nt,Qe)?rt.reset():rt[m||a.type]&&(lt=rt[m||a.type](a,pe,ee),this.mergeHandlerResult(P,H,lt,Qe,S),lt&<.needsRenderFrame&&this._triggerRenderFrame()),(lt||rt.isActive())&&(W[Qe]=rt)}const fe={};for(const Qe in this._previousActiveHandlers)W[Qe]||(fe[Qe]=S);this._previousActiveHandlers=W,(Object.keys(fe).length||bi(P))&&(this._changes.push([P,H,fe]),this._triggerRenderFrame()),(Object.keys(W).length||bi(P))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:Se}=P;Se&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Se(this._map))}mergeHandlerResult(a,m,b,S,P){if(!b)return;i.extend(a,b);const H={handlerName:S,originalEvent:b.originalEvent||P};b.zoomDelta!==void 0&&(m.zoom=H),b.panDelta!==void 0&&(m.drag=H),b.pitchDelta!==void 0&&(m.pitch=H),b.bearingDelta!==void 0&&(m.rotate=H)}_applyChanges(){const a={},m={},b={};for(const[S,P,H]of this._changes)S.panDelta&&(a.panDelta=(a.panDelta||new i.pointGeometry(0,0))._add(S.panDelta)),S.zoomDelta&&(a.zoomDelta=(a.zoomDelta||0)+S.zoomDelta),S.bearingDelta&&(a.bearingDelta=(a.bearingDelta||0)+S.bearingDelta),S.pitchDelta&&(a.pitchDelta=(a.pitchDelta||0)+S.pitchDelta),S.around!==void 0&&(a.around=S.around),S.aroundCoord!==void 0&&(a.aroundCoord=S.aroundCoord),S.pinchAround!==void 0&&(a.pinchAround=S.pinchAround),S.noInertia&&(a.noInertia=S.noInertia),i.extend(m,P),i.extend(b,H);this._updateMapTransform(a,m,b),this._changes=[]}_updateMapTransform(a,m,b){const S=this._map,P=S.transform,H=At=>[At.x,At.y,At.z];if((At=>{const ht=this._eventsInProgress.drag;return ht&&!this._handlersById[ht.handlerName].isActive()})()&&!bi(a)){const At=P.zoom;P.cameraElevationReference="sea",P.recenterOnTerrain(),P.cameraElevationReference="ground",At!==P.zoom&&this._map._update(!0)}if(P._isCameraConstrained&&S._stop(!0),!bi(a))return void this._fireEvents(m,b,!0);let{panDelta:W,zoomDelta:ee,bearingDelta:pe,pitchDelta:fe,around:Se,aroundCoord:Qe,pinchAround:rt}=a;P._isCameraConstrained&&(ee>0&&(ee=0),P._isCameraConstrained=!1),rt!==void 0&&(Se=rt),(At=>m.drag&&!this._eventsInProgress.drag)()&&Se&&(this._dragOrigin=H(P.pointCoordinate3D(Se)),this._trackingEllipsoid.setup(P._camera.position,this._dragOrigin)),P.cameraElevationReference="sea",S._stop(!0),Se=Se||S.transform.centerPoint,pe&&(P.bearing+=pe),fe&&(P.pitch+=fe),P._updateCameraState();const nt=[0,0,0];if(W)if(P.projection.name==="mercator"){const At=this._trackingEllipsoid.projectRay(P.screenPointToMercatorRay(Se).dir),ht=this._trackingEllipsoid.projectRay(P.screenPointToMercatorRay(Se.sub(W)).dir);nt[0]=ht[0]-At[0],nt[1]=ht[1]-At[1]}else{const At=P.pointCoordinate(Se);if(P.projection.name==="globe"){W=W.rotate(-P.angle);const ht=P._pixelsPerMercatorPixel/P.worldSize;nt[0]=-W.x*i.mercatorScale(i.latFromMercatorY(At.y))*ht,nt[1]=-W.y*i.mercatorScale(P.center.lat)*ht}else{const ht=P.pointCoordinate(Se.sub(W));At&&ht&&(nt[0]=ht.x-At.x,nt[1]=ht.y-At.y)}}const lt=P.zoom,Xe=[0,0,0];if(ee){const At=H(Qe||P.pointCoordinate3D(Se)),ht={dir:i.normalize([],i.sub([],At,P._camera.position))};if(ht.dir[2]<0){const Bt=P.zoomDeltaToMovement(At,ee);i.scale$2(Xe,ht.dir,Bt)}}const Ye=i.add(nt,nt,Xe);P._translateCameraConstrained(Ye),ee&&Math.abs(P.zoom-lt)>1e-4&&P.recenterOnTerrain(),P.cameraElevationReference="ground",this._map._update(),a.noInertia||this._inertia.record(a),this._fireEvents(m,b,!0)}_fireEvents(a,m,b){const S=zt(this._eventsInProgress),P=zt(a),H={};for(const fe in a){const{originalEvent:Se}=a[fe];this._eventsInProgress[fe]||(H[`${fe}start`]=Se),this._eventsInProgress[fe]=a[fe]}!S&&P&&this._fireEvent("movestart",P.originalEvent);for(const fe in H)this._fireEvent(fe,H[fe]);P&&this._fireEvent("move",P.originalEvent);for(const fe in a){const{originalEvent:Se}=a[fe];this._fireEvent(fe,Se)}const W={};let ee;for(const fe in this._eventsInProgress){const{handlerName:Se,originalEvent:Qe}=this._eventsInProgress[fe];this._handlersById[Se].isActive()||(delete this._eventsInProgress[fe],ee=m[Se]||Qe,W[`${fe}end`]=ee)}for(const fe in W)this._fireEvent(fe,W[fe]);const pe=zt(this._eventsInProgress);if(b&&(S||P)&&!pe){this._updatingCamera=!0;const fe=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),Se=Qe=>Qe!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new li("renderFrame",{timeStamp:a})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const xi="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class xn extends i.Evented{constructor(a,m){super(),this._moving=!1,this._zooming=!1,this.transform=a,this._bearingSnap=m.bearingSnap,i.bindAll(["_renderFrameCallback"],this)}getCenter(){return new i.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(a,m){return this.jumpTo({center:a},m)}panBy(a,m,b){return a=i.pointGeometry.convert(a).mult(-1),this.panTo(this.transform.center,i.extend({offset:a},m),b)}panTo(a,m,b){return this.easeTo(i.extend({center:a},m),b)}getZoom(){return this.transform.zoom}setZoom(a,m){return this.jumpTo({zoom:a},m),this}zoomTo(a,m,b){return this.easeTo(i.extend({zoom:a},m),b)}zoomIn(a,m){return this.zoomTo(this.getZoom()+1,a,m),this}zoomOut(a,m){return this.zoomTo(this.getZoom()-1,a,m),this}getBearing(){return this.transform.bearing}setBearing(a,m){return this.jumpTo({bearing:a},m),this}getPadding(){return this.transform.padding}setPadding(a,m){return this.jumpTo({padding:a},m),this}rotateTo(a,m,b){return this.easeTo(i.extend({bearing:a},m),b)}resetNorth(a,m){return this.rotateTo(0,i.extend({duration:1e3},a),m),this}resetNorthPitch(a,m){return this.easeTo(i.extend({bearing:0,pitch:0,duration:1e3},a),m),this}snapToNorth(a,m){return Math.abs(this.getBearing())a.aspect?b/(2*Math.tan(.5*a.fovX)*a.aspect):S/(2*Math.tan(.5*a.fovY)*a.aspect)}_cameraForBoundsOnGlobe(a,m,b,S,P,H){const W=a.clone(),ee=this._extendCameraOptions(H);W.bearing=S,W.pitch=P;const pe=i.LngLat.convert(m),fe=i.LngLat.convert(b),Se=.5*(pe.lat+fe.lat),Qe=.5*(pe.lng+fe.lng),rt=i.latLngToECEF(Se,Qe),nt=i.normalize([],rt),lt=i.normalize([],i.cross([],nt,[0,1,0])),Xe=i.cross([],lt,nt),Ye=[lt[0],lt[1],lt[2],0,Xe[0],Xe[1],Xe[2],0,nt[0],nt[1],nt[2],0,0,0,0,1],At=[rt,i.latLngToECEF(pe.lat,pe.lng),i.latLngToECEF(fe.lat,pe.lng),i.latLngToECEF(fe.lat,fe.lng),i.latLngToECEF(pe.lat,fe.lng),i.latLngToECEF(Se,pe.lng),i.latLngToECEF(Se,fe.lng),i.latLngToECEF(pe.lat,Qe),i.latLngToECEF(fe.lat,Qe)];let ht=i.Aabb.fromPoints(At.map(Jt=>[i.dot(lt,Jt),i.dot(Xe,Jt),i.dot(nt,Jt)]));const Bt=i.transformMat4([],ht.center,Ye);i.squaredLength(Bt)===0&&i.set(Bt,0,0,1),i.normalize(Bt,Bt),i.scale$2(Bt,Bt,i.GLOBE_RADIUS),W.center=i.ecefToLatLng(Bt);const Pt=W.getWorldToCameraMatrix(),It=i.invert(new Float64Array(16),Pt);ht=i.Aabb.applyTransform(ht,i.multiply([],Pt,Ye)),i.transformMat4(Bt,Bt,Pt);const Ht=.5*(ht.max[2]-ht.min[2]),hi=this._minimumAABBFrustumDistance(W,ht),si=i.scale$2([],[0,0,1],Ht),qt=i.add(si,Bt,si),ji=hi+(W.pitch===0?0:i.distance(Bt,qt)),Kt=W.globeCenterInViewSpace,Bi=i.sub([],Bt,[Kt[0],Kt[1],Kt[2]]);i.normalize(Bi,Bi),i.scale$2(Bi,Bi,ji);const di=i.add([],Bt,Bi);i.transformMat4(di,di,It);const Ri=i.earthRadius/i.GLOBE_RADIUS,Ai=i.length(di),Mi=i.mercatorZfromAltitude(Ai*Ri-i.earthRadius,0),$i=Math.min(W.zoomFromMercatorZAdjusted(Mi),ee.maxZoom);return $i>.5*(i.GLOBE_ZOOM_THRESHOLD_MIN+i.GLOBE_ZOOM_THRESHOLD_MAX)?(W.setProjection({name:"mercator"}),W.zoom=$i,this._cameraForBounds(W,m,b,S,P,H)):{center:W.center,zoom:$i,bearing:S,pitch:P}}queryTerrainElevation(a,m){const b=this.transform.elevation;return b?(m=i.extend({},{exaggerated:!0},m),b.getAtPoint(i.MercatorCoordinate.fromLngLat(a),null,m.exaggerated)):null}_cameraForBounds(a,m,b,S,P,H){if(a.projection.name==="globe")return this._cameraForBoundsOnGlobe(a,m,b,S,P,H);const W=a.clone(),ee=this._extendCameraOptions(H),pe=W.padding;W.bearing=S,W.pitch=P;const fe=i.LngLat.convert(m),Se=i.LngLat.convert(b),Qe=new i.LngLat(fe.lng,Se.lat),rt=new i.LngLat(Se.lng,fe.lat),nt=W.project(fe),lt=W.project(Se),Xe=this.queryTerrainElevation(fe),Ye=this.queryTerrainElevation(Se),At=this.queryTerrainElevation(Qe),ht=this.queryTerrainElevation(rt),Bt=[[nt.x,nt.y,Math.min(Xe||0,Ye||0,At||0,ht||0)],[lt.x,lt.y,Math.max(Xe||0,Ye||0,At||0,ht||0)]];let Pt=i.Aabb.fromPoints(Bt);const It=W.getWorldToCameraMatrix(),Ht=i.invert(new Float64Array(16),It);Pt=i.Aabb.applyTransform(Pt,It);const hi=i.sub([],Pt.max,Pt.min),si=pe.left||0,qt=pe.right||0,ji=pe.bottom||0,Kt=pe.top||0,{left:Bi,right:di,top:Ri,bottom:Ai}=ee.padding,Mi=.5*(si+qt),$i=.5*(Kt+ji),Jt=Math.min(W.scaleZoom(W.scale*Math.min((W.width-(si+qt+Bi+di))/hi[0],(W.height-(ji+Kt+Ai+Ri))/hi[1])),ee.maxZoom),pi=W.scale/W.zoomScale(Jt);Pt=new i.Aabb([Pt.min[0]-(Bi+Mi)*pi,Pt.min[1]-(Ai+$i)*pi,Pt.min[2]],[Pt.max[0]+(di+Mi)*pi,Pt.max[1]+(Ri+$i)*pi,Pt.max[2]]);const In=.5*hi[2],Hn=this._minimumAABBFrustumDistance(W,Pt),Mn=[0,0,1,0];i.transformMat4$1(Mn,Mn,It),i.normalize$2(Mn,Mn);const $n=i.scale$2([],Mn,Hn+In),ar=i.add([],Pt.center,$n),On=(typeof ee.offset.x=="number"&&typeof ee.offset.y=="number"?new i.pointGeometry(ee.offset.x,ee.offset.y):i.pointGeometry.convert(ee.offset)).rotate(-i.degToRad(S));Pt.center[0]-=On.x*pi,Pt.center[1]+=On.y*pi,i.transformMat4(Pt.center,Pt.center,Ht),i.transformMat4(ar,ar,Ht);const _n=[Pt.center[0],Pt.center[1],ar[2]*W.pixelsPerMeter];i.scale$2(_n,_n,1/W.worldSize);const Dr=i.lngFromMercatorX(_n[0]),Or=i.latFromMercatorY(_n[1]),Nr=Math.min(W._zoomFromMercatorZ(_n[2]),ee.maxZoom),Qr=new i.LngLat(Dr,Or);return W.mercatorFromTransition&&Nr<.5*(i.GLOBE_ZOOM_THRESHOLD_MIN+i.GLOBE_ZOOM_THRESHOLD_MAX)?(W.setProjection({name:"globe"}),W.zoom=Nr,this._cameraForBounds(W,m,b,S,P,H)):{center:Qr,zoom:Nr,bearing:S,pitch:P}}fitBounds(a,m,b){const S=this.cameraForBounds(a,m);return this._fitInternal(S,m,b)}fitScreenCoordinates(a,m,b,S,P){const H=i.pointGeometry.convert(a),W=i.pointGeometry.convert(m),ee=new i.pointGeometry(Math.min(H.x,W.x),Math.min(H.y,W.y)),pe=new i.pointGeometry(Math.max(H.x,W.x),Math.max(H.y,W.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(H,W))return this;const fe=this.transform.pointLocation3D(ee),Se=this.transform.pointLocation3D(pe),Qe=this.transform.pointLocation3D(new i.pointGeometry(ee.x,pe.y)),rt=this.transform.pointLocation3D(new i.pointGeometry(pe.x,ee.y)),nt=[Math.min(fe.lng,Se.lng,Qe.lng,rt.lng),Math.min(fe.lat,Se.lat,Qe.lat,rt.lat)],lt=[Math.max(fe.lng,Se.lng,Qe.lng,rt.lng),Math.max(fe.lat,Se.lat,Qe.lat,rt.lat)],Xe=S&&S.pitch?S.pitch:this.getPitch(),Ye=this._cameraForBounds(this.transform,nt,lt,b,Xe,S);return this._fitInternal(Ye,S,P)}_fitInternal(a,m,b){return a?(delete(m=i.extend(a,m)).padding,m.linear?this.easeTo(m,b):this.flyTo(m,b)):this}jumpTo(a,m){this.stop();const b=a.preloadOnly?this.transform.clone():this.transform;let S=!1,P=!1,H=!1;return"zoom"in a&&b.zoom!==+a.zoom&&(S=!0,b.zoom=+a.zoom),a.center!==void 0&&(b.center=i.LngLat.convert(a.center)),"bearing"in a&&b.bearing!==+a.bearing&&(P=!0,b.bearing=+a.bearing),"pitch"in a&&b.pitch!==+a.pitch&&(H=!0,b.pitch=+a.pitch),a.padding==null||b.isPaddingEqual(a.padding)||(b.padding=a.padding),a.preloadOnly?(this._preloadTiles(b),this):(this.fire(new i.Event("movestart",m)).fire(new i.Event("move",m)),S&&this.fire(new i.Event("zoomstart",m)).fire(new i.Event("zoom",m)).fire(new i.Event("zoomend",m)),P&&this.fire(new i.Event("rotatestart",m)).fire(new i.Event("rotate",m)).fire(new i.Event("rotateend",m)),H&&this.fire(new i.Event("pitchstart",m)).fire(new i.Event("pitch",m)).fire(new i.Event("pitchend",m)),this.fire(new i.Event("moveend",m)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.warnOnce(xi),this.transform.getFreeCameraOptions()}setFreeCameraOptions(a,m){const b=this.transform;if(!b.projection.supportsFreeCamera)return i.warnOnce(xi),this;this.stop();const S=b.zoom,P=b.pitch,H=b.bearing;b.setFreeCameraOptions(a);const W=S!==b.zoom,ee=P!==b.pitch,pe=H!==b.bearing;return this.fire(new i.Event("movestart",m)).fire(new i.Event("move",m)),W&&this.fire(new i.Event("zoomstart",m)).fire(new i.Event("zoom",m)).fire(new i.Event("zoomend",m)),pe&&this.fire(new i.Event("rotatestart",m)).fire(new i.Event("rotate",m)).fire(new i.Event("rotateend",m)),ee&&this.fire(new i.Event("pitchstart",m)).fire(new i.Event("pitch",m)).fire(new i.Event("pitchend",m)),this.fire(new i.Event("moveend",m)),this}easeTo(a,m){this._stop(!1,a.easeId),((a=i.extend({offset:[0,0],duration:500,easing:i.ease},a)).animate===!1||!a.essential&&i.exported.prefersReducedMotion)&&(a.duration=0);const b=this.transform,S=this.getZoom(),P=this.getBearing(),H=this.getPitch(),W=this.getPadding(),ee="zoom"in a?+a.zoom:S,pe="bearing"in a?this._normalizeBearing(a.bearing,P):P,fe="pitch"in a?+a.pitch:H,Se="padding"in a?a.padding:b.padding,Qe=i.pointGeometry.convert(a.offset);let rt,nt,lt;if(b.projection.name==="globe"){const si=i.MercatorCoordinate.fromLngLat(b.center),qt=Qe.rotate(-b.angle);si.x+=qt.x/b.worldSize,si.y+=qt.y/b.worldSize;const ji=si.toLngLat(),Kt=i.LngLat.convert(a.center||ji);this._normalizeCenter(Kt),rt=b.centerPoint.add(qt),nt=new i.pointGeometry(si.x,si.y).mult(b.worldSize),lt=new i.pointGeometry(i.mercatorXfromLng(Kt.lng),i.mercatorYfromLat(Kt.lat)).mult(b.worldSize).sub(nt)}else{rt=b.centerPoint.add(Qe);const si=b.pointLocation(rt),qt=i.LngLat.convert(a.center||si);this._normalizeCenter(qt),nt=b.project(si),lt=b.project(qt).sub(nt)}const Xe=b.zoomScale(ee-S);let Ye,At;a.around&&(Ye=i.LngLat.convert(a.around),At=b.locationPoint(Ye));const ht=this._zooming||ee!==S,Bt=this._rotating||P!==pe,Pt=this._pitching||fe!==H,It=!b.isPaddingEqual(Se),Ht=si=>qt=>{if(ht&&(si.zoom=i.number(S,ee,qt)),Bt&&(si.bearing=i.number(P,pe,qt)),Pt&&(si.pitch=i.number(H,fe,qt)),It&&(si.interpolatePadding(W,Se,qt),rt=si.centerPoint.add(Qe)),Ye)si.setLocationAtPoint(Ye,At);else{const ji=si.zoomScale(si.zoom-S),Kt=ee>S?Math.min(2,Xe):Math.max(.5,Xe),Bi=Math.pow(Kt,1-qt),di=si.unproject(nt.add(lt.mult(qt*Bi)).mult(ji));si.setLocationAtPoint(si.renderWorldCopies?di.wrap():di,rt)}return a.preloadOnly||this._fireMoveEvents(m),si};if(a.preloadOnly){const si=this._emulate(Ht,a.duration,b);return this._preloadTiles(si),this}const hi={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ht,this._rotating=Bt,this._pitching=Pt,this._padding=It,this._easeId=a.easeId,this._prepareEase(m,a.noMoveStart,hi),this._ease(Ht(b),si=>{b.recenterOnTerrain(),this._afterEase(m,si)},a),this}_prepareEase(a,m,b={}){this._moving=!0,this.transform.cameraElevationReference="sea",m||b.moving||this.fire(new i.Event("movestart",a)),this._zooming&&!b.zooming&&this.fire(new i.Event("zoomstart",a)),this._rotating&&!b.rotating&&this.fire(new i.Event("rotatestart",a)),this._pitching&&!b.pitching&&this.fire(new i.Event("pitchstart",a))}_fireMoveEvents(a){this.fire(new i.Event("move",a)),this._zooming&&this.fire(new i.Event("zoom",a)),this._rotating&&this.fire(new i.Event("rotate",a)),this._pitching&&this.fire(new i.Event("pitch",a))}_afterEase(a,m){if(this._easeId&&m&&this._easeId===m)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const b=this._zooming,S=this._rotating,P=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,b&&this.fire(new i.Event("zoomend",a)),S&&this.fire(new i.Event("rotateend",a)),P&&this.fire(new i.Event("pitchend",a)),this.fire(new i.Event("moveend",a))}flyTo(a,m){if(!a.essential&&i.exported.prefersReducedMotion){const Jt=i.pick(a,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Jt,m)}this.stop(),a=i.extend({offset:[0,0],speed:1.2,curve:1.42,easing:i.ease},a);const b=this.transform,S=this.getZoom(),P=this.getBearing(),H=this.getPitch(),W=this.getPadding(),ee="zoom"in a?i.clamp(+a.zoom,b.minZoom,b.maxZoom):S,pe="bearing"in a?this._normalizeBearing(a.bearing,P):P,fe="pitch"in a?+a.pitch:H,Se="padding"in a?a.padding:b.padding,Qe=b.zoomScale(ee-S),rt=i.pointGeometry.convert(a.offset);let nt=b.centerPoint.add(rt);const lt=b.pointLocation(nt),Xe=i.LngLat.convert(a.center||lt);this._normalizeCenter(Xe);const Ye=b.project(lt),At=b.project(Xe).sub(Ye);let ht=a.curve;const Bt=Math.max(b.width,b.height),Pt=Bt/Qe,It=At.mag();if("minZoom"in a){const Jt=i.clamp(Math.min(a.minZoom,S,ee),b.minZoom,b.maxZoom),pi=Bt/b.zoomScale(Jt-S);ht=Math.sqrt(pi/It*2)}const Ht=ht*ht;function hi(Jt){const pi=(Pt*Pt-Bt*Bt+(Jt?-1:1)*Ht*Ht*It*It)/(2*(Jt?Pt:Bt)*Ht*It);return Math.log(Math.sqrt(pi*pi+1)-pi)}function si(Jt){return(Math.exp(Jt)-Math.exp(-Jt))/2}function qt(Jt){return(Math.exp(Jt)+Math.exp(-Jt))/2}const ji=hi(0);let Kt=function(Jt){return qt(ji)/qt(ji+ht*Jt)},Bi=function(Jt){return Bt*((qt(ji)*(si(pi=ji+ht*Jt)/qt(pi))-si(ji))/Ht)/It;var pi},di=(hi(1)-ji)/ht;if(Math.abs(It)<1e-6||!isFinite(di)){if(Math.abs(Bt-Pt)<1e-6)return this.easeTo(a,m);const Jt=Pta.maxDuration&&(a.duration=0);const Ri=P!==pe,Ai=fe!==H,Mi=!b.isPaddingEqual(Se),$i=Jt=>pi=>{const In=pi*di,Hn=1/Kt(In);Jt.zoom=pi===1?ee:S+Jt.scaleZoom(Hn),Ri&&(Jt.bearing=i.number(P,pe,pi)),Ai&&(Jt.pitch=i.number(H,fe,pi)),Mi&&(Jt.interpolatePadding(W,Se,pi),nt=Jt.centerPoint.add(rt));const Mn=pi===1?Xe:Jt.unproject(Ye.add(At.mult(Bi(In))).mult(Hn));return Jt.setLocationAtPoint(Jt.renderWorldCopies?Mn.wrap():Mn,nt),Jt._updateCameraOnTerrain(),a.preloadOnly||this._fireMoveEvents(m),Jt};if(a.preloadOnly){const Jt=this._emulate($i,a.duration,b);return this._preloadTiles(Jt),this}return this._zooming=!0,this._rotating=Ri,this._pitching=Ai,this._padding=Mi,this._prepareEase(m,!1),this._ease($i(b),()=>this._afterEase(m),a),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(a,m){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const b=this._onEaseEnd;this._onEaseEnd=void 0,b.call(this,m)}if(!a){const b=this.handlers;b&&b.stop(!1)}return this}_ease(a,m,b){b.animate===!1||b.duration===0?(a(1),m()):(this._easeStart=i.exported.now(),this._easeOptions=b,this._onEaseFrame=a,this._onEaseEnd=m,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const a=Math.min((i.exported.now()-this._easeStart)/this._easeOptions.duration,1),m=this._onEaseFrame;m&&m(this._easeOptions.easing(a)),a<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(a,m){a=i.wrap(a,-180,180);const b=Math.abs(a-m);return Math.abs(a-360-m)180?-360:b<-180?360:0}_emulate(a,m,b){const S=Math.ceil(15*m/1e3),P=[],H=a(b.clone());for(let W=0;W<=S;W++){const ee=H(W/S);P.push(ee.clone())}return P}}class cn{constructor(a={}){this.options=a,i.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(a){const m=this.options&&this.options.compact;return this._map=a,this._container=R("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=R("button","mapboxgl-ctrl-attrib-button",this._container),R("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=R("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),m&&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),m===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(a,m){const b=this._map._getUIString(`AttributionControl.${m}`);a.setAttribute("aria-label",b),a.removeAttribute("title"),a.firstElementChild&&a.firstElementChild.setAttribute("title",b)}_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 a=this._editLink;a||(a=this._editLink=this._container.querySelector(".mapbox-improve-map"));const m=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.config.ACCESS_TOKEN}];if(a){const b=m.reduce((S,P,H)=>(P.value&&(S+=`${P.key}=${P.value}${HS.length-P.length),a=a.filter((S,P)=>{for(let H=P+1;H=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?a=[...this.options.customAttribution,...a]:a.unshift(this.options.customAttribution));const b=a.join(" | ");b!==this._attribHTML&&(this._attribHTML=b,a.length?(this._innerContainer.innerHTML=b,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 Bn{constructor(){i.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(a){this._map=a,this._container=R("div","mapboxgl-ctrl");const m=R("a","mapboxgl-ctrl-logo");return m.target="_blank",m.rel="noopener nofollow",m.href="https://www.mapbox.com/",m.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),m.setAttribute("rel","noopener nofollow"),this._container.appendChild(m),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(a){a&&a.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const a=this._map.style._sourceCaches;if(Object.entries(a).length===0)return!0;for(const m in a){const b=a[m].getSource();if(b.hasOwnProperty("mapbox_logo")&&!b.mapbox_logo)return!1}return!0}_updateCompact(){const a=this._container.children;if(a.length){const m=a[0];this._map.getCanvasContainer().offsetWidth<250?m.classList.add("mapboxgl-compact"):m.classList.remove("mapboxgl-compact")}}}class tr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(a){const m=++this._id;return this._queue.push({callback:a,id:m,cancelled:!1}),m}remove(a){const m=this._currentlyRunning,b=m?this._queue.concat(m):this._queue;for(const S of b)if(S.id===a)return void(S.cancelled=!0)}run(a=0){const m=this._currentlyRunning=this._queue;this._queue=[];for(const b of m)if(!b.cancelled&&(b.callback(a),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function ur(x,a,m){if(x=new i.LngLat(x.lng,x.lat),a){const b=new i.LngLat(x.lng-360,x.lat),S=new i.LngLat(x.lng+360,x.lat),P=360*Math.ceil(Math.abs(x.lng-m.center.lng)/360),H=m.locationPoint(x).distSqr(a),W=a.x<0||a.y<0||a.x>m.width||a.y>m.height;m.locationPoint(b).distSqr(a)180;){const b=m.locationPoint(x);if(b.x>=0&&b.y>=0&&b.x<=m.width&&b.y<=m.height)break;x.lng>m.center.lng?x.lng-=360:x.lng+=360}return x}const Un={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 Lr extends i.Evented{constructor(a,m){if(super(),(a instanceof i.window.HTMLElement||m)&&(a=i.extend({element:a},m)),i.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=a&&a.anchor||"center",this._color=a&&a.color||"#3FB1CE",this._scale=a&&a.scale||1,this._draggable=a&&a.draggable||!1,this._clickTolerance=a&&a.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=a&&a.rotation||0,this._rotationAlignment=a&&a.rotationAlignment||"auto",this._pitchAlignment=a&&a.pitchAlignment&&a.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=a&&a.occludedOpacity||.2,a&&a.element)this._element=a.element,this._offset=i.pointGeometry.convert(a&&a.offset||[0,0]);else{this._defaultMarker=!0,this._element=R("div");const S=41,P=27,H=G("svg",{display:"block",height:S*this._scale+"px",width:P*this._scale+"px",viewBox:`0 0 ${P} ${S}`},this._element),W=G("radialGradient",{id:"shadowGradient"},G("defs",{},H));G("stop",{offset:"10%","stop-opacity":.4},W),G("stop",{offset:"100%","stop-opacity":.05},W),G("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},H),G("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"},H),G("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"},H),G("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},H),this._offset=i.pointGeometry.convert(a&&a.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",S=>{S.preventDefault()}),this._element.addEventListener("mousedown",S=>{S.preventDefault()});const b=this._element.classList;for(const S in Un)b.remove(`mapboxgl-marker-anchor-${S}`);b.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(a){return a===this._map||(this.remove(),this._map=a,a.getCanvasContainer().appendChild(this._element),a.on("move",this._updateMoving),a.on("moveend",this._update),a.on("remove",this._clearFadeTimer),a._addMarker(this),this.setDraggable(this._draggable),this._update(),a.on("click",this._onMapClick)),this}remove(){const a=this._map;return a&&(a.off("click",this._onMapClick),a.off("move",this._updateMoving),a.off("moveend",this._update),a.off("mousedown",this._addDragHandler),a.off("touchstart",this._addDragHandler),a.off("mouseup",this._onUp),a.off("touchend",this._onUp),a.off("mousemove",this._onMove),a.off("touchmove",this._onMove),a.off("remove",this._clearFadeTimer),a._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(a){return this._lngLat=i.LngLat.convert(a),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(a){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")),a){if(!("offset"in a.options)){const S=Math.sqrt(Math.pow(13.5,2)/2);a.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[S,-1*(38.1-13.5+S)],"bottom-right":[-S,-1*(38.1-13.5+S)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=a,a._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(a){const m=a.code,b=a.charCode||a.keyCode;m!=="Space"&&m!=="Enter"&&b!==32&&b!==13||this.togglePopup()}_onMapClick(a){const m=a.originalEvent.target,b=this._element;this._popup&&(m===b||b.contains(m))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const a=this._popup;return a?(a.isOpen()?(a.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(a.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const a=this._map,m=this._pos;if(!a||!m)return!1;const b=a.unproject(m),S=a.getFreeCameraOptions();if(!S.position)return!1;const P=S.position.toLngLat();return P.distanceTo(b)<.9*P.distanceTo(this._lngLat)}_evaluateOpacity(){const a=this._map;if(!a)return;const m=this._pos;if(!m||m.x<0||m.x>a.transform.width||m.y<0||m.y>a.transform.height)return void this._clearFadeTimer();const b=a.unproject(m);let S;a._showingGlobe()&&i.isLngLatBehindGlobe(a.transform,this._lngLat)?S=0:(S=1-a._queryFogOpacity(b),a.transform._terrainEnabled()&&a.getTerrain()&&this._behindTerrain()&&(S*=this._occludedOpacity)),this._element.style.opacity=`${S}`,this._element.style.pointerEvents=S>0?"auto":"none",this._popup&&this._popup._setOpacity(S),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const a=this._pos;if(!a||!this._map)return;const m=this._offset.mult(this._scale);this._element.style.transform=` translate(${a.x}px,${a.y}px) ${Un[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${m.x}px,${m.y}px) `}_calculateXYTransform(){const a=this._pos,m=this._map,b=this.getPitchAlignment();if(!m||!a||b!=="map")return"";if(!m._showingGlobe()){const ee=m.getPitch();return ee?`rotateX(${ee}deg)`:""}const S=i.radToDeg(i.globeTiltAtLngLat(m.transform,this._lngLat)),P=a.sub(i.globeCenterToScreenPoint(m.transform)),H=Math.abs(P.x)+Math.abs(P.y);if(H===0)return"";const W=S/H;return`rotateX(${-P.y*W}deg) rotateY(${P.x*W}deg)`}_calculateZTransform(){const a=this._pos,m=this._map;if(!m||!a)return"";let b=0;const S=this.getRotationAlignment();if(S==="map")if(m._showingGlobe()){const P=m.project(new i.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),H=m.project(new i.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(P);b=i.radToDeg(Math.atan2(H.y,H.x))-90}else b=-m.getBearing();else if(S==="horizon"){const P=i.smoothstep(4,6,m.getZoom()),H=i.globeCenterToScreenPoint(m.transform);H.y+=P*m.transform.height;const W=a.sub(H),ee=i.radToDeg(Math.atan2(W.y,W.x));b=(ee>90?ee-270:ee+90)*(1-P)}return b+=this._rotation,b?`rotateZ(${b}deg)`:""}_update(a){i.window.cancelAnimationFrame(this._updateFrameId);const m=this._map;m&&(m.transform.renderWorldCopies&&(this._lngLat=ur(this._lngLat,this._pos,m.transform)),this._pos=m.project(this._lngLat),a===!0?this._updateFrameId=i.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),m._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(m._showingGlobe()||m.getTerrain()||m.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(a){return this._offset=i.pointGeometry.convert(a),this._update(),this}_onMove(a){const m=this._map;if(!m)return;const b=this._pointerdownPos,S=this._positionDelta;if(b&&S){if(!this._isDragging){const P=this._clickTolerance||m._clickTolerance;if(a.point.dist(b)=this._endTime)return this._end;const m=i.easeCubicInOut((a-this._startTime)/(this._endTime-this._startTime));return this._start*(1-m)+this._end*m}isEasing(a){return a>=this._startTime&&a<=this._endTime}jumpTo(a){this._startTime=-1/0,this._endTime=-1/0,this._start=a,this._end=a}easeTo(a,m,b){this._start=this.getValue(m),this._end=a,this._startTime=m,this._endTime=m+b}}const js={"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 \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},wa={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,crossSourceCollisions:!0},Aa={showCompass:!0,showZoom:!0,visualizePitch:!1};class ba{constructor(a,m,b=!1){this._clickTolerance=10,this.element=m,this.mouseRotate=new Kh({clickTolerance:a.dragRotate._mouseRotate._clickTolerance}),this.map=a,b&&(this.mousePitch=new xl({clickTolerance:a.dragRotate._mousePitch._clickTolerance})),i.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),m.addEventListener("mousedown",this.mousedown),m.addEventListener("touchstart",this.touchstart,{passive:!1}),m.addEventListener("touchmove",this.touchmove),m.addEventListener("touchend",this.touchend),m.addEventListener("touchcancel",this.reset)}down(a,m){this.mouseRotate.mousedown(a,m),this.mousePitch&&this.mousePitch.mousedown(a,m),ae()}move(a,m){const b=this.map,S=this.mouseRotate.mousemoveWindow(a,m),P=S&&S.bearingDelta;if(P&&b.setBearing(b.getBearing()+P),this.mousePitch){const H=this.mousePitch.mousemoveWindow(a,m),W=H&&H.pitchDelta;W&&b.setPitch(b.getPitch()+W)}}off(){const a=this.element;a.removeEventListener("mousedown",this.mousedown),a.removeEventListener("touchstart",this.touchstart,{passive:!1}),a.removeEventListener("touchmove",this.touchmove),a.removeEventListener("touchend",this.touchend),a.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){le(),i.window.removeEventListener("mousemove",this.mousemove),i.window.removeEventListener("mouseup",this.mouseup)}mousedown(a){this.down(i.extend({},a,{ctrlKey:!0,preventDefault:()=>a.preventDefault()}),me(this.element,a)),i.window.addEventListener("mousemove",this.mousemove),i.window.addEventListener("mouseup",this.mouseup)}mousemove(a){this.move(a,me(this.element,a))}mouseup(a){this.mouseRotate.mouseupWindow(a),this.mousePitch&&this.mousePitch.mouseupWindow(a),this.offTemp()}touchstart(a){a.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=Pe(this.element,a.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>a.preventDefault()},this._startPos))}touchmove(a){a.targetTouches.length!==1?this.reset():(this._lastPos=Pe(this.element,a.targetTouches)[0],this.move({preventDefault:()=>a.preventDefault()},this._lastPos))}touchend(a){a.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._container.style.width=x*S+"px",this._container.innerHTML=`${b} ${P}`})}function Ba(x){const a=Math.pow(10,`${Math.floor(x)}`.length-1);let m=x/a;return m=m>=10?10:m>=5?5:m>=3?3:m>=2?2:m>=1?1:function(b){const S=Math.pow(10,Math.ceil(-Math.log(b)/Math.LN10));return Math.round(b*S)/S}(m),a*m}const $l={version:i.version,supported:D,setRTLTextPlugin:i.setRTLTextPlugin,getRTLTextPluginStatus:i.getRTLTextPluginStatus,Map:class extends xn{constructor(x){if(i.LivePerformanceUtils.mark(i.PerformanceMarkers.create),(x=i.extend({},wa,x)).minZoom!=null&&x.maxZoom!=null&&x.minZoom>x.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(x.minPitch!=null&&x.maxPitch!=null&&x.minPitch>x.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(x.minPitch!=null&&x.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(x.maxPitch!=null&&x.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(x.antialias&&i.isSafariWithAntialiasingBug(i.window)&&(x.antialias=!1,i.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Kl(x.minZoom,x.maxZoom,x.minPitch,x.maxPitch,x.renderWorldCopies),x),this._interactive=x.interactive,this._minTileCacheSize=x.minTileCacheSize,this._maxTileCacheSize=x.maxTileCacheSize,this._failIfMajorPerformanceCaveat=x.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=x.preserveDrawingBuffer,this._antialias=x.antialias,this._trackResize=x.trackResize,this._bearingSnap=x.bearingSnap,this._refreshExpiredTiles=x.refreshExpiredTiles,this._fadeDuration=x.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=x.crossSourceCollisions,this._collectResourceTiming=x.collectResourceTiming,this._optimizeForTerrain=x.optimizeForTerrain,this._language=this._parseLanguage(x.language),this._worldview=x.worldview,this._renderTaskQueue=new tr,this._domRenderTaskQueue=new tr,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.uniqueId(),this._locale=i.extend({},js,x.locale),this._clickTolerance=x.clickTolerance,this._cooperativeGestures=x.cooperativeGestures,this._performanceMetricsCollection=x.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Gr(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new i.RequestManager(x.transformRequest,x.accessToken,x.testMode),this._silenceAuthErrors=!!x.testMode,typeof x.container=="string"){if(this._container=i.window.document.getElementById(x.container),!this._container)throw new Error(`Container '${x.container}' not found.`)}else{if(!(x.container instanceof i.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=x.container}if(this._container.childNodes.length>0&&i.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."),x.maxBounds&&this.setMaxBounds(x.maxBounds),i.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)),i.window!==void 0&&(i.window.addEventListener("online",this._onWindowOnline,!1),i.window.addEventListener("resize",this._onWindowResize,!1),i.window.addEventListener("orientationchange",this._onWindowResize,!1),i.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),i.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Hi(this,x),this._localFontFamily=x.localFontFamily,this._localIdeographFontFamily=x.localIdeographFontFamily,x.style&&this.setStyle(x.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),x.projection&&this.setProjection(x.projection),this._hash=x.hash&&new An(typeof x.hash=="string"&&x.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:x.center,zoom:x.zoom,bearing:x.bearing,pitch:x.pitch}),x.bounds&&(this.resize(),this.fitBounds(x.bounds,i.extend({},x.fitBoundsOptions,{duration:0})))),this.resize(),x.attributionControl&&this.addControl(new cn({customAttribution:x.customAttribution})),this._logoControl=new Bn,this.addControl(this._logoControl,x.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",a=>{this._update(a.dataType==="style"),this.fire(new i.Event(`${a.dataType}data`,a))}),this.on("dataloading",a=>{this.fire(new i.Event(`${a.dataType}dataloading`,a))})}_getMapId(){return this._mapId}addControl(x,a){if(a===void 0&&(a=x.getDefaultPosition?x.getDefaultPosition():"top-right"),!x||!x.onAdd)return this.fire(new i.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const m=x.onAdd(this);this._controls.push(x);const b=this._controlPositions[a];return a.indexOf("bottom")!==-1?b.insertBefore(m,b.firstChild):b.appendChild(m),this}removeControl(x){if(!x||!x.onRemove)return this.fire(new i.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const a=this._controls.indexOf(x);return a>-1&&this._controls.splice(a,1),x.onRemove(this),this}hasControl(x){return this._controls.indexOf(x)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(x){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 a=!this._moving;return a&&this.fire(new i.Event("movestart",x)).fire(new i.Event("move",x)),this.fire(new i.Event("resize",x)),a&&this.fire(new i.Event("moveend",x)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(x){return this.transform.setMaxBounds(i.LngLatBounds.convert(x)),this._update()}setMinZoom(x){if((x=x==null?-2:x)>=-2&&x<=this.transform.maxZoom)return this.transform.minZoom=x,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=x,this._update(),this.getZoom()>x?this.setZoom(x):this.fire(new i.Event("zoomstart")).fire(new i.Event("zoom")).fire(new i.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(x){if((x=x==null?0:x)<0)throw new Error("minPitch must be greater than or equal to 0");if(x>=0&&x<=this.transform.maxPitch)return this.transform.minPitch=x,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(x>=this.transform.minPitch)return this.transform.maxPitch=x,this._update(),this.getPitch()>x?this.setPitch(x):this.fire(new i.Event("pitchstart")).fire(new i.Event("pitch")).fire(new i.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(x){return this.transform.renderWorldCopies=x,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(x){return x==="auto"?i.window.navigator.language:Array.isArray(x)?x.length===0?void 0:x.map(a=>a==="auto"?i.window.navigator.language:a):x}setLanguage(x){const a=this._parseLanguage(x);if(!this.style||a===this._language)return this;this._language=a,this.style._reloadSources();for(const m of this._controls)m._setLanguage&&m._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(x){return this.style&&x!==this._worldview?(this._worldview=x,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(x){return this._lazyInitEmptyStyle(),x?typeof x=="string"&&(x={name:x}):x=null,this._useExplicitProjection=!!x,this._prioritizeAndUpdateProjection(x,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const x=this.transform,a=x.projection.name;let m;a==="globe"&&x.zoom>=i.GLOBE_ZOOM_THRESHOLD_MAX?(x.setMercatorFromTransition(),m=!0):a==="mercator"&&x.zoom=i.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(x),this.style.applyProjectionUpdate(),a){this.painter.clearBackgroundTiles();for(const m in this.style._sourceCaches)this.style._sourceCaches[m].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(x){return this.transform.locationPoint3D(i.LngLat.convert(x))}unproject(x){return this.transform.pointLocation3D(i.pointGeometry.convert(x))}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(x,a,m){if(x==="mouseenter"||x==="mouseover"){let b=!1;const S=H=>{const W=a.filter(pe=>this.getLayer(pe)),ee=W.length?this.queryRenderedFeatures(H.point,{layers:W}):[];ee.length?b||(b=!0,m.call(this,new Js(x,this,H.originalEvent,{features:ee}))):b=!1},P=()=>{b=!1};return{layers:new Set(a),listener:m,delegates:{mousemove:S,mouseout:P}}}if(x==="mouseleave"||x==="mouseout"){let b=!1;const S=H=>{const W=a.filter(ee=>this.getLayer(ee));(W.length?this.queryRenderedFeatures(H.point,{layers:W}):[]).length?b=!0:b&&(b=!1,m.call(this,new Js(x,this,H.originalEvent)))},P=H=>{b&&(b=!1,m.call(this,new Js(x,this,H.originalEvent)))};return{layers:new Set(a),listener:m,delegates:{mousemove:S,mouseout:P}}}{const b=S=>{const P=a.filter(W=>this.getLayer(W)),H=P.length?this.queryRenderedFeatures(S.point,{layers:P}):[];H.length&&(S.features=H,m.call(this,S),delete S.features)};return{layers:new Set(a),listener:m,delegates:{[x]:b}}}}on(x,a,m){if(m===void 0)return super.on(x,a);Array.isArray(a)||(a=[a]);const b=this._createDelegatedListener(x,a,m);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[x]=this._delegatedListeners[x]||[],this._delegatedListeners[x].push(b);for(const S in b.delegates)this.on(S,b.delegates[S]);return this}once(x,a,m){if(m===void 0)return super.once(x,a);Array.isArray(a)||(a=[a]);const b=this._createDelegatedListener(x,a,m);for(const S in b.delegates)this.once(S,b.delegates[S]);return this}off(x,a,m){if(m===void 0)return super.off(x,a);a=new Set(Array.isArray(a)?a:[a]);const b=(P,H)=>{if(P.size!==H.size)return!1;for(const W of P)if(!H.has(W))return!1;return!0},S=this._delegatedListeners?this._delegatedListeners[x]:void 0;return S&&(P=>{for(let H=0;H{S?this.fire(new i.ErrorEvent(S)):P&&this._updateDiff(P,a)})}else typeof x=="object"&&this._updateDiff(x,a)}_updateDiff(x,a){try{this.style.setState(x)&&this._update(!0)}catch(m){i.warnOnce(`Unable to perform style diff: ${m.message||m.error||m}. Rebuilding the style from scratch.`),this._updateStyle(x,a)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(i.warnOnce("There is no style added to the map."),!1)}addSource(x,a){return this._lazyInitEmptyStyle(),this.style.addSource(x,a),this._update(!0)}isSourceLoaded(x){return!!this.style&&this.style._isSourceCacheLoaded(x)}areTilesLoaded(){const x=this.style&&this.style._sourceCaches;for(const a in x){const m=x[a]._tiles;for(const b in m){const S=m[b];if(S.state!=="loaded"&&S.state!=="errored")return!1}}return!0}addSourceType(x,a,m){this._lazyInitEmptyStyle(),this.style.addSourceType(x,a,m)}removeSource(x){return this.style.removeSource(x),this._updateTerrain(),this._update(!0)}getSource(x){return this.style.getSource(x)}addImage(x,a,{pixelRatio:m=1,sdf:b=!1,stretchX:S,stretchY:P,content:H}={}){if(this._lazyInitEmptyStyle(),a instanceof i.window.HTMLImageElement||i.window.ImageBitmap&&a instanceof i.window.ImageBitmap){const{width:W,height:ee,data:pe}=i.exported.getImageData(a);this.style.addImage(x,{data:new i.RGBAImage({width:W,height:ee},pe),pixelRatio:m,stretchX:S,stretchY:P,content:H,sdf:b,version:0})}else if(a.width===void 0||a.height===void 0)this.fire(new i.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:W,height:ee}=a,pe=a;this.style.addImage(x,{data:new i.RGBAImage({width:W,height:ee},new Uint8Array(pe.data)),pixelRatio:m,stretchX:S,stretchY:P,content:H,sdf:b,version:0,userImage:pe}),pe.onAdd&&pe.onAdd(this,x)}}updateImage(x,a){const m=this.style.getImage(x);if(!m)return void this.fire(new i.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const b=a instanceof i.window.HTMLImageElement||i.window.ImageBitmap&&a instanceof i.window.ImageBitmap?i.exported.getImageData(a):a,{width:S,height:P}=b;S!==void 0&&P!==void 0?S===m.data.width&&P===m.data.height?(m.data.replace(b.data,!(a instanceof i.window.HTMLImageElement||i.window.ImageBitmap&&a instanceof i.window.ImageBitmap)),this.style.updateImage(x,m)):this.fire(new i.ErrorEvent(new Error(`The width and height of the updated image (${S}, ${P}) must be that same as the previous version of the image (${m.data.width}, ${m.data.height})`))):this.fire(new i.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(x){return x?!!this.style.getImage(x):(this.fire(new i.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(x){this.style.removeImage(x)}loadImage(x,a){i.getImage(this._requestManager.transformRequest(x,i.ResourceType.Image),(m,b)=>{a(m,b instanceof i.window.HTMLImageElement?i.exported.getImageData(b):b)})}listImages(){return this.style.listImages()}addLayer(x,a){return this._lazyInitEmptyStyle(),this.style.addLayer(x,a),this._update(!0)}moveLayer(x,a){return this.style.moveLayer(x,a),this._update(!0)}removeLayer(x){return this.style.removeLayer(x),this._update(!0)}getLayer(x){return this.style.getLayer(x)}setLayerZoomRange(x,a,m){return this.style.setLayerZoomRange(x,a,m),this._update(!0)}setFilter(x,a,m={}){return this.style.setFilter(x,a,m),this._update(!0)}getFilter(x){return this.style.getFilter(x)}setPaintProperty(x,a,m,b={}){return this.style.setPaintProperty(x,a,m,b),this._update(!0)}getPaintProperty(x,a){return this.style.getPaintProperty(x,a)}setLayoutProperty(x,a,m,b={}){return this.style.setLayoutProperty(x,a,m,b),this._update(!0)}getLayoutProperty(x,a){return this.style.getLayoutProperty(x,a)}setLight(x,a={}){return this._lazyInitEmptyStyle(),this.style.setLight(x,a),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(x){return this._lazyInitEmptyStyle(),!x&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(x),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(x){return this._lazyInitEmptyStyle(),this.style.setFog(x),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(x){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.LngLat.convert(x),this.transform):0}setFeatureState(x,a){return this.style.setFeatureState(x,a),this._update()}removeFeatureState(x,a){return this.style.removeFeatureState(x,a),this._update()}getFeatureState(x){return this.style.getFeatureState(x)}_updateContainerDimensions(){if(!this._container)return;const x=this._container.getBoundingClientRect().width||400,a=this._container.getBoundingClientRect().height||300;let m,b,S,P=this._container;for(;P&&(!b||!S);){const H=i.window.getComputedStyle(P).transform;H&&H!=="none"&&(m=H.match(/matrix.*\((.+)\)/)[1].split(", "),m[0]&&m[0]!=="0"&&m[0]!=="1"&&(b=m[0]),m[3]&&m[3]!=="0"&&m[3]!=="1"&&(S=m[3])),P=P.parentElement}this._containerWidth=b?Math.abs(x/b):x,this._containerHeight=S?Math.abs(a/S):a}_detectMissingCSS(){i.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&i.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 x=this._container;x.classList.add("mapboxgl-map"),(this._missingCSSCanary=R("div","mapboxgl-canary",x)).style.visibility="hidden",this._detectMissingCSS();const a=this._canvasContainer=R("div","mapboxgl-canvas-container",x);this._interactive&&a.classList.add("mapboxgl-interactive"),this._canvas=R("canvas","mapboxgl-canvas",a),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 m=this._controlContainer=R("div","mapboxgl-control-container",x),b=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(S=>{b[S]=R("div",`mapboxgl-ctrl-${S}`,m)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(x,a){const m=i.exported.devicePixelRatio||1;this._canvas.width=m*Math.ceil(x),this._canvas.height=m*Math.ceil(a),this._canvas.style.width=`${x}px`,this._canvas.style.height=`${a}px`}_addMarker(x){this._markers.push(x)}_removeMarker(x){const a=this._markers.indexOf(x);a!==-1&&this._markers.splice(a,1)}_addPopup(x){this._popups.push(x)}_removePopup(x){const a=this._popups.indexOf(x);a!==-1&&this._popups.splice(a,1)}_setupPainter(){const x=i.extend({},D.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),a=this._canvas.getContext("webgl",x)||this._canvas.getContext("experimental-webgl",x);a?(i.storeAuthState(a,!0),this.painter=new cA(a,this.transform),this.on("data",m=>{m.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),i.exported$1.testSupport(a)):this.fire(new i.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(x){x.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.Event("webglcontextlost",{originalEvent:x}))}_contextRestored(x){this._setupPainter(),this.resize(),this._update(),this.fire(new i.Event("webglcontextrestored",{originalEvent:x}))}_onMapScroll(x){if(x.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(x){return this.style?(this._styleDirty=this._styleDirty||x,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(x){return this._update(),this._renderTaskQueue.add(x)}_cancelRenderFrame(x){this._renderTaskQueue.remove(x)}_requestDomTask(x){!this.loaded()||this.loaded()&&!this.isMoving()?x():this._domRenderTaskQueue.add(x)}_render(x){let a;const m=this.painter.context.extTimerQuery,b=i.exported.now();if(this.listens("gpu-timing-frame")&&(a=m.createQueryEXT(),m.beginQueryEXT(m.TIME_ELAPSED_EXT,a)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],i.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],i.window.performance.now())),this._renderTaskQueue.run(x),this._domRenderTaskQueue.run(x),this._removed)return;this._updateProjectionTransition();const S=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const W=this.transform.zoom,ee=this.transform.pitch,pe=i.exported.now(),fe=new i.EvaluationParameters(W,{now:pe,fadeDuration:S,pitch:ee,transition:this.style.getTransition()});this.style.update(fe)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let P=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),P=this._updateAverageElevation(b),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):P=this._updateAverageElevation(b),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,S,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:S,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new i.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),a){const W=i.exported.now()-b;m.endQueryEXT(m.TIME_ELAPSED_EXT,a),setTimeout(()=>{const ee=m.getQueryObjectEXT(a,m.QUERY_RESULT_EXT)/1e6;m.deleteQueryEXT(a),this.fire(new i.Event("gpu-timing-frame",{cpuTime:W,gpuTime:ee})),i.window.performance.mark("frame-gpu",{startTime:b,detail:{gpuTime:ee}})},50)}if(this.listens("gpu-timing-layer")){const W=this.painter.collectGpuTimers();setTimeout(()=>{const ee=this.painter.queryGpuTimers(W);this.fire(new i.Event("gpu-timing-layer",{layerTimes:ee}))},50)}if(this.listens("gpu-timing-deferred-render")){const W=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const ee=this.painter.queryGpuTimeDeferredRender(W);this.fire(new i.Event("gpu-timing-deferred-render",{gpuTime:ee}))},50)}const H=this._sourcesDirty||this._styleDirty||this._placementDirty||P;if(H||this._repaint)this.triggerRepaint();else{const W=!this.isMoving()&&this.loaded();if(W&&(P=this._updateAverageElevation(b,!0)),P)this.triggerRepaint();else if(this._triggerFrame(!1),W&&(this.fire(new i.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const ee=this._calculateSpeedIndex();this.fire(new i.Event("speedindexcompleted",{speedIndex:ee})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||H||(this._fullyLoaded=!0,i.LivePerformanceUtils.mark(i.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&i.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(x){for(const a of this._markers)x&&!this.getRenderWorldCopies()&&(a._lngLat=a._lngLat.wrap()),a._update();for(const a of this._popups)!x||this.getRenderWorldCopies()||a._trackPointer||(a._lngLat=a._lngLat.wrap()),a._update()}_updateAverageElevation(x,a=!1){const m=b=>(this.transform.averageElevation=b,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&m(0);if((a||x-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(x)){const b=this.transform.averageElevation;let S=this.transform.sampleAverageElevation(),P=!1;this.transform.elevation&&(P=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(S)?S=0:this._averageElevationLastSampledAt=x;const H=Math.abs(b-S);if(H>1){if(this._isInitialLoad||P)return this._averageElevation.jumpTo(S),m(S);this._averageElevation.easeTo(S,x,300)}else if(H>1e-4)return this._averageElevation.jumpTo(S),m(S)}return!!this._averageElevation.isEasing(x)&&m(this._averageElevation.getValue(x))}_authenticate(){i.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,x=>{if(x&&(x.message===i.AUTH_ERR_MSG||x.status===401)){const a=this.painter.context.gl;i.storeAuthState(a,!1),this._logoControl instanceof Bn&&this._logoControl._updateLogo(),a&&a.clear(a.DEPTH_BUFFER_BIT|a.COLOR_BUFFER_BIT|a.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.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/")))}}),i.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const x=this._isDragging();this.painter.updateTerrain(this.style,x)}_calculateSpeedIndex(){const x=this.painter.canvasCopy(),a=this.painter.getCanvasCopiesAndTimestamps();a.timeStamps.push(performance.now());const m=this.painter.context.gl,b=m.createFramebuffer();function S(P){m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_2D,P,0);const H=new Uint8Array(m.drawingBufferWidth*m.drawingBufferHeight*4);return m.readPixels(0,0,m.drawingBufferWidth,m.drawingBufferHeight,m.RGBA,m.UNSIGNED_BYTE,H),H}return m.bindFramebuffer(m.FRAMEBUFFER,b),this._canvasPixelComparison(S(x),a.canvasCopies.map(S),a.timeStamps)}_canvasPixelComparison(x,a,m){let b=m[1]-m[0];const S=x.length/4;for(let P=0;P{const m=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,m&&this._render(a)}))}_preloadTiles(x){const a=this.style?Object.values(this.style._sourceCaches):[];return i.asyncAll(a,(m,b)=>m._preloadTiles(x,b),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(x){this._trackResize&&this.resize({originalEvent:x})._update()}_onVisibilityChange(){i.window.document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(x){this._showTileBoundaries!==x&&(this._showTileBoundaries=x,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(x){this._showTerrainWireframe!==x&&(this._showTerrainWireframe=x,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(x){this._speedIndexTiming!==x&&(this._speedIndexTiming=x,this._update())}get showPadding(){return!!this._showPadding}set showPadding(x){this._showPadding!==x&&(this._showPadding=x,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(x){this._showCollisionBoxes!==x&&(this._showCollisionBoxes=x,x?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(x){this._showOverdrawInspector!==x&&(this._showOverdrawInspector=x,this._update())}get repaint(){return!!this._repaint}set repaint(x){this._repaint!==x&&(this._repaint=x,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(x){this._vertices=x,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(x){this._showTileAABBs!==x&&(this._showTileAABBs=x,x&&this._update())}_setCacheLimits(x,a){i.setCacheLimits(x,a)}get version(){return i.version}},NavigationControl:class{constructor(x){this.options=i.extend({},Aa,x),this._container=R("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",a=>a.preventDefault()),this.options.showZoom&&(i.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",a=>{this._map&&this._map.zoomIn({},{originalEvent:a})}),R("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",a=>{this._map&&this._map.zoomOut({},{originalEvent:a})}),R("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",a=>{const m=this._map;m&&(this.options.visualizePitch?m.resetNorthPitch({},{originalEvent:a}):m.resetNorth({},{originalEvent:a}))}),this._compassIcon=R("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const x=this._map;if(!x)return;const a=x.getZoom(),m=a===x.getMaxZoom(),b=a===x.getMinZoom();this._zoomInButton.disabled=m,this._zoomOutButton.disabled=b,this._zoomInButton.setAttribute("aria-disabled",m.toString()),this._zoomOutButton.setAttribute("aria-disabled",b.toString())}_rotateCompassArrow(){const x=this._map;if(!x)return;const a=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(x.transform.pitch*(Math.PI/180)),.5)}) rotateX(${x.transform.pitch}deg) rotateZ(${x.transform.angle*(180/Math.PI)}deg)`:`rotate(${x.transform.angle*(180/Math.PI)}deg)`;x._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=a)})}onAdd(x){return this._map=x,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),x.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&x.on("pitch",this._rotateCompassArrow),x.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ba(x,this._compass,this.options.visualizePitch)),this._container}onRemove(){const x=this._map;x&&(this._container.remove(),this.options.showZoom&&x.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&x.off("pitch",this._rotateCompassArrow),x.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(x,a){const m=R("button",x,this._container);return m.type="button",m.addEventListener("click",a),m}_setButtonTitle(x,a){if(!this._map)return;const m=this._map._getUIString(`NavigationControl.${a}`);x.setAttribute("aria-label",m),x.firstElementChild&&x.firstElementChild.setAttribute("title",m)}},GeolocateControl:class extends i.Evented{constructor(x){super(),this.options=i.extend({geolocation:i.window.navigator.geolocation},ja,x),i.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=_l(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(x){return this._map=x,this._container=R("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(x){const a=(m=!!this.options.geolocation)=>{this._supportsGeolocation=m,x(m)};this._supportsGeolocation!==void 0?x(this._supportsGeolocation):i.window.navigator.permissions!==void 0?i.window.navigator.permissions.query({name:"geolocation"}).then(m=>a(m.state!=="denied")).catch(()=>a()):a()}_isOutOfMapMaxBounds(x){const a=this._map.getMaxBounds(),m=x.coords;return!!a&&(m.longitudea.getEast()||m.latitudea.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(x){if(this._map){if(this._isOutOfMapMaxBounds(x))return this._setErrorState(),this.fire(new i.Event("outofmaxbounds",x)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=x,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(x),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(x),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new i.Event("geolocate",x)),this._finish()}}_updateCamera(x){const a=new i.LngLat(x.coords.longitude,x.coords.latitude),m=x.coords.accuracy,b=this._map.getBearing(),S=i.extend({bearing:b},this.options.fitBoundsOptions);this._map.fitBounds(a.toBounds(m),S,{geolocateSource:!0})}_updateMarker(x){if(x){const a=new i.LngLat(x.coords.longitude,x.coords.latitude);this._accuracyCircleMarker.setLngLat(a).addTo(this._map),this._userLocationDotMarker.setLngLat(a).addTo(this._map),this._accuracy=x.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const x=this._map.transform,a=i.mercatorZfromAltitude(1,x._center.lat)*x.worldSize,m=Math.ceil(2*this._accuracy*a);this._circleElement.style.width=`${m}px`,this._circleElement.style.height=`${m}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(x){if(this._map){if(this.options.trackUserLocation)if(x.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 a=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",a),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",a),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(x.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 i.Event("error",x)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(x){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",a=>a.preventDefault()),this._geolocateButton=R("button","mapboxgl-ctrl-geolocate",this._container),R("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",x===!1){i.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const a=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",a),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",a)}else{const a=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",a),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",a)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=R("div","mapboxgl-user-location"),this._dotElement.appendChild(R("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(R("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Lr({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=R("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Lr({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",a=>{a.geolocateSource||this._watchState!=="ACTIVE_LOCK"||a.originalEvent&&a.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 i.Event("trackuserlocationend")))})}}_onDeviceOrientation(x){this._userLocationDotMarker&&(x.webkitCompassHeading?this._heading=x.webkitCompassHeading:x.absolute===!0&&(this._heading=-1*x.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return i.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 i.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 i.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 i.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 x;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(x={maximumAge:6e5,timeout:0},this._noTimeout=!0):(x=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,x),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 x=()=>{i.window.addEventListener("ondeviceorientationabsolute"in i.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};i.window.DeviceMotionEvent!==void 0&&typeof i.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(a=>{a==="granted"&&x()}).catch(console.error):x()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),i.window.removeEventListener("deviceorientation",this._onDeviceOrientation),i.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:cn,ScaleControl:class{constructor(x){this.options=i.extend({},Wo,x),function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"narrow",unit:"meter"}),!0}catch{return!1}}()||(this._setScale=mo.bind(this)),i.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const x=this.options.maxWidth||100,a=this._map,m=a._containerHeight/2,b=a._containerWidth/2-x/2,S=a.unproject([b,m]),P=a.unproject([b+x,m]),H=S.distanceTo(P);if(this.options.unit==="imperial"){const W=3.2808*H;W>5280?this._setScale(x,W/5280,"mile"):this._setScale(x,W,"foot")}else this.options.unit==="nautical"?this._setScale(x,H/1852,"nautical-mile"):H>=1e3?this._setScale(x,H/1e3,"kilometer"):this._setScale(x,H,"meter")}_setScale(x,a,m){const b=Ba(a),S=b/a;this._map._requestDomTask(()=>{this._container.style.width=x*S+"px",this._container.innerHTML=m!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"narrow",unit:m}).format(b):`${b} nm`})}onAdd(x){return this._map=x,this._language=x.getLanguage(),this._container=R("div","mapboxgl-ctrl mapboxgl-ctrl-scale",x.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(x){this._language=x,this._update()}setUnit(x){this.options.unit=x,this._update()}},FullscreenControl:class{constructor(x){this._fullscreen=!1,x&&x.container&&(x.container instanceof i.window.HTMLElement?this._container=x.container:i.warnOnce("Full screen control 'container' must be a DOM element.")),i.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in i.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in i.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(x){return this._map=x,this._container||(this._container=this._map.getContainer()),this._controlContainer=R("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,i.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!i.window.document.fullscreenEnabled&&!i.window.document.webkitFullscreenEnabled)}_setupUI(){const x=this._fullscreenButton=R("button","mapboxgl-ctrl-fullscreen",this._controlContainer);R("span","mapboxgl-ctrl-icon",x).setAttribute("aria-hidden","true"),x.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),i.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const x=this._getTitle();this._fullscreenButton.setAttribute("aria-label",x),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",x)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(i.window.document.fullscreenElement||i.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()?i.window.document.exitFullscreen?i.window.document.exitFullscreen():i.window.document.webkitCancelFullScreen&&i.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends i.Evented{constructor(x){super(),this.options=i.extend(Object.create(Rr),x),i.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(x&&x.className?x.className.trim().split(/\s+/):[])}addTo(x){return this._map&&this.remove(),this._map=x,this.options.closeOnClick&&x.on("preclick",this._onClose),this.options.closeOnMove&&x.on("move",this._onClose),x.on("remove",this.remove),this._update(),x._addPopup(this),this._focusFirstElement(),this._trackPointer?(x.on("mousemove",this._onMouseEvent),x.on("mouseup",this._onMouseEvent),x._canvasContainer.classList.add("mapboxgl-track-pointer")):x.on("move",this._update),this.fire(new i.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const x=this._map;return x&&(x.off("move",this._update),x.off("move",this._onClose),x.off("preclick",this._onClose),x.off("click",this._onClose),x.off("remove",this.remove),x.off("mousemove",this._onMouseEvent),x.off("mouseup",this._onMouseEvent),x.off("drag",this._onMouseEvent),x._canvasContainer&&x._canvasContainer.classList.remove("mapboxgl-track-pointer"),x._removePopup(this),this._map=void 0),this.fire(new i.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(x){this._lngLat=i.LngLat.convert(x),this._pos=null,this._trackPointer=!1,this._update();const a=this._map;return a&&(a.on("move",this._update),a.off("mousemove",this._onMouseEvent),a._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const x=this._map;return x&&(x.off("move",this._update),x.on("mousemove",this._onMouseEvent),x.on("drag",this._onMouseEvent),x._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(x){return this.setDOMContent(i.window.document.createTextNode(x))}setHTML(x){const a=i.window.document.createDocumentFragment(),m=i.window.document.createElement("body");let b;for(m.innerHTML=x;b=m.firstChild,b;)a.appendChild(b);return this.setDOMContent(a)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(x){return this.options.maxWidth=x,this._update(),this}setDOMContent(x){let a=this._content;if(a)for(;a.hasChildNodes();)a.firstChild&&a.removeChild(a.firstChild);else a=this._content=R("div","mapboxgl-popup-content",this._container||void 0);if(a.appendChild(x),this.options.closeButton){const m=this._closeButton=R("button","mapboxgl-popup-close-button",a);m.type="button",m.setAttribute("aria-label","Close popup"),m.setAttribute("aria-hidden","true"),m.innerHTML="×",m.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(x){return this._classList.add(x),this._updateClassList(),this}removeClassName(x){return this._classList.delete(x),this._updateClassList(),this}setOffset(x){return this.options.offset=x,this._update(),this}toggleClassName(x){let a;return this._classList.delete(x)?a=!1:(this._classList.add(x),a=!0),this._updateClassList(),a}_onMouseEvent(x){this._update(x.point)}_getAnchor(x){if(this.options.anchor)return this.options.anchor;const a=this._map,m=this._container,b=this._pos;if(!a||!m||!b)return"bottom";const S=m.offsetWidth,P=m.offsetHeight,H=b.xa.transform.width-S/2;if(b.y+xa.transform.height-P){if(H)return"bottom-left";if(W)return"bottom-right"}return H?"left":W?"right":"bottom"}_updateClassList(){const x=this._container;if(!x)return;const a=[...this._classList];a.push("mapboxgl-popup"),this._anchor&&a.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&a.push("mapboxgl-popup-track-pointer"),x.className=a.join(" ")}_update(x){const a=this._map,m=this._content;if(!a||!this._lngLat&&!this._trackPointer||!m)return;let b=this._container;if(b||(b=this._container=R("div","mapboxgl-popup",a.getContainer()),this._tip=R("div","mapboxgl-popup-tip",b),b.appendChild(m)),this.options.maxWidth&&b.style.maxWidth!==this.options.maxWidth&&(b.style.maxWidth=this.options.maxWidth),a.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=ur(this._lngLat,this._pos,a.transform)),!this._trackPointer||x){const S=this._pos=this._trackPointer&&x?x:a.project(this._lngLat),P=Er(this.options.offset),H=this._anchor=this._getAnchor(P.y),W=Er(this.options.offset,H),ee=S.add(W).round();a._requestDomTask(()=>{this._container&&H&&(this._container.style.transform=`${Un[H]} translate(${ee.x}px,${ee.y}px)`)})}if(!this._marker&&a._showingGlobe()){const S=i.isLngLatBehindGlobe(a.transform,this._lngLat)?0:1;this._setOpacity(S)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const x=this._container.querySelector(Cr);x&&x.focus()}_onClose(){this.remove()}_setOpacity(x){this._container&&(this._container.style.opacity=`${x}`),this._content&&(this._content.style.pointerEvents=x?"auto":"none")}},Marker:Lr,Style:Ws,LngLat:i.LngLat,LngLatBounds:i.LngLatBounds,Point:i.pointGeometry,MercatorCoordinate:i.MercatorCoordinate,FreeCameraOptions:Vh,Evented:i.Evented,config:i.config,prewarm:function(){jt().acquire(Je)},clearPrewarmedResources:function(){const x=Lt;x&&(x.isPreloaded()&&x.numActive()===1?(x.release(Je),Lt=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 i.config.ACCESS_TOKEN},set accessToken(x){i.config.ACCESS_TOKEN=x},get baseApiUrl(){return i.config.API_URL},set baseApiUrl(x){i.config.API_URL=x},get workerCount(){return pt.workerCount},set workerCount(x){pt.workerCount=x},get maxParallelImageRequests(){return i.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(x){i.config.MAX_PARALLEL_IMAGE_REQUESTS=x},clearStorage(x){i.clearTileCache(x)},workerUrl:"",workerClass:null,setNow:i.exported.setNow,restoreNow:i.exported.restoreNow};return $l});var y=c;return y})})(DF);const Tm=DF.exports,BV=` varying vec2 vUv; varying vec3 v3; varying vec3 v_color; attribute vec3 color; void main(){ v_color = color; vUv = uv; // v3 = vec3((position.x+1.0) /2.0,(position.y+1.0) /2.0,(position.z+1.0) /2.0); // v3 = vec3((position.x+1.0) /2.0,(position.y+1.0) /2.0,(position.z+1.0) /2.0); gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); } `,CV=` varying vec2 vUv; varying vec3 v3; uniform float iTime; uniform float opacity; uniform vec3 color; varying vec3 v_color; void main(){ vec2 uv = vUv; // vec3 vv3 = vec3((v3.x+1.0) /2.0,(v3.y+1.0) /2.0,(v3.z+1.0) /2.0); // v3.x = (v3.x + 1.0) / 2.0; // float time = iTime * 0.3 + 0.0*0.01; // // To create the BG pattern // vec3 wave_color = vec3(0.0); // // To create the waves // float wave_width = 0.01; // // uv.y -= 0.5; // // for(float i = 0.0; i < 1.0; i++) { // // // uv.y += cos(i * 2.0 + iTime ) > 0.0 ? sin(i * 2.0 + iTime ) : -sin(i * 2.0 + iTime ) ; // // \u63A7\u5236\u7EBF\u6761\u8FD0\u52A8\u65B9\u5F0F\u3002 sin \u5185\u90E8\u63A7\u5236\u901F\u5EA6 \u5916\u9762\u63A7\u5236\u5E45\u5EA6 // // uv.y += sin(i * 2.3 + iTime ) * 0.5 + 0.0 ; // 0 => 0.3 ,uv.y \u662F0-1\u533A\u95F4\u5185 // // uv.y += 1.5; // // | uv.y | < 0.293 \u9010\u6B65\u663E\u793A > 0.293 \u9010\u6B65\u9690\u85CF // // uv.y = 0.293; // // \u63A7\u5236\u7EBF\u6761\u5BBD\u5EA6 // wave_width = abs(1.0 / (40.0 * uv.y)); // wave_color = vec3(wave_width , wave_width * 3.9, wave_width * 4.5); // } // // float random = ((wave_color.r + wave_color.g + wave_color.b) / 4.0) - 0.2; // // gl_FragColor = vec4(wave_color, random); // // uv.y += 0.5; // gl_FragColor = vec4(uv.y,0.0,0.0,1.0); gl_FragColor = vec4(v_color,opacity); } `;function EV(u){let e=[];return u.features.forEach(function(t){const r={geo:[],name:t.properties.name};r.name,e.push(r);const c=0;t.geometry.type==="Polygon"?(r.geo[0]=[],t.geometry.coordinates[0].forEach((p=[0,1,2])=>{p[0]=Tm.MercatorCoordinate.fromLngLat(p,c).x,p[1]=Tm.MercatorCoordinate.fromLngLat(p,c).y,p[2]=Tm.MercatorCoordinate.fromLngLat(p,c).z,r.geo[0].push(new Di(p[0],p[1]))})):t.geometry.type==="MultiPolygon"&&t.geometry.coordinates.forEach((p,y)=>{r.geo[y]=[],p[0].forEach(i=>{i[0]=Tm.MercatorCoordinate.fromLngLat(i,c).x,i[1]=Tm.MercatorCoordinate.fromLngLat(i,c).y,i[2]=Tm.MercatorCoordinate.fromLngLat(i,c).z,r.geo[y].push(new ft(i[0],i[1],i[2]))})})}),e}function tb(u){let e=new As;return e.name="geojson",EV(u)}var ic=63710088e-1,UF={centimeters:ic*100,centimetres:ic*100,degrees:ic/111325,feet:ic*3.28084,inches:ic*39.37,kilometers:ic/1e3,kilometres:ic/1e3,meters:ic,metres:ic,miles:ic/1609.344,millimeters:ic*1e3,millimetres:ic*1e3,nauticalmiles:ic/1852,radians:1,yards:ic*1.0936};function TV(u,e,t){t===void 0&&(t={});var r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=u,r}function SV(u,e,t){if(t===void 0&&(t={}),!u)throw new Error("coordinates is required");if(!Array.isArray(u))throw new Error("coordinates must be an Array");if(u.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!tS(u[0])||!tS(u[1]))throw new Error("coordinates must contain numbers");var r={type:"Point",coordinates:u};return TV(r,e,t)}function MV(u,e){e===void 0&&(e="kilometers");var t=UF[e];if(!t)throw new Error(e+" units is invalid");return u*t}function IV(u,e){e===void 0&&(e="kilometers");var t=UF[e];if(!t)throw new Error(e+" units is invalid");return u/t}function _2(u){var e=u%(2*Math.PI);return e*180/Math.PI}function hu(u){var e=u%360;return e*Math.PI/180}function tS(u){return!isNaN(u)&&u!==null&&!Array.isArray(u)}function oy(u){if(!u)throw new Error("coord is required");if(!Array.isArray(u)){if(u.type==="Feature"&&u.geometry!==null&&u.geometry.type==="Point")return u.geometry.coordinates;if(u.type==="Point")return u.coordinates}if(Array.isArray(u)&&u.length>=2&&!Array.isArray(u[0])&&!Array.isArray(u[1]))return u;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function RF(u,e,t){t===void 0&&(t={});var r=oy(u),c=oy(e),p=hu(c[1]-r[1]),y=hu(c[0]-r[0]),i=hu(r[1]),C=hu(c[1]),D=Math.pow(Math.sin(p/2),2)+Math.pow(Math.sin(y/2),2)*Math.cos(i)*Math.cos(C);return MV(2*Math.atan2(Math.sqrt(D),Math.sqrt(1-D)),t.units)}function FV(u,e,t,r){r===void 0&&(r={});var c=oy(u),p=hu(c[0]),y=hu(c[1]),i=hu(t),C=IV(e,r.units),D=Math.asin(Math.sin(y)*Math.cos(C)+Math.cos(y)*Math.sin(C)*Math.cos(i)),U=p+Math.atan2(Math.sin(i)*Math.sin(C)*Math.cos(y),Math.cos(C)-Math.sin(y)*Math.sin(D)),N=_2(U),R=_2(D);return SV([N,R],r.properties)}function zF(u,e,t){if(t===void 0&&(t={}),t.final===!0)return LV(u,e);var r=oy(u),c=oy(e),p=hu(r[0]),y=hu(c[0]),i=hu(r[1]),C=hu(c[1]),D=Math.sin(y-p)*Math.cos(C),U=Math.cos(i)*Math.sin(C)-Math.sin(i)*Math.cos(C)*Math.cos(y-p);return _2(Math.atan2(D,U))}function LV(u,e){var t=zF(e,u);return t=(t+180)%360,t}function DV(u,e){var t=RF(u,e),r=zF(u,e),c=FV(u,t/2,r);return c}var vv={exports:{}};/*! * Knockout JavaScript library v3.5.1 * (c) The Knockout.js team - http://knockoutjs.com/ * License: MIT (http://www.opensource.org/licenses/mit-license.php) */(function(u,e){(function(){(function(t){var r=this||(0,eval)("this"),c=r.document,p=r.navigator,y=r.jQuery,i=r.JSON;y||typeof jQuery>"u"||(y=jQuery),function(C){C(u.exports||e)}(function(C,D){function U(te,ce){return te===null||typeof te in ae?te===ce:!1}function N(te,ce){var ye;return function(){ye||(ye=B.a.setTimeout(function(){ye=t,te()},ce))}}function R(te,ce){var ye;return function(){clearTimeout(ye),ye=B.a.setTimeout(te,ce)}}function G(te,ce){ce&&ce!=="change"?ce==="beforeChange"?this.pc(te):this.gb(te,ce):this.qc(te)}function J(te,ce){ce!==null&&ce.s&&ce.s()}function Y(te,ce){var ye=this.qd,xe=ye[Pe];xe.ra||(this.Qb&&this.mb[ce]?(ye.uc(ce,te,this.mb[ce]),this.mb[ce]=null,--this.Qb):xe.I[ce]||ye.uc(ce,te,xe.J?{da:te}:ye.$c(te)),te.Ja&&te.gd())}var B=typeof C<"u"?C:{};B.b=function(te,ce){for(var ye=te.split("."),xe=B,ze=0;ze",ut[0];);return 4B.a.A(dt,ut)&&dt.push(ut)}),dt},Mb:function(Be,dt,ut){var Qt=[];if(Be)for(var Wt=0,Nt=Be.length;WtQt?ut&&Be.push(dt):ut||Be.splice(Qt,1)},Ba:Ne,extend:ce,setPrototypeOf:ye,Ab:Ne?ye:ce,P:te,Ga:function(Be,dt,ut){if(!Be)return Be;var Qt={},Wt;for(Wt in Be)ze.call(Be,Wt)&&(Qt[Wt]=dt.call(ut,Be[Wt],Wt,Be));return Qt},Tb:function(Be){for(;Be.firstChild;)B.removeNode(Be.firstChild)},Yb:function(Be){Be=B.a.la(Be);for(var dt=(Be[0]&&Be[0].ownerDocument||c).createElement("div"),ut=0,Qt=Be.length;utqe?Be.setAttribute("selected",dt):Be.selected=dt},Db:function(Be){return Be===null||Be===t?"":Be.trim?Be.trim():Be.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},Ud:function(Be,dt){return Be=Be||"",dt.length>Be.length?!1:Be.substring(0,dt.length)===dt},vd:function(Be,dt){if(Be===dt)return!0;if(Be.nodeType===11)return!1;if(dt.contains)return dt.contains(Be.nodeType!==1?Be.parentNode:Be);if(dt.compareDocumentPosition)return(dt.compareDocumentPosition(Be)&16)==16;for(;Be&&Be!=dt;)Be=Be.parentNode;return!!Be},Sb:function(Be){return B.a.vd(Be,Be.ownerDocument.documentElement)},kd:function(Be){return!!B.a.Lb(Be,B.a.Sb)},R:function(Be){return Be&&Be.tagName&&Be.tagName.toLowerCase()},Ac:function(Be){return B.onError?function(){try{return Be.apply(this,arguments)}catch(dt){throw B.onError&&B.onError(dt),dt}}:Be},setTimeout:function(Be,dt){return setTimeout(B.a.Ac(Be),dt)},Gc:function(Be){setTimeout(function(){throw B.onError&&B.onError(Be),Be},0)},B:function(Be,dt,ut){var Qt=B.a.Ac(ut);if(ut=Ie[dt],B.options.useOnlyNativeEvents||ut||!y)if(ut||typeof Be.addEventListener!="function")if(typeof Be.attachEvent<"u"){var Wt=function(Ct){Qt.call(Be,Ct)},Nt="on"+dt;Be.attachEvent(Nt,Wt),B.a.K.za(Be,function(){Be.detachEvent(Nt,Wt)})}else throw Error("Browser doesn't support addEventListener or attachEvent");else Be.addEventListener(dt,Qt,!1);else vt||(vt=typeof y(Be).on=="function"?"on":"bind"),y(Be)[vt](dt,Qt)},Fb:function(Be,dt){if(!Be||!Be.nodeType)throw Error("element must be a DOM node when calling triggerEvent");var ut;if(B.a.R(Be)==="input"&&Be.type&&dt.toLowerCase()=="click"?(ut=Be.type,ut=ut=="checkbox"||ut=="radio"):ut=!1,B.options.useOnlyNativeEvents||!y||ut)if(typeof c.createEvent=="function")if(typeof Be.dispatchEvent=="function")ut=c.createEvent(Le[dt]||"HTMLEvents"),ut.initEvent(dt,!0,!0,r,0,0,0,0,0,!1,!1,!1,!1,0,Be),Be.dispatchEvent(ut);else throw Error("The supplied element doesn't support dispatchEvent");else if(ut&&Be.click)Be.click();else if(typeof Be.fireEvent<"u")Be.fireEvent("on"+dt);else throw Error("Browser doesn't support triggering events");else y(Be).trigger(dt)},f:function(Be){return B.O(Be)?Be():Be},bc:function(Be){return B.O(Be)?Be.v():Be},Eb:function(Be,dt,ut){var Qt;dt&&(typeof Be.classList=="object"?(Qt=Be.classList[ut?"add":"remove"],B.a.D(dt.match(et),function(Wt){Qt.call(Be.classList,Wt)})):typeof Be.className.baseVal=="string"?xe(Be.className,"baseVal",dt,ut):xe(Be,"className",dt,ut))},Bb:function(Be,dt){var ut=B.a.f(dt);(ut===null||ut===t)&&(ut="");var Qt=B.h.firstChild(Be);!Qt||Qt.nodeType!=3||B.h.nextSibling(Qt)?B.h.va(Be,[Be.ownerDocument.createTextNode(ut)]):Qt.data=ut,B.a.Ad(Be)},Yc:function(Be,dt){if(Be.name=dt,7>=qe)try{var ut=Be.name.replace(/[&<>'"]/g,function(Qt){return"&#"+Qt.charCodeAt(0)+";"});Be.mergeAttributes(c.createElement(""),!1)}catch{}},Ad:function(Be){9<=qe&&(Be=Be.nodeType==1?Be:Be.parentNode,Be.style&&(Be.style.zoom=Be.style.zoom))},wd:function(Be){if(qe){var dt=Be.style.width;Be.style.width=0,Be.style.width=dt}},Pd:function(Be,dt){Be=B.a.f(Be),dt=B.a.f(dt);for(var ut=[],Qt=Be;Qt<=dt;Qt++)ut.push(Qt);return ut},la:function(Be){for(var dt=[],ut=0,Qt=Be.length;ut",""],ye=[3,"","
"],xe=[1,""],ze={thead:ce,tbody:ce,tfoot:ce,tr:[2,"","
"],td:ye,th:ye,option:xe,optgroup:xe},Ne=8>=B.a.W;B.a.ua=function(Ge,Ve){var Le;if(y){if(y.parseHTML)Le=y.parseHTML(Ge,Ve)||[];else if((Le=y.clean([Ge],Ve))&&Le[0]){for(var Ie=Le[0];Ie.parentNode&&Ie.parentNode.nodeType!==11;)Ie=Ie.parentNode;Ie.parentNode&&Ie.parentNode.removeChild(Ie)}}else{(Le=Ve)||(Le=c);var Ie=Le.parentWindow||Le.defaultView||r,qe=B.a.Db(Ge).toLowerCase(),et=Le.createElement("div"),vt;for(vt=(qe=qe.match(/^(?:\x3c!--.*?--\x3e\s*?)*?<([a-z]+)[\s>]/))&&ze[qe[1]]||te,qe=vt[0],vt="ignored
"+vt[1]+Ge+vt[2]+"
",typeof Ie.innerShiv=="function"?et.appendChild(Ie.innerShiv(vt)):(Ne&&Le.body.appendChild(et),et.innerHTML=vt,Ne&&et.parentNode.removeChild(et));qe--;)et=et.lastChild;Le=B.a.la(et.lastChild.childNodes)}return Le},B.a.Md=function(Ge,Ve){var Le=B.a.ua(Ge,Ve);return Le.length&&Le[0].parentElement||B.a.Yb(Le)},B.a.fc=function(Ge,Ve){if(B.a.Tb(Ge),Ve=B.a.f(Ve),Ve!==null&&Ve!==t)if(typeof Ve!="string"&&(Ve=Ve.toString()),y)y(Ge).html(Ve);else for(var Le=B.a.ua(Ve,Ge.ownerDocument),Ie=0;Ie"},bd:function(ye,xe){var ze=ce[ye];if(ze===t)throw Error("Couldn't find any memo with ID "+ye+". Perhaps it's already been unmemoized.");try{return ze.apply(null,xe||[]),!0}finally{delete ce[ye]}},cd:function(ye,xe){var ze=[];te(ye,ze);for(var Ne=0,Ge=ze.length;NeVe){if(5e3<=++Le){Ge=ze,B.a.Gc(Error("'Too much recursion' after processing "+Le+" task groups."));break}Ve=ze}try{Ie()}catch(qe){B.a.Gc(qe)}}}}function ce(){te(),Ge=ze=xe.length=0}var ye,xe=[],ze=0,Ne=1,Ge=0;return r.MutationObserver?ye=function(Ve){var Le=c.createElement("div");return new MutationObserver(Ve).observe(Le,{attributes:!0}),function(){Le.classList.toggle("foo")}}(ce):ye=c&&"onreadystatechange"in c.createElement("script")?function(Ve){var Le=c.createElement("script");Le.onreadystatechange=function(){Le.onreadystatechange=null,c.documentElement.removeChild(Le),Le=null,Ve()},c.documentElement.appendChild(Le)}:function(Ve){setTimeout(Ve,0)},{scheduler:ye,zb:function(Ve){return ze||B.na.scheduler(ce),xe[ze++]=Ve,Ne++},cancel:function(Ve){Ve=Ve-(Ne-ze),Ve>=Ge&&VeBe[0]?Qt+Be[0]:Be[0]),Qt);for(var Qt=Wt===1?Qt:Math.min(vt+(Be[1]||0),Qt),Wt=vt+Wt-2,Nt=Math.max(Qt,Wt),Ct=[],Ft=[],Xt=2;vtNe;Ne++)ze=ze();return ze})},B.toJSON=function(xe,ze,Ne){return xe=B.ad(xe),B.a.hc(xe,ze,Ne)},ye.prototype={constructor:ye,save:function(xe,ze){var Ne=B.a.A(this.keys,xe);0<=Ne?this.values[Ne]=ze:(this.keys.push(xe),this.values.push(ze))},get:function(xe){return xe=B.a.A(this.keys,xe),0<=xe?this.values[xe]:t}}}(),B.b("toJS",B.ad),B.b("toJSON",B.toJSON),B.Wd=function(te,ce,ye){function xe(ze){var Ne=B.xb(te,ye).extend({ma:"always"}),Ge=Ne.subscribe(function(Ve){Ve&&(Ge.s(),ze(Ve))});return Ne.notifySubscribers(Ne.v()),Ge}return typeof Promise!="function"||ce?xe(ce.bind(ye)):new Promise(xe)},B.b("when",B.Wd),function(){B.w={M:function(te){switch(B.a.R(te)){case"option":return te.__ko__hasDomDataOptionValue__===!0?B.a.g.get(te,B.c.options.$b):7>=B.a.W?te.getAttributeNode("value")&&te.getAttributeNode("value").specified?te.value:te.text:te.value;case"select":return 0<=te.selectedIndex?B.w.M(te.options[te.selectedIndex]):t;default:return te.value}},cb:function(te,ce,ye){switch(B.a.R(te)){case"option":typeof ce=="string"?(B.a.g.set(te,B.c.options.$b,t),"__ko__hasDomDataOptionValue__"in te&&delete te.__ko__hasDomDataOptionValue__,te.value=ce):(B.a.g.set(te,B.c.options.$b,ce),te.__ko__hasDomDataOptionValue__=!0,te.value=typeof ce=="number"?ce:"");break;case"select":(ce===""||ce===null)&&(ce=t);for(var xe=-1,ze=0,Ne=te.options.length,Ge;ze=vt){Le.push(qe&&et.length?{key:qe,value:et.join("")}:{unknown:qe||et.join("")}),qe=vt=0,et=[];continue}}else if(ut===58){if(!vt&&!qe&&et.length===1){qe=et.pop();continue}}else{if(ut===47&&1",Ne=ze?/^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,Ge=ze?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,Ve={ul:!0,ol:!0},Le="__ko_matchedEndComment__";B.h={ea:{},childNodes:function(Ie){return te(Ie)?ye(Ie):Ie.childNodes},Ea:function(Ie){if(te(Ie)){Ie=B.h.childNodes(Ie);for(var qe=0,et=Ie.length;qearguments.length){if(Ct=c.body,!Ct)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?")}else if(!Ct||Ct.nodeType!==1&&Ct.nodeType!==8)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");Le(et(Nt,Ft),Ct)},B.Dc=function(Nt){return!Nt||Nt.nodeType!==1&&Nt.nodeType!==8?t:B.Td(Nt)},B.Ec=function(Nt){return(Nt=B.Dc(Nt))?Nt.$data:t},B.b("bindingHandlers",B.c),B.b("bindingEvent",B.i),B.b("bindingEvent.subscribe",B.i.subscribe),B.b("bindingEvent.startPossiblyAsyncContentBinding",B.i.Cb),B.b("applyBindings",B.vc),B.b("applyBindingsToDescendants",B.Oa),B.b("applyBindingAccessorsToNode",B.ib),B.b("applyBindingsToNode",B.ld),B.b("contextFor",B.Dc),B.b("dataFor",B.Ec)}(),function(te){function ce(Ge,Ve){var Le=Object.prototype.hasOwnProperty.call(ze,Ge)?ze[Ge]:te,Ie;Le?Le.subscribe(Ve):(Le=ze[Ge]=new B.T,Le.subscribe(Ve),ye(Ge,function(qe,et){var vt=!(!et||!et.synchronous);Ne[Ge]={definition:qe,Gd:vt},delete ze[Ge],Ie||vt?Le.notifySubscribers(qe):B.na.zb(function(){Le.notifySubscribers(qe)})}),Ie=!0)}function ye(Ge,Ve){xe("getConfig",[Ge],function(Le){Le?xe("loadComponent",[Ge,Le],function(Ie){Ve(Ie,Le)}):Ve(null,null)})}function xe(Ge,Ve,Le,Ie){Ie||(Ie=B.j.loaders.slice(0));var qe=Ie.shift();if(qe){var et=qe[Ge];if(et){var vt=!1;if(et.apply(qe,Ve.concat(function(Be){vt?Le(null):Be!==null?Le(Be):xe(Ge,Ve,Le,Ie)}))!==te&&(vt=!0,!qe.suppressLoaderExceptions))throw Error("Component loaders must supply values by invoking the callback, not by returning values synchronously.")}else xe(Ge,Ve,Le,Ie)}else Le(null)}var ze={},Ne={};B.j={get:function(Ge,Ve){var Le=Object.prototype.hasOwnProperty.call(Ne,Ge)?Ne[Ge]:te;Le?Le.Gd?B.u.G(function(){Ve(Le.definition)}):B.na.zb(function(){Ve(Le.definition)}):ce(Ge,Ve)},Bc:function(Ge){delete Ne[Ge]},oc:xe},B.j.loaders=[],B.b("components",B.j),B.b("components.get",B.j.get),B.b("components.clearCachedDefinition",B.j.Bc)}(),function(){function te(Le,Ie,qe,et){function vt(){--dt===0&&et(Be)}var Be={},dt=2,ut=qe.template;qe=qe.viewModel,ut?ze(Ie,ut,function(Qt){B.j.oc("loadTemplate",[Le,Qt],function(Wt){Be.template=Wt,vt()})}):vt(),qe?ze(Ie,qe,function(Qt){B.j.oc("loadViewModel",[Le,Qt],function(Wt){Be[Ve]=Wt,vt()})}):vt()}function ce(Le,Ie,qe){if(typeof Ie=="function")qe(function(vt){return new Ie(vt)});else if(typeof Ie[Ve]=="function")qe(Ie[Ve]);else if("instance"in Ie){var et=Ie.instance;qe(function(){return et})}else"viewModel"in Ie?ce(Le,Ie.viewModel,qe):Le("Unknown viewModel value: "+Ie)}function ye(Le){switch(B.a.R(Le)){case"script":return B.a.ua(Le.text);case"textarea":return B.a.ua(Le.value);case"template":if(xe(Le.content))return B.a.Ca(Le.content.childNodes)}return B.a.Ca(Le.childNodes)}function xe(Le){return r.DocumentFragment?Le instanceof DocumentFragment:Le&&Le.nodeType===11}function ze(Le,Ie,qe){typeof Ie.require=="string"?D||r.require?(D||r.require)([Ie.require],function(et){et&&typeof et=="object"&&et.Xd&&et.default&&(et=et.default),qe(et)}):Le("Uses require, but no AMD loader is present"):qe(Ie)}function Ne(Le){return function(Ie){throw Error("Component '"+Le+"': "+Ie)}}var Ge={};B.j.register=function(Le,Ie){if(!Ie)throw Error("Invalid configuration for "+Le);if(B.j.tb(Le))throw Error("Component "+Le+" is already registered");Ge[Le]=Ie},B.j.tb=function(Le){return Object.prototype.hasOwnProperty.call(Ge,Le)},B.j.unregister=function(Le){delete Ge[Le],B.j.Bc(Le)},B.j.Fc={getConfig:function(Le,Ie){Ie(B.j.tb(Le)?Ge[Le]:null)},loadComponent:function(Le,Ie,qe){var et=Ne(Le);ze(et,Ie,function(vt){te(Le,et,vt,qe)})},loadTemplate:function(Le,Ie,qe){if(Le=Ne(Le),typeof Ie=="string")qe(B.a.ua(Ie));else if(Ie instanceof Array)qe(Ie);else if(xe(Ie))qe(B.a.la(Ie.childNodes));else if(Ie.element)if(Ie=Ie.element,r.HTMLElement?Ie instanceof HTMLElement:Ie&&Ie.tagName&&Ie.nodeType===1)qe(ye(Ie));else if(typeof Ie=="string"){var et=c.getElementById(Ie);et?qe(ye(et)):Le("Cannot find element with ID "+Ie)}else Le("Unknown element type: "+Ie);else Le("Unknown template value: "+Ie)},loadViewModel:function(Le,Ie,qe){ce(Ne(Le),Ie,qe)}};var Ve="createViewModel";B.b("components.register",B.j.register),B.b("components.isRegistered",B.j.tb),B.b("components.unregister",B.j.unregister),B.b("components.defaultLoader",B.j.Fc),B.j.loaders.push(B.j.Fc),B.j.dd=Ge}(),function(){function te(ye,xe){var ze=ye.getAttribute("params");if(ze){var ze=ce.parseBindingsString(ze,xe,ye,{valueAccessors:!0,bindingParams:!0}),ze=B.a.Ga(ze,function(Ve){return B.o(Ve,null,{l:ye})}),Ne=B.a.Ga(ze,function(Ve){var Le=Ve.v();return Ve.ja()?B.o({read:function(){return B.a.f(Ve())},write:B.Za(Le)&&function(Ie){Ve()(Ie)},l:ye}):Le});return Object.prototype.hasOwnProperty.call(Ne,"$raw")||(Ne.$raw=ze),Ne}return{$raw:{}}}B.j.getComponentNameForNode=function(ye){var xe=B.a.R(ye);if(B.j.tb(xe)&&(xe.indexOf("-")!=-1||""+ye=="[object HTMLUnknownElement]"||8>=B.a.W&&ye.tagName===xe))return xe},B.j.tc=function(ye,xe,ze,Ne){if(xe.nodeType===1){var Ge=B.j.getComponentNameForNode(xe);if(Ge){if(ye=ye||{},ye.component)throw Error('Cannot use the "component" binding on a custom element matching a component');var Ve={name:Ge,params:te(xe,ze)};ye.component=Ne?function(){return Ve}:Ve}}return ye};var ce=new B.ga;9>B.a.W&&(B.j.register=function(ye){return function(xe){return ye.apply(this,arguments)}}(B.j.register),c.createDocumentFragment=function(ye){return function(){var xe=ye();return B.j.dd,xe}}(c.createDocumentFragment))}(),function(){function te(xe,ze,Ne){if(ze=ze.template,!ze)throw Error("Component '"+xe+"' has no template");xe=B.a.Ca(ze),B.h.va(Ne,xe)}function ce(xe,ze,Ne){var Ge=xe.createViewModel;return Ge?Ge.call(xe,ze,Ne):ze}var ye=0;B.c.component={init:function(xe,ze,Ne,Ge,Ve){function Le(){var Be=Ie&&Ie.dispose;typeof Be=="function"&&Be.call(Ie),et&&et.s(),qe=Ie=et=null}var Ie,qe,et,vt=B.a.la(B.h.childNodes(xe));return B.h.Ea(xe),B.a.K.za(xe,Le),B.o(function(){var Be=B.a.f(ze()),dt,ut;if(typeof Be=="string"?dt=Be:(dt=B.a.f(Be.name),ut=B.a.f(Be.params)),!dt)throw Error("No component name specified");var Qt=B.i.Cb(xe,Ve),Wt=qe=++ye;B.j.get(dt,function(Nt){if(qe===Wt){if(Le(),!Nt)throw Error("Unknown component '"+dt+"'");te(dt,Nt,xe);var Ct=ce(Nt,ut,{element:xe,templateNodes:vt});Nt=Qt.createChildContext(Ct,{extend:function(Ft){Ft.$component=Ct,Ft.$componentTemplateNodes=vt}}),Ct&&Ct.koDescendantsComplete&&(et=B.i.subscribe(xe,B.i.pa,Ct.koDescendantsComplete,Ct)),Ie=Ct,B.Oa(Nt,xe)}})},null,{l:xe}),{controlsDescendantBindings:!0}}},B.h.ea.component=!0}();var oi={class:"className",for:"htmlFor"};B.c.attr={update:function(te,ce){var ye=B.a.f(ce())||{};B.a.P(ye,function(xe,ze){ze=B.a.f(ze);var Ne=xe.indexOf(":"),Ne="lookupNamespaceURI"in te&&0=B.a.W&&xe in oi?(xe=oi[xe],Ge?te.removeAttribute(xe):te[xe]=ze):Ge||(Ne?te.setAttributeNS(Ne,xe,ze):te.setAttribute(xe,ze)),xe==="name"&&B.a.Yc(te,Ge?"":ze)})}},function(){B.c.checked={after:["value","attr"],init:function(te,ce,ye){function xe(){var Be=te.checked,dt=Ne();if(!B.S.Ya()&&(Be||!Ve&&!B.S.qa())){var ut=B.u.G(ce);if(Ie){var Qt=qe?ut.v():ut,Wt=vt;vt=dt,Wt!==dt?Be&&(B.a.Na(Qt,dt,!0),B.a.Na(Qt,Wt,!1)):B.a.Na(Qt,dt,Be),qe&&B.Za(ut)&&ut(Qt)}else Ge&&(dt===t?dt=Be:Be||(dt=t)),B.m.eb(ut,ye,"checked",dt,!0)}}function ze(){var Be=B.a.f(ce()),dt=Ne();Ie?(te.checked=0<=B.a.A(Be,dt),vt=dt):te.checked=Ge&&dt===t?!!Be:Ne()===Be}var Ne=B.xb(function(){if(ye.has("checkedValue"))return B.a.f(ye.get("checkedValue"));if(et)return ye.has("value")?B.a.f(ye.get("value")):te.value}),Ge=te.type=="checkbox",Ve=te.type=="radio";if(Ge||Ve){var Le=ce(),Ie=Ge&&B.a.f(Le)instanceof Array,qe=!(Ie&&Le.push&&Le.splice),et=Ve||Ie,vt=Ie?Ne():t;Ve&&!te.name&&B.c.uniqueName.init(te,function(){return!0}),B.o(xe,null,{l:te}),B.a.B(te,"click",xe),B.o(ze,null,{l:te}),Le=t}}},B.m.wa.checked=!0,B.c.checkedValue={update:function(te,ce){te.value=B.a.f(ce())}}}(),B.c.class={update:function(te,ce){var ye=B.a.Db(B.a.f(ce()));B.a.Eb(te,te.__ko__cssValue,!1),te.__ko__cssValue=ye,B.a.Eb(te,ye,!0)}},B.c.css={update:function(te,ce){var ye=B.a.f(ce());ye!==null&&typeof ye=="object"?B.a.P(ye,function(xe,ze){ze=B.a.f(ze),B.a.Eb(te,xe,ze)}):B.c.class.update(te,ce)}},B.c.enable={update:function(te,ce){var ye=B.a.f(ce());ye&&te.disabled?te.removeAttribute("disabled"):ye||te.disabled||(te.disabled=!0)}},B.c.disable={update:function(te,ce){B.c.enable.update(te,function(){return!B.a.f(ce())})}},B.c.event={init:function(te,ce,ye,xe,ze){var Ne=ce()||{};B.a.P(Ne,function(Ge){typeof Ge=="string"&&B.a.B(te,Ge,function(Ve){var Le,Ie=ce()[Ge];if(Ie){try{var qe=B.a.la(arguments);xe=ze.$data,qe.unshift(xe),Le=Ie.apply(xe,qe)}finally{Le!==!0&&(Ve.preventDefault?Ve.preventDefault():Ve.returnValue=!1)}ye.get(Ge+"Bubble")===!1&&(Ve.cancelBubble=!0,Ve.stopPropagation&&Ve.stopPropagation())}})})}},B.c.foreach={Rc:function(te){return function(){var ce=te(),ye=B.a.bc(ce);return!ye||typeof ye.length=="number"?{foreach:ce,templateEngine:B.ba.Ma}:(B.a.f(ce),{foreach:ye.data,as:ye.as,noChildContext:ye.noChildContext,includeDestroyed:ye.includeDestroyed,afterAdd:ye.afterAdd,beforeRemove:ye.beforeRemove,afterRender:ye.afterRender,beforeMove:ye.beforeMove,afterMove:ye.afterMove,templateEngine:B.ba.Ma})}},init:function(te,ce){return B.c.template.init(te,B.c.foreach.Rc(ce))},update:function(te,ce,ye,xe,ze){return B.c.template.update(te,B.c.foreach.Rc(ce),ye,xe,ze)}},B.m.Ra.foreach=!1,B.h.ea.foreach=!0,B.c.hasfocus={init:function(te,ce,ye){function xe(Ge){te.__ko_hasfocusUpdating=!0;var Ve=te.ownerDocument;if("activeElement"in Ve){var Le;try{Le=Ve.activeElement}catch{Le=Ve.body}Ge=Le===te}Ve=ce(),B.m.eb(Ve,ye,"hasfocus",Ge,!0),te.__ko_hasfocusLastValue=Ge,te.__ko_hasfocusUpdating=!1}var ze=xe.bind(null,!0),Ne=xe.bind(null,!1);B.a.B(te,"focus",ze),B.a.B(te,"focusin",ze),B.a.B(te,"blur",Ne),B.a.B(te,"focusout",Ne),te.__ko_hasfocusLastValue=!1},update:function(te,ce){var ye=!!B.a.f(ce());te.__ko_hasfocusUpdating||te.__ko_hasfocusLastValue===ye||(ye?te.focus():te.blur(),!ye&&te.__ko_hasfocusLastValue&&te.ownerDocument.body.focus(),B.u.G(B.a.Fb,null,[te,ye?"focusin":"focusout"]))}},B.m.wa.hasfocus=!0,B.c.hasFocus=B.c.hasfocus,B.m.wa.hasFocus="hasfocus",B.c.html={init:function(){return{controlsDescendantBindings:!0}},update:function(te,ce){B.a.fc(te,ce())}},function(){function te(ce,ye,xe){B.c[ce]={init:function(ze,Ne,Ge,Ve,Le){var Ie,qe,et={},vt,Be,dt;if(ye){Ve=Ge.get("as");var ut=Ge.get("noChildContext");dt=!(Ve&&ut),et={as:Ve,noChildContext:ut,exportDependencies:dt}}return Be=(vt=Ge.get("completeOn")=="render")||Ge.has(B.i.pa),B.o(function(){var Qt=B.a.f(Ne()),Wt=!xe!=!Qt,Nt=!qe,Ct;(dt||Wt!==Ie)&&(Be&&(Le=B.i.Cb(ze,Le)),Wt&&((!ye||dt)&&(et.dataDependency=B.S.o()),Ct=ye?Le.createChildContext(typeof Qt=="function"?Qt:Ne,et):B.S.qa()?Le.extend(null,et):Le),Nt&&B.S.qa()&&(qe=B.a.Ca(B.h.childNodes(ze),!0)),Wt?(Nt||B.h.va(ze,B.a.Ca(qe)),B.Oa(Ct,ze)):(B.h.Ea(ze),vt||B.i.ma(ze,B.i.H)),Ie=Wt)},null,{l:ze}),{controlsDescendantBindings:!0}}},B.m.Ra[ce]=!1,B.h.ea[ce]=!0}te("if"),te("ifnot",!1,!0),te("with",!0)}(),B.c.let={init:function(te,ce,ye,xe,ze){return ce=ze.extend(ce),B.Oa(ce,te),{controlsDescendantBindings:!0}}},B.h.ea.let=!0;var Ci={};B.c.options={init:function(te){if(B.a.R(te)!=="select")throw Error("options binding applies only to SELECT elements");for(;0"u"&&(Le=[Le]),et=B.a.jb(Le,function(ut){return qe||ut===t||ut===null||!B.a.f(ut._destroy)}),ye.has("optionsCaption")&&(Le=B.a.f(ye.get("optionsCaption")),Le!==null&&Le!==t&&et.unshift(Ci)));var Be=!1;if(ce.beforeRemove=function(ut){te.removeChild(ut)},Le=Ne,ye.has("optionsAfterRender")&&typeof ye.get("optionsAfterRender")=="function"&&(Le=function(ut,Qt){Ne(0,Qt),B.u.G(ye.get("optionsAfterRender"),null,[Qt[0],ut!==Ci?ut:t])}),B.a.ec(te,et,function(ut,Qt,Wt){return Wt.length&&(vt=!Ie&&Wt[0].selected?[B.w.M(Wt[0])]:[],Be=!0),Qt=te.ownerDocument.createElement("option"),ut===Ci?(B.a.Bb(Qt,ye.get("optionsCaption")),B.w.cb(Qt,t)):(Wt=ze(ut,ye.get("optionsValue"),ut),B.w.cb(Qt,B.a.f(Wt)),ut=ze(ut,ye.get("optionsText"),Wt),B.a.Bb(Qt,ut)),[Qt]},ce,Le),!Ie){var dt;Ge?dt=vt.length&&xe().lengthNe)var Ve=B.a.g.Z(),Le=B.a.g.Z(),Ie=function(et){var vt=this.activeElement;(vt=vt&&B.a.g.get(vt,Le))&&vt(et)},qe=function(et,vt){var Be=et.ownerDocument;B.a.g.get(Be,Ve)||(B.a.g.set(Be,Ve,!0),B.a.B(Be,"selectionchange",Ie)),B.a.g.set(et,Le,vt)};B.c.textInput={init:function(et,vt,Be){function dt(fi,Gi){B.a.B(et,fi,Gi)}function ut(){var fi=B.a.f(vt());(fi===null||fi===t)&&(fi=""),Ft!==t&&fi===Ft?B.a.setTimeout(ut,4):et.value!==fi&&(mi=!0,et.value=fi,mi=!1,Nt=et.value)}function Qt(){Ct||(Ft=et.value,Ct=B.a.setTimeout(Wt,4))}function Wt(){clearTimeout(Ct),Ft=Ct=t;var fi=et.value;Nt!==fi&&(Nt=fi,B.m.eb(vt(),Be,"textInput",fi))}var Nt=et.value,Ct,Ft,Xt=B.a.W==9?Qt:Wt,mi=!1;Ne&&dt("keypress",Wt),11>Ne&&dt("propertychange",function(fi){mi||fi.propertyName!=="value"||Xt()}),Ne==8&&(dt("keyup",Wt),dt("keydown",Wt)),qe&&(qe(et,Xt),dt("dragend",Qt)),(!Ne||9<=Ne)&&dt("input",Xt),5>xe&&B.a.R(et)==="textarea"?(dt("keydown",Qt),dt("paste",Qt),dt("cut",Qt)):11>ye?dt("keydown",Qt):4>ze?(dt("DOMAutoComplete",Wt),dt("dragdrop",Wt),dt("drop",Wt)):Ge&&et.type==="number"&&dt("keydown",Qt),dt("change",Wt),dt("blur",Wt),B.o(ut,null,{l:et})}},B.m.wa.textInput=!0,B.c.textinput={preprocess:function(et,vt,Be){Be("textInput",et)}}}(),B.c.uniqueName={init:function(te,ce){if(ce()){var ye="ko_unique_"+ ++B.c.uniqueName.rd;B.a.Yc(te,ye)}}},B.c.uniqueName.rd=0,B.c.using={init:function(te,ce,ye,xe,ze){var Ne;return ye.has("as")&&(Ne={as:ye.get("as"),noChildContext:ye.get("noChildContext")}),ce=ze.createChildContext(ce,Ne),B.Oa(ce,te),{controlsDescendantBindings:!0}}},B.h.ea.using=!0,B.c.value={init:function(te,ce,ye){var xe=B.a.R(te),ze=xe=="input";if(!ze||te.type!="checkbox"&&te.type!="radio"){var Ne=[],Ge=ye.get("valueUpdate"),Ve=!1,Le=null;Ge&&(typeof Ge=="string"?Ne=[Ge]:Ne=B.a.wc(Ge),B.a.Pa(Ne,"change"));var Ie=function(){Le=null,Ve=!1;var vt=ce(),Be=B.w.M(te);B.m.eb(vt,ye,"value",Be)};!B.a.W||!ze||te.type!="text"||te.autocomplete=="off"||te.form&&te.form.autocomplete=="off"||B.a.A(Ne,"propertychange")!=-1||(B.a.B(te,"propertychange",function(){Ve=!0}),B.a.B(te,"focus",function(){Ve=!1}),B.a.B(te,"blur",function(){Ve&&Ie()})),B.a.D(Ne,function(vt){var Be=Ie;B.a.Ud(vt,"after")&&(Be=function(){Le=B.w.M(te),B.a.setTimeout(Ie,0)},vt=vt.substring(5)),B.a.B(te,vt,Be)});var qe;if(qe=ze&&te.type=="file"?function(){var vt=B.a.f(ce());vt===null||vt===t||vt===""?te.value="":B.u.G(Ie)}:function(){var vt=B.a.f(ce()),Be=B.w.M(te);Le!==null&&vt===Le?B.a.setTimeout(qe,0):(vt!==Be||Be===t)&&(xe==="select"?(Be=ye.get("valueAllowUnset"),B.w.cb(te,vt,Be),Be||vt===B.w.M(te)||B.u.G(Ie)):B.w.cb(te,vt))},xe==="select"){var et;B.i.subscribe(te,B.i.H,function(){et?ye.get("valueAllowUnset")?qe():Ie():(B.a.B(te,"change",Ie),et=B.o(qe,null,{l:te}))},null,{notifyImmediately:!0})}else B.a.B(te,"change",Ie),B.o(qe,null,{l:te})}else B.ib(te,{checkedValue:ce})},update:function(){}},B.m.wa.value=!0,B.c.visible={update:function(te,ce){var ye=B.a.f(ce()),xe=te.style.display!="none";ye&&!xe?te.style.display="":!ye&&xe&&(te.style.display="none")}},B.c.hidden={update:function(te,ce){B.c.visible.update(te,function(){return!B.a.f(ce())})}},function(te){B.c[te]={init:function(ce,ye,xe,ze,Ne){return B.c.event.init.call(this,ce,function(){var Ge={};return Ge[te]=ye(),Ge},xe,ze,Ne)}}}("click"),B.ca=function(){},B.ca.prototype.renderTemplateSource=function(){throw Error("Override renderTemplateSource")},B.ca.prototype.createJavaScriptEvaluatorBlock=function(){throw Error("Override createJavaScriptEvaluatorBlock")},B.ca.prototype.makeTemplateSource=function(te,ce){if(typeof te=="string"){ce=ce||c;var ye=ce.getElementById(te);if(!ye)throw Error("Cannot find template with ID "+te);return new B.C.F(ye)}if(te.nodeType==1||te.nodeType==8)return new B.C.ia(te);throw Error("Unknown template type: "+te)},B.ca.prototype.renderTemplate=function(te,ce,ye,xe){return te=this.makeTemplateSource(te,xe),this.renderTemplateSource(te,ce,ye,xe)},B.ca.prototype.isTemplateRewritten=function(te,ce){return this.allowTemplateRewriting===!1?!0:this.makeTemplateSource(te,ce).data("isRewritten")},B.ca.prototype.rewriteTemplate=function(te,ce,ye){te=this.makeTemplateSource(te,ye),ce=ce(te.text()),te.text(ce),te.data("isRewritten",!0)},B.b("templateEngine",B.ca),B.kc=function(){function te(xe,ze,Ne,Ge){xe=B.m.ac(xe);for(var Ve=B.m.Ra,Le=0;Le]*))?)*\s+)data-bind\s*=\s*(["'])([\s\S]*?)\3/gi,ye=/\x3c!--\s*ko\b\s*([\s\S]*?)\s*--\x3e/g;return{xd:function(xe,ze,Ne){ze.isTemplateRewritten(xe,Ne)||ze.rewriteTemplate(xe,function(Ge){return B.kc.Ld(Ge,ze)},Ne)},Ld:function(xe,ze){return xe.replace(ce,function(Ne,Ge,Ve,Le,Ie){return te(Ie,Ge,Ve,ze)}).replace(ye,function(Ne,Ge){return te(Ge,"","#comment",ze)})},md:function(xe,ze){return B.aa.Xb(function(Ne,Ge){var Ve=Ne.nextSibling;Ve&&Ve.nodeName.toLowerCase()===ze&&B.ib(Ve,xe,Ge)})}}}(),B.b("__tr_ambtns",B.kc.md),function(){B.C={},B.C.F=function(ye){if(this.F=ye){var xe=B.a.R(ye);this.ab=xe==="script"?1:xe==="textarea"?2:xe=="template"&&ye.content&&ye.content.nodeType===11?3:4}},B.C.F.prototype.text=function(){var ye=this.ab===1?"text":this.ab===2?"value":"innerHTML";if(arguments.length==0)return this.F[ye];var xe=arguments[0];ye==="innerHTML"?B.a.fc(this.F,xe):this.F[ye]=xe};var te=B.a.g.Z()+"_";B.C.F.prototype.data=function(ye){if(arguments.length===1)return B.a.g.get(this.F,te+ye);B.a.g.set(this.F,te+ye,arguments[1])};var ce=B.a.g.Z();B.C.F.prototype.nodes=function(){var ye=this.F;if(arguments.length==0){var xe=B.a.g.get(ye,ce)||{},ze=xe.lb||(this.ab===3?ye.content:this.ab===4?ye:t);if(!ze||xe.jd){var Ne=this.text();Ne&&Ne!==xe.bb&&(ze=B.a.Md(Ne,ye.ownerDocument),B.a.g.set(ye,ce,{lb:ze,bb:Ne,jd:!0}))}return ze}xe=arguments[0],this.ab!==t&&this.text(""),B.a.g.set(ye,ce,{lb:xe})},B.C.ia=function(ye){this.F=ye},B.C.ia.prototype=new B.C.F,B.C.ia.prototype.constructor=B.C.ia,B.C.ia.prototype.text=function(){if(arguments.length==0){var ye=B.a.g.get(this.F,ce)||{};return ye.bb===t&&ye.lb&&(ye.bb=ye.lb.innerHTML),ye.bb}B.a.g.set(this.F,ce,{bb:arguments[0]})},B.b("templateSources",B.C),B.b("templateSources.domElement",B.C.F),B.b("templateSources.anonymousTemplate",B.C.ia)}(),function(){function te(Le,Ie,qe){var et;for(Ie=B.h.nextSibling(Ie);Le&&(et=Le)!==Ie;)Le=B.h.nextSibling(et),qe(et,Le)}function ce(Le,Ie){if(Le.length){var qe=Le[0],et=Le[Le.length-1],vt=qe.parentNode,Be=B.ga.instance,dt=Be.preprocessNode;if(dt){if(te(qe,et,function(ut,Qt){var Wt=ut.previousSibling,Nt=dt.call(Be,ut);Nt&&(ut===qe&&(qe=Nt[0]||Qt),ut===et&&(et=Nt[Nt.length-1]||Wt))}),Le.length=0,!qe)return;qe===et?Le.push(qe):(Le.push(qe,et),B.a.Ua(Le,vt))}te(qe,et,function(ut){ut.nodeType!==1&&ut.nodeType!==8||B.vc(Ie,ut)}),te(qe,et,function(ut){ut.nodeType!==1&&ut.nodeType!==8||B.aa.cd(ut,[Ie])}),B.a.Ua(Le,vt)}}function ye(Le){return Le.nodeType?Le:0"u"&&(Ft=[Ft]),Nt&&(Ft=B.a.jb(Ft,function(Xt){return Xt===t||Xt===null||!B.a.f(Xt._destroy)})),Be(Ft)},null,{l:et});Be(Ie.v());var Ct=Ie.subscribe(function(Ft){Be(Ie(),Ft)},null,"arrayChange");return Ct.l(et),Ct};var Ge=B.a.g.Z(),Ve=B.a.g.Z();B.c.template={init:function(Le,Ie){var qe=B.a.f(Ie());if(typeof qe=="string"||"name"in qe)B.h.Ea(Le);else if("nodes"in qe){if(qe=qe.nodes||[],B.O(qe))throw Error('The "nodes" option must be a plain, non-observable array.');var et=qe[0]&&qe[0].parentNode;et&&B.a.g.get(et,Ve)||(et=B.a.Yb(qe),B.a.g.set(et,Ve,!0)),new B.C.ia(Le).nodes(et)}else if(qe=B.h.childNodes(Le),0"u"&&(ze=[ze]),Ge=Ge||{};var vt=B.a.g.get(xe,ce),Be=!vt,dt=[],ut=0,Qt=0,Wt=[],Nt=[],Ct=[],Ft=[],Xt=[],mi,fi=0;if(Be)B.a.D(ze,Ie);else{if(!Le||vt&&vt._countWaitingForRemove){var Gi=B.a.Mb(vt,function(ti){return ti.Aa});Le=B.a.Pb(Gi,ze,{dontLimitMoves:Ge.dontLimitMoves,sparse:!0})}for(var Gi=0,wn,Qi,Gn;wn=Le[Gi];Gi++)switch(Qi=wn.moved,Gn=wn.index,wn.status){case"deleted":for(;utB.a.W)&&te.nodes?te.nodes():null)?B.a.la(ce.cloneNode(!0).childNodes):(te=te.text(),B.a.ua(te,xe))},B.ba.Ma=new B.ba,B.gc(B.ba.Ma),B.b("nativeTemplateEngine",B.ba),function(){B.$a=function(){var ce=this.Hd=function(){if(!y||!y.tmpl)return 0;try{if(0<=y.tmpl.tag.tmpl.open.toString().indexOf("__"))return 2}catch{}return 1}();this.renderTemplateSource=function(ye,xe,ze,Ne){if(Ne=Ne||c,ze=ze||{},2>ce)throw Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.");var Ge=ye.data("precompiled");return Ge||(Ge=ye.text()||"",Ge=y.template(null,"{{ko_with $item.koBindingContext}}"+Ge+"{{/ko_with}}"),ye.data("precompiled",Ge)),ye=[xe.$data],xe=y.extend({koBindingContext:xe},ze.templateOptions),xe=y.tmpl(Ge,ye,xe),xe.appendTo(Ne.createElement("div")),y.fragments={},xe},this.createJavaScriptEvaluatorBlock=function(ye){return"{{ko_code ((function() { return "+ye+" })()) }}"},this.addTemplate=function(ye,xe){c.write("