udrone/dist/bundle.js
2022-08-18 22:40:06 +03:00

2 lines
1.3 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*! For license information please see bundle.js.LICENSE.txt */
(()=>{var e={755:function(e,t){var r;!function(t,r){"use strict";"object"==typeof e.exports?e.exports=t.document?r(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return r(e)}:r(t)}("undefined"!=typeof window?window:this,(function(i,n){"use strict";var o=[],s=Object.getPrototypeOf,a=o.slice,l=o.flat?function(e){return o.flat.call(e)}:function(e){return o.concat.apply([],e)},c=o.push,u=o.indexOf,h={},p=h.toString,d=h.hasOwnProperty,f=d.toString,m=f.call(Object),_={},g=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},y=function(e){return null!=e&&e===e.window},v=i.document,x={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,r){var i,n,o=(r=r||v).createElement("script");if(o.text=e,t)for(i in x)(n=t[i]||t.getAttribute&&t.getAttribute(i))&&o.setAttribute(i,n);r.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?h[p.call(e)]||"object":typeof e}var T="3.6.0",E=function(e,t){return new E.fn.init(e,t)};function S(e){var t=!!e&&"length"in e&&e.length,r=w(e);return!g(e)&&!y(e)&&("array"===r||0===t||"number"==typeof t&&t>0&&t-1 in e)}E.fn=E.prototype={jquery:T,constructor:E,length:0,toArray:function(){return a.call(this)},get:function(e){return null==e?a.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=E.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return E.each(this,e)},map:function(e){return this.pushStack(E.map(this,(function(t,r){return e.call(t,r,t)})))},slice:function(){return this.pushStack(a.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(E.grep(this,(function(e,t){return(t+1)%2})))},odd:function(){return this.pushStack(E.grep(this,(function(e,t){return t%2})))},eq:function(e){var t=this.length,r=+e+(e<0?t:0);return this.pushStack(r>=0&&r<t?[this[r]]:[])},end:function(){return this.prevObject||this.constructor()},push:c,sort:o.sort,splice:o.splice},E.extend=E.fn.extend=function(){var e,t,r,i,n,o,s=arguments[0]||{},a=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[a]||{},a++),"object"==typeof s||g(s)||(s={}),a===l&&(s=this,a--);a<l;a++)if(null!=(e=arguments[a]))for(t in e)i=e[t],"__proto__"!==t&&s!==i&&(c&&i&&(E.isPlainObject(i)||(n=Array.isArray(i)))?(r=s[t],o=n&&!Array.isArray(r)?[]:n||E.isPlainObject(r)?r:{},n=!1,s[t]=E.extend(c,o,i)):void 0!==i&&(s[t]=i));return s},E.extend({expando:"jQuery"+(T+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,r;return!(!e||"[object Object]"!==p.call(e)||(t=s(e))&&("function"!=typeof(r=d.call(t,"constructor")&&t.constructor)||f.call(r)!==m))},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e,t,r){b(e,{nonce:t&&t.nonce},r)},each:function(e,t){var r,i=0;if(S(e))for(r=e.length;i<r&&!1!==t.call(e[i],i,e[i]);i++);else for(i in e)if(!1===t.call(e[i],i,e[i]))break;return e},makeArray:function(e,t){var r=t||[];return null!=e&&(S(Object(e))?E.merge(r,"string"==typeof e?[e]:e):c.call(r,e)),r},inArray:function(e,t,r){return null==t?-1:u.call(t,e,r)},merge:function(e,t){for(var r=+t.length,i=0,n=e.length;i<r;i++)e[n++]=t[i];return e.length=n,e},grep:function(e,t,r){for(var i=[],n=0,o=e.length,s=!r;n<o;n++)!t(e[n],n)!==s&&i.push(e[n]);return i},map:function(e,t,r){var i,n,o=0,s=[];if(S(e))for(i=e.length;o<i;o++)null!=(n=t(e[o],o,r))&&s.push(n);else for(o in e)null!=(n=t(e[o],o,r))&&s.push(n);return l(s)},guid:1,support:_}),"function"==typeof Symbol&&(E.fn[Symbol.iterator]=o[Symbol.iterator]),E.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),(function(e,t){h["[object "+t+"]"]=t.toLowerCase()}));var C=function(e){var t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x="sizzle"+1*new Date,b=e.document,w=0,T=0,E=le(),S=le(),C=le(),A=le(),k=function(e,t){return e===t&&(h=!0),0},I={}.hasOwnProperty,M=[],z=M.pop,P=M.push,D=M.push,L=M.slice,B=function(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1},R="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",O="[\\x20\\t\\r\\n\\f]",F="(?:\\\\[\\da-fA-F]{1,6}[\\x20\\t\\r\\n\\f]?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",N="\\[[\\x20\\t\\r\\n\\f]*("+F+")(?:"+O+"*([*^$|!~]?=)"+O+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+F+"))|)"+O+"*\\]",j=":("+F+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+N+")*)|.*)\\)|)",U=new RegExp(O+"+","g"),V=new RegExp("^[\\x20\\t\\r\\n\\f]+|((?:^|[^\\\\])(?:\\\\.)*)[\\x20\\t\\r\\n\\f]+$","g"),q=new RegExp("^[\\x20\\t\\r\\n\\f]*,[\\x20\\t\\r\\n\\f]*"),G=new RegExp("^[\\x20\\t\\r\\n\\f]*([>+~]|[\\x20\\t\\r\\n\\f])[\\x20\\t\\r\\n\\f]*"),$=new RegExp(O+"|>"),Z=new RegExp(j),W=new RegExp("^"+F+"$"),H={ID:new RegExp("^#("+F+")"),CLASS:new RegExp("^\\.("+F+")"),TAG:new RegExp("^("+F+"|[*])"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+j),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\([\\x20\\t\\r\\n\\f]*(even|odd|(([+-]|)(\\d*)n|)[\\x20\\t\\r\\n\\f]*(?:([+-]|)[\\x20\\t\\r\\n\\f]*(\\d+)|))[\\x20\\t\\r\\n\\f]*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^[\\x20\\t\\r\\n\\f]*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\([\\x20\\t\\r\\n\\f]*((?:-\\d)?\\d*)[\\x20\\t\\r\\n\\f]*\\)|)(?=[^-]|$)","i")},X=/HTML$/i,Y=/^(?:input|select|textarea|button)$/i,K=/^h\d$/i,J=/^[^{]+\{\s*\[native \w/,Q=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}[\\x20\\t\\r\\n\\f]?|\\\\([^\\r\\n\\f])","g"),re=function(e,t){var r="0x"+e.slice(1)-65536;return t||(r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320))},ie=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"<22>":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){p()},se=xe((function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()}),{dir:"parentNode",next:"legend"});try{D.apply(M=L.call(b.childNodes),b.childNodes),M[b.childNodes.length].nodeType}catch(e){D={apply:M.length?function(e,t){P.apply(e,L.call(t))}:function(e,t){for(var r=e.length,i=0;e[r++]=t[i++];);e.length=r-1}}}function ae(e,t,i,n){var o,a,c,u,h,f,g,y=t&&t.ownerDocument,b=t?t.nodeType:9;if(i=i||[],"string"!=typeof e||!e||1!==b&&9!==b&&11!==b)return i;if(!n&&(p(t),t=t||d,m)){if(11!==b&&(h=Q.exec(e)))if(o=h[1]){if(9===b){if(!(c=t.getElementById(o)))return i;if(c.id===o)return i.push(c),i}else if(y&&(c=y.getElementById(o))&&v(t,c)&&c.id===o)return i.push(c),i}else{if(h[2])return D.apply(i,t.getElementsByTagName(e)),i;if((o=h[3])&&r.getElementsByClassName&&t.getElementsByClassName)return D.apply(i,t.getElementsByClassName(o)),i}if(r.qsa&&!A[e+" "]&&(!_||!_.test(e))&&(1!==b||"object"!==t.nodeName.toLowerCase())){if(g=e,y=t,1===b&&($.test(e)||G.test(e))){for((y=ee.test(e)&&ge(t.parentNode)||t)===t&&r.scope||((u=t.getAttribute("id"))?u=u.replace(ie,ne):t.setAttribute("id",u=x)),a=(f=s(e)).length;a--;)f[a]=(u?"#"+u:":scope")+" "+ve(f[a]);g=f.join(",")}try{return D.apply(i,y.querySelectorAll(g)),i}catch(t){A(e,!0)}finally{u===x&&t.removeAttribute("id")}}}return l(e.replace(V,"$1"),t,i,n)}function le(){var e=[];return function t(r,n){return e.push(r+" ")>i.cacheLength&&delete t[e.shift()],t[r+" "]=n}}function ce(e){return e[x]=!0,e}function ue(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function he(e,t){for(var r=e.split("|"),n=r.length;n--;)i.attrHandle[r[n]]=t}function pe(e,t){var r=t&&e,i=r&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(i)return i;if(r)for(;r=r.nextSibling;)if(r===t)return-1;return e?1:-1}function de(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function fe(e){return function(t){var r=t.nodeName.toLowerCase();return("input"===r||"button"===r)&&t.type===e}}function me(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&se(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function _e(e){return ce((function(t){return t=+t,ce((function(r,i){for(var n,o=e([],r.length,t),s=o.length;s--;)r[n=o[s]]&&(r[n]=!(i[n]=r[n]))}))}))}function ge(e){return e&&void 0!==e.getElementsByTagName&&e}for(t in r=ae.support={},o=ae.isXML=function(e){var t=e&&e.namespaceURI,r=e&&(e.ownerDocument||e).documentElement;return!X.test(t||r&&r.nodeName||"HTML")},p=ae.setDocument=function(e){var t,n,s=e?e.ownerDocument||e:b;return s!=d&&9===s.nodeType&&s.documentElement?(f=(d=s).documentElement,m=!o(d),b!=d&&(n=d.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),r.scope=ue((function(e){return f.appendChild(e).appendChild(d.createElement("div")),void 0!==e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length})),r.attributes=ue((function(e){return e.className="i",!e.getAttribute("className")})),r.getElementsByTagName=ue((function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length})),r.getElementsByClassName=J.test(d.getElementsByClassName),r.getById=ue((function(e){return f.appendChild(e).id=x,!d.getElementsByName||!d.getElementsByName(x).length})),r.getById?(i.filter.ID=function(e){var t=e.replace(te,re);return function(e){return e.getAttribute("id")===t}},i.find.ID=function(e,t){if(void 0!==t.getElementById&&m){var r=t.getElementById(e);return r?[r]:[]}}):(i.filter.ID=function(e){var t=e.replace(te,re);return function(e){var r=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return r&&r.value===t}},i.find.ID=function(e,t){if(void 0!==t.getElementById&&m){var r,i,n,o=t.getElementById(e);if(o){if((r=o.getAttributeNode("id"))&&r.value===e)return[o];for(n=t.getElementsByName(e),i=0;o=n[i++];)if((r=o.getAttributeNode("id"))&&r.value===e)return[o]}return[]}}),i.find.TAG=r.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):r.qsa?t.querySelectorAll(e):void 0}:function(e,t){var r,i=[],n=0,o=t.getElementsByTagName(e);if("*"===e){for(;r=o[n++];)1===r.nodeType&&i.push(r);return i}return o},i.find.CLASS=r.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&m)return t.getElementsByClassName(e)},g=[],_=[],(r.qsa=J.test(d.querySelectorAll))&&(ue((function(e){var t;f.appendChild(e).innerHTML="<a id='"+x+"'></a><select id='"+x+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&_.push("[*^$]=[\\x20\\t\\r\\n\\f]*(?:''|\"\")"),e.querySelectorAll("[selected]").length||_.push("\\[[\\x20\\t\\r\\n\\f]*(?:value|"+R+")"),e.querySelectorAll("[id~="+x+"-]").length||_.push("~="),(t=d.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||_.push("\\[[\\x20\\t\\r\\n\\f]*name[\\x20\\t\\r\\n\\f]*=[\\x20\\t\\r\\n\\f]*(?:''|\"\")"),e.querySelectorAll(":checked").length||_.push(":checked"),e.querySelectorAll("a#"+x+"+*").length||_.push(".#.+[+~]"),e.querySelectorAll("\\\f"),_.push("[\\r\\n\\f]")})),ue((function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&_.push("name[\\x20\\t\\r\\n\\f]*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&_.push(":enabled",":disabled"),f.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&_.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),_.push(",.*:")}))),(r.matchesSelector=J.test(y=f.matches||f.webkitMatchesSelector||f.mozMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&ue((function(e){r.disconnectedMatch=y.call(e,"*"),y.call(e,"[s!='']:x"),g.push("!=",j)})),_=_.length&&new RegExp(_.join("|")),g=g.length&&new RegExp(g.join("|")),t=J.test(f.compareDocumentPosition),v=t||J.test(f.contains)?function(e,t){var r=9===e.nodeType?e.documentElement:e,i=t&&t.parentNode;return e===i||!(!i||1!==i.nodeType||!(r.contains?r.contains(i):e.compareDocumentPosition&&16&e.compareDocumentPosition(i)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},k=t?function(e,t){if(e===t)return h=!0,0;var i=!e.compareDocumentPosition-!t.compareDocumentPosition;return i||(1&(i=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!r.sortDetached&&t.compareDocumentPosition(e)===i?e==d||e.ownerDocument==b&&v(b,e)?-1:t==d||t.ownerDocument==b&&v(b,t)?1:u?B(u,e)-B(u,t):0:4&i?-1:1)}:function(e,t){if(e===t)return h=!0,0;var r,i=0,n=e.parentNode,o=t.parentNode,s=[e],a=[t];if(!n||!o)return e==d?-1:t==d?1:n?-1:o?1:u?B(u,e)-B(u,t):0;if(n===o)return pe(e,t);for(r=e;r=r.parentNode;)s.unshift(r);for(r=t;r=r.parentNode;)a.unshift(r);for(;s[i]===a[i];)i++;return i?pe(s[i],a[i]):s[i]==b?-1:a[i]==b?1:0},d):d},ae.matches=function(e,t){return ae(e,null,null,t)},ae.matchesSelector=function(e,t){if(p(e),r.matchesSelector&&m&&!A[t+" "]&&(!g||!g.test(t))&&(!_||!_.test(t)))try{var i=y.call(e,t);if(i||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return i}catch(e){A(t,!0)}return ae(t,d,null,[e]).length>0},ae.contains=function(e,t){return(e.ownerDocument||e)!=d&&p(e),v(e,t)},ae.attr=function(e,t){(e.ownerDocument||e)!=d&&p(e);var n=i.attrHandle[t.toLowerCase()],o=n&&I.call(i.attrHandle,t.toLowerCase())?n(e,t,!m):void 0;return void 0!==o?o:r.attributes||!m?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},ae.escape=function(e){return(e+"").replace(ie,ne)},ae.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},ae.uniqueSort=function(e){var t,i=[],n=0,o=0;if(h=!r.detectDuplicates,u=!r.sortStable&&e.slice(0),e.sort(k),h){for(;t=e[o++];)t===e[o]&&(n=i.push(o));for(;n--;)e.splice(i[n],1)}return u=null,e},n=ae.getText=function(e){var t,r="",i=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)r+=n(e)}else if(3===o||4===o)return e.nodeValue}else for(;t=e[i++];)r+=n(t);return r},i=ae.selectors={cacheLength:50,createPseudo:ce,match:H,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,re),e[3]=(e[3]||e[4]||e[5]||"").replace(te,re),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||ae.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&ae.error(e[0]),e},PSEUDO:function(e){var t,r=!e[6]&&e[2];return H.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":r&&Z.test(r)&&(t=s(r,!0))&&(t=r.indexOf(")",r.length-t)-r.length)&&(e[0]=e[0].slice(0,t),e[2]=r.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,re).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|[\\x20\\t\\r\\n\\f])"+e+"("+O+"|$)"))&&E(e,(function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")}))},ATTR:function(e,t,r){return function(i){var n=ae.attr(i,e);return null==n?"!="===t:!t||(n+="","="===t?n===r:"!="===t?n!==r:"^="===t?r&&0===n.indexOf(r):"*="===t?r&&n.indexOf(r)>-1:"$="===t?r&&n.slice(-r.length)===r:"~="===t?(" "+n.replace(U," ")+" ").indexOf(r)>-1:"|="===t&&(n===r||n.slice(0,r.length+1)===r+"-"))}},CHILD:function(e,t,r,i,n){var o="nth"!==e.slice(0,3),s="last"!==e.slice(-4),a="of-type"===t;return 1===i&&0===n?function(e){return!!e.parentNode}:function(t,r,l){var c,u,h,p,d,f,m=o!==s?"nextSibling":"previousSibling",_=t.parentNode,g=a&&t.nodeName.toLowerCase(),y=!l&&!a,v=!1;if(_){if(o){for(;m;){for(p=t;p=p[m];)if(a?p.nodeName.toLowerCase()===g:1===p.nodeType)return!1;f=m="only"===e&&!f&&"nextSibling"}return!0}if(f=[s?_.firstChild:_.lastChild],s&&y){for(v=(d=(c=(u=(h=(p=_)[x]||(p[x]={}))[p.uniqueID]||(h[p.uniqueID]={}))[e]||[])[0]===w&&c[1])&&c[2],p=d&&_.childNodes[d];p=++d&&p&&p[m]||(v=d=0)||f.pop();)if(1===p.nodeType&&++v&&p===t){u[e]=[w,d,v];break}}else if(y&&(v=d=(c=(u=(h=(p=t)[x]||(p[x]={}))[p.uniqueID]||(h[p.uniqueID]={}))[e]||[])[0]===w&&c[1]),!1===v)for(;(p=++d&&p&&p[m]||(v=d=0)||f.pop())&&((a?p.nodeName.toLowerCase()!==g:1!==p.nodeType)||!++v||(y&&((u=(h=p[x]||(p[x]={}))[p.uniqueID]||(h[p.uniqueID]={}))[e]=[w,v]),p!==t)););return(v-=n)===i||v%i==0&&v/i>=0}}},PSEUDO:function(e,t){var r,n=i.pseudos[e]||i.setFilters[e.toLowerCase()]||ae.error("unsupported pseudo: "+e);return n[x]?n(t):n.length>1?(r=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ce((function(e,r){for(var i,o=n(e,t),s=o.length;s--;)e[i=B(e,o[s])]=!(r[i]=o[s])})):function(e){return n(e,0,r)}):n}},pseudos:{not:ce((function(e){var t=[],r=[],i=a(e.replace(V,"$1"));return i[x]?ce((function(e,t,r,n){for(var o,s=i(e,null,n,[]),a=e.length;a--;)(o=s[a])&&(e[a]=!(t[a]=o))})):function(e,n,o){return t[0]=e,i(t,null,o,r),t[0]=null,!r.pop()}})),has:ce((function(e){return function(t){return ae(e,t).length>0}})),contains:ce((function(e){return e=e.replace(te,re),function(t){return(t.textContent||n(t)).indexOf(e)>-1}})),lang:ce((function(e){return W.test(e||"")||ae.error("unsupported lang: "+e),e=e.replace(te,re).toLowerCase(),function(t){var r;do{if(r=m?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(r=r.toLowerCase())===e||0===r.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}})),target:function(t){var r=e.location&&e.location.hash;return r&&r.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:me(!1),disabled:me(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return K.test(e.nodeName)},input:function(e){return Y.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:_e((function(){return[0]})),last:_e((function(e,t){return[t-1]})),eq:_e((function(e,t,r){return[r<0?r+t:r]})),even:_e((function(e,t){for(var r=0;r<t;r+=2)e.push(r);return e})),odd:_e((function(e,t){for(var r=1;r<t;r+=2)e.push(r);return e})),lt:_e((function(e,t,r){for(var i=r<0?r+t:r>t?t:r;--i>=0;)e.push(i);return e})),gt:_e((function(e,t,r){for(var i=r<0?r+t:r;++i<t;)e.push(i);return e}))}},i.pseudos.nth=i.pseudos.eq,{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})i.pseudos[t]=de(t);for(t in{submit:!0,reset:!0})i.pseudos[t]=fe(t);function ye(){}function ve(e){for(var t=0,r=e.length,i="";t<r;t++)i+=e[t].value;return i}function xe(e,t,r){var i=t.dir,n=t.next,o=n||i,s=r&&"parentNode"===o,a=T++;return t.first?function(t,r,n){for(;t=t[i];)if(1===t.nodeType||s)return e(t,r,n);return!1}:function(t,r,l){var c,u,h,p=[w,a];if(l){for(;t=t[i];)if((1===t.nodeType||s)&&e(t,r,l))return!0}else for(;t=t[i];)if(1===t.nodeType||s)if(u=(h=t[x]||(t[x]={}))[t.uniqueID]||(h[t.uniqueID]={}),n&&n===t.nodeName.toLowerCase())t=t[i]||t;else{if((c=u[o])&&c[0]===w&&c[1]===a)return p[2]=c[2];if(u[o]=p,p[2]=e(t,r,l))return!0}return!1}}function be(e){return e.length>1?function(t,r,i){for(var n=e.length;n--;)if(!e[n](t,r,i))return!1;return!0}:e[0]}function we(e,t,r,i,n){for(var o,s=[],a=0,l=e.length,c=null!=t;a<l;a++)(o=e[a])&&(r&&!r(o,i,n)||(s.push(o),c&&t.push(a)));return s}function Te(e,t,r,i,n,o){return i&&!i[x]&&(i=Te(i)),n&&!n[x]&&(n=Te(n,o)),ce((function(o,s,a,l){var c,u,h,p=[],d=[],f=s.length,m=o||function(e,t,r){for(var i=0,n=t.length;i<n;i++)ae(e,t[i],r);return r}(t||"*",a.nodeType?[a]:a,[]),_=!e||!o&&t?m:we(m,p,e,a,l),g=r?n||(o?e:f||i)?[]:s:_;if(r&&r(_,g,a,l),i)for(c=we(g,d),i(c,[],a,l),u=c.length;u--;)(h=c[u])&&(g[d[u]]=!(_[d[u]]=h));if(o){if(n||e){if(n){for(c=[],u=g.length;u--;)(h=g[u])&&c.push(_[u]=h);n(null,g=[],c,l)}for(u=g.length;u--;)(h=g[u])&&(c=n?B(o,h):p[u])>-1&&(o[c]=!(s[c]=h))}}else g=we(g===s?g.splice(f,g.length):g),n?n(null,s,g,l):D.apply(s,g)}))}function Ee(e){for(var t,r,n,o=e.length,s=i.relative[e[0].type],a=s||i.relative[" "],l=s?1:0,u=xe((function(e){return e===t}),a,!0),h=xe((function(e){return B(t,e)>-1}),a,!0),p=[function(e,r,i){var n=!s&&(i||r!==c)||((t=r).nodeType?u(e,r,i):h(e,r,i));return t=null,n}];l<o;l++)if(r=i.relative[e[l].type])p=[xe(be(p),r)];else{if((r=i.filter[e[l].type].apply(null,e[l].matches))[x]){for(n=++l;n<o&&!i.relative[e[n].type];n++);return Te(l>1&&be(p),l>1&&ve(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(V,"$1"),r,l<n&&Ee(e.slice(l,n)),n<o&&Ee(e=e.slice(n)),n<o&&ve(e))}p.push(r)}return be(p)}return ye.prototype=i.filters=i.pseudos,i.setFilters=new ye,s=ae.tokenize=function(e,t){var r,n,o,s,a,l,c,u=S[e+" "];if(u)return t?0:u.slice(0);for(a=e,l=[],c=i.preFilter;a;){for(s in r&&!(n=q.exec(a))||(n&&(a=a.slice(n[0].length)||a),l.push(o=[])),r=!1,(n=G.exec(a))&&(r=n.shift(),o.push({value:r,type:n[0].replace(V," ")}),a=a.slice(r.length)),i.filter)!(n=H[s].exec(a))||c[s]&&!(n=c[s](n))||(r=n.shift(),o.push({value:r,type:s,matches:n}),a=a.slice(r.length));if(!r)break}return t?a.length:a?ae.error(e):S(e,l).slice(0)},a=ae.compile=function(e,t){var r,n=[],o=[],a=C[e+" "];if(!a){for(t||(t=s(e)),r=t.length;r--;)(a=Ee(t[r]))[x]?n.push(a):o.push(a);a=C(e,function(e,t){var r=t.length>0,n=e.length>0,o=function(o,s,a,l,u){var h,f,_,g=0,y="0",v=o&&[],x=[],b=c,T=o||n&&i.find.TAG("*",u),E=w+=null==b?1:Math.random()||.1,S=T.length;for(u&&(c=s==d||s||u);y!==S&&null!=(h=T[y]);y++){if(n&&h){for(f=0,s||h.ownerDocument==d||(p(h),a=!m);_=e[f++];)if(_(h,s||d,a)){l.push(h);break}u&&(w=E)}r&&((h=!_&&h)&&g--,o&&v.push(h))}if(g+=y,r&&y!==g){for(f=0;_=t[f++];)_(v,x,s,a);if(o){if(g>0)for(;y--;)v[y]||x[y]||(x[y]=z.call(l));x=we(x)}D.apply(l,x),u&&!o&&x.length>0&&g+t.length>1&&ae.uniqueSort(l)}return u&&(w=E,c=b),v};return r?ce(o):o}(o,n)),a.selector=e}return a},l=ae.select=function(e,t,r,n){var o,l,c,u,h,p="function"==typeof e&&e,d=!n&&s(e=p.selector||e);if(r=r||[],1===d.length){if((l=d[0]=d[0].slice(0)).length>2&&"ID"===(c=l[0]).type&&9===t.nodeType&&m&&i.relative[l[1].type]){if(!(t=(i.find.ID(c.matches[0].replace(te,re),t)||[])[0]))return r;p&&(t=t.parentNode),e=e.slice(l.shift().value.length)}for(o=H.needsContext.test(e)?0:l.length;o--&&(c=l[o],!i.relative[u=c.type]);)if((h=i.find[u])&&(n=h(c.matches[0].replace(te,re),ee.test(l[0].type)&&ge(t.parentNode)||t))){if(l.splice(o,1),!(e=n.length&&ve(l)))return D.apply(r,n),r;break}}return(p||a(e,d))(n,t,!m,r,!t||ee.test(e)&&ge(t.parentNode)||t),r},r.sortStable=x.split("").sort(k).join("")===x,r.detectDuplicates=!!h,p(),r.sortDetached=ue((function(e){return 1&e.compareDocumentPosition(d.createElement("fieldset"))})),ue((function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")}))||he("type|href|height|width",(function(e,t,r){if(!r)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)})),r.attributes&&ue((function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")}))||he("value",(function(e,t,r){if(!r&&"input"===e.nodeName.toLowerCase())return e.defaultValue})),ue((function(e){return null==e.getAttribute("disabled")}))||he(R,(function(e,t,r){var i;if(!r)return!0===e[t]?t.toLowerCase():(i=e.getAttributeNode(t))&&i.specified?i.value:null})),ae}(i);E.find=C,E.expr=C.selectors,E.expr[":"]=E.expr.pseudos,E.uniqueSort=E.unique=C.uniqueSort,E.text=C.getText,E.isXMLDoc=C.isXML,E.contains=C.contains,E.escapeSelector=C.escape;var A=function(e,t,r){for(var i=[],n=void 0!==r;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(n&&E(e).is(r))break;i.push(e)}return i},k=function(e,t){for(var r=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&r.push(e);return r},I=E.expr.match.needsContext;function M(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var z=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function P(e,t,r){return g(t)?E.grep(e,(function(e,i){return!!t.call(e,i,e)!==r})):t.nodeType?E.grep(e,(function(e){return e===t!==r})):"string"!=typeof t?E.grep(e,(function(e){return u.call(t,e)>-1!==r})):E.filter(t,e,r)}E.filter=function(e,t,r){var i=t[0];return r&&(e=":not("+e+")"),1===t.length&&1===i.nodeType?E.find.matchesSelector(i,e)?[i]:[]:E.find.matches(e,E.grep(t,(function(e){return 1===e.nodeType})))},E.fn.extend({find:function(e){var t,r,i=this.length,n=this;if("string"!=typeof e)return this.pushStack(E(e).filter((function(){for(t=0;t<i;t++)if(E.contains(n[t],this))return!0})));for(r=this.pushStack([]),t=0;t<i;t++)E.find(e,n[t],r);return i>1?E.uniqueSort(r):r},filter:function(e){return this.pushStack(P(this,e||[],!1))},not:function(e){return this.pushStack(P(this,e||[],!0))},is:function(e){return!!P(this,"string"==typeof e&&I.test(e)?E(e):e||[],!1).length}});var D,L=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(E.fn.init=function(e,t,r){var i,n;if(!e)return this;if(r=r||D,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:L.exec(e))||!i[1]&&t)return!t||t.jquery?(t||r).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof E?t[0]:t,E.merge(this,E.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:v,!0)),z.test(i[1])&&E.isPlainObject(t))for(i in t)g(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(n=v.getElementById(i[2]))&&(this[0]=n,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):g(e)?void 0!==r.ready?r.ready(e):e(E):E.makeArray(e,this)}).prototype=E.fn,D=E(v);var B=/^(?:parents|prev(?:Until|All))/,R={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}E.fn.extend({has:function(e){var t=E(e,this),r=t.length;return this.filter((function(){for(var e=0;e<r;e++)if(E.contains(this,t[e]))return!0}))},closest:function(e,t){var r,i=0,n=this.length,o=[],s="string"!=typeof e&&E(e);if(!I.test(e))for(;i<n;i++)for(r=this[i];r&&r!==t;r=r.parentNode)if(r.nodeType<11&&(s?s.index(r)>-1:1===r.nodeType&&E.find.matchesSelector(r,e))){o.push(r);break}return this.pushStack(o.length>1?E.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(E(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(E.uniqueSort(E.merge(this.get(),E(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),E.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return A(e,"parentNode")},parentsUntil:function(e,t,r){return A(e,"parentNode",r)},next:function(e){return O(e,"nextSibling")},prev:function(e){return O(e,"previousSibling")},nextAll:function(e){return A(e,"nextSibling")},prevAll:function(e){return A(e,"previousSibling")},nextUntil:function(e,t,r){return A(e,"nextSibling",r)},prevUntil:function(e,t,r){return A(e,"previousSibling",r)},siblings:function(e){return k((e.parentNode||{}).firstChild,e)},children:function(e){return k(e.firstChild)},contents:function(e){return null!=e.contentDocument&&s(e.contentDocument)?e.contentDocument:(M(e,"template")&&(e=e.content||e),E.merge([],e.childNodes))}},(function(e,t){E.fn[e]=function(r,i){var n=E.map(this,t,r);return"Until"!==e.slice(-5)&&(i=r),i&&"string"==typeof i&&(n=E.filter(i,n)),this.length>1&&(R[e]||E.uniqueSort(n),B.test(e)&&n.reverse()),this.pushStack(n)}}));var F=/[^\x20\t\r\n\f]+/g;function N(e){return e}function j(e){throw e}function U(e,t,r,i){var n;try{e&&g(n=e.promise)?n.call(e).done(t).fail(r):e&&g(n=e.then)?n.call(e,t,r):t.apply(void 0,[e].slice(i))}catch(e){r.apply(void 0,[e])}}E.Callbacks=function(e){e="string"==typeof e?function(e){var t={};return E.each(e.match(F)||[],(function(e,r){t[r]=!0})),t}(e):E.extend({},e);var t,r,i,n,o=[],s=[],a=-1,l=function(){for(n=n||e.once,i=t=!0;s.length;a=-1)for(r=s.shift();++a<o.length;)!1===o[a].apply(r[0],r[1])&&e.stopOnFalse&&(a=o.length,r=!1);e.memory||(r=!1),t=!1,n&&(o=r?[]:"")},c={add:function(){return o&&(r&&!t&&(a=o.length-1,s.push(r)),function t(r){E.each(r,(function(r,i){g(i)?e.unique&&c.has(i)||o.push(i):i&&i.length&&"string"!==w(i)&&t(i)}))}(arguments),r&&!t&&l()),this},remove:function(){return E.each(arguments,(function(e,t){for(var r;(r=E.inArray(t,o,r))>-1;)o.splice(r,1),r<=a&&a--})),this},has:function(e){return e?E.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return n=s=[],o=r="",this},disabled:function(){return!o},lock:function(){return n=s=[],r||t||(o=r=""),this},locked:function(){return!!n},fireWith:function(e,r){return n||(r=[e,(r=r||[]).slice?r.slice():r],s.push(r),t||l()),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!i}};return c},E.extend({Deferred:function(e){var t=[["notify","progress",E.Callbacks("memory"),E.Callbacks("memory"),2],["resolve","done",E.Callbacks("once memory"),E.Callbacks("once memory"),0,"resolved"],["reject","fail",E.Callbacks("once memory"),E.Callbacks("once memory"),1,"rejected"]],r="pending",n={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},catch:function(e){return n.then(null,e)},pipe:function(){var e=arguments;return E.Deferred((function(r){E.each(t,(function(t,i){var n=g(e[i[4]])&&e[i[4]];o[i[1]]((function(){var e=n&&n.apply(this,arguments);e&&g(e.promise)?e.promise().progress(r.notify).done(r.resolve).fail(r.reject):r[i[0]+"With"](this,n?[e]:arguments)}))})),e=null})).promise()},then:function(e,r,n){var o=0;function s(e,t,r,n){return function(){var a=this,l=arguments,c=function(){var i,c;if(!(e<o)){if((i=r.apply(a,l))===t.promise())throw new TypeError("Thenable self-resolution");c=i&&("object"==typeof i||"function"==typeof i)&&i.then,g(c)?n?c.call(i,s(o,t,N,n),s(o,t,j,n)):(o++,c.call(i,s(o,t,N,n),s(o,t,j,n),s(o,t,N,t.notifyWith))):(r!==N&&(a=void 0,l=[i]),(n||t.resolveWith)(a,l))}},u=n?c:function(){try{c()}catch(i){E.Deferred.exceptionHook&&E.Deferred.exceptionHook(i,u.stackTrace),e+1>=o&&(r!==j&&(a=void 0,l=[i]),t.rejectWith(a,l))}};e?u():(E.Deferred.getStackHook&&(u.stackTrace=E.Deferred.getStackHook()),i.setTimeout(u))}}return E.Deferred((function(i){t[0][3].add(s(0,i,g(n)?n:N,i.notifyWith)),t[1][3].add(s(0,i,g(e)?e:N)),t[2][3].add(s(0,i,g(r)?r:j))})).promise()},promise:function(e){return null!=e?E.extend(e,n):n}},o={};return E.each(t,(function(e,i){var s=i[2],a=i[5];n[i[1]]=s.add,a&&s.add((function(){r=a}),t[3-e][2].disable,t[3-e][3].disable,t[0][2].lock,t[0][3].lock),s.add(i[3].fire),o[i[0]]=function(){return o[i[0]+"With"](this===o?void 0:this,arguments),this},o[i[0]+"With"]=s.fireWith})),n.promise(o),e&&e.call(o,o),o},when:function(e){var t=arguments.length,r=t,i=Array(r),n=a.call(arguments),o=E.Deferred(),s=function(e){return function(r){i[e]=this,n[e]=arguments.length>1?a.call(arguments):r,--t||o.resolveWith(i,n)}};if(t<=1&&(U(e,o.done(s(r)).resolve,o.reject,!t),"pending"===o.state()||g(n[r]&&n[r].then)))return o.then();for(;r--;)U(n[r],s(r),o.reject);return o.promise()}});var V=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;E.Deferred.exceptionHook=function(e,t){i.console&&i.console.warn&&e&&V.test(e.name)&&i.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},E.readyException=function(e){i.setTimeout((function(){throw e}))};var q=E.Deferred();function G(){v.removeEventListener("DOMContentLoaded",G),i.removeEventListener("load",G),E.ready()}E.fn.ready=function(e){return q.then(e).catch((function(e){E.readyException(e)})),this},E.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--E.readyWait:E.isReady)||(E.isReady=!0,!0!==e&&--E.readyWait>0||q.resolveWith(v,[E]))}}),E.ready.then=q.then,"complete"===v.readyState||"loading"!==v.readyState&&!v.documentElement.doScroll?i.setTimeout(E.ready):(v.addEventListener("DOMContentLoaded",G),i.addEventListener("load",G));var $=function(e,t,r,i,n,o,s){var a=0,l=e.length,c=null==r;if("object"===w(r))for(a in n=!0,r)$(e,t,a,r[a],!0,o,s);else if(void 0!==i&&(n=!0,g(i)||(s=!0),c&&(s?(t.call(e,i),t=null):(c=t,t=function(e,t,r){return c.call(E(e),r)})),t))for(;a<l;a++)t(e[a],r,s?i:i.call(e[a],a,t(e[a],r)));return n?e:c?t.call(e):l?t(e[0],r):o},Z=/^-ms-/,W=/-([a-z])/g;function H(e,t){return t.toUpperCase()}function X(e){return e.replace(Z,"ms-").replace(W,H)}var Y=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function K(){this.expando=E.expando+K.uid++}K.uid=1,K.prototype={cache:function(e){var t=e[this.expando];return t||(t={},Y(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,r){var i,n=this.cache(e);if("string"==typeof t)n[X(t)]=r;else for(i in t)n[X(i)]=t[i];return n},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][X(t)]},access:function(e,t,r){return void 0===t||t&&"string"==typeof t&&void 0===r?this.get(e,t):(this.set(e,t,r),void 0!==r?r:t)},remove:function(e,t){var r,i=e[this.expando];if(void 0!==i){if(void 0!==t){r=(t=Array.isArray(t)?t.map(X):(t=X(t))in i?[t]:t.match(F)||[]).length;for(;r--;)delete i[t[r]]}(void 0===t||E.isEmptyObject(i))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!E.isEmptyObject(t)}};var J=new K,Q=new K,ee=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,te=/[A-Z]/g;function re(e,t,r){var i;if(void 0===r&&1===e.nodeType)if(i="data-"+t.replace(te,"-$&").toLowerCase(),"string"==typeof(r=e.getAttribute(i))){try{r=function(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:ee.test(e)?JSON.parse(e):e)}(r)}catch(e){}Q.set(e,t,r)}else r=void 0;return r}E.extend({hasData:function(e){return Q.hasData(e)||J.hasData(e)},data:function(e,t,r){return Q.access(e,t,r)},removeData:function(e,t){Q.remove(e,t)},_data:function(e,t,r){return J.access(e,t,r)},_removeData:function(e,t){J.remove(e,t)}}),E.fn.extend({data:function(e,t){var r,i,n,o=this[0],s=o&&o.attributes;if(void 0===e){if(this.length&&(n=Q.get(o),1===o.nodeType&&!J.get(o,"hasDataAttrs"))){for(r=s.length;r--;)s[r]&&0===(i=s[r].name).indexOf("data-")&&(i=X(i.slice(5)),re(o,i,n[i]));J.set(o,"hasDataAttrs",!0)}return n}return"object"==typeof e?this.each((function(){Q.set(this,e)})):$(this,(function(t){var r;if(o&&void 0===t)return void 0!==(r=Q.get(o,e))||void 0!==(r=re(o,e))?r:void 0;this.each((function(){Q.set(this,e,t)}))}),null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each((function(){Q.remove(this,e)}))}}),E.extend({queue:function(e,t,r){var i;if(e)return t=(t||"fx")+"queue",i=J.get(e,t),r&&(!i||Array.isArray(r)?i=J.access(e,t,E.makeArray(r)):i.push(r)),i||[]},dequeue:function(e,t){t=t||"fx";var r=E.queue(e,t),i=r.length,n=r.shift(),o=E._queueHooks(e,t);"inprogress"===n&&(n=r.shift(),i--),n&&("fx"===t&&r.unshift("inprogress"),delete o.stop,n.call(e,(function(){E.dequeue(e,t)}),o)),!i&&o&&o.empty.fire()},_queueHooks:function(e,t){var r=t+"queueHooks";return J.get(e,r)||J.access(e,r,{empty:E.Callbacks("once memory").add((function(){J.remove(e,[t+"queue",r])}))})}}),E.fn.extend({queue:function(e,t){var r=2;return"string"!=typeof e&&(t=e,e="fx",r--),arguments.length<r?E.queue(this[0],e):void 0===t?this:this.each((function(){var r=E.queue(this,e,t);E._queueHooks(this,e),"fx"===e&&"inprogress"!==r[0]&&E.dequeue(this,e)}))},dequeue:function(e){return this.each((function(){E.dequeue(this,e)}))},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var r,i=1,n=E.Deferred(),o=this,s=this.length,a=function(){--i||n.resolveWith(o,[o])};for("string"!=typeof e&&(t=e,e=void 0),e=e||"fx";s--;)(r=J.get(o[s],e+"queueHooks"))&&r.empty&&(i++,r.empty.add(a));return a(),n.promise(t)}});var ie=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ne=new RegExp("^(?:([+-])=|)("+ie+")([a-z%]*)$","i"),oe=["Top","Right","Bottom","Left"],se=v.documentElement,ae=function(e){return E.contains(e.ownerDocument,e)},le={composed:!0};se.getRootNode&&(ae=function(e){return E.contains(e.ownerDocument,e)||e.getRootNode(le)===e.ownerDocument});var ce=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&ae(e)&&"none"===E.css(e,"display")};function ue(e,t,r,i){var n,o,s=20,a=i?function(){return i.cur()}:function(){return E.css(e,t,"")},l=a(),c=r&&r[3]||(E.cssNumber[t]?"":"px"),u=e.nodeType&&(E.cssNumber[t]||"px"!==c&&+l)&&ne.exec(E.css(e,t));if(u&&u[3]!==c){for(l/=2,c=c||u[3],u=+l||1;s--;)E.style(e,t,u+c),(1-o)*(1-(o=a()/l||.5))<=0&&(s=0),u/=o;u*=2,E.style(e,t,u+c),r=r||[]}return r&&(u=+u||+l||0,n=r[1]?u+(r[1]+1)*r[2]:+r[2],i&&(i.unit=c,i.start=u,i.end=n)),n}var he={};function pe(e){var t,r=e.ownerDocument,i=e.nodeName,n=he[i];return n||(t=r.body.appendChild(r.createElement(i)),n=E.css(t,"display"),t.parentNode.removeChild(t),"none"===n&&(n="block"),he[i]=n,n)}function de(e,t){for(var r,i,n=[],o=0,s=e.length;o<s;o++)(i=e[o]).style&&(r=i.style.display,t?("none"===r&&(n[o]=J.get(i,"display")||null,n[o]||(i.style.display="")),""===i.style.display&&ce(i)&&(n[o]=pe(i))):"none"!==r&&(n[o]="none",J.set(i,"display",r)));for(o=0;o<s;o++)null!=n[o]&&(e[o].style.display=n[o]);return e}E.fn.extend({show:function(){return de(this,!0)},hide:function(){return de(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each((function(){ce(this)?E(this).show():E(this).hide()}))}});var fe,me,_e=/^(?:checkbox|radio)$/i,ge=/<([a-z][^\/\0>\x20\t\r\n\f]*)/i,ye=/^$|^module$|\/(?:java|ecma)script/i;fe=v.createDocumentFragment().appendChild(v.createElement("div")),(me=v.createElement("input")).setAttribute("type","radio"),me.setAttribute("checked","checked"),me.setAttribute("name","t"),fe.appendChild(me),_.checkClone=fe.cloneNode(!0).cloneNode(!0).lastChild.checked,fe.innerHTML="<textarea>x</textarea>",_.noCloneChecked=!!fe.cloneNode(!0).lastChild.defaultValue,fe.innerHTML="<option></option>",_.option=!!fe.lastChild;var ve={thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};function xe(e,t){var r;return r=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&M(e,t)?E.merge([e],r):r}function be(e,t){for(var r=0,i=e.length;r<i;r++)J.set(e[r],"globalEval",!t||J.get(t[r],"globalEval"))}ve.tbody=ve.tfoot=ve.colgroup=ve.caption=ve.thead,ve.th=ve.td,_.option||(ve.optgroup=ve.option=[1,"<select multiple='multiple'>","</select>"]);var we=/<|&#?\w+;/;function Te(e,t,r,i,n){for(var o,s,a,l,c,u,h=t.createDocumentFragment(),p=[],d=0,f=e.length;d<f;d++)if((o=e[d])||0===o)if("object"===w(o))E.merge(p,o.nodeType?[o]:o);else if(we.test(o)){for(s=s||h.appendChild(t.createElement("div")),a=(ge.exec(o)||["",""])[1].toLowerCase(),l=ve[a]||ve._default,s.innerHTML=l[1]+E.htmlPrefilter(o)+l[2],u=l[0];u--;)s=s.lastChild;E.merge(p,s.childNodes),(s=h.firstChild).textContent=""}else p.push(t.createTextNode(o));for(h.textContent="",d=0;o=p[d++];)if(i&&E.inArray(o,i)>-1)n&&n.push(o);else if(c=ae(o),s=xe(h.appendChild(o),"script"),c&&be(s),r)for(u=0;o=s[u++];)ye.test(o.type||"")&&r.push(o);return h}var Ee=/^([^.]*)(?:\.(.+)|)/;function Se(){return!0}function Ce(){return!1}function Ae(e,t){return e===function(){try{return v.activeElement}catch(e){}}()==("focus"===t)}function ke(e,t,r,i,n,o){var s,a;if("object"==typeof t){for(a in"string"!=typeof r&&(i=i||r,r=void 0),t)ke(e,a,r,i,t[a],o);return e}if(null==i&&null==n?(n=r,i=r=void 0):null==n&&("string"==typeof r?(n=i,i=void 0):(n=i,i=r,r=void 0)),!1===n)n=Ce;else if(!n)return e;return 1===o&&(s=n,n=function(e){return E().off(e),s.apply(this,arguments)},n.guid=s.guid||(s.guid=E.guid++)),e.each((function(){E.event.add(this,t,n,i,r)}))}function Ie(e,t,r){r?(J.set(e,t,!1),E.event.add(e,t,{namespace:!1,handler:function(e){var i,n,o=J.get(this,t);if(1&e.isTrigger&&this[t]){if(o.length)(E.event.special[t]||{}).delegateType&&e.stopPropagation();else if(o=a.call(arguments),J.set(this,t,o),i=r(this,t),this[t](),o!==(n=J.get(this,t))||i?J.set(this,t,!1):n={},o!==n)return e.stopImmediatePropagation(),e.preventDefault(),n&&n.value}else o.length&&(J.set(this,t,{value:E.event.trigger(E.extend(o[0],E.Event.prototype),o.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===J.get(e,t)&&E.event.add(e,t,Se)}E.event={global:{},add:function(e,t,r,i,n){var o,s,a,l,c,u,h,p,d,f,m,_=J.get(e);if(Y(e))for(r.handler&&(r=(o=r).handler,n=o.selector),n&&E.find.matchesSelector(se,n),r.guid||(r.guid=E.guid++),(l=_.events)||(l=_.events=Object.create(null)),(s=_.handle)||(s=_.handle=function(t){return void 0!==E&&E.event.triggered!==t.type?E.event.dispatch.apply(e,arguments):void 0}),c=(t=(t||"").match(F)||[""]).length;c--;)d=m=(a=Ee.exec(t[c])||[])[1],f=(a[2]||"").split(".").sort(),d&&(h=E.event.special[d]||{},d=(n?h.delegateType:h.bindType)||d,h=E.event.special[d]||{},u=E.extend({type:d,origType:m,data:i,handler:r,guid:r.guid,selector:n,needsContext:n&&E.expr.match.needsContext.test(n),namespace:f.join(".")},o),(p=l[d])||((p=l[d]=[]).delegateCount=0,h.setup&&!1!==h.setup.call(e,i,f,s)||e.addEventListener&&e.addEventListener(d,s)),h.add&&(h.add.call(e,u),u.handler.guid||(u.handler.guid=r.guid)),n?p.splice(p.delegateCount++,0,u):p.push(u),E.event.global[d]=!0)},remove:function(e,t,r,i,n){var o,s,a,l,c,u,h,p,d,f,m,_=J.hasData(e)&&J.get(e);if(_&&(l=_.events)){for(c=(t=(t||"").match(F)||[""]).length;c--;)if(d=m=(a=Ee.exec(t[c])||[])[1],f=(a[2]||"").split(".").sort(),d){for(h=E.event.special[d]||{},p=l[d=(i?h.delegateType:h.bindType)||d]||[],a=a[2]&&new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=o=p.length;o--;)u=p[o],!n&&m!==u.origType||r&&r.guid!==u.guid||a&&!a.test(u.namespace)||i&&i!==u.selector&&("**"!==i||!u.selector)||(p.splice(o,1),u.selector&&p.delegateCount--,h.remove&&h.remove.call(e,u));s&&!p.length&&(h.teardown&&!1!==h.teardown.call(e,f,_.handle)||E.removeEvent(e,d,_.handle),delete l[d])}else for(d in l)E.event.remove(e,d+t[c],r,i,!0);E.isEmptyObject(l)&&J.remove(e,"handle events")}},dispatch:function(e){var t,r,i,n,o,s,a=new Array(arguments.length),l=E.event.fix(e),c=(J.get(this,"events")||Object.create(null))[l.type]||[],u=E.event.special[l.type]||{};for(a[0]=l,t=1;t<arguments.length;t++)a[t]=arguments[t];if(l.delegateTarget=this,!u.preDispatch||!1!==u.preDispatch.call(this,l)){for(s=E.event.handlers.call(this,l,c),t=0;(n=s[t++])&&!l.isPropagationStopped();)for(l.currentTarget=n.elem,r=0;(o=n.handlers[r++])&&!l.isImmediatePropagationStopped();)l.rnamespace&&!1!==o.namespace&&!l.rnamespace.test(o.namespace)||(l.handleObj=o,l.data=o.data,void 0!==(i=((E.event.special[o.origType]||{}).handle||o.handler).apply(n.elem,a))&&!1===(l.result=i)&&(l.preventDefault(),l.stopPropagation()));return u.postDispatch&&u.postDispatch.call(this,l),l.result}},handlers:function(e,t){var r,i,n,o,s,a=[],l=t.delegateCount,c=e.target;if(l&&c.nodeType&&!("click"===e.type&&e.button>=1))for(;c!==this;c=c.parentNode||this)if(1===c.nodeType&&("click"!==e.type||!0!==c.disabled)){for(o=[],s={},r=0;r<l;r++)void 0===s[n=(i=t[r]).selector+" "]&&(s[n]=i.needsContext?E(n,this).index(c)>-1:E.find(n,this,null,[c]).length),s[n]&&o.push(i);o.length&&a.push({elem:c,handlers:o})}return c=this,l<t.length&&a.push({elem:c,handlers:t.slice(l)}),a},addProp:function(e,t){Object.defineProperty(E.Event.prototype,e,{enumerable:!0,configurable:!0,get:g(t)?function(){if(this.originalEvent)return t(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})},fix:function(e){return e[E.expando]?e:new E.Event(e)},special:{load:{noBubble:!0},click:{setup:function(e){var t=this||e;return _e.test(t.type)&&t.click&&M(t,"input")&&Ie(t,"click",Se),!1},trigger:function(e){var t=this||e;return _e.test(t.type)&&t.click&&M(t,"input")&&Ie(t,"click"),!0},_default:function(e){var t=e.target;return _e.test(t.type)&&t.click&&M(t,"input")&&J.get(t,"click")||M(t,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},E.removeEvent=function(e,t,r){e.removeEventListener&&e.removeEventListener(t,r)},E.Event=function(e,t){if(!(this instanceof E.Event))return new E.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?Se:Ce,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&E.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[E.expando]=!0},E.Event.prototype={constructor:E.Event,isDefaultPrevented:Ce,isPropagationStopped:Ce,isImmediatePropagationStopped:Ce,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=Se,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=Se,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=Se,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},E.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,code:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:!0},E.event.addProp),E.each({focus:"focusin",blur:"focusout"},(function(e,t){E.event.special[e]={setup:function(){return Ie(this,e,Ae),!1},trigger:function(){return Ie(this,e),!0},_default:function(){return!0},delegateType:t}})),E.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},(function(e,t){E.event.special[e]={delegateType:t,bindType:t,handle:function(e){var r,i=this,n=e.relatedTarget,o=e.handleObj;return n&&(n===i||E.contains(i,n))||(e.type=o.origType,r=o.handler.apply(this,arguments),e.type=t),r}}})),E.fn.extend({on:function(e,t,r,i){return ke(this,e,t,r,i)},one:function(e,t,r,i){return ke(this,e,t,r,i,1)},off:function(e,t,r){var i,n;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,E(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(n in e)this.off(n,t,e[n]);return this}return!1!==t&&"function"!=typeof t||(r=t,t=void 0),!1===r&&(r=Ce),this.each((function(){E.event.remove(this,e,r,t)}))}});var Me=/<script|<style|<link/i,ze=/checked\s*(?:[^=]|=\s*.checked.)/i,Pe=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function De(e,t){return M(e,"table")&&M(11!==t.nodeType?t:t.firstChild,"tr")&&E(e).children("tbody")[0]||e}function Le(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Be(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Re(e,t){var r,i,n,o,s,a;if(1===t.nodeType){if(J.hasData(e)&&(a=J.get(e).events))for(n in J.remove(t,"handle events"),a)for(r=0,i=a[n].length;r<i;r++)E.event.add(t,n,a[n][r]);Q.hasData(e)&&(o=Q.access(e),s=E.extend({},o),Q.set(t,s))}}function Oe(e,t){var r=t.nodeName.toLowerCase();"input"===r&&_e.test(e.type)?t.checked=e.checked:"input"!==r&&"textarea"!==r||(t.defaultValue=e.defaultValue)}function Fe(e,t,r,i){t=l(t);var n,o,s,a,c,u,h=0,p=e.length,d=p-1,f=t[0],m=g(f);if(m||p>1&&"string"==typeof f&&!_.checkClone&&ze.test(f))return e.each((function(n){var o=e.eq(n);m&&(t[0]=f.call(this,n,o.html())),Fe(o,t,r,i)}));if(p&&(o=(n=Te(t,e[0].ownerDocument,!1,e,i)).firstChild,1===n.childNodes.length&&(n=o),o||i)){for(a=(s=E.map(xe(n,"script"),Le)).length;h<p;h++)c=n,h!==d&&(c=E.clone(c,!0,!0),a&&E.merge(s,xe(c,"script"))),r.call(e[h],c,h);if(a)for(u=s[s.length-1].ownerDocument,E.map(s,Be),h=0;h<a;h++)c=s[h],ye.test(c.type||"")&&!J.access(c,"globalEval")&&E.contains(u,c)&&(c.src&&"module"!==(c.type||"").toLowerCase()?E._evalUrl&&!c.noModule&&E._evalUrl(c.src,{nonce:c.nonce||c.getAttribute("nonce")},u):b(c.textContent.replace(Pe,""),c,u))}return e}function Ne(e,t,r){for(var i,n=t?E.filter(t,e):e,o=0;null!=(i=n[o]);o++)r||1!==i.nodeType||E.cleanData(xe(i)),i.parentNode&&(r&&ae(i)&&be(xe(i,"script")),i.parentNode.removeChild(i));return e}E.extend({htmlPrefilter:function(e){return e},clone:function(e,t,r){var i,n,o,s,a=e.cloneNode(!0),l=ae(e);if(!(_.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||E.isXMLDoc(e)))for(s=xe(a),i=0,n=(o=xe(e)).length;i<n;i++)Oe(o[i],s[i]);if(t)if(r)for(o=o||xe(e),s=s||xe(a),i=0,n=o.length;i<n;i++)Re(o[i],s[i]);else Re(e,a);return(s=xe(a,"script")).length>0&&be(s,!l&&xe(e,"script")),a},cleanData:function(e){for(var t,r,i,n=E.event.special,o=0;void 0!==(r=e[o]);o++)if(Y(r)){if(t=r[J.expando]){if(t.events)for(i in t.events)n[i]?E.event.remove(r,i):E.removeEvent(r,i,t.handle);r[J.expando]=void 0}r[Q.expando]&&(r[Q.expando]=void 0)}}}),E.fn.extend({detach:function(e){return Ne(this,e,!0)},remove:function(e){return Ne(this,e)},text:function(e){return $(this,(function(e){return void 0===e?E.text(this):this.empty().each((function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)}))}),null,e,arguments.length)},append:function(){return Fe(this,arguments,(function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||De(this,e).appendChild(e)}))},prepend:function(){return Fe(this,arguments,(function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=De(this,e);t.insertBefore(e,t.firstChild)}}))},before:function(){return Fe(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this)}))},after:function(){return Fe(this,arguments,(function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)}))},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(E.cleanData(xe(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map((function(){return E.clone(this,e,t)}))},html:function(e){return $(this,(function(e){var t=this[0]||{},r=0,i=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Me.test(e)&&!ve[(ge.exec(e)||["",""])[1].toLowerCase()]){e=E.htmlPrefilter(e);try{for(;r<i;r++)1===(t=this[r]||{}).nodeType&&(E.cleanData(xe(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)}),null,e,arguments.length)},replaceWith:function(){var e=[];return Fe(this,arguments,(function(t){var r=this.parentNode;E.inArray(this,e)<0&&(E.cleanData(xe(this)),r&&r.replaceChild(t,this))}),e)}}),E.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},(function(e,t){E.fn[e]=function(e){for(var r,i=[],n=E(e),o=n.length-1,s=0;s<=o;s++)r=s===o?this:this.clone(!0),E(n[s])[t](r),c.apply(i,r.get());return this.pushStack(i)}}));var je=new RegExp("^("+ie+")(?!px)[a-z%]+$","i"),Ue=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=i),t.getComputedStyle(e)},Ve=function(e,t,r){var i,n,o={};for(n in t)o[n]=e.style[n],e.style[n]=t[n];for(n in i=r.call(e),t)e.style[n]=o[n];return i},qe=new RegExp(oe.join("|"),"i");function Ge(e,t,r){var i,n,o,s,a=e.style;return(r=r||Ue(e))&&(""!==(s=r.getPropertyValue(t)||r[t])||ae(e)||(s=E.style(e,t)),!_.pixelBoxStyles()&&je.test(s)&&qe.test(t)&&(i=a.width,n=a.minWidth,o=a.maxWidth,a.minWidth=a.maxWidth=a.width=s,s=r.width,a.width=i,a.minWidth=n,a.maxWidth=o)),void 0!==s?s+"":s}function $e(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}!function(){function e(){if(u){c.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",u.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",se.appendChild(c).appendChild(u);var e=i.getComputedStyle(u);r="1%"!==e.top,l=12===t(e.marginLeft),u.style.right="60%",s=36===t(e.right),n=36===t(e.width),u.style.position="absolute",o=12===t(u.offsetWidth/3),se.removeChild(c),u=null}}function t(e){return Math.round(parseFloat(e))}var r,n,o,s,a,l,c=v.createElement("div"),u=v.createElement("div");u.style&&(u.style.backgroundClip="content-box",u.cloneNode(!0).style.backgroundClip="",_.clearCloneStyle="content-box"===u.style.backgroundClip,E.extend(_,{boxSizingReliable:function(){return e(),n},pixelBoxStyles:function(){return e(),s},pixelPosition:function(){return e(),r},reliableMarginLeft:function(){return e(),l},scrollboxSize:function(){return e(),o},reliableTrDimensions:function(){var e,t,r,n;return null==a&&(e=v.createElement("table"),t=v.createElement("tr"),r=v.createElement("div"),e.style.cssText="position:absolute;left:-11111px;border-collapse:separate",t.style.cssText="border:1px solid",t.style.height="1px",r.style.height="9px",r.style.display="block",se.appendChild(e).appendChild(t).appendChild(r),n=i.getComputedStyle(t),a=parseInt(n.height,10)+parseInt(n.borderTopWidth,10)+parseInt(n.borderBottomWidth,10)===t.offsetHeight,se.removeChild(e)),a}}))}();var Ze=["Webkit","Moz","ms"],We=v.createElement("div").style,He={};function Xe(e){return E.cssProps[e]||He[e]||(e in We?e:He[e]=function(e){for(var t=e[0].toUpperCase()+e.slice(1),r=Ze.length;r--;)if((e=Ze[r]+t)in We)return e}(e)||e)}var Ye=/^(none|table(?!-c[ea]).+)/,Ke=/^--/,Je={position:"absolute",visibility:"hidden",display:"block"},Qe={letterSpacing:"0",fontWeight:"400"};function et(e,t,r){var i=ne.exec(t);return i?Math.max(0,i[2]-(r||0))+(i[3]||"px"):t}function tt(e,t,r,i,n,o){var s="width"===t?1:0,a=0,l=0;if(r===(i?"border":"content"))return 0;for(;s<4;s+=2)"margin"===r&&(l+=E.css(e,r+oe[s],!0,n)),i?("content"===r&&(l-=E.css(e,"padding"+oe[s],!0,n)),"margin"!==r&&(l-=E.css(e,"border"+oe[s]+"Width",!0,n))):(l+=E.css(e,"padding"+oe[s],!0,n),"padding"!==r?l+=E.css(e,"border"+oe[s]+"Width",!0,n):a+=E.css(e,"border"+oe[s]+"Width",!0,n));return!i&&o>=0&&(l+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-l-a-.5))||0),l}function rt(e,t,r){var i=Ue(e),n=(!_.boxSizingReliable()||r)&&"border-box"===E.css(e,"boxSizing",!1,i),o=n,s=Ge(e,t,i),a="offset"+t[0].toUpperCase()+t.slice(1);if(je.test(s)){if(!r)return s;s="auto"}return(!_.boxSizingReliable()&&n||!_.reliableTrDimensions()&&M(e,"tr")||"auto"===s||!parseFloat(s)&&"inline"===E.css(e,"display",!1,i))&&e.getClientRects().length&&(n="border-box"===E.css(e,"boxSizing",!1,i),(o=a in e)&&(s=e[a])),(s=parseFloat(s)||0)+tt(e,t,r||(n?"border":"content"),o,i,s)+"px"}function it(e,t,r,i,n){return new it.prototype.init(e,t,r,i,n)}E.extend({cssHooks:{opacity:{get:function(e,t){if(t){var r=Ge(e,"opacity");return""===r?"1":r}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var n,o,s,a=X(t),l=Ke.test(t),c=e.style;if(l||(t=Xe(a)),s=E.cssHooks[t]||E.cssHooks[a],void 0===r)return s&&"get"in s&&void 0!==(n=s.get(e,!1,i))?n:c[t];"string"==(o=typeof r)&&(n=ne.exec(r))&&n[1]&&(r=ue(e,t,n),o="number"),null!=r&&r==r&&("number"!==o||l||(r+=n&&n[3]||(E.cssNumber[a]?"":"px")),_.clearCloneStyle||""!==r||0!==t.indexOf("background")||(c[t]="inherit"),s&&"set"in s&&void 0===(r=s.set(e,r,i))||(l?c.setProperty(t,r):c[t]=r))}},css:function(e,t,r,i){var n,o,s,a=X(t);return Ke.test(t)||(t=Xe(a)),(s=E.cssHooks[t]||E.cssHooks[a])&&"get"in s&&(n=s.get(e,!0,r)),void 0===n&&(n=Ge(e,t,i)),"normal"===n&&t in Qe&&(n=Qe[t]),""===r||r?(o=parseFloat(n),!0===r||isFinite(o)?o||0:n):n}}),E.each(["height","width"],(function(e,t){E.cssHooks[t]={get:function(e,r,i){if(r)return!Ye.test(E.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?rt(e,t,i):Ve(e,Je,(function(){return rt(e,t,i)}))},set:function(e,r,i){var n,o=Ue(e),s=!_.scrollboxSize()&&"absolute"===o.position,a=(s||i)&&"border-box"===E.css(e,"boxSizing",!1,o),l=i?tt(e,t,i,a,o):0;return a&&s&&(l-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-tt(e,t,"border",!1,o)-.5)),l&&(n=ne.exec(r))&&"px"!==(n[3]||"px")&&(e.style[t]=r,r=E.css(e,t)),et(0,r,l)}}})),E.cssHooks.marginLeft=$e(_.reliableMarginLeft,(function(e,t){if(t)return(parseFloat(Ge(e,"marginLeft"))||e.getBoundingClientRect().left-Ve(e,{marginLeft:0},(function(){return e.getBoundingClientRect().left})))+"px"})),E.each({margin:"",padding:"",border:"Width"},(function(e,t){E.cssHooks[e+t]={expand:function(r){for(var i=0,n={},o="string"==typeof r?r.split(" "):[r];i<4;i++)n[e+oe[i]+t]=o[i]||o[i-2]||o[0];return n}},"margin"!==e&&(E.cssHooks[e+t].set=et)})),E.fn.extend({css:function(e,t){return $(this,(function(e,t,r){var i,n,o={},s=0;if(Array.isArray(t)){for(i=Ue(e),n=t.length;s<n;s++)o[t[s]]=E.css(e,t[s],!1,i);return o}return void 0!==r?E.style(e,t,r):E.css(e,t)}),e,t,arguments.length>1)}}),E.Tween=it,it.prototype={constructor:it,init:function(e,t,r,i,n,o){this.elem=e,this.prop=r,this.easing=n||E.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=i,this.unit=o||(E.cssNumber[r]?"":"px")},cur:function(){var e=it.propHooks[this.prop];return e&&e.get?e.get(this):it.propHooks._default.get(this)},run:function(e){var t,r=it.propHooks[this.prop];return this.options.duration?this.pos=t=E.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),r&&r.set?r.set(this):it.propHooks._default.set(this),this}},it.prototype.init.prototype=it.prototype,it.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=E.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){E.fx.step[e.prop]?E.fx.step[e.prop](e):1!==e.elem.nodeType||!E.cssHooks[e.prop]&&null==e.elem.style[Xe(e.prop)]?e.elem[e.prop]=e.now:E.style(e.elem,e.prop,e.now+e.unit)}}},it.propHooks.scrollTop=it.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},E.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},E.fx=it.prototype.init,E.fx.step={};var nt,ot,st=/^(?:toggle|show|hide)$/,at=/queueHooks$/;function lt(){ot&&(!1===v.hidden&&i.requestAnimationFrame?i.requestAnimationFrame(lt):i.setTimeout(lt,E.fx.interval),E.fx.tick())}function ct(){return i.setTimeout((function(){nt=void 0})),nt=Date.now()}function ut(e,t){var r,i=0,n={height:e};for(t=t?1:0;i<4;i+=2-t)n["margin"+(r=oe[i])]=n["padding"+r]=e;return t&&(n.opacity=n.width=e),n}function ht(e,t,r){for(var i,n=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,s=n.length;o<s;o++)if(i=n[o].call(r,t,e))return i}function pt(e,t,r){var i,n,o=0,s=pt.prefilters.length,a=E.Deferred().always((function(){delete l.elem})),l=function(){if(n)return!1;for(var t=nt||ct(),r=Math.max(0,c.startTime+c.duration-t),i=1-(r/c.duration||0),o=0,s=c.tweens.length;o<s;o++)c.tweens[o].run(i);return a.notifyWith(e,[c,i,r]),i<1&&s?r:(s||a.notifyWith(e,[c,1,0]),a.resolveWith(e,[c]),!1)},c=a.promise({elem:e,props:E.extend({},t),opts:E.extend(!0,{specialEasing:{},easing:E.easing._default},r),originalProperties:t,originalOptions:r,startTime:nt||ct(),duration:r.duration,tweens:[],createTween:function(t,r){var i=E.Tween(e,c.opts,t,r,c.opts.specialEasing[t]||c.opts.easing);return c.tweens.push(i),i},stop:function(t){var r=0,i=t?c.tweens.length:0;if(n)return this;for(n=!0;r<i;r++)c.tweens[r].run(1);return t?(a.notifyWith(e,[c,1,0]),a.resolveWith(e,[c,t])):a.rejectWith(e,[c,t]),this}}),u=c.props;for(function(e,t){var r,i,n,o,s;for(r in e)if(n=t[i=X(r)],o=e[r],Array.isArray(o)&&(n=o[1],o=e[r]=o[0]),r!==i&&(e[i]=o,delete e[r]),(s=E.cssHooks[i])&&"expand"in s)for(r in o=s.expand(o),delete e[i],o)r in e||(e[r]=o[r],t[r]=n);else t[i]=n}(u,c.opts.specialEasing);o<s;o++)if(i=pt.prefilters[o].call(c,e,u,c.opts))return g(i.stop)&&(E._queueHooks(c.elem,c.opts.queue).stop=i.stop.bind(i)),i;return E.map(u,ht,c),g(c.opts.start)&&c.opts.start.call(e,c),c.progress(c.opts.progress).done(c.opts.done,c.opts.complete).fail(c.opts.fail).always(c.opts.always),E.fx.timer(E.extend(l,{elem:e,anim:c,queue:c.opts.queue})),c}E.Animation=E.extend(pt,{tweeners:{"*":[function(e,t){var r=this.createTween(e,t);return ue(r.elem,e,ne.exec(t),r),r}]},tweener:function(e,t){g(e)?(t=e,e=["*"]):e=e.match(F);for(var r,i=0,n=e.length;i<n;i++)r=e[i],pt.tweeners[r]=pt.tweeners[r]||[],pt.tweeners[r].unshift(t)},prefilters:[function(e,t,r){var i,n,o,s,a,l,c,u,h="width"in t||"height"in t,p=this,d={},f=e.style,m=e.nodeType&&ce(e),_=J.get(e,"fxshow");for(i in r.queue||(null==(s=E._queueHooks(e,"fx")).unqueued&&(s.unqueued=0,a=s.empty.fire,s.empty.fire=function(){s.unqueued||a()}),s.unqueued++,p.always((function(){p.always((function(){s.unqueued--,E.queue(e,"fx").length||s.empty.fire()}))}))),t)if(n=t[i],st.test(n)){if(delete t[i],o=o||"toggle"===n,n===(m?"hide":"show")){if("show"!==n||!_||void 0===_[i])continue;m=!0}d[i]=_&&_[i]||E.style(e,i)}if((l=!E.isEmptyObject(t))||!E.isEmptyObject(d))for(i in h&&1===e.nodeType&&(r.overflow=[f.overflow,f.overflowX,f.overflowY],null==(c=_&&_.display)&&(c=J.get(e,"display")),"none"===(u=E.css(e,"display"))&&(c?u=c:(de([e],!0),c=e.style.display||c,u=E.css(e,"display"),de([e]))),("inline"===u||"inline-block"===u&&null!=c)&&"none"===E.css(e,"float")&&(l||(p.done((function(){f.display=c})),null==c&&(u=f.display,c="none"===u?"":u)),f.display="inline-block")),r.overflow&&(f.overflow="hidden",p.always((function(){f.overflow=r.overflow[0],f.overflowX=r.overflow[1],f.overflowY=r.overflow[2]}))),l=!1,d)l||(_?"hidden"in _&&(m=_.hidden):_=J.access(e,"fxshow",{display:c}),o&&(_.hidden=!m),m&&de([e],!0),p.done((function(){for(i in m||de([e]),J.remove(e,"fxshow"),d)E.style(e,i,d[i])}))),l=ht(m?_[i]:0,i,p),i in _||(_[i]=l.start,m&&(l.end=l.start,l.start=0))}],prefilter:function(e,t){t?pt.prefilters.unshift(e):pt.prefilters.push(e)}}),E.speed=function(e,t,r){var i=e&&"object"==typeof e?E.extend({},e):{complete:r||!r&&t||g(e)&&e,duration:e,easing:r&&t||t&&!g(t)&&t};return E.fx.off?i.duration=0:"number"!=typeof i.duration&&(i.duration in E.fx.speeds?i.duration=E.fx.speeds[i.duration]:i.duration=E.fx.speeds._default),null!=i.queue&&!0!==i.queue||(i.queue="fx"),i.old=i.complete,i.complete=function(){g(i.old)&&i.old.call(this),i.queue&&E.dequeue(this,i.queue)},i},E.fn.extend({fadeTo:function(e,t,r,i){return this.filter(ce).css("opacity",0).show().end().animate({opacity:t},e,r,i)},animate:function(e,t,r,i){var n=E.isEmptyObject(e),o=E.speed(t,r,i),s=function(){var t=pt(this,E.extend({},e),o);(n||J.get(this,"finish"))&&t.stop(!0)};return s.finish=s,n||!1===o.queue?this.each(s):this.queue(o.queue,s)},stop:function(e,t,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=t,t=e,e=void 0),t&&this.queue(e||"fx",[]),this.each((function(){var t=!0,n=null!=e&&e+"queueHooks",o=E.timers,s=J.get(this);if(n)s[n]&&s[n].stop&&i(s[n]);else for(n in s)s[n]&&s[n].stop&&at.test(n)&&i(s[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));!t&&r||E.dequeue(this,e)}))},finish:function(e){return!1!==e&&(e=e||"fx"),this.each((function(){var t,r=J.get(this),i=r[e+"queue"],n=r[e+"queueHooks"],o=E.timers,s=i?i.length:0;for(r.finish=!0,E.queue(this,e,[]),n&&n.stop&&n.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;t<s;t++)i[t]&&i[t].finish&&i[t].finish.call(this);delete r.finish}))}}),E.each(["toggle","show","hide"],(function(e,t){var r=E.fn[t];E.fn[t]=function(e,i,n){return null==e||"boolean"==typeof e?r.apply(this,arguments):this.animate(ut(t,!0),e,i,n)}})),E.each({slideDown:ut("show"),slideUp:ut("hide"),slideToggle:ut("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},(function(e,t){E.fn[e]=function(e,r,i){return this.animate(t,e,r,i)}})),E.timers=[],E.fx.tick=function(){var e,t=0,r=E.timers;for(nt=Date.now();t<r.length;t++)(e=r[t])()||r[t]!==e||r.splice(t--,1);r.length||E.fx.stop(),nt=void 0},E.fx.timer=function(e){E.timers.push(e),E.fx.start()},E.fx.interval=13,E.fx.start=function(){ot||(ot=!0,lt())},E.fx.stop=function(){ot=null},E.fx.speeds={slow:600,fast:200,_default:400},E.fn.delay=function(e,t){return e=E.fx&&E.fx.speeds[e]||e,t=t||"fx",this.queue(t,(function(t,r){var n=i.setTimeout(t,e);r.stop=function(){i.clearTimeout(n)}}))},function(){var e=v.createElement("input"),t=v.createElement("select").appendChild(v.createElement("option"));e.type="checkbox",_.checkOn=""!==e.value,_.optSelected=t.selected,(e=v.createElement("input")).value="t",e.type="radio",_.radioValue="t"===e.value}();var dt,ft=E.expr.attrHandle;E.fn.extend({attr:function(e,t){return $(this,E.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each((function(){E.removeAttr(this,e)}))}}),E.extend({attr:function(e,t,r){var i,n,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?E.prop(e,t,r):(1===o&&E.isXMLDoc(e)||(n=E.attrHooks[t.toLowerCase()]||(E.expr.match.bool.test(t)?dt:void 0)),void 0!==r?null===r?void E.removeAttr(e,t):n&&"set"in n&&void 0!==(i=n.set(e,r,t))?i:(e.setAttribute(t,r+""),r):n&&"get"in n&&null!==(i=n.get(e,t))?i:null==(i=E.find.attr(e,t))?void 0:i)},attrHooks:{type:{set:function(e,t){if(!_.radioValue&&"radio"===t&&M(e,"input")){var r=e.value;return e.setAttribute("type",t),r&&(e.value=r),t}}}},removeAttr:function(e,t){var r,i=0,n=t&&t.match(F);if(n&&1===e.nodeType)for(;r=n[i++];)e.removeAttribute(r)}}),dt={set:function(e,t,r){return!1===t?E.removeAttr(e,r):e.setAttribute(r,r),r}},E.each(E.expr.match.bool.source.match(/\w+/g),(function(e,t){var r=ft[t]||E.find.attr;ft[t]=function(e,t,i){var n,o,s=t.toLowerCase();return i||(o=ft[s],ft[s]=n,n=null!=r(e,t,i)?s:null,ft[s]=o),n}}));var mt=/^(?:input|select|textarea|button)$/i,_t=/^(?:a|area)$/i;function gt(e){return(e.match(F)||[]).join(" ")}function yt(e){return e.getAttribute&&e.getAttribute("class")||""}function vt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(F)||[]}E.fn.extend({prop:function(e,t){return $(this,E.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each((function(){delete this[E.propFix[e]||e]}))}}),E.extend({prop:function(e,t,r){var i,n,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&E.isXMLDoc(e)||(t=E.propFix[t]||t,n=E.propHooks[t]),void 0!==r?n&&"set"in n&&void 0!==(i=n.set(e,r,t))?i:e[t]=r:n&&"get"in n&&null!==(i=n.get(e,t))?i:e[t]},propHooks:{tabIndex:{get:function(e){var t=E.find.attr(e,"tabindex");return t?parseInt(t,10):mt.test(e.nodeName)||_t.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),_.optSelected||(E.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),E.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],(function(){E.propFix[this.toLowerCase()]=this})),E.fn.extend({addClass:function(e){var t,r,i,n,o,s,a,l=0;if(g(e))return this.each((function(t){E(this).addClass(e.call(this,t,yt(this)))}));if((t=vt(e)).length)for(;r=this[l++];)if(n=yt(r),i=1===r.nodeType&&" "+gt(n)+" "){for(s=0;o=t[s++];)i.indexOf(" "+o+" ")<0&&(i+=o+" ");n!==(a=gt(i))&&r.setAttribute("class",a)}return this},removeClass:function(e){var t,r,i,n,o,s,a,l=0;if(g(e))return this.each((function(t){E(this).removeClass(e.call(this,t,yt(this)))}));if(!arguments.length)return this.attr("class","");if((t=vt(e)).length)for(;r=this[l++];)if(n=yt(r),i=1===r.nodeType&&" "+gt(n)+" "){for(s=0;o=t[s++];)for(;i.indexOf(" "+o+" ")>-1;)i=i.replace(" "+o+" "," ");n!==(a=gt(i))&&r.setAttribute("class",a)}return this},toggleClass:function(e,t){var r=typeof e,i="string"===r||Array.isArray(e);return"boolean"==typeof t&&i?t?this.addClass(e):this.removeClass(e):g(e)?this.each((function(r){E(this).toggleClass(e.call(this,r,yt(this),t),t)})):this.each((function(){var t,n,o,s;if(i)for(n=0,o=E(this),s=vt(e);t=s[n++];)o.hasClass(t)?o.removeClass(t):o.addClass(t);else void 0!==e&&"boolean"!==r||((t=yt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))}))},hasClass:function(e){var t,r,i=0;for(t=" "+e+" ";r=this[i++];)if(1===r.nodeType&&(" "+gt(yt(r))+" ").indexOf(t)>-1)return!0;return!1}});var xt=/\r/g;E.fn.extend({val:function(e){var t,r,i,n=this[0];return arguments.length?(i=g(e),this.each((function(r){var n;1===this.nodeType&&(null==(n=i?e.call(this,r,E(this).val()):e)?n="":"number"==typeof n?n+="":Array.isArray(n)&&(n=E.map(n,(function(e){return null==e?"":e+""}))),(t=E.valHooks[this.type]||E.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,n,"value")||(this.value=n))}))):n?(t=E.valHooks[n.type]||E.valHooks[n.nodeName.toLowerCase()])&&"get"in t&&void 0!==(r=t.get(n,"value"))?r:"string"==typeof(r=n.value)?r.replace(xt,""):null==r?"":r:void 0}}),E.extend({valHooks:{option:{get:function(e){var t=E.find.attr(e,"value");return null!=t?t:gt(E.text(e))}},select:{get:function(e){var t,r,i,n=e.options,o=e.selectedIndex,s="select-one"===e.type,a=s?null:[],l=s?o+1:n.length;for(i=o<0?l:s?o:0;i<l;i++)if(((r=n[i]).selected||i===o)&&!r.disabled&&(!r.parentNode.disabled||!M(r.parentNode,"optgroup"))){if(t=E(r).val(),s)return t;a.push(t)}return a},set:function(e,t){for(var r,i,n=e.options,o=E.makeArray(t),s=n.length;s--;)((i=n[s]).selected=E.inArray(E.valHooks.option.get(i),o)>-1)&&(r=!0);return r||(e.selectedIndex=-1),o}}}}),E.each(["radio","checkbox"],(function(){E.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=E.inArray(E(e).val(),t)>-1}},_.checkOn||(E.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})})),_.focusin="onfocusin"in i;var bt=/^(?:focusinfocus|focusoutblur)$/,wt=function(e){e.stopPropagation()};E.extend(E.event,{trigger:function(e,t,r,n){var o,s,a,l,c,u,h,p,f=[r||v],m=d.call(e,"type")?e.type:e,_=d.call(e,"namespace")?e.namespace.split("."):[];if(s=p=a=r=r||v,3!==r.nodeType&&8!==r.nodeType&&!bt.test(m+E.event.triggered)&&(m.indexOf(".")>-1&&(_=m.split("."),m=_.shift(),_.sort()),c=m.indexOf(":")<0&&"on"+m,(e=e[E.expando]?e:new E.Event(m,"object"==typeof e&&e)).isTrigger=n?2:3,e.namespace=_.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+_.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=r),t=null==t?[e]:E.makeArray(t,[e]),h=E.event.special[m]||{},n||!h.trigger||!1!==h.trigger.apply(r,t))){if(!n&&!h.noBubble&&!y(r)){for(l=h.delegateType||m,bt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)f.push(s),a=s;a===(r.ownerDocument||v)&&f.push(a.defaultView||a.parentWindow||i)}for(o=0;(s=f[o++])&&!e.isPropagationStopped();)p=s,e.type=o>1?l:h.bindType||m,(u=(J.get(s,"events")||Object.create(null))[e.type]&&J.get(s,"handle"))&&u.apply(s,t),(u=c&&s[c])&&u.apply&&Y(s)&&(e.result=u.apply(s,t),!1===e.result&&e.preventDefault());return e.type=m,n||e.isDefaultPrevented()||h._default&&!1!==h._default.apply(f.pop(),t)||!Y(r)||c&&g(r[m])&&!y(r)&&((a=r[c])&&(r[c]=null),E.event.triggered=m,e.isPropagationStopped()&&p.addEventListener(m,wt),r[m](),e.isPropagationStopped()&&p.removeEventListener(m,wt),E.event.triggered=void 0,a&&(r[c]=a)),e.result}},simulate:function(e,t,r){var i=E.extend(new E.Event,r,{type:e,isSimulated:!0});E.event.trigger(i,null,t)}}),E.fn.extend({trigger:function(e,t){return this.each((function(){E.event.trigger(e,t,this)}))},triggerHandler:function(e,t){var r=this[0];if(r)return E.event.trigger(e,t,r,!0)}}),_.focusin||E.each({focus:"focusin",blur:"focusout"},(function(e,t){var r=function(e){E.event.simulate(t,e.target,E.event.fix(e))};E.event.special[t]={setup:function(){var i=this.ownerDocument||this.document||this,n=J.access(i,t);n||i.addEventListener(e,r,!0),J.access(i,t,(n||0)+1)},teardown:function(){var i=this.ownerDocument||this.document||this,n=J.access(i,t)-1;n?J.access(i,t,n):(i.removeEventListener(e,r,!0),J.remove(i,t))}}}));var Tt=i.location,Et={guid:Date.now()},St=/\?/;E.parseXML=function(e){var t,r;if(!e||"string"!=typeof e)return null;try{t=(new i.DOMParser).parseFromString(e,"text/xml")}catch(e){}return r=t&&t.getElementsByTagName("parsererror")[0],t&&!r||E.error("Invalid XML: "+(r?E.map(r.childNodes,(function(e){return e.textContent})).join("\n"):e)),t};var Ct=/\[\]$/,At=/\r?\n/g,kt=/^(?:submit|button|image|reset|file)$/i,It=/^(?:input|select|textarea|keygen)/i;function Mt(e,t,r,i){var n;if(Array.isArray(t))E.each(t,(function(t,n){r||Ct.test(e)?i(e,n):Mt(e+"["+("object"==typeof n&&null!=n?t:"")+"]",n,r,i)}));else if(r||"object"!==w(t))i(e,t);else for(n in t)Mt(e+"["+n+"]",t[n],r,i)}E.param=function(e,t){var r,i=[],n=function(e,t){var r=g(t)?t():t;i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==r?"":r)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!E.isPlainObject(e))E.each(e,(function(){n(this.name,this.value)}));else for(r in e)Mt(r,e[r],t,n);return i.join("&")},E.fn.extend({serialize:function(){return E.param(this.serializeArray())},serializeArray:function(){return this.map((function(){var e=E.prop(this,"elements");return e?E.makeArray(e):this})).filter((function(){var e=this.type;return this.name&&!E(this).is(":disabled")&&It.test(this.nodeName)&&!kt.test(e)&&(this.checked||!_e.test(e))})).map((function(e,t){var r=E(this).val();return null==r?null:Array.isArray(r)?E.map(r,(function(e){return{name:t.name,value:e.replace(At,"\r\n")}})):{name:t.name,value:r.replace(At,"\r\n")}})).get()}});var zt=/%20/g,Pt=/#.*$/,Dt=/([?&])_=[^&]*/,Lt=/^(.*?):[ \t]*([^\r\n]*)$/gm,Bt=/^(?:GET|HEAD)$/,Rt=/^\/\//,Ot={},Ft={},Nt="*/".concat("*"),jt=v.createElement("a");function Ut(e){return function(t,r){"string"!=typeof t&&(r=t,t="*");var i,n=0,o=t.toLowerCase().match(F)||[];if(g(r))for(;i=o[n++];)"+"===i[0]?(i=i.slice(1)||"*",(e[i]=e[i]||[]).unshift(r)):(e[i]=e[i]||[]).push(r)}}function Vt(e,t,r,i){var n={},o=e===Ft;function s(a){var l;return n[a]=!0,E.each(e[a]||[],(function(e,a){var c=a(t,r,i);return"string"!=typeof c||o||n[c]?o?!(l=c):void 0:(t.dataTypes.unshift(c),s(c),!1)})),l}return s(t.dataTypes[0])||!n["*"]&&s("*")}function qt(e,t){var r,i,n=E.ajaxSettings.flatOptions||{};for(r in t)void 0!==t[r]&&((n[r]?e:i||(i={}))[r]=t[r]);return i&&E.extend(!0,e,i),e}jt.href=Tt.href,E.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Tt.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(Tt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Nt,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":E.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?qt(qt(e,E.ajaxSettings),t):qt(E.ajaxSettings,e)},ajaxPrefilter:Ut(Ot),ajaxTransport:Ut(Ft),ajax:function(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,n,o,s,a,l,c,u,h,p,d=E.ajaxSetup({},t),f=d.context||d,m=d.context&&(f.nodeType||f.jquery)?E(f):E.event,_=E.Deferred(),g=E.Callbacks("once memory"),y=d.statusCode||{},x={},b={},w="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s)for(s={};t=Lt.exec(o);)s[t[1].toLowerCase()+" "]=(s[t[1].toLowerCase()+" "]||[]).concat(t[2]);t=s[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return c?o:null},setRequestHeader:function(e,t){return null==c&&(e=b[e.toLowerCase()]=b[e.toLowerCase()]||e,x[e]=t),this},overrideMimeType:function(e){return null==c&&(d.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)T.always(e[T.status]);else for(t in e)y[t]=[y[t],e[t]];return this},abort:function(e){var t=e||w;return r&&r.abort(t),S(0,t),this}};if(_.promise(T),d.url=((e||d.url||Tt.href)+"").replace(Rt,Tt.protocol+"//"),d.type=t.method||t.type||d.method||d.type,d.dataTypes=(d.dataType||"*").toLowerCase().match(F)||[""],null==d.crossDomain){l=v.createElement("a");try{l.href=d.url,l.href=l.href,d.crossDomain=jt.protocol+"//"+jt.host!=l.protocol+"//"+l.host}catch(e){d.crossDomain=!0}}if(d.data&&d.processData&&"string"!=typeof d.data&&(d.data=E.param(d.data,d.traditional)),Vt(Ot,d,t,T),c)return T;for(h in(u=E.event&&d.global)&&0==E.active++&&E.event.trigger("ajaxStart"),d.type=d.type.toUpperCase(),d.hasContent=!Bt.test(d.type),n=d.url.replace(Pt,""),d.hasContent?d.data&&d.processData&&0===(d.contentType||"").indexOf("application/x-www-form-urlencoded")&&(d.data=d.data.replace(zt,"+")):(p=d.url.slice(n.length),d.data&&(d.processData||"string"==typeof d.data)&&(n+=(St.test(n)?"&":"?")+d.data,delete d.data),!1===d.cache&&(n=n.replace(Dt,"$1"),p=(St.test(n)?"&":"?")+"_="+Et.guid+++p),d.url=n+p),d.ifModified&&(E.lastModified[n]&&T.setRequestHeader("If-Modified-Since",E.lastModified[n]),E.etag[n]&&T.setRequestHeader("If-None-Match",E.etag[n])),(d.data&&d.hasContent&&!1!==d.contentType||t.contentType)&&T.setRequestHeader("Content-Type",d.contentType),T.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+("*"!==d.dataTypes[0]?", "+Nt+"; q=0.01":""):d.accepts["*"]),d.headers)T.setRequestHeader(h,d.headers[h]);if(d.beforeSend&&(!1===d.beforeSend.call(f,T,d)||c))return T.abort();if(w="abort",g.add(d.complete),T.done(d.success),T.fail(d.error),r=Vt(Ft,d,t,T)){if(T.readyState=1,u&&m.trigger("ajaxSend",[T,d]),c)return T;d.async&&d.timeout>0&&(a=i.setTimeout((function(){T.abort("timeout")}),d.timeout));try{c=!1,r.send(x,S)}catch(e){if(c)throw e;S(-1,e)}}else S(-1,"No Transport");function S(e,t,s,l){var h,p,v,x,b,w=t;c||(c=!0,a&&i.clearTimeout(a),r=void 0,o=l||"",T.readyState=e>0?4:0,h=e>=200&&e<300||304===e,s&&(x=function(e,t,r){for(var i,n,o,s,a=e.contents,l=e.dataTypes;"*"===l[0];)l.shift(),void 0===i&&(i=e.mimeType||t.getResponseHeader("Content-Type"));if(i)for(n in a)if(a[n]&&a[n].test(i)){l.unshift(n);break}if(l[0]in r)o=l[0];else{for(n in r){if(!l[0]||e.converters[n+" "+l[0]]){o=n;break}s||(s=n)}o=o||s}if(o)return o!==l[0]&&l.unshift(o),r[o]}(d,T,s)),!h&&E.inArray("script",d.dataTypes)>-1&&E.inArray("json",d.dataTypes)<0&&(d.converters["text script"]=function(){}),x=function(e,t,r,i){var n,o,s,a,l,c={},u=e.dataTypes.slice();if(u[1])for(s in e.converters)c[s.toLowerCase()]=e.converters[s];for(o=u.shift();o;)if(e.responseFields[o]&&(r[e.responseFields[o]]=t),!l&&i&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=u.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(!(s=c[l+" "+o]||c["* "+o]))for(n in c)if((a=n.split(" "))[1]===o&&(s=c[l+" "+a[0]]||c["* "+a[0]])){!0===s?s=c[n]:!0!==c[n]&&(o=a[0],u.unshift(a[1]));break}if(!0!==s)if(s&&e.throws)t=s(t);else try{t=s(t)}catch(e){return{state:"parsererror",error:s?e:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}(d,x,T,h),h?(d.ifModified&&((b=T.getResponseHeader("Last-Modified"))&&(E.lastModified[n]=b),(b=T.getResponseHeader("etag"))&&(E.etag[n]=b)),204===e||"HEAD"===d.type?w="nocontent":304===e?w="notmodified":(w=x.state,p=x.data,h=!(v=x.error))):(v=w,!e&&w||(w="error",e<0&&(e=0))),T.status=e,T.statusText=(t||w)+"",h?_.resolveWith(f,[p,w,T]):_.rejectWith(f,[T,w,v]),T.statusCode(y),y=void 0,u&&m.trigger(h?"ajaxSuccess":"ajaxError",[T,d,h?p:v]),g.fireWith(f,[T,w]),u&&(m.trigger("ajaxComplete",[T,d]),--E.active||E.event.trigger("ajaxStop")))}return T},getJSON:function(e,t,r){return E.get(e,t,r,"json")},getScript:function(e,t){return E.get(e,void 0,t,"script")}}),E.each(["get","post"],(function(e,t){E[t]=function(e,r,i,n){return g(r)&&(n=n||i,i=r,r=void 0),E.ajax(E.extend({url:e,type:t,dataType:n,data:r,success:i},E.isPlainObject(e)&&e))}})),E.ajaxPrefilter((function(e){var t;for(t in e.headers)"content-type"===t.toLowerCase()&&(e.contentType=e.headers[t]||"")})),E._evalUrl=function(e,t,r){return E.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){E.globalEval(e,t,r)}})},E.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=E(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map((function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e})).append(this)),this},wrapInner:function(e){return g(e)?this.each((function(t){E(this).wrapInner(e.call(this,t))})):this.each((function(){var t=E(this),r=t.contents();r.length?r.wrapAll(e):t.append(e)}))},wrap:function(e){var t=g(e);return this.each((function(r){E(this).wrapAll(t?e.call(this,r):e)}))},unwrap:function(e){return this.parent(e).not("body").each((function(){E(this).replaceWith(this.childNodes)})),this}}),E.expr.pseudos.hidden=function(e){return!E.expr.pseudos.visible(e)},E.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},E.ajaxSettings.xhr=function(){try{return new i.XMLHttpRequest}catch(e){}};var Gt={0:200,1223:204},$t=E.ajaxSettings.xhr();_.cors=!!$t&&"withCredentials"in $t,_.ajax=$t=!!$t,E.ajaxTransport((function(e){var t,r;if(_.cors||$t&&!e.crossDomain)return{send:function(n,o){var s,a=e.xhr();if(a.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(s in e.xhrFields)a[s]=e.xhrFields[s];for(s in e.mimeType&&a.overrideMimeType&&a.overrideMimeType(e.mimeType),e.crossDomain||n["X-Requested-With"]||(n["X-Requested-With"]="XMLHttpRequest"),n)a.setRequestHeader(s,n[s]);t=function(e){return function(){t&&(t=r=a.onload=a.onerror=a.onabort=a.ontimeout=a.onreadystatechange=null,"abort"===e?a.abort():"error"===e?"number"!=typeof a.status?o(0,"error"):o(a.status,a.statusText):o(Gt[a.status]||a.status,a.statusText,"text"!==(a.responseType||"text")||"string"!=typeof a.responseText?{binary:a.response}:{text:a.responseText},a.getAllResponseHeaders()))}},a.onload=t(),r=a.onerror=a.ontimeout=t("error"),void 0!==a.onabort?a.onabort=r:a.onreadystatechange=function(){4===a.readyState&&i.setTimeout((function(){t&&r()}))},t=t("abort");try{a.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}})),E.ajaxPrefilter((function(e){e.crossDomain&&(e.contents.script=!1)})),E.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return E.globalEval(e),e}}}),E.ajaxPrefilter("script",(function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")})),E.ajaxTransport("script",(function(e){var t,r;if(e.crossDomain||e.scriptAttrs)return{send:function(i,n){t=E("<script>").attr(e.scriptAttrs||{}).prop({charset:e.scriptCharset,src:e.url}).on("load error",r=function(e){t.remove(),r=null,e&&n("error"===e.type?404:200,e.type)}),v.head.appendChild(t[0])},abort:function(){r&&r()}}}));var Zt,Wt=[],Ht=/(=)\?(?=&|$)|\?\?/;E.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Wt.pop()||E.expando+"_"+Et.guid++;return this[e]=!0,e}}),E.ajaxPrefilter("json jsonp",(function(e,t,r){var n,o,s,a=!1!==e.jsonp&&(Ht.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ht.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return n=e.jsonpCallback=g(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ht,"$1"+n):!1!==e.jsonp&&(e.url+=(St.test(e.url)?"&":"?")+e.jsonp+"="+n),e.converters["script json"]=function(){return s||E.error(n+" was not called"),s[0]},e.dataTypes[0]="json",o=i[n],i[n]=function(){s=arguments},r.always((function(){void 0===o?E(i).removeProp(n):i[n]=o,e[n]&&(e.jsonpCallback=t.jsonpCallback,Wt.push(n)),s&&g(o)&&o(s[0]),s=o=void 0})),"script"})),_.createHTMLDocument=((Zt=v.implementation.createHTMLDocument("").body).innerHTML="<form></form><form></form>",2===Zt.childNodes.length),E.parseHTML=function(e,t,r){return"string"!=typeof e?[]:("boolean"==typeof t&&(r=t,t=!1),t||(_.createHTMLDocument?((i=(t=v.implementation.createHTMLDocument("")).createElement("base")).href=v.location.href,t.head.appendChild(i)):t=v),o=!r&&[],(n=z.exec(e))?[t.createElement(n[1])]:(n=Te([e],t,o),o&&o.length&&E(o).remove(),E.merge([],n.childNodes)));var i,n,o},E.fn.load=function(e,t,r){var i,n,o,s=this,a=e.indexOf(" ");return a>-1&&(i=gt(e.slice(a)),e=e.slice(0,a)),g(t)?(r=t,t=void 0):t&&"object"==typeof t&&(n="POST"),s.length>0&&E.ajax({url:e,type:n||"GET",dataType:"html",data:t}).done((function(e){o=arguments,s.html(i?E("<div>").append(E.parseHTML(e)).find(i):e)})).always(r&&function(e,t){s.each((function(){r.apply(this,o||[e.responseText,t,e])}))}),this},E.expr.pseudos.animated=function(e){return E.grep(E.timers,(function(t){return e===t.elem})).length},E.offset={setOffset:function(e,t,r){var i,n,o,s,a,l,c=E.css(e,"position"),u=E(e),h={};"static"===c&&(e.style.position="relative"),a=u.offset(),o=E.css(e,"top"),l=E.css(e,"left"),("absolute"===c||"fixed"===c)&&(o+l).indexOf("auto")>-1?(s=(i=u.position()).top,n=i.left):(s=parseFloat(o)||0,n=parseFloat(l)||0),g(t)&&(t=t.call(e,r,E.extend({},a))),null!=t.top&&(h.top=t.top-a.top+s),null!=t.left&&(h.left=t.left-a.left+n),"using"in t?t.using.call(e,h):u.css(h)}},E.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each((function(t){E.offset.setOffset(this,e,t)}));var t,r,i=this[0];return i?i.getClientRects().length?(t=i.getBoundingClientRect(),r=i.ownerDocument.defaultView,{top:t.top+r.pageYOffset,left:t.left+r.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,r,i=this[0],n={top:0,left:0};if("fixed"===E.css(i,"position"))t=i.getBoundingClientRect();else{for(t=this.offset(),r=i.ownerDocument,e=i.offsetParent||r.documentElement;e&&(e===r.body||e===r.documentElement)&&"static"===E.css(e,"position");)e=e.parentNode;e&&e!==i&&1===e.nodeType&&((n=E(e).offset()).top+=E.css(e,"borderTopWidth",!0),n.left+=E.css(e,"borderLeftWidth",!0))}return{top:t.top-n.top-E.css(i,"marginTop",!0),left:t.left-n.left-E.css(i,"marginLeft",!0)}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent;e&&"static"===E.css(e,"position");)e=e.offsetParent;return e||se}))}}),E.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},(function(e,t){var r="pageYOffset"===t;E.fn[e]=function(i){return $(this,(function(e,i,n){var o;if(y(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===n)return o?o[t]:e[i];o?o.scrollTo(r?o.pageXOffset:n,r?n:o.pageYOffset):e[i]=n}),e,i,arguments.length)}})),E.each(["top","left"],(function(e,t){E.cssHooks[t]=$e(_.pixelPosition,(function(e,r){if(r)return r=Ge(e,t),je.test(r)?E(e).position()[t]+"px":r}))})),E.each({Height:"height",Width:"width"},(function(e,t){E.each({padding:"inner"+e,content:t,"":"outer"+e},(function(r,i){E.fn[i]=function(n,o){var s=arguments.length&&(r||"boolean"!=typeof n),a=r||(!0===n||!0===o?"margin":"border");return $(this,(function(t,r,n){var o;return y(t)?0===i.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(o=t.documentElement,Math.max(t.body["scroll"+e],o["scroll"+e],t.body["offset"+e],o["offset"+e],o["client"+e])):void 0===n?E.css(t,r,a):E.style(t,r,n,a)}),t,s?n:void 0,s)}}))})),E.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],(function(e,t){E.fn[t]=function(e){return this.on(t,e)}})),E.fn.extend({bind:function(e,t,r){return this.on(e,null,t,r)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,r,i){return this.on(t,e,r,i)},undelegate:function(e,t,r){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",r)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),E.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),(function(e,t){E.fn[t]=function(e,r){return arguments.length>0?this.on(t,null,e,r):this.trigger(t)}}));var Xt=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;E.proxy=function(e,t){var r,i,n;if("string"==typeof t&&(r=e[t],t=e,e=r),g(e))return i=a.call(arguments,2),n=function(){return e.apply(t||this,i.concat(a.call(arguments)))},n.guid=e.guid=e.guid||E.guid++,n},E.holdReady=function(e){e?E.readyWait++:E.ready(!0)},E.isArray=Array.isArray,E.parseJSON=JSON.parse,E.nodeName=M,E.isFunction=g,E.isWindow=y,E.camelCase=X,E.type=w,E.now=Date.now,E.isNumeric=function(e){var t=E.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},E.trim=function(e){return null==e?"":(e+"").replace(Xt,"")},void 0===(r=function(){return E}.apply(t,[]))||(e.exports=r);var Yt=i.jQuery,Kt=i.$;return E.noConflict=function(e){return i.$===E&&(i.$=Kt),e&&i.jQuery===E&&(i.jQuery=Yt),E},void 0===n&&(i.jQuery=i.$=E),E}))},158:function(e){e.exports=function(){"use strict";var e,t,r;function i(i,n){if(e)if(t){var o="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 = {}; ("+e+")(sharedChunk); ("+t+")(sharedChunk); self.onerror = null;",s={};e(s),r=n(s),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(r.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else t=n;else e=n}return i(0,(function(e){var t="undefined"!=typeof self?self:{},r=i;function i(e,t,r,i){this.cx=3*e,this.bx=3*(r-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(i-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=r,this.p2y=i}i.prototype.sampleCurveX=function(e){return((this.ax*e+this.bx)*e+this.cx)*e},i.prototype.sampleCurveY=function(e){return((this.ay*e+this.by)*e+this.cy)*e},i.prototype.sampleCurveDerivativeX=function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},i.prototype.solveCurveX=function(e,t){var r,i,n,o,s;for(void 0===t&&(t=1e-6),n=e,s=0;s<8;s++){if(o=this.sampleCurveX(n)-e,Math.abs(o)<t)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=o/a}if((n=e)<(r=0))return r;if(n>(i=1))return i;for(;r<i;){if(o=this.sampleCurveX(n),Math.abs(o-e)<t)return n;e>o?r=n:i=n,n=.5*(i-r)+r}return n},i.prototype.solve=function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))};var n=o;function o(e,t){this.x=e,this.y=t}o.prototype={clone:function(){return new o(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},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(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),r=Math.sin(e),i=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=i,this},_rotateAround:function(e,t){var r=Math.cos(e),i=Math.sin(e),n=t.y+i*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-i*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},o.convert=function(e){return e instanceof o?e:Array.isArray(e)?new o(e[0],e[1]):e};const s=Math.PI/180,a=180/Math.PI;function l(e){return e*s}function c(e){return e*a}const u=[[0,0],[1,0],[1,1],[0,1]];function h(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,r=t*e;return 4*(e<.5?r:3*(e-t)+r-.75)}function p(e,t,i,n){const o=new r(e,t,i,n);return function(e){return o.solve(e)}}const d=p(.25,.1,.25,1);function f(e,t,r){return Math.min(r,Math.max(t,e))}function m(e,t,r){return(r=f((r-e)/(t-e),0,1))*r*(3-2*r)}function _(e,t,r){const i=r-t,n=((e-t)%i+i)%i+t;return n===t?r:n}function g(e,t,r){if(!e.length)return r(null,[]);let i=e.length;const n=new Array(e.length);let o=null;e.forEach(((e,s)=>{t(e,((e,t)=>{e&&(o=e),n[s]=t,0==--i&&r(o,n)}))}))}function y(e){const t=[];for(const r in e)t.push(e[r]);return t}function v(e,...t){for(const r of t)for(const t in r)e[t]=r[t];return e}let x=1;function b(){return x++}function w(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function T(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function E(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function S(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function C(e,t){return-1!==e.indexOf(t,e.length-t.length)}function A(e,t,r){const i={};for(const n in e)i[n]=t.call(r||this,e[n],n,e);return i}function k(e,t,r){const i={};for(const n in e)t.call(r||this,e[n],n,e)&&(i[n]=e[n]);return i}function I(e){return Array.isArray(e)?e.map(I):"object"==typeof e&&e?A(e,I):e}const M={};function z(e){M[e]||("undefined"!=typeof console&&console.warn(e),M[e]=!0)}function P(e,t,r){return(r.y-e.y)*(t.x-e.x)>(t.y-e.y)*(r.x-e.x)}function D(e){let t=0;for(let r,i,n=0,o=e.length,s=o-1;n<o;s=n++)r=e[n],i=e[s],t+=(i.x-r.x)*(r.y+i.y);return t}function L(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function B(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,r,i,n)=>{const o=i||n;return t[r]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let R=null;function O(e){if(null==R){const t=e.navigator?e.navigator.userAgent:null;R=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return R}function F(e){try{const r=t[e];return r.setItem("_mapbox_test_",1),r.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function N(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}const j=t.performance;function U(e){const t=e?e.url.toString():void 0;return j.getEntriesByName(t)}var V="2.9.2";let q,G,$,Z;const W={now:()=>void 0!==$?$:t.performance.now(),setNow(e){$=e},restoreNow(){$=void 0},frame(e){const r=t.requestAnimationFrame(e);return{cancel:()=>t.cancelAnimationFrame(r)}},getImageData(e,r=0){const{width:i,height:n}=e;Z||(Z=t.document.createElement("canvas"));const o=Z.getContext("2d");if(!o)throw new Error("failed to create canvas 2d context");return(i>Z.width||n>Z.height)&&(Z.width=i,Z.height=n),o.clearRect(-r,-r,i+2*r,n+2*r),o.drawImage(e,0,0,i,n),o.getImageData(-r,-r,i+2*r,n+2*r)},resolveURL:e=>(q||(q=t.document.createElement("a")),q.href=e,q.href),get devicePixelRatio(){return t.devicePixelRatio},get prefersReducedMotion(){return!!t.matchMedia&&(null==G&&(G=t.matchMedia("(prefers-reduced-motion: reduce)")),G.matches)}};let H;const X={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==H){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{H=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):e}catch(t){H=e}}return H},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"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},Y={supported:!1,testSupport:function(e){!Q&&J&&(ee?te(e):K=e)}};let K,J,Q=!1,ee=!1;function te(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,J),e.isContextLost())return;Y.supported=!0}catch(e){}e.deleteTexture(t),Q=!0}t.document&&(J=t.document.createElement("img"),J.onload=function(){K&&te(K),K=null,ee=!0},J.onerror=function(){Q=!0,K=null},J.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const re="01",ie="NO_ACCESS_TOKEN";function ne(e){return 0===e.indexOf("mapbox:")}function oe(e){return X.API_URL_REGEX.test(e)}const se=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ae(e){const t=e.match(se);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function le(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}function ce(e){if(!e)return null;const r=e.split(".");if(!r||3!==r.length)return null;try{return JSON.parse(decodeURIComponent(t.atob(r[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class ue{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const r=ce(X.ACCESS_TOKEN);let i="";return i=r&&r.u?t.btoa(encodeURIComponent(r.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):X.ACCESS_TOKEN||"",e?`mapbox.eventData.${e}:${i}`:`mapbox.eventData:${i}`}fetchEventData(){const e=F("localStorage"),r=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{const e=t.localStorage.getItem(r);e&&(this.eventData=JSON.parse(e));const n=t.localStorage.getItem(i);n&&(this.anonId=n)}catch(e){z("Unable to read from LocalStorage")}}saveEventData(){const e=F("localStorage"),r=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{t.localStorage.setItem(i,this.anonId),Object.keys(this.eventData).length>=1&&t.localStorage.setItem(r,JSON.stringify(this.eventData))}catch(e){z("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,r,i){if(!X.EVENTS_URL)return;const n=ae(X.EVENTS_URL);n.params.push(`access_token=${i||X.ACCESS_TOKEN||""}`);const o={event:this.type,created:new Date(e).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:V,skuId:re,userId:this.anonId},s=t?v(o,t):o,a={url:le(n),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=Pe(a,(e=>{this.pendingRequest=null,r(e),this.saveEventData(),this.processRequests(i)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const he=new class extends ue{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){X.EVENTS_URL&&X.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>ne(e)||oe(e)))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=ce(X.ACCESS_TOKEN),r=t?t.u:X.ACCESS_TOKEN;let i=r!==this.eventData.tokenU;E(this.anonId)||(this.anonId=w(),i=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(n),r=(n-this.eventData.lastSuccess)/864e5;i=i||r>=1||r<-1||e.getDate()!==t.getDate()}else i=!0;i?this.postEvent(n,{"enabled.telemetry":!1},(e=>{e||(this.eventData.lastSuccess=n,this.eventData.tokenU=r)}),e):this.processRequests()}},pe=he.postTurnstileEvent.bind(he),de=new class extends ue{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,r,i){this.skuToken=t,this.errorCb=i,X.EVENTS_URL&&(r||X.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},r):this.errorCb(new Error(ie)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:r}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),E(this.anonId)||(this.anonId=w()),this.postEvent(r,{skuToken:this.skuToken},(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e))}},fe=de.postMapLoadEvent.bind(de),me=new class extends ue{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,r,i){if(!X.API_URL||!X.SESSION_PATH)return;const n=ae(X.API_URL+X.SESSION_PATH);n.params.push(`sku=${t||""}`),n.params.push(`access_token=${i||X.ACCESS_TOKEN||""}`);const o={url:le(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=De(o,(e=>{this.pendingRequest=null,r(e),this.saveEventData(),this.processRequests(i)}))}getSessionAPI(e,t,r,i){this.skuToken=t,this.errorCb=i,X.SESSION_PATH&&X.API_URL&&(r||X.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},r):this.errorCb(new Error(ie)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:r}=this.queue.shift();t&&this.success[t]||this.getSession(r,this.skuToken,(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e)}},_e=me.getSessionAPI.bind(me),ge=new Set;let ye,ve=500,xe=50,be={};function we(e){const t=Ee(e);let r,i;t&&t.forEach((e=>{const t=e.split("=");"language"===t[0]?r=t[1]:"worldview"===t[0]&&(i=t[1])}));let n="mapbox-tiles";return r&&(n+=`-${r}`),i&&(n+=`-${i}`),n}function Te(e){t.caches&&!be[e]&&(be[e]=t.caches.open(e))}function Ee(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}function Se(e){const t=e.indexOf("?");if(t<0)return e;const r=Ee(e).filter((e=>{const t=e.split("=");return"language"===t[0]||"worldview"===t[0]}));return r.length?`${e.slice(0,t)}?${r.join("&")}`:e.slice(0,t)}let Ce=1/0;const Ae={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(Ae);class ke extends Error{constructor(e,t,r){401===t&&oe(r)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=r}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ie=L()?()=>self.worker&&self.worker.referrer:()=>("blob:"===t.location.protocol?t.parent:t).location.href,Me=function(e,r){if(!(/^file:/.test(i=e.url)||/^file:/.test(Ie())&&!/^\w+:/.test(i))){if(t.fetch&&t.Request&&t.AbortController&&t.Request.prototype.hasOwnProperty("signal"))return function(e,r){const i=new t.AbortController,n=new t.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Ie(),signal:i.signal});let o=!1,s=!1;const a=(l=n.url).indexOf("sku=")>0&&oe(l);var l;"json"===e.type&&n.headers.set("Accept","application/json");const c=(i,o,l)=>{if(s)return;if(i&&"SecurityError"!==i.message&&z(i),o&&l)return u(o);const c=Date.now();t.fetch(n).then((t=>{if(t.ok){const e=a?t.clone():null;return u(t,e,c)}return r(new ke(t.statusText,t.status,e.url))})).catch((e=>{20!==e.code&&r(new Error(e.message))}))},u=(i,a,l)=>{("arrayBuffer"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text()).then((e=>{s||(a&&l&&function(e,r,i){const n=we(e.url);if(Te(n),!be[n])return;const o={status:r.status,statusText:r.statusText,headers:new t.Headers};r.headers.forEach(((e,t)=>o.headers.set(t,e)));const s=B(r.headers.get("Cache-Control")||"");if(s["no-store"])return;s["max-age"]&&o.headers.set("Expires",new Date(i+1e3*s["max-age"]).toUTCString());const a=o.headers.get("Expires");a&&(new Date(a).getTime()-i<42e4||function(e,t){if(void 0===ye)try{new Response(new ReadableStream),ye=!0}catch(e){ye=!1}ye?t(e.body):e.blob().then(t)}(r,(r=>{const i=new t.Response(r,o);Te(n),be[n]&&be[n].then((t=>t.put(Se(e.url),i))).catch((e=>z(e.message)))})))}(n,a,l),o=!0,r(null,e,i.headers.get("Cache-Control"),i.headers.get("Expires")))})).catch((e=>{s||r(new Error(e.message))}))};return a?function(e,t){const r=we(e.url);if(Te(r),!be[r])return t(null);const i=Se(e.url);be[r].then((e=>{e.match(i).then((r=>{const n=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),r=B(e.headers.get("Cache-Control")||"");return t>Date.now()&&!r["no-cache"]}(r);e.delete(i),n&&e.put(i,r.clone()),t(null,r,n)})).catch(t)})).catch(t)}(n,c):c(null,null),{cancel:()=>{s=!0,o||i.abort()}}}(e,r);if(L()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,r,void 0,!0)}var i;return function(e,r){const i=new t.XMLHttpRequest;i.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(i.responseType="arraybuffer");for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===e.credentials,i.onerror=()=>{r(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let t=i.response;if("json"===e.type)try{t=JSON.parse(i.response)}catch(e){return r(e)}r(null,t,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else r(new ke(i.statusText,i.status,e.url))},i.send(e.body),{cancel:()=>i.abort()}}(e,r)},ze=function(e,t){return Me(v(e,{type:"arrayBuffer"}),t)},Pe=function(e,t){return Me(v(e,{method:"POST"}),t)},De=function(e,t){return Me(v(e,{method:"GET"}),t)};function Le(e){const r=t.document.createElement("a");return r.href=e,r.protocol===t.document.location.protocol&&r.host===t.document.location.host}const Be="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Re,Oe;Re=[],Oe=0;const Fe=function(e,r){if(Y.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Oe>=X.MAX_PARALLEL_IMAGE_REQUESTS){const t={requestParameters:e,callback:r,cancelled:!1,cancel(){this.cancelled=!0}};return Re.push(t),t}Oe++;let i=!1;const n=()=>{if(!i)for(i=!0,Oe--;Re.length&&Oe<X.MAX_PARALLEL_IMAGE_REQUESTS;){const e=Re.shift(),{requestParameters:t,callback:r,cancelled:i}=e;i||(e.cancel=Fe(t,r).cancel)}},o=ze(e,((e,i,o,s)=>{n(),e?r(e):i&&(t.createImageBitmap?function(e,r){const i=new t.Blob([new Uint8Array(e)],{type:"image/png"});t.createImageBitmap(i).then((e=>{r(null,e)})).catch((e=>{r(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.`))}))}(i,((e,t)=>r(e,t,o,s))):function(e,r){const i=new t.Image,n=t.URL;i.onload=()=>{r(null,i),n.revokeObjectURL(i.src),i.onload=null,t.requestAnimationFrame((()=>{i.src=Be}))},i.onerror=()=>r(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 o=new t.Blob([new Uint8Array(e)],{type:"image/png"});i.src=e.byteLength?n.createObjectURL(o):Be}(i,((e,t)=>r(e,t,o,s))))}));return{cancel:()=>{o.cancel(),n()}}};function Ne(e,t,r){r[e]&&-1!==r[e].indexOf(t)||(r[e]=r[e]||[],r[e].push(t))}function je(e,t,r){if(r&&r[e]){const i=r[e].indexOf(t);-1!==i&&r[e].splice(i,1)}}class Ue{constructor(e,t={}){v(this,t),this.type=e}}class Ve extends Ue{constructor(e,t={}){super("error",v({error:e},t))}}class qe{on(e,t){return this._listeners=this._listeners||{},Ne(e,t,this._listeners),this}off(e,t){return je(e,t,this._listeners),je(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Ne(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new Ue(e,t||{}));const r=e.type;if(this.listens(r)){e.target=this;const t=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const r of t)r.call(this,e);const i=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const t of i)je(r,t,this._oneTimeListeners),t.call(this,e);const n=this._eventedParent;n&&(v(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof Ve&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var Ge=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"}},"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":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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"}},"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":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"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"},"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"}}}');function $e(e,...t){for(const r of t)for(const t in r)e[t]=r[t];return e}function Ze(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function We(e){if(Array.isArray(e))return e.map(We);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const r in e)t[r]=We(e[r]);return t}return Ze(e)}class He extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var Xe=He;class Ye{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,r]of t)this.bindings[e]=r}concat(e){return new Ye(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var Ke=Ye;const Je={kind:"null"},Qe={kind:"number"},et={kind:"string"},tt={kind:"boolean"},rt={kind:"color"},it={kind:"object"},nt={kind:"value"},ot={kind:"collator"},st={kind:"formatted"},at={kind:"resolvedImage"};function lt(e,t){return{kind:"array",itemType:e,N:t}}function ct(e){if("array"===e.kind){const t=ct(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const ut=[Je,Qe,et,tt,rt,st,it,lt(nt),at];function ht(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!ht(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of ut)if(!ht(e,t))return null}return`Expected ${ct(e)} but found ${ct(t)} instead.`}function pt(e,t){return t.some((t=>t.kind===e.kind))}function dt(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}function ft(e){var t={exports:{}};return e(t,t.exports),t.exports}var mt=ft((function(e,t){var r={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 i(e){return(e=Math.round(e))<0?0:e>255?255:e}function n(e){return i("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function o(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function s(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}try{t.parseCSSColor=function(e){var t,a=e.replace(/ /g,"").toLowerCase();if(a in r)return r[a].slice();if("#"===a[0])return 4===a.length?(t=parseInt(a.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===a.length&&(t=parseInt(a.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var u=a.substr(0,l),h=a.substr(l+1,c-(l+1)).split(","),p=1;switch(u){case"rgba":if(4!==h.length)return null;p=o(h.pop());case"rgb":return 3!==h.length?null:[n(h[0]),n(h[1]),n(h[2]),p];case"hsla":if(4!==h.length)return null;p=o(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=o(h[1]),m=o(h[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[i(255*s(g,_,d+1/3)),i(255*s(g,_,d)),i(255*s(g,_,d-1/3)),p];default:return null}}return null}}catch(e){}}));class _t{constructor(e,t,r,i=1){this.r=e,this.g=t,this.b=r,this.a=i}static parse(e){if(!e)return;if(e instanceof _t)return e;if("string"!=typeof e)return;const t=mt.parseCSSColor(e);return t?new _t(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,r,i]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(r)},${i})`}toArray(){const{r:e,g:t,b:r,a:i}=this;return 0===i?[0,0,0,0]:[255*e/i,255*t/i,255*r/i,i]}toArray01(){const{r:e,g:t,b:r,a:i}=this;return 0===i?[0,0,0,0]:[e/i,t/i,r/i,i]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:r,a:i}=this;return[e,t,r,i]}}_t.black=new _t(0,0,0,1),_t.white=new _t(1,1,1,1),_t.transparent=new _t(0,0,0,0),_t.red=new _t(1,0,0,1),_t.blue=new _t(0,0,1,1);var gt=_t;class yt{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class vt{constructor(e,t,r,i,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=r,this.fontStack=i,this.textColor=n}}class xt{constructor(e){this.sections=e}static fromString(e){return new xt([new vt(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.name.length))}static factory(e){return e instanceof xt?e:xt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const r={};t.fontStack&&(r["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(r["font-scale"]=t.scale),t.textColor&&(r["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(r)}return e}}class bt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new bt({name:e,available:!1}):null}serialize(){return["image",this.name]}}function wt(e,t,r,i){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===i||"number"==typeof i&&i>=0&&i<=1?null:`Invalid rgba value [${[e,t,r,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof i?[e,t,r,i]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Tt(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof gt)return!0;if(e instanceof yt)return!0;if(e instanceof xt)return!0;if(e instanceof bt)return!0;if(Array.isArray(e)){for(const t of e)if(!Tt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Tt(e[t]))return!1;return!0}return!1}function Et(e){if(null===e)return Je;if("string"==typeof e)return et;if("boolean"==typeof e)return tt;if("number"==typeof e)return Qe;if(e instanceof gt)return rt;if(e instanceof yt)return ot;if(e instanceof xt)return st;if(e instanceof bt)return at;if(Array.isArray(e)){const t=e.length;let r;for(const t of e){const e=Et(t);if(r){if(r===e)continue;r=nt;break}r=e}return lt(r||nt,t)}return it}function St(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof gt||e instanceof xt||e instanceof bt?e.toString():JSON.stringify(e)}class Ct{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Tt(e[1]))return t.error("invalid value");const r=e[1];let i=Et(r);const n=t.expectedType;return"array"!==i.kind||0!==i.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(i=n),new Ct(i,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof gt?["rgba"].concat(this.value.toArray()):this.value instanceof xt?this.value.serialize():this.value}}var At=Ct,kt=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const It={string:et,number:Qe,boolean:tt,object:it};class Mt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r,i=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const r=e[1];if("string"!=typeof r||!(r in It)||"object"===r)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=It[r],i++}else n=nt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],i++}r=lt(n,o)}else r=It[n];const o=[];for(;i<e.length;i++){const r=t.parse(e[i],i,nt);if(!r)return null;o.push(r)}return new Mt(r,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const r=this.args[t].evaluate(e);if(!ht(this.type,Et(r)))return r;if(t===this.args.length-1)throw new kt(`Expected value to be of type ${ct(this.type)}, but found ${ct(Et(r))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const r=e.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){t.push(r.kind);const i=e.N;("number"==typeof i||this.args.length>1)&&t.push(i)}}return t.concat(this.args.map((e=>e.serialize())))}}var zt=Mt;class Pt{constructor(e){this.type=st,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return t.error("First argument must be an image or text section.");const i=[];let n=!1;for(let r=1;r<=e.length-1;++r){const o=e[r];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,Qe),!e))return null;let r=null;if(o["text-font"]&&(r=t.parse(o["text-font"],1,lt(et)),!r))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,rt),!s))return null;const a=i[i.length-1];a.scale=e,a.font=r,a.textColor=s}else{const o=t.parse(e[r],1,nt);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,i.push({content:o,scale:null,font:null,textColor:null})}}return new Pt(i)}evaluate(e){return new xt(this.sections.map((t=>{const r=t.content.evaluate(e);return Et(r)===at?new vt("",r,null,null,null):new vt(St(r),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const r={};t.scale&&(r["font-scale"]=t.scale.serialize()),t.font&&(r["text-font"]=t.font.serialize()),t.textColor&&(r["text-color"]=t.textColor.serialize()),e.push(r)}return e}}class Dt{constructor(e){this.type=at,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const r=t.parse(e[1],1,et);return r?new Dt(r):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),r=bt.fromString(t);return r&&e.availableImages&&(r.available=e.availableImages.indexOf(t)>-1),r}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Lt={"to-boolean":tt,"to-color":rt,"to-number":Qe,"to-string":et};class Bt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[0];if(("to-boolean"===r||"to-string"===r)&&2!==e.length)return t.error("Expected one argument.");const i=Lt[r],n=[];for(let r=1;r<e.length;r++){const i=t.parse(e[r],r,nt);if(!i)return null;n.push(i)}return new Bt(i,n)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,r;for(const i of this.args){if(t=i.evaluate(e),r=null,t instanceof gt)return t;if("string"==typeof t){const r=e.parseColor(t);if(r)return r}else if(Array.isArray(t)&&(r=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:wt(t[0],t[1],t[2],t[3]),!r))return new gt(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new kt(r||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const r of this.args){if(t=r.evaluate(e),null===t)return 0;const i=Number(t);if(!isNaN(i))return i}throw new kt(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?xt.fromString(St(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?bt.fromString(St(this.args[0].evaluate(e))):St(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Pt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Dt(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Rt=Bt;const Ot=["Unknown","Point","LineString","Polygon"];var Ft=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&&"id"in this.feature&&this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ot[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 e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:r,y:i}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*t-e[0])+this.featureDistanceData.bearing[1]*(i*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=gt.parse(e)),t}};class Nt{constructor(e,t,r,i){this.name=e,this.type=t,this._evaluate=r,this.args=i}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((e=>e.serialize())))}static parse(e,t){const r=e[0],i=Nt.definitions[r];if(!i)return t.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(i)?i[0]:i.type,o=Array.isArray(i)?[[i[1],i[2]]]:i.overloads,s=o.filter((([t])=>!Array.isArray(t)||t.length===e.length-1));let a=null;for(const[i,o]of s){a=new pr(t.registry,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t<e.length;t++){const r=e[t],n=Array.isArray(i)?i[t-1]:i.type,o=a.parse(r,1+s.length,n);if(!o){l=!0;break}s.push(o)}if(!l)if(Array.isArray(i)&&i.length!==s.length)a.error(`Expected ${i.length} arguments, but found ${s.length} instead.`);else{for(let e=0;e<s.length;e++){const t=Array.isArray(i)?i[e]:i.type,r=s[e];a.concat(e+1).checkSubtype(t,r.type)}if(0===a.errors.length)return new Nt(r,n,o,s)}}if(1===s.length)t.errors.push(...a.errors);else{const r=(s.length?s:o).map((([e])=>{return t=e,Array.isArray(t)?`(${t.map(ct).join(", ")})`:`(${ct(t.type)}...)`;var t})).join(" | "),i=[];for(let r=1;r<e.length;r++){const n=t.parse(e[r],1+i.length);if(!n)return null;i.push(ct(n.type))}t.error(`Expected arguments of type ${r}, but found (${i.join(", ")}) instead.`)}return null}static register(e,t){Nt.definitions=t;for(const r in t)e[r]=Nt}}var jt=Nt;class Ut{constructor(e,t,r){this.type=ot,this.locale=r,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const r=e[1];if("object"!=typeof r||Array.isArray(r))return t.error("Collator options argument must be an object.");const i=t.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,tt);if(!i)return null;const n=t.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,tt);if(!n)return null;let o=null;return r.locale&&(o=t.parse(r.locale,1,et),!o)?null:new Ut(i,n,o)}evaluate(e){return new yt(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}const Vt=8192;function qt(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Gt(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function $t(e,t){const r=(180+e[0])/360,i=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(r*n*Vt),Math.round(i*n*Vt)]}function Zt(e,t,r){const i=e[0]-t[0],n=e[1]-t[1],o=e[0]-r[0],s=e[1]-r[1];return i*s-o*n==0&&i*o<=0&&n*s<=0}function Wt(e,t){let r=!1;for(let s=0,a=t.length;s<a;s++){const a=t[s];for(let t=0,s=a.length;t<s-1;t++){if(Zt(e,a[t],a[t+1]))return!1;(n=a[t])[1]>(i=e)[1]!=(o=a[t+1])[1]>i[1]&&i[0]<(o[0]-n[0])*(i[1]-n[1])/(o[1]-n[1])+n[0]&&(r=!r)}}var i,n,o;return r}function Ht(e,t){for(let r=0;r<t.length;r++)if(Wt(e,t[r]))return!0;return!1}function Xt(e,t,r,i){const n=i[0]-r[0],o=i[1]-r[1],s=(e[0]-r[0])*o-n*(e[1]-r[1]),a=(t[0]-r[0])*o-n*(t[1]-r[1]);return s>0&&a<0||s<0&&a>0}function Yt(e,t,r){for(const c of r)for(let r=0;r<c.length-1;++r)if(0!=(a=[(s=c[r+1])[0]-(o=c[r])[0],s[1]-o[1]])[0]*(l=[(n=t)[0]-(i=e)[0],n[1]-i[1]])[1]-a[1]*l[0]&&Xt(i,n,o,s)&&Xt(o,s,i,n))return!0;var i,n,o,s,a,l;return!1}function Kt(e,t){for(let r=0;r<e.length;++r)if(!Wt(e[r],t))return!1;for(let r=0;r<e.length-1;++r)if(Yt(e[r],e[r+1],t))return!1;return!0}function Jt(e,t){for(let r=0;r<t.length;r++)if(Kt(e,t[r]))return!0;return!1}function Qt(e,t,r){const i=[];for(let n=0;n<e.length;n++){const o=[];for(let i=0;i<e[n].length;i++){const s=$t(e[n][i],r);qt(t,s),o.push(s)}i.push(o)}return i}function er(e,t,r){const i=[];for(let n=0;n<e.length;n++){const o=Qt(e[n],t,r);i.push(o)}return i}function tr(e,t,r,i){if(e[0]<r[0]||e[0]>r[2]){const t=.5*i;let n=e[0]-r[0]>t?-i:r[0]-e[0]>t?i:0;0===n&&(n=e[0]-r[2]>t?-i:r[2]-e[0]>t?i:0),e[0]+=n}qt(t,e)}function rr(e,t,r,i){const n=Math.pow(2,i.z)*Vt,o=[i.x*Vt,i.y*Vt],s=[];if(!e)return s;for(const i of e)for(const e of i){const i=[e.x+o[0],e.y+o[1]];tr(i,t,r,n),s.push(i)}return s}function ir(e,t,r,i){const n=Math.pow(2,i.z)*Vt,o=[i.x*Vt,i.y*Vt],s=[];if(!e)return s;for(const r of e){const e=[];for(const i of r){const r=[i.x+o[0],i.y+o[1]];qt(t,r),e.push(r)}s.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const i of e)tr(i,t,r,n)}var a;return s}class nr{constructor(e,t){this.type=tt,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Tt(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const r=t.features[e].geometry.type;if("Polygon"===r||"MultiPolygon"===r)return new nr(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new nr(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new nr(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=Qt(t.coordinates,i,n),s=rr(e.geometry(),r,i,n);if(!Gt(r,i))return!1;for(const e of s)if(!Wt(e,o))return!1}if("MultiPolygon"===t.type){const o=er(t.coordinates,i,n),s=rr(e.geometry(),r,i,n);if(!Gt(r,i))return!1;for(const e of s)if(!Ht(e,o))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){const o=Qt(t.coordinates,i,n),s=ir(e.geometry(),r,i,n);if(!Gt(r,i))return!1;for(const e of s)if(!Kt(e,o))return!1}if("MultiPolygon"===t.type){const o=er(t.coordinates,i,n),s=ir(e.geometry(),r,i,n);if(!Gt(r,i))return!1;for(const e of s)if(!Jt(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var or=nr;function sr(e){if(e instanceof jt){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof or)return!1;let t=!0;return e.eachChild((e=>{t&&!sr(e)&&(t=!1)})),t}function ar(e){if(e instanceof jt&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!ar(e)&&(t=!1)})),t}function lr(e,t){if(e instanceof jt&&t.indexOf(e.name)>=0)return!1;let r=!0;return e.eachChild((e=>{r&&!lr(e,t)&&(r=!1)})),r}class cr{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const r=e[1];return t.scope.has(r)?new cr(r,t.scope.get(r)):t.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var ur=cr;class hr{constructor(e,t=[],r,i=new Ke,n=[]){this.registry=e,this.path=t,this.key=t.map((e=>`[${e}]`)).join(""),this.scope=i,this.errors=n,this.expectedType=r}parse(e,t,r,i,n={}){return t?this.concat(t,r,i)._parse(e,n):this._parse(e,n)}_parse(e,t){function r(e,t,r){return"assert"===r?new zt(t,[e]):"coerce"===r?new Rt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const i=e[0];if("string"!=typeof i)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 n=this.registry[i];if(n){let i=n.parse(e,this);if(!i)return null;if(this.expectedType){const e=this.expectedType,n=i.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(e,n))return null}else i=r(i,e,t.typeAnnotation||"coerce");else i=r(i,e,t.typeAnnotation||"assert")}if(!(i instanceof At)&&"resolvedImage"!==i.type.kind&&dr(i)){const t=new Ft;try{i=new At(i.type,i.evaluate(t))}catch(e){return this.error(e.message),null}}return i}return this.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,r){const i="number"==typeof e?this.path.concat(e):this.path,n=r?this.scope.concat(r):this.scope;return new hr(this.registry,i,t||null,n,this.errors)}error(e,...t){const r=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Xe(r,e))}checkSubtype(e,t){const r=ht(e,t);return r&&this.error(r),r}}var pr=hr;function dr(e){if(e instanceof ur)return dr(e.boundExpression);if(e instanceof jt&&"error"===e.name)return!1;if(e instanceof Ut)return!1;if(e instanceof or)return!1;const t=e instanceof Rt||e instanceof zt;let r=!0;return e.eachChild((e=>{r=t?r&&dr(e):r&&e instanceof At})),!!r&&sr(e)&&lr(e,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function fr(e,t){const r=e.length-1;let i,n,o=0,s=r,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),i=e[a],n=e[a+1],i<=t){if(a===r||t<n)return a;o=a+1}else{if(!(i>t))throw new kt("Input is not a number.");s=a-1}return 0}class mr{constructor(e,t,r){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const r=t.parse(e[1],1,Qe);if(!r)return null;const i=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let r=1;r<e.length;r+=2){const o=1===r?-1/0:e[r],s=e[r+1],a=r,l=r+1;if("number"!=typeof o)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(i.length&&i[i.length-1][0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,i.push([o,c])}return new mr(n,r,i)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const i=this.input.evaluate(e);if(i<=t[0])return r[0].evaluate(e);const n=t.length;return i>=t[n-1]?r[n-1].evaluate(e):r[fr(t,i)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var _r=mr;function gr(e,t,r){return e*(1-r)+t*r}var yr=Object.freeze({__proto__:null,number:gr,color:function(e,t,r){return new gt(gr(e.r,t.r,r),gr(e.g,t.g,r),gr(e.b,t.b,r),gr(e.a,t.a,r))},array:function(e,t,r){return e.map(((e,i)=>gr(e,t[i],r)))}});const vr=.95047,xr=1.08883,br=4/29,wr=6/29,Tr=3*wr*wr,Er=Math.PI/180,Sr=180/Math.PI;function Cr(e){return e>.008856451679035631?Math.pow(e,1/3):e/Tr+br}function Ar(e){return e>wr?e*e*e:Tr*(e-br)}function kr(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Ir(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Mr(e){const t=Ir(e.r),r=Ir(e.g),i=Ir(e.b),n=Cr((.4124564*t+.3575761*r+.1804375*i)/vr),o=Cr((.2126729*t+.7151522*r+.072175*i)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-Cr((.0193339*t+.119192*r+.9503041*i)/xr)),alpha:e.a}}function zr(e){let t=(e.l+16)/116,r=isNaN(e.a)?t:t+e.a/500,i=isNaN(e.b)?t:t-e.b/200;return t=1*Ar(t),r=vr*Ar(r),i=xr*Ar(i),new gt(kr(3.2404542*r-1.5371385*t-.4985314*i),kr(-.969266*r+1.8760108*t+.041556*i),kr(.0556434*r-.2040259*t+1.0572252*i),e.alpha)}function Pr(e,t,r){const i=t-e;return e+r*(i>180||i<-180?i-360*Math.round(i/360):i)}const Dr={forward:Mr,reverse:zr,interpolate:function(e,t,r){return{l:gr(e.l,t.l,r),a:gr(e.a,t.a,r),b:gr(e.b,t.b,r),alpha:gr(e.alpha,t.alpha,r)}}},Lr={forward:function(e){const{l:t,a:r,b:i}=Mr(e),n=Math.atan2(i,r)*Sr;return{h:n<0?n+360:n,c:Math.sqrt(r*r+i*i),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Er,r=e.c;return zr({l:e.l,a:Math.cos(t)*r,b:Math.sin(t)*r,alpha:e.alpha})},interpolate:function(e,t,r){return{h:Pr(e.h,t.h,r),c:gr(e.c,t.c,r),l:gr(e.l,t.l,r),alpha:gr(e.alpha,t.alpha,r)}}};var Br=Object.freeze({__proto__:null,lab:Dr,hcl:Lr});class Rr{constructor(e,t,r,i,n){this.type=e,this.operator=t,this.interpolation=r,this.input=i,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,n){let o=0;if("exponential"===e.name)o=Or(t,e.base,i,n);else if("linear"===e.name)o=Or(t,1,i,n);else if("cubic-bezier"===e.name){const s=e.controlPoints;o=new r(s[0],s[1],s[2],s[3]).solve(Or(t,1,i,n))}return o}static parse(e,t){let[r,i,n,...o]=e;if(!Array.isArray(i)||0===i.length)return t.error("Expected an interpolation type expression.",1);if("linear"===i[0])i={name:"linear"};else if("exponential"===i[0]){const e=i[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);i={name:"exponential",base:e}}else{if("cubic-bezier"!==i[0])return t.error(`Unknown interpolation type ${String(i[0])}`,1,0);{const e=i.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);i={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,Qe),!n)return null;const s=[];let a=null;"interpolate-hcl"===r||"interpolate-lab"===r?a=rt:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e<o.length;e+=2){const r=o[e],i=o[e+1],n=e+3,l=e+4;if("number"!=typeof r)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s[s.length-1][0]>=r)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(i,l,a);if(!c)return null;a=a||c.type,s.push([r,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Rr(a,r,i,n,s):t.error(`Type ${ct(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const i=this.input.evaluate(e);if(i<=t[0])return r[0].evaluate(e);const n=t.length;if(i>=t[n-1])return r[n-1].evaluate(e);const o=fr(t,i),s=Rr.interpolationFactor(this.interpolation,i,t[o],t[o+1]),a=r[o].evaluate(e),l=r[o+1].evaluate(e);return"interpolate"===this.operator?yr[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Lr.reverse(Lr.interpolate(Lr.forward(a),Lr.forward(l),s)):Dr.reverse(Dr.interpolate(Dr.forward(a),Dr.forward(l),s))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let e=0;e<this.labels.length;e++)t.push(this.labels[e],this.outputs[e].serialize());return t}}function Or(e,t,r,i){const n=i-r,o=e-r;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}var Fr=Rr;class Nr{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument.");let r=null;const i=t.expectedType;i&&"value"!==i.kind&&(r=i);const n=[];for(const i of e.slice(1)){const e=t.parse(i,1+n.length,r,void 0,{typeAnnotation:"omit"});if(!e)return null;r=r||e.type,n.push(e)}const o=i&&n.some((e=>ht(i,e.type)));return new Nr(o?nt:r,n)}evaluate(e){let t,r=null,i=0;for(const n of this.args){if(i++,r=n.evaluate(e),r&&r instanceof bt&&!r.available&&(t||(t=r),r=null,i===this.args.length))return t;if(null!==r)break}return r}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var jr=Nr;class Ur{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let i=1;i<e.length-1;i+=2){const n=e[i];if("string"!=typeof n)return t.error(`Expected string, but found ${typeof n} instead.`,i);if(/[^a-zA-Z0-9_]/.test(n))return t.error("Variable names must contain only alphanumeric characters or '_'.",i);const o=t.parse(e[i+1],i+1);if(!o)return null;r.push([n,o])}const i=t.parse(e[e.length-1],e.length-1,t.expectedType,r);return i?new Ur(r,i):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,r]of this.bindings)e.push(t,r.serialize());return e.push(this.result.serialize()),e}}var Vr=Ur;class qr{constructor(e,t,r){this.type=e,this.index=t,this.input=r}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,Qe),i=t.parse(e[2],2,lt(t.expectedType||nt));return r&&i?new qr(i.type.itemType,r,i):null}evaluate(e){const t=this.index.evaluate(e),r=this.input.evaluate(e);if(t<0)throw new kt(`Array index out of bounds: ${t} < 0.`);if(t>=r.length)throw new kt(`Array index out of bounds: ${t} > ${r.length-1}.`);if(t!==Math.floor(t))throw new kt(`Array index must be an integer, but found ${t} instead.`);return r[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Gr=qr;class $r{constructor(e,t){this.type=tt,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,nt),i=t.parse(e[2],2,nt);return r&&i?pt(r.type,[tt,et,Qe,Je,nt])?new $r(r,i):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ct(r.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(null==r)return!1;if(!dt(t,["boolean","string","number","null"]))throw new kt(`Expected first argument to be of type boolean, string, number or null, but found ${ct(Et(t))} instead.`);if(!dt(r,["string","array"]))throw new kt(`Expected second argument to be of type array or string, but found ${ct(Et(r))} instead.`);return r.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Zr=$r;class Wr{constructor(e,t,r){this.type=Qe,this.needle=e,this.haystack=t,this.fromIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,nt),i=t.parse(e[2],2,nt);if(!r||!i)return null;if(!pt(r.type,[tt,et,Qe,Je,nt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${ct(r.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Qe);return n?new Wr(r,i,n):null}return new Wr(r,i)}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!dt(t,["boolean","string","number","null"]))throw new kt(`Expected first argument to be of type boolean, string, number or null, but found ${ct(Et(t))} instead.`);if(!dt(r,["string","array"]))throw new kt(`Expected second argument to be of type array or string, but found ${ct(Et(r))} instead.`);if(this.fromIndex){const i=this.fromIndex.evaluate(e);return r.indexOf(t,i)}return r.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Hr=Wr;class Xr{constructor(e,t,r,i,n,o){this.inputType=e,this.type=t,this.input=r,this.cases=i,this.outputs=n,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let r,i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const n={},o=[];for(let s=2;s<e.length-1;s+=2){let a=e[s];const l=e[s+1];Array.isArray(a)||(a=[a]);const c=t.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const e of a){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(r){if(c.checkSubtype(r,Et(e)))return null}else r=Et(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const u=t.parse(l,s,i);if(!u)return null;i=i||u.type,o.push(u)}const s=t.parse(e[1],1,nt);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,i);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(r,s.type)?null:new Xr(r,i,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Et(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),r=[],i={};for(const e of t){const t=i[this.cases[e]];void 0===t?(i[this.cases[e]]=r.length,r.push([this.cases[e],[e]])):r[t][1].push(e)}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,i]of r)e.push(1===i.length?n(i[0]):i.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var Yr=Xr;class Kr{constructor(e,t,r){this.type=e,this.branches=t,this.otherwise=r}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const i=[];for(let n=1;n<e.length-1;n+=2){const o=t.parse(e[n],n,tt);if(!o)return null;const s=t.parse(e[n+1],n+1,r);if(!s)return null;i.push([o,s]),r=r||s.type}const n=t.parse(e[e.length-1],e.length-1,r);return n?new Kr(r,i,n):null}evaluate(e){for(const[t,r]of this.branches)if(t.evaluate(e))return r.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,r]of this.branches)e(t),e(r);e(this.otherwise)}outputDefined(){return this.branches.every((([e,t])=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize())})),e}}var Jr=Kr;class Qr{constructor(e,t,r,i){this.type=e,this.input=t,this.beginIndex=r,this.endIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,nt),i=t.parse(e[2],2,Qe);if(!r||!i)return null;if(!pt(r.type,[lt(nt),et,nt]))return t.error(`Expected first argument to be of type array or string, but found ${ct(r.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Qe);return n?new Qr(r.type,r,i,n):null}return new Qr(r.type,r,i)}evaluate(e){const t=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(!dt(t,["string","array"]))throw new kt(`Expected first argument to be of type array or string, but found ${ct(Et(t))} instead.`);if(this.endIndex){const i=this.endIndex.evaluate(e);return t.slice(r,i)}return t.slice(r)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var ei=Qr;function ti(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function ri(e,t,r,i){return 0===i.compare(t,r)}function ii(e,t,r){const i="=="!==e&&"!="!==e;return class n{constructor(e,t,r){this.type=tt,this.lhs=e,this.rhs=t,this.collator=r,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const r=e[0];let o=t.parse(e[1],1,nt);if(!o)return null;if(!ti(r,o.type))return t.concat(1).error(`"${r}" comparisons are not supported for type '${ct(o.type)}'.`);let s=t.parse(e[2],2,nt);if(!s)return null;if(!ti(r,s.type))return t.concat(2).error(`"${r}" comparisons are not supported for type '${ct(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${ct(o.type)}' and '${ct(s.type)}'.`);i&&("value"===o.type.kind&&"value"!==s.type.kind?o=new zt(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new zt(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,ot),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(i&&this.hasUntypedArgument){const t=Et(o),r=Et(s);if(t.kind!==r.kind||"string"!==t.kind&&"number"!==t.kind)throw new kt(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${r.kind}) instead.`)}if(this.collator&&!i&&this.hasUntypedArgument){const e=Et(o),r=Et(s);if("string"!==e.kind||"string"!==r.kind)return t(n,o,s)}return this.collator?r(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize())})),t}}}const ni=ii("==",(function(e,t,r){return t===r}),ri),oi=ii("!=",(function(e,t,r){return t!==r}),(function(e,t,r,i){return!ri(0,t,r,i)})),si=ii("<",(function(e,t,r){return t<r}),(function(e,t,r,i){return i.compare(t,r)<0})),ai=ii(">",(function(e,t,r){return t>r}),(function(e,t,r,i){return i.compare(t,r)>0})),li=ii("<=",(function(e,t,r){return t<=r}),(function(e,t,r,i){return i.compare(t,r)<=0})),ci=ii(">=",(function(e,t,r){return t>=r}),(function(e,t,r,i){return i.compare(t,r)>=0}));class ui{constructor(e,t,r,i,n){this.type=et,this.number=e,this.locale=t,this.currency=r,this.minFractionDigits=i,this.maxFractionDigits=n}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const r=t.parse(e[1],1,Qe);if(!r)return null;const i=e[2];if("object"!=typeof i||Array.isArray(i))return t.error("NumberFormat options argument must be an object.");let n=null;if(i.locale&&(n=t.parse(i.locale,1,et),!n))return null;let o=null;if(i.currency&&(o=t.parse(i.currency,1,et),!o))return null;let s=null;if(i["min-fraction-digits"]&&(s=t.parse(i["min-fraction-digits"],1,Qe),!s))return null;let a=null;return i["max-fraction-digits"]&&(a=t.parse(i["max-fraction-digits"],1,Qe),!a)?null:new ui(r,n,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class hi{constructor(e){this.type=Qe,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const r=t.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?t.error(`Expected argument of type string or array, but found ${ct(r.type)} instead.`):new hi(r):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new kt(`Expected value to be of type string or array, but found ${ct(Et(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}const pi={"==":ni,"!=":oi,">":ai,"<":si,">=":ci,"<=":li,array:zt,at:Gr,boolean:zt,case:Jr,coalesce:jr,collator:Ut,format:Pt,image:Dt,in:Zr,"index-of":Hr,interpolate:Fr,"interpolate-hcl":Fr,"interpolate-lab":Fr,length:hi,let:Vr,literal:At,match:Yr,number:zt,"number-format":ui,object:zt,slice:ei,step:_r,string:zt,"to-boolean":Rt,"to-color":Rt,"to-number":Rt,"to-string":Rt,var:ur,within:or};function di(e,[t,r,i,n]){t=t.evaluate(e),r=r.evaluate(e),i=i.evaluate(e);const o=n?n.evaluate(e):1,s=wt(t,r,i,o);if(s)throw new kt(s);return new gt(t/255*o,r/255*o,i/255*o,o)}function fi(e,t){return e in t}function mi(e,t){const r=t[e];return void 0===r?null:r}function _i(e){return{type:e}}jt.register(pi,{error:[{kind:"error"},[et],(e,[t])=>{throw new kt(t.evaluate(e))}],typeof:[et,[nt],(e,[t])=>ct(Et(t.evaluate(e)))],"to-rgba":[lt(Qe,4),[rt],(e,[t])=>t.evaluate(e).toArray()],rgb:[rt,[Qe,Qe,Qe],di],rgba:[rt,[Qe,Qe,Qe,Qe],di],has:{type:tt,overloads:[[[et],(e,[t])=>fi(t.evaluate(e),e.properties())],[[et,it],(e,[t,r])=>fi(t.evaluate(e),r.evaluate(e))]]},get:{type:nt,overloads:[[[et],(e,[t])=>mi(t.evaluate(e),e.properties())],[[et,it],(e,[t,r])=>mi(t.evaluate(e),r.evaluate(e))]]},"feature-state":[nt,[et],(e,[t])=>mi(t.evaluate(e),e.featureState||{})],properties:[it,[],e=>e.properties()],"geometry-type":[et,[],e=>e.geometryType()],id:[nt,[],e=>e.id()],zoom:[Qe,[],e=>e.globals.zoom],pitch:[Qe,[],e=>e.globals.pitch||0],"distance-from-center":[Qe,[],e=>e.distanceFromCenter()],"heatmap-density":[Qe,[],e=>e.globals.heatmapDensity||0],"line-progress":[Qe,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[Qe,[],e=>e.globals.skyRadialProgress||0],accumulated:[nt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Qe,_i(Qe),(e,t)=>{let r=0;for(const i of t)r+=i.evaluate(e);return r}],"*":[Qe,_i(Qe),(e,t)=>{let r=1;for(const i of t)r*=i.evaluate(e);return r}],"-":{type:Qe,overloads:[[[Qe,Qe],(e,[t,r])=>t.evaluate(e)-r.evaluate(e)],[[Qe],(e,[t])=>-t.evaluate(e)]]},"/":[Qe,[Qe,Qe],(e,[t,r])=>t.evaluate(e)/r.evaluate(e)],"%":[Qe,[Qe,Qe],(e,[t,r])=>t.evaluate(e)%r.evaluate(e)],ln2:[Qe,[],()=>Math.LN2],pi:[Qe,[],()=>Math.PI],e:[Qe,[],()=>Math.E],"^":[Qe,[Qe,Qe],(e,[t,r])=>Math.pow(t.evaluate(e),r.evaluate(e))],sqrt:[Qe,[Qe],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Qe,[Qe],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Qe,[Qe],(e,[t])=>Math.log(t.evaluate(e))],log2:[Qe,[Qe],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Qe,[Qe],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Qe,[Qe],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Qe,[Qe],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Qe,[Qe],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Qe,[Qe],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Qe,[Qe],(e,[t])=>Math.atan(t.evaluate(e))],min:[Qe,_i(Qe),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[Qe,_i(Qe),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[Qe,[Qe],(e,[t])=>Math.abs(t.evaluate(e))],round:[Qe,[Qe],(e,[t])=>{const r=t.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[Qe,[Qe],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Qe,[Qe],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[tt,[et,nt],(e,[t,r])=>e.properties()[t.value]===r.value],"filter-id-==":[tt,[nt],(e,[t])=>e.id()===t.value],"filter-type-==":[tt,[et],(e,[t])=>e.geometryType()===t.value],"filter-<":[tt,[et,nt],(e,[t,r])=>{const i=e.properties()[t.value],n=r.value;return typeof i==typeof n&&i<n}],"filter-id-<":[tt,[nt],(e,[t])=>{const r=e.id(),i=t.value;return typeof r==typeof i&&r<i}],"filter->":[tt,[et,nt],(e,[t,r])=>{const i=e.properties()[t.value],n=r.value;return typeof i==typeof n&&i>n}],"filter-id->":[tt,[nt],(e,[t])=>{const r=e.id(),i=t.value;return typeof r==typeof i&&r>i}],"filter-<=":[tt,[et,nt],(e,[t,r])=>{const i=e.properties()[t.value],n=r.value;return typeof i==typeof n&&i<=n}],"filter-id-<=":[tt,[nt],(e,[t])=>{const r=e.id(),i=t.value;return typeof r==typeof i&&r<=i}],"filter->=":[tt,[et,nt],(e,[t,r])=>{const i=e.properties()[t.value],n=r.value;return typeof i==typeof n&&i>=n}],"filter-id->=":[tt,[nt],(e,[t])=>{const r=e.id(),i=t.value;return typeof r==typeof i&&r>=i}],"filter-has":[tt,[nt],(e,[t])=>t.value in e.properties()],"filter-has-id":[tt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[tt,[lt(et)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[tt,[lt(nt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[tt,[et,lt(nt)],(e,[t,r])=>r.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[tt,[et,lt(nt)],(e,[t,r])=>function(e,t,r,i){for(;r<=i;){const n=r+i>>1;if(t[n]===e)return!0;t[n]>e?i=n-1:r=n+1}return!1}(e.properties()[t.value],r.value,0,r.value.length-1)],all:{type:tt,overloads:[[[tt,tt],(e,[t,r])=>t.evaluate(e)&&r.evaluate(e)],[_i(tt),(e,t)=>{for(const r of t)if(!r.evaluate(e))return!1;return!0}]]},any:{type:tt,overloads:[[[tt,tt],(e,[t,r])=>t.evaluate(e)||r.evaluate(e)],[_i(tt),(e,t)=>{for(const r of t)if(r.evaluate(e))return!0;return!1}]]},"!":[tt,[tt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[tt,[et],(e,[t])=>{const r=e.globals&&e.globals.isSupportedScript;return!r||r(t.evaluate(e))}],upcase:[et,[et],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[et,[et],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[et,_i(nt),(e,t)=>t.map((t=>St(t.evaluate(e)))).join("")],"resolved-locale":[et,[ot],(e,[t])=>t.evaluate(e).resolvedLocale()]});var gi=pi;function yi(e){return{result:"success",value:e}}function vi(e){return{result:"error",value:e}}function xi(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function bi(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function wi(e){return!!e.expression&&e.expression.interpolated}function Ti(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Ei(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Si(e){return e}function Ci(e,t){const r="color"===t.type,i=e.stops&&"object"==typeof e.stops[0][0],n=i||!(i||void 0!==e.property),o=e.type||(wi(t)?"exponential":"interval");if(r&&((e=$e({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],gt.parse(e[1])]))),e.default=gt.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!Br[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=Mi;else if("interval"===o)s=Ii;else if("categorical"===o){s=ki,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=zi}if(i){const r={},i=[];for(let t=0;t<e.stops.length;t++){const n=e.stops[t],o=n[0].zoom;void 0===r[o]&&(r[o]={zoom:o,type:e.type,property:e.property,default:e.default,stops:[]},i.push(o)),r[o].stops.push([n[0].value,n[1]])}const n=[];for(const e of i)n.push([r[e].zoom,Ci(r[e],t)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:Fr.interpolationFactor.bind(void 0,o),zoomStops:n.map((e=>e[0])),evaluate:({zoom:r},i)=>Mi({stops:n,base:e.base},t,r).evaluate(r,i)}}if(n){const r="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:r,interpolationFactor:Fr.interpolationFactor.bind(void 0,r),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:r})=>s(e,t,r,a,l)}}return{kind:"source",evaluate(r,i){const n=i&&i.properties?i.properties[e.property]:void 0;return void 0===n?Ai(e.default,t.default):s(e,t,n,a,l)}}}function Ai(e,t,r){return void 0!==e?e:void 0!==t?t:void 0!==r?r:void 0}function ki(e,t,r,i,n){return Ai(typeof r===n?i[r]:void 0,e.default,t.default)}function Ii(e,t,r){if("number"!==Ti(r))return Ai(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[i-1][0])return e.stops[i-1][1];const n=fr(e.stops.map((e=>e[0])),r);return e.stops[n][1]}function Mi(e,t,r){const i=void 0!==e.base?e.base:1;if("number"!==Ti(r))return Ai(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[n-1][0])return e.stops[n-1][1];const o=fr(e.stops.map((e=>e[0])),r),s=function(e,t,r,i){const n=i-r,o=e-r;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(r,i,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=yr[t.type]||Si;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Br[e.colorSpace];c=(e,r)=>t.reverse(t.interpolate(t.forward(e),t.forward(r),s))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==r)return c(t,r,s)}}:c(a,l,s)}function zi(e,t,r){return"color"===t.type?r=gt.parse(r):"formatted"===t.type?r=xt.fromString(r.toString()):"resolvedImage"===t.type?r=bt.fromString(r.toString()):Ti(r)===t.type||"enum"===t.type&&t.values[r]||(r=void 0),Ai(r,e.default,t.default)}class Pi{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new Ft,this._defaultValue=t?function(e){return"color"===e.type&&(Ei(e.default)||Array.isArray(e.default))?new gt(0,0,0,0):"color"===e.type?gt.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,r,i,n,o,s,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=r,this._evaluator.canonical=i||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,r,i,n,o,s,a){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=r||null,this._evaluator.canonical=i||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new kt(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function Di(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in gi}function Li(e,t){const r=new pr(gi,[],t?function(e){const t={color:rt,string:et,number:Qe,enum:et,boolean:tt,formatted:st,resolvedImage:at};return"array"===e.type?lt(t[e.value]||nt,e.length):t[e.type]}(t):void 0),i=r.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return i?yi(new Pi(i,t)):vi(r.errors)}class Bi{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!ar(t.expression)}evaluateWithoutErrorHandling(e,t,r,i,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,i,n,o)}evaluate(e,t,r,i,n,o){return this._styleExpression.evaluate(e,t,r,i,n,o)}}class Ri{constructor(e,t,r,i){this.kind=e,this.zoomStops=r,this._styleExpression=t,this.isStateDependent="camera"!==e&&!ar(t.expression),this.interpolationType=i}evaluateWithoutErrorHandling(e,t,r,i,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,i,n,o)}evaluate(e,t,r,i,n,o){return this._styleExpression.evaluate(e,t,r,i,n,o)}interpolationFactor(e,t,r){return this.interpolationType?Fr.interpolationFactor(this.interpolationType,e,t,r):0}}function Oi(e,t){if("error"===(e=Li(e,t)).result)return e;const r=e.value.expression,i=sr(r);if(!i&&!xi(t))return vi([new Xe("","data expressions not supported")]);const n=lr(r,["zoom","pitch","distance-from-center"]);if(!n&&!bi(t))return vi([new Xe("","zoom expressions not supported")]);const o=Ni(r);return o||n?o instanceof Xe?vi([o]):o instanceof Fr&&!wi(t)?vi([new Xe("",'"interpolate" expressions cannot be used with this property')]):yi(o?new Ri(i?"camera":"composite",e.value,o.labels,o instanceof Fr?o.interpolation:void 0):new Bi(i?"constant":"source",e.value)):vi([new Xe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Fi{constructor(e,t){this._parameters=e,this._specification=t,$e(this,Ci(this._parameters,this._specification))}static deserialize(e){return new Fi(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Ni(e){let t=null;if(e instanceof Vr)t=Ni(e.result);else if(e instanceof jr){for(const r of e.args)if(t=Ni(r),t)break}else(e instanceof _r||e instanceof Fr)&&e.input instanceof jt&&"zoom"===e.input.name&&(t=e);return t instanceof Xe||e.eachChild((e=>{const r=Ni(e);r instanceof Xe?t=r:!t&&r?t=new Xe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&r&&t!==r&&(t=new Xe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}class ji{constructor(e,t,r,i){this.message=(e?`${e}: `:"")+r,i&&(this.identifier=i),null!=t&&t.__line__&&(this.line=t.__line__)}}function Ui(e){const t=e.key,r=e.value,i=e.valueSpec||{},n=e.objectElementValidators||{},o=e.style,s=e.styleSpec;let a=[];const l=Ti(r);if("object"!==l)return[new ji(t,r,`object expected, ${l} found`)];for(const e in r){const l=e.split(".")[0],c=i[l]||i["*"];let u;n[l]?u=n[l]:i[l]?u=bn:n["*"]?u=n["*"]:i["*"]&&(u=bn),u?a=a.concat(u({key:(t?`${t}.`:t)+e,value:r[e],valueSpec:c,style:o,styleSpec:s,object:r,objectKey:e},r)):a.push(new ji(t,r[e],`unknown property "${e}"`))}for(const e in i)n[e]||i[e].required&&void 0===i[e].default&&void 0===r[e]&&a.push(new ji(t,r,`missing required property "${e}"`));return a}function Vi(e){const t=e.value,r=e.valueSpec,i=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||bn;if("array"!==Ti(t))return[new ji(o,t,`array expected, ${Ti(t)} found`)];if(r.length&&t.length!==r.length)return[new ji(o,t,`array length ${r.length} expected, length ${t.length} found`)];if(r["min-length"]&&t.length<r["min-length"])return[new ji(o,t,`array length at least ${r["min-length"]} expected, length ${t.length} found`)];let a={type:r.value,values:r.values,minimum:r.minimum,maximum:r.maximum,function:void 0};n.$version<7&&(a.function=r.function),"object"===Ti(r.value)&&(a=r.value);let l=[];for(let e=0;e<t.length;e++)l=l.concat(s({array:t,arrayIndex:e,value:t[e],valueSpec:a,style:i,styleSpec:n,key:`${o}[${e}]`}));return l}function qi(e){const t=e.key,r=e.value,i=e.valueSpec;let n=Ti(r);if("number"===n&&r!=r&&(n="NaN"),"number"!==n)return[new ji(t,r,`number expected, ${n} found`)];if("minimum"in i){let n=i.minimum;if("array"===Ti(i.minimum)&&(n=i.minimum[e.arrayIndex]),r<n)return[new ji(t,r,`${r} is less than the minimum value ${n}`)]}if("maximum"in i){let n=i.maximum;if("array"===Ti(i.maximum)&&(n=i.maximum[e.arrayIndex]),r>n)return[new ji(t,r,`${r} is greater than the maximum value ${n}`)]}return[]}function Gi(e){const t=e.valueSpec,r=Ze(e.value.type);let i,n,o,s={};const a="categorical"!==r&&void 0===e.value.property,l=!a,c="array"===Ti(e.value.stops)&&"array"===Ti(e.value.stops[0])&&"object"===Ti(e.value.stops[0][0]),u=Ui({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===r)return[new ji(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const i=e.value;return t=t.concat(Vi({key:e.key,value:i,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Ti(i)&&0===i.length&&t.push(new ji(e.key,i,"array must have at least one stop")),t},default:function(e){return bn({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===r&&a&&u.push(new ji(e.key,e.value,'missing required property "property"')),"identity"===r||e.value.stops||u.push(new ji(e.key,e.value,'missing required property "stops"')),"exponential"===r&&e.valueSpec.expression&&!wi(e.valueSpec)&&u.push(new ji(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!xi(e.valueSpec)?u.push(new ji(e.key,e.value,"property functions not supported")):a&&!bi(e.valueSpec)&&u.push(new ji(e.key,e.value,"zoom functions not supported"))),"categorical"!==r&&!c||void 0!==e.value.property||u.push(new ji(e.key,e.value,'"property" property is required')),u;function h(e){let r=[];const i=e.value,a=e.key;if("array"!==Ti(i))return[new ji(a,i,`array expected, ${Ti(i)} found`)];if(2!==i.length)return[new ji(a,i,`array length 2 expected, length ${i.length} found`)];if(c){if("object"!==Ti(i[0]))return[new ji(a,i,`object expected, ${Ti(i[0])} found`)];if(void 0===i[0].zoom)return[new ji(a,i,"object stop key must have zoom")];if(void 0===i[0].value)return[new ji(a,i,"object stop key must have value")];const t=Ze(i[0].zoom);if("number"!=typeof t)return[new ji(a,i[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return[new ji(a,i[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,n=void 0,s={}),r=r.concat(Ui({key:`${a}[0]`,value:i[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:qi,value:p}}))}else r=r.concat(p({key:`${a}[0]`,value:i[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},i));return Di(We(i[1]))?r.concat([new ji(`${a}[1]`,i[1],"expressions are not allowed in function stops.")]):r.concat(bn({key:`${a}[1]`,value:i[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function p(e,o){const a=Ti(e.value),l=Ze(e.value),c=null!==e.value?e.value:o;if(i){if(a!==i)return[new ji(e.key,c,`${a} stop domain type must match previous stop domain type ${i}`)]}else i=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new ji(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==r){let i=`number expected, ${a} found`;return xi(t)&&void 0===r&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ji(e.key,c,i)]}return"categorical"!==r||"number"!==a||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===a&&"number"==typeof l&&"number"==typeof n&&void 0!==n&&l<n?[new ji(e.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===r&&l in s?[new ji(e.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new ji(e.key,c,`integer expected, found ${String(l)}`)]}}function $i(e){const t=("property"===e.expressionContext?Oi:Li)(We(e.value),e.valueSpec);if("error"===t.result)return t.value.map((t=>new ji(`${e.key}${t.key}`,e.value,t.message)));const r=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!r.outputDefined())return[new ji(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!ar(r))return[new ji(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return Zi(r,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!lr(r,["zoom","feature-state"]))return[new ji(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!sr(r))return[new ji(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Zi(e,t){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const i=[];return e instanceof jt&&r.has(e.name)?[new ji(t.key,t.value,`["${e.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(e.eachChild((e=>{i.push(...Zi(e,t))})),i)}function Wi(e){const t=e.key,r=e.value,i=e.valueSpec,n=[];return Array.isArray(i.values)?-1===i.values.indexOf(Ze(r))&&n.push(new ji(t,r,`expected one of [${i.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(i.values).indexOf(Ze(r))&&n.push(new ji(t,r,`expected one of [${Object.keys(i.values).join(", ")}], ${JSON.stringify(r)} found`)),n}function Hi(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Hi(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Xi(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Hi(e)||(e=rn(e));const r=e;let i=!0;try{i=function(e){if(!Ji(e))return e;let t=We(e);return Ki(t),t=Yi(t),t}(r)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(r,null,2)}\n `)}const n=Ge[`filter_${t}`],o=Li(i,n);let s=null;if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(e,t,r)=>o.value.evaluate(e,t,{},r);let a=null,l=null;if(i!==r){const e=Li(r,n);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a=(t,r,i,n,o)=>e.value.evaluate(t,r,{},i,void 0,void 0,n,o),l=!sr(e.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:tn(i),needFeature:!!l}}function Yi(e){if(!Array.isArray(e))return e;const t=function(e){if(Qi.has(e[0]))for(let t=1;t<e.length;t++)if(Ji(e[t]))return!0;return e}(e);return!0===t?t:t.map((e=>Yi(e)))}function Ki(e){let t=!1;const r=[];if("case"===e[0]){for(let i=1;i<e.length-1;i+=2)t=t||Ji(e[i]),r.push(e[i+1]);r.push(e[e.length-1])}else if("match"===e[0]){t=t||Ji(e[1]);for(let t=2;t<e.length-1;t+=2)r.push(e[t+1]);r.push(e[e.length-1])}else if("step"===e[0]){t=t||Ji(e[1]);for(let t=1;t<e.length-1;t+=2)r.push(e[t+1])}t&&(e.length=0,e.push("any",...r));for(let t=1;t<e.length;t++)Ki(e[t])}function Ji(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t<e.length;t++)if(Ji(e[t]))return!0;return!1}const Qi=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function en(e,t){return e<t?-1:e>t?1:0}function tn(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let t=1;t<e.length;t++)if(tn(e[t]))return!0;return!1}function rn(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?nn(e[1],e[2],"=="):"!="===t?an(nn(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?nn(e[1],e[2],t):"any"===t?(r=e.slice(1),["any"].concat(r.map(rn))):"all"===t?["all"].concat(e.slice(1).map(rn)):"none"===t?["all"].concat(e.slice(1).map(rn).map(an)):"in"===t?on(e[1],e.slice(2)):"!in"===t?an(on(e[1],e.slice(2))):"has"===t?sn(e[1]):"!has"===t?an(sn(e[1])):"within"!==t||e;var r}function nn(e,t,r){switch(e){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,e,t]}}function on(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(en)]]:["filter-in-small",e,["literal",t]]}}function sn(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function an(e){return["!",e]}function ln(e){return Hi(We(e.value))?$i($e({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${e.layerType||"fill"}`]})):cn(e)}function cn(e){const t=e.value,r=e.key;if("array"!==Ti(t))return[new ji(r,t,`array expected, ${Ti(t)} found`)];const i=e.styleSpec;let n,o=[];if(t.length<1)return[new ji(r,t,"filter array must have at least 1 element")];switch(o=o.concat(Wi({key:`${r}[0]`,value:t[0],valueSpec:i.filter_operator,style:e.style,styleSpec:e.styleSpec})),Ze(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===Ze(t[1])&&o.push(new ji(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new ji(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(n=Ti(t[1]),"string"!==n&&o.push(new ji(`${r}[1]`,t[1],`string expected, ${n} found`)));for(let s=2;s<t.length;s++)n=Ti(t[s]),"$type"===Ze(t[1])?o=o.concat(Wi({key:`${r}[${s}]`,value:t[s],valueSpec:i.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&o.push(new ji(`${r}[${s}]`,t[s],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let i=1;i<t.length;i++)o=o.concat(cn({key:`${r}[${i}]`,value:t[i],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":n=Ti(t[1]),2!==t.length?o.push(new ji(r,t,`filter array for "${t[0]}" operator must have 2 elements`)):"string"!==n&&o.push(new ji(`${r}[1]`,t[1],`string expected, ${n} found`));break;case"within":n=Ti(t[1]),2!==t.length?o.push(new ji(r,t,`filter array for "${t[0]}" operator must have 2 elements`)):"object"!==n&&o.push(new ji(`${r}[1]`,t[1],`object expected, ${n} found`))}return o}function un(e,t){const r=e.key,i=e.style,n=e.styleSpec,o=e.value,s=e.objectKey,a=n[`${t}_${e.layerType}`];if(!a)return[];const l=s.match(/^(.*)-transition$/);if("paint"===t&&l&&a[l[1]]&&a[l[1]].transition)return bn({key:r,value:o,valueSpec:n.transition,style:i,styleSpec:n});const c=e.valueSpec||a[s];if(!c)return[new ji(r,o,`unknown property "${s}"`)];let u;if("string"===Ti(o)&&xi(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new ji(r,o,`"${s}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const h=[];return"symbol"===e.layerType&&("text-field"===s&&i&&!i.glyphs&&h.push(new ji(r,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===s&&Ei(We(o))&&"identity"===Ze(o.type)&&h.push(new ji(r,o,'"text-font" does not support identity functions'))),h.concat(bn({key:e.key,value:o,valueSpec:c,style:i,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:s}))}function hn(e){return un(e,"paint")}function pn(e){return un(e,"layout")}function dn(e){let t=[];const r=e.value,i=e.key,n=e.style,o=e.styleSpec;r.type||r.ref||t.push(new ji(i,r,'either "type" or "ref" is required'));let s=Ze(r.type);const a=Ze(r.ref);if(r.id){const o=Ze(r.id);for(let s=0;s<e.arrayIndex;s++){const e=n.layers[s];Ze(e.id)===o&&t.push(new ji(i,r.id,`duplicate layer id "${r.id}", previously used at line ${e.id.__line__}`))}}if("ref"in r){let e;["type","source","source-layer","filter","layout"].forEach((e=>{e in r&&t.push(new ji(i,r[e],`"${e}" is prohibited for ref layers`))})),n.layers.forEach((t=>{Ze(t.id)===a&&(e=t)})),e?e.ref?t.push(new ji(i,r.ref,"ref cannot reference another ref layer")):s=Ze(e.type):"string"==typeof a&&t.push(new ji(i,r.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s)if(r.source){const e=n.sources&&n.sources[r.source],o=e&&Ze(e.type);e?"vector"===o&&"raster"===s?t.push(new ji(i,r.source,`layer "${r.id}" requires a raster source`)):"raster"===o&&"raster"!==s?t.push(new ji(i,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==o||r["source-layer"]?"raster-dem"===o&&"hillshade"!==s?t.push(new ji(i,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new ji(i,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new ji(i,r,`layer "${r.id}" must specify a "source-layer"`)):t.push(new ji(i,r.source,`source "${r.source}" not found`))}else t.push(new ji(i,r,'missing required property "source"'));return t=t.concat(Ui({key:i,value:r,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>bn({key:`${i}.type`,value:r.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:r,objectKey:"type"}),filter:e=>ln($e({layerType:s},e)),layout:e=>Ui({layer:r,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>pn($e({layerType:s},e))}}),paint:e=>Ui({layer:r,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>hn($e({layerType:s},e))}})}})),t}function fn(e){const t=e.value,r=e.key,i=Ti(t);return"string"!==i?[new ji(r,t,`string expected, ${i} found`)]:[]}const mn={promoteId:function({key:e,value:t}){if("string"===Ti(t))return fn({key:e,value:t});{const r=[];for(const i in t)r.push(...fn({key:`${e}.${i}`,value:t[i]}));return r}}};function _n(e){const t=e.value,r=e.key,i=e.styleSpec,n=e.style;if(!t.type)return[new ji(r,t,'"type" is required')];const o=Ze(t.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=Ui({key:r,value:t,valueSpec:i[`source_${o.replace("-","_")}`],style:e.style,styleSpec:i,objectElementValidators:mn}),s;case"geojson":if(s=Ui({key:r,value:t,valueSpec:i.source_geojson,style:n,styleSpec:i,objectElementValidators:mn}),t.cluster)for(const e in t.clusterProperties){const[i,n]=t.clusterProperties[e],o="string"==typeof i?[i,["accumulated"],["get",e]]:i;s.push(...$i({key:`${r}.${e}.map`,value:n,expressionContext:"cluster-map"})),s.push(...$i({key:`${r}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return Ui({key:r,value:t,valueSpec:i.source_video,style:n,styleSpec:i});case"image":return Ui({key:r,value:t,valueSpec:i.source_image,style:n,styleSpec:i});case"canvas":return[new ji(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Wi({key:`${r}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,styleSpec:i})}}function gn(e){const t=e.value,r=e.styleSpec,i=r.light,n=e.style;let o=[];const s=Ti(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new ji("light",t,`object expected, ${s} found`)]),o;for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&i[s[1]]&&i[s[1]].transition?bn({key:e,value:t[e],valueSpec:r.transition,style:n,styleSpec:r}):i[e]?bn({key:e,value:t[e],valueSpec:i[e],style:n,styleSpec:r}):[new ji(e,t[e],`unknown property "${e}"`)])}return o}function yn(e){const t=e.value,r=e.key,i=e.style,n=e.styleSpec,o=n.terrain;let s=[];const a=Ti(t);if(void 0===t)return s;if("object"!==a)return s=s.concat([new ji("terrain",t,`object expected, ${a} found`)]),s;for(const e in t){const r=e.match(/^(.*)-transition$/);s=s.concat(r&&o[r[1]]&&o[r[1]].transition?bn({key:e,value:t[e],valueSpec:n.transition,style:i,styleSpec:n}):o[e]?bn({key:e,value:t[e],valueSpec:o[e],style:i,styleSpec:n}):[new ji(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=i.sources&&i.sources[t.source],n=e&&Ze(e.type);e?"raster-dem"!==n&&s.push(new ji(r,t.source,`terrain cannot be used with a source of type ${String(n)}, it only be used with a "raster-dem" source type`)):s.push(new ji(r,t.source,`source "${t.source}" not found`))}else s.push(new ji(r,t,'terrain is missing required property "source"'));return s}function vn(e){const t=e.value,r=e.style,i=e.styleSpec,n=i.fog;let o=[];const s=Ti(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new ji("fog",t,`object expected, ${s} found`)]),o;for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?bn({key:e,value:t[e],valueSpec:i.transition,style:r,styleSpec:i}):n[e]?bn({key:e,value:t[e],valueSpec:n[e],style:r,styleSpec:i}):[new ji(e,t[e],`unknown property "${e}"`)])}return o}const xn={"*":()=>[],array:Vi,boolean:function(e){const t=e.value,r=e.key,i=Ti(t);return"boolean"!==i?[new ji(r,t,`boolean expected, ${i} found`)]:[]},number:qi,color:function(e){const t=e.key,r=e.value,i=Ti(r);return"string"!==i?[new ji(t,r,`color expected, ${i} found`)]:null===mt.parseCSSColor(r)?[new ji(t,r,`color expected, "${r}" found`)]:[]},enum:Wi,filter:ln,function:Gi,layer:dn,object:Ui,source:_n,light:gn,terrain:yn,fog:vn,string:fn,formatted:function(e){return 0===fn(e).length?[]:$i(e)},resolvedImage:function(e){return 0===fn(e).length?[]:$i(e)},projection:function(e){const t=e.value,r=e.styleSpec,i=r.projection,n=e.style;let o=[];const s=Ti(t);if("object"===s)for(const e in t)o=o.concat(bn({key:e,value:t[e],valueSpec:i[e],style:n,styleSpec:r}));else"string"!==s&&(o=o.concat([new ji("projection",t,`object or string expected, ${s} found`)]));return o}};function bn(e){const t=e.value,r=e.valueSpec,i=e.styleSpec;return r.expression&&Ei(Ze(t))?Gi(e):r.expression&&Di(We(t))?$i(e):r.type&&xn[r.type]?xn[r.type](e):Ui($e({},e,{valueSpec:r.type?i[r.type]:r}))}function wn(e){const t=e.value,r=e.key,i=fn(e);return i.length||(-1===t.indexOf("{fontstack}")&&i.push(new ji(r,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&i.push(new ji(r,t,'"glyphs" url must include a "{range}" token'))),i}function Tn(e,t=Ge){return Cn(bn({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:wn,"*":()=>[]}}))}const En=e=>Cn(hn(e)),Sn=e=>Cn(pn(e));function Cn(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function An(e,t){let r=!1;if(t&&t.length)for(const i of t)e.fire(new Ve(new Error(i.message))),r=!0;return r}var kn=In;function In(e,t,r){var i=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(r=n[2]);for(var o=0;o<this.d*this.d;o++){var s=n[3+o],a=n[3+o+1];i.push(s===a?null:n.subarray(s,a))}var l=n[3+i.length+1];this.keys=n.subarray(n[3+i.length],l),this.bboxes=n.subarray(l),this.insert=this._insertReadonly}else{this.d=t+2*r;for(var c=0;c<this.d*this.d;c++)i.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=r,this.scale=t/e,this.uid=0;var u=r/t*e;this.min=-u,this.max=e+u}In.prototype.insert=function(e,t,r,i,n){this._forEachCell(t,r,i,n,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(n)},In.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},In.prototype._insertCell=function(e,t,r,i,n,o){this.cells[n].push(o)},In.prototype.query=function(e,t,r,i,n){var o=this.min,s=this.max;if(e<=o&&t<=o&&s<=r&&s<=i&&!n)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(e,t,r,i,this._queryCell,a,{},n),a},In.prototype._queryCell=function(e,t,r,i,n,o,s,a){var l=this.cells[n];if(null!==l)for(var c=this.keys,u=this.bboxes,h=0;h<l.length;h++){var p=l[h];if(void 0===s[p]){var d=4*p;(a?a(u[d+0],u[d+1],u[d+2],u[d+3]):e<=u[d+2]&&t<=u[d+3]&&r>=u[d+0]&&i>=u[d+1])?(s[p]=!0,o.push(c[p])):s[p]=!1}}},In.prototype._forEachCell=function(e,t,r,i,n,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(r),h=this._convertToCellCoord(i),p=l;p<=u;p++)for(var d=c;d<=h;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&n.call(this,e,t,r,i,f,o,s,a))return}},In.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},In.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},In.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=3+this.cells.length+1+1,r=0,i=0;i<this.cells.length;i++)r+=this.cells[i].length;var n=new Int32Array(t+r+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var o=t,s=0;s<e.length;s++){var a=e[s];n[3+s]=o,n.set(a,o),o+=a.length}return n[3+e.length]=o,n.set(this.keys,o),n[3+e.length+1]=o+=this.keys.length,n.set(this.bboxes,o),o+=this.bboxes.length,n.buffer};const Mn={};function zn(e,t,r={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Mn[t]={klass:e,omit:r.omit||[]}}zn(Object,"Object"),kn.serialize=function(e,t){const r=e.toArrayBuffer();return t&&t.push(r),{buffer:r}},kn.deserialize=function(e){return new kn(e.buffer)},Object.defineProperty(kn,"name",{value:"Grid"}),zn(kn,"Grid"),zn(gt,"Color"),zn(Error,"Error"),zn(ke,"AJAXError"),zn(bt,"ResolvedImage"),zn(Fi,"StylePropertyFunction"),zn(Pi,"StyleExpression",{omit:["_evaluator"]}),zn(Ri,"ZoomDependentExpression"),zn(Bi,"ZoomConstantExpression"),zn(jt,"CompoundExpression",{omit:["_evaluate"]});for(const e in gi)Mn[gi[e]._classRegistryKey]||zn(gi[e],`Expression${e}`);function Pn(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function Dn(e){return t.ImageBitmap&&e instanceof t.ImageBitmap}function Ln(e,r){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp)return e;if(Pn(e)||Dn(e))return r&&r.push(e),e;if(ArrayBuffer.isView(e)){const t=e;return r&&r.push(t.buffer),t}if(e instanceof t.ImageData)return r&&r.push(e.data.buffer),e;if(Array.isArray(e)){const t=[];for(const i of e)t.push(Ln(i,r));return t}if("object"==typeof e){const t=e.constructor,i=t._classRegistryKey;if(!i)throw new Error(`can't serialize object of unregistered class ${i}`);const n=t.serialize?t.serialize(e,r):{};if(!t.serialize){for(const t in e)e.hasOwnProperty(t)&&(Mn[i].omit.indexOf(t)>=0||(n[t]=Ln(e[t],r)));e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(n.$name=i),n}throw new Error("can't serialize object of type "+typeof e)}function Bn(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||Pn(e)||Dn(e)||ArrayBuffer.isView(e)||e instanceof t.ImageData)return e;if(Array.isArray(e))return e.map(Bn);if("object"==typeof e){const t=e.$name||"Object",{klass:r}=Mn[t];if(!r)throw new Error(`can't deserialize unregistered class ${t}`);if(r.deserialize)return r.deserialize(e);const i=Object.create(r.prototype);for(const t of Object.keys(e))"$name"!==t&&(i[t]=Bn(e[t]));return i}throw new Error("can't deserialize object of type "+typeof e)}class Rn{constructor(){this.first=!0}update(e,t){const r=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=r,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=r,!0):(this.lastFloorZoom>r?(this.lastIntegerZoom=r+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<r&&(this.lastIntegerZoom=r,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=r,!0))}}const On=e=>e>=1536&&e<=1791,Fn=e=>e>=1872&&e<=1919,Nn=e=>e>=2208&&e<=2303,jn=e=>e>=11904&&e<=12031,Un=e=>e>=12032&&e<=12255,Vn=e=>e>=12272&&e<=12287,qn=e=>e>=12288&&e<=12351,Gn=e=>e>=12352&&e<=12447,$n=e=>e>=12448&&e<=12543,Zn=e=>e>=12544&&e<=12591,Wn=e=>e>=12704&&e<=12735,Hn=e=>e>=12736&&e<=12783,Xn=e=>e>=12784&&e<=12799,Yn=e=>e>=12800&&e<=13055,Kn=e=>e>=13056&&e<=13311,Jn=e=>e>=13312&&e<=19903,Qn=e=>e>=19968&&e<=40959,eo=e=>e>=40960&&e<=42127,to=e=>e>=42128&&e<=42191,ro=e=>e>=44032&&e<=55215,io=e=>e>=63744&&e<=64255,no=e=>e>=64336&&e<=65023,oo=e=>e>=65040&&e<=65055,so=e=>e>=65072&&e<=65103,ao=e=>e>=65104&&e<=65135,lo=e=>e>=65136&&e<=65279,co=e=>e>=65280&&e<=65519;function uo(e){for(const t of e)if(fo(t.charCodeAt(0)))return!0;return!1}function ho(e){for(const t of e)if(!po(t.charCodeAt(0)))return!1;return!0}function po(e){return!(On(e)||Fn(e)||Nn(e)||no(e)||lo(e))}function fo(e){return!(746!==e&&747!==e&&(e<4352||!(Wn(e)||Zn(e)||so(e)&&!(e>=65097&&e<=65103)||io(e)||Kn(e)||jn(e)||Hn(e)||!(!qn(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Jn(e)||Qn(e)||Yn(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||ro(e)||Gn(e)||Vn(e)||(e=>e>=12688&&e<=12703)(e)||Un(e)||Xn(e)||$n(e)&&12540!==e||!(!co(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!ao(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||oo(e)||(e=>e>=19904&&e<=19967)(e)||eo(e)||to(e))))}function mo(e){return!(fo(e)||function(e){return!!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||qn(e)||$n(e)||(e=>e>=57344&&e<=63743)(e)||so(e)||ao(e)||co(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function _o(e){return e>=1424&&e<=2303||no(e)||lo(e)}function go(e,t){return!(!t&&_o(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function yo(e){for(const t of e)if(_o(t.charCodeAt(0)))return!0;return!1}const vo="deferred",xo="loading",bo="loaded";let wo=null,To="unavailable",Eo=null;const So=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(To="error"),wo&&wo(e)};function Co(){Ao.fire(new Ue("pluginStateChange",{pluginStatus:To,pluginURL:Eo}))}const Ao=new qe,ko=function(){return To},Io=function(){if(To!==vo||!Eo)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");To=xo,Co(),Eo&&ze({url:Eo},(e=>{e?So(e):(To=bo,Co())}))},Mo={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>To===bo||null!=Mo.applyArabicShaping,isLoading:()=>To===xo,setState(e){To=e.pluginStatus,Eo=e.pluginURL},isParsed:()=>null!=Mo.applyArabicShaping&&null!=Mo.processBidirectionalText&&null!=Mo.processStyledBidirectionalText,getPluginURL:()=>Eo};class zo{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.zoomHistory=t.zoomHistory,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Rn,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const r of e)if(!go(r.charCodeAt(0),t))return!1;return!0}(e,Mo.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),r=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*r}:{fromScale:.5,toScale:1,t:1-(1-r)*t}}}class Po{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(Ei(e))return new Fi(e,t);if(Di(e)){const r=Oi(e,t);if("error"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return r.value}{let r=e;return"string"==typeof e&&"color"===t.type&&(r=gt.parse(e)),{kind:"constant",evaluate:()=>r}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,r){return this.property.possiblyEvaluate(this,e,t,r)}}class Do{constructor(e){this.property=e,this.value=new Po(e,void 0)}transitioned(e,t){return new Bo(this.property,this.value,t,v({},e.transition,this.transition),e.now)}untransitioned(){return new Bo(this.property,this.value,null,{},0)}}class Lo{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return I(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Do(this._values[e].property)),this._values[e].value=new Po(this._values[e].property,null===t?void 0:I(t))}getTransition(e){return I(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Do(this._values[e].property)),this._values[e].transition=I(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);void 0!==r&&(e[t]=r);const i=this.getTransition(t);void 0!==i&&(e[`${t}-transition`]=i)}return e}transitioned(e,t){const r=new Ro(this._properties);for(const i of Object.keys(this._values))r._values[i]=this._values[i].transitioned(e,t._values[i]);return r}untransitioned(){const e=new Ro(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Bo{constructor(e,t,r,i,n){const o=i.delay||0,s=i.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(i.delay||i.duration)&&(this.prior=r)}possiblyEvaluate(e,t,r){const i=e.now||0,n=this.value.possiblyEvaluate(e,t,r),o=this.prior;if(o){if(i>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(i<this.begin)return o.possiblyEvaluate(e,t,r);{const s=(i-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,r),n,h(s))}}return n}}class Ro{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,r){const i=new No(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].possiblyEvaluate(e,t,r);return i}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Oo{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return I(this._values[e].value)}setValue(e,t){this._values[e]=new Po(this._values[e].property,null===t?void 0:I(t))}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);void 0!==r&&(e[t]=r)}return e}possiblyEvaluate(e,t,r){const i=new No(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].possiblyEvaluate(e,t,r);return i}}class Fo{constructor(e,t,r){this.property=e,this.value=t,this.parameters=r}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,r,i){return this.property.evaluate(this.value,this.parameters,e,t,r,i)}}class No{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class jo{constructor(e){this.specification=e}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,r){const i=yr[this.specification.type];return i?i(e,t,r):e}}class Uo{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,r,i){return new Fo(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},r,i)}:e.expression,t)}interpolate(e,t,r){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new Fo(this,{kind:"constant",value:void 0},e.parameters);const i=yr[this.specification.type];return i?new Fo(this,{kind:"constant",value:i(e.value.value,t.value.value,r)},e.parameters):e}evaluate(e,t,r,i,n,o){return"constant"===e.kind?e.value:e.evaluate(t,r,i,n,o)}}class Vo extends Uo{possiblyEvaluate(e,t,r,i){if(void 0===e.value)return new Fo(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},r,i),o="resolvedImage"===e.property.specification.type&&"string"!=typeof n?n.name:n,s=this._calculate(o,o,o,t);return new Fo(this,{kind:"constant",value:s},t)}if("camera"===e.expression.kind){const r=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new Fo(this,{kind:"constant",value:r},t)}return new Fo(this,e.expression,t)}evaluate(e,t,r,i,n,o){if("source"===e.kind){const s=e.evaluate(t,r,i,n,o);return this._calculate(s,s,s,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},r,i),e.evaluate({zoom:Math.floor(t.zoom)},r,i),e.evaluate({zoom:Math.floor(t.zoom)+1},r,i),t):e.value}_calculate(e,t,r,i){return i.zoom>i.zoomHistory.lastIntegerZoom?{from:e,to:t,other:r}:{from:r,to:t,other:e}}interpolate(e){return e}}class qo{constructor(e){this.specification=e}possiblyEvaluate(e,t,r,i){if(void 0!==e.value){if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},r,i);return this._calculate(n,n,n,t)}return this._calculate(e.expression.evaluate(new zo(Math.floor(t.zoom-1),t)),e.expression.evaluate(new zo(Math.floor(t.zoom),t)),e.expression.evaluate(new zo(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,r,i){return i.zoom>i.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:r,to:t}}interpolate(e){return e}}class Go{constructor(e){this.specification=e}possiblyEvaluate(e,t,r,i){return!!e.expression.evaluate(t,null,{},r,i)}interpolate(){return!1}}class $o{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new zo(0,{});for(const r in e){const i=e[r];i.specification.overridable&&this.overridableProperties.push(r);const n=this.defaultPropertyValues[r]=new Po(i,void 0),o=this.defaultTransitionablePropertyValues[r]=new Do(i);this.defaultTransitioningPropertyValues[r]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=n.possiblyEvaluate(t)}}}function Zo(e,t){return 256*(e=f(Math.floor(e),0,255))+f(Math.floor(t),0,255)}zn(Uo,"DataDrivenProperty"),zn(jo,"DataConstantProperty"),zn(Vo,"CrossFadedDataDrivenProperty"),zn(qo,"CrossFadedProperty"),zn(Go,"ColorRampProperty");const Wo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ho{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Xo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Yo(e,t=1){let r=0,i=0;return{members:e.map((e=>{const n=Wo[e.type].BYTES_PER_ELEMENT,o=r=Ko(r,Math.max(t,n)),s=e.components||1;return i=Math.max(i,n),r+=n*s,{name:e.name,type:e.type,components:s,offset:o}})),size:Ko(r,Math.max(i,t)),alignment:t}}function Ko(e,t){return Math.ceil(e/t)*t}class Jo extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const i=2*e;return this.int16[i+0]=t,this.int16[i+1]=r,e}}Jo.prototype.bytesPerElement=4,zn(Jo,"StructArrayLayout2i4");class Qo extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r)}emplace(e,t,r,i){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=r,this.int16[n+2]=i,e}}Qo.prototype.bytesPerElement=6,zn(Qo,"StructArrayLayout3i6");class es extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}emplace(e,t,r,i,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=r,this.int16[o+2]=i,this.int16[o+3]=n,e}}es.prototype.bytesPerElement=8,zn(es,"StructArrayLayout4i8");class ts extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n,o,s)}emplace(e,t,r,i,n,o,s,a){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.uint8[c+4]=i,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[u+2]=a,e}}ts.prototype.bytesPerElement=12,zn(ts,"StructArrayLayout2i4ub1f12");class rs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}emplace(e,t,r,i,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=i,this.float32[o+3]=n,e}}rs.prototype.bytesPerElement=16,zn(rs,"StructArrayLayout4f16");class is extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,r,i,n,o,s,a,l,c)}emplace(e,t,r,i,n,o,s,a,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=r,this.uint16[h+2]=i,this.uint16[h+3]=n,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}is.prototype.bytesPerElement=20,zn(is,"StructArrayLayout10ui20");class ns extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,r,i,n,o,s,a)}emplace(e,t,r,i,n,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=r,this.uint16[c+2]=i,this.uint16[c+3]=n,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}ns.prototype.bytesPerElement=16,zn(ns,"StructArrayLayout8ui16");class os extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,i,n,o)}emplace(e,t,r,i,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=i,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}os.prototype.bytesPerElement=12,zn(os,"StructArrayLayout6i12");class ss extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o,s,a,l,c,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,r,i,n,o,s,a,l,c,u,h)}emplace(e,t,r,i,n,o,s,a,l,c,u,h,p){const d=12*e;return this.int16[d+0]=t,this.int16[d+1]=r,this.int16[d+2]=i,this.int16[d+3]=n,this.uint16[d+4]=o,this.uint16[d+5]=s,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=u,this.int16[d+10]=h,this.int16[d+11]=p,e}}ss.prototype.bytesPerElement=24,zn(ss,"StructArrayLayout4i4ui4i24");class as extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,i,n,o)}emplace(e,t,r,i,n,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=i,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}as.prototype.bytesPerElement=20,zn(as,"StructArrayLayout3i3f20");class ls extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}ls.prototype.bytesPerElement=4,zn(ls,"StructArrayLayout1ul4");class cs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o,s,a,l,c,u,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,r,i,n,o,s,a,l,c,u,h,p)}emplace(e,t,r,i,n,o,s,a,l,c,u,h,p,d){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=r,this.int16[f+2]=i,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,e}}cs.prototype.bytesPerElement=40,zn(cs,"StructArrayLayout5i4f1i1ul2ui40");class us extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n,o,s)}emplace(e,t,r,i,n,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.int16[l+2]=i,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}us.prototype.bytesPerElement=16,zn(us,"StructArrayLayout3i2i2i16");class hs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,i,n)}emplace(e,t,r,i,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=r,this.float32[s+2]=i,this.int16[a+6]=n,this.int16[a+7]=o,e}}hs.prototype.bytesPerElement=16,zn(hs,"StructArrayLayout2f1f2i16");class ps extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}emplace(e,t,r,i,n){const o=12*e,s=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=r,this.float32[s+1]=i,this.float32[s+2]=n,e}}ps.prototype.bytesPerElement=12,zn(ps,"StructArrayLayout2ub2f12");class ds extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r)}emplace(e,t,r,i){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=r,this.float32[n+2]=i,e}}ds.prototype.bytesPerElement=12,zn(ds,"StructArrayLayout3f12");class fs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r)}emplace(e,t,r,i){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=r,this.uint16[n+2]=i,e}}fs.prototype.bytesPerElement=6,zn(fs,"StructArrayLayout3ui6");class ms extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x)}emplace(e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=r,this.int16[w+2]=i,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=d,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[E+58]=b,e}}ms.prototype.bytesPerElement=60,zn(ms,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class _s extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x,b,w,T,E,S,C,A,k,I){const M=this.length;return this.resize(M+1),this.emplace(M,e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x,b,w,T,E,S,C,A,k,I)}emplace(e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x,b,w,T,E,S,C,A,k,I,M){const z=38*e,P=19*e;return this.int16[z+0]=t,this.int16[z+1]=r,this.int16[z+2]=i,this.float32[P+2]=n,this.float32[P+3]=o,this.int16[z+8]=s,this.int16[z+9]=a,this.int16[z+10]=l,this.int16[z+11]=c,this.int16[z+12]=u,this.int16[z+13]=h,this.uint16[z+14]=p,this.uint16[z+15]=d,this.uint16[z+16]=f,this.uint16[z+17]=m,this.uint16[z+18]=_,this.uint16[z+19]=g,this.uint16[z+20]=y,this.uint16[z+21]=v,this.uint16[z+22]=x,this.uint16[z+23]=b,this.uint16[z+24]=w,this.uint16[z+25]=T,this.uint16[z+26]=E,this.uint16[z+27]=S,this.uint16[z+28]=C,this.uint32[P+15]=A,this.float32[P+16]=k,this.float32[P+17]=I,this.float32[P+18]=M,e}}_s.prototype.bytesPerElement=76,zn(_s,"StructArrayLayout3i2f6i15ui1ul3f76");class gs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}gs.prototype.bytesPerElement=4,zn(gs,"StructArrayLayout1f4");class ys extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n,o,s)}emplace(e,t,r,i,n,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=r,this.float32[l+2]=i,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}ys.prototype.bytesPerElement=28,zn(ys,"StructArrayLayout7f28");class vs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,i,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,i,n)}emplace(e,t,r,i,n,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=r,this.float32[s+2]=i,this.float32[s+3]=n,this.float32[s+4]=o,e}}vs.prototype.bytesPerElement=20,zn(vs,"StructArrayLayout5f20");class xs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}emplace(e,t,r,i,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=r,this.uint16[o+3]=i,this.uint16[o+4]=n,e}}xs.prototype.bytesPerElement=12,zn(xs,"StructArrayLayout1ul3ui12");class bs extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const i=2*e;return this.uint16[i+0]=t,this.uint16[i+1]=r,e}}bs.prototype.bytesPerElement=4,zn(bs,"StructArrayLayout2ui4");class ws extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}ws.prototype.bytesPerElement=2,zn(ws,"StructArrayLayout1ui2");class Ts extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const i=2*e;return this.float32[i+0]=t,this.float32[i+1]=r,e}}Ts.prototype.bytesPerElement=8,zn(Ts,"StructArrayLayout2f8");class Es extends Ho{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Es.prototype.size=12;class Ss extends os{get(e){return new Es(this,e)}}zn(Ss,"FillExtrusionExtArray");class Cs extends Ho{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]}}Cs.prototype.size=40;class As extends cs{get(e){return new Cs(this,e)}}zn(As,"CollisionBoxArray");class ks extends Ho{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}ks.prototype.size=60;class Is extends ms{get(e){return new ks(this,e)}}zn(Is,"PlacedSymbolArray");class Ms extends Ho{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(e){this._structArray.uint32[this._pos4+15]=e}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}Ms.prototype.size=76;class zs extends _s{get(e){return new Ms(this,e)}}zn(zs,"SymbolInstanceArray");class Ps extends gs{getoffsetX(e){return this.float32[1*e+0]}}zn(Ps,"GlyphOffsetArray");class Ds extends Qo{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}zn(Ds,"SymbolLineVertexArray");class Ls extends Ho{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]}}Ls.prototype.size=12;class Bs extends xs{get(e){return new Ls(this,e)}}zn(Bs,"FeatureIndexArray");class Rs extends Ho{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Rs.prototype.size=4;class Os extends bs{get(e){return new Rs(this,e)}}zn(Os,"FillExtrusionCentroidArray");class Fs extends Ho{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Fs.prototype.size=12;class Ns extends os{get(e){return new Fs(this,e)}}zn(Ns,"CircleGlobeExtArray");const js=Yo([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),Us=Yo([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Vs=ft((function(e){e.exports=function(e,t){var r,i,n,o,s,a,l,c;for(i=e.length-(r=3&e.length),n=t,s=3432918353,a=461845907,c=0;c<i;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}})),qs=ft((function(e){e.exports=function(e,t){for(var r,i=e.length,n=t^i,o=0;i>=4;)r=1540483477*(65535&(r=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(r>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),i-=4,++o;switch(i){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}})),Gs=Vs,$s=qs;Gs.murmur3=Vs,Gs.murmur2=$s;class Zs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,r,i){this.ids.push(Ws(e)),this.positions.push(t,r,i)}getPositions(e){const t=Ws(e);let r=0,i=this.ids.length-1;for(;r<i;){const e=r+i>>1;this.ids[e]>=t?i=e:r=e+1}const n=[];for(;this.ids[r]===t;)n.push({index:this.positions[3*r],start:this.positions[3*r+1],end:this.positions[3*r+2]}),r++;return n}static serialize(e,t){const r=new Float64Array(e.ids),i=new Uint32Array(e.positions);return Hs(r,i,0,r.length-1),t&&t.push(r.buffer,i.buffer),{ids:r,positions:i}}static deserialize(e){const t=new Zs;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function Ws(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Gs(String(e))}function Hs(e,t,r,i){for(;r<i;){const n=e[r+i>>1];let o=r-1,s=i+1;for(;;){do{o++}while(e[o]<n);do{s--}while(e[s]>n);if(o>=s)break;Xs(e,o,s),Xs(t,3*o,3*s),Xs(t,3*o+1,3*s+1),Xs(t,3*o+2,3*s+2)}s-r<i-s?(Hs(e,t,r,s),r=s+1):(Hs(e,t,s+1,i),i=s)}}function Xs(e,t,r){const i=e[t];e[t]=e[r],e[r]=i}zn(Zs,"FeaturePositionMap");class Ys{constructor(e,t){this.gl=e.gl,this.location=t}}class Ks extends Ys{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Js extends Ys{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class Qs extends Ys{constructor(e,t){super(e,t),this.current=gt.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const ea=new Float32Array(16),ta=new Float32Array(9),ra=new Float32Array(4);function ia(e){return[Zo(255*e.r,255*e.g),Zo(255*e.b,255*e.a)]}class na{constructor(e,t,r){this.value=e,this.uniformNames=t.map((e=>`u_${e}`)),this.type=r}setUniform(e,t,r){e.set(r.constantOr(this.value))}getBinding(e,t,r){return"color"===this.type?new Qs(e,t):new Ks(e,t)}}class oa{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio||1,this.pixelRatioTo=e.pixelRatio||1,this.patternFrom=t.tl.concat(t.br),this.patternTo=e.tl.concat(e.br)}setUniform(e,t,r,i){const n="u_pattern_to"===i||"u_dash_to"===i?this.patternTo:"u_pattern_from"===i||"u_dash_from"===i?this.patternFrom:"u_pixel_ratio_to"===i?this.pixelRatioTo:"u_pixel_ratio_from"===i?this.pixelRatioFrom:null;n&&e.set(n)}getBinding(e,t,r){return"u_pattern_from"===r||"u_pattern_to"===r||"u_dash_from"===r||"u_dash_to"===r?new Js(e,t):new Ks(e,t)}}class sa{constructor(e,t,r,i){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new i}populatePaintArray(e,t,r,i,n,o){const s=this.paintVertexArray.length,a=this.expression.evaluate(new zo(0),t,{},n,i,o);this.paintVertexArray.resize(e),this._setPaintValue(s,e,a)}updatePaintArray(e,t,r,i,n){const o=this.expression.evaluate({zoom:0},r,i,void 0,n);this._setPaintValue(e,t,o)}_setPaintValue(e,t,r){if("color"===this.type){const i=ia(r);for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i[0],i[1])}else{for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r);this.maxValue=Math.max(this.maxValue,Math.abs(r))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class aa{constructor(e,t,r,i,n,o){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=r,this.useIntegerZoom=i,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,t,r,i,n,o){const s=this.expression.evaluate(new zo(this.zoom),t,{},n,i,o),a=this.expression.evaluate(new zo(this.zoom+1),t,{},n,i,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,s,a)}updatePaintArray(e,t,r,i,n){const o=this.expression.evaluate({zoom:this.zoom},r,i,void 0,n),s=this.expression.evaluate({zoom:this.zoom+1},r,i,void 0,n);this._setPaintValue(e,t,o,s)}_setPaintValue(e,t,r,i){if("color"===this.type){const n=ia(r),o=ia(i);for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,n[0],n[1],o[0],o[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,r,i);this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(i))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){const r=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,i=f(this.expression.interpolationFactor(r,this.zoom,this.zoom+1),0,1);e.set(i)}getBinding(e,t,r){return new Ks(e,t)}}class la{constructor(e,t,r,i,n,o,s){this.expression=e,this.type=r,this.useIntegerZoom=i,this.zoom=n,this.layerId=s,this.paintVertexAttributes=("array"===r?Us:js).members;for(let e=0;e<t.length;++e);this.zoomInPaintVertexArray=new o,this.zoomOutPaintVertexArray=new o}populatePaintArray(e,t,r){const i=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(i,e,t.patterns&&t.patterns[this.layerId],r)}updatePaintArray(e,t,r,i,n,o){this._setPaintValues(e,t,r.patterns&&r.patterns[this.layerId],o)}_setPaintValues(e,t,r,i){if(!i||!r)return;const{min:n,mid:o,max:s}=r,a=i[n],l=i[o],c=i[s];if(a&&l&&c)for(let r=e;r<t;r++)this._setPaintValue(this.zoomInPaintVertexArray,r,l,a),this._setPaintValue(this.zoomOutPaintVertexArray,r,l,c)}_setPaintValue(e,t,r,i){e.emplace(t,r.tl[0],r.tl[1],r.br[0],r.br[1],i.tl[0],i.tl[1],i.br[0],i.br[1],r.pixelRatio,i.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ca{constructor(e,t,r=(()=>!0)){this.binders={},this._buffers=[];const i=[];for(const n in e.paint._values){if(!r(n))continue;const o=e.paint.get(n);if(!(o instanceof Fo&&xi(o.property.specification)))continue;const s=pa(n,e.type),a=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,u=o.property.specification["property-type"],h="cross-faded"===u||"cross-faded-data-driven"===u,p="line-dasharray"===String(n)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||h){const r=ma(n,l,"source");this.binders[n]=h?new la(a,s,l,c,t,r,e.id):new sa(a,s,l,r),i.push(`/a_${n}`)}else{const e=ma(n,l,"composite");this.binders[n]=new aa(a,s,l,c,t,e),i.push(`/z_${n}`)}else this.binders[n]=h?new oa(a.value,s):new na(a.value,s,l),i.push(`/u_${n}`)}this.cacheKey=i.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof sa||t instanceof aa?t.maxValue:0}populatePaintArrays(e,t,r,i,n,o){for(const s in this.binders){const a=this.binders[s];(a instanceof sa||a instanceof aa||a instanceof la)&&a.populatePaintArray(e,t,r,i,n,o)}}setConstantPatternPositions(e,t){for(const r in this.binders){const i=this.binders[r];i instanceof oa&&i.setConstantPatternPositions(e,t)}}updatePaintArrays(e,t,r,i,n,o){let s=!1;for(const a in e){const l=t.getPositions(a);for(const t of l){const l=r.feature(t.index);for(const r in this.binders){const c=this.binders[r];if((c instanceof sa||c instanceof aa||c instanceof la)&&!0===c.expression.isStateDependent){const u=i.paint.get(r);c.expression=u.value,c.updatePaintArray(t.start,t.end,l,e[a],n,o),s=!0}}}}return s}defines(){const e=[];for(const t in this.binders){const r=this.binders[t];(r instanceof na||r instanceof oa)&&e.push(...r.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const r=this.binders[t];if(r instanceof sa||r instanceof aa||r instanceof la)for(let t=0;t<r.paintVertexAttributes.length;t++)e.push(r.paintVertexAttributes[t].name)}return e}getBinderUniforms(){const e=[];for(const t in this.binders){const r=this.binders[t];if(r instanceof na||r instanceof oa||r instanceof aa)for(const t of r.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){const r=[];for(const i in this.binders){const n=this.binders[i];if(n instanceof na||n instanceof oa||n instanceof aa)for(const o of n.uniformNames)if(t[o]){const s=n.getBinding(e,t[o],o);r.push({name:o,property:i,binding:s})}}return r}setUniforms(e,t,r,i){for(const{name:e,property:n,binding:o}of t)this.binders[n].setUniform(o,i,r.get(n),e)}updatePaintBuffers(e){this._buffers=[];for(const t in this.binders){const r=this.binders[t];if(e&&r instanceof la){const t=2===e.fromScale?r.zoomInPaintVertexBuffer:r.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(r instanceof sa||r instanceof aa)&&r.paintVertexBuffer&&this._buffers.push(r.paintVertexBuffer)}}upload(e){for(const t in this.binders){const r=this.binders[t];(r instanceof sa||r instanceof aa||r instanceof la)&&r.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof sa||t instanceof aa||t instanceof la)&&t.destroy()}}}class ua{constructor(e,t,r=(()=>!0)){this.programConfigurations={};for(const i of e)this.programConfigurations[i.id]=new ca(i,t,r);this.needsUpload=!1,this._featureMap=new Zs,this._bufferOffset=0}populatePaintArrays(e,t,r,i,n,o,s){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(e,t,i,n,o,s);void 0!==t.id&&this._featureMap.add(t.id,r,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,r,i,n){for(const o of r)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,i,n)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const ha={"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"],"line-dasharray":["dash_to","dash_from"]};function pa(e,t){return ha[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const da={"line-pattern":{source:is,composite:is},"fill-pattern":{source:is,composite:is},"fill-extrusion-pattern":{source:is,composite:is},"line-dasharray":{source:ns,composite:ns}},fa={color:{source:Ts,composite:rs},number:{source:gs,composite:Ts}};function ma(e,t,r){const i=da[e];return i&&i[r]||fa[t][r]}zn(na,"ConstantBinder"),zn(oa,"CrossFadedConstantBinder"),zn(sa,"SourceExpressionBinder"),zn(la,"CrossFadedCompositeBinder"),zn(aa,"CompositeExpressionBinder"),zn(ca,"ProgramConfiguration",{omit:["_buffers"]}),zn(ua,"ProgramConfigurationSet");const _a="-transition";class ga extends qe{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),t.layout&&(this._unevaluatedLayout=new Oo(t.layout)),t.paint)){this._transitionablePaint=new Lo(t.paint);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new No(t.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,r={}){null!=t&&this._validate(Sn,`layers.${this.id}.layout.${e}`,e,t,r)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return C(e,_a)?this._transitionablePaint.getTransition(e.slice(0,-_a.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,r={}){if(null!=t&&this._validate(En,`layers.${this.id}.paint.${e}`,e,t,r))return!1;if(C(e,_a))return this._transitionablePaint.setTransition(e.slice(0,-_a.length),t||void 0),!1;{const r=this._transitionablePaint._values[e],i="cross-faded-data-driven"===r.property.specification["property-type"],n=r.value.isDataDriven(),o=r.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||n||i||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,r){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),k(e,((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}_validate(e,t,r,i,n={}){return(!n||!1!==n.validate)&&An(this,e.call(Tn,{key:t,layerType:this.type,objectKey:r,value:i,styleSpec:Ge,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Fo&&xi(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Xi(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const ya=Yo([{name:"a_pos",components:2,type:"Int16"}],4),va=Yo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class xa{constructor(e=[]){this.segments=e}prepareSegment(e,t,r,i){let n=this.segments[this.segments.length-1];return e>xa.MAX_VERTEX_ARRAY_LENGTH&&z(`Max vertices per segment is ${xa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>xa.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==i)&&(n={vertexOffset:t.length,primitiveOffset:r.length,vertexLength:0,primitiveLength:0},void 0!==i&&(n.sortKey=i),this.segments.push(n)),n}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,r,i){return new xa([{vertexOffset:e,primitiveOffset:t,vertexLength:r,primitiveLength:i,vaos:{},sortKey:0}])}}xa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,zn(xa,"SegmentVector");var ba=8192;class wa{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof Ea?new Ea(e.lng,e.lat):Ea.convert(e),this}setSouthWest(e){return this._sw=e instanceof Ea?new Ea(e.lng,e.lat):Ea.convert(e),this}extend(e){const t=this._sw,r=this._ne;let i,n;if(e instanceof Ea)i=e,n=e;else{if(!(e instanceof wa))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(wa.convert(e)):this.extend(Ea.convert(e)):this;if(i=e._sw,n=e._ne,!i||!n)return this}return t||r?(t.lng=Math.min(i.lng,t.lng),t.lat=Math.min(i.lat,t.lat),r.lng=Math.max(n.lng,r.lng),r.lat=Math.max(n.lat,r.lat)):(this._sw=new Ea(i.lng,i.lat),this._ne=new Ea(n.lng,n.lat)),this}getCenter(){return new Ea((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 Ea(this.getWest(),this.getNorth())}getSouthEast(){return new Ea(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:r}=Ea.convert(e);let i=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(i=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&i}static convert(e){return!e||e instanceof wa?e:new wa(e)}}const Ta=6371008.8;class Ea{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Ea(_(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,r=this.lat*t,i=e.lat*t,n=Math.sin(r)*Math.sin(i)+Math.cos(r)*Math.cos(i)*Math.cos((e.lng-this.lng)*t);return Ta*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,r=t/Math.cos(Math.PI/180*this.lat);return new wa(new Ea(this.lng-r,this.lat-t),new Ea(this.lng+r,this.lat+t))}static convert(e){if(e instanceof Ea)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new Ea(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new Ea(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Sa=2*Math.PI*Ta;function Ca(e){return Sa*Math.cos(e*Math.PI/180)}function Aa(e){return(180+e)/360}function ka(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Ia(e,t){return e/Ca(t)}function Ma(e){return 360*e-180}function za(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Pa(e,t){return e*Ca(za(t))}const Da=85.051129;class La{constructor(e,t,r=0){this.x=+e,this.y=+t,this.z=+r}static fromLngLat(e,t=0){const r=Ea.convert(e);return new La(Aa(r.lng),ka(r.lat),Ia(t,r.lat))}toLngLat(){return new Ea(Ma(this.x),za(this.y))}toAltitude(){return Pa(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Sa*(e=za(this.y),1/Math.cos(e*Math.PI/180));var e}}function Ba(e,t,r,i,o,s,a,l,c){const u=(t+i)/2,h=(r+o)/2,p=new n(u,h);l(p),function(e,t,r,i,n,o){const s=r-n,a=i-o;return Math.abs((i-t)*s-(r-e)*a)/Math.hypot(s,a)}(p.x,p.y,s.x,s.y,a.x,a.y)>=c?(Ba(e,t,r,u,h,s,p,l,c),Ba(e,u,h,i,o,p,a,l,c)):e.push(a)}function Ra(e,t,r){let i=e[0],n=i.x,o=i.y;t(i);const s=[i];for(let a=1;a<e.length;a++){const l=e[a],{x:c,y:u}=l;t(l),Ba(s,n,o,c,u,i,l,t,r),n=c,o=u,i=l}return s}function Oa(e,t,r,i,n){if(n(t,r)){const o=t.add(r).mult(.5);i(o),Oa(e,t,o,i,n),Oa(e,o,r,i,n)}else e.push(r)}function Fa(e,t,r){let i=e[0];t(i);const n=[i];for(let o=1;o<e.length;o++){const s=e[o];t(s),Oa(n,i,s,t,r),i=s}return n}const Na=Math.pow(2,14)-1,ja=-Na-1;function Ua(e,t){const r=Math.round(e.x*t),i=Math.round(e.y*t);return e.x=f(r,ja,Na),e.y=f(i,ja,Na),(r<e.x||r>e.x+1||i<e.y||i>e.y+1)&&z("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Va(e,t,r){const i=e.loadGeometry(),n=e.extent,o=ba/n;if(t&&r&&r.projection.isReprojectedInTileSpace){const o=1<<t.z,{scale:s,x:a,y:l,projection:c}=r,u=e=>{const r=Ma((t.x+e.x/n)/o),i=za((t.y+e.y/n)/o),u=c.project(r,i);e.x=(u.x*s-a)*n,e.y=(u.y*s-l)*n};for(let t=0;t<i.length;t++)if(1!==e.type)i[t]=Ra(i[t],u,1);else{const e=[];for(const r of i[t])r.x<0||r.x>=n||r.y<0||r.y>=n||(u(r),e.push(r));i[t]=e}}for(const e of i)for(const t of e)Ua(t,o);return i}function qa(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Va(e):[]}}function Ga(e,t,r,i,n){e.emplaceBack(2*t+(i+1)/2,2*r+(n+1)/2)}function $a(e,t,r){const i=16384;e.emplaceBack(t.x,t.y,t.z,r[0]*i,r[1]*i,r[2]*i)}class Za{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Jo,this.indexArray=new fs,this.segments=new xa,this.programConfigurations=new ua(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,r,i){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=qa(t,e);if(!this.layers[0]._featureFilter.filter(new zo(this.zoom),c,r))continue;const u=s?s.evaluate(c,{},r):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Va(t,r,i),patterns:{},sortKey:u};o.push(h)}s&&o.sort(((e,t)=>e.sortKey-t.sortKey));let a=null;"globe"===i.projection.name&&(this.globeExtVertexArray=new Ns,a=i.projection);for(const i of o){const{geometry:n,index:o,sourceLayerIndex:s}=i,l=e[o].feature;this.addFeature(i,n,o,t.availableImages,r,a),t.featureIndex.insert(l,n,o,s,this.index)}}update(e,t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,r,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ya.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,va.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,r,i,n,o){for(const r of t)for(const t of r){const r=t.x,i=t.y;if(r<0||r>=ba||i<0||i>=ba)continue;if(o){const e=o.projectTilePoint(r,i,n),t=o.upVector(n,r,i),s=this.globeExtVertexArray;$a(s,e,t),$a(s,e,t),$a(s,e,t),$a(s,e,t)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;Ga(this.layoutVertexArray,r,i,-1,-1),Ga(this.layoutVertexArray,r,i,1,-1),Ga(this.layoutVertexArray,r,i,1,1),Ga(this.layoutVertexArray,r,i,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},i,n)}}function Wa(e,t){for(let r=0;r<e.length;r++)if(rl(t,e[r]))return!0;for(let r=0;r<t.length;r++)if(rl(e,t[r]))return!0;return!!Ka(e,t)}function Ha(e,t,r){return!!rl(e,t)||!!Qa(t,e,r)}function Xa(e,t){if(1===e.length)return tl(t,e[0]);for(let r=0;r<t.length;r++){const i=t[r];for(let t=0;t<i.length;t++)if(rl(e,i[t]))return!0}for(let r=0;r<e.length;r++)if(tl(t,e[r]))return!0;for(let r=0;r<t.length;r++)if(Ka(e,t[r]))return!0;return!1}function Ya(e,t,r){if(e.length>1){if(Ka(e,t))return!0;for(let i=0;i<t.length;i++)if(Qa(t[i],e,r))return!0}for(let i=0;i<e.length;i++)if(Qa(e[i],t,r))return!0;return!1}function Ka(e,t){if(0===e.length||0===t.length)return!1;for(let r=0;r<e.length-1;r++){const i=e[r],n=e[r+1];for(let e=0;e<t.length-1;e++)if(Ja(i,n,t[e],t[e+1]))return!0}return!1}function Ja(e,t,r,i){return P(e,r,i)!==P(t,r,i)&&P(e,t,r)!==P(e,t,i)}function Qa(e,t,r){const i=r*r;if(1===t.length)return e.distSqr(t[0])<i;for(let r=1;r<t.length;r++)if(el(e,t[r-1],t[r])<i)return!0;return!1}function el(e,t,r){const i=t.distSqr(r);if(0===i)return e.distSqr(t);const n=((e.x-t.x)*(r.x-t.x)+(e.y-t.y)*(r.y-t.y))/i;return e.distSqr(n<0?t:n>1?r:r.sub(t)._mult(n)._add(t))}function tl(e,t){let r,i,n,o=!1;for(let s=0;s<e.length;s++){r=e[s];for(let e=0,s=r.length-1;e<r.length;s=e++)i=r[e],n=r[s],i.y>t.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(o=!o)}return o}function rl(e,t){let r=!1;for(let i=0,n=e.length-1;i<e.length;n=i++){const o=e[i],s=e[n];o.y>t.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(r=!r)}return r}function il(e,t,r,i,o){for(const n of e)if(t<=n.x&&r<=n.y&&i>=n.x&&o>=n.y)return!0;const s=[new n(t,r),new n(t,o),new n(i,o),new n(i,r)];if(e.length>2)for(const t of s)if(rl(e,t))return!0;for(let t=0;t<e.length-1;t++)if(nl(e[t],e[t+1],s))return!0;return!1}function nl(e,t,r){const i=r[0],n=r[2];if(e.x<i.x&&t.x<i.x||e.x>n.x&&t.x>n.x||e.y<i.y&&t.y<i.y||e.y>n.y&&t.y>n.y)return!1;const o=P(e,t,r[0]);return o!==P(e,t,r[1])||o!==P(e,t,r[2])||o!==P(e,t,r[3])}function ol(e,t,r){const i=t.paint.get(e).value;return"constant"===i.kind?i.value:r.programConfigurations.get(t.id).getMaxValue(e)}function sl(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function al(e,t,r,i,o){if(!t[0]&&!t[1])return e;const s=n.convert(t)._mult(o);"viewport"===r&&s._rotate(-i);const a=[];for(let t=0;t<e.length;t++)a.push(e[t].sub(s));return a}function ll(e,t,r,i){const o=n.convert(e)._mult(i);return"viewport"===t&&o._rotate(-r),o}zn(Za,"CircleBucket",{omit:["layers"]});const cl=new $o({"circle-sort-key":new Uo(Ge.layout_circle["circle-sort-key"])});var ul={paint:new $o({"circle-radius":new Uo(Ge.paint_circle["circle-radius"]),"circle-color":new Uo(Ge.paint_circle["circle-color"]),"circle-blur":new Uo(Ge.paint_circle["circle-blur"]),"circle-opacity":new Uo(Ge.paint_circle["circle-opacity"]),"circle-translate":new jo(Ge.paint_circle["circle-translate"]),"circle-translate-anchor":new jo(Ge.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new jo(Ge.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new jo(Ge.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Uo(Ge.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Uo(Ge.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Uo(Ge.paint_circle["circle-stroke-opacity"])}),layout:cl},hl=1e-6,pl="undefined"!=typeof Float32Array?Float32Array:Array;function dl(){var e=new pl(9);return pl!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function fl(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ml(e,t,r){var i=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=t[9],d=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],v=r[0],x=r[1],b=r[2],w=r[3];return e[0]=v*i+x*a+b*h+w*m,e[1]=v*n+x*l+b*p+w*_,e[2]=v*o+x*c+b*d+w*g,e[3]=v*s+x*u+b*f+w*y,e[4]=(v=r[4])*i+(x=r[5])*a+(b=r[6])*h+(w=r[7])*m,e[5]=v*n+x*l+b*p+w*_,e[6]=v*o+x*c+b*d+w*g,e[7]=v*s+x*u+b*f+w*y,e[8]=(v=r[8])*i+(x=r[9])*a+(b=r[10])*h+(w=r[11])*m,e[9]=v*n+x*l+b*p+w*_,e[10]=v*o+x*c+b*d+w*g,e[11]=v*s+x*u+b*f+w*y,e[12]=(v=r[12])*i+(x=r[13])*a+(b=r[14])*h+(w=r[15])*m,e[13]=v*n+x*l+b*p+w*_,e[14]=v*o+x*c+b*d+w*g,e[15]=v*s+x*u+b*f+w*y,e}function _l(e,t,r){var i,n,o,s,a,l,c,u,h,p,d,f,m=r[0],_=r[1],g=r[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=t[9],d=t[10],f=t[11],e[0]=i=t[0],e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=p,e[10]=d,e[11]=f,e[12]=i*m+a*_+h*g+t[12],e[13]=n*m+l*_+p*g+t[13],e[14]=o*m+c*_+d*g+t[14],e[15]=s*m+u*_+f*g+t[15]),e}function gl(e,t,r){var i=r[0],n=r[1],o=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function yl(e,t,r){var i=Math.sin(r),n=Math.cos(r),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*n+c*i,e[5]=s*n+u*i,e[6]=a*n+h*i,e[7]=l*n+p*i,e[8]=c*n-o*i,e[9]=u*n-s*i,e[10]=h*n-a*i,e[11]=p*n-l*i,e}function vl(e,t,r){var i=Math.sin(r),n=Math.cos(r),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n-c*i,e[1]=s*n-u*i,e[2]=a*n-h*i,e[3]=l*n-p*i,e[8]=o*i+c*n,e[9]=s*i+u*n,e[10]=a*i+h*n,e[11]=l*i+p*n,e}function xl(e,t,r){var i,n,o,s=r[0],a=r[1],l=r[2],c=Math.hypot(s,a,l);return c<hl?null:(s*=c=1/c,a*=c,l*=c,i=Math.sin(t),n=Math.cos(t),e[0]=s*s*(o=1-n)+n,e[1]=a*s*o+l*i,e[2]=l*s*o-a*i,e[3]=0,e[4]=s*a*o-l*i,e[5]=a*a*o+n,e[6]=l*a*o+s*i,e[7]=0,e[8]=s*l*o+a*i,e[9]=a*l*o-s*i,e[10]=l*l*o+n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var bl=ml;function wl(){var e=new pl(3);return pl!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Tl(e){var t=new pl(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function El(e){return Math.hypot(e[0],e[1],e[2])}function Sl(e,t,r){var i=new pl(3);return i[0]=e,i[1]=t,i[2]=r,i}function Cl(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function Al(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function kl(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function Il(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function Ml(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function zl(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Pl(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e}function Dl(e,t){var r=t[0],i=t[1],n=t[2],o=r*r+i*i+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function Ll(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Bl(e,t,r){var i=t[0],n=t[1],o=t[2],s=r[0],a=r[1],l=r[2];return e[0]=n*l-o*a,e[1]=o*s-i*l,e[2]=i*a-n*s,e}function Rl(e,t,r){var i=t[0],n=t[1],o=t[2],s=r[3]*i+r[7]*n+r[11]*o+r[15];return e[0]=(r[0]*i+r[4]*n+r[8]*o+r[12])/(s=s||1),e[1]=(r[1]*i+r[5]*n+r[9]*o+r[13])/s,e[2]=(r[2]*i+r[6]*n+r[10]*o+r[14])/s,e}function Ol(e,t,r){var i=r[0],n=r[1],o=r[2],s=t[0],a=t[1],l=t[2],c=n*l-o*a,u=o*s-i*l,h=i*a-n*s,p=n*h-o*u,d=o*c-i*h,f=i*u-n*c,m=2*r[3];return u*=m,h*=m,d*=2,f*=2,e[0]=s+(c*=m)+(p*=2),e[1]=a+u+d,e[2]=l+h+f,e}var Fl,Nl=Al,jl=kl,Ul=El;function Vl(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function ql(e,t,r){var i=t[0],n=t[1],o=t[2],s=t[3];return e[0]=r[0]*i+r[4]*n+r[8]*o+r[12]*s,e[1]=r[1]*i+r[5]*n+r[9]*o+r[13]*s,e[2]=r[2]*i+r[6]*n+r[10]*o+r[14]*s,e[3]=r[3]*i+r[7]*n+r[11]*o+r[15]*s,e}function Gl(){var e=new pl(4);return pl!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function $l(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Zl(e,t,r){r*=.5;var i=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=i*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-i*a,e}function Wl(e,t,r){r*=.5;var i=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=i*l-o*a,e[1]=n*l+s*a,e[2]=o*l+i*a,e[3]=s*l-n*a,e}wl(),Fl=new pl(4),pl!=Float32Array&&(Fl[0]=0,Fl[1]=0,Fl[2]=0,Fl[3]=0),wl(),Sl(1,0,0),Sl(0,1,0),Gl(),Gl(),dl();class Hl{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,r){const i=Ll(t,this.dir);if(Math.abs(i)<1e-6)return!1;const n=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/i;return r[0]=this.pos[0]+this.dir[0]*n,r[1]=this.pos[1]+this.dir[1]*n,r[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(e,t,r){if(function(e,t){var r=e[0],i=e[1],n=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(r-o)<=hl*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-s)<=hl*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(n-a)<=hl*Math.max(1,Math.abs(n),Math.abs(a))}(this.pos,e)||0===t)return r[0]=r[1]=r[2]=0,!1;const[i,n,o]=this.dir,s=this.pos[0]-e[0],a=this.pos[1]-e[1],l=this.pos[2]-e[2],c=i*i+n*n+o*o,u=2*(s*i+a*n+l*o),h=u*u-4*c*(s*s+a*a+l*l-t*t);if(h<0){const e=Math.max(-u/2,0),c=s+i*e,h=a+n*e,p=l+o*e,d=Math.hypot(c,h,p);return r[0]=c*t/d,r[1]=h*t/d,r[2]=p*t/d,!1}{const e=(-u-Math.sqrt(h))/(2*c);if(e<0){const e=Math.hypot(s,a,l);return r[0]=s*t/e,r[1]=a*t/e,r[2]=l*t/e,!1}return r[0]=s+i*e,r[1]=a+n*e,r[2]=l+o*e,!0}}}class Xl{constructor(e,t,r,i,n){this.TL=e,this.TR=t,this.BR=r,this.BL=i,this.horizon=n}static fromInvProjectionMatrix(e,t,r){const i=[-1,1,1],n=[1,1,1],o=[1,-1,1],s=[-1,-1,1],a=Rl(i,i,e),l=Rl(n,n,e),c=Rl(o,o,e),u=Rl(s,s,e);return new Xl(a,l,c,u,t/r)}}class Yl{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,r,i){const n=Math.pow(2,r),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((r=>{const o=ql([],r,e),s=1/o[3]/t*n;return function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}(o,o,[s,s,i?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const t=Dl([],Bl([],Nl([],o[e[0]],o[e[1]]),Nl([],o[e[2]],o[e[1]]))),r=-Ll(t,o[e[1]]);return t.concat(r)}));return new Yl(o,s)}}class Kl{constructor(e,t){this.min=e,this.max=t,this.center=zl([],Cl([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],r=Tl(this.min),i=Tl(this.max);for(let e=0;e<t.length;e++)r[e]=t[e]?this.min[e]:this.center[e],i[e]=t[e]?this.center[e]:this.max[e];return i[2]=this.max[2],new Kl(r,i)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return[[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){const t=this.getCorners();let r=!0;for(let i=0;i<e.planes.length;i++){const n=e.planes[i];let o=0;for(let e=0;e<t.length;e++)o+=Ll(n,t[e])+n[3]>=0;if(0===o)return 0;o!==t.length&&(r=!1)}if(r)return 2;for(let t=0;t<3;t++){let r=Number.MAX_VALUE,i=-Number.MAX_VALUE;for(let n=0;n<e.points.length;n++){const o=e.points[n][t]-this.min[t];r=Math.min(r,o),i=Math.max(i,o)}if(i<0||r>this.max[t]-this.min[t])return 0}return 1}}function Jl(e,t,r,i,n,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,u=r.projection.upVectorScale(c,r.center.lat,r.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(a),p=n&&r.elevation?r.elevation.exaggeration()*n.getElevationAt(h.x,h.y,!0):0,d=r.projection.projectTilePoint(h.x,h.y,c);if(p>0){const e=r.projection.upVector(c,h.x,h.y);d.x+=e[0]*u*p,d.y+=e[1]*u*p,d.z+=e[2]*u*p}const f=o?h:Ql(d.x,d.y,d.z,i),m=o?e.tilespaceRays.map((e=>rc(e,p))):e.queryGeometry.screenGeometry,_=ql([],[d.x,d.y,d.z,1],i);if(!s&&o?l*=_[3]/r.cameraToCenterDistance:s&&!o&&(l*=r.cameraToCenterDistance/_[3]),o){const e=za((t.y/ba+c.y)/(1<<c.z));l/=r.projection.pixelsPerMeter(e,1)/Ia(1,e)}if(Ha(m,f,l))return!0}return!1}function Ql(e,t,r,i){const o=ql([],[e,t,r,1],i);return new n(o[0]/o[3],o[1]/o[3])}const ec=Sl(0,0,0),tc=Sl(0,0,1);function rc(e,t){const r=wl();return ec[2]=t,e.intersectsPlane(ec,tc,r),new n(r[0],r[1])}class ic extends Za{}function nc(e,{width:t,height:r},i,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*r*i)throw new RangeError("mismatched image size")}else n=new Uint8Array(t*r*i);return e.width=t,e.height=r,e.data=n,e}function oc(e,t,r){const{width:i,height:n}=t;i===e.width&&n===e.height||(sc(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,i),height:Math.min(e.height,n)},r),e.width=i,e.height=n,e.data=t.data)}function sc(e,t,r,i,n,o){if(0===n.width||0===n.height)return t;if(n.width>e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;for(let l=0;l<n.height;l++){const c=((r.y+l)*e.width+r.x)*o,u=((i.y+l)*t.width+i.x)*o;for(let e=0;e<n.width*o;e++)a[u+e]=s[c+e]}return t}zn(ic,"HeatmapBucket",{omit:["layers"]});class ac{constructor(e,t){nc(this,e,1,t)}resize(e){oc(this,new ac(e),1)}clone(){return new ac({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,r,i,n){sc(e,t,r,i,n,1)}}class lc{constructor(e,t){nc(this,e,4,t)}resize(e){oc(this,new lc(e),4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new lc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,r,i,n){sc(e,t,r,i,n,4)}}zn(ac,"AlphaImage"),zn(lc,"RGBAImage");var cc={paint:new $o({"heatmap-radius":new Uo(Ge.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Uo(Ge.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new jo(Ge.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Go(Ge.paint_heatmap["heatmap-color"]),"heatmap-opacity":new jo(Ge.paint_heatmap["heatmap-opacity"])})};function uc(e){const t={},r=e.resolution||256,i=e.clips?e.clips.length:1,n=e.image||new lc({width:r,height:i}),o=(r,i,o)=>{t[e.evaluationKey]=o;const s=e.expression.evaluate(t);n.data[r+i+0]=Math.floor(255*s.r/s.a),n.data[r+i+1]=Math.floor(255*s.g/s.a),n.data[r+i+2]=Math.floor(255*s.b/s.a),n.data[r+i+3]=Math.floor(255*s.a)};if(e.clips)for(let t=0,n=0;t<i;++t,n+=4*r)for(let i=0,s=0;i<r;i++,s+=4){const a=i/(r-1),{start:l,end:c}=e.clips[t];o(n,s,l*(1-a)+c*a)}else for(let e=0,t=0;e<r;e++,t+=4)o(0,t,e/(r-1));return n}var hc={paint:new $o({"hillshade-illumination-direction":new jo(Ge.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new jo(Ge.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new jo(Ge.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new jo(Ge.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new jo(Ge.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new jo(Ge.paint_hillshade["hillshade-accent-color"])})};const pc=Yo([{name:"a_pos",components:2,type:"Int16"}],4),{members:dc}=pc;var fc=_c,mc=_c;function _c(e,t,r){r=r||2;var i,n,o,s,a,l,c,u=t&&t.length,h=u?t[0]*r:e.length,p=gc(e,0,h,r,!0),d=[];if(!p||p.next===p.prev)return d;if(u&&(p=function(e,t,r,i){var n,o,s,a=[];for(n=0,o=t.length;n<o;n++)(s=gc(e,t[n]*i,n<o-1?t[n+1]*i:e.length,i,!1))===s.next&&(s.steiner=!0),a.push(kc(s));for(a.sort(Ec),n=0;n<a.length;n++)r=yc(r=Sc(a[n],r),r.next);return r}(e,t,p,r)),e.length>80*r){i=o=e[0],n=s=e[1];for(var f=r;f<h;f+=r)(a=e[f])<i&&(i=a),(l=e[f+1])<n&&(n=l),a>o&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-i,s-n))?1/c:0}return vc(p,d,r,i,n,c),d}function gc(e,t,r,i,n){var o,s;if(n===Uc(e,t,r,i)>0)for(o=t;o<r;o+=i)s=Fc(o,e[o],e[o+1],s);else for(o=r-i;o>=t;o-=i)s=Fc(o,e[o],e[o+1],s);return s&&Pc(s,s.next)&&(Nc(s),s=s.next),s}function yc(e,t){if(!e)return e;t||(t=e);var r,i=e;do{if(r=!1,i.steiner||!Pc(i,i.next)&&0!==zc(i.prev,i,i.next))i=i.next;else{if(Nc(i),(i=t=i.prev)===i.next)break;r=!0}}while(r||i!==t);return t}function vc(e,t,r,i,n,o,s){if(e){!s&&o&&function(e,t,r,i){var n=e;do{null===n.z&&(n.z=Ac(n.x,n.y,t,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,r,i,n,o,s,a,l,c=1;do{for(r=e,e=null,o=null,s=0;r;){for(s++,i=r,a=0,t=0;t<c&&(a++,i=i.nextZ);t++);for(l=c;a>0||l>0&&i;)0!==a&&(0===l||!i||r.z<=i.z)?(n=r,r=r.nextZ,a--):(n=i,i=i.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;r=i}o.nextZ=null,c*=2}while(s>1)}(n)}(e,i,n,o);for(var a,l,c=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?bc(e,i,n,o):xc(e))t.push(a.i/r),t.push(e.i/r),t.push(l.i/r),Nc(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?vc(e=wc(yc(e),t,r),t,r,i,n,o,2):2===s&&Tc(e,t,r,i,n,o):vc(yc(e),t,r,i,n,o,1);break}}}function xc(e){var t=e.prev,r=e,i=e.next;if(zc(t,r,i)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(Ic(t.x,t.y,r.x,r.y,i.x,i.y,n.x,n.y)&&zc(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function bc(e,t,r,i){var n=e.prev,o=e,s=e.next;if(zc(n,o,s)>=0)return!1;for(var a=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,l=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,c=Ac(n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,t,r,i),u=Ac(a,l,t,r,i),h=e.prevZ,p=e.nextZ;h&&h.z>=c&&p&&p.z<=u;){if(h!==e.prev&&h!==e.next&&Ic(n.x,n.y,o.x,o.y,s.x,s.y,h.x,h.y)&&zc(h.prev,h,h.next)>=0)return!1;if(h=h.prevZ,p!==e.prev&&p!==e.next&&Ic(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&zc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;h&&h.z>=c;){if(h!==e.prev&&h!==e.next&&Ic(n.x,n.y,o.x,o.y,s.x,s.y,h.x,h.y)&&zc(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;p&&p.z<=u;){if(p!==e.prev&&p!==e.next&&Ic(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&zc(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function wc(e,t,r){var i=e;do{var n=i.prev,o=i.next.next;!Pc(n,o)&&Dc(n,i,i.next,o)&&Rc(n,o)&&Rc(o,n)&&(t.push(n.i/r),t.push(i.i/r),t.push(o.i/r),Nc(i),Nc(i.next),i=e=o),i=i.next}while(i!==e);return yc(i)}function Tc(e,t,r,i,n,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Mc(s,a)){var l=Oc(s,a);return s=yc(s,s.next),l=yc(l,l.next),vc(s,t,r,i,n,o),void vc(l,t,r,i,n,o)}a=a.next}s=s.next}while(s!==e)}function Ec(e,t){return e.x-t.x}function Sc(e,t){var r=function(e,t){var r,i=t,n=e.x,o=e.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=n&&a>s){if(s=a,a===n){if(o===i.y)return i;if(o===i.next.y)return i.next}r=i.x<i.next.x?i:i.next}}i=i.next}while(i!==t);if(!r)return null;if(n===s)return r;var l,c=r,u=r.x,h=r.y,p=1/0;i=r;do{n>=i.x&&i.x>=u&&n!==i.x&&Ic(o<h?n:s,o,u,h,o<h?s:n,o,i.x,i.y)&&(l=Math.abs(o-i.y)/(n-i.x),Rc(i,e)&&(l<p||l===p&&(i.x>r.x||i.x===r.x&&Cc(r,i)))&&(r=i,p=l)),i=i.next}while(i!==c);return r}(e,t);if(!r)return t;var i=Oc(r,e),n=yc(r,r.next);return yc(i,i.next),t===r?n:t}function Cc(e,t){return zc(e.prev,e,t.prev)<0&&zc(t.next,e,e.next)<0}function Ac(e,t,r,i,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function kc(e){var t=e,r=e;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next}while(t!==e);return r}function Ic(e,t,r,i,n,o,s,a){return(n-s)*(t-a)-(e-s)*(o-a)>=0&&(e-s)*(i-a)-(r-s)*(t-a)>=0&&(r-s)*(o-a)-(n-s)*(i-a)>=0}function Mc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Dc(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(Rc(e,t)&&Rc(t,e)&&function(e,t){var r=e,i=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&n<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next}while(r!==e);return i}(e,t)&&(zc(e.prev,e,t.prev)||zc(e,t.prev,t))||Pc(e,t)&&zc(e.prev,e,e.next)>0&&zc(t.prev,t,t.next)>0)}function zc(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Pc(e,t){return e.x===t.x&&e.y===t.y}function Dc(e,t,r,i){var n=Bc(zc(e,t,r)),o=Bc(zc(e,t,i)),s=Bc(zc(r,i,e)),a=Bc(zc(r,i,t));return n!==o&&s!==a||!(0!==n||!Lc(e,r,t))||!(0!==o||!Lc(e,i,t))||!(0!==s||!Lc(r,e,i))||!(0!==a||!Lc(r,t,i))}function Lc(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function Bc(e){return e>0?1:e<0?-1:0}function Rc(e,t){return zc(e.prev,e,e.next)<0?zc(e,t,e.next)>=0&&zc(e,e.prev,t)>=0:zc(e,t,e.prev)<0||zc(e,e.next,t)<0}function Oc(e,t){var r=new jc(e.i,e.x,e.y),i=new jc(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=n,n.prev=r,i.next=r,r.prev=i,o.next=i,i.prev=o,i}function Fc(e,t,r,i){var n=new jc(e,t,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Nc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function jc(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Uc(e,t,r,i){for(var n=0,o=t,s=r-i;o<r;o+=i)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}function Vc(e,t,r,i,n){qc(e,t,r||0,i||e.length-1,n||$c)}function qc(e,t,r,i,n){for(;i>r;){if(i-r>600){var o=i-r+1,s=t-r+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);qc(e,t,Math.max(r,Math.floor(t-s*l/o+c)),Math.min(i,Math.floor(t+(o-s)*l/o+c)),n)}var u=e[t],h=r,p=i;for(Gc(e,r,t),n(e[i],u)>0&&Gc(e,r,i);h<p;){for(Gc(e,h,p),h++,p--;n(e[h],u)<0;)h++;for(;n(e[p],u)>0;)p--}0===n(e[r],u)?Gc(e,r,p):Gc(e,++p,i),p<=t&&(r=p+1),t<=p&&(i=p-1)}}function Gc(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function $c(e,t){return e<t?-1:e>t?1:0}function Zc(e,t){const r=e.length;if(r<=1)return[e];const i=[];let n,o;for(let t=0;t<r;t++){const r=D(e[t]);0!==r&&(e[t].area=Math.abs(r),void 0===o&&(o=r<0),o===r<0?(n&&i.push(n),n=[e[t]]):n.push(e[t]))}if(n&&i.push(n),t>1)for(let e=0;e<i.length;e++)i[e].length<=t||(Vc(i[e],t,1,i[e].length-1,Wc),i[e]=i[e].slice(0,t));return i}function Wc(e,t){return t.area-e.area}function Hc(e,t,r){const i=r.patternDependencies;let n=!1;for(const r of t){const t=r.paint.get(`${e}-pattern`);t.isConstant()||(n=!0);const o=t.constantOr(null);o&&(n=!0,i[o.to]=!0,i[o.from]=!0)}return n}function Xc(e,t,r,i,n){const o=n.patternDependencies;for(const s of t){const t=s.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:i-1},r,{},n.availableImages),a=t.evaluate({zoom:i},r,{},n.availableImages),l=t.evaluate({zoom:i+1},r,{},n.availableImages);e=e&&e.name?e.name:e,a=a&&a.name?a.name:a,l=l&&l.name?l.name:l,o[e]=!0,o[a]=!0,o[l]=!0,r.patterns[s.id]={min:e,mid:a,max:l}}}return r}_c.deviation=function(e,t,r,i){var n=t&&t.length,o=Math.abs(Uc(e,0,n?t[0]*r:e.length,r));if(n)for(var s=0,a=t.length;s<a;s++)o-=Math.abs(Uc(e,t[s]*r,s<a-1?t[s+1]*r:e.length,r));var l=0;for(s=0;s<i.length;s+=3){var c=i[s]*r,u=i[s+1]*r,h=i[s+2]*r;l+=Math.abs((e[c]-e[h])*(e[u+1]-e[c+1])-(e[c]-e[u])*(e[h+1]-e[c+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},_c.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},i=0,n=0;n<e.length;n++){for(var o=0;o<e[n].length;o++)for(var s=0;s<t;s++)r.vertices.push(e[n][o][s]);n>0&&r.holes.push(i+=e[n-1].length)}return r},fc.default=mc;class Yc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Jo,this.indexArray=new fs,this.indexArray2=new bs,this.programConfigurations=new ua(e.layers,e.zoom),this.segments=new xa,this.segments2=new xa,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection}populate(e,t,r,i){this.hasPattern=Hc("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=qa(s,e);if(!this.layers[0]._featureFilter.filter(new zo(this.zoom),u,r))continue;const h=n?n.evaluate(u,{},r,t.availableImages):void 0,p={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Va(s,r,i),patterns:{},sortKey:h};o.push(p)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const i of o){const{geometry:n,index:o,sourceLayerIndex:s}=i;if(this.hasPattern){const e=Xc("fill",this.layers,i,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(i,n,o,r,{},t.availableImages);t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,r,i)}addFeatures(e,t,r,i,n){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,r,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,dc),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,r,i,n,o=[]){for(const e of Zc(t,500)){let t=0;for(const r of e)t+=r.length;const r=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),i=r.vertexLength,n=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(n.length/2);const r=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),i=r.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(i+t.length-1,i),n.push(t[0].x),n.push(t[0].y);for(let e=1;e<t.length;e++)this.layoutVertexArray.emplaceBack(t[e].x,t[e].y),this.indexArray2.emplaceBack(i+e-1,i+e),n.push(t[e].x),n.push(t[e].y);r.vertexLength+=t.length,r.primitiveLength+=t.length}const s=fc(n,o);for(let e=0;e<s.length;e+=3)this.indexArray.emplaceBack(i+s[e],i+s[e+1],i+s[e+2]);r.vertexLength+=t,r.primitiveLength+=s.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,n,o,i)}}zn(Yc,"FillBucket",{omit:["layers","patternFeatures"]});const Kc=new $o({"fill-sort-key":new Uo(Ge.layout_fill["fill-sort-key"])});var Jc={paint:new $o({"fill-antialias":new jo(Ge.paint_fill["fill-antialias"]),"fill-opacity":new Uo(Ge.paint_fill["fill-opacity"]),"fill-color":new Uo(Ge.paint_fill["fill-color"]),"fill-outline-color":new Uo(Ge.paint_fill["fill-outline-color"]),"fill-translate":new jo(Ge.paint_fill["fill-translate"]),"fill-translate-anchor":new jo(Ge.paint_fill["fill-translate-anchor"]),"fill-pattern":new Vo(Ge.paint_fill["fill-pattern"])}),layout:Kc};const Qc=Yo([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),eu=Yo([{name:"a_centroid_pos",components:2,type:"Uint16"}]),tu=Yo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:ru}=Qc;var iu=nu;function nu(e,t,r,i,n){this.properties={},this.extent=r,this.type=0,this._pbf=e,this._geometry=-1,this._keys=i,this._values=n,e.readFields(ou,this,t)}function ou(e,t,r){1==e?t.id=r.readVarint():2==e?function(e,t){for(var r=e.readVarint()+e.pos;e.pos<r;){var i=t._keys[e.readVarint()],n=t._values[e.readVarint()];t.properties[i]=n}}(r,t):3==e?t.type=r.readVarint():4==e&&(t._geometry=r.pos)}function su(e){for(var t,r,i=0,n=0,o=e.length,s=o-1;n<o;s=n++)i+=((r=e[s]).x-(t=e[n]).x)*(t.y+r.y);return i}nu.types=["Unknown","Point","LineString","Polygon"],nu.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var t,r=e.readVarint()+e.pos,i=1,o=0,s=0,a=0,l=[];e.pos<r;){if(o<=0){var c=e.readVarint();i=7&c,o=c>>3}if(o--,1===i||2===i)s+=e.readSVarint(),a+=e.readSVarint(),1===i&&(t&&l.push(t),t=[]),t.push(new n(s,a));else{if(7!==i)throw new Error("unknown command "+i);t&&t.push(t[0].clone())}}return t&&l.push(t),l},nu.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,r=1,i=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;e.pos<t;){if(i<=0){var u=e.readVarint();r=7&u,i=u>>3}if(i--,1===r||2===r)(n+=e.readSVarint())<s&&(s=n),n>a&&(a=n),(o+=e.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==r)throw new Error("unknown command "+r)}return[s,l,a,c]},nu.prototype.toGeoJSON=function(e,t,r){var i,n,o=this.extent*Math.pow(2,r),s=this.extent*e,a=this.extent*t,l=this.loadGeometry(),c=nu.types[this.type];function u(e){for(var t=0;t<e.length;t++){var r=e[t];e[t]=[360*(r.x+s)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(r.y+a)/o)*Math.PI/180))-90]}}switch(this.type){case 1:var h=[];for(i=0;i<l.length;i++)h[i]=l[i][0];u(l=h);break;case 2:for(i=0;i<l.length;i++)u(l[i]);break;case 3:for(l=function(e){var t=e.length;if(t<=1)return[e];for(var r,i,n=[],o=0;o<t;o++){var s=su(e[o]);0!==s&&(void 0===i&&(i=s<0),i===s<0?(r&&n.push(r),r=[e[o]]):r.push(e[o]))}return r&&n.push(r),n}(l),i=0;i<l.length;i++)for(n=0;n<l[i].length;n++)u(l[i][n])}1===l.length?l=l[0]:c="Multi"+c;var p={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(p.id=this.id),p};var au=lu;function lu(e,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(cu,this,t),this.length=this._features.length}function cu(e,t,r){15===e?t.version=r.readVarint():1===e?t.name=r.readString():5===e?t.extent=r.readVarint():2===e?t._features.push(r.pos):3===e?t._keys.push(r.readString()):4===e&&t._values.push(function(e){for(var t=null,r=e.readVarint()+e.pos;e.pos<r;){var i=e.readVarint()>>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}return t}(r))}function uu(e,t,r){if(3===e){var i=new au(r,r.readVarint()+r.pos);i.length&&(t[i.name]=i)}}lu.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new iu(this._pbf,t,this.extent,this._keys,this._values)};var hu={VectorTile:function(e,t){this.layers=e.readFields(uu,{},t)},VectorTileFeature:iu,VectorTileLayer:au};function pu(e,t,r,i){const o=[],s=0===i?(e,t,r,i,o,s)=>{e.push(new n(s,r+(s-t)/(i-t)*(o-r)))}:(e,t,r,i,o,s)=>{e.push(new n(t+(s-r)/(o-r)*(i-t),s))};for(const n of e){const e=[];for(const o of n){if(o.length<=2)continue;const n=[];for(let e=0;e<o.length-1;e++){const a=o[e].x,l=o[e].y,c=o[e+1].x,u=o[e+1].y,h=0===i?a:l,p=0===i?c:u;h<t?p>t&&s(n,a,l,c,u,t):h>r?p<r&&s(n,a,l,c,u,r):n.push(o[e]),p<t&&h>=t&&s(n,a,l,c,u,t),p>r&&h<=r&&s(n,a,l,c,u,r)}let a=o[o.length-1];const l=0===i?a.x:a.y;l>=t&&l<=r&&n.push(a),n.length&&(a=n[n.length-1],n[0].x===a.x&&n[0].y===a.y||n.push(n[0]),e.push(n))}e.length&&o.push(e)}return o}const du=hu.VectorTileFeature.types,fu=Math.pow(2,13);function mu(e,t,r,i,n,o,s,a){e.emplaceBack((t<<1)+s,(r<<1)+o,(Math.floor(i*fu)<<1)+n,Math.round(a))}function _u(e,t,r){const i=16384;e.emplaceBack(t.x,t.y,t.z,r[0]*i,r[1]*i,r[2]*i)}class gu{constructor(){this.acc=new n(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new n(e.x,e.y),this.max=new n(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const r=this.min,i=this.max;e.x<r.x?r.x=e.x:e.x>i.x&&(i.x=e.x),e.y<r.y?r.y=e.y:e.y>i.y&&(i.y=e.y),((0===e.x||e.x===ba)&&e.x===t.x)!=((0===e.y||e.y===ba)&&e.y===t.y)&&this.processBorderOverlap(e,t),t.x<0!=e.x<0&&this.addBorderIntersection(0,gr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>ba!=e.x>ba&&this.addBorderIntersection(1,gr(t.y,e.y,(ba-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,gr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>ba!=e.y>ba&&this.addBorderIntersection(3,gr(t.x,e.x,(ba-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const r=this.borders[e];t<r[0]&&(r[0]=t),t>r[1]&&(r[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const r=0===e.x?0:1;this.addBorderIntersection(r,t.y),this.addBorderIntersection(r,e.y)}else{const r=0===e.y?2:3;this.addBorderIntersection(r,t.x),this.addBorderIntersection(r,e.x)}}centroid(){const e=this.polyCount.reduce(((e,t)=>e+t.edges),0);return 0!==e?this.acc.div(e)._round():new n(0,0)}span(){return new n(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0)}}class yu{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new es,this.centroidVertexArray=new Os,this.indexArray=new fs,this.programConfigurations=new ua(e.layers,e.zoom),this.segments=new xa,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.enableTerrain=e.enableTerrain}populate(e,t,r,i){this.features=[],this.hasPattern=Hc("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(e){const t=Math.exp(Math.PI*(1-e.y/(1<<e.z)*2));return 80150034*t/(t*t+1)/ba/(1<<e.z)}(r);for(const{feature:n,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=qa(n,e);if(!this.layers[0]._featureFilter.filter(new zo(this.zoom),l,r))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:Va(n,r,i),properties:n.properties,type:n.type,patterns:{}},u=this.layoutVertexArray.length;this.hasPattern?this.features.push(Xc("fill-extrusion",this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,s,r,{},t.availableImages,i),t.featureIndex.insert(n,c.geometry,s,a,this.index,u)}this.sortBorders()}addFeatures(e,t,r,i,n){for(const e of this.features){const{geometry:o}=e;this.addFeature(e,o,e.index,t,r,i,n)}this.sortBorders()}update(e,t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,r,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ru),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,tu.members,!0))),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,eu.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,r,i,o,s,a){const l=[new n(0,0),new n(ba,ba)],c=a.projection,u="globe"===c.name,h=this.enableTerrain&&!u?new gu:null;u&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Ss);const p=Zc(t,500);for(let e=p.length-1;e>=0;e--){const t=p[e];(0===t.length||(d=t[0]).every((e=>e.x<=0))||d.every((e=>e.x>=ba))||d.every((e=>e.y<=0))||d.every((e=>e.y>=ba)))&&p.splice(e,1)}var d;let f;if(u)f=bu(p,l,i);else{f=[];for(const e of p)f.push({polygon:e,bounds:l})}for(const t of f){const r=t.polygon;let n=0,o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(let e=0;e<r.length;e++){const s=r[e];if(0===s.length)continue;n+=s.length;let a=0;h&&h.startRing(s[0]);for(let e=0;e<s.length;e++){const r=s[e];if(e>=1){const n=s[e-1];if(!vu(r,n,t.bounds)){h&&h.append(r,n),o.vertexLength+4>xa.MAX_VERTEX_ARRAY_LENGTH&&(o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const e=r.sub(n)._perp(),t=e.x/(Math.abs(e.x)+Math.abs(e.y)),s=e.y>0?1:0,l=n.dist(r);a+l>32768&&(a=0),mu(this.layoutVertexArray,r.x,r.y,t,s,0,0,a),mu(this.layoutVertexArray,r.x,r.y,t,s,0,1,a),a+=l,mu(this.layoutVertexArray,n.x,n.y,t,s,0,0,a),mu(this.layoutVertexArray,n.x,n.y,t,s,0,1,a);const p=o.vertexLength;if(this.indexArray.emplaceBack(p,p+2,p+1),this.indexArray.emplaceBack(p+1,p+2,p+3),o.vertexLength+=4,o.primitiveLength+=2,u){const e=this.layoutVertexExtArray,t=c.projectTilePoint(r.x,r.y,i),o=c.projectTilePoint(n.x,n.y,i),s=c.upVector(i,r.x,r.y),a=c.upVector(i,n.x,n.y);_u(e,t,s),_u(e,t,s),_u(e,o,a),_u(e,o,a)}}}}}if(o.vertexLength+n>xa.MAX_VERTEX_ARRAY_LENGTH&&(o=this.segments.prepareSegment(n,this.layoutVertexArray,this.indexArray)),"Polygon"!==du[e.type])continue;const s=[],a=[],l=o.vertexLength;for(let e=0;e<r.length;e++){const t=r[e];if(0!==t.length){t!==r[0]&&a.push(s.length/2);for(let e=0;e<t.length;e++){const r=t[e];mu(this.layoutVertexArray,r.x,r.y,0,0,1,1,0),s.push(r.x),s.push(r.y),h&&h.currentPolyCount.top++,u&&_u(this.layoutVertexExtArray,c.projectTilePoint(r.x,r.y,i),c.upVector(i,r.x,r.y))}}}const p=fc(s,a);for(let e=0;e<p.length;e+=3)this.indexArray.emplaceBack(l+p[e],l+p[e+2],l+p[e+1]);o.primitiveLength+=p.length/3,o.vertexLength+=n}if(h&&h.polyCount.length>0){if(h.borders){h.vertexArrayOffset=this.centroidVertexArray.length;const e=h.borders,t=this.featuresOnBorder.push(h)-1;for(let r=0;r<4;r++)e[r][0]!==Number.MAX_VALUE&&this.borders[r].push(t)}this.encodeCentroid(h.borders?void 0:h.centroid(),h)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,o,s,i)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort(((t,r)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[r].borders[e][0]))}encodeCentroid(e,t,r=!0){let i,n;if(e)if(0!==e.y){const r=t.span()._mult(this.tileToMeter);i=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(r.x/10)),n=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(r.y/10))}else i=Math.ceil(7*(e.x+450)),n=0;else i=0,n=+r;let o=r?this.centroidVertexArray.length:t.vertexArrayOffset;for(const e of t.polyCount){r&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*e.edges+e.top);for(let t=0;t<2*e.edges;t++)this.centroidVertexArray.emplace(o++,0,n),this.centroidVertexArray.emplace(o++,i,n);for(let t=0;t<e.top;t++)this.centroidVertexArray.emplace(o++,i,n)}}}function vu(e,t,r){return e.x===t.x&&(e.x<r[0].x||e.x>r[1].x)||e.y===t.y&&(e.y<r[0].y||e.y>r[1].y)}function xu(){const e=Math.PI/32,t=Math.tan(e),r=Ta;return r*Math.sqrt(1+2*t*t)-r}function bu(e,t,r){const i=1<<r.z,o=Ma(r.x/i),s=Ma((r.x+1)/i),a=za(r.y/i),l=za((r.y+1)/i);return function(e,t,r,i,o=0,s){const a=[];if(!e.length||!r||!i)return a;const l=(e,t)=>{for(const r of e)a.push({polygon:r,bounds:t})},c=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(i)),h=c-u,p=[];for(let e=0;e<Math.abs(h);e++)p.push(h>0?0:1);for(let e=0;e<Math.min(c,u);e++)p.push(0),p.push(1);let d=e;if(d=pu(d,t[0].y-o,t[1].y+o,1),d=pu(d,t[0].x-o,t[1].x+o,0),!d.length)return a;const f=[];for(p.length?f.push({polygons:d,bounds:t,depth:0}):l(d,t);f.length;){const e=f.pop(),t=e.depth,r=p[t],i=e.bounds[0],a=e.bounds[1],c=0===r?i.x:i.y,u=0===r?a.x:a.y,h=s?s(r,c,u):.5*(c+u),d=pu(e.polygons,c-o,h+o,r),m=pu(e.polygons,h-o,u+o,r);if(d.length){const e=[i,new n(0===r?h:a.x,1===r?h:a.y)];p.length>t+1?f.push({polygons:d,bounds:e,depth:t+1}):l(d,e)}if(m.length){const e=[new n(0===r?h:i.x,1===r?h:i.y),a];p.length>t+1?f.push({polygons:m,bounds:e,depth:t+1}):l(m,e)}}return a}(e,t,Math.ceil((s-o)/11.25),Math.ceil((a-l)/11.25),1,((e,t,n)=>{if(0===e)return.5*(t+n);{const e=za((r.y+t/ba)/i);return(ka(.5*(za((r.y+n/ba)/i)+e))*i-r.y)*ba}}))}zn(yu,"FillExtrusionBucket",{omit:["layers","features"]}),zn(gu,"PartMetadata");var wu={paint:new $o({"fill-extrusion-opacity":new jo(Ge["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Uo(Ge["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new jo(Ge["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new jo(Ge["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Vo(Ge["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Uo(Ge["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Uo(Ge["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new jo(Ge["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Tu(e,t,r){var i=2*Math.PI*6378137/256/Math.pow(2,r);return[e*i-2*Math.PI*6378137/2,t*i-2*Math.PI*6378137/2]}class Eu{constructor(e,t,r){this.z=e,this.x=t,this.y=r,this.key=Au(0,e,e,t,r)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const r=function(e,t,r){var i=Tu(256*e,256*(t=Math.pow(2,r)-t-1),r),n=Tu(256*(e+1),256*(t+1),r);return i[0]+","+i[1]+","+n[0]+","+n[1]}(this.x,this.y,this.z),i=function(e,t,r){let i,n="";for(let o=e;o>0;o--)i=1<<o-1,n+=(t&i?1:0)+(r&i?2:0);return n}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===t?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",i).replace("{bbox-epsg-3857}",r)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Su{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Au(e,t.z,t.z,t.x,t.y)}}class Cu{constructor(e,t,r,i,n){this.overscaledZ=e,this.wrap=t,this.canonical=new Eu(r,+i,+n),this.key=0===t&&e===r?this.canonical.key:Au(t,e,r,i,n)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new Cu(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Cu(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Au(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-e;return Au(this.wrap*+t,e,e,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Cu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,r=2*this.canonical.x,i=2*this.canonical.y;return[new Cu(t,this.wrap,t,r,i),new Cu(t,this.wrap,t,r+1,i),new Cu(t,this.wrap,t,r,i+1),new Cu(t,this.wrap,t,r+1,i+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Cu(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Cu(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Su(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Au(e,t,r,i,n){const o=1<<Math.min(r,22);let s=o*(n%o)+i%o;return e&&r<22&&(s+=o*o*((e<0?-2*e-1:2*e)%(1<<2*(22-r)))),16*(32*s+r)+(t-r)}function ku(e,t){return e.x*t.x+e.y*t.y}function Iu(e,t){if(1===e.length){let r=0;const i=t[r++];let n;for(;!n||i.equals(n);)if(n=t[r++],!n)return 1/0;for(;r<t.length;r++){const o=t[r],s=e[0],a=n.sub(i),l=o.sub(i),c=s.sub(i),u=ku(a,a),h=ku(a,l),p=ku(l,l),d=ku(c,a),f=ku(c,l),m=u*p-h*h,_=(p*d-h*f)/m,g=(u*f-h*d)/m,y=i.z*(1-_-g)+n.z*_+o.z*g;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const r of t)e=Math.min(e,r.z);return e}}function Mu(e){const t=new n(e[0],e[1]);return t.z=e[2],t}function zu(e,t,r,i,n,o,s,a){const l=s*n.getElevationAt(e,t,!0,!0),c=0!==o[0],u=c?0===o[1]?s*(o[0]/7-450):s*function(e,t,r){const i=Math.floor(t[0]/8),n=Math.floor(t[1]/8),o=10*(t[0]-8*i),s=10*(t[1]-8*n),a=e.getElevationAt(i,n,!0,!0),l=e.getMeterToDEM(r),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(s*l-1)),h=e.tileCoordToPixel(i,n),p=2*c+1,d=2*u+1,f=function(e,t,r,i,n){return[e.getElevationAtPixel(t,r,!0),e.getElevationAtPixel(t+n,r,!0),e.getElevationAtPixel(t,r+n,!0),e.getElevationAtPixel(t+i,r+n,!0)]}(e,h.x-c,h.y-u,p,d),m=Math.abs(f[0]-f[1]),_=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+_)/p),v=Math.min(.25,.5*l*g/d);return a+Math.max(y*o,v*s)}(n,o,a):l;return{base:l+(0===r)?-1:r,top:c?Math.max(u+i,l+r+2):l+i}}zn(Eu,"CanonicalTileID"),zn(Cu,"OverscaledTileID",{omit:["projMatrix"]});const Pu=Yo([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Du}=Pu,Lu=Yo([{name:"a_packed",components:4,type:"Float32"}]),{members:Bu}=Lu,Ru=hu.VectorTileFeature.types,Ou=Math.cos(Math.PI/180*37.5);class Fu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={}})),this.layoutVertexArray=new ts,this.layoutVertexArray2=new rs,this.indexArray=new fs,this.programConfigurations=new ua(e.layers,e.zoom),this.segments=new xa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,r,i){this.hasPattern=Hc("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=qa(t,e);if(!this.layers[0]._featureFilter.filter(new zo(this.zoom),c,r))continue;const u=n?n.evaluate(c,{},r):void 0,h={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Va(t,r,i),patterns:{},sortKey:u};o.push(h)}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:s,featureIndex:a}=t,l=this.addConstantDashes(s);for(const i of o){const{geometry:n,index:o,sourceLayerIndex:c}=i;if(l&&this.addFeatureDashes(i,s),this.hasPattern){const e=Xc("line",this.layers,i,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(i,n,o,r,s.positions,t.availableImages);a.insert(e[o].feature,n,o,c,this.index)}}addConstantDashes(e){let t=!1;for(const r of this.layers){const i=r.paint.get("line-dasharray").value,n=r.layout.get("line-cap").value;if("constant"!==i.kind||"constant"!==n.kind)t=!0;else{const t=n.value,r=i.value;if(!r)continue;e.addDash(r.from,t),e.addDash(r.to,t),r.other&&e.addDash(r.other,t)}}return t}addFeatureDashes(e,t){const r=this.zoom;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,o=i.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a,l,c,u,h;if("constant"===n.kind){const e=n.value;if(!e)continue;s=e.other||e.to,a=e.to,l=e.from}else s=n.evaluate({zoom:r-1},e),a=n.evaluate({zoom:r},e),l=n.evaluate({zoom:r+1},e);"constant"===o.kind?c=u=h=o.value:(c=o.evaluate({zoom:r-1},e),u=o.evaluate({zoom:r},e),h=o.evaluate({zoom:r+1},e)),t.addDash(s,c),t.addDash(a,u),t.addDash(l,h);const p=t.getKey(s,c),d=t.getKey(a,u),f=t.getKey(l,h);e.patterns[i.id]={min:p,mid:d,max:f}}}update(e,t,r,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,r,i)}addFeatures(e,t,r,i,n){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,r,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Bu)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Du),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,r,i,n,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(e,{}),l=s.get("line-cap").evaluate(e,{}),c=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const r of t)this.addLine(r,e,a,l,c,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,n,o,i)}addLine(e,t,r,i,n,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const s="Polygon"===Ru[t.type];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;let l=0;for(;l<a-1&&e[l].equals(e[l+1]);)l++;if(a<(s?3:2))return;"bevel"===r&&(n=1.05);const c=this.overscaling<=16?122880/(512*this.overscaling):0,u=this.segments.prepareSegment(10*a,this.layoutVertexArray,this.indexArray);let h,p,d,f,m;this.e1=this.e2=-1,s&&(h=e[a-2],m=e[l].sub(h)._unit()._perp());for(let t=l;t<a;t++){if(d=t===a-1?s?e[l+1]:void 0:e[t+1],d&&e[t].equals(d))continue;m&&(f=m),h&&(p=h),h=e[t],m=d?d.sub(h)._unit()._perp():f,f=f||m;let _=f.add(m);0===_.x&&0===_.y||_._unit();const g=f.x*m.x+f.y*m.y,y=_.x*m.x+_.y*m.y,v=0!==y?1/y:1/0,x=2*Math.sqrt(2-2*y),b=y<Ou&&p&&d,w=f.x*m.y-f.y*m.x>0;if(b&&t>l){const e=h.dist(p);if(e>2*c){const t=h.sub(h.sub(p)._mult(c/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,f,0,0,u),p=t}}const T=p&&d;let E=T?r:s?"butt":i;if(T&&"round"===E&&(v<o?E="miter":v<=2&&(E="fakeround")),"miter"===E&&v>n&&(E="bevel"),"bevel"===E&&(v>2&&(E="flipbevel"),v<n&&(E="miter")),p&&this.updateDistance(p,h),"miter"===E)_._mult(v),this.addCurrentVertex(h,_,0,0,u);else if("flipbevel"===E){if(v>100)_=m.mult(-1);else{const e=v*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(h,_,0,0,u),this.addCurrentVertex(h,_.mult(-1),0,0,u)}else if("bevel"===E||"fakeround"===E){const e=-Math.sqrt(v*v-1),t=w?e:0,r=w?0:e;if(p&&this.addCurrentVertex(h,f,t,r,u),"fakeround"===E){const e=Math.round(180*x/Math.PI/20);for(let t=1;t<e;t++){let r=t/e;if(.5!==r){const e=r-.5;r+=r*e*(r-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*e*e+(.848013+g*(.215638*g-1.06021)))}const i=m.sub(f)._mult(r)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(h,i.x,i.y,!1,w,0,u)}}d&&this.addCurrentVertex(h,m,-t,-r,u)}else if("butt"===E)this.addCurrentVertex(h,_,0,0,u);else if("square"===E){const e=p?1:-1;p||this.addCurrentVertex(h,_,e,e,u),this.addCurrentVertex(h,_,0,0,u),p&&this.addCurrentVertex(h,_,e,e,u)}else"round"===E&&(p&&(this.addCurrentVertex(h,f,0,0,u),this.addCurrentVertex(h,f,1,1,u,!0)),d&&(this.addCurrentVertex(h,m,-1,-1,u,!0),this.addCurrentVertex(h,m,0,0,u)));if(b&&t<a-1){const e=h.dist(d);if(e>2*c){const t=h.add(d.sub(h)._mult(c/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,m,0,0,u),h=t}}}}addCurrentVertex(e,t,r,i,n,o=!1){const s=t.y*i-t.x,a=-t.y-t.x*i;this.addHalfVertex(e,t.x+t.y*r,t.y-t.x*r,o,!1,r,n),this.addHalfVertex(e,s,a,o,!0,-i,n)}addHalfVertex({x:e,y:t},r,i,n,o,s,a){this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*r)+128,Math.round(63*i)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}zn(Fu,"LineBucket",{omit:["layers","patternFeatures"]});const Nu=new $o({"line-cap":new Uo(Ge.layout_line["line-cap"]),"line-join":new Uo(Ge.layout_line["line-join"]),"line-miter-limit":new jo(Ge.layout_line["line-miter-limit"]),"line-round-limit":new jo(Ge.layout_line["line-round-limit"]),"line-sort-key":new Uo(Ge.layout_line["line-sort-key"])});var ju={paint:new $o({"line-opacity":new Uo(Ge.paint_line["line-opacity"]),"line-color":new Uo(Ge.paint_line["line-color"]),"line-translate":new jo(Ge.paint_line["line-translate"]),"line-translate-anchor":new jo(Ge.paint_line["line-translate-anchor"]),"line-width":new Uo(Ge.paint_line["line-width"]),"line-gap-width":new Uo(Ge.paint_line["line-gap-width"]),"line-offset":new Uo(Ge.paint_line["line-offset"]),"line-blur":new Uo(Ge.paint_line["line-blur"]),"line-dasharray":new Vo(Ge.paint_line["line-dasharray"]),"line-pattern":new Vo(Ge.paint_line["line-pattern"]),"line-gradient":new Go(Ge.paint_line["line-gradient"]),"line-trim-offset":new jo(Ge.paint_line["line-trim-offset"])}),layout:Nu};const Uu=new class extends Uo{possiblyEvaluate(e,t){return t=new zo(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,r,i){return t=v({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,r,i)}}(ju.paint.properties["line-width"].specification);function Vu(e,t){return t>0?t+2*e:e}Uu.useIntegerZoom=!0;const qu=Yo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Gu=Yo([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),$u=Yo([{name:"a_projected_pos",components:4,type:"Float32"}],4);Yo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Zu=Yo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Wu=Yo([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Yo([{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 Hu=Yo([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Xu=Yo([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Yo([{name:"triangle",components:3,type:"Uint16"}]),Yo([{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"}]),Yo([{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"}]),Yo([{type:"Float32",name:"offsetX"}]),Yo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var Yu=24;const Ku=128;function Ju(e,t){const{expression:r}=t;if("constant"===r.kind)return{kind:"constant",layoutSize:r.evaluate(new zo(e+1))};if("source"===r.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:i}=r;let n=0;for(;n<t.length&&t[n]<=e;)n++;n=Math.max(0,n-1);let o=n;for(;o<t.length&&t[o]<e+1;)o++;o=Math.min(t.length-1,o);const s=t[n],a=t[o];return"composite"===r.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:i}:{kind:"camera",minZoom:s,maxZoom:a,minSize:r.evaluate(new zo(s)),maxSize:r.evaluate(new zo(a)),interpolationType:i}}}function Qu(e,{uSize:t,uSizeT:r},{lowerSize:i,upperSize:n}){return"source"===e.kind?i/Ku:"composite"===e.kind?gr(i/Ku,n/Ku,r):t}function eh(e,t){let r=0,i=0;if("constant"===e.kind)i=e.layoutSize;else if("source"!==e.kind){const{interpolationType:n,minZoom:o,maxZoom:s}=e,a=n?f(Fr.interpolationFactor(n,t,o,s),0,1):0;"camera"===e.kind?i=gr(e.minSize,e.maxSize,a):r=a}return{uSizeT:r,uSize:i}}var th=Object.freeze({__proto__:null,getSizeData:Ju,evaluateSizeForFeature:Qu,evaluateSizeForZoom:eh,SIZE_PACK_FACTOR:Ku});function rh(e,t,r){return e.sections.forEach((e=>{e.text=function(e,t,r){const i=t.layout.get("text-transform").evaluate(r,{});return"uppercase"===i?e=e.toLocaleUpperCase():"lowercase"===i&&(e=e.toLocaleLowerCase()),Mo.applyArabicShaping&&(e=Mo.applyArabicShaping(e)),e}(e.text,t,r)})),e}const ih={"!":"︕","#":"",$:"","%":"","&":"","(":"︵",")":"︶","*":"","+":"",",":"︐","-":"︲",".":"・","/":"",":":"︓",";":"︔","<":"︿","=":"",">":"﹀","?":"︖","@":"","[":"﹇","\\":"","]":"﹈","^":"",_:"︳","`":"","{":"︷","|":"―","}":"︸","~":"","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","":"︲","—":"︱","":"﹃","":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","":"︹","":"︺","〖":"︗","〗":"︘","":"︕","":"︵","":"︶","":"︐","":"︲","":"・","":"︓","":"︔","":"︿","":"﹀","":"︖","":"﹇","":"﹈","_":"︳","":"︷","":"―","":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function nh(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||""===e||" ̄"===e||"︑"===e||"︒"===e}function oh(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}var sh=function(e,t,r,i,n){var o,s,a=8*n-i-1,l=(1<<a)-1,c=l>>1,u=-7,h=r?n-1:0,p=r?-1:1,d=e[t+h];for(h+=p,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+e[t+h],h+=p,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=i;u>0;s=256*s+e[t+h],h+=p,u-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,i),o-=c}return(d?-1:1)*s*Math.pow(2,o-i)},ah=function(e,t,r,i,n,o){var s,a,l,c=8*o-n-1,u=(1<<c)-1,h=u>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:o-1,f=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*l-1)*Math.pow(2,n),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;e[r+d]=255&a,d+=f,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;e[r+d]=255&s,d+=f,s/=256,c-=8);e[r+d-f]|=128*m},lh=ch;function ch(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}ch.Varint=0,ch.Fixed64=1,ch.Bytes=2,ch.Fixed32=5;var uh=4294967296,hh=1/uh,ph="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function dh(e){return e.type===ch.Bytes?e.readVarint()+e.pos:e.pos+1}function fh(e,t,r){return r?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function mh(e,t,r){var i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(i);for(var n=r.pos-1;n>=e;n--)r.buf[n+i]=r.buf[n]}function _h(e,t){for(var r=0;r<e.length;r++)t.writeVarint(e[r])}function gh(e,t){for(var r=0;r<e.length;r++)t.writeSVarint(e[r])}function yh(e,t){for(var r=0;r<e.length;r++)t.writeFloat(e[r])}function vh(e,t){for(var r=0;r<e.length;r++)t.writeDouble(e[r])}function xh(e,t){for(var r=0;r<e.length;r++)t.writeBoolean(e[r])}function bh(e,t){for(var r=0;r<e.length;r++)t.writeFixed32(e[r])}function wh(e,t){for(var r=0;r<e.length;r++)t.writeSFixed32(e[r])}function Th(e,t){for(var r=0;r<e.length;r++)t.writeFixed64(e[r])}function Eh(e,t){for(var r=0;r<e.length;r++)t.writeSFixed64(e[r])}function Sh(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function Ch(e,t,r){e[r]=t,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24}function Ah(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function kh(e,t,r){t.glyphs=[],1===e&&r.readMessage(Ih,t)}function Ih(e,t,r){if(3===e){const{id:e,bitmap:i,width:n,height:o,left:s,top:a,advance:l}=r.readMessage(Mh,{});t.glyphs.push({id:e,bitmap:new ac({width:n+6,height:o+6},i),metrics:{width:n,height:o,left:s,top:a,advance:l}})}else 4===e?t.ascender=r.readSVarint():5===e&&(t.descender=r.readSVarint())}function Mh(e,t,r){1===e?t.id=r.readVarint():2===e?t.bitmap=r.readBytes():3===e?t.width=r.readVarint():4===e?t.height=r.readVarint():5===e?t.left=r.readSVarint():6===e?t.top=r.readSVarint():7===e&&(t.advance=r.readVarint())}function zh(e){let t=0,r=0;for(const i of e)t+=i.w*i.h,r=Math.max(r,i.w);e.sort(((e,t)=>t.h-e.h));const i=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}];let n=0,o=0;for(const t of e)for(let e=i.length-1;e>=0;e--){const r=i[e];if(!(t.w>r.w||t.h>r.h)){if(t.x=r.x,t.y=r.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===r.w&&t.h===r.h){const t=i.pop();e<i.length&&(i[e]=t)}else t.h===r.h?(r.x+=t.w,r.w-=t.w):t.w===r.w?(r.y+=t.h,r.h-=t.h):(i.push({x:r.x+t.w,y:r.y,w:r.w-t.w,h:t.h}),r.y+=t.h,r.h-=t.h);break}}return{w:n,h:o,fill:t/(n*o)||0}}ch.prototype={destroy:function(){this.buf=null},readFields:function(e,t,r){for(r=r||this.length;this.pos<r;){var i=this.readVarint(),n=i>>3,o=this.pos;this.type=7&i,e(n,t,this),this.pos===o&&this.skip(i)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Sh(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Ah(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Sh(this.buf,this.pos)+Sh(this.buf,this.pos+4)*uh;return this.pos+=8,e},readSFixed64:function(){var e=Sh(this.buf,this.pos)+Ah(this.buf,this.pos+4)*uh;return this.pos+=8,e},readFloat:function(){var e=sh(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=sh(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,r,i=this.buf;return t=127&(r=i[this.pos++]),r<128?t:(t|=(127&(r=i[this.pos++]))<<7,r<128?t:(t|=(127&(r=i[this.pos++]))<<14,r<128?t:(t|=(127&(r=i[this.pos++]))<<21,r<128?t:function(e,t,r){var i,n,o=r.buf;if(i=(112&(n=o[r.pos++]))>>4,n<128)return fh(e,i,t);if(i|=(127&(n=o[r.pos++]))<<3,n<128)return fh(e,i,t);if(i|=(127&(n=o[r.pos++]))<<10,n<128)return fh(e,i,t);if(i|=(127&(n=o[r.pos++]))<<17,n<128)return fh(e,i,t);if(i|=(127&(n=o[r.pos++]))<<24,n<128)return fh(e,i,t);if(i|=(1&(n=o[r.pos++]))<<31,n<128)return fh(e,i,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(r=i[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&ph?function(e,t,r){return ph.decode(e.subarray(t,r))}(this.buf,t,e):function(e,t,r){for(var i="",n=t;n<r;){var o,s,a,l=e[n],c=null,u=l>239?4:l>223?3:l>191?2:1;if(n+u>r)break;1===u?l<128&&(c=l):2===u?128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(s=e[n+2],128==(192&(o=e[n+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(s=e[n+2],a=e[n+3],128==(192&(o=e[n+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,i+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),i+=String.fromCharCode(c),n+=u}return i}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==ch.Bytes)return e.push(this.readVarint(t));var r=dh(this);for(e=e||[];this.pos<r;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==ch.Bytes)return e.push(this.readSVarint());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==ch.Bytes)return e.push(this.readBoolean());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==ch.Bytes)return e.push(this.readFloat());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==ch.Bytes)return e.push(this.readDouble());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==ch.Bytes)return e.push(this.readFixed32());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==ch.Bytes)return e.push(this.readSFixed32());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==ch.Bytes)return e.push(this.readFixed64());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==ch.Bytes)return e.push(this.readSFixed64());var t=dh(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===ch.Varint)for(;this.buf[this.pos++]>127;);else if(t===ch.Bytes)this.pos=this.readVarint()+this.pos;else if(t===ch.Fixed32)this.pos+=4;else{if(t!==ch.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var r=new Uint8Array(t);r.set(this.buf),this.buf=r,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),Ch(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Ch(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Ch(this.buf,-1&e,this.pos),Ch(this.buf,Math.floor(e*hh),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Ch(this.buf,-1&e,this.pos),Ch(this.buf,Math.floor(e*hh),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var r,i;if(e>=0?(r=e%4294967296|0,i=e/4294967296|0):(i=~(-e/4294967296),4294967295^(r=~(-e%4294967296))?r=r+1|0:(r=0,i=i+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,r){r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,r.buf[r.pos]=127&(e>>>=7)}(r,0,t),function(e,t){var r=(7&e)<<4;t.buf[t.pos++]|=r|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(i,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,r){for(var i,n,o=0;o<t.length;o++){if((i=t.charCodeAt(o))>55295&&i<57344){if(!n){i>56319||o+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):n=i;continue}if(i<56320){e[r++]=239,e[r++]=191,e[r++]=189,n=i;continue}i=n-55296<<10|i-56320|65536,n=null}else n&&(e[r++]=239,e[r++]=191,e[r++]=189,n=null);i<128?e[r++]=i:(i<2048?e[r++]=i>>6|192:(i<65536?e[r++]=i>>12|224:(e[r++]=i>>18|240,e[r++]=i>>12&63|128),e[r++]=i>>6&63|128),e[r++]=63&i|128)}return r}(this.buf,e,this.pos);var r=this.pos-t;r>=128&&mh(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(e){this.realloc(4),ah(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),ah(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var r=0;r<t;r++)this.buf[this.pos++]=e[r]},writeRawMessage:function(e,t){this.pos++;var r=this.pos;e(t,this);var i=this.pos-r;i>=128&&mh(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,t,r){this.writeTag(e,ch.Bytes),this.writeRawMessage(t,r)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,_h,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,gh,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,xh,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,yh,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,vh,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,bh,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,wh,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Th,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Eh,t)},writeBytesField:function(e,t){this.writeTag(e,ch.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,ch.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,ch.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,ch.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,ch.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,ch.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,ch.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,ch.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,ch.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,ch.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};class Ph{constructor(e,{pixelRatio:t,version:r,stretchX:i,stretchY:n,content:o}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=i,this.stretchY=n,this.content=o,this.version=r}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 Dh{constructor(e,t){const r={},i={};this.haveRenderCallbacks=[];const n=[];this.addImages(e,r,n),this.addImages(t,i,n);const{w:o,h:s}=zh(n),a=new lc({width:o||1,height:s||1});for(const t in e){const i=e[t],n=r[t].paddedRect;lc.copy(i.data,a,{x:0,y:0},{x:n.x+1,y:n.y+1},i.data)}for(const e in t){const r=t[e],n=i[e].paddedRect,o=n.x+1,s=n.y+1,l=r.data.width,c=r.data.height;lc.copy(r.data,a,{x:0,y:0},{x:o,y:s},r.data),lc.copy(r.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),lc.copy(r.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),lc.copy(r.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),lc.copy(r.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=r,this.patternPositions=i}addImages(e,t,r){for(const i in e){const n=e[i],o={x:0,y:0,w:n.data.width+2,h:n.data.height+2};r.push(o),t[i]=new Ph(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(i)}}patchUpdatedImages(e,t){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((t=>e.hasImage(t))),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const r in e.updatedImages)this.patchUpdatedImage(this.iconPositions[r],e.getImage(r),t),this.patchUpdatedImage(this.patternPositions[r],e.getImage(r),t)}patchUpdatedImage(e,t,r){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[i,n]=e.tl;r.update(t.data,void 0,{x:i,y:n})}}zn(Ph,"ImagePosition"),zn(Dh,"ImageAtlas");const Lh={horizontal:1,vertical:2,horizontalOnly:3};class Bh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const r=new Bh;return r.scale=e||1,r.fontStack=t,r}static forImage(e){const t=new Bh;return t.imageName=e,t}}class Rh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const r=new Rh;for(let i=0;i<e.sections.length;i++){const n=e.sections[i];n.image?r.addImageSection(n):r.addTextSection(n,t)}return r}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(e){this.text=function(e,t){let r="";for(let i=0;i<e.length;i++){const n=e.charCodeAt(i+1)||null,o=e.charCodeAt(i-1)||null;r+=!t&&(n&&mo(n)&&!ih[e[i+1]]||o&&mo(o)&&!ih[e[i-1]])||!ih[e[i]]?e[i]:ih[e[i]]}return r}(this.text,e)}trim(){let e=0;for(let t=0;t<this.text.length&&Fh[this.text.charCodeAt(t)];t++)e++;let t=this.text.length;for(let r=this.text.length-1;r>=0&&r>=e&&Fh[this.text.charCodeAt(r)];r--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const r=new Rh;return r.text=this.text.substring(e,t),r.sectionIndex=this.sectionIndex.slice(e,t),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Bh.forText(e.scale,e.fontStack||t));const r=this.sections.length-1;for(let t=0;t<e.text.length;++t)this.sectionIndex.push(r)}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void z("Can't add FormattedSection with an empty image.");const r=this.getNextImageSectionCharCode();r?(this.text+=String.fromCharCode(r),this.sections.push(Bh.forImage(t)),this.sectionIndex.push(this.sections.length-1)):z("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Oh(e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m){const _=Rh.fromFeature(e,n);let g;h===Lh.vertical&&_.verticalizePunctuation(p);const{processBidirectionalText:y,processStyledBidirectionalText:v}=Mo;if(y&&1===_.sections.length){g=[];const e=y(_.toString(),$h(_,c,o,t,i,d,f));for(const t of e){const e=new Rh;e.text=t,e.sections=_.sections;for(let r=0;r<t.length;r++)e.sectionIndex.push(0);g.push(e)}}else if(v){g=[];const e=v(_.text,_.sectionIndex,$h(_,c,o,t,i,d,f));for(const t of e){const e=new Rh;e.text=t[0],e.sectionIndex=t[1],e.sections=_.sections,g.push(e)}}else g=function(e,t){const r=[],i=e.text;let n=0;for(const i of t)r.push(e.substring(n,i)),n=i;return n<i.length&&r.push(e.substring(n,i.length)),r}(_,$h(_,c,o,t,i,d,f));const x=[],b={positionedLines:x,text:_.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:h,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(e,t,r,i,n,o,s,a,l,c,u,h){let p=0,d=0,f=0;const m="right"===a?1:"left"===a?0:.5;let _=!1;for(const e of n){const r=e.getSections();for(const e of r){if(e.imageName)continue;const r=t[e.fontStack];if(r&&(_=void 0!==r.ascender&&void 0!==r.descender,!_))break}if(!_)break}let g=0;for(const s of n){s.trim();const n=s.getMaxScale(),a=(n-1)*Yu,v={positionedGlyphs:[],lineOffset:0};e.positionedLines[g]=v;const x=v.positionedGlyphs;let b=0;if(!s.length()){d+=o,++g;continue}let w=0,T=0;for(let o=0;o<s.length();o++){const a=s.getSection(o),f=s.getSectionIndex(o),m=s.getCharCode(o);let g=a.scale,v=null,E=null,S=null,C=Yu,A=0;const k=!(l===Lh.horizontal||!u&&!fo(m)||u&&(Fh[m]||(y=m,On(y)||Fn(y)||Nn(y)||no(y)||lo(y))));if(a.imageName){const t=i[a.imageName];if(!t)continue;S=a.imageName,e.iconsInText=e.iconsInText||!0,E=t.paddedRect;const r=t.displaySize;g=g*Yu/h,v={width:r[0],height:r[1],left:1,top:-3,advance:k?r[1]:r[0],localGlyph:!1},A=_?-v.height*g:n*Yu-17-r[1]*g,C=v.advance;const o=(k?r[0]:r[1])*g-Yu*n;o>0&&o>b&&(b=o)}else{const e=r[a.fontStack];if(!e)continue;e[m]&&(E=e[m]);const i=t[a.fontStack];if(!i)continue;const o=i.glyphs[m];if(!o)continue;if(v=o.metrics,C=8203!==m?Yu:0,_){const e=void 0!==i.ascender?Math.abs(i.ascender):0,t=void 0!==i.descender?Math.abs(i.descender):0,r=(e+t)*g;w<r&&(w=r,T=(e-t)/2*g),A=-e*g}else A=(n-g)*Yu-17}k?(e.verticalizable=!0,x.push({glyph:m,imageName:S,x:p,y:d+A,vertical:k,scale:g,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:v,rect:E}),p+=C*g+c):(x.push({glyph:m,imageName:S,x:p,y:d+A,vertical:k,scale:g,localGlyph:v.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:v,rect:E}),p+=v.advance*g+c)}0!==x.length&&(f=Math.max(p-c,f),_?Wh(x,m,b,T,o*n/2):Wh(x,m,b,0,o/2)),p=0;const E=o*n+b;v.lineOffset=Math.max(b,a),d+=E,++g}var y;const v=d,{horizontalAlign:x,verticalAlign:b}=Zh(s);(function(e,t,r,i,n,o){const s=(t-r)*n,a=-o*i;for(const t of e)for(const e of t.positionedGlyphs)e.x+=s,e.y+=a})(e.positionedLines,m,x,b,f,v),e.top+=-b*v,e.bottom=e.top+v,e.left+=-x*f,e.right=e.left+f,e.hasBaseline=_}(b,t,r,i,g,s,a,l,h,c,p,m),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return!1;return!0}(x)&&b}const Fh={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Nh={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 jh(e,t,r,i,n,o){if(t.imageName){const e=i[t.imageName];return e?e.displaySize[0]*t.scale*Yu/o+n:0}{const i=r[t.fontStack],o=i&&i.glyphs[e];return o?o.metrics.advance*t.scale+n:0}}function Uh(e,t,r,i){const n=Math.pow(e-t,2);return i?e<t?n/2:2*n:n+Math.abs(r)*r}function Vh(e,t,r){let i=0;return 10===e&&(i-=1e4),r&&(i+=150),40!==e&&65288!==e||(i+=50),41!==t&&65289!==t||(i+=50),i}function qh(e,t,r,i,n,o){let s=null,a=Uh(t,r,n,o);for(const e of i){const i=Uh(t-e.x,r,n,o)+e.badness;i<=a&&(s=e,a=i)}return{index:e,x:t,priorBreak:s,badness:a}}function Gh(e){return e?Gh(e.priorBreak).concat(e.index):[]}function $h(e,t,r,i,n,o,s){if("point"!==o)return[];if(!e)return[];const a=[],l=function(e,t,r,i,n,o){let s=0;for(let r=0;r<e.length();r++){const a=e.getSection(r);s+=jh(e.getCharCode(r),a,i,n,t,o)}return s/Math.max(1,Math.ceil(s/r))}(e,t,r,i,n,s),c=e.text.indexOf("")>=0;let u=0;for(let r=0;r<e.length();r++){const o=e.getSection(r),p=e.getCharCode(r);if(Fh[p]||(u+=jh(p,o,i,n,t,s)),r<e.length()-1){const t=!((h=p)<11904||!(Wn(h)||Zn(h)||so(h)||io(h)||Kn(h)||jn(h)||Hn(h)||qn(h)||Jn(h)||Qn(h)||Yn(h)||co(h)||Gn(h)||Vn(h)||Un(h)||Xn(h)||$n(h)||oo(h)||to(h)||eo(h)));(Nh[p]||t||o.imageName)&&a.push(qh(r+1,u,l,a,Vh(p,e.getCharCode(r+1),t&&c),!1))}}var h;return Gh(qh(e.length(),u,l,a,0,!0))}function Zh(e){let t=.5,r=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0}return{horizontalAlign:t,verticalAlign:r}}function Wh(e,t,r,i,n){if(!(t||r||i||n))return;const o=e.length-1,s=e[o],a=(s.x+s.metrics.advance*s.scale)*t;for(let t=0;t<=o;t++)e[t].x-=a,e[t].y+=r+i+n}function Hh(e,t,r){const{horizontalAlign:i,verticalAlign:n}=Zh(r),o=t[0]-e.displaySize[0]*i,s=t[1]-e.displaySize[1]*n;return{image:e,top:s,bottom:s+e.displaySize[1],left:o,right:o+e.displaySize[0]}}function Xh(e,t,r,i,n,o){const s=e.image;let a;if(s.content){const e=s.content,t=s.pixelRatio||1;a=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}const l=t.left*o,c=t.right*o;let u,h,p,d;"width"===r||"both"===r?(d=n[0]+l-i[3],h=n[0]+c+i[1]):(d=n[0]+(l+c-s.displaySize[0])/2,h=d+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===r||"both"===r?(u=n[1]+f-i[0],p=n[1]+m+i[2]):(u=n[1]+(f+m-s.displaySize[1])/2,p=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:p,left:d,collisionPadding:a}}class Yh extends n{constructor(e,t,r,i,n){super(e,t),this.angle=i,this.z=r,void 0!==n&&(this.segment=n)}clone(){return new Yh(this.x,this.y,this.z,this.angle,this.segment)}}function Kh(e,t,r,i,n){if(void 0===t.segment)return!0;let o=t,s=t.segment+1,a=0;for(;a>-r/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;a<r/2;){const t=e[s],r=e[s+1];if(!r)return!1;let o=e[s-1].angleTo(t)-t.angleTo(r);for(o=Math.abs((o+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:o}),c+=o;a-l[0].distance>i;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=t.dist(r)}return!0}function Jh(e){let t=0;for(let r=0;r<e.length-1;r++)t+=e[r].dist(e[r+1]);return t}function Qh(e,t,r){return e?.6*t*r:0}function ep(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function tp(e,t,r,i,n,o){const s=Qh(r,n,o),a=ep(r,i)*o;let l=0;const c=Jh(e)/2;for(let r=0;r<e.length-1;r++){const i=e[r],n=e[r+1],o=i.dist(n);if(l+o>c){const u=(c-l)/o,h=gr(i.x,n.x,u),p=gr(i.y,n.y,u),d=new Yh(h,p,0,n.angleTo(i),r);return!s||Kh(e,d,a,s,t)?d:void 0}l+=o}}function rp(e,t,r,i,n,o,s,a,l){const c=Qh(i,o,s),u=ep(i,n),h=u*s,p=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h<t/4&&(t=h+t/4),ip(e,p?t/2*a%t:(u/2+2*o)*s*a%t,t,c,r,h,p,!1,l)}function ip(e,t,r,i,n,o,s,a,l){const c=o/2,u=Jh(e);let h=0,p=t-r,d=[];for(let t=0;t<e.length-1;t++){const s=e[t],a=e[t+1],f=s.dist(a),m=a.angleTo(s);for(;p+r<h+f;){p+=r;const _=(p-h)/f,g=gr(s.x,a.x,_),y=gr(s.y,a.y,_);if(g>=0&&g<l&&y>=0&&y<l&&p-c>=0&&p+c<=u){const r=new Yh(g,y,0,m,t);r._round(),i&&!Kh(e,r,o,i,n)||d.push(r)}}h+=f}return a||d.length||s||(d=ip(e,h/2,r,i,n,o,s,!0,l)),d}function np(e,t,r,i,o){const s=[];for(let a=0;a<e.length;a++){const l=e[a];let c;for(let e=0;e<l.length-1;e++){let a=l[e],u=l[e+1];a.x<t&&u.x<t||(a.x<t?a=new n(t,a.y+(t-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x<t&&(u=new n(t,a.y+(t-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y<r&&u.y<r||(a.y<r?a=new n(a.x+(r-a.y)/(u.y-a.y)*(u.x-a.x),r)._round():u.y<r&&(u=new n(a.x+(r-a.y)/(u.y-a.y)*(u.x-a.x),r)._round()),a.x>=i&&u.x>=i||(a.x>=i?a=new n(i,a.y+(i-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=i&&(u=new n(i,a.y+(i-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new n(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new n(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}zn(Yh,"Anchor");const op=1e20;function sp(e,t,r,i,n,o,s,a,l){for(let c=t;c<t+i;c++)ap(e,r*o+c,o,n,s,a,l);for(let c=r;c<r+n;c++)ap(e,c*o+t,1,i,s,a,l)}function ap(e,t,r,i,n,o,s){o[0]=0,s[0]=-op,s[1]=op,n[0]=e[t];for(let a=1,l=0,c=0;a<i;a++){n[a]=e[t+a*r];const i=a*a;do{const e=o[l];c=(n[a]-n[e]+i-e*e)/(a-e)/2}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=op}for(let a=0,l=0;a<i;a++){for(;s[l+1]<a;)l++;const i=o[l],c=a-i;e[t+a*r]=n[i]+c*c}}const lp={none:0,ideographs:1,all:2};class cp{constructor(e,t,r){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=r,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,t){const r=[];for(const t in e)for(const i of e[t])r.push({stack:t,id:i});g(r,(({stack:e,id:t},r)=>{let i=this.entries[e];i||(i=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=i.glyphs[t];if(void 0!==n)return void r(null,{stack:e,id:t,glyph:n});if(n=this._tinySDF(i,e,t),n)return i.glyphs[t]=n,void r(null,{stack:e,id:t,glyph:n});const o=Math.floor(t/256);if(256*o>65535)return void r(new Error("glyphs > 65535 not supported"));if(i.ranges[o])return void r(null,{stack:e,id:t,glyph:n});let s=i.requests[o];s||(s=i.requests[o]=[],cp.loadGlyphRange(e,o,this.url,this.requestManager,((e,t)=>{if(t){i.ascender=t.ascender,i.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(i.glyphs[+e]=t.glyphs[+e]);i.ranges[o]=!0}for(const r of s)r(e,t);delete i.requests[o]}))),s.push(((i,n)=>{i?r(i):n&&r(null,{stack:e,id:t,glyph:n.glyphs[t]||null})}))}),((e,r)=>{if(e)t(e);else if(r){const e={};for(const{stack:t,id:i,glyph:n}of r)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[i]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}}))}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==lp.none&&(this.localGlyphMode===lp.all?!!this.localFontFamily:!!this.localFontFamily&&(Qn(e)||ro(e)||Gn(e)||$n(e)||qn(e)))}_tinySDF(e,t,r){const i=this.localFontFamily;if(!i||!this._doesCharSupportLocalGlyph(r))return;let n=e.tinySDF;if(!n){let r="400";/bold/i.test(t)?r="900":/medium/i.test(t)?r="500":/light/i.test(t)&&(r="200"),n=e.tinySDF=new cp.TinySDF({fontFamily:i,fontWeight:r,fontSize:48,buffer:6,radius:16}),n.fontWeight=r}if(this.localGlyphs[n.fontWeight][r])return this.localGlyphs[n.fontWeight][r];const o=String.fromCharCode(r),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:p,glyphAdvance:d}=n.draw(o);return this.localGlyphs[n.fontWeight][r]={id:r,bitmap:new ac({width:a,height:l},s),metrics:{width:c/2,height:u/2,left:h/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}function up(e,t,r,i){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2,u=e.right-e.left,h=e.bottom-e.top,p=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],f=(e,t)=>e+t[1]-t[0],m=p.reduce(f,0),_=d.reduce(f,0),g=l-m,y=c-_;let v=0,x=m,b=0,w=_,T=0,E=g,S=0,C=y;if(s.content&&i){const e=s.content;v=hp(p,0,e[0]),b=hp(d,0,e[1]),x=hp(p,e[0],e[2]),w=hp(d,e[1],e[3]),T=e[0]-v,S=e[1]-b,E=e[2]-e[0]-x,C=e[3]-e[1]-w}const A=(i,o,l,c)=>{const p=dp(i.stretch-v,x,u,e.left),d=fp(i.fixed-T,E,i.stretch,m),f=dp(o.stretch-b,w,h,e.top),g=fp(o.fixed-S,C,o.stretch,_),y=dp(l.stretch-v,x,u,e.left),A=fp(l.fixed-T,E,l.stretch,m),k=dp(c.stretch-b,w,h,e.top),I=fp(c.fixed-S,C,c.stretch,_),M=new n(p,f),z=new n(y,f),P=new n(y,k),D=new n(p,k),L=new n(d/a,g/a),B=new n(A/a,I/a),R=t*Math.PI/180;if(R){const e=Math.sin(R),t=Math.cos(R),r=[t,-e,e,t];M._matMult(r),z._matMult(r),D._matMult(r),P._matMult(r)}const O=i.stretch+i.fixed,F=o.stretch+o.fixed;return{tl:M,tr:z,bl:D,br:P,tex:{x:s.paddedRect.x+1+O,y:s.paddedRect.y+1+F,w:l.stretch+l.fixed-O,h:c.stretch+c.fixed-F},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:B,minFontScaleX:E/a/u,minFontScaleY:C/a/h,isSDF:r}};if(i&&(s.stretchX||s.stretchY)){const e=pp(p,g,m),t=pp(d,y,_);for(let r=0;r<e.length-1;r++){const i=e[r],n=e[r+1];for(let e=0;e<t.length-1;e++)o.push(A(i,t[e],n,t[e+1]))}}else o.push(A({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return o}function hp(e,t,r){let i=0;for(const n of e)i+=Math.max(t,Math.min(r,n[1]))-Math.max(t,Math.min(r,n[0]));return i}function pp(e,t,r){const i=[{fixed:-1,stretch:0}];for(const[t,r]of e){const e=i[i.length-1];i.push({fixed:t-e.stretch,stretch:e.stretch}),i.push({fixed:t-e.stretch,stretch:e.stretch+(r-t)})}return i.push({fixed:t+1,stretch:r}),i}function dp(e,t,r,i){return e/t*r+i}function fp(e,t,r,i){return e-t*r/i}function mp(e,t,r,i){const n=t+e.positionedLines[i].lineOffset;return 0===i?r+n/2:r+(n+(t+e.positionedLines[i-1].lineOffset))/2}cp.loadGlyphRange=function(e,t,r,i,n){const o=256*t,s=o+255,a=i.transformRequest(i.normalizeGlyphsURL(r).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),Ae.Glyphs);ze(a,((e,t)=>{if(e)n(e);else if(t){const e={},r=function(e){return new lh(e).readFields(kh,{})}(t);for(const t of r.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:r.ascender,descender:r.descender})}}))},cp.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:i=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=i,this.radius=r;const a=this.size=e+4*t,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:i,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(r),a=Math.min(this.size-this.buffer,Math.ceil(o-n)),l=Math.min(this.size-this.buffer,s+Math.ceil(i)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),p=new Uint8ClampedArray(h),d={data:p,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(op,0,h),_.fill(0,0,h);for(let e=0;e<l;e++)for(let t=0;t<a;t++){const r=y.data[4*(e*a+t)+3]/255;if(0===r)continue;const i=(e+m)*c+t+m;if(1===r)g[i]=0,_[i]=op;else{const e=.5-r;g[i]=e>0?e*e:0,_[i]=e<0?e*e:0}}sp(g,0,0,c,u,c,this.f,this.v,this.z),sp(_,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e<h;e++){const t=Math.sqrt(g[e])-Math.sqrt(_[e]);p[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return d}};class _p{constructor(e=[],t=gp){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,i=t[e];for(;e>0;){const n=e-1>>1,o=t[n];if(r(i,o)>=0)break;t[e]=o,e=n}t[e]=i}_down(e){const{data:t,compare:r}=this,i=this.length>>1,n=t[e];for(;e<i;){let i=1+(e<<1),o=t[i];const s=i+1;if(s<this.length&&r(t[s],o)<0&&(i=s,o=t[s]),r(o,n)>=0)break;t[e]=o,e=i}t[e]=n}}function gp(e,t){return e<t?-1:e>t?1:0}function yp(e,t=1,r=!1){let i=1/0,o=1/0,s=-1/0,a=-1/0;const l=e[0];for(let e=0;e<l.length;e++){const t=l[e];(!e||t.x<i)&&(i=t.x),(!e||t.y<o)&&(o=t.y),(!e||t.x>s)&&(s=t.x),(!e||t.y>a)&&(a=t.y)}const c=Math.min(s-i,a-o);let u=c/2;const h=new _p([],vp);if(0===c)return new n(i,o);for(let t=i;t<s;t+=c)for(let r=o;r<a;r+=c)h.push(new xp(t+u,r+u,u,e));let p=function(e){let t=0,r=0,i=0;const n=e[0];for(let e=0,o=n.length,s=o-1;e<o;s=e++){const o=n[e],a=n[s],l=o.x*a.y-a.x*o.y;r+=(o.x+a.x)*l,i+=(o.y+a.y)*l,t+=3*l}return new xp(r/t,i/t,0,e)}(e),d=h.length;for(;h.length;){const i=h.pop();(i.d>p.d||!p.d)&&(p=i,r&&console.log("found best %d after %d probes",Math.round(1e4*i.d)/1e4,d)),i.max-p.d<=t||(u=i.h/2,h.push(new xp(i.p.x-u,i.p.y-u,u,e)),h.push(new xp(i.p.x+u,i.p.y-u,u,e)),h.push(new xp(i.p.x-u,i.p.y+u,u,e)),h.push(new xp(i.p.x+u,i.p.y+u,u,e)),d+=4)}return r&&(console.log(`num probes: ${d}`),console.log(`best distance: ${p.d}`)),p.p}function vp(e,t){return t.max-e.max}function xp(e,t,r,i){this.p=new n(e,t),this.h=r,this.d=function(e,t){let r=!1,i=1/0;for(let n=0;n<t.length;n++){const o=t[n];for(let t=0,n=o.length,s=n-1;t<n;s=t++){const n=o[t],a=o[s];n.y>e.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(r=!r),i=Math.min(i,el(e,n,a))}}return(r?1:-1)*Math.sqrt(i)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}const bp=Number.POSITIVE_INFINITY,wp=Math.sqrt(2);function Tp(e,t){return t[1]!==bp?function(e,t,r){let i=0,n=0;switch(t=Math.abs(t),r=Math.abs(r),e){case"top-right":case"top-left":case"top":n=r-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-r}switch(e){case"top-right":case"bottom-right":case"right":i=-t;break;case"top-left":case"bottom-left":case"left":i=t}return[i,n]}(e,t[0],t[1]):function(e,t){let r=0,i=0;t<0&&(t=0);const n=t/wp;switch(e){case"top-right":case"top-left":i=n-7;break;case"bottom-right":case"bottom-left":i=7-n;break;case"bottom":i=7-t;break;case"top":i=t-7}switch(e){case"top-right":case"bottom-right":r=-n;break;case"top-left":case"bottom-left":r=n;break;case"left":r=t;break;case"right":r=-t}return[r,i]}(e,t[0])}function Ep(e,t,r,i,n,o,s,a,l,c){e.createArrays(),e.tilePixelRatio=ba/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const u=e.layers[0].layout,h=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:r}=e.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new zo(t),a),h["text-size"].possiblyEvaluate(new zo(r),a)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:r}=e.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new zo(t),a),h["icon-size"].possiblyEvaluate(new zo(r),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new zo(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new zo(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new zo(18),a);const d="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),f=u.get("text-size");for(const o of e.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=f.evaluate(o,{},a),m=p.layoutTextSize.evaluate(o,{},a),_=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),g=o.text;let y,v=[0,0];if(g){const i=g.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*Yu,c=u.get("text-line-height").evaluate(o,{},a)*Yu,p=ho(i)?s:0,f=u.get("text-anchor").evaluate(o,{},a),y=u.get("text-variable-anchor");if(!y){const e=u.get("text-radial-offset").evaluate(o,{},a);v=e?Tp(f,[e*Yu,bp]):u.get("text-offset").evaluate(o,{},a).map((e=>e*Yu))}let x=d?"center":u.get("text-justify").evaluate(o,{},a);const b=u.get("symbol-placement"),w="point"===b,T="point"===b?u.get("text-max-width").evaluate(o,{},a)*Yu:0,E=o=>{e.allowVerticalPlacement&&uo(i)&&(_.vertical=Oh(g,t,r,n,l,T,c,f,o,p,v,Lh.vertical,!0,b,m,h))};if(!d&&y){const e="auto"===x?y.map((e=>Sp(e))):[x];let i=!1;for(let o=0;o<e.length;o++){const s=e[o];if(!_.horizontal[s])if(i)_.horizontal[s]=_.horizontal[0];else{const e=Oh(g,t,r,n,l,T,c,"center",s,p,v,Lh.horizontal,!1,b,m,h);e&&(_.horizontal[s]=e,i=1===e.positionedLines.length)}}E("left")}else{if("auto"===x&&(x=Sp(f)),w||u.get("text-writing-mode").indexOf("horizontal")>=0||!uo(i)){const e=Oh(g,t,r,n,l,T,c,f,x,p,v,Lh.horizontal,!1,b,m,h);e&&(_.horizontal[x]=e)}E("point"===b?"left":x)}}let x=!1;if(o.icon&&o.icon.name){const t=i[o.icon.name];t&&(y=Hh(n[o.icon.name],u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),x=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&z("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const b=Ip(_.horizontal)||_.vertical;e.iconsInText||(e.iconsInText=!!b&&b.iconsInText),(b||y)&&Cp(e,o,_,y,i,p,m,0,v,x,s,a,c)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)}function Sp(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Cp(e,t,r,i,n,o,s,a,c,u,h,p,d){let f=o.textMaxSize.evaluate(t,{},p);void 0===f&&(f=s);const m=e.layers[0].layout,_=m.get("icon-offset").evaluate(t,{},p),g=Ip(r.horizontal)||r.vertical,y="globe"===d.name,v=s/24,x=e.tilePixelRatio*f/24,b=(I=e.overscaling,e.zoom>18&&I>2&&(I>>=1),Math.max(ba/(512*I),1)*m.get("symbol-spacing")),w=m.get("text-padding")*e.tilePixelRatio,T=m.get("icon-padding")*e.tilePixelRatio,E=l(m.get("text-max-angle")),S="map"===m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),C="map"===m.get("icon-rotation-alignment")&&"point"!==m.get("symbol-placement"),A=m.get("symbol-placement"),k=b/2;var I;const M=m.get("icon-text-fit");let P;i&&"none"!==M&&(e.allowVerticalPlacement&&r.vertical&&(P=Xh(i,r.vertical,M,m.get("icon-text-fit-padding"),_,v)),g&&(i=Xh(i,g,M,m.get("icon-text-fit-padding"),_,v)));const D=(s,a,l)=>{if(a.x<0||a.x>=ba||a.y<0||a.y>=ba)return;let f=null;if(y){const{x:e,y:t,z:r}=d.projectTilePoint(a.x,a.y,l);f={anchor:new Yh(e,t,r,0,void 0),up:d.upVector(l,a.x,a.y)}}!function(e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v,x,b,w,T,E){const S=e.addToLineVertexArray(t,i);let C,A,k,I,M,P,D,L=0,B=0,R=0,O=0,F=-1,N=-1;const j={};let U=Gs("");const V=r?r.anchor:t;let q=0,G=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[q,G]=l.layout.get("text-offset").evaluate(x,{},E).map((e=>e*Yu)):(q=l.layout.get("text-radial-offset").evaluate(x,{},E)*Yu,G=bp),e.allowVerticalPlacement&&n.vertical){const e=n.vertical;if(f)P=zp(e),a&&(D=zp(a));else{const r=l.layout.get("text-rotate").evaluate(x,{},E)+90;k=Mp(c,V,t,u,h,p,e,d,r,m),a&&(I=Mp(c,V,t,u,h,p,a,g,r))}}if(o){const i=l.layout.get("icon-rotate").evaluate(x,{},E),n="none"!==l.layout.get("icon-text-fit"),s=up(o,i,w,n),d=a?up(a,i,w,n):void 0;A=Mp(c,V,t,u,h,p,o,g,i),L=4*s.length;const f=e.iconSizeData;let m=null;"source"===f.kind?(m=[Ku*l.layout.get("icon-size").evaluate(x,{},E)],m[0]>Ap&&z(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Ku*b.compositeIconSizes[0].evaluate(x,{},E),Ku*b.compositeIconSizes[1].evaluate(x,{},E)],(m[0]>Ap||m[1]>Ap)&&z(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,s,m,v,y,x,!1,r,t,S.lineStartIndex,S.lineLength,-1,T,E),F=e.icon.placedSymbolArray.length-1,d&&(B=4*d.length,e.addSymbols(e.icon,d,m,v,y,x,Lh.vertical,r,t,S.lineStartIndex,S.lineLength,-1,T,E),N=e.icon.placedSymbolArray.length-1)}for(const i in n.horizontal){const o=n.horizontal[i];C||(U=Gs(o.text),f?M=zp(o):C=Mp(c,V,t,u,h,p,o,d,l.layout.get("text-rotate").evaluate(x,{},E),m));const a=1===o.positionedLines.length;if(R+=kp(e,r,t,o,s,l,f,x,m,S,n.vertical?Lh.horizontal:Lh.horizontalOnly,a?Object.keys(n.horizontal):[i],j,F,b,T,E),a)break}n.vertical&&(O+=kp(e,r,t,n.vertical,s,l,f,x,m,S,Lh.vertical,["vertical"],j,N,b,T,E));let $=-1;const Z=(e,t)=>e?Math.max(e,t):t;$=Z(M,$),$=Z(P,$),$=Z(D,$);const W=$>-1?1:0;e.glyphOffsetArray.length>=Fd.MAX_GLYPHS&&z("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey),e.symbolInstances.emplaceBack(V.x,V.y,V.z,t.x,t.y,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical>=0?j.vertical:-1,F,N,U,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,void 0!==k?k:e.collisionBoxArray.length,void 0!==k?k+1:e.collisionBoxArray.length,void 0!==A?A:e.collisionBoxArray.length,void 0!==A?A+1:e.collisionBoxArray.length,I||e.collisionBoxArray.length,I?I+1:e.collisionBoxArray.length,u,R,O,L,B,W,0,q,G,$)}(e,a,f,s,r,i,n,P,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,w,S,c,0,T,C,_,t,o,u,h,p)};if("line"===A)for(const n of np(t.geometry,0,0,ba,ba)){const t=rp(n,b,E,r.vertical||g,i,24,x,e.overscaling,ba);for(const r of t){const t=g;t&&Pp(e,t.text,k,r)||D(n,r,p)}}else if("line-center"===A){for(const e of t.geometry)if(e.length>1){const t=tp(e,E,r.vertical||g,i,24,x);t&&D(e,t,p)}}else if("Polygon"===t.type)for(const e of Zc(t.geometry,0)){const t=yp(e,16);D(e[0],new Yh(t.x,t.y,0,0,void 0),p)}else if("LineString"===t.type)for(const e of t.geometry)D(e,new Yh(e[0].x,e[0].y,0,0,void 0),p);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)D([t],new Yh(t.x,t.y,0,0,void 0),p)}const Ap=32640;function kp(e,t,r,i,o,s,a,l,c,u,h,p,d,f,m,_,g){const y=function(e,t,r,i,o,s,a,l){const c=[];if(0===t.positionedLines.length)return c;const u=i.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,h=function(e){const t=e[0],r=e[1],i=t*r;return i>0?[t,-r]:i<0?[-t,r]:0===t?[r,t]:[r,-t]}(r);let p=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)p-=e.lineOffset;const d=t.positionedLines.length,f=p/d;let m=t.top-r[1];for(let e=0;e<d;++e){const i=t.positionedLines[e];m=mp(t,f,m,e);for(const e of i.positionedGlyphs){if(!e.rect)continue;const i=e.rect||{};let s=4,p=!0,d=1,f=0;if(e.imageName){const t=a[e.imageName];if(!t)continue;if(t.sdf){z("SDF images are not supported in formatted text and will be ignored.");continue}p=!1,d=t.pixelRatio,s=1/d}const _=(o||l)&&e.vertical,g=e.metrics.advance*e.scale/2,y=e.metrics,v=e.rect;if(null===v)continue;l&&t.verticalizable&&(f=e.imageName?g-e.metrics.width*e.scale/2:0);const x=o?[e.x+g,e.y]:[0,0];let b=[0,0],w=[0,0],T=!1;o||(_?(w=[e.x+g+h[0],e.y+h[1]-f],T=!0):b=[e.x+g+r[0],e.y+r[1]-f]);const E=v.w*e.scale/(d*(e.localGlyph?2:1)),S=v.h*e.scale/(d*(e.localGlyph?2:1));let C,A,k,I;if(_){const t=e.y-m,r=new n(-g,g-t),i=-Math.PI/2,o=new n(...w);C=new n(-g+b[0],b[1]),C._rotateAround(i,r)._add(o),C.x+=-t+g,C.y-=(y.left-s)*e.scale;const a=e.imageName?y.advance*e.scale:Yu*e.scale,l=String.fromCharCode(e.glyph);nh(l)?C.x+=(1-s)*e.scale:oh(l)?C.x+=a-y.height*e.scale+(-s-1)*e.scale:C.x+=e.imageName||y.width+2*s===v.w&&y.height+2*s===v.h?(a-S)/2:(a-(y.height+2*s)*e.scale)/2,A=new n(C.x,C.y-E),k=new n(C.x+S,C.y),I=new n(C.x+S,C.y-E)}else{const t=(y.left-s)*e.scale-g+b[0],r=(-y.top-s)*e.scale+b[1],i=t+E,o=r+S;C=new n(t,r),A=new n(i,r),k=new n(t,o),I=new n(i,o)}if(u){let e;e=o?new n(0,0):T?new n(h[0],h[1]):new n(r[0],r[1]),C._rotateAround(u,e),A._rotateAround(u,e),k._rotateAround(u,e),I._rotateAround(u,e)}const M=new n(0,0),P=new n(0,0);c.push({tl:C,tr:A,bl:k,br:I,tex:i,writingMode:t.writingMode,glyphOffset:x,sectionIndex:e.sectionIndex,isSDF:p,pixelOffsetTL:M,pixelOffsetBR:P,minFontScaleX:0,minFontScaleY:0})}}return c}(0,i,c,s,a,l,o,e.allowVerticalPlacement),v=e.textSizeData;let x=null;"source"===v.kind?(x=[Ku*s.layout.get("text-size").evaluate(l,{},g)],x[0]>Ap&&z(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===v.kind&&(x=[Ku*m.compositeTextSizes[0].evaluate(l,{},g),Ku*m.compositeTextSizes[1].evaluate(l,{},g)],(x[0]>Ap||x[1]>Ap)&&z(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,y,x,c,a,l,h,t,r,u.lineStartIndex,u.lineLength,f,_,g);for(const t of p)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function Ip(e){for(const t in e)return e[t];return null}function Mp(e,t,r,i,o,s,a,c,u,h){let p=a.top,d=a.bottom,f=a.left,m=a.right;const _=a.collisionPadding;if(_&&(f-=_[0],p-=_[1],m+=_[2],d+=_[3]),u){const e=new n(f,p),t=new n(m,p),r=new n(f,d),i=new n(m,d),o=l(u);let s=new n(0,0);h&&(s=new n(h[0],h[1])),e._rotateAround(o,s),t._rotateAround(o,s),r._rotateAround(o,s),i._rotateAround(o,s),f=Math.min(e.x,t.x,r.x,i.x),m=Math.max(e.x,t.x,r.x,i.x),p=Math.min(e.y,t.y,r.y,i.y),d=Math.max(e.y,t.y,r.y,i.y)}return e.emplaceBack(t.x,t.y,t.z,r.x,r.y,f,p,m,d,c,i,o,s),e.length-1}function zp(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Pp(e,t,r,i){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(i.dist(e[t])<r)return!0}else n[t]=[];return n[t].push(i),!1}const Dp=Yo([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),{members:Lp}=Dp,Bp=Yo([{name:"a_pos_3",components:3,type:"Int16"}]);var Rp=Yo([{name:"a_pos",type:"Int16",components:2}]);const Op=ba/Math.PI/2,Fp=2*Ia(1,0)*Op*Math.PI,Np=[64,32,16],jp=-Op,Up=Op,Vp=[new Kl([jp,jp,jp],[Up,Up,Up]),new Kl([jp,jp,jp],[0,0,Up]),new Kl([0,jp,jp],[Up,0,Up]),new Kl([jp,0,jp],[0,Up,Up]),new Kl([0,0,jp],[Up,Up,Up])];function qp(e,t,r,i=!0){const n=zl([],e._camera.position,e.worldSize),o=[t,r,1,1];ql(o,o,e.pixelMatrixInverse),Vl(o,o,1/o[3]);const s=Dl([],Nl([],o,n)),a=e.globeMatrix,l=[a[12],a[13],a[14]],u=Nl([],l,n),h=El(u),p=Dl([],u),d=e.worldSize/(2*Math.PI),m=Ll(p,s),_=Math.asin(d/h);if(_<Math.acos(m)){if(!i)return null;const e=[],t=[];zl(e,s,h/m),Dl(t,Nl(t,e,u)),Dl(s,Cl(s,u,zl(s,t,Math.tan(_)*h)))}const g=[];new Hl(n,s).closestPointOnSphere(l,d,g);const y=Dl([],N(a,0)),v=Dl([],N(a,1)),x=Dl([],N(a,2)),b=Ll(y,g),w=Ll(v,g),T=Ll(x,g),E=c(Math.asin(-w/d));let S=c(Math.atan2(b,T));S=e.center.lng+function(e,t){const r=(t-e+180)%360-180;return r<-180?r+360:r}(e.center.lng,S);const C=Aa(S),A=f(ka(E),0,1);return new La(C,A)}class Gp{constructor(e,t,r){this.a=Nl([],e,r),this.b=Nl([],t,r),this.center=r;const i=Dl([],this.a),n=Dl([],this.b);this.angle=Math.acos(Ll(i,n))}}function $p(e,t){if(0===e.angle)return null;let r;return r=0===e.a[t]?1/e.angle*.5*Math.PI:1/e.angle*Math.atan(e.b[t]/e.a[t]/Math.sin(e.angle)-1/Math.tan(e.angle)),r<0||r>1?null:function(e,t,r,i){const n=Math.sin(r);return e*(Math.sin((1-i)*r)/n)+t*(Math.sin(i*r)/n)}(e.a[t],e.b[t],e.angle,f(r,0,1))+e.center[t]}function Zp(e){if(e.z<=1)return Vp[e.z+2*e.y+e.x];const[t,r]=Hp(e),i=[Yp(t[0],t[1]),Yp(t[0],r[1]),Yp(r[0],t[1]),Yp(r[0],r[1])],n=[Up,Up,Up],o=[jp,jp,jp];for(const e of i)n[0]=Math.min(n[0],e[0]),n[1]=Math.min(n[1],e[1]),n[2]=Math.min(n[2],e[2]),o[0]=Math.max(o[0],e[0]),o[1]=Math.max(o[1],e[1]),o[2]=Math.max(o[2],e[2]);return new Kl(n,o)}function Wp(e,t,r){const i=t/e.worldSize,n=Number.MAX_VALUE,o=[-n,-n,-n],s=[n,n,n],a=fl(new Float64Array(16));if(gl(a,a,[i,i,i]),ml(a,a,e.globeMatrix),r.z<=1){const e=Zp(r).getCorners();for(let t=0;t<e.length;t++)Rl(e[t],e[t],a),Il(s,s,e[t]),Ml(o,o,e[t]);return new Kl(s,o)}const[c,u]=Hp(r),h=new wa;h.setSouthWest([c[1],u[0]]),h.setNorthEast([u[1],c[0]]);const p=[Yp(h.getSouth(),h.getWest()),Yp(h.getSouth(),h.getEast()),Yp(h.getNorth(),h.getEast()),Yp(h.getNorth(),h.getWest())];for(let e=0;e<p.length;e++)Rl(p[e],p[e],a),Il(s,s,p[e]),Ml(o,o,p[e]);if(h.contains(e.center)){o[2]=0;const t=e.point,r=[t.x*i,t.y*i,0];return Il(s,s,r),Ml(o,o,r),new Kl(s,o)}const d=[a[12],a[13],a[14]],m=e.center.lng,_=f(e.center.lat,-85.051129,Da),g=[Aa(m),ka(_)],y=h.getCenter().lng,v=f(h.getCenter().lat,-85.051129,Da),x=[Aa(y),ka(v)];let b=new Array(3),w=0,T=g[0]-x[0];const E=g[1]-x[1];if(T>.5?T-=1:T<-.5&&(T+=1),Math.abs(T)>Math.abs(E))w=T>=0?1:3,b=d;else{w=E>=0?0:2;const e=[a[4],a[5],a[6]];let t;t=E>=0?-Math.sin(l(h.getSouth()))*Op:-Math.sin(l(h.getNorth()))*Op,b=Pl(b,d,e,t)}const S=p[w],C=p[(w+1)%4],A=new Gp(S,C,b),k=[$p(A,0)||S[0],$p(A,1)||S[1],$p(A,2)||S[2]];return s[2]=Math.min(S[2],C[2]),Il(s,s,k),Ml(o,o,k),new Kl(s,o)}function Hp(e){const t=1<<e.z,r=e.x/t,i=(e.x+1)/t,n=(e.y+1)/t;return[[za(e.y/t),Ma(r)],[za(n),Ma(i)]]}function Xp(e,t,r,i=Op){return r=l(r),[e*Math.sin(r)*i,-t*i,e*Math.cos(r)*i]}function Yp(e,t,r){return Xp(Math.cos(l(e)),Math.sin(l(e)),t,r)}function Kp(e,t,r){const i=Math.pow(2,r.z),n=(e/ba+r.x)/i;return Yp(za((t/ba+r.y)/i),Ma(n))}function Jp(e){return 16383/Math.max(...Nl([],e.max,e.min))}function Qp(e){const t=fl(new Float64Array(16)),r=Jp(e);var i,n;return gl(t,t,[r,r,r]),_l(t,t,((i=[])[0]=-(n=e.min)[0],i[1]=-n[1],i[2]=-n[2],i)),t}function ed(e){const t=fl(new Float64Array(16)),r=1/Jp(e);return _l(t,t,e.min),gl(t,t,[r,r,r]),t}function td(e,t,r,i,n){const o=function(e){const t=ba/(2*Math.PI);return e/(2*Math.PI)/t}(r),s=[e,t,-r/(2*Math.PI)],a=fl(new Float64Array(16));return _l(a,a,s),gl(a,a,[o,o,o]),yl(a,a,l(-n)),vl(a,a,l(-i)),a}function rd(e){return m(5,6,e)}function id(e,t){const r=Yp(t.lat,t.lng);return o=(i=Al([],function(e){const t=Yp(e._center.lat,e._center.lng);let r=Bl([],Sl(0,1,0),t);const i=xl([],-e.angle,t);r=Rl(r,r,i),xl(i,-e._pitch,r);const n=Dl([],t);return zl(n,n,e.cameraToCenterDistance/e.pixelsPerMeter*Fp),Rl(n,n,i),Cl([],t,n)}(e),r))[0],s=i[1],a=i[2],l=(n=r)[0],c=n[1],u=n[2],p=(h=Math.sqrt(o*o+s*s+a*a)*Math.sqrt(l*l+c*c+u*u))&&Ll(i,n)/h,Math.acos(Math.min(Math.max(p,-1),1));var i,n,o,s,a,l,c,u,h,p}const nd=l(85),od=Math.cos(nd),sd=Math.sin(nd);function ad(e,t){const r=e.fovAboveCenter,i=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,n=(e._camera.position[2]*e.worldSize-i)/Math.cos(e._pitch),o=Math.sin(r)*n/Math.sin(Math.max(Math.PI/2-e._pitch-r,.01)),s=Math.sin(e._pitch)*o+n;return Math.min(1.01*s,n*(1/e._horizonShift))}function ld(e,t){if(!t.isReprojectedInTileSpace)return{scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:t};const r=Math.pow(2,-e.z),i=e.x*r,n=(e.x+1)*r,o=e.y*r,s=(e.y+1)*r,a=Ma(i),l=Ma(n),c=za(o),u=za(s),h=t.project(a,c),p=t.project(l,c),d=t.project(l,u),f=t.project(a,u);let m=Math.min(h.x,p.x,d.x,f.x),_=Math.min(h.y,p.y,d.y,f.y),g=Math.max(h.x,p.x,d.x,f.x),y=Math.max(h.y,p.y,d.y,f.y);const v=r/16;function x(e,r,i,n,o,s){const a=(i+o)/2,l=(n+s)/2,c=t.project(Ma(a),za(l)),u=Math.max(0,m-c.x,_-c.y,c.x-g,c.y-y);m=Math.min(m,c.x),g=Math.max(g,c.x),_=Math.min(_,c.y),y=Math.max(y,c.y),u>v&&(x(e,c,i,n,a,l),x(c,r,a,l,o,s))}x(h,p,i,o,n,o),x(p,d,n,o,n,s),x(d,f,n,s,i,s),x(f,h,i,s,i,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}const cd=fl(new Float32Array(16));class ud{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new Ea(0,0)}projectTilePoint(e,t,r){return{x:e,y:t,z:0}}locationPoint(e,t,r=!0){return e._coordinatePoint(e.locationCoordinate(t),r)}pixelsPerMeter(e,t){return Ia(1,e)*t}pixelSpaceConversion(e,t,r){return 1}farthestPixelDistance(e){return ad(e,e.pixelsPerMeter)}pointCoordinate(e,t,r,i){const o=e.horizonLineFromTop(!1),s=new n(t,Math.max(o,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(s,i))}pointCoordinate3D(e,t,r){const i=new n(t,r);if(e.elevation)return e.elevation.pointCoordinate(i);{const t=this.pointCoordinate(e,i.x,i.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const r=e.horizonLineFromTop();return t.y<r}createInversionMatrix(e,t){return cd}createTileMatrix(e,t,r){let i,n,o;const s=r.canonical,a=fl(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=ld(s,this);i=1,n=l.x+r.wrap*l.scale,o=l.y,gl(a,a,[i/l.scale,i/l.scale,e.pixelsPerMeter/t])}else i=t/e.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*r.wrap)*i,o=s.y*i;return _l(a,a,[n,o,0]),gl(a,a,[i/ba,i/ba,1]),a}upVector(e,t,r){return[0,0,1]}upVectorScale(e,t,r){return{metersToTile:1}}}class hd extends ud{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,r]=this.parallels=e.parallels||[29.5,45.5],i=Math.sin(l(t));this.n=(i+Math.sin(l(r)))/2,this.c=1+i*(2*this.n-i),this.r0=Math.sqrt(this.c)/this.n}project(e,t){const{n:r,c:i,r0:n}=this,o=l(e-this.center[0]),s=l(t),a=Math.sqrt(i-2*r*Math.sin(s))/r;return{x:a*Math.sin(o*r),y:a*Math.cos(o*r)-n,z:0}}unproject(e,t){const{n:r,c:i,r0:n}=this,o=n+t;let s=Math.atan2(e,Math.abs(o))*Math.sign(o);o*r<0&&(s-=Math.PI*Math.sign(e)*Math.sign(o));const a=l(this.center[0])*r;s=_(s,-Math.PI-a,Math.PI-a);const u=c(s/r)+this.center[0],h=Math.asin(f((i-(e*e+o*o)*r*r)/(2*r),-1,1)),p=f(c(h),-85.051129,Da);return new Ea(u,p)}}const pd=1.340264,dd=-.081106,fd=893e-6,md=.003796,_d=Math.sqrt(3)/2;class gd extends ud{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const r=Math.asin(_d*Math.sin(t)),i=r*r,n=i*i*i;return{x:.5*(e*Math.cos(r)/(_d*(pd+3*dd*i+n*(7*fd+9*md*i)))/Math.PI+.5),y:1-.5*(r*(pd+dd*i+n*(fd+md*i))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let r=t=(2*(1-t)-1)*Math.PI,i=r*r,n=i*i*i;for(let e,o,s,a=0;a<12&&(o=r*(pd+dd*i+n*(fd+md*i))-t,s=pd+3*dd*i+n*(7*fd+9*md*i),e=o/s,r=f(r-e,-Math.PI/3,Math.PI/3),i=r*r,n=i*i*i,!(Math.abs(e)<1e-12));++a);const o=_d*e*(pd+3*dd*i+n*(7*fd+9*md*i))/Math.cos(r),s=Math.asin(Math.sin(r)/_d),a=f(180*o/Math.PI,-180,180),l=f(180*s/Math.PI,-85.051129,Da);return new Ea(a,l)}}class yd extends ud{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){return{x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const r=360*(e-.5),i=f(360*(.5-t),-85.051129,Da);return new Ea(r,i)}}const vd=Math.PI/2;function xd(e){return Math.tan((vd+e)/2)}class bd extends ud{constructor(e){super(e),this.center=e.center||[0,30];const[t,r]=this.parallels=e.parallels||[30,30],i=l(t),n=l(r),o=Math.cos(i);this.n=i===n?Math.sin(i):Math.log(o/Math.cos(n))/Math.log(xd(n)/xd(i)),this.f=o*Math.pow(xd(i),this.n)/this.n}project(e,t){t=l(t),e=l(e-this.center[0]);const r=1e-6,{n:i,f:n}=this;n>0?t<-vd+r&&(t=-vd+r):t>vd-r&&(t=vd-r);const o=n/Math.pow(xd(t),i),s=o*Math.sin(i*e),a=n-o*Math.cos(i*e);return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+.5),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,t=(2*(1-t)-.5)*Math.PI;const{n:r,f:i}=this,n=i-t,o=Math.sign(n),s=Math.sign(r)*Math.sqrt(e*e+n*n);let a=Math.atan2(e,Math.abs(n))*o;n*r<0&&(a-=Math.PI*Math.sign(e)*o);const l=f(c(a/r)+this.center[0],-180,180),u=f(c(2*Math.atan(Math.pow(i/s,1/r))-vd),-85.051129,Da);return new Ea(l,u)}}class wd extends ud{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:Aa(e),y:ka(t),z:0}}unproject(e,t){const r=Ma(e),i=za(t);return new Ea(r,i)}}const Td=l(Da);class Ed extends ud{project(e,t){const r=(t=l(t))*t,i=r*r;return{x:.5*((e=l(e))*(.8707-.131979*r+i*(i*(.003971*r-.001529*i)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+r*(.015085+i*(.028874*r-.044475-.005916*i)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let r=t=(2*(1-t)-1)*Math.PI,i=25,n=0,o=r*r;do{o=r*r;const e=o*o;n=(r*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),r=f(r-n,-Td,Td)}while(Math.abs(n)>1e-6&&--i>0);o=r*r;const s=f(c(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=c(r);return new Ea(s,a)}}const Sd=l(Da);class Cd extends ud{project(e,t){t=l(t),e=l(e);const r=Math.cos(t),i=2/Math.PI,n=Math.acos(r*Math.cos(e/2)),o=Math.sin(n)/n,s=.5*(e*i+2*r*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let r=e=(2*e-.5)*Math.PI,i=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let s=0,a=0;do{const n=Math.cos(i),o=Math.sin(i),l=2*o*n,c=o*o,u=n*n,h=Math.cos(r/2),p=Math.sin(r/2),d=2*h*p,m=p*p,_=1-u*h*h,g=_?1/_:0,y=_?Math.acos(n*h)*Math.sqrt(1/_):0,v=.5*(2*y*n*p+2*r/Math.PI)-e,x=.5*(y*o+i)-t,b=.5*g*(u*m+y*n*h*c)+1/Math.PI,w=g*(d*l/4-y*o*p),T=.125*g*(l*p-y*o*u*d),E=.5*g*(c*h+y*m*n)+.5,S=w*T-E*b;s=(x*w-v*E)/S,a=(v*T-x*b)/S,r=f(r-s,-Math.PI,Math.PI),i=f(i-a,-Sd,Sd)}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new Ea(c(r),c(i))}}class Ad extends ud{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(l(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:r,cosPhi:i}=this;return{x:l(e)*i*r+.5,y:-Math.sin(l(t))/i*r+.5,z:0}}unproject(e,t){const{scale:r,cosPhi:i}=this,n=-(t-.5)/r,o=f(c((e-.5)/r)/i,-180,180),s=Math.asin(f(n*i,-1,1)),a=f(c(s),-85.051129,Da);return new Ea(o,a)}}class kd extends wd{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(e,t,r){const i=Math.pow(2,r.z),n=(e/ba+r.x)/i,o=Yp(za((t/ba+r.y)/i),Ma(n));return Rl(o,o,Qp(Zp(r))),{x:o[0],y:o[1],z:o[2]}}locationPoint(e,t){const r=Yp(t.lat,t.lng),i=Dl([],r),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;Pl(r,r,i,Ia(1,0)*ba*o);const s=fl(new Float64Array(16));return ml(s,e.pixelMatrix,e.globeMatrix),Rl(r,r,s),new n(r[0],r[1])}pixelsPerMeter(e,t){return Ia(1,0)*t}pixelSpaceConversion(e,t,r){const i=gr(Ia(1,45)*t,Ia(1,e)*t,r);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,r){const i=ed(Zp(r.canonical));return ml(new Float64Array(16),e.globeMatrix,i)}createInversionMatrix(e,t){const{center:r}=e,i=fl(new Float64Array(16));return ml(i,i,Qp(Zp(t))),vl(i,i,l(r.lng)),yl(i,i,l(r.lat)),gl(i,i,[e._projectionScaler,e._projectionScaler,1]),Float32Array.from(i)}pointCoordinate(e,t,r,i){return qp(e,t,r,!0)||new La(0,0)}pointCoordinate3D(e,t,r){const i=this.pointCoordinate(e,t,r,0);return[i.x,i.y,i.z]}isPointAboveHorizon(e,t){return!qp(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const r=e.cameraToCenterDistance,i=e._centerAltitude*t,n=e._camera,o=e._camera.forward(),s=Cl([],zl([],o,-r),[0,0,i]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=zl([],n.up(),u),p=zl([],n.right(),u*c),d=Dl([],Cl([],Cl([],o,h),p)),f=[];let m;if(new Hl(s,d).closestPointOnSphere(l,a,f)){const t=Cl([],f,l),r=Nl([],t,s);m=Math.cos(e.fovAboveCenter)*El(r)}else{const e=Nl([],s,l),t=Nl([],l,s);Dl(t,t);const r=El(e)-a;m=Math.sqrt(r*(r+2*a));const i=Math.acos(m/(a+r))-Math.acos(Ll(o,t));m*=Math.cos(i)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=rd(e.zoom);if(r>0){const i=ad(e,Ia(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return gr(t,i+n*(1-Math.cos(o)),Math.pow(r,10))}return t}upVector(e,t,r){const i=1<<e.z,n=(t/ba+e.x)/i;return Yp(za((r/ba+e.y)/i),Ma(n),1)}upVectorScale(e){return{metersToTile:Fp*Jp(Zp(e))}}}function Id(e){const t=e.parallels,r=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new wd(e);case"equirectangular":return new yd(e);case"naturalEarth":return new Ed(e);case"equalEarth":return new gd(e);case"winkelTripel":return new Cd(e);case"albers":return r?new Ad(e):new hd(e);case"lambertConformalConic":return r?new Ad(e):new bd(e);case"globe":return new kd(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Md=hu.VectorTileFeature.types,zd=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Pd(e,t,r,i,n,o,s,a,l,c,u,h,p){const d=a?Math.min(Ap,Math.round(a[0])):0,f=a?Math.min(Ap,Math.round(a[1])):0;e.emplaceBack(t,r,Math.round(32*i),Math.round(32*n),o,s,(d<<1)+(l?1:0),f,16*c,16*u,256*h,256*p)}function Dd(e,t,r,i,n,o,s){e.emplaceBack(t,r,i,n,o,s)}function Ld(e,t,r,i,n){e.emplaceBack(t,r,i,n),e.emplaceBack(t,r,i,n),e.emplaceBack(t,r,i,n),e.emplaceBack(t,r,i,n)}function Bd(e){for(const t of e.sections)if(yo(t.text))return!0;return!1}class Rd{constructor(e){this.layoutVertexArray=new ss,this.indexArray=new fs,this.programConfigurations=e,this.segments=new xa,this.dynamicLayoutVertexArray=new rs,this.opacityVertexArray=new ls,this.placedSymbolArray=new Is,this.globeExtVertexArray=new as}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,r,i){this.isEmpty()||(r&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,qu.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,$u.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,zd,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Gu.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||i)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}zn(Rd,"SymbolBuffers");class Od{constructor(e,t,r){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new r,this.segments=new xa,this.collisionVertexArray=new ps,this.collisionVertexArrayExt=new ds}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Zu.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Wu.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}zn(Od,"CollisionBuffers");class Fd{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=fl([]),this.placementViewportMatrix=fl([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ju(this.zoom,t["text-size"]),this.iconSizeData=Ju(this.zoom,t["icon-size"]);const r=this.layers[0].layout,i=r.get("symbol-sort-key"),n=r.get("symbol-z-order");this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==i.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map((e=>Lh[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new Rd(new ua(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new Rd(new ua(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new Ps,this.lineVertexArray=new Ds,this.symbolInstances=new zs}calculateGlyphDependencies(e,t,r,i,n){for(let r=0;r<e.length;r++)if(t[e.charCodeAt(r)]=!0,i&&n){const i=ih[e.charAt(r)];i&&(t[i.charCodeAt(0)]=!0)}}populate(e,t,r,i){const n=this.layers[0],o=n.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),u=("constant"!==l.value.kind||l.value.value instanceof xt&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,p=o.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const d=t.iconDependencies,f=t.glyphDependencies,m=t.availableImages,_=new zo(this.zoom);for(const{feature:t,id:l,index:c,sourceLayerIndex:g}of e){const e=n._featureFilter.needGeometry,y=qa(t,e);if(!n._featureFilter.filter(_,y,r))continue;if(e||(y.geometry=Va(t,r,i)),s&&1!==t.type&&r.z<=5){const e=y.geometry,t=1<<r.z,i=r.x,n=r.y,o=.98078528056;for(let r=0;r<e.length;r++)e[r]=Fa(e[r],(e=>e),((e,r)=>Ll(Yp(za((e.y/ba+n)/t),Ma((e.x/ba+i)/t),1),Yp(za((r.y/ba+n)/t),Ma((r.x/ba+i)/t),1))<o))}let v,x;if(u){const e=n.getValueAndResolveTokens("text-field",y,r,m),t=xt.factory(e);Bd(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ko()||this.hasRTLText&&Mo.isParsed())&&(v=rh(t,n,y))}if(h){const e=n.getValueAndResolveTokens("icon-image",y,r,m);x=e instanceof bt?e:bt.fromString(e)}if(!v&&!x)continue;const b=this.sortFeaturesByKey?p.evaluate(y,{},r):void 0;if(this.features.push({id:l,text:v,icon:x,index:c,sourceLayerIndex:g,geometry:y.geometry,properties:t.properties,type:Md[t.type],sortKey:b}),x&&(d[x.name]=!0),v){const e=a.evaluate(y,{},r).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Lh.vertical)>=0;for(const r of v.sections)if(r.image)d[r.image.name]=!0;else{const i=uo(v.toString()),n=r.fontStack||e,o=f[n]=f[n]||{};this.calculateGlyphDependencies(r.text,o,t,this.allowVerticalPlacement,i)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},r={},i=[];let n=0;function o(t){i.push(e[t]),n++}function s(e,t,n){const o=r[e];return delete r[e],r[t]=o,i[o].geometry[0].pop(),i[o].geometry[0]=i[o].geometry[0].concat(n[0]),o}function a(e,r,n){const o=t[r];return delete t[r],t[e]=o,i[o].geometry[0].shift(),i[o].geometry[0]=n[0].concat(i[o].geometry[0]),o}function l(e,t,r){const i=r?t[0][t[0].length-1]:t[0][0];return`${e}:${i.x}:${i.y}`}for(let c=0;c<e.length;c++){const u=e[c],h=u.geometry,p=u.text?u.text.toString():null;if(!p){o(c);continue}const d=l(p,h),f=l(p,h,!0);if(d in r&&f in t&&r[d]!==t[f]){const e=a(d,f,h),n=s(d,f,i[e].geometry);delete t[d],delete r[f],r[l(p,i[n].geometry,!0)]=n,i[e].geometry=null}else d in r?s(d,f,h):f in t?a(d,f,h):(o(c),t[d]=n-1,r[f]=n-1)}return i.filter((e=>e.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,r,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,r,i),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,r,i))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Id(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const r=this.lineVertexArray.length,i=e.segment;if(void 0!==i){let r=e.dist(t[i+1]),n=e.dist(t[i]);const o={};for(let e=i+1;e<t.length;e++)o[e]={x:t[e].x,y:t[e].y,tileUnitDistanceFromAnchor:r},e<t.length-1&&(r+=t[e+1].dist(t[e]));for(let e=i||0;e>=0;e--)o[e]={x:t[e].x,y:t[e].y,tileUnitDistanceFromAnchor:n},e>0&&(n+=t[e-1].dist(t[e]));for(let e=0;e<t.length;e++){const t=o[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,t,r,i,n,o,s,a,l,c,u,h,p,d){const f=e.indexArray,m=e.layoutVertexArray,_=e.globeExtVertexArray,g=e.segments.prepareSegment(4*t.length,m,f,this.canOverlap?o.sortKey:void 0),y=this.glyphOffsetArray.length,v=g.vertexLength,x=this.allowVerticalPlacement&&s===Lh.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let i=0;i<t.length;i++){const{tl:n,tr:s,bl:c,br:u,tex:h,pixelOffsetTL:y,pixelOffsetBR:v,minFontScaleX:w,minFontScaleY:T,glyphOffset:E,isSDF:S,sectionIndex:C}=t[i],A=g.vertexLength,k=E[1];if(Pd(m,l.x,l.y,n.x,k+n.y,h.x,h.y,r,S,y.x,y.y,w,T),Pd(m,l.x,l.y,s.x,k+s.y,h.x+h.w,h.y,r,S,v.x,y.y,w,T),Pd(m,l.x,l.y,c.x,k+c.y,h.x,h.y+h.h,r,S,y.x,v.y,w,T),Pd(m,l.x,l.y,u.x,k+u.y,h.x+h.w,h.y+h.h,r,S,v.x,v.y,w,T),a){const t=a.anchor,r=a.up;Dd(_,t.x,t.y,t.z,r[0],r[1],r[2]),Dd(_,t.x,t.y,t.z,r[0],r[1],r[2]),Dd(_,t.x,t.y,t.z,r[0],r[1],r[2]),Dd(_,t.x,t.y,t.z,r[0],r[1],r[2]),Ld(e.dynamicLayoutVertexArray,t.x,t.y,t.z,x)}else Ld(e.dynamicLayoutVertexArray,l.x,l.y,l.z,x);f.emplaceBack(A,A+1,A+2),f.emplaceBack(A+1,A+2,A+3),g.vertexLength+=4,g.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(E[0]),i!==t.length-1&&C===t[i+1].sectionIndex||e.programConfigurations.populatePaintArrays(m.length,o,o.index,{},p,d,b&&b[C])}const w=a?a.anchor:l;e.placedSymbolArray.emplaceBack(w.x,w.y,w.z,l.x,l.y,y,this.glyphOffsetArray.length-y,v,c,u,l.segment,r?r[0]:0,r?r[1]:0,i[0],i[1],s,0,!1,0,h,0)}_commitLayoutVertex(e,t,r,i,n,o,s){e.emplaceBack(t,r,i,n,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(e,t,r,i,o,s,a){const l=r.segments.prepareSegment(4,r.layoutVertexArray,r.indexArray),c=l.vertexLength,u=a.tileAnchorX,h=a.tileAnchorY;for(let e=0;e<4;e++)r.collisionVertexArray.emplaceBack(0,0,0,0);r.collisionVertexArrayExt.emplaceBack(t,-e.padding,-e.padding),r.collisionVertexArrayExt.emplaceBack(t,e.padding,-e.padding),r.collisionVertexArrayExt.emplaceBack(t,e.padding,e.padding),r.collisionVertexArrayExt.emplaceBack(t,-e.padding,e.padding),this._commitLayoutVertex(r.layoutVertexArray,i,o,s,u,h,new n(e.x1,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,i,o,s,u,h,new n(e.x2,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,i,o,s,u,h,new n(e.x2,e.y2)),this._commitLayoutVertex(r.layoutVertexArray,i,o,s,u,h,new n(e.x1,e.y2)),l.vertexLength+=4;const p=r.indexArray;p.emplaceBack(c,c+1),p.emplaceBack(c+1,c+2),p.emplaceBack(c+2,c+3),p.emplaceBack(c+3,c),l.primitiveLength+=4}_addTextDebugCollisionBoxes(e,t,r,i,n,o){for(let s=i;s<n;s++){const i=r.get(s),n=this.getSymbolInstanceTextSize(e,o,t,s);this._addCollisionDebugVertices(i,n,this.textCollisionBox,i.projectedAnchorX,i.projectedAnchorY,i.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(e,t,r,i,n,o){for(let s=i;s<n;s++){const i=r.get(s),n=this.getSymbolInstanceIconSize(e,t,s);this._addCollisionDebugVertices(i,n,this.iconCollisionBox,i.projectedAnchorX,i.projectedAnchorY,i.projectedAnchorZ,o)}}generateCollisionDebugBuffers(e,t){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Od(us,Hu.members,bs),this.iconCollisionBox=new Od(us,Hu.members,bs);const r=eh(this.iconSizeData,e),i=eh(this.textSizeData,e);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._addTextDebugCollisionBoxes(i,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(i,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(r,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(r,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(e,t,r,i){const n=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:i),o=Qu(this.textSizeData,e,n)/Yu;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,r){const i=this.icon.placedSymbolArray.get(r),n=Qu(this.iconSizeData,e,i);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,r){e.emplaceBack(t,-r,-r),e.emplaceBack(t,r,-r),e.emplaceBack(t,r,r),e.emplaceBack(t,-r,r)}_updateTextDebugCollisionBoxes(e,t,r,i,n,o){for(let s=i;s<n;s++){const i=r.get(s),n=this.getSymbolInstanceTextSize(e,o,t,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,i.padding)}}_updateIconDebugCollisionBoxes(e,t,r,i,n){for(let o=i;o<n;o++){const i=r.get(o),n=this.getSymbolInstanceIconSize(e,t,o);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,i.padding)}}updateCollisionDebugBuffers(e,t){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const r=eh(this.iconSizeData,e),i=eh(this.textSizeData,e);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._updateTextDebugCollisionBoxes(i,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._updateTextDebugCollisionBoxes(i,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._updateIconDebugCollisionBoxes(r,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(r,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,t,r,i,n,o,s,a,l){const c={};for(let i=t;i<r;i++){const t=e.get(i);c.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,padding:t.padding,projectedAnchorX:t.projectedAnchorX,projectedAnchorY:t.projectedAnchorY,projectedAnchorZ:t.projectedAnchorZ,tileAnchorX:t.tileAnchorX,tileAnchorY:t.tileAnchorY},c.textFeatureIndex=t.featureIndex;break}for(let t=i;t<n;t++){const r=e.get(t);c.verticalTextBox={x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,padding:r.padding,projectedAnchorX:r.projectedAnchorX,projectedAnchorY:r.projectedAnchorY,projectedAnchorZ:r.projectedAnchorZ,tileAnchorX:r.tileAnchorX,tileAnchorY:r.tileAnchorY},c.verticalTextFeatureIndex=r.featureIndex;break}for(let t=o;t<s;t++){const r=e.get(t);c.iconBox={x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,padding:r.padding,projectedAnchorX:r.projectedAnchorX,projectedAnchorY:r.projectedAnchorY,projectedAnchorZ:r.projectedAnchorZ,tileAnchorX:r.tileAnchorX,tileAnchorY:r.tileAnchorY},c.iconFeatureIndex=r.featureIndex;break}for(let t=a;t<l;t++){const r=e.get(t);c.verticalIconBox={x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,padding:r.padding,projectedAnchorX:r.projectedAnchorX,projectedAnchorY:r.projectedAnchorY,projectedAnchorZ:r.projectedAnchorZ,tileAnchorX:r.tileAnchorX,tileAnchorY:r.tileAnchorY},c.verticalIconFeatureIndex=r.featureIndex;break}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const r=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const r=e.placedSymbolArray.get(t),i=r.vertexStartIndex+4*r.numGlyphs;for(let t=r.vertexStartIndex;t<i;t+=4)e.indexArray.emplaceBack(t,t+1,t+2),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),r=Math.cos(e),i=[],n=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const s=this.symbolInstances.get(e);i.push(0|Math.round(t*s.tileAnchorX+r*s.tileAnchorY)),n.push(s.featureIndex)}return o.sort(((e,t)=>i[e]-i[t]||n[t]-n[e])),o}addToSortKeyRanges(e,t){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===t?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach(((e,t,r)=>{e>=0&&r.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)})),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}zn(Fd,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Fd.MAX_GLYPHS=65535,Fd.addDynamicAttributes=Ld;const Nd=new $o({"symbol-placement":new jo(Ge.layout_symbol["symbol-placement"]),"symbol-spacing":new jo(Ge.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new jo(Ge.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Uo(Ge.layout_symbol["symbol-sort-key"]),"symbol-z-order":new jo(Ge.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new jo(Ge.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new jo(Ge.layout_symbol["icon-ignore-placement"]),"icon-optional":new jo(Ge.layout_symbol["icon-optional"]),"icon-rotation-alignment":new jo(Ge.layout_symbol["icon-rotation-alignment"]),"icon-size":new Uo(Ge.layout_symbol["icon-size"]),"icon-text-fit":new jo(Ge.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new jo(Ge.layout_symbol["icon-text-fit-padding"]),"icon-image":new Uo(Ge.layout_symbol["icon-image"]),"icon-rotate":new Uo(Ge.layout_symbol["icon-rotate"]),"icon-padding":new jo(Ge.layout_symbol["icon-padding"]),"icon-keep-upright":new jo(Ge.layout_symbol["icon-keep-upright"]),"icon-offset":new Uo(Ge.layout_symbol["icon-offset"]),"icon-anchor":new Uo(Ge.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new jo(Ge.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new jo(Ge.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new jo(Ge.layout_symbol["text-rotation-alignment"]),"text-field":new Uo(Ge.layout_symbol["text-field"]),"text-font":new Uo(Ge.layout_symbol["text-font"]),"text-size":new Uo(Ge.layout_symbol["text-size"]),"text-max-width":new Uo(Ge.layout_symbol["text-max-width"]),"text-line-height":new Uo(Ge.layout_symbol["text-line-height"]),"text-letter-spacing":new Uo(Ge.layout_symbol["text-letter-spacing"]),"text-justify":new Uo(Ge.layout_symbol["text-justify"]),"text-radial-offset":new Uo(Ge.layout_symbol["text-radial-offset"]),"text-variable-anchor":new jo(Ge.layout_symbol["text-variable-anchor"]),"text-anchor":new Uo(Ge.layout_symbol["text-anchor"]),"text-max-angle":new jo(Ge.layout_symbol["text-max-angle"]),"text-writing-mode":new jo(Ge.layout_symbol["text-writing-mode"]),"text-rotate":new Uo(Ge.layout_symbol["text-rotate"]),"text-padding":new jo(Ge.layout_symbol["text-padding"]),"text-keep-upright":new jo(Ge.layout_symbol["text-keep-upright"]),"text-transform":new Uo(Ge.layout_symbol["text-transform"]),"text-offset":new Uo(Ge.layout_symbol["text-offset"]),"text-allow-overlap":new jo(Ge.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new jo(Ge.layout_symbol["text-ignore-placement"]),"text-optional":new jo(Ge.layout_symbol["text-optional"])});var jd={paint:new $o({"icon-opacity":new Uo(Ge.paint_symbol["icon-opacity"]),"icon-color":new Uo(Ge.paint_symbol["icon-color"]),"icon-halo-color":new Uo(Ge.paint_symbol["icon-halo-color"]),"icon-halo-width":new Uo(Ge.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Uo(Ge.paint_symbol["icon-halo-blur"]),"icon-translate":new jo(Ge.paint_symbol["icon-translate"]),"icon-translate-anchor":new jo(Ge.paint_symbol["icon-translate-anchor"]),"text-opacity":new Uo(Ge.paint_symbol["text-opacity"]),"text-color":new Uo(Ge.paint_symbol["text-color"],{runtimeType:rt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Uo(Ge.paint_symbol["text-halo-color"]),"text-halo-width":new Uo(Ge.paint_symbol["text-halo-width"]),"text-halo-blur":new Uo(Ge.paint_symbol["text-halo-blur"]),"text-translate":new jo(Ge.paint_symbol["text-translate"]),"text-translate-anchor":new jo(Ge.paint_symbol["text-translate-anchor"])}),layout:Nd};class Ud{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Je,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}zn(Ud,"FormatSectionOverride",{omit:["defaultValue"]});class Vd extends ga{constructor(e){super(e,jd)}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const r=this.layout.get("text-writing-mode");if(r){const e=[];for(const t of r)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,r,i){const n=this.layout.get(e).evaluate(t,{},r,i),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||Di(o.value)||!n?n:function(e,t){return t.replace(/{([^{}]+)}/g,((t,r)=>r in e?String(e[r]):""))}(t.properties,n)}createBucket(e){return new Fd(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of jd.paint.overridableProperties){if(!Vd.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),r=new Ud(t),i=new Pi(r,t.property.specification);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new Bi("source",i):new Ri("composite",i,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Fo(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,r){return!(!this.layout||t.isDataDriven()||r.isDataDriven())&&Vd.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const r=e.get("text-field"),i=jd.paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(i.overrides&&i.overrides.hasOverride(t))return void(n=!0)};if("constant"===r.value.kind&&r.value.value instanceof xt)o(r.value.value.sections);else if("source"===r.value.kind){const e=t=>{n||(t instanceof At&&Et(t.value)===st?o(t.value.sections):t instanceof Pt?o(t.sections):t.eachChild(e))},t=r.value;t._styleExpression&&e(t._styleExpression.expression)}return n}getProgramConfiguration(e){return new ca(this,e)}}var qd={paint:new $o({"background-color":new jo(Ge.paint_background["background-color"]),"background-pattern":new qo(Ge.paint_background["background-pattern"]),"background-opacity":new jo(Ge.paint_background["background-opacity"])})},Gd={paint:new $o({"raster-opacity":new jo(Ge.paint_raster["raster-opacity"]),"raster-hue-rotate":new jo(Ge.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new jo(Ge.paint_raster["raster-brightness-min"]),"raster-brightness-max":new jo(Ge.paint_raster["raster-brightness-max"]),"raster-saturation":new jo(Ge.paint_raster["raster-saturation"]),"raster-contrast":new jo(Ge.paint_raster["raster-contrast"]),"raster-resampling":new jo(Ge.paint_raster["raster-resampling"]),"raster-fade-duration":new jo(Ge.paint_raster["raster-fade-duration"])})};class $d extends ga{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var Zd={paint:new $o({"sky-type":new jo(Ge.paint_sky["sky-type"]),"sky-atmosphere-sun":new jo(Ge.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new jo(Ge.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new jo(Ge.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new jo(Ge.paint_sky["sky-gradient-radius"]),"sky-gradient":new Go(Ge.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new jo(Ge.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new jo(Ge.paint_sky["sky-atmosphere-color"]),"sky-opacity":new jo(Ge.paint_sky["sky-opacity"])})};function Wd(e,t,r){const i=[0,0,1],n=$l([]);return Wl(n,n,r?-l(e)+Math.PI:l(e)),Zl(n,n,-l(t)),Ol(i,i,n),Dl(i,i)}const Hd={circle:class extends ga{constructor(e){super(e,ul)}createBucket(e){return new Za(e)}queryRadius(e){const t=e;return ol("circle-radius",this,t)+ol("circle-stroke-width",this,t)+sl(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,r,i,n,o,s,a){const l=ll(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,r)+this.paint.get("circle-stroke-width").evaluate(t,r);return Jl(e,i,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new ca(this,e)}},heatmap:class extends ga{createBucket(e){return new ic(e)}constructor(e){super(e,cc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=uc({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(e){return ol("heatmap-radius",this,e)}queryIntersectsFeature(e,t,r,i,o,s,a,l){const c=this.paint.get("heatmap-radius").evaluate(t,r);return Jl(e,i,s,a,l,!0,!0,new n(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new ca(this,e)}},hillshade:class extends ga{constructor(e){super(e,hc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends ga{constructor(e){super(e,Jc)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),r=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getProgramConfiguration(e){return new ca(this,e)}recalculate(e,t){super.recalculate(e,t);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Yc(e)}queryRadius(){return sl(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,r,i,n,o){return!e.queryGeometry.isAboveHorizon&&Xa(al(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),i)}isTileClipped(){return!0}},"fill-extrusion":class extends ga{constructor(e){super(e,wu)}createBucket(e){return new yu(e)}queryRadius(){return sl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(e){return new ca(this,e)}queryIntersectsFeature(e,t,r,i,o,s,a,l,c){const u=ll(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(t,r),p=this.paint.get("fill-extrusion-base").evaluate(t,r),d=[0,0],f=l&&s.elevation,m=s.elevation?s.elevation.exaggeration():1,_=e.tile.getBucket(this);if(f&&_ instanceof yu){const e=_.centroidVertexArray,t=c+1;if(t<e.length){const r=e.get(t);d[0]=r.a_centroid_pos0,d[1]=r.a_centroid_pos1}}if(0===d[0]&&1===d[1])return!1;"globe"===s.projection.name&&(i=bu([i],[new n(0,0),new n(ba,ba)],e.tileID.canonical).map((e=>e.polygon)).flat());const g=function(e,t,r,i,o,s,a,l,c,u,h){return"globe"===e.projection.name?function(e,t,r,i,n,o,s,a,l,c,u){const h=[],p=[],d=e.projection.upVectorScale(u,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(e,t,r,i)=>{e[0]=t,e[1]=r,e[2]=i,e[3]=1},g=xu();r>0&&(r+=g),i+=g;for(const g of t){const t=[],y=[];for(const h of g){const p=h.x+n.x,g=h.y+n.y,v=e.projection.projectTilePoint(p,g,u),x=e.projection.upVector(u,h.x,h.y);let b=r,w=i;if(s){const e=zu(p,g,r,i,s,a,l,c);b+=e.base,w+=e.top}0!==r?_(f,v.x+x[0]*d*b,v.y+x[1]*d*b,v.z+x[2]*d*b):_(f,v.x,v.y,v.z),_(m,v.x+x[0]*d*w,v.y+x[1]*d*w,v.z+x[2]*d*w),Rl(f,f,o),Rl(m,m,o),t.push(Mu(f)),y.push(Mu(m))}h.push(t),p.push(y)}return[h,p]}(e,t,r,i,o,s,a,l,c,u,h):a?function(e,t,r,i,n,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const p of e){const e=[],d=[];for(const c of p){const u=c.x+i.x,p=c.y+i.y,f=zu(u,p,t,r,o,s,a,l);h[0]=u,h[1]=p,h[2]=f.base,h[3]=1,ql(h,h,n),h[3]=Math.max(h[3],1e-5);const m=Mu([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);h[0]=u,h[1]=p,h[2]=f.top,h[3]=1,ql(h,h,n),h[3]=Math.max(h[3],1e-5);const _=Mu([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);e.push(m),d.push(_)}c.push(e),u.push(d)}return[c,u]}(t,r,i,o,s,a,l,c,u):function(e,t,r,i,o){const s=[],a=[],l=o[8]*t,c=o[9]*t,u=o[10]*t,h=o[11]*t,p=o[8]*r,d=o[9]*r,f=o[10]*r,m=o[11]*r;for(const t of e){const e=[],r=[];for(const s of t){const t=s.x+i.x,a=s.y+i.y,_=o[0]*t+o[4]*a+o[12],g=o[1]*t+o[5]*a+o[13],y=o[2]*t+o[6]*a+o[14],v=o[3]*t+o[7]*a+o[15],x=_+l,b=g+c,w=y+u,T=Math.max(v+h,1e-5),E=_+p,S=g+d,C=y+f,A=Math.max(v+m,1e-5),k=new n(x/T,b/T);k.z=w/T,e.push(k);const I=new n(E/A,S/A);I.z=C/A,r.push(I)}s.push(e),a.push(r)}return[s,a]}(t,r,i,o,s)}(s,i,p,h,u,a,f?l:null,d,m,s.center.lat,e.tileID.canonical),y=e.queryGeometry;return function(e,t,r){let i=1/0;Xa(r,t)&&(i=Iu(r,t[0]));for(let n=0;n<t.length;n++){const o=t[n],s=e[n];for(let e=0;e<o.length-1;e++){const t=o[e],n=[t,o[e+1],s[e+1],s[e],t];Wa(r,n)&&(i=Math.min(i,Iu(r,n)))}}return i!==1/0&&i}(g[0],g[1],y.isPointQuery()?y.screenBounds:y.screenGeometry)}},line:class extends ga{constructor(e){super(e,ju),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof _r,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Uu.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Fu(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(e){return new ca(this,e)}queryRadius(e){const t=e,r=Vu(ol("line-width",this,t),ol("line-gap-width",this,t)),i=ol("line-offset",this,t);return r/2+Math.abs(i)+sl(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,r,i,o,s){if(e.queryGeometry.isAboveHorizon)return!1;const a=al(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),l=e.pixelToTileUnitsFactor/2*Vu(this.paint.get("line-width").evaluate(t,r),this.paint.get("line-gap-width").evaluate(t,r)),c=this.paint.get("line-offset").evaluate(t,r);return c&&(i=function(e,t){const r=[],i=new n(0,0);for(let n=0;n<e.length;n++){const o=e[n],s=[];for(let e=0;e<o.length;e++){const r=o[e-1],n=o[e],a=o[e+1],l=0===e?i:n.sub(r)._unit()._perp(),c=e===o.length-1?i:a.sub(n)._unit()._perp(),u=l._add(c)._unit();u._mult(1/(u.x*c.x+u.y*c.y)),s.push(u._mult(t)._add(n))}r.push(s)}return r}(i,c*e.pixelToTileUnitsFactor)),function(e,t,r){for(let i=0;i<t.length;i++){const n=t[i];if(e.length>=3)for(let t=0;t<n.length;t++)if(rl(e,n[t]))return!0;if(Ya(e,n,r))return!0}return!1}(a,i,l)}isTileClipped(){return!0}},symbol:Vd,background:class extends ga{constructor(e){super(e,qd)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends ga{constructor(e){super(e,Gd)}getProgramIds(){return["raster"]}},sky:class extends ga{constructor(e){super(e,Zd),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=uc({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return!1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const r=this.paint.get("sky-atmosphere-sun"),i=!r,n=e.style.light,o=n.properties.get("position");return i&&"viewport"===n.properties.get("anchor")&&z("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),i?Wd(o.azimuthal,90-o.polar,t):Wd(r[0],90-r[1],t)}const r=this.paint.get("sky-gradient-center");return Wd(r[0],90-r[1],t)}is3D(){return!1}isSky(){return!0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const e=this.paint.get("sky-type");return"atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}}};class Xd{constructor(e,t,r,i){this.context=e,this.format=r,this.texture=e.gl.createTexture(),this.update(t,i)}update(e,r,i){const{width:n,height:o}=e,{context:s}=this,{gl:a}=s,{HTMLImageElement:l,HTMLCanvasElement:c,HTMLVideoElement:u,ImageData:h,ImageBitmap:p}=t;if(a.bindTexture(a.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!r||!1!==r.premultiply)),i||this.size&&this.size[0]===n&&this.size[1]===o){const{x:t,y:r}=i||{x:0,y:0};e instanceof l||e instanceof c||e instanceof u||e instanceof h||p&&e instanceof p?a.texSubImage2D(a.TEXTURE_2D,0,t,r,a.RGBA,a.UNSIGNED_BYTE,e):a.texSubImage2D(a.TEXTURE_2D,0,t,r,n,o,a.RGBA,a.UNSIGNED_BYTE,e.data)}else this.size=[n,o],e instanceof l||e instanceof c||e instanceof u||e instanceof h||p&&e instanceof p?a.texImage2D(a.TEXTURE_2D,0,this.format,this.format,a.UNSIGNED_BYTE,e):a.texImage2D(a.TEXTURE_2D,0,this.format,n,o,0,this.format,a.UNSIGNED_BYTE,e.data);this.useMipmap=Boolean(r&&r.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D)}bind(e,t){const{context:r}=this,{gl:i}=r;i.bindTexture(i.TEXTURE_2D,this.texture),e!==this.filter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap?e===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_NEAREST:e),this.filter=e),t!==this.wrap&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrap=t)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Yd{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new ac({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const r=this.getKey(e,t);return this.positions[r]}trim(){const e=this.width,t=this.height=T(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,r){const i=[];let n=e.length%2==1?-e[e.length-1]*r:0,o=e[0]*r,s=!0;i.push({left:n,right:o,isDash:s,zeroLength:0===e[0]});let a=e[0];for(let t=1;t<e.length;t++){s=!s;const l=e[t];n=a*r,a+=l,o=a*r,i.push({left:n,right:o,isDash:s,zeroLength:0===l})}return i}addRoundDash(e,t,r){const i=t/2;for(let t=-r;t<=r;t++){const n=this.width*(this.nextRow+r+t);let o=0,s=e[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const p=t/r*(i+1);if(s.isDash){const e=i-Math.abs(p);h=Math.sqrt(u*u+e*e)}else h=i-Math.sqrt(u*u+p*p);this.image.data[n+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const r=e[t],i=e[t+1];r.zeroLength?e.splice(t,1):i&&i.isDash===r.isDash&&(i.left=r.left,e.splice(t,1))}const r=e[0],i=e[e.length-1];r.isDash===i.isDash&&(r.left=i.left-this.width,i.right=r.right+this.width);const n=this.width*this.nextRow;let o=0,s=e[o];for(let r=0;r<this.width;r++){r/s.right>1&&(s=e[++o]);const i=Math.abs(r-s.left),a=Math.abs(r-s.right),l=Math.min(i,a);this.image.data[n+r]=Math.max(0,Math.min(255,(s.isDash?l:-l)+t+128))}}addDash(e,t){const r=this.getKey(e,t);if(this.positions[r])return this.positions[r];const i="round"===t,n=i?7:0,o=2*n+1;if(this.nextRow+o>this.height)return z("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;t<e.length;t++)e[t]<0&&(z("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),s+=e[t];if(0!==s){const r=this.width/s,o=this.getDashRanges(e,this.width,r);i?this.addRoundDash(o,r,n):this.addRegularDash(o,"square"===t?.5*r:0)}const a=this.nextRow+n;this.nextRow+=o;const l={tl:[a,n],br:[s,0]};return this.positions[r]=l,l}}zn(Yd,"LineAtlas");class Kd{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(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 Jd{constructor(){this.tasks={},this.taskQueue=[],S(["process"],this),this.invoker=new Kd(this.process),this.nextId=0}add(e,t){const r=this.nextId++,i=function({type:e,isSymbolTile:t,zoom:r}){return r=r||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-r:"maybePrepare"===e&&t?400-r:500:200-r:100-r}(t);if(0===i){L();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[r]={fn:e,metadata:t,priority:i,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r]}}}process(){L();try{if(this.taskQueue=this.taskQueue.filter((e=>!!this.tasks[e])),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let r=0;r<this.taskQueue.length;r++){const i=this.tasks[this.taskQueue[r]];i.priority<t&&(t=i.priority,e=r)}if(null===e)return null;const r=this.taskQueue[e];return this.taskQueue.splice(e,1),r}remove(){this.invoker.remove()}}class Qd{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const r=e[t];this._stringToNumber[r]=t,this._numberToString[t]=r}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}const ef=["tile","layer","source","sourceLayer","state"];class tf{constructor(e,t,r,i,n){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=r,this._y=i,this.properties=e.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",geometry:this.geometry,properties:this.properties};void 0!==this.id&&(e.id=this.id);for(const t of ef)void 0!==this[t]&&(e[t]=this[t]);return e}}const rf=32,nf=33,of=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,r=0,i=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=rf:r=i=a=rf;(t>>=1)>1;){const e=r+n>>1,l=i+o>>1;1&t?(n=r,o=i,r=s,i=a):(r=n,i=o,n=s,o=a),s=e,a=l}const l=4*e;of[l+0]=r,of[l+1]=i,of[l+2]=n,of[l+3]=o}const sf=new Uint16Array(2178),af=new Uint8Array(1089),lf=new Uint16Array(1089);function cf(e){return 0===e?-.03125:32===e?.03125:0}var uf=Yo([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const hf={type:2,extent:ba,loadGeometry:()=>[[new n(0,0),new n(8193,0),new n(8193,8193),new n(0,8193),new n(0,0)]]};class pf{constructor(e,t,r,i,n){this.tileID=e,this.uid=b(),this.uses=0,this.tileSize=t,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,this.expiredRequestCount=0,this.state="loading",i&&i.transform&&(this.projection=i.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;t<W.now()||this.fadeEndTime&&t<this.fadeEndTime||(this.fadeEndTime=t)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=ld(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,t,r){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const r={};if(!t)return r;for(const i of e){const e=i.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(0!==e.length){i.layers=e,i.stateDependentLayerIds&&(i.stateDependentLayers=i.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)r[t.id]=i}}return r}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Fd){if(this.hasSymbolBuckets=!0,!r)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Fd&&t.hasRTLText){this.hasRTLText=!0,Mo.isLoading()||Mo.isLoaded()||"deferred"!==ko()||Io();break}}this.queryPadding=0;for(const e in this.buckets){const r=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(r))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new As}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const r=this.buckets[t];r.uploadPending()&&r.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Xd(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Xd(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Xd(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,r,i,n,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:i,pixelPosMatrix:s,transform:o,params:n,tileTransform:this.tileTransform},e,t,r):{}}querySourceFeatures(e,t){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const i=r.loadVTLayers(),n=t?t.sourceLayer:"",o=i._geojsonTileLayer||i[n];if(!o)return;const s=Xi(t&&t.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let t=0;t<o.length;t++){const i=o.feature(t);if(s.needGeometry){const e=qa(i,!0);if(!s.filter(new zo(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new zo(this.tileID.overscaledZ),i))continue;const h=r.getId(i,n),p=new tf(i,a,l,c,h);p.tile=u,e.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const t=this.expirationTime;if(e.cacheControl){const t=B(e.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let r=!1;if(this.expirationTime>e)r=!1;else if(t)if(this.expirationTime<t)r=!0;else{const i=this.expirationTime-t;i?this.expirationTime=e+Math.max(i,3e4):r=!0}else r=!0;r?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,t){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(e).length||!t)return;const r=this.latestFeatureIndex.loadVTLayers(),i=t.style.listImages();for(const n in this.buckets){if(!t.style.hasLayer(n))continue;const o=this.buckets[n],s=o.layers[0].sourceLayer||"_geojsonTileLayer",a=r[s],l=e[s];if(!a||!l||0===Object.keys(l).length)continue;if(o.update(l,a,i,this.imageAtlas&&this.imageAtlas.patternPositions||{}),o instanceof Fu||o instanceof Yc){const e=t.style._getSourceCache(o.layers[0].source);t._terrain&&t._terrain.enabled&&e&&o.programConfigurations.needsUpload&&t._terrain._clearRenderCacheForTile(e.id,this.tileID)}const c=t&&t.style&&t.style.getLayer(n);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(o)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<W.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=W.now()+e}setTexture(e,t){const r=t.context,i=r.gl;this.texture=t.getTileTexture(e.width),this.texture?this.texture.update(e,{useMipmap:!0}):(this.texture=new Xd(r,e,i.RGBA,{useMipmap:!0}),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),r.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax))}setDependencies(e,t){const r={};for(const e of t)r[e]=!0;this.dependencies[e]=r}hasDependency(e,t){for(const r of e){const e=this.dependencies[r];if(e)for(const r of t)if(e[r])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,t){if(!t||"mercator"===t.name||this._tileDebugBuffer)return;const r=Va(hf,this.tileID.canonical,this.tileTransform)[0],i=new Jo,n=new ws;for(let e=0;e<r.length;e++){const{x:t,y:o}=r[e];i.emplaceBack(t,o),n.emplaceBack(e)}n.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(n),this._tileDebugBuffer=e.createVertexBuffer(i,Rp.members),this._tileDebugSegments=xa.simpleSegment(0,0,i.length,n.length)}_makeTileBoundsBuffers(e,t){if(this._tileBoundsBuffer||!t||"mercator"===t.name)return;const r=Va(hf,this.tileID.canonical,this.tileTransform)[0];let i,n;if(this.isRaster){const e=function(e,t){const r=ld(e,t),i=Math.pow(2,e.z);for(let n=0;n<nf;n++)for(let o=0;o<nf;o++){const s=Ma((e.x+(o+cf(o))/rf)/i),a=za((e.y+(n+cf(n))/rf)/i),l=t.project(s,a),c=n*nf+o;sf[2*c+0]=Math.round((l.x*r.scale-r.x)*ba),sf[2*c+1]=Math.round((l.y*r.scale-r.y)*ba)}af.fill(0),lf.fill(0);for(let e=2045;e>=0;e--){const t=4*e,r=of[t+0],i=of[t+1],n=of[t+2],o=of[t+3],s=r+n>>1,a=i+o>>1,l=s+a-i,c=a+r-s,u=i*nf+r,h=o*nf+n,p=a*nf+s,d=Math.hypot((sf[2*u+0]+sf[2*h+0])/2-sf[2*p+0],(sf[2*u+1]+sf[2*h+1])/2-sf[2*p+1])>=16;if(af[p]=af[p]||(d?1:0),e<1022){const e=(i+c>>1)*nf+(r+l>>1),t=(o+c>>1)*nf+(n+l>>1);af[p]=af[p]||af[e]||af[t]}}const n=new es,o=new fs;let s=0;function a(e,t){const r=t*nf+e;return 0===lf[r]&&(n.emplaceBack(sf[2*r+0],sf[2*r+1],e*ba/rf,t*ba/rf),lf[r]=++s),lf[r]-1}function l(e,t,r,i,n,s){const c=e+r>>1,u=t+i>>1;if(Math.abs(e-n)+Math.abs(t-s)>1&&af[u*nf+c])l(n,s,e,t,c,u),l(r,i,n,s,c,u);else{const l=a(e,t),c=a(r,i),u=a(n,s);o.emplaceBack(l,c,u)}}return l(0,0,rf,rf,rf,0),l(rf,rf,0,0,0,rf),{vertices:n,indices:o}}(this.tileID.canonical,t);i=e.vertices,n=e.indices}else{i=new es,n=new fs;for(const{x:e,y:t}of r)i.emplaceBack(e,t,0,0);const e=fc(i.int16,void 0,4);for(let t=0;t<e.length;t+=3)n.emplaceBack(e[t],e[t+1],e[t+2])}this._tileBoundsBuffer=e.createVertexBuffer(i,uf.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(n),this._tileBoundsSegments=xa.simpleSegment(0,0,i.length,n.length)}_makeGlobeTileDebugBuffers(e,t){if(this._globeTileDebugBorderBuffer||this._globeTileDebugTextBuffer||!t||"globe"!==t.name)return;const r=this.tileID.canonical,i=Qp(Zp(r));this._makeGlobeTileDebugBorderBuffer(e,r,i),this._makeGlobeTileDebugTextBuffer(e,r,i)}_makeGlobeTileDebugBorderBuffer(e,t,r){const i=new Jo,n=new ws,o=new Qo,s=(e,s,a,l,c)=>{const u=(a-e)/(c-1),h=(l-s)/(c-1),p=i.length;for(let a=0;a<c;a++){const l=e+a*u,c=s+a*h;i.emplaceBack(l,c);const d=Kp(l,c,t),f=Rl(d,d,r);o.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(p+a)}},a=ba;s(0,0,a,0,16),s(a,0,a,a,16),s(a,a,0,a,16),s(0,a,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(n),this._tileDebugBuffer=e.createVertexBuffer(i,Rp.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(o,Bp.members),this._tileDebugSegments=xa.simpleSegment(0,0,i.length,n.length)}_makeGlobeTileDebugTextBuffer(e,t,r){const i=new Jo,n=new fs,o=new Qo,s=25;n.reserve(32),i.reserve(s),o.reserve(s);const a=(e,t)=>s*e+t;for(let e=0;e<s;e++){const n=2048*e;for(let e=0;e<s;e++){const s=2048*e;i.emplaceBack(s,n);const a=Kp(s,n,t),l=Rl(a,a,r);o.emplaceBack(l[0],l[1],l[2])}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const r=a(e,t),i=a(e,t+1),o=a(e+1,t),s=a(e+1,t+1);n.emplaceBack(r,i,o),n.emplaceBack(o,i,s)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(n),this._tileDebugTextBuffer=e.createVertexBuffer(i,Rp.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(o,Bp.members),this._tileDebugTextSegments=xa.simpleSegment(0,0,s,32)}}class df{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,r){const i=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][i]=this.stateChanges[e][i]||{},v(this.stateChanges[e][i],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==i&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][i]){this.deletedStates[e][i]={};for(const t in this.state[e][i])r[t]||(this.deletedStates[e][i][t]=null)}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][i]&&null===this.deletedStates[e][i][t]&&delete this.deletedStates[e][i][t]}removeFeatureState(e,t,r){if(null===this.deletedStates[e])return;const i=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},r&&void 0!==t)null!==this.deletedStates[e][i]&&(this.deletedStates[e][i]=this.deletedStates[e][i]||{},this.deletedStates[e][i][r]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][i])for(r in this.deletedStates[e][i]={},this.stateChanges[e][i])this.deletedStates[e][i][r]=null;else this.deletedStates[e][i]=null;else this.deletedStates[e]=null}getState(e,t){const r=String(t),i=v({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const r=this.deletedStates[e][t];if(null===r)return{};for(const e in r)delete i[e]}return i}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,t){const r={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const r in this.stateChanges[e])this.state[e][r]||(this.state[e][r]={}),v(this.state[e][r],this.stateChanges[e][r]),t[r]=this.state[e][r];r[e]=t}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const r in this.state[e])t[r]={},this.state[e][r]={};else for(const r in this.deletedStates[e]){if(null===this.deletedStates[e][r])this.state[e][r]={};else for(const t of Object.keys(this.deletedStates[e][r]))delete this.state[e][r][t];t[r]=this.state[e][r]}r[e]=r[e]||{},v(r[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const i in e)e[i].setFeatureState(r,t)}}class ff{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const r=this.toIdx(e,t);return{min:this.minimums[r],max:this.maximums[r]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function mf(e,t,r,i){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(i[s])<1e-15){if(r[s]<e[s]||r[s]>t[s])return null}else{const a=1/i[s];let l=(e[s]-r[s])*a,c=(t[s]-r[s])*a;if(l>c){const e=l;l=c,c=e}if(l>n&&(n=l),c<o&&(o=c),n>o)return null}return n}function _f(e,t,r,i,n,o,s,a,l,c,u){const h=i-e,p=n-t,d=o-r,f=s-e,m=a-t,_=l-r,g=u[1]*_-u[2]*m,y=u[2]*f-u[0]*_,v=u[0]*m-u[1]*f,x=h*g+p*y+d*v;if(Math.abs(x)<1e-15)return null;const b=1/x,w=c[0]-e,T=c[1]-t,E=c[2]-r,S=(w*g+T*y+E*v)*b;if(S<0||S>1)return null;const C=T*d-E*p,A=E*h-w*d,k=w*p-T*h,I=(u[0]*C+u[1]*A+u[2]*k)*b;return I<0||S+I>1?null:(f*C+m*A+_*k)*b}function gf(e,t,r){return(e-t)/(r-t)}function yf(e,t,r,i,n,o,s,a,l){const c=1<<r,u=o-i,h=s-n,p=(e+1)/c*u+i,d=(t+0)/c*h+n,f=(t+1)/c*h+n;a[0]=(e+0)/c*u+i,a[1]=d,l[0]=p,l[1]=f}class vf{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(e){const t=Math.ceil(Math.log2(e.dim/8)),r=[];let i=Math.ceil(Math.pow(2,t));const n=1/i,o=(e,t,r,i,n)=>{const o=i?1:0,s=(e+1)*r-o,a=t*r,l=(t+1)*r-o;n[0]=e*r,n[1]=a,n[2]=s,n[3]=l};let s=new ff(i);const a=[];for(let t=0;t<i*i;t++){o(t%i,Math.floor(t/i),n,!1,a);const r=bf(a[0],a[1],e),l=bf(a[2],a[1],e),c=bf(a[2],a[3],e),u=bf(a[0],a[3],e);s.minimums.push(Math.min(r,l,c,u)),s.maximums.push(Math.max(r,l,c,u)),s.leaves.push(1)}for(r.push(s),i/=2;i>=1;i/=2){const e=r[r.length-1];s=new ff(i);for(let t=0;t<i*i;t++){o(t%i,Math.floor(t/i),2,!0,a);const r=e.getElevation(a[0],a[1]),n=e.getElevation(a[2],a[1]),l=e.getElevation(a[2],a[3]),c=e.getElevation(a[0],a[3]),u=e.isLeaf(a[0],a[1]),h=e.isLeaf(a[2],a[1]),p=e.isLeaf(a[2],a[3]),d=e.isLeaf(a[0],a[3]),f=Math.min(r.min,n.min,l.min,c.min),m=Math.max(r.max,n.max,l.max,c.max),_=u&&h&&p&&d;s.maximums.push(m),s.minimums.push(f),s.leaves.push(m-f<=5&&_?1:0)}r.push(s)}return r}(this.dem),r=t.length-1,i=t[r];this._addNode(i.minimums[0],i.maximums[0],i.leaves[0]),this._construct(t,0,0,r,0)}raycastRoot(e,t,r,i,n,o,s=1){return mf([e,t,-100],[r,i,this.maximums[0]*s],n,o)}raycast(e,t,r,i,n,o,s=1){if(!this.nodeCount)return null;const a=this.raycastRoot(e,t,r,i,n,o,s);if(null==a)return null;const l=[],c=[],u=[],h=[],p=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:a,t:d,nodex:f,nodey:m,depth:_}=p.pop();if(this.leaves[a]){yf(f,m,_,e,t,r,i,u,h);const a=1<<_,l=(f+0)/a,c=(f+1)/a,p=(m+0)/a,g=(m+1)/a,y=bf(l,p,this.dem)*s,v=bf(c,p,this.dem)*s,x=bf(c,g,this.dem)*s,b=bf(l,g,this.dem)*s,w=_f(u[0],u[1],y,h[0],u[1],v,h[0],h[1],x,n,o),T=_f(h[0],h[1],x,u[0],h[1],b,u[0],u[1],y,n,o),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const e=Pl([],n,o,d);if(xf(y,v,b,x,gf(e[0],u[0],h[0]),gf(e[1],u[1],h[1]))>=e[2])return d}continue}let g=0;for(let p=0;p<this._siblingOffset.length;p++){yf((f<<1)+this._siblingOffset[p][0],(m<<1)+this._siblingOffset[p][1],_+1,e,t,r,i,u,h),u[2]=-100,h[2]=this.maximums[this.childOffsets[a]+p]*s;const d=mf(u,h,n,o);if(null!=d){const e=d;l[p]=e;let t=!1;for(let r=0;r<g&&!t;r++)e>=l[c[r]]&&(c.splice(r,0,p),t=!0);t||(c[g]=p),g++}}for(let e=0;e<g;e++){const t=c[e];p.push({idx:this.childOffsets[a]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:_+1})}}return null}_addNode(e,t,r){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(r),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,r,i,n){if(1===e[i].isLeaf(t,r))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const o=i-1,s=e[o];let a=0,l=0;for(let e=0;e<this._siblingOffset.length;e++){const i=2*t+this._siblingOffset[e][0],n=2*r+this._siblingOffset[e][1],o=s.getElevation(i,n),c=s.isLeaf(i,n),u=this._addNode(o.min,o.max,c);c&&(a|=1<<e),l||(l=u)}for(let i=0;i<this._siblingOffset.length;i++)a&1<<i||this._construct(e,2*t+this._siblingOffset[i][0],2*r+this._siblingOffset[i][1],o,l+i)}}function xf(e,t,r,i,n,o){return gr(gr(e,r,o),gr(t,i,o),n)}function bf(e,t,r){const i=r.dim,n=f(e*i-.5,0,i-1),o=f(t*i-.5,0,i-1),s=Math.floor(n),a=Math.floor(o),l=Math.min(s+1,i-1),c=Math.min(a+1,i-1);return xf(r.get(s,a),r.get(l,a),r.get(s,c),r.get(l,c),n-s,o-a)}const wf={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class Tf{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,r,i=!1,n=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(r&&"mapbox"!==r&&"terrarium"!==r)return z(`"${r}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const o=this.dim=t.height-2,s=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.encoding=r||"mapbox",this.borderReady=i,!i){for(let e=0;e<o;e++)s[this._idx(-1,e)]=s[this._idx(0,e)],s[this._idx(o,e)]=s[this._idx(o-1,e)],s[this._idx(e,-1)]=s[this._idx(e,0)],s[this._idx(e,o)]=s[this._idx(e,o-1)];s[this._idx(-1,-1)]=s[this._idx(0,0)],s[this._idx(o,-1)]=s[this._idx(o-1,0)],s[this._idx(-1,o)]=s[this._idx(0,o-1)],s[this._idx(o,o)]=s[this._idx(o-1,o-1)],n&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new vf(this)}get(e,t,r=!1){r&&(e=f(e,-1,this.dim),t=f(t,-1,this.dim));const i=4*this._idx(e,t);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(this.pixels[i],this.pixels[i+1],this.pixels[i+2])}static getUnpackVector(e){return wf[e]}get unpackVector(){return wf[this.encoding]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}_unpackMapbox(e,t,r){return(256*e*256+256*t+r)/10-1e4}_unpackTerrarium(e,t,r){return 256*e+t+r/256-32768}static pack(e,t){const r=[0,0,0,0],i=Tf.getUnpackVector(t);let n=Math.floor((e+i[3])/i[2]);return r[2]=n%256,n=Math.floor(n/256),r[1]=n%256,n=Math.floor(n/256),r[0]=n,r}getPixels(){return new lc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let i=t*this.dim,n=t*this.dim+this.dim,o=r*this.dim,s=r*this.dim+this.dim;switch(t){case-1:i=n-1;break;case 1:n=i+1}switch(r){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-r*this.dim;for(let t=o;t<s;t++)for(let r=i;r<n;r++){const i=4*this._idx(r,t),n=4*this._idx(r+a,t+l);this.pixels[i+0]=e.pixels[n+0],this.pixels[i+1]=e.pixels[n+1],this.pixels[i+2]=e.pixels[n+2],this.pixels[i+3]=e.pixels[n+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}zn(Tf,"DEMData"),zn(vf,"DemMinMaxQuadTree",{omit:["dem"]});class Ef{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,r){const i=e.wrapped().key;void 0===this.data[i]&&(this.data[i]=[]);const n={value:t,timeout:void 0};if(void 0!==r&&(n.timeout=setTimeout((()=>{this.remove(e,n)}),r)),this.data[i].push(n),this.order.push(i),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const r=e.wrapped().key,i=void 0===t?0:this.data[r].indexOf(t),n=this.data[r][i];return this.data[r].splice(i,1),n.timeout&&clearTimeout(n.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(n.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const r in this.data)for(const i of this.data[r])e(i.value)||t.push(i);for(const e of t)this.remove(e.value.tileID,e)}}class Sf{constructor(e,t,r){this.func=e,this.mask=t,this.range=r}}Sf.ReadOnly=!1,Sf.ReadWrite=!0,Sf.disabled=new Sf(519,Sf.ReadOnly,[0,1]);const Cf=7680;class Af{constructor(e,t,r,i,n,o){this.test=e,this.ref=t,this.mask=r,this.fail=i,this.depthFail=n,this.pass=o}}Af.disabled=new Af({func:519,mask:0},0,0,Cf,Cf,Cf);class kf{constructor(e,t,r){this.blendFunction=e,this.blendColor=t,this.mask=r}}kf.Replace=[1,0],kf.disabled=new kf(kf.Replace,gt.transparent,[!1,!1,!1,!1]),kf.unblended=new kf(kf.Replace,gt.transparent,[!0,!0,!0,!0]),kf.alphaBlended=new kf([1,771],gt.transparent,[!0,!0,!0,!0]);const If=1029,Mf=2305;class zf{constructor(e,t,r){this.enable=e,this.mode=t,this.frontFace=r}}zf.disabled=new zf(!1,If,Mf),zf.backCCW=new zf(!0,If,Mf),zf.backCW=new zf(!0,If,2304),zf.frontCW=new zf(!0,1028,2304),zf.frontCCW=new zf(!0,1028,Mf);class Pf extends qe{constructor(e,t,r){super(),this.id=e,this._onlySymbols=r,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),t.on("error",(()=>{this._sourceErrored=!0})),this._source=t,this._tiles={},this._cache=new Ef(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new df,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const t in this._tiles){const r=this._tiles[t];this._source.prepareTile(r)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,r.tileID),r.upload(e),r.prepare(this.map.style.imageManager)}else for(const t in this._tiles){const r=this._tiles[t];r.upload(e),r.prepare(this.map.style.imageManager)}}getIds(){return y(this._tiles).map((e=>e.tileID)).sort(Df).map((e=>e.key))}getRenderableIds(e){const t=[];for(const r in this._tiles)this._isIdRenderable(+r,e)&&t.push(this._tiles[r]);return e?t.sort(((e,t)=>{const r=e.tileID,i=t.tileID,o=new n(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),s=new n(i.canonical.x,i.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-i.overscaledZ||s.y-o.y||s.x-o.x})).map((e=>e.tileID.key)):t.map((e=>e.tileID)).sort(Df).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const r=this._tiles[e];r&&("loading"!==r.state&&(r.state=t),this._loadTile(r,this._tileLoaded.bind(this,r,e,t)))}_tileLoaded(e,t,r,i){if(i)if(e.state="errored",404!==i.status)this._source.fire(new Ve(i,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=W.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new Ue("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let i=0;i<t.length;i++){const n=t[i];if(e.neighboringTiles&&e.neighboringTiles[n]){const t=this.getTileByID(n);r(e,t),r(t,e)}}function r(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let r=t.tileID.canonical.x-e.tileID.canonical.x;const i=t.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===r&&0===i||Math.abs(i)>1||(Math.abs(r)>1&&(1===Math.abs(r+n)?r+=n:1===Math.abs(r-n)&&(r-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,i),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,r,i){for(const n in this._tiles){let o=this._tiles[n];if(i[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>r)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){i[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const r=this._loadedParentTiles[e.key];return r&&r.tileID.overscaledZ>=t?r:null}for(let r=e.overscaledZ-1;r>=t;r--){const t=e.scaledTo(r),i=this._getLoadedTile(t);if(i)return i}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const r=Math.ceil(e.width/t)+1,i=Math.ceil(e.height/t)+1,n=Math.floor(r*i*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const r in this._tiles){const i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+t),e[i.tileID.key]=i}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(e,t,r){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!r)return;let i;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new Cu(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(i=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(i=i.filter((e=>this._source.hasTile(e))))):i=[];const n=this._updateRetainedTiles(i);if(Lf(this._source.type)&&0!==i.length){const e={},t={},r=Object.keys(n);for(const i of r){const r=n[i],o=this._tiles[i];if(!o||o.fadeEndTime&&o.fadeEndTime<=W.now())continue;const s=this.findLoadedParent(r,Math.max(r.overscaledZ-Pf.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),e[s.tileID.key]=s.tileID),t[i]=r}const o=i[i.length-1].overscaledZ;for(const e in this._tiles){const r=this._tiles[e];if(n[e]||!r.hasData())continue;let i=r.tileID;for(;i.overscaledZ>o;){i=i.scaledTo(i.overscaledZ-1);const o=this._tiles[i.key];if(o&&o.hasData()&&t[i.key]){n[e]=r.tileID;break}}}for(const t in e)n[t]||(this._coveredTiles[t]=!0,n[t]=e[t])}for(const e in n)this._tiles[e].clearFadeHold();const o=function(e,t){const r=[];for(const i in e)i in t||r.push(i);return r}(this._tiles,n);for(const e of o){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const r={},i=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-Pf.maxOverzooming,this._source.minzoom),s=Math.max(n+Pf.maxUnderzooming,this._source.minzoom),a={};for(const r of e){const e=this._addTile(r);t[r.key]=r,e.hasData()||i<this._source.maxzoom&&(a[r.key]=r)}this._retainLoadedChildren(a,i,s,t);for(const i of e){let e=this._tiles[i.key];if(e.hasData())continue;if(i.canonical.z>=this._source.maxzoom){const e=i.children(this._source.maxzoom)[0],r=this.getTile(e);if(r&&r.hasData()){t[e.key]=e;continue}}else{const e=i.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=i.overscaledZ-1;s>=o;--s){const o=i.scaledTo(s);if(r[o.key])break;if(r[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let r,i=this._tiles[e].tileID;for(;i.overscaledZ>0;){if(i.key in this._loadedParentTiles){r=this._loadedParentTiles[i.key];break}t.push(i.key);const e=i.scaledTo(i.overscaledZ-1);if(r=this._getLoadedTile(e),r)break;i=e}for(const e of t)this._loadedParentTiles[e]=r}}_addTile(e){let t=this._tiles[e.key];if(t)return this._source.prepareTile&&this._source.prepareTile(t),t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const r=Boolean(t);if(!r){const r=this.map?this.map.painter:null;t=new pf(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,r,this._isRaster),this._source.prepareTile&&this._source.prepareTile(t)||this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,r||this._source.fire(new Ue("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const r=t.getExpiryTimeout();r&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),r))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,t,r){const i=[],n=this.transform;if(!n)return i;const o="globe"===n.projection.name,s=Aa(n.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(r&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(f(s,...Bf(e,-1))-s),Math.abs(f(s,...Bf(e,1))-s)];c=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(f(s,...Bf(e,-1))-s),Math.abs(f(s,...Bf(e,0))-s),Math.abs(f(s,...Bf(e,1))-s)];c=[t.indexOf(Math.min(...t))-1]}}else c=[0];for(const r of c){const o=e.containsTile(l,n,t,r);o&&i.push(o)}}return i}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map((e=>this._tiles[e].tileID));for(const e of t)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(Lf(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=W.now())return!0}return!1}setFeatureState(e,t,r){this._state.updateState(e=e||"_geojsonTileLayer",t,r)}removeFeatureState(e,t,r){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,r)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,r){const i=this._tiles[e];i&&i.setDependencies(t,r)}reloadTilesForDependencies(e,t){for(const r in this._tiles)this._tiles[r].hasDependency(e,t)&&this._reloadTile(+r,"reloading");this._cache.filter((r=>!r.hasDependency(e,t)))}_preloadTiles(e,t){const r=new Map,i=Array.isArray(e)?e:[e],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of i){const t=e.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)r.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}g(Array.from(r.values()),((e,t)=>{const r=new pf(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(r,(e=>{"raster-dem"===this._source.type&&r.dem&&this._backfillDEM(r),t(e,r)}))}),t)}}function Df(e,t){const r=Math.abs(2*e.wrap)-+(e.wrap<0),i=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||i-r||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Lf(e){return"raster"===e||"image"===e||"video"===e}function Bf(e,t){const r=1<<e.z;return[e.x/r+t,(e.x+1)/r+t]}Pf.maxOverzooming=10,Pf.maxUnderzooming=3;class Rf{constructor(e,t,r){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=r}static create(e,t,r){const i=r||e.findDEMTileFor(t);if(!i||!i.dem)return;const n=i.dem,o=i.tileID,s=1<<t.canonical.z-o.canonical.z;return new Rf(i,i.tileSize/ba/s,[(t.canonical.x/s-o.canonical.x)*n.dim,(t.canonical.y/s-o.canonical.y)*n.dim])}tileCoordToPixel(e,t){const r=t*this._scale+this._offset[1],i=Math.floor(e*this._scale+this._offset[0]),o=Math.floor(r);return new n(i,o)}getElevationAt(e,t,r,i){const n=e*this._scale+this._offset[0],o=t*this._scale+this._offset[1],s=Math.floor(n),a=Math.floor(o),l=this._dem;return i=!!i,r?gr(gr(l.get(s,a,i),l.get(s,a+1,i),o-a),gr(l.get(s+1,a,i),l.get(s+1,a+1,i),o-a),n-s):l.get(s,a,i)}getElevationAtPixel(e,t,r){return this._dem.get(e,t,!!r)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Ia(1,e)*this._dem.stride}}class Of{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new kn(ba,16,0),this.featureIndexArray=new Bs,this.promoteId=t}insert(e,t,r,i,n,o=0){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,i,n,o);const a=this.grid;for(let e=0;e<t.length;e++){const r=t[e],i=[1/0,1/0,-1/0,-1/0];for(let e=0;e<r.length;e++){const t=r[e];i[0]=Math.min(i[0],t.x),i[1]=Math.min(i[1],t.y),i[2]=Math.max(i[2],t.x),i[3]=Math.max(i[3],t.y)}i[0]<ba&&i[1]<ba&&i[2]>=0&&i[3]>=0&&a.insert(s,i[0],i[1],i[2],i[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new hu.VectorTile(new lh(this.rawTileData)).layers,this.sourceLayerCoder=new Qd(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,r,i){this.loadVTLayers();const n=e.params||{},o=Xi(n.filter),s=e.tileResult,a=e.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((e,t,r,i)=>il(s.bufferedTilespaceGeometry,e,t,r,i)));c.sort(Nf);let u=null;a.elevation&&c.length>0&&(u=Rf.create(a.elevation,this.tileID));const h={};let p;for(let a=0;a<c.length;a++){const l=c[a];if(l===p)continue;p=l;const d=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(h,d,o,n.layers,n.availableImages,t,r,i,((t,r,i,n=0)=>(f||(f=Va(t,this.tileID.canonical,e.tileTransform)),r.queryIntersectsFeature(s,t,i,f,this.z,e.transform,e.pixelPosMatrix,u,n))))}return h}loadMatchingFeature(e,t,r,i,n,o,s,a,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:p}=t,d=this.bucketLayerIDs[u];if(i&&!function(e,t){for(let r=0;r<e.length;r++)if(t.indexOf(e[r])>=0)return!0;return!1}(i,d))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(r.needGeometry){const e=qa(m,!0);if(!r.filter(new zo(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!r.filter(new zo(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let t=0;t<d.length;t++){const r=d[t];if(i&&i.indexOf(r)<0)continue;const u=o[r];if(!u)continue;let h={};void 0!==_&&a&&(h=a.getState(u.sourceLayer||"_geojsonTileLayer",_));const f=v({},s[r]);f.paint=Ff(f.paint,u.paint,m,h,n),f.layout=Ff(f.layout,u.layout,m,h,n);const g=!l||l(m,u,h,p);if(!g)continue;const y=new tf(m,this.z,this.x,this.y,_);y.layer=f;let x=e[r];void 0===x&&(x=e[r]=[]),x.push({featureIndex:c,feature:y,intersectionZ:g})}}lookupSymbolFeatures(e,t,r,i,n,o,s,a){const l={};this.loadVTLayers();const c=Xi(n);for(const n of e)this.loadMatchingFeature(l,{bucketIndex:r,sourceLayerIndex:i,featureIndex:n,layoutVertexArrayOffset:0},c,o,s,a,t);return l}loadFeature(e){const{featureIndex:t,sourceLayerIndex:r}=e;this.loadVTLayers();const i=this.sourceLayerCoder.decode(r),n=this.vtFeatures[i];if(n[t])return n[t];const o=this.vtLayers[i].feature(t);return n[t]=o,o}hasLayer(e){for(const t of this.bucketLayerIDs)for(const r of t)if(e===r)return!0;return!1}getId(e,t){let r=e.id;return this.promoteId&&(r=e.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[t]],"boolean"==typeof r&&(r=Number(r))),r}}function Ff(e,t,r,i,n){return A(e,((e,o)=>{const s=t instanceof No?t.get(o):null;return s&&s.evaluate?s.evaluate(r,i,n):s}))}function Nf(e,t){return t-e}zn(Of,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class jf{constructor(e){const t={},r=[];for(const i in e){const n=e[i],o=t[i]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i=t.metrics.localGlyph?2:1,s={x:0,y:0,w:t.bitmap.width+2*i,h:t.bitmap.height+2*i};r.push(s),o[e]=s}}const{w:i,h:n}=zh(r),o=new ac({width:i||1,height:n||1});for(const r in e){const i=e[r];for(const e in i.glyphs){const n=i.glyphs[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const s=t[r][e],a=n.metrics.localGlyph?2:1;ac.copy(n.bitmap,o,{x:0,y:0},{x:s.x+a,y:s.y+a},n.bitmap)}}this.image=o,this.positions=t}}zn(jf,"GlyphAtlas");class Uf{constructor(e){this.tileID=new Cu(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.enableTerrain=!!e.enableTerrain,this.isSymbolTile=e.isSymbolTile,this.tileTransform=ld(e.tileID.canonical,e.projection),this.projection=e.projection}parse(e,t,r,i,n){this.status="parsing",this.data=e,this.collisionBoxArray=new As;const o=new Qd(Object.keys(e.layers).sort()),s=new Of(this.tileID,this.promoteId);s.bucketLayerIDs=[];const a={},l=new Yd(256,256),c={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:r},u=t.familiesBySource[this.source];for(const t in u){const i=e.layers[t];if(!i)continue;let n=!1,l=!1;for(const e of u[t])"symbol"===e[0].type?n=!0:l=!0;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!l)continue;1===i.version&&z(`Vector tile source "${this.source}" layer "${t}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const h=o.encode(t),p=[];for(let e=0;e<i.length;e++){const r=i.feature(e),n=s.getId(r,t);p.push({feature:r,id:n,index:e,sourceLayerIndex:h})}for(const e of u[t]){const t=e[0];void 0!==this.isSymbolTile&&"symbol"===t.type!==this.isSymbolTile||t.minzoom&&this.zoom<Math.floor(t.minzoom)||t.maxzoom&&this.zoom>=t.maxzoom||"none"!==t.visibility&&(Vf(e,this.zoom,r),(a[t.id]=t.createBucket({index:s.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:r})).populate(p,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(e.map((e=>e.id))))}}let h,p,d,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=A(c.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(_).length?i.send("getGlyphs",{uid:this.uid,stacks:_},((e,t)=>{h||(h=e,p=t,x.call(this))}),void 0,!1,m):p={};const g=Object.keys(c.iconDependencies);g.length?i.send("getImages",{icons:g,source:this.source,tileID:this.tileID,type:"icons"},((e,t)=>{h||(h=e,d=t,x.call(this))}),void 0,!1,m):d={};const v=Object.keys(c.patternDependencies);function x(){if(h)return n(h);if(p&&d&&f){const e=new jf(p),t=new Dh(d,f);for(const i in a){const n=a[i];n instanceof Fd?(Vf(n.layers,this.zoom,r),Ep(n,p,e.positions,d,t.iconPositions,this.showCollisionBoxes,r,this.tileID.canonical,this.tileZoom,this.projection)):n.hasPattern&&(n instanceof Fu||n instanceof Yc||n instanceof yu)&&(Vf(n.layers,this.zoom,r),n.addFeatures(c,this.tileID.canonical,t.patternPositions,r,this.tileTransform))}this.status="done",n(null,{buckets:y(a).filter((e=>!e.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?d:null,glyphPositions:this.returnDependencies?e.positions:null})}}v.length?i.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"patterns"},((e,t)=>{h||(h=e,f=t,x.call(this))}),void 0,!1,m):f={},x.call(this)}}function Vf(e,t,r){const i=new zo(t);for(const t of e)t.recalculate(i,r)}class qf{constructor(e){this.entries={},this.scheduler=e}request(e,t,r,i){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,r]=n.result;return this.scheduler?this.scheduler.add((()=>{i(e,r)}),t):i(e,r),()=>{}}return n.callbacks.push(i),n.cancel||(n.cancel=r(((r,i)=>{n.result=[r,i];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(r,i)}),t):e(r,i);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==i)),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}}function Gf(e,t,r){const i=JSON.stringify(e.request);return e.data&&(this.deduped.entries[i]={result:[null,e.data]}),this.deduped.request(i,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const i=ze(e.request,((e,i,n,o)=>{e?t(e):i&&t(null,{vectorTile:r?void 0:new hu.VectorTile(new lh(i)),rawData:i,cacheControl:n,expires:o})}));return()=>{i.cancel(),t()}}),t)}e.ARRAY_TYPE=pl,e.AUTH_ERR_MSG=ie,e.Aabb=Kl,e.Actor=class{constructor(e,r,i){this.target=e,this.parent=r,this.mapId=i,this.callbacks={},this.cancelCallbacks={},S(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=L()?e:t,this.scheduler=new Jd}send(e,t,r,i,n=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=o,this.callbacks[s]=r);const a=O(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:e,hasCallback:!!r,targetMapId:i,mustQueue:n,sourceMapId:this.mapId,data:Ln(t,a)},a),{cancel:()=>{r&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:i,sourceMapId:this.mapId})}}}receive(e){const t=e.data,r=t.id;if(r&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){const e=this.cancelCallbacks[r];delete this.cancelCallbacks[r],e&&e.cancel()}else if(t.mustQueue||L()){const e=this.callbacks[r];this.cancelCallbacks[r]=this.scheduler.add((()=>this.processTask(r,t)),e&&e.metadata||{type:"message"})}else this.processTask(r,t)}processTask(e,t){if("<response>"===t.type){const r=this.callbacks[e];delete this.callbacks[e],r&&(t.error?r(Bn(t.error)):r(null,Bn(t.data)))}else{const r=O(this.globalScope)?void 0:[],i=t.hasCallback?(t,i)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:t?Ln(t):null,data:Ln(i,r)},r)}:e=>{},n=Bn(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,i);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],n.source)[e[1]](n,i)}else i(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},e.CanonicalTileID=Eu,e.Color=gt,e.ColorMode=kf,e.CullFaceMode=zf,e.DEMData=Tf,e.DataConstantProperty=jo,e.DedupedRequest=qf,e.DepthMode=Sf,e.EXTENT=ba,e.Elevation=class{isDataAvailableAtPoint(e){const t=this._source();if(!t||e.y<0||e.y>1)return!1;const r=t.getSource().maxzoom,i=1<<r,n=Math.floor(e.x),o=Math.floor((e.x-n)*i),s=Math.floor(e.y*i),a=this.findDEMTileFor(new Cu(r,n,r,o,s));return!(!a||!a.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,r=!0){null==t&&(t=null);const i=this._source();if(!i)return t;if(e.y<0||e.y>1)return t;const n=i.getSource().maxzoom,o=1<<n,s=Math.floor(e.x),a=e.x-s,l=new Cu(n,s,n,Math.floor(a*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const u=c.dem,h=1<<c.tileID.canonical.z,p=(a*h-c.tileID.canonical.x)*u.dim,d=(e.y*h-c.tileID.canonical.y)*u.dim,f=Math.floor(p),m=Math.floor(d);return(r?this.exaggeration():1)*gr(gr(u.get(f,m),u.get(f,m+1),d-m),gr(u.get(f+1,m),u.get(f+1,m+1),d-m),p-f)}getAtTileOffset(e,t,r){const i=1<<e.canonical.z;return this.getAtPointOrZero(new La(e.wrap+(e.canonical.x+t/ba)/i,(e.canonical.y+r/ba)/i))}getAtTileOffsetFunc(e,t,r,i){return n=>{const o=this.getAtTileOffset(e,n.x,n.y),s=i.upVector(e.canonical,n.x,n.y);return zl(s,s,o*i.upVectorScale(e.canonical,t,r).metersToTile),s}}getForTilePoints(e,t,r,i){const n=Rf.create(this,e,i);return!!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],r)})),!0)}getMinMaxForTile(e){const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const r=t.dem.tree,i=t.tileID,n=1<<e.canonical.z-i.canonical.z;let o=e.canonical.x/n-i.canonical.x,s=e.canonical.y/n-i.canonical.y,a=0;for(let t=0;t<e.canonical.z-i.canonical.z&&!r.leaves[a];t++){o*=2,s*=2;const e=2*Math.floor(s)+Math.floor(o);a=r.childOffsets[a]+e,o%=1,s%=1}return{min:this.exaggeration()*r.minimums[a],max:this.exaggeration()*r.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,r){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},e.ErrorEvent=Ve,e.EvaluationParameters=zo,e.Event=Ue,e.Evented=qe,e.FillExtrusionBucket=yu,e.Frustum=Yl,e.FrustumCorners=Xl,e.GLOBE_METERS_TO_ECEF=Fp,e.GLOBE_RADIUS=Op,e.GLOBE_SCALE_MATCH_LATITUDE=45,e.GLOBE_ZOOM_THRESHOLD_MAX=6,e.GLOBE_ZOOM_THRESHOLD_MIN=5,e.GlobeSharedBuffers=class{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const e of this._wireframeSegments)e.destroy()}}_createGrid(e){const t=new Jo,r=new fs,i=65;for(let e=0;e<i;e++)for(let r=0;r<i;r++)t.emplaceBack(r,e);this._gridSegments=[];for(let e=0,t=0;e<Np.length;e++){const n=Np[e];for(let e=0;e<n;e++)for(let t=0;t<64;t++){const n=e*i+t;r.emplaceBack(n+1,n,n+i),r.emplaceBack(n+i,n+i+1,n+1)}const o=64*n*2;this._gridSegments.push(xa.simpleSegment(0,t,(n+1)*i,o)),t+=o}this._gridBuffer=e.createVertexBuffer(t,Rp.members),this._gridIndexBuffer=e.createIndexBuffer(r,!0)}_createPoles(e){const t=new fs;for(let e=0;e<=64;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const r=new ys,i=new ys;this._poleSegments=[];for(let e=0,t=0;e<5;e++){const n=1<<e,o=512*n/Math.PI/2,s=360/n;r.emplaceBack(0,-o,0,0,0,.5,0),i.emplaceBack(0,-o,0,0,0,.5,1);for(let e=0;e<=64;e++){const t=e/64,n=gr(0,s,t),[a,l,c]=Xp(od,sd,n,o);r.emplaceBack(a,l,c,0,0,t,0),i.emplaceBack(a,l,c,0,0,t,1)}this._poleSegments.push(xa.simpleSegment(t,0,66,64)),t+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(r,Lp,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(i,Lp,!1)}getGridBuffers(e){return[this._gridBuffer,this._gridIndexBuffer,this._gridSegments[e]]}getPoleBuffers(e){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}getWirefameBuffers(e,t){if(!this._wireframeSegments){const t=new bs,r=64,i=r+1;this._wireframeSegments=[];for(let e=0,n=0;e<Np.length;e++){const o=Np[e];for(let e=0;e<o;e++)for(let n=0;n<r;n++){const r=e*i+n;t.emplaceBack(r,r+1),t.emplaceBack(r,r+i),t.emplaceBack(r,r+i+1)}const s=o*r*3;this._wireframeSegments.push(xa.simpleSegment(0,n,(o+1)*i,s)),n+=s}this._wireframeIndexBuffer=e.createIndexBuffer(t)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[t]]}},e.GlyphManager=cp,e.ImagePosition=Ph,e.LineAtlas=Yd,e.LngLat=Ea,e.LngLatBounds=wa,e.LocalGlyphMode=lp,e.MAX_MERCATOR_LATITUDE=Da,e.MercatorCoordinate=La,e.ONE_EM=Yu,e.OverscaledTileID=Cu,e.Properties=$o,e.RGBAImage=lc,e.Ray=Hl,e.RequestManager=class{constructor(e,t,r){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!r,this._createSkuToken()}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",re,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!ne(e))return e;const r=ae(e);return r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!ne(e))return e;const r=ae(e);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||t)}normalizeSourceURL(e,t,r,i){if(!ne(e))return e;const n=ae(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),r&&n.params.push(`language=${r}`),i&&n.params.push(`worldview=${i}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSpriteURL(e,t,r,i){const n=ae(e);return ne(e)?(n.path=`/styles/v1${n.path}/sprite${t}${r}`,this._makeAPIURL(n,this._customAccessToken||i)):(n.path+=`${t}${r}`,le(n))}normalizeTileURL(e,t,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!ne(e))return e;const i=ae(e);i.path=i.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||r&&"raster"!==i.authority&&512===r?"@2x":""}${Y.supported?".webp":"$1"}`),"raster"===i.authority?i.path=`/${X.RASTER_URL_PREFIX}${i.path}`:(i.path=i.path.replace(/^.+\/v4\//,"/"),i.path=`/${X.TILE_URL_VERSION}${i.path}`);const n=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(i.params)||X.ACCESS_TOKEN;return X.REQUIRE_ACCESS_TOKEN&&n&&this._skuToken&&i.params.push(`sku=${this._skuToken}`),this._makeAPIURL(i,n)}canonicalizeTileURL(e,t){const r=ae(e);if(!r.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!r.path.match(/\.[\w]+$/))return e;let i="mapbox://";r.path.match(/^\/raster\/v1\//)?i+=`raster/${r.path.replace(`/${X.RASTER_URL_PREFIX}/`,"")}`:i+=`tiles/${r.path.replace(`/${X.TILE_URL_VERSION}/`,"")}`;let n=r.params;return t&&(n=n.filter((e=>!e.match(/^access_token=/)))),n.length&&(i+=`?${n.join("&")}`),i}canonicalizeTileset(e,t){const r=!!t&&ne(t),i=[];for(const t of e.tiles||[])oe(t)?i.push(this.canonicalizeTileURL(t,r)):i.push(t);return i}_makeAPIURL(e,t){const r="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",i=ae(X.API_URL);if(e.protocol=i.protocol,e.authority=i.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==i.path&&(e.path=`${i.path}${e.path}`),!X.REQUIRE_ACCESS_TOKEN)return le(e);if(t=t||X.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),le(e)}},e.ResourceType=Ae,e.SegmentVector=xa,e.SourceCache=Pf,e.StencilMode=Af,e.StructArrayLayout1ui2=ws,e.StructArrayLayout2f1f2i16=hs,e.StructArrayLayout2i4=Jo,e.StructArrayLayout2ui4=bs,e.StructArrayLayout3f12=ds,e.StructArrayLayout3ui6=fs,e.StructArrayLayout4i8=es,e.StructArrayLayout5f20=vs,e.Texture=Xd,e.Tile=pf,e.Transitionable=Lo,e.Uniform1f=Ks,e.Uniform1i=class extends Ys{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},e.Uniform2f=class extends Ys{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.Uniform3f=class extends Ys{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.Uniform4f=Js,e.UniformColor=Qs,e.UniformMatrix2f=class extends Ys{constructor(e,t){super(e,t),this.current=ra}set(e){for(let t=0;t<4;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix2fv(this.location,!1,e);break}}},e.UniformMatrix3f=class extends Ys{constructor(e,t){super(e,t),this.current=ta}set(e){for(let t=0;t<9;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix3fv(this.location,!1,e);break}}},e.UniformMatrix4f=class extends Ys{constructor(e,t){super(e,t),this.current=ea}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.UnwrappedTileID=Su,e.ValidationError=ji,e.VectorTileWorkerSource=class extends qe{constructor(e,t,r,i,n){super(),this.actor=e,this.layerIndex=t,this.availableImages=r,this.loadVectorData=n||Gf,this.loading={},this.loaded={},this.deduped=new qf(e.scheduler),this.isSpriteLoaded=i,this.scheduler=e.scheduler}loadTile(e,t){const r=e.uid,i=e&&e.request,n=i&&i.collectResourceTiming,o=this.loading[r]=new Uf(e);o.abort=this.loadVectorData(e,((s,a)=>{const l=!this.loading[r];if(delete this.loading[r],l||s||!a)return o.status="done",l||(this.loaded[r]=o),t(s);const c=a.rawData,u={};a.expires&&(u.expires=a.expires),a.cacheControl&&(u.cacheControl=a.cacheControl),o.vectorTile=a.vectorTile||new hu.VectorTile(new lh(c));const h=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((e,r)=>{if(e||!r)return t(e);const o={};if(n){const e=U(i);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)))}t(null,v({rawTileData:c.slice(0)},r,u,o))}))};this.isSpriteLoaded?h():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom}):h()})),this.loaded=this.loaded||{},this.loaded[r]=o}))}reloadTile(e,t){const r=this.loaded,i=e.uid,n=this;if(r&&r[i]){const o=r[i];o.showCollisionBoxes=e.showCollisionBoxes,o.enableTerrain=!!e.enableTerrain,o.projection=e.projection,o.tileTransform=ld(e.tileID.canonical,e.projection);const s=(e,r)=>{const i=o.reloadCallback;i&&(delete o.reloadCallback,o.parse(o.vectorTile,n.layerIndex,this.availableImages,n.actor,i)),t(e,r)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}}abortTile(e,t){const r=e.uid,i=this.loading[r];i&&(i.abort&&i.abort(),delete this.loading[r]),t()}removeTile(e,t){const r=this.loaded,i=e.uid;r&&r[i]&&delete r[i],t()}},e.WritingMode=Lh,e.ZoomHistory=Rn,e.add=Cl,e.addDynamicAttributes=Ld,e.adjoint=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e[0]=s*u-a*c,e[1]=n*c-i*u,e[2]=i*a-n*s,e[3]=a*l-o*u,e[4]=r*u-n*l,e[5]=n*o-r*a,e[6]=o*c-s*l,e[7]=i*l-r*c,e[8]=r*s-i*o,e},e.asyncAll=g,e.bezier=p,e.bindAll=S,e.boundsAttributes=uf,e.bufferConvexPolygon=function(e,t){const r=[];for(let i=0;i<e.length;i++){const n=_(i-1,-1,e.length-1),o=_(i+1,-1,e.length-1),s=e[i],a=e[o],l=e[n].sub(s).unit(),c=a.sub(s).unit(),u=c.angleWithSep(l.x,l.y),h=l.add(c).unit().mult(-1*t/Math.sin(u/2));r.push(s.add(h))}return r},e.cacheEntryPossiblyAdded=function(e){Ce++,Ce>xe&&(e.getActor().send("enforceCacheSizeLimit",ve),Ce=0)},e.calculateGlobeLabelMatrix=function(e,t){const{x:r,y:i}=e.point,n=td(r,i,e.worldSize/e._projectionScaler,0,0);return ml(n,n,ed(Zp(t)))},e.calculateGlobeMatrix=function(e){const{x:t,y:r}=e.point,{lng:i,lat:n}=e._center;return td(t,r,e.worldSize,i,n)},e.calculateGlobeMercatorMatrix=function(e){const t=e.worldSize,r=e.point,i=Ia(1,e.center.lat)*t,n=e.pixelsPerMeter,o=t/(i/e.pixelsPerMeter),s=fl(new Float64Array(16));return _l(s,s,[r.x,r.y,0]),gl(s,s,[o,o,n]),Float32Array.from(s)},e.circumferenceAtLatitude=Ca,e.clamp=f,e.clearTileCache=function(e){const r=[];for(const e in be)r.push(t.caches.delete(e)),delete be[e];e&&Promise.all(r).catch(e).then((()=>e()))},e.clipLine=np,e.clone=function(e){var t=new pl(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.clone$1=I,e.collisionCircleLayout=Xu,e.config=X,e.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},e.create=function(){var e=new pl(16);return pl!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.create$1=dl,e.createExpression=Li,e.createLayout=Yo,e.createStyleLayer=function(e){return"custom"===e.type?new $d(e):new Hd[e.type](e)},e.cross=Bl,e.degToRad=l,e.distance=function(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])},e.div=function(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e},e.dot=Ll,e.ease=d,e.easeCubicInOut=h,e.emitValidationErrors=An,e.endsWith=C,e.enforceCacheSizeLimit=function(e){for(const t in be)Te(t),be[t].then((t=>{t.keys().then((r=>{for(let i=0;i<r.length-e;i++)t.delete(r[i])}))}))},e.evaluateSizeForFeature=Qu,e.evaluateSizeForZoom=eh,e.evaluateVariableOffset=Tp,e.evented=Ao,e.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},e.exactEquals$1=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},e.exported=W,e.exported$1=Y,e.extend=v,e.extend$1=$e,e.fillExtrusionHeightLift=xu,e.filterObject=k,e.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},e.fromQuat=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],s=r+r,a=i+i,l=n+n,c=r*s,u=i*s,h=i*a,p=n*s,d=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-h-f,e[1]=u+g,e[2]=p-_,e[3]=0,e[4]=u-g,e[5]=1-c-f,e[6]=d+m,e[7]=0,e[8]=p+_,e[9]=d-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},e.fromRotation=function(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=0,e[3]=-r,e[4]=i,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},e.furthestTileCorner=function(e){const t=Math.round((e+45+360)%360/90)%4;return u[t]},e.getAABBPointSquareDist=function(e,t,r){let i=0;for(let n=0;n<2;++n){const o=r?r[n]:0;e[n]>o&&(i+=(e[n]-o)*(e[n]-o)),t[n]<o&&(i+=(o-t[n])*(o-t[n]))}return i},e.getAnchorAlignment=Zh,e.getAnchorJustification=Sp,e.getBounds=function(e){let t=1/0,r=1/0,i=-1/0,o=-1/0;for(const n of e)t=Math.min(t,n.x),r=Math.min(r,n.y),i=Math.max(i,n.x),o=Math.max(o,n.y);return{min:new n(t,r),max:new n(i,o)}},e.getColumn=N,e.getGridMatrix=function(e,t,r){const[i,n]=t,o=.015625;return[0,(n[1]-i[1])*o,1<<e.z,(n[0]-i[0])/Np[r],0,e.y,i[0],i[1],o]},e.getImage=Fe,e.getJSON=function(e,t){return Me(v(e,{type:"json"}),t)},e.getLatitudinalLod=function(e){const t=80.051129;e=f(e,-80.051129,t)/t*90;const r=Math.pow(Math.abs(Math.sin(l(e))),3);return Math.round(r*(Np.length-1))},e.getMapSessionAPI=_e,e.getPerformanceMeasurement=U,e.getProjection=Id,e.getRTLTextPluginStatus=ko,e.getReferrer=Ie,e.getTilePoint=function(e,{x:t,y:r},i=0){return new n(((t-i)*e.scale-e.x)*ba,(r*e.scale-e.y)*ba)},e.getTileVec3=function(e,t,r=0){return Sl(((t.x-r)*e.scale-e.x)*ba,(t.y*e.scale-e.y)*ba,Pa(t.z,t.y))},e.getVideo=function(e,r){const i=t.document.createElement("video");i.muted=!0,i.onloadstart=function(){r(null,i)};for(let r=0;r<e.length;r++){const n=t.document.createElement("source");Le(e[r])||(i.crossOrigin="Anonymous"),n.src=e[r],i.appendChild(n)}return{cancel:()=>{}}},e.globeCenterToScreenPoint=function(e){const t=[0,0,0],r=fl(new Float64Array(16));return ml(r,e.pixelMatrix,e.globeMatrix),Rl(t,t,r),new n(t[0],t[1])},e.globeECEFOrigin=function(e,t){const r=[0,0,0];return Rl(r,r,Qp(Zp(t.canonical))),Rl(r,r,e),r},e.globeNormalizeECEF=Qp,e.globePixelsToTileUnits=function(e,t){return ba/(512*Math.pow(2,e))*Jp(Zp(t))},e.globePoleMatrixForTile=function(e,t,r){const i=fl(new Float64Array(16)),n=1<<e,o=360*(t/n-.5),s=r.point,a=r.worldSize/(r.tileSize*n);return _l(i,i,[s.x,s.y,-r.worldSize/Math.PI/2]),gl(i,i,[a,a,a]),yl(i,i,l(-r._center.lat)),vl(i,i,l(-r._center.lng+o)),Float32Array.from(i)},e.globeTileBounds=Zp,e.globeTileLatLngCorners=Hp,e.globeTiltAtLngLat=id,e.globeToMercatorTransition=rd,e.globeUseCustomAntiAliasing=function(e,t,r){const i=rd(r.zoom),n=e.style.map._antialias,o=!!t.extStandardDerivatives,s=t.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===i&&!n&&!s&&o},e.identity=fl,e.identity$1=$l,e.invert=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],p=t[10],d=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=r*a-i*s,v=r*l-n*s,x=r*c-o*s,b=i*l-n*a,w=i*c-o*a,T=n*c-o*l,E=u*m-h*f,S=u*_-p*f,C=u*g-d*f,A=h*_-p*m,k=h*g-d*m,I=p*g-d*_,M=y*I-v*k+x*A+b*C-w*S+T*E;return M?(e[0]=(a*I-l*k+c*A)*(M=1/M),e[1]=(n*k-i*I-o*A)*M,e[2]=(m*T-_*w+g*b)*M,e[3]=(p*w-h*T-d*b)*M,e[4]=(l*C-s*I-c*S)*M,e[5]=(r*I-n*C+o*S)*M,e[6]=(_*x-f*T-g*v)*M,e[7]=(u*T-p*x+d*v)*M,e[8]=(s*k-a*C+c*E)*M,e[9]=(i*C-r*k-o*E)*M,e[10]=(f*w-m*x+g*y)*M,e[11]=(h*x-u*w-d*y)*M,e[12]=(a*S-s*A-l*E)*M,e[13]=(r*A-i*S+n*E)*M,e[14]=(m*v-f*b-_*y)*M,e[15]=(u*b-h*v+p*y)*M,e):null},e.isLngLatBehindGlobe=function(e,t){return id(e,t)>Math.PI/2*1.01},e.isMapAuthenticated=function(e){return ge.has(e)},e.isMapboxURL=ne,e.isSafariWithAntialiasingBug=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!O(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.latFromMercatorY=za,e.len=Ul,e.length=El,e.length$1=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},e.loadVectorTile=Gf,e.makeRequest=Me,e.mapValue=function(e,t,r,i,n){return f((e-t)/(r-t)*(n-i)+i,i,n)},e.mercatorXfromLng=Aa,e.mercatorYfromLat=ka,e.mercatorZfromAltitude=Ia,e.mul=bl,e.mul$1=jl,e.multiply=ml,e.multiply$1=function(e,t,r){var i=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],p=r[0],d=r[1],f=r[2],m=r[3],_=r[4],g=r[5],y=r[6],v=r[7],x=r[8];return e[0]=p*i+d*s+f*c,e[1]=p*n+d*a+f*u,e[2]=p*o+d*l+f*h,e[3]=m*i+_*s+g*c,e[4]=m*n+_*a+g*u,e[5]=m*o+_*l+g*h,e[6]=y*i+v*s+x*c,e[7]=y*n+v*a+x*u,e[8]=y*o+v*l+x*h,e},e.multiply$2=kl,e.nextPowerOfTwo=T,e.normalize=Dl,e.normalize$1=function(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],s=r*r+i*i+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=r*s,e[1]=i*s,e[2]=n*s,e[3]=o*s,e},e.number=gr,e.ortho=function(e,t,r,i,n,o,s){var a=1/(t-r),l=1/(i-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+r)*a,e[13]=(n+i)*l,e[14]=(s+o)*c,e[15]=1,e},e.pbf=lh,e.perspective=function(e,t,r,i,n){var o,s=1/Math.tan(t/2);return e[0]=s/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+i)*(o=1/(i-n)),e[14]=2*n*i*o):(e[10]=-1,e[14]=-2*i),e},e.pick=function(e,t){const r={};for(let i=0;i<t.length;i++){const n=t[i];n in e&&(r[n]=e[n])}return r},e.plugin=Mo,e.pointGeometry=n,e.polygonContainsPoint=rl,e.polygonIntersectsBox=il,e.polygonIntersectsPolygon=Wa,e.polygonizeBounds=function(e,t,r=0,i=!0){const o=new n(r,r),s=e.sub(o),a=t.add(o),l=[s,new n(a.x,s.y),a,new n(s.x,a.y)];return i&&l.push(s.clone()),l},e.posAttributes=Rp,e.postMapLoadEvent=fe,e.postTurnstileEvent=pe,e.potpack=zh,e.prevPowerOfTwo=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.radToDeg=c,e.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.registerForPluginStateChange=function(e){return e({pluginStatus:To,pluginURL:Eo}),Ao.on("pluginStateChange",e),e},e.removeAuthState=function(e){ge.delete(e)},e.renderColorRamp=uc,e.resample=Ra,e.rotateX=yl,e.rotateX$1=Zl,e.rotateY=vl,e.rotateY$1=Wl,e.rotateZ=function(e,t,r){var i=Math.sin(r),n=Math.cos(r),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n+c*i,e[1]=s*n+u*i,e[2]=a*n+h*i,e[3]=l*n+p*i,e[4]=c*n-o*i,e[5]=u*n-s*i,e[6]=h*n-a*i,e[7]=p*n-l*i,e},e.rotateZ$1=function(e,t,r){r*=.5;var i=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=i*l+n*a,e[1]=n*l-i*a,e[2]=o*l+s*a,e[3]=s*l-o*a,e},e.scale=gl,e.scale$1=Vl,e.scale$2=zl,e.scaleAndAdd=Pl,e.setCacheLimits=function(e,t){ve=e,xe=t},e.setColumn=function(e,t,r){e[4*t+0]=r[0],e[4*t+1]=r[1],e[4*t+2]=r[2],e[4*t+3]=r[3]},e.setRTLTextPlugin=function(e,t,r=!1){if(To===vo||To===xo||To===bo)throw new Error("setRTLTextPlugin cannot be called multiple times.");Eo=W.resolveURL(e),To=vo,wo=t,Co(),r||Io()},e.smoothstep=m,e.spec=Ge,e.storeAuthState=function(e,t){t?ge.add(e):ge.delete(e)},e.sub=Nl,e.subtract=Al,e.symbolSize=th,e.tileAABB=function(e,t,r,i,n,o,s,a,l){if("globe"===l.name)return Wp(e,t,new Eu(r,i,n));const c=ld({z:r,x:i,y:n},l);return new Kl([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])},e.tileTransform=ld,e.transformMat3=function(e,t,r){var i=t[0],n=t[1],o=t[2];return e[0]=i*r[0]+n*r[3]+o*r[6],e[1]=i*r[1]+n*r[4]+o*r[7],e[2]=i*r[2]+n*r[5]+o*r[8],e},e.transformMat4=Rl,e.transformMat4$1=ql,e.transformQuat=Ol,e.translate=_l,e.transpose=function(e,t){if(e===t){var r=t[1],i=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=i,e[7]=n}else 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];return e},e.triggerPluginCompletionEvent=So,e.uniqueId=b,e.updateGlobeVertexNormal=function(e,t,r,i,n){const o=5*t+2;e.float32[o+0]=r,e.float32[o+1]=i,e.float32[o+2]=n},e.validateCustomStyleLayer=function(e){const t=[],r=e.id;return void 0===r&&t.push({message:`layers.${r}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${r}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},e.validateFilter=e=>Cn(ln(e)),e.validateFog=e=>Cn(vn(e)),e.validateLayer=e=>Cn(dn(e)),e.validateLight=e=>Cn(gn(e)),e.validateSource=e=>Cn(_n(e)),e.validateStyle=Tn,e.validateTerrain=e=>Cn(yn(e)),e.values=y,e.vectorTile=hu,e.version=V,e.warnOnce=z,e.window=t,e.wrap=_})),i(0,(function(e){function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let r="[";for(const i of e)r+=`${t(i)},`;return`${r}]`}let r="{";for(const i of Object.keys(e).sort())r+=`${i}:${t(e[i])},`;return`${r}}`}function r(r){let i="";for(const n of e.refProperties)i+=`/${t(r[n])}`;return i}class i{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,i){for(const r of t)this._layerConfigs[r.id]=r,(this._layers[r.id]=e.createStyleLayer(r)).compileFilter(),this.keyCache[r.id]&&delete this.keyCache[r.id];for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=function(e,t){const i={};for(let n=0;n<e.length;n++){const o=t&&t[e[n].id]||r(e[n]);t&&(t[e[n].id]=o);let s=i[o];s||(s=i[o]=[]),s.push(e[n])}const n=[];for(const e in i)n.push(i[e]);return n}(e.values(this._layerConfigs),this.keyCache);for(const e of n){const t=e.map((e=>this._layers[e.id])),r=t[0];if("none"===r.visibility)continue;const i=r.source||"";let n=this.familiesBySource[i];n||(n=this.familiesBySource[i]={});const o=r.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(t)}}}class n{loadTile(t,r){const{uid:i,encoding:n,rawImageData:o,padding:s,buildQuadTree:a}=t,l=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap?this.getImageData(o,s):o;r(null,new e.DEMData(i,l,n,s<1,a))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const r=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}var o=function e(t,r){var i,n=t&&t.type;if("FeatureCollection"===n)for(i=0;i<t.features.length;i++)e(t.features[i],r);else if("GeometryCollection"===n)for(i=0;i<t.geometries.length;i++)e(t.geometries[i],r);else if("Feature"===n)e(t.geometry,r);else if("Polygon"===n)s(t.coordinates,r);else if("MultiPolygon"===n)for(i=0;i<t.coordinates.length;i++)s(t.coordinates[i],r);return t};function s(e,t){if(0!==e.length){a(e[0],t);for(var r=1;r<e.length;r++)a(e[r],!t)}}function a(e,t){for(var r=0,i=0,n=0,o=e.length,s=o-1;n<o;s=n++){var a=(e[n][0]-e[s][0])*(e[s][1]+e[n][1]),l=r+a;i+=Math.abs(r)>=Math.abs(a)?r-l+a:a-l+r,r=l}r+i>=0!=!!t&&e.reverse()}const l=e.vectorTile.VectorTileFeature.prototype.toGeoJSON;class c{constructor(t){this._feature=t,this.extent=e.EXTENT,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const r of this._feature.geometry)t.push([new e.pointGeometry(r[0],r[1])]);return t}{const t=[];for(const r of this._feature.geometry){const i=[];for(const t of r)i.push(new e.pointGeometry(t[0],t[1]));t.push(i)}return t}}toGeoJSON(e,t,r){return l.call(this,e,t,r)}}class u{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.EXTENT,this.length=t.length,this._features=t}feature(e){return new c(this._features[e])}}var h=e.vectorTile.VectorTileFeature,p=d;function d(e,t){this.options=t||{},this.features=e,this.length=e.length}function f(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096}d.prototype.feature=function(e){return new f(this.features[e],this.options.extent)},f.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var r=0;r<t.length;r++){for(var i=t[r],n=[],o=0;o<i.length;o++)n.push(new e.pointGeometry(i[o][0],i[o][1]));this.geometry.push(n)}return this.geometry},f.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var e=this.geometry,t=1/0,r=-1/0,i=1/0,n=-1/0,o=0;o<e.length;o++)for(var s=e[o],a=0;a<s.length;a++){var l=s[a];t=Math.min(t,l.x),r=Math.max(r,l.x),i=Math.min(i,l.y),n=Math.max(n,l.y)}return[t,i,r,n]},f.prototype.toGeoJSON=h.prototype.toGeoJSON;var m=g,_=p;function g(t){var r=new e.pbf;return function(e,t){for(var r in e.layers)t.writeMessage(3,y,e.layers[r])}(t,r),r.finish()}function y(e,t){var r;t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);var i={keys:[],values:[],keycache:{},valuecache:{}};for(r=0;r<e.length;r++)i.feature=e.feature(r),t.writeMessage(2,v,i);var n=i.keys;for(r=0;r<n.length;r++)t.writeStringField(3,n[r]);var o=i.values;for(r=0;r<o.length;r++)t.writeMessage(4,E,o[r])}function v(e,t){var r=e.feature;void 0!==r.id&&t.writeVarintField(1,r.id),t.writeMessage(2,x,e),t.writeVarintField(3,r.type),t.writeMessage(4,T,r)}function x(e,t){var r=e.feature,i=e.keys,n=e.values,o=e.keycache,s=e.valuecache;for(var a in r.properties){var l=r.properties[a],c=o[a];if(null!==l){void 0===c&&(i.push(a),o[a]=c=i.length-1),t.writeVarint(c);var u=typeof l;"string"!==u&&"boolean"!==u&&"number"!==u&&(l=JSON.stringify(l));var h=u+":"+l,p=s[h];void 0===p&&(n.push(l),s[h]=p=n.length-1),t.writeVarint(p)}}}function b(e,t){return(t<<3)+(7&e)}function w(e){return e<<1^e>>31}function T(e,t){for(var r=e.loadGeometry(),i=e.type,n=0,o=0,s=r.length,a=0;a<s;a++){var l=r[a],c=1;1===i&&(c=l.length),t.writeVarint(b(1,c));for(var u=3===i?l.length-1:l.length,h=0;h<u;h++){1===h&&1!==i&&t.writeVarint(b(2,u-1));var p=l[h].x-n,d=l[h].y-o;t.writeVarint(w(p)),t.writeVarint(w(d)),n+=p,o+=d}3===i&&t.writeVarint(b(7,1))}}function E(e,t){var r=typeof e;"string"===r?t.writeStringField(1,e):"boolean"===r?t.writeBooleanField(7,e):"number"===r&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e))}function S(e,t,r,i,n,o){if(n-i<=r)return;const s=i+n>>1;C(e,t,s,i,n,o%2),S(e,t,r,i,s-1,o+1),S(e,t,r,s+1,n,o+1)}function C(e,t,r,i,n,o){for(;n>i;){if(n-i>600){const s=n-i+1,a=r-i+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);C(e,t,r,Math.max(i,Math.floor(r-a*c/s+u)),Math.min(n,Math.floor(r+(s-a)*c/s+u)),o)}const s=t[2*r+o];let a=i,l=n;for(A(e,t,i,r),t[2*n+o]>s&&A(e,t,i,n);a<l;){for(A(e,t,a,l),a++,l--;t[2*a+o]<s;)a++;for(;t[2*l+o]>s;)l--}t[2*i+o]===s?A(e,t,i,l):(l++,A(e,t,l,n)),l<=r&&(i=l+1),r<=l&&(n=l-1)}}function A(e,t,r,i){k(e,r,i),k(t,2*r,2*i),k(t,2*r+1,2*i+1)}function k(e,t,r){const i=e[t];e[t]=e[r],e[r]=i}function I(e,t,r,i){const n=e-r,o=t-i;return n*n+o*o}m.fromVectorTileJs=g,m.fromGeojsonVt=function(e,t){t=t||{};var r={};for(var i in e)r[i]=new p(e[i].features,t),r[i].name=i,r[i].version=t.version,r[i].extent=t.extent;return g({layers:r})},m.GeoJSONWrapper=_;const M=e=>e[0],z=e=>e[1];class P{constructor(e,t=M,r=z,i=64,n=Float64Array){this.nodeSize=i,this.points=e;const o=e.length<65536?Uint16Array:Uint32Array,s=this.ids=new o(e.length),a=this.coords=new n(2*e.length);for(let i=0;i<e.length;i++)s[i]=i,a[2*i]=t(e[i]),a[2*i+1]=r(e[i]);S(s,a,i,0,s.length-1,0)}range(e,t,r,i){return function(e,t,r,i,n,o,s){const a=[0,e.length-1,0],l=[];let c,u;for(;a.length;){const h=a.pop(),p=a.pop(),d=a.pop();if(p-d<=s){for(let s=d;s<=p;s++)c=t[2*s],u=t[2*s+1],c>=r&&c<=n&&u>=i&&u<=o&&l.push(e[s]);continue}const f=Math.floor((d+p)/2);c=t[2*f],u=t[2*f+1],c>=r&&c<=n&&u>=i&&u<=o&&l.push(e[f]);const m=(h+1)%2;(0===h?r<=c:i<=u)&&(a.push(d),a.push(f-1),a.push(m)),(0===h?n>=c:o>=u)&&(a.push(f+1),a.push(p),a.push(m))}return l}(this.ids,this.coords,e,t,r,i,this.nodeSize)}within(e,t,r){return function(e,t,r,i,n,o){const s=[0,e.length-1,0],a=[],l=n*n;for(;s.length;){const c=s.pop(),u=s.pop(),h=s.pop();if(u-h<=o){for(let n=h;n<=u;n++)I(t[2*n],t[2*n+1],r,i)<=l&&a.push(e[n]);continue}const p=Math.floor((h+u)/2),d=t[2*p],f=t[2*p+1];I(d,f,r,i)<=l&&a.push(e[p]);const m=(c+1)%2;(0===c?r-n<=d:i-n<=f)&&(s.push(h),s.push(p-1),s.push(m)),(0===c?r+n>=d:i+n>=f)&&(s.push(p+1),s.push(u),s.push(m))}return a}(this.ids,this.coords,e,t,r,this.nodeSize)}}const D={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},L=Math.fround||(B=new Float32Array(1),e=>(B[0]=+e,B[0]));var B;class R{constructor(e){this.options=G(Object.create(D),e),this.trees=new Array(this.options.maxZoom+1)}load(e){const{log:t,minZoom:r,maxZoom:i,nodeSize:n}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;let s=[];for(let t=0;t<e.length;t++)e[t].geometry&&s.push(F(e[t],t));this.trees[i+1]=new P(s,$,Z,n,Float32Array),t&&console.timeEnd(o);for(let e=i;e>=r;e--){const r=+Date.now();s=this._cluster(s,e),this.trees[e]=new P(s,$,Z,n,Float32Array),t&&console.log("z%d: %d clusters in %dms",e,s.length,+Date.now()-r)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let r=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,n=180;else if(r>n){const e=this.getClusters([r,i,180,o],t),s=this.getClusters([-180,i,n,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(U(r),V(o),U(n),V(i)),l=[];for(const e of a){const t=s.points[e];l.push(t.numPoints?N(t):this.points[t.index])}return l}getChildren(e){const t=this._getOriginId(e),r=this._getOriginZoom(e),i="No cluster with the specified id.",n=this.trees[r];if(!n)throw new Error(i);const o=n.points[t];if(!o)throw new Error(i);const s=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=n.within(o.x,o.y,s),l=[];for(const t of a){const r=n.points[t];r.parentId===e&&l.push(r.numPoints?N(r):this.points[r.index])}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,r){const i=[];return this._appendLeaves(i,e,t=t||10,r=r||0,0),i}getTile(e,t,r){const i=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(r-a)/n,c=(r+1+a)/n,u={features:[]};return this._addTileFeatures(i.range((t-a)/n,l,(t+1+a)/n,c),i.points,t,r,n,u),0===t&&this._addTileFeatures(i.range(1-a/n,l,1,c),i.points,n,r,n,u),t===n-1&&this._addTileFeatures(i.range(0,l,a/n,c),i.points,-1,r,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const r=this.getChildren(e);if(t++,1!==r.length)break;e=r[0].properties.cluster_id}return t}_appendLeaves(e,t,r,i,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=i?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,r,i,n):n<i?n++:e.push(t),e.length===r)break}return n}_addTileFeatures(e,t,r,i,n,o){for(const s of e){const e=t[s],a=e.numPoints;let l,c,u;if(a)l=j(e),c=e.x,u=e.y;else{const t=this.points[e.index];l=t.properties,c=U(t.geometry.coordinates[0]),u=V(t.geometry.coordinates[1])}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-r)),Math.round(this.options.extent*(u*n-i))]],tags:l};let p;a?p=e.id:this.options.generateId?p=e.index:this.points[e.index].id&&(p=this.points[e.index].id),void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(+e,this.options.maxZoom+1))}_cluster(e,t){const r=[],{radius:i,extent:n,reduce:o,minPoints:s}=this.options,a=i/(n*Math.pow(2,t));for(let i=0;i<e.length;i++){const n=e[i];if(n.zoom<=t)continue;n.zoom=t;const l=this.trees[t+1],c=l.within(n.x,n.y,a),u=n.numPoints||1;let h=u;for(const e of c){const r=l.points[e];r.zoom>t&&(h+=r.numPoints||1)}if(h>u&&h>=s){let e=n.x*u,s=n.y*u,a=o&&u>1?this._map(n,!0):null;const p=(i<<5)+(t+1)+this.points.length;for(const r of c){const i=l.points[r];if(i.zoom<=t)continue;i.zoom=t;const c=i.numPoints||1;e+=i.x*c,s+=i.y*c,i.parentId=p,o&&(a||(a=this._map(n,!0)),o(a,this._map(i)))}n.parentId=p,r.push(O(e/h,s/h,p,h,a))}else if(r.push(n),h>1)for(const e of c){const i=l.points[e];i.zoom<=t||(i.zoom=t,r.push(i))}}return r}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t){if(e.numPoints)return t?G({},e.properties):e.properties;const r=this.points[e.index].properties,i=this.options.map(r);return t&&i===r?G({},i):i}}function O(e,t,r,i,n){return{x:L(e),y:L(t),zoom:1/0,id:r,parentId:-1,numPoints:i,properties:n}}function F(e,t){const[r,i]=e.geometry.coordinates;return{x:L(U(r)),y:L(V(i)),zoom:1/0,index:t,parentId:-1}}function N(e){return{type:"Feature",id:e.id,properties:j(e),geometry:{type:"Point",coordinates:[(t=e.x,360*(t-.5)),q(e.y)]}};var t}function j(e){const t=e.numPoints,r=t>=1e4?`${Math.round(t/1e3)}k`:t>=1e3?Math.round(t/100)/10+"k":t;return G(G({},e.properties),{cluster:!0,cluster_id:e.id,point_count:t,point_count_abbreviated:r})}function U(e){return e/360+.5}function V(e){const t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function q(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function G(e,t){for(const r in t)e[r]=t[r];return e}function $(e){return e.x}function Z(e){return e.y}function W(e,t,r,i){for(var n,o=i,s=r-t>>1,a=r-t,l=e[t],c=e[t+1],u=e[r],h=e[r+1],p=t+3;p<r;p+=3){var d=H(e[p],e[p+1],l,c,u,h);if(d>o)n=p,o=d;else if(d===o){var f=Math.abs(p-s);f<a&&(n=p,a=f)}}o>i&&(n-t>3&&W(e,t,n,i),e[n+2]=o,r-n>3&&W(e,n,r,i))}function H(e,t,r,i,n,o){var s=n-r,a=o-i;if(0!==s||0!==a){var l=((e-r)*s+(t-i)*a)/(s*s+a*a);l>1?(r=n,i=o):l>0&&(r+=s*l,i+=a*l)}return(s=e-r)*s+(a=t-i)*a}function X(e,t,r,i){var n={id:void 0===e?null:e,type:t,geometry:r,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,r=e.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)Y(e,t);else if("Polygon"===r||"MultiLineString"===r)for(var i=0;i<t.length;i++)Y(e,t[i]);else if("MultiPolygon"===r)for(i=0;i<t.length;i++)for(var n=0;n<t[i].length;n++)Y(e,t[i][n])}(n),n}function Y(e,t){for(var r=0;r<t.length;r+=3)e.minX=Math.min(e.minX,t[r]),e.minY=Math.min(e.minY,t[r+1]),e.maxX=Math.max(e.maxX,t[r]),e.maxY=Math.max(e.maxY,t[r+1])}function K(e,t,r,i){if(t.geometry){var n=t.geometry.coordinates,o=t.geometry.type,s=Math.pow(r.tolerance/((1<<r.maxZoom)*r.extent),2),a=[],l=t.id;if(r.promoteId?l=t.properties[r.promoteId]:r.generateId&&(l=i||0),"Point"===o)J(n,a);else if("MultiPoint"===o)for(var c=0;c<n.length;c++)J(n[c],a);else if("LineString"===o)Q(n,a,s,!1);else if("MultiLineString"===o){if(r.lineMetrics){for(c=0;c<n.length;c++)Q(n[c],a=[],s,!1),e.push(X(l,"LineString",a,t.properties));return}ee(n,a,s,!1)}else if("Polygon"===o)ee(n,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(c=0;c<t.geometry.geometries.length;c++)K(e,{id:l,geometry:t.geometry.geometries[c],properties:t.properties},r,i);return}throw new Error("Input data is not a valid GeoJSON object.")}for(c=0;c<n.length;c++){var u=[];ee(n[c],u,s,!0),a.push(u)}}e.push(X(l,o,a,t.properties))}}function J(e,t){t.push(te(e[0])),t.push(re(e[1])),t.push(0)}function Q(e,t,r,i){for(var n,o,s=0,a=0;a<e.length;a++){var l=te(e[a][0]),c=re(e[a][1]);t.push(l),t.push(c),t.push(0),a>0&&(s+=i?(n*c-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(c-o,2))),n=l,o=c}var u=t.length-3;t[2]=1,W(t,0,u,r),t[u+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function ee(e,t,r,i){for(var n=0;n<e.length;n++){var o=[];Q(e[n],o,r,i),t.push(o)}}function te(e){return e/360+.5}function re(e){var t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function ie(e,t,r,i,n,o,s,a){if(i/=t,o>=(r/=t)&&s<i)return e;if(s<r||o>=i)return null;for(var l=[],c=0;c<e.length;c++){var u=e[c],h=u.geometry,p=u.type,d=0===n?u.minX:u.minY,f=0===n?u.maxX:u.maxY;if(d>=r&&f<i)l.push(u);else if(!(f<r||d>=i)){var m=[];if("Point"===p||"MultiPoint"===p)ne(h,m,r,i,n);else if("LineString"===p)oe(h,m,r,i,n,!1,a.lineMetrics);else if("MultiLineString"===p)ae(h,m,r,i,n,!1);else if("Polygon"===p)ae(h,m,r,i,n,!0);else if("MultiPolygon"===p)for(var _=0;_<h.length;_++){var g=[];ae(h[_],g,r,i,n,!0),g.length&&m.push(g)}if(m.length){if(a.lineMetrics&&"LineString"===p){for(_=0;_<m.length;_++)l.push(X(u.id,p,m[_],u.tags));continue}"LineString"!==p&&"MultiLineString"!==p||(1===m.length?(p="LineString",m=m[0]):p="MultiLineString"),"Point"!==p&&"MultiPoint"!==p||(p=3===m.length?"Point":"MultiPoint"),l.push(X(u.id,p,m,u.tags))}}}return l.length?l:null}function ne(e,t,r,i,n){for(var o=0;o<e.length;o+=3){var s=e[o+n];s>=r&&s<=i&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function oe(e,t,r,i,n,o,s){for(var a,l,c=se(e),u=0===n?ce:ue,h=e.start,p=0;p<e.length-3;p+=3){var d=e[p],f=e[p+1],m=e[p+2],_=e[p+3],g=e[p+4],y=0===n?d:f,v=0===n?_:g,x=!1;s&&(a=Math.sqrt(Math.pow(d-_,2)+Math.pow(f-g,2))),y<r?v>r&&(l=u(c,d,f,_,g,r),s&&(c.start=h+a*l)):y>i?v<i&&(l=u(c,d,f,_,g,i),s&&(c.start=h+a*l)):le(c,d,f,m),v<r&&y>=r&&(l=u(c,d,f,_,g,r),x=!0),v>i&&y<=i&&(l=u(c,d,f,_,g,i),x=!0),!o&&x&&(s&&(c.end=h+a*l),t.push(c),c=se(e)),s&&(h+=a)}var b=e.length-3;d=e[b],f=e[b+1],m=e[b+2],(y=0===n?d:f)>=r&&y<=i&&le(c,d,f,m),b=c.length-3,o&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&le(c,c[0],c[1],c[2]),c.length&&t.push(c)}function se(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ae(e,t,r,i,n,o){for(var s=0;s<e.length;s++)oe(e[s],t,r,i,n,o,!1)}function le(e,t,r,i){e.push(t),e.push(r),e.push(i)}function ce(e,t,r,i,n,o){var s=(o-t)/(i-t);return e.push(o),e.push(r+(n-r)*s),e.push(1),s}function ue(e,t,r,i,n,o){var s=(o-r)/(n-r);return e.push(t+(i-t)*s),e.push(o),e.push(1),s}function he(e,t){for(var r=[],i=0;i<e.length;i++){var n,o=e[i],s=o.type;if("Point"===s||"MultiPoint"===s||"LineString"===s)n=pe(o.geometry,t);else if("MultiLineString"===s||"Polygon"===s){n=[];for(var a=0;a<o.geometry.length;a++)n.push(pe(o.geometry[a],t))}else if("MultiPolygon"===s)for(n=[],a=0;a<o.geometry.length;a++){for(var l=[],c=0;c<o.geometry[a].length;c++)l.push(pe(o.geometry[a][c],t));n.push(l)}r.push(X(o.id,s,n,o.tags))}return r}function pe(e,t){var r=[];r.size=e.size,void 0!==e.start&&(r.start=e.start,r.end=e.end);for(var i=0;i<e.length;i+=3)r.push(e[i]+t,e[i+1],e[i+2]);return r}function de(e,t){if(e.transformed)return e;var r,i,n,o=1<<e.z,s=e.x,a=e.y;for(r=0;r<e.features.length;r++){var l=e.features[r],c=l.geometry,u=l.type;if(l.geometry=[],1===u)for(i=0;i<c.length;i+=2)l.geometry.push(fe(c[i],c[i+1],t,o,s,a));else for(i=0;i<c.length;i++){var h=[];for(n=0;n<c[i].length;n+=2)h.push(fe(c[i][n],c[i][n+1],t,o,s,a));l.geometry.push(h)}}return e.transformed=!0,e}function fe(e,t,r,i,n,o){return[Math.round(r*(e*i-n)),Math.round(r*(t*i-o))]}function me(e,t,r,i,n){for(var o=t===n.maxZoom?0:n.tolerance/((1<<t)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:r,y:i,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<e.length;a++){s.numFeatures++,_e(s,e[a],o,n);var l=e[a].minX,c=e[a].minY,u=e[a].maxX,h=e[a].maxY;l<s.minX&&(s.minX=l),c<s.minY&&(s.minY=c),u>s.maxX&&(s.maxX=u),h>s.maxY&&(s.maxY=h)}return s}function _e(e,t,r,i){var n=t.geometry,o=t.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a<n.length;a+=3)s.push(n[a]),s.push(n[a+1]),e.numPoints++,e.numSimplified++;else if("LineString"===o)ge(s,n,e,r,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(a=0;a<n.length;a++)ge(s,n[a],e,r,"Polygon"===o,0===a);else if("MultiPolygon"===o)for(var l=0;l<n.length;l++){var c=n[l];for(a=0;a<c.length;a++)ge(s,c[a],e,r,!0,0===a)}if(s.length){var u=t.tags||null;if("LineString"===o&&i.lineMetrics){for(var h in u={},t.tags)u[h]=t.tags[h];u.mapbox_clip_start=n.start/n.size,u.mapbox_clip_end=n.end/n.size}var p={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:u};null!==t.id&&(p.id=t.id),e.features.push(p)}}function ge(e,t,r,i,n,o){var s=i*i;if(i>0&&t.size<(n?s:i))r.numPoints+=t.length/3;else{for(var a=[],l=0;l<t.length;l+=3)(0===i||t[l+2]>s)&&(r.numSimplified++,a.push(t[l]),a.push(t[l+1])),r.numPoints++;n&&function(e,t){for(var r=0,i=0,n=e.length,o=n-2;i<n;o=i,i+=2)r+=(e[i]-e[o])*(e[i+1]+e[o+1]);if(r>0===t)for(i=0,n=e.length;i<n/2;i+=2){var s=e[i],a=e[i+1];e[i]=e[n-2-i],e[i+1]=e[n-1-i],e[n-2-i]=s,e[n-1-i]=a}}(a,o),e.push(a)}}function ye(e,t){var r=(t=this.options=function(e,t){for(var r in t)e[r]=t[r];return e}(Object.create(this.options),t)).debug;if(r&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var i=function(e,t){var r=[];if("FeatureCollection"===e.type)for(var i=0;i<e.features.length;i++)K(r,e.features[i],t,i);else K(r,"Feature"===e.type?e:{geometry:e},t);return r}(e,t);this.tiles={},this.tileCoords=[],r&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(i=function(e,t){var r=t.buffer/t.extent,i=e,n=ie(e,1,-1-r,r,0,-1,2,t),o=ie(e,1,1-r,2+r,0,-1,2,t);return(n||o)&&(i=ie(e,1,-r,1+r,0,-1,2,t)||[],n&&(i=he(n,1).concat(i)),o&&(i=i.concat(he(o,-1)))),i}(i,t)).length&&this.splitTile(i,0,0,0),r&&(i.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function ve(e,t,r){return 32*((1<<e)*r+t)+e}function xe(e,t){const r=e.tileID.canonical;if(!this._geoJSONIndex)return t(null,null);const i=this._geoJSONIndex.getTile(r.z,r.x,r.y);if(!i)return t(null,null);const n=new u(i.features);let o=m(n);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),t(null,{vectorTile:n,rawData:o.buffer})}ye.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},ye.prototype.splitTile=function(e,t,r,i,n,o,s){for(var a=[e,t,r,i],l=this.options,c=l.debug;a.length;){i=a.pop(),r=a.pop(),t=a.pop(),e=a.pop();var u=1<<t,h=ve(t,r,i),p=this.tiles[h];if(!p&&(c>1&&console.time("creation"),p=this.tiles[h]=me(e,t,r,i,l),this.tileCoords.push({z:t,x:r,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,r,i,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var d="z"+t;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(p.source=e,n){if(t===l.maxZoom||t===n)continue;var f=1<<n-t;if(r!==Math.floor(o/f)||i!==Math.floor(s/f))continue}else if(t===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue;if(p.source=null,0!==e.length){c>1&&console.time("clipping");var m,_,g,y,v,x,b=.5*l.buffer/l.extent,w=.5-b,T=.5+b,E=1+b;m=_=g=y=null,v=ie(e,u,r-b,r+T,0,p.minX,p.maxX,l),x=ie(e,u,r+w,r+E,0,p.minX,p.maxX,l),e=null,v&&(m=ie(v,u,i-b,i+T,1,p.minY,p.maxY,l),_=ie(v,u,i+w,i+E,1,p.minY,p.maxY,l),v=null),x&&(g=ie(x,u,i-b,i+T,1,p.minY,p.maxY,l),y=ie(x,u,i+w,i+E,1,p.minY,p.maxY,l),x=null),c>1&&console.timeEnd("clipping"),a.push(m||[],t+1,2*r,2*i),a.push(_||[],t+1,2*r,2*i+1),a.push(g||[],t+1,2*r+1,2*i),a.push(y||[],t+1,2*r+1,2*i+1)}}},ye.prototype.getTile=function(e,t,r){var i=this.options,n=i.extent,o=i.debug;if(e<0||e>24)return null;var s=1<<e,a=ve(e,t=(t%s+s)%s,r);if(this.tiles[a])return de(this.tiles[a],n);o>1&&console.log("drilling down to z%d-%d-%d",e,t,r);for(var l,c=e,u=t,h=r;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[ve(c,u,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,u,h),o>1&&console.time("drilling down"),this.splitTile(l.source,c,u,h,e,t,r),o>1&&console.timeEnd("drilling down"),this.tiles[a]?de(this.tiles[a],n):null):null};class be extends e.VectorTileWorkerSource{constructor(e,t,r,i,n){super(e,t,r,i,xe),n&&(this.loadGeoJSON=n)}loadData(t,r){const i=t&&t.request,n=i&&i.collectResourceTiming;this.loadGeoJSON(t,((s,a)=>{if(s||!a)return r(s);if("object"!=typeof a)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{o(a,!0);try{if(t.filter){const r=e.createExpression(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const i=a.features.filter((e=>r.value.evaluate({zoom:0},e)));a={type:"FeatureCollection",features:i}}this._geoJSONIndex=t.cluster?new R(function({superclusterOptions:t,clusterProperties:r}){if(!r||!t)return t;const i={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(r);for(const t of a){const[o,s]=r[t],a=e.createExpression(s),l=e.createExpression("string"==typeof o?[o,["accumulated"],["get",t]]:o);i[t]=a.value,n[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=n[t].evaluate(o,s)},t}(t)).load(a.features):function(e,t){return new ye(e,t)}(a,t.geojsonVtOptions)}catch(s){return r(s)}this.loaded={};const l={};if(n){const r=e.getPerformanceMeasurement(i);r&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(r)))}r(null,l)}}))}reloadTile(e,t){const r=this.loaded;return r&&r[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,r){if(t.request)e.getJSON(t.request,r);else{if("string"!=typeof t.data)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return r(null,JSON.parse(t.data))}catch(e){return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class we{constructor(t){this.self=t,this.actor=new e.Actor(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.getProjection({name:"mercator"}),this.workerSourceTypes={vector:e.VectorTileWorkerSource,geojson:be},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.plugin.isParsed())throw new Error("RTL text plugin already registered.");e.plugin.applyArabicShaping=t.applyArabicShaping,e.plugin.processBidirectionalText=t.processBidirectionalText,e.plugin.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,r){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],r()}checkIfReady(e,t,r){r()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,r){this.isSpriteLoaded[t]=r;for(const i in this.workerSources[t]){const n=this.workerSources[t][i];for(const t in n)n[t]instanceof e.VectorTileWorkerSource&&(n[t].isSpriteLoaded=r,n[t].fire(new e.Event("isSpriteLoaded")))}}setImages(e,t,r){this.availableImages[e]=t;for(const r in this.workerSources[e]){const i=this.workerSources[e][r];for(const e in i)i[e].availableImages=t}r()}enableTerrain(e,t,r){this.terrain=t,r()}setProjection(t,r){this.projections[t]=e.getProjection(r)}setLayers(e,t,r){this.getLayerIndex(e).replace(t),r()}updateLayers(e,t,r){this.getLayerIndex(e).update(t.layers,t.removedIds),r()}loadTile(t,r,i){const n=this.enableTerrain?e.extend({enableTerrain:this.terrain},r):r;n.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,r.type,r.source).loadTile(n,i)}loadDEMTile(t,r,i){const n=this.enableTerrain?e.extend({buildQuadTree:this.terrain},r):r;this.getDEMWorkerSource(t,r.source).loadTile(n,i)}reloadTile(t,r,i){const n=this.enableTerrain?e.extend({enableTerrain:this.terrain},r):r;n.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,r.type,r.source).reloadTile(n,i)}abortTile(e,t,r){this.getWorkerSource(e,t.type,t.source).abortTile(t,r)}removeTile(e,t,r){this.getWorkerSource(e,t.type,t.source).removeTile(t,r)}removeSource(e,t,r){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const i=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==i.removeSource?i.removeSource(t,r):r()}loadWorkerSource(e,t,r){try{this.self.importScripts(t.url),r()}catch(e){r(e.toString())}}syncRTLPluginState(t,r,i){try{e.plugin.setState(r);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const r=e.plugin.isParsed();i(r?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),r)}}catch(e){i(e.toString())}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new i),t}getWorkerSource(e,t,r){return this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),this.workerSources[e][t][r]||(this.workerSources[e][t][r]=new this.workerSourceTypes[t]({send:(t,r,i,n,o,s)=>{this.actor.send(t,r,i,e,o,s)},scheduler:this.actor.scheduler},this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e])),this.workerSources[e][t][r]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}enforceCacheSizeLimit(t,r){e.enforceCacheSizeLimit(r)}getWorkerPerformanceMetrics(e,t,r){r(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new we(self)),we})),i(0,(function(e){function t(e,r){if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let i=0;i<e.length;i++)if(!t(e[i],r[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==r){if("object"!=typeof r)return!1;if(Object.keys(e).length!==Object.keys(r).length)return!1;for(const i in e)if(!t(e[i],r[i]))return!1;return!0}return e===r}var r=i;function i(e){return!function(e){return"undefined"==typeof window||"undefined"==typeof document?"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 e,t,r=new Blob([""],{type:"text/javascript"}),i=URL.createObjectURL(r);try{t=new Worker(i),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(i),e}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var r=t.getImageData(0,0,1,1);return r&&r.width===e.width}()?(void 0===n[t=e&&e.failIfMajorPerformanceCaveat]&&(n[t]=function(e){var t,r=function(e){var t=document.createElement("canvas"),r=Object.create(i.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=e,t.getContext("webgl",r)||t.getContext("experimental-webgl",r)}(e);if(!r)return!1;try{t=r.createShader(r.VERTEX_SHADER)}catch(e){return!1}return!(!t||r.isContextLost())&&(r.shaderSource(t,"void main() {}"),r.compileShader(t),!0===r.getShaderParameter(t,r.COMPILE_STATUS))}(t)),n[t]?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 t}(e)}var n={};function o(t,r,i){const n=e.window.document.createElement(t);return void 0!==r&&(n.className=r),i&&i.appendChild(n),n}function s(t,r,i){const n=e.window.document.createElementNS("http://www.w3.org/2000/svg",t);for(const e of Object.keys(r))n.setAttributeNS(null,e,r[e]);return i&&i.appendChild(n),n}i.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const a=e.window.document&&e.window.document.documentElement.style,l=a&&void 0!==a.userSelect?"userSelect":"WebkitUserSelect";let c;function u(){a&&l&&(c=a[l],a[l]="none")}function h(){a&&l&&(a[l]=c)}function p(t){t.preventDefault(),t.stopPropagation(),e.window.removeEventListener("click",p,!0)}function d(){e.window.addEventListener("click",p,!0),e.window.setTimeout((()=>{e.window.removeEventListener("click",p,!0)}),0)}function f(e,t){const r=e.getBoundingClientRect();return g(e,r,t)}function m(e,t){const r=e.getBoundingClientRect(),i=[];for(let n=0;n<t.length;n++)i.push(g(e,r,t[n]));return i}function _(t){return void 0!==e.window.InstallTrigger&&2===t.button&&t.ctrlKey&&e.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:t.button}function g(t,r,i){const n=t.offsetWidth===r.width?1:t.offsetWidth/r.width;return new e.pointGeometry((i.clientX-r.left)*n,(i.clientY-r.top)*n)}function y(e,t){var r=t[0],i=t[1],n=t[2],o=t[3],s=r*o-n*i;return s?(e[0]=o*(s=1/s),e[1]=-i*s,e[2]=-n*s,e[3]=r*s,e):null}function v(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class x extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[]}}hasImage(e){return!!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(t,r){let i=!0;return this._validateStretch(r.stretchX,r.data&&r.data.width)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(r.stretchY,r.data&&r.data.height)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(r.content,r)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let r=0;for(const i of e){if(i[0]<r||i[1]<i[0]||t<i[1])return!1;r=i[1]}return!0}_validateContent(e,t){return!(e&&(4!==e.length||e[0]<0||t.data.width<e[0]||e[1]<0||t.data.height<e[1]||e[2]<0||t.data.width<e[2]||e[3]<0||t.data.height<e[3]||e[2]<e[0]||e[3]<e[1]))}updateImage(e,t){t.version=this.images[e].version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){const t=this.images[e];delete this.images[e],delete this.patterns[e],t.userImage&&t.userImage.onRemove&&t.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e,t){let r=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(r=!1);this.isLoaded()||r?this._notify(e,t):this.requestors.push({ids:e,callback:t})}_notify(t,r){const i={};for(const r of t){this.images[r]||this.fire(new e.Event("styleimagemissing",{id:r}));const t=this.images[r];t?i[r]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.warnOnce(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}r(null,i)}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(t){const r=this.patterns[t],i=this.getImage(t);if(!i)return null;if(r&&r.position.version===i.version)return r.position;if(r)r.position.version=i.version;else{const r={w:i.data.width+2,h:i.data.height+2,x:0,y:0},n=new e.ImagePosition(r,i);this.patterns[t]={bin:r,position:n}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const r=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new e.Texture(t,this.atlasImage,r.RGBA),this.atlasTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:r,h:i}=e.potpack(t),n=this.atlasImage;n.resize({width:r||1,height:i||1});for(const t in this.patterns){const{bin:r}=this.patterns[t],i=r.x+1,o=r.y+1,s=this.images[t].data,a=s.width,l=s.height;e.RGBAImage.copy(s,n,{x:0,y:0},{x:i,y:o},{width:a,height:l}),e.RGBAImage.copy(s,n,{x:0,y:l-1},{x:i,y:o-1},{width:a,height:1}),e.RGBAImage.copy(s,n,{x:0,y:0},{x:i,y:o+l},{width:a,height:1}),e.RGBAImage.copy(s,n,{x:a-1,y:0},{x:i-1,y:o},{width:1,height:l}),e.RGBAImage.copy(s,n,{x:0,y:0},{x:i+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const t of e){if(this.callbackDispatchedThisFrame[t])continue;this.callbackDispatchedThisFrame[t]=!0;const e=this.images[t];v(e)&&this.updateImage(t,e)}}}const b=new e.Properties({anchor:new e.DataConstantProperty(e.spec.light.anchor),position:new class{constructor(){this.specification=e.spec.light.position}possiblyEvaluate(t,r){return function([t,r,i]){const n=e.degToRad(r+90),o=e.degToRad(i);return{x:t*Math.cos(n)*Math.sin(o),y:t*Math.sin(n)*Math.sin(o),z:t*Math.cos(o),azimuthal:r,polar:i}}(t.expression.evaluate(r))}interpolate(t,r,i){return{x:e.number(t.x,r.x,i),y:e.number(t.y,r.y,i),z:e.number(t.z,r.z,i),azimuthal:e.number(t.azimuthal,r.azimuthal,i),polar:e.number(t.polar,r.polar,i)}}},color:new e.DataConstantProperty(e.spec.light.color),intensity:new e.DataConstantProperty(e.spec.light.intensity)}),w="-transition";class T extends e.Evented{constructor(t){super(),this._transitionable=new e.Transitionable(b),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,r={}){if(!this._validate(e.validateLight,t,r))for(const r in t){const i=t[r];e.endsWith(r,w)?this._transitionable.setTransition(r.slice(0,-w.length),i):this._transitionable.setValue(r,i)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,r,i){return(!i||!1!==i.validate)&&e.emitValidationErrors(this,t.call(e.validateStyle,e.extend({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.spec})))}}const E=new e.Properties({source:new e.DataConstantProperty(e.spec.terrain.source),exaggeration:new e.DataConstantProperty(e.spec.terrain.exaggeration)}),S="-transition";class C extends e.Evented{constructor(t,r){super(),this._transitionable=new e.Transitionable(E),this.set(t),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=r}get(){return this._transitionable.serialize()}set(t){for(const r in t){const i=t[r];e.endsWith(r,S)?this._transitionable.setTransition(r.slice(0,-S.length),i):this._transitionable.setValue(r,i)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}}function A(t,r,i,n){const o=e.smoothstep(45,65,i),[s,a]=k(t,n),l=e.length(r);let c=1-Math.min(1,Math.exp((l-s)/(a-s)*-6));return c*=c*c,c=Math.min(1,1.00747*c),c*o*t.alpha}function k(e,t){const r=.5/Math.tan(.5*t);return[e.range[0]+r,e.range[1]+r]}const I=new e.Properties({range:new e.DataConstantProperty(e.spec.fog.range),color:new e.DataConstantProperty(e.spec.fog.color),"high-color":new e.DataConstantProperty(e.spec.fog["high-color"]),"space-color":new e.DataConstantProperty(e.spec.fog["space-color"]),"horizon-blend":new e.DataConstantProperty(e.spec.fog["horizon-blend"]),"star-intensity":new e.DataConstantProperty(e.spec.fog["star-intensity"])}),M="-transition";class z extends e.Evented{constructor(t,r){super(),this._transitionable=new e.Transitionable(I),this.set(t),this._transitioning=this._transitionable.untransitioned(),this._transform=r}get state(){const t=this._transform,r="globe"===t.projection.name,i=e.globeToMercatorTransition(t.zoom),n=this.properties.get("range"),o=[.5,3];return{range:r?[e.number(o[0],n[0],i),e.number(o[1],n[1],i)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,r={}){if(!this._validate(e.validateFog,t,r)){for(const r of Object.keys(e.spec.fog))t&&void 0===t[r]&&(t[r]=e.spec.fog[r].default);for(const r in t){const i=t[r];e.endsWith(r,M)?this._transitionable.setTransition(r.slice(0,-M.length),i):this._transitionable.setValue(r,i)}}}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const r=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.smoothstep(45,65,t))*r.a}getOpacityAtLatLng(t,r){return this._transform.projection.supportsFog?function(t,r,i){const n=e.MercatorCoordinate.fromLngLat(r),o=i.elevation?i.elevation.getAtPointOrZero(n):0,s=[n.x,n.y,o];return e.transformMat4(s,s,i.mercatorFogMatrix),A(t,s,i.pitch,i._fov)}(this.state,t,r):0}getFovAdjustedRange(e){return this._transform.projection.supportsFog?k(this.state,e):[0,1]}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,r,i){return(!i||!1!==i.validate)&&e.emitValidationErrors(this,t.call(e.validateStyle,e.extend({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.spec})))}}class P{constructor(t,r){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e.uniqueId();const i=this.workerPool.acquire(this.id);for(let e=0;e<i.length;e++){const t=new P.Actor(i[e],r,this.id);t.name=`Worker ${e}`,this.actors.push(t)}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0}))}broadcast(t,r,i){e.asyncAll(this.actors,((e,i)=>{e.send(t,r,i)}),i=i||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove()})),this.actors=[],this.workerPool.release(this.id)}}function D(t,r,i){return r*(e.EXTENT/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}P.Actor=e.Actor;class L{constructor(e,t,r,i){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=r,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i)}static createFromScreenPoints(t,r){let i,n;if(t instanceof e.pointGeometry||"number"==typeof t[0]){const o=e.pointGeometry.convert(t);i=[e.pointGeometry.convert(t)],n=r.isPointAboveHorizon(o)}else{const o=e.pointGeometry.convert(t[0]),s=e.pointGeometry.convert(t[1]);i=[o,s],n=e.polygonizeBounds(o,s).every((e=>r.isPointAboveHorizon(e)))}return new L(i,r.getCameraPoint(),n,r)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const r=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],n=e.polygonizeBounds(r,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>r.x&&this.cameraPoint.x<i.x?n.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?n[2]=this.cameraPoint:this.cameraPoint.x<=r.x&&(n[3]=this.cameraPoint)),e.bufferConvexPolygon(n,t)}bufferedCameraGeometryGlobe(t){const r=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],n=e.polygonizeBounds(r,i,t),o=this.cameraPoint.clone();switch(3*((o.y>r.y)+(o.y>i.y))+((o.x>r.x)+(o.x>i.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(t,r,i,n=0){const o=t.queryPadding/r._projectionScaler+1,s=i?this._bufferedCameraMercator(o,r):this._bufferedScreenMercator(o,r);let a=t.tileID.wrap+(s.unwrapped?n:0);const l=s.polygon.map((r=>e.getTilePoint(t.tileTransform,r,a)));if(!e.polygonIntersectsBox(l,0,0,e.EXTENT,e.EXTENT))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);const c=this.screenGeometryMercator.polygon.map((r=>e.getTileVec3(t.tileTransform,r,a))),u=c.map((t=>new e.pointGeometry(t[0],t[1]))),h=r.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),p=e.getTileVec3(t.tileTransform,h,a),d=c.map((t=>{const r=e.sub(t,t,p);return e.normalize(r,r),new e.Ray(p,r)})),f=D(t,1,r.zoom)*r._projectionScaler;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:d,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.getBounds(l),m.min.x=e.clamp(m.min.x,0,e.EXTENT),m.min.y=e.clamp(m.min.y,0,e.EXTENT),m.max.x=e.clamp(m.max.x,0,e.EXTENT),m.max.y=e.clamp(m.max.y,0,e.EXTENT),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const r=O(e);if(this._screenRaycastCache[r])return this._screenRaycastCache[r];{let i;return i="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[r]=i,i}}_bufferedCameraMercator(e,t){const r=O(e);if(this._cameraRaycastCache[r])return this._cameraRaycastCache[r];{let i;return i="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[r]=i,i}}_projectAndResample(t,r){const i=function(t,r){const i=e.multiply([],r.pixelMatrix,r.globeMatrix),n=[0,-e.GLOBE_RADIUS,0,1],o=[0,e.GLOBE_RADIUS,0,1],s=[0,0,0,1];e.transformMat4$1(n,n,i),e.transformMat4$1(o,o,i),e.transformMat4$1(s,s,i);const a=new e.pointGeometry(n[0]/n[3],n[1]/n[3]),l=new e.pointGeometry(o[0]/o[3],o[1]/o[3]),c=e.polygonContainsPoint(t,a)&&n[3]<s[3],u=e.polygonContainsPoint(t,l)&&o[3]<s[3];if(!c&&!u)return null;const h=function(e,t,r){for(let i=1;i<e.length;i++){const n=R(t.pointCoordinate3D(e[i-1]).x),o=R(t.pointCoordinate3D(e[i]).x);if(r<0){if(n<o)return{idx:i,t:-n/(o-1-n)}}else if(o<n)return{idx:i,t:(1-n)/(o+1-n)}}return null}(t,r,c?-1:1);if(!h)return null;const{idx:p,t:d}=h;let f=p>1?B(t.slice(0,p),r):[],m=p<t.length?B(t.slice(p),r):[];f=f.map((t=>new e.pointGeometry(R(t.x),t.y))),m=m.map((t=>new e.pointGeometry(R(t.x),t.y)));const _=[...f];0===_.length&&_.push(m[m.length-1]);const g=e.number(_[_.length-1].y,(0===m.length?f[0]:m[0]).y,d);let y;return y=c?[new e.pointGeometry(0,g),new e.pointGeometry(0,0),new e.pointGeometry(1,0),new e.pointGeometry(1,g)]:[new e.pointGeometry(1,g),new e.pointGeometry(1,1),new e.pointGeometry(0,1),new e.pointGeometry(0,g)],_.push(...y),0===m.length?_.push(f[0]):_.push(...m),{polygon:_.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:!1}}(t,r);if(i)return i;const n=function(t,r){let i=!1,n=-1/0,o=0;for(let e=0;e<t.length-1;e++)t[e].x>n&&(n=t[e].x,o=e);for(let e=0;e<t.length-1;e++){const r=(o+e)%(t.length-1),n=t[r],s=t[r+1];Math.abs(n.x-s.x)>.5&&(n.x<s.x?(n.x+=1,0===r&&(t[t.length-1].x+=1)):(s.x+=1,r+1===t.length-1&&(t[0].x+=1)),i=!0)}const s=e.mercatorXfromLng(r.center.lng);return i&&s<Math.abs(s-1)&&t.forEach((e=>{e.x-=1})),{polygon:t,unwrapped:i}}(B(t,r).map((t=>new e.pointGeometry(R(t.x),t.y))),r);return{polygon:n.polygon.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:n.unwrapped}}}function B(t,r){return e.resample(t,(e=>{const t=r.pointCoordinate3D(e);e.x=t.x,e.y=t.y}),1/256)}function R(e){return e<0?1+e%1:e%1}function O(e){return 100*e|0}function F(t,r,i,n,o){const s=function(i,n){if(i)return o(i);if(n){const i=e.pick(e.extend(n,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);n.vector_layers&&(i.vectorLayers=n.vector_layers,i.vectorLayerIds=i.vectorLayers.map((e=>e.id))),n.language_options&&(i.languageOptions=n.language_options),n.language&&n.language[n.id]&&(i.language=n.language[n.id]),n.worldview_options&&(i.worldviewOptions=n.worldview_options),n.worldview?i.worldview=n.worldview[n.id]:n.worldview_default&&(i.worldview=n.worldview_default),i.tiles=r.canonicalizeTileset(i,t.url),o(null,i)}};return t.url?e.getJSON(r.transformRequest(r.normalizeSourceURL(t.url,null,i,n),e.ResourceType.Source),s):e.exported.frame((()=>s(null,t)))}class N{constructor(t,r,i){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=r||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const r=Math.pow(2,t.z),i=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*r),n=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*r),o=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*r),s=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*r);return t.x>=i&&t.x<o&&t.y>=n&&t.y<s}}class j{constructor(e,t,r){this.context=e;const i=e.gl;this.buffer=i.createBuffer(),this.dynamicDraw=Boolean(r),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const U={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class V{constructor(e,t,r,i){this.length=t.length,this.attributes=r,this.itemSize=t.bytesPerElement,this.dynamicDraw=i,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let r=0;r<this.attributes.length;r++){const i=t.attributes[this.attributes[r].name];void 0!==i&&e.enableVertexAttribArray(i)}}setVertexAttribPointers(e,t,r){for(let i=0;i<this.attributes.length;i++){const n=this.attributes[i],o=t.attributes[n.name];void 0!==o&&e.vertexAttribPointer(o,n.components,e[U[n.type]],!1,this.itemSize,n.offset+this.itemSize*(r||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class q{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class G extends q{getDefault(){return e.Color.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class $ extends q{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Z extends q{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class W extends q{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class H extends q{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class X extends q{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Y extends q{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class K extends q{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class J extends q{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class Q extends q{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class ee extends q{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class te extends q{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class re extends q{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class ie extends q{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class ne extends q{getDefault(){return e.Color.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class oe extends q{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class se extends q{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class ae extends q{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class le extends q{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class ce extends q{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class ue extends q{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class he extends q{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class pe extends q{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class de extends q{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class fe extends q{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class me extends q{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class _e extends q{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class ge extends q{constructor(e){super(e),this.vao=e.extVertexArrayObject}getDefault(){return null}set(e){this.vao&&(e!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(e),this.current=e,this.dirty=!1)}}class ye extends q{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class ve extends q{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class xe extends q{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class be extends q{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class we extends be{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Te extends be{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Ee extends Te{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Se{constructor(e,t,r,i){this.context=e,this.width=t,this.height=r;const n=this.framebuffer=e.gl.createFramebuffer();this.colorAttachment=new we(e,n),i&&(this.depthAttachment=new Te(e,n))}destroy(){const e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class Ce{constructor(e){this.gl=e,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new G(this),this.clearDepth=new $(this),this.clearStencil=new Z(this),this.colorMask=new W(this),this.depthMask=new H(this),this.stencilMask=new X(this),this.stencilFunc=new Y(this),this.stencilOp=new K(this),this.stencilTest=new J(this),this.depthRange=new Q(this),this.depthTest=new ee(this),this.depthFunc=new te(this),this.blend=new re(this),this.blendFunc=new ie(this),this.blendColor=new ne(this),this.blendEquation=new oe(this),this.cullFace=new se(this),this.cullFaceSide=new ae(this),this.frontFace=new le(this),this.program=new ce(this),this.activeTexture=new ue(this),this.viewport=new he(this),this.bindFramebuffer=new pe(this),this.bindRenderbuffer=new de(this),this.bindTexture=new fe(this),this.bindVertexBuffer=new me(this),this.bindElementBuffer=new _e(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new ge(this),this.pixelStoreUnpack=new ye(this),this.pixelStoreUnpackPremultiplyAlpha=new ve(this),this.pixelStoreUnpackFlipY=new xe(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extTextureHalfFloat=e.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(e.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=e.getExtension("OES_standard_derivatives"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t){return new j(this,e,t)}createVertexBuffer(e,t,r){return new V(this,e,t,r)}createRenderbuffer(e,t,r){const i=this.gl,n=i.createRenderbuffer();return this.bindRenderbuffer.set(n),i.renderbufferStorage(i.RENDERBUFFER,e,t,r),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,r){return new Se(this,e,t,r)}clear({color:e,depth:t,stencil:r}){const i=this.gl;let n=0;e&&(n|=i.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(n|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==r&&(n|=i.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),i.clear(n)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(r){t(r.blendFunction,e.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(r.blendFunction),this.blendColor.set(r.blendColor)),this.colorMask.set(r.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class Ae extends e.Evented{constructor(t,r,i,n){super(),this.id=t,this.dispatcher=i,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.extend({type:"raster"},r),e.extend(this,e.pick(r,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=F(this._options,this.map._requestManager,null,null,((t,r)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):r&&(e.extend(this,r),r.bounds&&(this.tileBounds=new N(r.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(r.tiles),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return e.extend({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,r){const i=e.exported.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(n,e.ResourceType.Tile),((i,n,o,s)=>(delete t.request,t.aborted?(t.state="unloaded",r(null)):i?(t.state="errored",r(i)):n?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s}),t.setTexture(n,this.map.painter),t.state="loaded",e.cacheEntryPossiblyAdded(this.dispatcher),void r(null)):r(null))))}static loadTileData(e,t,r){e.setTexture(t,r)}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture)}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t()}hasTransition(){return!1}}let ke;function Ie(t,r,i,n,o,s,a,l){const c=[t,i,o,r,n,s,1,1,1],u=[a,l,1],h=e.adjoint([],c),[p,d,f]=e.transformMat3(u,u,e.transpose(h,h));return e.multiply$1(c,[p,0,0,0,d,0,0,0,f],c)}class Me extends e.Evented{constructor(e,t,r,i){super(),this.id=e,this.dispatcher=r,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(i),this.options=t}load(t,r){this._loaded=r||!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this.url=this.options.url,e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),((r,i)=>{if(this._loaded=!0,r)this.fire(new e.ErrorEvent(r));else if(i){const{HTMLImageElement:r}=e.window;this.image=i instanceof r?e.exported.getImageData(i):i,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const r=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let r=1/0,i=1/0,n=-1/0,o=-1/0;for(const e of t)r=Math.min(r,e.x),i=Math.min(i,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y);const s=Math.max(n-r,o-i),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new e.CanonicalTileID(a,Math.floor((r+n)/2*l),Math.floor((i+o)/2*l))}(r),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray)return;const r=e.tileTransform(this.tileID,this.map.transform.projection),[i,n,o,s]=this.coordinates.map((t=>{const i=r.projection.project(t[0],t[1]);return e.getTilePoint(r,i)._round()}));this.perspectiveTransform=function(t,r,i,n,o,s,a,l,c,u){const h=Ie(0,0,t,0,0,r,t,r),p=Ie(i,n,o,s,a,l,c,u);return e.multiply$1(p,e.adjoint(h,h),p),[p[6]/p[8]*t/e.EXTENT,p[7]/p[8]*r/e.EXTENT]}(this.width,this.height,i.x,i.y,n.x,n.y,s.x,s.y,o.x,o.y);const a=this._boundsArray=new e.StructArrayLayout4i8;a.emplaceBack(i.x,i.y,0,0),a.emplaceBack(n.x,n.y,e.EXTENT,0),a.emplaceBack(s.x,s.y,0,e.EXTENT),a.emplaceBack(o.x,o.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(a,e.boundsAttributes.members),this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,r=t.gl;this.texture?this.texture.update(this.image):(this.texture=new e.Texture(t,this.image,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE)),this._prepareData(t)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const ze={vector:class extends e.Evented{constructor(t,r,i,n){if(super(),this.id=t,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.extend(this,e.pick(r,["url","scheme","tileSize","promoteId"])),this._options=e.extend({type:"vector"},r),this._collectResourceTiming=r.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n),this._tileWorkers={},this._deduped=new e.DedupedRequest}load(t){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"}));const r=this.language||this.map._language,i=this.worldview||this.map._worldview;this._tileJSONRequest=F(this._options,this.map._requestManager,r,i,((n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code. Found: ${r}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new e.ErrorEvent(n))):o&&(e.extend(this,o),o.bounds&&(this.tileBounds=new N(o.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.cancel(),e(),this.load((()=>{const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles()}))}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e})),this}_setLanguage(e){return e===this.language||this.setSourceProperty((()=>{this.language=e})),this}_setWorldview(e){return e===this.worldview?this:this.worldviewOptions&&e&&!this.worldviewOptions[e]?(console.warn(`Vector tile source "${this.id}" does not support worldview "${e}".`),this):(this.setSourceProperty((()=>{this.worldview=e})),this)}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return e.extend({},this._options)}loadTile(t,r){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(i,e.ResourceType.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(n.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=r:t.request=t.actor.send("reloadTile",n,o.bind(this));else if(t.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);else{const r=e.loadVectorTile.call({deduped:this._deduped},n,((e,r)=>{e||!r?o.call(this,e):(n.data={cacheControl:r.cacheControl,expires:r.expires,rawData:r.rawData.slice(0)},t.actor&&t.actor.send("loadTile",n,o.bind(this),void 0,!0))}),!0);t.request={cancel:r}}function o(i,n){return delete t.request,t.aborted?r(null):i&&404!==i.status?r(i):(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),r(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id})}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:Ae,"raster-dem":class extends Ae{constructor(t,r,i,n){super(t,r,i,n),this.type="raster-dem",this.maxzoom=22,this._options=e.extend({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox"}loadTile(t,r){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(e,i){e&&(t.state="errored",r(e)),i&&(t.dem=i,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",r(null))}t.request=e.getImage(this.map._requestManager.transformRequest(i,e.ResourceType.Tile),function(i,o,s,a){if(delete t.request,t.aborted)t.state="unloaded",r(null);else if(i)t.state="errored",r(i);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:a});const r=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap&&(null==ke&&(ke=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.window.createImageBitmap),ke),i=1-(o.width-e.prevPowerOfTwo(o.width))/2;i<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=r?o:e.exported.getImageData(o,i),c={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:i};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",c,n.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const r=t.canonical,i=Math.pow(2,r.z),n=(r.x-1+i)%i,o=0===r.x?t.wrap-1:t.wrap,s=(r.x+1+i)%i,a=r.x+1===i?t.wrap+1:t.wrap,l={};return l[new e.OverscaledTileID(t.overscaledZ,o,r.z,n,r.y).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,r.z,s,r.y).key]={backfilled:!1},r.y>0&&(l[new e.OverscaledTileID(t.overscaledZ,o,r.z,n,r.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,r.z,s,r.y-1).key]={backfilled:!1}),r.y+1<i&&(l[new e.OverscaledTileID(t.overscaledZ,o,r.z,n,r.y+1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,r.z,r.x,r.y+1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,r.z,s,r.y+1).key]={backfilled:!1}),l}unloadTile(e){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded"}},geojson:class extends e.Evented{constructor(t,r,i,n){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=i.getActor(),this.setEventedParent(n),this._data=r.data,this._options=e.extend({},r),this._collectResourceTiming=r.collectResourceTiming,void 0!==r.maxzoom&&(this.maxzoom=r.maxzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId;const o=e.EXTENT/this.tileSize;this.workerOptions=e.extend({source:this.id,cluster:r.cluster||!1,geojsonVtOptions:{buffer:(void 0!==r.buffer?r.buffer:128)*o,tolerance:(void 0!==r.tolerance?r.tolerance:.375)*o,extent:e.EXTENT,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1},superclusterOptions:{maxZoom:void 0!==r.clusterMaxZoom?r.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,r.clusterMinPoints||2),extent:e.EXTENT,radius:(void 0!==r.clusterRadius?r.clusterRadius:50)*o,log:!1,generateId:r.generateId||!1},clusterProperties:r.clusterProperties,filter:r.filter},r.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id},t),this}getClusterLeaves(e,t,r,i){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:e,limit:t,offset:r},i),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.Event("dataloading",{dataType:"source"})),this._loaded=!1;const t=e.extend({},this.workerOptions),r=this._data;"string"==typeof r?(t.request=this.map._requestManager.transformRequest(e.exported.resolveURL(r),e.ResourceType.Source),t.request.collectResourceTiming=this._collectResourceTiming):t.data=JSON.stringify(r),this._pendingLoad=this.actor.send(`${this.type}.loadData`,t,((t,r)=>{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.ErrorEvent(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&r&&r.resourceTiming&&r.resourceTiming[this.id]&&(t.resourceTiming=r.resourceTiming[this.id]),this.fire(new e.Event("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,r){const i=t.actor?"reloadTile":"loadTile";t.actor=this.actor,t.request=this.actor.send(i,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((e,n)=>(delete t.request,t.unloadVectorData(),t.aborted?r(null):e?r(e):(t.loadVectorData(n,this.map.painter,"reloadTile"===i),r(null)))),void 0,"loadTile"===i)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Me{constructor(e,t,r,i){super(e,t,r,i),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const r of t.urls)this.urls.push(this.map._requestManager.transformRequest(r,e.ResourceType.Source).url);e.getVideo(this.urls,((t,r)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):r&&(this.video=r,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const r=this.video.seekable;t<r.start(0)||t>r.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,r=t.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Me,canvas:class extends Me{constructor(t,r,i,n){super(t,r,i,n),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.window.HTMLCanvasElement?this.options.canvas:e.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.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(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const r=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(r,this.canvas,r.gl.RGBA,{premultiply:!0}),this._prepareData(r)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.Evented{constructor(t,r,i,n){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=i,this._implementation=r,this.setEventedParent(n),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new N(this._implementation.bounds,this.minzoom,this.maxzoom)),r.update=this._update.bind(this),r.coveringTiles=this._coveringTiles.bind(this),e.extend(this,e.pick(r,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:r,z:i}=e.canonical;return this._implementation.hasTile({x:t,y:r,z:i})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,r){const{x:i,y:n,z:o}=t.tileID.canonical,s=new e.window.AbortController,a=this._implementation.loadTile({x:i,y:n,z:o},{signal:s.signal});if(!a)return this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",r(null);a.cancel=()=>s.abort(),t.request=a.then(function(i){return delete t.request,t.aborted?(t.state="unloaded",r(null)):i?function(t){return t instanceof e.window.ImageData||t instanceof e.window.ImageBitmap||t instanceof e.window.HTMLCanvasElement}(i)?(this.loadTileData(t,i),t.state="loaded",void r(null)):(t.state="errored",r(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",r(null))}.bind(this)).catch((e=>{20!==e.code&&(t.state="errored",r(e))}))}loadTileData(e,t){Ae.loadTileData(e,t,this._map.painter)}unloadTileData(e){Ae.unloadTileData(e,this._map.painter)}prepareTile(e){if(!this._implementation.prepareTile)return null;const{x:t,y:r,z:i}=e.tileID.canonical,n=this._implementation.prepareTile({x:t,y:r,z:i});return n?(this.loadTileData(e,n),e.state="loaded",n):null}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:r,z:i}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:r,z:i})}t()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_update(){this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Pe=function(t,r,i,n){const o=new ze[r.type](t,r,i,n);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.bindAll(["load","abort","unload","serialize","prepare"],o),o};function De(t,r){const i=e.identity([]);return e.scale(i,i,[.5*t.width,.5*-t.height,1]),e.translate(i,i,[1,-1,0]),e.multiply(i,i,t.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(i)}function Le(e,t,r,i,n,o,s,a=!1){const l=e.tilesIn(i,s,a);l.sort(Re);const c=[];for(const i of l)c.push({wrappedTileID:i.tile.tileID.wrapped().key,queryResults:i.tile.queryRenderedFeatures(t,r,e._state,i,n,o,De(e.transform,i.tile.tileID),a)});const u=function(e){const t={},r={};for(const i of e){const e=i.queryResults,n=i.wrappedTileID,o=r[n]=r[n]||{};for(const r in e){const i=e[r],n=o[r]=o[r]||{},s=t[r]=t[r]||[];for(const e of i)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return t}(c);for(const t in u)u[t].forEach((t=>{const r=t.feature,i=r.layer;i&&"background"!==i.type&&"sky"!==i.type&&(r.source=i.source,i["source-layer"]&&(r.sourceLayer=i["source-layer"]),r.state=void 0!==r.id?e.getFeatureState(i["source-layer"],r.id):{})}));return u}function Be(e,t){const r=e.getRenderableIds().map((t=>e.getTileByID(t))),i=[],n={};for(let e=0;e<r.length;e++){const o=r[e],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(i,t))}return i}function Re(e,t){const r=e.tileID,i=t.tileID;return r.overscaledZ-i.overscaledZ||r.canonical.y-i.canonical.y||r.wrap-i.wrap||r.canonical.x-i.canonical.x}function Oe(){return null!=ho.workerClass?new ho.workerClass:new e.window.Worker(ho.workerUrl)}const Fe="mapboxgl_preloaded_worker_pool";class Ne{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<Ne.workerCount;)this.workers.push(new Oe);return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],0===this.numActive()&&(this.workers.forEach((e=>{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Fe]}numActive(){return Object.keys(this.active).length}}let je;function Ue(){return je||(je=new Ne),je}function Ve(t,r){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return e.refProperties.forEach((e=>{e in r&&(i[e]=r[e])})),i}function qe(e){e=e.slice();const t=Object.create(null);for(let r=0;r<e.length;r++)t[e[r].id]=e[r];for(let r=0;r<e.length;r++)"ref"in e[r]&&(e[r]=Ve(e[r],t[e[r].ref]));return e}Ne.workerCount=2;const Ge={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function $e(e,t,r){r.push({command:Ge.addSource,args:[e,t[e]]})}function Ze(e,t,r){t.push({command:Ge.removeSource,args:[e]}),r[e]=!0}function We(e,t,r,i){Ze(e,r,i),$e(e,t,r)}function He(e,r,i){let n;for(n in e[i])if(e[i].hasOwnProperty(n)&&"data"!==n&&!t(e[i][n],r[i][n]))return!1;for(n in r[i])if(r[i].hasOwnProperty(n)&&"data"!==n&&!t(e[i][n],r[i][n]))return!1;return!0}function Xe(e,r,i,n,o,s){let a;for(a in r=r||{},e=e||{})e.hasOwnProperty(a)&&(t(e[a],r[a])||i.push({command:s,args:[n,a,r[a],o]}));for(a in r)r.hasOwnProperty(a)&&!e.hasOwnProperty(a)&&(t(e[a],r[a])||i.push({command:s,args:[n,a,r[a],o]}))}function Ye(e){return e.id}function Ke(e,t){return e[t.id]=t,e}class Je{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=e.clamp(t,0,1);let r=1,i=this._distances[r];const n=t*this.paddedLength+this.padding;for(;i<n&&r<this._distances.length;)i=this._distances[++r];const o=r-1,s=this._distances[o],a=i-s,l=a>0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[r].mult(l))}}class Qe{constructor(e,t,r){const i=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/r),this.yCellCount=Math.ceil(t/r);for(let e=0;e<this.xCellCount*this.yCellCount;e++)i.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,r,i,n){this._forEachCell(t,r,i,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(n)}insertCircle(e,t,r,i){this._forEachCell(t-i,r-i,t+i,r+i,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(r),this.circles.push(i)}_insertBoxCell(e,t,r,i,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,t,r,i,n,o){this.circleCells[n].push(o)}_query(e,t,r,i,n,o){if(r<0||e>this.width||i<0||t>this.height)return!n&&[];const s=[];if(e<=0&&t<=0&&this.width<=r&&this.height<=i){if(n)return!0;for(let e=0;e<this.boxKeys.length;e++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],r=this.circles[3*e+1],i=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-i,y1:r-i,x2:t+i,y2:r+i})}return o?s.filter(o):s}return this._forEachCell(e,t,r,i,this._queryCell,s,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?s.length>0:s}_queryCircle(e,t,r,i,n){const o=e-r,s=e+r,a=t-r,l=t+r;if(s<0||o>this.width||l<0||a>this.height)return!i&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:i,circle:{x:e,y:t,radius:r},seenUids:{box:{},circle:{}}},n),i?c.length>0:c}query(e,t,r,i,n){return this._query(e,t,r,i,!1,n)}hitTest(e,t,r,i,n){return this._query(e,t,r,i,!0,n)}hitTestCircle(e,t,r,i){return this._queryCircle(e,t,r,!0,i)}_queryCell(e,t,r,i,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=n[c+2]&&t<=n[c+3]&&r>=n[c+0]&&i>=n[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const u=this.circleCells[n];if(null!==u){const n=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],e,t,r,i)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[u],t=n[u+1],r=n[u+2];o.push({key:this.circleKeys[c],x1:e-r,y1:t-r,x2:e+r,y2:t+r})}}}}}_queryCellCircle(e,t,r,i,n,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[n];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const r=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[r+0],e[r+1],e[r+2],e[r+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[n];if(null!==h){const e=this.circles;for(const t of h)if(!c.circle[t]){c.circle[t]=!0;const r=3*t;if(this._circlesCollide(e[r],e[r+1],e[r+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,r,i,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(r),h=this._convertToYCellCoord(i);for(let p=l;p<=u;p++)for(let l=c;l<=h;l++)if(n.call(this,e,t,r,i,this.xCellCount*l+p,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,r,i,n,o){const s=i-e,a=n-t,l=r+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,r,i,n,o,s){const a=(o-i)/2,l=Math.abs(e-(i+a));if(l>a+r)return!1;const c=(s-n)/2,u=Math.abs(t-(n+c));if(u>c+r)return!1;if(l<=a||u<=c)return!0;const h=l-a,p=u-c;return h*h+p*p<=r*r}}const et=Math.tan(85*Math.PI/180);function tt(t,r,i,n,o,s,a){const l=e.create();if(i)if("globe"===s.name){const t=e.calculateGlobeLabelMatrix(o,r);e.multiply(l,l,t)}else{const t=y([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],n||e.rotateZ(l,l,o.angle)}else e.multiply(l,o.labelPlaneMatrix,t);return l}function rt(e,t,r,i,n,o,s){const a=tt(e,t,r,i,n,o,s);return"globe"===o.name&&r||(a[2]=a[6]=a[10]=a[14]=0),a}function it(t,r,i,n,o,s,a){if(i){if("globe"===s.name){const l=tt(t,r,i,n,o,s,a);return e.invert(l,l),e.multiply(l,t,l),l}{const r=e.clone(t),i=e.identity([]);return i[0]=a[0],i[1]=a[1],i[4]=a[2],i[5]=a[3],e.multiply(r,r,i),n||e.rotateZ(r,r,-o.angle),r}}return o.glCoordMatrix}function nt(t,r,i=0){const n=[t.x,t.y,i,1];i?e.transformMat4$1(n,n,r):gt(n,n,r);const o=n[3];return{point:[n[0]/o,n[1]/o,n[2]/o],signedDistanceFromCamera:o}}function ot(t,r){const i=[t[0],t[1],t[2],1];e.transformMat4$1(i,i,r);const n=i[3];return{point:[i[0]/n,i[1]/n,i[2]/n],signedDistanceFromCamera:n}}function st(e,t){return Math.min(.5+e/t*.5,1.5)}function at(e,t){const r=e[0]/e[3],i=e[1]/e[3];return r>=-t[0]&&r<=t[0]&&i>=-t[1]&&i<=t[1]}function lt(t,r,i,n,o,s,a,l,c,u){const h=i.transform,p=n?t.textSizeData:t.iconSizeData,d=e.evaluateSizeForZoom(p,i.transform.zoom),f="globe"===h.projection.name,m=[256/i.width*2+1,256/i.height*2+1],_=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let g=null;f&&(g=n?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=i.transform.width/i.transform.height;let b=!1;for(let n=0;n<v.length;n++){const f=v.get(n);if(f.writingMode!==e.WritingMode.vertical||b||0!==n&&v.get(n-1).writingMode===e.WritingMode.horizontal||(b=!0),(f.hidden||f.writingMode===e.WritingMode.vertical)&&!b){_t(f.numGlyphs,_);continue}b=!1;const w=new e.pointGeometry(f.tileAnchorX,f.tileAnchorY),T=c?c(w):[0,0,0],E=h.projection.projectTilePoint(w.x,w.y,u.canonical),S=[E.x+T[0],E.y+T[1],E.z+T[2]],C=[...S,1];if(e.transformMat4$1(C,C,r),!at(C,m)){_t(f.numGlyphs,_);continue}const A=st(i.transform.cameraToCenterDistance,C[3]),k=e.evaluateSizeForFeature(p,d,f),I=a?k/A:k*A,M=nt(new e.pointGeometry(S[0],S[1]),o,S[2]);if(M.signedDistanceFromCamera<=0){_t(f.numGlyphs,_);continue}let z={};const P=a?null:c,D=ht(f,I,!1,l,r,o,s,t.glyphOffsetArray,y,_,g,M.point,w,z,x,P,h.projection,u,a);b=D.useVertical,P&&D.needsFlipping&&(z={}),(D.notEnoughRoom||b||D.needsFlipping&&ht(f,I,!0,l,r,o,s,t.glyphOffsetArray,y,_,g,M.point,w,z,x,P,h.projection,u,a).notEnoughRoom)&&_t(f.numGlyphs,_)}n?(t.text.dynamicLayoutVertexBuffer.updateData(_),g&&t.text.globeExtVertexBuffer.updateData(g)):(t.icon.dynamicLayoutVertexBuffer.updateData(_),g&&t.icon.globeExtVertexBuffer.updateData(g))}function ct(e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m){const _=a.glyphStartIndex+a.numGlyphs,g=a.lineStartIndex,y=a.lineStartIndex+a.lineLength,v=t.getoffsetX(a.glyphStartIndex),x=t.getoffsetX(_-1),b=ft(e*v,r,i,n,o,s,a.segment,g,y,l,c,u,h,p,!0,d,f,m);if(!b)return null;const w=ft(e*x,r,i,n,o,s,a.segment,g,y,l,c,u,h,p,!0,d,f,m);return w?{first:b,last:w}:null}function ut(t,r,i,n){return t.writingMode===e.WritingMode.horizontal&&Math.abs(i.y-r.y)>Math.abs(i.x-r.x)*n?{useVertical:!0}:t.writingMode===e.WritingMode.vertical?r.y<i.y?{needsFlipping:!0}:null:0!==t.flipState&&function(e,t,r){const i=(t.x-e.x)*r;return 0===i||Math.abs((t.y-e.y)/i)>et}(r,i,n)?1===t.flipState?{needsFlipping:!0}:null:r.x>i.x?{needsFlipping:!0}:null}function ht(t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y,v){const x=r/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x;let T;if(t.numGlyphs>1){const r=t.glyphStartIndex+t.numGlyphs,o=t.lineStartIndex,u=t.lineStartIndex+t.lineLength,h=ct(x,l,b,w,i,p,d,t,c,s,f,_,!1,g,y,v);if(!h)return{notEnoughRoom:!0};const E=ot(h.first.point,a).point,S=ot(h.last.point,a).point,C=new e.pointGeometry(E[0],E[1]),A=new e.pointGeometry(S[0],S[1]);if(n&&!i){const e=ut(t,C,A,m);if(t.flipState=e&&e.needsFlipping?1:2,e)return e}T=[h.first];for(let e=t.glyphStartIndex+1;e<r-1;e++)T.push(ft(x*l.getoffsetX(e),b,w,i,p,d,t.segment,o,u,c,s,f,_,!1,!1,g,y,v));T.push(h.last)}else{if(n&&!i){const r=nt(d,o).point,i=t.lineStartIndex+t.segment+1,n=new e.pointGeometry(c.getx(i),c.gety(i)),s=nt(n,o),a=s.signedDistanceFromCamera>0?s.point:dt(d,n,r,1,o,void 0,g,y.canonical),l=ut(t,new e.pointGeometry(r[0],r[1]),new e.pointGeometry(a[0],a[1]),m);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const r=ft(x*l.getoffsetX(t.glyphStartIndex),b,w,i,p,d,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,c,s,f,_,!1,!1,g,y,v);if(!r)return{notEnoughRoom:!0};T=[r]}if(h)for(const t of T)e.updateGlobeVertexNormal(h,u.length+0,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,u.length+1,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,u.length+2,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,u.length+3,t.up[0],t.up[1],t.up[2]),e.addDynamicAttributes(u,t.point[0],t.point[1],t.point[2],t.angle);else for(const t of T)e.addDynamicAttributes(u,t.point[0],t.point[1],t.point[2],t.angle);return{}}function pt(t,r,i,n,o){const s=n.projectTilePoint(t.x,t.y,r);if(!o)return nt(s,i,s.z);const a=o(t);return nt(new e.pointGeometry(s.x+a[0],s.y+a[1]),i,s.z+a[2])}function dt(t,r,i,n,o,s,a,l){const c=pt(t.add(t.sub(r)._unit()),l,o,a,s).point,u=e.sub([],i,c);return e.scaleAndAdd([],i,u,n/e.length(u))}function ft(t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g,y){const v=n?t-r:t+r;let x=v>0?1:-1,b=0;n&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=x>0?l+a:l+a+1,T=o,E=o,S=0,C=0;const A=Math.abs(v),k=[],I=[];let M=s;const z=()=>{const t=w-x;return 0===S?s:new e.pointGeometry(u.getx(t),u.gety(t))},P=()=>dt(z(),M,E,A-S+1,h,d,_,g.canonical);for(;S+C<=A;){if(w+=x,w<l||w>=c)return null;if(E=T,k.push(T),f&&I.push(M||z()),T=p[w],void 0===T){M=new e.pointGeometry(u.getx(w),u.gety(w));const t=pt(M,g.canonical,h,_,d);T=t.signedDistanceFromCamera>0?p[w]=t.point:P()}else M=null;S+=C,C=e.distance(E,T)}M=M||new e.pointGeometry(u.getx(w),u.gety(w));const D=z();m&&d&&(p[w]=T=void 0===p[w]?T:P(),C=e.distance(E,T));const L=(A-S)/C,B=M.sub(D).mult(L)._add(D),R=e.sub([],T,E),O=e.scaleAndAdd([],E,R,L);let F=[0,0,1],N=R[0],j=R[1];if(y&&(F=_.upVector(g.canonical,B.x,B.y),0!==F[0]||0!==F[1]||1!==F[2])){const t=[1,0,0],r=[0,1,0];t[0]=F[2],t[1]=0,t[2]=-F[0],e.cross(r,F,t),e.normalize(t,t),e.normalize(r,r),N=e.dot(R,t),j=e.dot(R,r)}if(i){const t=e.cross([],F,R);e.normalize(t,t),e.scaleAndAdd(O,O,t,i*x)}const U=b+Math.atan2(j,N);return k.push(O),f&&I.push(B),{point:O,angle:U,path:k,tilePath:I,up:F}}const mt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function _t(e,t){for(let r=0;r<e;r++){const e=t.length;t.resize(e+4),t.float32.set(mt,4*e)}}function gt(e,t,r){const i=t[0],n=t[1];return e[0]=r[0]*i+r[4]*n+r[12],e[1]=r[1]*i+r[5]*n+r[13],e[3]=r[3]*i+r[7]*n+r[15],e}const yt=100;class vt{constructor(e,t,r=new Qe(e.width+200,e.height+200,25),i=new Qe(e.width+200,e.height+200,25)){this.transform=e,this.grid=r,this.ignoredGrid=i,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+yt,this.screenBottomBoundary=e.height+yt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,r,i,n,o,s,a){let l=r.projectedAnchorX,c=r.projectedAnchorY,u=r.projectedAnchorZ;const h=r.elevation,p=r.tileID;if(h&&p){const t=e.getProjection().upVector(p.canonical,r.tileAnchorX,r.tileAnchorY),i=e.getProjection().upVectorScale(p.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=t[0]*h*i,c+=t[1]*h*i,u+=t[2]*h*i}const d=this.projectAndGetPerspectiveRatio(s,[l,c,u],r.tileID,"globe"===e.projection.name||!!h||this.transform.pitch>0,e.getProjection()),f=o*d.perspectiveRatio,m=(r.x1*t+i.x-r.padding)*f+d.point.x,_=(r.y1*t+i.y-r.padding)*f+d.point.y,g=(r.x2*t+i.x+r.padding)*f+d.point.x,y=(r.y2*t+i.y+r.padding)*f+d.point.y,v=d.perspectiveRatio<=.55||d.occluded;return!this.isInsideGrid(m,_,g,y)||!n&&this.grid.hitTest(m,_,g,y,a)||v?{box:[],offscreen:!1,occluded:d.occluded}:{box:[m,_,g,y],offscreen:this.isOffscreen(m,_,g,y),occluded:!1}}placeCollisionCircles(t,r,i,n,o,s,a,l,c,u,h,p,d,f,m){const _=[],g=this.transform.elevation,y=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,t.getProjection()):e=>[0,0,0],v=new e.pointGeometry(i.tileAnchorX,i.tileAnchorY),x=t.getProjection().projectTilePoint(i.tileAnchorX,i.tileAnchorY,m.canonical),b=y(v),w=[x.x+b[0],x.y+b[1],x.z+b[2]],T="globe"===t.projection.name,E=this.projectAndGetPerspectiveRatio(a,[w[0],w[1],w[2]],m,T||!!g||this.transform.pitch>0,t.getProjection()),{perspectiveRatio:S}=E,C=(h?s/S:s*S)/e.ONE_EM,A=nt(new e.pointGeometry(w[0],w[1]),l,w[2]).point,k=E.signedDistanceFromCamera>0?ct(C,o,i.lineOffsetX*C,i.lineOffsetY*C,!1,A,v,i,n,l,{},g&&!h?y:null,h&&!!g,t.getProjection(),m,h):null;let I=!1,M=!1,z=!0;if(k&&!E.occluded){const t=.5*d*S+f,i=new e.pointGeometry(-100,-100),n=new e.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),o=new Je,s=k.first,a=k.last;let l=[];for(let e=s.path.length-1;e>=1;e--)l.push(s.path[e]);for(let e=1;e<a.path.length;e++)l.push(a.path[e]);const h=2.5*t;if(c){const e=l.map(g&&!T?(e,t)=>{const r=y(t<s.path.length-1?s.tilePath[s.path.length-1-t]:a.tilePath[t-s.path.length+2]);return e[2]=r[2],ot(e,c)}:e=>ot(e,c));l=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point))}let m=[];if(l.length>0){const t=l.map((t=>new e.pointGeometry(t[0],t[1])));let r=1/0,o=-1/0,s=1/0,a=-1/0;for(let e=0;e<t.length;e++)r=Math.min(r,t[e].x),s=Math.min(s,t[e].y),o=Math.max(o,t[e].x),a=Math.max(a,t[e].y);m=r>=i.x&&o<=n.x&&s>=i.y&&a<=n.y?[t]:o<i.x||r>n.x||a<i.y||s>n.y?[]:e.clipLine([t],i.x,i.y,n.x,n.y)}for(const e of m){o.reset(e,.25*t);let i=0;i=o.length<=.5*t?1:Math.ceil(o.paddedLength/h)+1;for(let e=0;e<i;e++){const n=e/Math.max(i-1,1),s=o.lerp(n),a=s.x+yt,l=s.y+yt;_.push(a,l,t,0);const c=a-t,h=l-t,d=a+t,f=l+t;if(z=z&&this.isOffscreen(c,h,d,f),M=M||this.isInsideGrid(c,h,d,f),!r&&this.grid.hitTestCircle(a,l,t,p)&&(I=!0,!u))return{circles:[],offscreen:!1,collisionDetected:I,occluded:!1}}}}return{circles:!u&&I||!M?[]:_,offscreen:z,collisionDetected:I,occluded:E.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const r=[];let i=1/0,n=1/0,o=-1/0,s=-1/0;for(const a of t){const t=new e.pointGeometry(a.x+yt,a.y+yt);i=Math.min(i,t.x),n=Math.min(n,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y),r.push(t)}const a=this.grid.query(i,n,o,s).concat(this.ignoredGrid.query(i,n,o,s)),l={},c={};for(const t of a){const i=t.key;if(void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]={}),l[i.bucketInstanceId][i.featureIndex])continue;const n=[new e.pointGeometry(t.x1,t.y1),new e.pointGeometry(t.x2,t.y1),new e.pointGeometry(t.x2,t.y2),new e.pointGeometry(t.x1,t.y2)];e.polygonIntersectsPolygon(r,n)&&(l[i.bucketInstanceId][i.featureIndex]=!0,void 0===c[i.bucketInstanceId]&&(c[i.bucketInstanceId]=[]),c[i.bucketInstanceId].push(i.featureIndex))}return c}insertCollisionBox(e,t,r,i,n){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:i,collisionGroupID:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,r,i,n){const o=t?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:i,collisionGroupID:n};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(t,r,i,n,o){const s=[r[0],r[1],r[2],1];let a=!1;if(r[2]||this.transform.pitch>0){e.transformMat4$1(s,s,t);const n="globe"===o.name;this.fogState&&i&&!n&&(a=function(t,r,i,n,o,s){const a=s.calculateFogTileMatrix(o),l=[r,i,n];return e.transformMat4(l,l,a),A(t,l,s.pitch,s._fov)}(this.fogState,r[0],r[1],r[2],i.toUnwrapped(),this.transform)>.9)}else gt(s,s,t);return{point:new e.pointGeometry((s[0]/s[3]+1)/2*this.transform.width+yt,(-s[1]/s[3]+1)/2*this.transform.height+yt),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(o)/s[3]*.5,1.5),signedDistanceFromCamera:s[3],occluded:n&&s[2]>s[3]||a}}isOffscreen(e,t,r,i){return r<yt||e>=this.screenRightBoundary||i<yt||t>this.screenBottomBoundary}isInsideGrid(e,t,r,i){return r>=0&&e<this.gridRightBoundary&&i>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const t=e.identity([]);return e.translate(t,t,[-100,-100,0]),t}}function xt(t,r,i){const n=r.createTileMatrix(t,t.worldSize,i.toUnwrapped());return e.multiply(new Float32Array(16),t.projMatrix,n)}function bt(e,t,r){if(t.projection.name===r.projection.name)return e.projMatrix;const i=r.clone();return i.setProjection(t.projection),xt(i,t.getProjection(),e)}function wt(e,t,r){return t.name===r.projection.name?e.projMatrix:xt(r,t,e)}class Tt{constructor(e,t,r,i){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):i&&r?1:0,this.placed=r}isHidden(){return 0===this.opacity&&!this.placed}}class Et{constructor(e,t,r,i,n,o=!1){this.text=new Tt(e?e.text:null,t,r,n),this.icon=new Tt(e?e.icon:null,t,i,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class St{constructor(e,t,r,i=!1){this.text=e,this.icon=t,this.skipFade=r,this.clipped=i}}class Ct{constructor(){this.invProjMatrix=e.create(),this.viewportMatrix=e.create(),this.circles=[]}}class At{constructor(e,t,r,i,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=r,this.bucketIndex=i,this.tileID=n}}class kt{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function It(t,r,i,n,o){const{horizontalAlign:s,verticalAlign:a}=e.getAnchorAlignment(t),l=-(s-.5)*r,c=-(a-.5)*i,u=e.evaluateVariableOffset(t,n);return new e.pointGeometry(l+u[0]*o,c+u[1]*o)}function Mt(t,r,i,n,o){const s=new e.pointGeometry(t,r);return i&&s._rotate(n?o:-o),s}class zt{constructor(e,t,r,i,n){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new vt(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new kt(r),this.collisionCircleArrays={},this.prevPlacement=i,i&&(i.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,r,i,n){const o=i.getBucket(r),s=i.latestFeatureIndex;if(!o||!s||r.id!==o.layerIds[0])return;const a=o.layers[0].layout,l=i.collisionBoxArray,c=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),u=i.tileSize/e.EXTENT,h=i.tileID.toUnwrapped();this.transform.setProjection(o.projection);const p=(d=i.tileID,f=o.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):xt(m,f,d));var d,f,m;const _="map"===a.get("text-pitch-alignment"),g="map"===a.get("text-rotation-alignment");r.compileFilter();const y=r.dynamicFilter(),v=r.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(i),b=rt(p,i.tileID.canonical,_,g,this.transform,o.getProjection(),x);let w=null;if(_){const t=it(p,i.tileID.canonical,_,g,this.transform,o.getProjection(),x);w=e.multiply([],this.transform.labelPlaneMatrix,t)}let T=null;y&&i.latestFeatureIndex&&(T={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new At(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,i.tileID);const E={bucket:o,layout:a,posMatrix:p,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:u,holdingForFade:i.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const e of o.sortKeyRanges){const{sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:n}=e;t.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:n,parameters:E})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:E})}attemptAnchorPlacement(e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g){const y=[h.textOffset0,h.textOffset1],v=It(e,r,i,y,n),x=this.collisionIndex.placeCollisionBox(d,n,t,Mt(v.x,v.y,o,s,this.transform.angle),u,a,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d,d.getSymbolInstanceIconSize(g,this.transform.zoom,p),m,Mt(v.x,v.y,o,s,this.transform.angle),u,a,l,c.predicate).box.length)&&x.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(t=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:y,width:r,height:i,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(d,e,h,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,h),this.placedOrientations[h.crossTileID]=f),{shift:v,placedGlyphBoxes:x}}}placeLayerBucketPart(t,r,i,n){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=t.parameters,g=s.get("text-optional"),y=s.get("icon-optional"),v=s.get("text-allow-overlap"),x=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="none"!==s.get("icon-text-fit"),E="viewport-y"===s.get("symbol-z-order");this.transform.setProjection(o.projection);let S=v&&(x||!o.hasIconData()||y),C=x&&(v||!o.hasTextData()||g);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d),i&&n&&o.updateCollisionDebugBuffers(this.transform.zoom,d);const A=(t,n,d)=>{if(u){const i={zoom:this.transform.zoom,pitch:this.transform.pitch};let n=null;if(u.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];n=u.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(i,n,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.pointGeometry(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[t.crossTileID]=new St(!1,!1,!1,!0),void(r[t.crossTileID]=!0)}if(r[t.crossTileID])return;if(p)return void(this.placements[t.crossTileID]=new St(!1,!1,!1));let E=!1,A=!1,k=!0,I=!1,M=!1,z=null,P={box:null,offscreen:null,occluded:null},D={box:null,offscreen:null,occluded:null},L=null,B=null,R=null,O=0,F=0,N=0;d.textFeatureIndex?O=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(O=t.featureIndex),d.verticalTextFeatureIndex&&(F=d.verticalTextFeatureIndex);const j=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID,(this.transform.elevation||e.elevation)&&(e.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[o.bucketInstanceId].tileID,e.tileAnchorX,e.tileAnchorY):0)},U=d.textBox;if(U){j(U);const r=r=>{let i=e.WritingMode.horizontal;if(o.allowVerticalPlacement&&!r&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,i=e,this.markUsedOrientation(o,i,t))}return i},i=(r,i)=>{if(o.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const t of o.writingModes)if(t===e.WritingMode.vertical?(P=i(),D=P):P=r(),P&&P.box&&P.box.length)break}else P=r()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[t.crossTileID]){const e=this.prevPlacement.variableOffsets[t.crossTileID];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor))}const c=(e,r,i)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),c=(e.x2-e.x1)*s+2*e.padding,u=(e.y2-e.y1)*s+2*e.padding,p=T&&!x?r:null;p&&j(p);let d={box:[],offscreen:!1,occluded:!1};const g=v?2*l.length:l.length;for(let r=0;r<g;++r){const g=this.attemptAnchorPlacement(l[r%l.length],e,c,u,s,b,w,h,a,_,r>=l.length,t,n,o,i,p,f,m);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){E=!0,z=g.shift;break}}return d};i((()=>c(U,d.iconBox,e.WritingMode.horizontal)),(()=>{const r=d.verticalTextBox;return r&&j(r),o.allowVerticalPlacement&&!(P&&P.box&&P.box.length)&&t.numVerticalGlyphVertices>0&&r?c(r,d.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),P&&(E=P.box,k=P.offscreen,I=P.occluded);const u=r(P&&P.box);if(!E&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(o,e.anchor,t,u))}}else{const s=(r,i)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),l=this.collisionIndex.placeCollisionBox(o,s,r,new e.pointGeometry(0,0),v,h,a,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,i,t),this.placedOrientations[t.crossTileID]=i),l};i((()=>s(U,e.WritingMode.horizontal)),(()=>{const r=d.verticalTextBox;return o.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&r?(j(r),s(r,e.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),r(P&&P.box&&P.box.length)}}if(L=P,E=L&&L.box&&L.box.length>0,k=L&&L.offscreen,I=L&&L.occluded,t.useRuntimeCollisionCircles){const r=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),n=e.evaluateSizeForFeature(o.textSizeData,f,r),u=s.get("text-padding");B=this.collisionIndex.placeCollisionCircles(o,v,r,o.lineVertexArray,o.glyphOffsetArray,n,a,l,c,i,w,_.predicate,t.collisionCircleDiameter*n/e.ONE_EM,u,this.retainedQueryData[o.bucketInstanceId].tileID),E=v||B.circles.length>0&&!B.collisionDetected,k=k&&B.offscreen,I=B.occluded}if(d.iconFeatureIndex&&(N=d.iconFeatureIndex),d.iconBox){const t=t=>{j(t);const r=T&&z?Mt(z.x,z.y,b,w,this.transform.angle):new e.pointGeometry(0,0),i=o.getSymbolInstanceIconSize(m,this.transform.zoom,n);return this.collisionIndex.placeCollisionBox(o,i,t,r,x,h,a,_.predicate)};D&&D.box&&D.box.length&&d.verticalIconBox?(R=t(d.verticalIconBox),A=R.box.length>0):(R=t(d.iconBox),A=R.box.length>0),k=k&&R.offscreen,M=R.occluded}const V=g||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,q=y||0===t.numIconVertices;if(V||q?q?V||(A=A&&E):E=A&&E:A=E=A&&E,E&&L&&L.box&&this.collisionIndex.insertCollisionBox(L.box,s.get("text-ignore-placement"),o.bucketInstanceId,D&&D.box&&F?F:O,_.ID),A&&R&&this.collisionIndex.insertCollisionBox(R.box,s.get("icon-ignore-placement"),o.bucketInstanceId,N,_.ID),B&&(E&&this.collisionIndex.insertCollisionCircles(B.circles,s.get("text-ignore-placement"),o.bucketInstanceId,O,_.ID),i)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new Ct);for(let e=0;e<B.circles.length;e+=4)t.circles.push(B.circles[e+0]),t.circles.push(B.circles[e+1]),t.circles.push(B.circles[e+2]),t.circles.push(B.collisionDetected?1:0)}const G="globe"!==o.projection.name;S=S&&(G||!I),C=C&&(G||!M),this.placements[t.crossTileID]=new St(E||S,A||C,k||o.justReloaded),r[t.crossTileID]=!0};if(E){const e=o.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const r=e[t];A(o.symbolInstances.get(r),r,o.collisionArrays[r])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)A(o.symbolInstances.get(e),e,o.collisionArrays[e]);if(i&&o.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[o.bucketInstanceId];e.invert(t.invProjMatrix,a),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(t,r,i,n){let o;o=n===e.WritingMode.vertical?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[e.getAnchorJustification(r)];const s=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(const e of s)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=o>=0&&e!==o?0:i.crossTileID)}markUsedOrientation(t,r,i){const n=r===e.WritingMode.horizontal||r===e.WritingMode.horizontalOnly?r:0,o=r===e.WritingMode.vertical?r:0,s=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(const e of s)t.text.placedSymbolArray.get(e).placedOrientation=n;i.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let r=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const i=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new Et(o,i,t.text,t.icon,null,t.clipped),r=r||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Et(null,i,t.text,t.icon,t.skipFade,t.clipped),r=r||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new Et(t,i,!1,!1);n.isHidden()||(this.opacities[e]=n,r=r||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);r?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const r={};for(const i of t){const t=i.getBucket(e);t&&i.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r,i.collisionBoxArray)}}updateBucketOpacities(t,r,i){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const n=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),s=new Et(null,0,!1,!1,!0),a=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),c=n.get("text-variable-anchor"),u="map"===n.get("text-rotation-alignment"),h="map"===n.get("text-pitch-alignment"),p="none"!==n.get("icon-text-fit"),d=new Et(null,0,a&&(l||!t.hasIconData()||n.get("icon-optional")),l&&(a||!t.hasTextData()||n.get("text-optional")),!0);!t.collisionArrays&&i&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(i);const f=(e,t,r)=>{for(let i=0;i<t/4;i++)e.opacityVertexArray.emplaceBack(r)};let m=0;for(let i=0;i<t.symbolInstances.length;i++){const n=t.symbolInstances.get(i),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,crossTileID:_}=n;let g=this.opacities[_];r[_]?g=s:g||(g=d,this.opacities[_]=g),r[_]=!0;const y=a>0||l>0,v=n.numIconVertices>0,x=this.placedOrientations[n.crossTileID],b=x===e.WritingMode.vertical,w=x===e.WritingMode.horizontal||x===e.WritingMode.horizontalOnly;if(!y&&!v||g.isHidden()||m++,y){const e=jt(g.text);f(t.text,a,b?Ut:e),f(t.text,l,w?Ut:e);const r=g.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=r||b?1:0)})),n.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=r||w?1:0);const i=this.variableOffsets[n.crossTileID];i&&this.markUsedJustification(t,i.anchor,n,x);const o=this.placedOrientations[n.crossTileID];o&&(this.markUsedJustification(t,"left",n,o),this.markUsedOrientation(t,o,n))}if(v){const e=jt(g.icon);n.placedIconSymbolIndex>=0&&(f(t.icon,n.numIconVertices,b?Ut:e),t.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=g.icon.isHidden()),n.verticalPlacedIconSymbolIndex>=0&&(f(t.icon,n.numVerticalIconVertices,w?Ut:e),t.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const r=t.collisionArrays[i];if(r){let i=new e.pointGeometry(0,0),n=!0;if(r.textBox||r.verticalTextBox){if(c){const e=this.variableOffsets[_];e?(i=It(e.anchor,e.width,e.height,e.textOffset,e.textScale),u&&i._rotate(h?this.transform.angle:-this.transform.angle)):n=!1}o&&(n=!g.clipped),r.textBox&&Pt(t.textCollisionBox.collisionVertexArray,g.text.placed,!n||b,i.x,i.y),r.verticalTextBox&&Pt(t.textCollisionBox.collisionVertexArray,g.text.placed,!n||w,i.x,i.y)}const s=n&&Boolean(!w&&r.verticalIconBox);r.iconBox&&Pt(t.iconCollisionBox.collisionVertexArray,g.icon.placed,s,p?i.x:0,p?i.y:0),r.verticalIconBox&&Pt(t.iconCollisionBox.collisionVertexArray,g.icon.placed,!s,p?i.x:0,p?i.y:0)}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const r=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*r>e}setStale(){this.stale=!0}}function Pt(e,t,r,i,n){e.emplaceBack(t?1:0,r?1:0,i||0,n||0),e.emplaceBack(t?1:0,r?1:0,i||0,n||0),e.emplaceBack(t?1:0,r?1:0,i||0,n||0),e.emplaceBack(t?1:0,r?1:0,i||0,n||0)}const Dt=Math.pow(2,25),Lt=Math.pow(2,24),Bt=Math.pow(2,17),Rt=Math.pow(2,16),Ot=Math.pow(2,9),Ft=Math.pow(2,8),Nt=Math.pow(2,1);function jt(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,r=Math.floor(127*e.opacity);return r*Dt+t*Lt+r*Bt+t*Rt+r*Ot+t*Ft+r*Nt+t}const Ut=0;class Vt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,r,i,n){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,i,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<o.length;){const e=o[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,r,0===e.symbolInstanceStart),this._currentPartIndex++,n())return!0}return!1}}class qt{constructor(e,t,r,i,n,o,s,a){this.placement=new zt(e,n,o,s,a),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=i,this._done=!1}isDone(){return this._done}continuePlacement(t,r,i){const n=e.exported.now(),o=()=>{const t=e.exported.now()-n;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const e=r[t[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===e.type&&(!e.minzoom||e.minzoom<=n)&&(!e.maxzoom||e.maxzoom>n)){if(this._inProgressLayer||(this._inProgressLayer=new Vt(e)),this._inProgressLayer.continuePlacement(i[e.source],this.placement,this._showCollisionBoxes,e,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Gt=512/e.EXTENT/2;class $t{constructor(e,t,r){this.tileID=e,this.indexedSymbolInstances={},this.bucketInstanceId=r;for(let r=0;r<t.length;r++){const i=t.get(r),n=i.key;this.indexedSymbolInstances[n]||(this.indexedSymbolInstances[n]=[]),this.indexedSymbolInstances[n].push({crossTileID:i.crossTileID,coord:this.getScaledCoordinates(i,e)})}}getScaledCoordinates(t,r){const i=Gt/Math.pow(2,r.canonical.z-this.tileID.canonical.z);return{x:Math.floor((r.canonical.x*e.EXTENT+t.tileAnchorX)*i),y:Math.floor((r.canonical.y*e.EXTENT+t.tileAnchorY)*i)}}findMatches(e,t,r){const i=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z);for(let n=0;n<e.length;n++){const o=e.get(n);if(o.crossTileID)continue;const s=this.indexedSymbolInstances[o.key];if(!s)continue;const a=this.getScaledCoordinates(o,t);for(const e of s)if(Math.abs(e.coord.x-a.x)<=i&&Math.abs(e.coord.y-a.y)<=i&&!r[e.crossTileID]){r[e.crossTileID]=!0,o.crossTileID=e.crossTileID;break}}}}class Zt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Wt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const r=this.indexes[e],i={};for(const e in r){const n=r[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),i[n.tileID.key]=n}this.indexes[e]=i}this.lng=e}addBucket(e,t,r){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const i=this.usedCrossTileIDs[e.overscaledZ];for(const r in this.indexes){const n=this.indexes[r];if(Number(r)>e.overscaledZ)for(const r in n){const o=n[r];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,i)}else{const o=n[e.scaledTo(Number(r)).key];o&&o.findMatches(t.symbolInstances,e,i)}}for(let e=0;e<t.symbolInstances.length;e++){const n=t.symbolInstances.get(e);n.crossTileID||(n.crossTileID=r.generate(),i[n.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new $t(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const r in t.indexedSymbolInstances)for(const i of t.indexedSymbolInstances[r])delete this.usedCrossTileIDs[e][i.crossTileID]}removeStaleBuckets(e){let t=!1;for(const r in this.indexes){const i=this.indexes[r];for(const n in i)e[i[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(r,i[n]),delete i[n],t=!0)}return t}}class Ht{constructor(){this.layerIndexes={},this.crossTileIDs=new Zt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,r,i){let n=this.layerIndexes[e.id];void 0===n&&(n=this.layerIndexes[e.id]=new Wt);let o=!1;const s={};"globe"!==i.name&&n.handleWrapJump(r);for(const r of t){const t=r.getBucket(e);t&&e.id===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(r.tileID,t,this.crossTileIDs)&&(o=!0),s[t.bucketInstanceId]=!0)}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach((e=>{t[e]=!0}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Xt=(t,r)=>e.emitValidationErrors(t,r&&r.filter((e=>"source.canvas"!==e.identifier))),Yt=e.pick(Ge,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Kt=e.pick(Ge,["setCenter","setZoom","setBearing","setPitch"]),Jt={version:8,layers:[],sources:{}},Qt={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class er extends e.Evented{constructor(t,r={}){super(),this.map=t,this.dispatcher=new P(Ue(),this),this.imageManager=new x,this.imageManager.setEventedParent(this),this.glyphManager=new e.GlyphManager(t._requestManager,r.localFontFamily?e.LocalGlyphMode.all:r.localIdeographFontFamily?e.LocalGlyphMode.ideographs:e.LocalGlyphMode.none,r.localFontFamily||r.localIdeographFontFamily),this.lineAtlas=new e.LineAtlas(256,512),this.crossTileSymbolIndex=new Ht,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new e.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",e.getReferrer());const i=this;this._rtlTextPluginCallback=er.registerForPluginStateChange((t=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,r)=>{if(e.triggerPluginCompletionEvent(t),r&&r.every((e=>e)))for(const e in i._sourceCaches){const t=i._sourceCaches[e],r=t.getSource().type;"vector"!==r&&"geojson"!==r||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const r=this._layers[e];r.source===t.id&&this._validateLayer(r)}}))}loadURL(t,r={}){this.fire(new e.Event("dataloading",{dataType:"style"}));const i="boolean"==typeof r.validate?r.validate:!e.isMapboxURL(t);t=this.map._requestManager.normalizeStyleURL(t,r.accessToken);const n=this.map._requestManager.transformRequest(t,e.ResourceType.Style);this._request=e.getJSON(n,((t,r)=>{this._request=null,t?this.fire(new e.ErrorEvent(t)):r&&this._load(r,i)}))}loadJSON(t,r={}){this.fire(new e.Event("dataloading",{dataType:"style"})),this._request=e.exported.frame((()=>{this._request=null,this._load(t,!1!==r.validate)}))}loadEmpty(){this.fire(new e.Event("dataloading",{dataType:"style"})),this._load(Jt,!1)}_updateLayerCount(e,t){const r=t?1:-1;e.is3D()&&(this._num3DLayers+=r),"circle"===e.type&&(this._numCircleLayers+=r),"symbol"===e.type&&(this._numSymbolLayers+=r)}_load(t,r){if(r&&Xt(this,e.validateStyle(t)))return;this._loaded=!0,this.stylesheet=e.clone$1(t),this._updateMapProjection();for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);const i=qe(this.stylesheet.layers);this._order=i.map((e=>e.id)),this._layers={},this._serializedLayers={};for(let t of i)t=e.createStyleLayer(t),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize(),this._updateLayerCount(t,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new T(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 e.Event("data",{dataType:"style"})),this.fire(new e.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.map._explicitProjection||this.map._updateProjection()}_updateMapProjection(){this.map._explicitProjection?this.applyProjectionUpdate():this.map._updateProjection()}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))}_loadSprite(t){this._spriteRequest=function(t,r,i){let n,o,s;const a=e.exported.devicePixelRatio>1?"@2x":"";let l=e.getJSON(r.transformRequest(r.normalizeSpriteURL(t,a,".json"),e.ResourceType.SpriteJSON),((e,t)=>{l=null,s||(s=e,n=t,u())})),c=e.getImage(r.transformRequest(r.normalizeSpriteURL(t,a,".png"),e.ResourceType.SpriteImage),((e,t)=>{c=null,s||(s=e,o=t,u())}));function u(){if(s)i(s);else if(n&&o){const t=e.exported.getImageData(o),r={};for(const i in n){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:p,content:d}=n[i],f=new e.RGBAImage({width:o,height:s});e.RGBAImage.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),r[i]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:p,content:d}}i(null,r)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,((t,r)=>{if(this._spriteRequest=null,t)this.fire(new e.ErrorEvent(t));else if(r)for(const e in r)this.imageManager.addImage(e,r[e]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new e.Event("data",{dataType:"style"}))}))}_validateLayer(t){const r=this.getSource(t.source);if(!r)return;const i=t.sourceLayer;i&&("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(i))&&this.fire(new e.ErrorEvent(new Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(e){const t=[];for(const r of e){const e=this._layers[r];"custom"!==e.type&&t.push(e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&Qt[e.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const r=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),r=Object.keys(this._removedLayers);(e.length||r.length)&&this._updateWorkerLayers(e,r);for(const e in this._updatedSources){const t=this._updatedSources[e];"reload"===t?this._reloadSource(e):"clear"===t&&this._clearSource(e)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const i={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];i[e]=t.used,t.used=!1}for(const e of this._order){const r=this._layers[e];if(r.recalculate(t,this._availableImages),!r.isHidden(t.zoom)){const e=this._getLayerSourceCache(r);e&&(e.used=!0)}const i=this.map.painter;if(i){const e=r.getProgramIds();if(!e)continue;const n=r.getProgramConfiguration(t.zoom);for(const t of e)i.useProgram(t,n)}}for(const t in i){const r=this._sourceCaches[t];i[t]!==r.used&&r.getSource().fire(new e.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:r.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),r&&this.fire(new e.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(e),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),Xt(this,e.validateStyle(r)))return!1;(r=e.clone$1(r)).layers=qe(r.layers);const i=function(e,r){if(!e)return[{command:Ge.setStyle,args:[r]}];let i=[];try{if(!t(e.version,r.version))return[{command:Ge.setStyle,args:[r]}];t(e.center,r.center)||i.push({command:Ge.setCenter,args:[r.center]}),t(e.zoom,r.zoom)||i.push({command:Ge.setZoom,args:[r.zoom]}),t(e.bearing,r.bearing)||i.push({command:Ge.setBearing,args:[r.bearing]}),t(e.pitch,r.pitch)||i.push({command:Ge.setPitch,args:[r.pitch]}),t(e.sprite,r.sprite)||i.push({command:Ge.setSprite,args:[r.sprite]}),t(e.glyphs,r.glyphs)||i.push({command:Ge.setGlyphs,args:[r.glyphs]}),t(e.transition,r.transition)||i.push({command:Ge.setTransition,args:[r.transition]}),t(e.light,r.light)||i.push({command:Ge.setLight,args:[r.light]}),t(e.fog,r.fog)||i.push({command:Ge.setFog,args:[r.fog]}),t(e.projection,r.projection)||i.push({command:Ge.setProjection,args:[r.projection]});const n={},o=[];!function(e,r,i,n){let o;for(o in r=r||{},e=e||{})e.hasOwnProperty(o)&&(r.hasOwnProperty(o)||Ze(o,i,n));for(o in r)r.hasOwnProperty(o)&&(e.hasOwnProperty(o)?t(e[o],r[o])||("geojson"===e[o].type&&"geojson"===r[o].type&&He(e,r,o)?i.push({command:Ge.setGeoJSONSourceData,args:[o,r[o].data]}):We(o,r,i,n)):$e(o,r,i))}(e.sources,r.sources,o,n);const s=[];e.layers&&e.layers.forEach((e=>{e.source&&n[e.source]?i.push({command:Ge.removeLayer,args:[e.id]}):s.push(e)}));let a=e.terrain;a&&n[a.source]&&(i.push({command:Ge.setTerrain,args:[void 0]}),a=void 0),i=i.concat(o),t(a,r.terrain)||i.push({command:Ge.setTerrain,args:[r.terrain]}),function(e,r,i){r=r||[];const n=(e=e||[]).map(Ye),o=r.map(Ye),s=e.reduce(Ke,{}),a=r.reduce(Ke,{}),l=n.slice(),c=Object.create(null);let u,h,p,d,f,m,_;for(u=0,h=0;u<n.length;u++)p=n[u],a.hasOwnProperty(p)?h++:(i.push({command:Ge.removeLayer,args:[p]}),l.splice(l.indexOf(p,h),1));for(u=0,h=0;u<o.length;u++)p=o[o.length-1-u],l[l.length-1-u]!==p&&(s.hasOwnProperty(p)?(i.push({command:Ge.removeLayer,args:[p]}),l.splice(l.lastIndexOf(p,l.length-h),1)):h++,m=l[l.length-u],i.push({command:Ge.addLayer,args:[a[p],m]}),l.splice(l.length-u,0,p),c[p]=!0);for(u=0;u<o.length;u++)if(p=o[u],d=s[p],f=a[p],!c[p]&&!t(d,f))if(t(d.source,f.source)&&t(d["source-layer"],f["source-layer"])&&t(d.type,f.type)){for(_ in Xe(d.layout,f.layout,i,p,null,Ge.setLayoutProperty),Xe(d.paint,f.paint,i,p,null,Ge.setPaintProperty),t(d.filter,f.filter)||i.push({command:Ge.setFilter,args:[p,f.filter]}),t(d.minzoom,f.minzoom)&&t(d.maxzoom,f.maxzoom)||i.push({command:Ge.setLayerZoomRange,args:[p,f.minzoom,f.maxzoom]}),d)d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Xe(d[_],f[_],i,p,_.slice(6),Ge.setPaintProperty):t(d[_],f[_])||i.push({command:Ge.setLayerProperty,args:[p,_,f[_]]}));for(_ in f)f.hasOwnProperty(_)&&!d.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?Xe(d[_],f[_],i,p,_.slice(6),Ge.setPaintProperty):t(d[_],f[_])||i.push({command:Ge.setLayerProperty,args:[p,_,f[_]]}))}else i.push({command:Ge.removeLayer,args:[p]}),m=l[l.lastIndexOf(p)+1],i.push({command:Ge.addLayer,args:[f,m]})}(s,r.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:Ge.setStyle,args:[r]}]}return i}(this.serialize(),r).filter((e=>!(e.command in Kt)));if(0===i.length)return!1;const n=i.filter((e=>!(e.command in Yt)));if(n.length>0)throw new Error(`Unimplemented: ${n.map((e=>e.command)).join(", ")}.`);return i.forEach((e=>{"setTransition"!==e.command&&this[e.command].apply(this,e.args)})),this.stylesheet=r,this._updateMapProjection(),!0}addImage(t,r){return this.getImage(t)?this.fire(new e.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,r),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t),this):this.fire(new e.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new e.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,r,i={}){if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!r.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(r).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(e.validateSource,`sources.${t}`,r,null,i))return;this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);const n=Pe(t,r,this.dispatcher,this);n.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:n.serialize(),sourceId:t})));const o=r=>{const i=(r?"symbol:":"other:")+t,o=this._sourceCaches[i]=new e.SourceCache(i,n,r);(r?this._symbolSourceCaches:this._otherSourceCaches)[t]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==r.type&&"geojson"!==r.type||o(!0),n.onAdd&&n.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const r=this.getSource(t);if(!r)throw new Error("There is no source with this ID");for(const r in this._layers)if(this._layers[r].source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${r}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const i=this._getSourceCaches(t);for(const t of i)delete this._sourceCaches[t.id],delete this._updatedSources[t.id],t.fire(new e.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],r.setEventedParent(null),r.onRemove&&r.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}addLayer(t,r,i={}){this._checkLoaded();const n=t.id;if(this.getLayer(n))return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${n}" already exists on this map`)));let o;if("custom"===t.type){if(Xt(this,e.validateCustomStyleLayer(t)))return;o=e.createStyleLayer(t)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=e.clone$1(t),t=e.extend(t,{source:n})),this._validate(e.validateLayer,`layers.${n}`,t,{arrayIndex:-1},i))return;o=e.createStyleLayer(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const s=r?this._order.indexOf(r):this._order.length;if(r&&-1===s)return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${r}" does not exist on this map.`)));this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o;const a=this._getLayerSourceCache(o);if(this._removedLayers[n]&&o.source&&a&&"custom"!==o.type){const e=this._removedLayers[n];delete this._removedLayers[n],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(t,r){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===r)return;const i=this._order.indexOf(t);this._order.splice(i,1);const n=r?this._order.indexOf(r):this._order.length;r&&-1===n?this.fire(new e.ErrorEvent(new Error(`Layer with id "${r}" does not exist on this map.`))):(this._order.splice(n,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const r=this._layers[t];if(!r)return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));r.setEventedParent(null),this._updateLayerCount(r,!1);const i=this._order.indexOf(t);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=r,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],r.onRemove&&r.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(e){return this._layers[e]}hasLayer(e){return e in this._layers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(t,r,i){this._checkLoaded();const n=this.getLayer(t);n?n.minzoom===r&&n.maxzoom===i||(null!=r&&(n.minzoom=r),null!=i&&(n.maxzoom=i),this._updateLayer(n)):this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,i,n={}){this._checkLoaded();const o=this.getLayer(r);if(o){if(!t(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(e.validateFilter,`layers.${o.id}.filter`,i,{layerType:o.type},n)||(o.filter=e.clone$1(i),this._updateLayer(o)))}else this.fire(new e.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){const r=this.getLayer(t);return r&&e.clone$1(r.filter)}setLayoutProperty(r,i,n,o={}){this._checkLoaded();const s=this.getLayer(r);s?t(s.getLayoutProperty(i),n)||(s.setLayoutProperty(i,n,o),this._updateLayer(s)):this.fire(new e.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,r){const i=this.getLayer(t);if(i)return i.getLayoutProperty(r);this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(r,i,n,o={}){this._checkLoaded();const s=this.getLayer(r);s?t(s.getPaintProperty(i),n)||(s.setPaintProperty(i,n,o)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new e.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(e,t){const r=this.getLayer(e);return r&&r.getPaintProperty(t)}setFeatureState(t,r){this._checkLoaded();const i=t.source,n=t.sourceLayer,o=this.getSource(i);if(!o)return void this.fire(new e.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)));const s=o.type;if("geojson"===s&&n)return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(i);for(const e of a)e.setFeatureState(n,t.id,r)}removeFeatureState(t,r){this._checkLoaded();const i=t.source,n=this.getSource(i);if(!n)return void this.fire(new e.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)));const o=n.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(r&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(i);for(const e of a)e.removeFeatureState(s,t.id,r)}getFeatureState(t){this._checkLoaded();const r=t.source,i=t.sourceLayer,n=this.getSource(r);if(n){if("vector"!==n.type||i)return void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(r)[0].getFeatureState(i,t.id);this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)))}getTransition(){return e.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const t={};for(const e in this._sourceCaches){const r=this._sourceCaches[e].getSource();t[r.id]||(t[r.id]=r.serialize())}return e.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,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:t,layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(e){this._updatedLayers[e.id]=!0;const t=this._getLayerSourceCache(e);e.source&&!this._updatedSources[e.source]&&t&&"raster"!==t.getSource().type&&(this._updatedSources[e.source]="reload",t.pause()),this._changed=!0,e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,r={},i=[];for(let n=this._order.length-1;n>=0;n--){const o=this._order[n];if(t(o)){r[o]=n;for(const t of e){const e=t[o];if(e)for(const t of e)i.push(t)}}}i.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=i.length-1;e>=0;e--){const t=i[e].feature;if(r[t.layer.id]<o)break;n.push(t),i.pop()}else for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t.feature)}}return n}queryRenderedFeatures(t,r,i){r&&r.filter&&this._validate(e.validateFilter,"queryRenderedFeatures.filter",r.filter,null,r);const n={};if(r&&r.layers){if(!Array.isArray(r.layers))return this.fire(new e.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const t of r.layers){const r=this._layers[t];if(!r)return this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];n[r.source]=!0}}const o=[];r.availableImages=this._availableImages;const s=r&&r.layers?r.layers.some((e=>{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),a=L.createFromScreenPoints(t,i);for(const e in this._sourceCaches){const t=this._sourceCaches[e].getSource().id;r.layers&&!n[t]||o.push(Le(this._sourceCaches[e],this._layers,this._serializedLayers,a,r,i,s,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,r,i,n,o,s){const a={},l=o.queryRenderedSymbols(i),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(Re);for(const r of c){const i=r.featureIndex.lookupSymbolFeatures(l[r.bucketInstanceId],t,r.bucketIndex,r.sourceLayerIndex,n.filter,n.layers,n.availableImages,e);for(const e in i){const t=a[e]=a[e]||[],n=i[e];n.sort(((e,t)=>{const i=r.featureSortOrder;if(i){const r=i.indexOf(e.featureIndex);return i.indexOf(t.featureIndex)-r}return t.featureIndex-e.featureIndex}));for(const e of n)t.push(e)}}for(const t in a)a[t].forEach((i=>{const n=i.feature,o=r(e[t]).getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,r,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,r){r&&r.filter&&this._validate(e.validateFilter,"querySourceFeatures.filter",r.filter,null,r);const i=this._getSourceCaches(t);let n=[];for(const e of i)n=n.concat(Be(e,r));return n}addSourceType(e,t,r){return er.getSourceType(e)?r(new Error(`A source type called "${e}" already exists.`)):(er.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},r):r(null,null))}getLight(){return this.light.getLight()}setLight(e,r={}){this._checkLoaded();const i=this.light.getLight();let n=!1;for(const r in e)if(!t(e[r],i[r])){n=!0;break}if(!n)return;const o=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,r),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(r,i=1){if(this._checkLoaded(),!r)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===i){if("object"==typeof r.source){const t="terrain-dem-src";this.addSource(t,r.source),r=e.clone$1(r),r=e.extend(r,{source:t})}if(this._validate(e.validateTerrain,"terrain",r))return}if(!this.terrain||this.terrain&&i!==this.terrain.drapeRenderMode)this._createTerrain(r,i);else{const i=this.terrain,n=i.get();for(const t of Object.keys(e.spec.terrain))!r.hasOwnProperty(t)&&e.spec.terrain[t].default&&(r[t]=e.spec.terrain[t].default);for(const e in r)if(!t(r[e],n[e])){i.set(r),this.stylesheet.terrain=r;const e=this._setTransitionParameters({duration:0});i.updateTransitions(e);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new z(e,this.map.transform);this.stylesheet.fog=e;const r=this._setTransitionParameters({duration:0});t.updateTransitions(r)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const r=this.fog,i=r.get();0===Object.keys(e).length&&r.set(e);for(const n in e)if(!t(e[n],i[n])){r.set(e),this.stylesheet.fog=e;const t=this._setTransitionParameters({duration:0});r.updateTransitions(t);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(t){return{now:e.exported.now(),transition:e.extend(t,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const e=this._order.filter((e=>this.isLayerDraped(this._layers[e]))),t=this._order.filter((e=>!this.isLayerDraped(this._layers[e])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const r=this.terrain=new C(e,t);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const i=this._setTransitionParameters({duration:0});r.updateTransitions(i)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,r,i,n,o={}){return(!o||!1!==o.validate)&&Xt(this,t.call(e.validateStyle,e.extend({key:r,style:this.serialize(),value:i,styleSpec:e.spec},n)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles(),this._sourceCaches[e].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(e){const t=this._getSourceCaches(e);for(const e of t)e.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const e of t)e.resume(),e.reload()}_updateSources(e){for(const t in this._sourceCaches)this._sourceCaches[t].update(e)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,r,i,n,o=!1){let s=!1,a=!1;const l={};for(const e of this._order){const r=this._layers[e];if("symbol"!==r.type)continue;if(!l[r.source]){const e=this._getLayerSourceCache(r);if(!e)continue;l[r.source]=e.getRenderableIds(!0).map((t=>e.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const i=this.crossTileSymbolIndex.addLayer(r,l[r.source],t.center.lng,t.projection);s=s||i}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new e.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.exported.now(),t.zoom))&&(this.pauseablePlacement=new qt(t,this._order,o,r,i,n,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.exported.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.exported.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,t,r){this.imageManager.getImages(t.icons,r),this._updateTilesForChangedImages();const i=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};i(this._otherSourceCaches[t.source]),i(this._symbolSourceCaches[t.source])}getGlyphs(e,t,r){this.glyphManager.getGlyphs(t.stacks,r)}getResource(t,r,i){return e.makeRequest(r,i)}_getSourceCache(e){return this._otherSourceCaches[e]}_getLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}_getSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const r=this._getSourceCaches(t);return 0===r.length?(this.fire(new e.ErrorEvent(new Error(`There is no source with ID '${t}'`))),!1):r.every((e=>e.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)}}er.getSourceType=function(e){return ze[e]},er.setSourceType=function(e,t){ze[e]=t},er.registerForPluginStateChange=e.registerForPluginStateChange;var tr="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",rr="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;}";let ir={},nr={};ir=cr("","\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform 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) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat 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);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=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);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.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(\nunpack_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))\n);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) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat 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;\n#else\nvec4 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);\n#endif\nreturn 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;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),nr=cr("#ifdef FOG\nuniform 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(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float 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);}\n#endif","#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;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);}\n#endif",!0);const or=cr("\nhighp 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;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#endif","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}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(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const 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."),sr=tr,ar="\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif";var lr={background:cr("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:cr("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);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:cr("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);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(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-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) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 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(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);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:cr("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:cr("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute 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;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 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);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 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;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:cr("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;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","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:cr("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(\n0.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:cr("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(\nmix(-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(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:cr("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;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying 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;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:cr("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:cr("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:cr("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;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=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);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=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;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:cr("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=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 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=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);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:cr("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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 vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute 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;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_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*(pos.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);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,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*=(\n(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.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:cr("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;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=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 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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 vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute 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;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;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);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_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);\n#endif\nfloat 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\n? pos_nx.xy\n: 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,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*=(\n(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;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:cr("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}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);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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:cr("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;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:cr("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;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nhighp vec4 out_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nvec4 out_color=color;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp 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);}}\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat 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];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:cr("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;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute 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;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;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;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:cr("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(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:cr("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform 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;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 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;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 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);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);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));\n#else\ngl_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));\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_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:cr("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float 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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_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;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 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;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);vec4 offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\nvec4 offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 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);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);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));\n#else\ngl_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));\n#endif\nfloat gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 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:cr("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_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;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);vec3 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;float globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nvec3 world_pos=vec3(tile_anchor,0)+h;float globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=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);}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);vec4 projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);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));\n#else\ngl_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));\n#endif\nfloat 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;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_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:cr("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst 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;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:cr("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying 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:cr("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_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);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",rr),skyboxGradient:cr("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));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",rr),skyboxCapture:cr("\nvarying 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;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;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:cr("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);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);vec4 color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\nvec4 color=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","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;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying 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() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 merc_pos=a_merc_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idy=u_grid_matrix[1][2];float S=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=a_pos[0]*S;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;uv=uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector.xyz*height;vec4 globe=u_globe_matrix*vec4(globe_pos,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:cr("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);\n#ifdef PROJECTION_GLOBE_VIEW\nfloat 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;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nhighp 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));float horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nfloat horizon_angle=horizon_angle_mercator;\n#endif\nhorizon_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(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_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(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function cr(e,t,r){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,o=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),s=e.match(n),a=t.match(n),l=tr.match(n);let c=a?a.concat(s):s;r||(ir.staticUniforms&&(c=ir.staticUniforms.concat(c)),nr.staticUniforms&&(c=nr.staticUniforms.concat(c))),c&&(c=c.concat(l));const u={};return{fragmentSource:e=e.replace(i,((e,t,r,i,n)=>(u[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nvarying ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = u_${n};\n#endif\n`))),vertexSource:t=t.replace(i,((e,t,r,i,n)=>{const o="float"===i?"vec2":"vec4",s=n.match(/color/)?"color":o;return u[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${r} ${o} a_${n};\nvarying ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${r} ${o} a_${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`})),staticAttributes:o,staticUniforms:c}}class ur{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,r,i,n,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==i.length;for(let e=0;!c&&e<i.length;e++)this.boundPaintVertexBuffers[e]!==i[e]&&(c=!0);e.extVertexArrayObject&&this.vao&&this.boundProgram===t&&this.boundLayoutVertexBuffer===r&&!c&&this.boundIndexBuffer===n&&this.boundVertexOffset===o&&this.boundDynamicVertexBuffer===s&&this.boundDynamicVertexBuffer2===a&&this.boundDynamicVertexBuffer3===l?(e.bindVertexArrayOES.set(this.vao),s&&s.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind(),l&&l.bind()):this.freshBind(t,r,i,n,o,s,a,l)}freshBind(e,t,r,i,n,o,s,a){let l;const c=e.numAttributes,u=this.context,h=u.gl;if(u.extVertexArrayObject)this.vao&&this.destroy(),this.vao=u.extVertexArrayObject.createVertexArrayOES(),u.bindVertexArrayOES.set(this.vao),l=0,this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=r,this.boundIndexBuffer=i,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=s,this.boundDynamicVertexBuffer3=a;else{l=u.currentNumAttributes||0;for(let e=c;e<l;e++)h.disableVertexAttribArray(e)}t.enableAttributes(h,e);for(const t of r)t.enableAttributes(h,e);o&&o.enableAttributes(h,e),s&&s.enableAttributes(h,e),a&&a.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,n);for(const t of r)t.bind(),t.setVertexAttribPointers(h,e,n);o&&(o.bind(),o.setVertexAttribPointers(h,e,n)),i&&i.bind(),s&&(s.bind(),s.setVertexAttribPointers(h,e,n)),a&&(a.bind(),a.setVertexAttribPointers(h,e,n)),u.currentNumAttributes=c}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function hr(t,r){const i=Math.pow(2,r.canonical.z),n=r.canonical.y;return[new e.MercatorCoordinate(0,n/i).toLngLat().lat,new e.MercatorCoordinate(0,(n+1)/i).toLngLat().lat]}function pr(t,r,i,n,o,s,a){const l=t.context,c=l.gl,u=i.fbo;if(!u)return;t.prepareDrawTile();const h=t.useProgram("hillshade");l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,u.colorAttachment.get());const p=((e,t,r,i)=>{const n=r.paint.get("hillshade-shadow-color"),o=r.paint.get("hillshade-highlight-color"),s=r.paint.get("hillshade-accent-color");let a=r.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===r.paint.get("hillshade-illumination-anchor")&&(a-=e.transform.angle);const l=!e.options.moving;return{u_matrix:i||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:hr(0,t.tileID),u_light:[r.paint.get("hillshade-exaggeration"),a],u_shadow:n,u_highlight:o,u_accent:s}})(t,i,n,t.terrain?r.projMatrix:null);t.prepareDrawProgram(l,h,r.toUnwrapped());const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=t.getTileBoundsBuffers(i);h.draw(l,c.TRIANGLES,o,s,a,e.CullFaceMode.disabled,p,n.id,d,f,m)}function dr(t,r,i){if(!r.needsDEMTextureUpload)return;const n=t.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||t.getTileTexture(i.stride);const s=i.getPixels();r.demTexture?r.demTexture.update(s,{premultiply:!1}):r.demTexture=new e.Texture(n,s,o.RGBA,{premultiply:!1}),r.needsDEMTextureUpload=!1}function fr(t,r,i,n,o,s){const a=t.context,l=a.gl;if(!r.dem)return;const c=r.dem;if(a.activeTexture.set(l.TEXTURE1),dr(t,r,c),!r.demTexture)return;r.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const u=c.dim;a.activeTexture.set(l.TEXTURE0);let h=r.fbo;if(!h){const t=new e.Texture(a,{width:u,height:u,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=r.fbo=a.createFramebuffer(u,u,!0),h.colorAttachment.set(t.texture)}a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,u,u]);const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,n,o,s,e.CullFaceMode.disabled,((t,r)=>{const i=r.stride,n=e.create();return e.ortho(n,0,e.EXTENT,-e.EXTENT,0,0,1),e.translate(n,n,[0,-e.EXTENT,0]),{u_matrix:n,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ,u_unpack:r.unpackVector}})(r.tileID,c),i.id,p,d,f),r.needsHillshadePrepare=!1}const mr=(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_image0:new e.Uniform1i(t,r.u_image0),u_skirt_height:new e.Uniform1f(t,r.u_skirt_height)}),_r=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),gr=(e,t,r,i,n,o,s,a,l,c,u,h,p,d)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(i),u_merc_matrix:r,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:p,u_grid_matrix:d?Float32Array.from(d):new Float32Array(9)});function yr(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const vr=new class{constructor(){this.operations={}}newMorphing(e,t,r,i,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==r.tileID.key&&(t.queued=r)}else this.operations[e]={startTime:i,phase:0,duration:n,from:t,to:r,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const r=this.operations[t];for(r.phase=(e-r.startTime)/r.duration;r.phase>=1||!this._validOp(r);)if(!this._nextOp(r,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},xr={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function br(e,t){const r=1<<e.z;return!t&&(0===e.x||e.x===r-1)||0===e.y||e.y===r-1}const wr=e=>({u_matrix:e});function Tr(t,r,i,n,o){if(o>0){const s=e.exported.now(),a=(s-t.timeAdded)/o,l=r?(s-r.timeAdded)/o:-1,c=i.getSource(),u=n.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!r||Math.abs(r.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),p=h&&t.refreshedUponExpiration?1:e.clamp(h?a:1-l,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),r?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}class Er extends e.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},r=new P(Ue(),null),i=Pe("mock-dem",t,r,e.style);super("mock-dem",i,!1),i.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Sr extends e.SourceCache{constructor(e){const t=Pe("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new P(Ue(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,r,i){if(t.freezeTileCoverage)return;this.transform=t;const n=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((r,i)=>{if(r[i.key]="",!this._tiles[i.key]){const r=new e.Tile(i,this._source.tileSize*i.overscaleFactor(),t.tileZoom);r.state="loaded",this._tiles[i.key]=r}return r}),{});for(const e in this._tiles)e in n||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const r=Object.values(t);this.renderCachePool.push(...r),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Cr extends e.OverscaledTileID{constructor(e,t,r){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=r}}class Ar extends e.Elevation{constructor(t,r){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[i,n,o]=function(t){const r=new e.StructArrayLayout4i8,i=new e.StructArrayLayout3ui6,n=131;r.reserve(17161),i.reserve(33800);const o=e.EXTENT/128,s=e.EXTENT+o/2,a=s+o;for(let t=-o;t<a;t+=o)for(let i=-o;i<a;i+=o){const n=i<0||i>s||t<0||t>s?24575:0,o=e.clamp(Math.round(i),0,e.EXTENT),a=e.clamp(Math.round(t),0,e.EXTENT);r.emplaceBack(o+n,a,o,a)}const l=(e,t)=>{const r=t*n+e;i.emplaceBack(r+1,r,r+n),i.emplaceBack(r+n,r+n+1,r+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)})),[r,i,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(i,e.boundsAttributes.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=e.SegmentVector.simpleSegment(0,0,i.length,n.length),this.gridNoSkirtSegments=e.SegmentVector.simpleSegment(0,0,i.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Sr(r.map),this.orthoMatrix=e.create(),e.ortho(this.orthoMatrix,0,e.EXTENT,0,e.EXTENT,0,1);const a=s.gl;this._overlapStencilMode=new e.StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=r,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Er(r.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency()}update(t,r,i){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const n=t.terrain.properties;this.sourceCache=0===t.terrain.drapeRenderMode?this._mockSourceCache:t._getSourceCache(n.get("source")),this._exaggeration=n.get("exaggeration");const o=()=>{this.sourceCache.used&&e.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const t=this.getScaledDemTileSize();this.sourceCache.update(r,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),r.updateElevation(!i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(r),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==t.efficiency&&e.warnOnce(`Terrain render cache efficiency is not optimal (${t.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${t.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._sourceCaches)this._style._sourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const r=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=r.getIds().map((e=>{const t=r.getTileByID(e).tileID;return t.projMatrix=i.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,r){const i=r.transform.pointCoordinate(r.transform.getCameraPoint()),n=new e.pointGeometry(i.x,i.y);t.sort(((t,r)=>{if(r.overscaledZ-t.overscaledZ)return r.overscaledZ-t.overscaledZ;const i=new e.pointGeometry(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),o=new e.pointGeometry(r.canonical.x+(1<<r.canonical.z)*r.wrap,r.canonical.y),s=n.mult(1<<t.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(i)-s.distSqr(o)}))}(n,this.painter),this._previousZoom=i.zoom;const o=this.proxyToSource||{};this.proxyToSource={},n.forEach((e=>{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const e in s){const r=s[e];if(!r.used)continue;if(r!==this.sourceCache&&this.resetTileLookupCache(r.id),this._setupProxiedCoordsForOrtho(r,t[e],o),r.usedForTerrain)continue;const i=t[e];r.getSource().reparseOverscaled&&this._assignTerrainTiles(i)}this.proxiedCoords[r.id]=n.map((e=>new Cr(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=e.exported.now();const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const r=t.tileID.key;r in a||(this._visibleDemTiles.push(t),a[r]=r)}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)}))}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const r in this.terrainTileForTile){const i=this.terrainTileForTile[r],n=i.dem;!n||i.demTexture&&!i.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),dr(this.painter,i,n))}}_prepareDemTileUniforms(e,t,r,i){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=i||"";return r[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],r[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,r=t.gl;if(!this._emptyDepthBufferTexture){const i=new e.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.Texture(t,i,r.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,r)=>{if(!r.dem)return t;const i=r.dem.tree.minimums[0];return i>0&&e++,t+i}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,r=t.gl;t.activeTexture.set(r.TEXTURE2);const i=this._getLoadedAreaMinimum(),n=new e.RGBAImage({width:1,height:1},new Uint8Array(e.DEMData.pack(i,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(n,{premultiply:!1}):o=this._emptyDEMTexture=new e.Texture(t,n,r.RGBA,{premultiply:!1}),o}setupElevationDraw(t,r,i){const n=this.painter.context,o=n.gl,s=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:e.DEMData.getUnpackVector(a),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,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var a;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();const l=this.painter.transform,c=l.projection,u=t.tileID.canonical;s.u_tile_tl_up=c.upVector(u,0,0),s.u_tile_tr_up=c.upVector(u,e.EXTENT,0),s.u_tile_br_up=c.upVector(u,e.EXTENT,e.EXTENT),s.u_tile_bl_up=c.upVector(u,0,e.EXTENT),s.u_tile_up_scale=i&&i.useDenormalizedUpVectorScale?e.GLOBE_METERS_TO_ECEF:c.upVectorScale(u,l.center.lat,l.worldSize).metersToTile;let h=null,p=null,d=1;if(i&&i.morphing&&this._useVertexMorphing){const e=i.morphing.srcDemTile,r=i.morphing.dstDemTile;d=i.morphing.phase,e&&r&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(p=e),this._prepareDemTileUniforms(t,r,s)&&(h=r))}if(p&&h?(n.activeTexture.set(o.TEXTURE2),h.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),n.activeTexture.set(o.TEXTURE4),p.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),s.u_dem_lerp=d):(h=this.terrainTileForTile[t.tileID.key],n.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(t,h,s)?h.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)),n.activeTexture.set(o.TEXTURE3),i&&i.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&h){const t=(1<<h.tileID.canonical.z)*e.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=t}i&&i.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),r.setTerrainUniformValues(n,s)}renderToBackBuffer(t){const r=this.painter,i=this.painter.context;0!==t.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,r.width,r.height]),r.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(t,r,i,n,o){if("globe"===t.transform.projection.name)!function(t,r,i,n,o){const s=t.context,a=s.gl;let l,c;const u=t.options.showTerrainWireframe?2:0,h=t.transform,p=e.globeUseCustomAntiAliasing(t,s,h),d=(e,r)=>{if(c===e)return;const i=[xr[e],"PROJECTION_GLOBE_VIEW"];p&&i.push("CUSTOM_ANTIALIASING"),r&&i.push(xr[u]),l=t.useProgram("globeRaster",null,i),c=e},f=t.colorModeForRenderPass(),m=new e.DepthMode(a.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);vr.update(o);const _=e.calculateGlobeMercatorMatrix(h),g=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],y=t.globeSharedBuffers,v=[h.width*e.exported.devicePixelRatio,h.height*e.exported.devicePixelRatio];if((u?[!1,!0]:[!1]).forEach((u=>{c=-1;const p=u?a.LINES:a.TRIANGLES;for(const c of n){const n=i.getTile(c),x=e.StencilMode.disabled,b=r.prevTerrainTileForTile[c.key],w=r.terrainTileForTile[c.key];yr(b,w)&&vr.newMorphing(c.key,b,w,o,250),s.activeTexture.set(a.TEXTURE0),n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=vr.getMorphValuesForProxy(c.key),E=T?1:0,S={useDenormalizedUpVectorScale:!0};T&&e.extend$1(S,{morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:e.easeCubicInOut(T.phase)}});const C=Float32Array.from(h.globeMatrix),A=e.globeTileLatLngCorners(c.canonical),k=e.getLatitudinalLod((A[0][0]+A[1][0])/2),I=e.getGridMatrix(c.canonical,A,k),M=e.globeNormalizeECEF(e.globeTileBounds(c.canonical)),z=gr(h.projMatrix,C,_,M,e.globeToMercatorTransition(h.zoom),g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,I);if(d(E,u),r.setupElevationDraw(n,l,S),t.prepareDrawProgram(s,l,c.toUnwrapped()),y){const[r,i,n]=u?y.getWirefameBuffers(t.context,k):y.getGridBuffers(k);l.draw(s,p,m,x,f,e.CullFaceMode.backCCW,z,"globe_raster",r,i,n)}}})),y){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];p&&o.push("CUSTOM_ANTIALIASING"),l=t.useProgram("globeRaster",null,o);for(const o of n){const{x:n,y:c,z:u}=o.canonical,p=0===c,d=c===(1<<u)-1,[_,x,b,w]=y.getPoleBuffers(u);if(w&&(p||d)){const c=i.getTile(o);s.activeTexture.set(a.TEXTURE0),c.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let y=e.globePoleMatrixForTile(u,n,h);const T=e.globeNormalizeECEF(e.globeTileBounds(o.canonical)),E=(t,r)=>t.draw(s,a.TRIANGLES,m,e.StencilMode.disabled,f,e.CullFaceMode.disabled,gr(h.projMatrix,y,y,T,0,g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v),"globe_pole_raster",r,b,w);r.setupElevationDraw(c,l,{}),t.prepareDrawProgram(s,l,o.toUnwrapped()),p&&E(l,_),d&&(y=e.scale(e.create(),y,[1,-1,1]),E(l,x))}}}}(t,r,i,n,o);else{const s=t.context,a=s.gl;let l,c;const u=t.options.showTerrainWireframe?2:0,h=(e,r)=>{if(c===e)return;const i=[xr[e]];r&&i.push(xr[u]),l=t.useProgram("terrainRaster",null,i),c=e},p=t.colorModeForRenderPass(),d=new e.DepthMode(a.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);vr.update(o);const f=t.transform,m=6*Math.pow(1.5,22-f.zoom)*r.exaggeration();(u?[!1,!0]:[!1]).forEach((u=>{c=-1;const _=u?a.LINES:a.TRIANGLES,[g,y]=u?r.getWirefameBuffer():[r.gridIndexBuffer,r.gridSegments];for(const c of n){const n=i.getTile(c),v=e.StencilMode.disabled,x=r.prevTerrainTileForTile[c.key],b=r.terrainTileForTile[c.key];yr(x,b)&&vr.newMorphing(c.key,x,b,o,250),s.activeTexture.set(a.TEXTURE0),n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST);const w=vr.getMorphValuesForProxy(c.key),T=w?1:0;let E;w&&(E={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:e.easeCubicInOut(w.phase)}});const S=_r(c.projMatrix,br(c.canonical,f.renderWorldCopies)?m/10:m);h(T,u),r.setupElevationDraw(n,l,E),t.prepareDrawProgram(s,l,c.toUnwrapped()),l.draw(s,_,d,v,p,e.CullFaceMode.backCCW,S,"terrain_raster",r.gridBuffer,g,y)}}))}}(r,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,r.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const r=this.painter,i=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=this._drapedRenderBatches.shift(),a=[],l=r.style.order;let c=0;for(const u of o){const o=n.getTileByID(u.proxyTileKey),h=n.proxyCachedFBO[u.key]?n.proxyCachedFBO[u.key][t]:void 0,p=void 0!==h?n.renderCache[h]:this.pool[c++],d=void 0!==h;if(o.texture=p.tex,d&&!p.dirty){a.push(o.tileID);continue}let f;i.bindFramebuffer.set(p.fb.framebuffer),this.renderedToTile=!1,p.dirty&&(i.clear({color:e.Color.transparent,stencil:0}),p.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=r.style._layers[l[e]];if(t.isHidden(r.transform.zoom))continue;const n=r.style._getLayerSourceCache(t),o=n?this.proxyToSource[u.key][n.id]:[u];if(!o)continue;const s=o;i.viewport.set([0,0,p.fb.width,p.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(p,o,t,n),f=n?n.id:null),r.renderLayer(r,n,t,s)}this.renderedToTile?(p.dirty=!0,a.push(o.tileID)):d||--c,5===c&&(c=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,r.width,r.height]),s.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let r,i=0,n=0,o=!1;for(let s=0;s<t;++s){const t=e._layers[e.order[s]];this._style.isLayerDraped(t)?(o&&++i,++n):o||(o=!0,r=t.id)}return 0===n?{efficiency:100}:{efficiency:100*(1-i/n),firstUndrapedLayer:r}}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,r){if(!this._visibleDemTiles)return null;const i=this._visibleDemTiles.filter((e=>e.dem)).map((i=>{const n=i.tileID,o=Math.pow(2,n.overscaledZ),{x:s,y:a}=n.canonical,l=s/o,c=(s+1)/o,u=a/o,h=(a+1)/o;return{minx:l,miny:u,maxx:c,maxy:h,t:i.dem.tree.raycastRoot(l,u,c,h,e,t,r),tile:i}}));i.sort(((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of i){if(null==n.t)return null;const i=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,r);if(null!=i)return i}return null}_createFBO(){const t=this.painter.context,r=t.gl,i=this.drapeBufferSize;t.activeTexture.set(r.TEXTURE0);const n=new e.Texture(t,{width:i[0],height:i[1],data:null},r.RGBA);n.bind(r.LINEAR,r.CLAMP_TO_EDGE);const o=t.createFramebuffer(i[0],i[1],!1);return o.colorAttachment.set(n.texture),o.depthAttachment=new Ee(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&r.texParameterf(r.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:n,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e].hasTransition())return!0;return this._style.order.some((e=>{const t=this._style._layers[e],r=t.isHidden(this.painter.transform.zoom),i=t.getCrossfadeParameters(),n=!!i&&1!==i.t,o=t.hasTransition();return"custom"!==t.type&&!r&&(n||o)}))}_clearRasterFadeFromRenderCache(){let e=!1;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t]._source instanceof Ae){e=!0;break}if(e)for(let e=0;e<this._style.order.length;++e){const t=this._style._layers[this._style.order[e]],r=t.isHidden(this.painter.transform.zoom),i=this._style._getLayerSourceCache(t);if("raster"!==t.type||r||!i)continue;const n=t.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][i.id];if(t)for(const e of t){const t=Tr(i.getTile(e),i.findLoadedParent(e,0),i,this.painter.transform,n);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(i.id,e)}}}}_setupDrapedRenderBatches(){const e=this._style.order,t=e.length;if(0===t)return;const r=[];let i,n=0,o=this._style._layers[e[n]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++n<t;)o=this._style._layers[e[n]];for(;n<t;++n){const t=this._style._layers[e[n]];t.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(t)?void 0===i&&(i=n):void 0!==i&&(r.push({start:i,end:n-1}),i=void 0))}void 0!==i&&r.push({start:i,end:n-1}),this._drapedRenderBatches=r}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let r=0;r<e.length;++r){const i=Object.values(e[r]);t.renderCachePool.push(...i)}}return}this._clearRasterFadeFromRenderCache();const r=this.proxyCoords,i=this._tilesDirty;for(let n=r.length-1;n>=0;n--){const o=r[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const r=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=r[e];if(!o||o.length!==t.length||t.some(((t,r)=>t!==o[r]||i[e]&&i[e].hasOwnProperty(t.key)))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(r).length}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const i of r){if(t.proxyCachedFBO[i.key])continue;let r=t.renderCachePool.pop();void 0===r&&t.renderCache.length<50&&(r=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==r&&(t.proxyCachedFBO[i.key]={},t.proxyCachedFBO[i.key][e.start]=r,t.renderCache[r].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,r,i){if(!i||!this._sourceTilesOverlap[i.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(r.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,r.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e.StencilMode.disabled}_renderTileClippingMasks(t,r){const i=this.painter,n=this.painter.context,o=n.gl;i._tileClippingMaskIDs={},n.setColorMode(e.ColorMode.disabled),n.setDepthMode(e.DepthMode.disabled);const s=i.useProgram("clippingMask");for(const a of t){const t=i._tileClippingMaskIDs[a.key]=--r;s.draw(n,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,wr(a.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(t){const r=this.painter.transform;if(t.x<0||t.x>r.width||t.y<0||t.y>r.height)return null;const i=[t.x,t.y,1,1];e.transformMat4$1(i,i,r.pixelMatrixInverse),e.scale$1(i,i,1/i[3]),i[0]/=r.worldSize,i[1]/=r.worldSize;const n=r._camera.position,o=e.mercatorZfromAltitude(1,r.center.lat),s=[n[0],n[1],n[2]/o,0],a=e.subtract([],i.slice(0,3),s);e.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const t=this.painter,r=t.context,i=this.proxySourceCache,n=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===n&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=r.gl,i=r.createFramebuffer(n,o,!0);r.activeTexture.set(t.TEXTURE0);const s=new e.Texture(r,{width:n,height:o,data:null},t.RGBA);s.bind(t.NEAREST,t.CLAMP_TO_EDGE),i.colorAttachment.set(s.texture);const a=r.createRenderbuffer(r.gl.DEPTH_COMPONENT16,n,o);i.depthAttachment.set(a),this._depthFBO=i,this._depthTexture=s}r.bindFramebuffer.set(this._depthFBO.framebuffer),r.viewport.set([0,0,n,o]),function(t,r,i,n){if("globe"===t.transform.projection.name)return;const o=t.context,s=o.gl;o.clear({depth:1});const a=t.useProgram("terrainDepth"),l=new e.DepthMode(s.LESS,e.DepthMode.ReadWrite,t.depthRangeFor3D);for(const t of n){const n=i.getTile(t),c=_r(t.projMatrix,0);r.setupElevationDraw(n,a),a.draw(o,s.TRIANGLES,l,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.backCCW,c,"terrain_depth",r.gridBuffer,r.gridIndexBuffer,r.gridNoSkirtSegments)}}(t,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,r){if(e.getSource()instanceof Me)return this._setupProxiedCoordsForImageSource(e,t,r);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const i=this.proxiedCoords[e.id]=[],n=this.proxyCoords;for(let t=0;t<n.length;t++){const o=n[t],s=this._findTileCoveringTileID(o,e);if(s){const t=this._createProxiedId(o,s,r[o.key]&&r[o.key][e.id]);i.push(t),this.proxyToSource[o.key][e.id]=[t]}}let o=!1;for(let n=0;n<t.length;n++){const s=e.getTile(t[n]);if(!s||!s.hasData())continue;const a=this._findTileCoveringTileID(s.tileID,this.proxySourceCache);if(a&&a.tileID.canonical.z!==s.tileID.canonical.z){const t=this.proxyToSource[a.tileID.key][e.id],n=this._createProxiedId(a.tileID,s,r[a.tileID.key]&&r[a.tileID.key][e.id]);t?t.splice(t.length-1,0,n):this.proxyToSource[a.tileID.key][e.id]=[n],i.push(n),o=!0}}this._sourceTilesOverlap[e.id]=o}_setupProxiedCoordsForImageSource(t,r,i){if(!t.getSource().loaded())return;const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=new e.pointGeometry(s.tileID.x,s.tileID.y)._div(1<<s.tileID.z),l=s.coordinates.map(e.MercatorCoordinate.fromLngLat).reduce(((e,t)=>(e.min.x=Math.min(e.min.x,t.x-a.x),e.min.y=Math.min(e.min.y,t.y-a.y),e.max.x=Math.max(e.max.x,t.x-a.x),e.max.y=Math.max(e.max.y,t.y-a.y),e)),{min:new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(t,r)=>{const i=t.wrap+t.canonical.x/(1<<t.canonical.z),n=t.canonical.y/(1<<t.canonical.z),o=e.EXTENT/(1<<t.canonical.z),s=r.wrap+r.canonical.x/(1<<r.canonical.z),a=r.canonical.y/(1<<r.canonical.z);return i+o<s+l.min.x||i>s+l.max.x||n+o<a+l.min.y||n>a+l.max.y};for(let e=0;e<o.length;e++){const s=o[e];for(let e=0;e<r.length;e++){const o=t.getTile(r[e]);if(!o||!o.hasData())continue;if(c(s,o.tileID))continue;const a=this._createProxiedId(s,o,i[s.key]&&i[s.key][t.id]),l=this.proxyToSource[s.key][t.id];l?l.push(a):this.proxyToSource[s.key][t.id]=[a],n.push(a)}}}_createProxiedId(t,r,i){let n=this.orthoMatrix;if(i){const e=i.find((e=>e.key===r.tileID.key));if(e)return e}if(r.tileID.key!==t.key){const i=t.canonical.z-r.tileID.canonical.z;let o,s,a;n=e.create();const l=r.tileID.wrap-t.wrap<<t.overscaledZ;i>0?(o=e.EXTENT>>i,s=o*((r.tileID.canonical.x<<i)-t.canonical.x+l),a=o*((r.tileID.canonical.y<<i)-t.canonical.y)):(o=e.EXTENT<<-i,s=e.EXTENT*(r.tileID.canonical.x-(t.canonical.x+l<<-i)),a=e.EXTENT*(r.tileID.canonical.y-(t.canonical.y<<-i))),e.ortho(n,0,o,0,o,0,1),e.translate(n,n,[s,a,0])}return new Cr(r.tileID,t.key,n)}_findTileCoveringTileID(t,r){let i=r.getTile(t);if(i&&i.hasData())return i;const n=this._findCoveringTileCache[r.id],o=n[t.key];if(i=o?r.getTileByID(o):null,i&&i.hasData()||null===o)return i;let s=i?i.tileID:t,a=s.overscaledZ;const l=r.getSource().minzoom,c=[];if(!o){const n=r.getSource().maxzoom;if(t.canonical.z>=n){const i=t.canonical.z-n;r.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,r.transform.tileZoom),s=new e.OverscaledTileID(a,t.wrap,n,t.canonical.x>>i,t.canonical.y>>i)):0!==i&&(a=n,s=new e.OverscaledTileID(a,t.wrap,n,t.canonical.x>>i,t.canonical.y>>i))}s.key!==t.key&&(c.push(s.key),i=r.getTile(s))}const u=e=>{c.forEach((t=>{n[t]=e})),c.length=0};for(a-=1;a>=l&&(!i||!i.hasData());a--){i&&u(i.tileID.key);const e=s.calculateScaledKey(a);if(i=r.getTileByID(e),i&&i.hasData())break;const t=n[e];if(null===t)break;void 0===t?c.push(e):i=r.getTileByID(t)}return u(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let r=this._tilesDirty[e];r||(r=this._tilesDirty[e]={}),r[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const t=function(t){let r=0;const i=new e.StructArrayLayout2ui4,n=131;for(let e=1;e<129;e++){for(let t=1;t<129;t++)r=e*n+t,i.emplaceBack(r,r+1),i.emplaceBack(r,r+n),i.emplaceBack(r+1,r+n),128===e&&i.emplaceBack(r+n,r+n+1);i.emplaceBack(r+1,r+1+n)}return i}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=e.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}function kr(e){const t=[];for(let r=0;r<e.length;r++){if(null===e[r])continue;const i=e[r].split(" ");t.push(i.pop())}return t}class Ir{static cacheKey(e,t,r){let i=`${e}${r?r.cacheKey:""}`;for(const e of t)i+=`/${e}`;return i}constructor(t,r,i,n,o,s){const a=t.gl;this.program=a.createProgram();const l=kr(i.staticAttributes),c=n?n.getBinderAttributes():[],u=l.concat(c),h=i.staticUniforms?kr(i.staticUniforms):[],p=n?n.getBinderUniforms():[],d=h.concat(p),f=[];for(const e of d)f.indexOf(e)<0&&f.push(e);let m=n?n.defines():[];m=m.concat(s.map((e=>`#define ${e}`)));const _=m.concat(t.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(ar):ar,ar,sr,or.fragmentSource,nr.fragmentSource,i.fragmentSource).join("\n"),g=m.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",sr,or.vertexSource,nr.vertexSource,ir.vertexSource,i.vertexSource).join("\n"),y=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(y,_),a.compileShader(y),a.attachShader(this.program,y);const v=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(v,g),a.compileShader(v),a.attachShader(this.program,v),this.attributes={};const x={};this.numAttributes=u.length;for(let e=0;e<this.numAttributes;e++)u[e]&&(a.bindAttribLocation(this.program,e,u[e]),this.attributes[u[e]]=e);a.linkProgram(this.program),a.deleteShader(v),a.deleteShader(y);for(let e=0;e<f.length;e++){const t=f[e];if(t&&!x[t]){const e=a.getUniformLocation(this.program,t);e&&(x[t]=e)}}this.fixedUniforms=o(t,x),this.binderUniforms=n?n.getUniforms(t,x):[],-1!==s.indexOf("TERRAIN")&&(this.terrainUniforms=((t,r)=>({u_dem:new e.Uniform1i(t,r.u_dem),u_dem_prev:new e.Uniform1i(t,r.u_dem_prev),u_dem_unpack:new e.Uniform4f(t,r.u_dem_unpack),u_dem_tl:new e.Uniform2f(t,r.u_dem_tl),u_dem_scale:new e.Uniform1f(t,r.u_dem_scale),u_dem_tl_prev:new e.Uniform2f(t,r.u_dem_tl_prev),u_dem_scale_prev:new e.Uniform1f(t,r.u_dem_scale_prev),u_dem_size:new e.Uniform1f(t,r.u_dem_size),u_dem_lerp:new e.Uniform1f(t,r.u_dem_lerp),u_exaggeration:new e.Uniform1f(t,r.u_exaggeration),u_depth:new e.Uniform1i(t,r.u_depth),u_depth_size_inv:new e.Uniform2f(t,r.u_depth_size_inv),u_meter_to_dem:new e.Uniform1f(t,r.u_meter_to_dem),u_label_plane_matrix_inv:new e.UniformMatrix4f(t,r.u_label_plane_matrix_inv),u_tile_tl_up:new e.Uniform3f(t,r.u_tile_tl_up),u_tile_tr_up:new e.Uniform3f(t,r.u_tile_tr_up),u_tile_br_up:new e.Uniform3f(t,r.u_tile_br_up),u_tile_bl_up:new e.Uniform3f(t,r.u_tile_bl_up),u_tile_up_scale:new e.Uniform1f(t,r.u_tile_up_scale)}))(t,x)),-1!==s.indexOf("FOG")&&(this.fogUniforms=((t,r)=>({u_fog_matrix:new e.UniformMatrix4f(t,r.u_fog_matrix),u_fog_range:new e.Uniform2f(t,r.u_fog_range),u_fog_color:new e.Uniform4f(t,r.u_fog_color),u_fog_horizon_blend:new e.Uniform1f(t,r.u_fog_horizon_blend),u_fog_temporal_offset:new e.Uniform1f(t,r.u_fog_temporal_offset),u_frustum_tl:new e.Uniform3f(t,r.u_frustum_tl),u_frustum_tr:new e.Uniform3f(t,r.u_frustum_tr),u_frustum_br:new e.Uniform3f(t,r.u_frustum_br),u_frustum_bl:new e.Uniform3f(t,r.u_frustum_bl),u_globe_pos:new e.Uniform3f(t,r.u_globe_pos),u_globe_radius:new e.Uniform1f(t,r.u_globe_radius),u_globe_transition:new e.Uniform1f(t,r.u_globe_transition),u_is_globe:new e.Uniform1i(t,r.u_is_globe),u_viewport:new e.Uniform2f(t,r.u_viewport)}))(t,x))}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const r=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e].set(t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const r=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e].location&&r[e].set(t[e])}}draw(e,t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_){const g=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(r),e.setStencilMode(i),e.setColorMode(n),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(s[e]);d&&d.setUniforms(e,this.binderUniforms,h,{zoom:p});const y={[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t];for(const r of u.get()){const i=r.vaos||(r.vaos={});(i[a]||(i[a]=new ur)).bind(e,this,l,d?d.getPaintVertexBuffers():[],c,r.vertexOffset,f,m,_),g.drawElements(t,r.primitiveLength*y,g.UNSIGNED_SHORT,r.primitiveOffset*y*2)}}}function Mr(e,t,r){const i=1/D(r,1,t.transform.tileZoom),n=Math.pow(2,r.tileID.overscaledZ),o=r.tileSize*Math.pow(2,t.transform.tileZoom)/n,s=o*(r.tileID.canonical.x+r.tileID.wrap*n),a=o*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[i,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a]}}const zr=e.create(),Pr=(t,r,i,n,o,s,a,l,c)=>{const u=r.style.light,h=u.properties.get("position"),p=[h.x,h.y,h.z],d=e.create$1();"viewport"===u.properties.get("anchor")&&(e.fromRotation(d,-r.transform.angle),e.transformMat3(p,p,d));const f=u.properties.get("color"),m=r.transform,_={u_matrix:t,u_lightpos:p,u_lightintensity:u.properties.get("intensity"),u_lightcolor:[f.r,f.g,f.b],u_vertical_gradient:+i,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:zr,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0};return"globe"===m.projection.name&&(_.u_tile_id=[o.canonical.x,o.canonical.y,1<<o.canonical.z],_.u_zoom_transition=a,_.u_inv_rot_matrix=c,_.u_merc_center=l,_.u_up_dir=m.projection.upVector(new e.CanonicalTileID(0,0,0),l[0]*e.EXTENT,l[1]*e.EXTENT),_.u_height_lift=s),_},Dr=(t,r,i,n,o,s,a,l,c,u,h)=>{const p=Pr(t,r,i,n,o,l,c,u,h),d={u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8};return e.extend(p,Mr(s,r,a),d)},Lr=e=>({u_matrix:e}),Br=(t,r,i,n)=>e.extend(Lr(t),Mr(i,r,n)),Rr=(e,t)=>({u_matrix:e,u_world:t}),Or=(t,r,i,n,o)=>e.extend(Br(t,r,i,n),{u_world:o}),Fr=e.create(),Nr=(t,r,i,n,o,s)=>{const a=t.transform,l="globe"===a.projection.name;let c;if("map"===s.paint.get("circle-pitch-alignment"))if(l){const t=e.globePixelsToTileUnits(a.zoom,r.canonical)*a._projectionScaler;c=Float32Array.from([t,0,0,t])}else c=a.calculatePixelsToTileUnitsMatrix(i);else c=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:t.translatePosMatrix(r.projMatrix,i,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:e.exported.devicePixelRatio,u_extrude_scale:c,u_inv_rot_matrix:Fr,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){u.u_inv_rot_matrix=n,u.u_merc_center=o,u.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],u.u_zoom_transition=e.globeToMercatorTransition(a.zoom);const t=o[0]*e.EXTENT,i=o[1]*e.EXTENT;u.u_up_dir=a.projection.upVector(new e.CanonicalTileID(0,0,0),t,i)}return u},jr=e=>{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},Ur=(t,r,i,n)=>{const o=e.EXTENT/i.tileSize;return{u_matrix:t,u_camera_to_center_distance:r.getCameraToCenterDistance(n),u_extrude_scale:[r.pixelsToGLUnits[0]/o,r.pixelsToGLUnits[1]/o]}},Vr=(e,t,r=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:r}),qr=e.create(),Gr=(t,r,i,n,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.globePixelsToTileUnits(l.zoom,r.canonical)*l._projectionScaler:D(i,1,s),h={u_matrix:r.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:qr,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=n,h.u_merc_center=o,h.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],h.u_zoom_transition=e.globeToMercatorTransition(l.zoom);const t=o[0]*e.EXTENT,i=o[1]*e.EXTENT;h.u_up_dir=l.projection.upVector(new e.CanonicalTileID(0,0,0),t,i)}return h},$r=(e,t,r,i,n,o,s,a)=>{const l=e.transform,c=l.calculatePixelsToTileUnitsMatrix(t),u={u_matrix:Hr(e,t,r,n),u_pixels_to_tile_units:c,u_device_pixel_ratio:s,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:o,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0,u_trim_offset:a};if(Xr(r)){const r=Wr(t,e.transform);u.u_texsize=t.lineAtlasTexture.size,u.u_scale=[r,i.fromScale,i.toScale],u.u_mix=i.t}return u},Zr=(e,t,r,i,n,o)=>{const s=e.transform,a=Wr(t,s);return{u_matrix:Hr(e,t,r,n),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:o,u_image:0,u_scale:[a,i.fromScale,i.toScale],u_fade:i.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Wr(e,t){return 1/D(e,1,t.tileZoom)}function Hr(e,t,r,i){return e.translatePosMatrix(i||t.tileID.projMatrix,t,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}function Xr(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const Yr=(e,t,r,i,n,o)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:r,u_fade_t:i.mix,u_opacity:i.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(a=n.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(s=n.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:Kr(n.paint.get("raster-hue-rotate")),u_perspective_transform:o};var s,a};function Kr(e){e*=Math.PI/180;const t=Math.sin(e),r=Math.cos(e);return[(2*r+1)/3,(-Math.sqrt(3)*t-r+1)/3,(Math.sqrt(3)*t-r+1)/3]}const Jr=e.create(),Qr=(t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_)=>{const g=o.transform,y={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:g.cameraToCenterDistance,u_rotate_symbol:+i,u_aspect_ratio:g.width/g.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+n,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Jr,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Jr,u_up_vector:[0,-1,0]};return"globe"===_.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],y.u_zoom_transition=p,y.u_inv_rot_matrix=f,y.u_merc_center=d,y.u_camera_forward=g._camera.forward(),y.u_ecef_origin=e.globeECEFOrigin(g.globeMatrix,h.toUnwrapped()),y.u_tile_matrix=Float32Array.from(g.globeMatrix),y.u_up_vector=m),y},ei=(t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_,g)=>e.extend(Qr(t,r,i,n,o,s,a,l,c,u,p,d,f,m,_,g),{u_gamma_scale:n?o.transform.cameraToCenterDistance*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.exported.devicePixelRatio,u_is_halo:+h}),ti=(t,r,i,n,o,s,a,l,c,u,h,p,d,f,m,_)=>e.extend(ei(t,r,i,n,o,s,a,l,!0,c,!0,h,p,d,f,m,_),{u_texsize_icon:u,u_texture_icon:1}),ri=(e,t,r)=>({u_matrix:e,u_opacity:t,u_color:r}),ii=(t,r,i,n,o,s)=>e.extend(function(e,t,r,i){const n=r.imageManager.getPattern(e.from.toString()),o=r.imageManager.getPattern(e.to.toString()),{width:s,height:a}=r.imageManager.getPixelSize(),l=Math.pow(2,i.tileID.overscaledZ),c=i.tileSize*Math.pow(2,r.transform.tileZoom)/l,u=c*(i.tileID.canonical.x+i.tileID.wrap*l),h=c*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,a],u_mix:t.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/D(i,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(n,s,i,o),{u_matrix:t,u_opacity:r}),ni={fillExtrusion:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_lightpos:new e.Uniform3f(t,r.u_lightpos),u_lightintensity:new e.Uniform1f(t,r.u_lightintensity),u_lightcolor:new e.Uniform3f(t,r.u_lightcolor),u_vertical_gradient:new e.Uniform1f(t,r.u_vertical_gradient),u_opacity:new e.Uniform1f(t,r.u_opacity),u_tile_id:new e.Uniform3f(t,r.u_tile_id),u_zoom_transition:new e.Uniform1f(t,r.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,r.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,r.u_merc_center),u_up_dir:new e.Uniform3f(t,r.u_up_dir),u_height_lift:new e.Uniform1f(t,r.u_height_lift)}),fillExtrusionPattern:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_lightpos:new e.Uniform3f(t,r.u_lightpos),u_lightintensity:new e.Uniform1f(t,r.u_lightintensity),u_lightcolor:new e.Uniform3f(t,r.u_lightcolor),u_vertical_gradient:new e.Uniform1f(t,r.u_vertical_gradient),u_height_factor:new e.Uniform1f(t,r.u_height_factor),u_tile_id:new e.Uniform3f(t,r.u_tile_id),u_zoom_transition:new e.Uniform1f(t,r.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,r.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,r.u_merc_center),u_up_dir:new e.Uniform3f(t,r.u_up_dir),u_height_lift:new e.Uniform1f(t,r.u_height_lift),u_image:new e.Uniform1i(t,r.u_image),u_texsize:new e.Uniform2f(t,r.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,r.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,r.u_scale),u_fade:new e.Uniform1f(t,r.u_fade),u_opacity:new e.Uniform1f(t,r.u_opacity)}),fill:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix)}),fillPattern:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_image:new e.Uniform1i(t,r.u_image),u_texsize:new e.Uniform2f(t,r.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,r.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,r.u_scale),u_fade:new e.Uniform1f(t,r.u_fade)}),fillOutline:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_world:new e.Uniform2f(t,r.u_world)}),fillOutlinePattern:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_world:new e.Uniform2f(t,r.u_world),u_image:new e.Uniform1i(t,r.u_image),u_texsize:new e.Uniform2f(t,r.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,r.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,r.u_scale),u_fade:new e.Uniform1f(t,r.u_fade)}),circle:(t,r)=>({u_camera_to_center_distance:new e.Uniform1f(t,r.u_camera_to_center_distance),u_extrude_scale:new e.UniformMatrix2f(t,r.u_extrude_scale),u_device_pixel_ratio:new e.Uniform1f(t,r.u_device_pixel_ratio),u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_inv_rot_matrix:new e.UniformMatrix4f(t,r.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,r.u_merc_center),u_tile_id:new e.Uniform3f(t,r.u_tile_id),u_zoom_transition:new e.Uniform1f(t,r.u_zoom_transition),u_up_dir:new e.Uniform3f(t,r.u_up_dir)}),collisionBox:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_camera_to_center_distance:new e.Uniform1f(t,r.u_camera_to_center_distance),u_extrude_scale:new e.Uniform2f(t,r.u_extrude_scale)}),collisionCircle:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_inv_matrix:new e.UniformMatrix4f(t,r.u_inv_matrix),u_camera_to_center_distance:new e.Uniform1f(t,r.u_camera_to_center_distance),u_viewport_size:new e.Uniform2f(t,r.u_viewport_size)}),debug:(t,r)=>({u_color:new e.UniformColor(t,r.u_color),u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_overlay:new e.Uniform1i(t,r.u_overlay),u_overlay_scale:new e.Uniform1f(t,r.u_overlay_scale)}),clippingMask:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix)}),heatmap:(t,r)=>({u_extrude_scale:new e.Uniform1f(t,r.u_extrude_scale),u_intensity:new e.Uniform1f(t,r.u_intensity),u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_inv_rot_matrix:new e.UniformMatrix4f(t,r.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,r.u_merc_center),u_tile_id:new e.Uniform3f(t,r.u_tile_id),u_zoom_transition:new e.Uniform1f(t,r.u_zoom_transition),u_up_dir:new e.Uniform3f(t,r.u_up_dir)}),heatmapTexture:(t,r)=>({u_image:new e.Uniform1i(t,r.u_image),u_color_ramp:new e.Uniform1i(t,r.u_color_ramp),u_opacity:new e.Uniform1f(t,r.u_opacity)}),hillshade:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_image:new e.Uniform1i(t,r.u_image),u_latrange:new e.Uniform2f(t,r.u_latrange),u_light:new e.Uniform2f(t,r.u_light),u_shadow:new e.UniformColor(t,r.u_shadow),u_highlight:new e.UniformColor(t,r.u_highlight),u_accent:new e.UniformColor(t,r.u_accent)}),hillshadePrepare:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_image:new e.Uniform1i(t,r.u_image),u_dimension:new e.Uniform2f(t,r.u_dimension),u_zoom:new e.Uniform1f(t,r.u_zoom),u_unpack:new e.Uniform4f(t,r.u_unpack)}),line:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_pixels_to_tile_units:new e.UniformMatrix2f(t,r.u_pixels_to_tile_units),u_device_pixel_ratio:new e.Uniform1f(t,r.u_device_pixel_ratio),u_units_to_pixels:new e.Uniform2f(t,r.u_units_to_pixels),u_dash_image:new e.Uniform1i(t,r.u_dash_image),u_gradient_image:new e.Uniform1i(t,r.u_gradient_image),u_image_height:new e.Uniform1f(t,r.u_image_height),u_texsize:new e.Uniform2f(t,r.u_texsize),u_scale:new e.Uniform3f(t,r.u_scale),u_mix:new e.Uniform1f(t,r.u_mix),u_alpha_discard_threshold:new e.Uniform1f(t,r.u_alpha_discard_threshold),u_trim_offset:new e.Uniform2f(t,r.u_trim_offset)}),linePattern:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_texsize:new e.Uniform2f(t,r.u_texsize),u_pixels_to_tile_units:new e.UniformMatrix2f(t,r.u_pixels_to_tile_units),u_device_pixel_ratio:new e.Uniform1f(t,r.u_device_pixel_ratio),u_image:new e.Uniform1i(t,r.u_image),u_units_to_pixels:new e.Uniform2f(t,r.u_units_to_pixels),u_scale:new e.Uniform3f(t,r.u_scale),u_fade:new e.Uniform1f(t,r.u_fade),u_alpha_discard_threshold:new e.Uniform1f(t,r.u_alpha_discard_threshold)}),raster:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_tl_parent:new e.Uniform2f(t,r.u_tl_parent),u_scale_parent:new e.Uniform1f(t,r.u_scale_parent),u_fade_t:new e.Uniform1f(t,r.u_fade_t),u_opacity:new e.Uniform1f(t,r.u_opacity),u_image0:new e.Uniform1i(t,r.u_image0),u_image1:new e.Uniform1i(t,r.u_image1),u_brightness_low:new e.Uniform1f(t,r.u_brightness_low),u_brightness_high:new e.Uniform1f(t,r.u_brightness_high),u_saturation_factor:new e.Uniform1f(t,r.u_saturation_factor),u_contrast_factor:new e.Uniform1f(t,r.u_contrast_factor),u_spin_weights:new e.Uniform3f(t,r.u_spin_weights),u_perspective_transform:new e.Uniform2f(t,r.u_perspective_transform)}),symbolIcon:(t,r)=>({u_is_size_zoom_constant:new e.Uniform1i(t,r.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,r.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,r.u_size_t),u_size:new e.Uniform1f(t,r.u_size),u_camera_to_center_distance:new e.Uniform1f(t,r.u_camera_to_center_distance),u_rotate_symbol:new e.Uniform1i(t,r.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,r.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,r.u_fade_change),u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,r.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,r.u_coord_matrix),u_is_text:new e.Uniform1i(t,r.u_is_text),u_pitch_with_map:new e.Uniform1i(t,r.u_pitch_with_map),u_texsize:new e.Uniform2f(t,r.u_texsize),u_tile_id:new e.Uniform3f(t,r.u_tile_id),u_zoom_transition:new e.Uniform1f(t,r.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,r.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,r.u_merc_center),u_camera_forward:new e.Uniform3f(t,r.u_camera_forward),u_tile_matrix:new e.UniformMatrix4f(t,r.u_tile_matrix),u_up_vector:new e.Uniform3f(t,r.u_up_vector),u_ecef_origin:new e.Uniform3f(t,r.u_ecef_origin),u_texture:new e.Uniform1i(t,r.u_texture)}),symbolSDF:(t,r)=>({u_is_size_zoom_constant:new e.Uniform1i(t,r.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,r.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,r.u_size_t),u_size:new e.Uniform1f(t,r.u_size),u_camera_to_center_distance:new e.Uniform1f(t,r.u_camera_to_center_distance),u_rotate_symbol:new e.Uniform1i(t,r.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,r.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,r.u_fade_change),u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,r.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,r.u_coord_matrix),u_is_text:new e.Uniform1i(t,r.u_is_text),u_pitch_with_map:new e.Uniform1i(t,r.u_pitch_with_map),u_texsize:new e.Uniform2f(t,r.u_texsize),u_texture:new e.Uniform1i(t,r.u_texture),u_gamma_scale:new e.Uniform1f(t,r.u_gamma_scale),u_device_pixel_ratio:new e.Uniform1f(t,r.u_device_pixel_ratio),u_tile_id:new e.Uniform3f(t,r.u_tile_id),u_zoom_transition:new e.Uniform1f(t,r.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,r.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,r.u_merc_center),u_camera_forward:new e.Uniform3f(t,r.u_camera_forward),u_tile_matrix:new e.UniformMatrix4f(t,r.u_tile_matrix),u_up_vector:new e.Uniform3f(t,r.u_up_vector),u_ecef_origin:new e.Uniform3f(t,r.u_ecef_origin),u_is_halo:new e.Uniform1i(t,r.u_is_halo)}),symbolTextAndIcon:(t,r)=>({u_is_size_zoom_constant:new e.Uniform1i(t,r.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,r.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,r.u_size_t),u_size:new e.Uniform1f(t,r.u_size),u_camera_to_center_distance:new e.Uniform1f(t,r.u_camera_to_center_distance),u_rotate_symbol:new e.Uniform1i(t,r.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,r.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,r.u_fade_change),u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,r.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,r.u_coord_matrix),u_is_text:new e.Uniform1i(t,r.u_is_text),u_pitch_with_map:new e.Uniform1i(t,r.u_pitch_with_map),u_texsize:new e.Uniform2f(t,r.u_texsize),u_texsize_icon:new e.Uniform2f(t,r.u_texsize_icon),u_texture:new e.Uniform1i(t,r.u_texture),u_texture_icon:new e.Uniform1i(t,r.u_texture_icon),u_gamma_scale:new e.Uniform1f(t,r.u_gamma_scale),u_device_pixel_ratio:new e.Uniform1f(t,r.u_device_pixel_ratio),u_is_halo:new e.Uniform1i(t,r.u_is_halo)}),background:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_opacity:new e.Uniform1f(t,r.u_opacity),u_color:new e.UniformColor(t,r.u_color)}),backgroundPattern:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_opacity:new e.Uniform1f(t,r.u_opacity),u_image:new e.Uniform1i(t,r.u_image),u_pattern_tl_a:new e.Uniform2f(t,r.u_pattern_tl_a),u_pattern_br_a:new e.Uniform2f(t,r.u_pattern_br_a),u_pattern_tl_b:new e.Uniform2f(t,r.u_pattern_tl_b),u_pattern_br_b:new e.Uniform2f(t,r.u_pattern_br_b),u_texsize:new e.Uniform2f(t,r.u_texsize),u_mix:new e.Uniform1f(t,r.u_mix),u_pattern_size_a:new e.Uniform2f(t,r.u_pattern_size_a),u_pattern_size_b:new e.Uniform2f(t,r.u_pattern_size_b),u_scale_a:new e.Uniform1f(t,r.u_scale_a),u_scale_b:new e.Uniform1f(t,r.u_scale_b),u_pixel_coord_upper:new e.Uniform2f(t,r.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,r.u_pixel_coord_lower),u_tile_units_to_pixels:new e.Uniform1f(t,r.u_tile_units_to_pixels)}),terrainRaster:mr,terrainDepth:mr,skybox:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_sun_direction:new e.Uniform3f(t,r.u_sun_direction),u_cubemap:new e.Uniform1i(t,r.u_cubemap),u_opacity:new e.Uniform1f(t,r.u_opacity),u_temporal_offset:new e.Uniform1f(t,r.u_temporal_offset)}),skyboxGradient:(t,r)=>({u_matrix:new e.UniformMatrix4f(t,r.u_matrix),u_color_ramp:new e.Uniform1i(t,r.u_color_ramp),u_center_direction:new e.Uniform3f(t,r.u_center_direction),u_radius:new e.Uniform1f(t,r.u_radius),u_opacity:new e.Uniform1f(t,r.u_opacity),u_temporal_offset:new e.Uniform1f(t,r.u_temporal_offset)}),skyboxCapture:(t,r)=>({u_matrix_3f:new e.UniformMatrix3f(t,r.u_matrix_3f),u_sun_direction:new e.Uniform3f(t,r.u_sun_direction),u_sun_intensity:new e.Uniform1f(t,r.u_sun_intensity),u_color_tint_r:new e.Uniform4f(t,r.u_color_tint_r),u_color_tint_m:new e.Uniform4f(t,r.u_color_tint_m),u_luminance:new e.Uniform1f(t,r.u_luminance)}),globeRaster:(t,r)=>({u_proj_matrix:new e.UniformMatrix4f(t,r.u_proj_matrix),u_globe_matrix:new e.UniformMatrix4f(t,r.u_globe_matrix),u_normalize_matrix:new e.UniformMatrix4f(t,r.u_normalize_matrix),u_merc_matrix:new e.UniformMatrix4f(t,r.u_merc_matrix),u_zoom_transition:new e.Uniform1f(t,r.u_zoom_transition),u_merc_center:new e.Uniform2f(t,r.u_merc_center),u_image0:new e.Uniform1i(t,r.u_image0),u_grid_matrix:new e.UniformMatrix3f(t,r.u_grid_matrix),u_frustum_tl:new e.Uniform3f(t,r.u_frustum_tl),u_frustum_tr:new e.Uniform3f(t,r.u_frustum_tr),u_frustum_br:new e.Uniform3f(t,r.u_frustum_br),u_frustum_bl:new e.Uniform3f(t,r.u_frustum_bl),u_globe_pos:new e.Uniform3f(t,r.u_globe_pos),u_globe_radius:new e.Uniform1f(t,r.u_globe_radius),u_viewport:new e.Uniform2f(t,r.u_viewport)}),globeAtmosphere:(t,r)=>({u_frustum_tl:new e.Uniform3f(t,r.u_frustum_tl),u_frustum_tr:new e.Uniform3f(t,r.u_frustum_tr),u_frustum_br:new e.Uniform3f(t,r.u_frustum_br),u_frustum_bl:new e.Uniform3f(t,r.u_frustum_bl),u_horizon:new e.Uniform1f(t,r.u_horizon),u_transition:new e.Uniform1f(t,r.u_transition),u_fadeout_range:new e.Uniform1f(t,r.u_fadeout_range),u_color:new e.Uniform4f(t,r.u_color),u_high_color:new e.Uniform4f(t,r.u_high_color),u_space_color:new e.Uniform4f(t,r.u_space_color),u_star_intensity:new e.Uniform1f(t,r.u_star_intensity),u_star_density:new e.Uniform1f(t,r.u_star_density),u_star_size:new e.Uniform1f(t,r.u_star_size),u_temporal_offset:new e.Uniform1f(t,r.u_temporal_offset),u_horizon_angle:new e.Uniform1f(t,r.u_horizon_angle),u_rotation_matrix:new e.UniformMatrix4f(t,r.u_rotation_matrix)})};let oi;function si(t,r,i,n,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=t.useProgram("collisionBox"),p=[];let d=0,f=0;for(let m=0;m<n.length;m++){const _=n[m],g=r.getTile(_),y=g.getBucket(i);if(!y)continue;const v=bt(_,y,u);let x=v;0===o[0]&&0===o[1]||(x=t.translatePosMatrix(v,g,o,s));const b=a?y.textCollisionBox:y.iconCollisionBox,w=y.collisionCircleArray;if(w.length>0){const t=e.create(),r=x;e.mul(t,y.placementInvProjMatrix,u.glCoordMatrix),e.mul(t,t,y.placementViewportMatrix),p.push({circleArray:w,circleOffset:f,transform:r,invTransform:t,projection:y.getProjection()}),d+=w.length/4,f=d}b&&(t.terrain&&t.terrain.setupElevationDraw(g,h),h.draw(l,c.LINES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,Ur(x,u,g,y.getProjection()),i.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,u.zoom,null,b.collisionVertexBuffer,b.collisionVertexBufferExt))}if(!a||!p.length)return;const m=t.useProgram("collisionCircle"),_=new e.StructArrayLayout2f1f2i16;_.resize(4*d),_._trim();let g=0;for(const e of p)for(let t=0;t<e.circleArray.length/4;t++){const r=4*t,i=e.circleArray[r+0],n=e.circleArray[r+1],o=e.circleArray[r+2],s=e.circleArray[r+3];_.emplace(g++,i,n,o,s,0),_.emplace(g++,i,n,o,s,1),_.emplace(g++,i,n,o,s,2),_.emplace(g++,i,n,o,s,3)}(!oi||oi.length<2*d)&&(oi=function(t){const r=2*t,i=new e.StructArrayLayout3ui6;i.resize(r),i._trim();for(let e=0;e<r;e++){const t=6*e;i.uint16[t+0]=4*e+0,i.uint16[t+1]=4*e+1,i.uint16[t+2]=4*e+2,i.uint16[t+3]=4*e+2,i.uint16[t+4]=4*e+3,i.uint16[t+5]=4*e+0}return i}(d));const y=l.createIndexBuffer(oi,!0),v=l.createVertexBuffer(_,e.collisionCircleLayout.members,!0);for(const r of p){const n={u_matrix:r.transform,u_inv_matrix:r.invTransform,u_camera_to_center_distance:(x=u).getCameraToCenterDistance(r.projection),u_viewport_size:[x.width,x.height]};m.draw(l,c.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,n,i.id,v,y,e.SegmentVector.simpleSegment(0,2*r.circleOffset,r.circleArray.length,r.circleArray.length/2),null,u.zoom)}var x;v.destroy(),y.destroy()}const ai=e.create();function li(t,r,i,n,o,s){const{horizontalAlign:a,verticalAlign:l}=e.getAnchorAlignment(t),c=-(a-.5)*r,u=-(l-.5)*i,h=e.evaluateVariableOffset(t,n);return new e.pointGeometry((c/o+h[0])*s,(u/o+h[1])*s)}function ci(t,r,i,n,o,s,a,l,c,u,h){const p=t.text.placedSymbolArray,d=t.text.dynamicLayoutVertexArray,f=t.icon.dynamicLayoutVertexArray,m={},_=wt(l,t.getProjection(),s),g=s.elevation,y=t.getProjection().upVectorScale(l.canonical,s.center.lat,s.worldSize);d.clear();for(let f=0;f<p.length;f++){const v=p.get(f),x=t.allowVerticalPlacement&&!v.placedOrientation,b=v.hidden||!v.crossTileID||x?null:n[v.crossTileID];if(b){const n=new e.pointGeometry(v.tileAnchorX,v.tileAnchorY),p=t.getProjection().upVector(l.canonical,n.x,n.y),f=g?g.getAtTileOffset(l,n.x,n.y):0,x=ot([v.projectedAnchorX+f*p[0]*y.metersToTile,v.projectedAnchorY+f*p[1]*y.metersToTile,v.projectedAnchorZ+f*p[2]*y.metersToTile],i?_:a),w=st(s.getCameraToCenterDistance(t.getProjection()),x.signedDistanceFromCamera);let T=o.evaluateSizeForFeature(t.textSizeData,u,v)*w/e.ONE_EM;i&&(T*=t.tilePixelRatio/c);const{width:E,height:S,anchor:C,textOffset:A,textScale:k}=b,I=li(C,E,S,A,k,T);let M;if(i){const e=n.add(I),{x:r,y:i,z:o}=t.getProjection().projectTilePoint(e.x,e.y,l.canonical);M=ot([r+f*p[0]*y.metersToTile,i+f*p[1]*y.metersToTile,o+f*p[2]*y.metersToTile],a).point}else{const e=r?I.rotate(-s.angle):I;M=[x.point[0]+e.x,x.point[1]+e.y,0]}const z=t.allowVerticalPlacement&&v.placedOrientation===e.WritingMode.vertical?Math.PI/2:0;for(let t=0;t<v.numGlyphs;t++)e.addDynamicAttributes(d,M[0],M[1],M[2],z);h&&v.associatedIconIndex>=0&&(m[v.associatedIconIndex]={shiftedAnchor:M,angle:z})}else _t(v.numGlyphs,d)}if(h){f.clear();const r=t.icon.placedSymbolArray;for(let t=0;t<r.length;t++){const i=r.get(t);if(i.hidden)_t(i.numGlyphs,f);else{const r=m[t];if(r)for(let t=0;t<i.numGlyphs;t++)e.addDynamicAttributes(f,r.shiftedAnchor[0],r.shiftedAnchor[1],r.shiftedAnchor[2],r.angle);else _t(i.numGlyphs,f)}}t.icon.dynamicLayoutVertexBuffer.updateData(f)}t.text.dynamicLayoutVertexBuffer.updateData(d)}function ui(e,t,r){return r.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function hi(t,r,i,n,o,s,a,l,c,u,h,p){const d=t.context,f=d.gl,m=t.transform,_="map"===l,g="map"===c,y=_&&"point"!==i.layout.get("symbol-placement"),v=_&&!g&&!y,x=void 0!==i.layout.get("symbol-sort-key").constantOr(1);let b=!1;const w=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),T=[e.mercatorXfromLng(m.center.lng),e.mercatorYfromLat(m.center.lat)],E=i.layout.get("text-variable-anchor"),S="globe"===m.projection.name,C=[],A=[0,-1,0];let k=A;!S&&!m.mercatorFromTransition||_||(k=function(t){const r=t._camera.getWorldToCamera(t.worldSize,1),i=e.multiply([],r,t.globeMatrix);e.invert(i,i);const n=[0,0,0],o=[0,1,0,0];return e.transformMat4$1(o,o,i),n[0]=o[0],n[1]=o[1],n[2]=o[2],e.normalize(n,n),n}(m));for(const l of n){const n=r.getTile(l),c=n.getBucket(i);if(!c)continue;if("mercator"===c.projection.name&&S)continue;const h=o?c.text:c.icon;if(!h||c.fullyClipped||!h.segments.get().length)continue;const p=h.programConfigurations.get(i.id),d=o||c.sdfIcons,w=o?c.textSizeData:c.iconSizeData,I=g||0!==m.pitch,M=e.evaluateSizeForZoom(w,m.zoom);let z,P,D,L,B=[0,0],R=null;if(o){if(P=n.glyphAtlasTexture,D=f.LINEAR,z=n.glyphAtlasTexture.size,c.iconsInText){B=n.imageAtlasTexture.size,R=n.imageAtlasTexture;const e="composite"===w.kind||"camera"===w.kind;L=I||t.options.rotating||t.options.zooming||e?f.LINEAR:f.NEAREST}}else{const e=1!==i.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;P=n.imageAtlasTexture,D=d||t.options.rotating||t.options.zooming||e||I?f.LINEAR:f.NEAREST,z=n.imageAtlasTexture.size}const O="globe"===c.projection.name,F=O?k:A,N=O?e.globeToMercatorTransition(m.zoom):0,j=wt(l,c.getProjection(),m),U=m.calculatePixelsToTileUnitsMatrix(n),V=tt(j,n.tileID.canonical,g,_,m,c.getProjection(),U),q=t.terrain&&g&&y?e.invert(e.create(),V):ai,G=it(j,n.tileID.canonical,g,_,m,c.getProjection(),U),$=E&&c.hasTextData(),Z="none"!==i.layout.get("icon-text-fit")&&$&&c.hasIconData();if(y){const e=m.elevation,r=e?e.getAtTileOffsetFunc(l,m.center.lat,m.worldSize,c.getProjection()):e=>[0,0,0],i=rt(j,n.tileID.canonical,g,_,m,c.getProjection(),U);lt(c,j,t,o,i,G,g,u,r,l)}const W=y||o&&E||Z,H=t.translatePosMatrix(j,n,s,a),X=W?ai:V,Y=t.translatePosMatrix(G,n,s,a,!0),K=c.getProjection().createInversionMatrix(m,l.canonical),J=[];t.terrain&&g&&J.push("PITCH_WITH_MAP_TERRAIN"),O&&J.push("PROJECTION_GLOBE_VIEW"),W&&J.push("PROJECTED_POS_ON_VIEWPORT");const Q=d&&0!==i.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let ee;ee=d?c.iconsInText?ti(w.kind,M,v,g,t,H,X,Y,z,B,l,N,T,K,F,c.getProjection()):ei(w.kind,M,v,g,t,H,X,Y,o,z,!0,l,N,T,K,F,c.getProjection()):Qr(w.kind,M,v,g,t,H,X,Y,o,z,l,N,T,K,F,c.getProjection());const te={program:t.useProgram(ui(d,o,c),p,J),buffers:h,uniformValues:ee,atlasTexture:P,atlasTextureIcon:R,atlasInterpolation:D,atlasInterpolationIcon:L,isSDF:d,hasHalo:Q,tile:n,labelPlaneMatrixInv:q};if(x&&c.canOverlap){b=!0;const t=h.segments.get();for(const r of t)C.push({segments:new e.SegmentVector([r]),sortKey:r.sortKey,state:te})}else C.push({segments:h.segments,sortKey:0,state:te})}b&&C.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of C){const r=e.state;if(t.terrain&&t.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:r.labelPlaneMatrixInv}),d.activeTexture.set(f.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,f.CLAMP_TO_EDGE),r.atlasTextureIcon&&(d.activeTexture.set(f.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),r.isSDF){const n=r.uniformValues;r.hasHalo&&(n.u_is_halo=1,pi(r.buffers,e.segments,i,t,r.program,w,h,p,n)),n.u_is_halo=0}pi(r.buffers,e.segments,i,t,r.program,w,h,p,r.uniformValues)}}function pi(t,r,i,n,o,s,a,l,c){const u=n.context;o.draw(u,u.gl.TRIANGLES,s,a,l,e.CullFaceMode.disabled,c,i.id,t.layoutVertexBuffer,t.indexBuffer,r,i.paint,n.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.globeExtVertexBuffer)}function di(t,r,i,n,o,s,a){const l=t.context.gl,c=i.paint.get("fill-pattern"),u=c&&c.constantOr(1),h=i.getCrossfadeParameters();let p,d,f,m,_;a?(d=u&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",p=l.LINES):(d=u?"fillPattern":"fill",p=l.TRIANGLES);for(const g of n){const n=r.getTile(g);if(u&&!n.patternsLoaded())continue;const y=n.getBucket(i);if(!y)continue;t.prepareDrawTile();const v=y.programConfigurations.get(i.id),x=t.useProgram(d,v);u&&(t.context.activeTexture.set(l.TEXTURE0),n.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),v.updatePaintBuffers(h));const b=c.constantOr(null);if(b&&n.imageAtlas){const e=n.imageAtlas,t=e.patternPositions[b.to.toString()],r=e.patternPositions[b.from.toString()];t&&r&&v.setConstantPatternPositions(t,r)}const w=t.translatePosMatrix(g.projMatrix,n,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(a){m=y.indexBuffer2,_=y.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===d&&u?Or(w,t,h,n,e):Rr(w,e)}else m=y.indexBuffer,_=y.segments,f=u?Br(w,t,h,n):Lr(w);t.prepareDrawProgram(t.context,x,g.toUnwrapped()),x.draw(t.context,p,o,t.stencilModeForClipping(g),s,e.CullFaceMode.disabled,f,i.id,y.layoutVertexBuffer,m,_,i.paint,t.transform.zoom,v)}}function fi(t,r,i,n,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=i.paint.get("fill-extrusion-pattern"),p=h.constantOr(1),d=i.getCrossfadeParameters(),f=i.paint.get("fill-extrusion-opacity"),m="globe"===u.projection.name?e.fillExtrusionHeightLift():0,_="globe"===u.projection.name,g=_?e.globeToMercatorTransition(u.zoom):0,y=[e.mercatorXfromLng(u.center.lng),e.mercatorYfromLat(u.center.lat)],v=[];_&&v.push("PROJECTION_GLOBE_VIEW");for(const x of n){const n=r.getTile(x),b=n.getBucket(i);if(!b||b.projection.name!==u.projection.name)continue;const w=b.programConfigurations.get(i.id),T=t.useProgram(p?"fillExtrusionPattern":"fillExtrusion",w,v);if(t.terrain){const e=t.terrain;if(t.style.terrainSetForDrapingOnly())e.setupElevationDraw(n,T,{useMeterToDem:!0});else{if(!b.enableTerrain)continue;if(e.setupElevationDraw(n,T,{useMeterToDem:!0}),mi(l,r,x,b,i,e),!b.centroidVertexBuffer){const e=T.attributes.a_centroid_pos;void 0!==e&&c.vertexAttrib2f(e,0,0)}}}p&&(t.context.activeTexture.set(c.TEXTURE0),n.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),w.updatePaintBuffers(d));const E=h.constantOr(null);if(E&&n.imageAtlas){const e=n.imageAtlas,t=e.patternPositions[E.to.toString()],r=e.patternPositions[E.from.toString()];t&&r&&w.setConstantPatternPositions(t,r)}const S=t.translatePosMatrix(x.projMatrix,n,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),C=u.projection.createInversionMatrix(u,x.canonical),A=i.paint.get("fill-extrusion-vertical-gradient"),k=p?Dr(S,t,A,f,x,d,n,m,g,y,C):Pr(S,t,A,f,x,m,g,y,C);t.prepareDrawProgram(l,T,x.toUnwrapped()),T.draw(l,l.gl.TRIANGLES,o,s,a,e.CullFaceMode.backCCW,k,i.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,i.paint,t.transform.zoom,w,t.terrain?b.centroidVertexBuffer:null,_?b.layoutVertexExtBuffer:null)}}function mi(t,r,i,n,o,s){const a=[t=>{let r=t.canonical.x-1,i=t.wrap;return r<0&&(r=(1<<t.canonical.z)-1,i--),new e.OverscaledTileID(t.overscaledZ,i,t.canonical.z,r,t.canonical.y)},t=>{let r=t.canonical.x+1,i=t.wrap;return r===1<<t.canonical.z&&(r=0,i++),new e.OverscaledTileID(t.overscaledZ,i,t.canonical.z,r,t.canonical.y)},t=>new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<<t.canonical.z:t.canonical.y)-1),t=>new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<<t.canonical.z)-1?0:t.canonical.y+1)],l=e=>{const t=r.getSource().minzoom,i=e=>{const t=r.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},n=[0,-1,1];for(const r of n){if(e.overscaledZ+r<t)continue;const n=i(e.calculateScaledKey(e.overscaledZ+r));if(n)return n}},c=[0,0,0],u=(t,r)=>(c[0]=Math.min(t.min.y,r.min.y),c[1]=Math.max(t.max.y,r.max.y),c[2]=e.EXTENT-r.min.x>t.max.x?r.min.x-e.EXTENT:t.max.x,c),h=(t,r)=>(c[0]=Math.min(t.min.x,r.min.x),c[1]=Math.max(t.max.x,r.max.x),c[2]=e.EXTENT-r.min.y>t.max.y?r.min.y-e.EXTENT:t.max.y,c),p=[(e,t)=>u(e,t),(e,t)=>u(t,e),(e,t)=>h(e,t),(e,t)=>h(t,e)],d=new e.pointGeometry(0,0);let f,m,_;const g=(t,r,n,o,a)=>{const l=[[o?n:t,o?t:n,0],[o?n:r,o?r:n,0]],c=a<0?e.EXTENT+a:a,u=[o?c:(t+r)/2,o?(t+r)/2:c,0];return 0===n&&a<0||0!==n&&a>0?s.getForTilePoints(_,[u],!0,m):l.push(u),s.getForTilePoints(i,l,!0,f),Math.max(l[0][2],l[1][2],u[2])/s.exaggeration()};for(let t=0;t<4;t++){const r=(t<2?1:5)-t,o=n.borders[t];if(0===o.length)continue;const c=_=a[t](i),u=l(c);if(!(u&&u instanceof e.FillExtrusionBucket&&u.enableTerrain))continue;if(n.borderDoneWithNeighborZ[t]===u.canonical.z&&u.borderDoneWithNeighborZ[r]===n.canonical.z)continue;if(m=s.findDEMTileFor(c),!m||!m.dem)continue;if(!f){const e=s.findDEMTileFor(i);if(!e||!e.dem)return;f=e}const h=u.borders[r];let y=0;const v=u.borderDoneWithNeighborZ[r]!==n.canonical.z;if(n.canonical.z===u.canonical.z){for(let i=0;i<o.length;i++){const s=n.featuresOnBorder[o[i]],a=s.borders[t];let l;for(;y<h.length&&(l=u.featuresOnBorder[h[y]],!(l.borders[r][1]>a[0]+3));)v&&u.encodeCentroid(void 0,l,!1),y++;if(l&&y<h.length){const i=y;let o=0;for(;!(l.borders[r][0]>a[1]-3)&&(o++,++y!==h.length);)l=u.featuresOnBorder[h[y]];if(l=u.featuresOnBorder[h[i]],s.intersectsCount()>1||l.intersectsCount()>1||1!==o){1!==o&&(y=i),n.encodeCentroid(void 0,s,!1),v&&u.encodeCentroid(void 0,l,!1);continue}const c=p[t](s,l),f=t%2?e.EXTENT-1:0;d.x=g(c[0],Math.min(e.EXTENT-1,c[1]),f,t<2,c[2]),d.y=0,n.encodeCentroid(d,s,!1),v&&u.encodeCentroid(d,l,!1)}else n.encodeCentroid(void 0,s,!1)}n.borderDoneWithNeighborZ[t]=u.canonical.z,n.needsCentroidUpdate=!0,v&&(u.borderDoneWithNeighborZ[r]=n.canonical.z,u.needsCentroidUpdate=!0)}else{for(const e of o)n.encodeCentroid(void 0,n.featuresOnBorder[e],!1);if(v){for(const e of h)u.encodeCentroid(void 0,u.featuresOnBorder[e],!1);u.borderDoneWithNeighborZ[r]=n.canonical.z,u.needsCentroidUpdate=!0}n.borderDoneWithNeighborZ[t]=u.canonical.z,n.needsCentroidUpdate=!0}}(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(t)}const _i=new e.Color(1,0,0,1),gi=new e.Color(0,1,0,1),yi=new e.Color(0,0,1,1),vi=new e.Color(1,0,1,1),xi=new e.Color(0,1,1,1);function bi(e,t,r,i){Ti(e,0,t+r/2,e.transform.width,r,i)}function wi(e,t,r,i){Ti(e,t-r/2,0,r,e.transform.height,i)}function Ti(t,r,i,n,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(r*e.exported.devicePixelRatio,i*e.exported.devicePixelRatio,n*e.exported.devicePixelRatio,o*e.exported.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}function Ei(t,r,i){const n=t.context,o=n.gl,s="globe"===t.transform.projection.name,a=i.projMatrix,l=t.useProgram("debug",null,s?["PROJECTION_GLOBE_VIEW"]:null),c=r.getTileByID(i.key);t.terrain&&t.terrain.setupElevationDraw(c,l);const u=e.DepthMode.disabled,h=e.StencilMode.disabled,p=t.colorModeForRenderPass(),d="$debug";n.activeTexture.set(o.TEXTURE0),t.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s?c._makeGlobeTileDebugBuffers(t.context,t.transform.projection):c._makeDebugTileBoundsBuffers(t.context,t.transform.projection);const f=c._tileDebugBuffer||t.debugBuffer,m=c._tileDebugIndexBuffer||t.debugIndexBuffer,_=c._tileDebugSegments||t.debugSegments;l.draw(n,o.LINE_STRIP,u,h,p,e.CullFaceMode.disabled,Vr(a,e.Color.red),d,f,m,_,null,null,null,c._globeTileDebugBorderBuffer);const g=c.latestRawTileData,y=Math.floor((g&&g.byteLength||0)/1024),v=r.getTile(i).tileSize,x=512/Math.min(v,512)*(i.overscaledZ/t.transform.zoom)*.5;let b=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(b+=` => ${i.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const r=e.debugOverlayCanvas,i=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,r.width,r.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(r),e.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}(t,`${b} ${y}kb`);const w=c._tileDebugTextBuffer||t.debugBuffer,T=c._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,E=c._tileDebugTextSegments||t.debugSegments;l.draw(n,o.TRIANGLES,u,h,e.ColorMode.alphaBlended,e.CullFaceMode.disabled,Vr(a,e.Color.transparent,x),d,w,T,E,null,null,null,c._globeTileDebugTextBuffer)}const Si=e.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Ci}=Si;function Ai(e,t,r,i){e.emplaceBack(t,r,i)}class ki{constructor(t){this.vertexArray=new e.StructArrayLayout3f12,this.indices=new e.StructArrayLayout3ui6,Ai(this.vertexArray,-1,-1,1),Ai(this.vertexArray,1,-1,1),Ai(this.vertexArray,-1,1,1),Ai(this.vertexArray,1,1,1),Ai(this.vertexArray,-1,-1,-1),Ai(this.vertexArray,1,-1,-1),Ai(this.vertexArray,-1,1,-1),Ai(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,Ci),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.SegmentVector.simpleSegment(0,0,36,12)}}function Ii(t,r,i,n,o,s){const a=t.gl,l=r.paint.get("sky-atmosphere-color"),c=r.paint.get("sky-atmosphere-halo-color"),u=r.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,r,i,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:r,u_color_tint_r:[i.r,i.g,i.b,i.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(e.fromMat4(e.create$1(),n),o,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,r.skyboxTexture,0),i.draw(t,a.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.frontCW,h,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}const Mi=e.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class zi{constructor(t){const r=new e.StructArrayLayout5f20;r.emplaceBack(-1,1,1,0,0),r.emplaceBack(1,1,1,1,0),r.emplaceBack(1,-1,1,1,1),r.emplaceBack(-1,-1,1,0,1);const i=new e.StructArrayLayout3ui6;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(r,Mi.members),this.indexBuffer=t.createIndexBuffer(i),this.segments=e.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Pi={symbol:function(t,r,i,n,o){if("translucent"!==t.renderPass)return;const s=e.StencilMode.disabled,a=t.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(t,r,i,n,o,s,a){const l=r.transform,c="map"===o,u="map"===s;for(const r of t){const t=n.getTile(r),o=t.getBucket(i);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.evaluateSizeForZoom(o.textSizeData,l.zoom),h=wt(r,o.getProjection(),l),p=l.calculatePixelsToTileUnitsMatrix(t),d=tt(h,t.tileID.canonical,u,c,l,o.getProjection(),p),f="none"!==i.layout.get("icon-text-fit")&&o.hasIconData();if(s){const i=Math.pow(2,l.zoom-t.tileID.overscaledZ);ci(o,c,u,a,e.symbolSize,l,d,r,i,s,f)}}}(n,t,i,r,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),o),0!==i.paint.get("icon-opacity").constantOr(1)&&hi(t,r,i,n,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),s,a),0!==i.paint.get("text-opacity").constantOr(1)&&hi(t,r,i,n,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),s,a),r.map.showCollisionBoxes&&(si(t,r,i,n,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),si(t,r,i,n,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(t,r,i,n){if("translucent"!==t.renderPass)return;const o=i.paint.get("circle-opacity"),s=i.paint.get("circle-stroke-width"),a=i.paint.get("circle-stroke-opacity"),l=void 0!==i.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const c=t.context,u=c.gl,h=t.transform,p=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),d=e.StencilMode.disabled,f=t.colorModeForRenderPass(),m="globe"===h.projection.name,_=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],g=[];for(let o=0;o<n.length;o++){const s=n[o],a=r.getTile(s),c=a.getBucket(i);if(!c||c.projection.name!==h.projection.name)continue;const u=c.programConfigurations.get(i.id),p=jr(i);m&&p.push("PROJECTION_GLOBE_VIEW");const d=t.useProgram("circle",u,p),f=c.layoutVertexBuffer,y=c.globeExtVertexBuffer,v=c.indexBuffer,x=h.projection.createInversionMatrix(h,s.canonical),b={programConfiguration:u,program:d,layoutVertexBuffer:f,globeExtVertexBuffer:y,indexBuffer:v,uniformValues:Nr(t,s,a,x,_,i),tile:a};if(l){const t=c.segments.get();for(const r of t)g.push({segments:new e.SegmentVector([r]),sortKey:r.sortKey,state:b})}else g.push({segments:c.segments,sortKey:0,state:b})}l&&g.sort(((e,t)=>e.sortKey-t.sortKey));const y={useDepthForOcclusion:!m};for(const r of g){const{programConfiguration:n,program:o,layoutVertexBuffer:s,globeExtVertexBuffer:a,indexBuffer:l,uniformValues:_,tile:g}=r.state,v=r.segments;t.terrain&&t.terrain.setupElevationDraw(g,o,y),t.prepareDrawProgram(c,o,g.tileID.toUnwrapped()),o.draw(c,u.TRIANGLES,p,d,f,e.CullFaceMode.disabled,_,i.id,s,l,v,i.paint,h.zoom,n,m?a:null)}},heatmap:function(t,r,i,n){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=e.StencilMode.disabled,l=new e.ColorMode([s.ONE,s.ONE],e.Color.transparent,[!0,!0,!0,!0]);!function(e,t,r,i){const n=e.gl,o=t.width*i,s=t.height*i;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=r.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=r.heatmapFbo=e.createFramebuffer(o,s,!1),function(e,t,r,i,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?e.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),i.colorAttachment.set(r)}(e,0,t,a,o,s)}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,i,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.Color.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:null,p=u?e.CullFaceMode.frontCCW:e.CullFaceMode.disabled,d=[e.mercatorXfromLng(c.center.lng),e.mercatorYfromLat(c.center.lat)];for(let f=0;f<n.length;f++){const m=n[f];if(r.hasRenderableParent(m))continue;const _=r.getTile(m),g=_.getBucket(i);if(!g||g.projection.name!==c.projection.name)continue;const y=g.programConfigurations.get(i.id),v=t.useProgram("heatmap",y,h),{zoom:x}=t.transform;t.terrain&&t.terrain.setupElevationDraw(_,v),t.prepareDrawProgram(o,v,m.toUnwrapped());const b=c.projection.createInversionMatrix(c,m.canonical);v.draw(o,s.TRIANGLES,e.DepthMode.disabled,a,l,p,Gr(t,m,_,b,d,x,i.paint.get("heatmap-intensity")),i.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,i.paint,t.transform.zoom,y,u?g.globeExtVertexBuffer:null)}o.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,r){const i=t.context,n=i.gl,o=r.heatmapFbo;if(!o)return;i.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),i.activeTexture.set(n.TEXTURE1);let s=r.colorRampTexture;s||(s=r.colorRampTexture=new e.Texture(i,r.colorRamp,n.RGBA)),s.bind(n.LINEAR,n.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(i,n.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,((e,t,r,i)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,r),r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,r.paint,t.transform.zoom)}(t,i))},line:function(t,r,i,n){if("translucent"!==t.renderPass)return;const o=i.paint.get("line-opacity"),s=i.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),l=t.colorModeForRenderPass(),c=t.terrain&&t.terrain.renderingToTexture?1:e.exported.devicePixelRatio,u=i.paint.get("line-dasharray"),h=u.constantOr(1),p=i.layout.get("line-cap"),d=i.paint.get("line-pattern"),f=d.constantOr(1),m=i.paint.get("line-gradient"),_=i.getCrossfadeParameters(),g=f?"linePattern":"line",y=t.context,v=y.gl,x=(e=>{const t=[];Xr(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const r=e.paint.get("line-trim-offset");0===r[0]&&0===r[1]||t.push("RENDER_LINE_TRIM_OFFSET");const i=e.paint.get("line-pattern").constantOr(1),n=1!==e.paint.get("line-opacity").constantOr(1);return!i&&n&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(i);let b=x.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const o of n){const n=r.getTile(o);if(f&&!n.patternsLoaded())continue;const s=n.getBucket(i);if(!s)continue;t.prepareDrawTile();const w=s.programConfigurations.get(i.id),T=t.useProgram(g,w,x),E=d.constantOr(null);if(E&&n.imageAtlas){const e=n.imageAtlas,t=e.patternPositions[E.to.toString()],r=e.patternPositions[E.from.toString()];t&&r&&w.setConstantPatternPositions(t,r)}const S=u.constantOr(null),C=p.constantOr(null);if(!f&&S&&C&&n.lineAtlas){const e=n.lineAtlas,t=e.getDash(S.to,C),r=e.getDash(S.from,C);t&&r&&w.setConstantPatternPositions(t,r)}let[A,k]=i.paint.get("line-trim-offset");if("round"===C||"square"===C){const e=1;A!==k&&(0===A&&(A-=e),1===k&&(k+=e))}const I=t.terrain?o.projMatrix:null,M=f?Zr(t,n,i,_,I,c):$r(t,n,i,_,I,s.lineClipsArray.length,c,[A,k]);if(m){const n=s.gradients[i.id];let a=n.texture;if(i.gradientVersion!==n.version){let l=256;if(i.stepInterpolant){const i=r.getSource().maxzoom,n=o.canonical.z===i?Math.ceil(1<<t.transform.maxZoom-o.canonical.z):1;l=e.clamp(e.nextPowerOfTwo(s.maxLineLength/e.EXTENT*1024*n),256,y.maxTextureSize)}n.gradient=e.renderColorRamp({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:n.gradient||void 0,clips:s.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new e.Texture(y,n.gradient,v.RGBA),n.version=i.gradientVersion,a=n.texture}y.activeTexture.set(v.TEXTURE1),a.bind(i.stepInterpolant?v.NEAREST:v.LINEAR,v.CLAMP_TO_EDGE)}h&&(y.activeTexture.set(v.TEXTURE0),n.lineAtlasTexture.bind(v.LINEAR,v.REPEAT),w.updatePaintBuffers(_)),f&&(y.activeTexture.set(v.TEXTURE0),n.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),w.updatePaintBuffers(_)),t.prepareDrawProgram(y,T,o.toUnwrapped());const z=r=>{T.draw(y,v.TRIANGLES,a,r,l,e.CullFaceMode.disabled,M,i.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,i.paint,t.transform.zoom,w,s.layoutVertexBuffer2)};if(b){const r=t.stencilModeForClipping(o).ref;0===r&&t.terrain&&y.clear({stencil:0});const i={func:v.EQUAL,mask:255};M.u_alpha_discard_threshold=.8,z(new e.StencilMode(i,r,255,v.KEEP,v.KEEP,v.INVERT)),M.u_alpha_discard_threshold=0,z(new e.StencilMode(i,r,255,v.KEEP,v.KEEP,v.KEEP))}else z(t.stencilModeForClipping(o))}b&&(t.resetStencilClippingMasks(),t.terrain&&y.clear({stencil:0}))},fill:function(t,r,i,n){const o=i.paint.get("fill-color"),s=i.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=t.colorModeForRenderPass(),l=i.paint.get("fill-pattern"),c=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(e.Color.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===c){const o=t.depthModeForSublayer(1,"opaque"===t.renderPass?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly);di(t,r,i,n,o,a,!1)}if("translucent"===t.renderPass&&i.paint.get("fill-antialias")){const o=t.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,e.DepthMode.ReadOnly);di(t,r,i,n,o,a,!0)}},"fill-extrusion":function(t,r,i,n){const o=i.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===t.renderPass){const s=new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);if(1!==o||i.paint.get("fill-extrusion-pattern").constantOr(1))fi(t,r,i,n,s,e.StencilMode.disabled,e.ColorMode.disabled),fi(t,r,i,n,s,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const o=t.colorModeForRenderPass();fi(t,r,i,n,s,e.StencilMode.disabled,o)}}},hillshade:function(t,r,i,n){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const o=t.context,s=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),a=t.colorModeForRenderPass(),l=t.terrain&&t.terrain.renderingToTexture,[c,u]="translucent"!==t.renderPass||l?[{},n]:t.stencilConfigForOverlap(n);for(const n of u){const o=r.getTile(n);if(o.needsHillshadePrepare&&"offscreen"===t.renderPass)fr(t,o,i,s,e.StencilMode.disabled,a);else if("translucent"===t.renderPass){const e=l&&t.terrain?t.terrain.stencilModeForRTTOverlap(n):c[n.overscaledZ];pr(t,n,o,i,s,e,a)}}o.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,r,i,n,o,s){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!n.length)return;const a=t.context,l=a.gl,c=r.getSource(),u=t.useProgram("raster"),h=t.colorModeForRenderPass(),p=t.terrain&&t.terrain.renderingToTexture,[d,f]=c instanceof Me||p?[{},n]:t.stencilConfigForOverlap(n),m=f[f.length-1].overscaledZ,_=!t.options.moving;for(const n of f){const o=p?e.DepthMode.disabled:t.depthModeForSublayer(n.overscaledZ-m,1===i.paint.get("raster-opacity")?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly,l.LESS),f=n.toUnwrapped(),g=r.getTile(n);if(p&&(!g||!g.hasData()))continue;const y=p?n.projMatrix:t.transform.calculateProjMatrix(f,_),v=t.terrain&&p?t.terrain.stencilModeForRTTOverlap(n):d[n.overscaledZ],x=s?0:i.paint.get("raster-fade-duration");g.registerFadeDuration(x);const b=r.findLoadedParent(n,0),w=Tr(g,b,r,t.transform,x);let T,E;t.terrain&&t.terrain.prepareDrawTile();const S="nearest"===i.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;a.activeTexture.set(l.TEXTURE0),g.texture.bind(S,l.CLAMP_TO_EDGE),a.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),T=Math.pow(2,b.tileID.overscaledZ-g.tileID.overscaledZ),E=[g.tileID.canonical.x*T%1,g.tileID.canonical.y*T%1]):g.texture.bind(S,l.CLAMP_TO_EDGE);const C=Yr(y,E||[0,0],T||1,w,i,c instanceof Me?c.perspectiveTransform:[0,0]);if(t.prepareDrawProgram(a,u,f),c instanceof Me)c.boundsBuffer&&c.boundsSegments&&u.draw(a,l.TRIANGLES,o,e.StencilMode.disabled,h,e.CullFaceMode.disabled,C,i.id,c.boundsBuffer,t.quadTriangleIndexBuffer,c.boundsSegments);else{const{tileBoundsBuffer:r,tileBoundsIndexBuffer:n,tileBoundsSegments:s}=t.getTileBoundsBuffers(g);u.draw(a,l.TRIANGLES,o,v,h,e.CullFaceMode.disabled,C,i.id,r,n,s)}}t.resetStencilClippingMasks()},background:function(t,r,i,n){const o=i.paint.get("background-color"),s=i.paint.get("background-opacity");if(0===s)return;const a=t.context,l=a.gl,c=t.transform,u=c.tileSize,h=i.paint.get("background-pattern");if(t.isPatternMissing(h))return;const p=!h&&1===o.a&&1===s&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==p)return;const d=e.StencilMode.disabled,f=t.depthModeForSublayer(0,"opaque"===p?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly),m=t.colorModeForRenderPass(),_=t.useProgram(h?"backgroundPattern":"background");let g,y=n;y||(g=t.getBackgroundTiles(),y=Object.values(g).map((e=>e.tileID))),h&&(a.activeTexture.set(l.TEXTURE0),t.imageManager.bind(t.context));const v=i.getCrossfadeParameters();for(const p of y){const y=p.toUnwrapped(),x=n?p.projMatrix:t.transform.calculateProjMatrix(y);t.prepareDrawTile();const b=r?r.getTile(p):g?g[p.key]:new e.Tile(p,u,c.zoom,t),w=h?ii(x,s,t,h,{tileID:p,tileSize:u},v):ri(x,s,o);t.prepareDrawProgram(a,_,y);const{tileBoundsBuffer:T,tileBoundsIndexBuffer:E,tileBoundsSegments:S}=t.getTileBoundsBuffers(b);_.draw(a,l.TRIANGLES,f,d,m,e.CullFaceMode.disabled,w,i.id,T,E,S)}},sky:function(t,r,i){const n=t.transform,o="mercator"===n.projection.name||"globe"===n.projection.name?1:e.smoothstep(7,8,n.zoom),s=i.paint.get("sky-opacity")*o;if(0===s)return;const a=t.context,l=i.paint.get("sky-type"),c=new e.DepthMode(a.gl.LEQUAL,e.DepthMode.ReadOnly,[0,1]),u=t.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===t.renderPass?i.needsSkyboxCapture(t)&&(function(t,r,i,n){const o=t.context,s=o.gl;let a=r.skyboxFbo;if(!a){a=r.skyboxFbo=o.createFramebuffer(32,32,!1),r.skyboxGeometry=new ki(o),r.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,r.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let e=0;e<6;++e)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,32,32]);const l=r.getCenter(t,!0),c=t.useProgram("skyboxCapture"),u=new Float64Array(16);e.identity(u),e.rotateY(u,u,.5*-Math.PI),Ii(o,r,c,u,l,0),e.identity(u),e.rotateY(u,u,.5*Math.PI),Ii(o,r,c,u,l,1),e.identity(u),e.rotateX(u,u,.5*-Math.PI),Ii(o,r,c,u,l,2),e.identity(u),e.rotateX(u,u,.5*Math.PI),Ii(o,r,c,u,l,3),e.identity(u),Ii(o,r,c,u,l,4),e.identity(u),e.rotateY(u,u,Math.PI),Ii(o,r,c,u,l,5),o.viewport.set([0,0,t.width,t.height])}(t,i),i.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,r,i,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.useProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,r.skyboxTexture);const u=((e,t,r,i,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:i,u_temporal_offset:n}))(l.skyboxMatrix,r.getCenter(t,!1),0,n,o);t.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,i,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,u,"skybox",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}(t,i,c,s,u):"gradient"===l&&"sky"===t.renderPass&&function(t,r,i,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.useProgram("skyboxGradient");r.skyboxGeometry||(r.skyboxGeometry=new ki(s)),s.activeTexture.set(a.TEXTURE0);let u=r.colorRampTexture;u||(u=r.colorRampTexture=new e.Texture(s,r.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,r,i,n,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:r,u_radius:e.degToRad(i),u_opacity:n,u_temporal_offset:o}))(l.skyboxMatrix,r.getCenter(t,!1),r.paint.get("sky-gradient-radius"),n,o);t.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,i,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,h,"skyboxGradient",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}(t,i,c,s,u)},debug:function(e,t,r){for(let i=0;i<r.length;i++)Ei(e,t,r[i])},custom:function(t,r,i){const n=t.context,o=i.implementation;if(t.transform.projection.unsupportedLayers&&t.transform.projection.unsupportedLayers.includes("custom"))e.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if("offscreen"===t.renderPass){const e=o.prerender;e&&(t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),e.call(o,n.gl,t.transform.customLayerMatrix()),n.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),n.setStencilMode(e.StencilMode.disabled);const r="3d"===o.renderingMode?new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,e.DepthMode.ReadOnly);n.setDepthMode(r),o.render(n.gl,t.transform.customLayerMatrix()),n.setDirty(),t.setBaseState(),n.bindFramebuffer.set(null)}}};class Di{constructor(t,r){this.context=new Ce(t),this.transform=r,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=e.SourceCache.maxUnderzooming+e.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Ht,this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(e,t){const r=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(r||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Ar(this,e));const i=this._terrain;this.transform.elevation=r?i:null,i.update(e,this.transform,t)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[r,i]=t.getFovAdjustedRange(this.transform._fov);if(r>i)return void(this.transform.fogCullDistSq=null);const n=r+.78*(i-r);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(t,r){if(this.width=t*e.exported.devicePixelRatio,this.height=r*e.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._layers[e].resize()}setup(){const t=this.context,r=new e.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(e.EXTENT,0),r.emplaceBack(0,e.EXTENT),r.emplaceBack(e.EXTENT,e.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(r,e.posAttributes.members),this.tileExtentSegments=e.SegmentVector.simpleSegment(0,0,4,2);const i=new e.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(e.EXTENT,0),i.emplaceBack(0,e.EXTENT),i.emplaceBack(e.EXTENT,e.EXTENT),this.debugBuffer=t.createVertexBuffer(i,e.posAttributes.members),this.debugSegments=e.SegmentVector.simpleSegment(0,0,4,5);const n=new e.StructArrayLayout2i4;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,e.posAttributes.members),this.viewportSegments=e.SegmentVector.simpleSegment(0,0,4,2);const o=new e.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(e.EXTENT,0,e.EXTENT,0),o.emplaceBack(0,e.EXTENT,0,e.EXTENT),o.emplaceBack(e.EXTENT,e.EXTENT,e.EXTENT,e.EXTENT),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.boundsAttributes.members),this.mercatorBoundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);const s=new e.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.StructArrayLayout1ui2;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.Texture(t,new e.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.create();const l=this.context.gl;this.stencilClearMode=new e.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(e.window.performance.now()),this.atmosphereBuffer=new zi(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context,r=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(t,r.TRIANGLES,e.DepthMode.disabled,this.stencilClearMode,e.ColorMode.disabled,e.CullFaceMode.disabled,wr(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,r,i){if(!r||this.currentStencilSource===r.id||!t.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=r.id;const n=this.context,o=n.gl;this.nextStencilID+i.length>256&&this.clearStencil(),n.setColorMode(e.ColorMode.disabled),n.setDepthMode(e.DepthMode.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of i){const i=r.getTile(t),a=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:u}=this.getTileBoundsBuffers(i);s.draw(n,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},a,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,wr(t.projMatrix),"$clipping",l,c,u)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,r=this.context.gl;return new e.StencilMode({func:r.NOTEQUAL,mask:255},t,255,r.KEEP,r.KEEP,r.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const r=this.context.gl;return new e.StencilMode({func:r.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,r.KEEP,r.KEEP,r.REPLACE)}stencilConfigForOverlap(t){const r=this.context.gl,i=t.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),n=i[i.length-1].overscaledZ,o=i[0].overscaledZ-n+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const t={};for(let i=0;i<o;i++)t[i+n]=new e.StencilMode({func:r.GEQUAL,mask:255},i+this.nextStencilID,255,r.KEEP,r.KEEP,r.REPLACE);return this.nextStencilID+=o,[t,i]}return[{[n]:e.StencilMode.disabled},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const r=1/8;return new e.ColorMode([t.CONSTANT_COLOR,t.ONE],new e.Color(r,r,r,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?e.ColorMode.unblended:e.ColorMode.alphaBlended}depthModeForSublayer(t,r,i){if(!this.opaquePassEnabledForLayer())return e.DepthMode.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new e.DepthMode(i||this.context.gl.LEQUAL,r,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,r){this.style=t,this.options=r,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.exported.now()),this.imageManager.beginFrame();const i=this.style.order,n=this.style._sourceCaches;for(const e in n){const t=n[e];t.used&&t.prepare(this.context)}const o={},s={},a={};for(const e in n){const t=n[e];o[e]=t.getVisibleCoordinates(),s[e]=o[e].slice().reverse(),a[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<i.length;e++)if(this.style._layers[i[e]].is3D()){this.opaquePassCutoff=e;break}if(this.terrain&&(this.terrain.updateTileBinding(a),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.GlobeSharedBuffers(this.context)),e.isMapAuthenticated(this.context.gl)){this.renderPass="offscreen";for(const e of i){const r=this.style._layers[e],i=t._getLayerSourceCache(r);if(!r.hasOffscreenPass()||r.isHidden(this.transform.zoom))continue;const n=i?s[i.id]:void 0;("custom"===r.type||r.isSky()||n&&n.length)&&this.renderLayer(this,i,r,n)}if(this.depthRangeFor3D=[0,1-(t.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]),this.context.clear({color:r.showOverdrawInspector?e.Color.black:e.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=r.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[i[this.currentLayer]],r=t._getLayerSourceCache(e);if(e.isSky())continue;const n=r?s[r.id]:void 0;this._renderTileClippingMasks(e,r,n),this.renderLayer(this,r,e,n)}if(this.style.fog&&this.transform.projection.supportsFog&&function(t,r){const i=t.context,n=i.gl,o=t.transform,s=new e.DepthMode(n.LEQUAL,e.DepthMode.ReadOnly,[0,1]),a=t.useProgram("globeAtmosphere",null,"globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=e.globeToMercatorTransition(o.zoom),c=r.properties.get("color").toArray01(),u=r.properties.get("high-color").toArray01(),h=r.properties.get("space-color").toArray01PremultipliedAlpha(),p=e.identity$1([]);e.rotateY$1(p,p,-e.degToRad(o._center.lng)),e.rotateX$1(p,p,e.degToRad(o._center.lat)),e.rotateZ$1(p,p,o.angle),e.rotateX$1(p,p,-o._pitch);const d=e.fromQuat(new Float32Array(16),p),f=e.mapValue(r.properties.get("star-intensity"),0,1,0,.25),m=5e-4,_=e.mapValue(r.properties.get("horizon-blend"),0,1,m,.25),g=e.globeUseCustomAntiAliasing(t,i,o)&&_===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=t.frameCounter/1e3%1,v=e.length(o.globeCenterInViewSpace),x=Math.sqrt(Math.pow(v,2)-Math.pow(g,2)),b=Math.acos(x/v),w=((t,r,i,n,o,s,a,l,c,u,h,p,d,f)=>({u_frustum_tl:t,u_frustum_tr:r,u_frustum_br:i,u_frustum_bl:n,u_horizon:o,u_transition:s,u_fadeout_range:a,u_color:l,u_high_color:c,u_space_color:u,u_star_intensity:h,u_star_size:5*e.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:p,u_horizon_angle:d,u_rotation_matrix:f}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,l,_,c,u,h,f,y,b,d);t.prepareDrawProgram(i,a);const T=t.atmosphereBuffer;T&&a.draw(i,n.TRIANGLES,s,e.StencilMode.disabled,e.ColorMode.alphaBlended,e.CullFaceMode.backCW,w,"skybox",T.vertexBuffer,T.indexBuffer,T.segments)}(this,this.style.fog),this.renderPass="sky",(e.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){const e=this.style._layers[i[this.currentLayer]],r=t._getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,r,e,r?s[r.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<i.length;){const e=this.style._layers[i[this.currentLayer]],r=t._getLayerSourceCache(e);if(e.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const n=r?("symbol"===e.type?a:s)[r.id]:void 0;this._renderTileClippingMasks(e,r,r?o[r.id]:void 0),this.renderLayer(this,r,e,n),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let r=null;e.values(this.style._layers).forEach((e=>{const i=t._getLayerSourceCache(e);i&&!e.isHidden(this.transform.zoom)&&(!r||r.getSource().maxzoom<i.getSource().maxzoom)&&(r=i)})),r&&this.options.showTileBoundaries&&Pi.debug(this,r,r.getVisibleCoordinates())}this.options.showPadding&&function(e){const t=e.transform.padding;bi(e,e.transform.height-(t.top||0),3,_i),bi(e,t.bottom||0,3,gi),wi(e,t.left||0,3,yi),wi(e,e.transform.width-(t.right||0),3,vi);const r=e.transform.centerPoint;!function(e,t,r,i){Ti(e,t-1,r-10,2,20,i),Ti(e,t-10,r-1,20,2,i)}(e,r.x,e.transform.height-r.y,xi)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(e.window.performance.now()),this.saveCanvasCopy())}}renderLayer(e,t,r,i){r.isHidden(this.transform.zoom)||("background"===r.type||"sky"===r.type||"custom"===r.type||i&&i.length)&&(this.id=r.id,this.gpuTimingStart(r),e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes(r.type)||Pi[r.type](e,t,r,i,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;let r=this.gpuTimers[e.id];r||(r=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:t.createQueryEXT()}),r.calls++,t.beginQueryEXT(t.TIME_ELAPSED_EXT,r.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=e.createQueryEXT();this.deferredRenderGpuTimeQueries.push(t),e.beginQueryEXT(e.TIME_ELAPSED_EXT,t)}}gpuTimingDeferredRenderEnd(){if(!this.options.gpuTimingDeferredRender)return;const e=this.context.extTimerQuery;e.endQueryEXT(e.TIME_ELAPSED_EXT)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;e.endQueryEXT(e.TIME_ELAPSED_EXT)}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const r in e){const i=e[r],n=this.context.extTimerQuery,o=n.getQueryObjectEXT(i.query,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(i.query),t[r]=o}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.extTimerQuery;let r=0;for(const i of e)r+=t.getQueryObjectEXT(i,t.QUERY_RESULT_EXT)/1e6,t.deleteQueryEXT(i);return r}translatePosMatrix(t,r,i,n,o){if(!i[0]&&!i[1])return t;const s=o?"map"===n?this.transform.angle:0:"viewport"===n?-this.transform.angle:0;if(s){const e=Math.sin(s),t=Math.cos(s);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}const a=[o?i[0]:D(r,i[0],this.transform.zoom),o?i[1]:D(r,i[1],this.transform.zoom),0],l=new Float32Array(16);return e.translate(l,t,a),l}saveTileTexture(e){const t=this._tileTextures[e.size[0]];t?t.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),r=this.imageManager.getPattern(e.to.toString());return!t||!r}currentGlobalDefines(){const e=this.terrain&&this.terrain.renderingToTexture,t=this.style&&this.style.fog,r=[];return this.terrain&&!this.terrain.renderingToTexture&&r.push("TERRAIN"),t&&!e&&0!==t.getOpacity(this.transform.pitch)&&r.push("FOG"),e&&r.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&r.push("OVERDRAW_INSPECTOR"),r}useProgram(e,t,r){this.cache=this.cache||{};const i=r||[],n=this.currentGlobalDefines().concat(i),o=Ir.cacheKey(e,n,t);return this.cache[o]||(this.cache[o]=new Ir(this.context,e,lr[e],t,ni[e],n)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=e.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.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(t,r,i){if(this.terrain&&this.terrain.renderingToTexture)return;const n=this.style.fog;if(n){const o=n.getOpacity(this.transform.pitch),s=((t,r,i,n,o,s,a,l,c,u,h)=>{const p=t.transform,d=r.properties.get("color").toArray01();d[3]=n;const f=t.frameCounter/1e3%1;return{u_fog_matrix:i?p.calculateFogTileMatrix(i):t.identityMat,u_fog_range:r.getFovAdjustedRange(p._fov),u_fog_color:d,u_fog_horizon_blend:r.properties.get("horizon-blend"),u_fog_temporal_offset:f,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.globeToMercatorTransition(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,n,i,o,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.exported.devicePixelRatio,this.transform.height*e.exported.devicePixelRatio]);r.setFogUniformValues(t,s)}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,r=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const n of i)r[n.key]=t[n.key]||new e.Tile(n,512,this.transform.tileZoom,this);return r}clearBackgroundTiles(){this._backgroundTiles={}}}class Li{constructor(e=0,t=0,r=0,i=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(r)||r<0||isNaN(i)||i<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=r,this.right=i}interpolate(t,r,i){return null!=r.top&&null!=t.top&&(this.top=e.number(t.top,r.top,i)),null!=r.bottom&&null!=t.bottom&&(this.bottom=e.number(t.bottom,r.bottom,i)),null!=r.left&&null!=t.left&&(this.left=e.number(t.left,r.left,i)),null!=r.right&&null!=t.right&&(this.right=e.number(t.right,r.right,i)),this}getCenter(t,r){const i=e.clamp((this.left+t-this.right)/2,0,t),n=e.clamp((this.top+r-this.bottom)/2,0,r);return new e.pointGeometry(i,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Li(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Bi(t,r){const i=e.getColumn(t,3);e.fromQuat(t,r),e.setColumn(t,3,i)}function Ri(t,r){const i=e.identity$1([]);return e.rotateZ$1(i,i,-r),e.rotateX$1(i,i,-t),i}function Oi(t,r){const i=[t[0],t[1],0],n=[r[0],r[1],0];if(e.length(i)>=1e-15){const t=e.normalize([],i);e.scale$2(n,t,e.dot(n,t)),r[0]=n[0],r[1]=n[1]}const o=e.cross([],r,t);if(e.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Ri(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class Fi{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const r=t instanceof e.MercatorCoordinate?t:new e.MercatorCoordinate(t[0],t[1],t[2]);this._renderWorldCopies&&(r.x=e.wrap(r.x,0,1)),this._position=r}else this._position=null}lookAtPoint(t,r){if(this.orientation=null,!this.position)return;const i=this._elevation?this._elevation.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(t)):0,n=this.position,o=e.MercatorCoordinate.fromLngLat(t,i),s=[o.x-n.x,o.y-n.y,o.z-n.z];r||(r=[0,0,1]),r[2]=Math.abs(r[2]),this.orientation=Oi(s,r)}setPitchBearing(t,r){this.orientation=Ri(e.degToRad(t),e.degToRad(-r))}}class Ni{constructor(t,r){this._transform=e.identity([]),this.orientation=r,this.position=t}get mercatorPosition(){const t=this.position;return new e.MercatorCoordinate(t[0],t[1],t[2])}get position(){const t=e.getColumn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var r;t&&e.setColumn(this._transform,3,[(r=t)[0],r[1],r[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.identity$1([]),t&&Bi(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Ri(e,t),Bi(this._transform,this._orientation)}forward(){const t=e.getColumn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.getColumn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.getColumn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,r){const i=new Float64Array(16);return e.invert(i,this.getWorldToCamera(t,r)),i}getWorldToCameraPosition(t,r,i){const n=this.position;e.scale$2(n,n,-t);const o=new Float64Array(16);return e.fromScaling(o,[i,i,i]),e.translate(o,o,n),o[10]*=r,o}getWorldToCamera(t,r){const i=new Float64Array(16),n=new Float64Array(4),o=this.position;return e.conjugate(n,this._orientation),e.scale$2(o,o,-t),e.fromQuat(i,n),e.translate(i,i,o),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=r,i[9]*=r,i[10]*=r,i[11]*=r,i}getCameraToClipPerspective(t,r,i,n){const o=new Float64Array(16);return e.perspective(o,t,r,i,n),o}getDistanceToElevation(t){const r=0===t?0:e.mercatorZfromAltitude(t,this.position[1]),i=this.forward();return(r-this.position[2])/i[2]}clone(){return new Ni([...this.position],[...this.orientation])}}function ji(t,r){const i=Vi(t.projection,t.zoom,t.width,t.height),n=function(t,r,i,n,o){const s=new e.LngLat(i.lng-180*qi,i.lat),a=new e.LngLat(i.lng+180*qi,i.lat),l=t.project(s.lng,s.lat),c=t.project(a.lng,a.lat),u=-Math.atan2(c.y-l.y,c.x-l.x),h=e.MercatorCoordinate.fromLngLat(i);h.y=e.clamp(h.y,-.999975,.999975);const p=h.toLngLat(),d=t.project(p.lng,p.lat),f=e.MercatorCoordinate.fromLngLat(p);f.x+=qi;const m=f.toLngLat(),_=t.project(m.lng,m.lat),g=$i(_.x-d.x,_.y-d.y,u),y=e.MercatorCoordinate.fromLngLat(p);y.y+=qi;const v=y.toLngLat(),x=t.project(v.lng,v.lat),b=$i(x.x-d.x,x.y-d.y,u),w=Math.abs(g.x)/Math.abs(b.y),T=e.identity([]);e.rotateZ(T,T,-u*(1-(o?0:n)));const E=e.identity([]);return e.scale(E,E,[1,1-(1-w)*n,1]),E[4]=-b.x/b.y*n,e.rotateZ(E,E,u),e.multiply(E,T,E),E}(t.projection,0,t.center,i,r),o=Ui(t);return e.scale(n,n,[o,o,1]),n}function Ui(t){const r=t.projection,i=Vi(t.projection,t.zoom,t.width,t.height),n=Gi(r,t.center),o=Gi(r,e.LngLat.convert(r.center));return Math.pow(2,n*i+(1-i)*o)}function Vi(t,r,i,n,o=1/0){const s=t.range;if(!s)return 0;const a=Math.min(o,Math.max(i,n)),l=Math.log(a/1024)/Math.LN2;return e.smoothstep(s[0]+l,s[1]+l,r)}const qi=1/4e4;function Gi(t,r){const i=e.clamp(r.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),n=new e.LngLat(r.lng-180*qi,i),o=new e.LngLat(r.lng+180*qi,i),s=t.project(n.lng,i),a=t.project(o.lng,i),l=e.MercatorCoordinate.fromLngLat(n),c=e.MercatorCoordinate.fromLngLat(o),u=a.x-s.x,h=a.y-s.y,p=c.x-l.x,d=c.y-l.y,f=Math.sqrt((p*p+d*d)/(u*u+h*h));return Math.log(f)/Math.LN2}function $i(e,t,r){const i=Math.cos(r),n=Math.sin(r);return{x:e*i-t*n,y:e*n+t*i}}class Zi{constructor(t,r,i,n,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=r||22,this._minPitch=null==i?0:i,this._maxPitch=null==n?60:n,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.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 Li,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Ni,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const e=new Zi(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(e){const t=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||t)&&this._updateCameraOnTerrain(),(e||t)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return e.pick(this.projection,["name","center","parallels"])}setProjection(r){this.projectionOptions=r||{name:"mercator"};const i=this.projection?this.getProjection():void 0;this.projection=e.getProjection(this.projectionOptions);const n=!t(i,this.getProjection());return n&&this._calcMatrices(),n}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.mercatorZfromAltitude(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.pointGeometry(this.width,this.height)}get bearing(){return e.wrap(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const r=-t*Math.PI/180;var i;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=(i=new e.ARRAY_TYPE(4),e.ARRAY_TYPE!=Float32Array&&(i[1]=0,i[2]=0),i[0]=1,i[3]=1,i),function(e,t,r){var i=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(r),l=Math.cos(r);e[0]=i*l+o*a,e[1]=n*l+s*a,e[2]=i*-a+o*l,e[3]=n*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const r=e.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-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 e=this._elevation;this._centerAltitude=e.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=e.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,r=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let n=0,o=0;for(let s=0;s<r.length;s++){const a=new e.pointGeometry(r[s][0]*this.width,i+r[s][1]*(this.height-i)),l=t.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);n+=l[3]*c,o+=c}return 0===o?NaN:n/o}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),r=this.pixelsPerMeter/this.worldSize*t,i=this._mercatorZfromZoom(e),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(i-r,n);this._setZoom(this._zoomFromMercatorZ(o))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}computeZoomRelativeTo(t){const r=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let i;i=t.z<this._camera.position[2]?[r.x,r.y,r.z]:[t.x,t.y,t.z];const n=e.length(e.sub([],this._camera.position,i));return e.clamp(this._zoomFromMercatorZ(n),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let r=!1;if(t.orientation&&!e.exactEquals(t.orientation,this._camera.orientation)&&(r=this._setCameraOrientation(t.orientation)),t.position){const i=[t.position.x,t.position.y,t.position.z];e.exactEquals$1(i,this._camera.position)||(this._setCameraPosition(i),r=!0)}r&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,r=new Fi;return r.position=new e.MercatorCoordinate(t[0],t[1],t[2]),r.orientation=this._camera.orientation,r._elevation=this.elevation,r._renderWorldCopies=this.renderWorldCopies,r}_setCameraOrientation(t){if(!e.length$1(t))return!1;e.normalize$1(t,t);const r=e.transformQuat([],[0,0,-1],t),i=e.transformQuat([],[0,-1,0],t);if(i[2]<0)return!1;const n=Oi(r,i);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(t){const r=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,n=this.cameraToCenterDistance;t[2]=e.clamp(t[2],n/i,n/r),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,r){this._unmodified=!1,this._edgeInsets.interpolate(e,t,r),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(t){const r=[new e.UnwrappedTileID(0,t)];if(this.renderWorldCopies){const i=this.pointCoordinate(new e.pointGeometry(0,0)),n=this.pointCoordinate(new e.pointGeometry(this.width,0)),o=this.pointCoordinate(new e.pointGeometry(this.width,this.height)),s=this.pointCoordinate(new e.pointGeometry(0,this.height)),a=Math.floor(Math.min(i.x,n.x,o.x,s.x)),l=Math.floor(Math.max(i.x,n.x,o.x,s.x)),c=1;for(let i=a-c;i<=l+c;i++)0!==i&&r.push(new e.UnwrappedTileID(i,t))}return r}coveringTiles(t){let r=this.coveringZoomLevel(t);const i=r,n=this.elevation&&!t.isTerrainDEM,o="mercator"===this.projection.name;if(void 0!==t.minzoom&&r<t.minzoom)return[];void 0!==t.maxzoom&&r>t.maxzoom&&(r=t.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<<r,c=[l*s.x,l*s.y,0],u="globe"===this.projection.name,h=!u,p=e.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r,h),d=u?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),f=l*e.mercatorZfromAltitude(1,this.center.lat),m=this._camera.position[2]/e.mercatorZfromAltitude(1,this.center.lat),_=[l*d.x,l*d.y,m*(h?1:f)],g=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),y=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?r:0,v=t.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,x=t.isTerrainDEM?-v:this._elevation?this._elevation.getMinElevationBelowMSL():0,b=this.projection.isReprojectedInTileSpace?Ui(this):1,w=t=>{const r=1/4e4,i=new e.MercatorCoordinate(t.x+r,t.y,t.z),n=new e.MercatorCoordinate(t.x,t.y+r,t.z),o=t.toLngLat(),s=i.toLngLat(),a=n.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),p=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*p)*b/r},T=t=>{const r=v,i=x;return{aabb:e.tileAABB(this,l,0,0,0,t,i,r,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:r,wrap:t,fullyVisible:!1}},E=[];let S=[];const C=r,A=t.reparseOverscaled?i:r,k=e=>e*e,I=k((m-this._centerAltitude)*f),M=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),r=e.aabb;t?(r.min[2]=t.min,r.max[2]=t.max,r.center[2]=(r.min[2]+r.max[2])/2):(e.shouldSplit=z(e),e.shouldSplit||(r.min[2]=r.max[2]=r.center[2]=this._centerAltitude))},z=t=>{if(t.zoom<y)return!0;if(t.zoom===C)return!1;if(null!=t.shouldSplit)return t.shouldSplit;const r=t.aabb.distanceX(_),o=t.aabb.distanceY(_);let s=I,l=1;if(u){s=k(t.aabb.distanceZ(_));const r=Math.pow(2,t.zoom),i=e.latFromMercatorY((t.y+1)/r),n=e.latFromMercatorY(t.y/r),o=Math.min(Math.max(a,i),n),c=e.circumferenceAtLatitude(o)/e.circumferenceAtLatitude(a);if(l=o===a?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,c/this._mercatorScaleRatio),this.zoom<=e.GLOBE_ZOOM_THRESHOLD_MIN&&t.zoom===C-1&&c>=.9)return!0}else if(n&&(s=k(t.aabb.distanceZ(_)*f)),this.projection.isReprojectedInTileSpace&&i<=5){const r=Math.pow(2,t.zoom),i=w(new e.MercatorCoordinate((t.x+.5)/r,(t.y+.5)/r));l=i>.85?1:i}const c=r*r+o*o+s;return c<k((1<<C-t.zoom)*g*l*((e,t)=>{if(t*k(.707)<e)return 1;const r=Math.sqrt(t/e);return r/(1.4144271570014144+(Math.pow(1.1,r-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(s,I),c))};if(this.renderWorldCopies)for(let e=1;e<=3;e++)E.push(T(-e)),E.push(T(e));for(E.push(T(0));E.length>0;){const i=E.pop(),s=i.x,a=i.y;let h=i.fullyVisible;if(!h){const e=i.aabb.intersects(p);if(0===e)continue;h=2===e}if(i.zoom!==C&&z(i))for(let t=0;t<4;t++){const r=(s<<1)+t%2,c=(a<<1)+(t>>1),p={aabb:o?i.aabb.quadrant(t):e.tileAABB(this,l,i.zoom+1,r,c,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:r,y:c,wrap:i.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};n&&!u&&(p.tileID=new e.OverscaledTileID(i.zoom+1===C?A:i.zoom+1,i.wrap,i.zoom+1,r,c),M(p)),E.push(p)}else{const n=i.zoom===C?A:i.zoom;if(t.minzoom&&t.minzoom>n)continue;const o=c[0]-(.5+s+(i.wrap<<i.zoom))*(1<<r-i.zoom),l=c[1]-.5-a,u=i.tileID?i.tileID:new e.OverscaledTileID(n,i.wrap,i.zoom,s,a);S.push({tileID:u,distanceSq:o*o+l*l})}}if(this.fogCullDistSq){const r=this.fogCullDistSq,i=this.horizonLineFromTop();S=S.filter((n=>{const o=[0,0,0,1],s=[e.EXTENT,e.EXTENT,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());e.transformMat4$1(o,o,a),e.transformMat4$1(s,s,a);const l=e.getAABBPointSquareDist(o,s);if(0===l)return!0;let c=!1;const u=this._elevation;if(u&&l>r&&0!==i){const r=this.calculateProjMatrix(n.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=u.getMinMaxForTile(n.tileID)),o||(o={min:x,max:v});const s=e.furthestTileCorner(this.rotation),a=[s[0]*e.EXTENT,s[1]*e.EXTENT,o.max];e.transformMat4(a,a,r),c=(1-a[1])*this.height*.5<i}return l<r||c}))}return S.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const r=e.clamp(t.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),i=this.projection.project(t.lng,r);return new e.pointGeometry(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(t,r){let i,n;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;i=(r.x-o.x)/e,n=(r.y-o.y)/e}else{const e=this.pointCoordinate(r),t=this.pointCoordinate(o);i=e.x-t.x,n=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.MercatorCoordinate(s.x-i,s.y-n))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,r){const i=r?e.mercatorZfromAltitude(r,t.lat):void 0,n=this.projection.project(t.lng,t.lat);return new e.MercatorCoordinate(n.x,n.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,r){const i=null!=r?r:this._centerAltitude,n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.transformMat4$1(n,n,this.pixelMatrixInverse),e.transformMat4$1(o,o,this.pixelMatrixInverse);const s=o[3];e.scale$1(n,n,1/n[3]),e.scale$1(o,o,1/s);const a=n[2],l=o[2];return{p0:n,p1:o,t:a===l?0:(i-a)/(l-a)}}screenPointToMercatorRay(t){const r=[t.x,t.y,0,1],i=[t.x,t.y,1,1];return e.transformMat4$1(r,r,this.pixelMatrixInverse),e.transformMat4$1(i,i,this.pixelMatrixInverse),e.scale$1(r,r,1/r[3]),e.scale$1(i,i,1/i[3]),r[2]=e.mercatorZfromAltitude(r[2],this._center.lat)*this.worldSize,i[2]=e.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,e.scale$1(r,r,1/this.worldSize),e.scale$1(i,i,1/this.worldSize),new e.Ray([r[0],r[1],r[2]],e.normalize([],e.sub([],i,r)))}rayIntersectionCoordinate(t){const{p0:r,p1:i,t:n}=t,o=e.mercatorZfromAltitude(r[2],this._center.lat),s=e.mercatorZfromAltitude(i[2],this._center.lat);return new e.MercatorCoordinate(e.number(r[0],i[0],n)/this.worldSize,e.number(r[1],i[1],n)/this.worldSize,e.number(o,s,n))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let r=this.projection.pointCoordinate3D(this,t.x,t.y);if(r)return new e.MercatorCoordinate(r[0],r[1],r[2]);let i=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);const o=.02*n,s=t.clone();for(let t=0;t<10&&n-i>o;t++){s.y=e.number(i,n,.66);const t=this.projection.pointCoordinate3D(this,s.x,s.y);t?(n=s.y,r=t):i=s.y}return r?new e.MercatorCoordinate(r[0],r[1],r[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}_coordinatePoint(t,r){const i=r&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,n=[t.x*this.worldSize,t.y*this.worldSize,i+t.toAltitude(),1];return e.transformMat4$1(n,n,this.pixelMatrix),n[3]>0?new e.pointGeometry(n[0]/n[3],n[1]/n[3]):new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(t,r){const i=new e.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),n=new e.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),o=new e.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new e.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let a=this.pointCoordinate(i,t),l=this.pointCoordinate(n,t);const c=this.pointCoordinate(o,r),u=this.pointCoordinate(s,r),h=(e,t)=>(t.y-e.y)/(t.x-e.x);return a.y>1&&l.y>=0?a=new e.MercatorCoordinate((1-u.y)/h(u,a)+u.x,1):a.y<0&&l.y<=1&&(a=new e.MercatorCoordinate(-u.y/h(u,a)+u.x,0)),l.y>1&&a.y>=0?l=new e.MercatorCoordinate((1-c.y)/h(c,l)+c.x,1):l.y<0&&a.y<=1&&(l=new e.MercatorCoordinate(-c.y/h(c,l)+c.x,0)),(new e.LngLatBounds).extend(this.coordinateLocation(a)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(c))}_getBounds3D(){const e=this.elevation;if(!e.visibleDemTiles.length)return this._getBounds(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const r=t.dem.tree;e.min=Math.min(e.min,r.minimums[0]),e.max=Math.max(e.max,r.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBounds(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,r=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,r):r}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.MAX_MERCATOR_LATITUDE,this.maxLat=e.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=e.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=e.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=e.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=e.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(t){const r=t.key,i=this._distanceTileDataCache;if(i[r])return i[r];const n=t.canonical,o=1/this.height,s=this.cameraWorldSize/this.zoomScale(n.z),a=(n.x+Math.pow(2,n.z)*t.wrap)*s,l=n.y*s,c=this.point,u=this.angle,h=Math.sin(-u),p=-Math.cos(-u);return i[r]={bearing:[h,p],center:[(c.x-a)*o,(c.y-l)*o],scale:s/e.EXTENT*o},i[r]}calculateFogTileMatrix(t){const r=t.key,i=this._fogTileMatrixCache;if(i[r])return i[r];const n=this.projection.createTileMatrix(this,this.cameraWorldSize,t);return e.multiply(n,this.worldToFogMatrix,n),i[r]=new Float32Array(n),i[r]}calculateProjMatrix(t,r=!1){const i=t.key,n=r?this._alignedProjMatrixCache:this._projMatrixCache;if(n[i])return n[i];const o=this.calculatePosMatrix(t,this.worldSize);return e.multiply(o,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:r?this.alignedProjMatrix:this.projMatrix,o),n[i]=new Float32Array(o),n[i]}calculatePixelsToTileUnitsMatrix(t){const r=t.tileID.key,i=this._pixelsToTileUnitsCache;if(i[r])return i[r];const n=function(t,r){const{scale:i}=t.tileTransform,n=i*e.EXTENT/(t.tileSize*Math.pow(2,r.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return o=new Float32Array(4),l=(s=r.inverseAdjustmentMatrix)[1],c=s[2],u=s[3],p=(a=[n,n])[1],o[0]=s[0]*(h=a[0]),o[1]=l*h,o[2]=c*p,o[3]=u*p,o;var o,s,a,l,c,u,h,p}(t,this);return i[r]=n,i[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const t=this._elevation;this._updateCameraState();const r=e.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(r),n=this._camera.forward(),o=e.mercatorZfromAltitude(1,this._center.lat);i[2]/=o,n[2]/=o,e.normalize(n,n);const s=t.raycast(i,n,t.exaggeration());if(s){const t=e.scaleAndAdd([],i,n,s),r=new e.MercatorCoordinate(t[0],t[1],e.mercatorZfromAltitude(t[2],e.latFromMercatorY(t[1]))),a=(r.z+e.length([r.x-i[0],r.y-i[1],r.z-i[2]*o]))*this._projectionScaler;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=r.toAltitude(),this._center=this.coordinateLocation(r),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const t=this._elevation;this._updateCameraState();const r=e.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(r),n=t.getAtPointOrZero(new e.MercatorCoordinate(...i)),o=this._minimumHeightOverTerrain()*Math.cos(e.degToRad(this._maxPitch)),s=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*n;if(s<o){const t=this.locationCoordinate(this._center,this._centerAltitude),r=[t.x-i[0],t.y-i[1],t.z-i[2]],n=e.length(r);r[2]-=(o-s)/this._projectionScaler;const a=e.length(r);if(0===a)return;e.scale$2(r,r,n/a*this._projectionScaler),this._camera.position=[t.x-r[0],t.y-r[1],t.z*this._projectionScaler-r[2]],this._camera.orientation=Oi(r,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const t=this.center;return t.lat=e.clamp(t.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(t.lng=e.clamp(t.lng,this.minLng,this.maxLng)),this.center=t,void(this._constraining=!1)}const t=this._unmodified,{x:r,y:i}=this.point;let n=0,o=r,s=i;const a=this.width/2,l=this.height/2,c=this.worldMinY*this.scale,u=this.worldMaxY*this.scale;if(i-l<c&&(s=c+l),i+l>u&&(s=u-l),u-c<this.height&&(n=Math.max(n,this.height/(u-c)),s=(u+c)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,i=this.worldSize/2-(e+t)/2;o=(r+i+this.worldSize)%this.worldSize-i,o-a<e&&(o=e+a),o+a>t&&(o=t-a),t-e<this.width&&(n=Math.max(n,this.width/(t-e)),o=(t+e)/2)}o===r&&s===i||(this.center=this.unproject(new e.pointGeometry(o,s))),n&&(this.zoom+=this.scaleZoom(n)),this._constrainCameraAltitude(),this._unmodified=t,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,r=this.pixelsPerMeter;if("globe"===this.projection.name){const t=e.mercatorZfromAltitude(1,this.center.lat)*this.worldSize,r=e.mercatorZfromAltitude(1,e.GLOBE_SCALE_MATCH_LATITUDE)*this.worldSize;this._mercatorScaleRatio=t/r}const i=Vi(this.projection,this.zoom,this.width,this.height,1024);this._projectionScaler=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,i),this.cameraToCenterDistance=this.getCameraToCenterDistance(this.projection),this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const n=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?r:1),o=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);o[8]=2*-t.x/this.width,o[9]=2*t.y/this.height;let s=e.mul([],o,n);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),r=e.identity([]);e.translate(r,r,[t.x*this.worldSize,t.y*this.worldSize,0]),e.multiply(r,r,ji(this)),e.translate(r,r,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.multiply(s,s,r),this.inverseAdjustmentMatrix=function(e){const t=ji(e,!0);return y([],[t[0],t[1],t[4],t[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=e.scale([],s,[this.worldSize,this.worldSize,this.worldSize/r,1]),this.projMatrix=s,this.invProjMatrix=e.invert(new Float64Array(16),this.projMatrix);const a=e.invert([],o);this.frustumCorners=e.FrustumCorners.fromInvProjectionMatrix(a,this.horizonLineFromTop(),this.height);const l=new Float32Array(16);e.identity(l),e.scale(l,l,[1,-1,1]),e.rotateX(l,l,this._pitch),e.rotateZ(l,l,this.angle);const c=e.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),u=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;c[8]=2*-t.x/this.width,c[9]=2*(t.y+u)/this.height,this.skyboxMatrix=e.multiply(l,c,l);const h=this.point,p=h.x,d=h.y,f=this.width%2/2,m=this.height%2/2,_=Math.cos(this.angle),g=Math.sin(this.angle),v=p-Math.round(p)+_*f+g*m,x=d-Math.round(d)+_*m+g*f,b=new Float64Array(s);if(e.translate(b,b,[v>.5?v-1:v,x>.5?x-1:x,0]),this.alignedProjMatrix=b,s=e.create(),e.scale(s,s,[this.width/2,-this.height/2,1]),e.translate(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=e.create(),e.scale(s,s,[1,-1,1]),e.translate(s,s,[-1,-1,0]),e.scale(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s,this.pixelMatrix=e.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},s=e.invert(new Float64Array(16),this.pixelMatrix),!s)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=s,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.calculateGlobeMatrix(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.transformMat4(t,t,n),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=s;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSize,r=this.cameraPixelsPerMeter,i=this._camera.position,n=1/this.height/this._projectionScaler,o=[t,t,r];e.scale$2(o,o,n),e.scale$2(i,i,-1),e.multiply$2(i,i,o);const s=e.create();e.translate(s,s,i),e.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,r,n)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,r=this._camera.forward(),i=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[i.x/this.worldSize-r[0]*n,i.y/this.worldSize-r[1]*n,e/this.worldSize*this._centerAltitude-r[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const r=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=t[2];let n=1;i>0&&(n=Math.min((r-this._camera.position[2])/i,1)),this._camera.position=e.scaleAndAdd([],this._camera.position,t,n),this._updateStateFromCamera(),this.projection.wrap&&(this.center=this.center.wrap())}_updateStateFromCamera(){const t=this._camera.position,r=this._camera.forward(),{pitch:i,bearing:n}=this._camera.getPitchBearing(),o=e.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.degToRad(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(i),s),l=this._zoomFromMercatorZ(a);e.scaleAndAdd(t,t,r,a),this._pitch=e.clamp(i,e.degToRad(this.minPitch),e.degToRad(this.maxPitch)),this.angle=e.wrap(n,-Math.PI,Math.PI),this._setZoom(e.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.MercatorCoordinate(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(e.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,r){const i=Math.min(t.x,r.x),n=Math.max(t.x,r.x),o=Math.min(t.y,r.y),s=Math.max(t.y,r.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new e.pointGeometry(i,o),new e.pointGeometry(n,s),new e.pointGeometry(i,s),new e.pointGeometry(n,o)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const e of a){const t=this.pointRayIntersection(e);if(t.t<0)return!0;const r=this.rayIntersectionCoordinate(t);if(r.x<l||r.y<0||r.x>c||r.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.pointGeometry(0,0),new e.pointGeometry(this.width,this.height))}zoomDeltaToMovement(t,r){const i=e.length(e.sub([],this._camera.position,t)),n=this._zoomFromMercatorZ(i)+r;return i-this._mercatorZfromZoom(n)}getCameraPoint(){if("globe"===this.projection.name){const t=function(t,r){const i=[t[0],t[1],t[2],1];e.transformMat4$1(i,i,r);const n=Math.max(i[3],1e-6);return[i[0]/n,i[1]/n,i[2]/n,n]}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.pointGeometry(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.pointGeometry(0,t))}}getCameraToCenterDistance(e){const t=Vi(e,this.zoom,this.width,this.height,1024),r=e.pixelSpaceConversion(this.center.lat,this.worldSize,t);return.5/Math.tan(.5*this._fov)*this.height*r}}function Wi(e,t){let r=!1,i=null;const n=()=>{i=null,r&&(e(),i=setTimeout(n,t),r=!1)};return()=>(r=!0,i||n(),i)}class Hi{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Wi(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),e.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(t){const r=this._map;if(!r)return"";const i=r.getCenter(),n=Math.round(100*r.getZoom())/100,o=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,o),a=Math.round(i.lng*s)/s,l=Math.round(i.lat*s)/s,c=r.getBearing(),u=r.getPitch();let h="";if(h+=t?`/${a}/${l}/${n}`:`${n}/${l}/${a}`,(c||u)&&(h+="/"+Math.round(10*c)/10),u&&(h+=`/${Math.round(u)}`),this._hashName){const t=this._hashName;let r=!1;const i=e.window.location.hash.slice(1).split("&").map((e=>{const i=e.split("=")[0];return i===t?(r=!0,`${i}=${h}`):e})).filter((e=>e));return r||i.push(`${t}=${h}`),`#${i.join("&")}`}return`#${h}`}_getCurrentHash(){const t=e.window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((e=>e.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const r=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:r,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=e.window.location.href.replace(/(#.+)?$/,this.getHashString());e.window.history.replaceState(e.window.history.state,null,t)}}const Xi={linearity:.3,easing:e.bezier(0,0,.3,1)},Yi=e.extend({deceleration:2500,maxSpeed:1400},Xi),Ki=e.extend({deceleration:20,maxSpeed:1400},Xi),Ji=e.extend({deceleration:1e3,maxSpeed:360},Xi),Qi=e.extend({deceleration:1e3,maxSpeed:90},Xi);class en{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.exported.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,r=e.exported.now();for(;t.length>0&&r-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const r={zoom:0,bearing:0,pitch:0,pan:new e.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)r.zoom+=e.zoomDelta||0,r.bearing+=e.bearingDelta||0,r.pitch+=e.pitchDelta||0,e.panDelta&&r.pan._add(e.panDelta),e.around&&(r.around=e.around),e.pinchAround&&(r.pinchAround=e.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(r.pan.mag()){const o=rn(r.pan.mag(),i,e.extend({},Yi,t||{}));n.offset=r.pan.mult(o.amount/r.pan.mag()),n.center=this._map.transform.center,tn(n,o)}if(r.zoom){const e=rn(r.zoom,i,Ki);n.zoom=this._map.transform.zoom+e.amount,tn(n,e)}if(r.bearing){const t=rn(r.bearing,i,Ji);n.bearing=this._map.transform.bearing+e.clamp(t.amount,-179,179),tn(n,t)}if(r.pitch){const e=rn(r.pitch,i,Qi);n.pitch=this._map.transform.pitch+e.amount,tn(n,e)}if(n.zoom||n.bearing){const e=void 0===r.pinchAround?r.around:r.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function tn(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function rn(t,r,i){const{maxSpeed:n,linearity:o,deceleration:s}=i,a=e.clamp(t*o/(r/1e3),-n,n),l=Math.abs(a)/(s*o);return{easing:i.easing,duration:1e3*l,amount:a*(l/2)}}class nn extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,r,i,n={}){const o=f(r.getCanvasContainer(),i),s=r.unproject(o);super(t,e.extend({point:o,lngLat:s,originalEvent:i},n)),this._defaultPrevented=!1,this.target=r}}class on extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,r,i){const n="touchend"===t?i.changedTouches:i.touches,o=m(r.getCanvasContainer(),n),s=o.map((e=>r.unproject(e))),a=o.reduce(((e,t,r,i)=>e.add(t.div(i.length))),new e.pointGeometry(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:r.unproject(a),originalEvent:i}),this._defaultPrevented=!1}}class sn extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,r){super(e,{originalEvent:r}),this._defaultPrevented=!1}}class an{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new sn(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new nn(e.type,this._map,e))}mouseup(e){this._map.fire(new nn(e.type,this._map,e))}preclick(t){const r=e.extend({},t);r.type="preclick",this._map.fire(new nn(r.type,this._map,r))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new nn(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new nn(e.type,this._map,e))}mouseover(e){this._map.fire(new nn(e.type,this._map,e))}mouseout(e){this._map.fire(new nn(e.type,this._map,e))}touchstart(e){return this._firePreventable(new on(e.type,this._map,e))}touchmove(e){this._map.fire(new on(e.type,this._map,e))}touchend(e){this._map.fire(new on(e.type,this._map,e))}touchcancel(e){this._map.fire(new on(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ln{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new nn(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new nn("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new nn(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cn{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(u(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const r=t;if(this._lastPos.equals(r)||!this._box&&r.dist(this._startPos)<this._clickTolerance)return;const i=this._startPos;this._lastPos=r,this._box||(this._box=o("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const n=Math.min(i.x,r.x),s=Math.max(i.x,r.x),a=Math.min(i.y,r.y),l=Math.max(i.y,r.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${n}px,${a}px)`,this._box.style.width=s-n+"px",this._box.style.height=l-a+"px")}))}mouseupWindow(t,r){if(!this._active)return;if(0!==t.button)return;const i=this._startPos,n=r;if(this.reset(),d(),i.x!==n.x||i.y!==n.y)return this._map.fire(new e.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(i,n,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(t,r){return this._map.fire(new e.Event(t,{originalEvent:r}))}}function un(e,t){const r={};for(let i=0;i<e.length;i++)r[e[i].identifier]=t[i];return r}class hn{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,r,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=function(t){const r=new e.pointGeometry(0,0);for(const e of t)r._add(e);return r.div(t.length)}(r),this.touches=un(i,r)))}touchmove(e,t,r){if(this.aborted||!this.centroid)return;const i=un(r,t);for(const e in this.touches){const t=this.touches[e],r=i[e];(!r||r.dist(t)>30)&&(this.aborted=!0)}}touchend(e,t,r){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===r.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class pn{constructor(e){this.singleTap=new hn(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,r){this.singleTap.touchstart(e,t,r)}touchmove(e,t,r){this.singleTap.touchmove(e,t,r)}touchend(e,t,r){const i=this.singleTap.touchend(e,t,r);if(i){const t=e.timeStamp-this.lastTime<500,r=!this.lastTap||this.lastTap.dist(i)<30;if(t&&r||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}}class dn{constructor(){this._zoomIn=new pn({numTouches:1,numTaps:2}),this._zoomOut=new pn({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,r){this._zoomIn.touchstart(e,t,r),this._zoomOut.touchstart(e,t,r)}touchmove(e,t,r){this._zoomIn.touchmove(e,t,r),this._zoomOut.touchmove(e,t,r)}touchend(e,t,r){const i=this._zoomIn.touchend(e,t,r),n=this._zoomOut.touchend(e,t,r);return i?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(i)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const fn={0:1,2:2};class mn{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const r=_(e);this._correctButton(e,r)&&(this._lastPoint=t,this._eventButton=r)}mousemoveWindow(e,t){const r=this._lastPoint;if(r)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const r=fn[t];return void 0===e.buttons||(e.buttons&r)!==r}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(r)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(r,t)}mouseupWindow(e){this._lastPoint&&_(e)===this._eventButton&&(this._moved&&d(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class _n extends mn{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0)}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return{around:t,panDelta:t.sub(e)}}}class gn extends mn{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const r=.8*(t.x-e.x);if(r)return this._active=!0,{bearingDelta:r}}contextmenu(e){e.preventDefault()}}class yn extends mn{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const r=-.5*(t.y-e.y);if(r)return this._active=!0,{pitchDelta:r}}contextmenu(e){e.preventDefault()}}class vn{constructor(t,r){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=r.clickTolerance||1,this.reset(),e.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new e.pointGeometry(0,0)}touchstart(e,t,r){return this._calculateTransform(e,t,r)}touchmove(e,t,r){if(this._active&&!(r.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===r.length)return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return e.preventDefault(),this._calculateTransform(e,t,r)}}touchend(e,t,r){this._calculateTransform(e,t,r),this._active&&r.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,r,i){i.length>0&&(this._active=!0);const n=un(i,r),o=new e.pointGeometry(0,0),s=new e.pointGeometry(0,0);let a=0;for(const e in n){const t=n[e],r=this._touches[e];r&&(o._add(t),s._add(t.sub(r)),a++,n[e]=t)}if(this._touches=n,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")}),500)}}class xn{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,r){return{}}touchstart(e,t,r){this._firstTwoTouches||r.length<2||(this._firstTwoTouches=[r[0].identifier,r[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,r){const i=this._firstTwoTouches;if(!i)return;e.preventDefault();const[n,o]=i,s=bn(r,t,n),a=bn(r,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,r){if(!this._firstTwoTouches)return;const[i,n]=this._firstTwoTouches,o=bn(r,t,i),s=bn(r,t,n);o&&s||(this._active&&d(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function bn(e,t,r){for(let i=0;i<e.length;i++)if(e[i].identifier===r)return t[i]}function wn(e,t){return Math.log(e/t)/Math.LN2}class Tn extends xn{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const r=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(wn(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:wn(this._distance,r),pinchAround:t}}}function En(e,t){return 180*e.angleWith(t)/Math.PI}class Sn extends xn{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t){const r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:En(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,r=En(e,this._startVector);return Math.abs(r)<t}}function Cn(e){return Math.abs(e.y)>Math.abs(e.x)}class An extends xn{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,Cn(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,r){const i=this._lastPoints;if(!i)return;const n=e[0].sub(i[0]),o=e[1].sub(i[1]);return this._map._cooperativeGestures&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(n,o,r.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+o.y)/2*-.5})}gestureBeginsVertically(e,t,r){if(void 0!==this._valid)return this._valid;const i=e.mag()>=2,n=t.mag()>=2;if(!i&&!n)return;if(!i||!n)return null==this._firstMove&&(this._firstMove=r),r-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Cn(e)&&Cn(t)&&o}}const kn={panStep:100,bearingStep:15,pitchStep:10};class In{constructor(){const e=kn;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,r=0,i=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?r=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?r=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?i=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?i=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Mn,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+r*this._bearingStep,pitch:s.getPitch()+i*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Mn(e){return e*(2-e)}const zn=4.000244140625;class Pn{constructor(t,r){this._map=t,this._el=t.getCanvasContainer(),this._handler=r,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let r=t.deltaMode===e.window.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=e.exported.now(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==r&&r%zn==0?this._type="wheel":0!==r&&Math.abs(r)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=r,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*r)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,r+=this._lastValue)),t.shiftKey&&r&&(r/=4),this._type&&(this._lastWheelEvent=t,this._delta-=r,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=f(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform,r=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>zn?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);const n=r(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*i))),"wheel"===this._type&&(this._startZoom=r(),this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:r(),n=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&n&&o){const t=Math.min((e.exported.now()-this._lastWheelEventTime)/200,1),r=o(t);s=e.number(n,i,r),t<1?this._frameId||(this._frameId=!0):a=!0}else s=i,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s-r(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let r=e.ease;if(this._prevEase){const t=this._prevEase,i=(e.exported.now()-t.start)/t.duration,n=t.easing(i+.01)-t.easing(i),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);r=e.bezier(o,s,.25,1)}return this._prevEase={start:e.exported.now(),duration:t,easing:r},r}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(e.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`)}_isFullscreen(){return!!e.window.document.fullscreenElement||!!e.window.document.webkitFullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")}),200)}}class Dn{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ln{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:r.getZoom()+(e.shiftKey?-1:1),around:r.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Bn{constructor(){this._tap=new pn({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,r){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?r.length>0&&(this._swipePoint=t[0],this._swipeTouch=r[0].identifier):this._tap.touchstart(e,t,r))}touchmove(e,t,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;const i=t[0],n=i.y-this._swipePoint.y;return this._swipePoint=i,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,r)}touchend(e,t,r){this._tapTime?this._swipePoint&&0===r.length&&this.reset():this._tap.touchend(e,t,r)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Rn{constructor(e,t,r){this._el=e,this._mousePan=t,this._touchPan=r}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class On{constructor(e,t,r){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=r}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 Fn{constructor(e,t,r,i){this._el=e,this._touchZoom=t,this._touchRotate=r,this._tapDragZoom=i,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("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 Nn=e=>e.zoom||e.drag||e.pitch||e.rotate;class jn extends e.Event{}class Un{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,r){const i=e.sub([],r,t);this.radius=e.length(i[2]<0?e.div([],i,this.constants):[i[0],i[1],0])}projectRay(t){e.div(t,t,this.constants),e.normalize(t,t),e.mul$1(t,t,this.constants);const r=e.scale$2([],t,this.radius);if(r[2]>0){const t=e.scale$2([],[0,0,1],e.dot(r,[0,0,1])),i=e.scale$2([],e.normalize([],[r[0],r[1],0]),this.radius),n=e.add([],r,e.scale$2([],e.sub([],e.add([],i,t),r),2));r[0]=n[0],r[1]=n[1]}return r}}function Vn(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class qn{constructor(t,r){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new en(t),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Un,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(r),e.bindAll(["handleEvent","handleWindowEvent"],this);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[e.window.document,"mousemove",{capture:!0}],[e.window.document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[e.window,"blur",void 0]];for(const[t,r,i]of this._listeners)t.addEventListener(r,t===e.window.document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,r,i]of this._listeners)t.removeEventListener(r,t===e.window.document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const t=this._map,r=t.getCanvasContainer();this._add("mapEvent",new an(t,e));const i=t.boxZoom=new cn(t,e);this._add("boxZoom",i);const n=new dn,o=new Ln;t.doubleClickZoom=new Dn(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new Bn;this._add("tapDragZoom",s);const a=t.touchPitch=new An(t);this._add("touchPitch",a);const l=new gn(e),c=new yn(e);t.dragRotate=new On(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new _n(e),h=new vn(t,e);t.dragPan=new Rn(r,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const p=new Sn,d=new Tn;t.touchZoomRotate=new Fn(r,d,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new ln(t));const f=t.scrollZoom=new Pn(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new In;this._add("keyboard",m);for(const r of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[r]&&t[r].enable(e[r])}_add(e,t,r){this._handlers.push({handlerName:e,handler:t,allowed:r}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Nn(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,r){for(const i in e)if(i!==r&&(!t||t.indexOf(i)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const r of e)this._el.contains(r.target)&&t.push(r);return t}handleEvent(e,t){this._updatingCamera=!0;const r="renderFrame"===e.type,i=r?void 0:e,n={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?m(this._el,a):r?void 0:f(this._el,e);for(const{handlerName:r,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,r)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(n,o,h,r,i),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[r]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=i);this._previousActiveHandlers=s,(Object.keys(c).length||Vn(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Vn(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(t,r,i,n,o){if(!i)return;e.extend(t,i);const s={handlerName:n,originalEvent:i.originalEvent||o};void 0!==i.zoomDelta&&(r.zoom=s),void 0!==i.panDelta&&(r.drag=s),void 0!==i.pitchDelta&&(r.pitch=s),void 0!==i.bearingDelta&&(r.rotate=s)}_applyChanges(){const t={},r={},i={};for(const[n,o,s]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.pointGeometry(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.aroundCoord&&(t.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),e.extend(r,o),e.extend(i,s);this._updateMapTransform(t,r,i),this._changes=[]}_updateMapTransform(t,r,i){const n=this._map,o=n.transform,s=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Vn(t)){const e=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",e!==o.zoom&&this._map._update(!0)}if(!Vn(t))return void this._fireEvents(r,i,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:p,pinchAround:d}=t;void 0!==d&&(h=d),(e=>r.drag&&!this._eventsInProgress.drag)()&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),h=h||n.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a){const t=o.pointCoordinate(h);if("globe"===o.projection.name){const r=e.latFromMercatorY(t.y),i=o.center.lat,n=Math.min(e.mercatorZfromAltitude(1,r)/e.mercatorZfromAltitude(1,i),2);a=a.rotate(-o.angle),f[0]=-a.x/o.worldSize*n,f[1]=-a.y/o.worldSize*n}else{const e=o.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,_=[0,0,0];if(l){const t=s(p||o.pointCoordinate3D(h)),r={dir:e.normalize([],e.sub([],t,o._camera.position))};if(r.dir[2]<0){const i=o.zoomDeltaToMovement(t,l);e.scale$2(_,r.dir,i)}}const g=e.add(f,f,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(r,i,!0)}_fireEvents(t,r,i){const n=Nn(this._eventsInProgress),o=Nn(t),s={};for(const e in t){const{originalEvent:r}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=r),this._eventsInProgress[e]=t[e]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:r}=t[e];this._fireEvent(e,r)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:i}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=r[t]||i,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=Nn(this._eventsInProgress);if(i&&(n||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),r=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;t?(r(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new e.Event("moveend",{originalEvent:l})),r(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,r){this._map.fire(new e.Event(t,r?{originalEvent:r}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{this._frameId=void 0,this.handleEvent(new jn("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Gn="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class $n extends e.Evented{constructor(t,r){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=r.bearingSnap,e.bindAll(["_renderFrameCallback"],this)}getCenter(){return new e.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,r,i){return t=e.pointGeometry.convert(t).mult(-1),this.panTo(this.transform.center,e.extend({offset:t},r),i)}panTo(t,r,i){return this.easeTo(e.extend({center:t},r),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,r,i){return this.easeTo(e.extend({zoom:t},r),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,r,i){return this.easeTo(e.extend({bearing:t},r),i)}resetNorth(t,r){return this.rotateTo(0,e.extend({duration:1e3},t),r),this}resetNorthPitch(t,r){return this.easeTo(e.extend({bearing:0,pitch:0,duration:1e3},t),r),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(t,r){"globe"===this.transform.projection.name&&e.warnOnce('Globe projection does not support cameraForBounds API, this API may behave unexpectedly."'),t=e.LngLatBounds.convert(t);const i=r&&r.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,r)}_extendCameraOptions(t){const r={top:0,bottom:0,right:0,left:0};if("number"==typeof(t=e.extend({padding:r,offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding){const e=t.padding;t.padding={top:e,bottom:e,right:e,left:e}}return t.padding=e.extend(r,t.padding),t}_cameraForBoxAndBearing(t,r,i,n){const o=this._extendCameraOptions(n),s=this.transform,a=s.padding,l=s.project(e.LngLat.convert(t)),c=s.project(e.LngLat.convert(r)),u=new e.pointGeometry(l.x,c.y),h=new e.pointGeometry(c.x,l.y),p=-e.degToRad(i),d=l.rotate(p),f=c.rotate(p),m=u.rotate(p),_=h.rotate(p),g=new e.pointGeometry(Math.max(d.x,f.x,m.x,_.x),Math.max(d.y,f.y,m.y,_.y)),y=new e.pointGeometry(Math.min(d.x,f.x,m.x,_.x),Math.min(d.y,f.y,m.y,_.y)),v=g.sub(y),x=(s.width-((a.left||0)+(a.right||0)+o.padding.left+o.padding.right))/v.x,b=(s.height-((a.top||0)+(a.bottom||0)+o.padding.top+o.padding.bottom))/v.y;if(b<0||x<0)return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const w=Math.min(s.scaleZoom(s.scale*Math.min(x,b)),o.maxZoom),T="number"==typeof o.offset.x&&"number"==typeof o.offset.y?new e.pointGeometry(o.offset.x,o.offset.y):e.pointGeometry.convert(o.offset),E=new e.pointGeometry((o.padding.left-o.padding.right)/2,(o.padding.top-o.padding.bottom)/2).rotate(i*Math.PI/180),S=T.add(E).mult(s.scale/s.zoomScale(w));return{center:s.unproject(l.add(c).div(2).sub(S)),zoom:w,bearing:i}}_cameraForBox(t,r,i,n,o){const s=this._extendCameraOptions(o);i=i||0,n=n||0,t=e.LngLat.convert(t),r=e.LngLat.convert(r);const a=this.transform.clone();a.padding=s.padding;const l=this.getFreeCameraOptions(),c=new e.LngLat(.5*(t.lng+r.lng),.5*(t.lat+r.lat)),u=.5*(i+n);if(a._camera.position[2]<e.mercatorZfromAltitude(u,c.lat))return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");l.lookAtPoint(c),a.setFreeCameraOptions(l);const h=e.MercatorCoordinate.fromLngLat(t),p=e.MercatorCoordinate.fromLngLat(r),d=a.pointRayIntersection(a.centerPoint,u),f=[(m=a.rayIntersectionCoordinate(d)).x,m.y,m.z];var m;const _=a.screenPointToMercatorRay(a.centerPoint),g="globe"!==a.projection.name;let y,v=0;do{const r=Math.floor(a.zoom),o=1<<r,s=Math.min(o*h.x,o*p.x),l=Math.min(o*h.y,o*p.y),c=Math.max(o*h.x,o*p.x),u=Math.max(o*h.y,o*p.y),d=new e.Aabb([s,l,i],[c,u,n]),m=e.Frustum.fromInvProjectionMatrix(a.invProjMatrix,a.worldSize,r,g);if(2!==d.intersects(m)){y&&(a._camera.position=e.scaleAndAdd([],a._camera.position,_.dir,-y),a._updateStateFromCamera());break}const v=e.sub([],a._camera.position,f);y=.5*e.length(v),a._camera.position=e.scaleAndAdd([],a._camera.position,_.dir,y);try{a._updateStateFromCamera()}catch(t){return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++v<10);return{center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}fitBounds(t,r,i){return"globe"===this.transform.projection.name&&e.warnOnce("Globe projection does not support fitBounds API, this API may behave unexpectedly."),this._fitInternal(this.cameraForBounds(t,r),r,i)}_raycastElevationBox(t,r){const i=this.transform.elevation;if(!i)return;const n=new e.pointGeometry(t.x,r.y),o=new e.pointGeometry(r.x,t.y),s=i.pointCoordinate(t);if(!s)return;const a=i.pointCoordinate(r);if(!a)return;const l=i.pointCoordinate(n);if(!l)return;const c=i.pointCoordinate(o);if(!c)return;const u=new e.MercatorCoordinate(s[0],s[1]).toLngLat(),h=new e.MercatorCoordinate(a[0],a[1]).toLngLat(),p=new e.MercatorCoordinate(l[0],l[1]).toLngLat(),d=new e.MercatorCoordinate(c[0],c[1]).toLngLat(),f=Math.min(u.lng,Math.min(h.lng,Math.min(p.lng,d.lng))),m=Math.min(u.lat,Math.min(h.lat,Math.min(p.lat,d.lat))),_=Math.max(u.lng,Math.max(h.lng,Math.max(p.lng,d.lng))),g=Math.max(u.lat,Math.max(h.lat,Math.max(p.lat,d.lat))),y=Math.min(s[3],Math.min(a[3],Math.min(l[3],c[3]))),v=Math.max(s[3],Math.max(a[3],Math.max(l[3],c[3])));return{minLngLat:new e.LngLat(f,m),maxLngLat:new e.LngLat(_,g),minAltitude:y,maxAltitude:v}}fitScreenCoordinates(t,r,i,n,o){let s,a,l,c;"globe"===this.transform.projection.name&&e.warnOnce("Globe projection does not support fitScreenCoordinates API, this API may behave unexpectedly.");const u=e.pointGeometry.convert(t),h=e.pointGeometry.convert(r),p=this._raycastElevationBox(u,h);if(p)s=p.minLngLat,a=p.maxLngLat,l=p.minAltitude,c=p.maxAltitude;else{if(this.transform.anyCornerOffEdge(u,h))return this;s=this.transform.pointLocation(u),a=this.transform.pointLocation(h)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(e.pointGeometry.convert(t)),this.transform.pointLocation(e.pointGeometry.convert(r)),i,n):this._cameraForBox(s,a,l,c,n),n,o)}_fitInternal(t,r,i){return t?(delete(r=e.extend(t,r)).padding,r.linear?this.easeTo(r,i):this.flyTo(r,i)):this}jumpTo(t,r){this.stop();const i=t.preloadOnly?this.transform.clone():this.transform;let n=!1,o=!1,s=!1;return"zoom"in t&&i.zoom!==+t.zoom&&(n=!0,i.zoom=+t.zoom),void 0!==t.center&&(i.center=e.LngLat.convert(t.center)),"bearing"in t&&i.bearing!==+t.bearing&&(o=!0,i.bearing=+t.bearing),"pitch"in t&&i.pitch!==+t.pitch&&(s=!0,i.pitch=+t.pitch),null==t.padding||i.isPaddingEqual(t.padding)||(i.padding=t.padding),t.preloadOnly?(this._preloadTiles(i),this):(this.fire(new e.Event("movestart",r)).fire(new e.Event("move",r)),n&&this.fire(new e.Event("zoomstart",r)).fire(new e.Event("zoom",r)).fire(new e.Event("zoomend",r)),o&&this.fire(new e.Event("rotatestart",r)).fire(new e.Event("rotate",r)).fire(new e.Event("rotateend",r)),s&&this.fire(new e.Event("pitchstart",r)).fire(new e.Event("pitch",r)).fire(new e.Event("pitchend",r)),this.fire(new e.Event("moveend",r)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.warnOnce(Gn),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,r){const i=this.transform;if(!i.projection.supportsFreeCamera)return e.warnOnce(Gn),this;this.stop();const n=i.zoom,o=i.pitch,s=i.bearing;i.setFreeCameraOptions(t);const a=n!==i.zoom,l=o!==i.pitch,c=s!==i.bearing;return this.fire(new e.Event("movestart",r)).fire(new e.Event("move",r)),a&&this.fire(new e.Event("zoomstart",r)).fire(new e.Event("zoom",r)).fire(new e.Event("zoomend",r)),c&&this.fire(new e.Event("rotatestart",r)).fire(new e.Event("rotate",r)).fire(new e.Event("rotateend",r)),l&&this.fire(new e.Event("pitchstart",r)).fire(new e.Event("pitch",r)).fire(new e.Event("pitchend",r)),this.fire(new e.Event("moveend",r)),this}easeTo(t,r){this._stop(!1,t.easeId),(!1===(t=e.extend({offset:[0,0],duration:500,easing:e.ease},t)).animate||!t.essential&&e.exported.prefersReducedMotion)&&(t.duration=0);const i=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h="padding"in t?t.padding:i.padding,p=e.pointGeometry.convert(t.offset);let d,f,m;if("globe"===i.projection.name){const r=e.MercatorCoordinate.fromLngLat(i.center),n=p.rotate(-i.angle);r.x+=n.x/i.worldSize,r.y+=n.y/i.worldSize;const o=r.toLngLat(),s=e.LngLat.convert(t.center||o);this._normalizeCenter(s),d=i.centerPoint.add(n),f=new e.pointGeometry(r.x,r.y).mult(i.worldSize),m=new e.pointGeometry(e.mercatorXfromLng(s.lng),e.mercatorYfromLat(s.lat)).mult(i.worldSize).sub(f)}else{d=i.centerPoint.add(p);const r=i.pointLocation(d),n=e.LngLat.convert(t.center||r);this._normalizeCenter(n),f=i.project(r),m=i.project(n).sub(f)}const _=i.zoomScale(l-n);let g,y;t.around&&(g=e.LngLat.convert(t.around),y=i.locationPoint(g));const v=this._zooming||l!==n,x=this._rotating||o!==c,b=this._pitching||u!==s,w=!i.isPaddingEqual(h),T=i=>T=>{if(v&&(i.zoom=e.number(n,l,T)),x&&(i.bearing=e.number(o,c,T)),b&&(i.pitch=e.number(s,u,T)),w&&(i.interpolatePadding(a,h,T),d=i.centerPoint.add(p)),g)i.setLocationAtPoint(g,y);else{const e=i.zoomScale(i.zoom-n),t=l>n?Math.min(2,_):Math.max(.5,_),r=Math.pow(t,1-T),o=i.unproject(f.add(m.mult(T*r)).mult(e));i.setLocationAtPoint(i.renderWorldCopies?o.wrap():o,d)}return t.preloadOnly||this._fireMoveEvents(r),i};if(t.preloadOnly){const e=this._emulate(T,t.duration,i);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(r,t.noMoveStart,E),this._ease(T(i),(e=>{i.recenterOnTerrain(),this._afterEase(r,e)}),t),this}_prepareEase(t,r,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",r||i.moving||this.fire(new e.Event("movestart",t)),this._zooming&&!i.zooming&&this.fire(new e.Event("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new e.Event("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new e.Event("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.Event("move",t)),this._zooming&&this.fire(new e.Event("zoom",t)),this._rotating&&this.fire(new e.Event("rotate",t)),this._pitching&&this.fire(new e.Event("pitch",t))}_afterEase(t,r){if(this._easeId&&r&&this._easeId===r)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const i=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new e.Event("zoomend",t)),n&&this.fire(new e.Event("rotateend",t)),o&&this.fire(new e.Event("pitchend",t)),this.fire(new e.Event("moveend",t))}flyTo(t,r){if(!t.essential&&e.exported.prefersReducedMotion){const i=e.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,r)}this.stop(),t=e.extend({offset:[0,0],speed:1.2,curve:1.42,easing:e.ease},t);const i=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.clamp(+t.zoom,i.minZoom,i.maxZoom):n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h="padding"in t?t.padding:i.padding,p=i.zoomScale(l-n),d=e.pointGeometry.convert(t.offset);let f=i.centerPoint.add(d);const m=i.pointLocation(f),_=e.LngLat.convert(t.center||m);this._normalizeCenter(_);const g=i.project(m),y=i.project(_).sub(g);let v=t.curve;const x=Math.max(i.width,i.height),b=x/p,w=y.mag();if("minZoom"in t){const r=e.clamp(Math.min(t.minZoom,n,l),i.minZoom,i.maxZoom),o=x/i.zoomScale(r-n);v=Math.sqrt(o/w*2)}const T=v*v;function E(e){const t=(b*b-x*x+(e?-1:1)*T*T*w*w)/(2*(e?b:x)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function C(e){return(Math.exp(e)+Math.exp(-e))/2}const A=E(0);let k=function(e){return C(A)/C(A+v*e)},I=function(e){return x*((C(A)*(S(t=A+v*e)/C(t))-S(A))/T)/w;var t},M=(E(1)-A)/v;if(Math.abs(w)<1e-6||!isFinite(M)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,r);const e=b<x?-1:1;M=Math.abs(Math.log(b/x))/v,I=function(){return 0},k=function(t){return Math.exp(e*v*t)}}t.duration="duration"in t?+t.duration:1e3*M/("screenSpeed"in t?+t.screenSpeed/v:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const z=o!==c,P=u!==s,D=!i.isPaddingEqual(h),L=i=>p=>{const m=p*M,v=1/k(m);i.zoom=1===p?l:n+i.scaleZoom(v),z&&(i.bearing=e.number(o,c,p)),P&&(i.pitch=e.number(s,u,p)),D&&(i.interpolatePadding(a,h,p),f=i.centerPoint.add(d));const x=1===p?_:i.unproject(g.add(y.mult(I(m))).mult(v));return i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,f),i._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(r),i};if(t.preloadOnly){const e=this._emulate(L,t.duration,i);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=z,this._pitching=P,this._padding=D,this._prepareEase(r,!1),this._ease(L(i),(()=>this._afterEase(r)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,r,i){!1===i.animate||0===i.duration?(t(1),r()):(this._easeStart=e.exported.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=r,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.exported.now()-this._easeStart)/this._easeOptions.duration,1),r=this._onEaseFrame;r&&r(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,r){t=e.wrap(t,-180,180);const i=Math.abs(t-r);return Math.abs(t-360-r)<i&&(t-=360),Math.abs(t+360-r)<i&&(t+=360),t}_normalizeCenter(e){const t=this.transform;if(!t.renderWorldCopies||t.maxBounds)return;const r=e.lng-t.center.lng;e.lng+=r>180?-360:r<-180?360:0}_emulate(e,t,r){const i=Math.ceil(15*t/1e3),n=[],o=e(r.clone());for(let e=0;e<=i;e++){const t=o(e/i);n.push(t.clone())}return n}}class Zn{constructor(t={}){this.options=t,e.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("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=o("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const r=this._map._getUIString(`AttributionControl.${t}`);e.setAttribute("aria-label",r),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",r)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const r=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.config.ACCESS_TOKEN}];if(t){const i=r.reduce(((e,t,i)=>(t.value&&(e+=`${t.key}=${t.value}${i<r.length-1?"&":""}`),e)),"?");t.href=`${e.config.FEEDBACK_URL}/${i}${this._map._hash?this._map._hash.getHashString(!0):""}`,t.rel="noopener nofollow",this._setElementTitle(t,"MapFeedback")}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style._sourceCaches;for(const r in t){const i=t[r];if(i.used){const t=i.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,r)=>{for(let i=r+1;i<e.length;i++)if(e[i].indexOf(t)>=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const r=e.join(" | ");r!==this._attribHTML&&(this._attribHTML=r,e.length?(this._innerContainer.innerHTML=r,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 Wn{constructor(){e.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const r=e[t].getSource();if(r.hasOwnProperty("mapbox_logo")&&!r.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class Hn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,r=t?this._queue.concat(t):this._queue;for(const t of r)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const r of t)if(!r.cancelled&&(r.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Xn(t,r,i){if(t=new e.LngLat(t.lng,t.lat),r){const n=new e.LngLat(t.lng-360,t.lat),o=new e.LngLat(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-i.center.lng)/360),a=i.locationPoint(t).distSqr(r),l=r.x<0||r.y<0||r.x>i.width||r.y>i.height;i.locationPoint(n).distSqr(r)<a&&(l||Math.abs(n.lng-i.center.lng)<s)?t=n:i.locationPoint(o).distSqr(r)<a&&(l||Math.abs(o.lng-i.center.lng)<s)&&(t=o)}for(;Math.abs(t.lng-i.center.lng)>180;){const e=i.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=i.width&&e.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t}const Yn={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 Kn extends e.Evented{constructor(t,r){if(super(),(t instanceof e.window.HTMLElement||r)&&(t=e.extend({element:t},r)),e.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),t&&t.element)this._element=t.element,this._offset=e.pointGeometry.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const r=41,i=27,n=s("svg",{display:"block",height:r*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${r}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},n));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},n),s("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"},n),s("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"},n),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),this._offset=e.pointGeometry.convert(t&&t.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",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()}));const i=this._element.classList;for(const e in Yn)i.remove(`mapboxgl-marker-anchor-${e}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.LngLat.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,r=13.5,i=Math.sqrt(Math.pow(r,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[i,-1*(t-r+i)],"bottom-right":[-i,-1*(t-r+i)],left:[r,-1*(t-r)],right:[-r,-1*(t-r)]}:this._offset}this._popup=e,e._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(e){const t=e.code,r=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==r&&13!==r||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,r=this._element;this._popup&&(t===r||r.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map;if(!e)return!1;const t=e.unproject(this._pos),r=e.getFreeCameraOptions();if(!r.position)return!1;const i=r.position.toLngLat();return i.distanceTo(t)<.9*i.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const r=this._pos;if(!r||r.x<0||r.x>t.transform.width||r.y<0||r.y>t.transform.height)return void this._clearFadeTimer();const i=t.unproject(r);let n;t._usingGlobe()&&e.isLngLatBehindGlobe(t.transform,this._lngLat)?n=0:(n=1-t._queryFogOpacity(i),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(n*=.2)),this._element.style.opacity=`${n}`,this._element.style.pointerEvents=n>0?"auto":"none",this._popup&&this._popup._setOpacity(n),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._calculateXYTransform()+this._calculateZTransform(),r=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px) ${Yn[this._anchor]}\n ${t}\n translate(${r.x}px,${r.y}px)\n `}_calculateXYTransform(){const t=this._pos,r=this._map;if("map"!==this.getPitchAlignment()||!r||!t)return"";if(!r._usingGlobe()){const e=r.getPitch();return e?`rotateX(${e}deg)`:""}const i=e.radToDeg(e.globeTiltAtLngLat(r.transform,this._lngLat)),n=t.sub(e.globeCenterToScreenPoint(r.transform)),o=i/(Math.abs(n.x)+Math.abs(n.y)),s=n.x*o,a=-n.y*o;return a||s?`rotateX(${a}deg) rotateY(${s}deg)`:""}_calculateZTransform(){const e=this._calculateRotation();return e?`rotateZ(${e}deg)`:""}_calculateRotation(){if("viewport"===this._rotationAlignment||"auto"===this._rotationAlignment)return this._rotation;if(this._map&&"map"===this._rotationAlignment){const t=this._map;if(this._pos&&t&&t._usingGlobe()){const r=t.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),i=t.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(r);return this._rotation+e.radToDeg(Math.atan2(i.y,i.x))-90}return this._rotation-this._map.getBearing()}return 0}_update(t){e.window.cancelAnimationFrame(this._updateFrameId);const r=this._map;r&&(r.transform.renderWorldCopies&&(this._lngLat=Xn(this._lngLat,this._pos,r.transform)),this._pos=r.project(this._lngLat),!0===t?this._updateFrameId=e.window.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),r._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(r._usingGlobe()||r.getTerrain()||r.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=e.pointGeometry.convert(t),this._update(),this}_onMove(t){const r=this._map;if(r){if(!this._isDragging){const e=this._clickTolerance||r._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=r.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.Event("dragstart"))),this.fire(new e.Event("drag")))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.Event("dragend")),this._state="inactive"}_addDragHandler(e){const t=this._map;t&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp))}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}}class Jn{constructor(e){this.jumpTo(e)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const r=e.easeCubicInOut((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-r)+this._end*r}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,r){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+r}}const Qn={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},eo={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,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};function to(e){e.parentNode&&e.parentNode.removeChild(e)}const ro={showCompass:!0,showZoom:!0,visualizePitch:!1};class io{constructor(t,r,i=!1){this._clickTolerance=10,this.element=r,this.mouseRotate=new gn({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,i&&(this.mousePitch=new yn({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.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(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),u()}move(e,t){const r=this.map,i=this.mouseRotate.mousemoveWindow(e,t),n=i&&i.bearingDelta;if(n&&r.setBearing(r.getBearing()+n),this.mousePitch){const i=this.mousePitch.mousemoveWindow(e,t),n=i&&i.pitchDelta;n&&r.setPitch(r.getPitch()+n)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),e.window.removeEventListener("mousemove",this.mousemove),e.window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),f(this.element,t)),e.window.addEventListener("mousemove",this.mousemove),e.window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,f(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=m(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const no={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},oo={maxWidth:100,unit:"metric"};function so(e,t,r){const i=ao(t),n=i/t,o={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"}[r];this._map._requestDomTask((()=>{this._container.style.width=e*n+"px",this._container.innerHTML=`${i}&nbsp;${o}`}))}function ao(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let r=e/t;return r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(r),t*r}const lo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},co=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function uo(t=new e.pointGeometry(0,0),r="bottom"){if("number"==typeof t){const i=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(r){case"top":return new e.pointGeometry(0,t);case"top-left":return new e.pointGeometry(i,i);case"top-right":return new e.pointGeometry(-i,i);case"bottom":return new e.pointGeometry(0,-t);case"bottom-left":return new e.pointGeometry(i,-i);case"bottom-right":return new e.pointGeometry(-i,-i);case"left":return new e.pointGeometry(t,0);case"right":return new e.pointGeometry(-t,0)}return new e.pointGeometry(0,0)}return t instanceof e.pointGeometry||Array.isArray(t)?e.pointGeometry.convert(t):e.pointGeometry.convert(t[r]||[0,0])}const ho={version:e.version,supported:r,setRTLTextPlugin:e.setRTLTextPlugin,getRTLTextPluginStatus:e.getRTLTextPluginStatus,Map:class extends $n{constructor(t){if(null!=(t=e.extend({},eo,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.isSafariWithAntialiasingBug(e.window)&&(t.antialias=!1,e.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Zi(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._language="auto"===t.language?e.window.navigator.language:t.language,this._worldview=t.worldview,this._renderTaskQueue=new Hn,this._domRenderTaskQueue=new Hn,this._controls=[],this._markers=[],this._mapId=e.uniqueId(),this._locale=e.extend({},Qn,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Jn(0),this._explicitProjection=null,this._requestManager=new e.RequestManager(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=e.window.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof e.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)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))),void 0!==e.window&&(e.window.addEventListener("online",this._onWindowOnline,!1),e.window.addEventListener("resize",this._onWindowResize,!1),e.window.addEventListener("orientationchange",this._onWindowResize,!1),e.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new qn(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),this._hash=t.hash&&new Hi("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.extend({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new Zn({customAttribution:t.customAttribution})),this._logoControl=new Wn,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.Event(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.Event(`${t.dataType}dataloading`,t))}))}_getMapId(){return this._mapId}addControl(t,r){if(void 0===r&&(r=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[r];return-1!==r.indexOf("bottom")?n.insertBefore(i,n.firstChild):n.appendChild(i),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(t);return r>-1&&this._controls.splice(r,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const r=!this._moving;return r&&this.fire(new e.Event("movestart",t)).fire(new e.Event("move",t)),this.fire(new e.Event("resize",t)),r&&this.fire(new e.Event("moveend",t)),this}getBounds(){return"globe"===this.transform.projection.name&&e.warnOnce('Globe projection does not support getBounds API, this API may behave unexpectedly."'),this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.LngLatBounds.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?85:t)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.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(e){return this.transform.renderWorldCopies=e,this._update()}getLanguage(){return this._language}setLanguage(t){if(this._language="auto"===t?e.window.navigator.language:t,this.style)for(const e in this.style._sourceCaches){const t=this.style._sourceCaches[e]._source;t._setLanguage&&t._setLanguage(this._language)}for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){if(this._worldview=e,this.style)for(const t in this.style._sourceCaches){const r=this.style._sourceCaches[t]._source;r._setWorldview&&r._setWorldview(e)}return this}getProjection(){return this._explicitProjection?this._explicitProjection:this.style&&this.style.stylesheet&&this.style.stylesheet.projection?this.style.stylesheet.projection:{name:"mercator",center:[0,0]}}_usingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._updateProjection(e)}_updateProjection(t){const r=this.getProjection();null===t&&(this._explicitProjection=null);const i=t||this.getProjection();let n;if(i&&"globe"===i.name&&this.transform.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX?(n=this.transform.setProjection({name:"mercator"}),this.transform.mercatorFromTransition=!0):(n=this.transform.setProjection(i),this.transform.mercatorFromTransition=!1),t&&(this._explicitProjection="globe"===t.name?{name:"globe",center:[0,0]}:this.transform.getProjection()),this.style.applyProjectionUpdate(),n){if("globe"===r.name&&"globe"===this.getProjection().name)this.style._forceSymbolLayerUpdate();else{this.painter.clearBackgroundTiles();for(const e in this.style._sourceCaches)this.style._sourceCaches[e].clearTiles()}this._update(!0)}return this}project(t){return this.transform.locationPoint3D(e.LngLat.convert(t))}unproject(t){return this.transform.pointLocation3D(e.pointGeometry.convert(t))}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}_createDelegatedListener(e,t,r){if("mouseenter"===e||"mouseover"===e){let i=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e))),s=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?i||(i=!0,r.call(this,new nn(e,this,n.originalEvent,{features:s}))):i=!1},o=()=>{i=!1};return{layers:new Set(t),listener:r,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let i=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?i=!0:i&&(i=!1,r.call(this,new nn(e,this,n.originalEvent)))},o=t=>{i&&(i=!1,r.call(this,new nn(e,this,t.originalEvent)))};return{layers:new Set(t),listener:r,delegates:{mousemove:n,mouseout:o}}}{const i=e=>{const i=t.filter((e=>this.getLayer(e))),n=i.length?this.queryRenderedFeatures(e.point,{layers:i}):[];n.length&&(e.features=n,r.call(this,e),delete e.features)};return{layers:new Set(t),listener:r,delegates:{[e]:i}}}}on(e,t,r){if(void 0===r)return super.on(e,t);Array.isArray(t)||(t=[t]);const i=this._createDelegatedListener(e,t,r);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(i);for(const e in i.delegates)this.on(e,i.delegates[e]);return this}once(e,t,r){if(void 0===r)return super.once(e,t);Array.isArray(t)||(t=[t]);const i=this._createDelegatedListener(e,t,r);for(const e in i.delegates)this.once(e,i.delegates[e]);return this}off(e,t,r){if(void 0===r)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const i=(e,t)=>{if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0},n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n<e.length;n++){const o=e[n];if(o.listener===r&&i(o.layers,t)){for(const e in o.delegates)this.off(e,o.delegates[e]);return e.splice(n,1),this}}})(n),this}queryRenderedFeatures(t,r){return this.style?(void 0!==r||void 0===t||t instanceof e.pointGeometry||Array.isArray(t)||(r=t,t=void 0),this.style.queryRenderedFeatures(t=t||[[0,0],[this.transform.width,this.transform.height]],r=r||{},this.transform)):[]}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}queryTerrainElevation(t,r){const i=this.transform.elevation;return i?(r=e.extend({},{exaggerated:!0},r),i.getAtPoint(e.MercatorCoordinate.fromLngLat(t),null,r.exaggerated)):null}setStyle(t,r){return!1!==(r=e.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},r)).diff&&r.localIdeographFontFamily===this._localIdeographFontFamily&&r.localFontFamily===this._localFontFamily&&this.style&&t?(this._diffStyle(t,r),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._localFontFamily=r.localFontFamily,this._updateStyle(t,r))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e&&(this.style=new er(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e):this.style.loadJSON(e)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new er(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,r){if("string"==typeof t){const i=this._requestManager.normalizeStyleURL(t),n=this._requestManager.transformRequest(i,e.ResourceType.Style);e.getJSON(n,((t,i)=>{t?this.fire(new e.ErrorEvent(t)):i&&this._updateDiff(i,r)}))}else"object"==typeof t&&this._updateDiff(t,r)}_updateDiff(t,r){try{this.style.setState(t)&&this._update(!0)}catch(i){e.warnOnce(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(t,r)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.warnOnce("There is no style added to the map."),!1)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){return!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const r=e[t]._tiles;for(const e in r){const t=r[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}addSourceType(e,t,r){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,r)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(t,r,{pixelRatio:i=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),r instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&r instanceof e.window.ImageBitmap){const{width:l,height:c,data:u}=e.exported.getImageData(r);this.style.addImage(t,{data:new e.RGBAImage({width:l,height:c},u),pixelRatio:i,stretchX:o,stretchY:s,content:a,sdf:n,version:0})}else if(void 0===r.width||void 0===r.height)this.fire(new e.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:l,height:c}=r,u=r;this.style.addImage(t,{data:new e.RGBAImage({width:l,height:c},new Uint8Array(u.data)),pixelRatio:i,stretchX:o,stretchY:s,content:a,sdf:n,version:0,userImage:u}),u.onAdd&&u.onAdd(this,t)}}updateImage(t,r){const i=this.style.getImage(t);if(!i)return void this.fire(new e.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=r instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&r instanceof e.window.ImageBitmap?e.exported.getImageData(r):r,{width:o,height:s}=n;void 0!==o&&void 0!==s?o===i.data.width&&s===i.data.height?(i.data.replace(n.data,!(r instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&r instanceof e.window.ImageBitmap)),this.style.updateImage(t,i)):this.fire(new e.ErrorEvent(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${i.data.width}, ${i.data.height})`))):this.fire(new e.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(t){return t?!!this.style.getImage(t):(this.fire(new e.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,r){e.getImage(this._requestManager.transformRequest(t,e.ResourceType.Image),((t,i)=>{r(t,i instanceof e.window.HTMLImageElement?e.exported.getImageData(i):i)}))}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayerZoomRange(e,t,r){return this.style.setLayerZoomRange(e,t,r),this._update(!0)}setFilter(e,t,r={}){return this.style.setFilter(e,t,r),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,r,i={}){return this.style.setPaintProperty(e,t,r,i),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,r,i={}){return this.style.setLayoutProperty(e,t,r,i),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.LngLat.convert(t),this.transform):0}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,r=this._container.getBoundingClientRect().height||300;let i,n,o,s=this._container;for(;s&&(!n||!o);){const t=e.window.getComputedStyle(s).transform;t&&"none"!==t&&(i=t.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(n=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(o=i[3])),s=s.parentElement}this._containerWidth=n?Math.abs(t/n):t,this._containerHeight=o?Math.abs(r/o):r}_detectMissingCSS(){"rgb(250, 128, 114)"!==e.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=o("canvas","mapboxgl-canvas",t),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 r=this._controlContainer=o("div","mapboxgl-control-container",e),i=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{i[e]=o("div",`mapboxgl-ctrl-${e}`,r)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,r){const i=e.exported.devicePixelRatio||1;this._canvas.width=i*Math.ceil(t),this._canvas.height=i*Math.ceil(r),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${r}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_setupPainter(){const t=e.extend({},r.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl",t)||this._canvas.getContext("experimental-webgl",t);i?(e.storeAuthState(i,!0),this.painter=new Di(i,this.transform),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),e.exported$1.testSupport(i)):this.fire(new e.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.Event("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.Event("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.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(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let r;const i=this.painter.context.extTimerQuery,n=e.exported.now();if(this.listens("gpu-timing-frame")&&(r=i.createQueryEXT(),i.beginQueryEXT(i.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;"globe"===this.getProjection().name&&(this.transform.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX?"globe"===this.transform.projection.name&&this._updateProjection():"mercator"===this.transform.projection.name&&this._updateProjection());let o=!1;const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,r=this.transform.pitch,i=e.exported.now();this.style.zoomHistory.update(t,i);const n=new e.EvaluationParameters(t,{now:i,fadeDuration:s,pitch:r,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),a=n.crossFadingFactor();1===a&&a===this._crossFadingFactor||(o=!0,this._crossFadingFactor=a),this.style.update(n)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(n),this.style._updateSources(this.transform),this._forceMarkerUpdate()):a=this._updateAverageElevation(n),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,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 e.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.Event("load"))),this.style&&(this.style.hasTransitions()||o)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const t=e.exported.now()-n;i.endQueryEXT(i.TIME_ELAPSED_EXT,r),setTimeout((()=>{const o=i.getQueryObjectEXT(r,i.QUERY_RESULT_EXT)/1e6;i.deleteQueryEXT(r),this.fire(new e.Event("gpu-timing-frame",{cpuTime:t,gpuTime:o})),e.window.performance.mark("frame-gpu",{startTime:n,detail:{gpuTime:o}})}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const r=this.painter.queryGpuTimers(t);this.fire(new e.Event("gpu-timing-layer",{layerTimes:r}))}),50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const r=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.Event("gpu-timing-deferred-render",{gpuTime:r}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(n,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.Event("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._authenticate())}_forceMarkerUpdate(){for(const e of this._markers)e._update()}_updateAverageElevation(e,t=!1){const r=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&r(0);if((t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let i=this.transform.sampleAverageElevation(),n=!1;this.transform.elevation&&(n=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(i)?i=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-i);if(o>1){if(this._isInitialLoad||n)return this._averageElevation.jumpTo(i),r(i);this._averageElevation.easeTo(i,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(i),r(i)}return!!this._averageElevation.isEasing(e)&&r(this._averageElevation.getValue(e))}_authenticate(){e.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.AUTH_ERR_MSG||401===t.status)){const t=this.painter.context.gl;e.storeAuthState(t,!1),this._logoControl instanceof Wn&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.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/")))}})),e.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const r=this.painter.context.gl,i=r.createFramebuffer();function n(e){r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0);const t=new Uint8Array(r.drawingBufferWidth*r.drawingBufferHeight*4);return r.readPixels(0,0,r.drawingBufferWidth,r.drawingBufferHeight,r.RGBA,r.UNSIGNED_BYTE,t),t}return r.bindFramebuffer(r.FRAMEBUFFER,i),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,r){let i=r[1]-r[0];const n=e.length/4;for(let o=0;o<t.length;o++){const s=t[o];let a=0;for(let t=0;t<s.length;t+=4)s[t]===e[t]&&s[t+1]===e[t+1]&&s[t+2]===e[t+2]&&s[t+3]===e[t+3]&&(a+=1);i+=(r[o+2]-r[o+1])*(1-a/n)}return i}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),void 0!==e.window&&(e.window.removeEventListener("resize",this._onWindowResize,!1),e.window.removeEventListener("orientationchange",this._onWindowResize,!1),e.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),e.window.removeEventListener("online",this._onWindowOnline,!1));const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),to(this._canvasContainer),to(this._controlContainer),to(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),e.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new e.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=e.exported.frame((e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(t){const r=this.style?Object.values(this.style._sourceCaches):[];return e.asyncAll(r,((e,r)=>e._preloadTiles(t,r)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}_setCacheLimits(t,r){e.setCacheLimits(t,r)}get version(){return e.version}},NavigationControl:class{constructor(t){this.options=e.extend({},ro,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),r=t===e.getMaxZoom(),i=t===e.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new io(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const r=o("button",e,this._container);return r.type="button",r.addEventListener("click",t),r}_setButtonTitle(e,t){if(!this._map)return;const r=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",r),e.firstElementChild&&e.firstElementChild.setAttribute("title",r)}},GeolocateControl:class extends e.Evented{constructor(t){super(),this.options=e.extend({geolocation:e.window.navigator.geolocation},no,t),e.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Wi(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(t){void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==e.window.navigator.permissions?e.window.navigator.permissions.query({name:"geolocation"}).then((e=>{this._supportsGeolocation="denied"!==e.state,t(this._supportsGeolocation)})):(this._supportsGeolocation=!!this.options.geolocation,t(this._supportsGeolocation))}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),r=e.coords;return!!t&&(r.longitude<t.getWest()||r.longitude>t.getEast()||r.latitude<t.getSouth()||r.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.Event("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,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&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("geolocate",t)),this._finish()}}_updateCamera(t){const r=new e.LngLat(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,n=this._map.getBearing(),o=e.extend({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(i),o,{geolocateSource:!0})}_updateMarker(t){if(t){const r=new e.LngLat(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,r=e.mercatorZfromAltitude(1,t._center.lat)*t.worldSize,i=Math.ceil(2*this._accuracy*r);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(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(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Kn({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Kn({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",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.Event("trackuserlocationend")))}))}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.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 e.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 e.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 e.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("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const t=()=>{e.window.addEventListener("ondeviceorientationabsolute"in e.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==e.window.DeviceMotionEvent&&"function"==typeof e.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((e=>{"granted"===e&&t()})).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),e.window.removeEventListener("deviceorientation",this._onDeviceOrientation),e.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:Zn,ScaleControl:class{constructor(t){this.options=e.extend({},oo,t),function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"narrow",unit:"meter"}),!0}catch(e){return!1}}()||(this._setScale=so.bind(this)),e.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,r=t._containerHeight/2,i=t._containerWidth/2-e/2,n=t.unproject([i,r]),o=t.unproject([i+e,r]),s=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter")}_setScale(e,t,r){const i=ao(t),n=i/t;this._map._requestDomTask((()=>{this._container.style.width=e*n+"px",this._container.innerHTML="nautical-mile"!==r?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"narrow",unit:r}).format(i):`${i}&nbsp;nm`}))}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof e.window.HTMLElement?this._container=t.container:e.warnOnce("Full screen control 'container' must be a DOM element.")),e.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in e.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in e.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,e.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!e.window.document.fullscreenEnabled&&!e.window.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),e.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(e.window.document.fullscreenElement||e.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()?e.window.document.exitFullscreen?e.window.document.exitFullscreen():e.window.document.webkitCancelFullScreen&&e.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.Evented{constructor(t){super(),this.options=e.extend(Object.create(lo),t),e.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),this._map=void 0),this.fire(new e.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.LngLat.convert(t),this._pos=null,this._trackPointer=!1,this._update();const r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(e.window.document.createTextNode(t))}setHTML(t){const r=e.window.document.createDocumentFragment(),i=e.window.document.createElement("body");let n;for(i.innerHTML=t;n=i.firstChild,n;)r.appendChild(n);return this.setDOMContent(r)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="&#215;",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,r=this._container,i=this._pos;if(!t||!r||!i)return"bottom";const n=r.offsetWidth,o=r.offsetHeight,s=i.x<n/2,a=i.x>t.transform.width-n/2;if(i.y+e<o)return s?"top-left":a?"top-right":"top";if(i.y>t.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const r=this._map,i=this._content;if(!r||!this._lngLat&&!this._trackPointer||!i)return;let n=this._container;if(n||(n=this._container=o("div","mapboxgl-popup",r.getContainer()),this._tip=o("div","mapboxgl-popup-tip",n),n.appendChild(i)),this.options.maxWidth&&n.style.maxWidth!==this.options.maxWidth&&(n.style.maxWidth=this.options.maxWidth),r.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Xn(this._lngLat,this._pos,r.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:r.project(this._lngLat),i=uo(this.options.offset),n=this._anchor=this._getAnchor(i.y),o=uo(this.options.offset,n),s=e.add(o).round();r._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${Yn[n]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&r._usingGlobe()){const t=e.isLngLatBehindGlobe(r.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(co);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:Kn,Style:er,LngLat:e.LngLat,LngLatBounds:e.LngLatBounds,Point:e.pointGeometry,MercatorCoordinate:e.MercatorCoordinate,FreeCameraOptions:Fi,Evented:e.Evented,config:e.config,prewarm:function(){Ue().acquire(Fe)},clearPrewarmedResources:function(){const e=je;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Fe),je=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return e.config.ACCESS_TOKEN},set accessToken(t){e.config.ACCESS_TOKEN=t},get baseApiUrl(){return e.config.API_URL},set baseApiUrl(t){e.config.API_URL=t},get workerCount(){return Ne.workerCount},set workerCount(e){Ne.workerCount=e},get maxParallelImageRequests(){return e.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.clearTileCache(t)},workerUrl:"",workerClass:null,setNow:e.exported.setNow,restoreNow:e.exported.restoreNow};return ho})),r}()},277:(e,t,r)=>{e.exports=function e(t,r,i){function n(s,a){if(!r[s]){if(!t[s]){if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[s]={exports:{}};t[s][0].call(c.exports,(function(e){return n(t[s][1][e]||e)}),c,c.exports,e,t,r,i)}return r[s].exports}for(var o=void 0,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(e,t,i){(function(r,i){(function(){"use strict";const n=e("events").EventEmitter,o=e("./store"),s=e("./topic-alias-recv"),a=e("./topic-alias-send"),l=e("mqtt-packet"),c=e("./default-message-id-provider"),u=e("readable-stream").Writable,h=e("inherits"),p=e("reinterval"),d=e("rfdc/default"),f=e("./validations"),m=e("xtend"),_=e("debug")("mqttjs:client"),g=r?r.nextTick:function(e){setTimeout(e,0)},y=i.setImmediate||function(e){g(e)},v={keepalive:60,reschedulePings:!0,protocolId:"MQTT",protocolVersion:4,reconnectPeriod:1e3,connectTimeout:3e4,clean:!0,resubscribe:!0},x=["ECONNREFUSED","EADDRINUSE","ECONNRESET","ENOTFOUND"],b={0:"",1:"Unacceptable protocol version",2:"Identifier rejected",3:"Server unavailable",4:"Bad username or password",5:"Not authorized",16:"No matching subscribers",17:"No subscription existed",128:"Unspecified error",129:"Malformed Packet",130:"Protocol Error",131:"Implementation specific error",132:"Unsupported Protocol Version",133:"Client Identifier not valid",134:"Bad User Name or Password",135:"Not authorized",136:"Server unavailable",137:"Server busy",138:"Banned",139:"Server shutting down",140:"Bad authentication method",141:"Keep Alive timeout",142:"Session taken over",143:"Topic Filter invalid",144:"Topic Name invalid",145:"Packet identifier in use",146:"Packet Identifier not found",147:"Receive Maximum exceeded",148:"Topic Alias invalid",149:"Packet too large",150:"Message rate too high",151:"Quota exceeded",152:"Administrative action",153:"Payload format invalid",154:"Retain not supported",155:"QoS not supported",156:"Use another server",157:"Server moved",158:"Shared Subscriptions not supported",159:"Connection rate exceeded",160:"Maximum connect time",161:"Subscription Identifiers not supported",162:"Wildcard Subscriptions not supported"};function w(e,t){let r;t.properties&&(r=t.properties.topicAlias);let i=t.topic.toString();if(0===i.length){if(void 0===r)return new Error("Unregistered Topic Alias");if(i=e.topicAliasSend.getTopicByAlias(r),void 0===i)return new Error("Unregistered Topic Alias");t.topic=i}r&&delete t.properties.topicAlias}function T(e,t,r){_("sendPacket :: packet: %O",t),_("sendPacket :: emitting `packetsend`"),e.emit("packetsend",t),_("sendPacket :: writing to stream");const i=l.writeToStream(t,e.stream,e.options);_("sendPacket :: writeToStream result %s",i),!i&&r&&r!==C?(_("sendPacket :: handle events on `drain` once through callback."),e.stream.once("drain",r)):r&&(_("sendPacket :: invoking cb"),r())}function E(e){e&&(_("flush: queue exists? %b",!!e),Object.keys(e).forEach((function(t){"function"==typeof e[t].cb&&(e[t].cb(new Error("Connection closed")),delete e[t])})))}function S(e,t,r,i){_("storeAndSend :: store packet with cmd %s to outgoingStore",t.cmd);let n,o=t;if("publish"===o.cmd&&(o=d(t),n=w(e,o),n))return r&&r(n);e.outgoingStore.put(o,(function(n){if(n)return r&&r(n);i(),T(e,t,r)}))}function C(e){_("nop ::",e)}function A(e,t){let r;const i=this;if(!(this instanceof A))return new A(e,t);for(r in this.options=t||{},v)void 0===this.options[r]?this.options[r]=v[r]:this.options[r]=t[r];_("MqttClient :: options.protocol",t.protocol),_("MqttClient :: options.protocolVersion",t.protocolVersion),_("MqttClient :: options.username",t.username),_("MqttClient :: options.keepalive",t.keepalive),_("MqttClient :: options.reconnectPeriod",t.reconnectPeriod),_("MqttClient :: options.rejectUnauthorized",t.rejectUnauthorized),_("MqttClient :: options.topicAliasMaximum",t.topicAliasMaximum),this.options.clientId="string"==typeof t.clientId?t.clientId:"mqttjs_"+Math.random().toString(16).substr(2,8),_("MqttClient :: clientId",this.options.clientId),this.options.customHandleAcks=5===t.protocolVersion&&t.customHandleAcks?t.customHandleAcks:function(){arguments[3](0)},this.streamBuilder=e,this.messageIdProvider=void 0===this.options.messageIdProvider?new c:this.options.messageIdProvider,this.outgoingStore=t.outgoingStore||new o,this.incomingStore=t.incomingStore||new o,this.queueQoSZero=void 0===t.queueQoSZero||t.queueQoSZero,this._resubscribeTopics={},this.messageIdToTopic={},this.pingTimer=null,this.connected=!1,this.disconnecting=!1,this.queue=[],this.connackTimer=null,this.reconnectTimer=null,this._storeProcessing=!1,this._packetIdsDuringStoreProcessing={},this._storeProcessingQueue=[],this.outgoing={},this._firstConnection=!0,t.topicAliasMaximum>0&&(t.topicAliasMaximum>65535?_("MqttClient :: options.topicAliasMaximum is out of range"):this.topicAliasRecv=new s(t.topicAliasMaximum)),this.on("connect",(function(){const e=this.queue;_("connect :: sending queued packets"),function t(){const r=e.shift();_("deliver :: entry %o",r);let n=null;if(!r)return void i._resubscribe();n=r.packet,_("deliver :: call _sendPacket for %o",n);let o=!0;n.messageId&&0!==n.messageId&&(i.messageIdProvider.register(n.messageId)||(o=!1)),o?i._sendPacket(n,(function(e){r.cb&&r.cb(e),t()})):(_("messageId: %d has already used. The message is skipped and removed.",n.messageId),t())}()})),this.on("close",(function(){_("close :: connected set to `false`"),this.connected=!1,_("close :: clearing connackTimer"),clearTimeout(this.connackTimer),_("close :: clearing ping timer"),null!==i.pingTimer&&(i.pingTimer.clear(),i.pingTimer=null),this.topicAliasRecv&&this.topicAliasRecv.clear(),_("close :: calling _setupReconnect"),this._setupReconnect()})),n.call(this),_("MqttClient :: setting up stream"),this._setupStream()}h(A,n),A.prototype._setupStream=function(){const e=this,t=new u,r=l.parser(this.options);let i=null;const n=[];function o(){if(n.length)g(s);else{const e=i;i=null,e()}}function s(){_("work :: getting next packet in queue");const t=n.shift();if(t)_("work :: packet pulled from queue"),e._handlePacket(t,o);else{_("work :: no packets in queue");const e=i;i=null,_("work :: done flag is %s",!!e),e&&e()}}_("_setupStream :: calling method to clear reconnect"),this._clearReconnect(),_("_setupStream :: using streamBuilder provided to client to create stream"),this.stream=this.streamBuilder(this),r.on("packet",(function(e){_("parser :: on packet push to packets array."),n.push(e)})),t._write=function(e,t,n){i=n,_("writable stream :: parsing buffer"),r.parse(e),s()},_("_setupStream :: pipe stream to writable stream"),this.stream.pipe(t),this.stream.on("error",(function(t){_("streamErrorHandler :: error",t.message),x.includes(t.code)?(_("streamErrorHandler :: emitting error"),e.emit("error",t)):C(t)})),this.stream.on("close",(function(){var t;_("(%s)stream :: on close",e.options.clientId),(t=e.outgoing)&&(_("flushVolatile :: deleting volatile messages from the queue and setting their callbacks as error function"),Object.keys(t).forEach((function(e){t[e].volatile&&"function"==typeof t[e].cb&&(t[e].cb(new Error("Connection closed")),delete t[e])}))),_("stream: emit close to MqttClient"),e.emit("close")})),_("_setupStream: sending packet `connect`");const a=Object.create(this.options);if(a.cmd="connect",this.topicAliasRecv&&(a.properties||(a.properties={}),this.topicAliasRecv&&(a.properties.topicAliasMaximum=this.topicAliasRecv.max)),T(this,a),r.on("error",this.emit.bind(this,"error")),this.options.properties){if(!this.options.properties.authenticationMethod&&this.options.properties.authenticationData)return e.end((()=>this.emit("error",new Error("Packet has no Authentication Method")))),this;this.options.properties.authenticationMethod&&this.options.authPacket&&"object"==typeof this.options.authPacket&&T(this,m({cmd:"auth",reasonCode:0},this.options.authPacket))}this.stream.setMaxListeners(1e3),clearTimeout(this.connackTimer),this.connackTimer=setTimeout((function(){_("!!connectTimeout hit!! Calling _cleanUp with force `true`"),e._cleanUp(!0)}),this.options.connectTimeout)},A.prototype._handlePacket=function(e,t){const r=this.options;if(5===r.protocolVersion&&r.properties&&r.properties.maximumPacketSize&&r.properties.maximumPacketSize<e.length)return this.emit("error",new Error("exceeding packets size "+e.cmd)),this.end({reasonCode:149,properties:{reasonString:"Maximum packet size was exceeded"}}),this;switch(_("_handlePacket :: emitting packetreceive"),this.emit("packetreceive",e),e.cmd){case"publish":this._handlePublish(e,t);break;case"puback":case"pubrec":case"pubcomp":case"suback":case"unsuback":this._handleAck(e),t();break;case"pubrel":this._handlePubrel(e,t);break;case"connack":this._handleConnack(e),t();break;case"auth":this._handleAuth(e),t();break;case"pingresp":this._handlePingresp(e),t();break;case"disconnect":this._handleDisconnect(e),t()}},A.prototype._checkDisconnecting=function(e){return this.disconnecting&&(e&&e!==C?e(new Error("client disconnecting")):this.emit("error",new Error("client disconnecting"))),this.disconnecting},A.prototype.publish=function(e,t,r,i){_("publish :: message `%s` to topic `%s`",t,e);const n=this.options;if("function"==typeof r&&(i=r,r=null),r=m({qos:0,retain:!1,dup:!1},r),this._checkDisconnecting(i))return this;const o=this,s=function(){let s=0;if((1===r.qos||2===r.qos)&&(s=o._nextId(),null===s))return _("No messageId left"),!1;const a={cmd:"publish",topic:e,payload:t,qos:r.qos,retain:r.retain,messageId:s,dup:r.dup};switch(5===n.protocolVersion&&(a.properties=r.properties),_("publish :: qos",r.qos),r.qos){case 1:case 2:o.outgoing[a.messageId]={volatile:!1,cb:i||C},_("MqttClient:publish: packet cmd: %s",a.cmd),o._sendPacket(a,void 0,r.cbStorePut);break;default:_("MqttClient:publish: packet cmd: %s",a.cmd),o._sendPacket(a,i,r.cbStorePut)}return!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,cbStorePut:r.cbStorePut,callback:i}),this},A.prototype.subscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];const r=[];let i=t.shift();const n=i.resubscribe;let o=t.pop()||C,s=t.pop();const a=this.options.protocolVersion;delete i.resubscribe,"string"==typeof i&&(i=[i]),"function"!=typeof o&&(s=o,o=C);const l=f.validateTopics(i);if(null!==l)return y(o,new Error("Invalid topic "+l)),this;if(this._checkDisconnecting(o))return _("subscribe: discconecting true"),this;const c={qos:0};if(5===a&&(c.nl=!1,c.rap=!1,c.rh=0),s=m(c,s),Array.isArray(i)?i.forEach((function(t){if(_("subscribe: array topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<s.qos||n){const e={topic:t,qos:s.qos};5===a&&(e.nl=s.nl,e.rap=s.rap,e.rh=s.rh,e.properties=s.properties),_("subscribe: pushing topic `%s` and qos `%s` to subs list",e.topic,e.qos),r.push(e)}})):Object.keys(i).forEach((function(t){if(_("subscribe: object topic %s",t),!Object.prototype.hasOwnProperty.call(e._resubscribeTopics,t)||e._resubscribeTopics[t].qos<i[t].qos||n){const e={topic:t,qos:i[t].qos};5===a&&(e.nl=i[t].nl,e.rap=i[t].rap,e.rh=i[t].rh,e.properties=s.properties),_("subscribe: pushing `%s` to subs list",e),r.push(e)}})),!r.length)return o(null,[]),this;const u=function(){const t=e._nextId();if(null===t)return _("No messageId left"),!1;const i={cmd:"subscribe",subscriptions:r,qos:1,retain:!1,dup:!1,messageId:t};if(s.properties&&(i.properties=s.properties),e.options.resubscribe){_("subscribe :: resubscribe true");const t=[];r.forEach((function(r){if(e.options.reconnectPeriod>0){const i={qos:r.qos};5===a&&(i.nl=r.nl||!1,i.rap=r.rap||!1,i.rh=r.rh||0,i.properties=r.properties),e._resubscribeTopics[r.topic]=i,t.push(r.topic)}})),e.messageIdToTopic[i.messageId]=t}return e.outgoing[i.messageId]={volatile:!0,cb:function(e,t){if(!e){const e=t.granted;for(let t=0;t<e.length;t+=1)r[t].qos=e[t]}o(e,r)}},_("subscribe :: call _sendPacket"),e._sendPacket(i),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!u())&&this._storeProcessingQueue.push({invoke:u,callback:o}),this},A.prototype.unsubscribe=function(){const e=this,t=new Array(arguments.length);for(let e=0;e<arguments.length;e++)t[e]=arguments[e];let r=t.shift(),i=t.pop()||C,n=t.pop();"string"==typeof r&&(r=[r]),"function"!=typeof i&&(n=i,i=C);const o=f.validateTopics(r);if(null!==o)return y(i,new Error("Invalid topic "+o)),this;if(e._checkDisconnecting(i))return this;const s=function(){const t=e._nextId();if(null===t)return _("No messageId left"),!1;const o={cmd:"unsubscribe",qos:1,messageId:t};return"string"==typeof r?o.unsubscriptions=[r]:Array.isArray(r)&&(o.unsubscriptions=r),e.options.resubscribe&&o.unsubscriptions.forEach((function(t){delete e._resubscribeTopics[t]})),"object"==typeof n&&n.properties&&(o.properties=n.properties),e.outgoing[o.messageId]={volatile:!0,cb:i},_("unsubscribe: call _sendPacket"),e._sendPacket(o),!0};return(this._storeProcessing||this._storeProcessingQueue.length>0||!s())&&this._storeProcessingQueue.push({invoke:s,callback:i}),this},A.prototype.end=function(e,t,r){const i=this;function n(){_("end :: closeStores: closing incoming and outgoing stores"),i.disconnected=!0,i.incomingStore.close((function(e){i.outgoingStore.close((function(t){if(_("end :: closeStores: emitting end"),i.emit("end"),r){const i=e||t;_("end :: closeStores: invoking callback with args"),r(i)}}))})),i._deferredReconnect&&i._deferredReconnect()}function o(){_("end :: (%s) :: finish :: calling _cleanUp with force %s",i.options.clientId,e),i._cleanUp(e,(()=>{_("end :: finish :: calling process.nextTick on closeStores"),g(n.bind(i))}),t)}return _("end :: (%s)",this.options.clientId),null!=e&&"boolean"==typeof e||(r=t||C,t=e,e=!1,"object"!=typeof t&&(r=t,t=null,"function"!=typeof r&&(r=C))),"object"!=typeof t&&(r=t,t=null),_("end :: cb? %s",!!r),r=r||C,this.disconnecting?(r(),this):(this._clearReconnect(),this.disconnecting=!0,!e&&Object.keys(this.outgoing).length>0?(_("end :: (%s) :: calling finish in 10ms once outgoing is empty",i.options.clientId),this.once("outgoingEmpty",setTimeout.bind(null,o,10))):(_("end :: (%s) :: immediately calling finish",i.options.clientId),o()),this)},A.prototype.removeOutgoingMessage=function(e){const t=this.outgoing[e]?this.outgoing[e].cb:null;return delete this.outgoing[e],this.outgoingStore.del({messageId:e},(function(){t(new Error("Message removed"))})),this},A.prototype.reconnect=function(e){_("client reconnect");const t=this,r=function(){e?(t.options.incomingStore=e.incomingStore,t.options.outgoingStore=e.outgoingStore):(t.options.incomingStore=null,t.options.outgoingStore=null),t.incomingStore=t.options.incomingStore||new o,t.outgoingStore=t.options.outgoingStore||new o,t.disconnecting=!1,t.disconnected=!1,t._deferredReconnect=null,t._reconnect()};return this.disconnecting&&!this.disconnected?this._deferredReconnect=r:r(),this},A.prototype._reconnect=function(){_("_reconnect: emitting reconnect to client"),this.emit("reconnect"),this.connected?(this.end((()=>{this._setupStream()})),_("client already connected. disconnecting first.")):(_("_reconnect: calling _setupStream"),this._setupStream())},A.prototype._setupReconnect=function(){const e=this;!e.disconnecting&&!e.reconnectTimer&&e.options.reconnectPeriod>0?(this.reconnecting||(_("_setupReconnect :: emit `offline` state"),this.emit("offline"),_("_setupReconnect :: set `reconnecting` to `true`"),this.reconnecting=!0),_("_setupReconnect :: setting reconnectTimer for %d ms",e.options.reconnectPeriod),e.reconnectTimer=setInterval((function(){_("reconnectTimer :: reconnect triggered!"),e._reconnect()}),e.options.reconnectPeriod)):_("_setupReconnect :: doing nothing...")},A.prototype._clearReconnect=function(){_("_clearReconnect : clearing reconnect timer"),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null)},A.prototype._cleanUp=function(e,t){const r=arguments[2];if(t&&(_("_cleanUp :: done callback provided for on stream close"),this.stream.on("close",t)),_("_cleanUp :: forced? %s",e),e)0===this.options.reconnectPeriod&&this.options.clean&&E(this.outgoing),_("_cleanUp :: (%s) :: destroying stream",this.options.clientId),this.stream.destroy();else{const e=m({cmd:"disconnect"},r);_("_cleanUp :: (%s) :: call _sendPacket with disconnect packet",this.options.clientId),this._sendPacket(e,y.bind(null,this.stream.end.bind(this.stream)))}this.disconnecting||(_("_cleanUp :: client not disconnecting. Clearing and resetting reconnect."),this._clearReconnect(),this._setupReconnect()),null!==this.pingTimer&&(_("_cleanUp :: clearing pingTimer"),this.pingTimer.clear(),this.pingTimer=null),t&&!this.connected&&(_("_cleanUp :: (%s) :: removing stream `done` callback `close` listener",this.options.clientId),this.stream.removeListener("close",t),t())},A.prototype._sendPacket=function(e,t,r){_("_sendPacket :: (%s) :: start",this.options.clientId),r=r||C,t=t||C;const i=function(e,t){if(5===e.options.protocolVersion&&"publish"===t.cmd){let r;t.properties&&(r=t.properties.topicAlias);const i=t.topic.toString();if(e.topicAliasSend)if(r){if(0!==i.length&&(_("applyTopicAlias :: register topic: %s - alias: %d",i,r),!e.topicAliasSend.put(i,r)))return _("applyTopicAlias :: error out of range. topic: %s - alias: %d",i,r),new Error("Sending Topic Alias out of range")}else 0!==i.length&&(e.options.autoAssignTopicAlias?(r=e.topicAliasSend.getAliasByTopic(i),r?(t.topic="",t.properties={...t.properties,topicAlias:r},_("applyTopicAlias :: auto assign(use) topic: %s - alias: %d",i,r)):(r=e.topicAliasSend.getLruAlias(),e.topicAliasSend.put(i,r),t.properties={...t.properties,topicAlias:r},_("applyTopicAlias :: auto assign topic: %s - alias: %d",i,r))):e.options.autoUseTopicAlias&&(r=e.topicAliasSend.getAliasByTopic(i),r&&(t.topic="",t.properties={...t.properties,topicAlias:r},_("applyTopicAlias :: auto use topic: %s - alias: %d",i,r))));else if(r)return _("applyTopicAlias :: error out of range. topic: %s - alias: %d",i,r),new Error("Sending Topic Alias out of range")}}(this,e);if(i)t(i);else{if(!this.connected)return"auth"===e.cmd?(this._shiftPingInterval(),void T(this,e,t)):(_("_sendPacket :: client not connected. Storing packet offline."),void this._storePacket(e,t,r));switch(this._shiftPingInterval(),e.cmd){case"publish":break;case"pubrel":return void S(this,e,t,r);default:return void T(this,e,t)}switch(e.qos){case 2:case 1:S(this,e,t,r);break;default:T(this,e,t)}_("_sendPacket :: (%s) :: end",this.options.clientId)}},A.prototype._storePacket=function(e,t,r){_("_storePacket :: packet: %o",e),_("_storePacket :: cb? %s",!!t),r=r||C;let i=e;if("publish"===i.cmd){i=d(e);const r=w(this,i);if(r)return t&&t(r)}0===(i.qos||0)&&this.queueQoSZero||"publish"!==i.cmd?this.queue.push({packet:i,cb:t}):i.qos>0?(t=this.outgoing[i.messageId]?this.outgoing[i.messageId].cb:null,this.outgoingStore.put(i,(function(e){if(e)return t&&t(e);r()}))):t&&t(new Error("No connection to broker"))},A.prototype._setupPingTimer=function(){_("_setupPingTimer :: keepalive %d (seconds)",this.options.keepalive);const e=this;!this.pingTimer&&this.options.keepalive&&(this.pingResp=!0,this.pingTimer=p((function(){e._checkPing()}),1e3*this.options.keepalive))},A.prototype._shiftPingInterval=function(){this.pingTimer&&this.options.keepalive&&this.options.reschedulePings&&this.pingTimer.reschedule(1e3*this.options.keepalive)},A.prototype._checkPing=function(){_("_checkPing :: checking ping..."),this.pingResp?(_("_checkPing :: ping response received. Clearing flag and sending `pingreq`"),this.pingResp=!1,this._sendPacket({cmd:"pingreq"})):(_("_checkPing :: calling _cleanUp with force true"),this._cleanUp(!0))},A.prototype._handlePingresp=function(){this.pingResp=!0},A.prototype._handleConnack=function(e){_("_handleConnack");const t=this.options,r=5===t.protocolVersion?e.reasonCode:e.returnCode;if(clearTimeout(this.connackTimer),delete this.topicAliasSend,e.properties){if(e.properties.topicAliasMaximum){if(e.properties.topicAliasMaximum>65535)return void this.emit("error",new Error("topicAliasMaximum from broker is out of range"));e.properties.topicAliasMaximum>0&&(this.topicAliasSend=new a(e.properties.topicAliasMaximum))}e.properties.serverKeepAlive&&t.keepalive&&(t.keepalive=e.properties.serverKeepAlive,this._shiftPingInterval()),e.properties.maximumPacketSize&&(t.properties||(t.properties={}),t.properties.maximumPacketSize=e.properties.maximumPacketSize)}if(0===r)this.reconnecting=!1,this._onConnect(e);else if(r>0){const e=new Error("Connection refused: "+b[r]);e.code=r,this.emit("error",e)}},A.prototype._handleAuth=function(e){const t=this.options.protocolVersion,r=5===t?e.reasonCode:e.returnCode;if(5!==t){const e=new Error("Protocol error: Auth packets are only supported in MQTT 5. Your version:"+t);return e.code=r,void this.emit("error",e)}const i=this;this.handleAuth(e,(function(e,t){if(e)i.emit("error",e);else if(24===r)i.reconnecting=!1,i._sendPacket(t);else{const t=new Error("Connection refused: "+b[r]);e.code=r,i.emit("error",t)}}))},A.prototype.handleAuth=function(e,t){t()},A.prototype._handlePublish=function(e,t){_("_handlePublish: packet %o",e),t=void 0!==t?t:C;let r=e.topic.toString();const i=e.payload,n=e.qos,o=e.messageId,s=this,a=this.options,l=[0,16,128,131,135,144,145,151,153];if(5===this.options.protocolVersion){let t;if(e.properties&&(t=e.properties.topicAlias),void 0!==t)if(0===r.length){if(!(t>0&&t<=65535))return _("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));{const e=this.topicAliasRecv.getTopicByAlias(t);if(!e)return _("_handlePublish :: unregistered topic alias. alias: %d",t),void this.emit("error",new Error("Received unregistered Topic Alias"));r=e,_("_handlePublish :: topic complemented by alias. topic: %s - alias: %d",r,t)}}else{if(!this.topicAliasRecv.put(r,t))return _("_handlePublish :: topic alias out of range. alias: %d",t),void this.emit("error",new Error("Received Topic Alias is out of range"));_("_handlePublish :: registered topic: %s - alias: %d",r,t)}}switch(_("_handlePublish: qos %d",n),n){case 2:a.customHandleAcks(r,i,e,(function(r,i){return r instanceof Error||(i=r,r=null),r?s.emit("error",r):-1===l.indexOf(i)?s.emit("error",new Error("Wrong reason code for pubrec")):void(i?s._sendPacket({cmd:"pubrec",messageId:o,reasonCode:i},t):s.incomingStore.put(e,(function(){s._sendPacket({cmd:"pubrec",messageId:o},t)})))}));break;case 1:a.customHandleAcks(r,i,e,(function(n,a){return n instanceof Error||(a=n,n=null),n?s.emit("error",n):-1===l.indexOf(a)?s.emit("error",new Error("Wrong reason code for puback")):(a||s.emit("message",r,i,e),void s.handleMessage(e,(function(e){if(e)return t&&t(e);s._sendPacket({cmd:"puback",messageId:o,reasonCode:a},t)})))}));break;case 0:this.emit("message",r,i,e),this.handleMessage(e,t);break;default:_("_handlePublish: unknown QoS. Doing nothing.")}},A.prototype.handleMessage=function(e,t){t()},A.prototype._handleAck=function(e){const t=e.messageId,r=e.cmd;let i=null;const n=this.outgoing[t]?this.outgoing[t].cb:null,o=this;let s;if(n){switch(_("_handleAck :: packet type",r),r){case"pubcomp":case"puback":{const r=e.reasonCode;r&&r>0&&16!==r&&(s=new Error("Publish error: "+b[r]),s.code=r,n(s,e)),delete this.outgoing[t],this.outgoingStore.del(e,n),this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue();break}case"pubrec":{i={cmd:"pubrel",qos:2,messageId:t};const r=e.reasonCode;r&&r>0&&16!==r?(s=new Error("Publish error: "+b[r]),s.code=r,n(s,e)):this._sendPacket(i);break}case"suback":delete this.outgoing[t],this.messageIdProvider.deallocate(t);for(let r=0;r<e.granted.length;r++)if(0!=(128&e.granted[r])){const e=this.messageIdToTopic[t];e&&e.forEach((function(e){delete o._resubscribeTopics[e]}))}this._invokeStoreProcessingQueue(),n(null,e);break;case"unsuback":delete this.outgoing[t],this.messageIdProvider.deallocate(t),this._invokeStoreProcessingQueue(),n(null);break;default:o.emit("error",new Error("unrecognized packet type"))}this.disconnecting&&0===Object.keys(this.outgoing).length&&this.emit("outgoingEmpty")}else _("_handleAck :: Server sent an ack in error. Ignoring.")},A.prototype._handlePubrel=function(e,t){_("handling pubrel packet"),t=void 0!==t?t:C;const r=e.messageId,i=this,n={cmd:"pubcomp",messageId:r};i.incomingStore.get(e,(function(e,r){e?i._sendPacket(n,t):(i.emit("message",r.topic,r.payload,r),i.handleMessage(r,(function(e){if(e)return t(e);i.incomingStore.del(r,C),i._sendPacket(n,t)})))}))},A.prototype._handleDisconnect=function(e){this.emit("disconnect",e)},A.prototype._nextId=function(){return this.messageIdProvider.allocate()},A.prototype.getLastMessageId=function(){return this.messageIdProvider.getLastAllocated()},A.prototype._resubscribe=function(){_("_resubscribe");const e=Object.keys(this._resubscribeTopics);if(!this._firstConnection&&(this.options.clean||5===this.options.protocolVersion&&!this.connackPacket.sessionPresent)&&e.length>0)if(this.options.resubscribe)if(5===this.options.protocolVersion){_("_resubscribe: protocolVersion 5");for(let t=0;t<e.length;t++){const r={};r[e[t]]=this._resubscribeTopics[e[t]],r.resubscribe=!0,this.subscribe(r,{properties:r[e[t]].properties})}}else this._resubscribeTopics.resubscribe=!0,this.subscribe(this._resubscribeTopics);else this._resubscribeTopics={};this._firstConnection=!1},A.prototype._onConnect=function(e){if(this.disconnected)return void this.emit("connect",e);const t=this;this.connackPacket=e,this.messageIdProvider.clear(),this._setupPingTimer(),this.connected=!0,function r(){let i=t.outgoingStore.createStream();function n(){t._storeProcessing=!1,t._packetIdsDuringStoreProcessing={}}function o(){i.destroy(),i=null,t._flushStoreProcessingQueue(),n()}t.once("close",o),i.on("error",(function(e){n(),t._flushStoreProcessingQueue(),t.removeListener("close",o),t.emit("error",e)})),i.on("end",(function(){let i=!0;for(const e in t._packetIdsDuringStoreProcessing)if(!t._packetIdsDuringStoreProcessing[e]){i=!1;break}i?(n(),t.removeListener("close",o),t._invokeAllStoreProcessingQueue(),t.emit("connect",e)):r()})),function e(){if(!i)return;t._storeProcessing=!0;const r=i.read(1);let n;r?t._packetIdsDuringStoreProcessing[r.messageId]?e():t.disconnecting||t.reconnectTimer?i.destroy&&i.destroy():(n=t.outgoing[r.messageId]?t.outgoing[r.messageId].cb:null,t.outgoing[r.messageId]={volatile:!1,cb:function(t,r){n&&n(t,r),e()}},t._packetIdsDuringStoreProcessing[r.messageId]=!0,t.messageIdProvider.register(r.messageId)?t._sendPacket(r):_("messageId: %d has already used.",r.messageId)):i.once("readable",e)}()}()},A.prototype._invokeStoreProcessingQueue=function(){if(this._storeProcessingQueue.length>0){const e=this._storeProcessingQueue[0];if(e&&e.invoke())return this._storeProcessingQueue.shift(),!0}return!1},A.prototype._invokeAllStoreProcessingQueue=function(){for(;this._invokeStoreProcessingQueue(););},A.prototype._flushStoreProcessingQueue=function(){for(const e of this._storeProcessingQueue)e.cbStorePut&&e.cbStorePut(new Error("Connection closed")),e.callback&&e.callback(new Error("Connection closed"));this._storeProcessingQueue.splice(0)},t.exports=A}).call(this)}).call(this,e("_process"),void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./default-message-id-provider":7,"./store":8,"./topic-alias-recv":9,"./topic-alias-send":10,"./validations":11,_process:50,debug:18,events:22,inherits:24,"mqtt-packet":40,"readable-stream":69,reinterval:70,"rfdc/default":71,xtend:81}],2:[function(e,t,r){"use strict";const{Buffer:i}=e("buffer"),n=e("readable-stream").Transform,o=e("duplexify");let s,a,l,c=!1;t.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);const u=function(e,t){const r="alis"===e.protocol?"wss":"ws";let i=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(i=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(i=e.transformWsUrl(i,e,t)),i}(t,e);return s=t.my,s.connectSocket({url:u,protocols:r}),a=function(){const e=new n;return e._write=function(e,t,r){s.sendSocketMessage({data:e.buffer,success:function(){r()},fail:function(){r(new Error)}})},e._flush=function(e){s.closeSocket({success:function(){e()}})},e}(),l=o.obj(),c||(c=!0,s.onSocketOpen((function(){l.setReadable(a),l.setWritable(a),l.emit("connect")})),s.onSocketMessage((function(e){if("string"==typeof e.data){const t=i.from(e.data,"base64");a.push(t)}else{const t=new FileReader;t.addEventListener("load",(function(){let e=t.result;e=e instanceof ArrayBuffer?i.from(e):i.from(e,"utf8"),a.push(e)})),t.readAsArrayBuffer(e.data)}})),s.onSocketClose((function(){l.end(),l.destroy()})),s.onSocketError((function(e){l.destroy(e)}))),l}},{buffer:17,duplexify:20,"readable-stream":69}],3:[function(e,t,r){"use strict";const i=e("net"),n=e("debug")("mqttjs:tcp");t.exports=function(e,t){t.port=t.port||1883,t.hostname=t.hostname||t.host||"localhost";const r=t.port,o=t.hostname;return n("port %d and host %s",r,o),i.createConnection(r,o)}},{debug:18,net:16}],4:[function(e,t,r){"use strict";const i=e("tls"),n=e("net"),o=e("debug")("mqttjs:tls");t.exports=function(e,t){t.port=t.port||8883,t.host=t.hostname||t.host||"localhost",0===n.isIP(t.host)&&(t.servername=t.host),t.rejectUnauthorized=!1!==t.rejectUnauthorized,delete t.path,o("port %d host %s rejectUnauthorized %b",t.port,t.host,t.rejectUnauthorized);const r=i.connect(t);function s(i){t.rejectUnauthorized&&e.emit("error",i),r.end()}return r.on("secureConnect",(function(){t.rejectUnauthorized&&!r.authorized?r.emit("error",new Error("TLS not authorized")):r.removeListener("error",s)})),r.on("error",s),r}},{debug:18,net:16,tls:16}],5:[function(e,t,i){(function(i){(function(){"use strict";const{Buffer:n}=e("buffer"),o=e("ws"),s=e("debug")("mqttjs:ws"),a=e("duplexify"),l=e("readable-stream").Transform,c=["rejectUnauthorized","ca","cert","key","pfx","passphrase"],u=void 0!==i&&"browser"===i.title||"function"==typeof r;function h(e,t){let r=e.protocol+"://"+e.hostname+":"+e.port+e.path;return"function"==typeof e.transformWsUrl&&(r=e.transformWsUrl(r,e,t)),r}function p(e){const t=e;return e.hostname||(t.hostname="localhost"),e.port||("wss"===e.protocol?t.port=443:t.port=80),e.path||(t.path="/"),e.wsOptions||(t.wsOptions={}),u||"wss"!==e.protocol||c.forEach((function(r){Object.prototype.hasOwnProperty.call(e,r)&&!Object.prototype.hasOwnProperty.call(e.wsOptions,r)&&(t.wsOptions[r]=e[r])})),t}t.exports=u?function(e,t){let r;s("browserStreamBuilder");const i=function(e){const t=p(e);if(t.hostname||(t.hostname=t.host),!t.hostname){if("undefined"==typeof document)throw new Error("Could not determine host. Specify host manually.");const e=new URL(document.URL);t.hostname=e.hostname,t.port||(t.port=e.port)}return void 0===t.objectMode&&(t.objectMode=!(!0===t.binary||void 0===t.binary)),t}(t).browserBufferSize||524288,o=t.browserBufferTimeout||1e3,c=!t.objectMode,u=function(e,t){const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt",i=h(t,e),n=new WebSocket(i,[r]);return n.binaryType="arraybuffer",n}(e,t),d=function(e,t,r){const i=new l({objectModeMode:e.objectMode});return i._write=t,i._flush=r,i}(t,(function e(t,r,s){u.bufferedAmount>i&&setTimeout(e,o,t,r,s),c&&"string"==typeof t&&(t=n.from(t,"utf8"));try{u.send(t)}catch(e){return s(e)}s()}),(function(e){u.close(),e()}));t.objectMode||(d._writev=v),d.on("close",(()=>{u.close()}));const f=void 0!==u.addEventListener;function m(){r.setReadable(d),r.setWritable(d),r.emit("connect")}function _(){r.end(),r.destroy()}function g(e){r.destroy(e)}function y(e){let t=e.data;t=t instanceof ArrayBuffer?n.from(t):n.from(t,"utf8"),d.push(t)}function v(e,t){const r=new Array(e.length);for(let t=0;t<e.length;t++)"string"==typeof e[t].chunk?r[t]=n.from(e[t],"utf8"):r[t]=e[t].chunk;this._write(n.concat(r),"binary",t)}return u.readyState===u.OPEN?r=d:(r=r=a(void 0,void 0,t),t.objectMode||(r._writev=v),f?u.addEventListener("open",m):u.onopen=m),r.socket=u,f?(u.addEventListener("close",_),u.addEventListener("error",g),u.addEventListener("message",y)):(u.onclose=_,u.onerror=g,u.onmessage=y),r}:function(e,t){s("streamBuilder");const r=p(t),i=h(r,e),n=function(e,t,r){s("createWebSocket"),s("protocol: "+r.protocolId+" "+r.protocolVersion);const i="MQIsdp"===r.protocolId&&3===r.protocolVersion?"mqttv3.1":"mqtt";return s("creating new Websocket for url: "+t+" and protocol: "+i),new o(t,[i],r.wsOptions)}(0,i,r),a=o.createWebSocketStream(n,r.wsOptions);return a.url=i,n.on("close",(()=>{a.destroy()})),a}}).call(this)}).call(this,e("_process"))},{_process:50,buffer:17,debug:18,duplexify:20,"readable-stream":69,ws:80}],6:[function(e,t,r){"use strict";const{Buffer:i}=e("buffer"),n=e("readable-stream").Transform,o=e("duplexify");let s,a,l;t.exports=function(e,t){if(t.hostname=t.hostname||t.host,!t.hostname)throw new Error("Could not determine host. Specify host manually.");const r="MQIsdp"===t.protocolId&&3===t.protocolVersion?"mqttv3.1":"mqtt";!function(e){e.hostname||(e.hostname="localhost"),e.path||(e.path="/"),e.wsOptions||(e.wsOptions={})}(t);const c=function(e,t){const r="wxs"===e.protocol?"wss":"ws";let i=r+"://"+e.hostname+e.path;return e.port&&80!==e.port&&443!==e.port&&(i=r+"://"+e.hostname+":"+e.port+e.path),"function"==typeof e.transformWsUrl&&(i=e.transformWsUrl(i,e,t)),i}(t,e);s=wx.connectSocket({url:c,protocols:[r]}),a=function(){const e=new n;return e._write=function(e,t,r){s.send({data:e.buffer,success:function(){r()},fail:function(e){r(new Error(e))}})},e._flush=function(e){s.close({success:function(){e()}})},e}(),l=o.obj(),l._destroy=function(e,t){s.close({success:function(){t&&t(e)}})};const u=l.destroy;return l.destroy=function(){l.destroy=u;const e=this;setTimeout((function(){s.close({fail:function(){e._destroy(new Error)}})}),0)}.bind(l),s.onOpen((function(){l.setReadable(a),l.setWritable(a),l.emit("connect")})),s.onMessage((function(e){let t=e.data;t=t instanceof ArrayBuffer?i.from(t):i.from(t,"utf8"),a.push(t)})),s.onClose((function(){l.end(),l.destroy()})),s.onError((function(e){l.destroy(new Error(e.errMsg))})),l}},{buffer:17,duplexify:20,"readable-stream":69}],7:[function(e,t,r){"use strict";function i(){if(!(this instanceof i))return new i;this.nextId=Math.max(1,Math.floor(65535*Math.random()))}i.prototype.allocate=function(){const e=this.nextId++;return 65536===this.nextId&&(this.nextId=1),e},i.prototype.getLastAllocated=function(){return 1===this.nextId?65535:this.nextId-1},i.prototype.register=function(e){return!0},i.prototype.deallocate=function(e){},i.prototype.clear=function(){},t.exports=i},{}],8:[function(e,t,r){"use strict";const i=e("xtend"),n=e("readable-stream").Readable,o={objectMode:!0},s={clean:!0};function a(e){if(!(this instanceof a))return new a(e);this.options=e||{},this.options=i(s,e),this._inflights=new Map}a.prototype.put=function(e,t){return this._inflights.set(e.messageId,e),t&&t(),this},a.prototype.createStream=function(){const e=new n(o),t=[];let r=!1,i=0;return this._inflights.forEach((function(e,r){t.push(e)})),e._read=function(){!r&&i<t.length?this.push(t[i++]):this.push(null)},e.destroy=function(){if(r)return;const e=this;r=!0,setTimeout((function(){e.emit("close")}),0)},e},a.prototype.del=function(e,t){return(e=this._inflights.get(e.messageId))?(this._inflights.delete(e.messageId),t(null,e)):t&&t(new Error("missing packet")),this},a.prototype.get=function(e,t){return(e=this._inflights.get(e.messageId))?t(null,e):t&&t(new Error("missing packet")),this},a.prototype.close=function(e){this.options.clean&&(this._inflights=null),e&&e()},t.exports=a},{"readable-stream":69,xtend:81}],9:[function(e,t,r){"use strict";function i(e){if(!(this instanceof i))return new i(e);this.aliasToTopic={},this.max=e}i.prototype.put=function(e,t){return!(0===t||t>this.max||(this.aliasToTopic[t]=e,this.length=Object.keys(this.aliasToTopic).length,0))},i.prototype.getTopicByAlias=function(e){return this.aliasToTopic[e]},i.prototype.clear=function(){this.aliasToTopic={}},t.exports=i},{}],10:[function(e,t,r){"use strict";const i=e("lru-cache"),n=e("number-allocator").NumberAllocator;function o(e){if(!(this instanceof o))return new o(e);e>0&&(this.aliasToTopic=new i({max:e}),this.topicToAlias={},this.numberAllocator=new n(1,e),this.max=e,this.length=0)}o.prototype.put=function(e,t){if(0===t||t>this.max)return!1;const r=this.aliasToTopic.get(t);return r&&delete this.topicToAlias[r],this.aliasToTopic.set(t,e),this.topicToAlias[e]=t,this.numberAllocator.use(t),this.length=this.aliasToTopic.length,!0},o.prototype.getTopicByAlias=function(e){return this.aliasToTopic.get(e)},o.prototype.getAliasByTopic=function(e){const t=this.topicToAlias[e];return void 0!==t&&this.aliasToTopic.get(t),t},o.prototype.clear=function(){this.aliasToTopic.reset(),this.topicToAlias={},this.numberAllocator.clear(),this.length=0},o.prototype.getLruAlias=function(){return this.numberAllocator.firstVacant()||this.aliasToTopic.keys()[this.aliasToTopic.length-1]},t.exports=o},{"lru-cache":37,"number-allocator":46}],11:[function(e,t,r){"use strict";function i(e){const t=e.split("/");for(let e=0;e<t.length;e++)if("+"!==t[e]){if("#"===t[e])return e===t.length-1;if(-1!==t[e].indexOf("+")||-1!==t[e].indexOf("#"))return!1}return!0}t.exports={validateTopics:function(e){if(0===e.length)return"empty_topic_list";for(let t=0;t<e.length;t++)if(!i(e[t]))return e[t];return null}}},{}],12:[function(e,t,i){(function(i){(function(){"use strict";const n=e("../client"),o=e("../store"),s=e("url"),a=e("xtend"),l=e("debug")("mqttjs"),c={};function u(e,t){if(l("connecting to an MQTT broker..."),"object"!=typeof e||t||(t=e,e=null),t=t||{},e){const r=s.parse(e,!0);if(null!=r.port&&(r.port=Number(r.port)),null===(t=a(r,t)).protocol)throw new Error("Missing protocol");t.protocol=t.protocol.replace(/:$/,"")}if(function(e){let t;e.auth&&(t=e.auth.match(/^(.+):(.+)$/),t?(e.username=t[1],e.password=t[2]):e.username=e.auth)}(t),t.query&&"string"==typeof t.query.clientId&&(t.clientId=t.query.clientId),t.cert&&t.key){if(!t.protocol)throw new Error("Missing secure protocol key");if(-1===["mqtts","wss","wxs","alis"].indexOf(t.protocol))switch(t.protocol){case"mqtt":t.protocol="mqtts";break;case"ws":t.protocol="wss";break;case"wx":t.protocol="wxs";break;case"ali":t.protocol="alis";break;default:throw new Error('Unknown protocol for secure connection: "'+t.protocol+'"!')}}if(!c[t.protocol]){const e=-1!==["mqtts","wss"].indexOf(t.protocol);t.protocol=["mqtt","mqtts","ws","wss","wx","wxs","ali","alis"].filter((function(t,r){return(!e||r%2!=0)&&"function"==typeof c[t]}))[0]}if(!1===t.clean&&!t.clientId)throw new Error("Missing clientId for unclean clients");t.protocol&&(t.defaultProtocol=t.protocol);const r=new n((function(e){return t.servers&&(e._reconnectCount&&e._reconnectCount!==t.servers.length||(e._reconnectCount=0),t.host=t.servers[e._reconnectCount].host,t.port=t.servers[e._reconnectCount].port,t.protocol=t.servers[e._reconnectCount].protocol?t.servers[e._reconnectCount].protocol:t.defaultProtocol,t.hostname=t.host,e._reconnectCount++),l("calling streambuilder for",t.protocol),c[t.protocol](e,t)}),t);return r.on("error",(function(){})),r}void 0!==i&&"browser"!==i.title||"function"!=typeof r?(c.mqtt=e("./tcp"),c.tcp=e("./tcp"),c.ssl=e("./tls"),c.tls=e("./tls"),c.mqtts=e("./tls")):(c.wx=e("./wx"),c.wxs=e("./wx"),c.ali=e("./ali"),c.alis=e("./ali")),c.ws=e("./ws"),c.wss=e("./ws"),t.exports=u,t.exports.connect=u,t.exports.MqttClient=n,t.exports.Store=o}).call(this)}).call(this,e("_process"))},{"../client":1,"../store":8,"./ali":2,"./tcp":3,"./tls":4,"./ws":5,"./wx":6,_process:50,debug:18,url:76,xtend:81}],13:[function(e,t,r){"use strict";r.byteLength=function(e){var t=c(e),r=t[0],i=t[1];return 3*(r+i)/4-i},r.toByteArray=function(e){var t,r,i=c(e),s=i[0],a=i[1],l=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),u=0,h=a>0?s-4:s;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],l[u++]=t>>16&255,l[u++]=t>>8&255,l[u++]=255&t;return 2===a&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,l[u++]=255&t),1===a&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,l[u++]=t>>8&255,l[u++]=255&t),l},r.fromByteArray=function(e){for(var t,r=e.length,n=r%3,o=[],s=16383,a=0,l=r-n;a<l;a+=s)o.push(u(e,a,a+s>l?l:a+s));return 1===n?(t=e[r-1],o.push(i[t>>2]+i[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],o.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"=")),o.join("")};for(var i=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,l=s.length;a<l;++a)i[a]=s[a],n[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var n,o=[],s=t;s<r;s+=3)n=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(255&e[s+2]),o.push(i[(a=n)>>18&63]+i[a>>12&63]+i[a>>6&63]+i[63&a]);var a;return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},{}],14:[function(e,t,r){"use strict";const{Buffer:i}=e("buffer"),n=Symbol.for("BufferList");function o(e){if(!(this instanceof o))return new o(e);o._init.call(this,e)}o._init=function(e){Object.defineProperty(this,n,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)},o.prototype._new=function(e){return new o(e)},o.prototype._offset=function(e){if(0===e)return[0,0];let t=0;for(let r=0;r<this._bufs.length;r++){const i=t+this._bufs[r].length;if(e<i||r===this._bufs.length-1)return[r,e-t];t=i}},o.prototype._reverseOffset=function(e){const t=e[0];let r=e[1];for(let e=0;e<t;e++)r+=this._bufs[e].length;return r},o.prototype.get=function(e){if(e>this.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},o.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},o.prototype.copy=function(e,t,r,n){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof n||n>this.length)&&(n=this.length),r>=this.length)return e||i.alloc(0);if(n<=0)return e||i.alloc(0);const o=!!e,s=this._offset(r),a=n-r;let l=a,c=o&&t||0,u=s[1];if(0===r&&n===this.length){if(!o)return 1===this._bufs.length?this._bufs[0]:i.concat(this._bufs,this.length);for(let t=0;t<this._bufs.length;t++)this._bufs[t].copy(e,c),c+=this._bufs[t].length;return e}if(l<=this._bufs[s[0]].length-u)return o?this._bufs[s[0]].copy(e,t,u,u+l):this._bufs[s[0]].slice(u,u+l);o||(e=i.allocUnsafe(a));for(let t=s[0];t<this._bufs.length;t++){const r=this._bufs[t].length-u;if(!(l>r)){this._bufs[t].copy(e,c,u,u+l),c+=r;break}this._bufs[t].copy(e,c,u),c+=r,l-=r,u&&(u=0)}return e.length>c?e.slice(0,c):e},o.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const r=this._offset(e),i=this._offset(t),n=this._bufs.slice(r[0],i[0]+1);return 0===i[1]?n.pop():n[n.length-1]=n[n.length-1].slice(0,i[1]),0!==r[1]&&(n[0]=n[0].slice(r[1])),this._new(n)},o.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},o.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},o.prototype.duplicate=function(){const e=this._new();for(let t=0;t<this._bufs.length;t++)e.append(this._bufs[t]);return e},o.prototype.append=function(e){if(null==e)return this;if(e.buffer)this._appendBuffer(i.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let t=0;t<e.length;t++)this.append(e[t]);else if(this._isBufferList(e))for(let t=0;t<e._bufs.length;t++)this.append(e._bufs[t]);else"number"==typeof e&&(e=e.toString()),this._appendBuffer(i.from(e));return this},o.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length},o.prototype.indexOf=function(e,t,r){if(void 0===r&&"string"==typeof t&&(r=t,t=void 0),"function"==typeof e||Array.isArray(e))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if("number"==typeof e?e=i.from([e]):"string"==typeof e?e=i.from(e,r):this._isBufferList(e)?e=e.slice():Array.isArray(e.buffer)?e=i.from(e.buffer,e.byteOffset,e.byteLength):i.isBuffer(e)||(e=i.from(e)),t=Number(t||0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const n=this._offset(t);let o=n[0],s=n[1];for(;o<this._bufs.length;o++){const t=this._bufs[o];for(;s<t.length;)if(t.length-s>=e.length){const r=t.indexOf(e,s);if(-1!==r)return this._reverseOffset([o,r]);s=t.length-e.length+1}else{const t=this._reverseOffset([o,s]);if(this._match(t,e))return t;s++}s=0}return-1},o.prototype._match=function(e,t){if(this.length-e<t.length)return!1;for(let r=0;r<t.length;r++)if(this.get(e+r)!==t[r])return!1;return!0},function(){const e={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(const t in e)!function(t){o.prototype[t]=null===e[t]?function(e,r){return this.slice(e,e+r)[t](0,r)}:function(r=0){return this.slice(r,r+e[t])[t](0)}}(t)}(),o.prototype._isBufferList=function(e){return e instanceof o||o.isBufferList(e)},o.isBufferList=function(e){return null!=e&&e[n]},t.exports=o},{buffer:17}],15:[function(e,t,r){"use strict";const i=e("readable-stream").Duplex,n=e("inherits"),o=e("./BufferList");function s(e){if(!(this instanceof s))return new s(e);if("function"==typeof e){this._callback=e;const t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)})),e=null}o._init.call(this,e),i.call(this)}n(s,i),Object.assign(s.prototype,o.prototype),s.prototype._new=function(e){return new s(e)},s.prototype._write=function(e,t,r){this._appendBuffer(e),"function"==typeof r&&r()},s.prototype._read=function(e){if(!this.length)return this.push(null);e=Math.min(e,this.length),this.push(this.slice(0,e)),this.consume(e)},s.prototype.end=function(e){i.prototype.end.call(this,e),this._callback&&(this._callback(null,this.slice()),this._callback=null)},s.prototype._destroy=function(e,t){this._bufs.length=0,this.length=0,t(e)},s.prototype._isBufferList=function(e){return e instanceof s||e instanceof o||s.isBufferList(e)},s.isBufferList=o.isBufferList,t.exports=s,t.exports.BufferListStream=s,t.exports.BufferList=o},{"./BufferList":14,inherits:24,"readable-stream":69}],16:[function(e,t,r){},{}],17:[function(e,t,r){(function(t){(function(){"use strict";var t=e("base64-js"),i=e("ieee754");r.Buffer=s,r.SlowBuffer=function(e){return+e!=e&&(e=0),s.alloc(+e)},r.INSPECT_MAX_BYTES=50;var n=2147483647;function o(e){if(e>n)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=s.prototype,t}function s(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return c(e)}return a(e,t,r)}function a(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|p(e,t),i=o(r),n=i.write(e,t);return n!==r&&(i=i.slice(0,n)),i}(e,t);if(ArrayBuffer.isView(e))return u(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(N(e,ArrayBuffer)||e&&N(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;return(i=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r)).__proto__=s.prototype,i}(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return s.from(i,t,r);var n=function(e){if(s.isBuffer(e)){var t=0|h(e.length),r=o(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||j(e.length)?o(0):u(e):"Buffer"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return s.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function c(e){return l(e),o(e<0?0:0|h(e))}function u(e){for(var t=e.length<0?0:0|h(e.length),r=o(t),i=0;i<t;i+=1)r[i]=255&e[i];return r}function h(e){if(e>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|e}function p(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||N(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return R(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return O(e).length;default:if(n)return i?-1:R(e).length;t=(""+t).toLowerCase(),n=!0}}function d(e,t,r){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return k(this,t,r);case"utf8":case"utf-8":return E(this,t,r);case"ascii":return C(this,t,r);case"latin1":case"binary":return A(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function f(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function m(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),j(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=s.from(t,i)),s.isBuffer(t))return 0===t.length?-1:_(e,t,r,i,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):_(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function _(e,t,r,i,n){var o,s=1,a=e.length,l=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;s=2,a/=2,l/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(n){var u=-1;for(o=r;o<a;o++)if(c(e,o)===c(t,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===l)return u*s}else-1!==u&&(o-=o-u),u=-1}else for(r+l>a&&(r=a-l),o=r;o>=0;o--){for(var h=!0,p=0;p<l;p++)if(c(e,o+p)!==c(t,p)){h=!1;break}if(h)return o}return-1}function g(e,t,r,i){r=Number(r)||0;var n=e.length-r;i?(i=Number(i))>n&&(i=n):i=n;var o=t.length;i>o/2&&(i=o/2);for(var s=0;s<i;++s){var a=parseInt(t.substr(2*s,2),16);if(j(a))return s;e[r+s]=a}return s}function y(e,t,r,i){return F(R(t,e.length-r),e,r,i)}function v(e,t,r,i){return F(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,i)}function x(e,t,r,i){return v(e,t,r,i)}function b(e,t,r,i){return F(O(t),e,r,i)}function w(e,t,r,i){return F(function(e,t){for(var r,i,n,o=[],s=0;s<e.length&&!((t-=2)<0);++s)i=(r=e.charCodeAt(s))>>8,n=r%256,o.push(n),o.push(i);return o}(t,e.length-r),e,r,i)}function T(e,r,i){return 0===r&&i===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(r,i))}function E(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n<r;){var o,s,a,l,c=e[n],u=null,h=c>239?4:c>223?3:c>191?2:1;if(n+h<=r)switch(h){case 1:c<128&&(u=c);break;case 2:128==(192&(o=e[n+1]))&&(l=(31&c)<<6|63&o)>127&&(u=l);break;case 3:o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(l=(15&c)<<12|(63&o)<<6|63&s)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&l<1114112&&(u=l)}null===u?(u=65533,h=1):u>65535&&(u-=65536,i.push(u>>>10&1023|55296),u=56320|1023&u),i.push(u),n+=h}return function(e){var t=e.length;if(t<=S)return String.fromCharCode.apply(String,e);for(var r="",i=0;i<t;)r+=String.fromCharCode.apply(String,e.slice(i,i+=S));return r}(i)}r.kMaxLength=n,s.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),s.poolSize=8192,s.from=function(e,t,r){return a(e,t,r)},s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,s.alloc=function(e,t,r){return function(e,t,r){return l(e),e<=0?o(e):void 0!==t?"string"==typeof r?o(e).fill(t,r):o(e).fill(t):o(e)}(e,t,r)},s.allocUnsafe=function(e){return c(e)},s.allocUnsafeSlow=function(e){return c(e)},s.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==s.prototype},s.compare=function(e,t){if(N(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),N(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,i=t.length,n=0,o=Math.min(r,i);n<o;++n)if(e[n]!==t[n]){r=e[n],i=t[n];break}return r<i?-1:i<r?1:0},s.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return s.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var i=s.allocUnsafe(t),n=0;for(r=0;r<e.length;++r){var o=e[r];if(N(o,Uint8Array)&&(o=s.from(o)),!s.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,n),n+=o.length}return i},s.byteLength=p,s.prototype._isBuffer=!0,s.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)f(this,t,t+1);return this},s.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)f(this,t,t+3),f(this,t+1,t+2);return this},s.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)f(this,t,t+7),f(this,t+1,t+6),f(this,t+2,t+5),f(this,t+3,t+4);return this},s.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?E(this,0,e):d.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===s.compare(this,e)},s.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},s.prototype.compare=function(e,t,r,i,n){if(N(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=r)return 0;if(i>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(n>>>=0)-(i>>>=0),a=(r>>>=0)-(t>>>=0),l=Math.min(o,a),c=this.slice(i,n),u=e.slice(t,r),h=0;h<l;++h)if(c[h]!==u[h]){o=c[h],a=u[h];break}return o<a?-1:a<o?1:0},s.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},s.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},s.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)},s.prototype.write=function(e,t,r,i){if(void 0===t)i="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)i=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return g(this,e,t,r);case"utf8":case"utf-8":return y(this,e,t,r);case"ascii":return v(this,e,t,r);case"latin1":case"binary":return x(this,e,t,r);case"base64":return b(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function C(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(127&e[n]);return i}function A(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;++n)i+=String.fromCharCode(e[n]);return i}function k(e,t,r){var i,n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var o="",s=t;s<r;++s)o+=(i=e[s])<16?"0"+i.toString(16):i.toString(16);return o}function I(e,t,r){for(var i=e.slice(t,r),n="",o=0;o<i.length;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function M(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function z(e,t,r,i,n,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||t<o)throw new RangeError('"value" argument is out of bounds');if(r+i>e.length)throw new RangeError("Index out of range")}function P(e,t,r,i,n,o){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(e,t,r,n,o){return t=+t,r>>>=0,o||P(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function L(e,t,r,n,o){return t=+t,r>>>=0,o||P(e,0,r,8),i.write(e,t,r,n,52,8),r+8}s.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var i=this.subarray(e,t);return i.__proto__=s.prototype,i},s.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i},s.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},s.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var i=this[e],n=1,o=0;++o<t&&(n*=256);)i+=this[e+o]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*t)),i},s.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var i=t,n=1,o=this[e+--i];i>0&&(n*=256);)o+=this[e+--i]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*t)),o},s.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),i.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),i.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),i.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),i.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,r,i){e=+e,t>>>=0,r>>>=0,i||z(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[t]=255&e;++o<r&&(n*=256);)this[t+o]=e/n&255;return t+r},s.prototype.writeUIntBE=function(e,t,r,i){e=+e,t>>>=0,r>>>=0,i||z(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[t+n]=255&e;--n>=0&&(o*=256);)this[t+n]=e/o&255;return t+r},s.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||z(this,e,t,1,255,0),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||z(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||z(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||z(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},s.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||z(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);z(this,e,t,r,n-1,-n)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},s.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);z(this,e,t,r,n-1,-n)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},s.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||z(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||z(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||z(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},s.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||z(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||z(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},s.prototype.writeFloatLE=function(e,t,r){return D(this,e,t,!0,r)},s.prototype.writeFloatBE=function(e,t,r){return D(this,e,t,!1,r)},s.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,!0,r)},s.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,!1,r)},s.prototype.copy=function(e,t,r,i){if(!s.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);var n=i-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,i);else if(this===e&&r<t&&t<i)for(var o=n-1;o>=0;--o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,i),t);return n},s.prototype.fill=function(e,t,r,i){if("string"==typeof e){if("string"==typeof t?(i=t,t=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===e.length){var n=e.charCodeAt(0);("utf8"===i&&n<128||"latin1"===i)&&(e=n)}}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var a=s.isBuffer(e)?e:s.from(e,i),l=a.length;if(0===l)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=a[o%l]}return this};var B=/[^+/0-9A-Za-z-_]/g;function R(e,t){var r;t=t||1/0;for(var i=e.length,n=null,o=[],s=0;s<i;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(t-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&o.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function O(e){return t.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,i){for(var n=0;n<i&&!(n+r>=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function N(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function j(e){return e!=e}}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":13,buffer:17,ieee754:23}],18:[function(e,t,r){(function(i){(function(){r.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let i=0,n=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(i++,"%c"===e&&(n=i))})),e.splice(n,0,r)},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){let e;try{e=r.storage.getItem("debug")}catch(e){}return!e&&void 0!==i&&"env"in i&&(e=i.env.DEBUG),e},r.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},r.storage=function(){try{return localStorage}catch(e){}}(),r.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(r);const{formatters:n}=t.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":19,_process:50}],19:[function(e,t,r){t.exports=function(t){function r(e){let t,n,o,s=null;function a(...e){if(!a.enabled)return;const i=a,n=Number(new Date),o=n-(t||n);i.diff=o,i.prev=t,i.curr=n,t=n,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,n)=>{if("%%"===t)return"%";s++;const o=r.formatters[n];if("function"==typeof o){const r=e[s];t=o.call(i,r),e.splice(s,1),s--}return t})),r.formatArgs.call(i,e),(i.log||r.log).apply(i,e)}return a.namespace=e,a.useColors=r.useColors(),a.color=r.selectColor(e),a.extend=i,a.destroy=r.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(n!==r.namespaces&&(n=r.namespaces,o=r.enabled(e)),o),set:e=>{s=e}}),"function"==typeof r.init&&r.init(a),a}function i(e,t){const i=r(this.namespace+(void 0===t?":":t)+e);return i.log=this.log,i}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){const e=[...r.names.map(n),...r.skips.map(n).map((e=>"-"+e))].join(",");return r.enable(""),e},r.enable=function(e){let t;r.save(e),r.namespaces=e,r.names=[],r.skips=[];const i=("string"==typeof e?e:"").split(/[\s,]+/),n=i.length;for(t=0;t<n;t++)i[t]&&("-"===(e=i[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.slice(1)+"$")):r.names.push(new RegExp("^"+e+"$")))},r.enabled=function(e){if("*"===e[e.length-1])return!0;let t,i;for(t=0,i=r.skips.length;t<i;t++)if(r.skips[t].test(e))return!1;for(t=0,i=r.names.length;t<i;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=e("ms"),r.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach((e=>{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return r.colors[Math.abs(t)%r.colors.length]},r.enable(r.load()),r}},{ms:45}],20:[function(e,t,r){(function(r,i){(function(){var n=e("readable-stream"),o=e("end-of-stream"),s=e("inherits"),a=e("stream-shift"),l=i.from&&i.from!==Uint8Array.from?i.from([0]):new i([0]),c=function(e,t){e._corked?e.once("uncork",t):t()},u=function(e,t){return function(r){r?function(e,t){e._autoDestroy&&e.destroy(t)}(e,"premature close"===r.message?null:r):t&&!e._ended&&e.end()}},h=function(){},p=function(e,t,r){if(!(this instanceof p))return new p(e,t,r);n.Duplex.call(this,r),this._writable=null,this._readable=null,this._readable2=null,this._autoDestroy=!r||!1!==r.autoDestroy,this._forwardDestroy=!r||!1!==r.destroy,this._forwardEnd=!r||!1!==r.end,this._corked=1,this._ondrain=null,this._drained=!1,this._forwarding=!1,this._unwrite=null,this._unread=null,this._ended=!1,this.destroyed=!1,e&&this.setWritable(e),t&&this.setReadable(t)};s(p,n.Duplex),p.obj=function(e,t,r){return r||(r={}),r.objectMode=!0,r.highWaterMark=16,new p(e,t,r)},p.prototype.cork=function(){1==++this._corked&&this.emit("cork")},p.prototype.uncork=function(){this._corked&&0==--this._corked&&this.emit("uncork")},p.prototype.setWritable=function(e){if(this._unwrite&&this._unwrite(),this.destroyed)e&&e.destroy&&e.destroy();else if(null!==e&&!1!==e){var t=this,i=o(e,{writable:!0,readable:!1},u(this,this._forwardEnd)),n=function(){var e=t._ondrain;t._ondrain=null,e&&e()};this._unwrite&&r.nextTick(n),this._writable=e,this._writable.on("drain",n),this._unwrite=function(){t._writable.removeListener("drain",n),i()},this.uncork()}else this.end()},p.prototype.setReadable=function(e){if(this._unread&&this._unread(),this.destroyed)e&&e.destroy&&e.destroy();else{if(null===e||!1===e)return this.push(null),void this.resume();var t=this,r=o(e,{writable:!1,readable:!0},u(this)),i=function(){t._forward()},s=function(){t.push(null)};this._drained=!0,this._readable=e,this._readable2=e._readableState?e:(a=e,new n.Readable({objectMode:!0,highWaterMark:16}).wrap(a)),this._readable2.on("readable",i),this._readable2.on("end",s),this._unread=function(){t._readable2.removeListener("readable",i),t._readable2.removeListener("end",s),r()},this._forward()}var a},p.prototype._read=function(){this._drained=!0,this._forward()},p.prototype._forward=function(){if(!this._forwarding&&this._readable2&&this._drained){var e;for(this._forwarding=!0;this._drained&&null!==(e=a(this._readable2));)this.destroyed||(this._drained=this.push(e));this._forwarding=!1}},p.prototype.destroy=function(e,t){if(t||(t=h),this.destroyed)return t(null);this.destroyed=!0;var i=this;r.nextTick((function(){i._destroy(e),t(null)}))},p.prototype._destroy=function(e){if(e){var t=this._ondrain;this._ondrain=null,t?t(e):this.emit("error",e)}this._forwardDestroy&&(this._readable&&this._readable.destroy&&this._readable.destroy(),this._writable&&this._writable.destroy&&this._writable.destroy()),this.emit("close")},p.prototype._write=function(e,t,r){if(!this.destroyed)return this._corked?c(this,this._write.bind(this,e,t,r)):e===l?this._finish(r):this._writable?void(!1===this._writable.write(e)?this._ondrain=r:this.destroyed||r()):r()},p.prototype._finish=function(e){var t=this;this.emit("preend"),c(this,(function(){var r,i;r=t._forwardEnd&&t._writable,i=function(){!1===t._writableState.prefinished&&(t._writableState.prefinished=!0),t.emit("prefinish"),c(t,e)},r?r._writableState&&r._writableState.finished?i():r._writableState?r.end(i):(r.end(),i()):i()}))},p.prototype.end=function(e,t,r){return"function"==typeof e?this.end(null,null,e):"function"==typeof t?this.end(e,null,t):(this._ended=!0,e&&this.write(e),this._writableState.ending||this._writableState.destroyed||this.write(l),n.Writable.prototype.end.call(this,r))},t.exports=p}).call(this)}).call(this,e("_process"),e("buffer").Buffer)},{_process:50,buffer:17,"end-of-stream":21,inherits:24,"readable-stream":69,"stream-shift":74}],21:[function(e,t,r){(function(r){(function(){var i=e("once"),n=function(){},o=function(e,t,s){if("function"==typeof t)return o(e,null,t);t||(t={}),s=i(s||n);var a=e._writableState,l=e._readableState,c=t.readable||!1!==t.readable&&e.readable,u=t.writable||!1!==t.writable&&e.writable,h=!1,p=function(){e.writable||d()},d=function(){u=!1,c||s.call(e)},f=function(){c=!1,u||s.call(e)},m=function(t){s.call(e,t?new Error("exited with error code: "+t):null)},_=function(t){s.call(e,t)},g=function(){r.nextTick(y)},y=function(){if(!h)return(!c||l&&l.ended&&!l.destroyed)&&(!u||a&&a.ended&&!a.destroyed)?void 0:s.call(e,new Error("premature close"))},v=function(){e.req.on("finish",d)};return function(e){return e.setHeader&&"function"==typeof e.abort}(e)?(e.on("complete",d),e.on("abort",g),e.req?v():e.on("request",v)):u&&!a&&(e.on("end",p),e.on("close",p)),function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length}(e)&&e.on("exit",m),e.on("end",f),e.on("finish",d),!1!==t.error&&e.on("error",_),e.on("close",g),function(){h=!0,e.removeListener("complete",d),e.removeListener("abort",g),e.removeListener("request",v),e.req&&e.req.removeListener("finish",d),e.removeListener("end",p),e.removeListener("close",p),e.removeListener("finish",d),e.removeListener("exit",m),e.removeListener("end",f),e.removeListener("error",_),e.removeListener("close",g)}};t.exports=o}).call(this)}).call(this,e("_process"))},{_process:50,once:48}],22:[function(e,t,r){var i=Object.create||function(e){var t=function(){};return t.prototype=e,new t},n=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return r},o=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=i(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}t.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,l=10;try{var c={};Object.defineProperty&&Object.defineProperty(c,"x",{value:0}),a=0===c.x}catch(e){a=!1}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function h(e,t,r){if(t)e.call(r);else for(var i=e.length,n=b(e,i),o=0;o<i;++o)n[o].call(r)}function p(e,t,r,i){if(t)e.call(r,i);else for(var n=e.length,o=b(e,n),s=0;s<n;++s)o[s].call(r,i)}function d(e,t,r,i,n){if(t)e.call(r,i,n);else for(var o=e.length,s=b(e,o),a=0;a<o;++a)s[a].call(r,i,n)}function f(e,t,r,i,n,o){if(t)e.call(r,i,n,o);else for(var s=e.length,a=b(e,s),l=0;l<s;++l)a[l].call(r,i,n,o)}function m(e,t,r,i){if(t)e.apply(r,i);else for(var n=e.length,o=b(e,n),s=0;s<n;++s)o[s].apply(r,i)}function _(e,t,r,n){var o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),a=s[t]):(s=e._events=i(null),e._eventsCount=0),a){if("function"==typeof a?a=s[t]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),!a.warned&&(o=u(e))&&o>0&&a.length>o){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(t)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",l.name,l.message)}}else a=s[t]=r,++e._eventsCount;return e}function g(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=new Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e)}}function y(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=o.call(g,i);return n.listener=r,i.wrapFn=n,n}function v(e,t,r){var i=e._events;if(!i)return[];var n=i[t];return n?"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(n):b(n,n.length):[]}function x(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function b(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return l},set:function(e){if("number"!=typeof e||e<0||e!=e)throw new TypeError('"defaultMaxListeners" must be a positive number');l=e}}):s.defaultMaxListeners=l,s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){var t,r,i,n,o,s,a="error"===e;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(t=arguments[1]),t instanceof Error)throw t;var l=new Error('Unhandled "error" event. ('+t+")");throw l.context=t,l}if(!(r=s[e]))return!1;var c="function"==typeof r;switch(i=arguments.length){case 1:h(r,c,this);break;case 2:p(r,c,this,arguments[1]);break;case 3:d(r,c,this,arguments[1],arguments[2]);break;case 4:f(r,c,this,arguments[1],arguments[2],arguments[3]);break;default:for(n=new Array(i-1),o=1;o<i;o++)n[o-1]=arguments[o];m(r,c,this,n)}return!0},s.prototype.addListener=function(e,t){return _(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return _(this,e,t,!0)},s.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,y(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,y(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,n,o,s,a;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=i(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){a=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(e,t){for(var r=t,i=r+1,n=e.length;i<n;r+=1,i+=1)e[r]=e[i];e.pop()}(r,o),1===r.length&&(n[e]=r[0]),n.removeListener&&this.emit("removeListener",e,a||t)}return this},s.prototype.removeAllListeners=function(e){var t,r,o;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=i(null),this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=i(null):delete r[e]),this;if(0===arguments.length){var s,a=n(r);for(o=0;o<a.length;++o)"removeListener"!==(s=a[o])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=i(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)for(o=t.length-1;o>=0;o--)this.removeListener(e,t[o]);return this},s.prototype.listeners=function(e){return v(this,e,!0)},s.prototype.rawListeners=function(e){return v(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):x.call(e,t)},s.prototype.listenerCount=x,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],23:[function(e,t,r){r.read=function(e,t,r,i,n){var o,s,a=8*n-i-1,l=(1<<a)-1,c=l>>1,u=-7,h=r?n-1:0,p=r?-1:1,d=e[t+h];for(h+=p,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+e[t+h],h+=p,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=i;u>0;s=256*s+e[t+h],h+=p,u-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,i),o-=c}return(d?-1:1)*s*Math.pow(2,o-i)},r.write=function(e,t,r,i,n,o){var s,a,l,c=8*o-n-1,u=(1<<c)-1,h=u>>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:o-1,f=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=u):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(t*l-1)*Math.pow(2,n),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;e[r+d]=255&a,d+=f,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;e[r+d]=255&s,d+=f,s/=256,c-=8);e[r+d-f]|=128*m}},{}],24:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},{}],25:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=function(){function e(e,t){this.color=!0,this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0,this.leftChild=void 0,this.rightChild=void 0,this.key=e,this.value=t}return e.prototype.rotateLeft=function(){var e=this.parent,t=this.brother,r=this.leftChild,i=this.rightChild;if(!i)throw new Error("unknown error");var n=i.leftChild,o=i.rightChild;return e&&(e.leftChild===this?e.leftChild=i:e.rightChild===this&&(e.rightChild=i)),i.parent=e,i.brother=t,i.leftChild=this,i.rightChild=o,t&&(t.brother=i),this.parent=i,this.brother=o,this.leftChild=r,this.rightChild=n,o&&(o.parent=i,o.brother=this),r&&(r.parent=this,r.brother=n),n&&(n.parent=this,n.brother=r),i},e.prototype.rotateRight=function(){var e=this.parent,t=this.brother,r=this.leftChild;if(!r)throw new Error("unknown error");var i=this.rightChild,n=r.leftChild,o=r.rightChild;return e&&(e.leftChild===this?e.leftChild=r:e.rightChild===this&&(e.rightChild=r)),r.parent=e,r.brother=t,r.leftChild=n,r.rightChild=this,t&&(t.brother=r),n&&(n.parent=r,n.brother=this),this.parent=r,this.brother=n,this.leftChild=o,this.rightChild=i,o&&(o.parent=this,o.brother=i),i&&(i.parent=this,i.brother=o),r},e.prototype.remove=function(){if(this.leftChild||this.rightChild)throw new Error("can only remove leaf node");this.parent&&(this===this.parent.leftChild?this.parent.leftChild=void 0:this===this.parent.rightChild&&(this.parent.rightChild=void 0)),this.brother&&(this.brother.brother=void 0),this.key=void 0,this.value=void 0,this.parent=void 0,this.brother=void 0},e.TreeNodeColorType={red:!0,black:!1},e}();Object.freeze(i),r.default=i},{}],26:[function(e,t,r){"use strict";var i=this&&this.__generator||function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};function n(e){var t=this;void 0===e&&(e=[]);var r=[],o=0,s=0,a=0,l=0,c=0,u=0;this.size=function(){return u},this.empty=function(){return 0===u},this.clear=function(){o=a=s=l=c=u=0,p.call(this,n.bucketSize),u=0},this.front=function(){return r[o][s]},this.back=function(){return r[a][l]},this.forEach=function(e){if(!this.empty()){var t=0;if(o!==a){for(c=s;c<n.bucketSize;++c)e(r[o][c],t++);for(c=o+1;c<a;++c)for(var i=0;i<n.bucketSize;++i)e(r[c][i],t++);for(c=0;c<=l;++c)e(r[a][c],t++)}else for(var c=s;c<=l;++c)e(r[o][c],t++)}};var h=function(e){var t=o*n.bucketSize+s,r=t+e,i=a*n.bucketSize+l;if(r<t||r>i)throw new Error("pos should more than 0 and less than queue's size");return{curNodeBucketIndex:Math.floor(r/n.bucketSize),curNodePointerIndex:r%n.bucketSize}};this.getElementByPos=function(e){var t=h(e),i=t.curNodeBucketIndex,n=t.curNodePointerIndex;return r[i][n]},this.eraseElementByPos=function(e){var t=this;if(e<0||e>u)throw new Error("pos should more than 0 and less than queue's size");if(0===e)this.popFront();else if(e===this.size())this.popBack();else{for(var r=[],i=e+1;i<u;++i)r.push(this.getElementByPos(i));this.cut(e),this.popBack(),r.forEach((function(e){return t.pushBack(e)}))}},this.eraseElementByValue=function(e){if(!this.empty()){var t=[];this.forEach((function(r){r!==e&&t.push(r)}));for(var r=t.length,i=0;i<r;++i)this.setElementByPos(i,t[i]);this.cut(r-1)}};var p=function(e){for(var t=[],i=e*n.sigma,h=Math.max(Math.ceil(i/n.bucketSize),2),p=0;p<h;++p)t.push(new Array(n.bucketSize));var d=Math.ceil(e/n.bucketSize),f=Math.floor(h/2)-Math.floor(d/2),m=f,_=0;if(this.size())for(p=0;p<d;++p){for(var g=0;g<n.bucketSize;++g)if(t[f+p][g]=this.front(),this.popFront(),this.empty()){m=f+p,_=g;break}if(this.empty())break}r=t,o=f,s=0,a=m,l=_,c=h,u=e};this.pushBack=function(e){this.empty()||(a===c-1&&l===n.bucketSize-1&&p.call(this,this.size()),l<n.bucketSize-1?++l:a<c-1&&(++a,l=0)),++u,r[a][l]=e},this.popBack=function(){this.empty()||(1!==this.size()&&(l>0?--l:o<a&&(--a,l=n.bucketSize-1)),u>0&&--u)},this.setElementByPos=function(e,t){var i=h(e),n=i.curNodeBucketIndex,o=i.curNodePointerIndex;r[n][o]=t},this.insert=function(e,t,r){var i=this;if(void 0===r&&(r=1),0===e)for(;r--;)this.pushFront(t);else if(e===this.size())for(;r--;)this.pushBack(t);else{for(var n=[],o=e;o<u;++o)n.push(this.getElementByPos(o));for(this.cut(e-1),o=0;o<r;++o)this.pushBack(t);n.forEach((function(e){return i.pushBack(e)}))}},this.find=function(e){if(o===a){for(var t=s;t<=l;++t)if(r[o][t]===e)return!0;return!1}for(t=s;t<n.bucketSize;++t)if(r[o][t]===e)return!0;for(t=o+1;t<a;++t)for(var i=0;i<n.bucketSize;++i)if(r[t][i]===e)return!0;for(t=0;t<=l;++t)if(r[a][t]===e)return!0;return!1},this.reverse=function(){for(var e=0,t=u-1;e<t;){var r=this.getElementByPos(e);this.setElementByPos(e,this.getElementByPos(t)),this.setElementByPos(t,r),++e,--t}},this.unique=function(){if(!this.empty()){var e=[],t=this.front();this.forEach((function(r,i){0!==i&&r===t||(e.push(r),t=r)}));for(var r=0;r<u;++r)this.setElementByPos(r,e[r]);this.cut(e.length-1)}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);for(var r=0;r<u;++r)this.setElementByPos(r,t[r])},this.pushFront=function(e){this.empty()||(0===o&&0===s&&p.call(this,this.size()),s>0?--s:o>0&&(--o,s=n.bucketSize-1)),++u,r[o][s]=e},this.popFront=function(){this.empty()||(1!==this.size()&&(s<n.bucketSize-1?++s:o<a&&(++o,s=0)),u>0&&--u)},this.shrinkToFit=function(){var e=this,t=[];this.forEach((function(e){t.push(e)}));var i=t.length;r=[];for(var o=Math.ceil(i/n.bucketSize),s=0;s<o;++s)r.push(new Array(n.bucketSize));this.clear(),t.forEach((function(t){return e.pushBack(t)}))},this.cut=function(e){if(e<0)this.clear();else{var t=h(e),r=t.curNodeBucketIndex,i=t.curNodePointerIndex;a=r,l=i,u=e+1}},this[Symbol.iterator]=function(){return function(){var e,t;return i(this,(function(i){switch(i.label){case 0:if(0===u)return[2];if(o!==a)return[3,5];t=s,i.label=1;case 1:return t<=l?[4,r[o][t]]:[3,4];case 2:i.sent(),i.label=3;case 3:return++t,[3,1];case 4:return[2];case 5:t=s,i.label=6;case 6:return t<n.bucketSize?[4,r[o][t]]:[3,9];case 7:i.sent(),i.label=8;case 8:return++t,[3,6];case 9:t=o+1,i.label=10;case 10:if(!(t<a))return[3,15];e=0,i.label=11;case 11:return e<n.bucketSize?[4,r[t][e]]:[3,14];case 12:i.sent(),i.label=13;case 13:return++e,[3,11];case 14:return++t,[3,10];case 15:t=0,i.label=16;case 16:return t<=l?[4,r[a][t]]:[3,19];case 17:i.sent(),i.label=18;case 18:return++t,[3,16];case 19:return[2]}}))}()},function(){var i=n.bucketSize;e.size?i=e.size():e.length&&(i=e.length);var s=i*n.sigma;c=Math.ceil(s/n.bucketSize),c=Math.max(c,3);for(var l=0;l<c;++l)r.push(new Array(n.bucketSize));var u=Math.ceil(i/n.bucketSize);o=Math.floor(c/2)-Math.floor(u/2),a=o,e.forEach((function(e){return t.pushBack(e)}))}(),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),n.sigma=3,n.bucketSize=5e3,Object.freeze(n),r.default=n},{}],27:[function(e,t,r){"use strict";var i=this&&this.__generator||function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var o=e("../LinkList/LinkList"),s=e("../Map/Map");function a(e,t,r){var l=this;if(void 0===e&&(e=[]),void 0===t&&(t=a.initSize),r=r||function(e){var t,r,i=0,o="";if("number"==typeof e)i=((i=Math.floor(e))<<5)-i,i&=i;else{o="string"!=typeof e?JSON.stringify(e):e;try{for(var s=n(o),a=s.next();!a.done;a=s.next())i=(i<<5)-i+a.value.charCodeAt(0),i&=i}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}}return i^i>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var c=0,u=[],h=Math.max(a.initSize,Math.min(a.maxSize,t));this.size=function(){return c},this.empty=function(){return 0===c},this.clear=function(){c=0,h=t,u=[]},this.forEach=function(e){var t=0;u.forEach((function(r){r.forEach((function(r){e(r,t++)}))}))};var p=function(e){if(!(e>=a.maxSize)){h=2*e;var t=[];u.forEach((function(i,n){if(!i.empty()){if(i instanceof o.default&&1===i.size()){var l=i.front(),c=l.key,p=l.value;t[r(c)&h-1]=new o.default([{key:c,value:p}])}else if(i instanceof s.default){var d=new o.default,f=new o.default;i.forEach((function(t){0==(r(t.key)&e)?d.pushBack(t):f.pushBack(t)})),d.size()>a.untreeifyThreshold?t[n]=new s.default(d):d.size()&&(t[n]=d),f.size()>a.untreeifyThreshold?t[n+e]=new s.default(f):f.size()&&(t[n+e]=f)}else{var m=new o.default,_=new o.default;i.forEach((function(t){0==(r(t.key)&e)?m.pushBack(t):_.pushBack(t)})),m.size()&&(t[n]=m),_.size()&&(t[n+e]=_)}u[n].clear()}})),u=t}};this.setElement=function(e,t){var i,l;if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=t){var d=r(e)&h-1;if(u[d]){var f=u[d].size();if(u[d]instanceof o.default){try{for(var m=n(u[d]),_=m.next();!_.done;_=m.next()){var g=_.value;if(g.key===e)return void(g.value=t)}}catch(e){i={error:e}}finally{try{_&&!_.done&&(l=m.return)&&l.call(m)}finally{if(i)throw i.error}}u[d].pushBack({key:e,value:t}),u[d].size()>=a.treeifyThreshold&&(u[d]=new s.default(u[d]))}else u[d].setElement(e,t);var y=u[d].size();c+=y-f}else++c,u[d]=new o.default([{key:e,value:t}]);c>h*a.sigma&&p.call(this,h)}else this.eraseElementByKey(e)},this.getElementByKey=function(e){var t,i,o=r(e)&h-1;if(u[o]){if(u[o]instanceof s.default)return u[o].getElementByKey(e);try{for(var a=n(u[o]),l=a.next();!l.done;l=a.next()){var c=l.value;if(c.key===e)return c.value}}catch(e){t={error:e}}finally{try{l&&!l.done&&(i=a.return)&&i.call(a)}finally{if(t)throw t.error}}}},this.eraseElementByKey=function(e){var t,i,l=r(e)&h-1;if(u[l]){var p=u[l].size();if(u[l]instanceof s.default)u[l].eraseElementByKey(e),u[l].size()<=a.untreeifyThreshold&&(u[l]=new o.default(u[l]));else{var d=-1;try{for(var f=n(u[l]),m=f.next();!m.done;m=f.next()){var _=m.value;if(++d,_.key===e){u[l].eraseElementByPos(d);break}}}catch(e){t={error:e}}finally{try{m&&!m.done&&(i=f.return)&&i.call(f)}finally{if(t)throw t.error}}}var g=u[l].size();c+=g-p}},this.find=function(e){var t,i,o=r(e)&h-1;if(!u[o])return!1;if(u[o]instanceof s.default)return u[o].find(e);try{for(var a=n(u[o]),l=a.next();!l.done;l=a.next())if(l.value.key===e)return!0}catch(e){t={error:e}}finally{try{l&&!l.done&&(i=a.return)&&i.call(a)}finally{if(t)throw t.error}}return!1},this[Symbol.iterator]=function(){return function(){var e,t,r,o,s,a;return i(this,(function(i){switch(i.label){case 0:e=0,i.label=1;case 1:if(!(e<h))return[3,10];for(;e<h&&!u[e];)++e;if(e>=h)return[3,10];i.label=2;case 2:i.trys.push([2,7,8,9]),s=void 0,t=n(u[e]),r=t.next(),i.label=3;case 3:return r.done?[3,6]:[4,r.value];case 4:i.sent(),i.label=5;case 5:return r=t.next(),[3,3];case 6:return[3,9];case 7:return o=i.sent(),s={error:o},[3,9];case 8:try{r&&!r.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){var t=e.key,r=e.value;return l.setElement(t,r)})),Object.freeze(this)}a.initSize=16,a.maxSize=1<<30,a.sigma=.75,a.treeifyThreshold=8,a.untreeifyThreshold=6,a.minTreeifySize=64,Object.freeze(a),r.default=a},{"../LinkList/LinkList":29,"../Map/Map":30}],28:[function(e,t,r){"use strict";var i=this&&this.__generator||function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var o=e("../Set/Set"),s=e("../LinkList/LinkList");function a(e,t,r){var l=this;if(void 0===e&&(e=[]),void 0===t&&(t=a.initSize),r=r||function(e){var t=0,r="";if("number"==typeof e)t=((t=Math.floor(e))<<5)-t,t&=t;else{r="string"!=typeof e?JSON.stringify(e):e;for(var i=0;i<r.length;i++)t=(t<<5)-t+r.charCodeAt(i),t&=t}return t^t>>>16},0!=(t&t-1))throw new Error("initBucketNum must be 2 to the power of n");var c=0,u=[],h=Math.max(a.initSize,Math.min(a.maxSize,t));this.size=function(){return c},this.empty=function(){return 0===c},this.clear=function(){c=0,h=t,u=[]},this.forEach=function(e){var t=0;u.forEach((function(r){r.forEach((function(r){e(r,t++)}))}))};var p=function(e){if(!(e>=a.maxSize)){h=2*e;var t=[];u.forEach((function(i,n){if(!i.empty()){if(i instanceof s.default&&1===i.size()){var l=i.front();if(void 0===l)throw new Error("unknown error");t[r(l)&h-1]=new s.default([l])}else if(i instanceof o.default){var c=new s.default,p=new s.default;i.forEach((function(t){0==(r(t)&e)?c.pushBack(t):p.pushBack(t)})),c.size()>a.untreeifyThreshold?t[n]=new o.default(c):c.size()&&(t[n]=c),p.size()>a.untreeifyThreshold?t[n+e]=new o.default(p):p.size()&&(t[n+e]=p)}else{var d=new s.default,f=new s.default;i.forEach((function(t){0==(r(t)&e)?d.pushBack(t):f.pushBack(t)})),d.size()&&(t[n]=d),f.size()&&(t[n+e]=f)}u[n].clear()}})),u=t}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");var t=r(e)&h-1;if(u[t]){var i=u[t].size();if(u[t]instanceof s.default){if(u[t].find(e))return;u[t].pushBack(e),u[t].size()>=a.treeifyThreshold&&(u[t]=new o.default(u[t]))}else u[t].insert(e);var n=u[t].size();c+=n-i}else u[t]=new s.default([e]),++c;c>h*a.sigma&&p.call(this,h)},this.eraseElementByValue=function(e){var t=r(e)&h-1;if(u[t]){var i=u[t].size();u[t].eraseElementByValue(e),u[t]instanceof o.default&&u[t].size()<=a.untreeifyThreshold&&(u[t]=new s.default(u[t]));var n=u[t].size();c+=n-i}},this.find=function(e){var t=r(e)&h-1;return!!u[t]&&u[t].find(e)},this[Symbol.iterator]=function(){return function(){var e,t,r,o,s,a;return i(this,(function(i){switch(i.label){case 0:e=0,i.label=1;case 1:if(!(e<h))return[3,10];for(;e<h&&!u[e];)++e;if(e>=h)return[3,10];i.label=2;case 2:i.trys.push([2,7,8,9]),s=void 0,t=n(u[e]),r=t.next(),i.label=3;case 3:return r.done?[3,6]:[4,r.value];case 4:i.sent(),i.label=5;case 5:return r=t.next(),[3,3];case 6:return[3,9];case 7:return o=i.sent(),s={error:o},[3,9];case 8:try{r&&!r.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return++e,[3,1];case 10:return[2]}}))}()},e.forEach((function(e){return l.insert(e)})),Object.freeze(this)}a.initSize=16,a.maxSize=1<<30,a.sigma=.75,a.treeifyThreshold=8,a.untreeifyThreshold=6,a.minTreeifySize=64,Object.freeze(a),r.default=a},{"../LinkList/LinkList":29,"../Set/Set":33}],29:[function(e,t,r){"use strict";var i=this&&this.__generator||function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(r,"__esModule",{value:!0});var n=function(e){this.value=void 0,this.pre=void 0,this.next=void 0,this.value=e};function o(e){var t=this;void 0===e&&(e=[]);var r=0,o=void 0,s=void 0;this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){o=s=void 0,r=0},this.front=function(){return null==o?void 0:o.value},this.back=function(){return null==s?void 0:s.value},this.forEach=function(e){for(var t=o,r=0;t;){if(void 0===t.value)throw new Error("unknown error");e(t.value,r++),t=t.next}},this.getElementByPos=function(e){if(e<0||e>=r)throw new Error("pos must more then 0 and less then the list length");for(var t=o;e--&&t;)t=t.next;if(!t||void 0===t.value)throw new Error("unknown error");return t.value},this.eraseElementByPos=function(e){if(e<0||e>=r)throw new Error("erase pos must more then 0 and less then the list length");if(0===e)this.popFront();else if(e===r-1)this.popBack();else{for(var t=o;e--;){if(!(null==t?void 0:t.next))throw new Error("unknown error");t=t.next}if(!t||!t.pre||!t.next)throw new Error("unknown error");var i=t.pre,n=t.next;n.pre=i,i.next=n,r>0&&--r}},this.eraseElementByValue=function(e){for(;o&&o.value===e;)this.popFront();for(;s&&s.value===e;)this.popBack();if(o)for(var t=o;t;){if(t.value===e){var i=t.pre,n=t.next;n&&(n.pre=i),i&&(i.next=n),r>0&&--r}t=t.next}},this.pushBack=function(e){if(null==e)throw new Error("you can't push null or undefined here");++r;var t=new n(e);s?(s.next=t,t.pre=s,s=t):o=s=t},this.popBack=function(){s&&(r>0&&--r,s&&(o===s?o=s=void 0:(s=s.pre)&&(s.next=void 0)))},this.setElementByPos=function(e,t){if(null==t)throw new Error("you can't set null or undefined here");if(e<0||e>=r)throw new Error("pos must more then 0 and less then the list length");for(var i=o;e--;){if(!i)throw new Error("unknown error");i=i.next}i&&(i.value=t)},this.insert=function(e,t,i){if(void 0===i&&(i=1),null==t)throw new Error("you can't insert null or undefined here");if(e<0||e>r)throw new Error("insert pos must more then 0 and less then or equal to the list length");if(i<0)throw new Error("insert size must more than 0");if(0===e)for(;i--;)this.pushFront(t);else if(e===r)for(;i--;)this.pushBack(t);else{for(var s=o,a=1;a<e;++a){if(!(null==s?void 0:s.next))throw new Error("unknown error");s=null==s?void 0:s.next}if(!s)throw new Error("unknown error");var l=s.next;for(r+=i;i--;)s.next=new n(t),s.next.pre=s,s=s.next;s.next=l,l&&(l.pre=s)}},this.find=function(e){for(var t=o;t;){if(t.value===e)return!0;t=t.next}return!1},this.reverse=function(){for(var e=o,t=s,i=0;e&&t&&2*i<r;){var n=e.value;e.value=t.value,t.value=n,e=e.next,t=t.pre,++i}},this.unique=function(){for(var e=o;e;){for(var t=e;t&&t.next&&t.value===t.next.value;)t=t.next,r>0&&--r;e.next=t.next,e.next&&(e.next.pre=e),e=e.next}},this.sort=function(e){var t=[];this.forEach((function(e){t.push(e)})),t.sort(e);var r=o;t.forEach((function(e){r&&(r.value=e,r=r.next)}))},this.pushFront=function(e){if(null==e)throw new Error("you can't push null or undefined here");++r;var t=new n(e);o?(t.next=o,o.pre=t,o=t):o=s=t},this.popFront=function(){o&&(r>0&&--r,o&&(o===s?o=s=void 0:(o=o.next)&&(o.pre=void 0)))},this.merge=function(e){var t=this,i=o;e.forEach((function(e){for(;i&&void 0!==i.value&&i.value<=e;)i=i.next;if(void 0===i)t.pushBack(e),i=s;else if(i===o)t.pushFront(e),i=o;else{++r;var a=i.pre;a&&(a.next=new n(e),a.next.pre=a,a.next.next=i,i&&(i.pre=a.next))}}))},this[Symbol.iterator]=function(){return function(){var e;return i(this,(function(t){switch(t.label){case 0:e=o,t.label=1;case 1:if(void 0===e)return[3,3];if(!e.value)throw new Error("unknown error");return[4,e.value];case 2:return t.sent(),e=e.next,[3,1];case 3:return[2]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.freeze(o),r.default=o},{}],30:[function(e,t,r){"use strict";var i=this&&this.__generator||function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var o=e("../Base/TreeNode");function s(e,t){var r=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var s=0,a=new o.default;a.color=o.default.TreeNodeColorType.black,this.size=function(){return s},this.empty=function(){return 0===s},this.clear=function(){s=0,a.key=a.value=void 0,a.leftChild=a.rightChild=a.brother=void 0};var l=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?l(e.leftChild):e},c=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?c(e.rightChild):e};this.front=function(){if(!this.empty()){var e=l(a);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.back=function(){if(!this.empty()){var e=c(a);if(void 0===e.key||void 0===e.value)throw new Error("unknown error");return{key:e.key,value:e.value}}},this.forEach=function(e){var t,r,i=0;try{for(var o=n(this),s=o.next();!s.done;s=o.next())e(s.value,i++)}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,r;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var i=0;try{for(var o=n(this),s=o.next();!s.done;s=o.next()){var a=s.value;if(i===e)return a;++i}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}throw new Error("unknown Error")};var u=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value){var i=t(e.key,r);return 0===i?{key:e.key,value:e.value}:i<0?u(e.rightChild,r):u(e.leftChild,r)||{key:e.key,value:e.value}}};this.lowerBound=function(e){return u(a,e)};var h=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,r)<=0?h(e.rightChild,r):h(e.leftChild,r)||{key:e.key,value:e.value}};this.upperBound=function(e){return h(a,e)};var p=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value){var i=t(e.key,r);return 0===i?{key:e.key,value:e.value}:i>0?p(e.leftChild,r):p(e.rightChild,r)||{key:e.key,value:e.value}}};this.reverseLowerBound=function(e){return p(a,e)};var d=function(e,r){if(e&&void 0!==e.key&&void 0!==e.value)return t(e.key,r)>=0?d(e.leftChild,r):d(e.rightChild,r)||{key:e.key,value:e.value}};this.reverseUpperBound=function(e){return d(a,e)};var f=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(e.color!==o.default.TreeNodeColorType.red){var r=e.brother;if(!r)throw new Error("unknown error");if(e===t.leftChild)if(r.color===o.default.TreeNodeColorType.red){r.color=o.default.TreeNodeColorType.black,t.color=o.default.TreeNodeColorType.red;var i=t.rotateLeft();a===t&&(a=i),f(e)}else r.color===o.default.TreeNodeColorType.black&&(r.rightChild&&r.rightChild.color===o.default.TreeNodeColorType.red?(r.color=t.color,t.color=o.default.TreeNodeColorType.black,r.rightChild&&(r.rightChild.color=o.default.TreeNodeColorType.black),i=t.rotateLeft(),a===t&&(a=i),e.color=o.default.TreeNodeColorType.black):r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||!r.leftChild||r.leftChild.color!==o.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||(r.color=o.default.TreeNodeColorType.red,f(t)):(r.color=o.default.TreeNodeColorType.red,r.leftChild&&(r.leftChild.color=o.default.TreeNodeColorType.black),i=r.rotateRight(),a===r&&(a=i),f(e)));else e===t.rightChild&&(r.color===o.default.TreeNodeColorType.red?(r.color=o.default.TreeNodeColorType.black,t.color=o.default.TreeNodeColorType.red,i=t.rotateRight(),a===t&&(a=i),f(e)):r.color===o.default.TreeNodeColorType.black&&(r.leftChild&&r.leftChild.color===o.default.TreeNodeColorType.red?(r.color=t.color,t.color=o.default.TreeNodeColorType.black,r.leftChild&&(r.leftChild.color=o.default.TreeNodeColorType.black),i=t.rotateRight(),a===t&&(a=i),e.color=o.default.TreeNodeColorType.black):r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||!r.rightChild||r.rightChild.color!==o.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||(r.color=o.default.TreeNodeColorType.red,f(t)):(r.color=o.default.TreeNodeColorType.red,r.rightChild&&(r.rightChild.color=o.default.TreeNodeColorType.black),i=r.rotateLeft(),a===r&&(a=i),f(e))))}else e.color=o.default.TreeNodeColorType.black},m=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=l(t.rightChild);var r=e.key;e.key=t.key,t.key=r;var i=e.value;e.value=t.value,t.value=i,e=t}t.leftChild&&(t=c(t.leftChild),r=e.key,e.key=t.key,t.key=r,i=e.value,e.value=t.value,t.value=i,e=t)}f(t),t&&t.remove(),--s,a.color=o.default.TreeNodeColorType.black},_=function(e,t){return!(!e||void 0===e.key)&&(!!_(e.leftChild,t)||!!t(e)||_(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=s)throw new Error("pos must more than 0 and less than set's size");var t=0;_(a,(function(r){return e===t?(m(r),!0):(++t,!1)}))},this.eraseElementByKey=function(e){if(!this.empty()){var r=v(a,e);void 0!==r&&void 0!==r.key&&0===t(r.key,e)&&m(r)}};var g=function(e,r){if(!e||void 0===e.key)throw new Error("unknown error");var i=t(r,e.key);return i<0?e.leftChild?g(e.leftChild,r):(e.leftChild=new o.default,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):i>0?e.rightChild?g(e.rightChild,r):(e.rightChild=new o.default,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},y=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(t.color!==o.default.TreeNodeColorType.black&&t.color===o.default.TreeNodeColorType.red){var r=t.brother,i=t.parent;if(!i)throw new Error("unknown error");if(r&&r.color===o.default.TreeNodeColorType.red)r.color=t.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red,y(i);else if(!r||r.color===o.default.TreeNodeColorType.black)if(t===i.leftChild)if(e===t.leftChild){t.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red;var n=i.rotateRight();i===a&&(a=n)}else e===t.rightChild&&(n=t.rotateLeft(),i===a&&(a=n),y(t));else t===i.rightChild&&(e===t.leftChild?(n=t.rotateRight(),i===a&&(a=n),y(t)):e===t.rightChild&&(t.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red,n=i.rotateLeft(),i===a&&(a=n)))}};this.setElement=function(e,r){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(null!=r){if(this.empty())return++s,a.key=e,a.value=r,void(a.color=o.default.TreeNodeColorType.black);var i=g(a,e);void 0===i.key||0!==t(i.key,e)?(++s,i.key=e,i.value=r,y(i),a.color=o.default.TreeNodeColorType.black):i.value=r}else this.eraseElementByKey(e)};var v=function(e,r){if(e&&void 0!==e.key){var i=t(r,e.key);return i<0?v(e.leftChild,r):i>0?v(e.rightChild,r):e}};this.find=function(e){return!!v(a,e)},this.getElementByKey=function(e){var t=v(a,e);if(void 0===(null==t?void 0:t.key)||void 0===(null==t?void 0:t.value))throw new Error("unknown error");return t.value},this.union=function(e){var t=this;e.forEach((function(e){var r=e.key,i=e.value;return t.setElement(r,i)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(a)};var x=function(e){return i(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key&&void 0!==e.value?[5,n(x(e.leftChild))]:[2];case 1:return t.sent(),[4,{key:e.key,value:e.value}];case 2:return t.sent(),[5,n(x(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return x(a)},e.forEach((function(e){var t=e.key,i=e.value;return r.setElement(t,i)})),Object.freeze(this)}Object.freeze(s),r.default=s},{"../Base/TreeNode":25}],31:[function(e,t,r){"use strict";function i(e,t){void 0===e&&(e=[]),t=t||function(e,t){return e>t?-1:e<t?1:0};var r=[];e.forEach((function(e){return r.push(e)}));var i=r.length,n=function(e,t){if(e<0||e>=i)throw new Error("unknown error");if(t<0||t>=i)throw new Error("unknown error");var n=r[e];r[e]=r[t],r[t]=n},o=function(e){if(e<0||e>=i)throw new Error("unknown error");var o=2*e+1,s=2*e+2;o<i&&t(r[e],r[o])>0&&n(e,o),s<i&&t(r[e],r[s])>0&&n(e,s)};!function(){for(var e=Math.floor((i-1)/2);e>=0;--e)for(var o=e,s=2*o+1;s<i;){var a=s+1,l=s;if(a<i&&t(r[s],r[a])>0&&(l=a),t(r[o],r[l])<=0)break;n(o,l),s=2*(o=l)+1}}(),this.size=function(){return i},this.empty=function(){return 0===i},this.clear=function(){i=0,r.length=0},this.push=function(e){if(r.push(e),1!=++i)for(var n=i-1;n>0;){var s=Math.floor((n-1)/2);if(t(r[s],e)<=0)break;o(s),n=s}},this.pop=function(){if(!this.empty())if(1!==this.size()){var e=r[i-1];--i;for(var n=0;n<this.size();){var o=2*n+1,s=2*n+2;if(o>=this.size())break;var a=o;if(s<this.size()&&t(r[o],r[s])>0&&(a=s),t(r[a],e)>=0)break;r[n]=r[a],n=a}r[n]=e}else--i},this.top=function(){return r[0]},Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(i),r.default=i},{}],32:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../LinkList/LinkList");function n(e){void 0===e&&(e=[]);var t=new i.default(e);this.size=function(){return t.size()},this.empty=function(){return t.empty()},this.clear=function(){t.clear()},this.push=function(e){t.pushBack(e)},this.pop=function(){t.popFront()},this.front=function(){return t.front()},Object.freeze(this)}Object.freeze(n),r.default=n},{"../LinkList/LinkList":29}],33:[function(e,t,r){"use strict";var i=this&&this.__generator||function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(r,"__esModule",{value:!0});var o=e("../Base/TreeNode");function s(e,t){var r=this;void 0===e&&(e=[]),t=t||function(e,t){return e<t?-1:e>t?1:0};var s=0,a=new o.default;a.color=o.default.TreeNodeColorType.black,this.size=function(){return s},this.empty=function(){return 0===s},this.clear=function(){s=0,a.key=void 0,a.leftChild=a.rightChild=a.brother=a.parent=void 0,a.color=o.default.TreeNodeColorType.black};var l=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.leftChild?l(e.leftChild):e},c=function(e){if(!e||void 0===e.key)throw new Error("unknown error");return e.rightChild?c(e.rightChild):e};this.front=function(){if(!this.empty())return l(a).key},this.back=function(){if(!this.empty())return c(a).key},this.forEach=function(e){var t,r,i=0;try{for(var o=n(this),s=o.next();!s.done;s=o.next())e(s.value,i++)}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}},this.getElementByPos=function(e){var t,r;if(e<0||e>=this.size())throw new Error("pos must more than 0 and less than set's size");var i=0;try{for(var o=n(this),s=o.next();!s.done;s=o.next()){var a=s.value;if(i===e)return a;++i}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}throw new Error("unknown error")};var u=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(e.color!==o.default.TreeNodeColorType.red){var r=e.brother;if(!r)throw new Error("unknown error");if(e===t.leftChild)if(r.color===o.default.TreeNodeColorType.red){r.color=o.default.TreeNodeColorType.black,t.color=o.default.TreeNodeColorType.red;var i=t.rotateLeft();a===t&&(a=i),u(e)}else r.color===o.default.TreeNodeColorType.black&&(r.rightChild&&r.rightChild.color===o.default.TreeNodeColorType.red?(r.color=t.color,t.color=o.default.TreeNodeColorType.black,r.rightChild&&(r.rightChild.color=o.default.TreeNodeColorType.black),i=t.rotateLeft(),a===t&&(a=i),e.color=o.default.TreeNodeColorType.black):r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||!r.leftChild||r.leftChild.color!==o.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||(r.color=o.default.TreeNodeColorType.red,u(t)):(r.color=o.default.TreeNodeColorType.red,r.leftChild&&(r.leftChild.color=o.default.TreeNodeColorType.black),i=r.rotateRight(),a===r&&(a=i),u(e)));else e===t.rightChild&&(r.color===o.default.TreeNodeColorType.red?(r.color=o.default.TreeNodeColorType.black,t.color=o.default.TreeNodeColorType.red,i=t.rotateRight(),a===t&&(a=i),u(e)):r.color===o.default.TreeNodeColorType.black&&(r.leftChild&&r.leftChild.color===o.default.TreeNodeColorType.red?(r.color=t.color,t.color=o.default.TreeNodeColorType.black,r.leftChild&&(r.leftChild.color=o.default.TreeNodeColorType.black),i=t.rotateRight(),a===t&&(a=i),e.color=o.default.TreeNodeColorType.black):r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||!r.rightChild||r.rightChild.color!==o.default.TreeNodeColorType.red?r.leftChild&&r.leftChild.color!==o.default.TreeNodeColorType.black||r.rightChild&&r.rightChild.color!==o.default.TreeNodeColorType.black||(r.color=o.default.TreeNodeColorType.red,u(t)):(r.color=o.default.TreeNodeColorType.red,r.rightChild&&(r.rightChild.color=o.default.TreeNodeColorType.black),i=r.rotateLeft(),a===r&&(a=i),u(e))))}else e.color=o.default.TreeNodeColorType.black},h=function(e){for(var t=e;t.leftChild||t.rightChild;){if(t.rightChild){t=l(t.rightChild);var r=e.key;e.key=t.key,t.key=r,e=t}t.leftChild&&(t=c(t.leftChild),r=e.key,e.key=t.key,t.key=r,e=t)}u(t),t&&t.remove(),--s,a.color=o.default.TreeNodeColorType.black},p=function(e,t){return!(!e||void 0===e.key)&&(!!p(e.leftChild,t)||!!t(e)||p(e.rightChild,t))};this.eraseElementByPos=function(e){if(e<0||e>=s)throw new Error("pos must more than 0 and less than set's size");var t=0;p(a,(function(r){return e===t?(h(r),!0):(++t,!1)}))},this.eraseElementByValue=function(e){if(!this.empty()){var r=m(a,e);void 0!==r&&void 0!==r.key&&0===t(r.key,e)&&h(r)}};var d=function(e,r){if(!e||void 0===e.key)throw new Error("unknown error");var i=t(r,e.key);return i<0?e.leftChild?d(e.leftChild,r):(e.leftChild=new o.default,e.leftChild.parent=e,e.leftChild.brother=e.rightChild,e.rightChild&&(e.rightChild.brother=e.leftChild),e.leftChild):i>0?e.rightChild?d(e.rightChild,r):(e.rightChild=new o.default,e.rightChild.parent=e,e.rightChild.brother=e.leftChild,e.leftChild&&(e.leftChild.brother=e.rightChild),e.rightChild):e},f=function(e){var t=e.parent;if(!t){if(e===a)return;throw new Error("unknown error")}if(t.color!==o.default.TreeNodeColorType.black&&t.color===o.default.TreeNodeColorType.red){var r=t.brother,i=t.parent;if(!i)throw new Error("unknown error");if(r&&r.color===o.default.TreeNodeColorType.red)r.color=t.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red,f(i);else if(!r||r.color===o.default.TreeNodeColorType.black)if(t===i.leftChild)if(e===t.leftChild){t.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red;var n=i.rotateRight();i===a&&(a=n)}else e===t.rightChild&&(n=t.rotateLeft(),i===a&&(a=n),f(t));else t===i.rightChild&&(e===t.leftChild?(n=t.rotateRight(),i===a&&(a=n),f(t)):e===t.rightChild&&(t.color=o.default.TreeNodeColorType.black,i.color=o.default.TreeNodeColorType.red,n=i.rotateLeft(),i===a&&(a=n)))}};this.insert=function(e){if(null==e)throw new Error("to avoid some unnecessary errors, we don't suggest you insert null or undefined here");if(this.empty())return++s,a.key=e,void(a.color=o.default.TreeNodeColorType.black);var r=d(a,e);void 0!==r.key&&0===t(r.key,e)||(++s,r.key=e,f(r),a.color=o.default.TreeNodeColorType.black)};var m=function(e,r){if(e&&void 0!==e.key){var i=t(r,e.key);return i<0?m(e.leftChild,r):i>0?m(e.rightChild,r):e}};this.find=function(e){var r=m(a,e);return void 0!==r&&void 0!==r.key&&0===t(r.key,e)};var _=function(e,r){if(e&&void 0!==e.key){var i=t(e.key,r);if(0===i)return e.key;if(i<0)return _(e.rightChild,r);var n=_(e.leftChild,r);return void 0!==n?n:e.key}};this.lowerBound=function(e){return _(a,e)};var g=function(e,r){if(e&&void 0!==e.key){if(t(e.key,r)<=0)return g(e.rightChild,r);var i=g(e.leftChild,r);return void 0!==i?i:e.key}};this.upperBound=function(e){return g(a,e)};var y=function(e,r){if(e&&void 0!==e.key){var i=t(e.key,r);if(0===i)return e.key;if(i>0)return y(e.leftChild,r);var n=y(e.rightChild,r);return void 0!==n?n:e.key}};this.reverseLowerBound=function(e){return y(a,e)};var v=function(e,r){if(e&&void 0!==e.key){if(t(e.key,r)>=0)return v(e.leftChild,r);var i=v(e.rightChild,r);return void 0!==i?i:e.key}};this.reverseUpperBound=function(e){return v(a,e)},this.union=function(e){var t=this;e.forEach((function(e){return t.insert(e)}))},this.getHeight=function(){if(this.empty())return 0;var e=function(t){return t?Math.max(e(t.leftChild),e(t.rightChild))+1:1};return e(a)};var x=function(e){return i(this,(function(t){switch(t.label){case 0:return e&&void 0!==e.key?[5,n(x(e.leftChild))]:[2];case 1:return t.sent(),[4,e.key];case 2:return t.sent(),[5,n(x(e.rightChild))];case 3:return t.sent(),[2]}}))};this[Symbol.iterator]=function(){return x(a)},e.forEach((function(e){return r.insert(e)})),Object.freeze(this)}Object.freeze(s),r.default=s},{"../Base/TreeNode":25}],34:[function(e,t,r){"use strict";function i(e){var t=this;void 0===e&&(e=[]);var r=0,i=[];this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){r=0,i.length=0},this.push=function(e){i.push(e),++r},this.pop=function(){i.pop(),r>0&&--r},this.top=function(){return i[r-1]},e.forEach((function(e){return t.push(e)})),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(i),r.default=i},{}],35:[function(e,t,r){"use strict";var i=this&&this.__generator||function(e,t){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&o[0]?i.return:o[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,o[1])).done)return n;switch(i=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((n=(n=s.trys).length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var i,n=0,o=t.length;n<o;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function a(e){var t=this;void 0===e&&(e=[]);var r=0,a=[];this.size=function(){return r},this.empty=function(){return 0===r},this.clear=function(){r=0,a.length=0},this.front=function(){if(!this.empty())return a[0]},this.back=function(){if(!this.empty())return a[r-1]},this.forEach=function(e){a.forEach(e)},this.getElementByPos=function(e){if(e<0||e>=r)throw new Error("pos must more than 0 and less than vector's size");return a[e]},this.eraseElementByPos=function(e){if(e<0||e>=r)throw new Error("pos must more than 0 and less than vector's size");for(var t=e;t<r-1;++t)a[t]=a[t+1];this.popBack()},this.eraseElementByValue=function(e){var t=[];this.forEach((function(r){r!==e&&t.push(r)})),t.forEach((function(e,t){a[t]=e}));for(var i=t.length;r>i;)this.popBack()},this.pushBack=function(e){a.push(e),++r},this.popBack=function(){a.pop(),r>0&&--r},this.setElementByPos=function(e,t){if(e<0||e>=r)throw new Error("pos must more than 0 and less than vector's size");a[e]=t},this.insert=function(e,t,i){if(void 0===i&&(i=1),e<0||e>r)throw new Error("pos must more than 0 and less than or equal to vector's size");a.splice.apply(a,o([e,0],n(new Array(i).fill(t)),!1)),r+=i},this.find=function(e){return a.includes(e)},this.reverse=function(){a.reverse()},this.unique=function(){var e,t=[];this.forEach((function(r,i){0!==i&&r===e||(t.push(r),e=r)})),t.forEach((function(e,t){a[t]=e}));for(var i=t.length;r>i;)this.popBack()},this.sort=function(e){a.sort(e)},this[Symbol.iterator]=function(){return function(){return i(this,(function(e){switch(e.label){case 0:return[5,s(a)];case 1:return[2,e.sent()]}}))}()},e.forEach((function(e){return t.pushBack(e)})),Object.freeze(this)}Object.defineProperty(r,"__esModule",{value:!0}),Object.freeze(a),r.default=a},{}],36:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.HashMap=r.HashSet=r.Map=r.Set=r.PriorityQueue=r.Deque=r.LinkList=r.Queue=r.Stack=r.Vector=void 0;var i=e("./Vector/Vector");r.Vector=i.default;var n=e("./Stack/Stack");r.Stack=n.default;var o=e("./Queue/Queue");r.Queue=o.default;var s=e("./LinkList/LinkList");r.LinkList=s.default;var a=e("./Deque/Deque");r.Deque=a.default;var l=e("./PriorityQueue/PriorityQueue");r.PriorityQueue=l.default;var c=e("./Set/Set");r.Set=c.default;var u=e("./Map/Map");r.Map=u.default;var h=e("./HashSet/HashSet");r.HashSet=h.default;var p=e("./HashMap/HashMap");r.HashMap=p.default},{"./Deque/Deque":26,"./HashMap/HashMap":27,"./HashSet/HashSet":28,"./LinkList/LinkList":29,"./Map/Map":30,"./PriorityQueue/PriorityQueue":31,"./Queue/Queue":32,"./Set/Set":33,"./Stack/Stack":34,"./Vector/Vector":35}],37:[function(e,t,r){"use strict";const i=e("yallist"),n=Symbol("max"),o=Symbol("length"),s=Symbol("lengthCalculator"),a=Symbol("allowStale"),l=Symbol("maxAge"),c=Symbol("dispose"),u=Symbol("noDisposeOnSet"),h=Symbol("lruList"),p=Symbol("cache"),d=Symbol("updateAgeOnGet"),f=()=>1;const m=(e,t,r)=>{const i=e[p].get(t);if(i){const t=i.value;if(_(e,t)){if(y(e,i),!e[a])return}else r&&(e[d]&&(i.value.now=Date.now()),e[h].unshiftNode(i));return t.value}},_=(e,t)=>{if(!t||!t.maxAge&&!e[l])return!1;const r=Date.now()-t.now;return t.maxAge?r>t.maxAge:e[l]&&r>e[l]},g=e=>{if(e[o]>e[n])for(let t=e[h].tail;e[o]>e[n]&&null!==t;){const r=t.prev;y(e,t),t=r}},y=(e,t)=>{if(t){const r=t.value;e[c]&&e[c](r.key,r.value),e[o]-=r.length,e[p].delete(r.key),e[h].removeNode(t)}};class v{constructor(e,t,r,i,n){this.key=e,this.value=t,this.length=r,this.now=i,this.maxAge=n||0}}const x=(e,t,r,i)=>{let n=r.value;_(e,n)&&(y(e,r),e[a]||(n=void 0)),n&&t.call(i,n.value,n.key,e)};t.exports=class{constructor(e){if("number"==typeof e&&(e={max:e}),e||(e={}),e.max&&("number"!=typeof e.max||e.max<0))throw new TypeError("max must be a non-negative number");this[n]=e.max||1/0;const t=e.length||f;if(this[s]="function"!=typeof t?f:t,this[a]=e.stale||!1,e.maxAge&&"number"!=typeof e.maxAge)throw new TypeError("maxAge must be a number");this[l]=e.maxAge||0,this[c]=e.dispose,this[u]=e.noDisposeOnSet||!1,this[d]=e.updateAgeOnGet||!1,this.reset()}set max(e){if("number"!=typeof e||e<0)throw new TypeError("max must be a non-negative number");this[n]=e||1/0,g(this)}get max(){return this[n]}set allowStale(e){this[a]=!!e}get allowStale(){return this[a]}set maxAge(e){if("number"!=typeof e)throw new TypeError("maxAge must be a non-negative number");this[l]=e,g(this)}get maxAge(){return this[l]}set lengthCalculator(e){"function"!=typeof e&&(e=f),e!==this[s]&&(this[s]=e,this[o]=0,this[h].forEach((e=>{e.length=this[s](e.value,e.key),this[o]+=e.length}))),g(this)}get lengthCalculator(){return this[s]}get length(){return this[o]}get itemCount(){return this[h].length}rforEach(e,t){t=t||this;for(let r=this[h].tail;null!==r;){const i=r.prev;x(this,e,r,t),r=i}}forEach(e,t){t=t||this;for(let r=this[h].head;null!==r;){const i=r.next;x(this,e,r,t),r=i}}keys(){return this[h].toArray().map((e=>e.key))}values(){return this[h].toArray().map((e=>e.value))}reset(){this[c]&&this[h]&&this[h].length&&this[h].forEach((e=>this[c](e.key,e.value))),this[p]=new Map,this[h]=new i,this[o]=0}dump(){return this[h].map((e=>!_(this,e)&&{k:e.key,v:e.value,e:e.now+(e.maxAge||0)})).toArray().filter((e=>e))}dumpLru(){return this[h]}set(e,t,r){if((r=r||this[l])&&"number"!=typeof r)throw new TypeError("maxAge must be a number");const i=r?Date.now():0,a=this[s](t,e);if(this[p].has(e)){if(a>this[n])return y(this,this[p].get(e)),!1;const s=this[p].get(e).value;return this[c]&&(this[u]||this[c](e,s.value)),s.now=i,s.maxAge=r,s.value=t,this[o]+=a-s.length,s.length=a,this.get(e),g(this),!0}const d=new v(e,t,a,i,r);return d.length>this[n]?(this[c]&&this[c](e,t),!1):(this[o]+=d.length,this[h].unshift(d),this[p].set(e,this[h].head),g(this),!0)}has(e){if(!this[p].has(e))return!1;const t=this[p].get(e).value;return!_(this,t)}get(e){return m(this,e,!0)}peek(e){return m(this,e,!1)}pop(){const e=this[h].tail;return e?(y(this,e),e.value):null}del(e){y(this,this[p].get(e))}load(e){this.reset();const t=Date.now();for(let r=e.length-1;r>=0;r--){const i=e[r],n=i.e||0;if(0===n)this.set(i.k,i.v);else{const e=n-t;e>0&&this.set(i.k,i.v,e)}}}prune(){this[p].forEach(((e,t)=>m(this,t,!1)))}}},{yallist:83}],38:[function(e,t,r){(function(e){(function(){const r=t.exports;r.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"},r.codes={};for(const e in r.types){const t=r.types[e];r.codes[t]=e}r.CMD_SHIFT=4,r.CMD_MASK=240,r.DUP_MASK=8,r.QOS_MASK=3,r.QOS_SHIFT=1,r.RETAIN_MASK=1,r.VARBYTEINT_MASK=127,r.VARBYTEINT_FIN_MASK=128,r.VARBYTEINT_MAX=268435455,r.SESSIONPRESENT_MASK=1,r.SESSIONPRESENT_HEADER=e.from([r.SESSIONPRESENT_MASK]),r.CONNACK_HEADER=e.from([r.codes.connack<<r.CMD_SHIFT]),r.USERNAME_MASK=128,r.PASSWORD_MASK=64,r.WILL_RETAIN_MASK=32,r.WILL_QOS_MASK=24,r.WILL_QOS_SHIFT=3,r.WILL_FLAG_MASK=4,r.CLEAN_SESSION_MASK=2,r.CONNECT_HEADER=e.from([r.codes.connect<<r.CMD_SHIFT]),r.properties={sessionExpiryInterval:17,willDelayInterval:24,receiveMaximum:33,maximumPacketSize:39,topicAliasMaximum:34,requestResponseInformation:25,requestProblemInformation:23,userProperties:38,authenticationMethod:21,authenticationData:22,payloadFormatIndicator:1,messageExpiryInterval:2,contentType:3,responseTopic:8,correlationData:9,maximumQoS:36,retainAvailable:37,assignedClientIdentifier:18,reasonString:31,wildcardSubscriptionAvailable:40,subscriptionIdentifiersAvailable:41,sharedSubscriptionAvailable:42,serverKeepAlive:19,responseInformation:26,serverReference:28,topicAlias:35,subscriptionIdentifier:11},r.propertiesCodes={};for(const e in r.properties){const t=r.properties[e];r.propertiesCodes[t]=e}function i(t){return[0,1,2].map((i=>[0,1].map((n=>[0,1].map((o=>{const s=e.alloc(1);return s.writeUInt8(r.codes[t]<<r.CMD_SHIFT|(n?r.DUP_MASK:0)|i<<r.QOS_SHIFT|o,0,!0),s}))))))}r.propertiesTypes={sessionExpiryInterval:"int32",willDelayInterval:"int32",receiveMaximum:"int16",maximumPacketSize:"int32",topicAliasMaximum:"int16",requestResponseInformation:"byte",requestProblemInformation:"byte",userProperties:"pair",authenticationMethod:"string",authenticationData:"binary",payloadFormatIndicator:"byte",messageExpiryInterval:"int32",contentType:"string",responseTopic:"string",correlationData:"binary",maximumQoS:"int8",retainAvailable:"byte",assignedClientIdentifier:"string",reasonString:"string",wildcardSubscriptionAvailable:"byte",subscriptionIdentifiersAvailable:"byte",sharedSubscriptionAvailable:"byte",serverKeepAlive:"int16",responseInformation:"string",serverReference:"string",topicAlias:"int16",subscriptionIdentifier:"var"},r.PUBLISH_HEADER=i("publish"),r.SUBSCRIBE_HEADER=i("subscribe"),r.SUBSCRIBE_OPTIONS_QOS_MASK=3,r.SUBSCRIBE_OPTIONS_NL_MASK=1,r.SUBSCRIBE_OPTIONS_NL_SHIFT=2,r.SUBSCRIBE_OPTIONS_RAP_MASK=1,r.SUBSCRIBE_OPTIONS_RAP_SHIFT=3,r.SUBSCRIBE_OPTIONS_RH_MASK=3,r.SUBSCRIBE_OPTIONS_RH_SHIFT=4,r.SUBSCRIBE_OPTIONS_RH=[0,16,32],r.SUBSCRIBE_OPTIONS_NL=4,r.SUBSCRIBE_OPTIONS_RAP=8,r.SUBSCRIBE_OPTIONS_QOS=[0,1,2],r.UNSUBSCRIBE_HEADER=i("unsubscribe"),r.ACKS={unsuback:i("unsuback"),puback:i("puback"),pubcomp:i("pubcomp"),pubrel:i("pubrel"),pubrec:i("pubrec")},r.SUBACK_HEADER=e.from([r.codes.suback<<r.CMD_SHIFT]),r.VERSION3=e.from([3]),r.VERSION4=e.from([4]),r.VERSION5=e.from([5]),r.VERSION131=e.from([131]),r.VERSION132=e.from([132]),r.QOS=[0,1,2].map((t=>e.from([t]))),r.EMPTY={pingreq:e.from([r.codes.pingreq<<4,0]),pingresp:e.from([r.codes.pingresp<<4,0]),disconnect:e.from([r.codes.disconnect<<4,0])}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],39:[function(e,t,r){(function(r){(function(){const i=e("./writeToStream"),n=e("events");class o extends n{constructor(){super(),this._array=new Array(20),this._i=0}write(e){return this._array[this._i++]=e,!0}concat(){let e=0;const t=new Array(this._array.length),i=this._array;let n,o=0;for(n=0;n<i.length&&void 0!==i[n];n++)"string"!=typeof i[n]?t[n]=i[n].length:t[n]=r.byteLength(i[n]),e+=t[n];const s=r.allocUnsafe(e);for(n=0;n<i.length&&void 0!==i[n];n++)"string"!=typeof i[n]?(i[n].copy(s,o),o+=t[n]):(s.write(i[n],o),o+=t[n]);return s}}t.exports=function(e,t){const r=new o;return i(e,r,t),r.concat()}}).call(this)}).call(this,e("buffer").Buffer)},{"./writeToStream":44,buffer:17,events:22}],40:[function(e,t,r){r.parser=e("./parser").parser,r.generate=e("./generate"),r.writeToStream=e("./writeToStream")},{"./generate":39,"./parser":43,"./writeToStream":44}],41:[function(e,t,r){(function(e){(function(){const r={},i=e.isBuffer(e.from([1,2]).subarray(0,1));function n(t){const r=e.allocUnsafe(2);return r.writeUInt8(t>>8,0),r.writeUInt8(255&t,1),r}t.exports={cache:r,generateCache:function(){for(let e=0;e<65536;e++)r[e]=n(e)},generateNumber:n,genBufVariableByteInt:function(t){let r=0,n=0;const o=e.allocUnsafe(4);do{r=t%128|0,(t=t/128|0)>0&&(r|=128),o.writeUInt8(r,n++)}while(t>0&&n<4);return t>0&&(n=0),i?o.subarray(0,n):o.slice(0,n)},generate4ByteBuffer:function(t){const r=e.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],42:[function(e,t,r){t.exports=class{constructor(){this.cmd=null,this.retain=!1,this.qos=0,this.dup=!1,this.length=-1,this.topic=null,this.payload=null}}},{}],43:[function(e,t,r){const i=e("bl"),n=e("events"),o=e("./packet"),s=e("./constants"),a=e("debug")("mqtt-packet:parser");class l extends n{constructor(){super(),this.parser=this.constructor.parser}static parser(e){return this instanceof l?(this.settings=e||{},this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"],this._resetState(),this):(new l).parser(e)}_resetState(){a("_resetState: resetting packet, error, _list, and _stateCounter"),this.packet=new o,this.error=null,this._list=i(),this._stateCounter=0}parse(e){for(this.error&&this._resetState(),this._list.append(e),a("parse: current state: %s",this._states[this._stateCounter]);(-1!==this.packet.length||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error;)this._stateCounter++,a("parse: state complete. _stateCounter is now: %d",this._stateCounter),a("parse: packet.length: %d, buffer list length: %d",this.packet.length,this._list.length),this._stateCounter>=this._states.length&&(this._stateCounter=0);return a("parse: exited while loop. packet: %d, buffer list length: %d",this.packet.length,this._list.length),this._list.length}_parseHeader(){const e=this._list.readUInt8(0);return this.packet.cmd=s.types[e>>s.CMD_SHIFT],this.packet.retain=0!=(e&s.RETAIN_MASK),this.packet.qos=e>>s.QOS_SHIFT&s.QOS_MASK,this.packet.dup=0!=(e&s.DUP_MASK),a("_parseHeader: packet: %o",this.packet),this._list.consume(1),!0}_parseLength(){const e=this._parseVarByteNum(!0);return e&&(this.packet.length=e.value,this._list.consume(e.bytes)),a("_parseLength %d",e.value),!!e}_parsePayload(){a("_parsePayload: payload %O",this._list);let e=!1;if(0===this.packet.length||this._list.length>=this.packet.length){switch(this._pos=0,this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}e=!0}return a("_parsePayload complete result: %s",e),e}_parseConnect(){let e,t,r,i;a("_parseConnect");const n={},o=this.packet,l=this._parseString();if(null===l)return this._emitError(new Error("Cannot parse protocolId"));if("MQTT"!==l&&"MQIsdp"!==l)return this._emitError(new Error("Invalid protocolId"));if(o.protocolId=l,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(o.protocolVersion=this._list.readUInt8(this._pos),o.protocolVersion>=128&&(o.bridgeMode=!0,o.protocolVersion=o.protocolVersion-128),3!==o.protocolVersion&&4!==o.protocolVersion&&5!==o.protocolVersion)return this._emitError(new Error("Invalid protocol version"));if(this._pos++,this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));if(n.username=this._list.readUInt8(this._pos)&s.USERNAME_MASK,n.password=this._list.readUInt8(this._pos)&s.PASSWORD_MASK,n.will=this._list.readUInt8(this._pos)&s.WILL_FLAG_MASK,n.will&&(o.will={},o.will.retain=0!=(this._list.readUInt8(this._pos)&s.WILL_RETAIN_MASK),o.will.qos=(this._list.readUInt8(this._pos)&s.WILL_QOS_MASK)>>s.WILL_QOS_SHIFT),o.clean=0!=(this._list.readUInt8(this._pos)&s.CLEAN_SESSION_MASK),this._pos++,o.keepalive=this._parseNum(),-1===o.keepalive)return this._emitError(new Error("Packet too short"));if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.properties=e)}const c=this._parseString();if(null===c)return this._emitError(new Error("Packet too short"));if(o.clientId=c,a("_parseConnect: packet.clientId: %s",o.clientId),n.will){if(5===o.protocolVersion){const e=this._parseProperties();Object.getOwnPropertyNames(e).length&&(o.will.properties=e)}if(e=this._parseString(),null===e)return this._emitError(new Error("Cannot parse will topic"));if(o.will.topic=e,a("_parseConnect: packet.will.topic: %s",o.will.topic),t=this._parseBuffer(),null===t)return this._emitError(new Error("Cannot parse will payload"));o.will.payload=t,a("_parseConnect: packet.will.paylaod: %s",o.will.payload)}if(n.username){if(i=this._parseString(),null===i)return this._emitError(new Error("Cannot parse username"));o.username=i,a("_parseConnect: packet.username: %s",o.username)}if(n.password){if(r=this._parseBuffer(),null===r)return this._emitError(new Error("Cannot parse password"));o.password=r}return this.settings=o,a("_parseConnect: complete"),o}_parseConnack(){a("_parseConnack");const e=this.packet;if(this._list.length<1)return null;if(e.sessionPresent=!!(this._list.readUInt8(this._pos++)&s.SESSIONPRESENT_MASK),5===this.settings.protocolVersion)this._list.length>=2?e.reasonCode=this._list.readUInt8(this._pos++):e.reasonCode=0;else{if(this._list.length<2)return null;e.returnCode=this._list.readUInt8(this._pos++)}if(-1===e.returnCode||-1===e.reasonCode)return this._emitError(new Error("Cannot parse return code"));if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}a("_parseConnack: complete")}_parsePublish(){a("_parsePublish");const e=this.packet;if(e.topic=this._parseString(),null===e.topic)return this._emitError(new Error("Cannot parse topic"));if(!(e.qos>0)||this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}e.payload=this._list.slice(this._pos,e.length),a("_parsePublish: payload from buffer list: %o",e.payload)}}_parseSubscribe(){a("_parseSubscribe");const e=this.packet;let t,r,i,n,o,l,c;if(1!==e.qos)return this._emitError(new Error("Wrong subscribe header"));if(e.subscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){if(t=this._parseString(),null===t)return this._emitError(new Error("Cannot parse topic"));if(this._pos>=e.length)return this._emitError(new Error("Malformed Subscribe Payload"));r=this._parseByte(),i=r&s.SUBSCRIBE_OPTIONS_QOS_MASK,l=0!=(r>>s.SUBSCRIBE_OPTIONS_NL_SHIFT&s.SUBSCRIBE_OPTIONS_NL_MASK),o=0!=(r>>s.SUBSCRIBE_OPTIONS_RAP_SHIFT&s.SUBSCRIBE_OPTIONS_RAP_MASK),n=r>>s.SUBSCRIBE_OPTIONS_RH_SHIFT&s.SUBSCRIBE_OPTIONS_RH_MASK,c={topic:t,qos:i},5===this.settings.protocolVersion?(c.nl=l,c.rap=o,c.rh=n):this.settings.bridgeMode&&(c.rh=0,c.rap=!0,c.nl=!0),a("_parseSubscribe: push subscription `%s` to subscription",c),e.subscriptions.push(c)}}}_parseSuback(){a("_parseSuback");const e=this.packet;if(this.packet.granted=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseUnsubscribe(){a("_parseUnsubscribe");const e=this.packet;if(e.unsubscriptions=[],this._parseMessageId()){if(5===this.settings.protocolVersion){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}for(;this._pos<e.length;){const t=this._parseString();if(null===t)return this._emitError(new Error("Cannot parse topic"));a("_parseUnsubscribe: push topic `%s` to unsubscriptions",t),e.unsubscriptions.push(t)}}}_parseUnsuback(){a("_parseUnsuback");const e=this.packet;if(!this._parseMessageId())return this._emitError(new Error("Cannot parse messageId"));if(5===this.settings.protocolVersion){const t=this._parseProperties();for(Object.getOwnPropertyNames(t).length&&(e.properties=t),e.granted=[];this._pos<this.packet.length;)this.packet.granted.push(this._list.readUInt8(this._pos++))}}_parseConfirmation(){a("_parseConfirmation: packet.cmd: `%s`",this.packet.cmd);const e=this.packet;if(this._parseMessageId(),5===this.settings.protocolVersion&&(e.length>2?(e.reasonCode=this._parseByte(),a("_parseConfirmation: packet.reasonCode `%d`",e.reasonCode)):e.reasonCode=0,e.length>3)){const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return!0}_parseDisconnect(){const e=this.packet;if(a("_parseDisconnect"),5===this.settings.protocolVersion){this._list.length>0?e.reasonCode=this._parseByte():e.reasonCode=0;const t=this._parseProperties();Object.getOwnPropertyNames(t).length&&(e.properties=t)}return a("_parseDisconnect result: true"),!0}_parseAuth(){a("_parseAuth");const e=this.packet;if(5!==this.settings.protocolVersion)return this._emitError(new Error("Not supported auth packet for this version MQTT"));e.reasonCode=this._parseByte();const t=this._parseProperties();return Object.getOwnPropertyNames(t).length&&(e.properties=t),a("_parseAuth: result: true"),!0}_parseMessageId(){const e=this.packet;return e.messageId=this._parseNum(),null===e.messageId?(this._emitError(new Error("Cannot parse messageId")),!1):(a("_parseMessageId: packet.messageId %d",e.messageId),!0)}_parseString(e){const t=this._parseNum(),r=t+this._pos;if(-1===t||r>this._list.length||r>this.packet.length)return null;const i=this._list.toString("utf8",this._pos,r);return this._pos+=t,a("_parseString: result: %s",i),i}_parseStringPair(){return a("_parseStringPair"),{name:this._parseString(),value:this._parseString()}}_parseBuffer(){const e=this._parseNum(),t=e+this._pos;if(-1===e||t>this._list.length||t>this.packet.length)return null;const r=this._list.slice(this._pos,t);return this._pos+=e,a("_parseBuffer: result: %o",r),r}_parseNum(){if(this._list.length-this._pos<2)return-1;const e=this._list.readUInt16BE(this._pos);return this._pos+=2,a("_parseNum: result: %s",e),e}_parse4ByteNum(){if(this._list.length-this._pos<4)return-1;const e=this._list.readUInt32BE(this._pos);return this._pos+=4,a("_parse4ByteNum: result: %s",e),e}_parseVarByteNum(e){a("_parseVarByteNum");let t,r=0,i=1,n=0,o=!1;const l=this._pos?this._pos:0;for(;r<4&&l+r<this._list.length;){if(t=this._list.readUInt8(l+r++),n+=i*(t&s.VARBYTEINT_MASK),i*=128,0==(t&s.VARBYTEINT_FIN_MASK)){o=!0;break}if(this._list.length<=r)break}return!o&&4===r&&this._list.length>=r&&this._emitError(new Error("Invalid variable byte integer")),l&&(this._pos+=r),o=!!o&&(e?{bytes:r,value:n}:n),a("_parseVarByteNum: result: %o",o),o}_parseByte(){let e;return this._pos<this._list.length&&(e=this._list.readUInt8(this._pos),this._pos++),a("_parseByte: result: %o",e),e}_parseByType(e){switch(a("_parseByType: type: %s",e),e){case"byte":return 0!==this._parseByte();case"int8":return this._parseByte();case"int16":return this._parseNum();case"int32":return this._parse4ByteNum();case"var":return this._parseVarByteNum();case"string":return this._parseString();case"pair":return this._parseStringPair();case"binary":return this._parseBuffer()}}_parseProperties(){a("_parseProperties");const e=this._parseVarByteNum(),t=this._pos+e,r={};for(;this._pos<t;){const e=this._parseByte();if(!e)return this._emitError(new Error("Cannot parse property code type")),!1;const t=s.propertiesCodes[e];if(!t)return this._emitError(new Error("Unknown property")),!1;if("userProperties"!==t)r[t]?(Array.isArray(r[t])||(r[t]=[r[t]]),r[t].push(this._parseByType(s.propertiesTypes[t]))):r[t]=this._parseByType(s.propertiesTypes[t]);else{r[t]||(r[t]=Object.create(null));const e=this._parseByType(s.propertiesTypes[t]);if(r[t][e.name])if(Array.isArray(r[t][e.name]))r[t][e.name].push(e.value);else{const i=r[t][e.name];r[t][e.name]=[i],r[t][e.name].push(e.value)}else r[t][e.name]=e.value}}return r}_newPacket(){return a("_newPacket"),this.packet&&(this._list.consume(this.packet.length),a("_newPacket: parser emit packet: packet.cmd: %s, packet.payload: %s, packet.length: %d",this.packet.cmd,this.packet.payload,this.packet.length),this.emit("packet",this.packet)),a("_newPacket: new packet"),this.packet=new o,this._pos=0,!0}_emitError(e){a("_emitError"),this.error=e,this.emit("error",e)}}t.exports=l},{"./constants":38,"./packet":42,bl:15,debug:18,events:22}],44:[function(e,t,r){(function(r){(function(){const i=e("./constants"),n=r.allocUnsafe(0),o=r.from([0]),s=e("./numbers"),a=e("process-nextick-args").nextTick,l=e("debug")("mqtt-packet:writeToStream"),c=s.cache,u=s.generateNumber,h=s.generateCache,p=s.genBufVariableByteInt,d=s.generate4ByteBuffer;let f=w,m=!0;function _(e,t,s){switch(l("generate called"),t.cork&&(t.cork(),a(g,t)),m&&(m=!1,h()),l("generate: packet.cmd: %s",e.cmd),e.cmd){case"connect":return function(e,t,n){const o=e||{},s=o.protocolId||"MQTT";let a=o.protocolVersion||4;const l=o.will;let c=o.clean;const u=o.keepalive||0,h=o.clientId||"",p=o.username,d=o.password,m=o.properties;void 0===c&&(c=!0);let _=0;if(!s||"string"!=typeof s&&!r.isBuffer(s))return t.emit("error",new Error("Invalid protocolId")),!1;if(_+=s.length+2,3!==a&&4!==a&&5!==a)return t.emit("error",new Error("Invalid protocol version")),!1;if(_+=1,("string"==typeof h||r.isBuffer(h))&&(h||a>=4)&&(h||c))_+=r.byteLength(h)+2;else{if(a<4)return t.emit("error",new Error("clientId must be supplied before 3.1.1")),!1;if(1*c==0)return t.emit("error",new Error("clientId must be given if cleanSession set to 0")),!1}if("number"!=typeof u||u<0||u>65535||u%1!=0)return t.emit("error",new Error("Invalid keepalive")),!1;if(_+=2,_+=1,5===a){var g=S(t,m);if(!g)return!1;_+=g.length}if(l){if("object"!=typeof l)return t.emit("error",new Error("Invalid will")),!1;if(!l.topic||"string"!=typeof l.topic)return t.emit("error",new Error("Invalid will topic")),!1;if(_+=r.byteLength(l.topic)+2,_+=2,l.payload){if(!(l.payload.length>=0))return t.emit("error",new Error("Invalid will payload")),!1;"string"==typeof l.payload?_+=r.byteLength(l.payload):_+=l.payload.length}var y={};if(5===a){if(!(y=S(t,l.properties)))return!1;_+=y.length}}let b=!1;if(null!=p){if(!M(p))return t.emit("error",new Error("Invalid username")),!1;b=!0,_+=r.byteLength(p)+2}if(null!=d){if(!b)return t.emit("error",new Error("Username is required to use password")),!1;if(!M(d))return t.emit("error",new Error("Invalid password")),!1;_+=I(d)+2}t.write(i.CONNECT_HEADER),v(t,_),E(t,s),o.bridgeMode&&(a+=128),t.write(131===a?i.VERSION131:132===a?i.VERSION132:4===a?i.VERSION4:5===a?i.VERSION5:i.VERSION3);let w=0;return w|=null!=p?i.USERNAME_MASK:0,w|=null!=d?i.PASSWORD_MASK:0,w|=l&&l.retain?i.WILL_RETAIN_MASK:0,w|=l&&l.qos?l.qos<<i.WILL_QOS_SHIFT:0,w|=l?i.WILL_FLAG_MASK:0,w|=c?i.CLEAN_SESSION_MASK:0,t.write(r.from([w])),f(t,u),5===a&&g.write(),E(t,h),l&&(5===a&&y.write(),x(t,l.topic),E(t,l.payload)),null!=p&&E(t,p),null!=d&&E(t,d),!0}(e,t);case"connack":return function(e,t,n){const s=n?n.protocolVersion:4,a=e||{},l=5===s?a.reasonCode:a.returnCode,c=a.properties;let u=2;if("number"!=typeof l)return t.emit("error",new Error("Invalid return code")),!1;let h=null;if(5===s){if(h=S(t,c),!h)return!1;u+=h.length}return t.write(i.CONNACK_HEADER),v(t,u),t.write(a.sessionPresent?i.SESSIONPRESENT_HEADER:o),t.write(r.from([l])),null!=h&&h.write(),!0}(e,t,s);case"publish":return function(e,t,o){l("publish: packet: %o",e);const s=o?o.protocolVersion:4,a=e||{},c=a.qos||0,u=a.retain?i.RETAIN_MASK:0,h=a.topic,p=a.payload||n,d=a.messageId,m=a.properties;let _=0;if("string"==typeof h)_+=r.byteLength(h)+2;else{if(!r.isBuffer(h))return t.emit("error",new Error("Invalid topic")),!1;_+=h.length+2}if(r.isBuffer(p)?_+=p.length:_+=r.byteLength(p),c&&"number"!=typeof d)return t.emit("error",new Error("Invalid messageId")),!1;c&&(_+=2);let g=null;if(5===s){if(g=S(t,m),!g)return!1;_+=g.length}return t.write(i.PUBLISH_HEADER[c][a.dup?1:0][u?1:0]),v(t,_),f(t,I(h)),t.write(h),c>0&&f(t,d),null!=g&&g.write(),l("publish: payload: %o",p),t.write(p)}(e,t,s);case"puback":case"pubrec":case"pubrel":case"pubcomp":return function(e,t,n){const o=n?n.protocolVersion:4,s=e||{},a=s.cmd||"puback",l=s.messageId,c=s.dup&&"pubrel"===a?i.DUP_MASK:0;let u=0;const h=s.reasonCode,p=s.properties;let d=5===o?3:2;if("pubrel"===a&&(u=1),"number"!=typeof l)return t.emit("error",new Error("Invalid messageId")),!1;let m=null;if(5===o&&"object"==typeof p){if(m=C(t,p,n,d),!m)return!1;d+=m.length}return t.write(i.ACKS[a][u][c][0]),v(t,d),f(t,l),5===o&&t.write(r.from([h])),null!==m&&m.write(),!0}(e,t,s);case"subscribe":return function(e,t,n){l("subscribe: packet: ");const o=n?n.protocolVersion:4,s=e||{},a=s.dup?i.DUP_MASK:0,c=s.messageId,u=s.subscriptions,h=s.properties;let p=0;if("number"!=typeof c)return t.emit("error",new Error("Invalid messageId")),!1;p+=2;let d=null;if(5===o){if(d=S(t,h),!d)return!1;p+=d.length}if("object"!=typeof u||!u.length)return t.emit("error",new Error("Invalid subscriptions")),!1;for(let e=0;e<u.length;e+=1){const i=u[e].topic,n=u[e].qos;if("string"!=typeof i)return t.emit("error",new Error("Invalid subscriptions - invalid topic")),!1;if("number"!=typeof n)return t.emit("error",new Error("Invalid subscriptions - invalid qos")),!1;if(5===o){if("boolean"!=typeof(u[e].nl||!1))return t.emit("error",new Error("Invalid subscriptions - invalid No Local")),!1;if("boolean"!=typeof(u[e].rap||!1))return t.emit("error",new Error("Invalid subscriptions - invalid Retain as Published")),!1;const r=u[e].rh||0;if("number"!=typeof r||r>2)return t.emit("error",new Error("Invalid subscriptions - invalid Retain Handling")),!1}p+=r.byteLength(i)+2+1}l("subscribe: writing to stream: %o",i.SUBSCRIBE_HEADER),t.write(i.SUBSCRIBE_HEADER[1][a?1:0][0]),v(t,p),f(t,c),null!==d&&d.write();let m=!0;for(const e of u){const n=e.topic,s=e.qos,a=+e.nl,l=+e.rap,c=e.rh;let u;x(t,n),u=i.SUBSCRIBE_OPTIONS_QOS[s],5===o&&(u|=a?i.SUBSCRIBE_OPTIONS_NL:0,u|=l?i.SUBSCRIBE_OPTIONS_RAP:0,u|=c?i.SUBSCRIBE_OPTIONS_RH[c]:0),m=t.write(r.from([u]))}return m}(e,t,s);case"suback":return function(e,t,n){const o=n?n.protocolVersion:4,s=e||{},a=s.messageId,l=s.granted,c=s.properties;let u=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(u+=2,"object"!=typeof l||!l.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<l.length;e+=1){if("number"!=typeof l[e])return t.emit("error",new Error("Invalid qos vector")),!1;u+=1}let h=null;if(5===o){if(h=C(t,c,n,u),!h)return!1;u+=h.length}return t.write(i.SUBACK_HEADER),v(t,u),f(t,a),null!==h&&h.write(),t.write(r.from(l))}(e,t,s);case"unsubscribe":return function(e,t,n){const o=n?n.protocolVersion:4,s=e||{},a=s.messageId,l=s.dup?i.DUP_MASK:0,c=s.unsubscriptions,u=s.properties;let h=0;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(h+=2,"object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid unsubscriptions")),!1;for(let e=0;e<c.length;e+=1){if("string"!=typeof c[e])return t.emit("error",new Error("Invalid unsubscriptions")),!1;h+=r.byteLength(c[e])+2}let p=null;if(5===o){if(p=S(t,u),!p)return!1;h+=p.length}t.write(i.UNSUBSCRIBE_HEADER[1][l?1:0][0]),v(t,h),f(t,a),null!==p&&p.write();let d=!0;for(let e=0;e<c.length;e++)d=x(t,c[e]);return d}(e,t,s);case"unsuback":return function(e,t,n){const o=n?n.protocolVersion:4,s=e||{},a=s.messageId,l=s.dup?i.DUP_MASK:0,c=s.granted,u=s.properties,h=s.cmd,p=0;let d=2;if("number"!=typeof a)return t.emit("error",new Error("Invalid messageId")),!1;if(5===o){if("object"!=typeof c||!c.length)return t.emit("error",new Error("Invalid qos vector")),!1;for(let e=0;e<c.length;e+=1){if("number"!=typeof c[e])return t.emit("error",new Error("Invalid qos vector")),!1;d+=1}}let m=null;if(5===o){if(m=C(t,u,n,d),!m)return!1;d+=m.length}return t.write(i.ACKS[h][p][l][0]),v(t,d),f(t,a),null!==m&&m.write(),5===o&&t.write(r.from(c)),!0}(e,t,s);case"pingreq":case"pingresp":return function(e,t,r){return t.write(i.EMPTY[e.cmd])}(e,t);case"disconnect":return function(e,t,n){const o=n?n.protocolVersion:4,s=e||{},a=s.reasonCode,l=s.properties;let c=5===o?1:0,u=null;if(5===o){if(u=C(t,l,n,c),!u)return!1;c+=u.length}return t.write(r.from([i.codes.disconnect<<4])),v(t,c),5===o&&t.write(r.from([a])),null!==u&&u.write(),!0}(e,t,s);case"auth":return function(e,t,n){const o=n?n.protocolVersion:4,s=e||{},a=s.reasonCode,l=s.properties;let c=5===o?1:0;5!==o&&t.emit("error",new Error("Invalid mqtt version for auth packet"));const u=C(t,l,n,c);return!!u&&(c+=u.length,t.write(r.from([i.codes.auth<<4])),v(t,c),t.write(r.from([a])),null!==u&&u.write(),!0)}(e,t,s);default:return t.emit("error",new Error("Unknown command")),!1}}function g(e){e.uncork()}Object.defineProperty(_,"cacheNumbers",{get:()=>f===w,set(e){e?(c&&0!==Object.keys(c).length||(m=!0),f=w):(m=!1,f=T)}});const y={};function v(e,t){if(t>i.VARBYTEINT_MAX)return e.emit("error",new Error(`Invalid variable byte integer: ${t}`)),!1;let r=y[t];return r||(r=p(t),t<16384&&(y[t]=r)),l("writeVarByteInt: writing to stream: %o",r),e.write(r)}function x(e,t){const i=r.byteLength(t);return f(e,i),l("writeString: %s",t),e.write(t,"utf8")}function b(e,t,r){x(e,t),x(e,r)}function w(e,t){return l("writeNumberCached: number: %d",t),l("writeNumberCached: %o",c[t]),e.write(c[t])}function T(e,t){const r=u(t);return l("writeNumberGenerated: %o",r),e.write(r)}function E(e,t){"string"==typeof t?x(e,t):t?(f(e,t.length),e.write(t)):f(e,0)}function S(e,t){if("object"!=typeof t||null!=t.length)return{length:1,write(){k(e,{},0)}};let n=0;function o(t,n){let o=0;switch(i.propertiesTypes[t]){case"byte":if("boolean"!=typeof n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=2;break;case"int8":if("number"!=typeof n||n<0||n>255)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=2;break;case"binary":if(n&&null===n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=1+r.byteLength(n)+2;break;case"int16":if("number"!=typeof n||n<0||n>65535)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=3;break;case"int32":if("number"!=typeof n||n<0||n>4294967295)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=5;break;case"var":if("number"!=typeof n||n<0||n>268435455)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=1+r.byteLength(p(n));break;case"string":if("string"!=typeof n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=3+r.byteLength(n.toString());break;case"pair":if("object"!=typeof n)return e.emit("error",new Error(`Invalid ${t}: ${n}`)),!1;o+=Object.getOwnPropertyNames(n).reduce(((e,t)=>{const i=n[t];return Array.isArray(i)?e+=i.reduce(((e,i)=>e+(3+r.byteLength(t.toString())+2+r.byteLength(i.toString()))),0):e+=3+r.byteLength(t.toString())+2+r.byteLength(n[t].toString()),e}),0);break;default:return e.emit("error",new Error(`Invalid property ${t}: ${n}`)),!1}return o}if(t)for(const e in t){let r=0,i=0;const s=t[e];if(Array.isArray(s))for(let t=0;t<s.length;t++){if(i=o(e,s[t]),!i)return!1;r+=i}else{if(i=o(e,s),!i)return!1;r=i}if(!r)return!1;n+=r}return{length:r.byteLength(p(n))+n,write(){k(e,t,n)}}}function C(e,t,r,i){const n=["reasonString","userProperties"],o=r&&r.properties&&r.properties.maximumPacketSize?r.properties.maximumPacketSize:0;let s=S(e,t);if(o)for(;i+s.length>o;){const r=n.shift();if(!r||!t[r])return!1;delete t[r],s=S(e,t)}return s}function A(e,t,n){switch(i.propertiesTypes[t]){case"byte":e.write(r.from([i.properties[t]])),e.write(r.from([+n]));break;case"int8":e.write(r.from([i.properties[t]])),e.write(r.from([n]));break;case"binary":e.write(r.from([i.properties[t]])),E(e,n);break;case"int16":e.write(r.from([i.properties[t]])),f(e,n);break;case"int32":e.write(r.from([i.properties[t]])),function(e,t){const r=d(t);l("write4ByteNumber: %o",r),e.write(r)}(e,n);break;case"var":e.write(r.from([i.properties[t]])),v(e,n);break;case"string":e.write(r.from([i.properties[t]])),x(e,n);break;case"pair":Object.getOwnPropertyNames(n).forEach((o=>{const s=n[o];Array.isArray(s)?s.forEach((n=>{e.write(r.from([i.properties[t]])),b(e,o.toString(),n.toString())})):(e.write(r.from([i.properties[t]])),b(e,o.toString(),s.toString()))}));break;default:return e.emit("error",new Error(`Invalid property ${t} value: ${n}`)),!1}}function k(e,t,r){v(e,r);for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&null!==t[r]){const i=t[r];if(Array.isArray(i))for(let t=0;t<i.length;t++)A(e,r,i[t]);else A(e,r,i)}}function I(e){return e?e instanceof r?e.length:r.byteLength(e):0}function M(e){return"string"==typeof e||e instanceof r}t.exports=_}).call(this)}).call(this,e("buffer").Buffer)},{"./constants":38,"./numbers":41,buffer:17,debug:18,"process-nextick-args":49}],45:[function(e,t,r){var i=1e3,n=60*i,o=60*n,s=24*o;function a(e,t,r,i){var n=t>=1.5*r;return Math.round(e/r)+" "+i+(n?"s":"")}t.exports=function(e,t){t=t||{};var r,l,c=typeof e;if("string"===c&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}(e);if("number"===c&&isFinite(e))return t.long?(r=e,(l=Math.abs(r))>=s?a(r,l,s,"day"):l>=o?a(r,l,o,"hour"):l>=n?a(r,l,n,"minute"):l>=i?a(r,l,i,"second"):r+" ms"):function(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=o?Math.round(e/o)+"h":t>=n?Math.round(e/n)+"m":t>=i?Math.round(e/i)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],46:[function(e,t,r){const i=e("./lib/number-allocator.js");t.exports.NumberAllocator=i},{"./lib/number-allocator.js":47}],47:[function(e,t,r){"use strict";const i=e("js-sdsl").Set,n=e("debug")("number-allocator:trace"),o=e("debug")("number-allocator:error");function s(e,t){this.low=e,this.high=t}function a(e,t){if(!(this instanceof a))return new a(e,t);this.min=e,this.max=t,this.ss=new i([],((e,t)=>e.compare(t))),n("Create"),this.clear()}s.prototype.equals=function(e){return this.low===e.low&&this.high===e.high},s.prototype.compare=function(e){return this.low<e.low&&this.high<e.low?-1:e.low<this.low&&e.high<this.low?1:0},a.prototype.firstVacant=function(){return 0===this.ss.size()?null:this.ss.front().low},a.prototype.alloc=function(){if(0===this.ss.size())return n("alloc():empty"),null;const e=this.ss.front(),t=e.low;return t+1<=e.high?++e.low:this.ss.eraseElementByPos(0),n("alloc():"+t),t},a.prototype.use=function(e){const t=new s(e,e),r=this.ss.lowerBound(t);if(r){if(r.equals(t))return this.ss.eraseElementByValue(r),n("use():"+e),!0;if(r.low>e)return!1;if(r.low===e)return++r.low,n("use():"+e),!0;if(r.high===e)return--r.high,n("use():"+e),!0;const i=r.low;return r.low=e+1,this.ss.insert(new s(i,e-1)),n("use():"+e),!0}return n("use():failed"),!1},a.prototype.free=function(e){if(e<this.min||e>this.max)return void o("free():"+e+" is out of range");const t=new s(e,e),r=this.ss.lowerBound(t);if(r){if(r.low<=e&&e<=r.high)return void o("free():"+e+" has already been vacant");if(r===this.ss.front())e+1===r.low?--r.low:this.ss.insert(t);else{const i=this.ss.reverseLowerBound(t);i.high+1===e?e+1===r.low?(this.ss.eraseElementByValue(i),r.low=i.low):i.high=e:e+1===r.low?r.low=e:this.ss.insert(t)}}else{if(r===this.ss.front())return void this.ss.insert(t);const i=this.ss.reverseLowerBound(t);i.high+1===e?i.high=e:this.ss.insert(t)}n("free():"+e)},a.prototype.clear=function(){n("clear()"),this.ss.clear(),this.ss.insert(new s(this.min,this.max))},a.prototype.intervalCount=function(){return this.ss.size()},a.prototype.dump=function(){console.log("length:"+this.ss.size());for(const e of this.ss)console.log(e)},t.exports=a},{debug:18,"js-sdsl":36}],48:[function(e,t,r){var i=e("wrappy");function n(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function o(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},r=e.name||"Function wrapped with `once`";return t.onceError=r+" shouldn't be called more than once",t.called=!1,t}t.exports=i(n),t.exports.strict=i(o),n.proto=n((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return o(this)},configurable:!0})}))},{wrappy:79}],49:[function(e,t,r){(function(e){(function(){"use strict";void 0===e||!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:function(t,r,i,n){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick((function(){t.call(null,r)}));case 3:return e.nextTick((function(){t.call(null,r,i)}));case 4:return e.nextTick((function(){t.call(null,r,i,n)}));default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return e.nextTick((function(){t.apply(null,o)}))}}}:t.exports=e}).call(this)}).call(this,e("_process"))},{_process:50}],50:[function(e,t,r){var i,n,o=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function l(e){if(i===setTimeout)return setTimeout(e,0);if((i===s||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:s}catch(e){i=s}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,u=[],h=!1,p=-1;function d(){h&&c&&(h=!1,c.length?u=c.concat(u):p=-1,u.length&&f())}function f(){if(!h){var e=l(d);h=!0;for(var t=u.length;t;){for(c=u,u=[];++p<t;)c&&c[p].run();p=-1,t=u.length}c=null,h=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function _(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new m(e,t)),1!==u.length||h||l(f)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=_,o.addListener=_,o.once=_,o.off=_,o.removeListener=_,o.removeAllListeners=_,o.emit=_,o.prependListener=_,o.prependOnceListener=_,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],51:[function(e,t,i){(function(e){(function(){!function(r){var n="object"==typeof i&&i&&!i.nodeType&&i,o="object"==typeof t&&t&&!t.nodeType&&t,s="object"==typeof e&&e;s.global!==s&&s.window!==s&&s.self!==s||(r=s);var a,l,c=2147483647,u=36,h=/^xn--/,p=/[^\x20-\x7E]/,d=/[\x2E\u3002\uFF0E\uFF61]/g,f={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},m=Math.floor,_=String.fromCharCode;function g(e){throw new RangeError(f[e])}function y(e,t){for(var r=e.length,i=[];r--;)i[r]=t(e[r]);return i}function v(e,t){var r=e.split("@"),i="";return r.length>1&&(i=r[0]+"@",e=r[1]),i+y((e=e.replace(d,".")).split("."),t).join(".")}function x(e){for(var t,r,i=[],n=0,o=e.length;n<o;)(t=e.charCodeAt(n++))>=55296&&t<=56319&&n<o?56320==(64512&(r=e.charCodeAt(n++)))?i.push(((1023&t)<<10)+(1023&r)+65536):(i.push(t),n--):i.push(t);return i}function b(e){return y(e,(function(e){var t="";return e>65535&&(t+=_((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+_(e)})).join("")}function w(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function T(e,t,r){var i=0;for(e=r?m(e/700):e>>1,e+=m(e/t);e>455;i+=u)e=m(e/35);return m(i+36*e/(e+38))}function E(e){var t,r,i,n,o,s,a,l,h,p,d,f=[],_=e.length,y=0,v=128,x=72;for((r=e.lastIndexOf("-"))<0&&(r=0),i=0;i<r;++i)e.charCodeAt(i)>=128&&g("not-basic"),f.push(e.charCodeAt(i));for(n=r>0?r+1:0;n<_;){for(o=y,s=1,a=u;n>=_&&g("invalid-input"),((l=(d=e.charCodeAt(n++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:u)>=u||l>m((c-y)/s))&&g("overflow"),y+=l*s,!(l<(h=a<=x?1:a>=x+26?26:a-x));a+=u)s>m(c/(p=u-h))&&g("overflow"),s*=p;x=T(y-o,t=f.length+1,0==o),m(y/t)>c-v&&g("overflow"),v+=m(y/t),y%=t,f.splice(y++,0,v)}return b(f)}function S(e){var t,r,i,n,o,s,a,l,h,p,d,f,y,v,b,E=[];for(f=(e=x(e)).length,t=128,r=0,o=72,s=0;s<f;++s)(d=e[s])<128&&E.push(_(d));for(i=n=E.length,n&&E.push("-");i<f;){for(a=c,s=0;s<f;++s)(d=e[s])>=t&&d<a&&(a=d);for(a-t>m((c-r)/(y=i+1))&&g("overflow"),r+=(a-t)*y,t=a,s=0;s<f;++s)if((d=e[s])<t&&++r>c&&g("overflow"),d==t){for(l=r,h=u;!(l<(p=h<=o?1:h>=o+26?26:h-o));h+=u)b=l-p,v=u-p,E.push(_(w(p+b%v,0))),l=m(b/v);E.push(_(w(l,0))),o=T(r,y,i==n),r=0,++i}++r,++t}return E.join("")}if(a={version:"1.4.1",ucs2:{decode:x,encode:b},decode:E,encode:S,toASCII:function(e){return v(e,(function(e){return p.test(e)?"xn--"+S(e):e}))},toUnicode:function(e){return v(e,(function(e){return h.test(e)?E(e.slice(4).toLowerCase()):e}))}},n&&o)if(t.exports==n)o.exports=a;else for(l in a)a.hasOwnProperty(l)&&(n[l]=a[l]);else r.punycode=a}(this)}).call(this)}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],52:[function(e,t,r){"use strict";function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&",r=r||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var l=1e3;o&&"number"==typeof o.maxKeys&&(l=o.maxKeys);var c=e.length;l>0&&c>l&&(c=l);for(var u=0;u<c;++u){var h,p,d,f,m=e[u].replace(a,"%20"),_=m.indexOf(r);_>=0?(h=m.substr(0,_),p=m.substr(_+1)):(h=m,p=""),d=decodeURIComponent(h),f=decodeURIComponent(p),i(s,d)?n(s[d])?s[d].push(f):s[d]=[s[d],f]:s[d]=f}return s};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],53:[function(e,t,r){"use strict";var i=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,a){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?o(s(e),(function(s){var a=encodeURIComponent(i(s))+r;return n(e[s])?o(e[s],(function(e){return a+encodeURIComponent(i(e))})).join(t):a+encodeURIComponent(i(e[s]))})).join(t):a?encodeURIComponent(i(a))+r+encodeURIComponent(i(e)):""};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function o(e,t){if(e.map)return e.map(t);for(var r=[],i=0;i<e.length;i++)r.push(t(e[i],i));return r}var s=Object.keys||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t}},{}],54:[function(e,t,r){"use strict";r.decode=r.parse=e("./decode"),r.encode=r.stringify=e("./encode")},{"./decode":52,"./encode":53}],55:[function(e,t,r){"use strict";var i={};function n(e,t,r){r||(r=Error);var n=function(e){function r(r,i,n){return e.call(this,function(e,r,i){return"string"==typeof t?t:t(e,r,i)}(r,i,n))||this}return n=e,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,i.__proto__=n,r;var i,n}(r);n.prototype.name=r.name,n.prototype.code=e,i[e]=n}function o(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}n("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),n("ERR_INVALID_ARG_TYPE",(function(e,t,r){var i,n,s,a;if("string"==typeof t&&(s="not ",t.substr(!a||a<0?0:+a,s.length)===s)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))n="The ".concat(e," ").concat(i," ").concat(o(t,"type"));else{var l=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";n='The "'.concat(e,'" ').concat(l," ").concat(i," ").concat(o(t,"type"))}return n+". Received type ".concat(typeof r)}),TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=i},{}],56:[function(e,t,r){(function(r){(function(){"use strict";var i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=c;var n=e("./_stream_readable"),o=e("./_stream_writable");e("inherits")(c,n);for(var s=i(o.prototype),a=0;a<s.length;a++){var l=s[a];c.prototype[l]||(c.prototype[l]=o.prototype[l])}function c(e){if(!(this instanceof c))return new c(e);n.call(this,e),o.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",u)))}function u(){this._writableState.ended||r.nextTick(h,this)}function h(e){e.end()}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this)}).call(this,e("_process"))},{"./_stream_readable":58,"./_stream_writable":60,_process:50,inherits:24}],57:[function(e,t,r){"use strict";t.exports=n;var i=e("./_stream_transform");function n(e){if(!(this instanceof n))return new n(e);i.call(this,e)}e("inherits")(n,i),n.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":59,inherits:24}],58:[function(e,t,i){(function(r,i){(function(){"use strict";var n;t.exports=S,S.ReadableState=E,e("events").EventEmitter;var o=function(e,t){return e.listeners(t).length},s=e("./internal/streams/stream"),a=e("buffer").Buffer,l=i.Uint8Array||function(){};var c,u=e("util");c=u&&u.debuglog?u.debuglog("stream"):function(){};var h,p,d,f=e("./internal/streams/buffer_list"),m=e("./internal/streams/destroy"),_=e("./internal/streams/state").getHighWaterMark,g=e("../errors").codes,y=g.ERR_INVALID_ARG_TYPE,v=g.ERR_STREAM_PUSH_AFTER_EOF,x=g.ERR_METHOD_NOT_IMPLEMENTED,b=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(S,s);var w=m.errorOrDestroy,T=["error","close","destroy","pause","resume"];function E(t,r,i){n=n||e("./_stream_duplex"),t=t||{},"boolean"!=typeof i&&(i=r instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=_(this,t,"readableHighWaterMark",i),this.buffer=new f,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(h||(h=e("string_decoder/").StringDecoder),this.decoder=new h(t.encoding),this.encoding=t.encoding)}function S(t){if(n=n||e("./_stream_duplex"),!(this instanceof S))return new S(t);var r=this instanceof n;this._readableState=new E(t,this,r),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function C(e,t,r,i,n){c("readableAddChunk",t);var o,s=e._readableState;if(null===t)s.reading=!1,function(e,t){if(c("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?M(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,z(e)))}}(e,s);else if(n||(o=function(e,t){var r;return i=t,a.isBuffer(i)||i instanceof l||"string"==typeof t||void 0===t||e.objectMode||(r=new y("chunk",["string","Buffer","Uint8Array"],t)),r;var i}(s,t)),o)w(e,o);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),i)s.endEmitted?w(e,new b):A(e,s,t,!0);else if(s.ended)w(e,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?A(e,s,t,!1):P(e,s)):A(e,s,t,!1)}else i||(s.reading=!1,P(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function A(e,t,r,i){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&M(e)),P(e,t)}Object.defineProperty(S.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),S.prototype.destroy=m.destroy,S.prototype._undestroy=m.undestroy,S.prototype._destroy=function(e,t){t(e)},S.prototype.push=function(e,t){var r,i=this._readableState;return i.objectMode?r=!0:"string"==typeof e&&((t=t||i.defaultEncoding)!==i.encoding&&(e=a.from(e,t),t=""),r=!0),C(this,e,t,!1,r)},S.prototype.unshift=function(e){return C(this,e,null,!0,!1)},S.prototype.isPaused=function(){return!1===this._readableState.flowing},S.prototype.setEncoding=function(t){h||(h=e("string_decoder/").StringDecoder);var r=new h(t);this._readableState.decoder=r,this._readableState.encoding=this._readableState.decoder.encoding;for(var i=this._readableState.buffer.head,n="";null!==i;)n+=r.write(i.data),i=i.next;return this._readableState.buffer.clear(),""!==n&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var k=1073741824;function I(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=k?e=k:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function M(e){var t=e._readableState;c("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(c("emitReadable",t.flowing),t.emittedReadable=!0,r.nextTick(z,e))}function z(e){var t=e._readableState;c("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,O(e)}function P(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(D,e,t))}function D(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(c("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function L(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function B(e){c("readable nexttick read 0"),e.read(0)}function R(e,t){c("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),O(e),t.flowing&&!t.reading&&e.read(0)}function O(e){var t=e._readableState;for(c("flow",t.flowing);t.flowing&&null!==e.read(););}function F(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function N(e){var t=e._readableState;c("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,r.nextTick(j,t,e))}function j(e,t){if(c("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function U(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}S.prototype.read=function(e){c("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return c("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?N(this):M(this),null;if(0===(e=I(e,t))&&t.ended)return 0===t.length&&N(this),null;var i,n=t.needReadable;return c("need readable",n),(0===t.length||t.length-e<t.highWaterMark)&&c("length less than watermark",n=!0),t.ended||t.reading?c("reading or ended",n=!1):n&&(c("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=I(r,t))),null===(i=e>0?F(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&N(this)),null!==i&&this.emit("data",i),i},S.prototype._read=function(e){w(this,new x("_read()"))},S.prototype.pipe=function(e,t){var i=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,c("pipe count=%d opts=%j",n.pipesCount,t);var s=t&&!1===t.end||e===r.stdout||e===r.stderr?_:l;function a(t,r){c("onunpipe"),t===i&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,c("cleanup"),e.removeListener("close",f),e.removeListener("finish",m),e.removeListener("drain",u),e.removeListener("error",d),e.removeListener("unpipe",a),i.removeListener("end",l),i.removeListener("end",_),i.removeListener("data",p),h=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||u())}function l(){c("onend"),e.end()}n.endEmitted?r.nextTick(s):i.once("end",s),e.on("unpipe",a);var u=function(e){return function(){var t=e._readableState;c("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,O(e))}}(i);e.on("drain",u);var h=!1;function p(t){c("ondata");var r=e.write(t);c("dest.write",r),!1===r&&((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==U(n.pipes,e))&&!h&&(c("false write response, pause",n.awaitDrain),n.awaitDrain++),i.pause())}function d(t){c("onerror",t),_(),e.removeListener("error",d),0===o(e,"error")&&w(e,t)}function f(){e.removeListener("finish",m),_()}function m(){c("onfinish"),e.removeListener("close",f),_()}function _(){c("unpipe"),i.unpipe(e)}return i.on("data",p),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",f),e.once("finish",m),e.emit("pipe",i),n.flowing||(c("pipe resume"),i.resume()),e},S.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<n;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=U(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},S.prototype.on=function(e,t){var i=s.prototype.on.call(this,e,t),n=this._readableState;return"data"===e?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===e&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,c("on readable",n.length,n.reading),n.length?M(this):n.reading||r.nextTick(B,this))),i},S.prototype.addListener=S.prototype.on,S.prototype.removeListener=function(e,t){var i=s.prototype.removeListener.call(this,e,t);return"readable"===e&&r.nextTick(L,this),i},S.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||r.nextTick(L,this),t},S.prototype.resume=function(){var e=this._readableState;return e.flowing||(c("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,r.nextTick(R,e,t))}(this,e)),e.paused=!1,this},S.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},S.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;for(var n in e.on("end",(function(){if(c("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(n){c("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n||(r.objectMode||n&&n.length)&&(t.push(n)||(i=!0,e.pause()))})),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));for(var o=0;o<T.length;o++)e.on(T[o],this.emit.bind(this,T[o]));return this._read=function(t){c("wrapped _read",t),i&&(i=!1,e.resume())},this},"function"==typeof Symbol&&(S.prototype[Symbol.asyncIterator]=function(){return void 0===p&&(p=e("./internal/streams/async_iterator")),p(this)}),Object.defineProperty(S.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(S.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(S.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),S._fromList=F,Object.defineProperty(S.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(S.from=function(t,r){return void 0===d&&(d=e("./internal/streams/from")),d(S,t,r)})}).call(this)}).call(this,e("_process"),void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/async_iterator":61,"./internal/streams/buffer_list":62,"./internal/streams/destroy":63,"./internal/streams/from":65,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,events:22,inherits:24,"string_decoder/":75,util:16}],59:[function(e,t,r){"use strict";t.exports=u;var i=e("../errors").codes,n=i.ERR_METHOD_NOT_IMPLEMENTED,o=i.ERR_MULTIPLE_CALLBACK,s=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=i.ERR_TRANSFORM_WITH_LENGTH_0,l=e("./_stream_duplex");function c(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),i(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function u(e){if(!(this instanceof u))return new u(e);l.call(this,e),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",h)}function h(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?p(this,null,null):this._flush((function(t,r){p(e,t,r)}))}function p(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new a;if(e._transformState.transforming)throw new s;return e.push(null)}e("inherits")(u,l),u.prototype.push=function(e,t){return this._transformState.needTransform=!1,l.prototype.push.call(this,e,t)},u.prototype._transform=function(e,t,r){r(new n("_transform()"))},u.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},u.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},u.prototype._destroy=function(e,t){l.prototype._destroy.call(this,e,(function(e){t(e)}))}},{"../errors":55,"./_stream_duplex":56,inherits:24}],60:[function(e,t,i){(function(r,i){(function(){"use strict";function n(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var i=e.entry;for(e.entry=null;i;){var n=i.callback;t.pendingcb--,n(r),i=i.next}t.corkedRequestsFree.next=e}(t,e)}}var o;t.exports=S,S.WritableState=E;var s={deprecate:e("util-deprecate")},a=e("./internal/streams/stream"),l=e("buffer").Buffer,c=i.Uint8Array||function(){};var u,h=e("./internal/streams/destroy"),p=e("./internal/streams/state").getHighWaterMark,d=e("../errors").codes,f=d.ERR_INVALID_ARG_TYPE,m=d.ERR_METHOD_NOT_IMPLEMENTED,_=d.ERR_MULTIPLE_CALLBACK,g=d.ERR_STREAM_CANNOT_PIPE,y=d.ERR_STREAM_DESTROYED,v=d.ERR_STREAM_NULL_VALUES,x=d.ERR_STREAM_WRITE_AFTER_END,b=d.ERR_UNKNOWN_ENCODING,w=h.errorOrDestroy;function T(){}function E(t,i,s){o=o||e("./_stream_duplex"),t=t||{},"boolean"!=typeof s&&(s=i instanceof o),this.objectMode=!!t.objectMode,s&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=p(this,t,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var i=e._writableState,n=i.sync,o=i.writecb;if("function"!=typeof o)throw new _;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(i),t)!function(e,t,i,n,o){--t.pendingcb,i?(r.nextTick(o,n),r.nextTick(P,e,t),e._writableState.errorEmitted=!0,w(e,n)):(o(n),e._writableState.errorEmitted=!0,w(e,n),P(e,t))}(e,i,n,t,o);else{var s=M(i)||e.destroyed;s||i.corked||i.bufferProcessing||!i.bufferedRequest||I(e,i),n?r.nextTick(k,e,i,s,o):k(e,i,s,o)}}(i,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}function S(t){var r=this instanceof(o=o||e("./_stream_duplex"));if(!r&&!u.call(S,this))return new S(t);this._writableState=new E(t,this,r),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function C(e,t,r,i,n,o){if(!r){var s=function(e,t,r){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=l.from(t,r)),t}(t,i,n);i!==s&&(r=!0,n="buffer",i=s)}var a=t.objectMode?1:i.length;t.length+=a;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:o,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else A(e,t,!1,a,i,n,o);return c}function A(e,t,r,i,n,o,s){t.writelen=i,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new y("write")):r?e._writev(n,t.onwrite):e._write(n,o,t.onwrite),t.sync=!1}function k(e,t,r,i){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,i(),P(e,t)}function I(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,o=new Array(i),s=t.corkedRequestsFree;s.entry=r;for(var a=0,l=!0;r;)o[a]=r,r.isBuf||(l=!1),r=r.next,a+=1;o.allBuffers=l,A(e,t,!0,t.length,o,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new n(t),t.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,u=r.encoding,h=r.callback;if(A(e,t,!1,t.objectMode?1:c.length,c,u,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function M(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function z(e,t){e._final((function(r){t.pendingcb--,r&&w(e,r),t.prefinished=!0,e.emit("prefinish"),P(e,t)}))}function P(e,t){var i=M(t);if(i&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,r.nextTick(z,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return i}e("inherits")(S,a),E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(E.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(u=Function.prototype[Symbol.hasInstance],Object.defineProperty(S,Symbol.hasInstance,{value:function(e){return!!u.call(this,e)||this===S&&e&&e._writableState instanceof E}})):u=function(e){return e instanceof this},S.prototype.pipe=function(){w(this,new g)},S.prototype.write=function(e,t,i){var n,o=this._writableState,s=!1,a=!o.objectMode&&(n=e,l.isBuffer(n)||n instanceof c);return a&&!l.isBuffer(e)&&(e=function(e){return l.from(e)}(e)),"function"==typeof t&&(i=t,t=null),a?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof i&&(i=T),o.ending?function(e,t){var i=new x;w(e,i),r.nextTick(t,i)}(this,i):(a||function(e,t,i,n){var o;return null===i?o=new v:"string"==typeof i||t.objectMode||(o=new f("chunk",["string","Buffer"],i)),!o||(w(e,o),r.nextTick(n,o),!1)}(this,o,e,i))&&(o.pendingcb++,s=C(this,o,a,e,t,i)),s},S.prototype.cork=function(){this._writableState.corked++},S.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||I(this,e))},S.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new b(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(S.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(S.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),S.prototype._write=function(e,t,r){r(new m("_write()"))},S.prototype._writev=null,S.prototype.end=function(e,t,i){var n=this._writableState;return"function"==typeof e?(i=e,e=null,t=null):"function"==typeof t&&(i=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||function(e,t,i){t.ending=!0,P(e,t),i&&(t.finished?r.nextTick(i):e.once("finish",i)),t.ended=!0,e.writable=!1}(this,n,i),this},Object.defineProperty(S.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(S.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),S.prototype.destroy=h.destroy,S.prototype._undestroy=h.undestroy,S.prototype._destroy=function(e,t){t(e)}}).call(this)}).call(this,e("_process"),void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../errors":55,"./_stream_duplex":56,"./internal/streams/destroy":63,"./internal/streams/state":67,"./internal/streams/stream":68,_process:50,buffer:17,inherits:24,"util-deprecate":78}],61:[function(e,t,r){(function(r){(function(){"use strict";var i;function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=e("./end-of-stream"),s=Symbol("lastResolve"),a=Symbol("lastReject"),l=Symbol("error"),c=Symbol("ended"),u=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(e,t){return{value:e,done:t}}function f(e){var t=e[s];if(null!==t){var r=e[p].read();null!==r&&(e[u]=null,e[s]=null,e[a]=null,t(d(r,!1)))}}function m(e){r.nextTick(f,e)}var _=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((n(i={get stream(){return this[p]},next:function(){var e=this,t=this[l];if(null!==t)return Promise.reject(t);if(this[c])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise((function(t,i){r.nextTick((function(){e[l]?i(e[l]):t(d(void 0,!0))}))}));var i,n=this[u];if(n)i=new Promise(function(e,t){return function(r,i){e.then((function(){t[c]?r(d(void 0,!0)):t[h](r,i)}),i)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));i=new Promise(this[h])}return this[u]=i,i}},Symbol.asyncIterator,(function(){return this})),n(i,"return",(function(){var e=this;return new Promise((function(t,r){e[p].destroy(null,(function(e){e?r(e):t(d(void 0,!0))}))}))})),i),_);t.exports=function(e){var t,r=Object.create(g,(n(t={},p,{value:e,writable:!0}),n(t,s,{value:null,writable:!0}),n(t,a,{value:null,writable:!0}),n(t,l,{value:null,writable:!0}),n(t,c,{value:e._readableState.endEmitted,writable:!0}),n(t,h,{value:function(e,t){var i=r[p].read();i?(r[u]=null,r[s]=null,r[a]=null,e(d(i,!1))):(r[s]=e,r[a]=t)},writable:!0}),t));return r[u]=null,o(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[a];return null!==t&&(r[u]=null,r[s]=null,r[a]=null,t(e)),void(r[l]=e)}var i=r[s];null!==i&&(r[u]=null,r[s]=null,r[a]=null,i(d(void 0,!0))),r[c]=!0})),e.on("readable",m.bind(null,r)),r}}).call(this)}).call(this,e("_process"))},{"./end-of-stream":64,_process:50}],62:[function(e,t,r){"use strict";function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var s=e("buffer").Buffer,a=e("util").inspect,l=a&&a.custom||"inspect";t.exports=function(){function e(){(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this.head=null,this.tail=null,this.length=0}return t=e,r=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return s.alloc(0);for(var t=s.allocUnsafe(e>>>0),r=this.head,i=0;r;)n=r.data,o=t,a=i,s.prototype.copy.call(n,o,a),i+=r.data.length,r=r.next;var n,o,a;return t}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,i=t.data;for(e-=i.length;t=t.next;){var n=t.data,o=e>n.length?n.length:e;if(o===n.length?i+=n:i+=n.slice(0,e),0==(e-=o)){o===n.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=n.slice(o));break}++r}return this.length-=r,i}},{key:"_getBuffer",value:function(e){var t=s.allocUnsafe(e),r=this.head,i=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var n=r.data,o=e>n.length?n.length:e;if(n.copy(t,t.length-e,0,o),0==(e-=o)){o===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(o));break}++i}return this.length-=i,t}},{key:l,value:function(e,t){return a(this,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},t,{depth:0,customInspect:!1}))}}],r&&o(t.prototype,r),c&&o(t,c),e;var t,r,c}()},{buffer:17,util:16}],63:[function(e,t,r){(function(e){(function(){"use strict";function r(e,t){n(e,t),i(e)}function i(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function n(e,t){e.emit("error",t)}t.exports={destroy:function(t,o){var s=this,a=this._readableState&&this._readableState.destroyed,l=this._writableState&&this._writableState.destroyed;return a||l?(o?o(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e.nextTick(n,this,t)):e.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!o&&t?s._writableState?s._writableState.errorEmitted?e.nextTick(i,s):(s._writableState.errorEmitted=!0,e.nextTick(r,s,t)):e.nextTick(r,s,t):o?(e.nextTick(i,s),o(t)):e.nextTick(i,s)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}}}).call(this)}).call(this,e("_process"))},{_process:50}],64:[function(e,t,r){"use strict";var i=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function n(){}t.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];e.apply(this,i)}}}(o||n);var s=r.readable||!1!==r.readable&&t.readable,a=r.writable||!1!==r.writable&&t.writable,l=function(){t.writable||u()},c=t._writableState&&t._writableState.finished,u=function(){a=!1,c=!0,s||o.call(t)},h=t._readableState&&t._readableState.endEmitted,p=function(){s=!1,h=!0,a||o.call(t)},d=function(e){o.call(t,e)},f=function(){var e;return s&&!h?(t._readableState&&t._readableState.ended||(e=new i),o.call(t,e)):a&&!c?(t._writableState&&t._writableState.ended||(e=new i),o.call(t,e)):void 0},m=function(){t.req.on("finish",u)};return function(e){return e.setHeader&&"function"==typeof e.abort}(t)?(t.on("complete",u),t.on("abort",f),t.req?m():t.on("request",m)):a&&!t._writableState&&(t.on("end",l),t.on("close",l)),t.on("end",p),t.on("finish",u),!1!==r.error&&t.on("error",d),t.on("close",f),function(){t.removeListener("complete",u),t.removeListener("abort",f),t.removeListener("request",m),t.req&&t.req.removeListener("finish",u),t.removeListener("end",l),t.removeListener("close",l),t.removeListener("finish",u),t.removeListener("end",p),t.removeListener("error",d),t.removeListener("close",f)}}},{"../../../errors":55}],65:[function(e,t,r){t.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],66:[function(e,t,r){"use strict";var i;var n=e("../../../errors").codes,o=n.ERR_MISSING_ARGS,s=n.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function l(t,r,n,o){o=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(o);var a=!1;t.on("close",(function(){a=!0})),void 0===i&&(i=e("./end-of-stream")),i(t,{readable:r,writable:n},(function(e){if(e)return o(e);a=!0,o()}));var l=!1;return function(e){if(!a&&!l)return l=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new s("pipe"))}}function c(e){e()}function u(e,t){return e.pipe(t)}function h(e){return e.length?"function"!=typeof e[e.length-1]?a:e.pop():a}t.exports=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var i,n=h(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new o("streams");var s=t.map((function(e,r){var o=r<t.length-1;return l(e,o,r>0,(function(e){i||(i=e),e&&s.forEach(c),o||(s.forEach(c),n(i))}))}));return t.reduce(u)}},{"../../../errors":55,"./end-of-stream":64}],67:[function(e,t,r){"use strict";var i=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(e,t,r,n){var o=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,n,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new i(n?r:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}},{"../../../errors":55}],68:[function(e,t,r){t.exports=e("events").EventEmitter},{events:22}],69:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js"),r.finished=e("./lib/internal/streams/end-of-stream.js"),r.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":56,"./lib/_stream_passthrough.js":57,"./lib/_stream_readable.js":58,"./lib/_stream_transform.js":59,"./lib/_stream_writable.js":60,"./lib/internal/streams/end-of-stream.js":64,"./lib/internal/streams/pipeline.js":66}],70:[function(e,t,r){"use strict";function i(e,t,r){var i=this;this._callback=e,this._args=r,this._interval=setInterval(e,t,this._args),this.reschedule=function(e){e||(e=i._interval),i._interval&&clearInterval(i._interval),i._interval=setInterval(i._callback,e,i._args)},this.clear=function(){i._interval&&(clearInterval(i._interval),i._interval=void 0)},this.destroy=function(){i._interval&&clearInterval(i._interval),i._callback=void 0,i._interval=void 0,i._args=void 0}}t.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("interval needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t<e.length;t++)e[t]=arguments[t+2]}return new i(arguments[0],arguments[1],e)}},{}],71:[function(e,t,r){"use strict";t.exports=e("./index.js")()},{"./index.js":72}],72:[function(e,t,r){(function(e){(function(){"use strict";function r(t){return t instanceof e?e.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}t.exports=function(e){return(e=e||{}).circles?function(e){var t=[],i=[];return e.proto?s:o;function n(e,n){for(var o=Object.keys(e),s=new Array(o.length),a=0;a<o.length;a++){var l=o[a],c=e[l];if("object"!=typeof c||null===c)s[l]=c;else if(c instanceof Date)s[l]=new Date(c);else if(ArrayBuffer.isView(c))s[l]=r(c);else{var u=t.indexOf(c);s[l]=-1!==u?i[u]:n(c)}}return s}function o(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return n(e,o);if(e instanceof Map)return new Map(n(Array.from(e),o));if(e instanceof Set)return new Set(n(Array.from(e),o));var s={};for(var a in t.push(e),i.push(s),e)if(!1!==Object.hasOwnProperty.call(e,a)){var l=e[a];if("object"!=typeof l||null===l)s[a]=l;else if(l instanceof Date)s[a]=new Date(l);else if(l instanceof Map)s[a]=new Map(n(Array.from(l),o));else if(l instanceof Set)s[a]=new Set(n(Array.from(l),o));else if(ArrayBuffer.isView(l))s[a]=r(l);else{var c=t.indexOf(l);s[a]=-1!==c?i[c]:o(l)}}return t.pop(),i.pop(),s}function s(e){if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return n(e,s);if(e instanceof Map)return new Map(n(Array.from(e),s));if(e instanceof Set)return new Set(n(Array.from(e),s));var o={};for(var a in t.push(e),i.push(o),e){var l=e[a];if("object"!=typeof l||null===l)o[a]=l;else if(l instanceof Date)o[a]=new Date(l);else if(l instanceof Map)o[a]=new Map(n(Array.from(l),s));else if(l instanceof Set)o[a]=new Set(n(Array.from(l),s));else if(ArrayBuffer.isView(l))o[a]=r(l);else{var c=t.indexOf(l);o[a]=-1!==c?i[c]:s(l)}}return t.pop(),i.pop(),o}}(e):e.proto?function e(i){if("object"!=typeof i||null===i)return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return t(i,e);if(i instanceof Map)return new Map(t(Array.from(i),e));if(i instanceof Set)return new Set(t(Array.from(i),e));var n={};for(var o in i){var s=i[o];"object"!=typeof s||null===s?n[o]=s:s instanceof Date?n[o]=new Date(s):s instanceof Map?n[o]=new Map(t(Array.from(s),e)):s instanceof Set?n[o]=new Set(t(Array.from(s),e)):ArrayBuffer.isView(s)?n[o]=r(s):n[o]=e(s)}return n}:function e(i){if("object"!=typeof i||null===i)return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return t(i,e);if(i instanceof Map)return new Map(t(Array.from(i),e));if(i instanceof Set)return new Set(t(Array.from(i),e));var n={};for(var o in i)if(!1!==Object.hasOwnProperty.call(i,o)){var s=i[o];"object"!=typeof s||null===s?n[o]=s:s instanceof Date?n[o]=new Date(s):s instanceof Map?n[o]=new Map(t(Array.from(s),e)):s instanceof Set?n[o]=new Set(t(Array.from(s),e)):ArrayBuffer.isView(s)?n[o]=r(s):n[o]=e(s)}return n};function t(e,t){for(var i=Object.keys(e),n=new Array(i.length),o=0;o<i.length;o++){var s=i[o],a=e[s];"object"!=typeof a||null===a?n[s]=a:a instanceof Date?n[s]=new Date(a):ArrayBuffer.isView(a)?n[s]=r(a):n[s]=t(a)}return n}}}).call(this)}).call(this,e("buffer").Buffer)},{buffer:17}],73:[function(e,t,r){var i=e("buffer"),n=i.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(o(i,r),r.Buffer=s),s.prototype=Object.create(n.prototype),o(n,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},{buffer:17}],74:[function(e,t,r){t.exports=function(e){var t,r=e._readableState;return r?r.objectMode||"number"==typeof e._duplexState?e.read():e.read((t=r).buffer.length?t.buffer.head?t.buffer.head.data.length:t.buffer[0].length:t.length):null}},{}],75:[function(e,t,r){"use strict";var i=e("safe-buffer").Buffer,n=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=c,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=u,this.end=h,t=3;break;default:return this.write=p,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"<22>";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"<22>";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"<22>"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function c(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function u(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function d(e){return e&&e.length?this.write(e):""}r.StringDecoder=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},o.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"<22>":t},o.prototype.text=function(e,t){var r=function(e,t,r){var i=t.length-1;if(i<r)return 0;var n=s(t[i]);return n>=0?(n>0&&(e.lastNeed=n-1),n):--i<r||-2===n?0:(n=s(t[i]))>=0?(n>0&&(e.lastNeed=n-2),n):--i<r||-2===n?0:(n=s(t[i]))>=0?(n>0&&(2===n?n=0:e.lastNeed=n-3),n):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":73}],76:[function(e,t,r){"use strict";var i=e("punycode"),n=e("./util");function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}r.parse=v,r.resolve=function(e,t){return v(e,!1,!0).resolve(t)},r.resolveObject=function(e,t){return e?v(e,!1,!0).resolveObject(t):t},r.format=function(e){return n.isString(e)&&(e=v(e)),e instanceof o?e.format():o.prototype.format.call(e)},r.Url=o;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,c=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(c),h=["%","/","?",";","#"].concat(u),p=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},_={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=e("querystring");function v(e,t,r){if(e&&n.isObject(e)&&e instanceof o)return e;var i=new o;return i.parse(e,t,r),i}o.prototype.parse=function(e,t,r){if(!n.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var o=e.indexOf("?"),a=-1!==o&&o<e.indexOf("#")?"?":"#",c=e.split(a);c[0]=c[0].replace(/\\/g,"/");var v=e=c.join(a);if(v=v.trim(),!r&&1===e.split("#").length){var x=l.exec(v);if(x)return this.path=v,this.href=v,this.pathname=x[1],x[2]?(this.search=x[2],this.query=t?y.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var b=s.exec(v);if(b){var w=(b=b[0]).toLowerCase();this.protocol=w,v=v.substr(b.length)}if(r||b||v.match(/^\/\/[^@\/]+@[^@\/]+/)){var T="//"===v.substr(0,2);!T||b&&_[b]||(v=v.substr(2),this.slashes=!0)}if(!_[b]&&(T||b&&!g[b])){for(var E,S,C=-1,A=0;A<p.length;A++)-1!==(k=v.indexOf(p[A]))&&(-1===C||k<C)&&(C=k);for(-1!==(S=-1===C?v.lastIndexOf("@"):v.lastIndexOf("@",C))&&(E=v.slice(0,S),v=v.slice(S+1),this.auth=decodeURIComponent(E)),C=-1,A=0;A<h.length;A++){var k;-1!==(k=v.indexOf(h[A]))&&(-1===C||k<C)&&(C=k)}-1===C&&(C=v.length),this.host=v.slice(0,C),v=v.slice(C),this.parseHost(),this.hostname=this.hostname||"";var I="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!I)for(var M=this.hostname.split(/\./),z=(A=0,M.length);A<z;A++){var P=M[A];if(P&&!P.match(d)){for(var D="",L=0,B=P.length;L<B;L++)P.charCodeAt(L)>127?D+="x":D+=P[L];if(!D.match(d)){var R=M.slice(0,A),O=M.slice(A+1),F=P.match(f);F&&(R.push(F[1]),O.unshift(F[2])),O.length&&(v="/"+O.join(".")+v),this.hostname=R.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),I||(this.hostname=i.toASCII(this.hostname));var N=this.port?":"+this.port:"",j=this.hostname||"";this.host=j+N,this.href+=this.host,I&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!m[w])for(A=0,z=u.length;A<z;A++){var U=u[A];if(-1!==v.indexOf(U)){var V=encodeURIComponent(U);V===U&&(V=escape(U)),v=v.split(U).join(V)}}var q=v.indexOf("#");-1!==q&&(this.hash=v.substr(q),v=v.slice(0,q));var G=v.indexOf("?");if(-1!==G?(this.search=v.substr(G),this.query=v.substr(G+1),t&&(this.query=y.parse(this.query)),v=v.slice(0,G)):t&&(this.search="",this.query={}),v&&(this.pathname=v),g[w]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){N=this.pathname||"";var $=this.search||"";this.path=N+$}return this.href=this.format(),this},o.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":"),e+="@");var t=this.protocol||"",r=this.pathname||"",i=this.hash||"",o=!1,s="";this.host?o=e+this.host:this.hostname&&(o=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&n.isObject(this.query)&&Object.keys(this.query).length&&(s=y.stringify(this.query));var a=this.search||s&&"?"+s||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||g[t])&&!1!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),i&&"#"!==i.charAt(0)&&(i="#"+i),a&&"?"!==a.charAt(0)&&(a="?"+a),t+o+(r=r.replace(/[?#]/g,(function(e){return encodeURIComponent(e)})))+(a=a.replace("#","%23"))+i},o.prototype.resolve=function(e){return this.resolveObject(v(e,!1,!0)).format()},o.prototype.resolveObject=function(e){if(n.isString(e)){var t=new o;t.parse(e,!1,!0),e=t}for(var r=new o,i=Object.keys(this),s=0;s<i.length;s++){var a=i[s];r[a]=this[a]}if(r.hash=e.hash,""===e.href)return r.href=r.format(),r;if(e.slashes&&!e.protocol){for(var l=Object.keys(e),c=0;c<l.length;c++){var u=l[c];"protocol"!==u&&(r[u]=e[u])}return g[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(e.protocol&&e.protocol!==r.protocol){if(!g[e.protocol]){for(var h=Object.keys(e),p=0;p<h.length;p++){var d=h[p];r[d]=e[d]}return r.href=r.format(),r}if(r.protocol=e.protocol,e.host||_[e.protocol])r.pathname=e.pathname;else{for(var f=(e.pathname||"").split("/");f.length&&!(e.host=f.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==f[0]&&f.unshift(""),f.length<2&&f.unshift(""),r.pathname=f.join("/")}if(r.search=e.search,r.query=e.query,r.host=e.host||"",r.auth=e.auth,r.hostname=e.hostname||e.host,r.port=e.port,r.pathname||r.search){var m=r.pathname||"",y=r.search||"";r.path=m+y}return r.slashes=r.slashes||e.slashes,r.href=r.format(),r}var v=r.pathname&&"/"===r.pathname.charAt(0),x=e.host||e.pathname&&"/"===e.pathname.charAt(0),b=x||v||r.host&&e.pathname,w=b,T=r.pathname&&r.pathname.split("/")||[],E=(f=e.pathname&&e.pathname.split("/")||[],r.protocol&&!g[r.protocol]);if(E&&(r.hostname="",r.port=null,r.host&&(""===T[0]?T[0]=r.host:T.unshift(r.host)),r.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===f[0]?f[0]=e.host:f.unshift(e.host)),e.host=null),b=b&&(""===f[0]||""===T[0])),x)r.host=e.host||""===e.host?e.host:r.host,r.hostname=e.hostname||""===e.hostname?e.hostname:r.hostname,r.search=e.search,r.query=e.query,T=f;else if(f.length)T||(T=[]),T.pop(),T=T.concat(f),r.search=e.search,r.query=e.query;else if(!n.isNullOrUndefined(e.search))return E&&(r.hostname=r.host=T.shift(),(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift())),r.search=e.search,r.query=e.query,n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!T.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var S=T.slice(-1)[0],C=(r.host||e.host||T.length>1)&&("."===S||".."===S)||""===S,A=0,k=T.length;k>=0;k--)"."===(S=T[k])?T.splice(k,1):".."===S?(T.splice(k,1),A++):A&&(T.splice(k,1),A--);if(!b&&!w)for(;A--;A)T.unshift("..");!b||""===T[0]||T[0]&&"/"===T[0].charAt(0)||T.unshift(""),C&&"/"!==T.join("/").substr(-1)&&T.push("");var I,M=""===T[0]||T[0]&&"/"===T[0].charAt(0);return E&&(r.hostname=r.host=M?"":T.length?T.shift():"",(I=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=I.shift(),r.host=r.hostname=I.shift())),(b=b||r.host&&T.length)&&!M&&T.unshift(""),T.length?r.pathname=T.join("/"):(r.pathname=null,r.path=null),n.isNull(r.pathname)&&n.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var e=this.host,t=a.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":77,punycode:51,querystring:54}],77:[function(e,t,r){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],78:[function(e,t,i){(function(e){(function(){function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}t.exports=function(e,t){if(r("noDeprecation"))return e;var i=!1;return function(){if(!i){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),i=!0}return e.apply(this,arguments)}}}).call(this)}).call(this,void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],79:[function(e,t,r){t.exports=function e(t,r){if(t&&r)return e(t)(r);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){i[e]=t[e]})),i;function i(){for(var e=new Array(arguments.length),r=0;r<e.length;r++)e[r]=arguments[r];var i=t.apply(this,e),n=e[e.length-1];return"function"==typeof i&&i!==n&&Object.keys(n).forEach((function(e){i[e]=n[e]})),i}}},{}],80:[function(e,t,r){"use strict";t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},{}],81:[function(e,t,r){t.exports=function(){for(var e={},t=0;t<arguments.length;t++){var r=arguments[t];for(var n in r)i.call(r,n)&&(e[n]=r[n])}return e};var i=Object.prototype.hasOwnProperty},{}],82:[function(e,t,r){"use strict";t.exports=function(e){e.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}},{}],83:[function(e,t,r){"use strict";function i(e){var t=this;if(t instanceof i||(t=new i),t.tail=null,t.head=null,t.length=0,e&&"function"==typeof e.forEach)e.forEach((function(e){t.push(e)}));else if(arguments.length>0)for(var r=0,n=arguments.length;r<n;r++)t.push(arguments[r]);return t}function n(e,t,r){var i=t===e.head?new a(r,null,t,e):new a(r,t,t.next,e);return null===i.next&&(e.tail=i),null===i.prev&&(e.head=i),e.length++,i}function o(e,t){e.tail=new a(t,e.tail,null,e),e.head||(e.head=e.tail),e.length++}function s(e,t){e.head=new a(t,null,e.head,e),e.tail||(e.tail=e.head),e.length++}function a(e,t,r,i){if(!(this instanceof a))return new a(e,t,r,i);this.list=i,this.value=e,t?(t.next=this,this.prev=t):this.prev=null,r?(r.prev=this,this.next=r):this.next=null}t.exports=i,i.Node=a,i.create=i,i.prototype.removeNode=function(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");var t=e.next,r=e.prev;return t&&(t.prev=r),r&&(r.next=t),e===this.head&&(this.head=t),e===this.tail&&(this.tail=r),e.list.length--,e.next=null,e.prev=null,e.list=null,t},i.prototype.unshiftNode=function(e){if(e!==this.head){e.list&&e.list.removeNode(e);var t=this.head;e.list=this,e.next=t,t&&(t.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}},i.prototype.pushNode=function(e){if(e!==this.tail){e.list&&e.list.removeNode(e);var t=this.tail;e.list=this,e.prev=t,t&&(t.next=e),this.tail=e,this.head||(this.head=e),this.length++}},i.prototype.push=function(){for(var e=0,t=arguments.length;e<t;e++)o(this,arguments[e]);return this.length},i.prototype.unshift=function(){for(var e=0,t=arguments.length;e<t;e++)s(this,arguments[e]);return this.length},i.prototype.pop=function(){if(this.tail){var e=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,e}},i.prototype.shift=function(){if(this.head){var e=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,e}},i.prototype.forEach=function(e,t){t=t||this;for(var r=this.head,i=0;null!==r;i++)e.call(t,r.value,i,this),r=r.next},i.prototype.forEachReverse=function(e,t){t=t||this;for(var r=this.tail,i=this.length-1;null!==r;i--)e.call(t,r.value,i,this),r=r.prev},i.prototype.get=function(e){for(var t=0,r=this.head;null!==r&&t<e;t++)r=r.next;if(t===e&&null!==r)return r.value},i.prototype.getReverse=function(e){for(var t=0,r=this.tail;null!==r&&t<e;t++)r=r.prev;if(t===e&&null!==r)return r.value},i.prototype.map=function(e,t){t=t||this;for(var r=new i,n=this.head;null!==n;)r.push(e.call(t,n.value,this)),n=n.next;return r},i.prototype.mapReverse=function(e,t){t=t||this;for(var r=new i,n=this.tail;null!==n;)r.push(e.call(t,n.value,this)),n=n.prev;return r},i.prototype.reduce=function(e,t){var r,i=this.head;if(arguments.length>1)r=t;else{if(!this.head)throw new TypeError("Reduce of empty list with no initial value");i=this.head.next,r=this.head.value}for(var n=0;null!==i;n++)r=e(r,i.value,n),i=i.next;return r},i.prototype.reduceReverse=function(e,t){var r,i=this.tail;if(arguments.length>1)r=t;else{if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");i=this.tail.prev,r=this.tail.value}for(var n=this.length-1;null!==i;n--)r=e(r,i.value,n),i=i.prev;return r},i.prototype.toArray=function(){for(var e=new Array(this.length),t=0,r=this.head;null!==r;t++)e[t]=r.value,r=r.next;return e},i.prototype.toArrayReverse=function(){for(var e=new Array(this.length),t=0,r=this.tail;null!==r;t++)e[t]=r.value,r=r.prev;return e},i.prototype.slice=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new i;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=0,o=this.head;null!==o&&n<e;n++)o=o.next;for(;null!==o&&n<t;n++,o=o.next)r.push(o.value);return r},i.prototype.sliceReverse=function(e,t){(t=t||this.length)<0&&(t+=this.length),(e=e||0)<0&&(e+=this.length);var r=new i;if(t<e||t<0)return r;e<0&&(e=0),t>this.length&&(t=this.length);for(var n=this.length,o=this.tail;null!==o&&n>t;n--)o=o.prev;for(;null!==o&&n>e;n--,o=o.prev)r.push(o.value);return r},i.prototype.splice=function(e,t,...r){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);for(var i=0,o=this.head;null!==o&&i<e;i++)o=o.next;var s=[];for(i=0;o&&i<t;i++)s.push(o.value),o=this.removeNode(o);for(null===o&&(o=this.tail),o!==this.head&&o!==this.tail&&(o=o.prev),i=0;i<r.length;i++)o=n(this,o,r[i]);return s},i.prototype.reverse=function(){for(var e=this.head,t=this.tail,r=e;null!==r;r=r.prev){var i=r.prev;r.prev=r.next,r.next=i}return this.head=t,this.tail=e,this};try{e("./iterator.js")(i)}catch(e){}},{"./iterator.js":82}]},{},[12])(12)},689:e=>{!function(){"use strict";function t(e){return function(t){for(var r=[],i=1;""!==t;){var n=function(e,t){for(var r=!1,i=0;i<e.length;i++)if(r=t(e[i]))return r;return r}(e,(function(e){var r=e.re.exec(t);if(r){var n=r[0];return t=t.slice(n.length),{raw:n,matched:e.f(r,i)}}}));if(!n){var o=new SyntaxError("Unexpected character: "+t[0]+"; input: "+t.substr(0,100));throw o.line=i,o}n.matched.line=i,i+=n.raw.replace(/[^\n]/g,"").length,r.push(n.matched)}return r}}function r(e){var t=e[1].replace(/([^'\\]|\\['bnrtf\\]|\\u[0-9a-fA-F]{4})/g,(function(e){return'"'===e?'\\"':"\\'"===e?"'":e}));return{type:"string",match:'"'+t+'"',value:JSON.parse('"'+t+'"')}}function i(e){return{type:"string",match:e[0],value:JSON.parse(e[0])}}function n(e){return{type:"string",value:e[0],match:'"'+e[0].replace(/./g,(function(e){return"\\"===e?"\\\\":e}))+'"'}}function o(e){return{type:" ",match:e[0].replace(/./g,(function(e){return/\s/.test(e)?e:" "}))}}function s(e){return{type:"number",match:e[0],value:parseFloat(e[0])}}function a(e){var t;switch(e[1]){case"null":t=null;break;case"true":t=!0;break;case"false":t=!1}return{type:"atom",match:e[0],value:t}}function l(e){function t(e){return function(t){return{type:e,match:t[0]}}}var l=[{re:/^\s+/,f:t(" ")},{re:/^\{/,f:t("{")},{re:/^\}/,f:t("}")},{re:/^\[/,f:t("[")},{re:/^\]/,f:t("]")},{re:/^,/,f:t(",")},{re:/^:/,f:t(":")},{re:/^(true|false|null)/,f:a},{re:/^\-?\d+(\.\d+)?([eE][+-]?\d+)?/,f:s},{re:/^"([^"\\]|\\["bnrtf\\\/]|\\u[0-9a-fA-F]{4})*"/,f:i}];return e&&(l=l.concat([{re:/^'(([^'\\]|\\['bnrtf\\\/]|\\u[0-9a-fA-F]{4})*)'/,f:r},{re:/^\/\/.*?(?:\r\n|\r|\n)/,f:o},{re:/^\/\*[\s\S]*?\*\//,f:o},{re:/^[$a-zA-Z0-9_\-+\.\*\?!\|&%\^\/#\\]+/,f:n}])),l}var c=t(l(!0)),u=t(l(!1));function h(e,t){for(;t>=0;t--)if(" "!==e[t].type)return t}function p(e){var t=[];return e.forEach((function(r,i){if("]"===r.type||"}"===r.type){var n=h(t,i-1);if(n&&","===t[n].type){var o=h(t,n-1);o&&"["!==t[o].type&&"{"!==t[o].type&&(t[n]={type:" ",match:" ",line:e[n].line})}}t.push(r)})),t}function d(e){var t=c(e);return(t=p(t)).reduce((function(e,t){return e+t.match}),"")}function f(e,t){var r=e[t.pos];return t.pos+=1,r||{type:"eof",line:0!==e.length?e[e.length-1].line:1}}function m(e){switch(e.type){case"atom":case"string":case"number":return e.type+" "+e.match;case"eof":return"end-of-file";default:return"'"+e.type+"'"}}function _(e,t,r){for(var i=[",",":","]","}"],n=f(e,t);;){if(r&&-1!==r.indexOf(n.type))return n;if("eof"===n.type)return n;if(-1===i.indexOf(n.type))return n;var o="Unexpected token: "+m(n)+", expected '[', '{', number, string or atom";if(!t.tolerant){var s=new SyntaxError(o);throw s.line=n.line,s}t.warnings.push({message:o,line:n.line}),n=f(e,t)}}function g(e,t,r){if(!e.tolerant){var i=new SyntaxError(r);throw i.line=t.line,i}e.warnings.push({message:r,line:t.line})}function y(e,t,r){g(e,t,"Unexpected token: "+m(t)+", expected "+r)}function v(e,t,r,i){void 0!==(i=e.reviver?e.reviver(r,i):i)&&(t[r]=i)}function x(e,t,r){var i,n=_(e,t,[":"]);if("string"!==n.type)switch(y(t,n,"string"),n.type){case":":n={type:"string",value:"null",line:n.line},t.pos-=1;break;case"number":case"atom":n={type:"string",value:""+n.value,line:n.line};break;case"[":case"{":return t.pos-=1,void v(t,r,"null",T(e,t))}!function(e,t,r){var i=r.value;e.duplicate&&Object.prototype.hasOwnProperty.call(t,i)&&g(e,r,"Duplicate key: "+i)}(t,r,n),i=n.value,function(e,t){var r=f(e,t);if(":"!==r.type){var i="Unexpected token: "+m(r)+", expected ':'";if(!t.tolerant){var n=new SyntaxError(i);throw n.line=r.line,n}t.warnings.push({message:i,line:r.line}),t.pos-=1}}(e,t),v(t,r,i,T(e,t))}function b(e,t,r){var i=r.length,n=T(e,t);r[i]=t.reviver?t.reviver(""+i,n):n}function w(e,t,r,i){var n=_(e,t,i.skip);if("eof"===n.type&&(y(t,n,"'"+i.endSymbol+"' or "+i.elementName),n={type:i.endSymbol,line:n.line}),n.type===i.endSymbol)return r;for(t.pos-=1,i.elementParser(e,t,r);;)switch((n=f(e,t)).type!==i.endSymbol&&","!==n.type&&(y(t,n,"',' or '"+i.endSymbol+"'"),n={type:"eof"===n.type?i.endSymbol:",",line:n.line},t.pos-=1),n.type){case i.endSymbol:return r;case",":i.elementParser(e,t,r)}}function T(e,t,r){var i,n=_(e,t);switch("eof"===n.type&&y(t,n,"json object"),n.type){case"{":i=function(e,t){return w(e,t,{},{skip:[":","}"],elementParser:x,elementName:"string",endSymbol:"}"})}(e,t);break;case"[":i=function(e,t){return w(e,t,[],{skip:["]"],elementParser:b,elementName:"json object",endSymbol:"]"})}(e,t);break;case"string":case"number":case"atom":i=n.value}return r&&(i=t.reviver?t.reviver("",i):i,function(e,t,r){if(t.pos<e.length&&g(t,e[t.pos],"Unexpected token: "+m(e[t.pos])+", expected end-of-input"),t.tolerant&&0!==t.warnings.length){var i=1===t.warnings.length?t.warnings[0].message:t.warnings.length+" parse warnings",n=new SyntaxError(i);throw n.line=t.warnings[0].line,n.warnings=t.warnings,n.obj=r,n}}(e,t,i)),i}function E(e,t){return JSON.stringify(t)+":"+S(e[t])}function S(e){switch(typeof e){case"string":case"number":case"boolean":return JSON.stringify(e)}if(Array.isArray(e))return"["+e.map(S).join(",")+"]";if(new Object(e)===e){var t=Object.keys(e);return t.sort(),"{"+t.map(E.bind(null,e))+"}"}return"null"}var C={transform:d,parse:function(e,t){if("function"==typeof t||void 0===t)return JSON.parse(d(e),t);if(new Object(t)!==t)throw new TypeError("opts/reviver should be undefined, a function or an object");if(t.relaxed=void 0===t.relaxed||t.relaxed,t.warnings=t.warnings||t.tolerant||!1,t.tolerant=t.tolerant||!1,t.duplicate=t.duplicate||!1,!t.warnings&&!t.relaxed)return JSON.parse(e,t.reviver);var r=t.relaxed?c(e):u(e);if(t.relaxed&&(r=p(r)),t.warnings)return T(r=r.filter((function(e){return" "!==e.type})),{pos:0,reviver:t.reviver,tolerant:t.tolerant,duplicate:t.duplicate,warnings:[]},!0);var i=r.reduce((function(e,t){return e+t.match}),"");return JSON.parse(i,t.reviver)},stringify:S};e.exports=C}()}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var o=t[i]={exports:{}};return e[i].call(o.exports,o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=r(158),t=r.n(e);r(755);class i{static TAG="instrument";static TYPE_HEADING="heading";static TYPE_AIRSPEED="airspeed";static TYPE_ALTIMETER="altimeter";static TYPE_VERTICAL_SPEED="vertical";static TYPE_ATTITUDE="attitude";static TYPE_TURN_COORDINATOR="coordinator";static TYPES=[i.TYPE_HEADING,i.TYPE_AIRSPEED,i.TYPE_ALTIMETER,i.TYPE_VERTICAL_SPEED,i.TYPE_ATTITUDE,i.TYPE_TURN_COORDINATOR];static CONSTANTS={pitch_bound:30,vertical_speed_bound:1.95,airspeed_bound_l:0,airspeed_bound_h:160};static DEFAULT_OPTIONS={size:200,roll:0,pitch:0,turn:0,heading:0,verticalSpeed:0,airspeed:0,altitude:0,pressure:1e3,hideBox:!0,imagesDirectory:"../img"};constructor(e,t,r){this.placeholder=e,this.type=t,this.settings=this.simpleMerge(i.DEFAULT_OPTIONS,r),this.createInstrument()}createInstrument(){const e=this.settings.imagesDirectory;let t;switch(this.type){case i.TYPE_HEADING:t=this.createHeadingIndicator(e);break;case i.TYPE_AIRSPEED:t=this.createAirspeedIndicator(e);break;case i.TYPE_ALTIMETER:t=this.createAltimeterIndicator(e);break;case i.TYPE_VERTICAL_SPEED:t=this.createVerticalSpeedIndicator(e);break;case i.TYPE_ATTITUDE:t=this.createAttitudeIndicator(e);break;case i.TYPE_TURN_COORDINATOR:t=this.createCoordinatorIndicator(e);break;default:return null}this.resize(this.settings.size),this.toggleBox(this.settings.hideBox)}updateHeading(e){this.placeholder.querySelector("div.instrument.heading div.heading").style.transform=`rotate(${-e}deg)`}updateRoll(e){this.placeholder.querySelector("div.instrument.attitude div.roll").style.transform=`rotate(${e}deg)`}updatePitch(e){e>i.CONSTANTS.pitch_bound?e=i.CONSTANTS.pitch_bound:e<-i.CONSTANTS.pitch_bound&&(e=-i.CONSTANTS.pitch_bound),this.placeholder.querySelector("div.instrument.attitude div.roll div.pitch").style.top=.7*e+"%"}updateCoordinator(e){this.placeholder.querySelector("div.instrument.turn-coordinator div.turn").style.transform=`rotate(${e}deg)`}updateVerticalSpeed(e){e>i.CONSTANTS.vertical_speed_bound?e=i.CONSTANTS.vertical_speed_bound:e<-i.CONSTANTS.vertical_speed_bound&&(e=-i.CONSTANTS.vertical_speed_bound),e*=90,this.placeholder.querySelector("div.instrument.vertical-speed div.vertical-speed").style.transform=`rotate(${e}deg)`}updateAirSpeed(e){e>i.CONSTANTS.airspeed_bound_h?e=i.CONSTANTS.airspeed_bound_h:e<i.CONSTANTS.airspeed_bound_l&&(e=i.CONSTANTS.airspeed_bound_l),e=90+2*e,this.placeholder.querySelector("div.instrument.airspeed div.speed").style.transform=`rotate(${e}deg)`}updateAltitude(e){let t=90+e%1e3*360/1e3,r=e/1e4*360;this.placeholder.querySelector("div.instrument.altimeter div.needle").style.transform=`rotate(${t}deg)`,this.placeholder.querySelector("div.instrument.altimeter div.small-needle").style.transform=`rotate(${r}deg)`}updatePressure(e){e=2*e-1980,this.placeholder.querySelector("div.instrument.altimeter div.pressure").style.transform=`rotate(${e}deg)`}resize(e){let t=this.placeholder.querySelector("div.instrument");t.style.height=`${e}px`,t.style.width=`${e}px`}toggleBox(e){this.placeholder.querySelector("img.box.background").classList.toggle("hidden",e)}showBox(){this.placeholder.querySelector("img.box.background").classList.remove("hidden")}hideBox(){this.placeholder.querySelector("img.box.background").classList.add("hidden")}simpleMerge(...e){return e.reduce(((e,t)=>({...e,...t})),{})}mergeOptions(...e){let t={},r=!1,i=0,n=e.length;for("boolean"==typeof e[0]&&(r=e[0],i++);i<n;i++){const n=e[i];this.mergeObject(t,n,r)}return t}mergeObject(e,t,r){for(const i in t)if(t.hasOwnProperty(i)){const n=e=>e?.constructor===Object;r&&n(t[i])?e[i]=this.mergeOptions(!0,e[i],t[i]):e[i]=t[i]}}toggle(e){this.placeholder.classList.toggle("hidden",e)}show(){this.placeholder.classList.remove("hidden")}hide(){this.placeholder.classList.add("hidden")}createDivIndicator(e){const t=document.createElement("div");return t.setAttribute("class",`instrument ${e}`),t}createFiBoxImage(e){const t=this.createImgBox(e,"fi_box.svg");return t.classList.add("background"),t}createDivBox(e,t,r){const i=document.createElement("div");i.setAttribute("class",`${e} box`);const n=this.createImgBox(t,r);return i.appendChild(n),i}createImgBox(e,t){const r=document.createElement("img");return r.setAttribute("class","box"),r.src=`${e}/${t}`,r}createNeedleBox(e,t){return this.createDivBox(e,t,"fi_needle.svg")}createRollBox(e){const t=this.createDivBox("roll",e,"horizon_back.svg"),r=this.createDivBox("pitch",e,"horizon_ball.svg"),i=this.createImgBox(e,"horizon_circle.svg");return t.appendChild(r),t.appendChild(i),t}createMechanicsBox(e,t=null){const r=this.createDivBox("mechanics",e,"fi_circle.svg");return t&&r.prepend(t),r}createHeadingIndicator(e){const t=this.createDivIndicator("heading"),r=this.createFiBoxImage(e),i=this.createDivBox("heading",e,"heading_yaw.svg"),n=this.createImgBox(e,"heading_mechanics.svg"),o=this.createMechanicsBox(e,n);return t.appendChild(r),t.appendChild(i),t.appendChild(o),this.placeholder.appendChild(t),this.updateHeading(this.settings.heading),t}createAltimeterIndicator(e){const t=this.createDivIndicator("altimeter"),r=this.createFiBoxImage(e),i=this.createDivBox("pressure",e,"altitude_pressure.svg"),n=this.createImgBox(e,"altitude_ticks.svg"),o=this.createDivBox("small-needle",e,"fi_needle_small.svg"),s=this.createNeedleBox("needle",e),a=this.createMechanicsBox(e);return t.appendChild(r),t.appendChild(i),t.appendChild(n),t.appendChild(o),t.appendChild(s),t.appendChild(a),this.placeholder.appendChild(t),this.updateAltitude(this.settings.altitude),this.updatePressure(this.settings.pressure),t}createAirspeedIndicator(e){const t=this.createDivIndicator("airspeed"),r=this.createFiBoxImage(e),i=this.createImgBox(e,"speed_mechanics.svg"),n=this.createNeedleBox("speed",e),o=this.createMechanicsBox(e);return t.appendChild(r),t.appendChild(i),t.appendChild(n),t.appendChild(o),this.placeholder.appendChild(t),this.updateAirSpeed(this.settings.airspeed),t}createAttitudeIndicator(e){const t=this.createDivIndicator("attitude"),r=this.createFiBoxImage(e),i=this.createRollBox(e),n=this.createImgBox(e,"horizon_mechanics.svg"),o=this.createMechanicsBox(e,n);return t.appendChild(r),t.appendChild(i),t.appendChild(o),this.placeholder.appendChild(t),this.updateRoll(this.settings.roll),this.updatePitch(this.settings.pitch),t}createCoordinatorIndicator(e){const t=this.createDivIndicator("turn-coordinator"),r=this.createFiBoxImage(e),i=this.createImgBox(e,"turn_coordinator.svg"),n=this.createDivBox("turn",e,"fi_tc_airplane.svg"),o=this.createMechanicsBox(e);return t.appendChild(r),t.appendChild(i),t.appendChild(n),t.appendChild(o),this.placeholder.appendChild(t),this.updateCoordinator(this.settings.turn),t}createVerticalSpeedIndicator(e){const t=this.createDivIndicator("vertical-speed"),r=this.createFiBoxImage(e),i=this.createImgBox(e,"vertical_mechanics.svg"),n=this.createNeedleBox("vertical-speed",e),o=this.createMechanicsBox(e);return t.appendChild(r),t.appendChild(i),t.appendChild(n),t.appendChild(o),this.placeholder.appendChild(t),this.updateVerticalSpeed(this.settings.verticalSpeed),t}}var n,o,s,a,l,c,u,h=r(277),p=r.n(h),d=r(689),f=r.n(d);(c=n||(n={})).Default="",c.Move="move",c.Grabbing="grabbing",c.NESWResize="nesw-resize",c.NWSEResize="nwse-resize",(l=o||(o={})).Move="move",l.Transform="transform",(a=s||(s={})).Visible="visible",a.None="none",function(e){e.Next="next",e.Prev="prev"}(u||(u={}));var m=6371008.8,_={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*m,kilometers:6371.0088,kilometres:6371.0088,meters:m,metres:m,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:m/1852,radians:1,yards:6967335.223679999};function g(e){return e%360*Math.PI/180}function y(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}const v=function(e,t,r){void 0===r&&(r={});var i=y(e),n=y(t),o=g(n[1]-i[1]),s=g(n[0]-i[0]),a=g(i[1]),l=g(n[1]),c=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(l);return function(e,t){void 0===t&&(t="kilometers");var r=_[t];if(!r)throw new Error(t+" units is invalid");return e*r}(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)},x=class{constructor(){this.node=document.createElement("div"),this.node.classList.add("mapboxgl-ctrl"),this.node.classList.add("mapboxgl-ctrl-group"),this.node.classList.add("mapbox-control")}addButton(e){this.node.appendChild(e.node)}addClassName(e){this.node.classList.add(e)}removeClassName(e){this.node.classList.remove(e)}onAddControl(){}onRemoveControl(){}onAdd(e){return this.map=e,this.onAddControl(),this.node}onRemove(){this.onRemoveControl(),this.node.parentNode.removeChild(this.node),this.map=void 0}},b=class{constructor(){this.node=document.createElement("button"),this.node.type="button",this.icon=null}setIcon(e){this.icon=e,this.node.appendChild(e)}setText(e){this.node.textContent=e}onClick(e){this.node.addEventListener("click",e)}addClassName(e){this.node.classList.add(e)}removeClassName(e){this.node.classList.remove(e)}};function w(e){return e<1?`${(1e3*e).toFixed()} m`:`${e.toFixed(2)} km`}function T(e){return{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}}}function E(e=[],t=[]){return{type:"FeatureCollection",features:e.map(((e,r)=>({type:"Feature",properties:{text:t[r]},geometry:{type:"Point",coordinates:e}})))}}const S="controls-layer-line",C="controls-layer-symbol",A="controls-source-line",k="controls-source-symbol";function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function M(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var z={id:"mapboxgl-minimap",width:"320px",height:"180px",style:"mapbox://styles/mapbox/streets-v8",center:[0,0],zoom:6,zoomAdjust:null,zoomLevels:[[18,14,16],[16,12,14],[14,10,12],[12,8,10],[10,6,8]],lineColor:"#08F",lineWidth:1,lineOpacity:1,fillColor:"#F80",fillOpacity:.25,dragPan:!1,scrollZoom:!1,boxZoom:!1,dragRotate:!1,keyboard:!1,doubleClickZoom:!1,touchZoomRotate:!1};const P=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.options=z,Object.assign(this.options,t),this._ticking=!1,this._lastMouseMoveEvent=null,this._parentMap=null,this._isDragging=!1,this._isCursorOverFeature=!1,this._previousPoint=[0,0],this._currentPoint=[0,0],this._trackingRectCoordinates=[[[],[],[],[],[]]]}var r,i;return r=e,(i=[{key:"onAdd",value:function(e){this._parentMap=e;var r=this.options,i=this._container=this._createContainer(e),n=this._miniMap=new(t().Map)({attributionControl:!1,container:i,style:r.style,zoom:r.zoom,center:r.center});return r.maxBounds&&n.setMaxBounds(r.maxBounds),n.on("load",this._load.bind(this)),this._container}},{key:"_load",value:function(){var e=this.options,t=this._parentMap,r=this._miniMap;["dragPan","scrollZoom","boxZoom","dragRotate","keyboard","doubleClickZoom","touchZoomRotate"].forEach((function(t){!0!==e[t]&&r[t].disable()})),"function"==typeof e.zoomAdjust?this.options.zoomAdjust=e.zoomAdjust.bind(this):null===e.zoomAdjust&&(this.options.zoomAdjust=this._zoomAdjust.bind(this));var i=r.getBounds();this._convertBoundsToPoints(i),r.addSource("trackingRect",{type:"geojson",data:{type:"Feature",properties:{name:"trackingRect"},geometry:{type:"Polygon",coordinates:this._trackingRectCoordinates}}}),r.addLayer({id:"trackingRectOutline",type:"line",source:"trackingRect",layout:{},paint:{"line-color":e.lineColor,"line-width":e.lineWidth,"line-opacity":e.lineOpacity}}),r.addLayer({id:"trackingRectFill",type:"fill",source:"trackingRect",layout:{},paint:{"fill-color":e.fillColor,"fill-opacity":e.fillOpacity}}),this._trackingRect=this._miniMap.getSource("trackingRect"),this._update(),t.on("move",this._update.bind(this)),r.on("mousemove",this._mouseMove.bind(this)),r.on("mousedown",this._mouseDown.bind(this)),r.on("mouseup",this._mouseUp.bind(this)),r.on("touchmove",this._mouseMove.bind(this)),r.on("touchstart",this._mouseDown.bind(this)),r.on("touchend",this._mouseUp.bind(this)),this._miniMapCanvas=r.getCanvasContainer(),this._miniMapCanvas.addEventListener("wheel",this._preventDefault),this._miniMapCanvas.addEventListener("mousewheel",this._preventDefault)}},{key:"_mouseDown",value:function(e){this._isCursorOverFeature&&(this._isDragging=!0,this._previousPoint=this._currentPoint,this._currentPoint=[e.lngLat.lng,e.lngLat.lat])}},{key:"_mouseMove",value:function(e){this._ticking=!1;var t=this._miniMap.queryRenderedFeatures(e.point,{layers:["trackingRectFill"]});if(this._isCursorOverFeature&&t.length>0||(this._isCursorOverFeature=t.length>0,this._miniMapCanvas.style.cursor=this._isCursorOverFeature?"move":""),this._isDragging){this._previousPoint=this._currentPoint,this._currentPoint=[e.lngLat.lng,e.lngLat.lat];var r=[this._previousPoint[0]-this._currentPoint[0],this._previousPoint[1]-this._currentPoint[1]],i=this._moveTrackingRect(r);this._parentMap.fitBounds(i,{duration:80,noMoveStart:!0})}}},{key:"_mouseUp",value:function(){this._isDragging=!1,this._ticking=!1}},{key:"_moveTrackingRect",value:function(e){var t=this._trackingRect,r=t._data,i=r.properties.bounds;return i._ne.lat-=e[1],i._ne.lng-=e[0],i._sw.lat-=e[1],i._sw.lng-=e[0],this._convertBoundsToPoints(i),t.setData(r),i}},{key:"_setTrackingRectBounds",value:function(e){var t=this._trackingRect,r=t._data;r.properties.bounds=e,this._convertBoundsToPoints(e),t.setData(r)}},{key:"_convertBoundsToPoints",value:function(e){var t=e._ne,r=e._sw,i=this._trackingRectCoordinates;i[0][0][0]=t.lng,i[0][0][1]=t.lat,i[0][1][0]=r.lng,i[0][1][1]=t.lat,i[0][2][0]=r.lng,i[0][2][1]=r.lat,i[0][3][0]=t.lng,i[0][3][1]=r.lat,i[0][4][0]=t.lng,i[0][4][1]=t.lat}},{key:"_update",value:function(){if(!this._isDragging){var e=this._parentMap.getBounds();this._setTrackingRectBounds(e),"function"==typeof this.options.zoomAdjust&&this.options.zoomAdjust()}}},{key:"_zoomAdjust",value:function(){var e=this._miniMap,t=this._parentMap,r=parseInt(e.getZoom(),10),i=parseInt(t.getZoom(),10),n=this.options.zoomLevels,o=!1;n.forEach((function(n){!o&&i>=n[0]&&(r>=n[1]&&e.setZoom(n[2]),e.setCenter(t.getCenter()),o=!0)})),o||r===this.options.zoom||("object"===I(this.options.bounds)&&e.fitBounds(this.options.bounds,{duration:50}),e.setZoom(this.options.zoom))}},{key:"_createContainer",value:function(e){var t=this.options,r=document.createElement("div");return r.className="mapboxgl-ctrl-minimap mapboxgl-ctrl",r.setAttribute("style","width: "+t.width+"; height: "+t.height+";"),r.addEventListener("contextmenu",this._preventDefault),e.getContainer().appendChild(r),""!==t.id&&(r.id=t.id),r}},{key:"_preventDefault",value:function(e){e.preventDefault()}}])&&M(r.prototype,i),Object.defineProperty(r,"prototype",{writable:!1}),e}();t().accessToken="pk.eyJ1IjoiYXNzYWRhIiwiYSI6ImNrbTkzd2RlOTBrMmwyb3BoZGZ5bXpyZXIifQ.qPyi1nxJHcc4Z1xL1EKuuA";var D=new(t().Map)({container:"map",style:"mapbox://styles/mapbox/satellite-streets-v9",center:[8.545564,47.397974],zoom:13,projection:"globe"});D.addControl(new(t().NavigationControl),"bottom-right"),D.on("style.load",(function(){D.setFog({}),document.onclick=B})),D.addControl(new class extends x{constructor(e){var t,r,i,n,o,s,a,l,c;super(),this.isMeasuring=!1,this.markers=[],this.coordinates=[],this.labels=[],this.units=null!==(t=null==e?void 0:e.units)&&void 0!==t?t:"kilometers",this.font=null!==(r=null==e?void 0:e.font)&&void 0!==r?r:["Roboto Medium"],this.fontSize=null!==(i=null==e?void 0:e.fontSize)&&void 0!==i?i:12,this.fontHalo=null!==(n=null==e?void 0:e.fontHalo)&&void 0!==n?n:1,this.textVariableAnchor=(null==e?void 0:e.textVariableAnchor)||["top"],this.textAllowOverlap=(null==e?void 0:e.textAllowOverlap)||!1,this.markerNodeSize=`${null!==(o=null==e?void 0:e.markerNodeSize)&&void 0!==o?o:12}px`,this.markerNodeBorderWidth=`${null!==(s=null==e?void 0:e.markerNodeBorderWidth)&&void 0!==s?s:2}px`,this.labelFormat=null!==(a=null==e?void 0:e.labelFormat)&&void 0!==a?a:w,this.mainColor=null!==(l=null==e?void 0:e.mainColor)&&void 0!==l?l:"#263238",this.secondaryColor=null!==(c=null==e?void 0:e.secondaryColor)&&void 0!==c?c:"#fff",this.button=new b,this.mapClickListener=this.mapClickListener.bind(this),this.styleLoadListener=this.styleLoadListener.bind(this)}insert(){this.addClassName("mapbox-control-ruler"),this.button.setIcon((new DOMParser).parseFromString('\n<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" viewBox="0 0 24 24" width="22" height="22" fill="#505050">\n <rect fill="none" height="24" width="24"/>\n <path d="M20,6H4C2.9,6,2,6.9,2,8v8c0,1.1,0.9,2,2,2h16c1.1,0,2-0.9,2-2V8C22,6.9,21.1,6,20,6z M20,16H4V8h3v3c0,0.55,0.45,1,1,1h0 c0.55,0,1-0.45,1-1V8h2v3c0,0.55,0.45,1,1,1h0c0.55,0,1-0.45,1-1V8h2v3c0,0.55,0.45,1,1,1h0c0.55,0,1-0.45,1-1V8h3V16z"/>\n</svg>\n',"image/svg+xml").firstChild),this.button.onClick((()=>{this.isMeasuring?this.measuringOff():this.measuringOn()})),this.addButton(this.button)}draw(){this.map.addSource(A,{type:"geojson",data:T(this.coordinates)}),this.map.addSource(k,{type:"geojson",data:E(this.coordinates,this.labels)}),this.map.addLayer({id:S,type:"line",source:A,paint:{"line-color":this.mainColor,"line-width":2}}),this.map.addLayer({id:C,type:"symbol",source:k,layout:{"text-field":"{text}","text-font":this.font,"text-anchor":"top","text-size":this.fontSize,"text-offset":[0,.8]},paint:{"text-color":this.mainColor,"text-halo-color":this.secondaryColor,"text-halo-width":this.fontHalo}})}measuringOn(){this.isMeasuring=!0,this.markers=[],this.coordinates=[],this.labels=[],this.map.getCanvas().style.cursor="crosshair",this.button.addClassName("-active"),this.draw(),this.map.on("click",this.mapClickListener),this.map.on("style.load",this.styleLoadListener),this.map.fire("ruler.on")}measuringOff(){this.isMeasuring=!1,this.map.getCanvas().style.cursor="",this.button.removeClassName("-active"),this.map.removeLayer(S),this.map.removeLayer(C),this.map.removeSource(A),this.map.removeSource(k),this.markers.forEach((e=>e.remove())),this.map.off("click",this.mapClickListener),this.map.off("style.load",this.styleLoadListener),this.map.fire("ruler.off")}mapClickListener(e){const r=this.getMarkerNode(),i=new(t().Marker)({element:r,draggable:!0}).setLngLat(e.lngLat).addTo(this.map),n=[e.lngLat.lng,e.lngLat.lat];this.coordinates.push(n),this.updateLabels(),this.updateSource(),this.markers.push(i),this.map.fire("ruler.change",{coordinates:this.coordinates}),i.on("drag",(()=>{const e=this.markers.indexOf(i),t=i.getLngLat();this.coordinates[e]=[t.lng,t.lat],this.updateLabels(),this.updateSource()})),i.on("dragend",(()=>{this.map.fire("ruler.change",{coordinates:this.coordinates})}))}updateSource(){const e=this.map.getSource(A),t=this.map.getSource(k);e.setData(T(this.coordinates)),t.setData(E(this.coordinates,this.labels))}updateLabels(){const{coordinates:e,units:t,labelFormat:r}=this;let i=0;this.labels=e.map(((n,o)=>0===o?r(0):(i+=v(e[o-1],e[o],{units:t}),r(i))))}getMarkerNode(){const e=document.createElement("div");return e.style.width="12px",e.style.height="12px",e.style.borderRadius="50%",e.style.background=this.secondaryColor,e.style.boxSizing="border-box",e.style.border=`2px solid ${this.mainColor}`,e}styleLoadListener(){this.draw()}onAddControl(){this.insert()}onRemoveControl(){this.isMeasuring&&this.measuringOff(),this.map.off("click",this.mapClickListener)}},"top-right");var L=new P({center:[31.393023,49.011527],zoom:6,dragPan:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,zoomLevels:[[26,22,24],[24,20,22],[22,18,20],[20,16,18],[18,14,16],[16,12,14],[14,10,12],[12,8,10],[10,6,8],[8,4,6]],togglePosition:"topright"});function B(){console.log("hideMenu"),document.getElementById("contextMenu").style.display="none"}D.addControl(L,"top-right"),D.addControl(new class extends x{constructor(e){var t;super(),this.styles=null!==(t=null==e?void 0:e.styles)&&void 0!==t?t:this.defaultOptions,this.onChange=null==e?void 0:e.onChange,this.buttons=[]}insert(){this.addClassName("mapbox-control-styles"),this.styles.forEach((e=>{const t=new b;t.setText(e.label),t.onClick((()=>{t.node.classList.contains("-active")||(this.map.setStyle(e.styleUrl),this.onChange&&this.onChange(e))})),this.buttons.push(t),this.addButton(t)})),this.map.on("styledata",(()=>{this.buttons.forEach((e=>{e.removeClassName("-active")}));const e=this.styles.map((e=>e.styleName)).indexOf(this.map.getStyle().name);-1!==e&&this.buttons[e].addClassName("-active")}))}get defaultOptions(){return[{label:"Streets",styleName:"Mapbox Streets",styleUrl:"mapbox://styles/mapbox/streets-v11"},{label:"Satellite",styleName:"Mapbox Satellite Streets",styleUrl:"mapbox://sprites/mapbox/satellite-streets-v11"}]}onAddControl(){this.insert()}}({styles:[{label:"ST",styleName:"Mapbox Streets",styleUrl:"mapbox://styles/mapbox/streets-v9"},{label:"SA",styleName:"Satellite",styleUrl:"mapbox://styles/mapbox/satellite-streets-v9"}],onChange:function(e){return console.log(e)}}),"top-right"),D.on("contextmenu",(function(e){if(console.log(e),"block"==document.getElementById("contextMenu").style.display)B();else{var t=document.getElementById("contextMenu");t.style.display="block",t.style.left=e.point.x+"px",t.style.top=e.point.y+"px",console.log(t)}}));var R=new(t().Popup)({offset:25}).setHTML("<b>Командир:</b> Роман Валильйев");document.createElement("div").id="marker";var O=new(t().Marker)({color:"#FFFFFF",draggable:!1,rotation:90,element:document.getElementById("drone")}).setLngLat([37.9202856,48.6063243]).setPopup(R).addTo(D),F=document.querySelector("#attitude"),N=new i(F,i.TYPE_ATTITUDE,{roll:50,pitch:-20,size:200,hideBox:!0}),j=document.querySelector("#heading"),U=new i(j,i.TYPE_HEADING,{heading:0,hideBox:!0}),V=p().connect("ws://localhost:9001",{clean:!0,connectTimeout:4e3,clientId:"emqx_test"});V.on("connect",(function(){console.log("Connected!"),V.subscribe("a1/#",(function(e){e||console.log("Subscribed!")}))})),V.on("message",(function(e,t){var r=t.toString();try{var i=f().transform(r),n=JSON.parse(i);if("a1/ATTITUDE"==e?(N.setRoll(100*n.roll),N.setPitch(100*n.pitch)):"a1/VFR_HUD"==e&&(U.setHeading(n.heading),O.setRotation(n.heading)),"a1/SYS_STATUS"==e&&(document.getElementById("batt").innerHTML=n.battery_remaining),"a1/GPS_RAW_INT"==e&&(document.getElementById("satellites_visible").innerHTML=n.satellites_visible),"a1/GLOBAL_POSITION_INT"==e&&O.setLngLat([n.lon/1e7,n.lat/1e7]),"a1/HEARTBEAT"==e){var o=document.getElementById("status"),s="unknown";switch(n.system_status){case 0:s="unknown";break;case 1:s="boot";break;case 2:s="calibrating";break;case 3:s="standby";break;case 4:s="active";break;case 5:s="CRITICAL";break;case 6:s="EMERGENCY";break;case 7:s="poweroff";break;case 8:s="terminating"}if(o.innerHTML=s,2==n.type){var a=128&n.base_mode,l=64&n.base_mode,c=32&n.base_mode,u=16&n.base_mode,h=8&n.base_mode,p=4&n.base_mode,d=2&n.base_mode,m=1&n.base_mode;document.getElementById("armed").innerHTML=128===a?"true":"false",console.log(a,l,c,u,h,p,d,m)}}}catch(t){console.error(t),console.log(e),console.log(r)}}))})()})();