From c89d0604fd54bb700c479821002159ace2723869 Mon Sep 17 00:00:00 2001 From: Nick Cassab Date: Tue, 12 Nov 2024 07:18:45 -0500 Subject: [PATCH] incremented version number --- asset-manifest.json | 6 +- index.html | 2 +- static/js/main.a0881156.js | 3 + static/js/main.a0881156.js.LICENSE.txt | 136 +++++++++++++++++++++++++ static/js/main.a0881156.js.map | 1 + 5 files changed, 144 insertions(+), 4 deletions(-) create mode 100644 static/js/main.a0881156.js create mode 100644 static/js/main.a0881156.js.LICENSE.txt create mode 100644 static/js/main.a0881156.js.map diff --git a/asset-manifest.json b/asset-manifest.json index 766feafd..f7e1d14f 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,15 +1,15 @@ { "files": { "main.css": "/UBEMViewer/static/css/main.fd669a23.css", - "main.js": "/UBEMViewer/static/js/main.091eb93b.js", + "main.js": "/UBEMViewer/static/js/main.a0881156.js", "static/js/453.1b384830.chunk.js": "/UBEMViewer/static/js/453.1b384830.chunk.js", "index.html": "/UBEMViewer/index.html", "main.fd669a23.css.map": "/UBEMViewer/static/css/main.fd669a23.css.map", - "main.091eb93b.js.map": "/UBEMViewer/static/js/main.091eb93b.js.map", + "main.a0881156.js.map": "/UBEMViewer/static/js/main.a0881156.js.map", "453.1b384830.chunk.js.map": "/UBEMViewer/static/js/453.1b384830.chunk.js.map" }, "entrypoints": [ "static/css/main.fd669a23.css", - "static/js/main.091eb93b.js" + "static/js/main.a0881156.js" ] } \ No newline at end of file diff --git a/index.html b/index.html index ab1be8e9..ea83379f 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -Urbano Viewer
\ No newline at end of file +Urbano Viewer
\ No newline at end of file diff --git a/static/js/main.a0881156.js b/static/js/main.a0881156.js new file mode 100644 index 00000000..67103a00 --- /dev/null +++ b/static/js/main.a0881156.js @@ -0,0 +1,3 @@ +/*! For license information please see main.a0881156.js.LICENSE.txt */ +(()=>{var e={5513:(e,t,n)=>{"use strict";n.d(t,{A:()=>ie});var r=function(){function e(e){var t=this;this._insertTag=function(e){var n;n=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,n),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var n=function(e){if(e.sheet)return e.sheet;for(var t=0;t0?u(x,--y):0,g--,10===v&&(g=1,m--),v}function M(){return v=y<_?u(x,y++):0,g++,10===v&&(g=1,m++),v}function A(){return u(x,y)}function E(){return y}function T(e,t){return h(x,e,t)}function C(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function k(e){return m=g=1,_=d(x=e),y=0,[]}function I(e){return x="",e}function P(e){return s(T(y-1,z(91===e?e+2:40===e?e+1:e)))}function R(e){for(;(v=A())&&v<33;)M();return C(e)>2||C(v)>3?"":" "}function L(e,t){for(;--t&&M()&&!(v<48||v>102||v>57&&v<65||v>70&&v<97););return T(e,E()+(t<6&&32==A()&&32==M()))}function z(e){for(;M();)switch(v){case e:return y;case 34:case 39:34!==e&&39!==e&&z(v);break;case 40:41===e&&z(e);break;case 92:M()}return y}function O(e,t){for(;M()&&e+v!==57&&(e+v!==84||47!==A()););return"/*"+T(t,y-1)+"*"+o(47===e?e:M())}function D(e){for(;!C(A());)M();return T(e,y)}var B="-ms-",F="-moz-",N="-webkit-",j="comm",V="rule",U="decl",G="@keyframes";function q(e,t){for(var n="",r=f(e),i=0;i0&&d(F)-_&&p(v>32?X(F+";",r,n,_-1):X(l(F," ","")+";",r,n,_-2),f);break;case 59:F+=";";default:if(p(B=Y(F,t,n,m,g,i,h,k,I=[],z=[],_),a),123===C)if(0===g)Z(F,t,B,B,I,a,_,h,z);else switch(99===y&&110===u(F,3)?100:y){case 100:case 108:case 109:case 115:Z(e,B,B,r&&p(Y(e,B,B,0,0,i,h,k,i,I=[],_),z),i,z,_,h,r?I:z);break;default:Z(F,B,B,B,[""],z,0,h,z)}}m=g=v=0,b=T=1,k=F="",_=s;break;case 58:_=1+d(F),v=x;default:if(b<1)if(123==C)--b;else if(125==C&&0==b++&&125==S())continue;switch(F+=o(C),C*b){case 38:T=g>0?1:(F+="\f",-1);break;case 44:h[m++]=(d(F)-1)*T,T=1;break;case 64:45===A()&&(F+=P(M())),y=A(),g=_=d(k=F+=D(E())),C++;break;case 45:45===x&&2==d(F)&&(b=0)}}return a}function Y(e,t,n,r,o,a,c,u,d,p,m){for(var g=o-1,_=0===o?a:[""],y=f(_),v=0,x=0,w=0;v0?_[S]+" "+M:l(M,/&\f/g,_[S])))&&(d[w++]=A);return b(e,t,n,0===o?V:u,d,p,m)}function Q(e,t,n){return b(e,t,n,j,o(v),h(e,2,-2),0)}function X(e,t,n,r){return b(e,t,n,U,h(e,0,r),h(e,r+1,-1),r)}var K=function(e,t,n){for(var r=0,i=0;r=i,i=A(),38===r&&12===i&&(t[n]=1),!C(i);)M();return T(e,y)},J=function(e,t){return I(function(e,t){var n=-1,r=44;do{switch(C(r)){case 0:38===r&&12===A()&&(t[n]=1),e[n]+=K(y-1,t,n);break;case 2:e[n]+=P(r);break;case 4:if(44===r){e[++n]=58===A()?"&\f":"",t[n]=e[n].length;break}default:e[n]+=o(r)}}while(r=M());return e}(k(e),t))},$=new WeakMap,ee=function(e){if("rule"===e.type&&e.parent&&!(e.length<1)){for(var t=e.value,n=e.parent,r=e.column===n.column&&e.line===n.line;"rule"!==n.type;)if(!(n=n.parent))return;if((1!==e.props.length||58===t.charCodeAt(0)||$.get(n))&&!r){$.set(e,!0);for(var i=[],o=J(t,i),a=n.props,s=0,l=0;s6)switch(u(e,t+1)){case 109:if(45!==u(e,t+4))break;case 102:return l(e,/(.+:)(.+)-([^]+)/,"$1"+N+"$2-$3$1"+F+(108==u(e,t+3)?"$3":"$2-$3"))+e;case 115:return~c(e,"stretch")?ne(l(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(115!==u(e,t+1))break;case 6444:switch(u(e,d(e)-3-(~c(e,"!important")&&10))){case 107:return l(e,":",":"+N)+e;case 101:return l(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+N+(45===u(e,14)?"inline-":"")+"box$3$1"+N+"$2$3$1"+B+"$2box$3")+e}break;case 5936:switch(u(e,t+11)){case 114:return N+e+B+l(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return N+e+B+l(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return N+e+B+l(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return N+e+B+e+e}return e}var re=[function(e,t,n,r){if(e.length>-1&&!e.return)switch(e.type){case U:e.return=ne(e.value,e.length);break;case G:return q([w(e,{value:l(e.value,"@","@"+N)})],r);case V:if(e.length)return function(e,t){return e.map(t).join("")}(e.props,(function(t){switch(function(e,t){return(e=t.exec(e))?e[0]:e}(t,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return q([w(e,{props:[l(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return q([w(e,{props:[l(t,/:(plac\w+)/,":"+N+"input-$1")]}),w(e,{props:[l(t,/:(plac\w+)/,":-moz-$1")]}),w(e,{props:[l(t,/:(plac\w+)/,B+"input-$1")]})],r)}return""}))}}],ie=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var i=e.stylisPlugins||re;var o,a,s={},l=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n{"use strict";function r(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}n.d(t,{A:()=>r})},5756:(e,t,n)=>{"use strict";n.d(t,{C:()=>s,T:()=>c,i:()=>o,w:()=>l});var r=n(5043),i=n(5513),o=(n(2830),n(9436),!0),a=r.createContext("undefined"!==typeof HTMLElement?(0,i.A)({key:"css"}):null);var s=a.Provider,l=function(e){return(0,r.forwardRef)((function(t,n){var i=(0,r.useContext)(a);return e(t,i,n)}))};o||(l=function(e){return function(t){var n=(0,r.useContext)(a);return null===n?(n=(0,i.A)({key:"css"}),r.createElement(a.Provider,{value:n},e(t,n))):e(t,n)}});var c=r.createContext({})},3290:(e,t,n)=>{"use strict";n.d(t,{AH:()=>c,i7:()=>u,mL:()=>l});var r=n(5756),i=n(5043),o=n(1722),a=n(9436),s=n(2830),l=(n(5513),n(219),(0,r.w)((function(e,t){var n=e.styles,l=(0,s.J)([n],void 0,i.useContext(r.T));if(!r.i){for(var c,u=l.name,h=l.styles,d=l.next;void 0!==d;)u+=" "+d.name,h+=d.styles,d=d.next;var f=!0===t.compat,p=t.insert("",{name:u,styles:h},t.sheet,f);return f?null:i.createElement("style",((c={})["data-emotion"]=t.key+"-global "+u,c.dangerouslySetInnerHTML={__html:p},c.nonce=t.sheet.nonce,c))}var m=i.useRef();return(0,a.i)((function(){var e=t.key+"-global",n=new t.sheet.constructor({key:e,nonce:t.sheet.nonce,container:t.sheet.container,speedy:t.sheet.isSpeedy}),r=!1,i=document.querySelector('style[data-emotion="'+e+" "+l.name+'"]');return t.sheet.tags.length&&(n.before=t.sheet.tags[0]),null!==i&&(r=!0,i.setAttribute("data-emotion",e),n.hydrate([i])),m.current=[n,r],function(){n.flush()}}),[t]),(0,a.i)((function(){var e=m.current,n=e[0];if(e[1])e[1]=!1;else{if(void 0!==l.next&&(0,o.sk)(t,l.next,!0),n.tags.length){var r=n.tags[n.tags.length-1].nextElementSibling;n.before=r,n.flush()}t.insert("",l,n,!1)}}),[t,l.name]),null})));function c(){for(var e=arguments.length,t=new Array(e),n=0;n{"use strict";n.d(t,{J:()=>p});var r={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},i=n(918),o=/[A-Z]|^ms/g,a=/_EMO_([^_]+?)_([^]*?)_EMO_/g,s=function(e){return 45===e.charCodeAt(1)},l=function(e){return null!=e&&"boolean"!==typeof e},c=(0,i.A)((function(e){return s(e)?e:e.replace(o,"-$&").toLowerCase()})),u=function(e,t){switch(e){case"animation":case"animationName":if("string"===typeof t)return t.replace(a,(function(e,t,n){return d={name:t,styles:n,next:d},t}))}return 1===r[e]||s(e)||"number"!==typeof t||0===t?t:t+"px"};function h(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles)return n;switch(typeof n){case"boolean":return"";case"object":if(1===n.anim)return d={name:n.name,styles:n.styles,next:d},n.name;if(void 0!==n.styles){var r=n.next;if(void 0!==r)for(;void 0!==r;)d={name:r.name,styles:r.styles,next:d},r=r.next;return n.styles+";"}return function(e,t,n){var r="";if(Array.isArray(n))for(var i=0;i=4;++r,i-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(i){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(i)+l;return{name:c,styles:i,next:d}}},5903:(e,t,n)=>{"use strict";n.d(t,{A:()=>_});var r=n(8168),i=n(5043),o=n(918),a=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,s=(0,o.A)((function(e){return a.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91})),l=n(5756),c=n(1722),u=n(2830),h=n(9436),d=s,f=function(e){return"theme"!==e},p=function(e){return"string"===typeof e&&e.charCodeAt(0)>96?d:f},m=function(e,t,n){var r;if(t){var i=t.shouldForwardProp;r=e.__emotion_forwardProp&&i?function(t){return e.__emotion_forwardProp(t)&&i(t)}:i}return"function"!==typeof r&&n&&(r=e.__emotion_forwardProp),r},g=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return(0,c.SF)(t,n,r),(0,h.s)((function(){return(0,c.sk)(t,n,r)})),null},_=function e(t,n){var o,a,s=t.__emotion_real===t,h=s&&t.__emotion_base||t;void 0!==n&&(o=n.label,a=n.target);var d=m(t,n,s),f=d||p(h),_=!f("as");return function(){var y=arguments,v=s&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==o&&v.push("label:"+o+";"),null==y[0]||void 0===y[0].raw)v.push.apply(v,y);else{0,v.push(y[0][0]);for(var x=y.length,b=1;b{"use strict";var r;n.d(t,{i:()=>s,s:()=>a});var i=n(5043),o=!!(r||(r=n.t(i,2))).useInsertionEffect&&(r||(r=n.t(i,2))).useInsertionEffect,a=o||function(e){return e()},s=o||i.useLayoutEffect},1722:(e,t,n)=>{"use strict";n.d(t,{Rk:()=>r,SF:()=>i,sk:()=>o});function r(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):r+=n+" "})),r}var i=function(e,t,n){var r=e.key+"-"+t.name;!1===n&&void 0===e.registered[r]&&(e.registered[r]=t.styles)},o=function(e,t,n){i(e,t,n);var r=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var o=t;do{e.insert(t===o?"."+r:"",o,e.sheet,!0),o=o.next}while(void 0!==o)}}},6366:(e,t,n)=>{"use strict";var r=n(3119),i=n(49),o="value",a="\n ",s={};function l(e){var t=Array.isArray(e);return function(n){var r,i=c(s.plainArray,n);if(i)return i;if(t&&n.length!==e.length)return"an array with "+e.length+" items";for(var o=0;oe.length?t:e}))}},s.equal=function(e){return function(t){if(t!==e)return JSON.stringify(e)}},s.oneOf=function(){var e=(Array.isArray(arguments[0])?arguments[0]:Array.prototype.slice.call(arguments)).map((function(e){return s.equal(e)}));return s.oneOfType.apply(this,e)},s.range=function(e){var t=e[0],n=e[1];return function(e){if(c(s.number,e)||en)return"number between "+t+" & "+n+" (inclusive)"}},s.any=function(){},s.boolean=function(e){if("boolean"!==typeof e)return"boolean"},s.number=function(e){if("number"!==typeof e)return"number"},s.plainArray=function(e){if(!Array.isArray(e))return"array"},s.plainObject=function(e){if(!r(e))return"object"},s.string=function(e){if("string"!==typeof e)return"string"},s.func=function(e){if("function"!==typeof e)return"function"},s.validate=c,s.processMessage=u,e.exports=s},3119:e=>{"use strict";var t=Object.prototype.toString;e.exports=function(e){var n;return"[object Object]"===t.call(e)&&(null===(n=Object.getPrototypeOf(e))||n===Object.getPrototypeOf({}))}},5609:(e,t,n)=>{"use strict";var r=n(9452).Ak;function i(e){this.origin=e.origin||"https://api.mapbox.com",this.endpoint="events/v2",this.access_token=e.accessToken,this.version="0.3.0",this.pluginSessionID=this.generateSessionID(),this.sessionIncrementer=0,this.userAgent=this.getUserAgent(),this.options=e,this.send=this.send.bind(this),this.countries=e.countries?e.countries.split(","):null,this.types=e.types?e.types.split(","):null,this.bbox=e.bbox?e.bbox:null,this.language=e.language?e.language.split(","):null,this.limit=e.limit?+e.limit:null,this.locale=navigator.language||null,this.enableEventLogging=this.shouldEnableLogging(e),this.eventQueue=new Array,this.flushInterval=e.flushInterval||1e3,this.maxQueueSize=e.maxQueueSize||100,this.timer=this.flushInterval?setTimeout(this.flush.bind(this),this.flushInterval):null,this.lastSentInput="",this.lastSentIndex=0}i.prototype={select:function(e,t){var n=this.getEventPayload("search.select",t,{selectedFeature:e});if(n&&(n.resultIndex!==this.lastSentIndex||n.queryString!==this.lastSentInput)&&-1!=n.resultIndex)return this.lastSentIndex=n.resultIndex,this.lastSentInput=n.queryString,this.push(n)},start:function(e){var t=this.getEventPayload("search.start",e);if(t)return this.push(t)},keyevent:function(e,t){if(e.key&&!e.metaKey&&-1===[9,27,37,39,13,38,40].indexOf(e.keyCode)){var n=this.getEventPayload("search.keystroke",t,{key:e.key});if(n)return this.push(n)}},send:function(e,t){if(!this.enableEventLogging)return t?t():void 0;var n=this.getRequestOptions(e);this.request(n,function(e){return e?this.handleError(e,t):t?t():void 0}.bind(this))},getRequestOptions:function(e){return Array.isArray(e)||(e=[e]),{method:"POST",host:this.origin,path:this.endpoint+"?access_token="+this.access_token,headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}},getEventPayload:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("search.select"===e&&!n.selectedFeature||"search.keystroke"===e&&!n.key)return null;var r;if(t.options.proximity)if("object"===typeof t.options.proximity)r=[t.options.proximity.longitude,t.options.proximity.latitude];else if("ip"===t.options.proximity){var i=t._headers?t._headers["ip-proximity"]:null;r=i&&"string"===typeof i?i.split(",").map(parseFloat):[999,999]}else r=t.options.proximity;else r=null;var o=t._map?t._map.getZoom():void 0,a={event:e,version:this.getEventSchemaVersion(e),created:+new Date,sessionIdentifier:this.getSessionId(),country:this.countries,userAgent:this.userAgent,language:this.language,bbox:this.bbox,types:this.types,endpoint:"mapbox.places",autocomplete:t.options.autocomplete,fuzzyMatch:t.options.fuzzyMatch,proximity:r,limit:t.options.limit,routing:t.options.routing,worldview:t.options.worldview,mapZoom:o,keyboardLocale:this.locale};if("search.select"===e?a.queryString=t.inputString:"search.select"!=e&&t._inputEl?a.queryString=t._inputEl.value:a.queryString=t.inputString,["search.keystroke","search.select"].includes(e)&&(a.path="geocoding/v5/mapbox.places"),"search.keystroke"===e&&n.key)a.lastAction=n.key;else if("search.select"===e&&n.selectedFeature){var s=n.selectedFeature,l=this.getSelectedIndex(s,t);if(a.resultIndex=l,a.resultPlaceName=s.place_name,a.resultId=s.id,s.properties&&(a.resultMapboxId=s.properties.mapbox_id),t._typeahead){var c=t._typeahead.data;c&&c.length>0&&(a.suggestionIds=this.getSuggestionIds(c),a.suggestionNames=this.getSuggestionNames(c),a.suggestionTypes=this.getSuggestionTypes(c),a.suggestionSources=this.getSuggestionSources(c))}}return this.validatePayload(a)?a:null},request:function(e,t){var n=new XMLHttpRequest;for(var r in n.onreadystatechange=function(){if(4==this.readyState)return 204==this.status?t(null):t(this.statusText)},n.open(e.method,e.host+"/"+e.path,!0),e.headers){var i=e.headers[r];n.setRequestHeader(r,i)}n.send(e.body)},handleError:function(e,t){if(t)return t(e)},generateSessionID:function(){return r()},getSessionId:function(){return this.pluginSessionID+"."+this.sessionIncrementer},getUserAgent:function(){return"mapbox-gl-geocoder."+this.version+"."+navigator.userAgent},getSelectedIndex:function(e,t){if(t._typeahead){var n=t._typeahead.data,r=e.id;return n.map((function(e){return e.id})).indexOf(r)}},getSuggestionIds:function(e){return e.map((function(e){return e.properties?e.properties.mapbox_id||"":e.id||""}))},getSuggestionNames:function(e){return e.map((function(e){return e.place_name||""}))},getSuggestionTypes:function(e){return e.map((function(e){return e.place_type&&Array.isArray(e.place_type)&&e.place_type[0]||""}))},getSuggestionSources:function(e){return e.map((function(e){return e._source||""}))},getEventSchemaVersion:function(e){return["search.keystroke","search.select"].includes(e)?"2.2":"2.0"},validatePayload:function(e){if(!e||!e.event)return!1;var t=e.event;return"search.start"===t?this.objectHasRequiredProps(e,["event","created","sessionIdentifier","queryString"]):"search.keystroke"===t?this.objectHasRequiredProps(e,["event","created","sessionIdentifier","queryString","lastAction"]):"search.select"!==t||this.objectHasRequiredProps(e,["event","created","sessionIdentifier","queryString","resultIndex","path","suggestionIds"])},objectHasRequiredProps:function(e,t){return t.every((function(t){return"queryString"===t?"string"===typeof e[t]&&e[t].length>0:void 0!==e[t]}))},shouldEnableLogging:function(e){return!1!==e.enableEventLogging&&(!e.origin||"https://api.mapbox.com"===e.origin)},flush:function(){this.eventQueue.length>0&&(this.send(this.eventQueue),this.eventQueue=new Array),this.timer&&clearTimeout(this.timer),this.flushInterval&&(this.timer=setTimeout(this.flush.bind(this),this.flushInterval))},push:function(e,t){this.eventQueue.push(e),(this.eventQueue.length>=this.maxQueueSize||t)&&this.flush()},remove:function(){this.flush()}},e.exports=i},438:e=>{e.exports={fr:{name:"France",bbox:[[-4.59235,41.380007],[9.560016,51.148506]]},us:{name:"United States",bbox:[[-171.791111,18.91619],[-66.96466,71.357764]]},ru:{name:"Russia",bbox:[[19.66064,41.151416],[190.10042,81.2504]]},ca:{name:"Canada",bbox:[[-140.99778,41.675105],[-52.648099,83.23324]]}}},792:e=>{function t(){}t.prototype={isSupport:function(){return Boolean(window.navigator.geolocation)},getCurrentPosition:function(){const e={enableHighAccuracy:!0};return new Promise((function(t,n){window.navigator.geolocation.getCurrentPosition(t,n,e)}))}},e.exports=t},4066:(e,t,n)=>{"use strict";var r=n(7053),i=n(446),o=n(49),a=n(7284).EventEmitter,s=n(438),l=n(7050),c=n(4012),u=n(5609),h=n(6397),d=n(3058),f=n(792),p=n(7651);const m=0,g=1,_=2;function y(e){this._eventEmitter=new a,this.options=o({},this.options,e),this.inputString="",this.fresh=!0,this.lastSelected=null,this.geolocation=new f}y.prototype={options:{zoom:16,flyTo:!0,trackProximity:!0,minLength:2,reverseGeocode:!1,flipCoordinates:!1,limit:5,origin:"https://api.mapbox.com",enableEventLogging:!0,marker:!0,mapboxgl:null,collapsed:!1,clearAndBlurOnEsc:!1,clearOnBlur:!1,enableGeolocation:!1,addressAccuracy:"street",getItemValue:function(e){return e.place_name},render:function(e){var t=e.place_name.split(",");return'
'+t[0]+'
'+t.splice(1,t.length).join(",")+"
"}},_headers:{},addTo:function(e){function t(e,t){if(!document.body.contains(t))throw new Error("Element provided to #addTo() exists, but is not in the DOM");const n=e.onAdd();t.appendChild(n)}if(e._controlContainer)e.addControl(this);else if(e instanceof HTMLElement)t(this,e);else{if("string"!=typeof e)throw new Error("Error: addTo must be a mapbox-gl-js map, an html element, or a CSS selector query for a single html element");{const n=document.querySelectorAll(e);if(0===n.length)throw new Error("Element ",e,"not found.");if(n.length>1)throw new Error("Geocoder can only be added to a single html element");t(this,n[0])}}},onAdd:function(e){if(e&&"string"!=typeof e&&(this._map=e),this.setLanguage(),this.options.localGeocoderOnly||(this.geocoderService=c(l({accessToken:this.options.accessToken,origin:this.options.origin}))),this.options.localGeocoderOnly&&!this.options.localGeocoder)throw new Error("A localGeocoder function must be specified to use localGeocoderOnly mode");this.eventManager=new u(this.options),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onPaste=this._onPaste.bind(this),this._onBlur=this._onBlur.bind(this),this._showButton=this._showButton.bind(this),this._hideButton=this._hideButton.bind(this),this._onQueryResult=this._onQueryResult.bind(this),this.clear=this.clear.bind(this),this._updateProximity=this._updateProximity.bind(this),this._collapse=this._collapse.bind(this),this._unCollapse=this._unCollapse.bind(this),this._clear=this._clear.bind(this),this._clearOnBlur=this._clearOnBlur.bind(this),this._geolocateUser=this._geolocateUser.bind(this);var t=this.container=document.createElement("div");t.className="mapboxgl-ctrl-geocoder mapboxgl-ctrl";var n=this.createIcon("search",'');this._inputEl=document.createElement("input"),this._inputEl.type="text",this._inputEl.className="mapboxgl-ctrl-geocoder--input",this.setPlaceholder(),this.options.collapsed&&(this._collapse(),this.container.addEventListener("mouseenter",this._unCollapse),this.container.addEventListener("mouseleave",this._collapse),this._inputEl.addEventListener("focus",this._unCollapse)),(this.options.collapsed||this.options.clearOnBlur)&&this._inputEl.addEventListener("blur",this._onBlur),this._inputEl.addEventListener("keydown",i(this._onKeyDown,200)),this._inputEl.addEventListener("paste",this._onPaste),this._inputEl.addEventListener("change",this._onChange),this.container.addEventListener("mouseenter",this._showButton),this.container.addEventListener("mouseleave",this._hideButton),this._inputEl.addEventListener("keyup",function(e){this.eventManager.keyevent(e,this)}.bind(this));var o=document.createElement("div");o.classList.add("mapboxgl-ctrl-geocoder--pin-right"),this._clearEl=document.createElement("button"),this._clearEl.setAttribute("aria-label","Clear"),this._clearEl.addEventListener("click",this.clear),this._clearEl.className="mapboxgl-ctrl-geocoder--button";var a=this.createIcon("close",'');if(this._clearEl.appendChild(a),this._loadingEl=this.createIcon("loading",''),o.appendChild(this._clearEl),o.appendChild(this._loadingEl),t.appendChild(n),t.appendChild(this._inputEl),t.appendChild(o),this.options.enableGeolocation&&this.geolocation.isSupport()){this._geolocateEl=document.createElement("button"),this._geolocateEl.setAttribute("aria-label","Geolocate"),this._geolocateEl.addEventListener("click",this._geolocateUser),this._geolocateEl.className="mapboxgl-ctrl-geocoder--button";var s=this.createIcon("geolocate",'');this._geolocateEl.appendChild(s),o.appendChild(this._geolocateEl),this._showGeolocateButton()}var h=this._typeahead=new r(this._inputEl,[],{filter:!1,minLength:this.options.minLength,limit:this.options.limit});this.setRenderFunction(this.options.render),h.getItemValue=this.options.getItemValue;var d=h.list.draw,f=this._footerNode=function(){var e=document.createElement("div");return e.className="mapboxgl-ctrl-geocoder--powered-by",e.innerHTML='Powered by Mapbox',e}();return h.list.draw=function(){d.call(this),f.addEventListener("mousedown",function(){this.selectingListItem=!0}.bind(this)),f.addEventListener("mouseup",function(){this.selectingListItem=!1}.bind(this)),this.element.appendChild(f)},this.mapMarker=null,this._handleMarker=this._handleMarker.bind(this),this._map&&(this.options.trackProximity&&(this._updateProximity(),this._map.on("moveend",this._updateProximity)),this._mapboxgl=this.options.mapboxgl,!this._mapboxgl&&this.options.marker&&(console.error("No mapboxgl detected in options. Map markers are disabled. Please set options.mapboxgl."),this.options.marker=!1)),t},_geolocateUser:function(){this._hideGeolocateButton(),this._showLoadingIcon(),this.geolocation.getCurrentPosition().then(function(e){this._hideLoadingIcon();const t={geometry:{type:"Point",coordinates:[e.coords.longitude,e.coords.latitude]}};this._handleMarker(t),this._fly(t),this._typeahead.clear(),this._typeahead.selected=!0,this.lastSelected=JSON.stringify(t),this._showClearButton(),this.fresh=!1;const n={limit:1,language:[this.options.language],query:t.geometry.coordinates,types:["address"]};if(this.options.localGeocoderOnly){const e=t.geometry.coordinates[0]+","+t.geometry.coordinates[1];this._setInputValue(e),this._eventEmitter.emit("result",{result:t})}else this.geocoderService.reverseGeocode(n).send().then(function(e){const n=e.body.features[0];if(n){const e=p.transformFeatureToGeolocationText(n,this.options.addressAccuracy);this._setInputValue(e),n.user_coordinates=t.geometry.coordinates,this._eventEmitter.emit("result",{result:n})}else this._eventEmitter.emit("result",{result:{user_coordinates:t.geometry.coordinates}})}.bind(this))}.bind(this)).catch(function(e){1===e.code?this._renderUserDeniedGeolocationError():this._renderLocationError(),this._hideLoadingIcon(),this._showGeolocateButton(),this._hideAttribution()}.bind(this))},createIcon:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("class","mapboxgl-ctrl-geocoder--icon mapboxgl-ctrl-geocoder--icon-"+e),n.setAttribute("viewBox","0 0 18 18"),n.setAttribute("xml:space","preserve"),n.setAttribute("width",18),n.setAttribute("height",18),n.innerHTML=t,n},onRemove:function(){return this.container.parentNode.removeChild(this.container),this.options.trackProximity&&this._map&&this._map.off("moveend",this._updateProximity),this._removeMarker(),this._map=null,this},_setInputValue:function(e){this._inputEl.value=e,setTimeout(function(){this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0)}.bind(this),1)},_onPaste:function(e){var t=(e.clipboardData||window.clipboardData).getData("text");t.length>=this.options.minLength&&this._geocode(t)},_onKeyDown:function(e){var t=27,n=9;if(e.keyCode===t&&this.options.clearAndBlurOnEsc)return this._clear(e),this._inputEl.blur();var r=e.target&&e.target.shadowRoot?e.target.shadowRoot.activeElement:e.target;if(!(r?r.value:""))return this.fresh=!0,e.keyCode!==n&&this.clear(e),this._showGeolocateButton(),this._hideClearButton();this._hideGeolocateButton(),e.metaKey||-1!==[n,t,37,39,13,38,40].indexOf(e.keyCode)||r.value.length>=this.options.minLength&&this._geocode(r.value)},_showButton:function(){this._typeahead.selected&&this._showClearButton()},_hideButton:function(){this._typeahead.selected&&this._hideClearButton()},_showClearButton:function(){this._clearEl.style.display="block"},_hideClearButton:function(){this._clearEl.style.display="none"},_showGeolocateButton:function(){this._geolocateEl&&this.geolocation.isSupport()&&(this._geolocateEl.style.display="block")},_hideGeolocateButton:function(){this._geolocateEl&&(this._geolocateEl.style.display="none")},_showLoadingIcon:function(){this._loadingEl.style.display="block"},_hideLoadingIcon:function(){this._loadingEl.style.display="none"},_showAttribution:function(){this._footerNode.style.display="block"},_hideAttribution:function(){this._footerNode.style.display="none"},_onBlur:function(e){this.options.clearOnBlur&&this._clearOnBlur(e),this.options.collapsed&&this._collapse()},_onChange:function(){var e=this._typeahead.selected;e&&JSON.stringify(e)!==this.lastSelected&&(this._hideClearButton(),this.options.flyTo&&this._fly(e),this.options.marker&&this._mapboxgl&&this._handleMarker(e),this._inputEl.focus(),this._inputEl.scrollLeft=0,this._inputEl.setSelectionRange(0,0),this.lastSelected=JSON.stringify(e),this._eventEmitter.emit("result",{result:e}),this.eventManager.select(e,this))},_fly:function(e){var t;if(e.properties&&s[e.properties.short_code])t=o({},this.options.flyTo),this._map&&this._map.fitBounds(s[e.properties.short_code].bbox,t);else if(e.bbox){var n=e.bbox;t=o({},this.options.flyTo),this._map&&this._map.fitBounds([[n[0],n[1]],[n[2],n[3]]],t)}else{var r={zoom:this.options.zoom};t=o({},r,this.options.flyTo),e.center?t.center=e.center:e.geometry&&e.geometry.type&&"Point"===e.geometry.type&&e.geometry.coordinates&&(t.center=e.geometry.coordinates),this._map&&this._map.flyTo(t)}},_requestType:function(e,t){return e.localGeocoderOnly?g:e.reverseGeocode&&p.REVERSE_GEOCODE_COORD_RGX.test(t)?_:m},_setupConfig:function(e,t){const n=/[\s,]+/;var r=this,i=["bbox","limit","proximity","countries","types","language","reverseMode","mode","autocomplete","fuzzyMatch","routing","worldview"].reduce((function(e,t){if(void 0===r.options[t]||null===r.options[t])return e;["countries","types","language"].indexOf(t)>-1?e[t]=r.options[t].split(n):e[t]=r.options[t];const i="number"===typeof r.options[t].longitude&&"number"===typeof r.options[t].latitude;if("proximity"===t&&i){const n=r.options[t].longitude,i=r.options[t].latitude;e[t]=[n,i]}return e}),{});switch(e){case _:var a=t.split(n).map((function(e){return parseFloat(e,10)}));r.options.flipCoordinates||a.reverse(),!i.types||i.types[0],i=o(i,{query:a,limit:1}),["proximity","autocomplete","fuzzyMatch","bbox"].forEach((function(e){e in i&&delete i[e]}));break;case m:{const e=t.trim();/^(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)?$/.test(e)&&(t=t.replace(/,/g," ")),i=o(i,{query:t})}}return i.session_token=this.eventManager.getSessionId(),i},_geocode:function(e){this.inputString=e,this._showLoadingIcon(),this._eventEmitter.emit("loading",{query:e});const t=this._requestType(this.options,e),n=this._setupConfig(t,e);var r;switch(t){case g:r=Promise.resolve();break;case m:r=this.geocoderService.forwardGeocode(n).send();break;case _:r=this.geocoderService.reverseGeocode(n).send()}var i=this.options.localGeocoder&&this.options.localGeocoder(e)||[],o=[],a=null;return r.catch(function(e){a=e}.bind(this)).then(function(t){this._hideLoadingIcon();var r={};return t?"200"==t.statusCode&&((r=t.body).request=t.request,r.headers=t.headers,this._headers=t.headers):r={type:"FeatureCollection",features:[]},r.config=n,this.fresh&&(this.eventManager.start(this),this.fresh=!1),r.features&&r.features.length&&r.features.map((function(e){e._source="mapbox"})),r.features=r.features?i.concat(r.features):i,this.options.externalGeocoder?(o=this.options.externalGeocoder(e,r.features)||Promise.resolve([])).then((function(e){return r.features=r.features?e.concat(r.features):e,r}),(function(){return r})):r}.bind(this)).then(function(e){if(a)throw a;this.options.filter&&e.features.length&&(e.features=e.features.filter(this.options.filter)),e.features.length?(this._showClearButton(),this._hideGeolocateButton(),this._showAttribution(),this._eventEmitter.emit("results",e),this._typeahead.update(e.features)):(this._hideClearButton(),this._hideAttribution(),this._typeahead.selected=null,this._renderNoResults(),this._eventEmitter.emit("results",e))}.bind(this)).catch(function(e){this._hideLoadingIcon(),this._hideAttribution(),i.length&&this.options.localGeocoder||o.length&&this.options.externalGeocoder?(this._showClearButton(),this._hideGeolocateButton(),this._typeahead.update(i)):(this._hideClearButton(),this._typeahead.selected=null,this._renderError()),this._eventEmitter.emit("results",{features:i}),this._eventEmitter.emit("error",{error:e})}.bind(this)),r},_clear:function(e){e&&e.preventDefault(),this._inputEl.value="",this._typeahead.selected=null,this._typeahead.clear(),this.eventManager.sessionIncrementer++,this._onChange(),this._hideClearButton(),this._showGeolocateButton(),this._removeMarker(),this.lastSelected=null,this._eventEmitter.emit("clear"),this.fresh=!0},clear:function(e){this._clear(e),this._inputEl.focus()},_clearOnBlur:function(e){e.relatedTarget&&this._clear(e)},_onQueryResult:function(e){var t=e.body;if(t.features.length){var n=t.features[0];this._typeahead.selected=n,this._inputEl.value=n.place_name,this._onChange()}},_updateProximity:function(){if(this._map&&this.options.trackProximity)if(this._map.getZoom()>9){var e=this._map.getCenter().wrap();this.setProximity({longitude:e.lng,latitude:e.lat},!1)}else this.setProximity(null,!1)},_collapse:function(){this._inputEl.value||this._inputEl===document.activeElement||this.container.classList.add("mapboxgl-ctrl-geocoder--collapsed")},_unCollapse:function(){this.container.classList.remove("mapboxgl-ctrl-geocoder--collapsed")},query:function(e){return this._geocode(e).then(this._onQueryResult),this},_renderError:function(){this._renderMessage("
There was an error reaching the server
")},_renderLocationError:function(){this._renderMessage("
A location error has occurred
")},_renderNoResults:function(){this._renderMessage("
No results found
")},_renderUserDeniedGeolocationError:function(){this._renderMessage("
Geolocation permission denied
")},_renderMessage:function(e){this._typeahead.update([]),this._typeahead.selected=null,this._typeahead.clear(),this._typeahead.renderError(e)},_getPlaceholderText:function(){if(this.options.placeholder)return this.options.placeholder;if(this.options.language){var e=this.options.language.split(",")[0],t=d.language(e),n=h.placeholder[t];if(n)return n}return"Search"},setInput:function(e,t){return void 0===t&&(t=!1),this._inputEl.value=e,this._typeahead.selected=null,this._typeahead.clear(),e.length>=this.options.minLength&&(t?this._geocode(e):this._onChange()),this},setProximity:function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.options.proximity=e,t&&(this.options.trackProximity=!1),this},getProximity:function(){return this.options.proximity},setRenderFunction:function(e){return e&&"function"==typeof e&&(this._typeahead.render=e),this},getRenderFunction:function(){return this._typeahead.render},setLanguage:function(e){var t=navigator.language||navigator.userLanguage||navigator.browserLanguage;return this.options.language=e||this.options.language||t,this},getLanguage:function(){return this.options.language},getZoom:function(){return this.options.zoom},setZoom:function(e){return this.options.zoom=e,this},getFlyTo:function(){return this.options.flyTo},setFlyTo:function(e){return this.options.flyTo=e,this},getPlaceholder:function(){return this.options.placeholder},setPlaceholder:function(e){return this.options.placeholder=e||this._getPlaceholderText(),this._inputEl.placeholder=this.options.placeholder,this._inputEl.setAttribute("aria-label",this.options.placeholder),this},getBbox:function(){return this.options.bbox},setBbox:function(e){return this.options.bbox=e,this},getCountries:function(){return this.options.countries},setCountries:function(e){return this.options.countries=e,this},getTypes:function(){return this.options.types},setTypes:function(e){return this.options.types=e,this},getMinLength:function(){return this.options.minLength},setMinLength:function(e){return this.options.minLength=e,this._typeahead&&(this._typeahead.options.minLength=e),this},getLimit:function(){return this.options.limit},setLimit:function(e){return this.options.limit=e,this._typeahead&&(this._typeahead.options.limit=e),this},getFilter:function(){return this.options.filter},setFilter:function(e){return this.options.filter=e,this},setOrigin:function(e){return this.options.origin=e,this.geocoderService=c(l({accessToken:this.options.accessToken,origin:this.options.origin})),this},getOrigin:function(){return this.options.origin},setAccessToken:function(e){return this.options.accessToken=e,this.geocoderService=c(l({accessToken:this.options.accessToken,origin:this.options.origin})),this},setAutocomplete:function(e){return this.options.autocomplete=e,this},getAutocomplete:function(){return this.options.autocomplete},setFuzzyMatch:function(e){return this.options.fuzzyMatch=e,this},getFuzzyMatch:function(){return this.options.fuzzyMatch},setRouting:function(e){return this.options.routing=e,this},getRouting:function(){return this.options.routing},setWorldview:function(e){return this.options.worldview=e,this},getWorldview:function(){return this.options.worldview},_handleMarker:function(e){if(this._map){this._removeMarker();var t=o({},{color:"#4668F2"},this.options.marker);return this.mapMarker=new this._mapboxgl.Marker(t),e.center?this.mapMarker.setLngLat(e.center).addTo(this._map):e.geometry&&e.geometry.type&&"Point"===e.geometry.type&&e.geometry.coordinates&&this.mapMarker.setLngLat(e.geometry.coordinates).addTo(this._map),this}},_removeMarker:function(){this.mapMarker&&(this.mapMarker.remove(),this.mapMarker=null)},on:function(e,t){return this._eventEmitter.on(e,t),this},off:function(e,t){return this._eventEmitter.removeListener(e,t),this.eventManager.remove(),this}},e.exports=y},6397:e=>{"use strict";e.exports={placeholder:{de:"Suche",it:"Ricerca",en:"Search",nl:"Zoeken",fr:"Chercher",ca:"Cerca",he:"\u05dc\u05d7\u05e4\u05e9",ja:"\u30b5\u30fc\u30c1",lv:"Mekl\u0113t",pt:"Procurar",sr:"\u041f\u0440\u0435\u0442\u0440\u0430\u0433\u0430",zh:"\u641c\u7d22",cs:"Vyhled\xe1v\xe1n\xed",hu:"Keres\xe9s",ka:"\u10eb\u10d8\u10d4\u10d1\u10d0",nb:"S\xf8ke",sk:"Vyh\u013ead\xe1vanie",th:"\u0e04\u0e49\u0e19\u0e2b\u0e32",fi:"Hae",is:"Leita",ko:"\uc218\uc0c9",pl:"Szukaj",sl:"Iskanje",fa:"\u062c\u0633\u062a\u062c\u0648",ru:"\u041f\u043e\u0438\u0441\u043a"}}},7651:e=>{function t(e){const t=e.address||"",n=e.text||"",r=e.place_name||"",i={address:r.split(",")[0],houseNumber:t,street:n,placeName:r};return e.context.forEach((function(e){const t=e.id.split(".")[0];i[t]=e.text})),i}e.exports={transformFeatureToGeolocationText:function(e,n){const r=t(e),i=["address","street","place","country"];if("function"===typeof n)return n(r);const o=i.indexOf(n);return(-1===o?i:i.slice(o)).reduce((function(e,t){return r[t]?(""!==e&&(e+=", "),e+r[t]):e}),"")},getAddressInfo:t,REVERSE_GEOCODE_COORD_RGX:/^[ ]*(-?\d{1,3}(\.\d{0,256})?)[, ]+(-?\d{1,3}(\.\d{0,256})?)[ ]*$/}},7050:(e,t,n)=>{"use strict";var r=n(6537);e.exports=r},6537:(e,t,n)=>{"use strict";var r=n(3465),i=n(4690);function o(e){i.call(this,e)}o.prototype=Object.create(i.prototype),o.prototype.constructor=o,o.prototype.sendRequest=r.browserSend,o.prototype.abortRequest=r.browserAbort,e.exports=function(e){return new o(e)}},3465:(e,t,n)=>{"use strict";var r=n(6238),i=n(7227),o=n(3487),a=n(3104),s={};function l(e){var t=e.total,n=e.loaded;return{total:t,transferred:n,percent:100*n/t}}function c(e,t){return new Promise((function(n,r){t.onprogress=function(t){e.emitter.emit(o.EVENT_PROGRESS_DOWNLOAD,l(t))};var a=e.file;a&&(t.upload.onprogress=function(t){e.emitter.emit(o.EVENT_PROGRESS_UPLOAD,l(t))}),t.onerror=function(e){r(e)},t.onabort=function(){var t=new i({request:e,type:o.ERROR_REQUEST_ABORTED});r(t)},t.onload=function(){if(delete s[e.id],t.status<200||t.status>=400){var o=new i({request:e,body:t.response,statusCode:t.status});r(o)}else n(t)};var c=e.body;"string"===typeof c?t.send(c):c?t.send(JSON.stringify(c)):a?t.send(a):t.send(),s[e.id]=t})).then((function(t){return function(e,t){return new r(e,{body:t.response,headers:a(t.getAllResponseHeaders()),statusCode:t.status})}(e,t)}))}function u(e,t){var n=e.url(t),r=new window.XMLHttpRequest;return r.open(e.method,n),Object.keys(e.headers).forEach((function(t){r.setRequestHeader(t,e.headers[t])})),r}e.exports={browserAbort:function(e){var t=s[e.id];t&&(t.abort(),delete s[e.id])},sendRequestXhr:c,browserSend:function(e){return Promise.resolve().then((function(){var t=u(e,e.client.accessToken);return c(e,t)}))},createRequestXhr:u}},4690:(e,t,n)=>{"use strict";var r=n(9229),i=n(3868),o=n(3487);function a(e){if(!e||!e.accessToken)throw new Error("Cannot create a client without an access token");r(e.accessToken),this.accessToken=e.accessToken,this.origin=e.origin||o.API_ORIGIN}a.prototype.createRequest=function(e){return new i(this,e)},e.exports=a},7227:(e,t,n)=>{"use strict";var r=n(3487);e.exports=function(e){var t,n=e.type||r.ERROR_HTTP;if(e.body)try{t=JSON.parse(e.body)}catch(o){t=e.body}else t=null;var i=e.message||null;i||("string"===typeof t?i=t:t&&"string"===typeof t.message?i=t.message:n===r.ERROR_REQUEST_ABORTED&&(i="Request aborted")),this.message=i,this.type=n,this.statusCode=e.statusCode||null,this.request=e.request,this.body=t}},3868:(e,t,n)=>{"use strict";var r=n(9229),i=n(49),o=n(9097),a=n(5141),s=n(3487),l=1;function c(e,t){if(!e)throw new Error("MapiRequest requires a client");if(!t||!t.path||!t.method)throw new Error("MapiRequest requires an options object with path and method properties");var n={};t.body&&(n["content-type"]="application/json");var r=i(n,t.headers),a=Object.keys(r).reduce((function(e,t){return e[t.toLowerCase()]=r[t],e}),{});this.id=l++,this._options=t,this.emitter=new o,this.client=e,this.response=null,this.error=null,this.sent=!1,this.aborted=!1,this.path=t.path,this.method=t.method,this.origin=t.origin||e.origin,this.query=t.query||{},this.params=t.params||{},this.body=t.body||null,this.file=t.file||null,this.encoding=t.encoding||"utf8",this.sendFileAs=t.sendFileAs||null,this.headers=a}c.prototype.url=function(e){var t=a.prependOrigin(this.path,this.origin);t=a.appendQueryObject(t,this.query);var n=this.params,o=null==e?this.client.accessToken:e;if(o){t=a.appendQueryParam(t,"access_token",o);var s=r(o).user;n=i({ownerId:s},n)}return t=a.interpolateRouteParams(t,n),t},c.prototype.send=function(){var e=this;if(e.sent)throw new Error("This request has already been sent. Check the response and error properties. Create a new request with clone().");return e.sent=!0,e.client.sendRequest(e).then((function(t){return e.response=t,e.emitter.emit(s.EVENT_RESPONSE,t),t}),(function(t){throw e.error=t,e.emitter.emit(s.EVENT_ERROR,t),t}))},c.prototype.abort=function(){this._nextPageRequest&&(this._nextPageRequest.abort(),delete this._nextPageRequest),this.response||this.error||this.aborted||(this.aborted=!0,this.client.abortRequest(this))},c.prototype.eachPage=function(e){var t=this;function n(n){e(null,n,(function(){delete t._nextPageRequest;var e=n.nextPage();e&&(t._nextPageRequest=e,i(e))}))}function r(t){e(t,null,(function(){}))}function i(e){e.send().then(n,r)}i(this)},c.prototype.clone=function(){return this._extend()},c.prototype._extend=function(e){var t=i(this._options,e);return new c(this.client,t)},e.exports=c},6238:(e,t,n)=>{"use strict";var r=n(7484);function i(e,t){this.request=e,this.headers=t.headers,this.rawBody=t.body,this.statusCode=t.statusCode;try{this.body=JSON.parse(t.body||"{}")}catch(n){this.body=t.body}this.links=r(this.headers.link)}i.prototype.hasNextPage=function(){return!!this.links.next},i.prototype.nextPage=function(){return this.hasNextPage()?this.request._extend({path:this.links.next.url}):null},e.exports=i},3487:e=>{"use strict";e.exports={API_ORIGIN:"https://api.mapbox.com",EVENT_PROGRESS_DOWNLOAD:"downloadProgress",EVENT_PROGRESS_UPLOAD:"uploadProgress",EVENT_ERROR:"error",EVENT_RESPONSE:"response",ERROR_HTTP:"HttpError",ERROR_REQUEST_ABORTED:"RequestAbortedError"}},3104:e=>{"use strict";e.exports=function(e){var t={};return e?(e.trim().split(/[\r|\n]+/).forEach((function(e){var n=function(e){var t=e.indexOf(":");return{name:e.substring(0,t).trim().toLowerCase(),value:e.substring(t+1).trim()}}(e);t[n.name]=n.value})),t):t}},7484:e=>{"use strict";e.exports=function(e){return e?e.split(/,\s*]*)>(.*)/);if(!t)return null;var n=t[1],r=t[2].split(";"),i=null,o=r.reduce((function(e,t){var n=function(e){var t=e.match(/\s*(.+)\s*=\s*"?([^"]+)"?/);return t?{key:t[1],value:t[2]}:null}(t);return n?"rel"===n.key?(i||(i=n.value),e):(e[n.key]=n.value,e):e}),{});return i?{url:n,rel:i,params:o}:null}(t);return n?(n.rel.split(/\s+/).forEach((function(t){e[t]||(e[t]={url:n.url,params:n.params})})),e):e}),{}):{}}},5141:e=>{"use strict";function t(e){return Array.isArray(e)?e.map(encodeURIComponent).join(","):encodeURIComponent(String(e))}function n(e,n,r){if(!1===r||null===r)return e;var i=/\?/.test(e)?"&":"?",o=encodeURIComponent(n);return void 0!==r&&""!==r&&!0!==r&&(o+="="+t(r)),""+e+i+o}e.exports={appendQueryObject:function(e,t){if(!t)return e;var r=e;return Object.keys(t).forEach((function(e){var i=t[e];void 0!==i&&(Array.isArray(i)&&(i=i.filter((function(e){return null!==e&&void 0!==e})).join(",")),r=n(r,e,i))})),r},appendQueryParam:n,prependOrigin:function(e,t){if(!t)return e;if("http"===e.slice(0,4))return e;var n="/"===e[0]?"":"/";return""+t.replace(/\/$/,"")+n+e},interpolateRouteParams:function(e,n){return n?e.replace(/\/:([a-zA-Z0-9]+)/g,(function(e,r){var i=n[r];if(void 0===i)throw new Error("Unspecified route parameter "+r);return"/"+t(i)})):e}}},9097:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,a){if("function"!==typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||e,a),l=n?n+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,a=new Array(o);i{"use strict";var r=n(49),i=n(5217),o=n(7594),a=n(2522),s=n(682),l={},c=["country","region","postcode","district","place","locality","neighborhood","address","poi","poi.landmark"];l.forwardGeocode=function(e){i.assertShape({query:i.required(i.string),mode:i.oneOf("mapbox.places","mapbox.places-permanent"),countries:i.arrayOf(i.string),proximity:i.oneOf(i.coordinates,"ip"),types:i.arrayOf(i.oneOf(c)),autocomplete:i.boolean,bbox:i.arrayOf(i.number),limit:i.number,language:i.arrayOf(i.string),routing:i.boolean,fuzzyMatch:i.boolean,worldview:i.string,session_token:i.string})(e),e.mode=e.mode||"mapbox.places";var t=a(r({country:e.countries},o(e,["proximity","types","autocomplete","bbox","limit","language","routing","fuzzyMatch","worldview","session_token"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(e,["mode","query"]),query:t})},l.reverseGeocode=function(e){i.assertShape({query:i.required(i.coordinates),mode:i.oneOf("mapbox.places","mapbox.places-permanent"),countries:i.arrayOf(i.string),types:i.arrayOf(i.oneOf(c)),bbox:i.arrayOf(i.number),limit:i.number,language:i.arrayOf(i.string),reverseMode:i.oneOf("distance","score"),routing:i.boolean,worldview:i.string,session_token:i.string})(e),e.mode=e.mode||"mapbox.places";var t=a(r({country:e.countries},o(e,["country","types","bbox","limit","language","reverseMode","routing","worldview","session_token"])));return this.client.createRequest({method:"GET",path:"/geocoding/v5/:mode/:query.json",params:o(e,["mode","query"]),query:t})},e.exports=s(l)},682:(e,t,n)=>{"use strict";var r=n(4690),i=n(6537);e.exports=function(e){return function(t){var n;n=r.prototype.isPrototypeOf(t)?t:i(t);var o=Object.create(e);return o.client=n,o}}},743:e=>{"use strict";e.exports=function(e,t){return Object.keys(e).reduce((function(n,r){return n[r]=t(r,e[r]),n}),{})}},7594:e=>{"use strict";e.exports=function(e,t){var n=function(e,n){return-1!==t.indexOf(e)&&void 0!==n};return"function"===typeof t&&(n=t),Object.keys(e).filter((function(t){return n(t,e[t])})).reduce((function(t,n){return t[n]=e[n],t}),{})}},2522:(e,t,n)=>{"use strict";var r=n(743);e.exports=function(e){return r(e,(function(e,t){return"boolean"===typeof t?JSON.stringify(t):t}))}},5217:(e,t,n)=>{"use strict";var r=n(49),i=n(6366);e.exports=r(i,{file:function(e){if("undefined"!==typeof window){if(e instanceof n.g.Blob||e instanceof n.g.ArrayBuffer)return;return"Blob or ArrayBuffer"}if("string"!==typeof e&&void 0===e.pipe)return"Filename or Readable stream"},date:function(e){var t="date";if("boolean"===typeof e)return t;try{var n=new Date(e);if(n.getTime&&isNaN(n.getTime()))return t}catch(r){return t}},coordinates:function(e){return i.tuple(i.number,i.number)(e)},assertShape:function(e,t){return i.assert(i.strictShape(e),t)}})},9229:(e,t,n)=>{"use strict";var r=n(2511),i={};function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.exports=function(e){if(i[e])return i[e];var t=e.split("."),n=t[0],a=t[1];if(!a)throw new Error("Invalid token");var s=function(e){try{return JSON.parse(r.decode(e))}catch(t){throw new Error("Invalid token")}}(a),l={usage:n,user:s.u};return o(s,"a")&&(l.authorization=s.a),o(s,"exp")&&(l.expires=1e3*s.exp),o(s,"iat")&&(l.created=1e3*s.iat),o(s,"scopes")&&(l.scopes=s.scopes),o(s,"client")&&(l.client=s.client),o(s,"ll")&&(l.lastLogin=s.ll),o(s,"iu")&&(l.impersonator=s.iu),i[e]=l,l}},4802:(e,t,n)=>{"use strict";var r=n(4994);t.A=void 0;var i=r(n(39)),o=n(579);t.A=(0,i.default)((0,o.jsx)("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close")},6061:(e,t,n)=>{"use strict";var r=n(4994);t.A=void 0;var i=r(n(39)),o=n(579);t.A=(0,i.default)((0,o.jsx)("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"DragIndicator")},2462:(e,t,n)=>{"use strict";var r=n(4994);t.A=void 0;var i=r(n(39)),o=n(579);t.A=(0,i.default)((0,o.jsx)("path",{d:"m11.99 18.54-7.37-5.73L3 14.07l9 7 9-7-1.63-1.27zM12 16l7.36-5.73L21 9l-9-7-9 7 1.63 1.27z"}),"Layers")},8082:(e,t,n)=>{"use strict";var r=n(4994);t.A=void 0;var i=r(n(39)),o=n(579);t.A=(0,i.default)((0,o.jsx)("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"MoreVert")},2577:(e,t,n)=>{"use strict";var r=n(4994);t.A=void 0;var i=r(n(39)),o=n(579);t.A=(0,i.default)((0,o.jsx)("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6"}),"Settings")},5624:(e,t,n)=>{"use strict";var r=n(4994);t.A=void 0;var i=r(n(39)),o=n(579);t.A=(0,i.default)([(0,o.jsx)("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14"},"0"),(0,o.jsx)("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2z"},"1")],"ZoomIn")},39:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return r.createSvgIcon}});var r=n(4962)},7470:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r={50:"#e3f2fd",100:"#bbdefb",200:"#90caf9",300:"#64b5f6",400:"#42a5f5",500:"#2196f3",600:"#1e88e5",700:"#1976d2",800:"#1565c0",900:"#0d47a1",A100:"#82b1ff",A200:"#448aff",A400:"#2979ff",A700:"#2962ff"}},5881:(e,t)=>{"use strict";var n,r=Symbol.for("react.element"),i=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.server_context"),h=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen");function _(e){if("object"===typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case o:case s:case a:case d:case f:return e;default:switch(e=e&&e.$$typeof){case u:case c:case h:case m:case p:case l:return e;default:return t}}case i:return t}}}n=Symbol.for("react.module.reference")},805:(e,t,n)=>{"use strict";n(5881)},3623:(e,t,n)=>{"use strict";n.d(t,{A:()=>N});var r=n(8168),i=n(8587),o=n(6632),a=n(3216),s=n(7758),l=n(8812),c=n(8280);var u=n(7266);const h={black:"#000",white:"#fff"},d={50:"#fafafa",100:"#f5f5f5",200:"#eeeeee",300:"#e0e0e0",400:"#bdbdbd",500:"#9e9e9e",600:"#757575",700:"#616161",800:"#424242",900:"#212121",A100:"#f5f5f5",A200:"#eeeeee",A400:"#bdbdbd",A700:"#616161"},f={50:"#f3e5f5",100:"#e1bee7",200:"#ce93d8",300:"#ba68c8",400:"#ab47bc",500:"#9c27b0",600:"#8e24aa",700:"#7b1fa2",800:"#6a1b9a",900:"#4a148c",A100:"#ea80fc",A200:"#e040fb",A400:"#d500f9",A700:"#aa00ff"},p={50:"#ffebee",100:"#ffcdd2",200:"#ef9a9a",300:"#e57373",400:"#ef5350",500:"#f44336",600:"#e53935",700:"#d32f2f",800:"#c62828",900:"#b71c1c",A100:"#ff8a80",A200:"#ff5252",A400:"#ff1744",A700:"#d50000"},m={50:"#fff3e0",100:"#ffe0b2",200:"#ffcc80",300:"#ffb74d",400:"#ffa726",500:"#ff9800",600:"#fb8c00",700:"#f57c00",800:"#ef6c00",900:"#e65100",A100:"#ffd180",A200:"#ffab40",A400:"#ff9100",A700:"#ff6d00"};var g=n(7470);const _={50:"#e1f5fe",100:"#b3e5fc",200:"#81d4fa",300:"#4fc3f7",400:"#29b6f6",500:"#03a9f4",600:"#039be5",700:"#0288d1",800:"#0277bd",900:"#01579b",A100:"#80d8ff",A200:"#40c4ff",A400:"#00b0ff",A700:"#0091ea"},y={50:"#e8f5e9",100:"#c8e6c9",200:"#a5d6a7",300:"#81c784",400:"#66bb6a",500:"#4caf50",600:"#43a047",700:"#388e3c",800:"#2e7d32",900:"#1b5e20",A100:"#b9f6ca",A200:"#69f0ae",A400:"#00e676",A700:"#00c853"},v=["mode","contrastThreshold","tonalOffset"],x={text:{primary:"rgba(0, 0, 0, 0.87)",secondary:"rgba(0, 0, 0, 0.6)",disabled:"rgba(0, 0, 0, 0.38)"},divider:"rgba(0, 0, 0, 0.12)",background:{paper:h.white,default:h.white},action:{active:"rgba(0, 0, 0, 0.54)",hover:"rgba(0, 0, 0, 0.04)",hoverOpacity:.04,selected:"rgba(0, 0, 0, 0.08)",selectedOpacity:.08,disabled:"rgba(0, 0, 0, 0.26)",disabledBackground:"rgba(0, 0, 0, 0.12)",disabledOpacity:.38,focus:"rgba(0, 0, 0, 0.12)",focusOpacity:.12,activatedOpacity:.12}},b={text:{primary:h.white,secondary:"rgba(255, 255, 255, 0.7)",disabled:"rgba(255, 255, 255, 0.5)",icon:"rgba(255, 255, 255, 0.5)"},divider:"rgba(255, 255, 255, 0.12)",background:{paper:"#121212",default:"#121212"},action:{active:h.white,hover:"rgba(255, 255, 255, 0.08)",hoverOpacity:.08,selected:"rgba(255, 255, 255, 0.16)",selectedOpacity:.16,disabled:"rgba(255, 255, 255, 0.3)",disabledBackground:"rgba(255, 255, 255, 0.12)",disabledOpacity:.38,focus:"rgba(255, 255, 255, 0.12)",focusOpacity:.12,activatedOpacity:.24}};function w(e,t,n,r){const i=r.light||r,o=r.dark||1.5*r;e[t]||(e.hasOwnProperty(n)?e[t]=e[n]:"light"===t?e.light=(0,u.a)(e.main,i):"dark"===t&&(e.dark=(0,u.e$)(e.main,o)))}function S(e){const{mode:t="light",contrastThreshold:n=3,tonalOffset:s=.2}=e,l=(0,i.A)(e,v),c=e.primary||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:g.A[200],light:g.A[50],dark:g.A[400]}:{main:g.A[700],light:g.A[400],dark:g.A[800]}}(t),S=e.secondary||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:f[200],light:f[50],dark:f[400]}:{main:f[500],light:f[300],dark:f[700]}}(t),M=e.error||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:p[500],light:p[300],dark:p[700]}:{main:p[700],light:p[400],dark:p[800]}}(t),A=e.info||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:_[400],light:_[300],dark:_[700]}:{main:_[700],light:_[500],dark:_[900]}}(t),E=e.success||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:y[400],light:y[300],dark:y[700]}:{main:y[800],light:y[500],dark:y[900]}}(t),T=e.warning||function(){return"dark"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"light")?{main:m[400],light:m[300],dark:m[700]}:{main:"#ed6c02",light:m[500],dark:m[900]}}(t);function C(e){return(0,u.eM)(e,b.text.primary)>=n?b.text.primary:x.text.primary}const k=e=>{let{color:t,name:n,mainShade:i=500,lightShade:a=300,darkShade:l=700}=e;if(t=(0,r.A)({},t),!t.main&&t[i]&&(t.main=t[i]),!t.hasOwnProperty("main"))throw new Error((0,o.A)(11,n?" (".concat(n,")"):"",i));if("string"!==typeof t.main)throw new Error((0,o.A)(12,n?" (".concat(n,")"):"",JSON.stringify(t.main)));return w(t,"light",a,s),w(t,"dark",l,s),t.contrastText||(t.contrastText=C(t.main)),t},I={dark:b,light:x};return(0,a.A)((0,r.A)({common:(0,r.A)({},h),mode:t,primary:k({color:c,name:"primary"}),secondary:k({color:S,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:k({color:M,name:"error"}),warning:k({color:T,name:"warning"}),info:k({color:A,name:"info"}),success:k({color:E,name:"success"}),grey:d,contrastThreshold:n,getContrastText:C,augmentColor:k,tonalOffset:s},I[t]),l)}const M=["fontFamily","fontSize","fontWeightLight","fontWeightRegular","fontWeightMedium","fontWeightBold","htmlFontSize","allVariants","pxToRem"];const A={textTransform:"uppercase"},E='"Roboto", "Helvetica", "Arial", sans-serif';function T(e,t){const n="function"===typeof t?t(e):t,{fontFamily:o=E,fontSize:s=14,fontWeightLight:l=300,fontWeightRegular:c=400,fontWeightMedium:u=500,fontWeightBold:h=700,htmlFontSize:d=16,allVariants:f,pxToRem:p}=n,m=(0,i.A)(n,M);const g=s/14,_=p||(e=>"".concat(e/d*g,"rem")),y=(e,t,n,i,a)=>{return(0,r.A)({fontFamily:o,fontWeight:e,fontSize:_(t),lineHeight:n},o===E?{letterSpacing:"".concat((s=i/t,Math.round(1e5*s)/1e5),"em")}:{},a,f);var s},v={h1:y(l,96,1.167,-1.5),h2:y(l,60,1.2,-.5),h3:y(c,48,1.167,0),h4:y(c,34,1.235,.25),h5:y(c,24,1.334,0),h6:y(u,20,1.6,.15),subtitle1:y(c,16,1.75,.15),subtitle2:y(u,14,1.57,.1),body1:y(c,16,1.5,.15),body2:y(c,14,1.43,.15),button:y(u,14,1.75,.4,A),caption:y(c,12,1.66,.4),overline:y(c,12,2.66,1,A),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return(0,a.A)((0,r.A)({htmlFontSize:d,pxToRem:_,fontFamily:o,fontSize:s,fontWeightLight:l,fontWeightRegular:c,fontWeightMedium:u,fontWeightBold:h},v),m,{clone:!1})}function C(){return["".concat(arguments.length<=0?void 0:arguments[0],"px ").concat(arguments.length<=1?void 0:arguments[1],"px ").concat(arguments.length<=2?void 0:arguments[2],"px ").concat(arguments.length<=3?void 0:arguments[3],"px rgba(0,0,0,").concat(.2,")"),"".concat(arguments.length<=4?void 0:arguments[4],"px ").concat(arguments.length<=5?void 0:arguments[5],"px ").concat(arguments.length<=6?void 0:arguments[6],"px ").concat(arguments.length<=7?void 0:arguments[7],"px rgba(0,0,0,").concat(.14,")"),"".concat(arguments.length<=8?void 0:arguments[8],"px ").concat(arguments.length<=9?void 0:arguments[9],"px ").concat(arguments.length<=10?void 0:arguments[10],"px ").concat(arguments.length<=11?void 0:arguments[11],"px rgba(0,0,0,").concat(.12,")")].join(",")}const k=["none",C(0,2,1,-1,0,1,1,0,0,1,3,0),C(0,3,1,-2,0,2,2,0,0,1,5,0),C(0,3,3,-2,0,3,4,0,0,1,8,0),C(0,2,4,-1,0,4,5,0,0,1,10,0),C(0,3,5,-1,0,5,8,0,0,1,14,0),C(0,3,5,-1,0,6,10,0,0,1,18,0),C(0,4,5,-2,0,7,10,1,0,2,16,1),C(0,5,5,-3,0,8,10,1,0,3,14,2),C(0,5,6,-3,0,9,12,1,0,3,16,2),C(0,6,6,-3,0,10,14,1,0,4,18,3),C(0,6,7,-4,0,11,15,1,0,4,20,3),C(0,7,8,-4,0,12,17,2,0,5,22,4),C(0,7,8,-4,0,13,19,2,0,5,24,4),C(0,7,9,-4,0,14,21,2,0,5,26,4),C(0,8,9,-5,0,15,22,2,0,6,28,5),C(0,8,10,-5,0,16,24,2,0,6,30,5),C(0,8,11,-5,0,17,26,2,0,6,32,5),C(0,9,11,-5,0,18,28,2,0,7,34,6),C(0,9,12,-6,0,19,29,2,0,7,36,6),C(0,10,13,-6,0,20,31,3,0,8,38,7),C(0,10,13,-6,0,21,33,3,0,8,40,7),C(0,10,14,-6,0,22,35,3,0,8,42,7),C(0,11,14,-7,0,23,36,3,0,9,44,8),C(0,11,15,-7,0,24,38,3,0,9,46,8)],I=["duration","easing","delay"],P={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},R={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function L(e){return"".concat(Math.round(e),"ms")}function z(e){if(!e)return 0;const t=e/36;return Math.round(10*(4+15*t**.25+t/5))}function O(e){const t=(0,r.A)({},P,e.easing),n=(0,r.A)({},R,e.duration);return(0,r.A)({getAutoHeightDuration:z,create:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["all"],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{duration:o=n.standard,easing:a=t.easeInOut,delay:s=0}=r;(0,i.A)(r,I);return(Array.isArray(e)?e:[e]).map((e=>"".concat(e," ").concat("string"===typeof o?o:L(o)," ").concat(a," ").concat("string"===typeof s?s:L(s)))).join(",")}},e,{easing:t,duration:n})}const D={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500},B=["breakpoints","mixins","spacing","palette","transitions","typography","shape"];function F(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{mixins:t={},palette:n={},transitions:u={},typography:h={}}=e,d=(0,i.A)(e,B);if(e.vars)throw new Error((0,o.A)(18));const f=S(n),p=(0,c.A)(e);let m=(0,a.A)(p,{mixins:(g=p.breakpoints,_=t,(0,r.A)({toolbar:{minHeight:56,[g.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[g.up("sm")]:{minHeight:64}}},_)),palette:f,shadows:k.slice(),typography:T(f,h),transitions:O(u),zIndex:(0,r.A)({},D)});var g,_;m=(0,a.A)(m,d);for(var y=arguments.length,v=new Array(y>1?y-1:0),x=1;x(0,a.A)(e,t)),m),m.unstable_sxConfig=(0,r.A)({},s.A,null==d?void 0:d.unstable_sxConfig),m.unstable_sx=function(e){return(0,l.A)({sx:e,theme:this})},m}const N=F},5170:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=(0,n(3623).A)()},3375:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r="$$material"},1475:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(7123);const i=e=>(0,r.A)(e)&&"classes"!==e},7123:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=function(e){return"ownerState"!==e&&"theme"!==e&&"sx"!==e&&"as"!==e}},4535:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>s});var r=n(8052),i=n(5170),o=n(3375),a=n(1475);const s=(0,r.Ay)({themeId:o.A,defaultTheme:i.A,rootShouldForwardProp:a.A})},1070:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});var r=n(2018);var i=n(5527);function o(e){let{props:t,name:n,defaultTheme:o,themeId:a}=e,s=(0,i.A)(o);a&&(s=s[a]||s);const l=function(e){const{theme:t,name:n,props:i}=e;return t&&t.components&&t.components[n]&&t.components[n].defaultProps?(0,r.A)(t.components[n].defaultProps,i):i}({theme:s,name:n,props:t});return l}var a=n(5170),s=n(3375);function l(e){let{props:t,name:n}=e;return o({props:t,name:n,defaultTheme:a.A,themeId:s.A})}},6803:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=n(410).A},9662:(e,t,n)=>{"use strict";n.d(t,{A:()=>v});var r=n(8168),i=n(5043),o=n(8587),a=n(8387),s=n(8606),l=n(6803),c=n(1070),u=n(4535),h=n(7056),d=n(2400);function f(e){return(0,d.Ay)("MuiSvgIcon",e)}(0,h.A)("MuiSvgIcon",["root","colorPrimary","colorSecondary","colorAction","colorError","colorDisabled","fontSizeInherit","fontSizeSmall","fontSizeMedium","fontSizeLarge"]);var p=n(579);const m=["children","className","color","component","fontSize","htmlColor","inheritViewBox","titleAccess","viewBox"],g=(0,u.Ay)("svg",{name:"MuiSvgIcon",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,"inherit"!==n.color&&t["color".concat((0,l.A)(n.color))],t["fontSize".concat((0,l.A)(n.fontSize))]]}})((e=>{let{theme:t,ownerState:n}=e;var r,i,o,a,s,l,c,u,h,d,f,p,m;return{userSelect:"none",width:"1em",height:"1em",display:"inline-block",fill:n.hasSvgAsChild?void 0:"currentColor",flexShrink:0,transition:null==(r=t.transitions)||null==(i=r.create)?void 0:i.call(r,"fill",{duration:null==(o=t.transitions)||null==(o=o.duration)?void 0:o.shorter}),fontSize:{inherit:"inherit",small:(null==(a=t.typography)||null==(s=a.pxToRem)?void 0:s.call(a,20))||"1.25rem",medium:(null==(l=t.typography)||null==(c=l.pxToRem)?void 0:c.call(l,24))||"1.5rem",large:(null==(u=t.typography)||null==(h=u.pxToRem)?void 0:h.call(u,35))||"2.1875rem"}[n.fontSize],color:null!=(d=null==(f=(t.vars||t).palette)||null==(f=f[n.color])?void 0:f.main)?d:{action:null==(p=(t.vars||t).palette)||null==(p=p.action)?void 0:p.active,disabled:null==(m=(t.vars||t).palette)||null==(m=m.action)?void 0:m.disabled,inherit:void 0}[n.color]}})),_=i.forwardRef((function(e,t){const n=(0,c.A)({props:e,name:"MuiSvgIcon"}),{children:u,className:h,color:d="inherit",component:_="svg",fontSize:y="medium",htmlColor:v,inheritViewBox:x=!1,titleAccess:b,viewBox:w="0 0 24 24"}=n,S=(0,o.A)(n,m),M=i.isValidElement(u)&&"svg"===u.type,A=(0,r.A)({},n,{color:d,component:_,fontSize:y,instanceFontSize:e.fontSize,inheritViewBox:x,viewBox:w,hasSvgAsChild:M}),E={};x||(E.viewBox=w);const T=(e=>{const{color:t,fontSize:n,classes:r}=e,i={root:["root","inherit"!==t&&"color".concat((0,l.A)(t)),"fontSize".concat((0,l.A)(n))]};return(0,s.A)(i,f,r)})(A);return(0,p.jsxs)(g,(0,r.A)({as:_,className:(0,a.A)(T.root,h),focusable:"false",color:v,"aria-hidden":!b||void 0,role:b?"img":void 0,ref:t},E,S,M&&u.props,{ownerState:A,children:[M?u.props.children:u,b?(0,p.jsx)("title",{children:b}):null]}))}));_.muiName="SvgIcon";const y=_;function v(e,t){function n(n,i){return(0,p.jsx)(y,(0,r.A)({"data-testid":"".concat(t,"Icon"),ref:i},n,{children:e}))}return n.muiName=y.muiName,i.memo(i.forwardRef(n))}},950:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=n(6440).A},4962:(e,t,n)=>{"use strict";n.r(t),n.d(t,{capitalize:()=>i.A,createChainedFunction:()=>o,createSvgIcon:()=>a.A,debounce:()=>s.A,deprecatedPropType:()=>l,isMuiElement:()=>c.A,ownerDocument:()=>u.A,ownerWindow:()=>h.A,requirePropFactory:()=>d,setRef:()=>f,unstable_ClassNameGenerator:()=>b,unstable_useEnhancedEffect:()=>p.A,unstable_useId:()=>m,unsupportedProp:()=>g,useControlled:()=>_.A,useEventCallback:()=>y.A,useForkRef:()=>v.A,useIsFocusVisible:()=>x.A});var r=n(5430),i=n(6803);const o=n(4708).A;var a=n(9662),s=n(950);const l=function(e,t){return()=>null};var c=n(154),u=n(2427),h=n(6078);n(8168);const d=function(e,t){return()=>null};const f=n(9184).A;var p=n(5013);const m=n(992).A;const g=function(e,t,n,r,i){return null};var _=n(4516),y=n(3319),v=n(5849),x=n(7844);const b={configure:e=>{r.A.configure(e)}}},154:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(5043);const i=function(e,t){var n,i;return r.isValidElement(e)&&-1!==t.indexOf(null!=(n=e.type.muiName)?n:null==(i=e.type)||null==(i=i._payload)||null==(i=i.value)?void 0:i.muiName)}},2427:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=n(2144).A},6078:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=n(6288).A},4516:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=n(1944).A},5013:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=n(3844).A},3319:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=n(4626).A},5849:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=n(7042).A},7844:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=n(932).A},869:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});n(5043);var r=n(3290),i=n(579);function o(e){const{styles:t,defaultTheme:n={}}=e,o="function"===typeof t?e=>{return t(void 0===(r=e)||null===r||0===Object.keys(r).length?n:e);var r}:t;return(0,i.jsx)(r.mL,{styles:o})}},8131:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GlobalStyles:()=>u.A,StyledEngineProvider:()=>c,ThemeContext:()=>o.T,css:()=>i.AH,default:()=>h,internal_processStyles:()=>d,keyframes:()=>i.i7});var r=n(5903),i=n(3290),o=n(5756),a=(n(5043),n(5513)),s=n(579);let l;function c(e){const{injectFirst:t,children:n}=e;return t&&l?(0,s.jsx)(o.C,{value:l,children:n}):n}"object"===typeof document&&(l=(0,a.A)({key:"css",prepend:!0}));var u=n(869);function h(e,t){return(0,r.A)(e,t)}const d=(e,t)=>{Array.isArray(e.__emotion_styles)&&(e.__emotion_styles=t(e.__emotion_styles))}},7266:(e,t,n)=>{"use strict";var r=n(4994);t.X4=f,t.e$=p,t.tL=g,t.eM=function(e,t){const n=d(e),r=d(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)},t.a=m;var i=r(n(7245)),o=r(n(5383));function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return(0,o.default)(e,t,n)}function s(e){e=e.slice(1);const t=new RegExp(".{1,".concat(e.length>=6?2:1,"}"),"g");let n=e.match(t);return n&&1===n[0].length&&(n=n.map((e=>e+e))),n?"rgb".concat(4===n.length?"a":"","(").concat(n.map(((e,t)=>t<3?parseInt(e,16):Math.round(parseInt(e,16)/255*1e3)/1e3)).join(", "),")"):""}function l(e){if(e.type)return e;if("#"===e.charAt(0))return l(s(e));const t=e.indexOf("("),n=e.substring(0,t);if(-1===["rgb","rgba","hsl","hsla","color"].indexOf(n))throw new Error((0,i.default)(9,e));let r,o=e.substring(t+1,e.length-1);if("color"===n){if(o=o.split(" "),r=o.shift(),4===o.length&&"/"===o[3].charAt(0)&&(o[3]=o[3].slice(1)),-1===["srgb","display-p3","a98-rgb","prophoto-rgb","rec-2020"].indexOf(r))throw new Error((0,i.default)(10,r))}else o=o.split(",");return o=o.map((e=>parseFloat(e))),{type:n,values:o,colorSpace:r}}const c=e=>{const t=l(e);return t.values.slice(0,3).map(((e,n)=>-1!==t.type.indexOf("hsl")&&0!==n?"".concat(e,"%"):e)).join(" ")};function u(e){const{type:t,colorSpace:n}=e;let{values:r}=e;return-1!==t.indexOf("rgb")?r=r.map(((e,t)=>t<3?parseInt(e,10):e)):-1!==t.indexOf("hsl")&&(r[1]="".concat(r[1],"%"),r[2]="".concat(r[2],"%")),r=-1!==t.indexOf("color")?"".concat(n," ").concat(r.join(" ")):"".concat(r.join(", ")),"".concat(t,"(").concat(r,")")}function h(e){e=l(e);const{values:t}=e,n=t[0],r=t[1]/100,i=t[2]/100,o=r*Math.min(i,1-i),a=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(e+n/30)%12;return i-o*Math.max(Math.min(t-3,9-t,1),-1)};let s="rgb";const c=[Math.round(255*a(0)),Math.round(255*a(8)),Math.round(255*a(4))];return"hsla"===e.type&&(s+="a",c.push(t[3])),u({type:s,values:c})}function d(e){let t="hsl"===(e=l(e)).type||"hsla"===e.type?l(h(e)).values:e.values;return t=t.map((t=>("color"!==e.type&&(t/=255),t<=.03928?t/12.92:((t+.055)/1.055)**2.4))),Number((.2126*t[0]+.7152*t[1]+.0722*t[2]).toFixed(3))}function f(e,t){return e=l(e),t=a(t),"rgb"!==e.type&&"hsl"!==e.type||(e.type+="a"),"color"===e.type?e.values[3]="/".concat(t):e.values[3]=t,u(e)}function p(e,t){if(e=l(e),t=a(t),-1!==e.type.indexOf("hsl"))e.values[2]*=1-t;else if(-1!==e.type.indexOf("rgb")||-1!==e.type.indexOf("color"))for(let n=0;n<3;n+=1)e.values[n]*=1-t;return u(e)}function m(e,t){if(e=l(e),t=a(t),-1!==e.type.indexOf("hsl"))e.values[2]+=(100-e.values[2])*t;else if(-1!==e.type.indexOf("rgb"))for(let n=0;n<3;n+=1)e.values[n]+=(255-e.values[n])*t;else if(-1!==e.type.indexOf("color"))for(let n=0;n<3;n+=1)e.values[n]+=(1-e.values[n])*t;return u(e)}function g(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.15;return d(e)>.5?p(e,t):m(e,t)}},8052:(e,t,n)=>{"use strict";var r=n(4994);t.Ay=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{themeId:t,defaultTheme:n=m,rootShouldForwardProp:r=p,slotShouldForwardProp:l=p}=e,u=e=>(0,c.default)((0,i.default)({},e,{theme:_((0,i.default)({},e,{defaultTheme:n,themeId:t}))}));return u.__mui_systemSx=!0,function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,a.internal_processStyles)(e,(e=>e.filter((e=>!(null!=e&&e.__mui_systemSx)))));const{name:h,slot:f,skipVariantsResolver:m,skipSx:x,overridesResolver:b=y(g(f))}=c,w=(0,o.default)(c,d),S=void 0!==m?m:f&&"Root"!==f&&"root"!==f||!1,M=x||!1;let A=p;"Root"===f||"root"===f?A=r:f?A=l:function(e){return"string"===typeof e&&e.charCodeAt(0)>96}(e)&&(A=void 0);const E=(0,a.default)(e,(0,i.default)({shouldForwardProp:A,label:undefined},w)),T=e=>"function"===typeof e&&e.__emotion_real!==e||(0,s.isPlainObject)(e)?r=>v(e,(0,i.default)({},r,{theme:_({theme:r.theme,defaultTheme:n,themeId:t})})):e,C=function(r){let o=T(r);for(var a=arguments.length,s=new Array(a>1?a-1:0),l=1;l{const r=_((0,i.default)({},e,{defaultTheme:n,themeId:t}));if(!r.components||!r.components[h]||!r.components[h].styleOverrides)return null;const o=r.components[h].styleOverrides,a={};return Object.entries(o).forEach((t=>{let[n,o]=t;a[n]=v(o,(0,i.default)({},e,{theme:r}))})),b(e,a)})),h&&!S&&c.push((e=>{var r;const o=_((0,i.default)({},e,{defaultTheme:n,themeId:t}));return v({variants:null==o||null==(r=o.components)||null==(r=r[h])?void 0:r.variants},(0,i.default)({},e,{theme:o}))})),M||c.push(u);const d=c.length-s.length;if(Array.isArray(r)&&d>0){const e=new Array(d).fill("");o=[...r,...e],o.raw=[...r.raw,...e]}const f=E(o,...c);return e.muiName&&(f.muiName=e.muiName),f};return E.withConfig&&(C.withConfig=E.withConfig),C}};var i=r(n(4634)),o=r(n(4893)),a=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=f(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(n(8131)),s=n(4534),l=(r(n(578)),r(n(2046)),r(n(4989))),c=r(n(3234));const u=["ownerState"],h=["variants"],d=["name","slot","skipVariantsResolver","skipSx","overridesResolver"];function f(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(f=function(e){return e?n:t})(e)}function p(e){return"ownerState"!==e&&"theme"!==e&&"sx"!==e&&"as"!==e}const m=(0,l.default)(),g=e=>e?e.charAt(0).toLowerCase()+e.slice(1):e;function _(e){let{defaultTheme:t,theme:n,themeId:r}=e;return i=n,0===Object.keys(i).length?t:n[r]||n;var i}function y(e){return e?(t,n)=>n[e]:null}function v(e,t){let{ownerState:n}=t,r=(0,o.default)(t,u);const a="function"===typeof e?e((0,i.default)({ownerState:n},r)):e;if(Array.isArray(a))return a.flatMap((e=>v(e,(0,i.default)({ownerState:n},r))));if(a&&"object"===typeof a&&Array.isArray(a.variants)){const{variants:e=[]}=a;let t=(0,o.default)(a,h);return e.forEach((e=>{let o=!0;"function"===typeof e.props?o=e.props((0,i.default)({ownerState:n},r,n)):Object.keys(e.props).forEach((t=>{(null==n?void 0:n[t])!==e.props[t]&&r[t]!==e.props[t]&&(o=!1)})),o&&(Array.isArray(t)||(t=[t]),t.push("function"===typeof e.style?e.style((0,i.default)({ownerState:n},r,n)):e.style))})),t}return a}},9751:(e,t,n)=>{"use strict";n.d(t,{EU:()=>a,NI:()=>o,vf:()=>s,zu:()=>r});const r={xs:0,sm:600,md:900,lg:1200,xl:1536},i={keys:["xs","sm","md","lg","xl"],up:e=>"@media (min-width:".concat(r[e],"px)")};function o(e,t,n){const o=e.theme||{};if(Array.isArray(t)){const e=o.breakpoints||i;return t.reduce(((r,i,o)=>(r[e.up(e.keys[o])]=n(t[o]),r)),{})}if("object"===typeof t){const e=o.breakpoints||i;return Object.keys(t).reduce(((i,o)=>{if(-1!==Object.keys(e.values||r).indexOf(o)){i[e.up(o)]=n(t[o],o)}else{const e=o;i[e]=t[e]}return i}),{})}return n(t)}function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t;return(null==(t=e.keys)?void 0:t.reduce(((t,n)=>(t[e.up(n)]={},t)),{}))||{}}function s(e,t){return e.reduce(((e,t)=>{const n=e[t];return(!n||0===Object.keys(n).length)&&delete e[t],e}),t)}},9703:(e,t,n)=>{"use strict";function r(e,t){const n=this;if(n.vars&&"function"===typeof n.getColorSchemeSelector){const r=n.getColorSchemeSelector(e).replace(/(\[[^\]]+\])/,"*:where($1)");return{[r]:t}}return n.palette.mode===e?t:{}}n.d(t,{A:()=>r})},4853:(e,t,n)=>{"use strict";n.d(t,{A:()=>s});var r=n(8587),i=n(8168);const o=["values","unit","step"],a=e=>{const t=Object.keys(e).map((t=>({key:t,val:e[t]})))||[];return t.sort(((e,t)=>e.val-t.val)),t.reduce(((e,t)=>(0,i.A)({},e,{[t.key]:t.val})),{})};function s(e){const{values:t={xs:0,sm:600,md:900,lg:1200,xl:1536},unit:n="px",step:s=5}=e,l=(0,r.A)(e,o),c=a(t),u=Object.keys(c);function h(e){const r="number"===typeof t[e]?t[e]:e;return"@media (min-width:".concat(r).concat(n,")")}function d(e){const r="number"===typeof t[e]?t[e]:e;return"@media (max-width:".concat(r-s/100).concat(n,")")}function f(e,r){const i=u.indexOf(r);return"@media (min-width:".concat("number"===typeof t[e]?t[e]:e).concat(n,") and ")+"(max-width:".concat((-1!==i&&"number"===typeof t[u[i]]?t[u[i]]:r)-s/100).concat(n,")")}return(0,i.A)({keys:u,values:c,up:h,down:d,between:f,only:function(e){return u.indexOf(e)+1{"use strict";n.d(t,{A:()=>f});var r=n(8168),i=n(8587),o=n(3216),a=n(4853);const s={borderRadius:4};var l=n(8604);var c=n(8812),u=n(7758),h=n(9703);const d=["breakpoints","palette","spacing","shape"];const f=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{breakpoints:t={},palette:n={},spacing:f,shape:p={}}=e,m=(0,i.A)(e,d),g=(0,a.A)(t),_=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8;if(e.mui)return e;const t=(0,l.LX)({spacing:e}),n=function(){for(var e=arguments.length,n=new Array(e),r=0;r{const n=t(e);return"number"===typeof n?"".concat(n,"px"):n})).join(" ")};return n.mui=!0,n}(f);let y=(0,o.A)({breakpoints:g,direction:"ltr",components:{},palette:(0,r.A)({mode:"light"},n),spacing:_,shape:(0,r.A)({},s,p)},m);y.applyStyles=h.A;for(var v=arguments.length,x=new Array(v>1?v-1:0),b=1;b(0,o.A)(e,t)),y),y.unstable_sxConfig=(0,r.A)({},u.A,null==m?void 0:m.unstable_sxConfig),y.unstable_sx=function(e){return(0,c.A)({sx:e,theme:this})},y}},4989:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r.A,private_createBreakpoints:()=>i.A,unstable_applyStyles:()=>o.A});var r=n(8280),i=n(4853),o=n(9703)},3815:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(3216);const i=function(e,t){return t?(0,r.A)(e,t,{clone:!1}):e}},8604:(e,t,n)=>{"use strict";n.d(t,{LX:()=>p,MA:()=>f,_W:()=>m,Lc:()=>y,Ms:()=>v});var r=n(9751),i=n(7162),o=n(3815);const a={m:"margin",p:"padding"},s={t:"Top",r:"Right",b:"Bottom",l:"Left",x:["Left","Right"],y:["Top","Bottom"]},l={marginX:"mx",marginY:"my",paddingX:"px",paddingY:"py"},c=function(e){const t={};return n=>(void 0===t[n]&&(t[n]=e(n)),t[n])}((e=>{if(e.length>2){if(!l[e])return[e];e=l[e]}const[t,n]=e.split(""),r=a[t],i=s[n]||"";return Array.isArray(i)?i.map((e=>r+e)):[r+i]})),u=["m","mt","mr","mb","ml","mx","my","margin","marginTop","marginRight","marginBottom","marginLeft","marginX","marginY","marginInline","marginInlineStart","marginInlineEnd","marginBlock","marginBlockStart","marginBlockEnd"],h=["p","pt","pr","pb","pl","px","py","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingX","paddingY","paddingInline","paddingInlineStart","paddingInlineEnd","paddingBlock","paddingBlockStart","paddingBlockEnd"],d=[...u,...h];function f(e,t,n,r){var o;const a=null!=(o=(0,i.Yn)(e,t,!1))?o:n;return"number"===typeof a?e=>"string"===typeof e?e:a*e:Array.isArray(a)?e=>"string"===typeof e?e:a[e]:"function"===typeof a?a:()=>{}}function p(e){return f(e,"spacing",8)}function m(e,t){if("string"===typeof t||null==t)return t;const n=e(Math.abs(t));return t>=0?n:"number"===typeof n?-n:"-".concat(n)}function g(e,t,n,i){if(-1===t.indexOf(n))return null;const o=function(e,t){return n=>e.reduce(((e,r)=>(e[r]=m(t,n),e)),{})}(c(n),i),a=e[n];return(0,r.NI)(e,a,o)}function _(e,t){const n=p(e.theme);return Object.keys(e).map((r=>g(e,t,r,n))).reduce(o.A,{})}function y(e){return _(e,u)}function v(e){return _(e,h)}function x(e){return _(e,d)}y.propTypes={},y.filterProps=u,v.propTypes={},v.filterProps=h,x.propTypes={},x.filterProps=d},7162:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>s,BO:()=>a,Yn:()=>o});var r=n(410),i=n(9751);function o(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!t||"string"!==typeof t)return null;if(e&&e.vars&&n){const n="vars.".concat(t).split(".").reduce(((e,t)=>e&&e[t]?e[t]:null),e);if(null!=n)return n}return t.split(".").reduce(((e,t)=>e&&null!=e[t]?e[t]:null),e)}function a(e,t,n){let r,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;return r="function"===typeof e?e(n):Array.isArray(e)?e[n]||i:o(e,n)||i,t&&(r=t(r,i,e)),r}const s=function(e){const{prop:t,cssProperty:n=e.prop,themeKey:s,transform:l}=e,c=e=>{if(null==e[t])return null;const c=e[t],u=o(e.theme,s)||{};return(0,i.NI)(e,c,(e=>{let i=a(u,l,e);return e===i&&"string"===typeof e&&(i=a(u,l,"".concat(t).concat("default"===e?"":(0,r.A)(e)),e)),!1===n?i:{[n]:i}}))};return c.propTypes={},c.filterProps=[t],c}},7758:(e,t,n)=>{"use strict";n.d(t,{A:()=>z});var r=n(8604),i=n(7162),o=n(3815);const a=function(){for(var e=arguments.length,t=new Array(e),n=0;n(t.filterProps.forEach((n=>{e[n]=t})),e)),{}),i=e=>Object.keys(e).reduce(((t,n)=>r[n]?(0,o.A)(t,r[n](e)):t),{});return i.propTypes={},i.filterProps=t.reduce(((e,t)=>e.concat(t.filterProps)),[]),i};var s=n(9751);function l(e){return"number"!==typeof e?e:"".concat(e,"px solid")}function c(e,t){return(0,i.Ay)({prop:e,themeKey:"borders",transform:t})}const u=c("border",l),h=c("borderTop",l),d=c("borderRight",l),f=c("borderBottom",l),p=c("borderLeft",l),m=c("borderColor"),g=c("borderTopColor"),_=c("borderRightColor"),y=c("borderBottomColor"),v=c("borderLeftColor"),x=c("outline",l),b=c("outlineColor"),w=e=>{if(void 0!==e.borderRadius&&null!==e.borderRadius){const t=(0,r.MA)(e.theme,"shape.borderRadius",4,"borderRadius"),n=e=>({borderRadius:(0,r._W)(t,e)});return(0,s.NI)(e,e.borderRadius,n)}return null};w.propTypes={},w.filterProps=["borderRadius"];a(u,h,d,f,p,m,g,_,y,v,w,x,b);const S=e=>{if(void 0!==e.gap&&null!==e.gap){const t=(0,r.MA)(e.theme,"spacing",8,"gap"),n=e=>({gap:(0,r._W)(t,e)});return(0,s.NI)(e,e.gap,n)}return null};S.propTypes={},S.filterProps=["gap"];const M=e=>{if(void 0!==e.columnGap&&null!==e.columnGap){const t=(0,r.MA)(e.theme,"spacing",8,"columnGap"),n=e=>({columnGap:(0,r._W)(t,e)});return(0,s.NI)(e,e.columnGap,n)}return null};M.propTypes={},M.filterProps=["columnGap"];const A=e=>{if(void 0!==e.rowGap&&null!==e.rowGap){const t=(0,r.MA)(e.theme,"spacing",8,"rowGap"),n=e=>({rowGap:(0,r._W)(t,e)});return(0,s.NI)(e,e.rowGap,n)}return null};A.propTypes={},A.filterProps=["rowGap"];a(S,M,A,(0,i.Ay)({prop:"gridColumn"}),(0,i.Ay)({prop:"gridRow"}),(0,i.Ay)({prop:"gridAutoFlow"}),(0,i.Ay)({prop:"gridAutoColumns"}),(0,i.Ay)({prop:"gridAutoRows"}),(0,i.Ay)({prop:"gridTemplateColumns"}),(0,i.Ay)({prop:"gridTemplateRows"}),(0,i.Ay)({prop:"gridTemplateAreas"}),(0,i.Ay)({prop:"gridArea"}));function E(e,t){return"grey"===t?t:e}a((0,i.Ay)({prop:"color",themeKey:"palette",transform:E}),(0,i.Ay)({prop:"bgcolor",cssProperty:"backgroundColor",themeKey:"palette",transform:E}),(0,i.Ay)({prop:"backgroundColor",themeKey:"palette",transform:E}));function T(e){return e<=1&&0!==e?"".concat(100*e,"%"):e}const C=(0,i.Ay)({prop:"width",transform:T}),k=e=>{if(void 0!==e.maxWidth&&null!==e.maxWidth){const t=t=>{var n,r;const i=(null==(n=e.theme)||null==(n=n.breakpoints)||null==(n=n.values)?void 0:n[t])||s.zu[t];return i?"px"!==(null==(r=e.theme)||null==(r=r.breakpoints)?void 0:r.unit)?{maxWidth:"".concat(i).concat(e.theme.breakpoints.unit)}:{maxWidth:i}:{maxWidth:T(t)}};return(0,s.NI)(e,e.maxWidth,t)}return null};k.filterProps=["maxWidth"];const I=(0,i.Ay)({prop:"minWidth",transform:T}),P=(0,i.Ay)({prop:"height",transform:T}),R=(0,i.Ay)({prop:"maxHeight",transform:T}),L=(0,i.Ay)({prop:"minHeight",transform:T}),z=((0,i.Ay)({prop:"size",cssProperty:"width",transform:T}),(0,i.Ay)({prop:"size",cssProperty:"height",transform:T}),a(C,k,I,P,R,L,(0,i.Ay)({prop:"boxSizing"})),{border:{themeKey:"borders",transform:l},borderTop:{themeKey:"borders",transform:l},borderRight:{themeKey:"borders",transform:l},borderBottom:{themeKey:"borders",transform:l},borderLeft:{themeKey:"borders",transform:l},borderColor:{themeKey:"palette"},borderTopColor:{themeKey:"palette"},borderRightColor:{themeKey:"palette"},borderBottomColor:{themeKey:"palette"},borderLeftColor:{themeKey:"palette"},outline:{themeKey:"borders",transform:l},outlineColor:{themeKey:"palette"},borderRadius:{themeKey:"shape.borderRadius",style:w},color:{themeKey:"palette",transform:E},bgcolor:{themeKey:"palette",cssProperty:"backgroundColor",transform:E},backgroundColor:{themeKey:"palette",transform:E},p:{style:r.Ms},pt:{style:r.Ms},pr:{style:r.Ms},pb:{style:r.Ms},pl:{style:r.Ms},px:{style:r.Ms},py:{style:r.Ms},padding:{style:r.Ms},paddingTop:{style:r.Ms},paddingRight:{style:r.Ms},paddingBottom:{style:r.Ms},paddingLeft:{style:r.Ms},paddingX:{style:r.Ms},paddingY:{style:r.Ms},paddingInline:{style:r.Ms},paddingInlineStart:{style:r.Ms},paddingInlineEnd:{style:r.Ms},paddingBlock:{style:r.Ms},paddingBlockStart:{style:r.Ms},paddingBlockEnd:{style:r.Ms},m:{style:r.Lc},mt:{style:r.Lc},mr:{style:r.Lc},mb:{style:r.Lc},ml:{style:r.Lc},mx:{style:r.Lc},my:{style:r.Lc},margin:{style:r.Lc},marginTop:{style:r.Lc},marginRight:{style:r.Lc},marginBottom:{style:r.Lc},marginLeft:{style:r.Lc},marginX:{style:r.Lc},marginY:{style:r.Lc},marginInline:{style:r.Lc},marginInlineStart:{style:r.Lc},marginInlineEnd:{style:r.Lc},marginBlock:{style:r.Lc},marginBlockStart:{style:r.Lc},marginBlockEnd:{style:r.Lc},displayPrint:{cssProperty:!1,transform:e=>({"@media print":{display:e}})},display:{},overflow:{},textOverflow:{},visibility:{},whiteSpace:{},flexBasis:{},flexDirection:{},flexWrap:{},justifyContent:{},alignItems:{},alignContent:{},order:{},flex:{},flexGrow:{},flexShrink:{},alignSelf:{},justifyItems:{},justifySelf:{},gap:{style:S},rowGap:{style:A},columnGap:{style:M},gridColumn:{},gridRow:{},gridAutoFlow:{},gridAutoColumns:{},gridAutoRows:{},gridTemplateColumns:{},gridTemplateRows:{},gridTemplateAreas:{},gridArea:{},position:{},zIndex:{themeKey:"zIndex"},top:{},right:{},bottom:{},left:{},boxShadow:{themeKey:"shadows"},width:{transform:T},maxWidth:{style:k},minWidth:{transform:T},height:{transform:T},maxHeight:{transform:T},minHeight:{transform:T},boxSizing:{},fontFamily:{themeKey:"typography"},fontSize:{themeKey:"typography"},fontStyle:{themeKey:"typography"},fontWeight:{themeKey:"typography"},letterSpacing:{},textTransform:{},lineHeight:{},textAlign:{},typography:{cssProperty:!1,themeKey:"typography"}})},8698:(e,t,n)=>{"use strict";n.d(t,{A:()=>c});var r=n(8168),i=n(8587),o=n(3216),a=n(7758);const s=["sx"],l=e=>{var t,n;const r={systemProps:{},otherProps:{}},i=null!=(t=null==e||null==(n=e.theme)?void 0:n.unstable_sxConfig)?t:a.A;return Object.keys(e).forEach((t=>{i[t]?r.systemProps[t]=e[t]:r.otherProps[t]=e[t]})),r};function c(e){const{sx:t}=e,n=(0,i.A)(e,s),{systemProps:a,otherProps:c}=l(n);let u;return u=Array.isArray(t)?[a,...t]:"function"===typeof t?function(){const e=t(...arguments);return(0,o.Q)(e)?(0,r.A)({},a,e):a}:(0,r.A)({},a,t),(0,r.A)({},c,{sx:u})}},3234:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r.A,extendSxProp:()=>i.A,unstable_createStyleFunctionSx:()=>r.k,unstable_defaultSxConfig:()=>o.A});var r=n(8812),i=n(8698),o=n(7758)},8812:(e,t,n)=>{"use strict";n.d(t,{A:()=>u,k:()=>l});var r=n(410),i=n(3815),o=n(7162),a=n(9751),s=n(7758);function l(){function e(e,t,n,i){const s={[e]:t,theme:n},l=i[e];if(!l)return{[e]:t};const{cssProperty:c=e,themeKey:u,transform:h,style:d}=l;if(null==t)return null;if("typography"===u&&"inherit"===t)return{[e]:t};const f=(0,o.Yn)(n,u)||{};if(d)return d(s);return(0,a.NI)(s,t,(t=>{let n=(0,o.BO)(f,h,t);return t===n&&"string"===typeof t&&(n=(0,o.BO)(f,h,"".concat(e).concat("default"===t?"":(0,r.A)(t)),t)),!1===c?n:{[c]:n}}))}return function t(n){var r;const{sx:o,theme:l={}}=n||{};if(!o)return null;const c=null!=(r=l.unstable_sxConfig)?r:s.A;function u(n){let r=n;if("function"===typeof n)r=n(l);else if("object"!==typeof n)return n;if(!r)return null;const o=(0,a.EU)(l.breakpoints),s=Object.keys(o);let u=o;return Object.keys(r).forEach((n=>{const o=(s=r[n],h=l,"function"===typeof s?s(h):s);var s,h;if(null!==o&&void 0!==o)if("object"===typeof o)if(c[n])u=(0,i.A)(u,e(n,o,l,c));else{const e=(0,a.NI)({theme:l},o,(e=>({[n]:e})));!function(){for(var e=arguments.length,t=new Array(e),n=0;ne.concat(Object.keys(t))),[]),i=new Set(r);return t.every((e=>i.size===Object.keys(e).length))}(e,o)?u=(0,i.A)(u,e):u[n]=t({sx:o,theme:l})}else u=(0,i.A)(u,e(n,o,l,c))})),(0,a.vf)(s,u)}return Array.isArray(o)?o.map(u):u(o)}}const c=l();c.filterProps=["sx"];const u=c},5527:(e,t,n)=>{"use strict";n.d(t,{A:()=>a});var r=n(8280),i=n(7082);const o=(0,r.A)();const a=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o;return(0,i.A)(e)}},7082:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(5043),i=n(5756);const o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=r.useContext(i.T);return t&&(n=t,0!==Object.keys(n).length)?t:e;var n}},5430:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});const r=e=>e,i=(()=>{let e=r;return{configure(t){e=t},generate:t=>e(t),reset(){e=r}}})()},410:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(6632);function i(e){if("string"!==typeof e)throw new Error((0,r.A)(7));return e.charAt(0).toUpperCase()+e.slice(1)}},578:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r.A});var r=n(410)},7040:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});const r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.MIN_SAFE_INTEGER,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.MAX_SAFE_INTEGER;return Math.max(t,Math.min(e,n))}},5383:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r.A});var r=n(7040)},8606:(e,t,n)=>{"use strict";function r(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;const r={};return Object.keys(e).forEach((i=>{r[i]=e[i].reduce(((e,r)=>{if(r){const i=t(r);""!==i&&e.push(i),n&&n[r]&&e.push(n[r])}return e}),[]).join(" ")})),r}n.d(t,{A:()=>r})},4708:(e,t,n)=>{"use strict";function r(){for(var e=arguments.length,t=new Array(e),n=0;nnull==t?e:function(){for(var n=arguments.length,r=new Array(n),i=0;i{}))}n.d(t,{A:()=>r})},6440:(e,t,n)=>{"use strict";function r(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:166;function r(){for(var r=arguments.length,i=new Array(r),o=0;o{e.apply(this,i)}),n)}return r.clear=()=>{clearTimeout(t)},r}n.d(t,{A:()=>r})},3216:(e,t,n)=>{"use strict";n.d(t,{A:()=>a,Q:()=>i});var r=n(8168);function i(e){if("object"!==typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function o(e){if(!i(e))return e;const t={};return Object.keys(e).forEach((n=>{t[n]=o(e[n])})),t}function a(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{clone:!0};const s=n.clone?(0,r.A)({},e):e;return i(e)&&i(t)&&Object.keys(t).forEach((r=>{i(t[r])&&Object.prototype.hasOwnProperty.call(e,r)&&i(e[r])?s[r]=a(e[r],t[r],n):n.clone?s[r]=i(t[r])?o(t[r]):t[r]:s[r]=t[r]})),s}},4534:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r.A,isPlainObject:()=>r.Q});var r=n(3216)},6632:(e,t,n)=>{"use strict";function r(e){let t="https://mui.com/production-error/?code="+e;for(let n=1;nr})},7245:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r.A});var r=n(6632)},2400:(e,t,n)=>{"use strict";n.d(t,{Ay:()=>o});var r=n(5430);const i={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function o(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Mui";const o=i[t];return o?"".concat(n,"-").concat(o):"".concat(r.A.generate(e),"-").concat(t)}},7056:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(2400);function i(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Mui";const i={};return t.forEach((t=>{i[t]=(0,r.Ay)(e,t,n)})),i}},2046:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>l,getFunctionName:()=>o});var r=n(9565);const i=/^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/;function o(e){const t="".concat(e).match(i);return t&&t[1]||""}function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return e.displayName||e.name||o(e)||t}function s(e,t,n){const r=a(t);return e.displayName||(""!==r?"".concat(n,"(").concat(r,")"):n)}function l(e){if(null!=e){if("string"===typeof e)return e;if("function"===typeof e)return a(e,"Component");if("object"===typeof e)switch(e.$$typeof){case r.ForwardRef:return s(e,e.render,"ForwardRef");case r.Memo:return s(e,e.type,"memo");default:return}}}},8609:(e,t)=>{"use strict";var n,r=Symbol.for("react.element"),i=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.server_context"),h=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen");function _(e){if("object"===typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case o:case s:case a:case d:case f:return e;default:switch(e=e&&e.$$typeof){case u:case c:case h:case m:case p:case l:return e;default:return t}}case i:return t}}}n=Symbol.for("react.module.reference"),t.ForwardRef=h,t.Memo=p},9565:(e,t,n)=>{"use strict";e.exports=n(8609)},2144:(e,t,n)=>{"use strict";function r(e){return e&&e.ownerDocument||document}n.d(t,{A:()=>r})},6288:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(2144);function i(e){return(0,r.A)(e).defaultView||window}},2018:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(8168);function i(e,t){const n=(0,r.A)({},t);return Object.keys(e).forEach((o=>{if(o.toString().match(/^(components|slots)$/))n[o]=(0,r.A)({},e[o],n[o]);else if(o.toString().match(/^(componentsProps|slotProps)$/)){const a=e[o]||{},s=t[o];n[o]={},s&&Object.keys(s)?a&&Object.keys(a)?(n[o]=(0,r.A)({},s),Object.keys(a).forEach((e=>{n[o][e]=i(a[e],s[e])}))):n[o]=s:n[o]=a}else void 0===n[o]&&(n[o]=e[o])})),n}},9184:(e,t,n)=>{"use strict";function r(e,t){"function"===typeof e?e(t):e&&(e.current=t)}n.d(t,{A:()=>r})},1944:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(5043);function i(e){let{controlled:t,default:n,name:i,state:o="value"}=e;const{current:a}=r.useRef(void 0!==t),[s,l]=r.useState(n);return[a?t:s,r.useCallback((e=>{a||l(e)}),[])]}},3844:(e,t,n)=>{"use strict";n.d(t,{A:()=>i});var r=n(5043);const i="undefined"!==typeof window?r.useLayoutEffect:r.useEffect},4626:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(5043),i=n(3844);const o=function(e){const t=r.useRef(e);return(0,i.A)((()=>{t.current=e})),r.useRef((function(){return(0,t.current)(...arguments)})).current}},7042:(e,t,n)=>{"use strict";n.d(t,{A:()=>o});var r=n(5043),i=n(9184);function o(){for(var e=arguments.length,t=new Array(e),n=0;nt.every((e=>null==e))?null:e=>{t.forEach((t=>{(0,i.A)(t,e)}))}),t)}},992:(e,t,n)=>{"use strict";var r;n.d(t,{A:()=>s});var i=n(5043);let o=0;const a=(r||(r=n.t(i,2)))["useId".toString()];function s(e){if(void 0!==a){const t=a();return null!=e?e:t}return function(e){const[t,n]=i.useState(e),r=e||t;return i.useEffect((()=>{null==t&&(o+=1,n("mui-".concat(o)))}),[t]),r}(e)}},932:(e,t,n)=>{"use strict";n.d(t,{A:()=>f});var r=n(5043),i=n(1140);let o=!0,a=!1;const s=new i.E,l={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function c(e){e.metaKey||e.altKey||e.ctrlKey||(o=!0)}function u(){o=!1}function h(){"hidden"===this.visibilityState&&a&&(o=!0)}function d(e){const{target:t}=e;try{return t.matches(":focus-visible")}catch(n){}return o||function(e){const{type:t,tagName:n}=e;return!("INPUT"!==n||!l[t]||e.readOnly)||"TEXTAREA"===n&&!e.readOnly||!!e.isContentEditable}(t)}function f(){const e=r.useCallback((e=>{var t;null!=e&&((t=e.ownerDocument).addEventListener("keydown",c,!0),t.addEventListener("mousedown",u,!0),t.addEventListener("pointerdown",u,!0),t.addEventListener("touchstart",u,!0),t.addEventListener("visibilitychange",h,!0))}),[]),t=r.useRef(!1);return{isFocusVisibleRef:t,onFocus:function(e){return!!d(e)&&(t.current=!0,!0)},onBlur:function(){return!!t.current&&(a=!0,s.start(100,(()=>{a=!1})),t.current=!1,!0)},ref:e}}},1140:(e,t,n)=>{"use strict";n.d(t,{E:()=>a,A:()=>s});var r=n(5043);const i={};const o=[];class a{constructor(){this.currentId=null,this.clear=()=>{null!==this.currentId&&(clearTimeout(this.currentId),this.currentId=null)},this.disposeEffect=()=>this.clear}static create(){return new a}start(e,t){this.clear(),this.currentId=setTimeout((()=>{this.currentId=null,t()}),e)}}function s(){const e=function(e,t){const n=r.useRef(i);return n.current===i&&(n.current=e(t)),n}(a.create).current;var t;return t=e.disposeEffect,r.useEffect(t,o),e}},2511:function(e,t,n){var r;e=n.nmd(e),function(i){var o=t,a=(e&&e.exports,"object"==typeof n.g&&n.g);a.global!==a&&a.window;var s=function(e){this.message=e};(s.prototype=new Error).name="InvalidCharacterError";var l=function(e){throw new s(e)},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=/[\t\n\f\r ]/g,h={encode:function(e){e=String(e),/[^\0-\xFF]/.test(e)&&l("The string to be encoded contains characters outside of the Latin1 range.");for(var t,n,r,i,o=e.length%3,a="",s=-1,u=e.length-o;++s>18&63)+c.charAt(i>>12&63)+c.charAt(i>>6&63)+c.charAt(63&i);return 2==o?(t=e.charCodeAt(s)<<8,n=e.charCodeAt(++s),a+=c.charAt((i=t+n)>>10)+c.charAt(i>>4&63)+c.charAt(i<<2&63)+"="):1==o&&(i=e.charCodeAt(s),a+=c.charAt(i>>2)+c.charAt(i<<4&63)+"=="),a},decode:function(e){var t=(e=String(e).replace(u,"")).length;t%4==0&&(t=(e=e.replace(/==?$/,"")).length),(t%4==1||/[^+a-zA-Z0-9/]/.test(e))&&l("Invalid character: the string to be decoded is not correctly encoded.");for(var n,r,i=0,o="",a=-1;++a>(-2*i&6)));return o},version:"0.1.0"};void 0===(r=function(){return h}.call(t,n,t,e))||(e.exports=r)}()},7284:e=>{"use strict";var t,n="object"===typeof Reflect?Reflect:null,r=n&&"function"===typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"===typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!==e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"===typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}m(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"===typeof e.on&&m(e,"error",t,n)}(e,i,{once:!0})}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function s(e){if("function"!==typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function c(e,t,n,r){var i,o,a,c;if(s(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),void 0===a)a=o[t]=n,++e._eventsCount;else if("function"===typeof a?a=o[t]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=l(e))>0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,c=u,console&&console.warn&&console.warn(c)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=u.bind(r);return i.listener=n,r.wrapFn=i,i}function d(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"===typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var l=o[e];if(void 0===l)return!1;if("function"===typeof l)r(l,this,t);else{var c=l.length,u=p(l,c);for(n=0;n=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1=0;r--)this.removeListener(e,t[r]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"===typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},5944:e=>{!function(){var t={};e.exports=t,t.simpleFilter=function(e,n){return n.filter((function(n){return t.test(e,n)}))},t.test=function(e,n){return null!==t.match(e,n)},t.match=function(e,t,n){n=n||{};var r,i=0,o=[],a=t.length,s=0,l=0,c=n.pre||"",u=n.post||"",h=n.caseSensitive&&t||t.toLowerCase();e=n.caseSensitive&&e||e.toLowerCase();for(var d=0;d{"use strict";var r=n(3763),i={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function l(e){return r.isMemo(e)?a:s[e.$$typeof]||i}s[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[r.Memo]=a;var c=Object.defineProperty,u=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,p=Object.prototype;e.exports=function e(t,n,r){if("string"!==typeof n){if(p){var i=f(n);i&&i!==p&&e(t,i,r)}var a=u(n);h&&(a=a.concat(h(n)));for(var s=l(t),m=l(n),g=0;g{"use strict";var n="function"===typeof Symbol&&Symbol.for,r=n?Symbol.for("react.element"):60103,i=n?Symbol.for("react.portal"):60106,o=n?Symbol.for("react.fragment"):60107,a=n?Symbol.for("react.strict_mode"):60108,s=n?Symbol.for("react.profiler"):60114,l=n?Symbol.for("react.provider"):60109,c=n?Symbol.for("react.context"):60110,u=n?Symbol.for("react.async_mode"):60111,h=n?Symbol.for("react.concurrent_mode"):60111,d=n?Symbol.for("react.forward_ref"):60112,f=n?Symbol.for("react.suspense"):60113,p=n?Symbol.for("react.suspense_list"):60120,m=n?Symbol.for("react.memo"):60115,g=n?Symbol.for("react.lazy"):60116,_=n?Symbol.for("react.block"):60121,y=n?Symbol.for("react.fundamental"):60117,v=n?Symbol.for("react.responder"):60118,x=n?Symbol.for("react.scope"):60119;function b(e){if("object"===typeof e&&null!==e){var t=e.$$typeof;switch(t){case r:switch(e=e.type){case u:case h:case o:case s:case a:case f:return e;default:switch(e=e&&e.$$typeof){case c:case d:case g:case m:case l:return e;default:return t}}case i:return t}}}function w(e){return b(e)===h}t.AsyncMode=u,t.ConcurrentMode=h,t.ContextConsumer=c,t.ContextProvider=l,t.Element=r,t.ForwardRef=d,t.Fragment=o,t.Lazy=g,t.Memo=m,t.Portal=i,t.Profiler=s,t.StrictMode=a,t.Suspense=f,t.isAsyncMode=function(e){return w(e)||b(e)===u},t.isConcurrentMode=w,t.isContextConsumer=function(e){return b(e)===c},t.isContextProvider=function(e){return b(e)===l},t.isElement=function(e){return"object"===typeof e&&null!==e&&e.$$typeof===r},t.isForwardRef=function(e){return b(e)===d},t.isFragment=function(e){return b(e)===o},t.isLazy=function(e){return b(e)===g},t.isMemo=function(e){return b(e)===m},t.isPortal=function(e){return b(e)===i},t.isProfiler=function(e){return b(e)===s},t.isStrictMode=function(e){return b(e)===a},t.isSuspense=function(e){return b(e)===f},t.isValidElementType=function(e){return"string"===typeof e||"function"===typeof e||e===o||e===h||e===s||e===a||e===f||e===p||"object"===typeof e&&null!==e&&(e.$$typeof===g||e.$$typeof===m||e.$$typeof===l||e.$$typeof===c||e.$$typeof===d||e.$$typeof===y||e.$$typeof===v||e.$$typeof===x||e.$$typeof===_)},t.typeOf=b},3763:(e,t,n)=>{"use strict";e.exports=n(4983)},446:(e,t,n)=>{var r=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt,u="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,h="object"==typeof self&&self&&self.Object===Object&&self,d=u||h||Function("return this")(),f=Object.prototype.toString,p=Math.max,m=Math.min,g=function(){return d.Date.now()};function _(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function y(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&f.call(e)==i}(e))return r;if(_(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=_(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(o,"");var n=s.test(e);return n||l.test(e)?c(e.slice(2),n?2:8):a.test(e)?r:+e}e.exports=function(e,t,n){var r,i,o,a,s,l,c=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){var n=r,o=i;return r=i=void 0,c=t,a=e.apply(o,n)}function v(e){var n=e-l;return void 0===l||n>=t||n<0||h&&e-c>=o}function x(){var e=g();if(v(e))return b(e);s=setTimeout(x,function(e){var n=t-(e-l);return h?m(n,o-(e-c)):n}(e))}function b(e){return s=void 0,d&&r?f(e):(r=i=void 0,a)}function w(){var e=g(),n=v(e);if(r=arguments,i=this,l=e,n){if(void 0===s)return function(e){return c=e,s=setTimeout(x,t),u?f(e):a}(l);if(h)return s=setTimeout(x,t),f(l)}return void 0===s&&(s=setTimeout(x,t)),a}return t=y(t)||0,_(n)&&(u=!!n.leading,o=(h="maxWait"in n)?p(y(n.maxWait)||0,t):o,d="trailing"in n?!!n.trailing:d),w.cancel=function(){void 0!==s&&clearTimeout(s),c=0,r=l=i=s=void 0},w.flush=function(){return void 0===s?a:b(g())},w}},3536:function(e,t,n){var r;e=n.nmd(e),function(){var i,o="Expected a function",a="__lodash_hash_undefined__",s="__lodash_placeholder__",l=16,c=32,u=64,h=128,d=256,f=1/0,p=9007199254740991,m=NaN,g=4294967295,_=[["ary",h],["bind",1],["bindKey",2],["curry",8],["curryRight",l],["flip",512],["partial",c],["partialRight",u],["rearg",d]],y="[object Arguments]",v="[object Array]",x="[object Boolean]",b="[object Date]",w="[object Error]",S="[object Function]",M="[object GeneratorFunction]",A="[object Map]",E="[object Number]",T="[object Object]",C="[object Promise]",k="[object RegExp]",I="[object Set]",P="[object String]",R="[object Symbol]",L="[object WeakMap]",z="[object ArrayBuffer]",O="[object DataView]",D="[object Float32Array]",B="[object Float64Array]",F="[object Int8Array]",N="[object Int16Array]",j="[object Int32Array]",V="[object Uint8Array]",U="[object Uint8ClampedArray]",G="[object Uint16Array]",q="[object Uint32Array]",W=/\b__p \+= '';/g,H=/\b(__p \+=) '' \+/g,Z=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Y=/&(?:amp|lt|gt|quot|#39);/g,Q=/[&<>"']/g,X=RegExp(Y.source),K=RegExp(Q.source),J=/<%-([\s\S]+?)%>/g,$=/<%([\s\S]+?)%>/g,ee=/<%=([\s\S]+?)%>/g,te=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ne=/^\w*$/,re=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ie=/[\\^$.*+?()[\]{}|]/g,oe=RegExp(ie.source),ae=/^\s+/,se=/\s/,le=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ce=/\{\n\/\* \[wrapped with (.+)\] \*/,ue=/,? & /,he=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,de=/[()=,{}\[\]\/\s]/,fe=/\\(\\)?/g,pe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,me=/\w*$/,ge=/^[-+]0x[0-9a-f]+$/i,_e=/^0b[01]+$/i,ye=/^\[object .+?Constructor\]$/,ve=/^0o[0-7]+$/i,xe=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,we=/($^)/,Se=/['\n\r\u2028\u2029\\]/g,Me="\\ud800-\\udfff",Ae="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ee="\\u2700-\\u27bf",Te="a-z\\xdf-\\xf6\\xf8-\\xff",Ce="A-Z\\xc0-\\xd6\\xd8-\\xde",ke="\\ufe0e\\ufe0f",Ie="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Pe="['\u2019]",Re="["+Me+"]",Le="["+Ie+"]",ze="["+Ae+"]",Oe="\\d+",De="["+Ee+"]",Be="["+Te+"]",Fe="[^"+Me+Ie+Oe+Ee+Te+Ce+"]",Ne="\\ud83c[\\udffb-\\udfff]",je="[^"+Me+"]",Ve="(?:\\ud83c[\\udde6-\\uddff]){2}",Ue="[\\ud800-\\udbff][\\udc00-\\udfff]",Ge="["+Ce+"]",qe="\\u200d",We="(?:"+Be+"|"+Fe+")",He="(?:"+Ge+"|"+Fe+")",Ze="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",Ye="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",Qe="(?:"+ze+"|"+Ne+")"+"?",Xe="["+ke+"]?",Ke=Xe+Qe+("(?:"+qe+"(?:"+[je,Ve,Ue].join("|")+")"+Xe+Qe+")*"),Je="(?:"+[De,Ve,Ue].join("|")+")"+Ke,$e="(?:"+[je+ze+"?",ze,Ve,Ue,Re].join("|")+")",et=RegExp(Pe,"g"),tt=RegExp(ze,"g"),nt=RegExp(Ne+"(?="+Ne+")|"+$e+Ke,"g"),rt=RegExp([Ge+"?"+Be+"+"+Ze+"(?="+[Le,Ge,"$"].join("|")+")",He+"+"+Ye+"(?="+[Le,Ge+We,"$"].join("|")+")",Ge+"?"+We+"+"+Ze,Ge+"+"+Ye,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Oe,Je].join("|"),"g"),it=RegExp("["+qe+Me+Ae+ke+"]"),ot=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,at=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],st=-1,lt={};lt[D]=lt[B]=lt[F]=lt[N]=lt[j]=lt[V]=lt[U]=lt[G]=lt[q]=!0,lt[y]=lt[v]=lt[z]=lt[x]=lt[O]=lt[b]=lt[w]=lt[S]=lt[A]=lt[E]=lt[T]=lt[k]=lt[I]=lt[P]=lt[L]=!1;var ct={};ct[y]=ct[v]=ct[z]=ct[O]=ct[x]=ct[b]=ct[D]=ct[B]=ct[F]=ct[N]=ct[j]=ct[A]=ct[E]=ct[T]=ct[k]=ct[I]=ct[P]=ct[R]=ct[V]=ct[U]=ct[G]=ct[q]=!0,ct[w]=ct[S]=ct[L]=!1;var ut={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ht=parseFloat,dt=parseInt,ft="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,pt="object"==typeof self&&self&&self.Object===Object&&self,mt=ft||pt||Function("return this")(),gt=t&&!t.nodeType&&t,_t=gt&&e&&!e.nodeType&&e,yt=_t&&_t.exports===gt,vt=yt&&ft.process,xt=function(){try{var e=_t&&_t.require&&_t.require("util").types;return e||vt&&vt.binding&&vt.binding("util")}catch(t){}}(),bt=xt&&xt.isArrayBuffer,wt=xt&&xt.isDate,St=xt&&xt.isMap,Mt=xt&&xt.isRegExp,At=xt&&xt.isSet,Et=xt&&xt.isTypedArray;function Tt(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Ct(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i-1}function zt(e,t,n){for(var r=-1,i=null==e?0:e.length;++r-1;);return n}function rn(e,t){for(var n=e.length;n--&&Gt(t,e[n],0)>-1;);return n}var on=Yt({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"}),an=Yt({"&":"&","<":"<",">":">",'"':""","'":"'"});function sn(e){return"\\"+ut[e]}function ln(e){return it.test(e)}function cn(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function un(e,t){return function(n){return e(t(n))}}function hn(e,t){for(var n=-1,r=e.length,i=0,o=[];++n",""":'"',"'":"'"});var yn=function e(t){var n=(t=null==t?mt:yn.defaults(mt.Object(),t,yn.pick(mt,at))).Array,r=t.Date,se=t.Error,Me=t.Function,Ae=t.Math,Ee=t.Object,Te=t.RegExp,Ce=t.String,ke=t.TypeError,Ie=n.prototype,Pe=Me.prototype,Re=Ee.prototype,Le=t["__core-js_shared__"],ze=Pe.toString,Oe=Re.hasOwnProperty,De=0,Be=function(){var e=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Fe=Re.toString,Ne=ze.call(Ee),je=mt._,Ve=Te("^"+ze.call(Oe).replace(ie,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ue=yt?t.Buffer:i,Ge=t.Symbol,qe=t.Uint8Array,We=Ue?Ue.allocUnsafe:i,He=un(Ee.getPrototypeOf,Ee),Ze=Ee.create,Ye=Re.propertyIsEnumerable,Qe=Ie.splice,Xe=Ge?Ge.isConcatSpreadable:i,Ke=Ge?Ge.iterator:i,Je=Ge?Ge.toStringTag:i,$e=function(){try{var e=ho(Ee,"defineProperty");return e({},"",{}),e}catch(t){}}(),nt=t.clearTimeout!==mt.clearTimeout&&t.clearTimeout,it=r&&r.now!==mt.Date.now&&r.now,ut=t.setTimeout!==mt.setTimeout&&t.setTimeout,ft=Ae.ceil,pt=Ae.floor,gt=Ee.getOwnPropertySymbols,_t=Ue?Ue.isBuffer:i,vt=t.isFinite,xt=Ie.join,jt=un(Ee.keys,Ee),Yt=Ae.max,vn=Ae.min,xn=r.now,bn=t.parseInt,wn=Ae.random,Sn=Ie.reverse,Mn=ho(t,"DataView"),An=ho(t,"Map"),En=ho(t,"Promise"),Tn=ho(t,"Set"),Cn=ho(t,"WeakMap"),kn=ho(Ee,"create"),In=Cn&&new Cn,Pn={},Rn=Fo(Mn),Ln=Fo(An),zn=Fo(En),On=Fo(Tn),Dn=Fo(Cn),Bn=Ge?Ge.prototype:i,Fn=Bn?Bn.valueOf:i,Nn=Bn?Bn.toString:i;function jn(e){if(ts(e)&&!qa(e)&&!(e instanceof qn)){if(e instanceof Gn)return e;if(Oe.call(e,"__wrapped__"))return No(e)}return new Gn(e)}var Vn=function(){function e(){}return function(t){if(!es(t))return{};if(Ze)return Ze(t);e.prototype=t;var n=new e;return e.prototype=i,n}}();function Un(){}function Gn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}function qn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=g,this.__views__=[]}function Wn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function lr(e,t,n,r,o,a){var s,l=1&t,c=2&t,u=4&t;if(n&&(s=o?n(e,r,o,a):n(e)),s!==i)return s;if(!es(e))return e;var h=qa(e);if(h){if(s=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&Oe.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!l)return ki(e,s)}else{var d=mo(e),f=d==S||d==M;if(Ya(e))return Si(e,l);if(d==T||d==y||f&&!o){if(s=c||f?{}:_o(e),!l)return c?function(e,t){return Ii(e,po(e),t)}(e,function(e,t){return e&&Ii(t,Rs(t),e)}(s,e)):function(e,t){return Ii(e,fo(e),t)}(e,ir(s,e))}else{if(!ct[d])return o?e:{};s=function(e,t,n){var r=e.constructor;switch(t){case z:return Mi(e);case x:case b:return new r(+e);case O:return function(e,t){var n=t?Mi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case D:case B:case F:case N:case j:case V:case U:case G:case q:return Ai(e,n);case A:return new r;case E:case P:return new r(e);case k:return function(e){var t=new e.constructor(e.source,me.exec(e));return t.lastIndex=e.lastIndex,t}(e);case I:return new r;case R:return i=e,Fn?Ee(Fn.call(i)):{}}var i}(e,d,l)}}a||(a=new Qn);var p=a.get(e);if(p)return p;a.set(e,s),as(e)?e.forEach((function(r){s.add(lr(r,t,n,r,e,a))})):ns(e)&&e.forEach((function(r,i){s.set(i,lr(r,t,n,i,e,a))}));var m=h?i:(u?c?io:ro:c?Rs:Ps)(e);return kt(m||e,(function(r,i){m&&(r=e[i=r]),tr(s,i,lr(r,t,n,i,e,a))})),s}function cr(e,t,n){var r=n.length;if(null==e)return!r;for(e=Ee(e);r--;){var o=n[r],a=t[o],s=e[o];if(s===i&&!(o in e)||!a(s))return!1}return!0}function ur(e,t,n){if("function"!=typeof e)throw new ke(o);return Po((function(){e.apply(i,n)}),t)}function hr(e,t,n,r){var i=-1,o=Lt,a=!0,s=e.length,l=[],c=t.length;if(!s)return l;n&&(t=Ot(t,$t(n))),r?(o=zt,a=!1):t.length>=200&&(o=tn,a=!1,t=new Yn(t));e:for(;++i-1},Hn.prototype.set=function(e,t){var n=this.__data__,r=nr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Zn.prototype.clear=function(){this.size=0,this.__data__={hash:new Wn,map:new(An||Hn),string:new Wn}},Zn.prototype.delete=function(e){var t=co(this,e).delete(e);return this.size-=t?1:0,t},Zn.prototype.get=function(e){return co(this,e).get(e)},Zn.prototype.has=function(e){return co(this,e).has(e)},Zn.prototype.set=function(e,t){var n=co(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Yn.prototype.add=Yn.prototype.push=function(e){return this.__data__.set(e,a),this},Yn.prototype.has=function(e){return this.__data__.has(e)},Qn.prototype.clear=function(){this.__data__=new Hn,this.size=0},Qn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Qn.prototype.get=function(e){return this.__data__.get(e)},Qn.prototype.has=function(e){return this.__data__.has(e)},Qn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Hn){var r=n.__data__;if(!An||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Zn(r)}return n.set(e,t),this.size=n.size,this};var dr=Li(xr),fr=Li(br,!0);function pr(e,t){var n=!0;return dr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function mr(e,t,n){for(var r=-1,o=e.length;++r0&&n(s)?t>1?_r(s,t-1,n,r,i):Dt(i,s):r||(i[i.length]=s)}return i}var yr=zi(),vr=zi(!0);function xr(e,t){return e&&yr(e,t,Ps)}function br(e,t){return e&&vr(e,t,Ps)}function wr(e,t){return Rt(t,(function(t){return Ka(e[t])}))}function Sr(e,t){for(var n=0,r=(t=vi(t,e)).length;null!=e&&nt}function Tr(e,t){return null!=e&&Oe.call(e,t)}function Cr(e,t){return null!=e&&t in Ee(e)}function kr(e,t,r){for(var o=r?zt:Lt,a=e[0].length,s=e.length,l=s,c=n(s),u=1/0,h=[];l--;){var d=e[l];l&&t&&(d=Ot(d,$t(t))),u=vn(d.length,u),c[l]=!r&&(t||a>=120&&d.length>=120)?new Yn(l&&d):i}d=e[0];var f=-1,p=c[0];e:for(;++f=s?l:l*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)}))}function Wr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)s!==e&&Qe.call(s,l,1),Qe.call(e,l,1);return e}function Zr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;vo(i)?Qe.call(e,i,1):hi(e,i)}}return e}function Yr(e,t){return e+pt(wn()*(t-e+1))}function Qr(e,t){var n="";if(!e||t<1||t>p)return n;do{t%2&&(n+=e),(t=pt(t/2))&&(e+=e)}while(t);return n}function Xr(e,t){return Ro(To(e,t,rl),e+"")}function Kr(e){return Kn(js(e))}function Jr(e,t){var n=js(e);return Oo(n,sr(t,0,n.length))}function $r(e,t,n,r){if(!es(e))return e;for(var o=-1,a=(t=vi(t,e)).length,s=a-1,l=e;null!=l&&++oo?0:o+t),(r=r>o?o:r)<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var a=n(o);++i>>1,a=e[o];null!==a&&!ls(a)&&(n?a<=t:a=200){var c=t?null:Qi(e);if(c)return dn(c);a=!1,i=tn,l=new Yn}else l=t?[]:s;e:for(;++r=r?e:ri(e,t,n)}var wi=nt||function(e){return mt.clearTimeout(e)};function Si(e,t){if(t)return e.slice();var n=e.length,r=We?We(n):new e.constructor(n);return e.copy(r),r}function Mi(e){var t=new e.constructor(e.byteLength);return new qe(t).set(new qe(e)),t}function Ai(e,t){var n=t?Mi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ei(e,t){if(e!==t){var n=e!==i,r=null===e,o=e===e,a=ls(e),s=t!==i,l=null===t,c=t===t,u=ls(t);if(!l&&!u&&!a&&e>t||a&&s&&c&&!l&&!u||r&&s&&c||!n&&c||!o)return 1;if(!r&&!a&&!u&&e1?n[o-1]:i,s=o>2?n[2]:i;for(a=e.length>3&&"function"==typeof a?(o--,a):i,s&&xo(n[0],n[1],s)&&(a=o<3?i:a,o=1),t=Ee(t);++r-1?o[a?t[s]:s]:i}}function Ni(e){return no((function(t){var n=t.length,r=n,a=Gn.prototype.thru;for(e&&t.reverse();r--;){var s=t[r];if("function"!=typeof s)throw new ke(o);if(a&&!l&&"wrapper"==ao(s))var l=new Gn([],!0)}for(r=l?r:n;++r1&&x.reverse(),f&&ul))return!1;var u=a.get(e),h=a.get(t);if(u&&h)return u==t&&h==e;var d=-1,f=!0,p=2&n?new Yn:i;for(a.set(e,t),a.set(t,e);++d-1&&e%1==0&&e1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(le,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return kt(_,(function(n){var r="_."+n[0];t&n[1]&&!Lt(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(ce);return t?t[1].split(ue):[]}(r),n)))}function zo(e){var t=0,n=0;return function(){var r=xn(),o=16-(r-n);if(n=r,o>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(i,arguments)}}function Oo(e,t){var n=-1,r=e.length,o=r-1;for(t=t===i?r:t;++n1?e[t-1]:i;return n="function"==typeof n?(e.pop(),n):i,oa(e,n)}));function da(e){var t=jn(e);return t.__chain__=!0,t}function fa(e,t){return t(e)}var pa=no((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,o=function(t){return ar(t,e)};return!(t>1||this.__actions__.length)&&r instanceof qn&&vo(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:fa,args:[o],thisArg:i}),new Gn(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(i),e}))):this.thru(o)}));var ma=Pi((function(e,t,n){Oe.call(e,n)?++e[n]:or(e,n,1)}));var ga=Fi(Go),_a=Fi(qo);function ya(e,t){return(qa(e)?kt:dr)(e,lo(t,3))}function va(e,t){return(qa(e)?It:fr)(e,lo(t,3))}var xa=Pi((function(e,t,n){Oe.call(e,n)?e[n].push(t):or(e,n,[t])}));var ba=Xr((function(e,t,r){var i=-1,o="function"==typeof t,a=Ha(e)?n(e.length):[];return dr(e,(function(e){a[++i]=o?Tt(t,e,r):Ir(e,t,r)})),a})),wa=Pi((function(e,t,n){or(e,n,t)}));function Sa(e,t){return(qa(e)?Ot:Nr)(e,lo(t,3))}var Ma=Pi((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));var Aa=Xr((function(e,t){if(null==e)return[];var n=t.length;return n>1&&xo(e,t[0],t[1])?t=[]:n>2&&xo(t[0],t[1],t[2])&&(t=[t[0]]),qr(e,_r(t,1),[])})),Ea=it||function(){return mt.Date.now()};function Ta(e,t,n){return t=n?i:t,t=e&&null==t?e.length:t,Ki(e,h,i,i,i,i,t)}function Ca(e,t){var n;if("function"!=typeof t)throw new ke(o);return e=ps(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=i),n}}var ka=Xr((function(e,t,n){var r=1;if(n.length){var i=hn(n,so(ka));r|=c}return Ki(e,r,t,n,i)})),Ia=Xr((function(e,t,n){var r=3;if(n.length){var i=hn(n,so(Ia));r|=c}return Ki(t,r,e,n,i)}));function Pa(e,t,n){var r,a,s,l,c,u,h=0,d=!1,f=!1,p=!0;if("function"!=typeof e)throw new ke(o);function m(t){var n=r,o=a;return r=a=i,h=t,l=e.apply(o,n)}function g(e){var n=e-u;return u===i||n>=t||n<0||f&&e-h>=s}function _(){var e=Ea();if(g(e))return y(e);c=Po(_,function(e){var n=t-(e-u);return f?vn(n,s-(e-h)):n}(e))}function y(e){return c=i,p&&r?m(e):(r=a=i,l)}function v(){var e=Ea(),n=g(e);if(r=arguments,a=this,u=e,n){if(c===i)return function(e){return h=e,c=Po(_,t),d?m(e):l}(u);if(f)return wi(c),c=Po(_,t),m(u)}return c===i&&(c=Po(_,t)),l}return t=gs(t)||0,es(n)&&(d=!!n.leading,s=(f="maxWait"in n)?Yt(gs(n.maxWait)||0,t):s,p="trailing"in n?!!n.trailing:p),v.cancel=function(){c!==i&&wi(c),h=0,r=u=a=c=i},v.flush=function(){return c===i?l:y(Ea())},v}var Ra=Xr((function(e,t){return ur(e,1,t)})),La=Xr((function(e,t,n){return ur(e,gs(t)||0,n)}));function za(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new ke(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(za.Cache||Zn),n}function Oa(e){if("function"!=typeof e)throw new ke(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}za.Cache=Zn;var Da=xi((function(e,t){var n=(t=1==t.length&&qa(t[0])?Ot(t[0],$t(lo())):Ot(_r(t,1),$t(lo()))).length;return Xr((function(r){for(var i=-1,o=vn(r.length,n);++i=t})),Ga=Pr(function(){return arguments}())?Pr:function(e){return ts(e)&&Oe.call(e,"callee")&&!Ye.call(e,"callee")},qa=n.isArray,Wa=bt?$t(bt):function(e){return ts(e)&&Ar(e)==z};function Ha(e){return null!=e&&$a(e.length)&&!Ka(e)}function Za(e){return ts(e)&&Ha(e)}var Ya=_t||gl,Qa=wt?$t(wt):function(e){return ts(e)&&Ar(e)==b};function Xa(e){if(!ts(e))return!1;var t=Ar(e);return t==w||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!is(e)}function Ka(e){if(!es(e))return!1;var t=Ar(e);return t==S||t==M||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Ja(e){return"number"==typeof e&&e==ps(e)}function $a(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=p}function es(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ts(e){return null!=e&&"object"==typeof e}var ns=St?$t(St):function(e){return ts(e)&&mo(e)==A};function rs(e){return"number"==typeof e||ts(e)&&Ar(e)==E}function is(e){if(!ts(e)||Ar(e)!=T)return!1;var t=He(e);if(null===t)return!0;var n=Oe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&ze.call(n)==Ne}var os=Mt?$t(Mt):function(e){return ts(e)&&Ar(e)==k};var as=At?$t(At):function(e){return ts(e)&&mo(e)==I};function ss(e){return"string"==typeof e||!qa(e)&&ts(e)&&Ar(e)==P}function ls(e){return"symbol"==typeof e||ts(e)&&Ar(e)==R}var cs=Et?$t(Et):function(e){return ts(e)&&$a(e.length)&&!!lt[Ar(e)]};var us=Hi(Fr),hs=Hi((function(e,t){return e<=t}));function ds(e){if(!e)return[];if(Ha(e))return ss(e)?mn(e):ki(e);if(Ke&&e[Ke])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Ke]());var t=mo(e);return(t==A?cn:t==I?dn:js)(e)}function fs(e){return e?(e=gs(e))===f||e===-1/0?17976931348623157e292*(e<0?-1:1):e===e?e:0:0===e?e:0}function ps(e){var t=fs(e),n=t%1;return t===t?n?t-n:t:0}function ms(e){return e?sr(ps(e),0,g):0}function gs(e){if("number"==typeof e)return e;if(ls(e))return m;if(es(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=es(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Jt(e);var n=_e.test(e);return n||ve.test(e)?dt(e.slice(2),n?2:8):ge.test(e)?m:+e}function _s(e){return Ii(e,Rs(e))}function ys(e){return null==e?"":ci(e)}var vs=Ri((function(e,t){if(Mo(t)||Ha(t))Ii(t,Ps(t),e);else for(var n in t)Oe.call(t,n)&&tr(e,n,t[n])})),xs=Ri((function(e,t){Ii(t,Rs(t),e)})),bs=Ri((function(e,t,n,r){Ii(t,Rs(t),e,r)})),ws=Ri((function(e,t,n,r){Ii(t,Ps(t),e,r)})),Ss=no(ar);var Ms=Xr((function(e,t){e=Ee(e);var n=-1,r=t.length,o=r>2?t[2]:i;for(o&&xo(t[0],t[1],o)&&(r=1);++n1),t})),Ii(e,io(e),n),r&&(n=lr(n,7,eo));for(var i=t.length;i--;)hi(n,t[i]);return n}));var Ds=no((function(e,t){return null==e?{}:function(e,t){return Wr(e,t,(function(t,n){return Ts(e,n)}))}(e,t)}));function Bs(e,t){if(null==e)return{};var n=Ot(io(e),(function(e){return[e]}));return t=lo(t),Wr(e,n,(function(e,n){return t(e,n[0])}))}var Fs=Xi(Ps),Ns=Xi(Rs);function js(e){return null==e?[]:en(e,Ps(e))}var Vs=Di((function(e,t,n){return t=t.toLowerCase(),e+(n?Us(t):t)}));function Us(e){return Xs(ys(e).toLowerCase())}function Gs(e){return(e=ys(e))&&e.replace(be,on).replace(tt,"")}var qs=Di((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ws=Di((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Hs=Oi("toLowerCase");var Zs=Di((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var Ys=Di((function(e,t,n){return e+(n?" ":"")+Xs(t)}));var Qs=Di((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Xs=Oi("toUpperCase");function Ks(e,t,n){return e=ys(e),(t=n?i:t)===i?function(e){return ot.test(e)}(e)?function(e){return e.match(rt)||[]}(e):function(e){return e.match(he)||[]}(e):e.match(t)||[]}var Js=Xr((function(e,t){try{return Tt(e,i,t)}catch(n){return Xa(n)?n:new se(n)}})),$s=no((function(e,t){return kt(t,(function(t){t=Bo(t),or(e,t,ka(e[t],e))})),e}));function el(e){return function(){return e}}var tl=Ni(),nl=Ni(!0);function rl(e){return e}function il(e){return Or("function"==typeof e?e:lr(e,1))}var ol=Xr((function(e,t){return function(n){return Ir(n,e,t)}})),al=Xr((function(e,t){return function(n){return Ir(e,n,t)}}));function sl(e,t,n){var r=Ps(t),i=wr(t,r);null!=n||es(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=wr(t,Ps(t)));var o=!(es(n)&&"chain"in n)||!!n.chain,a=Ka(e);return kt(i,(function(n){var r=t[n];e[n]=r,a&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__);return(n.__actions__=ki(this.__actions__)).push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,Dt([this.value()],arguments))})})),e}function ll(){}var cl=Gi(Ot),ul=Gi(Pt),hl=Gi(Nt);function dl(e){return bo(e)?Zt(Bo(e)):function(e){return function(t){return Sr(t,e)}}(e)}var fl=Wi(),pl=Wi(!0);function ml(){return[]}function gl(){return!1}var _l=Ui((function(e,t){return e+t}),0),yl=Yi("ceil"),vl=Ui((function(e,t){return e/t}),1),xl=Yi("floor");var bl=Ui((function(e,t){return e*t}),1),wl=Yi("round"),Sl=Ui((function(e,t){return e-t}),0);return jn.after=function(e,t){if("function"!=typeof t)throw new ke(o);return e=ps(e),function(){if(--e<1)return t.apply(this,arguments)}},jn.ary=Ta,jn.assign=vs,jn.assignIn=xs,jn.assignInWith=bs,jn.assignWith=ws,jn.at=Ss,jn.before=Ca,jn.bind=ka,jn.bindAll=$s,jn.bindKey=Ia,jn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return qa(e)?e:[e]},jn.chain=da,jn.chunk=function(e,t,r){t=(r?xo(e,t,r):t===i)?1:Yt(ps(t),0);var o=null==e?0:e.length;if(!o||t<1)return[];for(var a=0,s=0,l=n(ft(o/t));ao?0:o+n),(r=r===i||r>o?o:ps(r))<0&&(r+=o),r=n>r?0:ms(r);n>>0)?(e=ys(e))&&("string"==typeof t||null!=t&&!os(t))&&!(t=ci(t))&&ln(e)?bi(mn(e),0,n):e.split(t,n):[]},jn.spread=function(e,t){if("function"!=typeof e)throw new ke(o);return t=null==t?0:Yt(ps(t),0),Xr((function(n){var r=n[t],i=bi(n,0,t);return r&&Dt(i,r),Tt(e,this,i)}))},jn.tail=function(e){var t=null==e?0:e.length;return t?ri(e,1,t):[]},jn.take=function(e,t,n){return e&&e.length?ri(e,0,(t=n||t===i?1:ps(t))<0?0:t):[]},jn.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?ri(e,(t=r-(t=n||t===i?1:ps(t)))<0?0:t,r):[]},jn.takeRightWhile=function(e,t){return e&&e.length?fi(e,lo(t,3),!1,!0):[]},jn.takeWhile=function(e,t){return e&&e.length?fi(e,lo(t,3)):[]},jn.tap=function(e,t){return t(e),e},jn.throttle=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new ke(o);return es(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Pa(e,t,{leading:r,maxWait:t,trailing:i})},jn.thru=fa,jn.toArray=ds,jn.toPairs=Fs,jn.toPairsIn=Ns,jn.toPath=function(e){return qa(e)?Ot(e,Bo):ls(e)?[e]:ki(Do(ys(e)))},jn.toPlainObject=_s,jn.transform=function(e,t,n){var r=qa(e),i=r||Ya(e)||cs(e);if(t=lo(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:es(e)&&Ka(o)?Vn(He(e)):{}}return(i?kt:xr)(e,(function(e,r,i){return t(n,e,r,i)})),n},jn.unary=function(e){return Ta(e,1)},jn.union=ta,jn.unionBy=na,jn.unionWith=ra,jn.uniq=function(e){return e&&e.length?ui(e):[]},jn.uniqBy=function(e,t){return e&&e.length?ui(e,lo(t,2)):[]},jn.uniqWith=function(e,t){return t="function"==typeof t?t:i,e&&e.length?ui(e,i,t):[]},jn.unset=function(e,t){return null==e||hi(e,t)},jn.unzip=ia,jn.unzipWith=oa,jn.update=function(e,t,n){return null==e?e:di(e,t,yi(n))},jn.updateWith=function(e,t,n,r){return r="function"==typeof r?r:i,null==e?e:di(e,t,yi(n),r)},jn.values=js,jn.valuesIn=function(e){return null==e?[]:en(e,Rs(e))},jn.without=aa,jn.words=Ks,jn.wrap=function(e,t){return Ba(yi(t),e)},jn.xor=sa,jn.xorBy=la,jn.xorWith=ca,jn.zip=ua,jn.zipObject=function(e,t){return gi(e||[],t||[],tr)},jn.zipObjectDeep=function(e,t){return gi(e||[],t||[],$r)},jn.zipWith=ha,jn.entries=Fs,jn.entriesIn=Ns,jn.extend=xs,jn.extendWith=bs,sl(jn,jn),jn.add=_l,jn.attempt=Js,jn.camelCase=Vs,jn.capitalize=Us,jn.ceil=yl,jn.clamp=function(e,t,n){return n===i&&(n=t,t=i),n!==i&&(n=(n=gs(n))===n?n:0),t!==i&&(t=(t=gs(t))===t?t:0),sr(gs(e),t,n)},jn.clone=function(e){return lr(e,4)},jn.cloneDeep=function(e){return lr(e,5)},jn.cloneDeepWith=function(e,t){return lr(e,5,t="function"==typeof t?t:i)},jn.cloneWith=function(e,t){return lr(e,4,t="function"==typeof t?t:i)},jn.conformsTo=function(e,t){return null==t||cr(e,t,Ps(t))},jn.deburr=Gs,jn.defaultTo=function(e,t){return null==e||e!==e?t:e},jn.divide=vl,jn.endsWith=function(e,t,n){e=ys(e),t=ci(t);var r=e.length,o=n=n===i?r:sr(ps(n),0,r);return(n-=t.length)>=0&&e.slice(n,o)==t},jn.eq=ja,jn.escape=function(e){return(e=ys(e))&&K.test(e)?e.replace(Q,an):e},jn.escapeRegExp=function(e){return(e=ys(e))&&oe.test(e)?e.replace(ie,"\\$&"):e},jn.every=function(e,t,n){var r=qa(e)?Pt:pr;return n&&xo(e,t,n)&&(t=i),r(e,lo(t,3))},jn.find=ga,jn.findIndex=Go,jn.findKey=function(e,t){return Vt(e,lo(t,3),xr)},jn.findLast=_a,jn.findLastIndex=qo,jn.findLastKey=function(e,t){return Vt(e,lo(t,3),br)},jn.floor=xl,jn.forEach=ya,jn.forEachRight=va,jn.forIn=function(e,t){return null==e?e:yr(e,lo(t,3),Rs)},jn.forInRight=function(e,t){return null==e?e:vr(e,lo(t,3),Rs)},jn.forOwn=function(e,t){return e&&xr(e,lo(t,3))},jn.forOwnRight=function(e,t){return e&&br(e,lo(t,3))},jn.get=Es,jn.gt=Va,jn.gte=Ua,jn.has=function(e,t){return null!=e&&go(e,t,Tr)},jn.hasIn=Ts,jn.head=Ho,jn.identity=rl,jn.includes=function(e,t,n,r){e=Ha(e)?e:js(e),n=n&&!r?ps(n):0;var i=e.length;return n<0&&(n=Yt(i+n,0)),ss(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Gt(e,t,n)>-1},jn.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:ps(n);return i<0&&(i=Yt(r+i,0)),Gt(e,t,i)},jn.inRange=function(e,t,n){return t=fs(t),n===i?(n=t,t=0):n=fs(n),function(e,t,n){return e>=vn(t,n)&&e=-9007199254740991&&e<=p},jn.isSet=as,jn.isString=ss,jn.isSymbol=ls,jn.isTypedArray=cs,jn.isUndefined=function(e){return e===i},jn.isWeakMap=function(e){return ts(e)&&mo(e)==L},jn.isWeakSet=function(e){return ts(e)&&"[object WeakSet]"==Ar(e)},jn.join=function(e,t){return null==e?"":xt.call(e,t)},jn.kebabCase=qs,jn.last=Xo,jn.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r;return n!==i&&(o=(o=ps(n))<0?Yt(r+o,0):vn(o,r-1)),t===t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,o):Ut(e,Wt,o,!0)},jn.lowerCase=Ws,jn.lowerFirst=Hs,jn.lt=us,jn.lte=hs,jn.max=function(e){return e&&e.length?mr(e,rl,Er):i},jn.maxBy=function(e,t){return e&&e.length?mr(e,lo(t,2),Er):i},jn.mean=function(e){return Ht(e,rl)},jn.meanBy=function(e,t){return Ht(e,lo(t,2))},jn.min=function(e){return e&&e.length?mr(e,rl,Fr):i},jn.minBy=function(e,t){return e&&e.length?mr(e,lo(t,2),Fr):i},jn.stubArray=ml,jn.stubFalse=gl,jn.stubObject=function(){return{}},jn.stubString=function(){return""},jn.stubTrue=function(){return!0},jn.multiply=bl,jn.nth=function(e,t){return e&&e.length?Gr(e,ps(t)):i},jn.noConflict=function(){return mt._===this&&(mt._=je),this},jn.noop=ll,jn.now=Ea,jn.pad=function(e,t,n){e=ys(e);var r=(t=ps(t))?pn(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return qi(pt(i),n)+e+qi(ft(i),n)},jn.padEnd=function(e,t,n){e=ys(e);var r=(t=ps(t))?pn(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var o=wn();return vn(e+o*(t-e+ht("1e-"+((o+"").length-1))),t)}return Yr(e,t)},jn.reduce=function(e,t,n){var r=qa(e)?Bt:Qt,i=arguments.length<3;return r(e,lo(t,4),n,i,dr)},jn.reduceRight=function(e,t,n){var r=qa(e)?Ft:Qt,i=arguments.length<3;return r(e,lo(t,4),n,i,fr)},jn.repeat=function(e,t,n){return t=(n?xo(e,t,n):t===i)?1:ps(t),Qr(ys(e),t)},jn.replace=function(){var e=arguments,t=ys(e[0]);return e.length<3?t:t.replace(e[1],e[2])},jn.result=function(e,t,n){var r=-1,o=(t=vi(t,e)).length;for(o||(o=1,e=i);++rp)return[];var n=g,r=vn(e,g);t=lo(t),e-=g;for(var i=Kt(r,t);++n=a)return e;var l=n-pn(r);if(l<1)return r;var c=s?bi(s,0,l).join(""):e.slice(0,l);if(o===i)return c+r;if(s&&(l+=c.length-l),os(o)){if(e.slice(l).search(o)){var u,h=c;for(o.global||(o=Te(o.source,ys(me.exec(o))+"g")),o.lastIndex=0;u=o.exec(h);)var d=u.index;c=c.slice(0,d===i?l:d)}}else if(e.indexOf(ci(o),l)!=l){var f=c.lastIndexOf(o);f>-1&&(c=c.slice(0,f))}return c+r},jn.unescape=function(e){return(e=ys(e))&&X.test(e)?e.replace(Y,_n):e},jn.uniqueId=function(e){var t=++De;return ys(e)+t},jn.upperCase=Qs,jn.upperFirst=Xs,jn.each=ya,jn.eachRight=va,jn.first=Ho,sl(jn,function(){var e={};return xr(jn,(function(t,n){Oe.call(jn.prototype,n)||(e[n]=t)})),e}(),{chain:!1}),jn.VERSION="4.17.21",kt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){jn[e].placeholder=jn})),kt(["drop","take"],(function(e,t){qn.prototype[e]=function(n){n=n===i?1:Yt(ps(n),0);var r=this.__filtered__&&!t?new qn(this):this.clone();return r.__filtered__?r.__takeCount__=vn(n,r.__takeCount__):r.__views__.push({size:vn(n,g),type:e+(r.__dir__<0?"Right":"")}),r},qn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),kt(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;qn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:lo(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),kt(["head","last"],(function(e,t){var n="take"+(t?"Right":"");qn.prototype[e]=function(){return this[n](1).value()[0]}})),kt(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");qn.prototype[e]=function(){return this.__filtered__?new qn(this):this[n](1)}})),qn.prototype.compact=function(){return this.filter(rl)},qn.prototype.find=function(e){return this.filter(e).head()},qn.prototype.findLast=function(e){return this.reverse().find(e)},qn.prototype.invokeMap=Xr((function(e,t){return"function"==typeof e?new qn(this):this.map((function(n){return Ir(n,e,t)}))})),qn.prototype.reject=function(e){return this.filter(Oa(lo(e)))},qn.prototype.slice=function(e,t){e=ps(e);var n=this;return n.__filtered__&&(e>0||t<0)?new qn(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==i&&(n=(t=ps(t))<0?n.dropRight(-t):n.take(t-e)),n)},qn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},qn.prototype.toArray=function(){return this.take(g)},xr(qn.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),o=jn[r?"take"+("last"==t?"Right":""):t],a=r||/^find/.test(t);o&&(jn.prototype[t]=function(){var t=this.__wrapped__,s=r?[1]:arguments,l=t instanceof qn,c=s[0],u=l||qa(t),h=function(e){var t=o.apply(jn,Dt([e],s));return r&&d?t[0]:t};u&&n&&"function"==typeof c&&1!=c.length&&(l=u=!1);var d=this.__chain__,f=!!this.__actions__.length,p=a&&!d,m=l&&!f;if(!a&&u){t=m?t:new qn(this);var g=e.apply(t,s);return g.__actions__.push({func:fa,args:[h],thisArg:i}),new Gn(g,d)}return p&&m?e.apply(this,s):(g=this.thru(h),p?r?g.value()[0]:g.value():g)})})),kt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ie[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);jn.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(qa(i)?i:[],e)}return this[n]((function(n){return t.apply(qa(n)?n:[],e)}))}})),xr(qn.prototype,(function(e,t){var n=jn[t];if(n){var r=n.name+"";Oe.call(Pn,r)||(Pn[r]=[]),Pn[r].push({name:t,func:n})}})),Pn[ji(i,2).name]=[{name:"wrapper",func:i}],qn.prototype.clone=function(){var e=new qn(this.__wrapped__);return e.__actions__=ki(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=ki(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=ki(this.__views__),e},qn.prototype.reverse=function(){if(this.__filtered__){var e=new qn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},qn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=qa(e),r=t<0,i=n?e.length:0,o=function(e,t,n){var r=-1,i=n.length;for(;++r=this.__values__.length;return{done:e,value:e?i:this.__values__[this.__index__++]}},jn.prototype.plant=function(e){for(var t,n=this;n instanceof Un;){var r=No(n);r.__index__=0,r.__values__=i,t?o.__wrapped__=r:t=r;var o=r;n=n.__wrapped__}return o.__wrapped__=e,t},jn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof qn){var t=e;return this.__actions__.length&&(t=new qn(this)),(t=t.reverse()).__actions__.push({func:fa,args:[ea],thisArg:i}),new Gn(t,this.__chain__)}return this.thru(ea)},jn.prototype.toJSON=jn.prototype.valueOf=jn.prototype.value=function(){return pi(this.__wrapped__,this.__actions__)},jn.prototype.first=jn.prototype.head,Ke&&(jn.prototype[Ke]=function(){return this}),jn}();mt._=yn,(r=function(){return yn}.call(t,n,t,e))===i||(e.exports=r)}.call(this)},879:function(e){e.exports=function(){"use strict";var e,t,n;function r(r,i){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;",a={};e(a),n=i(a),"undefined"!==typeof window&&window&&window.URL&&window.URL.createObjectURL&&(n.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else t=i;else e=i}return r(["exports"],(function(e){var t="3.4.0";let n;const r={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==n){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{n=null!={NODE_ENV:"production",PUBLIC_URL:"/UBEMViewer",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_MAPBOX_TOKEN:"pk.eyJ1Ijoia3g2NCIsImEiOiJjbGkzd2E1dmsxMzNoM2twY2p2azF0bGVlIn0.t_v73kaAMUtoGBPESpw3uA"}.API_URL_REGEX?new RegExp({NODE_ENV:"production",PUBLIC_URL:"/UBEMViewer",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_MAPBOX_TOKEN:"pk.eyJ1Ijoia3g2NCIsImEiOiJjbGkzd2E1dmsxMzNoM2twY2p2azF0bGVlIn0.t_v73kaAMUtoGBPESpw3uA"}.API_URL_REGEX):e}catch(t){n=e}}return n},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!r.API_URL)return null;try{const e=new URL(r.API_URL);return"api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"};function i(e){return r.API_URL_REGEX.test(e)}function o(e){return 0===e.indexOf("mapbox:")}function a(e){return r.API_CDN_URL_REGEX.test(e)}function s(e){return r.API_SPRITE_REGEX.test(e)}function l(e){return r.API_STYLE_REGEX.test(e)&&!s(e)}const c={create:"create",load:"load",fullLoad:"fullLoad"};function u(e){const t=e.name.split("?")[0];return a(t)&&t.includes("mapbox-gl.js")?"javascript":a(t)&&t.includes("mapbox-gl.css")?"css":function(e){return r.API_FONTS_REGEX.test(e)}(t)?"fontRange":s(t)?"sprite":l(t)?"style":function(e){return r.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}function h(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var d={},f={};Object.defineProperty(f,"__esModule",{value:!0}),f.setMatrixArrayType=function(e){f.ARRAY_TYPE=m=e},f.toRadian=function(e){return e*_},f.equals=function(e,t){return Math.abs(e-t)<=p*Math.max(1,Math.abs(e),Math.abs(t))},f.RANDOM=f.ARRAY_TYPE=f.EPSILON=void 0;var p=1e-6;f.EPSILON=p;var m="undefined"!=typeof Float32Array?Float32Array:Array;f.ARRAY_TYPE=m;var g=Math.random;f.RANDOM=g;var _=Math.PI/180;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var y={};function v(e){return v="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},v(e)}Object.defineProperty(y,"__esModule",{value:!0}),y.create=function(){var e=new x.ARRAY_TYPE(4);return x.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},y.clone=function(e){var t=new x.ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},y.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},y.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},y.fromValues=function(e,t,n,r){var i=new x.ARRAY_TYPE(4);return i[0]=e,i[1]=t,i[2]=n,i[3]=r,i},y.set=function(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e},y.transpose=function(e,t){if(e===t){var n=t[1];e[1]=t[2],e[2]=n}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},y.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*o-i*r;return a?(e[0]=o*(a=1/a),e[1]=-r*a,e[2]=-i*a,e[3]=n*a,e):null},y.adjoint=function(e,t){var n=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=n,e},y.determinant=function(e){return e[0]*e[3]-e[2]*e[1]},y.multiply=w,y.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+o*s,e[1]=i*l+a*s,e[2]=r*-s+o*l,e[3]=i*-s+a*l,e},y.scale=function(e,t,n){var r=t[1],i=t[2],o=t[3],a=n[0],s=n[1];return e[0]=t[0]*a,e[1]=r*a,e[2]=i*s,e[3]=o*s,e},y.fromRotation=function(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=-n,e[3]=r,e},y.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e},y.str=function(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},y.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},y.LDU=function(e,t,n,r){return e[2]=r[2]/r[0],n[0]=r[0],n[1]=r[1],n[3]=r[3]-e[2]*n[1],[e,t,n]},y.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},y.subtract=S,y.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},y.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=t[0],s=t[1],l=t[2],c=t[3];return Math.abs(n-a)<=x.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-s)<=x.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-l)<=x.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(o-c)<=x.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},y.multiplyScalar=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},y.multiplyScalarAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e},y.sub=y.mul=void 0;var x=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==v(e)&&"function"!=typeof e)return{default:e};var n=b(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(f);function b(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(b=function(e){return e?n:t})(e)}function w(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],c=n[2],u=n[3];return e[0]=r*s+o*l,e[1]=i*s+a*l,e[2]=r*c+o*u,e[3]=i*c+a*u,e}function S(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}y.mul=w,y.sub=S;var M={};function A(e){return A="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},A(e)}Object.defineProperty(M,"__esModule",{value:!0}),M.create=function(){var e=new E.ARRAY_TYPE(6);return E.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e},M.clone=function(e){var t=new E.ARRAY_TYPE(6);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},M.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},M.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},M.fromValues=function(e,t,n,r,i,o){var a=new E.ARRAY_TYPE(6);return a[0]=e,a[1]=t,a[2]=n,a[3]=r,a[4]=i,a[5]=o,a},M.set=function(e,t,n,r,i,o,a){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o,e[5]=a,e},M.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=n*o-r*i;return l?(e[0]=o*(l=1/l),e[1]=-r*l,e[2]=-i*l,e[3]=n*l,e[4]=(i*s-o*a)*l,e[5]=(r*a-n*s)*l,e):null},M.determinant=function(e){return e[0]*e[3]-e[1]*e[2]},M.multiply=C,M.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=Math.sin(n),u=Math.cos(n);return e[0]=r*u+o*c,e[1]=i*u+a*c,e[2]=r*-c+o*u,e[3]=i*-c+a*u,e[4]=s,e[5]=l,e},M.scale=function(e,t,n){var r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=n[0],c=n[1];return e[0]=t[0]*l,e[1]=r*l,e[2]=i*c,e[3]=o*c,e[4]=a,e[5]=s,e},M.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=n[0],u=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=r*c+o*u+s,e[5]=i*c+a*u+l,e},M.fromRotation=function(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=-n,e[3]=r,e[4]=0,e[5]=0,e},M.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e},M.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e},M.str=function(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},M.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],1)},M.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e},M.subtract=k,M.multiplyScalar=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*n,e[5]=t[5]*n,e},M.multiplyScalarAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e[4]=t[4]+n[4]*r,e[5]=t[5]+n[5]*r,e},M.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]},M.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=t[0],c=t[1],u=t[2],h=t[3],d=t[4],f=t[5];return Math.abs(n-l)<=E.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(r-c)<=E.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(i-u)<=E.EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(o-h)<=E.EPSILON*Math.max(1,Math.abs(o),Math.abs(h))&&Math.abs(a-d)<=E.EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(s-f)<=E.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))},M.sub=M.mul=void 0;var E=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==A(e)&&"function"!=typeof e)return{default:e};var n=T(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(f);function T(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(T=function(e){return e?n:t})(e)}function C(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=n[0],u=n[1],h=n[2],d=n[3],f=n[4],p=n[5];return e[0]=r*c+o*u,e[1]=i*c+a*u,e[2]=r*h+o*d,e[3]=i*h+a*d,e[4]=r*f+o*p+s,e[5]=i*f+a*p+l,e}function k(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e}M.mul=C,M.sub=k;var I={};function P(e){return P="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},P(e)}Object.defineProperty(I,"__esModule",{value:!0}),I.create=function(){var e=new R.ARRAY_TYPE(9);return R.ARRAY_TYPE!=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},I.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},I.clone=function(e){var t=new R.ARRAY_TYPE(9);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},I.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},I.fromValues=function(e,t,n,r,i,o,a,s,l){var c=new R.ARRAY_TYPE(9);return c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=i,c[5]=o,c[6]=a,c[7]=s,c[8]=l,c},I.set=function(e,t,n,r,i,o,a,s,l,c){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o,e[5]=a,e[6]=s,e[7]=l,e[8]=c,e},I.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},I.transpose=function(e,t){if(e===t){var n=t[1],r=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=i}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},I.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],h=u*a-s*c,d=-u*o+s*l,f=c*o-a*l,p=n*h+r*d+i*f;return p?(e[0]=h*(p=1/p),e[1]=(-u*r+i*c)*p,e[2]=(s*r-i*a)*p,e[3]=d*p,e[4]=(u*n-i*l)*p,e[5]=(-s*n+i*o)*p,e[6]=f*p,e[7]=(-c*n+r*l)*p,e[8]=(a*n-r*o)*p,e):null},I.adjoint=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8];return e[0]=a*u-s*c,e[1]=i*c-r*u,e[2]=r*s-i*a,e[3]=s*l-o*u,e[4]=n*u-i*l,e[5]=i*o-n*s,e[6]=o*c-a*l,e[7]=r*l-n*c,e[8]=n*a-r*o,e},I.determinant=function(e){var t=e[3],n=e[4],r=e[5],i=e[6],o=e[7],a=e[8];return e[0]*(a*n-r*o)+e[1]*(-a*t+r*i)+e[2]*(o*t-n*i)},I.multiply=z,I.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=n[0],f=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=d*r+f*a+c,e[7]=d*i+f*s+u,e[8]=d*o+f*l+h,e},I.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=Math.sin(n),f=Math.cos(n);return e[0]=f*r+d*a,e[1]=f*i+d*s,e[2]=f*o+d*l,e[3]=f*a-d*r,e[4]=f*s-d*i,e[5]=f*l-d*o,e[6]=c,e[7]=u,e[8]=h,e},I.scale=function(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},I.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e},I.fromRotation=function(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=-n,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},I.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},I.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},I.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,c=n*a,u=r*a,h=r*s,d=i*a,f=i*s,p=i*l,m=o*a,g=o*s,_=o*l;return e[0]=1-h-p,e[3]=u-_,e[6]=d+g,e[1]=u+_,e[4]=1-c-p,e[7]=f-m,e[2]=d-g,e[5]=f+m,e[8]=1-c-h,e},I.normalFromMat4=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],_=t[15],y=n*s-r*a,v=n*l-i*a,x=n*c-o*a,b=r*l-i*s,w=r*c-o*s,S=i*c-o*l,M=u*m-h*p,A=u*g-d*p,E=u*_-f*p,T=h*g-d*m,C=h*_-f*m,k=d*_-f*g,I=y*k-v*C+x*T+b*E-w*A+S*M;return I?(e[0]=(s*k-l*C+c*T)*(I=1/I),e[1]=(l*E-a*k-c*A)*I,e[2]=(a*C-s*E+c*M)*I,e[3]=(i*C-r*k-o*T)*I,e[4]=(n*k-i*E+o*A)*I,e[5]=(r*E-n*C-o*M)*I,e[6]=(m*S-g*w+_*b)*I,e[7]=(g*x-p*S-_*v)*I,e[8]=(p*w-m*x+_*y)*I,e):null},I.projection=function(e,t,n){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/n,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e},I.str=function(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},I.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},I.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e},I.subtract=O,I.multiplyScalar=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e},I.multiplyScalarAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e[4]=t[4]+n[4]*r,e[5]=t[5]+n[5]*r,e[6]=t[6]+n[6]*r,e[7]=t[7]+n[7]*r,e[8]=t[8]+n[8]*r,e},I.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]},I.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],h=t[0],d=t[1],f=t[2],p=t[3],m=t[4],g=t[5],_=t[6],y=t[7],v=t[8];return Math.abs(n-h)<=R.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(r-d)<=R.EPSILON*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(i-f)<=R.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(o-p)<=R.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(a-m)<=R.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(s-g)<=R.EPSILON*Math.max(1,Math.abs(s),Math.abs(g))&&Math.abs(l-_)<=R.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(c-y)<=R.EPSILON*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(u-v)<=R.EPSILON*Math.max(1,Math.abs(u),Math.abs(v))},I.sub=I.mul=void 0;var R=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==P(e)&&"function"!=typeof e)return{default:e};var n=L(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(f);function L(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(L=function(e){return e?n:t})(e)}function z(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=n[0],f=n[1],p=n[2],m=n[3],g=n[4],_=n[5],y=n[6],v=n[7],x=n[8];return e[0]=d*r+f*a+p*c,e[1]=d*i+f*s+p*u,e[2]=d*o+f*l+p*h,e[3]=m*r+g*a+_*c,e[4]=m*i+g*s+_*u,e[5]=m*o+g*l+_*h,e[6]=y*r+v*a+x*c,e[7]=y*i+v*s+x*u,e[8]=y*o+v*l+x*h,e}function O(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e}I.mul=z,I.sub=O;var D={};function B(e){return B="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},B(e)}Object.defineProperty(D,"__esModule",{value:!0}),D.create=function(){var e=new F.ARRAY_TYPE(16);return F.ARRAY_TYPE!=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},D.clone=function(e){var t=new F.ARRAY_TYPE(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},D.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},D.fromValues=function(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m){var g=new F.ARRAY_TYPE(16);return g[0]=e,g[1]=t,g[2]=n,g[3]=r,g[4]=i,g[5]=o,g[6]=a,g[7]=s,g[8]=l,g[9]=c,g[10]=u,g[11]=h,g[12]=d,g[13]=f,g[14]=p,g[15]=m,g},D.set=function(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o,e[5]=a,e[6]=s,e[7]=l,e[8]=c,e[9]=u,e[10]=h,e[11]=d,e[12]=f,e[13]=p,e[14]=m,e[15]=g,e},D.identity=j,D.transpose=function(e,t){if(e===t){var n=t[1],r=t[2],i=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=i,e[13]=a,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},D.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],_=t[15],y=n*s-r*a,v=n*l-i*a,x=n*c-o*a,b=r*l-i*s,w=r*c-o*s,S=i*c-o*l,M=u*m-h*p,A=u*g-d*p,E=u*_-f*p,T=h*g-d*m,C=h*_-f*m,k=d*_-f*g,I=y*k-v*C+x*T+b*E-w*A+S*M;return I?(e[0]=(s*k-l*C+c*T)*(I=1/I),e[1]=(i*C-r*k-o*T)*I,e[2]=(m*S-g*w+_*b)*I,e[3]=(d*w-h*S-f*b)*I,e[4]=(l*E-a*k-c*A)*I,e[5]=(n*k-i*E+o*A)*I,e[6]=(g*x-p*S-_*v)*I,e[7]=(u*S-d*x+f*v)*I,e[8]=(a*C-s*E+c*M)*I,e[9]=(r*E-n*C-o*M)*I,e[10]=(p*w-m*x+_*y)*I,e[11]=(h*x-u*w-f*y)*I,e[12]=(s*A-a*T-l*M)*I,e[13]=(n*T-r*A+i*M)*I,e[14]=(m*v-p*b-g*y)*I,e[15]=(u*b-h*v+d*y)*I,e):null},D.adjoint=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],_=t[15];return e[0]=s*(d*_-f*g)-h*(l*_-c*g)+m*(l*f-c*d),e[1]=-(r*(d*_-f*g)-h*(i*_-o*g)+m*(i*f-o*d)),e[2]=r*(l*_-c*g)-s*(i*_-o*g)+m*(i*c-o*l),e[3]=-(r*(l*f-c*d)-s*(i*f-o*d)+h*(i*c-o*l)),e[4]=-(a*(d*_-f*g)-u*(l*_-c*g)+p*(l*f-c*d)),e[5]=n*(d*_-f*g)-u*(i*_-o*g)+p*(i*f-o*d),e[6]=-(n*(l*_-c*g)-a*(i*_-o*g)+p*(i*c-o*l)),e[7]=n*(l*f-c*d)-a*(i*f-o*d)+u*(i*c-o*l),e[8]=a*(h*_-f*m)-u*(s*_-c*m)+p*(s*f-c*h),e[9]=-(n*(h*_-f*m)-u*(r*_-o*m)+p*(r*f-o*h)),e[10]=n*(s*_-c*m)-a*(r*_-o*m)+p*(r*c-o*s),e[11]=-(n*(s*f-c*h)-a*(r*f-o*h)+u*(r*c-o*s)),e[12]=-(a*(h*g-d*m)-u*(s*g-l*m)+p*(s*d-l*h)),e[13]=n*(h*g-d*m)-u*(r*g-i*m)+p*(r*d-i*h),e[14]=-(n*(s*g-l*m)-a*(r*g-i*m)+p*(r*l-i*s)),e[15]=n*(s*d-l*h)-a*(r*d-i*h)+u*(r*l-i*s),e},D.determinant=function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],f=e[12],p=e[13],m=e[14],g=e[15];return(t*a-n*o)*(h*g-d*m)-(t*s-r*o)*(u*g-d*p)+(t*l-i*o)*(u*m-h*p)+(n*s-r*a)*(c*g-d*f)-(n*l-i*a)*(c*m-h*f)+(r*l-i*s)*(c*p-u*f)},D.multiply=V,D.translate=function(e,t,n){var r,i,o,a,s,l,c,u,h,d,f,p,m=n[0],g=n[1],_=n[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],f=t[10],p=t[11],e[0]=r=t[0],e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=f,e[11]=p,e[12]=r*m+s*g+h*_+t[12],e[13]=i*m+l*g+d*_+t[13],e[14]=o*m+c*g+f*_+t[14],e[15]=a*m+u*g+p*_+t[15]),e},D.scale=function(e,t,n){var r=n[0],i=n[1],o=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,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},D.rotate=function(e,t,n,r){var i,o,a,s,l,c,u,h,d,f,p,m,g,_,y,v,x,b,w,S,M,A,E,T,C=r[0],k=r[1],I=r[2],P=Math.hypot(C,k,I);return P0?(n[0]=2*(s*a+u*r+l*o-c*i)/h,n[1]=2*(l*a+u*i+c*r-s*o)/h,n[2]=2*(c*a+u*o+s*i-l*r)/h):(n[0]=2*(s*a+u*r+l*o-c*i),n[1]=2*(l*a+u*i+c*r-s*o),n[2]=2*(c*a+u*o+s*i-l*r)),U(e,t,n),e},D.getTranslation=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},D.getScaling=G,D.getRotation=function(e,t){var n=new F.ARRAY_TYPE(3);G(n,t);var r=1/n[0],i=1/n[1],o=1/n[2],a=t[0]*r,s=t[1]*i,l=t[2]*o,c=t[4]*r,u=t[5]*i,h=t[6]*o,d=t[8]*r,f=t[9]*i,p=t[10]*o,m=a+u+p,g=0;return m>0?(g=2*Math.sqrt(m+1),e[3]=.25*g,e[0]=(h-f)/g,e[1]=(d-l)/g,e[2]=(s-c)/g):a>u&&a>p?(g=2*Math.sqrt(1+a-u-p),e[3]=(h-f)/g,e[0]=.25*g,e[1]=(s+c)/g,e[2]=(d+l)/g):u>p?(g=2*Math.sqrt(1+u-a-p),e[3]=(d-l)/g,e[0]=(s+c)/g,e[1]=.25*g,e[2]=(h+f)/g):(g=2*Math.sqrt(1+p-a-u),e[3]=(s-c)/g,e[0]=(d+l)/g,e[1]=(h+f)/g,e[2]=.25*g),e},D.fromRotationTranslationScale=function(e,t,n,r){var i=t[0],o=t[1],a=t[2],s=t[3],l=i+i,c=o+o,u=a+a,h=i*l,d=i*c,f=i*u,p=o*c,m=o*u,g=a*u,_=s*l,y=s*c,v=s*u,x=r[0],b=r[1],w=r[2];return e[0]=(1-(p+g))*x,e[1]=(d+v)*x,e[2]=(f-y)*x,e[3]=0,e[4]=(d-v)*b,e[5]=(1-(h+g))*b,e[6]=(m+_)*b,e[7]=0,e[8]=(f+y)*w,e[9]=(m-_)*w,e[10]=(1-(h+p))*w,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},D.fromRotationTranslationScaleOrigin=function(e,t,n,r,i){var o=t[0],a=t[1],s=t[2],l=t[3],c=o+o,u=a+a,h=s+s,d=o*c,f=o*u,p=o*h,m=a*u,g=a*h,_=s*h,y=l*c,v=l*u,x=l*h,b=r[0],w=r[1],S=r[2],M=i[0],A=i[1],E=i[2],T=(1-(m+_))*b,C=(f+x)*b,k=(p-v)*b,I=(f-x)*w,P=(1-(d+_))*w,R=(g+y)*w,L=(p+v)*S,z=(g-y)*S,O=(1-(d+m))*S;return e[0]=T,e[1]=C,e[2]=k,e[3]=0,e[4]=I,e[5]=P,e[6]=R,e[7]=0,e[8]=L,e[9]=z,e[10]=O,e[11]=0,e[12]=n[0]+M-(T*M+I*A+L*E),e[13]=n[1]+A-(C*M+P*A+z*E),e[14]=n[2]+E-(k*M+R*A+O*E),e[15]=1,e},D.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,c=n*a,u=r*a,h=r*s,d=i*a,f=i*s,p=i*l,m=o*a,g=o*s,_=o*l;return e[0]=1-h-p,e[1]=u+_,e[2]=d-g,e[3]=0,e[4]=u-_,e[5]=1-c-p,e[6]=f+m,e[7]=0,e[8]=d+g,e[9]=f-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},D.frustum=function(e,t,n,r,i,o,a){var s=1/(n-t),l=1/(i-r),c=1/(o-a);return e[0]=2*o*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*l,e[10]=(a+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*c,e[15]=0,e},D.perspectiveNO=q,D.perspectiveZO=function(e,t,n,r,i){var o,a=1/Math.tan(t/2);return e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,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!=i&&i!==1/0?(e[10]=i*(o=1/(r-i)),e[14]=i*r*o):(e[10]=-1,e[14]=-r),e},D.perspectiveFromFieldOfView=function(e,t,n,r){var i=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),a=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),l=2/(a+s),c=2/(i+o);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=-(a-s)*l*.5,e[9]=(i-o)*c*.5,e[10]=r/(n-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*n/(n-r),e[15]=0,e},D.orthoNO=W,D.orthoZO=function(e,t,n,r,i,o,a){var s=1/(t-n),l=1/(r-i),c=1/(o-a);return e[0]=-2*s,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]=c,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*l,e[14]=o*c,e[15]=1,e},D.lookAt=function(e,t,n,r){var i,o,a,s,l,c,u,h,d,f,p=t[0],m=t[1],g=t[2],_=r[0],y=r[1],v=r[2],x=n[0],b=n[1],w=n[2];return Math.abs(p-x)0&&(u*=f=1/Math.sqrt(f),h*=f,d*=f);var p=l*d-c*h,m=c*u-s*d,g=s*h-l*u;return(f=p*p+m*m+g*g)>0&&(p*=f=1/Math.sqrt(f),m*=f,g*=f),e[0]=p,e[1]=m,e[2]=g,e[3]=0,e[4]=h*g-d*m,e[5]=d*p-u*g,e[6]=u*m-h*p,e[7]=0,e[8]=u,e[9]=h,e[10]=d,e[11]=0,e[12]=i,e[13]=o,e[14]=a,e[15]=1,e},D.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},D.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},D.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e[9]=t[9]+n[9],e[10]=t[10]+n[10],e[11]=t[11]+n[11],e[12]=t[12]+n[12],e[13]=t[13]+n[13],e[14]=t[14]+n[14],e[15]=t[15]+n[15],e},D.subtract=H,D.multiplyScalar=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12]*n,e[13]=t[13]*n,e[14]=t[14]*n,e[15]=t[15]*n,e},D.multiplyScalarAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e[4]=t[4]+n[4]*r,e[5]=t[5]+n[5]*r,e[6]=t[6]+n[6]*r,e[7]=t[7]+n[7]*r,e[8]=t[8]+n[8]*r,e[9]=t[9]+n[9]*r,e[10]=t[10]+n[10]*r,e[11]=t[11]+n[11]*r,e[12]=t[12]+n[12]*r,e[13]=t[13]+n[13]*r,e[14]=t[14]+n[14]*r,e[15]=t[15]+n[15]*r,e},D.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},D.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=e[8],h=e[9],d=e[10],f=e[11],p=e[12],m=e[13],g=e[14],_=e[15],y=t[0],v=t[1],x=t[2],b=t[3],w=t[4],S=t[5],M=t[6],A=t[7],E=t[8],T=t[9],C=t[10],k=t[11],I=t[12],P=t[13],R=t[14],L=t[15];return Math.abs(n-y)<=F.EPSILON*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(r-v)<=F.EPSILON*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(i-x)<=F.EPSILON*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(o-b)<=F.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(a-w)<=F.EPSILON*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(s-S)<=F.EPSILON*Math.max(1,Math.abs(s),Math.abs(S))&&Math.abs(l-M)<=F.EPSILON*Math.max(1,Math.abs(l),Math.abs(M))&&Math.abs(c-A)<=F.EPSILON*Math.max(1,Math.abs(c),Math.abs(A))&&Math.abs(u-E)<=F.EPSILON*Math.max(1,Math.abs(u),Math.abs(E))&&Math.abs(h-T)<=F.EPSILON*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(d-C)<=F.EPSILON*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(f-k)<=F.EPSILON*Math.max(1,Math.abs(f),Math.abs(k))&&Math.abs(p-I)<=F.EPSILON*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(m-P)<=F.EPSILON*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(g-R)<=F.EPSILON*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(_-L)<=F.EPSILON*Math.max(1,Math.abs(_),Math.abs(L))},D.sub=D.mul=D.ortho=D.perspective=void 0;var F=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==B(e)&&"function"!=typeof e)return{default:e};var n=N(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(f);function N(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(N=function(e){return e?n:t})(e)}function j(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 V(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],f=t[10],p=t[11],m=t[12],g=t[13],_=t[14],y=t[15],v=n[0],x=n[1],b=n[2],w=n[3];return e[0]=v*r+x*s+b*h+w*m,e[1]=v*i+x*l+b*d+w*g,e[2]=v*o+x*c+b*f+w*_,e[3]=v*a+x*u+b*p+w*y,e[4]=(v=n[4])*r+(x=n[5])*s+(b=n[6])*h+(w=n[7])*m,e[5]=v*i+x*l+b*d+w*g,e[6]=v*o+x*c+b*f+w*_,e[7]=v*a+x*u+b*p+w*y,e[8]=(v=n[8])*r+(x=n[9])*s+(b=n[10])*h+(w=n[11])*m,e[9]=v*i+x*l+b*d+w*g,e[10]=v*o+x*c+b*f+w*_,e[11]=v*a+x*u+b*p+w*y,e[12]=(v=n[12])*r+(x=n[13])*s+(b=n[14])*h+(w=n[15])*m,e[13]=v*i+x*l+b*d+w*g,e[14]=v*o+x*c+b*f+w*_,e[15]=v*a+x*u+b*p+w*y,e}function U(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=r+r,l=i+i,c=o+o,u=r*s,h=r*l,d=r*c,f=i*l,p=i*c,m=o*c,g=a*s,_=a*l,y=a*c;return e[0]=1-(f+m),e[1]=h+y,e[2]=d-_,e[3]=0,e[4]=h-y,e[5]=1-(u+m),e[6]=p+g,e[7]=0,e[8]=d+_,e[9]=p-g,e[10]=1-(u+f),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function G(e,t){var n=t[4],r=t[5],i=t[6],o=t[8],a=t[9],s=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(n,r,i),e[2]=Math.hypot(o,a,s),e}function q(e,t,n,r,i){var o,a=1/Math.tan(t/2);return e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,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!=i&&i!==1/0?(e[10]=(i+r)*(o=1/(r-i)),e[14]=2*i*r*o):(e[10]=-1,e[14]=-2*r),e}function W(e,t,n,r,i,o,a){var s=1/(t-n),l=1/(r-i),c=1/(o-a);return e[0]=-2*s,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+n)*s,e[13]=(i+r)*l,e[14]=(a+o)*c,e[15]=1,e}function H(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e[9]=t[9]-n[9],e[10]=t[10]-n[10],e[11]=t[11]-n[11],e[12]=t[12]-n[12],e[13]=t[13]-n[13],e[14]=t[14]-n[14],e[15]=t[15]-n[15],e}D.perspective=q,D.ortho=W,D.mul=V,D.sub=H;var Z={},Y={};function Q(e){return Q="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},Q(e)}Object.defineProperty(Y,"__esModule",{value:!0}),Y.create=J,Y.clone=function(e){var t=new X.ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},Y.length=$,Y.fromValues=function(e,t,n){var r=new X.ARRAY_TYPE(3);return r[0]=e,r[1]=t,r[2]=n,r},Y.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},Y.set=function(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e},Y.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e},Y.subtract=ee,Y.multiply=te,Y.divide=ne,Y.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},Y.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},Y.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e},Y.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e},Y.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},Y.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e},Y.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e},Y.distance=re,Y.squaredDistance=ie,Y.squaredLength=oe,Y.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},Y.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},Y.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},Y.dot=ae,Y.cross=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2];return e[0]=i*l-o*s,e[1]=o*a-r*l,e[2]=r*s-i*a,e},Y.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e},Y.hermite=function(e,t,n,r,i,o){var a=o*o,s=a*(2*o-3)+1,l=a*(o-2)+o,c=a*(o-1),u=a*(3-2*o);return e[0]=t[0]*s+n[0]*l+r[0]*c+i[0]*u,e[1]=t[1]*s+n[1]*l+r[1]*c+i[1]*u,e[2]=t[2]*s+n[2]*l+r[2]*c+i[2]*u,e},Y.bezier=function(e,t,n,r,i,o){var a=1-o,s=a*a,l=o*o,c=s*a,u=3*o*s,h=3*l*a,d=l*o;return e[0]=t[0]*c+n[0]*u+r[0]*h+i[0]*d,e[1]=t[1]*c+n[1]*u+r[1]*h+i[1]*d,e[2]=t[2]*c+n[2]*u+r[2]*h+i[2]*d,e},Y.random=function(e,t){t=t||1;var n=2*X.RANDOM()*Math.PI,r=2*X.RANDOM()-1,i=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(n)*i,e[1]=Math.sin(n)*i,e[2]=r*t,e},Y.transformMat4=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/(a=a||1),e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,e},Y.transformMat3=function(e,t,n){var r=t[0],i=t[1],o=t[2];return e[0]=r*n[0]+i*n[3]+o*n[6],e[1]=r*n[1]+i*n[4]+o*n[7],e[2]=r*n[2]+i*n[5]+o*n[8],e},Y.transformQuat=function(e,t,n){var r=n[0],i=n[1],o=n[2],a=t[0],s=t[1],l=t[2],c=i*l-o*s,u=o*a-r*l,h=r*s-i*a,d=i*h-o*u,f=o*c-r*h,p=r*u-i*c,m=2*n[3];return u*=m,h*=m,f*=2,p*=2,e[0]=a+(c*=m)+(d*=2),e[1]=s+u+f,e[2]=l+h+p,e},Y.rotateX=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0],o[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),o[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Y.rotateY=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),o[1]=i[1],o[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Y.rotateZ=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),o[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),o[2]=i[2],e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},Y.angle=function(e,t){var n=e[0],r=e[1],i=e[2],o=t[0],a=t[1],s=t[2],l=Math.sqrt(n*n+r*r+i*i)*Math.sqrt(o*o+a*a+s*s),c=l&&ae(e,t)/l;return Math.acos(Math.min(Math.max(c,-1),1))},Y.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e},Y.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},Y.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},Y.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=t[0],a=t[1],s=t[2];return Math.abs(n-o)<=X.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=X.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=X.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))},Y.forEach=Y.sqrLen=Y.len=Y.sqrDist=Y.dist=Y.div=Y.mul=Y.sub=void 0;var X=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Q(e)&&"function"!=typeof e)return{default:e};var n=K(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(f);function K(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(K=function(e){return e?n:t})(e)}function J(){var e=new X.ARRAY_TYPE(3);return X.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function $(e){return Math.hypot(e[0],e[1],e[2])}function ee(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function te(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function ne(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e}function re(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function ie(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return n*n+r*r+i*i}function oe(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r}function ae(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}Y.sub=ee,Y.mul=te,Y.div=ne,Y.dist=re,Y.sqrDist=ie,Y.len=$,Y.sqrLen=oe;var se,le=(se=J(),function(e,t,n,r,i,o){var a,s;for(t||(t=3),n||(n=0),s=r?Math.min(r*t+n,e.length):e.length,a=n;a0&&(a=1/Math.sqrt(a)),e[0]=n*a,e[1]=r*a,e[2]=i*a,e[3]=o*a,e},ce.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},ce.cross=function(e,t,n,r){var i=n[0]*r[1]-n[1]*r[0],o=n[0]*r[2]-n[2]*r[0],a=n[0]*r[3]-n[3]*r[0],s=n[1]*r[2]-n[2]*r[1],l=n[1]*r[3]-n[3]*r[1],c=n[2]*r[3]-n[3]*r[2],u=t[0],h=t[1],d=t[2],f=t[3];return e[0]=h*c-d*l+f*s,e[1]=-u*c+d*a-f*o,e[2]=u*l-h*a+f*i,e[3]=-u*s+h*o-d*i,e},ce.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2],s=t[3];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e[3]=s+r*(n[3]-s),e},ce.random=function(e,t){var n,r,i,o,a,s;t=t||1;do{a=(n=2*he.RANDOM()-1)*n+(r=2*he.RANDOM()-1)*r}while(a>=1);do{s=(i=2*he.RANDOM()-1)*i+(o=2*he.RANDOM()-1)*o}while(s>=1);var l=Math.sqrt((1-a)/s);return e[0]=t*n,e[1]=t*r,e[2]=t*i*l,e[3]=t*o*l,e},ce.transformMat4=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,e},ce.transformQuat=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2],c=n[3],u=c*r+s*o-l*i,h=c*i+l*r-a*o,d=c*o+a*i-s*r,f=-a*r-s*i-l*o;return e[0]=u*c+f*-a+h*-l-d*-s,e[1]=h*c+f*-s+d*-a-u*-l,e[2]=d*c+f*-l+u*-s-h*-a,e[3]=t[3],e},ce.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},ce.str=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},ce.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},ce.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=t[0],s=t[1],l=t[2],c=t[3];return Math.abs(n-a)<=he.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-s)<=he.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-l)<=he.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(o-c)<=he.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},ce.forEach=ce.sqrLen=ce.len=ce.sqrDist=ce.dist=ce.div=ce.mul=ce.sub=void 0;var he=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==ue(e)&&"function"!=typeof e)return{default:e};var n=de(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(f);function de(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(de=function(e){return e?n:t})(e)}function fe(){var e=new he.ARRAY_TYPE(4);return he.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function pe(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function me(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function ge(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e}function _e(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2],t[3]-e[3])}function ye(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],o=t[3]-e[3];return n*n+r*r+i*i+o*o}function ve(e){return Math.hypot(e[0],e[1],e[2],e[3])}function xe(e){var t=e[0],n=e[1],r=e[2],i=e[3];return t*t+n*n+r*r+i*i}ce.sub=pe,ce.mul=me,ce.div=ge,ce.dist=_e,ce.sqrDist=ye,ce.len=ve,ce.sqrLen=xe;var be=function(){var e=fe();return function(t,n,r,i,o,a){var s,l;for(n||(n=4),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;sSe.EPSILON?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=1,e[1]=0,e[2]=0),n},Z.getAngle=function(e,t){var n=Be(e,t);return Math.acos(2*n*n-1)},Z.multiply=Pe,Z.rotateX=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+a*s,e[1]=i*l+o*s,e[2]=o*l-i*s,e[3]=a*l-r*s,e},Z.rotateY=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l-o*s,e[1]=i*l+a*s,e[2]=o*l+r*s,e[3]=a*l-i*s,e},Z.rotateZ=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+i*s,e[1]=i*l-r*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e},Z.calculateW=function(e,t){var n=t[0],r=t[1],i=t[2];return e[0]=n,e[1]=r,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),e},Z.exp=Re,Z.ln=Le,Z.pow=function(e,t,n){return Le(e,t),De(e,e,n),Re(e,e),e},Z.slerp=ze,Z.random=function(e){var t=Se.RANDOM(),n=Se.RANDOM(),r=Se.RANDOM(),i=Math.sqrt(1-t),o=Math.sqrt(t);return e[0]=i*Math.sin(2*Math.PI*n),e[1]=i*Math.cos(2*Math.PI*n),e[2]=o*Math.sin(2*Math.PI*r),e[3]=o*Math.cos(2*Math.PI*r),e},Z.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o,s=a?1/a:0;return e[0]=-n*s,e[1]=-r*s,e[2]=-i*s,e[3]=o*s,e},Z.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},Z.fromMat3=Oe,Z.fromEuler=function(e,t,n,r){var i=.5*Math.PI/180;t*=i,n*=i,r*=i;var o=Math.sin(t),a=Math.cos(t),s=Math.sin(n),l=Math.cos(n),c=Math.sin(r),u=Math.cos(r);return e[0]=o*l*u-a*s*c,e[1]=a*s*u+o*l*c,e[2]=a*l*c-o*s*u,e[3]=a*l*u+o*s*c,e},Z.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},Z.setAxes=Z.sqlerp=Z.rotationTo=Z.equals=Z.exactEquals=Z.normalize=Z.sqrLen=Z.squaredLength=Z.len=Z.length=Z.lerp=Z.dot=Z.scale=Z.mul=Z.add=Z.set=Z.copy=Z.fromValues=Z.clone=void 0;var Se=Ce(f),Me=Ce(I),Ae=Ce(Y),Ee=Ce(ce);function Te(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(Te=function(e){return e?n:t})(e)}function Ce(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==we(e)&&"function"!=typeof e)return{default:e};var n=Te(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}function ke(){var e=new Se.ARRAY_TYPE(4);return Se.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Ie(e,t,n){n*=.5;var r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e}function Pe(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],c=n[2],u=n[3];return e[0]=r*u+a*s+i*c-o*l,e[1]=i*u+a*l+o*s-r*c,e[2]=o*u+a*c+r*l-i*s,e[3]=a*u-r*s-i*l-o*c,e}function Re(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=Math.sqrt(n*n+r*r+i*i),s=Math.exp(o),l=a>0?s*Math.sin(a)/a:0;return e[0]=n*l,e[1]=r*l,e[2]=i*l,e[3]=s*Math.cos(a),e}function Le(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=Math.sqrt(n*n+r*r+i*i),s=a>0?Math.atan2(a,o)/a:0;return e[0]=n*s,e[1]=r*s,e[2]=i*s,e[3]=.5*Math.log(n*n+r*r+i*i+o*o),e}function ze(e,t,n,r){var i,o,a,s,l,c=t[0],u=t[1],h=t[2],d=t[3],f=n[0],p=n[1],m=n[2],g=n[3];return(o=c*f+u*p+h*m+d*g)<0&&(o=-o,f=-f,p=-p,m=-m,g=-g),1-o>Se.EPSILON?(i=Math.acos(o),a=Math.sin(i),s=Math.sin((1-r)*i)/a,l=Math.sin(r*i)/a):(s=1-r,l=r),e[0]=s*c+l*f,e[1]=s*u+l*p,e[2]=s*h+l*m,e[3]=s*d+l*g,e}function Oe(e,t){var n,r=t[0]+t[4]+t[8];if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,e[0]=(t[5]-t[7])*(n=.5/n),e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var o=(i+1)%3,a=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*o+o]-t[3*a+a]+1),e[i]=.5*n,e[3]=(t[3*o+a]-t[3*a+o])*(n=.5/n),e[o]=(t[3*o+i]+t[3*i+o])*n,e[a]=(t[3*a+i]+t[3*i+a])*n}return e}Z.clone=Ee.clone,Z.fromValues=Ee.fromValues,Z.copy=Ee.copy,Z.set=Ee.set,Z.add=Ee.add,Z.mul=Pe;var De=Ee.scale;Z.scale=De;var Be=Ee.dot;Z.dot=Be,Z.lerp=Ee.lerp;var Fe=Ee.length;Z.length=Fe,Z.len=Fe;var Ne=Ee.squaredLength;Z.squaredLength=Ne,Z.sqrLen=Ne;var je=Ee.normalize;Z.normalize=je,Z.exactEquals=Ee.exactEquals,Z.equals=Ee.equals;var Ve,Ue,Ge,qe=(Ve=Ae.create(),Ue=Ae.fromValues(1,0,0),Ge=Ae.fromValues(0,1,0),function(e,t,n){var r=Ae.dot(t,n);return r<-.999999?(Ae.cross(Ve,Ue,t),Ae.len(Ve)<1e-6&&Ae.cross(Ve,Ge,t),Ae.normalize(Ve,Ve),Ie(e,Ve,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Ae.cross(Ve,t,n),e[0]=Ve[0],e[1]=Ve[1],e[2]=Ve[2],e[3]=1+r,je(e,e))});Z.rotationTo=qe;var We,He,Ze=(We=ke(),He=ke(),function(e,t,n,r,i,o){return ze(We,t,i,o),ze(He,n,r,o),ze(e,We,He,2*o*(1-o)),e});Z.sqlerp=Ze;var Ye,Qe=(Ye=Me.create(),function(e,t,n,r){return Ye[0]=n[0],Ye[3]=n[1],Ye[6]=n[2],Ye[1]=r[0],Ye[4]=r[1],Ye[7]=r[2],Ye[2]=-t[0],Ye[5]=-t[1],Ye[8]=-t[2],je(e,Oe(e,Ye))});Z.setAxes=Qe;var Xe={};function Ke(e){return Ke="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},Ke(e)}Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.create=function(){var e=new Je.ARRAY_TYPE(8);return Je.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e},Xe.clone=function(e){var t=new Je.ARRAY_TYPE(8);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},Xe.fromValues=function(e,t,n,r,i,o,a,s){var l=new Je.ARRAY_TYPE(8);return l[0]=e,l[1]=t,l[2]=n,l[3]=r,l[4]=i,l[5]=o,l[6]=a,l[7]=s,l},Xe.fromRotationTranslationValues=function(e,t,n,r,i,o,a){var s=new Je.ARRAY_TYPE(8);s[0]=e,s[1]=t,s[2]=n,s[3]=r;var l=.5*i,c=.5*o,u=.5*a;return s[4]=l*r+c*n-u*t,s[5]=c*r+u*e-l*n,s[6]=u*r+l*t-c*e,s[7]=-l*e-c*t-u*n,s},Xe.fromRotationTranslation=rt,Xe.fromTranslation=function(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e},Xe.fromRotation=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},Xe.fromMat4=function(e,t){var n=$e.create();et.getRotation(n,t);var r=new Je.ARRAY_TYPE(3);return et.getTranslation(r,t),rt(e,n,r),e},Xe.copy=it,Xe.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},Xe.set=function(e,t,n,r,i,o,a,s,l){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o,e[5]=a,e[6]=s,e[7]=l,e},Xe.getDual=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},Xe.setDual=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},Xe.getTranslation=function(e,t){var n=t[4],r=t[5],i=t[6],o=t[7],a=-t[0],s=-t[1],l=-t[2],c=t[3];return e[0]=2*(n*c+o*a+r*l-i*s),e[1]=2*(r*c+o*s+i*a-n*l),e[2]=2*(i*c+o*l+n*s-r*a),e},Xe.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=.5*n[0],l=.5*n[1],c=.5*n[2],u=t[4],h=t[5],d=t[6],f=t[7];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=a*s+i*c-o*l+u,e[5]=a*l+o*s-r*c+h,e[6]=a*c+r*l-i*s+d,e[7]=-r*s-i*l-o*c+f,e},Xe.rotateX=function(e,t,n){var r=-t[0],i=-t[1],o=-t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=s*a+u*r+l*o-c*i,d=l*a+u*i+c*r-s*o,f=c*a+u*o+s*i-l*r,p=u*a-s*r-l*i-c*o;return $e.rotateX(e,t,n),e[4]=h*(a=e[3])+p*(r=e[0])+d*(o=e[2])-f*(i=e[1]),e[5]=d*a+p*i+f*r-h*o,e[6]=f*a+p*o+h*i-d*r,e[7]=p*a-h*r-d*i-f*o,e},Xe.rotateY=function(e,t,n){var r=-t[0],i=-t[1],o=-t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=s*a+u*r+l*o-c*i,d=l*a+u*i+c*r-s*o,f=c*a+u*o+s*i-l*r,p=u*a-s*r-l*i-c*o;return $e.rotateY(e,t,n),e[4]=h*(a=e[3])+p*(r=e[0])+d*(o=e[2])-f*(i=e[1]),e[5]=d*a+p*i+f*r-h*o,e[6]=f*a+p*o+h*i-d*r,e[7]=p*a-h*r-d*i-f*o,e},Xe.rotateZ=function(e,t,n){var r=-t[0],i=-t[1],o=-t[2],a=t[3],s=t[4],l=t[5],c=t[6],u=t[7],h=s*a+u*r+l*o-c*i,d=l*a+u*i+c*r-s*o,f=c*a+u*o+s*i-l*r,p=u*a-s*r-l*i-c*o;return $e.rotateZ(e,t,n),e[4]=h*(a=e[3])+p*(r=e[0])+d*(o=e[2])-f*(i=e[1]),e[5]=d*a+p*i+f*r-h*o,e[6]=f*a+p*o+h*i-d*r,e[7]=p*a-h*r-d*i-f*o,e},Xe.rotateByQuatAppend=function(e,t,n){var r=n[0],i=n[1],o=n[2],a=n[3],s=t[0],l=t[1],c=t[2],u=t[3];return e[0]=s*a+u*r+l*o-c*i,e[1]=l*a+u*i+c*r-s*o,e[2]=c*a+u*o+s*i-l*r,e[3]=u*a-s*r-l*i-c*o,e[4]=(s=t[4])*a+(u=t[7])*r+(l=t[5])*o-(c=t[6])*i,e[5]=l*a+u*i+c*r-s*o,e[6]=c*a+u*o+s*i-l*r,e[7]=u*a-s*r-l*i-c*o,e},Xe.rotateByQuatPrepend=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],c=n[2],u=n[3];return e[0]=r*u+a*s+i*c-o*l,e[1]=i*u+a*l+o*s-r*c,e[2]=o*u+a*c+r*l-i*s,e[3]=a*u-r*s-i*l-o*c,e[4]=r*(u=n[7])+a*(s=n[4])+i*(c=n[6])-o*(l=n[5]),e[5]=i*u+a*l+o*s-r*c,e[6]=o*u+a*c+r*l-i*s,e[7]=a*u-r*s-i*l-o*c,e},Xe.rotateAroundAxis=function(e,t,n,r){if(Math.abs(r)0){n=Math.sqrt(n);var r=t[0]/n,i=t[1]/n,o=t[2]/n,a=t[3]/n,s=t[4],l=t[5],c=t[6],u=t[7],h=r*s+i*l+o*c+a*u;e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=(s-r*h)/n,e[5]=(l-i*h)/n,e[6]=(c-o*h)/n,e[7]=(u-a*h)/n}return e},Xe.str=function(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},Xe.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]},Xe.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],c=e[7],u=t[0],h=t[1],d=t[2],f=t[3],p=t[4],m=t[5],g=t[6],_=t[7];return Math.abs(n-u)<=Je.EPSILON*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(r-h)<=Je.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(i-d)<=Je.EPSILON*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(o-f)<=Je.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(a-p)<=Je.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(s-m)<=Je.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(l-g)<=Je.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(c-_)<=Je.EPSILON*Math.max(1,Math.abs(c),Math.abs(_))},Xe.sqrLen=Xe.squaredLength=Xe.len=Xe.length=Xe.dot=Xe.mul=Xe.setReal=Xe.getReal=void 0;var Je=nt(f),$e=nt(Z),et=nt(D);function tt(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(tt=function(e){return e?n:t})(e)}function nt(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Ke(e)&&"function"!=typeof e)return{default:e};var n=tt(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}function rt(e,t,n){var r=.5*n[0],i=.5*n[1],o=.5*n[2],a=t[0],s=t[1],l=t[2],c=t[3];return e[0]=a,e[1]=s,e[2]=l,e[3]=c,e[4]=r*c+i*l-o*s,e[5]=i*c+o*a-r*l,e[6]=o*c+r*s-i*a,e[7]=-r*a-i*s-o*l,e}function it(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function ot(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[4],l=n[5],c=n[6],u=n[7],h=t[4],d=t[5],f=t[6],p=t[7],m=n[0],g=n[1],_=n[2],y=n[3];return e[0]=r*y+a*m+i*_-o*g,e[1]=i*y+a*g+o*m-r*_,e[2]=o*y+a*_+r*g-i*m,e[3]=a*y-r*m-i*g-o*_,e[4]=r*u+a*s+i*c-o*l+h*y+p*m+d*_-f*g,e[5]=i*u+a*l+o*s-r*c+d*y+p*g+f*m-h*_,e[6]=o*u+a*c+r*l-i*s+f*y+p*_+h*g-d*m,e[7]=a*u-r*s-i*l-o*c+p*y-h*m-d*g-f*_,e}Xe.getReal=$e.copy,Xe.setReal=$e.copy,Xe.mul=ot;var at=$e.dot;Xe.dot=at;var st=$e.length;Xe.length=st,Xe.len=st;var lt=$e.squaredLength;Xe.squaredLength=lt,Xe.sqrLen=lt;var ct={};function ut(e){return ut="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},ut(e)}Object.defineProperty(ct,"__esModule",{value:!0}),ct.create=ft,ct.clone=function(e){var t=new ht.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},ct.fromValues=function(e,t){var n=new ht.ARRAY_TYPE(2);return n[0]=e,n[1]=t,n},ct.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},ct.set=function(e,t,n){return e[0]=t,e[1]=n,e},ct.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},ct.subtract=pt,ct.multiply=mt,ct.divide=gt,ct.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},ct.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},ct.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e},ct.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e},ct.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},ct.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},ct.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},ct.distance=_t,ct.squaredDistance=yt,ct.length=vt,ct.squaredLength=xt,ct.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},ct.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},ct.normalize=function(e,t){var n=t[0],r=t[1],i=n*n+r*r;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e},ct.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},ct.cross=function(e,t,n){var r=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=r,e},ct.lerp=function(e,t,n,r){var i=t[0],o=t[1];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e},ct.random=function(e,t){t=t||1;var n=2*ht.RANDOM()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},ct.transformMat2=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e},ct.transformMat2d=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e},ct.transformMat3=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[3]*i+n[6],e[1]=n[1]*r+n[4]*i+n[7],e},ct.transformMat4=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e},ct.rotate=function(e,t,n,r){var i=t[0]-n[0],o=t[1]-n[1],a=Math.sin(r),s=Math.cos(r);return e[0]=i*s-o*a+n[0],e[1]=i*a+o*s+n[1],e},ct.angle=function(e,t){var n=e[0],r=e[1],i=t[0],o=t[1],a=Math.sqrt(n*n+r*r)*Math.sqrt(i*i+o*o);return Math.acos(Math.min(Math.max(a&&(n*i+r*o)/a,-1),1))},ct.zero=function(e){return e[0]=0,e[1]=0,e},ct.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},ct.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ct.equals=function(e,t){var n=e[0],r=e[1],i=t[0],o=t[1];return Math.abs(n-i)<=ht.EPSILON*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-o)<=ht.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))},ct.forEach=ct.sqrLen=ct.sqrDist=ct.dist=ct.div=ct.mul=ct.sub=ct.len=void 0;var ht=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==ut(e)&&"function"!=typeof e)return{default:e};var n=dt(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(f);function dt(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(dt=function(e){return e?n:t})(e)}function ft(){var e=new ht.ARRAY_TYPE(2);return ht.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function pt(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function mt(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e}function gt(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e}function _t(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function yt(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function vt(e){return Math.hypot(e[0],e[1])}function xt(e){var t=e[0],n=e[1];return t*t+n*n}ct.len=vt,ct.sub=pt,ct.mul=mt,ct.div=gt,ct.dist=_t,ct.sqrDist=yt,ct.sqrLen=xt;var bt=function(){var e=ft();return function(t,n,r,i,o,a){var s,l;for(n||(n=2),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;s1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)i?a=n:s=n,n=.5*(s-a)+a;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}};var Bt=h(Ot),Ft=Nt;function Nt(e,t){this.x=e,this.y=t}Nt.prototype={clone:function(){return new Nt(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,n=e.y-this.y;return t*t+n*n},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),n=Math.sin(e),r=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround:function(e,t){var n=Math.cos(e),r=Math.sin(e),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-r*(this.y-t.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Nt.convert=function(e){return e instanceof Nt?e:Array.isArray(e)?new Nt(e[0],e[1]):e};var jt=h(Ft);const Vt=Math.PI/180,Ut=180/Math.PI;function Gt(e){return e*Vt}function qt(e){return e*Ut}const Wt=[[0,0],[1,0],[1,1],[0,1]];function Ht(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function Zt(e,t,n,r){const i=new Bt(e,t,n,r);return function(e){return i.solve(e)}}const Yt=Zt(.25,.1,.25,1);function Qt(e,t,n){return Math.min(n,Math.max(t,e))}function Xt(e,t,n){return(n=Qt((n-e)/(t-e),0,1))*n*(3-2*n)}function Kt(e,t,n){const r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function Jt(e,t,n){if(!e.length)return n(null,[]);let r=e.length;const i=new Array(e.length);let o=null;e.forEach(((e,a)=>{t(e,((e,t)=>{e&&(o=e),i[a]=t,0==--r&&n(o,i)}))}))}function $t(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function rn(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function on(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 an(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t))}))}function sn(e,t){return-1!==e.indexOf(t,e.length-t.length)}function ln(e,t,n){const r={};for(const i in e)r[i]=t.call(this,e[i],i,e);return r}function cn(e,t,n){const r={};for(const i in e)t.call(this,e[i],i,e)&&(r[i]=e[i]);return r}function un(e){return Array.isArray(e)?e.map(un):"object"==typeof e&&e?ln(e,un):e}const hn={};function dn(e){hn[e]||("undefined"!=typeof console&&console.warn(e),hn[e]=!0)}function fn(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function pn(e){let t=0;for(let n,r,i=0,o=e.length,a=o-1;i@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,n,r,i)=>{const o=r||i;return t[n]=!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 yn,vn,xn,bn,wn,Sn,Mn=null;function An(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function En(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function Tn(e,t,n,r){for(;t>1;e[i]>1;e[i]<=r?t=i+1:n=i}return t}function kn(e){return e>0?1/(1.001-e):1+e}function In(e){return e>0?1-1/(1.001-e):-e}function Pn(){return null==yn&&(yn=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),yn}const Rn={now:()=>void 0!==bn?bn:performance.now(),setNow(e){bn=e},restoreNow(){bn=void 0},frame(e){const t=requestAnimationFrame(e);return{cancel:()=>cancelAnimationFrame(t)}},getImageData(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const{width:n,height:r}=e;wn||(wn=document.createElement("canvas"));const i=wn.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return(n>wn.width||r>wn.height)&&(wn.width=n,wn.height=r),i.clearRect(-t,-t,n+2*t,r+2*t),i.drawImage(e,0,0,n,r),i.getImageData(-t,-t,n+2*t,r+2*t)},resolveURL:e=>(vn||(vn=document.createElement("a")),vn.href=e,vn.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==xn&&(xn=window.matchMedia("(prefers-reduced-motion: reduce)")),xn.matches)},hasCanvasFingerprintNoise(){if(void 0!==Sn)return Sn;if(!Pn())return Sn=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let n=0;for(let i=0;i1&&void 0!==arguments[1]?arguments[1]:{persistentParams:[]};const n=e.indexOf("?");if(n<0)return e;const r=new URLSearchParams,i=new URLSearchParams(e.slice(n));for(const a of t.persistentParams){const e=i.get(a);e&&r.set(a,e)}const o=r.toString();return"".concat(e.slice(0,n)).concat(o.length>0?"?".concat(o):"")}const On="mapbox-tiles";let Dn,Bn,Fn=500,Nn=50;function jn(){try{return caches}catch(e){}}function Vn(){const e=jn();e&&!Dn&&(Dn=e.open(On))}let Un=1/0;const Gn={supported:!1,testSupport:function(e){!Hn&&Wn&&(Zn?Qn(e):qn=e)}};let qn,Wn,Hn=!1,Zn=!1;const Yn="undefined"!=typeof self?self:{};function Qn(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,Wn),e.isContextLost())return;Gn.supported=!0}catch(e){}e.deleteTexture(t),Hn=!0}Yn.document&&(Wn=Yn.document.createElement("img"),Wn.onload=function(){qn&&Qn(qn),qn=null,Zn=!0},Wn.onerror=function(){Hn=!0,qn=null},Wn.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Xn={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(Xn);class Kn extends Error{constructor(e,t,n){401===t&&i(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=n}toString(){return"".concat(this.name,": ").concat(this.message," (").concat(this.status,"): ").concat(this.url)}}const Jn=gn()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,$n=function(e,t){if(!(/^file:/.test(n=e.url)||/^file:/.test(Jn())&&!/^\w+:/.test(n))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(e,t){const n=new AbortController,r=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Jn(),referrerPolicy:e.referrerPolicy,signal:n.signal});let o=!1,a=!1;const s=(l=r.url).indexOf("sku=")>0&&i(l);var l;"json"===e.type&&r.headers.set("Accept","application/json");const c=(n,i,o)=>{if(a)return;if(n&&"SecurityError"!==n.message&&dn(n.toString()),i&&o)return u(i);const l=Date.now();fetch(r).then((n=>{if(n.ok){const e=s?n.clone():null;return u(n,e,l)}return t(new Kn(n.statusText,n.status,e.url))})).catch((n=>{"AbortError"!==n.name&&t(new Error("".concat(n.message," ").concat(e.url)))}))},u=(n,i,s)=>{("arrayBuffer"===e.type?n.arrayBuffer():"json"===e.type?n.json():n.text()).then((e=>{a||(i&&s&&function(e,t,n){if(Vn(),!Dn)return;const r=_n(t.headers.get("Cache-Control")||"");if(r["no-store"])return;const i={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach(((e,t)=>i.headers.set(t,e))),r["max-age"]&&i.headers.set("Expires",new Date(n+1e3*r["max-age"]).toUTCString());const o=i.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-n<42e4)return;let a=zn(e.url,{persistentParams:["language","worldview"]});if(206===t.status){const t=e.headers.get("Range");if(!t)return;i.status=200,a=Ln(a,{range:t})}!function(e,t){if(void 0===Bn)try{new Response(new ReadableStream),Bn=!0}catch(e){Bn=!1}Bn?t(e.body):e.blob().then(t)}(t,(e=>{const t=new Response(e,i);Vn(),Dn&&Dn.then((e=>e.put(a,t))).catch((e=>dn(e.message)))}))}(r,i,s),o=!0,t(null,e,n.headers.get("Cache-Control"),n.headers.get("Expires")))})).catch((e=>{a||t(new Error(e.message))}))};return s?function(e,t){if(Vn(),!Dn)return t(null);Dn.then((n=>{let r=zn(e.url,{persistentParams:["language","worldview"]});const i=e.headers.get("Range");i&&(r=Ln(r,{range:i})),n.match(r).then((e=>{const i=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),n=_n(e.headers.get("Cache-Control")||"");return t>Date.now()&&!n["no-cache"]}(e);n.delete(r),i&&n.put(r,e.clone()),t(null,e,i)})).catch(t)})).catch(t)}(r,c):c(null,null),{cancel:()=>{a=!0,o||n.abort()}}}(e,t);if(gn()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var n;return function(e,t){const n=new XMLHttpRequest;n.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(n.responseType="arraybuffer");for(const r in e.headers)n.setRequestHeader(r,e.headers[r]);return"json"===e.type&&(n.responseType="text",n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===e.credentials,n.onerror=()=>{t(new Error(n.statusText))},n.onload=()=>{if((n.status>=200&&n.status<300||0===n.status)&&null!==n.response){let r=n.response;if("json"===e.type)try{r=JSON.parse(n.response)}catch(e){return t(e)}t(null,r,n.getResponseHeader("Cache-Control"),n.getResponseHeader("Expires"))}else t(new Kn(n.statusText,n.status,e.url))},n.send(e.body),{cancel:()=>n.abort()}}(e,t)},er=function(e,t){return $n($t(e,{type:"arrayBuffer"}),t)};function tr(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}const nr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let rr,ir;rr=[],ir=0;const or=function(e,t){if(Gn.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),ir>=r.MAX_PARALLEL_IMAGE_REQUESTS){const n={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return rr.push(n),n}ir++;let n=!1;const i=()=>{if(!n)for(n=!0,ir--;rr.length&&ir{i(),e?t(e):n&&(self.createImageBitmap?function(e,t){const n=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(n).then((e=>{t(null,e)})).catch((e=>{t(new Error("Could not load image because of ".concat(e.message,". Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.")))}))}(n,((e,n)=>t(e,n,r,o))):function(e,t){const n=new Image;n.onload=()=>{t(null,n),URL.revokeObjectURL(n.src),n.onload=null,requestAnimationFrame((()=>{n.src=nr}))},n.onerror=()=>t(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 r=new Blob([new Uint8Array(e)],{type:"image/png"});n.src=e.byteLength?URL.createObjectURL(r):nr}(n,((e,n)=>t(e,n,r,o))))}));return{cancel:()=>{o.cancel(),i()}}},ar="01",sr="NO_ACCESS_TOKEN",lr=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function cr(e){const t=e.match(lr);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 ur(e){const t=e.params.length?"?".concat(e.params.join("&")):"";return"".concat(e.protocol,"://").concat(e.authority).concat(e.path).concat(t)}const hr="mapbox.eventData";function dr(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(decodeURIComponent(atob(t[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class fr{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=dr(r.ACCESS_TOKEN);let n="";return n=t&&t.u?btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):r.ACCESS_TOKEN||"",e?"".concat(hr,".").concat(e,":").concat(n):"".concat(hr,":").concat(n)}fetchEventData(){const e=An("localStorage"),t=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{const e=localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const r=localStorage.getItem(n);r&&(this.anonId=r)}catch(e){dn("Unable to read from LocalStorage")}}saveEventData(){const e=An("localStorage"),t=this.getStorageKey(),n=this.getStorageKey("uuid"),r=this.anonId;if(e&&r)try{localStorage.setItem(n,r),Object.keys(this.eventData).length>=1&&localStorage.setItem(t,JSON.stringify(this.eventData))}catch(e){dn("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,n,i){if(!r.EVENTS_URL)return;const o=cr(r.EVENTS_URL);o.params.push("access_token=".concat(i||r.ACCESS_TOKEN||""));const a={event:this.type,created:new Date(e).toISOString()},s=t?$t(a,t):a,l={url:ur(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=function(e,t){return $n($t(e,{method:"POST"}),t)}(l,(e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(i)}))}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const pr=new class extends fr{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){r.EVENTS_URL&&r.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>o(e)||i(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 n=dr(r.ACCESS_TOKEN),i=n?n.u:r.ACCESS_TOKEN;let o=i!==this.eventData.tokenU;on(this.anonId)||(this.anonId=nn(),o=!0);const a=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(a),n=(a-this.eventData.lastSuccess)/864e5;o=o||n>=1||n<-1||e.getDate()!==t.getDate()}else o=!0;o?this.postEvent(a,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:ar,"enabled.telemetry":!1,userId:this.anonId},(e=>{e||(this.eventData.lastSuccess=a,this.eventData.tokenU=i)}),e):this.processRequests()}},mr=pr.postTurnstileEvent.bind(pr),gr=new class extends fr{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,n,i){this.skuToken=t,this.errorCb=i,r.EVENTS_URL&&(n||r.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(sr)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:n,timestamp:r}=this.queue.shift();n&&this.success[n]||(this.anonId||this.fetchEventData(),on(this.anonId)||(this.anonId=nn()),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:ar,skuToken:this.skuToken,userId:this.anonId},(e=>{e?this.errorCb(e):n&&(this.success[n]=!0)}),e))}remove(){this.errorCb=null}},_r=gr.postMapLoadEvent.bind(gr),yr=new class extends fr{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(e){let t=this.mapInstanceIdMap.get(e);return t||(t=nn(),this.mapInstanceIdMap.set(e,t)),t}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(e,t){const{map:n,style:i,importedStyles:o}=t;if(!r.EVENTS_URL||!e&&!r.ACCESS_TOKEN)return;const a=this.getMapInstanceId(n),s={mapInstanceId:a,eventId:this.getEventId(a),style:i};o.length&&(s.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:s},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:n}=this.queue.shift();this.postEvent(t,n,(()=>{}),e)}},vr=yr.postStyleLoadEvent.bind(yr),xr=new class extends fr{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){r.EVENTS_URL&&(e||r.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:n,performanceData:r}=this.queue.shift(),i=function(e){const n=performance.getEntriesByType("resource"),r=performance.getEntriesByType("mark"),i=function(e){const t={};if(e)for(const n in e)if("other"!==n)for(const r of e[n]){const e="".concat(n,"ResolveRangeMin"),i="".concat(n,"ResolveRangeMax"),o="".concat(n,"RequestCount"),a="".concat(n,"RequestCachedCount");t[e]=Math.min(t[e]||1/0,r.startTime),t[i]=Math.max(t[i]||-1/0,r.responseEnd);const s=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==r.transferSize&&0===r.transferSize&&s(a),s(o)}return t}(function(e,t){const n={};if(e)for(const r of e){const e=t(r);void 0===n[e]&&(n[e]=[]),n[e].push(r)}return n}(n,u)),o=window.devicePixelRatio,a=navigator.connection||navigator.mozConnection||navigator.webkitConnection,s=a?a.effectiveType:void 0,h={counters:[],metadata:[],attributes:[]},d=(e,t,n)=>{null!=n&&e.push({name:t,value:n.toString()})};for(const t in i)d(h.counters,t,i[t]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(d(h.counters,"interactionRangeMin",e.interactionRange[0]),d(h.counters,"interactionRangeMax",e.interactionRange[1])),r)for(const t of Object.keys(c)){const e=c[t],n=r.find((t=>t.name===e));n&&d(h.counters,e,n.startTime)}return d(h.counters,"visibilityHidden",e.visibilityHidden),d(h.attributes,"style",function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(l(e)){const t=e.split("/").slice(-2);if(2===t.length)return"mapbox://styles/".concat(t[0],"/").concat(t[1])}}}(n)),d(h.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),d(h.attributes,"fogEnabled",e.fogEnabled?"true":"false"),d(h.attributes,"projection",e.projection),d(h.attributes,"zoom",e.zoom),d(h.metadata,"devicePixelRatio",o),d(h.metadata,"connectionEffectiveType",s),d(h.metadata,"navigatorUserAgent",navigator.userAgent),d(h.metadata,"screenWidth",window.screen.width),d(h.metadata,"screenHeight",window.screen.height),d(h.metadata,"windowWidth",window.innerWidth),d(h.metadata,"windowHeight",window.innerHeight),d(h.metadata,"mapWidth",e.width/o),d(h.metadata,"mapHeight",e.height/o),d(h.metadata,"webglRenderer",e.renderer),d(h.metadata,"webglVendor",e.vendor),d(h.metadata,"sdkVersion",t),d(h.metadata,"sdkIdentifier","mapbox-gl-js"),h}(r);for(const t of i.metadata);for(const t of i.counters);for(const t of i.attributes);this.postEvent(n,i,(()=>{}),e)}},br=xr.postPerformanceEvent.bind(xr),wr=new class extends fr{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,n,i){if(!r.API_URL||!r.SESSION_PATH)return;const o=cr(r.API_URL+r.SESSION_PATH);o.params.push("sku=".concat(t||"")),o.params.push("access_token=".concat(i||r.ACCESS_TOKEN||""));const a={url:ur(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(e,t){return $n($t(e,{method:"GET"}),t)}(a,(e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(i)}))}getSessionAPI(e,t,n,i){this.skuToken=t,this.errorCb=i,r.SESSION_PATH&&r.API_URL&&(n||r.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(sr)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:n}=this.queue.shift();t&&this.success[t]||this.getSession(n,this.skuToken,(e=>{e?this.errorCb(e):t&&(this.success[t]=!0)}),e)}remove(){this.errorCb=null}},Sr=wr.getSessionAPI.bind(wr),Mr=new Set;var Ar={exports:{}},Er={exports:{}};Er.exports=function(e,t){var n,r,i,o,a,s,l,c;for(r=e.length-(n=3&e.length),i=t,a=3432918353,s=461845907,c=0;c>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0};var Tr=Er.exports,Cr={exports:{}};Cr.exports=function(e,t){for(var n,r=e.length,i=t^r,o=0;r>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:i^=(255&e.charCodeAt(o+2))<<16;case 2:i^=(255&e.charCodeAt(o+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};var kr=Tr,Ir=Cr.exports;Ar.exports=kr,Ar.exports.murmur3=kr,Ar.exports.murmur2=Ir;var Pr=h(Ar.exports);function Rr(e,t,n){n[e]&&-1!==n[e].indexOf(t)||(n[e]=n[e]||[],n[e].push(t))}function Lr(e,t,n){if(n&&n[e]){const r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}class zr{constructor(e){$t(this,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),this.type=e}}class Or extends zr{constructor(e){super("error",$t({error:e},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}))}}class Dr{on(e,t){return this._listeners=this._listeners||{},Rr(e,t,this._listeners),this}off(e,t){return Lr(e,t,this._listeners),Lr(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Rr(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new zr(e,t||{}));const n=e.type;if(this.listens(n)){e.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const n of t)n.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const o of r)Lr(n,o,this._oneTimeListeners),o.call(this,e);const i=this._eventedParent;i&&($t(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof Or&&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}}e.z=void 0;var Br={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 Fr(e){return(e=Math.round(e))<0?0:e>255?255:e}function Nr(e){return Fr("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function jr(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function Vr(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}try{e.z={}.parseCSSColor=function(e){var t,n=e.replace(/ /g,"").toLowerCase();if(n in Br)return Br[n].slice();if("#"===n[0])return 4===n.length?(t=parseInt(n.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===n.length&&(t=parseInt(n.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var r=n.indexOf("("),i=n.indexOf(")");if(-1!==r&&i+1===n.length){var o=n.substr(0,r),a=n.substr(r+1,i-(r+1)).split(","),s=1;switch(o){case"rgba":if(4!==a.length)return null;s=jr(a.pop());case"rgb":return 3!==a.length?null:[Nr(a[0]),Nr(a[1]),Nr(a[2]),s];case"hsla":if(4!==a.length)return null;s=jr(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,c=jr(a[1]),u=jr(a[2]),h=u<=.5?u*(c+1):u+c-u*c,d=2*u-h;return[Fr(255*Vr(d,h,l+1/3)),Fr(255*Vr(d,h,l)),Fr(255*Vr(d,h,l-1/3)),s];default:return null}}return null}}catch(e){}class Ur{constructor(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;this.r=e,this.g=t,this.b=n,this.a=r}static parse(t){if(!t)return;if(t instanceof Ur)return t;if("string"!=typeof t)return;const n=e.z(t);return n?new Ur(n[0]/255*n[3],n[1]/255*n[3],n[2]/255*n[3],n[3]):void 0}toString(){const[e,t,n,r]=this.toArray();return"rgba(".concat(Math.round(e),",").concat(Math.round(t),",").concat(Math.round(n),",").concat(r,")")}toArray(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*n/r,r]}toArray01(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,n/r,r]}toArray01Scaled(e){const{r:t,g:n,b:r,a:i}=this;return 0===i?[0,0,0]:[t/i*e,n/i*e,r/i*e]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:n,a:r}=this;return[e,t,n,r]}toArray01Linear(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[Math.pow(e/r,2.2),Math.pow(t/r,2.2),Math.pow(n/r,2.2),r]}}function Gr(e,t,n){return e*(1-n)+t*n}function qr(e,t,n){return e.map(((e,r)=>Gr(e,t[r],n)))}Ur.black=new Ur(0,0,0,1),Ur.white=new Ur(1,1,1,1),Ur.transparent=new Ur(0,0,0,0),Ur.red=new Ur(1,0,0,1),Ur.blue=new Ur(0,0,1,1);var Wr=Object.freeze({__proto__:null,array:qr,color:function(e,t,n){return new Ur(Gr(e.r,t.r,n),Gr(e.g,t.g,n),Gr(e.b,t.b,n),Gr(e.a,t.a,n))},number:Gr});function Hr(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:[];this.parent=e,this.bindings={};for(const[n,r]of t)this.bindings[n]=r}concat(e){return new Yr(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error("".concat(e," not found in scope."))}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Qr={kind:"null"},Xr={kind:"number"},Kr={kind:"string"},Jr={kind:"boolean"},$r={kind:"color"},ei={kind:"object"},ti={kind:"value"},ni={kind:"collator"},ri={kind:"formatted"},ii={kind:"resolvedImage"};function oi(e,t){return{kind:"array",itemType:e,N:t}}function ai(e){if("array"===e.kind){const t=ai(e.itemType);return"number"==typeof e.N?"array<".concat(t,", ").concat(e.N,">"):"value"===e.itemType.kind?"array":"array<".concat(t,">")}return e.kind}const si=[Qr,Xr,Kr,Jr,$r,ri,ei,oi(ti),ii];function li(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!li(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 si)if(!li(e,t))return null}return"Expected ".concat(ai(e)," but found ").concat(ai(t)," instead.")}function ci(e,t){return t.some((t=>t.kind===e.kind))}function ui(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))}class hi{constructor(e,t,n){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=n,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 di{constructor(e,t,n,r,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=n,this.fontStack=r,this.textColor=i}}class fi{constructor(e){this.sections=e}static fromString(e){return new fi([new di(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.namePrimary.length))}static factory(e){return e instanceof fi?e:fi.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.namePrimary]);continue}e.push(t.text);const n={};t.fontStack&&(n["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(n["font-scale"]=t.scale),t.textColor&&(n["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(n)}return e}}class pi{constructor(e){this.namePrimary=e.namePrimary,e.nameSecondary&&(this.nameSecondary=e.nameSecondary),this.available=e.available}toString(){return this.nameSecondary?"[".concat(this.namePrimary,",").concat(this.nameSecondary,"]"):this.namePrimary}static fromString(e,t){return e?new pi({namePrimary:e,nameSecondary:t,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function mi(e,t,n,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:"Invalid rgba value [".concat([e,t,n,r].join(", "),"]: 'a' must be between 0 and 1."):"Invalid rgba value [".concat(("number"==typeof r?[e,t,n,r]:[e,t,n]).join(", "),"]: 'r', 'g', and 'b' must be between 0 and 255.")}function gi(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 Ur)return!0;if(e instanceof hi)return!0;if(e instanceof fi)return!0;if(e instanceof pi)return!0;if(Array.isArray(e)){for(const t of e)if(!gi(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!gi(e[t]))return!1;return!0}return!1}function _i(e){if(null===e)return Qr;if("string"==typeof e)return Kr;if("boolean"==typeof e)return Jr;if("number"==typeof e)return Xr;if(e instanceof Ur)return $r;if(e instanceof hi)return ni;if(e instanceof fi)return ri;if(e instanceof pi)return ii;if(Array.isArray(e)){const t=e.length;let n;for(const r of e){const e=_i(r);if(n){if(n===e)continue;n=ti;break}n=e}return oi(n||ti,t)}return ei}function yi(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ur||e instanceof fi||e instanceof pi?e.toString():JSON.stringify(e)}class vi{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 ".concat(e.length-1," instead."));if(!gi(e[1]))return t.error("invalid value");const n=e[1];let r=_i(n);const i=t.expectedType;return"array"!==r.kind||0!==r.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(r=i),new vi(r,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Ur?["rgba"].concat(this.value.toArray()):this.value instanceof fi?this.value.serialize():this.value}}class xi{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const bi={string:Kr,number:Xr,boolean:Jr,object:ei};class wi{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 n,r=1;const i=e[0];if("array"===i){let i,o;if(e.length>2){const n=e[1];if("string"!=typeof n||!(n in bi)||"object"===n)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=bi[n],r++}else i=ti;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],r++}n=oi(i,o)}else n=bi[i];const o=[];for(;re.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const n=e.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){t.push(n.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map((e=>e.serialize())))}}class Si{constructor(e){this.type=ri,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[1];if(!Array.isArray(n)&&"object"==typeof n)return t.error("First argument must be an image or text section.");const r=[];let i=!1;for(let o=1;o<=e.length-1;++o){const n=e[o];if(i&&"object"==typeof n&&!Array.isArray(n)){i=!1;let e=null;if(n["font-scale"]&&(e=t.parse(n["font-scale"],1,Xr),!e))return null;let o=null;if(n["text-font"]&&(o=t.parse(n["text-font"],1,oi(Kr)),!o))return null;let a=null;if(n["text-color"]&&(a=t.parse(n["text-color"],1,$r),!a))return null;const s=r[r.length-1];s.scale=e,s.font=o,s.textColor=a}else{const n=t.parse(e[o],1,ti);if(!n)return null;const a=n.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,r.push({content:n,scale:null,font:null,textColor:null})}}return new Si(r)}evaluate(e){return new fi(this.sections.map((t=>{const n=t.content.evaluate(e);return _i(n)===ii?new di("",n,null,null,null):new di(yi(n),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 n={};t.scale&&(n["font-scale"]=t.scale.serialize()),t.font&&(n["text-font"]=t.font.serialize()),t.textColor&&(n["text-color"]=t.textColor.serialize()),e.push(n)}return e}}class Mi{constructor(e,t){this.type=ii,this.inputPrimary=e,this.inputSecondary=t}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");const n=t.parse(e[1],1,Kr);if(!n)return t.error("No image name provided.");if(2===e.length)return new Mi(n);const r=t.parse(e[2],1,Kr);return r?new Mi(n,r):t.error("Secondary image variant is not a string.")}evaluate(e){const t=pi.fromString(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0);return t&&e.availableImages&&(t.available=e.availableImages.indexOf(t.namePrimary)>-1,t.nameSecondary&&t.available&&e.availableImages&&(t.available=e.availableImages.indexOf(t.nameSecondary)>-1)),t}eachChild(e){e(this.inputPrimary),this.inputSecondary&&e(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function Ai(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}const Ei={"to-boolean":Jr,"to-color":$r,"to-number":Xr,"to-string":Kr};class Ti{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 n=e[0],r=[];let i=Qr;if("to-array"===n){if(!Array.isArray(e[1]))return null;const n=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error("Expected ".concat(t.expectedType.kind," but found array."));i=oi(t.expectedType.itemType,n)}else{if(!(n>0&&gi(e[1][0])))return null;i=oi(_i(e[1][0]),n)}for(let o=0;o4?"Invalid rbga value ".concat(JSON.stringify(t),": expected an array containing either three or four numeric values."):mi(t[0],t[1],t[2],t[3]),!n))return new Ur(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new xi(n||"Could not parse color from value '".concat("string"==typeof t?t:String(JSON.stringify(t)),"'"))}if("number"===this.type.kind){let t=null;for(const n of this.args){if(t=n.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new xi("Could not convert ".concat(JSON.stringify(t)," to number."))}return"formatted"===this.type.kind?fi.fromString(yi(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?pi.fromString(yi(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map((t=>t.evaluate(e))):yi(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 Si([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Mi(this.args[0]).serialize();const e="array"===this.type.kind?[]:["to-".concat(this.type.kind)];return this.eachChild((t=>{e.push(t.serialize())})),e}}const Ci=["Unknown","Point","LineString","Polygon"];class ki{constructor(e,t){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,this.scope=e,this.options=t}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Ci[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||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:n,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Ur.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class Ii{constructor(e,t,n,r,i){this.name=e,this.type=t,this._evaluate=n,this.args=r,this._overloadIndex=i}evaluate(e){if(!this._evaluate){const e=Ii.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1]}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 n=e[0],r=Ii.definitions[n];if(!r)return t.error('Unknown expression "'.concat(n,'". If you wanted a literal array, use ["literal", [...]].'),0);const i=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=[];let s=null,l=-1;for(const[c,u]of o){if(Array.isArray(c)&&c.length!==e.length-1)continue;a.push(c),l++,s=new qo(t.registry,t.path,null,t.scope,void 0,t._scope,t.options);const r=[];let o=!1;for(let t=1;t{let[t]=e;return t}))).map(Pi).join(" | "),r=[];for(let i=1;ii;){if(o-i>600){var s=o-i+1,l=r-i+1,c=Math.log(s),u=.5*Math.exp(2*c/3),h=.5*Math.sqrt(c*u*(s-u)/s)*(l-s/2<0?-1:1);e(n,r,Math.max(i,Math.floor(r-l*u/s+h)),Math.min(o,Math.floor(r+(s-l)*u/s+h)),a)}var d=n[r],f=i,p=o;for(t(n,i,r),a(n[o],d)>0&&t(n,i,o);f0;)p--}0===a(n[i],d)?t(n,i,p):t(n,++p,o),p<=r&&(i=p+1),r<=p&&(o=p-1)}}function t(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function n(e,t){return et?1:0}return function(t,r,i,o,a){e(t,r,i||0,o||t.length-1,a||n)}}();var zi=h(Li.exports);function Oi(e){let t=0;for(let n,r,i=0,o=e.length,a=o-1;i=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Fi(e,t,n){const r=e[0]-t[0],i=e[1]-t[1],o=e[0]-n[0],a=e[1]-n[1];return r*a-o*i==0&&r*o<=0&&i*a<=0}function Ni(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=!1;for(let s=0,l=t.length;s(i=e)[1]!=(a=u)[1]>i[1]&&i[0]<(a[0]-o[0])*(i[1]-o[1])/(a[1]-o[1])+o[0]&&(r=!r)}}var i,o,a;return r}function ji(e,t,n,r){const i=r[0]-n[0],o=r[1]-n[1],a=(e[0]-n[0])*o-i*(e[1]-n[1]),s=(t[0]-n[0])*o-i*(t[1]-n[1]);return a>0&&s<0||a<0&&s>0}function Vi(e,t,n,r){return 0!=(i=[r[0]-n[0],r[1]-n[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*o[0]&&!(!ji(e,t,n,r)||!ji(n,r,e,t));var i,o}const Ui=8192;function Gi(e,t){const n=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=Math.pow(2,t.z);return[Math.round(n*i*Ui),Math.round(r*i*Ui)]}function qi(e,t){for(let n=0;nn[2]){const t=.5*r;let i=e[0]-n[0]>t?-r:n[0]-e[0]>t?r:0;0===i&&(i=e[0]-n[2]>t?-r:n[2]-e[0]>t?r:0),e[0]+=i}Di(t,e)}function Ki(e,t,n,r){const i=Math.pow(2,r.z)*Ui,o=[r.x*Ui,r.y*Ui],a=[];if(!e)return a;for(const s of e)for(const e of s){const r=[e.x+o[0],e.y+o[1]];Xi(r,t,n,i),a.push(r)}return a}function Ji(e,t,n,r){const i=Math.pow(2,r.z)*Ui,o=[r.x*Ui,r.y*Ui],a=[];if(!e)return a;for(const l of e){const e=[];for(const n of l){const r=[n.x+o[0],n.y+o[1]];Di(t,r),e.push(r)}a.push(e)}if(t[2]-t[0]<=i/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(const e of a)for(const r of e)Xi(r,t,n,i)}var s;return a}class $i{constructor(e,t){this.type=Jr,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 ".concat(e.length-1," instead."));if(gi(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e180;)e-=360;return e}return i.fromTile=function(e,t,n){var o=Math.PI*(1-2*(e+.5)/Math.pow(2,t)),a=Math.atan(.5*(Math.exp(o)-Math.exp(-o)))/r;return new i(a,n)},o.units.get=function(){return e},i.prototype.distance=function(e,t){var n=l(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(n*n+r*r)},i.prototype.bearing=function(e,t){var n=l(t[0]-e[0])*this.kx;return Math.atan2(n,(t[1]-e[1])*this.ky)/r},i.prototype.destination=function(e,t,n){var i=n*r;return this.offset(e,Math.sin(i)*t,Math.cos(i)*t)},i.prototype.offset=function(e,t,n){return[e[0]+t/this.kx,e[1]+n/this.ky]},i.prototype.lineDistance=function(e){for(var t=0,n=0;nt)return s(i,o,(t-(n-a))/a)}return e[e.length-1]},i.prototype.pointToSegmentDistance=function(e,t,n){var r=t[0],i=t[1],o=l(n[0]-r)*this.kx,a=(n[1]-i)*this.ky,s=0;return 0===o&&0===a||((s=(l(e[0]-r)*this.kx*o+(e[1]-i)*this.ky*a)/(o*o+a*a))>1?(r=n[0],i=n[1]):s>0&&(r+=o/this.kx*s,i+=a/this.ky*s)),o=l(e[0]-r)*this.kx,a=(e[1]-i)*this.ky,Math.sqrt(o*o+a*a)},i.prototype.pointOnLine=function(e,t){for(var n,r,i,o,a=1/0,s=0;s1?(c=e[s+1][0],u=e[s+1][1]):f>0&&(c+=h/this.kx*f,u+=d/this.ky*f));var p=(h=l(t[0]-c)*this.kx)*h+(d=(t[1]-u)*this.ky)*d;pi.index||r.index===i.index&&r.t>i.t){var o=r;r=i,i=o}var s=[r.point],l=r.index+1,c=i.index;!a(n[l],s[0])&&l<=c&&s.push(n[l]);for(var u=l+1;u<=c;u++)s.push(n[u]);return a(n[c],i.point)||s.push(i.point),s},i.prototype.lineSliceAlong=function(e,t,n){for(var r=0,i=[],o=0;oe&&0===i.length&&i.push(s(a,l,(e-(r-c))/c)),r>=t)return i.push(s(a,l,(t-(r-c))/c)),i;r>e&&i.push(l)}return i},i.prototype.bufferPoint=function(e,t){var n=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-n,e[0]+r,e[1]+n]},i.prototype.bufferBBox=function(e,t){var n=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-n,e[2]+r,e[3]+n]},i.prototype.insideBBox=function(e,t){return l(e[0]-t[0])>=0&&l(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]},Object.defineProperties(i,o),i}()}(eo);var to=h(eo.exports),no={exports:{}};!function(e,t){e.exports=function(){var e=function(e,n){if(void 0===e&&(e=[]),void 0===n&&(n=t),this.data=e,this.length=this.data.length,this.compare=n,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)};function t(e,t){return et?1:0}return e.prototype.push=function(e){this.data.push(e),this.length++,this._up(this.length-1)},e.prototype.pop=function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}},e.prototype.peek=function(){return this.data[0]},e.prototype._up=function(e){for(var t=this.data,n=this.compare,r=t[e];e>0;){var i=e-1>>1,o=t[i];if(n(r,o)>=0)break;t[e]=o,e=i}t[e]=r},e.prototype._down=function(e){for(var t=this.data,n=this.compare,r=this.length>>1,i=t[e];e=0)break;t[e]=a,e=o}t[e]=i},e}()}(no);var ro=h(no.exports),io=8192;function oo(e,t){return t.dist-e.dist}const ao=100,so=50;function lo(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(let n=0;n=e[0]&&e[1]e[1])return[null,null];const n=co(e);if(t){if(2===n)return[e,null];const t=Math.floor(n/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===n)return[e,null];const t=Math.floor(n/2)-1;return[[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function fo(e,t){const n=[1/0,1/0,-1/0,-1/0];if(!uo(t,e.length))return n;for(let r=t[0];r<=t[1];++r)Di(n,e[r]);return n}function po(e){const t=[1/0,1/0,-1/0,-1/0];for(let n=0;nt[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]3&&void 0!==arguments[3]?arguments[3]:1/0;const i=po(e),o=po(t);if(r!==1/0&&mo(i,o,n)>=r)return r;if(Bi(i,o)){if(To(e,t))return 0}else if(To(t,e))return 0;let a=r;for(const s of e)for(let e=0,r=s.length,i=r-1;e4&&void 0!==arguments[4]?arguments[4]:1/0,o=Math.min(r.distance(e[0],n[0][0]),i);if(0===o)return o;const a=new ro([{dist:0,range1:[0,e.length-1],range2:[0,0]}],oo),s=t?so:ao,l=po(n);for(;a.length;){const i=a.pop();if(i.dist>=o)continue;const c=i.range1;if(co(c)<=s){if(!uo(c,e.length))return NaN;if(t){const t=Eo(e,c,n,r);if(0===(o=Math.min(o,t)))return o}else for(let t=c[0];t<=c[1];++t){const i=Ao(e[t],n,r);if(0===(o=Math.min(o,i)))return o}}else{const n=ho(c,t);if(null!==n[0]){const t=mo(fo(e,n[0]),l,r);t5&&void 0!==arguments[5]?arguments[5]:1/0,a=Math.min(o,i.distance(e[0],n[0]));if(0===a)return a;const s=new ro([{dist:0,range1:[0,e.length-1],range2:[0,n.length-1]}],oo),l=t?so:ao,c=r?so:ao;for(;s.length;){const o=s.pop();if(o.dist>=a)continue;const u=o.range1,h=o.range2;if(co(u)<=l&&co(h)<=c){if(!uo(u,e.length)||!uo(h,n.length))return NaN;if(t&&r?a=Math.min(a,So(e,u,n,h,i)):t||r?t&&!r?a=Math.min(a,bo(n,h,e,u,i)):!t&&r&&(a=Math.min(a,bo(e,u,n,h,i))):a=Math.min(a,Mo(e,u,n,h,i)),0===a)return a}else{const o=ho(u,t),l=ho(h,r);ko(s,a,i,e,n,o[0],l[0]),ko(s,a,i,e,n,o[0],l[1]),ko(s,a,i,e,n,o[1],l[0]),ko(s,a,i,e,n,o[1],l[1])}}return a}function Ro(e,t,n,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1/0;const o=fo(e,[0,e.length-1]);for(const a of n)if(!(i!==1/0&&mo(o,fo(a,[0,a.length-1]),r)>=i)&&(i=Math.min(i,Po(e,t,a,!0,r,i)),0===i))return i;return i}function Lo(e,t,n,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1/0;const o=fo(e,[0,e.length-1]);for(const a of n){if(i!==1/0&&mo(o,po(a),r)>=i)continue;const n=Io(e,t,a,r,i);if(isNaN(n))return n;if(0===(i=Math.min(i,n)))return i}return i}function zo(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class Oo{constructor(e,t){this.type=Xr,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error("'distance' expression requires either one argument, but found ' ".concat(e.length-1," instead."));if(gi(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;en&&(e=n),e}class Fo{constructor(e,t,n){this.type=e,this.key=t,this.scope=n}static parse(e,t){let n=t.expectedType;if(null==n&&(n=ti),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const r=t.parse(e[1],1);if(!(r instanceof vi))return t.error("Key name of 'config' expression must be a string literal.");if(e.length>=3){const i=t.parse(e[2],2);return i instanceof vi?new Fo(n,yi(r.value),yi(i.value)):t.error("Scope of 'config' expression must be a string literal.")}return new Fo(n,yi(r.value))}evaluate(e){const t=[this.key,this.scope,e.scope].filter(Boolean).join("\x1f"),n=e.getConfig(t);if(!n)return null;const{type:r,value:i,values:o,minValue:a,maxValue:s,stepValue:l}=n,c=n.default.evaluate(e);let u=c;if(i){const t=e.scope;e.scope=(t||"").split("\x1f").slice(1).join("\x1f"),u=i.evaluate(e),e.scope=t}return r&&(u=Do(r,u)),void 0===u||void 0===a&&void 0===s&&void 0===l||("number"==typeof u?u=Bo(u,a,s,l):Array.isArray(u)&&(u=u.map((e=>"number"==typeof e?Bo(e,a,s,l):e)))),void 0!==i&&void 0!==u&&o&&!o.includes(u)&&(u=c,r&&(u=Do(r,u))),(r&&r!==this.type||void 0!==u&&_i(u)!==this.type)&&(u=Do(this.type.kind,u)),u}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.key),e}}function No(e){if(e instanceof Ii){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 $i)return!1;if(e instanceof Oo)return!1;let t=!0;return e.eachChild((e=>{t&&!No(e)&&(t=!1)})),t}function jo(e){if(e instanceof Ii&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild((e=>{t&&!jo(e)&&(t=!1)})),t}function Vo(e){if(e instanceof Fo)return!1;let t=!0;return e.eachChild((e=>{t&&!Vo(e)&&(t=!1)})),t}function Uo(e,t){if(e instanceof Ii&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild((e=>{n&&!Uo(e,t)&&(n=!1)})),n}class Go{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 n=e[1];return t.scope.has(n)?new Go(n,t.scope.get(n)):t.error('Unknown variable "'.concat(n,'". Make sure "').concat(n,'" 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]}}class qo{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Yr,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],o=arguments.length>5?arguments[5]:void 0,a=arguments.length>6?arguments[6]:void 0;this.registry=e,this.path=t,this.key=t.map((e=>"[".concat(e,"]"))).join(""),this.scope=r,this.errors=i,this.expectedType=n,this._scope=o,this.options=a}parse(e,t,n,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return t||n?this.concat(t,n,r)._parse(e,i):this._parse(e,i)}_parse(e,t){function n(e,t,n){return"assert"===n?new wi(t,[e]):"coerce"===n?new Ti(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r="string"==typeof e[0]?this.registry[e[0]]:void 0;if(r){let i=r.parse(e,this);if(!i)return null;if(this.expectedType){const e=this.expectedType,r=i.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else i=n(i,e,t.typeAnnotation||"coerce");else i=n(i,e,t.typeAnnotation||"assert")}if(!(i instanceof vi)&&"resolvedImage"!==i.type.kind&&Wo(i)){const t=new ki(this._scope,this.options);try{i=new vi(i.type,i.evaluate(t))}catch(e){return this.error(e.message),null}}return i}return Ti.parse(["to-array",e],this)}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 ".concat(typeof e," instead."))}concat(e,t,n){const r="number"==typeof e?this.path.concat(e):this.path,i=n?this.scope.concat(n):this.scope;return new qo(this.registry,r,t||null,i,this.errors,this._scope,this.options)}error(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r"[".concat(e,"]"))).join(""));this.errors.push(new Zr(i,e))}checkSubtype(e,t){const n=li(e,t);return n&&this.error(n),n}}function Wo(e){if(e instanceof Go)return Wo(e.boundExpression);if(e instanceof Ii&&"error"===e.name)return!1;if(e instanceof Ri)return!1;if(e instanceof $i)return!1;if(e instanceof Oo)return!1;if(e instanceof Fo)return!1;const t=e instanceof Ti||e instanceof wi;let n=!0;return e.eachChild((e=>{n=t?n&&Wo(e):n&&e instanceof vi})),!!n&&No(e)&&Uo(e,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Ho(e,t){const n=e.length-1;let r,i,o=0,a=n,s=0;for(;o<=a;)if(s=Math.floor((o+a)/2),r=e[s],i=e[s+1],r<=t){if(s===n||tt))throw new xi("Input is not a number.");a=s-1}return 0}class Zo{constructor(e,t,n){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[r,i]of n)this.labels.push(r),this.outputs.push(i)}static parse(e,t){if(e.length-1<4)return t.error("Expected at least 4 arguments, but found only ".concat(e.length-1,"."));if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const n=t.parse(e[1],1,Xr);if(!n)return null;const r=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let o=1;o=n)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const c=t.parse(a,l,i);if(!c)return null;i=i||c.type,r.push([n,c])}return new Zo(i,n,r)}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);const i=t.length;return r>=t[i-1]?n[i-1].evaluate(e):n[Ho(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const Yo=.95047,Qo=1.08883,Xo=4/29,Ko=6/29,Jo=3*Ko*Ko,$o=Ko*Ko*Ko,ea=Math.PI/180,ta=180/Math.PI;function na(e){return e>$o?Math.pow(e,1/3):e/Jo+Xo}function ra(e){return e>Ko?e*e*e:Jo*(e-Xo)}function ia(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function oa(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function aa(e){const t=oa(e.r),n=oa(e.g),r=oa(e.b),i=na((.4124564*t+.3575761*n+.1804375*r)/Yo),o=na((.2126729*t+.7151522*n+.072175*r)/1);return{l:116*o-16,a:500*(i-o),b:200*(o-na((.0193339*t+.119192*n+.9503041*r)/Qo)),alpha:e.a}}function sa(e){let t=(e.l+16)/116,n=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*ra(t),n=Yo*ra(n),r=Qo*ra(r),new Ur(ia(3.2404542*n-1.5371385*t-.4985314*r),ia(-.969266*n+1.8760108*t+.041556*r),ia(.0556434*n-.2040259*t+1.0572252*r),e.alpha)}function la(e,t,n){const r=t-e;return e+n*(r>180||r<-180?r-360*Math.round(r/360):r)}const ca={forward:aa,reverse:sa,interpolate:function(e,t,n){return{l:Gr(e.l,t.l,n),a:Gr(e.a,t.a,n),b:Gr(e.b,t.b,n),alpha:Gr(e.alpha,t.alpha,n)}}},ua={forward:function(e){const{l:t,a:n,b:r}=aa(e),i=Math.atan2(r,n)*ta;return{h:i<0?i+360:i,c:Math.sqrt(n*n+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*ea,n=e.c;return sa({l:e.l,a:Math.cos(t)*n,b:Math.sin(t)*n,alpha:e.alpha})},interpolate:function(e,t,n){return{h:la(e.h,t.h,n),c:Gr(e.c,t.c,n),l:Gr(e.l,t.l,n),alpha:Gr(e.alpha,t.alpha,n)}}};var ha=Object.freeze({__proto__:null,hcl:ua,lab:ca});class da{constructor(e,t,n,r,i){this.type=e,this.operator=t,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(const[o,a]of i)this.labels.push(o),this.outputs.push(a)}static interpolationFactor(e,t,n,r){let i=0;if("exponential"===e.name)i=fa(t,e.base,n,r);else if("linear"===e.name)i=fa(t,1,n,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;i=new Bt(o[0],o[1],o[2],o[3]).solve(fa(t,1,n,r))}return i}static parse(e,t){let[n,r,i,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error("Unknown interpolation type ".concat(String(r[0])),1,0);{const e=r.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error("Expected at least 4 arguments, but found only ".concat(e.length-1,"."));if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,Xr),!i)return null;const a=[];let s=null;"interpolate-hcl"===n||"interpolate-lab"===n?s=$r:t.expectedType&&"value"!==t.expectedType.kind&&(s=t.expectedType);for(let l=0;l=e)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,i,s);if(!c)return null;s=s||c.type,a.push([e,c])}return"number"===s.kind||"color"===s.kind||"array"===s.kind&&"number"===s.itemType.kind&&"number"==typeof s.N?new da(s,n,r,i,a):t.error("Type ".concat(ai(s)," is not interpolatable."))}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);const i=t.length;if(r>=t[i-1])return n[i-1].evaluate(e);const o=Ho(t,r),a=da.interpolationFactor(this.interpolation,r,t[o],t[o+1]),s=n[o].evaluate(e),l=n[o+1].evaluate(e);return"interpolate"===this.operator?Wr[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?ua.reverse(ua.interpolate(ua.forward(s),ua.forward(l),a)):ca.reverse(ca.interpolate(ca.forward(s),ca.forward(l),a))}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 n=0;nli(r,e.type)));return new pa(o?ti:n,i)}evaluate(e){let t,n=null,r=0;for(const i of this.args){if(r++,n=i.evaluate(e),n&&n instanceof pi&&!n.available&&(t||(t=n),n=null,r===this.args.length))return t;if(null!==n)break}return n}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}}class ma{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 ".concat(e.length-1," instead."));const n=[];for(let i=1;i=n.length)throw new xi("Array index out of bounds: ".concat(t," > ").concat(n.length-1,"."));if(t!==Math.floor(t))throw new xi("Array index must be an integer, but found ".concat(t," instead."));return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class _a{constructor(e,t){this.type=Jr,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error("Expected 2 arguments, but found ".concat(e.length-1," instead."));const n=t.parse(e[1],1,ti),r=t.parse(e[2],2,ti);return n&&r?ci(n.type,[Jr,Kr,Xr,Qr,ti])?new _a(n,r):t.error("Expected first argument to be of type boolean, string, number or null, but found ".concat(ai(n.type)," instead")):null}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(null==n)return!1;if(!ui(t,["boolean","string","number","null"]))throw new xi("Expected first argument to be of type boolean, string, number or null, but found ".concat(ai(_i(t))," instead."));if(!ui(n,["string","array"]))throw new xi("Expected second argument to be of type array or string, but found ".concat(ai(_i(n))," instead."));return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ya{constructor(e,t,n){this.type=Xr,this.needle=e,this.haystack=t,this.fromIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error("Expected 3 or 4 arguments, but found ".concat(e.length-1," instead."));const n=t.parse(e[1],1,ti),r=t.parse(e[2],2,ti);if(!n||!r)return null;if(!ci(n.type,[Jr,Kr,Xr,Qr,ti]))return t.error("Expected first argument to be of type boolean, string, number or null, but found ".concat(ai(n.type)," instead"));if(4===e.length){const i=t.parse(e[3],3,Xr);return i?new ya(n,r,i):null}return new ya(n,r)}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!ui(t,["boolean","string","number","null"]))throw new xi("Expected first argument to be of type boolean, string, number or null, but found ".concat(ai(_i(t))," instead."));if(!ui(n,["string","array"]))throw new xi("Expected second argument to be of type array or string, but found ".concat(ai(_i(n))," instead."));if(this.fromIndex){const r=this.fromIndex.evaluate(e);return n.indexOf(t,r)}return n.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()]}}class va{constructor(e,t,n,r,i,o){this.inputType=e,this.type=t,this.input=n,this.cases=r,this.outputs=i,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error("Expected at least 4 arguments, but found only ".concat(e.length-1,"."));if(e.length%2!=1)return t.error("Expected an even number of arguments.");let n,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const i={},o=[];for(let l=2;lNumber.MAX_SAFE_INTEGER)return c.error("Branch labels must be integers no larger than ".concat(Number.MAX_SAFE_INTEGER,"."));if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(n){if(c.checkSubtype(n,_i(e)))return null}else n=_i(e);if(void 0!==i[String(e)])return c.error("Branch labels must be unique.");i[String(e)]=o.length}const u=t.parse(s,l,r);if(!u)return null;r=r||u.type,o.push(u)}const a=t.parse(e[1],1,ti);if(!a)return null;const s=t.parse(e[e.length-1],e.length-1,r);return s?"value"!==a.type.kind&&t.concat(1).checkSubtype(n,a.type)?null:new va(n,r,a,i,o,s):null}evaluate(e){const t=this.input.evaluate(e);return(_i(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(),n=[],r={};for(const o of t){const e=r[this.cases[o]];void 0===e?(r[this.cases[o]]=n.length,n.push([this.cases[o],[o]])):n[e][1].push(o)}const i=e=>"number"===this.inputType.kind?Number(e):e;for(const[o,a]of n)e.push(1===a.length?i(a[0]):a.map(i)),e.push(this.outputs[o].serialize());return e.push(this.otherwise.serialize()),e}}class xa{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}static parse(e,t){if(e.length<4)return t.error("Expected at least 3 arguments, but found only ".concat(e.length-1,"."));if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r=[];for(let o=1;o{let[t,n]=e;return n.outputDefined()}))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize())})),e}}class ba{constructor(e,t,n,r){this.type=e,this.input=t,this.beginIndex=n,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error("Expected 3 or 4 arguments, but found ".concat(e.length-1," instead."));const n=t.parse(e[1],1,ti),r=t.parse(e[2],2,Xr);if(!n||!r)return null;if(!ci(n.type,[oi(ti),Kr,ti]))return t.error("Expected first argument to be of type array or string, but found ".concat(ai(n.type)," instead"));if(4===e.length){const i=t.parse(e[3],3,Xr);return i?new ba(n.type,n,r,i):null}return new ba(n.type,n,r)}evaluate(e){const t=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!ui(t,["string","array"]))throw new xi("Expected first argument to be of type array or string, but found ".concat(ai(_i(t))," instead."));if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(n,r)}return t.slice(n)}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()]}}function wa(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 Sa(e,t,n,r){return 0===r.compare(t,n)}function Ma(e,t,n){const r="=="!==e&&"!="!==e;return class i{constructor(e,t,n){this.type=Jr,this.lhs=e,this.rhs=t,this.collator=n,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 n=e[0];let o=t.parse(e[1],1,ti);if(!o)return null;if(!wa(n,o.type))return t.concat(1).error('"'.concat(n,"\" comparisons are not supported for type '").concat(ai(o.type),"'."));let a=t.parse(e[2],2,ti);if(!a)return null;if(!wa(n,a.type))return t.concat(2).error('"'.concat(n,"\" comparisons are not supported for type '").concat(ai(a.type),"'."));if(o.type.kind!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error("Cannot compare types '".concat(ai(o.type),"' and '").concat(ai(a.type),"'."));r&&("value"===o.type.kind&&"value"!==a.type.kind?o=new wi(a.type,[o]):"value"!==o.type.kind&&"value"===a.type.kind&&(a=new wi(o.type,[a])));let s=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(s=t.parse(e[3],3,ni),!s)return null}return new i(o,a,s)}evaluate(i){const o=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){const t=_i(o),n=_i(a);if(t.kind!==n.kind||"string"!==t.kind&&"number"!==t.kind)throw new xi('Expected arguments for "'.concat(e,'" to be (string, string) or (number, number), but found (').concat(t.kind,", ").concat(n.kind,") instead."))}if(this.collator&&!r&&this.hasUntypedArgument){const e=_i(o),n=_i(a);if("string"!==e.kind||"string"!==n.kind)return t(i,o,a)}return this.collator?n(i,o,a,this.collator.evaluate(i)):t(i,o,a)}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 Aa=Ma("==",(function(e,t,n){return t===n}),Sa),Ea=Ma("!=",(function(e,t,n){return t!==n}),(function(e,t,n,r){return!Sa(0,t,n,r)})),Ta=Ma("<",(function(e,t,n){return t",(function(e,t,n){return t>n}),(function(e,t,n,r){return r.compare(t,n)>0})),ka=Ma("<=",(function(e,t,n){return t<=n}),(function(e,t,n,r){return r.compare(t,n)<=0})),Ia=Ma(">=",(function(e,t,n){return t>=n}),(function(e,t,n,r){return r.compare(t,n)>=0}));class Pa{constructor(e,t,n,r,i,o){this.type=Kr,this.number=e,this.locale=t,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,Xr);if(!n)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let i=null;if(r.locale&&(i=t.parse(r.locale,1,Kr),!i))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,Kr),!o))return null;let a=null;if(r.unit&&(a=t.parse(r.unit,1,Kr),!a))return null;let s=null;if(r["min-fraction-digits"]&&(s=t.parse(r["min-fraction-digits"],1,Xr),!s))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,Xr),!l)?null:new Pa(n,i,o,a,s,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Ra{constructor(e){this.type=Xr,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected 1 argument, but found ".concat(e.length-1," instead."));const n=t.parse(e[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?t.error("Expected argument of type string or array, but found ".concat(ai(n.type)," instead.")):new Ra(n):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 xi("Expected value to be of type string or array, but found ".concat(ai(_i(t))," instead."))}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize())})),e}}function La(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const za={"==":Aa,"!=":Ea,">":Ca,"<":Ta,">=":Ia,"<=":ka,array:wi,at:ga,boolean:wi,case:xa,coalesce:pa,collator:Ri,format:Si,image:Mi,in:_a,"index-of":ya,interpolate:da,"interpolate-hcl":da,"interpolate-lab":da,length:Ra,let:ma,literal:vi,match:va,number:wi,"number-format":Pa,object:wi,slice:ba,step:Zo,string:wi,"to-boolean":Ti,"to-color":Ti,"to-number":Ti,"to-string":Ti,var:Go,within:$i,distance:Oo,config:Fo};function Oa(e,t){let[n,r,i,o]=t;n=n.evaluate(e),r=r.evaluate(e),i=i.evaluate(e);const a=o?o.evaluate(e):1,s=mi(n,r,i,a);if(s)throw new xi(s);return new Ur(n/255*a,r/255*a,i/255*a,a)}function Da(e,t){let[n,r,i,o]=t;n=n.evaluate(e),r=r.evaluate(e),i=i.evaluate(e);const a=o?o.evaluate(e):1,s=function(e,t,n,r){return"number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof n&&n>=0&&n<=100?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:"Invalid hsla value [".concat([e,t,n,r].join(", "),"]: 'a' must be between 0 and 1."):"Invalid hsla value [".concat(("number"==typeof r?[e,t,n,r]:[e,t,n]).join(", "),"]: 's', and 'l' must be between 0 and 100."):"Invalid hsla value [".concat(("number"==typeof r?[e,t,n,r]:[e,t,n]).join(", "),"]: 'h' must be between 0 and 360.")}(n,r,i,a);if(s)throw new xi(s);const l="hsla(".concat(n,", ").concat(r,"%, ").concat(i,"%, ").concat(a,")"),c=Ur.parse(l);if(!c)throw new xi("Failed to parse HSLA color: ".concat(l));return c}function Ba(e,t){return e in t}function Fa(e,t){const n=t[e];return void 0===n?null:n}function Na(e){return{type:e}}function ja(e){return{result:"success",value:e}}function Va(e){return{result:"error",value:e}}function Ua(e,t){return!!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function Ga(e){return"data-driven"===e["property-type"]}function qa(e){return Ua(e.expression,"measure-light")}function Wa(e){return Ua(e.expression,"zoom")}function Ha(e){return!!e.expression&&e.expression.interpolated}function Za(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ya(e){return e}function Qa(e,t){const n="color"===t.type,r=e.stops&&"object"==typeof e.stops[0][0],i=r||!(r||void 0!==e.property),o=e.type||(Ha(t)?"exponential":"interval");if(n&&((e=Hr({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],Ur.parse(e[1])]))),e.default=Ur.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!ha[e.colorSpace])throw new Error("Unknown color space: ".concat(e.colorSpace));let a,s,l;if("exponential"===o)a=$a;else if("interval"===o)a=Ja;else if("categorical"===o){a=Ka,s=Object.create(null);for(const t of e.stops)s[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error('Unknown function type "'.concat(o,'"'));a=es}if(r){const n={},r=[];for(let t=0;te[0])),evaluate:(n,r)=>{let{zoom:o}=n;return $a({stops:i,base:e.base},t,o).evaluate(o,r)}}}if(i){const n="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:n,interpolationFactor:da.interpolationFactor.bind(void 0,n),zoomStops:e.stops.map((e=>e[0])),evaluate:n=>{let{zoom:r}=n;return a(e,t,r,s,l)}}}return{kind:"source",evaluate(n,r){const i=r&&r.properties?r.properties[e.property]:void 0;return void 0===i?Xa(e.default,t.default):a(e,t,i,s,l)}}}function Xa(e,t,n){return void 0!==e?e:void 0!==t?t:void 0!==n?n:void 0}function Ka(e,t,n,r,i){return Xa(typeof n===i?r[n]:void 0,e.default,t.default)}function Ja(e,t,n){if("number"!==Ai(n))return Xa(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[r-1][0])return e.stops[r-1][1];const i=Ho(e.stops.map((e=>e[0])),n);return e.stops[i][1]}function $a(e,t,n){const r=void 0!==e.base?e.base:1;if("number"!==Ai(n))return Xa(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];const o=Ho(e.stops.map((e=>e[0])),n),a=function(e,t,n,r){const i=r-n,o=e-n;return 0===i?0:1===t?o/i:(Math.pow(t,o)-1)/(Math.pow(t,i)-1)}(n,r,e.stops[o][0],e.stops[o+1][0]),s=e.stops[o][1],l=e.stops[o+1][1];let c=Wr[t.type]||Ya;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=ha[e.colorSpace];c=(e,n)=>t.reverse(t.interpolate(t.forward(e),t.forward(n),a))}return"function"==typeof s.evaluate?{evaluate(){for(var e=arguments.length,t=new Array(e),n=0;n{let[n]=t;throw new xi(n.evaluate(e))}],typeof:[Kr,[ti],(e,t)=>{let[n]=t;return ai(_i(n.evaluate(e)))}],"to-rgba":[oi(Xr,4),[$r],(e,t)=>{let[n]=t;return n.evaluate(e).toArray()}],rgb:[$r,[Xr,Xr,Xr],Oa],rgba:[$r,[Xr,Xr,Xr,Xr],Oa],hsl:[$r,[Xr,Xr,Xr],Da],hsla:[$r,[Xr,Xr,Xr,Xr],Da],has:{type:Jr,overloads:[[[Kr],(e,t)=>{let[n]=t;return Ba(n.evaluate(e),e.properties())}],[[Kr,ei],(e,t)=>{let[n,r]=t;return Ba(n.evaluate(e),r.evaluate(e))}]]},get:{type:ti,overloads:[[[Kr],(e,t)=>{let[n]=t;return Fa(n.evaluate(e),e.properties())}],[[Kr,ei],(e,t)=>{let[n,r]=t;return Fa(n.evaluate(e),r.evaluate(e))}]]},"feature-state":[ti,[Kr],(e,t)=>{let[n]=t;return Fa(n.evaluate(e),e.featureState||{})}],properties:[ei,[],e=>e.properties()],"geometry-type":[Kr,[],e=>e.geometryType()],id:[ti,[],e=>e.id()],zoom:[Xr,[],e=>e.globals.zoom],pitch:[Xr,[],e=>e.globals.pitch||0],"distance-from-center":[Xr,[],e=>e.distanceFromCenter()],"measure-light":[Xr,[Kr],(e,t)=>{let[n]=t;return e.measureLight(n.evaluate(e))}],"heatmap-density":[Xr,[],e=>e.globals.heatmapDensity||0],"line-progress":[Xr,[],e=>e.globals.lineProgress||0],"raster-value":[Xr,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[Xr,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[Xr,[],e=>e.globals.skyRadialProgress||0],accumulated:[ti,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Xr,Na(Xr),(e,t)=>{let n=0;for(const r of t)n+=r.evaluate(e);return n}],"*":[Xr,Na(Xr),(e,t)=>{let n=1;for(const r of t)n*=r.evaluate(e);return n}],"-":{type:Xr,overloads:[[[Xr,Xr],(e,t)=>{let[n,r]=t;return n.evaluate(e)-r.evaluate(e)}],[[Xr],(e,t)=>{let[n]=t;return-n.evaluate(e)}]]},"/":[Xr,[Xr,Xr],(e,t)=>{let[n,r]=t;return n.evaluate(e)/r.evaluate(e)}],"%":[Xr,[Xr,Xr],(e,t)=>{let[n,r]=t;return n.evaluate(e)%r.evaluate(e)}],ln2:[Xr,[],()=>Math.LN2],pi:[Xr,[],()=>Math.PI],e:[Xr,[],()=>Math.E],"^":[Xr,[Xr,Xr],(e,t)=>{let[n,r]=t;return Math.pow(n.evaluate(e),r.evaluate(e))}],sqrt:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.sqrt(n.evaluate(e))}],log10:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.log(n.evaluate(e))/Math.LN10}],ln:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.log(n.evaluate(e))}],log2:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.log(n.evaluate(e))/Math.LN2}],sin:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.sin(n.evaluate(e))}],cos:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.cos(n.evaluate(e))}],tan:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.tan(n.evaluate(e))}],asin:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.asin(n.evaluate(e))}],acos:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.acos(n.evaluate(e))}],atan:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.atan(n.evaluate(e))}],min:[Xr,Na(Xr),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[Xr,Na(Xr),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.abs(n.evaluate(e))}],round:[Xr,[Xr],(e,t)=>{let[n]=t;const r=n.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.floor(n.evaluate(e))}],ceil:[Xr,[Xr],(e,t)=>{let[n]=t;return Math.ceil(n.evaluate(e))}],"filter-==":[Jr,[Kr,ti],(e,t)=>{let[n,r]=t;return e.properties()[n.value]===r.value}],"filter-id-==":[Jr,[ti],(e,t)=>{let[n]=t;return e.id()===n.value}],"filter-type-==":[Jr,[Kr],(e,t)=>{let[n]=t;return e.geometryType()===n.value}],"filter-<":[Jr,[Kr,ti],(e,t)=>{let[n,r]=t;const i=e.properties()[n.value],o=r.value;return typeof i==typeof o&&i{let[n]=t;const r=e.id(),i=n.value;return typeof r==typeof i&&r":[Jr,[Kr,ti],(e,t)=>{let[n,r]=t;const i=e.properties()[n.value],o=r.value;return typeof i==typeof o&&i>o}],"filter-id->":[Jr,[ti],(e,t)=>{let[n]=t;const r=e.id(),i=n.value;return typeof r==typeof i&&r>i}],"filter-<=":[Jr,[Kr,ti],(e,t)=>{let[n,r]=t;const i=e.properties()[n.value],o=r.value;return typeof i==typeof o&&i<=o}],"filter-id-<=":[Jr,[ti],(e,t)=>{let[n]=t;const r=e.id(),i=n.value;return typeof r==typeof i&&r<=i}],"filter->=":[Jr,[Kr,ti],(e,t)=>{let[n,r]=t;const i=e.properties()[n.value],o=r.value;return typeof i==typeof o&&i>=o}],"filter-id->=":[Jr,[ti],(e,t)=>{let[n]=t;const r=e.id(),i=n.value;return typeof r==typeof i&&r>=i}],"filter-has":[Jr,[ti],(e,t)=>{let[n]=t;return n.value in e.properties()}],"filter-has-id":[Jr,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Jr,[oi(Kr)],(e,t)=>{let[n]=t;return n.value.indexOf(e.geometryType())>=0}],"filter-id-in":[Jr,[oi(ti)],(e,t)=>{let[n]=t;return n.value.indexOf(e.id())>=0}],"filter-in-small":[Jr,[Kr,oi(ti)],(e,t)=>{let[n,r]=t;return r.value.indexOf(e.properties()[n.value])>=0}],"filter-in-large":[Jr,[Kr,oi(ti)],(e,t)=>{let[n,r]=t;return function(e,t,n,r){for(;n<=r;){const i=n+r>>1;if(t[i]===e)return!0;t[i]>e?r=i-1:n=i+1}return!1}(e.properties()[n.value],r.value,0,r.value.length-1)}],all:{type:Jr,overloads:[[[Jr,Jr],(e,t)=>{let[n,r]=t;return n.evaluate(e)&&r.evaluate(e)}],[Na(Jr),(e,t)=>{for(const n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:Jr,overloads:[[[Jr,Jr],(e,t)=>{let[n,r]=t;return n.evaluate(e)||r.evaluate(e)}],[Na(Jr),(e,t)=>{for(const n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[Jr,[Jr],(e,t)=>{let[n]=t;return!n.evaluate(e)}],"is-supported-script":[Jr,[Kr],(e,t)=>{let[n]=t;const r=e.globals&&e.globals.isSupportedScript;return!r||r(n.evaluate(e))}],upcase:[Kr,[Kr],(e,t)=>{let[n]=t;return n.evaluate(e).toUpperCase()}],downcase:[Kr,[Kr],(e,t)=>{let[n]=t;return n.evaluate(e).toLowerCase()}],concat:[Kr,Na(ti),(e,t)=>t.map((t=>yi(t.evaluate(e)))).join("")],"resolved-locale":[Kr,[ni],(e,t)=>{let[n]=t;return n.evaluate(e).resolvedLocale()}],random:[Xr,[Xr,Xr,ti],(e,t)=>{const[n,r,i]=t.map((t=>t.evaluate(e)));if(n>r)return n;if(n===r)return n;let o;if("string"==typeof i)o=function(e){let t=0;if(0===e.length)return t;for(let n=0;nJSON.stringify(e))).join(", "),", but found ").concat(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 ns(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in za}function rs(e,t,n,r){const i=new qo(za,[],t?function(e){const t={color:$r,string:Kr,number:Xr,enum:Kr,boolean:Jr,formatted:ri,resolvedImage:ii};return"array"===e.type?oi(t[e.value]||ti,e.length):t[e.type]}(t):void 0,void 0,void 0,n,r),o=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return o?ja(new ts(o,t,n,r)):Va(i.errors)}class is{constructor(e,t,n){this.kind=e,this._styleExpression=t,this.isLightConstant=n,this.isStateDependent="constant"!==e&&!jo(t.expression),this.isConfigDependent=!Vo(t.expression)}evaluateWithoutErrorHandling(e,t,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,o)}evaluate(e,t,n,r,i,o){return this._styleExpression.evaluate(e,t,n,r,i,o)}}class os{constructor(e,t,n,r,i){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent="camera"!==e&&!jo(t.expression),this.isLightConstant=i,this.isConfigDependent=!Vo(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,o)}evaluate(e,t,n,r,i,o){return this._styleExpression.evaluate(e,t,n,r,i,o)}interpolationFactor(e,t,n){return this.interpolationType?da.interpolationFactor(this.interpolationType,e,t,n):0}}function as(e,t,n,r){if("error"===(e=rs(e,t,n,r)).result)return e;const i=e.value.expression,o=No(i);if(!o&&!Ga(t))return Va([new Zr("","data expressions not supported")]);const a=Uo(i,["zoom","pitch","distance-from-center"]);if(!a&&!Wa(t))return Va([new Zr("","zoom expressions not supported")]);const s=Uo(i,["measure-light"]);if(!s&&!qa(t))return Va([new Zr("","measure-light expression not supported")]);const l=t.expression&&t.expression.relaxZoomRestriction,c=ls(i);return c||a||l?c instanceof Zr?Va([c]):c instanceof da&&!Ha(t)?Va([new Zr("",'"interpolate" expressions cannot be used with this property')]):ja(c?new os(o?"camera":"composite",e.value,c.labels,c instanceof da?c.interpolation:void 0,s):new is(o?"constant":"source",e.value,s)):Va([new Zr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class ss{constructor(e,t){this._parameters=e,this._specification=t,Hr(this,Qa(this._parameters,this._specification))}static deserialize(e){return new ss(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ls(e){let t=null;if(e instanceof ma)t=ls(e.result);else if(e instanceof pa){for(const n of e.args)if(t=ls(n),t)break}else(e instanceof Zo||e instanceof da)&&e.input instanceof Ii&&"zoom"===e.input.name&&(t=e);return t instanceof Zr||e.eachChild((e=>{const n=ls(e);n instanceof Zr?t=n:t&&n&&t!==n&&(t=new Zr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}var cs=hs,us=3;function hs(e,t,n){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var i=new Int32Array(this.arrayBuffer);e=i[0],this.d=(t=i[1])+2*(n=i[2]);for(var o=0;o=u[f+0]&&r>=u[f+1])?(a[d]=!0,o.push(c[d])):a[d]=!1}}},hs.prototype._forEachCell=function(e,t,n,r,i,o,a,s){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(n),h=this._convertToCellCoord(r),d=l;d<=u;d++)for(var f=c;f<=h;f++){var p=this.d*f+d;if((!s||s(this._convertFromCellCoord(d),this._convertFromCellCoord(f),this._convertFromCellCoord(d+1),this._convertFromCellCoord(f+1)))&&i.call(this,e,t,n,r,p,o,a,s))return}},hs.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},hs.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},hs.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=us+this.cells.length+1+1,n=0,r=0;r2&&void 0!==arguments[2]?arguments[2]:{};Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),fs[t]={klass:e,omit:n.omit||[]}}ps(Object,"Object"),ds.serialize=function(e,t){const n=e.toArrayBuffer();return t&&t.add(n),{buffer:n}},ds.deserialize=function(e){return new ds(e.buffer)},Object.defineProperty(ds,"name",{value:"Grid"}),ps(ds,"Grid"),ps(Ur,"Color"),ps(Error,"Error"),ps(fi,"Formatted"),ps(di,"FormattedSection"),ps(Kn,"AJAXError"),ps(pi,"ResolvedImage"),ps(ss,"StylePropertyFunction"),ps(ts,"StyleExpression",{omit:["_evaluator"]}),ps(os,"ZoomDependentExpression"),ps(is,"ZoomConstantExpression"),ps(Ii,"CompoundExpression",{omit:["_evaluate"]});for(const mx in za)fs[za[mx]._classRegistryKey]||ps(za[mx],"Expression".concat(mx));function ms(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function gs(e){return self.ImageBitmap&&e instanceof ImageBitmap}function _s(e,t){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(ms(e)||gs(e))return t&&t.add(e),e;if(ArrayBuffer.isView(e)){const n=e;return t&&t.add(n.buffer),n}if(e instanceof ImageData)return t&&t.add(e.data.buffer),e;if(Array.isArray(e)){const n=[];for(const r of e)n.push(_s(r,t));return n}if(e instanceof Map){const t={$name:"Map"};for(const[n,r]of e.entries())t[n]=_s(r);return t}if("object"==typeof e){const n=e.constructor,r=n._classRegistryKey;if(!r)throw new Error("can't serialize object of unregistered class ".concat(r));const i=n.serialize?n.serialize(e,t):{};if(!n.serialize){for(const n in e)e.hasOwnProperty(n)&&(fs[r].omit.indexOf(n)>=0||(i[n]=_s(e[n],t)));e instanceof Error&&(i.message=e.message)}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(i.$name=r),i}throw new Error("can't serialize object of type "+typeof e)}function ys(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||ms(e)||gs(e)||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(ys);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=new Map;for(const n of Object.keys(e))"$name"!==n&&t.set(n,ys(e[n]));return t}const{klass:n}=fs[t];if(!n)throw new Error("can't deserialize unregistered class ".concat(t));if(n.deserialize)return n.deserialize(e);const r=Object.create(n.prototype);for(const i of Object.keys(e))"$name"!==i&&(r[i]=ys(e[i]));return r}throw new Error("can't deserialize object of type "+typeof e)}const vs={"Latin-1 Supplement":e=>e>=128&&e<=255,Arabic:e=>e>=1536&&e<=1791,"Arabic Supplement":e=>e>=1872&&e<=1919,"Arabic Extended-A":e=>e>=2208&&e<=2303,"Hangul Jamo":e=>e>=4352&&e<=4607,"Unified Canadian Aboriginal Syllabics":e=>e>=5120&&e<=5759,Khmer:e=>e>=6016&&e<=6143,"Unified Canadian Aboriginal Syllabics Extended":e=>e>=6320&&e<=6399,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"CJK Radicals Supplement":e=>e>=11904&&e<=12031,"Kangxi Radicals":e=>e>=12032&&e<=12255,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Bopomofo:e=>e>=12544&&e<=12591,"Hangul Compatibility Jamo":e=>e>=12592&&e<=12687,Kanbun:e=>e>=12688&&e<=12703,"Bopomofo Extended":e=>e>=12704&&e<=12735,"CJK Strokes":e=>e>=12736&&e<=12783,"Katakana Phonetic Extensions":e=>e>=12784&&e<=12799,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"CJK Unified Ideographs Extension A":e=>e>=13312&&e<=19903,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Yi Syllables":e=>e>=40960&&e<=42127,"Yi Radicals":e=>e>=42128&&e<=42191,"Hangul Jamo Extended-A":e=>e>=43360&&e<=43391,"Hangul Syllables":e=>e>=44032&&e<=55215,"Hangul Jamo Extended-B":e=>e>=55216&&e<=55295,"Private Use Area":e=>e>=57344&&e<=63743,"CJK Compatibility Ideographs":e=>e>=63744&&e<=64255,"Arabic Presentation Forms-A":e=>e>=64336&&e<=65023,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Arabic Presentation Forms-B":e=>e>=65136&&e<=65279,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519,"CJK Unified Ideographs Extension B":e=>e>=131072&&e<=173791};function xs(e){for(const t of e)if(Ss(t.charCodeAt(0)))return!0;return!1}function bs(e){for(const t of e)if(!ws(t.charCodeAt(0)))return!1;return!0}function ws(e){return!(vs.Arabic(e)||vs["Arabic Supplement"](e)||vs["Arabic Extended-A"](e)||vs["Arabic Presentation Forms-A"](e)||vs["Arabic Presentation Forms-B"](e))}function Ss(e){return!(746!==e&&747!==e&&(e<4352||!(vs["Bopomofo Extended"](e)||vs.Bopomofo(e)||vs["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||vs["CJK Compatibility Ideographs"](e)||vs["CJK Compatibility"](e)||vs["CJK Radicals Supplement"](e)||vs["CJK Strokes"](e)||!(!vs["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||vs["CJK Unified Ideographs Extension A"](e)||vs["CJK Unified Ideographs"](e)||vs["Enclosed CJK Letters and Months"](e)||vs["Hangul Compatibility Jamo"](e)||vs["Hangul Jamo Extended-A"](e)||vs["Hangul Jamo Extended-B"](e)||vs["Hangul Jamo"](e)||vs["Hangul Syllables"](e)||vs.Hiragana(e)||vs["Ideographic Description Characters"](e)||vs.Kanbun(e)||vs["Kangxi Radicals"](e)||vs["Katakana Phonetic Extensions"](e)||vs.Katakana(e)&&12540!==e||!(!vs["Halfwidth and Fullwidth Forms"](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)||!(!vs["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||vs["Unified Canadian Aboriginal Syllabics"](e)||vs["Unified Canadian Aboriginal Syllabics Extended"](e)||vs["Vertical Forms"](e)||vs["Yijing Hexagram Symbols"](e)||vs["Yi Syllables"](e)||vs["Yi Radicals"](e))))}function Ms(e){return!(Ss(e)||function(e){return!!(vs["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||vs["General Punctuation"](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)||vs["Letterlike Symbols"](e)||vs["Number Forms"](e)||vs["Miscellaneous Technical"](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)||vs["Control Pictures"](e)&&9251!==e||vs["Optical Character Recognition"](e)||vs["Enclosed Alphanumerics"](e)||vs["Geometric Shapes"](e)||vs["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||vs["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||vs["CJK Symbols and Punctuation"](e)||vs.Katakana(e)||vs["Private Use Area"](e)||vs["CJK Compatibility Forms"](e)||vs["Small Form Variants"](e)||vs["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function As(e){return e>=1424&&e<=2303||vs["Arabic Presentation Forms-A"](e)||vs["Arabic Presentation Forms-B"](e)}function Es(e,t){return!(!t&&As(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||vs.Khmer(e))}function Ts(e){for(const t of e)if(As(t.charCodeAt(0)))return!0;return!1}const Cs="deferred",ks="loading",Is="loaded";let Ps=null,Rs="unavailable",Ls=null;const zs=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Rs="error"),Ps&&Ps(e)};function Os(){Ds.fire(new zr("pluginStateChange",{pluginStatus:Rs,pluginURL:Ls}))}const Ds=new Dr,Bs=function(){return Rs},Fs=function(){if(Rs!==Cs||!Ls)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Rs=ks,Os(),Ls&&er({url:Ls},(e=>{e?zs(e):(Rs=Is,Os())}))},Ns={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Rs===Is||null!=Ns.applyArabicShaping,isLoading:()=>Rs===ks,setState(e){Rs=e.pluginStatus,Ls=e.pluginURL},isParsed:()=>null!=Ns.applyArabicShaping&&null!=Ns.processBidirectionalText&&null!=Ns.processStyledBidirectionalText,getPluginURL:()=>Ls};class js{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(e,t){for(const n of e)if(!Es(n.charCodeAt(0),t))return!1;return!0}(e,Ns.isLoaded())}}class Vs{constructor(e,t,n,r){this.property=e,this.value=t,this.expression=function(e,t,n,r){if(Za(e))return new ss(e,t);if(ns(e)||Array.isArray(e)&&e.length>0){const i=as(e,t,n,r);if("error"===i.result)throw new Error(i.value.map((e=>"".concat(e.key,": ").concat(e.message))).join(", "));return i.value}{let n=e;return"string"==typeof e&&"color"===t.type&&(n=Ur.parse(e)),{kind:"constant",isConfigDependent:!1,evaluate:()=>n}}}(void 0===t?e.specification.default:t,e.specification,n,r)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}}class Us{constructor(e,t,n){this.property=e,this.value=new Vs(e,void 0,t,n)}transitioned(e,t){return new qs(this.property,this.value,t,$t({},e.transition,this.transition),e.now)}untransitioned(){return new qs(this.property,this.value,null,{},0)}}class Gs{constructor(e,t,n){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=n,this.isConfigDependent=!1}getValue(e){return un(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Us(this._values[e].property,this._scope,this._options)),this._values[e].value=new Vs(this._values[e].property,null===t?void 0:un(t),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].value.expression.isConfigDependent}setTransitionOrValue(e,t){t&&(this._options=t);const n=this._properties.properties;if(e)for(const r in e){const t=e[r];if(sn(r,"-transition")){const e=r.slice(0,-11);n[e]&&this.setTransition(e,t)}else n[r]&&this.setValue(r,t)}}getTransition(e){return un(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Us(this._values[e].property)),this._values[e].transition=un(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const n=this.getValue(t);void 0!==n&&(e[t]=n);const r=this.getTransition(t);void 0!==r&&(e["".concat(t,"-transition")]=r)}return e}transitioned(e,t){const n=new Ws(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(e,t._values[r]);return n}untransitioned(){const e=new Ws(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class qs{constructor(e,t,n,r,i){const o=r.delay||0,a=r.duration||0;i=i||0,this.property=e,this.value=t,this.begin=i+o,this.end=this.begin+a,e.specification.transition&&(r.delay||r.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){const r=e.now||0,i=this.value.possiblyEvaluate(e,t,n),o=this.prior;if(o){if(r>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(r":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"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":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"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","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"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","measure-light"],"relaxZoomRestriction":true},"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","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"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":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90]}},"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}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"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","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"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,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"property-type":"data-constant","type":"color","default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"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","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","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],"property-type":"constant"},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-border-width":{"type":"number","private":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","private":true,"default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"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","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"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"],"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,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-image-cross-fade":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"transition":true},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{},"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-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-value"]},"property-type":"color-ramp"},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"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":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"raster-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-particle-count":{"type":"number","default":512,"minimum":1,"property-type":"data-constant"},"raster-particle-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-particle-speed"]},"property-type":"color-ramp"},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1,"property-type":"data-constant"},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1,"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"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","measure-light"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","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"}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d","property-type":"data-constant"},"model-cast-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant","transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"model-front-cutoff":{"type":"array","private":true,"value":"number","property-type":"data-constant","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function nl(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(!nl(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function rl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fill";if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};nl(e)||(e=ul(e));const n=e;let r=!0;try{r=function(e){if(!al(e))return e;let t=el(e);return ol(t),t=il(t),t}(n)}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".concat(JSON.stringify(n,null,2),"\n "))}const i=tl["filter_".concat(t)],o=rs(r,i);let a=null;if("error"===o.result)throw new Error(o.value.map((e=>"".concat(e.key,": ").concat(e.message))).join(", "));a=(e,t,n)=>o.value.evaluate(e,t,{},n);let s=null,l=null;if(r!==n){const e=rs(n,i);if("error"===e.result)throw new Error(e.value.map((e=>"".concat(e.key,": ").concat(e.message))).join(", "));s=(t,n,r,i,o)=>e.value.evaluate(t,n,{},r,void 0,void 0,i,o),l=!No(e.value.expression)}return{filter:a,dynamicFilter:s||void 0,needGeometry:cl(r),needFeature:!!l}}function il(e){if(!Array.isArray(e))return e;const t=function(e){if(sl.has(e[0]))for(let t=1;til(e)))}function ol(e){let t=!1;const n=[];if("case"===e[0]){for(let r=1;r",">=","<","<=","to-boolean"]);function ll(e,t){return et?1:0}function cl(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?hl(e[1],e[2],t):"any"===t?(n=e.slice(1),["any"].concat(n.map(ul))):"all"===t?["all"].concat(e.slice(1).map(ul)):"none"===t?["all"].concat(e.slice(1).map(ul).map(pl)):"in"===t?dl(e[1],e.slice(2)):"!in"===t?pl(dl(e[1],e.slice(2))):"has"===t?fl(e[1]):"!has"!==t||pl(fl(e[1]));var n}function hl(e,t,n){switch(e){case"$type":return["filter-type-".concat(n),t];case"$id":return["filter-id-".concat(n),t];default:return["filter-".concat(n),e,t]}}function dl(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(ll)]]:["filter-in-small",e,["literal",t]]}}function fl(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function pl(e){return["!",e]}const ml="\x1f";function gl(e,t){return t?"".concat(e).concat(ml).concat(t):e}const _l="-transition",yl=new Set(["fill","line","background","hillshade","raster"]);class vl extends Dr{constructor(e,t,n,r){if(super(),this.id=e.id,this.fqid=gl(this.id,n),this.type=e.type,this.scope=n,this.options=r,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),e.slot&&(this.slot=e.slot),t.layout&&(this._unevaluatedLayout=new Hs(t.layout,this.scope,r),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),t.paint)){this._transitionablePaint=new Gs(t.paint,this.scope,r);for(const t in e.paint)this.setPaintProperty(t,e.paint[t]);for(const t in e.layout)this.setLayoutProperty(t,e.layout[t]);this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ys(t.paint)}}onAdd(e){}onRemove(e){}isDraped(e){return yl.has(this.type)}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const n=this._unevaluatedLayout;n._properties.properties[e]&&(n.setValue(e,t),this.isConfigDependent=this.isConfigDependent||n.isConfigDependent,"visibility"===e&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(e){return sn(e,_l)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t){const n=this._transitionablePaint,r=n._properties.properties;if(sn(e,_l)){const i=e.slice(0,-11);return r[i]&&n.setTransition(i,t||void 0),!1}if(!r[e])return!1;const i=n._values[e],o=i.value.isDataDriven(),a=i.value;n.setValue(e,t),this.isConfigDependent=this.isConfigDependent||n.isConfigDependent,this._handleSpecialPaintPropertyUpdate(e);const s=n._values[e].value,l=s.isDataDriven(),c=sn(e,"pattern")||"line-dasharray"===e;return l||o||c||this._handleOverridablePaintPropertyUpdate(e,a,s)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t){return null}_handleOverridablePaintPropertyUpdate(e,t,n){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){return cn({id:this.id,type:this.type,slot:this.slot,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()},((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Zs&&Ga(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=rl(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(e){}queryIntersectsFeature(e,t,n,r,i,o,a,s,l){}queryIntersectsMatchingFeature(e,t,n,r){}}const xl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class bl{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 wl{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.add(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("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(){throw new Error("StructArray#emplaceBack() 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 Sl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=0,r=0;return{members:e.map((e=>{const i=xl[e.type].BYTES_PER_ELEMENT,o=n=Ml(n,Math.max(t,i)),a=e.components||1;return r=Math.max(r,i),n+=i*a,{name:e.name,type:e.type,components:a,offset:o}})),size:Ml(n,Math.max(r,t)),alignment:t}}function Ml(e,t){return Math.ceil(e/t)*t}class Al extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=n,e}}Al.prototype.bytesPerElement=4,ps(Al,"StructArrayLayout2i4");class El extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=r,e}}El.prototype.bytesPerElement=6,ps(El,"StructArrayLayout3i6");class Tl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=n,this.int16[o+2]=r,this.int16[o+3]=i,e}}Tl.prototype.bytesPerElement=8,ps(Tl,"StructArrayLayout4i8");class Cl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=5*e;return this.int16[a+0]=t,this.int16[a+1]=n,this.int16[a+2]=r,this.int16[a+3]=i,this.int16[a+4]=o,e}}Cl.prototype.bytesPerElement=10,ps(Cl,"StructArrayLayout5i10");class kl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.uint8[c+4]=r,this.uint8[c+5]=i,this.uint8[c+6]=o,this.uint8[c+7]=a,this.float32[u+2]=s,e}}kl.prototype.bytesPerElement=12,ps(kl,"StructArrayLayout2i4ub1f12");class Il extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=n,this.float32[o+2]=r,this.float32[o+3]=i,e}}Il.prototype.bytesPerElement=16,ps(Il,"StructArrayLayout4f16");class Pl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=n,e}}Pl.prototype.bytesPerElement=8,ps(Pl,"StructArrayLayout2f8");class Rl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=6*e,s=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=n,this.uint16[a+2]=r,this.uint16[a+3]=i,this.float32[s+2]=o,e}}Rl.prototype.bytesPerElement=12,ps(Rl,"StructArrayLayout4ui1f12");class Ll extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=n,this.uint16[o+2]=r,this.uint16[o+3]=i,e}}Ll.prototype.bytesPerElement=8,ps(Ll,"StructArrayLayout4ui8");class zl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i,o)}emplace(e,t,n,r,i,o,a){const s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,e}}zl.prototype.bytesPerElement=12,ps(zl,"StructArrayLayout6i12");class Ol extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,n,r,i,o,a,s,l,c,u,h)}emplace(e,t,n,r,i,o,a,s,l,c,u,h,d){const f=12*e;return this.int16[f+0]=t,this.int16[f+1]=n,this.int16[f+2]=r,this.int16[f+3]=i,this.uint16[f+4]=o,this.uint16[f+5]=a,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=c,this.int16[f+9]=u,this.int16[f+10]=h,this.int16[f+11]=d,e}}Ol.prototype.bytesPerElement=24,ps(Ol,"StructArrayLayout4i4ui4i24");class Dl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i,o)}emplace(e,t,n,r,i,o,a){const s=10*e,l=5*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.float32[l+2]=i,this.float32[l+3]=o,this.float32[l+4]=a,e}}Dl.prototype.bytesPerElement=20,ps(Dl,"StructArrayLayout3i3f20");class Bl extends wl{_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}}Bl.prototype.bytesPerElement=4,ps(Bl,"StructArrayLayout1ul4");class Fl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=n,e}}Fl.prototype.bytesPerElement=4,ps(Fl,"StructArrayLayout2ui4");class Nl extends wl{_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,n,r,i,o,a,s,l,c,u,h,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,t,n,r,i,o,a,s,l,c,u,h,d)}emplace(e,t,n,r,i,o,a,s,l,c,u,h,d,f){const p=20*e,m=10*e;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=r,this.int16[p+3]=i,this.int16[p+4]=o,this.float32[m+3]=a,this.float32[m+4]=s,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[p+14]=u,this.uint32[m+8]=h,this.uint16[p+18]=d,this.uint16[p+19]=f,e}}Nl.prototype.bytesPerElement=40,ps(Nl,"StructArrayLayout5i4f1i1ul2ui40");class jl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.int16[l+2]=r,this.int16[l+4]=i,this.int16[l+5]=o,this.int16[l+6]=a,this.int16[l+7]=s,e}}jl.prototype.bytesPerElement=16,ps(jl,"StructArrayLayout3i2i2i16");class Vl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=4*e,s=8*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.int16[s+6]=i,this.int16[s+7]=o,e}}Vl.prototype.bytesPerElement=16,ps(Vl,"StructArrayLayout2f1f2i16");class Ul extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=12*e,a=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=n,this.float32[a+1]=r,this.float32[a+2]=i,e}}Ul.prototype.bytesPerElement=12,ps(Ul,"StructArrayLayout2ub2f12");class Gl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=r,e}}Gl.prototype.bytesPerElement=6,ps(Gl,"StructArrayLayout3ui6");class ql extends wl{_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,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y,v,x)}emplace(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y,v,x,b){const w=30*e,S=15*e,M=60*e;return this.int16[w+0]=t,this.int16[w+1]=n,this.int16[w+2]=r,this.float32[S+2]=i,this.float32[S+3]=o,this.uint16[w+8]=a,this.uint16[w+9]=s,this.uint32[S+5]=l,this.uint32[S+6]=c,this.uint32[S+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=d,this.uint16[w+18]=f,this.float32[S+10]=p,this.float32[S+11]=m,this.uint8[M+48]=g,this.uint8[M+49]=_,this.uint8[M+50]=y,this.uint32[S+13]=v,this.int16[w+28]=x,this.uint8[M+58]=b,e}}ql.prototype.bytesPerElement=60,ps(ql,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Wl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y,v,x,b,w,S,M,A,E,T,C,k,I,P){const R=this.length;return this.resize(R+1),this.emplace(R,e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y,v,x,b,w,S,M,A,E,T,C,k,I,P)}emplace(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y,v,x,b,w,S,M,A,E,T,C,k,I,P,R){const L=20*e,z=40*e,O=80*e;return this.float32[L+0]=t,this.float32[L+1]=n,this.int16[z+4]=r,this.int16[z+5]=i,this.int16[z+6]=o,this.int16[z+7]=a,this.int16[z+8]=s,this.int16[z+9]=l,this.int16[z+10]=c,this.int16[z+11]=u,this.int16[z+12]=h,this.uint16[z+13]=d,this.uint16[z+14]=f,this.uint16[z+15]=p,this.uint16[z+16]=m,this.uint16[z+17]=g,this.uint16[z+18]=_,this.uint16[z+19]=y,this.uint16[z+20]=v,this.uint16[z+21]=x,this.uint16[z+22]=b,this.uint16[z+23]=w,this.uint16[z+24]=S,this.uint16[z+25]=M,this.uint16[z+26]=A,this.uint16[z+27]=E,this.uint32[L+14]=T,this.float32[L+15]=C,this.float32[L+16]=k,this.float32[L+17]=I,this.float32[L+18]=P,this.uint8[O+76]=R,e}}Wl.prototype.bytesPerElement=80,ps(Wl,"StructArrayLayout2f9i15ui1ul4f1ub80");class Hl extends wl{_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}}Hl.prototype.bytesPerElement=4,ps(Hl,"StructArrayLayout1f4");class Zl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.float32[a+3]=i,this.float32[a+4]=o,e}}Zl.prototype.bytesPerElement=20,ps(Zl,"StructArrayLayout5f20");class Yl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=n,this.float32[l+2]=r,this.float32[l+3]=i,this.float32[l+4]=o,this.float32[l+5]=a,this.float32[l+6]=s,e}}Yl.prototype.bytesPerElement=28,ps(Yl,"StructArrayLayout7f28");class Ql extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=n,this.uint16[o+3]=r,this.uint16[o+4]=i,e}}Ql.prototype.bytesPerElement=12,ps(Ql,"StructArrayLayout1ul3ui12");class Xl extends wl{_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}}Xl.prototype.bytesPerElement=2,ps(Xl,"StructArrayLayout1ui2");class Kl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}Kl.prototype.bytesPerElement=12,ps(Kl,"StructArrayLayout3f12");class Jl extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m)}emplace(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g){const _=16*e;return this.float32[_+0]=t,this.float32[_+1]=n,this.float32[_+2]=r,this.float32[_+3]=i,this.float32[_+4]=o,this.float32[_+5]=a,this.float32[_+6]=s,this.float32[_+7]=l,this.float32[_+8]=c,this.float32[_+9]=u,this.float32[_+10]=h,this.float32[_+11]=d,this.float32[_+12]=f,this.float32[_+13]=p,this.float32[_+14]=m,this.float32[_+15]=g,e}}Jl.prototype.bytesPerElement=64,ps(Jl,"StructArrayLayout16f64");class $l extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=10*e,c=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=n,this.uint16[l+2]=r,this.uint16[l+3]=i,this.float32[c+2]=o,this.float32[c+3]=a,this.float32[c+4]=s,e}}$l.prototype.bytesPerElement=20,ps($l,"StructArrayLayout4ui3f20");class ec extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}ec.prototype.bytesPerElement=2,ps(ec,"StructArrayLayout1i2");class tc extends wl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}tc.prototype.bytesPerElement=1,ps(tc,"StructArrayLayout1ub1");class nc extends bl{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]}}nc.prototype.size=40;class rc extends Nl{get(e){return new nc(this,e)}}ps(rc,"CollisionBoxArray");class ic extends bl{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}}ic.prototype.size=60;class oc extends ql{get(e){return new ic(this,e)}}ps(oc,"PlacedSymbolArray");class ac extends bl{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}ac.prototype.size=80;class sc extends Wl{get(e){return new ac(this,e)}}ps(sc,"SymbolInstanceArray");class lc extends Hl{getoffsetX(e){return this.float32[1*e+0]}}ps(lc,"GlyphOffsetArray");class cc extends Al{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}ps(cc,"SymbolLineVertexArray");class uc extends bl{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]}}uc.prototype.size=12;class hc extends Ql{get(e){return new uc(this,e)}}ps(hc,"FeatureIndexArray");class dc extends Fl{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}ps(dc,"FillExtrusionCentroidArray");const fc=Sl([{name:"a_pos",components:2,type:"Int16"}],4),pc=Sl([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class mc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.segments=e}_prepareSegment(e,t,n,r){let i=this.segments[this.segments.length-1];return e>mc.MAX_VERTEX_ARRAY_LENGTH&&dn("Max vertices per segment is ".concat(mc.MAX_VERTEX_ARRAY_LENGTH,": bucket requested ").concat(e)),(!i||i.vertexLength+e>mc.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r)&&(i={vertexOffset:t,primitiveOffset:n,vertexLength:0,primitiveLength:0},void 0!==r&&(i.sortKey=r),this.segments.push(i)),i}prepareSegment(e,t,n,r){return this._prepareSegment(e,t.length,n.length,r)}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,n,r){return new mc([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])}}function gc(e,t){return 256*(e=Qt(Math.floor(e),0,255))+Qt(Math.floor(t),0,255)}mc.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ps(mc,"SegmentVector");const _c=Sl([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),yc=Sl([{name:"a_dash",components:4,type:"Uint16"}]);class vc{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(xc(e)),this.positions.push(t,n,r)}eachPosition(e,t){const n=xc(e);let r=0,i=this.ids.length-1;for(;r>1;this.ids[e]>=n?i=e:r=e+1}for(;this.ids[r]===n;)t(this.positions[3*r],this.positions[3*r+1],this.positions[3*r+2]),r++}static serialize(e,t){const n=new Float64Array(e.ids),r=new Uint32Array(e.positions);return bc(n,r,0,n.length-1),t&&(t.add(n.buffer),t.add(r.buffer)),{ids:n,positions:r}}static deserialize(e){const t=new vc;let n;t.ids=e.ids,t.positions=e.positions;for(const r of t.ids)r!==n&&t.uniqueIds.push(r),n=r;return t.indexed=!0,t}}function xc(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Pr(String(e))}function bc(e,t,n,r){for(;n>1];let o=n-1,a=r+1;for(;;){do{o++}while(e[o]i);if(o>=a)break;wc(e,o,a),wc(t,3*o,3*a),wc(t,3*o+1,3*a+1),wc(t,3*o+2,3*a+2)}a-n"u_".concat(e))),this.type=n}setUniform(e,t,n,r,i){t.set(e,i,r.constantOr(this.value))}getBinding(e,t){return"color"===this.type?new kc(e):new Ac(e)}}class Bc{constructor(e,t){this.uniformNames=t.map((e=>"u_".concat(e))),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,t,n,r,i){const o="u_pattern"===i||"u_dash"===i?this.pattern:"u_pixel_ratio"===i?this.pixelRatio:null;o&&t.set(e,i,o)}getBinding(e,t){return"u_pattern"===t||"u_dash"===t?new Cc(e):new Ac(e)}}class Fc{constructor(e,t,n,r){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:"a_".concat(e),type:"Float32",components:"color"===n?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(e,t,n,r,i,o,a){const s=this.paintVertexArray.length,l=this.expression.evaluate(new js(0,{brightness:o}),t,{},i,r,a);this.paintVertexArray.resize(e),this._setPaintValue(s,e,l)}updatePaintArray(e,t,n,r,i,o,a){const s=this.expression.evaluate({zoom:0,brightness:a},n,r,void 0,i);this._setPaintValue(e,t,s)}_setPaintValue(e,t,n){if("color"===this.type){const r=Oc(n);for(let n=e;n"u_".concat(e,"_t"))),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:"a_".concat(e),type:"Float32",components:"color"===n?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(e,t,n,r,i,o,a){const s=this.expression.evaluate(new js(this.zoom,{brightness:o}),t,{},i,r,a),l=this.expression.evaluate(new js(this.zoom+1,{brightness:o}),t,{},i,r,a),c=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(c,e,s,l)}updatePaintArray(e,t,n,r,i,o,a){const s=this.expression.evaluate({zoom:this.zoom,brightness:a},n,r,void 0,i),l=this.expression.evaluate({zoom:this.zoom+1,brightness:a},n,r,void 0,i);this._setPaintValue(e,t,s,l)}_setPaintValue(e,t,n,r){if("color"===this.type){const i=Oc(n),o=Oc(r);for(let n=e;n2&&void 0!==arguments[2]?arguments[2]:()=>!0;this.binders={},this._buffers=[];const r=[];for(const i in e.paint._values){const o=e.paint.get(i);if(!n(i))continue;if(!(o instanceof Zs&&Ga(o.property.specification)))continue;const a=qc(i,e.type),s=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,u="line-dasharray"===i||i.endsWith("pattern"),h="line-dasharray"===i&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==s.kind||h)if("source"===s.kind||h||u){const t=Zc(i,l,"source");this.binders[i]=u?new jc(s,a,l,t,e.id):new Fc(s,a,l,t),r.push("/a_".concat(i))}else{const e=Zc(i,l,"composite");this.binders[i]=new Nc(s,a,l,c,t,e),r.push("/z_".concat(i))}else this.binders[i]=u?new Bc(s.value,a):new Dc(s.value,a,l),r.push("/u_".concat(i))}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Fc||t instanceof Nc?t.maxValue:0}populatePaintArrays(e,t,n,r,i,o,a){for(const s in this.binders){const l=this.binders[s];(l instanceof Fc||l instanceof Nc||l instanceof jc)&&l.populatePaintArray(e,t,n,r,i,o,a)}}setConstantPatternPositions(e){for(const t in this.binders){const n=this.binders[t];n instanceof Bc&&n.setConstantPatternPositions(e)}}updatePaintArrays(e,t,n,r,i,o,a,s){let l=!1;const c=Object.keys(e),u=0!==c.length,h=u?c:t.uniqueIds;for(const d in this.binders){const c=this.binders[d];if((c instanceof Fc||c instanceof Nc||c instanceof jc)&&(!0===c.expression.isStateDependent||!1===c.expression.isLightConstant)){const f=i.paint.get(d);c.expression=f.value;for(const n of h){const i=e[n.toString()];t.eachPosition(n,((e,t,n)=>{const l=r.feature(e);c.updatePaintArray(t,n,l,i,o,a,s)}))}if(!u)for(const t of n.uniqueIds){const i=e[t.toString()];n.eachPosition(t,((e,t,n)=>{const l=r.feature(e);c.updatePaintArray(t,n,l,i,o,a,s)}))}l=!0}}return l}defines(){const e=[];for(const t in this.binders){const n=this.binders[t];(n instanceof Dc||n instanceof Bc)&&e.push(...n.uniformNames.map((e=>"#define HAS_UNIFORM_".concat(e))))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const n=this.binders[t];if(n instanceof Fc||n instanceof Nc||n instanceof jc)for(let t=0;t2&&void 0!==arguments[2]?arguments[2]:()=>!0;this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Vc(r,t,n);this.needsUpload=!1,this._featureMap=new vc,this._featureMapWithoutIds=new vc,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,n,r,i,o,a,s){for(const l in this.programConfigurations)this.programConfigurations[l].populatePaintArrays(e,t,r,i,o,a,s);void 0!==t.id?this._featureMap.add(t.id,n,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,n,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r,i,o){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,a,r,i,o||0)||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 Gc={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function qc(e,t){return Gc[e]||[e.replace("".concat(t,"-"),"").replace(/-/g,"_")]}const Wc={"line-pattern":{source:Rl,composite:Rl},"fill-pattern":{source:Rl,composite:Rl},"fill-extrusion-pattern":{source:Rl,composite:Rl},"line-dasharray":{source:Ll,composite:Ll}},Hc={color:{source:Pl,composite:Il},number:{source:Hl,composite:Pl}};function Zc(e,t,n){const r=Wc[e];return r&&r[n]||Hc[t][n]}ps(Dc,"ConstantBinder"),ps(Bc,"PatternConstantBinder"),ps(Fc,"SourceExpressionBinder"),ps(jc,"PatternCompositeBinder"),ps(Nc,"CompositeExpressionBinder"),ps(Vc,"ProgramConfiguration",{omit:["_buffers"]}),ps(Uc,"ProgramConfigurationSet");const Yc=io/Math.PI/2,Qc=5,Xc=6,Kc=16383,Jc=64,$c=[Jc,32,16],eu=-Yc,tu=Yc;function nu(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Yc;return n=Gt(n),[e*Math.sin(n)*r,-t*r,e*Math.cos(n)*r]}function ru(e,t,n){return nu(Math.cos(Gt(e)),Math.sin(Gt(e)),t,n)}const iu=6371008.8,ou=2*Math.PI*iu;class au{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error("Invalid LngLat object: (".concat(e,", ").concat(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 au(Kt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return"LngLat(".concat(this.lng,", ").concat(this.lat,")")}distanceTo(e){const t=Math.PI/180,n=this.lat*t,r=e.lat*t,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return iu*Math.acos(Math.min(i,1))}toBounds(){const e=360*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)/40075017,t=e/Math.cos(Math.PI/180*this.lat);return new su({lng:this.lng-t,lat:this.lat-e},{lng:this.lng+t,lat:this.lat+e})}toEcef(e){return ru(this.lat,this.lng,Yc+e*Yc/iu)}static convert(e){if(e instanceof au)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new au(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new au(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class su{constructor(e,t){if(e)if(t)this.setSouthWest(e).setNorthEast(t);else if(4===e.length){const t=e;this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]])}else{const t=e;this.setSouthWest(t[0]).setNorthEast(t[1])}}setNorthEast(e){return this._ne=e instanceof au?new au(e.lng,e.lat):au.convert(e),this}setSouthWest(e){return this._sw=e instanceof au?new au(e.lng,e.lat):au.convert(e),this}extend(e){const t=this._sw,n=this._ne;let r,i;if(e instanceof au)r=e,i=e;else{if(!(e instanceof su))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(su.convert(e)):this.extend(au.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(au.convert(e)):this;if(r=e._sw,i=e._ne,!r||!i)return this}return t||n?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),n.lng=Math.max(i.lng,n.lng),n.lat=Math.max(i.lat,n.lat)):(this._sw=new au(r.lng,r.lat),this._ne=new au(i.lng,i.lat)),this}getCenter(){return new au((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 au(this.getWest(),this.getNorth())}getSouthEast(){return new au(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(".concat(this._sw.toString(),", ").concat(this._ne.toString(),")")}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:n}=au.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}static convert(e){return!e||e instanceof su?e:new su(e)}}var lu={};!function(e,t){!function(e){function t(e,t,r){var i=n(256*e,256*(t=Math.pow(2,r)-t-1),r),o=n(256*(e+1),256*(t+1),r);return i[0]+","+i[1]+","+o[0]+","+o[1]}function n(e,t,n){var r=2*Math.PI*6378137/256/Math.pow(2,n);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}e.getURL=function(e,n,r,i,o,a){return a=a||{},e+"?"+["bbox="+t(r,i,o),"format="+(a.format||"image/png"),"service="+(a.service||"WMS"),"version="+(a.version||"1.1.1"),"request="+(a.request||"GetMap"),"srs="+(a.srs||"EPSG:3857"),"width="+(a.width||256),"height="+(a.height||256),"layers="+n].join("&")},e.getTileBBox=t,e.getMercCoords=n,Object.defineProperty(e,"__esModule",{value:!0})}(t)}(0,lu);var cu=lu;class uu{constructor(e,t,n){this.z=e,this.x=t,this.y=n,this.key=fu(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const n=cu.getTileBBox(this.x,this.y,this.z),r=function(e,t,n){let r,i="";for(let o=e;o>0;o--)r=1<this.canonical.z?new du(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new du(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return fu(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return fu(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new du(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new du(t,this.wrap,t,n,r),new du(t,this.wrap,t,n+1,r),new du(t,this.wrap,t,n,r+1),new du(t,this.wrap,t,n+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let t=e.canonical.x-1,n=e.wrap;return t<0&&(t=(1<{let t=e.canonical.x+1,n=e.wrap;return t===1<new du(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new du(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<1&&void 0!==arguments[1]?arguments[1]:0;const n=Math.exp(Math.PI*(1-(e.y+t/io)/(1<2&&void 0!==arguments[2]?arguments[2]:0;this.x=+e,this.y=+t,this.z=+n}static fromLngLat(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=au.convert(e);return new ku(yu(n.lng),vu(n.lat),xu(t,n.lat))}toLngLat(){return new au(bu(this.x),wu(this.y))}toAltitude(){return Su(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ou*Tu(wu(this.y))}}function Iu(e,t,n,r,i,o,a,s,l){const c=(t+r)/2,u=(n+i)/2,h=new jt(c,u);s(h),function(e,t,n,r,i,o){const a=n-i,s=r-o;return Math.abs((r-t)*a-(n-e)*s)/Math.hypot(a,s)}(h.x,h.y,o.x,o.y,a.x,a.y)>=l?(Iu(e,t,n,c,u,o,h,s,l),Iu(e,c,u,r,i,h,a,s,l)):e.push(a)}function Pu(e,t,n){let r=e[0],i=r.x,o=r.y;t(r);const a=[r];for(let s=1;se.x+1||re.y+1)&&dn("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Bu(e,t,n){const r=e.loadGeometry(),i=e.extent,o=io/i;if(t&&n&&n.projection.isReprojectedInTileSpace){const o=1<{const n=bu((t.x+e.x/i)/o),r=wu((t.y+e.y/i)/o),u=c.project(n,r);e.x=(u.x*a-s)*i,e.y=(u.y*a-l)*i};for(let t=0;t=i||n.y<0||n.y>=i||(u(n),e.push(n));r[t]=e}}for(const a of r)for(const e of a)Du(e,o);return r}function Fu(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Bu(e):[]}}function Nu(e,t,n,r,i){e.emplaceBack(2*t+(r+1)/2,2*n+(i+1)/2)}function ju(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class Vu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Al,this.indexArray=new Gl,this.segments=new mc,this.programConfigurations=new Uc(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n,r){const i=this.layers[0],o=[];let a=null;"circle"===i.type&&(a=i.layout.get("circle-sort-key"));for(const{feature:l,id:c,index:u,sourceLayerIndex:h}of e){const e=this.layers[0]._featureFilter.needGeometry,t=Fu(l,e);if(!this.layers[0]._featureFilter.filter(new js(this.zoom),t,n))continue;const i=a?a.evaluate(t,{},n):void 0,s={id:c,properties:l.properties,type:l.type,sourceLayerIndex:h,index:u,geometry:e?t.geometry:Bu(l,n,r),patterns:{},sortKey:i};o.push(s)}a&&o.sort(((e,t)=>e.sortKey-t.sortKey));let s=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new zl,s=r.projection);for(const l of o){const{geometry:r,index:i,sourceLayerIndex:o}=l,a=e[i].feature;this.addFeature(l,r,i,t.availableImages,n,s,t.brightness),t.featureIndex.insert(a,r,i,o,this.index)}}update(e,t,n,r,i){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,n,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,fc.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,pc.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,n,r,i,o,a){for(const s of t)for(const t of s){const n=t.x,r=t.y;if(n<0||n>=io||r<0||r>=io)continue;if(o){const e=o.projectTilePoint(n,r,i),t=o.upVector(i,n,r),a=this.globeExtVertexArray;ju(a,e,t),ju(a,e,t),ju(a,e,t),ju(a,e,t)}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;Nu(this.layoutVertexArray,n,r,-1,-1),Nu(this.layoutVertexArray,n,r,1,-1),Nu(this.layoutVertexArray,n,r,1,1),Nu(this.layoutVertexArray,n,r,-1,1),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+2,s+3),a.vertexLength+=4,a.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},r,i,a)}}function Uu(e,t){for(let n=0;n1){if(Hu(e,t))return!0;for(let r=0;r1?n:n.sub(t)._mult(i)._add(t))}function Xu(e,t){let n,r,i,o=!1;for(let a=0;at.y!=i.y>t.y&&t.x<(i.x-r.x)*(t.y-r.y)/(i.y-r.y)+r.x&&(o=!o)}return o}function Ku(e,t){let n=!1;for(let r=0,i=e.length-1;rt.y!=a.y>t.y&&t.x<(a.x-o.x)*(t.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}function Ju(e,t,n,r,i){for(const a of e)if(t<=a.x&&n<=a.y&&r>=a.x&&i>=a.y)return!0;const o=[new jt(t,n),new jt(t,i),new jt(r,i),new jt(r,n)];if(e.length>2)for(const a of o)if(Ku(e,a))return!0;for(let a=0;ai.x&&t.x>i.x||e.yi.y&&t.y>i.y)return!1;const o=fn(e,t,n[0]);return o!==fn(e,t,n[1])||o!==fn(e,t,n[2])||o!==fn(e,t,n[3])}function eh(e,t,n,r,i,o){let a=t.y-e.y,s=e.x-t.x;if(o=o||0){const e=a*a+s*s;if(0===e)return!0;const t=Math.sqrt(e);a/=t,s/=t}return!((n.x-e.x)*a+(n.y-e.y)*s-o<0||(r.x-e.x)*a+(r.y-e.y)*s-o<0||(i.x-e.x)*a+(i.y-e.y)*s-o<0)}function th(e,t,n,r,i,o,a){return!(eh(e,t,r,i,o,a)||eh(t,n,r,i,o,a)||eh(n,e,r,i,o,a)||eh(r,i,e,t,n,a)||eh(i,o,e,t,n,a)||eh(o,r,e,t,n,a))}function nh(e,t,n){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function rh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ih(e,t,n,r,i){if(!t[0]&&!t[1])return e;const o=jt.convert(t)._mult(i);"viewport"===n&&o._rotate(-r);const a=[];for(let s=0;s=0;if(0===a)return 0;a!==n.length&&(r=!1)}return r?2:1}function dh(e,t){for(const n of e.projections){const r=uh(t,e.points[0],n.axis);if(n.projection[1]r[1])return 0}return 1}function fh(t,n){let r=0;const i=[0,0,0,0];for(let o=0;o=0&&r++;return r}class ph{constructor(t,n){this.points=t||new Array(8).fill([0,0,0]),this.planes=n||new Array(6).fill([0,0,0,0]),this.bounds=mh.fromPoints(this.points),this.projections=[],this.frustumEdges=[e.Q.sub([],this.points[2],this.points[3]),e.Q.sub([],this.points[0],this.points[3]),e.Q.sub([],this.points[4],this.points[0]),e.Q.sub([],this.points[5],this.points[1]),e.Q.sub([],this.points[6],this.points[2]),e.Q.sub([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],n=[e[2],0,-e[0]];this.projections.push({axis:t,projection:uh(this.points,this.points[0],t)}),this.projections.push({axis:n,projection:uh(this.points,this.points[0],n)})}}static fromInvProjectionMatrix(t,n,r,i){const o=Math.pow(2,r),a=[[-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 a=e.aa.transformMat4([],r,t),s=1/a[3]/n*o;return e.aa.mul(a,a,[s,s,i?1/a[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const n=e.Q.sub([],a[t[0]],a[t[1]]),r=e.Q.sub([],a[t[2]],a[t[1]]),i=e.Q.normalize([],e.Q.cross([],n,r)),o=-e.Q.dot(i,a[t[1]]);return i.concat(o)})),l=[];for(let e=0;es[1]||s[0]>a[1])return 0}return 1}}class mh{static fromPoints(t){const n=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const i of t)e.Q.min(n,n,i),e.Q.max(r,r,i);return new mh(n,r)}static fromTileIdAndHeight(e,t,n){const r=1<e.max[t]||e.min[t]>this.max[t])return!1;return!0}intersectsAabbXY(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t])}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t])}closestPoint(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}ps(mh,"Aabb");const gh=Sl([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:_h}=gh,yh=Sl([{name:"a_pos_3",components:3,type:"Int16"}]);var vh=Sl([{name:"a_pos",type:"Int16",components:2}]);function xh(e){return e*Yc/iu}const bh=[new mh([eu,eu,eu],[tu,tu,tu]),new mh([eu,eu,eu],[0,0,tu]),new mh([0,eu,eu],[tu,0,tu]),new mh([eu,0,eu],[0,tu,tu]),new mh([0,0,eu],[tu,tu,tu])];function wh(t,n,r){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const o=e.Q.scale([],t._camera.position,t.worldSize),a=[n,r,1,1];e.aa.transformMat4(a,a,t.pixelMatrixInverse),e.aa.scale(a,a,1/a[3]);const s=e.Q.sub([],a,o),l=e.Q.normalize([],s),c=t.globeMatrix,u=[c[12],c[13],c[14]],h=e.Q.sub([],u,o),d=e.Q.length(h),f=e.Q.normalize([],h),p=t.worldSize/(2*Math.PI),m=e.Q.dot(f,l),g=Math.asin(p/d);if(g1?null:function(e,t,n,r){const i=Math.sin(n);return e*(Math.sin((1-r)*n)/i)+t*(Math.sin(r*n)/i)}(e.a[t],e.b[t],e.angle,Qt(n,0,1))+e.center[t]}function Ah(e){if(e.z<=1)return bh[e.z+2*e.y+e.x];const t=Ih(kh(e));return mh.fromPoints(t)}function Eh(t,n,r){return e.Q.scale(t,t,1-r),e.Q.scaleAndAdd(t,t,n,r)}function Th(t,n,r){for(const i of t)e.Q.transformMat4(i,i,n),e.Q.scale(i,i,r)}function Ch(t,n,r,i){const o=n/t.worldSize,a=t.globeMatrix;if(r.z<=1){const e=Ah(r).getCorners();return Th(e,a,o),mh.fromPoints(e)}const s=kh(r,i),l=Ih(s,Yc+xh(t._tileCoverLift));Th(l,a,o);const c=Number.MAX_VALUE,u=[-c,-c,-c],h=[c,c,c];if(s.contains(t.center)){for(const t of l)e.Q.min(h,h,t),e.Q.max(u,u,t);u[2]=0;const n=t.point,r=[n.x*o,n.y*o,0];return e.Q.min(h,h,r),e.Q.max(u,u,r),new mh(h,u)}if(t._tileCoverLift>0){for(const t of l)e.Q.min(h,h,t),e.Q.max(u,u,t);return new mh(h,u)}const d=[a[12]*o,a[13]*o,a[14]*o],f=s.getCenter(),p=Qt(t.center.lat,-Mu,Mu),m=Qt(f.lat,-Mu,Mu),g=yu(t.center.lng),_=vu(p);let y=g-yu(f.lng);const v=_-vu(m);y>.5?y-=1:y<-.5&&(y+=1);let x=0;if(Math.abs(y)>Math.abs(v))x=y>=0?1:3;else{x=v>=0?0:2;const t=[a[4]*o,a[5]*o,a[6]*o],n=-Math.sin(Gt(v>=0?s.getSouth():s.getNorth()))*Yc;e.Q.scaleAndAdd(d,d,t,n)}const b=l[x],w=l[(x+1)%4],S=new Sh(b,w,d),M=[Mh(S,0)||b[0],Mh(S,1)||b[1],Mh(S,2)||b[2]],A=Nh(t.zoom);if(A>0){const i=function(e,t,n,r,i){let{x:o,y:a,z:s}=e;const l=1/(1<.5?f=-1:p<-.5&&(f=1),c=((c+f)*t-(r*=t))*n+r,u=((u+f)*t-r)*n+r,h=(h*t-(i*=t))*n+i,d=(d*t-i)*n+i,[[c,d,0],[u,d,0],[u,h,0],[c,h,0]]}(r,n,t._pixelsPerMercatorPixel,g,_);for(let e=0;e1&&void 0!==arguments[1]&&arguments[1];const o=1/(1<1&&void 0!==arguments[1]?arguments[1]:Yc;const n=Gt(e.getNorth()),r=Gt(e.getSouth()),i=Math.cos(n),o=Math.cos(r),a=Math.sin(n),s=Math.sin(r),l=e.getWest(),c=e.getEast();return[nu(o,s,l,t),nu(o,s,c,t),nu(i,a,c,t),nu(i,a,l,t)]}function Ph(e,t,n,r){const i=1<Math.PI/2*1.01}const Uh=Gt(85),Gh=Math.cos(Uh),qh=Math.sin(Uh),Wh=e.a9.create(),Hh=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};function Zh(t,n,r,i,o,a,s,l,c){if(a&&t.queryGeometry.isAboveHorizon)return!1;a&&(c*=t.pixelToTileUnitsFactor);const u=t.tileID.canonical,h=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(const d of n)for(const n of d){const d=n.add(l),f=o&&r.elevation?r.elevation.exaggeration()*o.getElevationAt(d.x,d.y,!0):0,p=r.projection.projectTilePoint(d.x,d.y,u);if(f>0){const e=r.projection.upVector(u,d.x,d.y);p.x+=e[0]*h*f,p.y+=e[1]*h*f,p.z+=e[2]*h*f}const m=a?d:Yh(p.x,p.y,p.z,i),g=a?t.tilespaceRays.map((e=>Kh(e,f))):t.queryGeometry.screenGeometry,_=e.aa.transformMat4([],[p.x,p.y,p.z,1],i);if(!s&&a?c*=_[3]/r.cameraToCenterDistance:s&&!a&&(c*=r.cameraToCenterDistance/_[3]),a){const e=wu((n.y/io+u.y)/(1<e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,l=t.data,c=4===o&&a;for(let u=0;u{t[e.evaluationKey]=o;const a=e.expression.evaluate(t);a&&(i.data[n+r+0]=Math.floor(255*a.r/a.a),i.data[n+r+1]=Math.floor(255*a.g/a.a),i.data[n+r+2]=Math.floor(255*a.b/a.a),i.data[n+r+3]=Math.floor(255*a.a))};if(e.clips)for(let a=0,s=0;a80*n){r=o=e[0],i=a=e[1];for(var p=n;po&&(o=s),l>a&&(a=l);c=0!==(c=Math.max(o-r,a-i))?32767/c:0}return gd(d,f,n,r,i,c,0),f}function pd(e,t,n,r,i){var o,a;if(i===Fd(e,t,n,r)>0)for(o=t;o=t;o-=r)a=Od(o,e[o],e[o+1],a);return a&&kd(a,a.next)&&(Dd(a),a=a.next),a}function md(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!kd(r,r.next)&&0!==Cd(r.prev,r,r.next))r=r.next;else{if(Dd(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function gd(e,t,n,r,i,o,a){if(e){!a&&o&&function(e,t,n,r){var i=e;do{0===i.z&&(i.z=Md(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,o,a,s,l,c=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,c*=2}while(a>1)}(i)}(e,r,i,o);for(var s,l,c=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?yd(e,r,i,o):_d(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Dd(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?gd(e=vd(md(e),t,n),t,n,r,i,o,2):2===a&&xd(e,t,n,r,i,o):gd(md(e),t,n,r,i,o,1);break}}}function _d(e){var t=e.prev,n=e,r=e.next;if(Cd(t,n,r)>=0)return!1;for(var i=t.x,o=n.x,a=r.x,s=t.y,l=n.y,c=r.y,u=io?i>a?i:a:o>a?o:a,f=s>l?s>c?s:c:l>c?l:c,p=r.next;p!==t;){if(p.x>=u&&p.x<=d&&p.y>=h&&p.y<=f&&Ed(i,s,o,l,a,c,p.x,p.y)&&Cd(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function yd(e,t,n,r){var i=e.prev,o=e,a=e.next;if(Cd(i,o,a)>=0)return!1;for(var s=i.x,l=o.x,c=a.x,u=i.y,h=o.y,d=a.y,f=sl?s>c?s:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,_=Md(f,p,t,n,r),y=Md(m,g,t,n,r),v=e.prevZ,x=e.nextZ;v&&v.z>=_&&x&&x.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&Ed(s,u,l,h,c,d,v.x,v.y)&&Cd(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&Ed(s,u,l,h,c,d,x.x,x.y)&&Cd(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=_;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&Ed(s,u,l,h,c,d,v.x,v.y)&&Cd(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&Ed(s,u,l,h,c,d,x.x,x.y)&&Cd(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function vd(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!kd(i,o)&&Id(i,r,r.next,o)&&Ld(i,o)&&Ld(o,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),Dd(r),Dd(r.next),r=e=o),r=r.next}while(r!==e);return md(r)}function xd(e,t,n,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Td(a,s)){var l=zd(a,s);return a=md(a,a.next),l=md(l,l.next),gd(a,t,n,r,i,o,0),void gd(l,t,n,r,i,o,0)}s=s.next}a=a.next}while(a!==e)}function bd(e,t){return e.x-t.x}function wd(e,t){var n=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a&&(a=s,n=r.x=r.x&&r.x>=u&&i!==r.x&&Ed(on.x||r.x===n.x&&Sd(n,r)))&&(n=r,d=l)),r=r.next}while(r!==c);return n}(e,t);if(!n)return t;var r=zd(n,e);return md(r,r.next),md(n,n.next)}function Sd(e,t){return Cd(e.prev,e,t.prev)<0&&Cd(t.next,e,e.next)<0}function Md(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ad(e){var t=e,n=e;do{(t.x=(e-a)*(o-s)&&(e-a)*(r-s)>=(n-a)*(t-s)&&(n-a)*(o-s)>=(i-a)*(r-s)}function Td(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Id(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Ld(e,t)&&Ld(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Cd(e.prev,e,t.prev)||Cd(e,t.prev,t))||kd(e,t)&&Cd(e.prev,e,e.next)>0&&Cd(t.prev,t,t.next)>0)}function Cd(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function kd(e,t){return e.x===t.x&&e.y===t.y}function Id(e,t,n,r){var i=Rd(Cd(e,t,n)),o=Rd(Cd(e,t,r)),a=Rd(Cd(n,r,e)),s=Rd(Cd(n,r,t));return i!==o&&a!==s||!(0!==i||!Pd(e,n,t))||!(0!==o||!Pd(e,r,t))||!(0!==a||!Pd(n,e,r))||!(0!==s||!Pd(n,t,r))}function Pd(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Rd(e){return e>0?1:e<0?-1:0}function Ld(e,t){return Cd(e.prev,e,e.next)<0?Cd(e,t,e.next)>=0&&Cd(e,e.prev,t)>=0:Cd(e,t,e.prev)<0||Cd(e,e.next,t)<0}function zd(e,t){var n=new Bd(e.i,e.x,e.y),r=new Bd(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Od(e,t,n,r){var i=new Bd(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Dd(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 Bd(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Fd(e,t,n,r){for(var i=0,o=t,a=n-r;o0&&n.holes.push(r+=e[i-1].length)}return n};var Nd=h(dd.exports);function jd(e,t){const n=e.length;if(n<=1)return[e];const r=[];let i,o;for(let a=0;a1)for(let a=0;ae.fqid)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Al,this.indexArray=new Gl,this.indexArray2=new Fl,this.programConfigurations=new Uc(e.layers,e.zoom),this.segments=new mc,this.segments2=new mc,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection}populate(e,t,n,r){this.hasPattern=Ud("fill",this.layers,t);const i=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:a,id:s,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Fu(a,e);if(!this.layers[0]._featureFilter.filter(new js(this.zoom),u,n))continue;const h=i?i.evaluate(u,{},n,t.availableImages):void 0,d={id:s,properties:a.properties,type:a.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Bu(a,n,r),patterns:{},sortKey:h};o.push(d)}i&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const a of o){const{geometry:r,index:i,sourceLayerIndex:o}=a;if(this.hasPattern){const e=Gd("fill",this.layers,a,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(a,r,i,n,{},t.availableImages,t.brightness);t.featureIndex.insert(e[i].feature,r,i,o,this.index)}}update(e,t,n,r,i){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,n,r,i)}addFeatures(e,t,n,r,i,o){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,n,r,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,hd),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,n,r,i){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[],a=arguments.length>6?arguments[6]:void 0;for(const s of jd(t,500)){let e=0;for(const a of s)e+=a.length;const t=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=t.vertexLength,r=[],i=[];for(const a of s){if(0===a.length)continue;a!==s[0]&&i.push(r.length/2);const e=this.segments2.prepareSegment(a.length,this.layoutVertexArray,this.indexArray2),t=e.vertexLength;this.layoutVertexArray.emplaceBack(a[0].x,a[0].y),this.indexArray2.emplaceBack(t+a.length-1,t),r.push(a[0].x),r.push(a[0].y);for(let n=1;n>3}if(i--,1===r||2===r)o+=e.readSVarint(),a+=e.readSVarint(),1===r&&(t&&s.push(t),t=[]),t.push(new ef(o,a));else{if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone())}}return t&&s.push(t),s},nf.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,n=1,r=0,i=0,o=0,a=1/0,s=-1/0,l=1/0,c=-1/0;e.pos>3}if(r--,1===n||2===n)(i+=e.readSVarint())s&&(s=i),(o+=e.readSVarint())c&&(c=o);else if(7!==n)throw new Error("unknown command "+n)}return[a,l,s,c]},nf.prototype.toGeoJSON=function(e,t,n){var r,i,o=this.extent*Math.pow(2,n),a=this.extent*e,s=this.extent*t,l=this.loadGeometry(),c=nf.types[this.type];function u(e){for(var t=0;t>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(n))}lf.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 af(this._pbf,t,this.extent,this._keys,this._values)};var uf=sf;function hf(e,t,n){if(3===e){var r=new uf(n,n.readVarint()+n.pos);r.length&&(t[r.name]=r)}}var df=$d.VectorTile=function(e,t){this.layers=e.readFields(hf,{},t)},ff=$d.VectorTileFeature=tf;function pf(e,t,n,r){const i=[],o=0===r?(e,t,n,r,i,o)=>{e.push(new jt(o,n+(o-t)/(r-t)*(i-n)))}:(e,t,n,r,i,o)=>{e.push(new jt(t+(o-n)/(i-n)*(r-t),o))};for(const a of e){const e=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let e=0;et&&o(a,s,l,c,u,t):h>n?d=t&&o(a,s,l,c,u,t),d>n&&h<=n&&o(a,s,l,c,u,n)}let s=i[i.length-1];const l=0===r?s.x:s.y;l>=t&&l<=n&&a.push(s),a.length&&(s=a[a.length-1],a[0].x===s.x&&a[0].y===s.y||a.push(a[0]),e.push(a))}e.length&&i.push(e)}return i}function mf(e,t){return e.x-t.x||e.y-t.y}function gf(e,t){return 0===mf(e.min,t.min)&&0===mf(e.max,t.max)}function _f(e,t){return!(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew jt((e.x+o.x*io)*s-a.x*io,(e.y+o.y*io)*s-a.y*io)))}return xf(n,i,e.indices,0,e.indices.length,0,0)}$d.VectorTileLayer=sf;class wf{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const n=this.toIdx(e,t);return{min:this.minimums[n],max:this.maximums[n]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function Sf(e,t,n,r){let i=0,o=Number.MAX_VALUE;for(let a=0;a<3;a++)if(Math.abs(r[a])<1e-15){if(n[a]t[a])return null}else{const s=1/r[a];let l=(e[a]-n[a])*s,c=(t[a]-n[a])*s;if(l>c){const e=l;l=c,c=e}if(l>i&&(i=l),co)return null}return i}function Mf(e,t,n,r,i,o,a,s,l,c,u){const h=r-e,d=i-t,f=o-n,p=a-e,m=s-t,g=l-n,_=u[1]*g-u[2]*m,y=u[2]*p-u[0]*g,v=u[0]*m-u[1]*p,x=h*_+d*y+f*v;if(Math.abs(x)<1e-15)return null;const b=1/x,w=c[0]-e,S=c[1]-t,M=c[2]-n,A=(w*_+S*y+M*v)*b;if(A<0||A>1)return null;const E=S*f-M*d,T=M*h-w*f,C=w*d-S*h,k=(u[0]*E+u[1]*T+u[2]*C)*b;return k<0||A+k>1?null:(p*E+m*T+g*C)*b}function Af(e,t,n){return(e-t)/(n-t)}function Ef(e,t,n,r,i,o,a,s,l){const c=1<{const o=r?1:0,a=(e+1)*n-o,s=t*n,l=(t+1)*n-o;i[0]=e*n,i[1]=s,i[2]=a,i[3]=l};let a=new wf(r);const s=[];for(let l=0;l=1;r/=2){const e=n[n.length-1];a=new wf(r);for(let t=0;t6&&void 0!==arguments[6]?arguments[6]:1;return Sf([e,t,-100],[n,r,this.maximums[0]*a],i,o)}raycast(t,n,r,i,o,a){let s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1;if(!this.nodeCount)return null;const l=this.raycastRoot(t,n,r,i,o,a,s);if(null==l)return null;const c=[],u=[],h=[],d=[],f=[{idx:0,t:l,nodex:0,nodey:0,depth:0}];for(;f.length>0;){const{idx:l,t:p,nodex:m,nodey:g,depth:_}=f.pop();if(this.leaves[l]){Ef(m,g,_,t,n,r,i,h,d);const l=1<<_,c=(m+0)/l,u=(m+1)/l,f=(g+0)/l,y=(g+1)/l,v=kf(c,f,this.dem)*s,x=kf(u,f,this.dem)*s,b=kf(u,y,this.dem)*s,w=kf(c,y,this.dem)*s,S=Mf(h[0],h[1],v,d[0],h[1],x,d[0],d[1],b,o,a),M=Mf(d[0],d[1],b,h[0],d[1],w,h[0],h[1],v,o,a),A=Math.min(null!==S?S:Number.MAX_VALUE,null!==M?M:Number.MAX_VALUE);if(A!==Number.MAX_VALUE)return A;{const t=e.Q.scaleAndAdd([],o,a,p);if(Cf(v,x,w,b,Af(t[0],h[0],d[0]),Af(t[1],h[1],d[1]))>=t[2])return p}continue}let y=0;for(let e=0;e=c[u[r]]&&(u.splice(r,0,e),n=!0);n||(u[y]=e),y++}}for(let e=0;e3&&void 0!==arguments[3]&&arguments[3];if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(n&&"mapbox"!==n&&"terrarium"!==n)return dn('"'.concat(n,'" is not a valid encoding type. Valid types include "mapbox" and "terrarium".'));this.stride=t.height;const i=this.dim=t.height-2,o=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.floatView=new Float32Array(t.data.buffer),this.borderReady=r,this._modifiedForSources={},!r){for(let e=0;e2&&void 0!==arguments[2]&&arguments[2]&&(e=Qt(e,-1,this.dim),t=Qt(t,-1,this.dim));const n=this._idx(e,t);return this.floatView[n]}set(e,t,n){const r=this._idx(e,t),i=this.floatView[r];return this.floatView[r]=n,n-i}static getUnpackVector(e){return If[e]}_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)}static pack(e,t){const n=[0,0,0,0],r=Lf.getUnpackVector(t);let i=Math.floor((e+r[3])/r[2]);return n[2]=i%256,i=Math.floor(i/256),n[1]=i%256,i=Math.floor(i/256),n[0]=i,n}getPixels(){return new id({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,i=t*this.dim+this.dim,o=n*this.dim,a=n*this.dim+this.dim;switch(t){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:o=a-1;break;case 1:a=o+1}const s=-t*this.dim,l=-n*this.dim;for(let c=o;ce.max.x&&(e.max.x=t.x,r=!0),t.ye.max.y&&(e.max.y=t.y,r=!0),((0===t.x||t.x===io)&&t.x===n.x)!=((0===t.y||t.y===io)&&t.y===n.y)&&this.processBorderOverlap(t,n),r&&this.checkBorderIntersection(t,n)}checkBorderIntersection(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>io!=e.x>io&&this.addBorderIntersection(1,Gr(t.y,e.y,(io-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>io!=e.y>io&&this.addBorderIntersection(3,Gr(t.x,e.x,(io-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 n=this.borders[e];tn[1]&&(n[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const n=0===e.x?0:1;this.addBorderIntersection(n,t.y),this.addBorderIntersection(n,e.y)}else{const n=0===e.y?2:3;this.addBorderIntersection(n,t.x),this.addBorderIntersection(n,e.x)}}centroid(){return 0===this.accCount?new jt(0,0):new jt(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0):0}}function Yf(e,t){const n=e.add(t)._unit(),r=Qt(e.x*n.x+e.y*n.y,-1,1);var i,o,a;return i=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(i)))/4*Nf*((o=e).x*(a=t).y-o.y*a.x<0?-1:1)}const Qf=[e=>e.x<0,e=>e.x>io,e=>e.y<0,e=>e.y>io];function Xf(e,t,n,r){const i=[4];if(0===r)return i;n._mult(r);const o=e.sub(n),a=t.sub(n),s=[e,t,o,a];for(let l=0;l<4;l++)for(const e of s)if(Qf[l](e)){i.push(l);break}return i}class Kf{constructor(e){this.vertexArray=new Cl,this.indexArray=new Gl,this.programConfigurations=new Uc(e.layers,e.zoom,(e=>Bf.includes(e))),this._segments=new mc,this.hiddenByLandmarkVertexArray=new tc,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new mc}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=e.length;if(i>2){let o=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let s;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const t=e[0],n=e[1];s=Yf(t.sub(e[i-1])._perp()._unit(),n.sub(t)._perp()._unit())}for(let l=0;le.region-t.region));for(let n=0;ne+t),0);let o=0;for(let e=0;e<=4;e++){const t=i[e];if(0!==t){let n=this.regionSegments[e];n||(n=this.regionSegments[e]=new mc);const i={vertexOffset:r.vertexOffset,primitiveOffset:r.primitiveOffset+o,vertexLength:r.vertexLength,primitiveLength:t};n.get().push(i)}o+=t}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Xd.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy()}}}}class Jf{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.fqid)),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Gl,this.footprintVertices=new Al,this.footprintSegments=[],this.layoutVertexArray=new Tl,this.centroidVertexArray=new dc,this.indexArray=new Gl,this.programConfigurations=new Uc(e.layers,e.zoom,(e=>Df.includes(e))),this.segments=new mc,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.groundEffect=new Kf(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}populate(e,t,n,r){this.features=[],this.hasPattern=Ud("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=Cu(n),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:i,id:o,index:a,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Fu(i,e);if(!this.layers[0]._featureFilter.filter(new js(this.zoom),l,n))continue;const c={id:o,sourceLayerIndex:s,index:a,geometry:e?l.geometry:Bu(i,n,r),properties:i.properties,type:i.type,patterns:{}},u=this.layoutVertexArray.length;this.hasPattern?this.features.push(Gd("fill-extrusion",this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,a,n,{},t.availableImages,r,t.brightness),t.featureIndex.insert(i,c.geometry,a,s,this.index,u)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,n,r,i,o){for(const a of this.features){const{geometry:e}=a;this.addFeature(a,e,a.index,t,n,r,i,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,n,r,i){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const a=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,t,a,n,r,i),this.groundEffect.update(e,t,a,n,r,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Jd),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Kd.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Qd.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,n,r,i,o,a,s){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,c=[new jt(0,0),new jt(io,io)],u=a.projection,h="globe"===u.name,d="Polygon"===Of[e.type],f=new Zf;f.centroidDataIndex=this.centroidData.length;const p=new Hf,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},r)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},r);p.height=g,p.vertexArrayOffset=this.layoutVertexArray.length,p.groundVertexArrayOffset=this.groundEffect.vertexArray.length,h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new zl);const _=jd(t,500);for(let S=_.length-1;S>=0;S--){const e=_[S];(0===e.length||(y=e[0]).every((e=>e.x<=0))||y.every((e=>e.x>=io))||y.every((e=>e.y<=0))||y.every((e=>e.y>=io)))&&_.splice(S,1)}var y;let v;if(h)v=sp(_,c,r);else{v=[];for(const e of _)v.push({polygon:e,bounds:c})}const x=d?this.edgeRadius:0,b=x>0&&this.zoom<17,w=(e,t)=>{if(0===e.length)return!1;const n=e[e.length-1];return t.x===n.x&&t.y===n.y};for(const{polygon:S,bounds:M}of v){let e=0,t=0;for(const r of S)d&&!r[0].equals(r[r.length-1])&&r.push(r[0]),t+=d?r.length-1:r.length;const n=this.segments.prepareSegment((d?5:4)*t,this.layoutVertexArray,this.indexArray);p.footprintSegIdx<0&&(p.footprintSegIdx=this.footprintSegments.length),p.polygonSegIdx<0&&(p.polygonSegIdx=this.polygonSegments.length);const i={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},o=new Wf;if(o.vertexOffset=this.footprintVertices.length,o.indexOffset=3*this.footprintIndices.length,o.ringIndices=[],d){const t=[],i=[];e=n.vertexLength;for(let e=0;e4&&ip(t[t.length-2],t[0],t[1]),o=x?ep(t[t.length-2],t[0],t[1],x):0;const s=[];let c,g,_;g=t[1].sub(t[0])._perp()._unit();let y=!0;for(let a=1,l=0;a0?1:0,T=d.dist(v);if(l+T>32768&&(l=0),x){_=b.sub(v)._perp()._unit();let e=tp(d,v,b,$f(g,_),x);isNaN(e)&&(e=0);const t=v.sub(d)._unit();d=d.add(t.mult(o))._round(),v=v.add(t.mult(-e))._round(),o=e,g=_,m&&this.zoom>=17&&(w(s,d)||s.push(d),w(s,v)||s.push(v))}const C=n.vertexLength,k=t.length>4&&ip(d,v,b);let I=op(l,i,y);if(Uf(this.layoutVertexArray,d.x,d.y,A,E,0,0,I),Uf(this.layoutVertexArray,d.x,d.y,A,E,0,1,I),l+=T,I=op(l,k,!y),i=k,Uf(this.layoutVertexArray,v.x,v.y,A,E,0,0,I),Uf(this.layoutVertexArray,v.x,v.y,A,E,0,1,I),n.vertexLength+=4,this.indexArray.emplaceBack(C+0,C+1,C+2),this.indexArray.emplaceBack(C+1,C+3,C+2),n.primitiveLength+=2,x){const r=e+(1===a?t.length-2:a-2),i=1===a?e:r+1;if(this.indexArray.emplaceBack(C+1,r,C+3),this.indexArray.emplaceBack(r,i,C+3),n.primitiveLength+=2,void 0===c&&(c=C),!np(b,t[a],M)){const e=a===t.length-1?c:n.vertexLength;this.indexArray.emplaceBack(C+2,C+3,e),this.indexArray.emplaceBack(C+3,e+1,e),this.indexArray.emplaceBack(C+3,i,e+1),n.primitiveLength+=3}y=!y}if(h){const e=this.layoutVertexExtArray,t=u.projectTilePoint(d.x,d.y,r),n=u.projectTilePoint(v.x,v.y,r),i=u.upVector(r,d.x,d.y),o=u.upVector(r,v.x,v.y);qf(e,t,i),qf(e,t,i),qf(e,n,o),qf(e,n,o)}}d&&(e+=t.length-1),m&&x&&this.zoom>=17&&(0!==s.length&&w(s,s[0])&&s.pop(),this.groundEffect.addData(s,M,l,x>0))}this.footprintSegments.push(o),i.triangleCount=this.indexArray.length-i.triangleArrayOffset,this.polygonSegments.push(i),++p.footprintSegLen,++p.polygonSegLen}if(p.vertexCount=this.layoutVertexArray.length-p.vertexArrayOffset,p.groundVertexCount=this.groundEffect.vertexArray.length-p.groundVertexArrayOffset,0!==p.vertexCount){if(p.centroidXY=f.borders?jf:this.encodeCentroid(f,p),this.centroidData.push(p),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[n].borders[e][0]))}splitToSubtiles(){const e=[];for(let a=0;aio),r=2*n+(+(t.min.x+t.max.x>io)^n);for(let i=0;ie.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx));let n=0,r=0,i=0;for(const a of e){if(a.triangleSegmentIdx!==n)break;i++}const o=e.length;for(;r!==e.length;){n=e[r].triangleSegmentIdx;let a=0,s=r,l=r;for(let t=s;t0&&this.triangleSubSegments.push({segment:u,min:o,max:c}),s=l;for(let t=s;t[e[0]*(1-n[0])+t[0]*n[0],e[1]*(1-n[1])+t[1]*n[1]],d=[],f=[];for(const p of this.triangleSubSegments){d[0]=p.min.x/io,d[1]=p.min.y/io,f[0]=p.max.x/io,f[1]=p.max.y/io;const e=h(l,c,d),t=h(l,c,f);if(0===new mh([e[0],e[1],r],[t[0],t[1],i]).intersectsPrecise(n)){s&&(u.segments.push(s),s=void 0);continue}const o=p.segment;s&&s.vertexOffset!==o.vertexOffset&&(u.segments.push(s),s=void 0),s?(s.vertexLength+=o.vertexLength,s.primitiveLength+=o.primitiveLength):s={vertexOffset:o.vertexOffset,primitiveLength:o.primitiveLength,vertexLength:o.vertexLength,primitiveOffset:o.primitiveOffset,sortKey:void 0,vaos:{}}}return s&&u.segments.push(s),u}encodeCentroid(e,t){const n=e.centroid(),r=t.span(),i=Math.min(7,Math.round(r.x*this.tileToMeter/10)),o=Math.min(7,Math.round(r.y*this.tileToMeter/10));return new jt(Qt(n.x,1,io-1)<<3|i,Qt(n.y,1,io-1)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new jt(0,0);const t=e.borders,n=Number.MAX_VALUE;if(t[0][0]!==n||t[1][0]!==n){const e=t[0][0]!==n?0:1;return new jt(6|(t[0][0]!==n?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==n?2:3;return new jt((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==n?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=Vf,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,n=e.vertexCount+e.vertexArrayOffset,r=e.flags&Vf?jf:e.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==r.y||i!==r.x){for(let e=t;en.max.x||n.min.x>i.max.x||i.min.y>n.max.y||n.min.y>i.max.y))for(let o=0;ot!=l>t&&e<(this.footprintVertices.int16[2*(s+o.vertexOffset)+0]-n)*(t-a)/(l-a)+n&&(r=!r)}a=n}}return r}getHeightAtTileCoord(e,t){let n=Number.NEGATIVE_INFINITY,r=!0;const i=4*(e+io)*io+(t+io);if(this.partLookup.hasOwnProperty(i)){const e=this.partLookup[i];return e?{height:e.height,hidden:!!(e.flags&Vf)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||this.footprintContainsPoint(e,t,o)&&o&&o.height>n&&(n=o.height,this.partLookup[i]=o,r=!!(o.flags&Vf));if(n!==Number.NEGATIVE_INFINITY)return{height:n,hidden:r};this.partLookup[i]=void 0}}function $f(e,t){const n=e.add(t)._unit();return e.x*n.x+e.y*n.y}function ep(e,t,n,r){const i=t.sub(e)._perp()._unit(),o=n.sub(t)._perp()._unit();return tp(e,t,n,$f(i,o),r)}function tp(e,t,n,r,i){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(n)/3,i*o/r)}function np(e,t,n){return e.xn[1].x&&t.x>n[1].x||e.yn[1].y&&t.y>n[1].y}function rp(e,t){return e.xt[1].x||e.yt[1].y}function ip(e,t,n){if(e.x<0||e.x>=io||t.x<0||t.x>=io||n.x<0||n.x>=io)return!1;const r=n.sub(t),i=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&i.x*o.x+i.y*o.y<0}function op(e,t,n){const r=t?2|e:-3&e;return n?1|r:-2&r}function ap(){const e=Math.PI/32,t=Math.tan(e),n=iu;return n*Math.sqrt(1+2*t*t)-n}function sp(e,t,n){const r=1<4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5?arguments[5]:void 0;const a=[];if(!e.length||!n||!r)return a;const s=(e,t)=>{for(const n of e)a.push({polygon:n,bounds:t})},l=Math.ceil(Math.log2(n)),c=Math.ceil(Math.log2(r)),u=l-c,h=[];for(let p=0;p0?0:1);for(let p=0;pt+1?f.push({polygons:d,bounds:e,depth:t+1}):s(d,e)}if(p.length){const e=[new jt(0===n?u:r.x,1===n?u:r.y),a];h.length>t+1?f.push({polygons:p,bounds:e,depth:t+1}):s(p,e)}}return a}(e,t,Math.ceil((o-i)/11.25),Math.ceil((a-s)/11.25),1,((e,t,i)=>{if(0===e)return.5*(t+i);{const e=wu((n.y+t/io)/r);return(vu(.5*(wu((n.y+i/io)/r)+e))*r-n.y)*io}}))}function lp(e,t,n,r,i,o){const a=Math.pow(2,r.z-i.z);for(let s=0;s1&&(a=e[++o]);const l=Math.abs(s-a.left),c=Math.abs(s-a.right),u=Math.min(l,c);let h;const d=i/n*(r+1);if(a.isDash){const e=r-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=r-Math.sqrt(u*u+d*d);this.image.data[t+s]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let s=e.length-1;s>=0;--s){const t=e[s],n=e[s+1];t.zeroLength?e.splice(s,1):n&&n.isDash===t.isDash&&(n.left=t.left,e.splice(s,1))}const n=e[0],r=e[e.length-1];n.isDash===r.isDash&&(n.left=r.left-this.width,r.right=n.right+this.width);const i=this.width*this.nextRow;let o=0,a=e[o];for(let s=0;s1&&(a=e[++o]);const n=Math.abs(s-a.left),r=Math.abs(s-a.right),l=Math.min(n,r);this.image.data[i+s]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128))}}addDash(e,t){const n=this.getKey(e,t);if(this.positions[n])return this.positions[n];const r="round"===t,i=r?7:0,o=2*i+1;if(this.nextRow+o>this.height)return dn("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let c=0;ce.fqid)),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 kl,this.layoutVertexArray2=new Il,this.patternVertexArray=new Pl,this.indexArray=new Gl,this.programConfigurations=new Uc(e.layers,e.zoom),this.segments=new mc,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id))}populate(e,t,n,r){this.hasPattern=Ud("line",this.layers,t);const i=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:c,id:u,index:h,sourceLayerIndex:d}of e){const e=this.layers[0]._featureFilter.needGeometry,t=Fu(c,e);if(!this.layers[0]._featureFilter.filter(new js(this.zoom),t,n))continue;const a=i?i.evaluate(t,{},n):void 0,s={id:u,properties:c.properties,type:c.type,sourceLayerIndex:d,index:h,geometry:e?t.geometry:Bu(c,n,r),patterns:{},sortKey:a};o.push(s)}i&&o.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:a,featureIndex:s}=t,l=this.addConstantDashes(a);for(const c of o){const{geometry:r,index:i,sourceLayerIndex:o}=c;if(l&&this.addFeatureDashes(c,a),this.hasPattern){const e=Gd("line",this.layers,c,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(c,r,i,n,a.positions,t.availableImages,t.brightness);s.insert(e[i].feature,r,i,o,this.index)}}addConstantDashes(e){let t=!1;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,i=n.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==i.kind)t=!0;else{const t=i.value,n=r.value;if(!n)continue;e.addDash(n,t)}}return t}addFeatureDashes(e,t){const n=this.zoom;for(const r of this.layers){const i=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===o.kind)continue;let a,s;if("constant"===i.kind){if(a=i.value,!a)continue}else a=i.evaluate({zoom:n},e);s="constant"===o.kind?o.value:o.evaluate({zoom:n},e),t.addDash(a,s),e.patterns[r.id]=t.getKey(a,s)}}update(e,t,n,r,i){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,n,r,i)}addFeatures(e,t,n,r,i,o){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,t,n,r,o)}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,yp)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,xp)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gp),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,n,r,i,o,a){const s=this.layers[0].layout,l=s.get("line-join").evaluate(e,{}),c=s.get("line-cap").evaluate(e,{}),u=s.get("line-miter-limit"),h=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const d of t)this.addLine(d,e,l,c,u,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r,a)}addLine(e,t,n,r,i,o){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0;const a="none"===n;if(this.patternJoinNone=this.hasPattern&&a,this.segmentStart=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[l-1].equals(e[l-2]);)l--;let c=0;for(;c0;if(M&&_>c){const e=d.dist(f);if(e>2*u){const t=d.sub(d.sub(f)._mult(u/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,m,0,0,h),f=t}}if(t&&"round"===y&&(wi&&(y="bevel"),"bevel"===y&&(w>2&&(y="flipbevel"),w100)x=g.mult(-1);else{const e=w*m.add(g).mag()/m.sub(g).mag();x._perp()._mult(e*(A?-1:1))}this.addCurrentVertex(d,x,0,0,h),this.addCurrentVertex(d,x.mult(-1),0,0,h)}else if("bevel"===y||"fakeround"===y){const e=-Math.sqrt(w*w-1),t=A?e:0,n=A?0:e;if(f&&this.addCurrentVertex(d,m,t,n,h),"fakeround"===y){const e=Math.round(180*S/Math.PI/20);for(let t=1;t2*u){const t=d.add(p.sub(d)._mult(u/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,g,0,0,h),d=t}}}}addCurrentVertex(e,t,n,r,i){let o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];const a=t.y*r-t.x,s=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*n,t.y-t.x*n,o,!1,n,i),this.addHalfVertex(e,a,s,o,!0,-r,i),this.patternJoinNone&&this.segmentPoints.push(this.lineSoFar-this.segmentStart,n)}addHalfVertex(e,t,n,r,i,o,a){let{x:s,y:l}=e;this.layoutVertexArray.emplaceBack((s<<1)+(r?1:0),(l<<1)+(i?1:0),Math.round(63*t)+128,Math.round(63*n)+128,1+(0===o?0:o<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),i?this.e2=c:this.e1=c}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()}}ps(Ap,"LineBucket",{omit:["layers","patternFeatures"]});const Ep=new Js({"line-cap":new Xs(tl.layout_line["line-cap"]),"line-join":new Xs(tl.layout_line["line-join"]),"line-miter-limit":new Qs(tl.layout_line["line-miter-limit"]),"line-round-limit":new Qs(tl.layout_line["line-round-limit"]),"line-sort-key":new Xs(tl.layout_line["line-sort-key"]),visibility:new Qs(tl.layout_line.visibility)});var Tp={paint:new Js({"line-opacity":new Xs(tl.paint_line["line-opacity"]),"line-color":new Xs(tl.paint_line["line-color"]),"line-translate":new Qs(tl.paint_line["line-translate"]),"line-translate-anchor":new Qs(tl.paint_line["line-translate-anchor"]),"line-width":new Xs(tl.paint_line["line-width"]),"line-gap-width":new Xs(tl.paint_line["line-gap-width"]),"line-offset":new Xs(tl.paint_line["line-offset"]),"line-blur":new Xs(tl.paint_line["line-blur"]),"line-dasharray":new Xs(tl.paint_line["line-dasharray"]),"line-pattern":new Xs(tl.paint_line["line-pattern"]),"line-gradient":new Ks(tl.paint_line["line-gradient"]),"line-trim-offset":new Qs(tl.paint_line["line-trim-offset"]),"line-emissive-strength":new Qs(tl.paint_line["line-emissive-strength"]),"line-border-width":new Xs(tl.paint_line["line-border-width"]),"line-border-color":new Xs(tl.paint_line["line-border-color"])}),layout:Ep};function Cp(e,t,n){return t*(io/(e.tileSize*Math.pow(2,n-e.tileID.overscaledZ)))}function kp(e,t){return 1/Cp(e,1,t.tileZoom)}function Ip(e,t,n,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Pp=e=>{const t=[];Rp(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const n=e.paint.get("line-trim-offset");0===n[0]&&0===n[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const r="none"===e.layout.get("line-join").constantOr("miter"),i=!!e.paint.get("line-pattern").constantOr(1);return r&&i&&t.push("LINE_JOIN_NONE"),t};function Rp(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const Lp=new class extends Xs{possiblyEvaluate(e,t){return t=new js(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,r){return t=$t({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,n,r)}}(Tp.paint.properties["line-width"].specification);function zp(e,t){return t>0?t+2*e:e}Lp.useIntegerZoom=!0;const Op=Sl([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Dp=Sl([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Bp=Sl([{name:"a_projected_pos",components:4,type:"Float32"}],4);Sl([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Fp=Sl([{name:"a_z_offset",components:1,type:"Float32"}],4),Np=Sl([{name:"a_texb",components:2,type:"Uint16"}]),jp=Sl([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Vp=Sl([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_z_offset",components:1,type:"Float32"}]);Sl([{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 Up=Sl([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Gp=Sl([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Sl([{name:"triangle",components:3,type:"Uint16"}]),Sl([{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"}]),Sl([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),Sl([{type:"Float32",name:"offsetX"}]),Sl([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var qp=24;const Wp=128;function Hp(e,t){const{expression:n}=t;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new js(e+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=n;let i=0;for(;i{e.text=function(e,t,n){const r=t.layout.get("text-transform").evaluate(n,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Ns.applyArabicShaping&&(e=Ns.applyArabicShaping(e)),e}(e.text,t,n)})),e}const Kp={"!":"\ufe15","#":"\uff03",$:"\uff04","%":"\uff05","&":"\uff06","(":"\ufe35",")":"\ufe36","*":"\uff0a","+":"\uff0b",",":"\ufe10","-":"\ufe32",".":"\u30fb","/":"\uff0f",":":"\ufe13",";":"\ufe14","<":"\ufe3f","=":"\uff1d",">":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42","\u2190":"\u2191","\u2192":"\u2193"};function Jp(e){return"\ufe36"===e||"\ufe48"===e||"\ufe38"===e||"\ufe44"===e||"\ufe42"===e||"\ufe3e"===e||"\ufe3c"===e||"\ufe3a"===e||"\ufe18"===e||"\ufe40"===e||"\ufe10"===e||"\ufe13"===e||"\ufe14"===e||"\uff40"===e||"\uffe3"===e||"\ufe11"===e||"\ufe12"===e}function $p(e){return"\ufe35"===e||"\ufe47"===e||"\ufe37"===e||"\ufe43"===e||"\ufe41"===e||"\ufe3d"===e||"\ufe3b"===e||"\ufe39"===e||"\ufe17"===e||"\ufe3f"===e}var em={read:function(e,t,n,r,i){var o,a,s=8*i-r-1,l=(1<>1,u=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-u)-1,f>>=-u,u+=s;u>0;o=256*o+e[t+h],h+=d,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=r;u>0;a=256*a+e[t+h],h+=d,u-=8);if(0===o)o=1-c;else{if(o===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,r),o-=c}return(f?-1:1)*a*Math.pow(2,o-r)},write:function(e,t,n,r,i,o){var a,s,l,c=8*o-i-1,u=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=u?(s=0,a=u):a+h>=1?(s=(t*l-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[n+f]=255&s,f+=p,s/=256,i-=8);for(a=a<0;e[n+f]=255&a,f+=p,a/=256,c-=8);e[n+f-p]|=128*m}},tm=rm,nm=em;function rm(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}rm.Varint=0,rm.Fixed64=1,rm.Bytes=2,rm.Fixed32=5;var im=4294967296,om=1/im,am="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function sm(e){return e.type===rm.Bytes?e.readVarint()+e.pos:e.pos+1}function lm(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function cm(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function um(e,t){for(var n=0;n>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function bm(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}rm.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos>3,o=this.pos;this.type=7&r,e(i,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=vm(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=bm(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=vm(this.buf,this.pos)+vm(this.buf,this.pos+4)*im;return this.pos+=8,e},readSFixed64:function(){var e=vm(this.buf,this.pos)+bm(this.buf,this.pos+4)*im;return this.pos+=8,e},readFloat:function(){var e=nm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=nm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,n,r=this.buf;return t=127&(n=r[this.pos++]),n<128?t:(t|=(127&(n=r[this.pos++]))<<7,n<128?t:(t|=(127&(n=r[this.pos++]))<<14,n<128?t:(t|=(127&(n=r[this.pos++]))<<21,n<128?t:function(e,t,n){var r,i,o=n.buf;if(r=(112&(i=o[n.pos++]))>>4,i<128)return lm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return lm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return lm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return lm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return lm(e,r,t);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return lm(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(n=r[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&&am?function(e,t,n){return am.decode(e.subarray(t,n))}(this.buf,t,e):function(e,t,n){for(var r="",i=t;i239?4:l>223?3:l>191?2:1;if(i+u>n)break;1===u?l<128&&(c=l):2===u?128==(192&(o=e[i+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(a=e[i+2],128==(192&(o=e[i+1]))&&128==(192&a)&&((c=(15&l)<<12|(63&o)<<6|63&a)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(a=e[i+2],s=e[i+3],128==(192&(o=e[i+1]))&&128==(192&a)&&128==(192&s)&&((c=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),i+=u}return r}(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!==rm.Bytes)return e.push(this.readVarint(t));var n=sm(this);for(e=e||[];this.pos127;);else if(t===rm.Bytes)this.pos=this.readVarint()+this.pos;else if(t===rm.Fixed32)this.pos+=4;else{if(t!==rm.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;t268435455||e<0?function(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,n.buf[n.pos]=127&(e>>>=7)}(n,0,t),function(e,t){var n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint: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,n){for(var r,i,o=0;o55295&&r<57344){if(!i){r>56319||o+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&cm(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),nm.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),nm.write(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 n=0;n=128&&cm(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,rm.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,um,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,hm,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,pm,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,dm,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,fm,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,mm,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,gm,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,_m,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,ym,t)},writeBytesField:function(e,t){this.writeTag(e,rm.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,rm.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,rm.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,rm.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,rm.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,rm.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,rm.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,rm.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,rm.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,rm.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};var wm=h(tm);const Sm=3;function Mm(e,t,n){t.glyphs=[],1===e&&n.readMessage(Am,t)}function Am(e,t,n){if(3===e){const{id:e,bitmap:r,width:i,height:o,left:a,top:s,advance:l}=n.readMessage(Em,{});t.glyphs.push({id:e,bitmap:new nd({width:i+2*Sm,height:o+2*Sm},r),metrics:{width:i,height:o,left:a,top:s,advance:l}})}else 4===e?t.ascender=n.readSVarint():5===e&&(t.descender=n.readSVarint())}function Em(e,t,n){1===e?t.id=n.readVarint():2===e?t.bitmap=n.readBytes():3===e?t.width=n.readVarint():4===e?t.height=n.readVarint():5===e?t.left=n.readSVarint():6===e?t.top=n.readSVarint():7===e&&(t.advance=n.readVarint())}const Tm=Sm,Cm={horizontal:1,vertical:2,horizontalOnly:3};class km{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const n=new km;return n.scale=e||1,n.fontStack=t,n}static forImage(e){const t=new km;return t.imageName=e,t}}class Im{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const n=new Im;for(let r=0;r=0&&n>=e&&Rm[this.text.charCodeAt(n)];n--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const n=new Im;return n.text=this.text.substring(e,t),n.sectionIndex=this.sectionIndex.slice(e,t),n.sections=this.sections,n}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(km.forText(e.scale,e.fontStack||t));const n=this.sections.length-1;for(let r=0;r=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Pm(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p){const m=Im.fromFeature(e,i);h===Cm.vertical&&m.verticalizePunctuation(d);let g=[];const _=function(e,t,n,r,i,o){if(!e)return[];const a=[],s=function(e,t,n,r,i,o){let a=0;for(let s=0;s=0;let c=0;for(let h=0;h0&&o>x&&(x=o)}else{const e=n[a.fontStack];if(!e)continue;e[p]&&(M=e[p]);const r=t[a.fontStack];if(!r)continue;const o=r.glyphs[p];if(!o)continue;if(_=o.metrics,E=8203!==p?qp:0,g){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,n=(e+t)*m;b-n/2;){if(a--,a<0)return!1;s-=e[a].dist(o),o=e[a]}s+=e[a].dist(e[a+1]),a++;const l=[];let c=0;for(;sr;)c-=l.shift().angleDelta;if(c>i)return!1;a++,s+=t.dist(n)}return!0}function Wm(e){let t=0;for(let n=0;nc){const o=(c-l)/i,h=Gr(n.x,r.x,o),d=Gr(n.y,r.y,o),f=new Gm(h,d,0,r.angleTo(n),u);return!a||qm(e,f,s,a,t)?f:void 0}l+=i}}function Qm(e,t,n,r,i,o,a,s,l){const c=Hm(r,o,a),u=Zm(r,i),h=u*a,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&y=0&&d+c<=u){const t=new Gm(_,y,0,m,p);r&&!qm(e,t,o,r,i)||f.push(t)}}h+=s}return s||f.length||a||(f=Xm(e,h/2,n,r,i,o,a,!0,l)),f}function Km(e,t,n,r,i){const o=[];for(let a=0;a=r&&c.x>=r||(a.x>=r?a=new jt(r,a.y+(r-a.x)/(c.x-a.x)*(c.y-a.y))._round():c.x>=r&&(c=new jt(r,a.y+(r-a.x)/(c.x-a.x)*(c.y-a.y))._round()),a.y>=i&&c.y>=i||(a.y>=i?a=new jt(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round():c.y>=i&&(c=new jt(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i)._round()),l&&a.equals(l[l.length-1])||(l=[a],o.push(l)),l.push(c)))))}}return o}function Jm(e){let t=0,n=0;for(const a of e)t+=a.w*a.h,n=Math.max(n,a.w);e.sort(((e,t)=>t.h-e.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}];let i=0,o=0;for(const a of e)for(let e=r.length-1;e>=0;e--){const t=r[e];if(!(a.w>t.w||a.h>t.h)){if(a.x=t.x,a.y=t.y,o=Math.max(o,a.y+a.h),i=Math.max(i,a.x+a.w),a.w===t.w&&a.h===t.h){const t=r.pop();ee.hasImage(t,n))),e.dispatchRenderCallbacks(this.haveRenderCallbacks,n);for(const r in e.getUpdatedImages(n))this.patchUpdatedImage(this.iconPositions[r],e.getImage(r,n),t),this.patchUpdatedImage(this.patternPositions[r],e.getImage(r,n),t)}patchUpdatedImage(e,t,n){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,i]=e.tl,o=!!Object.keys(this.patternPositions).length;n.update(t.data,{useMipmap:o},{x:r,y:i})}}ps(eg,"ImagePosition"),ps(tg,"ImageAtlas");const ng=1e20;function rg(e,t,n,r,i,o,a,s,l){for(let c=t;c-1);l++,o[l]=s,a[l]=c,a[l+1]=ng}for(let s=0,l=0;s{let{stack:n,id:r}=e,i=this.entries[n];i||(i=this.entries[n]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let a=i.glyphs[r];if(void 0!==a)return void t(null,{stack:n,id:r,glyph:a});if(a=this._tinySDF(i,n,r),a)return i.glyphs[r]=a,void t(null,{stack:n,id:r,glyph:a});const s=Math.floor(r/256);if(256*s>65535)return void t(new Error("glyphs > 65535 not supported"));if(i.ranges[s])return void t(null,{stack:n,id:r,glyph:a});let l=i.requests[s];l||(l=i.requests[s]=[],sg.loadGlyphRange(n,s,o,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[s]=!0}for(const n of l)n(e,t);delete i.requests[s]}))),l.push(((e,i)=>{e?t(e):i&&t(null,{stack:n,id:r,glyph:i.glyphs[r]||null})}))}),((e,t)=>{if(e)n(e);else if(t){const e={};for(const{stack:n,id:r,glyph:i}of t)void 0===e[n]&&(e[n]={}),void 0===e[n].glyphs&&(e[n].glyphs={}),e[n].glyphs[r]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[n].ascender=this.entries[n].ascender,e[n].descender=this.entries[n].descender;n(null,e)}}))}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==ag.none&&(this.localGlyphMode===ag.all?!!this.localFontFamily:!!this.localFontFamily&&(vs["CJK Unified Ideographs"](e)||vs["Hangul Syllables"](e)||vs.Hiragana(e)||vs.Katakana(e)||vs["CJK Symbols and Punctuation"](e)||vs["CJK Unified Ideographs Extension A"](e)||vs["CJK Unified Ideographs Extension B"](e)))}_tinySDF(e,t,n){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(n))return;let i=e.tinySDF;if(!i){let n="400";/bold/i.test(t)?n="900":/medium/i.test(t)?n="500":/light/i.test(t)&&(n="200"),i=e.tinySDF=new sg.TinySDF({fontFamily:r,fontWeight:n,fontSize:24*og,buffer:3*og,radius:8*og}),i.fontWeight=n}if(this.localGlyphs[i.fontWeight][n])return this.localGlyphs[i.fontWeight][n];const o=String.fromCodePoint(n),{data:a,width:s,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:d,glyphAdvance:f}=i.draw(o);return this.localGlyphs[i.fontWeight][n]={id:n,bitmap:new nd({width:s,height:l},a),metrics:{width:c/og,height:u/og,left:h/og,top:d/og-27,advance:f/og,localGlyph:!0}}}}sg.loadGlyphRange=function(e,t,n,r,i){const o=256*t,a=o+255,s=r.transformRequest(r.normalizeGlyphsURL(n).replace("{fontstack}",e).replace("{range}","".concat(o,"-").concat(a)),Xn.Glyphs);er(s,((e,t)=>{if(e)i(e);else if(t){const e={},n=function(e){return new wm(e).readFields(Mm,{})}(t);for(const t of n.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:n.ascender,descender:n.descender})}}))},sg.TinySDF=class{constructor(){let{fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.buffer=t,this.cutoff=r,this.radius=n;const s=this.size=e+4*t,l=this._createCanvas(s),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font="".concat(a," ").concat(o," ").concat(e,"px ").concat(i),c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(n),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),c=s+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),f={data:d,width:c,height:u,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===l)return f;const{ctx:p,buffer:m,gridInner:g,gridOuter:_}=this;p.clearRect(m,m,s,l),p.fillText(e,m,m+a);const y=p.getImageData(m,m,s,l);_.fill(ng,0,h),g.fill(0,0,h);for(let v=0;v0?e*e:0,g[n]=e<0?e*e:0}}rg(_,0,0,c,u,c,this.f,this.v,this.z),rg(g,m,m,s,l,c,this.f,this.v,this.z);for(let v=0;ve+t[1]-t[0],p=h.reduce(f,0),m=d.reduce(f,0),g=s-p,_=l-m;let y=0,v=p,x=0,b=m,w=0,S=g,M=0,A=_;if(o.content&&r){const e=o.content;y=ug(h,0,e[0]),x=ug(d,0,e[1]),v=ug(h,e[0],e[2]),b=ug(d,e[1],e[3]),w=e[0]-y,M=e[1]-x,S=e[2]-e[0]-v,A=e[3]-e[1]-b}const E=(r,i,s,l)=>{const h=dg(r.stretch-y,v,c,e.left),d=fg(r.fixed-w,S,r.stretch,p),f=dg(i.stretch-x,b,u,e.top),g=fg(i.fixed-M,A,i.stretch,m),_=dg(s.stretch-y,v,c,e.left),E=fg(s.fixed-w,S,s.stretch,p),T=dg(l.stretch-x,b,u,e.top),C=fg(l.fixed-M,A,l.stretch,m),k=new jt(h,f),I=new jt(_,f),P=new jt(_,T),R=new jt(h,T),L=new jt(d/a,g/a),z=new jt(E/a,C/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),n=[t,-e,e,t];k._matMult(n),I._matMult(n),R._matMult(n),P._matMult(n)}const D=r.stretch+r.fixed,B=s.stretch+s.fixed,F=i.stretch+i.fixed,N=l.stretch+l.fixed,j=e.imageSecondary;return{tl:k,tr:I,bl:R,br:P,texPrimary:{x:o.paddedRect.x+lg+D,y:o.paddedRect.y+lg+F,w:B-D,h:N-F},texSecondary:j?{x:j.paddedRect.x+lg+D,y:j.paddedRect.y+lg+F,w:B-D,h:N-F}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:z,minFontScaleX:S/a/c,minFontScaleY:A/a/u,isSDF:n}};if(r&&(o.stretchX||o.stretchY)){const e=hg(h,g,p),t=hg(d,_,m);for(let n=0;n1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=1/0,i=1/0,o=-1/0,a=-1/0;const s=e[0];for(let f=0;fo)&&(o=e.x),(!f||e.y>a)&&(a=e.y)}const l=Math.min(o-r,a-i);let c=l/2;const u=new ro([],gg);if(0===l)return new jt(r,i);for(let f=r;fh.d||!h.d)&&(h=r,n&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-h.d<=t||(c=r.h/2,u.push(new _g(r.p.x-c,r.p.y-c,c,e)),u.push(new _g(r.p.x+c,r.p.y-c,c,e)),u.push(new _g(r.p.x-c,r.p.y+c,c,e)),u.push(new _g(r.p.x+c,r.p.y+c,c,e)),d+=4)}return n&&(console.log("num probes: ".concat(d)),console.log("best distance: ".concat(h.d))),h.p}function gg(e,t){return t.max-e.max}class _g{constructor(e,t,n,r){this.p=new jt(e,t),this.h=n,this.d=function(e,t){let n=!1,r=1/0;for(let i=0;ie.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n),r=Math.min(r,Qu(e,i,s))}}return(n?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}}const yg=Number.POSITIVE_INFINITY,vg=Math.sqrt(2);function xg(e,t){let[n,r]=t,i=0,o=0;if(r===yg){n<0&&(n=0);const t=n/vg;switch(e){case"top-right":case"top-left":o=t-7;break;case"bottom-right":case"bottom-left":o=7-t;break;case"bottom":o=7-n;break;case"top":o=n-7}switch(e){case"top-right":case"bottom-right":i=-t;break;case"top-left":case"bottom-left":i=t;break;case"left":i=n;break;case"right":i=-n}}else{switch(n=Math.abs(n),r=Math.abs(r),e){case"top-right":case"top-left":case"top":o=r-7;break;case"bottom-right":case"bottom-left":case"bottom":o=7-r}switch(e){case"top-right":case"bottom-right":case"right":i=-n;break;case"top-left":case"bottom-left":case"left":i=n}}return[i,o]}function bg(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 wg(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p){let m=o.textMaxSize.evaluate(t,{},h);void 0===m&&(m=a);const g=e.layers[0].layout,_=g.get("icon-offset").evaluate(t,{},h),y=Eg(n.horizontal)||n.vertical,v="globe"===d.name,x=qp,b=a/x,w=e.tilePixelRatio*m/x,S=(P=e.overscaling,e.zoom>18&&P>2&&(P>>=1),Math.max(io/(512*P),1)*g.get("symbol-spacing")),M=g.get("text-padding")*e.tilePixelRatio,A=g.get("icon-padding")*e.tilePixelRatio,E=Gt(g.get("text-max-angle")),T="map"===g.get("text-rotation-alignment")&&"point"!==g.get("symbol-placement"),C="map"===g.get("icon-rotation-alignment")&&"point"!==g.get("symbol-placement"),k=g.get("symbol-placement"),I=S/2;var P;const R=g.get("icon-text-fit").evaluate(t,{},h),L=g.get("icon-text-fit-padding").evaluate(t,{},h),z="none"!==R;let O;!1===e.hasAnyIconTextFit&&z&&(e.hasAnyIconTextFit=!0),r&&z&&(e.allowVerticalPlacement&&n.vertical&&(O=Um(r,n.vertical,R,L,_,b)),y&&(r=Um(r,y,R,L,_,b)));const D=(a,s,m)=>{if(s.x<0||s.x>=io||s.y<0||s.y>=io)return;let g=null;if(v){const{x:e,y:t,z:n}=d.projectTilePoint(s.x,s.y,m);g={anchor:new Gm(e,t,n,0,void 0),up:d.upVector(m,s.x,s.y)}}!function(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y,v,x,b,w,S,M,A,E){const T=e.addToLineVertexArray(t,r);let C,k,I,P,R,L,z,O=0,D=0,B=0,F=0,N=-1,j=-1;const V={};let U=Pr("");const G=n?n.anchor:t,q="none"!==l.layout.get("icon-text-fit").evaluate(x,{},M);let W=0,H=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[W,H]=l.layout.get("text-offset").evaluate(x,{},M).map((e=>e*qp)):(W=l.layout.get("text-radial-offset").evaluate(x,{},M)*qp,H=yg),e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(p)L=Cg(e),s&&(z=Cg(s));else{const n=l.layout.get("text-rotate").evaluate(x,{},M)+90;I=Tg(c,G,t,u,h,d,e,f,n,m),s&&(P=Tg(c,G,t,u,h,d,s,_,n))}}if(o){const r=l.layout.get("icon-rotate").evaluate(x,{},M),i=cg(o,r,w,q),a=s?cg(s,r,w,q):void 0;k=Tg(c,G,t,u,h,d,o,_,r),O=4*i.length;const f=e.iconSizeData;let p=null;"source"===f.kind?(p=[Wp*l.layout.get("icon-size").evaluate(x,{},M)],p[0]>Mg&&dn("".concat(e.layerIds[0],': Value for "icon-size" is >= ').concat(Sg,'. Reduce your "icon-size".'))):"composite"===f.kind&&(p=[Wp*b.compositeIconSizes[0].evaluate(x,{},M),Wp*b.compositeIconSizes[1].evaluate(x,{},M)],(p[0]>Mg||p[1]>Mg)&&dn("".concat(e.layerIds[0],': Value for "icon-size" is >= ').concat(Sg,'. Reduce your "icon-size".'))),e.addSymbols(e.icon,i,p,v,y,x,!1,n,t,T.lineStartIndex,T.lineLength,-1,S,M,A,E),N=e.icon.placedSymbolArray.length-1,a&&(D=4*a.length,e.addSymbols(e.icon,a,p,v,y,x,Cm.vertical,n,t,T.lineStartIndex,T.lineLength,-1,S,M,A,E),j=e.icon.placedSymbolArray.length-1)}for(const X in i.horizontal){const r=i.horizontal[X];C||(U=Pr(r.text),p?R=Cg(r):C=Tg(c,G,t,u,h,d,r,f,l.layout.get("text-rotate").evaluate(x,{},M),m));const o=1===r.positionedLines.length;if(B+=Ag(e,n,t,r,a,l,p,x,m,T,i.vertical?Cm.horizontal:Cm.horizontalOnly,o?Object.keys(i.horizontal):[X],V,N,b,S,M,A),o)break}i.vertical&&(F+=Ag(e,n,t,i.vertical,a,l,p,x,m,T,Cm.vertical,["vertical"],V,j,b,S,M,A));let Z=-1;const Y=(e,t)=>e?Math.max(e,t):t;Z=Y(R,Z),Z=Y(L,Z),Z=Y(z,Z);const Q=Z>-1?1:0;e.glyphOffsetArray.length>=65535&&dn("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(t.x,t.y,G.x,G.y,G.z,V.right>=0?V.right:-1,V.center>=0?V.center:-1,V.left>=0?V.left:-1,V.vertical>=0?V.vertical:-1,N,j,U,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,void 0!==I?I:e.collisionBoxArray.length,void 0!==I?I+1:e.collisionBoxArray.length,void 0!==k?k:e.collisionBoxArray.length,void 0!==k?k+1:e.collisionBoxArray.length,P||e.collisionBoxArray.length,P?P+1:e.collisionBoxArray.length,u,B,F,O,D,Q,0,W,H,Z,0,q?1:0)}(e,s,g,a,n,r,i,O,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,M,T,l,0,A,C,_,t,o,c,u,h,f,p)};if("line"===k)for(const B of Km(t.geometry,0,0,io,io)){const t=Qm(B,S,E,n.vertical||y,r,x,w,e.overscaling,io);for(const n of t)y&&kg(e,y.text,I,n)||D(B,n,h)}else if("line-center"===k){for(const B of t.geometry)if(B.length>1){const e=Ym(B,E,n.vertical||y,r,x,w);e&&D(B,e,h)}}else if("Polygon"===t.type)for(const B of jd(t.geometry,0)){const e=mg(B,16);D(B[0],new Gm(e.x,e.y,0,0,void 0),h)}else if("LineString"===t.type)for(const B of t.geometry)D(B,new Gm(B[0].x,B[0].y,0,0,void 0),h);else if("Point"===t.type)for(const B of t.geometry)for(const e of B)D([e],new Gm(e.x,e.y,0,0,void 0),h)}const Sg=255,Mg=Sg*Wp;function Ag(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_){const y=function(e,t,n,r,i,o,a,s){const l=[];if(0===t.positionedLines.length)return l;const c=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,u=function(e){const t=e[0],n=e[1],r=t*n;return r>0?[t,-n]:r<0?[-t,n]:0===t?[n,t]:[n,-t]}(n);let h=Math.abs(t.top-t.bottom);for(const m of t.positionedLines)h-=m.lineOffset;const d=t.positionedLines.length,f=h/d;let p=t.top-n[1];for(let m=0;mMg&&dn("".concat(e.layerIds[0],': Value for "text-size" is >= ').concat(Sg,'. Reduce your "text-size".'))):"composite"===v.kind&&(x=[Wp*p.compositeTextSizes[0].evaluate(s,{},g),Wp*p.compositeTextSizes[1].evaluate(s,{},g)],(x[0]>Mg||x[1]>Mg)&&dn("".concat(e.layerIds[0],': Value for "text-size" is >= ').concat(Sg,'. Reduce your "text-size".'))),e.addSymbols(e.text,y,x,l,a,s,u,t,n,c.lineStartIndex,c.lineLength,f,m,g,_,!1);for(const b of h)d[b]=e.text.placedSymbolArray.length-1;return 4*y.length}function Eg(e){for(const t in e)return e[t];return null}function Tg(e,t,n,r,i,o,a,s,l,c){let u=a.top,h=a.bottom,d=a.left,f=a.right;const p=a.collisionPadding;if(p&&(d-=p[0],u-=p[1],f+=p[2],h+=p[3]),l){const e=new jt(d,u),t=new jt(f,u),n=new jt(d,h),r=new jt(f,h),i=Gt(l);let o=new jt(0,0);c&&(o=new jt(c[0],c[1])),e._rotateAround(i,o),t._rotateAround(i,o),n._rotateAround(i,o),r._rotateAround(i,o),d=Math.min(e.x,t.x,n.x,r.x),f=Math.max(e.x,t.x,n.x,r.x),u=Math.min(e.y,t.y,n.y,r.y),h=Math.max(e.y,t.y,n.y,r.y)}return e.emplaceBack(t.x,t.y,t.z,n.x,n.y,d,u,f,h,s,r,i,o),e.length-1}function Cg(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 kg(e,t,n,r){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])v&&(x(e,c,r,i,s,l),x(c,n,s,l,o,a))}x(h,d,r,o,i,o),x(d,f,i,o,i,a),x(f,p,i,a,r,a),x(p,h,r,a,r,o),m-=v,g-=v,_+=v,y+=v;const b=1/Math.max(_-m,y-g);return{scale:b,x:m*b,y:g*b,x2:_*b,y2:y*b,projection:t}}function Rg(e,t){let{x:n,y:r}=t;return new jt(((n-(arguments.length>2&&void 0!==arguments[2]?arguments[2]:0))*e.scale-e.x)*io,(r*e.scale-e.y)*io)}const Lg=e.a9.identity(new Float32Array(16));class zg{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 au(0,0)}projectTilePoint(e,t,n){return{x:e,y:t,z:0}}locationPoint(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e._coordinatePoint(e.locationCoordinate(t),n)}pixelsPerMeter(e,t){return xu(1,e)*t}pixelSpaceConversion(e,t,n){return 1}farthestPixelDistance(e){return Ig(e,e.pixelsPerMeter)}pointCoordinate(e,t,n,r){const i=e.horizonLineFromTop(!1),o=new jt(t,Math.max(i,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,n){const r=new jt(t,n);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const n=e.horizonLineFromTop();return t.y0?t<-Gg+n&&(t=-Gg+n):t>Gg-n&&(t=Gg-n);const o=i/Math.pow(qg(t),r);let a=o*Math.sin(r*e),s=i-o*Math.cos(r*e);return a=.5*(a/Math.PI+.5),s=.5*(s/Math.PI+.5),{x:a,y:this.southernCenter?s:1-s,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:n,f:r}=this,i=r-t,o=Math.sign(i),a=Math.sign(n)*Math.sqrt(e*e+i*i);let s=Math.atan2(e,Math.abs(i))*o;i*n<0&&(s-=Math.PI*Math.sign(e)*o);const l=Qt(qt(s/n)+this.center[0],-180,180),c=Qt(qt(2*Math.atan(Math.pow(r/a,1/n))-Gg),-Mu,Mu);return new au(l,this.southernCenter?-c:c)}}class Hg extends zg{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:yu(e),y:vu(t),z:0}}unproject(e,t){const n=bu(e),r=wu(t);return new au(n,r)}}const Zg=Gt(Mu);class Yg extends zg{project(e,t){const n=(t=Gt(t))*t,r=n*n;return{x:.5*((e=Gt(e))*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let n=t=(2*(1-t)-1)*Math.PI,r=25,i=0,o=n*n;do{o=n*n;const e=o*o;i=(n*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),n=Qt(n-i,-Zg,Zg)}while(Math.abs(i)>1e-6&&--r>0);o=n*n;const a=Qt(qt(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=qt(n);return new au(a,s)}}const Qg=Gt(Mu);class Xg extends zg{project(e,t){t=Gt(t),e=Gt(e);const n=Math.cos(t),r=2/Math.PI,i=Math.acos(n*Math.cos(e/2)),o=Math.sin(i)/i,a=.5*(e*r+2*n*Math.sin(e/2)/o)||0,s=.5*(t+Math.sin(t)/o)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}}unproject(e,t){let n=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,i=25;const o=1e-6;let a=0,s=0;do{const i=Math.cos(r),o=Math.sin(r),l=2*o*i,c=o*o,u=i*i,h=Math.cos(n/2),d=Math.sin(n/2),f=2*h*d,p=d*d,m=1-u*h*h,g=m?1/m:0,_=m?Math.acos(i*h)*Math.sqrt(1/m):0,y=.5*(2*_*i*d+2*n/Math.PI)-e,v=.5*(_*o+r)-t,x=.5*g*(u*p+_*i*h*c)+1/Math.PI,b=g*(f*l/4-_*o*d),w=.125*g*(l*d-_*o*u*f),S=.5*g*(c*h+_*p*i)+.5,M=b*w-S*x;a=(v*b-y*S)/M,s=(y*w-v*x)/M,n=Qt(n-a,-Math.PI,Math.PI),r=Qt(r-s,-Qg,Qg)}while((Math.abs(a)>o||Math.abs(s)>o)&&--i>0);return new au(qt(n),qt(r))}}class Kg extends zg{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Gt(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:n,cosPhi:r}=this;return{x:Gt(e)*r*n+.5,y:-Math.sin(Gt(t))/r*n+.5,z:0}}unproject(e,t){const{scale:n,cosPhi:r}=this,i=-(t-.5)/n,o=Qt(qt((e-.5)/n)/r,-180,180),a=Math.asin(Qt(i*r,-1,1)),s=Qt(qt(a),-Mu,Mu);return new au(o,s)}}class Jg extends Hg{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,n,r){const i=Ph(t,n,r),o=zh(Ah(r));return e.Q.transformMat4(i,i,o),{x:i[0],y:i[1],z:i[2]}}locationPoint(t,n){const r=ru(n.lat,n.lng),i=e.Q.normalize([],r),o=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(n),t._centerAltitude):t._centerAltitude,a=xu(1,0)*io*o;e.Q.scaleAndAdd(r,r,i,a);const s=e.a9.identity(new Float64Array(16));return e.a9.multiply(s,t.pixelMatrix,t.globeMatrix),e.Q.transformMat4(r,r,s),new jt(r[0],r[1])}pixelsPerMeter(e,t){return xu(1,0)*t}pixelSpaceConversion(e,t,n){const r=xu(1,e)*t,i=Gr(xu(1,45)*t,r,n);return this.pixelsPerMeter(e,t)/i}createTileMatrix(t,n,r){const i=Oh(Ah(r.canonical));return e.a9.multiply(new Float64Array(16),t.globeMatrix,i)}createInversionMatrix(t,n){const{center:r}=t,i=zh(Ah(n));return e.a9.rotateY(i,i,Gt(r.lng)),e.a9.rotateX(i,i,Gt(r.lat)),e.a9.scale(i,i,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(i)}pointCoordinate(e,t,n,r){return wh(e,t,n,!0)||new ku(0,0)}pointCoordinate3D(e,t,n){const r=this.pointCoordinate(e,t,n,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!wh(e,t.x,t.y,!1)}farthestPixelDistance(t){const n=function(t,n){const r=t.cameraToCenterDistance,i=t._centerAltitude*n,o=t._camera,a=t._camera.forward(),s=e.Q.add([],e.Q.scale([],a,-r),[0,0,i]),l=t.worldSize/(2*Math.PI),c=[0,0,-l],u=t.width/t.height,h=Math.tan(t.fovAboveCenter),d=e.Q.scale([],o.up(),h),f=e.Q.scale([],o.right(),h*u),p=e.Q.normalize([],e.Q.add([],e.Q.add([],a,d),f)),m=[];let g;if(new lh(s,p).closestPointOnSphere(c,l,m)){const n=e.Q.add([],m,c),r=e.Q.sub([],n,s);g=Math.cos(t.fovAboveCenter)*e.Q.length(r)}else{const t=e.Q.sub([],s,c),n=e.Q.sub([],c,s);e.Q.normalize(n,n);const r=e.Q.length(t)-l;g=Math.sqrt(r*(r+2*l));const i=Math.acos(g/(l+r))-Math.acos(e.Q.dot(a,n));g*=Math.cos(i)}return 1.01*g}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),r=Nh(t.zoom);if(r>0){const e=Ig(t,xu(1,t.center.lat)*t.worldSize),i=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Gr(n,e+i*(1-Math.cos(o)),Math.pow(r,10))}return n}upVector(e,t,n){return Ph(t,n,e,1)}upVectorScale(e){return{metersToTile:xh(Rh(Ah(e)))}}}function $g(e){const t=e.parallels,n=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new Hg(e);case"equirectangular":return new Ug(e);case"naturalEarth":return new Yg(e);case"equalEarth":return new Vg(e);case"winkelTripel":return new Xg(e);case"albers":return n?new Kg(e):new Og(e);case"lambertConformalConic":return n?new Kg(e):new Wg(e);case"globe":return new Jg(e)}throw new Error("Invalid projection name: ".concat(e.name))}const e_=ff.types,t_=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function n_(e,t,n,r,i,o,a,s,l,c,u,h,d){const f=s?Math.min(Mg,Math.round(s[0])):0,p=s?Math.min(Mg,Math.round(s[1])):0;e.emplaceBack(t,n,Math.round(32*r),Math.round(32*i),o,a,(f<<1)+(l?1:0),p,16*c,16*u,256*h,256*d)}function r_(e,t,n){e.emplaceBack(t,n)}function i_(e,t,n,r,i,o,a){e.emplaceBack(t,n,r,i,o,a)}function o_(e,t,n,r,i){e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i)}function a_(e){for(const t of e.sections)if(Ts(t.text))return!0;return!1}class s_{constructor(e){this.layoutVertexArray=new Ol,this.indexArray=new Gl,this.programConfigurations=e,this.segments=new mc,this.dynamicLayoutVertexArray=new Il,this.opacityVertexArray=new Bl,this.placedSymbolArray=new oc,this.iconTransitioningVertexArray=new Fl,this.globeExtVertexArray=new Dl,this.zOffsetVertexArray=new Hl}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,t,n,r,i){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Op.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Bp.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,t_,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,Np.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Dp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Fp.members,!0)),this.opacityVertexBuffer.itemSize=1),(n||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}ps(s_,"SymbolBuffers");class l_{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new mc,this.collisionVertexArray=new Ul,this.collisionVertexArrayExt=new Il}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,jp.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Vp.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ps(l_,"CollisionBuffers");class c_{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=e.a9.identity([]),this.placementViewportMatrix=e.a9.identity([]);const n=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Hp(this.zoom,n["text-size"]),this.iconSizeData=Hp(this.zoom,n["icon-size"]);const r=this.layers[0].layout,i=r.get("symbol-sort-key"),o=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"!==o&&void 0!==i.constantOr(1),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map((e=>Cm[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=r.get("symbol-z-elevate")}createArrays(){this.text=new s_(new Uc(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new s_(new Uc(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new lc,this.lineVertexArray=new cc,this.symbolInstances=new sc}calculateGlyphDependencies(e,t,n,r,i){for(let o=0;o0)&&("constant"!==l.value.kind||l.value.value.length>0),d="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,f=a.get("symbol-sort-key");if(this.features=[],!h&&!d)return;const p=n.iconDependencies,m=n.glyphDependencies,g=n.availableImages,_=new js(this.zoom);for(const{feature:y,id:v,index:x,sourceLayerIndex:b}of t){const t=o._featureFilter.needGeometry,n=Fu(y,t);if(!o._featureFilter.filter(_,n,r))continue;if(t||(n.geometry=Bu(y,r,i)),s&&1!==y.type&&r.z<=5){const t=n.geometry,i=.98078528056,o=(t,n)=>{const o=Ph(t.x,t.y,r,1),a=Ph(n.x,n.y,r,1);return e.Q.dot(o,a)=0;for(const n of c.sections)if(n.image)p[n.image.namePrimary]=!0;else{const r=xs(c.toString()),i=n.fontStack||e,o=m[i]=m[i]||{};this.calculateGlyphDependencies(n.text,o,t,this.allowVerticalPlacement,r)}}}"line"===a.get("symbol-placement")&&(this.features=function(e){const t={},n={},r=[];let i=0;function o(t){r.push(e[t]),i++}function a(e,t,i){const o=n[e];return delete n[e],n[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(i[0]),o}function s(e,n,i){const o=t[n];return delete t[n],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=i[0].concat(r[o].geometry[0]),o}function l(e,t,n){const r=n?t[0][t[0].length-1]:t[0][0];return"".concat(e,":").concat(r.x,":").concat(r.y)}for(let c=0;ce.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey))}update(e,t,n,r,i){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const a=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,t,a,n,r,i),this.icon.programConfigurations.updatePaintArrays(e,t,a,n,r,i)}updateZOffset(){const e=(e,t,r)=>{n+=t,n>e.length&&e.resize(n);for(let i=-t;i<0;i++)e.emplace(i+n,r)},t=(e,t,n)=>{r+=t,r>e.length&&e.resize(r);for(let i=-t;i<0;i++)e.emplace(i+r,n)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let n=0,r=0;for(let i=0;i0;if((r>0||o>0)&&(e(this.text.zOffsetVertexArray,r,s),e(this.text.zOffsetVertexArray,o,s)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:r}=n;e>=0&&t(this.icon.zOffsetVertexArray,a,s),r>=0&&t(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,s)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}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.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=$g(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const n=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:r,y:i}of t)this.lineVertexArray.emplaceBack(r,i);return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m){const g=e.indexArray,_=e.layoutVertexArray,y=e.globeExtVertexArray,v=e.segments.prepareSegment(4*t.length,_,g,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&a===Cm.vertical?Math.PI/2:0,S=o.text&&o.text.sections;for(let A=0;A=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=Zp(this.textSizeData,e,i)/qp;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,n){const r=this.icon.placedSymbolArray.get(n),i=Zp(this.iconSizeData,e,r);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,n,r){e.emplaceBack(t,-n,-n,r),e.emplaceBack(t,n,-n,r),e.emplaceBack(t,n,n,r),e.emplaceBack(t,-n,n,r)}_updateTextDebugCollisionBoxes(e,t,n,r,i,o){for(let a=r;a0}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}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const n=e.placedSymbolArray.get(t),r=n.vertexStartIndex+4*n.numGlyphs;for(let i=n.vertexStartIndex;ir[e]-r[t]||i[t]-i[e])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset))}addToSortKeyRanges(e,t){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===t?n.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);const{rightJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:s}=t;n>=0&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&this.addIndicesForPlacedSymbol(this.text,r),i>=0&&i!==r&&i!==n&&this.addIndicesForPlacedSymbol(this.text,i),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}ps(c_,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),c_.addDynamicAttributes=o_;const u_=new Js({"symbol-placement":new Qs(tl.layout_symbol["symbol-placement"]),"symbol-spacing":new Qs(tl.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Qs(tl.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Xs(tl.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Qs(tl.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Qs(tl.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Qs(tl.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Qs(tl.layout_symbol["icon-ignore-placement"]),"icon-optional":new Qs(tl.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Qs(tl.layout_symbol["icon-rotation-alignment"]),"icon-size":new Xs(tl.layout_symbol["icon-size"]),"icon-text-fit":new Xs(tl.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Xs(tl.layout_symbol["icon-text-fit-padding"]),"icon-image":new Xs(tl.layout_symbol["icon-image"]),"icon-rotate":new Xs(tl.layout_symbol["icon-rotate"]),"icon-padding":new Qs(tl.layout_symbol["icon-padding"]),"icon-keep-upright":new Qs(tl.layout_symbol["icon-keep-upright"]),"icon-offset":new Xs(tl.layout_symbol["icon-offset"]),"icon-anchor":new Xs(tl.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Qs(tl.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Qs(tl.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Qs(tl.layout_symbol["text-rotation-alignment"]),"text-field":new Xs(tl.layout_symbol["text-field"]),"text-font":new Xs(tl.layout_symbol["text-font"]),"text-size":new Xs(tl.layout_symbol["text-size"]),"text-max-width":new Xs(tl.layout_symbol["text-max-width"]),"text-line-height":new Xs(tl.layout_symbol["text-line-height"]),"text-letter-spacing":new Xs(tl.layout_symbol["text-letter-spacing"]),"text-justify":new Xs(tl.layout_symbol["text-justify"]),"text-radial-offset":new Xs(tl.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Qs(tl.layout_symbol["text-variable-anchor"]),"text-anchor":new Xs(tl.layout_symbol["text-anchor"]),"text-max-angle":new Qs(tl.layout_symbol["text-max-angle"]),"text-writing-mode":new Qs(tl.layout_symbol["text-writing-mode"]),"text-rotate":new Xs(tl.layout_symbol["text-rotate"]),"text-padding":new Qs(tl.layout_symbol["text-padding"]),"text-keep-upright":new Qs(tl.layout_symbol["text-keep-upright"]),"text-transform":new Xs(tl.layout_symbol["text-transform"]),"text-offset":new Xs(tl.layout_symbol["text-offset"]),"text-allow-overlap":new Qs(tl.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Qs(tl.layout_symbol["text-ignore-placement"]),"text-optional":new Qs(tl.layout_symbol["text-optional"]),visibility:new Qs(tl.layout_symbol.visibility)});var h_={paint:new Js({"icon-opacity":new Xs(tl.paint_symbol["icon-opacity"]),"icon-emissive-strength":new Xs(tl.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Xs(tl.paint_symbol["text-emissive-strength"]),"icon-color":new Xs(tl.paint_symbol["icon-color"]),"icon-halo-color":new Xs(tl.paint_symbol["icon-halo-color"]),"icon-halo-width":new Xs(tl.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Xs(tl.paint_symbol["icon-halo-blur"]),"icon-translate":new Qs(tl.paint_symbol["icon-translate"]),"icon-translate-anchor":new Qs(tl.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Xs(tl.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Xs(tl.paint_symbol["text-opacity"]),"text-color":new Xs(tl.paint_symbol["text-color"],{runtimeType:$r,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Xs(tl.paint_symbol["text-halo-color"]),"text-halo-width":new Xs(tl.paint_symbol["text-halo-width"]),"text-halo-blur":new Xs(tl.paint_symbol["text-halo-blur"]),"text-translate":new Qs(tl.paint_symbol["text-translate"]),"text-translate-anchor":new Qs(tl.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Qs(tl.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Qs(tl.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Qs(tl.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Qs(tl.paint_symbol["icon-color-brightness-max"])}),layout:u_};class d_{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Qr,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}}ps(d_,"FormatSectionOverride",{omit:["defaultValue"]});class f_ extends vl{constructor(t,n,r){super(t,h_,n,r),this._colorAdjustmentMatrix=e.a9.identity([])}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 n=this.layout.get("text-writing-mode");if(n){const e=[];for(const t of n)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()}getColorAdjustmentMatrix(t,n,r,i){return this._saturation===t&&this._contrast===n&&this._brightnessMin===r&&this._brightnessMax===i||(this._colorAdjustmentMatrix=function(t,n,r,i){t=In(t),n=kn(n);const o=e.a9.create(),a=t/3,s=1-2*a,l=[s,a,a,0,a,s,a,0,a,a,s,0,0,0,0,1],c=.5-.5*n,u=i-r;return e.a9.multiply(o,[u,0,0,0,0,u,0,0,0,0,u,0,r,r,r,1],[n,0,0,0,0,n,0,0,0,0,n,0,c,c,c,1]),e.a9.multiply(o,o,l),o}(t,n,r,i),this._saturation=t,this._contrast=n,this._brightnessMin=r,this._brightnessMax=i),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,n,r){const i=this.layout.get(e).evaluate(t,{},n,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||ns(o.value)||!i?i:function(e,t){return t.replace(/{([^{}]+)}/g,((t,n)=>n in e?String(e[n]):""))}(t.properties,i)}createBucket(e){return new c_(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of h_.paint.overridableProperties){if(!f_.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),n=new d_(t),r=new ts(n,t.property.specification,this.scope,this.options);let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new is("source",r):new os("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Zs(t.property,i,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&f_.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const n=e.get("text-field"),r=h_.paint.properties[t];let i=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(i=!0)};if("constant"===n.value.kind&&n.value.value instanceof fi)o(n.value.value.sections);else if("source"===n.value.kind){const e=t=>{i||(t instanceof vi&&_i(t.value)===ri?o(t.value.sections):t instanceof Si?o(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}getProgramIds(){const e=0!==this.paint.get("icon-opacity").constantOr(1),t=0!==this.paint.get("text-opacity").constantOr(1),n=[];return e&&n.push("symbolIcon"),t&&n.push("symbolSDF"),n}getDefaultProgramParams(e,t){return{config:new Vc(this,t),overrideFog:!1}}}const p_=new Js({visibility:new Qs(tl.layout_background.visibility)});var m_={paint:new Js({"background-color":new Qs(tl.paint_background["background-color"]),"background-pattern":new Qs(tl.paint_background["background-pattern"]),"background-opacity":new Qs(tl.paint_background["background-opacity"]),"background-emissive-strength":new Qs(tl.paint_background["background-emissive-strength"])}),layout:p_};const g_=new Js({visibility:new Qs(tl.layout_raster.visibility)});var __={paint:new Js({"raster-opacity":new Qs(tl.paint_raster["raster-opacity"]),"raster-color":new Ks(tl.paint_raster["raster-color"]),"raster-color-mix":new Qs(tl.paint_raster["raster-color-mix"]),"raster-color-range":new Qs(tl.paint_raster["raster-color-range"]),"raster-hue-rotate":new Qs(tl.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Qs(tl.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Qs(tl.paint_raster["raster-brightness-max"]),"raster-saturation":new Qs(tl.paint_raster["raster-saturation"]),"raster-contrast":new Qs(tl.paint_raster["raster-contrast"]),"raster-resampling":new Qs(tl.paint_raster["raster-resampling"]),"raster-fade-duration":new Qs(tl.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new Qs(tl.paint_raster["raster-emissive-strength"]),"raster-array-band":new Qs(tl.paint_raster["raster-array-band"]),"raster-elevation":new Qs(tl.paint_raster["raster-elevation"])}),layout:g_},y_=Sl([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class v_{constructor(e,t,n,r){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this.update(t,r)}update(e,t,n){const{width:r,height:i}=e,{context:o}=this,{gl:a}=o;if(a.bindTexture(a.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!t||!1!==t.premultiply)),n||this.size&&this.size[0]===r&&this.size[1]===i){const{x:t,y:o}=n||{x:0,y:0};if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap)a.texSubImage2D(a.TEXTURE_2D,0,t,o,a.RGBA,a.UNSIGNED_BYTE,e);else{let n=this.format,s=a.UNSIGNED_BYTE;this.format===a.R32F&&(n=a.RED,s=a.FLOAT),a.texSubImage2D(a.TEXTURE_2D,0,t,o,r,i,n,s,e.data)}}else if(this.size=[r,i],e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap){let t=this.format;this.format===a.R8&&(t=a.RED),a.texImage2D(a.TEXTURE_2D,0,this.format,t,a.UNSIGNED_BYTE,e)}else{let t=this.format,n=this.format,o=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(t=a.DEPTH_COMPONENT16,o=a.UNSIGNED_SHORT),this.format===a.R8&&(n=a.RED),this.format===a.R32F&&(o=a.FLOAT,n=a.RED),a.texImage2D(a.TEXTURE_2D,0,t,r,i,0,n,o,e.data)}this.useMipmap=Boolean(t&&t.useMipmap),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D)}bind(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{context:r}=this,{gl:i}=r;i.bindTexture(i.TEXTURE_2D,this.texture),e!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!n?e===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrapS=t)}bindExtraParam(e,t,n,r){const{context:i}=this,{gl:o}=i;o.bindTexture(o.TEXTURE_2D,this.texture),t!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),n!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,n),this.wrapS=n),r!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapT=r)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class x_{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}}function b_(t,n,r,i,o,a,s,l){const c=[t,n,1,r,i,1,o,a,1],u=[s,l,1],h=e.ct.adjoint([],c),[d,f,p]=e.Q.transformMat3(u,u,h);return e.ct.multiply(c,c,[d,0,0,0,f,0,0,0,p])}function w_(t,n,r,i,o,a,s,l){const c=function(t,n,r,i,o,a,s,l){const c=b_(0,0,1,0,1,1,0,1),u=b_(t,n,r,i,o,a,s,l),h=e.ct.adjoint([],c);return e.ct.multiply(u,u,h)}(t,n,r,i,o,a,s,l);return[c[2]/c[8]/io,c[5]/c[8]/io]}function S_(e){return[e[0],Math.min(Math.max(e[1],-Mu),Mu)]}class M_ extends Dr{constructor(e,t,n,r){super(),this.id=e,this.dispatcher=n,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(r),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new zr("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=or(this.map._requestManager.transformRequest(this.url,Xn.Image),((t,n)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new Or(t)):n&&(this.image=n instanceof HTMLImageElement?Rn.getImageData(n):n,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())}))}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new x_(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new zr("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof x_||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],n=e[0][1];for(const i of e)i[1]>n&&(n=i[1]),i[1]Mu?this.onNorthPole=!0:r<-Mu&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(ku.fromLngLat);this.tileID=function(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const c of e)t=Math.min(t,c.x),n=Math.min(n,c.y),r=Math.max(r,c.x),i=Math.max(i,c.y);const o=Math.max(r-t,i-n),a=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),s=Math.pow(2,a);let l=Math.floor((t+r)/2*s);return l>1&&(l-=1),new uu(a,l,Math.floor((n+i)/2*s))}(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new zr("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_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||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const n=Pg(new uu(0,0,0),this.map.transform.projection),r=[n.projection.project(this.coordinates[0][0],this.coordinates[0][1]),n.projection.project(this.coordinates[1][0],this.coordinates[1][1]),n.projection.project(this.coordinates[2][0],this.coordinates[2][1]),n.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){const t=e[1].x-e[0].x,n=e[1].y-e[0].y,r=e[2].x-e[1].x,i=e[2].y-e[1].y,o=e[3].x-e[2].x,a=e[3].y-e[2].y,s=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*i-r*n,u=r*a-o*i,h=o*l-s*a,d=s*n-t*l;return c>0&&u>0&&h>0&&d>0||c<0&&u<0&&h<0&&d<0}(r))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const i=Pg(this.tileID,this.map.transform.projection),[o,a,s,l]=this.coordinates.map((e=>{const t=i.projection.project(e[0],e[1]);return Rg(i,t)._round()}));this.perspectiveTransform=w_(o.x,o.y,a.x,a.y,s.x,s.y,l.x,l.y);const c=this._boundsArray=new Tl;c.emplaceBack(o.x,o.y,0,0),c.emplaceBack(a.x,a.y,io,0),c.emplaceBack(l.x,l.y,0,io),c.emplaceBack(s.x,s.y,io,io),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(c,y_.members),this.boundsSegments=mc.simpleSegment(0,0,4,2);const u=[],h=[S_((d=this.coordinates)[0]),S_(d[1]),S_(d[2]),S_(d[3])];var d;const[f,p,m,g]=function(e){let t=e[0][0],n=t,r=e[0][1],i=r;for(let o=1;on&&(n=e[o][0]),e[o][1]i&&(i=e[o][1]);return[t,r,n-t,i-r]}(h);{const i=new Tl,[o,a,s,l]=function(e){let t=e[0].x,n=t,r=e[0].y,i=r;for(let o=1;on&&(n=e[o].x),e[o].yi&&(i=e[o].y);return[t,r,n-t,i-r]}(r),c=e=>[(e.x-o)/s,(e.y-a)/l],[h,d,_,y]=r.map(c),v=function(t,n,r,i,o,a,s,l){const c=b_(0,0,1,0,1,1,0,1),u=b_(t,n,r,i,o,a,s,l),h=e.ct.adjoint([],u);return e.ct.multiply(c,c,h)}(h[0],h[1],d[0],d[1],_[0],_[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=w_(h[0],h[1],d[0],d[1],_[0],_[1],y[0],y[1]);const x=(t,n)=>{u.push(t.lng);const r=Math.round((t.lng-f)/m*io),o=Math.round((t.lat-p)/g*io),a=c(n),s=e.Q.transformMat3([],[a[0],a[1],1],v),l=Math.round(s[0]/s[2]*io),h=Math.round(s[1]/s[2]*io);i.emplaceBack(r,o,l,h)},b=r[3].x-r[0].x,w=r[3].y-r[0].y,S=r[2].x-r[1].x,M=r[2].y-r[1].y;for(let e=0;e<65;e++){const t=e/64,i=[r[0].x+t*b,r[0].y+t*w],o=[r[1].x+t*S,r[1].y+t*M],a=o[0]-i[0],s=o[1]-i[1];for(let e=0;e<65;e++){const t=e/64,r={x:i[0]+a*t,y:i[1]+s*t,z:0};x(n.projection.unproject(r.x,r.y),r)}}this.elevatedGlobeVertexBuffer=t.createVertexBuffer(i,y_.members)}{this.maxLongitudeTriangleSize=0;let e=[],n=new Gl;const r=(t,r,i)=>{n.emplaceBack(t,r,i);const o=u[t],a=u[r],s=u[i],l=Math.min(Math.min(o,a),s),c=Math.max(Math.max(o,a),s)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),e.push(l+c/2)};for(let t=0;t<64;t++)for(let e=0;e<64;e++){const n=65*t+e,i=n+1,o=n+65,a=o+1;r(n,o,i),r(i,o,a)}[e,n]=function(e,t){const n=Array.from({length:e.length},((e,t)=>t));n.sort(((t,n)=>e[t]-e[n]));const r=[],i=new Gl;for(let o=0;oe+360*Math.round((t-e)/360))(e+180,n[0]);const i=new mc,o=(e,n)=>{i.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:n,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(n[0]-r)<=a){const e=Cn(n,0,n.length,r+a);return e===n.length||o(e,Tn(n,e+1,n.length,r+360-a)-e),i}r4&&void 0!==arguments[4]?arguments[4]:1/0;const o=e.range;if(!o)return 0;const a=Math.min(i,Math.max(n,r)),s=Math.log(a/1024)/Math.LN2;return Xt(o[0]+s,o[1]+s,t)}const F_=1/4e4;function N_(e,t){const n=Qt(t.lat,-Mu,Mu),r=new au(t.lng-180*F_,n),i=new au(t.lng+180*F_,n),o=e.project(r.lng,n),a=e.project(i.lng,n),s=ku.fromLngLat(r),l=ku.fromLngLat(i),c=a.x-o.x,u=a.y-o.y,h=l.x-s.x,d=l.y-s.y,f=Math.sqrt((h*h+d*d)/(c*c+u*u));return Math.log(f)/Math.LN2}function j_(e,t,n){const r=Math.cos(n),i=Math.sin(n);return{x:e*r-t*i,y:e*i+t*r}}function V_(t,n,r){e.a9.identity(t),e.a9.rotateZ(t,t,Gt(n[2])),e.a9.rotateX(t,t,Gt(n[0])),e.a9.rotateY(t,t,Gt(n[1])),e.a9.scale(t,t,r),e.a9.multiply(t,t,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function U_(t,n,r,i,o,a,s,l){const c=[r[0]-n[0],r[1]-n[1],0],u=[i[0]-n[0],i[1]-n[1],0];if(e.Q.length(c)<1e-12||e.Q.length(u)<1e-12)return e.bl.identity(t);const h=e.Q.cross([],c,u);e.Q.normalize(h,h),e.Q.subtract(u,i,n),c[2]=(a-o)*l,u[2]=(s-o)*l;const d=c;return e.Q.cross(d,c,u),e.Q.normalize(d,d),e.bl.rotationTo(t,h,d)}function G_(t,n){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=Nh(n.zoom),o=function(t,n,r){const i=n.worldSize,o=[t[12],t[13],t[14]],a=wu(o[1]/i),s=bu(o[0]/i),l=e.a9.identity([]),c=xu(1,a)*i,u=xu(1,0)*i*Eu(a,n.zoom),h=1/Dh(i);let d=u*h;if(r){const e=B_(n.projection,n.zoom,n.width,n.height,1024);d=h*n.projection.pixelSpaceConversion(n.center.lat,i,e)}const f=ru(a,s);e.Q.add(f,f,e.Q.scale([],e.Q.normalize([],f),c*d*o[2]));const p=function(t){const n=[t[0],t[1],t[2]];let r=[0,1,0];const i=e.Q.cross([],r,n);return e.Q.cross(r,n,i),0===e.Q.squaredLength(r)&&(r=[0,1,0],e.Q.cross(i,n,r)),e.Q.normalize(i,i),e.Q.normalize(r,r),e.Q.normalize(n,n),[i[0],i[1],i[2],0,r[0],r[1],r[2],0,n[0],n[1],n[2],0,t[0],t[1],t[2],1]}(f);e.a9.scale(l,l,[d,d,d*c]),e.a9.translate(l,l,[-o[0],-o[1],-o[2]]);const m=e.a9.multiply([],n.globeMatrix,p);return e.a9.multiply(m,m,l),e.a9.multiply(m,m,t),m}(t,n,r);if(i>0){const r=function(t,n){const r=n.worldSize,i=xu(1,0)*r*Eu(n.center.lat,n.zoom)/Dh(r),o=xu(1,n.center.lat)*r,a=e.a9.identity([]);return e.a9.rotateY(a,a,Gt(n.center.lng)),e.a9.rotateX(a,a,Gt(n.center.lat)),e.a9.translate(a,a,[0,0,Yc]),e.a9.scale(a,a,[i,i,i*o]),e.a9.translate(a,a,[n.point.x-.5*r,n.point.y-.5*r,0]),e.a9.multiply(a,a,t),e.a9.multiply(a,n.globeMatrix,a)}(t,n);return function(t,n,r){const i=(t,n,r)=>{const i=e.Q.length(t),o=e.Q.length(n),a=Eh(t,n,r);return e.Q.scale(a,a,1/e.Q.length(a)*Gr(i,o,r))},o=i([t[0],t[1],t[2]],[n[0],n[1],n[2]],r),a=i([t[4],t[5],t[6]],[n[4],n[5],n[6]],r),s=i([t[8],t[9],t[10]],[n[8],n[9],n[10]],r),l=Eh([t[12],t[13],t[14]],[n[12],n[13],n[14]],r);return[o[0],o[1],o[2],0,a[0],a[1],a[2],0,s[0],s[1],s[2],0,l[0],l[1],l[2],1]}(o,r,i)}return o}function q_(e,t,n,r){const i=mh.projectAabbCorners(r,n);let o=Number.MAX_VALUE,a=-1;for(let c=0;cnew jt(i[e][0],i[e][1]);let l;switch(a){case 0:case 6:l=[s(1),s(5),s(4),s(7),s(3),s(2),s(1)];break;case 1:case 7:l=[s(0),s(4),s(5),s(6),s(2),s(3),s(0)];break;case 3:case 5:l=[s(1),s(0),s(4),s(7),s(6),s(2),s(1)];break;default:l=[s(1),s(5),s(6),s(7),s(3),s(0),s(1)]}if(Uu(e,l))return o}const W_=Sl([{name:"a_pos_3f",components:3,type:"Float32"}]),H_=Sl([{name:"a_color_3f",components:3,type:"Float32"}]),Z_=Sl([{name:"a_color_4f",components:4,type:"Float32"}]),Y_=Sl([{name:"a_uv_2f",components:2,type:"Float32"}]),Q_=Sl([{name:"a_normal_3f",components:3,type:"Float32"}]),X_=Sl([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),K_=Sl([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class J_{constructor(e,t,n,r){this.message=(e?"".concat(e,": "):"")+n,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function $_(e,t){const n=-1===e.indexOf("://");try{return new URL(e,n&&t?"http://example.com":void 0),!0}catch(e){return!1}}class ey{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class ty{constructor(){this.instancedDataArray=new Jl,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class ny{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1}populate(e,t,n,r){this.tileToMeter=Cu(n);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:a,index:s,sourceLayerIndex:l}of e){const e=null!=a?a:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Fu(o,i);if(!this.layers[0]._featureFilter.filter(new js(this.zoom),c,n))continue;const u={id:e,sourceLayerIndex:l,index:s,geometry:i?c.geometry:Bu(o,n,r),properties:o.properties,type:o.type,patterns:{}},h=this.addFeature(u,u.geometry,c);h&&t.featureIndex.insert(o,u.geometry,s,l,this.index,this.instancesPerModel[h].instancedDataArray.length,io/32)}this.lookup=null}update(e,t,n,r){for(const i in this.instancesPerModel){const t=this.instancesPerModel[i];for(const n in e)t.idToFeaturesIndex.hasOwnProperty(n)&&(this.evaluate(t.features[t.idToFeaturesIndex[n]],e[n],t,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let t=!1;for(const n in this.instancesPerModel){const r=this.instancesPerModel[n];for(const n of r.features){const i=this.layers[0],o=n.feature,a=this.canonical,s=i.paint.get("model-rotation").evaluate(o,{},a),l=i.paint.get("model-scale").evaluate(o,{},a),c=i.paint.get("model-translation").evaluate(o,{},a);e.Q.exactEquals(n.rotation,s)&&e.Q.exactEquals(n.scale,l)&&e.Q.exactEquals(n.translation,c)||(this.evaluate(n,n.featureStates,r,!0),t=!0)}}return t}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const n=this.instancesPerModel[t];n.instancedDataArray.length<0||0===n.instancedDataArray.length||(n.instancedDataBuffer?n.instancedDataBuffer.updateData(n.instancedDataArray):n.instancedDataBuffer=e.createVertexBuffer(n.instancedDataArray,X_.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const t in this.instancesPerModel){const e=this.instancesPerModel[t];0!==e.instancedDataArray.length&&e.instancedDataBuffer&&e.instancedDataBuffer.destroy()}const e=this.layers[0].modelManager;if(e&&this.modelUris)for(const t of this.modelUris)e.removeModel(t,"")}addFeature(e,t,n){const r=this.layers[0],i=r.layout.get("model-id").evaluate(n,{},this.canonical);if(!i)return dn("modelId is not evaluated for layer ".concat(r.id," and it is not going to get rendered.")),i;$_(i,!1)&&(this.modelUris.includes(i)||this.modelUris.push(i)),this.instancesPerModel[i]||(this.instancesPerModel[i]=new ty);const o=this.instancesPerModel[i],a=o.instancedDataArray,s=new ey(n,a.length);for(const l of t)for(const e of l){if(e.x<0||e.x>=io||e.y<0||e.y>=io)continue;const t=(this.lookupDim-1)/io,n=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[n])continue;this.lookup[n]=1}this.instanceCount++;const r=a.length;a.resize(r+1),o.instancesEvaluatedElevation.push(0),a.float32[16*r]=e.x,a.float32[16*r+1]=e.y}return s.instancedDataCount=o.instancedDataArray.length-s.instancedDataOffset,s.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(s),this.evaluate(s,{},o,!1)),i}getModelUris(){return this.modelUris}evaluate(e,t,n,r){const i=this.layers[0],o=e.feature,a=this.canonical,s=e.rotation=i.paint.get("model-rotation").evaluate(o,t,a),l=e.scale=i.paint.get("model-scale").evaluate(o,t,a),c=e.translation=i.paint.get("model-translation").evaluate(o,t,a),u=i.paint.get("model-color").evaluate(o,t,a);u.a=i.paint.get("model-color-mix-intensity").evaluate(o,t,a);const h=[];this.maxVerticalOffset10?this.tileToMeter:Cu(a,l)),o[i+4]=c[0],o[i+5]=c[1],o[i+6]=c[2]+s,o[i+7]=h[0],o[i+8]=h[1],o[i+9]=h[2],o[i+10]=h[4],o[i+11]=h[5],o[i+12]=h[6],o[i+13]=h[8],o[i+14]=h[9],o[i+15]=h[10],n.instancesEvaluatedElevation[t]=c[2]}}}ps(ny,"ModelBucket",{omit:["layers"]}),ps(ty,"PerModelAttributes"),ps(ey,"ModelFeature");const ry=new Js({visibility:new Qs(tl.layout_model.visibility),"model-id":new Xs(tl.layout_model["model-id"])});var iy={paint:new Js({"model-opacity":new Qs(tl.paint_model["model-opacity"]),"model-rotation":new Xs(tl.paint_model["model-rotation"]),"model-scale":new Xs(tl.paint_model["model-scale"]),"model-translation":new Xs(tl.paint_model["model-translation"]),"model-color":new Xs(tl.paint_model["model-color"]),"model-color-mix-intensity":new Xs(tl.paint_model["model-color-mix-intensity"]),"model-type":new Qs(tl.paint_model["model-type"]),"model-cast-shadows":new Qs(tl.paint_model["model-cast-shadows"]),"model-receive-shadows":new Qs(tl.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new Qs(tl.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Xs(tl.paint_model["model-emissive-strength"]),"model-roughness":new Xs(tl.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Xs(tl.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new Qs(tl.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new Qs(tl.paint_model["model-front-cutoff"])}),layout:ry};const oy=64,ay={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function sy(t,n,r,i,o,a,s,l,c){let u=arguments.length>9&&void 0!==arguments[9]&&arguments[9];const h=r.zoom,d=r.project(i),f=Eu(i.lat,h),p=1/f;e.a9.identity(t),e.a9.translate(t,t,[d.x+s[0]*p,d.y+s[1]*p,s[2]]);let m=1,g=1;const _=r.worldSize;if(u){if("mercator"===r.projection.name){let t=0;r.elevation&&(t=r.elevation.getAtPointOrZero(new ku(d.x/_,d.y/_),0));const n=e.aa.transformMat4([],[d.x,d.y,t,1],r.projMatrix)[3]/r.cameraToCenterDistance;m=n,g=n*Eu(r.center.lat,h)}else if("globe"===r.projection.name){const n=G_(t,r),o=e.a9.multiply([],r.projMatrix,n),a=[0,0,0,1];e.aa.transformMat4(a,a,o);const s=a[3]/r.cameraToCenterDistance,l=Nh(h),c=r.projection.pixelsPerMeter(i.lat,_)*Eu(i.lat,h),u=r.projection.pixelsPerMeter(r.center.lat,_)*Eu(r.center.lat,h);m=s/Gr(c,Au(r.center.lat),l),g=s*f/c,m*=u,g*=u}}else m=p;e.a9.scale(t,t,[m,m,g]);const y=[...t],v=n.orientation,x=[];if(V_(x,[v[0]+o[0],v[1]+o[1],v[2]+o[2]],a),e.a9.multiply(t,y,x),l&&r.elevation){let o=0;const a=[];if(c&&r.elevation){o=function(t,n,r,i,o){const a=n.elevation;if(!a)return 0;const s=mh.projectAabbCorners(r,i),l=xu(1,o.lat)*n.worldSize,c=function(t,n){const r=[0,0,1],i=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const o of i){const i=t[o.corners[0]],a=t[o.corners[1]],s=t[o.corners[2]],l=[a[0]-i[0],a[1]-i[1],n*(a[2]-i[2])],c=e.Q.cross(l,l,[s[0]-i[0],s[1]-i[1],n*(s[2]-i[2])]);e.Q.normalize(c,c),o.dotProductWithUp=e.Q.dot(c,r)}return i.sort(((e,t)=>e.dotProductWithUp-t.dotProductWithUp)),i[0].corners}(s,l),u=s[c[0]],h=s[c[1]],d=s[c[2]],f=s[c[3]],p=a.getAtPointOrZero(new ku(u[0]/n.worldSize,u[1]/n.worldSize),0),m=a.getAtPointOrZero(new ku(h[0]/n.worldSize,h[1]/n.worldSize),0),g=a.getAtPointOrZero(new ku(d[0]/n.worldSize,d[1]/n.worldSize),0),_=a.getAtPointOrZero(new ku(f[0]/n.worldSize,f[1]/n.worldSize),0),y=(p+_)/2,v=(m+g)/2;return y>v?m2&&void 0!==arguments[2]&&arguments[2];e.uploaded||(e.gfxTexture=new v_(t,e.image,n?t.gl.R8:t.gl.RGBA,{useMipmap:e.sampler.minFilter>=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function cy(e,t,n){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,W_.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Q_.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Y_.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?H_:Z_).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,K_.members,!0)),e.segments=mc.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const r=e.material;r.pbrMetallicRoughness.baseColorTexture&&ly(r.pbrMetallicRoughness.baseColorTexture,t),r.pbrMetallicRoughness.metallicRoughnessTexture&&ly(r.pbrMetallicRoughness.metallicRoughnessTexture,t),r.normalTexture&&ly(r.normalTexture,t),r.occlusionTexture&&ly(r.occlusionTexture,t,n),r.emissionTexture&&ly(r.emissionTexture,t)}function uy(e,t,n){if(e.meshes)for(const r of e.meshes)cy(r,t,n);if(e.children)for(const r of e.children)uy(r,t,n)}function hy(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)hy(t)}function dy(e){if(e.meshes)for(const n of e.meshes)n.vertexBuffer&&(n.vertexBuffer.destroy(),n.indexBuffer.destroy(),n.normalBuffer&&n.normalBuffer.destroy(),n.texcoordBuffer&&n.texcoordBuffer.destroy(),n.colorBuffer&&n.colorBuffer.destroy(),n.pbrBuffer&&n.pbrBuffer.destroy(),n.segments.destroy(),n.material&&((t=n.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));var t;if(e.children)for(const n of e.children)dy(n)}class fy{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 py{constructor(){this.tasks={},this.taskQueue=[],an(["process"],this),this.invoker=new fy(this.process),this.nextId=0}add(e,t){const n=this.nextId++,r=function(e){let{type:t,isSymbolTile:n,zoom:r}=e;return r=r||0,"message"===t?0:"maybePrepare"!==t||n?"parseTile"!==t||n?"parseTile"===t&&n?300-r:"maybePrepare"===t&&n?400-r:500:200-r:100-r}(t);if(0===r){gn();try{e()}finally{}return null}return this.tasks[n]={fn:e,metadata:t,priority:r,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){gn();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;r4&&void 0!==arguments[4]&&arguments[4],o=arguments.length>5?arguments[5]:void 0;const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=o,this.callbacks[a]=n);const s=new Set;return this.target.postMessage({id:a,type:e,hasCallback:!!n,targetMapId:r,mustQueue:i,sourceMapId:this.mapId,data:_s(t,s)},s),{cancel:()=>{n&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,n=t.id;if(n&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[n];delete this.cancelCallbacks[n],e&&e.cancel()}else if(t.mustQueue||gn()){const e=this.callbacks[n],r=this.scheduler.add((()=>this.processTask(n,t)),e&&e.metadata||{type:"message"});r&&(this.cancelCallbacks[n]=r)}else this.processTask(n,t)}processTask(e,t){if(delete this.cancelCallbacks[e],""===t.type){const n=this.callbacks[e];delete this.callbacks[e],n&&(t.error?n(ys(t.error)):n(null,ys(t.data)))}else{const n=new Set,r=t.hasCallback?(t,r)=>{this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?_s(t):null,data:_s(r,n)},n)}:e=>{},i=ys(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,i,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],i.source,i.scope)[e[1]](i,r)}else r(new Error("Could not find function ".concat(t.type)))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class gy{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=tn();const n=this.workerPool.acquire(this.id);for(let r=0;r{this.ready=!0}))}broadcast(e,t,n){Jt(this.actors,((n,r)=>{n.send(e,t,r)}),n=n||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)}}gy.Actor=my;var _y={workerUrl:"",workerClass:null,workerParams:void 0};function yy(){return null!=_y.workerClass?new _y.workerClass:new self.Worker(_y.workerUrl,_y.workerParams)}const vy="mapboxgl_preloaded_worker_pool";class xy{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[vy]}numActive(){return Object.keys(this.active).length}}let by;function wy(){return by||(by=new xy),by}xy.workerCount=2;let Sy,My,Ay,Ey,Ty,Cy=null;function ky(){return gn()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:My||r.DRACO_URL}function Iy(){if(gn()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(Ey)return Ey;const e=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return Ey=WebAssembly.validate(e)?r.MESHOPT_SIMD_URL:r.MESHOPT_URL,Ey}const Py={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ry={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},Ly={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function zy(e,t,n){const r=n.json.bufferViews.length,i=n.buffers.length;t.bufferView=r,n.json.bufferViews[r]={buffer:i,byteLength:e.byteLength},n.buffers[i]=e}const Oy="KHR_draco_mesh_compression";function Dy(e,t){const n=e.extensions&&e.extensions[Oy];if(!n)return;const r=new Ay.Decoder,i=Gy(t,n.bufferView),o=new Ay.Mesh;if(!r.DecodeArrayToMesh(i,i.byteLength,o))throw new Error("Failed to decode Draco mesh");const a=t.json.accessors[e.indices],s=Py[a.componentType],l=a.count*s.BYTES_PER_ELEMENT,c=Ay._malloc(l);s===Uint16Array?r.GetTrianglesUInt16Array(o,l,c):r.GetTrianglesUInt32Array(o,l,c),zy(Ay.memory.buffer.slice(c,c+l),a,t),Ay._free(c);for(const u of Object.keys(n.attributes)){const i=r.GetAttributeByUniqueId(o,n.attributes[u]),a=t.json.accessors[e.attributes[u]],s=Ry[a.componentType],l=a.count*Ly[a.type]*Py[a.componentType].BYTES_PER_ELEMENT,c=Ay._malloc(l);r.GetAttributeDataArrayForAllPoints(o,i,Ay[s],l,c),zy(Ay.memory.buffer.slice(c,c+l),a,t),Ay._free(c)}r.destroy(),o.destroy(),delete e.extensions[Oy]}const By="EXT_meshopt_compression";function Fy(e,t){if(!e.extensions||!e.extensions[By])return;const n=e.extensions[By],r=new Uint8Array(t.buffers[n.buffer],n.byteOffset||0,n.byteLength||0),i=new Uint8Array(n.count*n.byteStride);Ty.decodeGltfBuffer(i,n.count,n.byteStride,r,n.mode,n.filter),e.buffer=t.buffers.length,e.byteOffset=0,t.buffers[e.buffer]=i.buffer,delete e.extensions[By]}const Ny=1179937895,jy=new TextDecoder("utf8");function Vy(e,t){return new URL(e,t).href}function Uy(e,t,n,r){return fetch(Vy(e.uri,r)).then((e=>e.arrayBuffer())).then((e=>{t.buffers[n]=e}))}function Gy(e,t){const n=e.json.bufferViews[t];return new Uint8Array(e.buffers[n.buffer],n.byteOffset||0,n.byteLength)}function qy(e,t,n,r){if(e.uri){const i=Vy(e.uri,r);return fetch(i).then((e=>e.blob())).then((e=>createImageBitmap(e))).then((e=>{t.images[n]=e}))}if(void 0!==e.bufferView){const r=Gy(t,e.bufferView),i=new Blob([r],{type:e.mimeType});return createImageBitmap(i).then((e=>{t.images[n]=e}))}}function Wy(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===Ny){const n=new Uint32Array(e,t);let i=2;const o=(n[i++]>>2)-3,a=n[i++]>>2;if(i++,r.json=JSON.parse(jy.decode(n.subarray(i,i+a))),i+=a,i{const e=[],t=s&&s.includes(Oy),i=s&&s.includes(By);if(t&&e.push(function(){if(!Ay)return Sy||(Sy=function(e){let t,n=null;function r(){t=new Uint8Array(n.buffer)}function i(){throw new Error("Unexpected Draco error.")}const o={a:{a:i,d:function(e,n,r){return t.copyWithin(e,n,n+r)},c:function(e){const i=t.length,o=Math.max(e>>>0,Math.ceil(1.2*i)),a=Math.ceil((o-i)/65536);try{return n.grow(a),r(),!0}catch(e){return!1}},b:i}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,o)))).then((e=>{const{Rb:i,Qb:o,P:a,T:s,X:l,Ja:c,La:u,Qa:h,Va:d,Wa:f,eb:p,jb:m,f:g,e:_,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:S}=e.instance.exports;n=_;const M=(()=>{let e=0,n=0,r=0,a=0;return s=>{r&&(i(a),i(e),n+=r,r=e=0),e||(n+=128,e=o(n));const l=s.length+7&-8;let c=e;l>=n&&(r=l,c=a=o(l));for(let e=0;e{Ay=e,Sy=void 0})))}()),i&&e.push(function(){if(Ty)return;const e=function(e){let t;const n=WebAssembly.instantiateStreaming(e,{}).then((e=>{t=e.instance,t.exports.__wasm_call_ctors()})),r={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},i={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:n,supported:!0,decodeGltfBuffer(e,n,o,a,s,l){!function(e,t,n,r,i,o,a){const s=e.exports.sbrk,l=r+3&-4,c=s(l*i),u=s(o.length),h=new Uint8Array(e.exports.memory.buffer);h.set(o,u);const d=t(c,r,i,u,o.length);if(0===d&&a&&a(c,l,i),n.set(h.subarray(c,c+r*i)),s(c-s(0)),0!==d)throw new Error("Malformed buffer data: ".concat(d))}(t,t.exports[i[s]],e,n,o,a,t.exports[r[l]])}}}(fetch(Iy()));return e.ready.then((()=>{Ty=e}))}()),o)for(let a=0;a{if(t&&a)for(const{primitives:e}of a)for(const t of e)Dy(t,r);if(i&&a&&l)for(const e of l)Fy(e,r);return r}))}))}class Hy{constructor(e,t,n,r){if(this.triangleCount=t.length/3,this.min=new jt(0,0),this.max=new jt(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length)return;const[i,o]=[e[0].clone(),e[0].clone()];for(let u=1;ue.cellIdx-t.cellIdx||e.triIdx-t.triIdx));let c=0;for(;cthis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let s=0;s0){for(let i=0;i0){o.texcoordArray=new Pl;const e=t.json.accessors[i.TEXCOORD_0];o.texcoordArray.resize(e.count);const n=Yy(t,e);Qy(t,e,o.texcoordArray,n)}if(void 0!==i._FEATURE_ID_RGBA4444){const e=t.json.accessors[i._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=Yy(t,e))}void 0!==i._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(Yy(t,t.json.accessors[i._FEATURE_RGBA4444]).buffer));const h=e.material;return o.material=function(e,t){const{emissiveFactor:n=[0,0,0],alphaMode:r="OPAQUE",alphaCutoff:i=.5,normalTexture:o,occlusionTexture:a,emissiveTexture:s,doubleSided:l}=e,{baseColorFactor:c=[1,1,1,1],metallicFactor:u=1,roughnessFactor:h=1,baseColorTexture:d,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},p=a?t[a.index]:void 0;if(a&&a.extensions&&a.extensions.KHR_texture_transform&&p){const e=a.extensions.KHR_texture_transform;p.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new Ur(...c),metallicFactor:u,roughnessFactor:h,baseColorTexture:d?t[d.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:n,alphaMode:r,alphaCutoff:i,normalTexture:o?t[o.index]:void 0,occlusionTexture:p,emissionTexture:s?t[s.index]:void 0,defined:void 0===e.defined}}(void 0!==h?t.json.materials[h]:{defined:!1},n),o}function Ky(t,n,r){const{matrix:i,rotation:o,translation:a,scale:s,mesh:l,extras:c,children:u}=t,h={};if(h.matrix=i||e.a9.fromRotationTranslationScale([],o||[0,0,0,1],a||[0,0,0],s||[1,1,1]),void 0!==l){h.meshes=r[l];const e=h.anchor=[0,0];for(const t of h.meshes){const{min:n,max:r}=t.aabb;e[0]+=n[0]+r[0],e[1]+=n[1]+r[1]}e[0]=Math.floor(e[0]/h.meshes.length/2),e[1]=Math.floor(e[1]/h.meshes.length/2)}if(c&&(c.id&&(h.id=c.id),c.lights&&(h.lights=function(e){if(!e.length)return[];const t=function(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r1&&r[r.length-1].equals(r[0])&&r.pop();let i=0;for(let a=0;a0&&r.reverse();const o=Nd(r.flatMap((e=>[e.x,e.y])),[]);return 0===o.length?null:{vertices:r,indices:o}}function ev(t,n){const r=[],i=[];let o=0;const a=[];for(const s of t){o=r.length;const t=s.vertexArray.float32,l=s.indexArray.uint16;for(let i=0;i0&&([i[e+1],i[e+2]]=[i[e+2],i[e+1]])}return{vertices:r,indices:i}}function tv(e){const t=function(e,t){const n=[],r=WebGL2RenderingContext;if(e.json.textures)for(const i of e.json.textures){const o={magFilter:r.LINEAR,minFilter:r.NEAREST,wrapS:r.REPEAT,wrapT:r.REPEAT};void 0!==i.sampler&&Object.assign(o,e.json.samplers[i.sampler]),n.push({image:t[i.source],sampler:o,uploaded:!1})}return n}(e,e.images),n=function(e,t){const n=[];for(const r of e.json.meshes){const i=[];for(const n of r.primitives)i.push(Xy(n,e,t));n.push(i)}return n}(e,t),{scenes:r,scene:i,nodes:o}=e.json,a=r?r[i||0].nodes:o,s=[];for(const l of a)s.push(Ky(o[l],e,n));return function(e,t,n){const r={},i=new Set;for(let o=0;o0){const t=Array.from(i.values()).sort(((e,t)=>e-t));for(let n=t.length-1;n>=0;n--)e.splice(t[n],1)}}(s,a,e.json.nodes),s}function nv(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,n=e.aabb.min[0]-1,r=e.aabb.min[1]-1,i=oy/(e.aabb.max[0]-n+2),o=oy/(e.aabb.max[1]-r+2);for(let a=0;ae.heightmap[c*oy+l]&&(e.heightmap[c*oy+l]=s)}}function rv(t,n){const r={};r.indexArray=new Gl,r.indexArray.reserve(4*t.length),r.vertexArray=new Kl,r.vertexArray.reserve(10*t.length),r.colorArray=new Il,r.vertexArray.reserve(10*t.length);let i=0;for(const s of t){const t=Math.min(10,Math.max(4,1.3*s.height))*n,o=[-s.normal[1],s.normal[0],0],a=Math.min(.29,.1*s.width/s.depth),l=s.width-2*s.depth*n*(a+.01),c=e.Q.scaleAndAdd([],s.pos,o,l/2),u=e.Q.scaleAndAdd([],s.pos,o,-l/2),h=[c[0],c[1],c[2]+s.height],d=[u[0],u[1],u[2]+s.height],f=e.Q.scaleAndAdd([],s.normal,o,a);e.Q.scale(f,f,t);const p=e.Q.scaleAndAdd([],s.normal,o,-a);e.Q.scale(p,p,t),e.Q.add(f,c,f),e.Q.add(p,u,p),c[2]+=.1,u[2]+=.1,r.vertexArray.emplaceBack(f[0],f[1],f[2]),r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(c[0],c[1],c[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(h[0],h[1],h[2]),r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(c[0],c[1],c[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]),r.vertexArray.emplaceBack(p[0],p[1],p[2]);const m=l/t/2;r.colorArray.emplaceBack(-m-a,-1,m,.8),r.colorArray.emplaceBack(m+a,-1,m,.8),r.colorArray.emplaceBack(-m,0,m,1.3),r.colorArray.emplaceBack(m,0,m,1.3),r.colorArray.emplaceBack(m+a,-.8,m,.7),r.colorArray.emplaceBack(m+a,-.8,m,.7),r.colorArray.emplaceBack(0,0,m,1.3),r.colorArray.emplaceBack(0,0,m,1.3),r.colorArray.emplaceBack(m+a,-1.2,m,.8),r.colorArray.emplaceBack(m+a,-1.2,m,.8),r.indexArray.emplaceBack(6+i,4+i,8+i),r.indexArray.emplaceBack(7+i,9+i,5+i),r.indexArray.emplaceBack(0+i,1+i,2+i),r.indexArray.emplaceBack(1+i,3+i,2+i),i+=10}const o={defined:!0,emissiveFactor:[0,0,0]},a={};return a.baseColorFactor=Ur.white,o.pbrMetallicRoughness=a,r.material=o,r.aabb=new mh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}ps(Hy,"TriangleGridIndex");class iv{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t5&&void 0!==arguments[5]?arguments[5]:0,a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,r,i,o);const l=this.grid;for(let c=0;c=0&&n[3]>=0&&l.insert(s,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new df(new wm(this.rawTileData)).layers,this.sourceLayerCoder=new iv(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,n,r){var i=this;this.loadVTLayers();const o=e.params||{},a=rl(o.filter),s=e.tileResult,l=e.transform,c=s.bufferedTilespaceBounds,u=this.grid.query(c.min.x,c.min.y,c.max.x,c.max.y,((e,t,n,r)=>Ju(s.bufferedTilespaceGeometry,e,t,n,r)));u.sort(cv);let h=null;l.elevation&&u.length>0&&(h=zf.create(l.elevation,this.tileID));const d={};let f;for(let p=0;p3&&void 0!==arguments[3]?arguments[3]:0;return g||(g=Bu(t,i.tileID.canonical,e.tileTransform)),n.queryIntersectsFeature(s,t,r,g,i.z,e.transform,e.pixelPosMatrix,h,o)}))}return d}loadMatchingFeature(e,t,n,r,i,o,a,s,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:d}=t,f=this.bucketLayerIDs[u];if(r&&!function(e,t){for(let n=0;n=0)return!0;return!1}(r,f))return;const p=this.sourceLayerCoder.decode(h),m=this.vtLayers[p].feature(c);if(n.needGeometry){const e=Fu(m,!0);if(!n.filter(new js(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new js(this.tileID.overscaledZ),m))return;const g=this.getId(m,p);for(let _=0;_{const a=t instanceof Ys?t.get(o):null;return a&&a.evaluate?a.evaluate(n,r,i):a}))}function cv(e,t){return t-e}ps(sv,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const uv=new Float32Array(262144),hv=new Uint8Array(262144);function dv(e){let t=0;if(e.meshes)for(const n of e.meshes)t=Math.max(t,n.aabb.max[2]);if(e.children)for(const n of e.children)t=Math.max(t,dv(n));return t}function fv(e,t,n){if(e.meshes)for(const r of e.meshes)r.aabb.min[0]!==1/0&&n.insert(t,r.aabb.min[0],r.aabb.min[1],r.aabb.max[0],r.aabb.max[1]);if(e.children)for(const r of e.children)fv(r,t,n)}const pv=["","wall","door","roof","window","lamp","logo"];class mv{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:e.id,geometry:[],properties:{height:dv(e)}}}getLocalBounds(){if(!this.node.meshes)return new mh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const t=new mh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const n of this.node.meshes)this.node.lightMeshIndex!==e&&t.encapsulate(n.aabb),e++;this.aabb=mh.applyTransform(t,this.node.matrix)}return this.aabb}}class gv{constructor(e,t,n,r,i,o){this.id=t,this.modelTraits|=ay.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=ay.HasMapboxMeshFeatures),r&&(this.modelTraits|=ay.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=i,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const a of e)this.nodesInfo.push(new mv(a)),fv(a,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0)}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const n of t){const t=n.node;this.uploaded?this.updatePbrBuffer(t):uy(t,e,!0)}for(const n of t)hy(n.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const n of e.meshes)n.pbrBuffer&&(n.pbrBuffer.updateData(n.featureArray),t=!0);return t}needsReEvaluation(e,t,n){const r=e.transform.projectionOptions,i=e.style.getBrightness(),o=this.brightness!==i;return!!(!this.uploaded||this.dirty||r.name!==this.projection.name||_v(n.paint.get("model-color").value,o)||_v(n.paint.get("model-color-mix-intensity").value,o)||_v(n.paint.get("model-roughness").value,o)||_v(n.paint.get("model-emissive-strength").value,o)||_v(n.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=r,this.brightness=i,!0)}evaluateScale(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const n=this.getNodesInfo(),r=this.id.canonical;for(const i of n){const e=i.feature;i.evaluatedScale=t.paint.get("model-scale").evaluate(e,{},r)}}evaluate(e){const t=this.getNodesInfo();for(const n of t){if(!n.node.meshes)continue;const t=n.feature,r=n.node.meshes&&n.node.meshes[0].featureData,i=n.evaluatedColor[2],o=n.evaluatedRMEA[2],a=this.id.canonical;if(n.hasTranslucentParts=!1,r){for(let r=0;r=a)continue;const h=uv[c],d=Math.abs(h);d>s&&(i=h,s=d,l=r,u=t)}if(s>.1){const o=1-(a+.5*Math.abs(l*u))/c;let s=t._dem.get(n,e)+i*o;const h=t._dem.get(n+l,e+u),d=t._dem.get(n-l,e-u,!0);(s-h)*(s-d)>0&&(s=(h+d)/2),uv[r]=t._dem.set(n,e,s),hv[r]=a}}}}}a&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=Rn.now())}getNodesInfo(){return this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)hy(t.node),dy(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped()),r=this.getNodesInfo();for(let i=0;it.footprint===e.footprint))}}getHeightAtTileCoord(t,n){const r=this.getNodesInfo(),i=[],o=[0,0,0];for(let a=0;ac.max[0]||n>c.max[1])continue;const u=(t-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*oy|0,h=Math.min(63,(n-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*oy|0)*oy+Math.min(63,u);if(o[2]=l.heightmap[h],e.Q.transformMat4(o,o,s.node.matrix),!(l.heightmap[h]<0&&s.node.footprint)){if(s.hiddenByReplacement)return;return{height:o[2],maxHeight:s.feature.properties.height,hidden:!1,verticalScale:s.evaluatedScale[2]}}if(s.node.footprint.grid.query(new jt(t,n),new jt(t,n),i),i.length>0)return{height:void 0,maxHeight:s.feature.properties.height,hidden:s.hiddenByReplacement,verticalScale:s.evaluatedScale[2]}}}}function _v(e,t){return!e.isLightConstant&&t}function yv(e,t,n,r,i,o,a,s){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,u=240&t|(240&t)>>4;n[3]>0&&(l=Gr(l,255*n[0],n[3]),c=Gr(c,255*n[1],n[3]),u=Gr(u,255*n[2],n[3]));const h=l<<8|c,d=u<<8|Math.floor(255*r[3]),f=function(e){const t=Qt(e,0,2);return Math.min(Math.round(.5*t*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],p=Qt(i[0],0,1),m=Qt(i[1],0,1),g=Qt(i[2],0,1),_=Qt(i[3],0,1);let y,v,x,b;if(p!==m&&a!==o&&m!==p){const e=a-o;v=1/(e*(m-p)),x=-(o+e*p)/(e*(m-p));const t=Qt(i[4],-1,1);b=Math.pow(10,t),y=255*g<<8|255*_}else y=65535,v=0,x=1,b=1;if(e.emplaceBack(h,d,f,y,v,x,b),s){const e=s.length;s.clear();for(let t=0;t>16&65535,s=o?t>>16&65535:65535&t,l=(15&s)<8?15&s:0,c=e.evaluatedRMEA[l],u=e.evaluatedColor[l],h=e.emissionHeightBasedParams[l];let d;if(n&&2===l&&r.lights&&(d=new $l,d.resize(10*r.lights.length)),yv(a.featureArray,i,u,c,h,a.aabb.min[2],a.aabb.max[2],d),d&&n){n=!1;const e=r.meshes[r.lightMeshIndex];e.featureArray=d,e.featureArray._trim()}}a.featureArray._trim(),i++}}function xv(e,t,n,r){const i=1<e.polygon)).flat());const _=p?l:null,[y,v]=function(t,n,r,i,o,a,s,l,c,u,h){return"globe"===t.projection.name?function(t,n,r,i,o,a,s,l,c,u,h){const d=[],f=[],p=t.projection.upVectorScale(h,t.center.lat,t.worldSize).metersToTile,m=[0,0,0,1],g=[0,0,0,1],_=(e,t,n,r)=>{e[0]=t,e[1]=n,e[2]=r,e[3]=1},y=ap();r>0&&(r+=y),i+=y;for(const v of n){const n=[],y=[];for(const d of v){const f=d.x+o.x,v=d.y+o.y,x=t.projection.projectTilePoint(f,v,h),b=t.projection.upVector(h,d.x,d.y);let w=r,S=i;if(s){const e=pp(f,v,r,i,s,l,c,u);w+=e.base,S+=e.top}0!==r?_(m,x.x+b[0]*p*w,x.y+b[1]*p*w,x.z+b[2]*p*w):_(m,x.x,x.y,x.z),_(g,x.x+b[0]*p*S,x.y+b[1]*p*S,x.z+b[2]*p*S),e.Q.transformMat4(m,m,a),e.Q.transformMat4(g,g,a),n.push(new hp(m[0],m[1],m[2])),y.push(new hp(g[0],g[1],g[2]))}d.push(n),f.push(y)}return[d,f]}(t,n,r,i,o,a,s,l,c,u,h):s?function(t,n,r,i,o,a,s,l,c){const u=[],h=[],d=[0,0,0,1];for(const f of t){const t=[],p=[];for(const u of f){const h=u.x+i.x,f=u.y+i.y,m=pp(h,f,n,r,a,s,l,c);d[0]=h,d[1]=f,d[2]=m.base,d[3]=1,e.aa.transformMat4(d,d,o),d[3]=Math.max(d[3],1e-5);const g=new hp(d[0]/d[3],d[1]/d[3],d[2]/d[3]);d[0]=h,d[1]=f,d[2]=m.top,d[3]=1,e.aa.transformMat4(d,d,o),d[3]=Math.max(d[3],1e-5);const _=new hp(d[0]/d[3],d[1]/d[3],d[2]/d[3]);t.push(g),p.push(_)}u.push(t),h.push(p)}return[u,h]}(n,r,i,o,a,s,l,c,u):function(e,t,n,r,i){const o=[],a=[],s=i[8]*t,l=i[9]*t,c=i[10]*t,u=i[11]*t,h=i[8]*n,d=i[9]*n,f=i[10]*n,p=i[11]*n;for(const m of e){const e=[],t=[];for(const n of m){const o=n.x+r.x,a=n.y+r.y,m=i[0]*o+i[4]*a+i[12],g=i[1]*o+i[5]*a+i[13],_=i[2]*o+i[6]*a+i[14],y=i[3]*o+i[7]*a+i[15],v=m+s,x=g+l,b=_+c,w=Math.max(y+u,1e-5),S=m+h,M=g+d,A=_+f,E=Math.max(y+p,1e-5);e.push(new hp(v/w,x/w,b/w)),t.push(new hp(S/E,M/E,A/E))}o.push(e),a.push(t)}return[o,a]}(n,r,i,o,a)}(a,i,d,h,u,s,_,f,m,a.center.lat,t.tileID.canonical),x=t.queryGeometry;return function(e,t,n){let r=1/0;qu(n,t)&&(r=fp(n,t[0]));for(let i=0;i=3)for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=n,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.keys()).map((e=>[e,this.get(e)]))}evict(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0]||this.size>0){const e=this.first;delete this.items[e.key],0==--this.size?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t;if(this.has(e)){const n=this.items[e];this.ttl>0&&n.expiry<=Date.now()?this.delete(e):(t=n.value,this.set(e,t,!0))}return t}has(e){return e in this.items}keys(){const e=[];let t=this.first;for(;null!==t;)e.push(t.key),t=t.next;return e}set(e,t){let n,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.resetTtl;if(r||this.has(e)){if(n=this.items[e],n.value=t,!1===r&&i&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==n){const e=this.last,t=n.next,r=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,e.next=n,null!==r&&(r.next=t),null!==t&&(t.prev=r)}}else this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},1==++this.size?this.first=n:this.last.next=n;return this.last=n,this}values(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.keys()).map((e=>this.get(e)))}}function Av(e,t){if(4!==t.length)throw new Error("Expected data of dimension 4 but got ".concat(t.length,"."));let n=t[3];for(let r=2;r>=1;r--){const i=1===r?1:0,o=2===r?1:0;for(let r=0;r>>1^-(1&e[t]);return e}function Tv(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t>4|(61440&n)>>8|(240&r)<<4|61440&r,e[t+1]=15&n|(3840&n)>>4|(15&r)<<8|(3840&r)<<4}return e;case"uint8":for(let t=0;t>6|(192&r)>>4|(192&i)>>2|192&o,e[t+1]=(48&n)>>4|(48&r)>>2|48&i|(48&o)<<2,e[t+2]=(12&n)>>2|12&r|(12&i)<<2|(12&o)<<4,e[t+3]=3&n|(3&r)<<2|(3&i)<<4|(3&o)<<6}return e;default:throw new Error('Invalid pixel format, "'.concat(t,'"'))}}class Cv extends Error{constructor(e){super(e),this.name="MRTError"}}var kv=Uint8Array,Iv=Uint16Array,Pv=Int32Array,Rv=new kv([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Lv=new kv([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),zv=new kv([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ov=function(e,t){for(var n=new Iv(31),r=0;r<31;++r)n[r]=t+=1<>1|(21845&Vv)<<1;jv[Vv]=((65280&(Uv=(61680&(Uv=(52428&Uv)>>2|(13107&Uv)<<2))>>4|(3855&Uv)<<4))>>8|(255&Uv)<<8)>>1}var Gv=function(e,t,n){for(var r=e.length,i=0,o=new Iv(t);i>l]=c}else for(a=new Iv(r),i=0;i>15-e[i]);return a},qv=new kv(288);for(Vv=0;Vv<144;++Vv)qv[Vv]=8;for(Vv=144;Vv<256;++Vv)qv[Vv]=9;for(Vv=256;Vv<280;++Vv)qv[Vv]=7;for(Vv=280;Vv<288;++Vv)qv[Vv]=8;var Wv=new kv(32);for(Vv=0;Vv<32;++Vv)Wv[Vv]=5;var Hv=Gv(qv,9,1),Zv=Gv(Wv,5,1),Yv=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},Qv=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},Xv=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Kv=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Jv=function(e,t,n){var r=new Error(t||Kv[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Jv),!n)throw r;return r},$v=new kv(0),ex="undefined"!=typeof TextDecoder&&new TextDecoder;try{ex.decode($v,{stream:!0})}catch(e){}const tx={gzip_data:"gzip"},nx={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},rx={uint32:1,uint16:2,uint8:4},ix={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class ox{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){return this.layers[e]}getHeaderLength(e){const t=new Uint8Array(e),n=new DataView(e);if(13!==t[0])throw new Cv("File is not a valid MRT.");return n.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),n=this.getHeaderLength(e);if(t.length= ".concat(n," but got buffer of length ").concat(t.length));const r=new wm(t.subarray(0,n)),i=wv.read(r);if(!isNaN(this.x)&&(this.x!==i.x||this.y!==i.y||this.z!==i.z))throw new Cv("Invalid attempt to parse header ".concat(i.z,"/").concat(i.x,"/").concat(i.y," for tile ").concat(this.z,"/").concat(this.x,"/").concat(this.y));this.x=i.x,this.y=i.y,this.z=i.z;for(const o of i.layers)this.layers[o.name]=new ax(o,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],n=this.getLayer(e.layerName);for(let r=0;re.lastBlock)continue;if(n._blocksInProgress.has(r))continue;const s={layerName:n.name,firstByte:o,lastByte:a,pixelFormat:n.pixelFormat,blockIndex:r,blockShape:[i.bands.length].concat(n.bandShape),buffer:n.buffer,codec:i.codec.codec,filters:i.filters.map((e=>e.filter))};n._blocksInProgress.add(r),t.push(s)}return new sx(t,(()=>{t.forEach((e=>n._blocksInProgress.delete(e.blockIndex)))}),((e,r)=>{if(t.forEach((e=>n._blocksInProgress.delete(e.blockIndex))),e)throw e;r.forEach((e=>{this.getLayer(e.layerName).processDecodedData(e)}))}))}}class ax{constructor(e,t){let{version:n,name:r,units:i,tilesize:o,pixel_format:a,buffer:s,data_index:l}=e;if(this.version=n,1!==this.version)throw new Cv("Cannot parse raster layer encoded with MRT version ".concat(n));this.name=r,this.units=i,this.tileSize=o,this.buffer=s,this.pixelFormat=nx[a],this.dataIndex=l,this.bandShape=[o+2*s,o+2*s,rx[this.pixelFormat]],this._decodedBlocks=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof n)throw new TypeError("Invalid resetTtl value");return new Mv(e,t,n)}(t?t.cacheSize:5),this._blocksInProgress=new Set}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.set(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[n,r]of this.dataIndex.entries()){for(const[i,o]of r.bands.entries())if(o===e)return{bandIndex:t+i,blockIndex:n,blockBandIndex:i};t+=r.bands.length}break;case"number":for(const[n,r]of this.dataIndex.entries()){if(e>=t&&e=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:n}=this.getBlockForBand(e),r=this._decodedBlocks.get(t.toString());if(!r)throw new Cv("Data for band ".concat(JSON.stringify(e),' of layer "').concat(this.name,'" not decoded.'));const i=this.dataIndex[t],o=this.bandShape.reduce(((e,t)=>e*t),1),a=n*o,s=r.subarray(a,a+o);return{data:s,bytes:new Uint8Array(s.buffer).subarray(s.byteOffset,s.byteOffset+s.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:i.offset,scale:i.scale}}}class sx{constructor(e,t,n){this.tasks=e,this._onCancel=t,this._onComplete=n,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}ox.performDecoding=function(e,t){return Promise.all(t.tasks.map((t=>{const{layerName:n,firstByte:r,lastByte:i,pixelFormat:o,blockShape:a,blockIndex:s,filters:l,codec:c}=t,u=new Uint8Array(e).subarray(r,i+1),h=new Uint32Array(a[0]*a[1]*a[2]);let d;if("gzip_data"!==c)throw new Error("Unhandled codec: ".concat(c));return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||Jv(6,"invalid gzip data");var t=e[3],n=10;4&t&&(n+=2+(e[10]|e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(2&t)}(i=e))+8>i.length&&Jv(6,"invalid gzip data"),function(e,t,n,r){var i=e.length;if(!i||t.f&&!t.l)return n||new kv(0);var o=!n,a=o||2!=t.i,s=t.i;o&&(n=new kv(3*i));var l,c,u=function(e){var t=n.length;if(e>t){var r=new kv(Math.max(2*t,e));r.set(n),n=r}},h=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,g=t.m,_=t.n,y=8*i;do{if(!p){h=Qv(e,d,1);var v=Qv(e,d+1,3);if(d+=3,!v){var x=e[(P=4+((d+7)/8|0))-4]|e[P-3]<<8,b=P+x;if(b>i){s&&Jv(0);break}a&&u(f+x),n.set(e.subarray(P,b),f),t.b=f+=x,t.p=d=8*b,t.f=h;continue}if(1==v)p=Hv,m=Zv,g=9,_=5;else if(2==v){var w=Qv(e,d,31)+257,S=Qv(e,d+10,15)+4,M=w+Qv(e,d+5,31)+1;d+=14;for(var A=new kv(M),E=new kv(19),T=0;T>4)<16)A[T++]=P;else{var L=0,z=0;for(16==P?(z=3+Qv(e,d,3),d+=2,L=A[T-1]):17==P?(z=3+Qv(e,d,7),d+=3):18==P&&(z=11+Qv(e,d,127),d+=7);z--;)A[T++]=L}}var O=A.subarray(0,w),D=A.subarray(w);g=Yv(O),_=Yv(D),p=Gv(O,g,1),m=Gv(D,_,1)}else Jv(1);if(d>y){s&&Jv(0);break}}a&&u(f+131072);for(var B=(1<>4;if((d+=15&L)>y){s&&Jv(0);break}if(L||Jv(2),j<256)n[f++]=j;else{if(256==j){N=d,p=null;break}var V=j-254;j>264&&(V=Qv(e,d,(1<<(q=Rv[T=j-257]))-1)+Bv[T],d+=q);var U=m[Xv(e,d)&F],G=U>>4;if(U||Jv(3),d+=15&U,D=Nv[G],G>3){var q=Lv[G];D+=Xv(e,d)&(1<y){s&&Jv(0);break}a&&u(f+131072);var W=f+V;if(fl.length)&&(c=l.length),new kv(l.subarray(0,c))):n.subarray(0,f)}(i.subarray(o,-8),{i:2},new kv(((n=i)[(r=n.length)-4]|n[r-3]<<8|n[r-2]<<16|n[r-1]<<24)>>>0))));var n,r,i,o;const a=tx[t];if(!a)throw new Error("Unhandled codec: ".concat(t));const s=new globalThis.DecompressionStream(a);return new Response(new Blob([e]).stream().pipeThrough(s)).arrayBuffer().then((e=>new Uint8Array(e)))}(u,c).then((e=>{const t=Sv.read(new wm(e));if("uint32_values"===t.values)return t.uint32_values.readValuesInto(h),new(0,ix[o])(h.buffer);throw new Error('Unhandled numeric data "'.concat(t.values,'"'))})),d.then((e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":Av(e,a);break;case"zigzag_filter":Ev(e);break;case"bitshuffle_filter":Tv(e,o);break;default:throw new Error('Unhandled filter "'.concat(l[t],'"'))}return{layerName:n,blockIndex:s,data:e}})).catch((e=>{throw e}))})))},ps(sx,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});const lx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class cx{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,n]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=n>>4;if(1!==r)throw new Error("Got v".concat(r," data when expected v1."));const i=lx[15&n];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new cx(a,o,i,e)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Float64Array,r=arguments.length>3?arguments[3]:void 0;if(isNaN(e)||e<0)throw new Error("Unpexpected numItems value: ".concat(e,"."));this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const i=lx.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-a%8)%8;if(i<0)throw new Error("Unexpected typed array class: ".concat(n,"."));r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+a+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error("Added ".concat(e," items when expected ").concat(this.numItems,"."));return ux(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,s=[0,i.length-1,0],l=[];for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=a){for(let a=h;a<=u;a++){const s=o[2*a],c=o[2*a+1];s>=e&&s<=n&&c>=t&&c<=r&&l.push(i[a])}continue}const d=h+u>>1,f=o[2*d],p=o[2*d+1];f>=e&&f<=n&&p>=t&&p<=r&&l.push(i[d]),(0===c?e<=f:t<=p)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?n>=f:r>=p)&&(s.push(d+1),s.push(u),s.push(1-c))}return l}within(e,t,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:i,nodeSize:o}=this,a=[0,r.length-1,0],s=[],l=n*n;for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=o){for(let n=h;n<=u;n++)px(i[2*n],i[2*n+1],e,t)<=l&&s.push(r[n]);continue}const d=h+u>>1,f=i[2*d],p=i[2*d+1];px(f,p,e,t)<=l&&s.push(r[d]),(0===c?e-n<=f:t-n<=p)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?e+n>=f:t+n>=p)&&(a.push(d+1),a.push(u),a.push(1-c))}return s}}function ux(e,t,n,r,i,o){if(i-r<=n)return;const a=r+i>>1;hx(e,t,a,r,i,o),ux(e,t,n,r,a-1,1-o),ux(e,t,n,a+1,i,1-o)}function hx(e,t,n,r,i,o){for(;i>r;){if(i-r>600){const a=i-r+1,s=n-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(a-c)/a)*(s-a/2<0?-1:1);hx(e,t,n,Math.max(r,Math.floor(n-s*c/a+u)),Math.min(i,Math.floor(n+(a-s)*c/a+u)),o)}const a=t[2*n+o];let s=r,l=i;for(dx(e,t,r,n),t[2*i+o]>a&&dx(e,t,r,i);sa;)l--}t[2*r+o]===a?dx(e,t,r,l):(l++,dx(e,t,l,i)),l<=n&&(r=l+1),n<=l&&(i=l-1)}}function dx(e,t,n,r){fx(e,n,r),fx(t,2*n,2*r),fx(t,2*n+1,2*r+1)}function fx(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function px(e,t,n,r){const i=e-n,o=t-r;return i*i+o*o}e.$=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function(e){let[t,n]=e;const r=mn([1,t,n]);return{x:r.x,y:r.y,z:r.z}}(e.expression.evaluate(t))}interpolate(e,t,n){return{x:Gr(e.x,t.x,n),y:Gr(e.y,t.y,n),z:Gr(e.z,t.z,n)}}},e.A=nl,e.B=Za,e.C=Ii,e.D=qa,e.E=Dr,e.F=function(e){const t=e.value;let n=[];if(!t)return n;const r=Ai(t);return"string"!==r?(n=n.concat([new J_(e.key,t,'string expected, "'.concat(r,'" found'))]),n):($_(t,!0)||(n=n.concat([new J_(e.key,t,'invalid url "'.concat(t,'"'))])),n)},e.G=tl,e.H=Js,e.I=eg,e.J=Qs,e.K=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return mn(e.expression.evaluate(t))}interpolate(e,t,n){return{x:Gr(e.x,t.x,n),y:Gr(e.y,t.y,n),z:Gr(e.z,t.z,n),azimuthal:Gr(e.azimuthal,t.azimuthal,n),polar:Gr(e.polar,t.polar,n)}}},e.L=Gs,e.M=class{constructor(e,t,n,r){this.id=e,this.position=null!=t?new au(t[0],t[1]):new au(0,0),this.orientation=null!=n?n:[0,0,0],this.nodes=r,this.uploaded=!1,this.aabb=new mh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,n){if(e.a9.multiply(t.matrix,n,t.matrix),t.meshes)for(const e of t.meshes){const n=mh.applyTransform(e.aabb,t.matrix);this.aabb.encapsulate(n)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=e.a9.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(e,t,n,r,i,o){let a=arguments.length>6&&void 0!==arguments[6]&&arguments[6];sy(this.matrix,this,e.transform,this.position,t,n,r,i,o,a)}upload(e){if(!this.uploaded){for(const t of this.nodes)uy(t,e);for(const e of this.nodes)hy(e);this.uploaded=!0}}destroy(){for(const e of this.nodes)dy(e)}},e.N=js,e.O=ku,e.P=jt,e.R=Xn,e.S=Xt,e.T=v_,e.U=Ys,e.V=J_,e.W=Nh,e.X=Gr,e.Y=io,e.Z=os,e._=qr,e.a=Or,e.a$=an,e.a0=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const i=new jt(n,n),o=e.sub(i),a=t.add(i),s=[o,new jt(a.x,o.y),a,new jt(o.x,a.y)];return r&&s.push(o.clone()),s},e.a1=function(e,t){const n=[];for(let r=0;r2&&void 0!==arguments[2]?arguments[2]:0;return e.Q.fromValues(((n.x-r)*t.scale-t.x)*io,(n.y*t.scale-t.y)*io,Su(n.z,n.y))},e.a5=lh,e.a6=Cp,e.a7=function(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x),i=Math.max(i,o.y);return{min:new jt(t,n),max:new jt(r,i)}},e.a8=yu,e.aA=Ur,e.aB=Sl,e.aC=La,e.aD=ec,e.aE=mc,e.aF=tn,e.aG=rc,e.aH=c_,e.aI=function(){Ns.isLoading()||Ns.isLoaded()||"deferred"!==Bs()||Fs()},e.aJ=rl,e.aK=Fu,e.aL=av,e.aM=_n,e.aN=Ap,e.aO=qd,e.aP=Bu,e.aQ=Al,e.aR=Xl,e.aS=vh,e.aT=Nd,e.aU=y_,e.aV=function(t,n){const r=Nh(n.zoom);if(0===r)return Ah(t);const i=kh(t),o=Ih(i),a=yu(i.getWest())*n.worldSize,s=yu(i.getEast())*n.worldSize,l=vu(i.getNorth())*n.worldSize,c=vu(i.getSouth())*n.worldSize,u=[a,l,0],h=[s,l,0],d=[a,c,0],f=[s,c,0],p=e.a9.invert([],n.globeMatrix);return e.Q.transformMat4(u,u,p),e.Q.transformMat4(h,h,p),e.Q.transformMat4(d,d,p),e.Q.transformMat4(f,f,p),o[0]=Eh(o[0],d,r),o[1]=Eh(o[1],f,r),o[2]=Eh(o[2],h,r),o[3]=Eh(o[3],u,r),mh.fromPoints(o)},e.aW=zh,e.aX=Ph,e.aY=Eh,e.aZ=El,e.a_=yh,e.ab=Ku,e.ac=Pu,e.ad=Qt,e.ae=Yc,e.af=function(e,t){const n={};for(let r=0;r{r(e,n)}),t):r(e,n),()=>{}}return i.callbacks.push(r),i.cancel||(i.cancel=n(((n,r)=>{i.result=[n,r];for(const e of i.callbacks)this.scheduler?this.scheduler.add((()=>{e(n,r)}),t):e(n,r);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{i.result||(i.callbacks=i.callbacks.filter((e=>e!==r)),i.callbacks.length||(i.cancel(),delete this.entries[e]))}}},e.aj=gl,e.ak=function(e,t,n){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const r=er(e.request,((e,r,i,o)=>{e?t(e):r&&t(null,{vectorTile:n?void 0:new df(new wm(r)),rawData:r,cacheControl:i,expires:o})}));return()=>{r.cancel(),t()}}),t)},e.al=function(e){Un++,Un>Nn&&(e.getActor().send("enforceCacheSizeLimit",Fn),Un=0)},e.am=mr,e.an=Pn,e.ao=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.ap=du,e.aq=E_,e.ar=k_,e.as=M_,e.at=function(e,t){const n=document.createElement("video");n.muted=!0,n.onloadstart=function(){t(null,n)};for(let r=0;r{}}},e.au=x_,e.av=Pg,e.aw=bu,e.ax=wu,e.ay=Tl,e.az=Gl,e.b=zr,e.b$=sg,e.b0=ox,e.b1=er,e.b2=function(e){const t=[];for(const n in e)t.push(e[n]);return t},e.b3=function(e,t){const n=[];for(const r in e)r in t||n.push(r);return n},e.b4=Jt,e.b5=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.b6=function(t,n){const{x:r,y:i}=t.point,o=Fh(r,i,t.worldSize/t._pixelsPerMercatorPixel,0,0);return e.a9.multiply(o,o,Oh(Ah(n)))},e.b8=Yp,e.b9=Cm,e.bA=Xc,e.bB=function(t){const n=e.a9.identity(new Float64Array(16));e.a9.multiply(n,t.pixelMatrix,t.globeMatrix);const r=[0,eu,0],i=[0,tu,0];return e.Q.transformMat4(r,r,n),e.Q.transformMat4(i,i,n),[r[0]>0&&r[0]<=t.width&&r[1]>0&&r[1]<=t.height&&!Vh(t,new au(t.center.lat,90)),i[0]>0&&i[0]<=t.width&&i[1]>0&&i[1]<=t.height&&!Vh(t,new au(t.center.lat,-90))]},e.bC=function(t,n){const{scale:r}=t.tileTransform,i=r*io/(t.tileSize*Math.pow(2,n.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return e.b7.scale(new Float32Array(4),n.inverseAdjustmentMatrix,[i,i])},e.bD=B_,e.bE=O_,e.bF=function(t){const n=O_(t,!0);return e.b7.invert([],[n[0],n[1],n[4],n[5]])},e.bG=ch,e.bH=function(e){const{x:t,y:n}=e.point,{lng:r,lat:i}=e._center;return Fh(t,n,e.worldSize,r,i)},e.bI=qt,e.bJ=Qc,e.bK=function(e){const t=Math.round((e+45+360)%360/90)%4;return Wt[t]},e.bL=45,e.bM=_u,e.bN=Pc,e.bO=Ec,e.bP=Tc,e.bQ=Ac,e.bR=Mc,e.bS=Cc,e.bT=function(e,t,n){const r=Math.sqrt(e*e+t*t+n*n),i=r>0?Math.acos(n/r)*Ut:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*Ut+90:0;return o<0&&(o+=360),[r,o,i]},e.bU=Cu,e.bV=mh,e.bW=mn,e.bX=function(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},e.bY=function(e){return e({pluginStatus:Rs,pluginURL:Ls}),Ds.on("pluginStateChange",e),e},e.bZ=gy,e.b_=wy,e.ba=Zp,e.bb=function(e,t,n,r,i){const o=5*t+2;e.float32[o+0]=n,e.float32[o+1]=r,e.float32[o+2]=i},e.bc=o_,e.bd=Km,e.be=Uu,e.bf=qp,e.bg=bg,e.bh=xg,e.bi=Nm,e.bj=cx,e.bk=Kt,e.bm=Gt,e.bn=En,e.bo=xu,e.bp=function(e,t,n){e[4*t+0]=n[0],e[4*t+1]=n[1],e[4*t+2]=n[2],e[4*t+3]=n[3]},e.bq=au,e.br=$g,e.bs=hu,e.bt=ph,e.bu=D_,e.bv=uu,e.bw=Ch,e.bx=function(e,t,n,r,i,o,a,s,l){if("globe"===l.name)return Ch(e,t,new uu(n,r,i),!1);const c=Pg({z:n,x:r,y:i},l);return new mh([(o+c.x/c.scale)*t,t*(c.y/c.scale),a],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),s])},e.by=function(e,t,n){let r=0;for(let i=0;i<2;++i){const n=0;e[i]>n&&(r+=(e[i]-n)*(e[i]-n)),t[i]=0?e.slice(0,t):e},e.c9=function(e){return e.indexOf(ml)>=0},e.cA=e=>({u_matrix:new Pc(e),u_pixels_to_tile_units:new zc(e),u_device_pixel_ratio:new Ac(e),u_units_to_pixels:new Ec(e),u_dash_image:new Mc(e),u_gradient_image:new Mc(e),u_image_height:new Ac(e),u_texsize:new Ec(e),u_tile_units_to_pixels:new Ac(e),u_alpha_discard_threshold:new Ac(e),u_trim_offset:new Ec(e),u_emissive_strength:new Ac(e)}),e.cB=e=>({u_matrix:new Pc(e),u_texsize:new Ec(e),u_pixels_to_tile_units:new zc(e),u_device_pixel_ratio:new Ac(e),u_image:new Mc(e),u_units_to_pixels:new Ec(e),u_tile_units_to_pixels:new Ac(e),u_alpha_discard_threshold:new Ac(e),u_trim_offset:new Ec(e)}),e.cC=Vl,e.cD=Gp,e.cE=Qp,e.cF=Hh,e.cG=(e,t,n,r,i,o)=>{const a=e.transform,s="globe"===a.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(s){const e=Bh(a.zoom,t.canonical)*a._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=a.calculatePixelsToTileUnitsMatrix(n);else l=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(a.projection),u_matrix:e.translatePosMatrix(t.projMatrix,n,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Rn.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Wh,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(s){c.u_inv_rot_matrix=r,c.u_merc_center=i,c.u_tile_id=[t.canonical.x,t.canonical.y,1<{const a=e.transform;return{u_matrix:Ip(e,t,n,r),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:a.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:kp(t,a),u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},e.cJ=(e,t,n,r,i,o,a)=>{const s=e.transform,l=s.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:Ip(e,t,n,r),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:Rp(n)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:kp(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:a,u_emissive_strength:n.paint.get("line-emissive-strength")}},e.cK=rn,e.cL=sd,e.cM=ap,e.cN=pu,e.cO=Jf,e.cP=Vf,e.cQ=450,e.cR=7,e.cS=A_,e.cT=256,e.cU=Oh,e.cV=Kl,e.cW=Zl,e.cX=Yl,e.cY=function(e,t,n,r,i){return Qt((e-t)/(n-t)*(i-r)+r,r,i)},e.cZ=Eu,e.c_=G_,e.ca=function(e){const t=e.indexOf(ml);return t>=0?e.slice(t+1):""},e.cb=function(e){const t=[],n=e.id;return void 0===n&&t.push({message:"layers.".concat(n,': missing required property "id"')}),void 0===e.render&&t.push({message:"layers.".concat(n,': missing required method "render"')}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:"layers.".concat(n,': property "renderingMode" must be either "2d" or "3d"')}),t},e.cc=cn,e.cd=Ds,e.ce=$n,e.cf=kc,e.cg=class extends Sc{constructor(e){super(e),this.current=Rc}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let r=0;r<9;r++)if(n[r]!==this.current[r]){this.current=n,this.gl.uniformMatrix3fv(this.location,!1,n);break}}},e.ch=Ht,e.ci=function(e,t,n){const r=Nh(n.zoom),i=e.style.map._antialias,o=t.options.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===r&&!i&&!o},e.cj=function(t){const n=t.pixelsPerMeter,r=n/xu(1,t.center.lat),i=e.a9.identity(new Float64Array(16));return e.a9.translate(i,i,[t.point.x,t.point.y,0]),e.a9.scale(i,i,[r,r,n]),Float32Array.from(i)},e.ck=kh,e.cl=function(e){const t=Mu-5;e=Qt(e,-t,t)/t*90;const n=Math.pow(Math.abs(Math.sin(Gt(e))),3);return Math.round(n*($c.length-1))},e.cm=function(t,n,r,i){const o=n.getNorth(),a=n.getSouth(),s=n.getWest(),l=n.getEast(),c=1<0){const t=180/i;e.ct.multiply(p,p,[t/u+1,0,0,0,t/h+1,0,-.5*t/d,.5*t/f,1])}return p[2]=c,p[5]=t.x,p[8]=t.y,p},e.cn=Ah,e.co=function(t,n,r){const i=e.a9.identity(new Float64Array(16)),o=(n/(1<1)return!1;const n=t.getSource().maxzoom,r=1<1&&void 0!==arguments[1]?arguments[1]:0;return this.getAtPoint(e,t)||0}getAtPoint(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(this.isUsingMockSource())return null;null==t&&(t=null);const r=this._source();if(!r)return t;if(e.y<0||e.y>1)return t;const i=r.getSource().maxzoom,o=1<{const a=this.getAtTileOffset(t,o.x,o.y),s=i.upVector(t.canonical,o.x,o.y),l=i.upVectorScale(t.canonical,n,r).metersToTile;return e.Q.scale(s,s,a*l),s}}getForTilePoints(e,t,n,r){if(this.isUsingMockSource())return!1;const i=zf.create(this,e,r);return!!i&&(t.forEach((e=>{e[2]=this.exaggeration()*i.getElevationAt(e[0],e[1],n)})),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const n=t.dem.tree,r=t.tileID,i=1<({u_camera_to_center_distance:new Ac(e),u_extrude_scale:new zc(e),u_device_pixel_ratio:new Ac(e),u_matrix:new Pc(e),u_inv_rot_matrix:new Pc(e),u_merc_center:new Ec(e),u_tile_id:new Tc(e),u_zoom_transition:new Ac(e),u_up_dir:new Tc(e),u_emissive_strength:new Ac(e)}),e.d=or,e.d$=my,e.d0=zf,e.d1=ay,e.d2=Fl,e.d3=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[]}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e){const t=yf(new jt(0,0),new jt(io,io),e),n=[];for(const r of this._activeRegions){if(r.hiddenByOverlap)continue;if(!_f(t,r))continue;const i=vf(r.min,r.max,e);n.push({min:i.min,max:i.max,sourceId:this._sourceIds[r.priority],footprint:r.footprint,footprintTileId:r.tileId})}return n}setSources(e){this._setSources(e.map((e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const n of e.cache.getVisibleCoordinates()){const r=e.cache.getTile(n).buckets[e.layer];if(r)for(const e of r.getNodesInfo()){const r=e.node;r.footprint&&t.push({footprint:r.footprint,id:n.toUnwrapped()})}}return t}}))))}_addSource(e){const t=e.getFootprints();if(0!==t.length){for(const e of t){if(!e.footprint)continue;const t=yf(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint})}this._sourceIds.push(e.getSourceId())}}_computeReplacement(){this._activeRegions.sort(((e,t)=>e.priority-t.priority||mf(e.min,t.min)||mf(e.max,t.max)));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0,n=0;for(;!e&&t!==this._activeRegions.length;){const r=this._activeRegions[t],i=this._prevRegions[n];e=r.priority!==i.priority||!gf(r,i),++t,++n}}if(e){++this._updateTime;const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const n=t[e].priority;for(;e1){let t=0,n=e(t);for(;t!==n;){let r=t;const i=t;for(;r!==n;){const e=this._activeRegions[r];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement()}},e.d4=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.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,t){const n=new Al,r=new Gl,i=[],o=e+1+2,a=t[0]+1,s=t[0]+1+(1+t.length),l=(e,t,n)=>{let r=e===o-1?e-2:0===e?e:e-1;return r+=n?24575:0,[r,t]};for(let c=0;ce()))},e.dC=_y,e.dD=ky,e.dE=function(e){My=Rn.resolveURL(e),Cy||(Cy=new gy(wy(),new Dr)),Cy.broadcast("setDracoUrl",My)},e.dF=Iy,e.dG=function(e){Ey=Rn.resolveURL(e),Cy||(Cy=new gy(wy(),new Dr)),Cy.broadcast("setMeshoptUrl",Ey)},e.dH=ps,e.dI=nd,e.dJ=og,e.dK=iv,e.dL=sv,e.dM=bp,e.dN=ln,e.dO=tg,e.dP=function(e,t,n,r,i,o,a,s,l,c,u){e.createArrays(),e.tilePixelRatio=io/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const h=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,f={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:n}=e.textSizeData;f.compositeTextSizes=[d["text-size"].possiblyEvaluate(new js(t),s),d["text-size"].possiblyEvaluate(new js(n),s)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:n}=e.iconSizeData;f.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new js(t),s),d["icon-size"].possiblyEvaluate(new js(n),s)]}f.layoutTextSize=d["text-size"].possiblyEvaluate(new js(l+1),s),f.layoutIconSize=d["icon-size"].possiblyEvaluate(new js(l+1),s),f.textMaxSize=d["text-size"].possiblyEvaluate(new js(18),s);const p="map"===h.get("text-rotation-alignment")&&"point"!==h.get("symbol-placement"),m=h.get("text-size");let g=!1;for(const _ of e.features)if(_.icon&&_.icon.nameSecondary){g=!0;break}for(const _ of e.features){const o=h.get("text-font").evaluate(_,{},s).join(","),l=m.evaluate(_,{},s),d=f.layoutTextSize.evaluate(_,{},s),y=(f.layoutIconSize.evaluate(_,{},s),{horizontal:{},vertical:void 0}),v=_.text;let x,b=[0,0];if(v){const r=v.toString(),a=h.get("text-letter-spacing").evaluate(_,{},s)*qp,c=h.get("text-line-height").evaluate(_,{},s)*qp,u=bs(r)?a:0,f=h.get("text-anchor").evaluate(_,{},s),m=h.get("text-variable-anchor");if(!m){const e=h.get("text-radial-offset").evaluate(_,{},s);b=e?xg(f,[e*qp,yg]):h.get("text-offset").evaluate(_,{},s).map((e=>e*qp))}let g=p?"center":h.get("text-justify").evaluate(_,{},s);const x="point"===h.get("symbol-placement"),w=x?h.get("text-max-width").evaluate(_,{},s)*qp:1/0,S=a=>{e.allowVerticalPlacement&&xs(r)&&(y.vertical=Pm(v,t,n,i,o,w,c,f,a,u,b,Cm.vertical,!0,d,l))};if(!p&&m){const e="auto"===g?m.map((e=>bg(e))):[g];let r=!1;for(let a=0;a=0||!xs(r)){const e=Pm(v,t,n,i,o,w,c,f,g,u,b,Cm.horizontal,!1,d,l);e&&(y.horizontal[g]=e)}S(x?"left":g)}}let w=!1;if(_.icon&&_.icon.namePrimary){const t=r[_.icon.namePrimary];t&&(x=Vm(i[_.icon.namePrimary],_.icon.nameSecondary?i[_.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(_,{},s),h.get("icon-anchor").evaluate(_,{},s)),w=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&dn("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const S=Eg(y.horizontal)||y.vertical;e.iconsInText||(e.iconsInText=!!S&&S.iconsInText),(S||x)&&wg(e,_,y,x,r,f,d,0,b,w,a,s,c,u,g)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)},e.dQ=df,e.dR=wm,e.dS=Lf,e.dT=ff,e.dU=$d,e.dV=Ft,e.dW=tm,e.dX=h,e.dY=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==Ny){const n=new Uint32Array(e,0,7),[,,r,i,o,a]=n;t=n.byteLength+i+o+a+o,(r!==e.byteLength||t>=e.byteLength)&&dn("Invalid b3dm header information.")}return Wy(e,t)},e.dZ=function(e,t){const n=tv(e);for(const r of n){for(const e of r.meshes)nv(e);r.lights&&(r.lightMeshIndex=r.meshes.length,r.meshes.push(rv(r.lights,t)))}return n},e.d_=gv,e.da=ru,e.db=function(e){let[t,n,r]=e;const i=Math.hypot(t,n,r),o=Math.atan2(t,r),a=.5*Math.PI-Math.acos(-n/i);return new au(qt(o),qt(a))},e.dc=iu,e.dd=r,e.de=Vh,e.df=jh,e.dg=function(t){const n=[0,0,0],r=e.a9.identity(new Float64Array(16));return e.a9.multiply(r,t.pixelMatrix,t.globeMatrix),e.Q.transformMat4(n,n,r),new jt(n[0],n[1])},e.dh=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==Mn){const t=e.navigator?e.navigator.userAgent:null;Mn=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Mn}(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.di=class{constructor(e,t,n){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!n,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",ar,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,n){if(!o(e))return e;const r=cr(e);return r.params.push("sdk=js-".concat(t)),r.path="/styles/v1".concat(r.path),this._makeAPIURL(r,this._customAccessToken||n)}normalizeGlyphsURL(e,t){if(!o(e))return e;const n=cr(e);return n.path="/fonts/v1".concat(n.path),this._makeAPIURL(n,this._customAccessToken||t)}normalizeModelURL(e,t){if(!o(e))return e;const n=cr(e);return n.path="/models/v1".concat(n.path),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSourceURL(e,t,n,r){if(!o(e))return e;const i=cr(e);return i.path="/v4/".concat(i.authority,".json"),i.params.push("secure"),n&&i.params.push("language=".concat(n)),r&&i.params.push("worldview=".concat(r)),this._makeAPIURL(i,this._customAccessToken||t)}normalizeSpriteURL(e,t,n,r){const i=cr(e);return o(e)?(i.path="/styles/v1".concat(i.path,"/sprite").concat(t).concat(n),this._makeAPIURL(i,this._customAccessToken||r)):(i.path+="".concat(t).concat(n),ur(i))}normalizeTileURL(e,t,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!o(e))return e;const i=cr(e);i.path=i.path.replace(/(\.(png|jpg)\d*)(?=$)/,"".concat(t||n&&"raster"!==i.authority&&512===n?"@2x":"").concat(Gn.supported?".webp":"$1")),"raster"===i.authority?i.path="/".concat(r.RASTER_URL_PREFIX).concat(i.path):"rasterarrays"===i.authority?i.path="/".concat(r.RASTERARRAYS_URL_PREFIX).concat(i.path):(i.path=i.path.replace(/^.+\/v4\//,"/"),i.path="/".concat(r.TILE_URL_VERSION).concat(i.path));const a=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(i.params)||r.ACCESS_TOKEN;return r.REQUIRE_ACCESS_TOKEN&&a&&this._skuToken&&i.params.push("sku=".concat(this._skuToken)),this._makeAPIURL(i,a)}canonicalizeTileURL(e,t){const n=cr(e);if(!n.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!n.path.match(/\.[\w]+$/))return e;let i="mapbox://";n.path.match(/^\/raster\/v1\//)?i+="raster/".concat(n.path.replace("/".concat(r.RASTER_URL_PREFIX,"/"),"")):n.path.match(/^\/rasterarrays\/v1\//)?i+="rasterarrays/".concat(n.path.replace("/".concat(r.RASTERARRAYS_URL_PREFIX,"/"),"")):i+="tiles/".concat(n.path.replace("/".concat(r.TILE_URL_VERSION,"/"),""));let o=n.params;return t&&(o=o.filter((e=>!e.match(/^access_token=/)))),o.length&&(i+="?".concat(o.join("&"))),i}canonicalizeTileset(e,t){const n=!!t&&o(t),r=[];for(const o of e.tiles||[])i(o)?r.push(this.canonicalizeTileURL(o,n)):r.push(o);return r}_makeAPIURL(e,t){const n="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",i=cr(r.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="".concat(i.path).concat(e.path)),!r.REQUIRE_ACCESS_TOKEN)return ur(e);if(t=t||r.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error("An API access token is required to use Mapbox GL. ".concat(n));if("s"===t[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ".concat(n))}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push("access_token=".concat(t||"")),ur(e)}},e.dj=function(e,t){t?Mr.add(e):Mr.delete(e)},e.dk=Gn,e.dl=br,e.dm=Sr,e.dn=sr,e.dp=_r,e.dq=vr,e.dr=function(e){Mr.delete(e)},e.ds=wr,e.dt=gr,e.du=t,e.dv=function(e,t){Fn=e,Nn=t},e.dw=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(Rs===Cs||Rs===ks||Rs===Is)throw new Error("setRTLTextPlugin cannot be called multiple times.");Ls=Rn.resolveURL(e),Rs=Cs,Ps=t,Os(),n||Fs()},e.dx=Bs,e.dy=function(){wy().acquire(vy)},e.dz=function(){const e=by;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(vy),by=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},e.e=$t,e.e0=Ns,e.e1=function(e){Vn(),Dn&&Dn.then((t=>{t.keys().then((n=>{for(let r=0;re.arrayBuffer())).then((t=>Wy(t,0,e)))},e.m=Ga,e.n=Wa,e.o=ns,e.p=Jm,e.q=el,e.r=as,e.s=Ha,e.t=rs,e.u=$s,e.v=jo,e.w=dn,e.x=Uo,e.y=No})),r(["./shared"],(function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function n(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const r of e)t+="".concat(n(r),",");return"".concat(t,"]")}let t="{";for(const r of Object.keys(e).sort())t+="".concat(r,":").concat(n(e[r]),",");return"".concat(t,"}")}function r(t){let r="";for(const i of e.b5)r+="/".concat(n(t[i]));return r}class i{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,n,i){this._options=i;for(const r of t)this._layerConfigs[r.id]=r,(this._layers[r.id]=e.c7(r,this.scope,this._options)).compileFilter(),this.keyCache[r.id]&&delete this.keyCache[r.id];for(const e of n)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const o=function(e,t){const n={};for(let o=0;othis._layers[e.id])),n=t[0];if("none"===n.visibility)continue;const r=n.source||"";let i=this.familiesBySource[r];i||(i=this.familiesBySource[r]={});const o=n.sourceLayer||"_geojsonTileLayer";let a=i[o];a||(a=i[o]=[]),a.push(t)}}}const o=1*e.dJ;class a{constructor(t){const n={},r=[];for(const e in t){const i=t[e],a=n[e]={};for(const e in i.glyphs){const t=i.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const n=t.metrics.localGlyph?o:1,s={x:0,y:0,w:t.bitmap.width+2*n,h:t.bitmap.height+2*n};r.push(s),a[e]=s}}const{w:i,h:a}=e.p(r),s=new e.dI({width:i||1,height:a||1});for(const l in t){const r=t[l];for(const t in r.glyphs){const i=r.glyphs[+t];if(!i||0===i.bitmap.width||0===i.bitmap.height)continue;const a=n[l][t],c=i.metrics.localGlyph?o:1;e.dI.copy(i.bitmap,s,{x:0,y:0},{x:a.x+c,y:a.y+c},i.bitmap)}}this.image=s,this.positions=n}}e.dH(a,"GlyphAtlas");class s{constructor(t){this.tileID=new e.ap(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.av(t.tileID.canonical,t.projection),this.projection=t.projection,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster}parse(t,n,r,i,o){this.status="parsing",this.data=t,this.collisionBoxArray=new e.aG;const s=new e.dK(Object.keys(t.layers).sort()),c=new e.dL(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h=new e.dM(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:h,availableImages:r,brightness:this.brightness},f=n.familiesBySource[this.source];for(const a in f){const n=t.layers[a];if(!n)continue;let i=!1,o=!1,h=!1;for(const e of f[a])"symbol"===e[0].type?i=!0:o=!0,e[0].is3D()&&"model"!==e[0].type&&(h=!0);if(this.extraShadowCaster&&!h)continue;if(!0===this.isSymbolTile&&!i)continue;if(!1===this.isSymbolTile&&!o)continue;1===n.version&&e.w('Vector tile source "'.concat(this.source,'" layer "').concat(a,'" does not use vector tile spec v2 and therefore may have some rendering errors.'));const p=s.encode(a),m=[];for(let e=0;e=t.maxzoom||"none"!==t.visibility&&(l(e,this.zoom,d.brightness,r),(u[t.id]=t.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:p,sourceID:this.source,projection:this.projection.spec})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(e.map((e=>e.id)))))}}let p,m,g,_;h.trim();const y={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(p)return this.status="done",o(p);if(this.extraShadowCaster)this.status="done",o(null,{buckets:e.b2(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&g&&_){const t=new a(m),n=new e.dO(g,_);for(const i in u){const o=u[i];o instanceof e.aH?(l(o.layers,this.zoom,d.brightness,r),e.dP(o,m,t.positions,g,n.iconPositions,this.showCollisionBoxes,r,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof e.aN||o instanceof e.aO||o instanceof e.cO)&&(l(o.layers,this.zoom,d.brightness,r),o.addFeatures(d,this.tileID.canonical,n.patternPositions,r,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:e.b2(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:h,imageAtlas:n,brightness:d.brightness})}};if(!this.extraShadowCaster){const t=e.dN(d.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(t).length?i.send("getGlyphs",{uid:this.uid,stacks:t,scope:this.scope},((e,t)=>{p||(p=e,m=t,v())}),void 0,!1,y):m={};const n=Object.keys(d.iconDependencies);n.length?i.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{p||(p=e,g=t,v())}),void 0,!1,y):g={};const r=Object.keys(d.patternDependencies);r.length?i.send("getImages",{icons:r,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{p||(p=e,_=t,v())}),void 0,!1,y):_={}}v()}}function l(t,n,r,i){const o=new e.N(n,{brightness:r});for(const e of t)e.recalculate(o,i)}class c extends e.E{constructor(t,n,r,i,o,a){super(),this.actor=t,this.layerIndex=n,this.availableImages=r,this.loadVectorData=o||e.ak,this.loading={},this.loaded={},this.deduped=new e.ai(t.scheduler),this.isSpriteLoaded=i,this.scheduler=t.scheduler,this.brightness=a}loadTile(n,r){const i=n.uid,o=n&&n.request,a=o&&o.collectResourceTiming,l=this.loading[i]=new s(n);l.abort=this.loadVectorData(n,((s,c)=>{const u=!this.loading[i];if(delete this.loading[i],u||s||!c)return l.status="done",u||(this.loaded[i]=l),r(s);const h=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new e.dQ(new e.dR(h));const f=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((n,i)=>{if(n||!i)return r(n);const s={};if(a){const e=t(o);e.length>0&&(s.resourceTiming=JSON.parse(JSON.stringify(e)))}r(null,e.e({rawTileData:h.slice(0)},i,d,s))}))};this.isSpriteLoaded?f():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(f,{type:"parseTile",isSymbolTile:n.isSymbolTile,zoom:n.tileZoom}):f()})),this.loaded=this.loaded||{},this.loaded[i]=l}))}reloadTile(t,n){const r=this.loaded,i=t.uid,o=this;if(r&&r[i]){const a=r[i];a.showCollisionBoxes=t.showCollisionBoxes,a.projection=t.projection,a.brightness=t.brightness,a.tileTransform=e.av(t.tileID.canonical,t.projection),a.extraShadowCaster=t.extraShadowCaster;const s=(e,t)=>{const r=a.reloadCallback;r&&(delete a.reloadCallback,a.parse(a.vectorTile,o.layerIndex,this.availableImages,o.actor,r)),n(e,t)};"parsing"===a.status?a.reloadCallback=s:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else n(null,void 0)}abortTile(e,t){const n=e.uid,r=this.loading[n];r&&(r.abort&&r.abort(),delete this.loading[n]),t()}removeTile(e,t){const n=this.loaded,r=e.uid;n&&n[r]&&delete n[r],t()}}class u{loadTile(t,n){const{uid:r,encoding:i,rawImageData:o,padding:a}=t,s=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,a):o;n(null,new e.dS(r,s,i,a<1))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const n=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),n}}class h{decodeRasterArray(t,n){let{task:r,buffer:i}=t;e.b0.performDecoding(i,r).then((e=>{n(null,e)}),(e=>{n(e)}))}}const d=e.dT.prototype.toGeoJSON;let f=class{constructor(t){this._feature=t,this.extent=e.Y,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 n of this._feature.geometry)t.push([new e.P(n[0],n[1])]);return t}{const t=[];for(const n of this._feature.geometry){const r=[];for(const t of n)r.push(new e.P(t[0],t[1]));t.push(r)}return t}}toGeoJSON(e,t,n){return d.call(this,e,t,n)}},p=class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.Y,this.length=t.length,this._features=t}feature(e){return new f(this._features[e])}};var m={exports:{}},g=e.dV,_=e.dU.VectorTileFeature,y=v;function v(e,t){this.options=t||{},this.features=e,this.length=e.length}function x(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}v.prototype.feature=function(e){return new x(this.features[e],this.options.extent)},x.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var t=0;t>31}function k(e,t){for(var n=e.loadGeometry(),r=e.type,i=0,o=0,a=n.length,s=0;se},L=Math.fround||(z=new Float32Array(1),e=>(z[0]=+e,z[0]));var z;const O=3,D=5,B=6;class F{constructor(e){this.options=Object.assign(Object.create(R),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:n,maxZoom:r}=this.options;t&&console.time("total time");const i="prepare ".concat(e.length," points");t&&console.time(i),this.points=e;const o=[];for(let s=0;s=n;s--){const e=+Date.now();a=this.trees[s]=this._createTree(this._cluster(a,s)),t&&console.log("z%d: %d clusters in %dms",s,a.numItems,+Date.now()-e)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let n=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let i=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)n=-180,i=180;else if(n>i){const e=this.getClusters([n,r,180,o],t),a=this.getClusters([-180,r,i,o],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],s=a.range(V(n),U(o),V(i),U(r)),l=a.data,c=[];for(const u of s){const e=this.stride*u;c.push(l[e+D]>1?N(l,e,this.clusterProps):this.points[l[e+O]])}return c}getChildren(e){const t=this._getOriginId(e),n=this._getOriginZoom(e),r="No cluster with the specified id.",i=this.trees[n];if(!i)throw new Error(r);const o=i.data;if(t*this.stride>=o.length)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,n-1)),s=i.within(o[t*this.stride],o[t*this.stride+1],a),l=[];for(const c of s){const t=c*this.stride;o[t+4]===e&&l.push(o[t+D]>1?N(o,t,this.clusterProps):this.points[o[t+O]])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,n){const r=[];return this._appendLeaves(r,e,t=t||10,n=n||0,0),r}getTile(e,t,n){const r=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:o,radius:a}=this.options,s=a/o,l=(n-s)/i,c=(n+1+s)/i,u={features:[]};return this._addTileFeatures(r.range((t-s)/i,l,(t+1+s)/i,c),r.data,t,n,i,u),0===t&&this._addTileFeatures(r.range(1-s/i,l,1,c),r.data,i,n,i,u),t===i-1&&this._addTileFeatures(r.range(0,l,s/i,c),r.data,-1,n,i,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const n=this.getChildren(e);if(t++,1!==n.length)break;e=n[0].properties.cluster_id}return t}_appendLeaves(e,t,n,r,i){const o=this.getChildren(t);for(const a of o){const t=a.properties;if(t&&t.cluster?i+t.point_count<=r?i+=t.point_count:i=this._appendLeaves(e,t.cluster_id,n,r,i):i1;let l,c,u;if(s)l=j(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const n=this.points[t[e+O]];l=n.properties;const[r,i]=n.geometry.coordinates;c=V(r),u=U(i)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*i-n)),Math.round(this.options.extent*(u*i-r))]],tags:l};let d;d=s||this.options.generateId?t[e+O]:this.points[t[e+O]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:n,extent:r,reduce:i,minPoints:o}=this.options,a=n/(r*Math.pow(2,t)),s=e.data,l=[],c=this.stride;for(let u=0;ut&&(f+=s[n+D])}if(f>d&&f>=o){let e,o=n*d,a=r*d,p=-1;const m=(u/c<<5)+(t+1)+this.points.length;for(const n of h){const r=n*c;if(s[r+2]<=t)continue;s[r+2]=t;const l=s[r+D];o+=s[r]*l,a+=s[r+1]*l,s[r+4]=m,i&&(e||(e=this._map(s,u,!0),p=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(s,r)))}s[u+4]=m,l.push(o/f,a/f,1/0,m,-1,f),i&&l.push(p)}else{for(let e=0;e1)for(const e of h){const n=e*c;if(!(s[n+2]<=t)){s[n+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,n){if(e[t+D]>1){const r=this.clusterProps[e[t+B]];return n?Object.assign({},r):r}const r=this.points[e[t+O]].properties,i=this.options.map(r);return n&&i===r?Object.assign({},i):i}}function N(e,t,n){return{type:"Feature",id:e[t+O],properties:j(e,t,n),geometry:{type:"Point",coordinates:[(r=e[t],360*(r-.5)),G(e[t+1])]}};var r}function j(e,t,n){const r=e[t+D],i=r>=1e4?"".concat(Math.round(r/1e3),"k"):r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+B],a=-1===o?{}:Object.assign({},n[o]);return Object.assign(a,{cluster:!0,cluster_id:e[t+O],point_count:r,point_count_abbreviated:i})}function V(e){return e/360+.5}function U(e){const t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function G(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var q={exports:{}};q.exports=function(){function e(n,r,i,o){for(var a,s=o,l=i-r>>1,c=i-r,u=n[r],h=n[r+1],d=n[i],f=n[i+1],p=r+3;ps)a=p,s=m;else if(m===s){var g=Math.abs(p-l);go&&(a-r>3&&e(n,r,a,o),n[a+2]=s,i-a>3&&e(n,a,i,o))}function t(e,t,n,r,i,o){var a=i-n,s=o-r;if(0!==a||0!==s){var l=((e-n)*a+(t-r)*s)/(a*a+s*s);l>1?(n=i,r=o):l>0&&(n+=a*l,r+=s*l)}return(a=e-n)*a+(s=t-r)*s}function n(e,t,n,i){var o={id:void 0===e?null:e,type:t,geometry:n,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,n=e.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)r(e,t);else if("Polygon"===n||"MultiLineString"===n)for(var i=0;i0&&(s+=i?(o*d-h*a)/2:Math.sqrt(Math.pow(h-o,2)+Math.pow(d-a,2))),o=h,a=d}var f=n.length-3;n[2]=1,e(n,0,f,r),n[f+2]=1,n.size=Math.abs(s),n.start=0,n.end=n.size}function s(e,t,n,r){for(var i=0;i1?1:n}function u(e,t,r,i,o,a,s,l){if(i/=t,a>=(r/=t)&&s=i)return null;for(var c=[],u=0;u=r&&y=i)){var v=[];if("Point"===g||"MultiPoint"===g)h(m,v,r,i,o);else if("LineString"===g)d(m,v,r,i,o,!1,l.lineMetrics);else if("MultiLineString"===g)p(m,v,r,i,o,!1);else if("Polygon"===g)p(m,v,r,i,o,!0);else if("MultiPolygon"===g)for(var x=0;x=n&&a<=r&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function d(e,t,n,r,i,o,a){for(var s,l,c=f(e),u=0===i?g:_,h=e.start,d=0;dn&&(l=u(c,p,y,x,b,n),a&&(c.start=h+s*l)):w>r?S=n&&(l=u(c,p,y,x,b,n),M=!0),S>r&&w<=r&&(l=u(c,p,y,x,b,r),M=!0),!o&&M&&(a&&(c.end=h+s*l),t.push(c),c=f(e)),a&&(h+=s)}var A=e.length-3;p=e[A],y=e[A+1],v=e[A+2],(w=0===i?p:y)>=n&&w<=r&&m(c,p,y,v),A=c.length-3,o&&A>=3&&(c[A]!==c[0]||c[A+1]!==c[1])&&m(c,c[0],c[1],c[2]),c.length&&t.push(c)}function f(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function p(e,t,n,r,i,o){for(var a=0;aa.maxX&&(a.maxX=u),h>a.maxY&&(a.maxY=h)}return a}function S(e,t,n,r){var i=t.geometry,o=t.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s0&&t.size<(i?a:r))n.numPoints+=t.length/3;else{for(var s=[],l=0;la)&&(n.numSimplified++,s.push(t[l]),s.push(t[l+1])),n.numPoints++;i&&function(e,t){for(var n=0,r=0,i=e.length,o=i-2;r0===t)for(r=0,i=e.length;r24)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 r=function(e,t){var n=[];if("FeatureCollection"===e.type)for(var r=0;r1&&console.time("creation"),f=this.tiles[d]=w(e,t,n,r,l),this.tileCoords.push({z:t,x:n,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,n,r,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var p="z"+t;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(f.source=e,i){if(t===l.maxZoom||t===i)continue;var m=1<1&&console.time("clipping");var g,_,y,v,x,b,S=.5*l.buffer/l.extent,M=.5-S,A=.5+S,T=1+S;g=_=y=v=null,x=u(e,h,n-S,n+A,0,f.minX,f.maxX,l),b=u(e,h,n+M,n+T,0,f.minX,f.maxX,l),e=null,x&&(g=u(x,h,r-S,r+A,1,f.minY,f.maxY,l),_=u(x,h,r+M,r+T,1,f.minY,f.maxY,l),x=null),b&&(y=u(b,h,r-S,r+A,1,f.minY,f.maxY,l),v=u(b,h,r+M,r+T,1,f.minY,f.maxY,l),b=null),c>1&&console.timeEnd("clipping"),s.push(g||[],t+1,2*n,2*r),s.push(_||[],t+1,2*n,2*r+1),s.push(y||[],t+1,2*n+1,2*r),s.push(v||[],t+1,2*n+1,2*r+1)}}},A.prototype.getTile=function(e,t,n){var r=this.options,i=r.extent,o=r.debug;if(e<0||e>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",e,t,n);for(var l,c=e,u=t,h=n;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[E(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,n),o>1&&console.timeEnd("drilling down"),this.tiles[s]?x(this.tiles[s],i):null):null},function(e,t){return new A(e,t)}}();var W=e.dX(q.exports);function H(e,t){const n=e.tileID.canonical;if(!this._geoJSONIndex)return t(null,null);const r=this._geoJSONIndex.getTile(n.z,n.x,n.y);if(!r)return t(null,null);const i=new p(r.features);let o=P(i);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),t(null,{vectorTile:i,rawData:o.buffer})}class Z extends c{constructor(e,t,n,r,i,o){super(e,t,n,r,H,o),i&&(this.loadGeoJSON=i),this._featureMap=new Map}loadData(n,r){const i=n&&n.request,o=i&&i.collectResourceTiming;this.loadGeoJSON(n,((a,s)=>{if(a||!s)return r(a);if("object"!=typeof s)return r(new Error("Input data given to '".concat(n.source,"' is not a valid GeoJSON object.")));{try{if(n.filter){const t=e.t(n.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map((e=>"".concat(e.key,": ").concat(e.message))).join(", "));s.features=s.features.filter((e=>t.value.evaluate({zoom:0},e)))}if(n.dynamic){"Feature"===s.type&&(s={type:"FeatureCollection",features:[s]}),n.append||this._featureMap.clear();for(const e of s.features||[]){const t=e.id;void 0!==t&&(e.geometry?this._featureMap.set(t,e):this._featureMap.delete(t))}s.features=[...this._featureMap.values()]}this._geoJSONIndex=n.cluster?new F(function(t){let{superclusterOptions:n,clusterProperties:r}=t;if(!r||!n)return n;const i={},o={},a={accumulated:null,zoom:0},s={properties:null},l=Object.keys(r);for(const c of l){const[t,n]=r[c],a=e.t(n),s=e.t("string"==typeof t?[t,["accumulated"],["get",c]]:t);i[c]=a.value,o[c]=s.value}return n.map=e=>{s.properties=e;const t={};for(const n of l)t[n]=i[n].evaluate(a,s);return t},n.reduce=(e,t)=>{s.properties=t;for(const n of l)a.accumulated=e[n],e[n]=o[n].evaluate(a,s)},n}(n)).load(s.features):W(s,n.geojsonVtOptions)}catch(a){return r(a)}this.loaded={};const l={};if(o){const e=t(i);e&&(l.resourceTiming={},l.resourceTiming[n.source]=JSON.parse(JSON.stringify(e)))}r(null,l)}}))}reloadTile(e,t){const n=this.loaded;return n&&n[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,n){if(t.request)e.g(t.request,n);else{if("string"!=typeof t.data)return n(new Error("Input data given to '".concat(t.source,"' is not a valid GeoJSON object.")));try{return n(null,JSON.parse(t.data))}catch(e){return n(new Error("Input data given to '".concat(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 Y{constructor(t,n){this.tileID=new e.ap(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=n}parse(t,n,r,i){this.status="parsing";const o=new e.ap(r.tileID.overscaledZ,r.tileID.wrap,r.tileID.canonical.z,r.tileID.canonical.x,r.tileID.canonical.y),a={},s=n.familiesBySource[r.source],l=new e.dL(o,r.promoteId);return l.bucketLayerIDs=[],l.is3DTile=!0,e.dY(t).then((t=>{if(!t)return i(new Error("Could not parse tile"));const n=e.dZ(t,1/e.bU(r.tileID.canonical)),c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,u=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),h=new e.N(this.zoom,{brightness:this.brightness});for(const r in s)for(const t of s[r]){const r=t[0];l.bucketLayerIDs.push(t.map((e=>e.id))),r.recalculate(h,[]);const i=new e.d_(n,o,c,u,this.brightness,l);c||(i.needsUpload=!0),a[r.fqid]=i,i.evaluate(r)}this.status="done",i(null,{buckets:a,featureIndex:l})})).catch((e=>i(new Error(e.message))))}}class Q{constructor(e,t,n,r,i,o){this.actor=e,this.layerIndex=t,this.brightness=o,this.loading={},this.loaded={}}loadTile(t,n){const r=t.uid,i=this.loading[r]=new Y(t,this.brightness);e.b1(t.request,((e,o)=>{const a=!this.loading[r];return delete this.loading[r],a||e?(i.status="done",a||(this.loaded[r]=i),n(e)):o&&0!==o.byteLength?void i.parse(o,this.layerIndex,t,((e,t)=>{i.status="done",this.loaded=this.loaded||{},this.loaded[r]=i,e||!t?n(e):n(null,t)})):(i.status="done",this.loaded[r]=i,n())}))}reloadTile(e,t){const n=this.loaded,r=e.uid;if(n&&n[r]){const i=n[r];i.projection=e.projection,i.brightness=e.brightness;const o=(n,r)=>{i.reloadCallback&&(delete i.reloadCallback,this.loadTile(e,t)),t(n,r)};"parsing"===i.status?i.reloadCallback=o:"done"===i.status&&this.loadTile(e,t)}}abortTile(e,t){const n=e.uid;this.loading[n]&&delete this.loading[n],t()}removeTile(e,t){const n=this.loaded,r=e.uid;n&&n[r]&&delete n[r],t()}}class X{constructor(t){this.self=t,this.actor=new e.d$(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.br({name:"mercator"}),this.workerSourceTypes={vector:c,geojson:Z,"batched-model":Q},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error('Worker source with name "'.concat(e,'" already registered.'));this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.e0.isParsed())throw new Error("RTL text plugin already registered.");e.e0.applyArabicShaping=t.applyArabicShaping,e.e0.processBidirectionalText=t.processBidirectionalText,e.e0.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,n){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],delete this.rasterArrayWorkerSource,n()}checkIfReady(e,t,n){n()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,n){let{scope:r,isLoaded:i}=n;if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][r]=i,this.workerSources[t]&&this.workerSources[t][r])for(const o in this.workerSources[t][r]){const n=this.workerSources[t][r][o];for(const t in n)n[t]instanceof c&&(n[t].isSpriteLoaded=i,n[t].fire(new e.b("isSpriteLoaded")))}}setImages(e,t,n){let{scope:r,images:i}=t;if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][r]=i,this.workerSources[e]&&this.workerSources[e][r]){for(const t in this.workerSources[e][r]){const n=this.workerSources[e][r][t];for(const e in n)n[e].availableImages=i}n()}else n()}setProjection(t,n){this.projections[t]=e.br(n)}setBrightness(e,t,n){this.brightness=t,n()}setLayers(e,t,n){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),n()}updateLayers(e,t,n){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),n()}loadTile(e,t,n){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,n)}loadDEMTile(e,t,n){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,n)}decodeRasterArray(e,t,n){this.getRasterArrayWorkerSource().decodeRasterArray(t,n)}reloadTile(e,t,n){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,n)}abortTile(e,t,n){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,n)}removeTile(e,t,n){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,n)}removeSource(e,t,n){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const r=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,n):n()}loadWorkerSource(e,t,n){try{this.self.importScripts(t.url),n()}catch(e){n(e.toString())}}syncRTLPluginState(t,n,r){try{e.e0.setState(n);const t=e.e0.getPluginURL();if(e.e0.isLoaded()&&!e.e0.isParsed()&&null!=t){this.self.importScripts(t);const n=e.e0.isParsed();r(n?void 0:new Error("RTL Text Plugin failed to import scripts from ".concat(t)),n)}}catch(e){r(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let n=this.availableImages[e][t];return n||(n=[]),n}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let n=this.layerIndexes[e][t];return n||(n=this.layerIndexes[e][t]=new i,n.scope=t),n}getWorkerSource(e,t,n,r){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][r]||(this.workerSources[e][r]={}),this.workerSources[e][r][t]||(this.workerSources[e][r][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!this.workerSources[e][r][t][n]){const i={send:(t,n,r,i,o,a)=>{this.actor.send(t,n,r,e,o,a)},scheduler:this.actor.scheduler};this.workerSources[e][r][t][n]=new this.workerSourceTypes[t](i,this.getLayerIndex(e,r),this.getAvailableImages(e,r),this.isSpriteLoaded[e][r],void 0,this.brightness)}return this.workerSources[e][r][t][n]}getDEMWorkerSource(e,t,n){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][n]||(this.demWorkerSources[e][n]={}),this.demWorkerSources[e][n][t]||(this.demWorkerSources[e][n][t]=new u),this.demWorkerSources[e][n][t]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new h),this.rasterArrayWorkerSource}enforceCacheSizeLimit(t,n){e.e1(n)}getWorkerPerformanceMetrics(e,t,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new X(self)),X})),r(["./shared"],(function(e){function t(e,n){if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let r=0;r{window.removeEventListener("click",d,!0)}),0)}function p(e,t){const n=e.getBoundingClientRect();return _(e,n,t)}function m(e,t){const n=e.getBoundingClientRect(),r=[];for(let i=0;i=0?0:e.button}function _(t,n,r){const i=t.offsetWidth===n.width?1:t.offsetWidth/n.width;return new e.P((r.clientX-n.left)*i,(r.clientY-n.top)*i)}class y{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty()}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty()}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty()}resetUpdatedImages(){this._updatedImages.clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}class v extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={}}loadModel(t,n){return e.l(this.requestManager.transformRequest(n,e.R.Model).url).then((n=>{if(!n)return;const r=e.c(n),i=new e.M(t,void 0,void 0,r);return i.computeBoundsAndApplyParent(),i})).catch((r=>{if(r&&404===r.status)return null;this.fire(new e.a(new Error("Could not load model ".concat(t," from ").concat(n,": ").concat(r.message))))}))}load(t,n){this.models[n]||(this.models[n]={});const r=Object.keys(t);this.numModelsLoading[n]=(this.numModelsLoading[n]||0)+r.length;const i=[];for(const e of r)i.push(this.loadModel(e,t[e]));Promise.allSettled(i).then((t=>{for(let e=0;e{this.fire(new e.a(new Error("Could not load models: ".concat(t.message))))}))}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t){return!!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}addModel(e,t,n){this.models[n]||(this.models[n]={}),this.hasModel(e,n)&&this.models[n][e].numReferences++,this.load({[e]:this.requestManager.normalizeModelURL(t)},n)}addModels(e,t){this.models[t]||(this.models[t]={});const n={};for(const r in e)this.models[t][r]={},n[r]=this.requestManager.normalizeModelURL(e[r]);this.load(n,t)}addModelsFromBucket(e,t){this.models[t]||(this.models[t]={});const n={};for(const r of e)this.hasModel(r,t)?this.models[t][r].numReferences++:n[r]=this.requestManager.normalizeModelURL(r);this.load(n,t)}removeModel(e,t){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences)){const n=this.models[t][e].model;delete this.models[t][e],n.destroy()}}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const n in this.models[t])this.models[t][n].model&&this.models[t][n].model.upload(e.context)}}class x{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,r){const i=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][i]=this.stateChanges[t][i]||{},e.e(this.stateChanges[t][i],r),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==i&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][i]){this.deletedStates[t][i]={};for(const e in this.state[t][i])r[e]||(this.deletedStates[t][i][e]=null)}else for(const e in r)this.deletedStates[t]&&this.deletedStates[t][i]&&null===this.deletedStates[t][i][e]&&delete this.deletedStates[t][i][e]}removeFeatureState(e,t,n){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},n&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][n]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(n in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][n]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(t,n){const r=String(n),i=e.e({},(this.state[t]||{})[r],(this.stateChanges[t]||{})[r]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][n];if(null===e)return{};for(const t in e)delete i[t]}return i}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(t,n){const r={};for(const i in this.stateChanges){this.state[i]=this.state[i]||{};const t={};for(const n in this.stateChanges[i])this.state[i][n]||(this.state[i][n]={}),e.e(this.state[i][n],this.stateChanges[i][n]),t[n]=this.state[i][n];r[i]=t}for(const i in this.deletedStates){this.state[i]=this.state[i]||{};const t={};if(null===this.deletedStates[i])for(const e in this.state[i])t[e]={},this.state[i][e]={};else for(const e in this.deletedStates[i]){if(null===this.deletedStates[i][e])this.state[i][e]={};else if(this.state[i][e])for(const t of Object.keys(this.deletedStates[i][e]))delete this.state[i][e][t];t[e]=this.state[i][e]}r[i]=r[i]||{},e.e(r[i],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const e in t)t[e].setFeatureState(r,n)}}function b(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class w extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0}createScope(t){this.images[t]={},this.loaded[t]=!1,this.updatedImages[t]={},this.patterns[t]={},this.callbackDispatchedThisFrame[t]={},this.atlasImage[t]=new e.h({width:1,height:1})}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return!1;return!0}setLoaded(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(const{ids:e,callback:n}of this.requestors)this._notify(e,t,n);this.requestors=[]}}hasImage(e,t){return!!this.getImage(e,t)}getImage(e,t){return this.images[t][e]}addImage(e,t,n){this._validate(e,n)&&(this.images[t][e]=n)}_validate(t,n){let r=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new e.a(new Error('Image "'.concat(t,'" has invalid "stretchX" value')))),r=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new e.a(new Error('Image "'.concat(t,'" has invalid "stretchY" value')))),r=!1),this._validateContent(n.content,n)||(this.fire(new e.a(new Error('Image "'.concat(t,'" has invalid "content" value')))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let n=0;for(const r of e){if(r[0]o)return[new e.V(n,r,"".concat(r," is greater than the maximum value ").concat(o))]}return[]}function E(t){const n=t.valueSpec,r=e.u(t.value.type);let i,o,a,s={};const l="categorical"!==r&&void 0===t.value.property,c=!l,u="array"===e.j(t.value.stops)&&"array"===e.j(t.value.stops[0])&&"object"===e.j(t.value.stops[0][0]),h=S({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return[new e.V(t.key,t.value,'identity function may not have a "stops" property')];let n=[];const i=t.value;return n=n.concat(M({key:t.key,value:i,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:d})),"array"===e.j(i)&&0===i.length&&n.push(new e.V(t.key,i,"array must have at least one stop")),n},default:function(e){return W({key:e.key,value:e.value,valueSpec:n,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===r&&l&&h.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===r||t.value.stops||h.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===r&&t.valueSpec.expression&&!e.s(t.valueSpec)&&h.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(c&&!e.m(t.valueSpec)?h.push(new e.V(t.key,t.value,"property functions not supported")):l&&!e.n(t.valueSpec)&&h.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==t.value.property||h.push(new e.V(t.key,t.value,'"property" property is required')),h;function d(t){let r=[];const i=t.value,l=t.key;if("array"!==e.j(i))return[new e.V(l,i,"array expected, ".concat(e.j(i)," found"))];if(2!==i.length)return[new e.V(l,i,"array length 2 expected, length ".concat(i.length," found"))];if(u){if("object"!==e.j(i[0]))return[new e.V(l,i,"object expected, ".concat(e.j(i[0])," found"))];if(void 0===i[0].zoom)return[new e.V(l,i,"object stop key must have zoom")];if(void 0===i[0].value)return[new e.V(l,i,"object stop key must have value")];const n=e.u(i[0].zoom);if("number"!=typeof n)return[new e.V(l,i[0].zoom,"stop zoom values must be numbers")];if(a&&a>n)return[new e.V(l,i[0].zoom,"stop zoom values must appear in ascending order")];n!==a&&(a=n,o=void 0,s={}),r=r.concat(S({key:"".concat(l,"[0]"),value:i[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:A,value:f}}))}else r=r.concat(f({key:"".concat(l,"[0]"),value:i[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},i));return e.o(e.q(i[1]))?r.concat([new e.V("".concat(l,"[1]"),i[1],"expressions are not allowed in function stops.")]):r.concat(W({key:"".concat(l,"[1]"),value:i[1],valueSpec:n,style:t.style,styleSpec:t.styleSpec}))}function f(t,a){const l=e.j(t.value),c=e.u(t.value),u=null!==t.value?t.value:a;if(i){if(l!==i)return[new e.V(t.key,u,"".concat(l," stop domain type must match previous stop domain type ").concat(i))]}else i=l;if("number"!==l&&"string"!==l&&"boolean"!==l&&"number"!=typeof c&&"string"!=typeof c&&"boolean"!=typeof c)return[new e.V(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==r){let i="number expected, ".concat(l," found");return e.m(n)&&void 0===r&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,u,i)]}return"categorical"!==r||"number"!==l||"number"==typeof c&&isFinite(c)&&Math.floor(c)===c?"categorical"!==r&&"number"===l&&"number"==typeof c&&"number"==typeof o&&void 0!==o&&cnew e.V("".concat(t.key).concat(n.key),t.value,n.message)));const r=n.value.expression||n.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return[new e.V(t.key,t.value,'Invalid data expression for "'.concat(t.propertyKey,'". Output values must be contained as literals within the expression.'))];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.v(r))return[new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return C(r,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.x(r,["zoom","feature-state"]))return[new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.y(r))return[new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function C(t,n){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(n.valueSpec&&n.valueSpec.expression)for(const e of n.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const i=[];return t instanceof e.C&&r.has(t.name)?[new e.V(n.key,n.value,'["'.concat(t.name,'"] expression is not supported in a filter for a ').concat(n.object.type," layer with id: ").concat(n.object.id))]:(t.eachChild((e=>{i.push(...C(e,n))})),i)}function k(t){const n=t.key,r=t.value,i=t.valueSpec,o=[];return Array.isArray(i.values)?-1===i.values.indexOf(e.u(r))&&o.push(new e.V(n,r,"expected one of [".concat(i.values.join(", "),"], ").concat(JSON.stringify(r)," found"))):-1===Object.keys(i.values).indexOf(e.u(r))&&o.push(new e.V(n,r,"expected one of [".concat(Object.keys(i.values).join(", "),"], ").concat(JSON.stringify(r)," found"))),o}function I(t){return e.A(e.q(t.value))?T(e.k({},t,{expressionContext:"filter",valueSpec:t.styleSpec["filter_".concat(t.layerType||"fill")]})):P(t)}function P(t){const n=t.value,r=t.key;if("array"!==e.j(n))return[new e.V(r,n,"array expected, ".concat(e.j(n)," found"))];const i=t.styleSpec;let o,a=[];if(n.length<1)return[new e.V(r,n,"filter array must have at least 1 element")];switch(a=a.concat(k({key:"".concat(r,"[0]"),value:n[0],valueSpec:i.filter_operator,style:t.style,styleSpec:t.styleSpec})),e.u(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===e.u(n[1])&&a.push(new e.V(r,n,'"$type" cannot be use with operator "'.concat(n[0],'"')));case"==":case"!=":3!==n.length&&a.push(new e.V(r,n,'filter array for operator "'.concat(n[0],'" must have 3 elements')));case"in":case"!in":n.length>=2&&(o=e.j(n[1]),"string"!==o&&a.push(new e.V("".concat(r,"[1]"),n[1],"string expected, ".concat(o," found"))));for(let s=2;s{t in r&&n.push(new e.V(i,r[t],'"'.concat(t,'" is prohibited for ref layers')))})),o.layers.forEach((n=>{e.u(n.id)===l&&(t=n)})),t?t.ref?n.push(new e.V(i,r.ref,"ref cannot reference another ref layer")):s=e.u(t.type):"string"==typeof l&&n.push(new e.V(i,r.ref,'ref layer "'.concat(l,'" not found')))}else if("background"!==s&&"sky"!==s&&"slot"!==s)if(r.source){const t=o.sources&&o.sources[r.source],a=t&&e.u(t.type);t?"vector"===a&&"raster"===s?n.push(new e.V(i,r.source,'layer "'.concat(r.id,'" requires a raster source'))):"raster"===a&&"raster"!==s?n.push(new e.V(i,r.source,'layer "'.concat(r.id,'" requires a vector source'))):"vector"!==a||r["source-layer"]?"raster-dem"===a&&"hillshade"!==s?n.push(new e.V(i,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==a||["raster","raster-particle"].includes(s)?"line"!==s||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||"geojson"===a&&t.lineMetrics?"raster-particle"===s&&"raster-array"!==a&&n.push(new e.V(i,r.source,'layer "'.concat(r.id,"\" requires a 'raster-array' source."))):n.push(new e.V(i,r,'layer "'.concat(r.id,'" specifies a line-gradient, which requires a GeoJSON source with `lineMetrics` enabled.'))):n.push(new e.V(i,r.source,"raster-array source can only be used with layer type 'raster'.")):n.push(new e.V(i,r,'layer "'.concat(r.id,'" must specify a "source-layer"'))):n.push(new e.V(i,r.source,'source "'.concat(r.source,'" not found')))}else n.push(new e.V(i,r,'missing required property "source"'));return n=n.concat(S({key:i,value:r,valueSpec:a.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>W({key:"".concat(i,".type"),value:r.type,valueSpec:a.layer.type,style:t.style,styleSpec:t.styleSpec,object:r,objectKey:"type"}),filter:t=>I(e.k({layerType:s},t)),layout:t=>S({layer:r,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>z(e.k({layerType:s},t))}}),paint:t=>S({layer:r,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>L(e.k({layerType:s,layer:r},t))}})}})),n}function D(t){const n=t.value,r=t.key,i=e.j(n);return"string"!==i?[new e.V(r,n,"string expected, ".concat(i," found"))]:[]}const B={promoteId:function(t){let{key:n,value:r}=t;if("string"===e.j(r))return D({key:n,value:r});{const e=[];for(const t in r)e.push(...D({key:"".concat(n,".").concat(t),value:r[t]}));return e}}};function F(t){const n=t.value,r=t.key,i=t.styleSpec,o=t.style;if(!n.type)return[new e.V(r,n,'"type" is required')];const a=e.u(n.type);let s=[];switch(["vector","raster","raster-dem","raster-array"].includes(a)&&(n.url||n.tiles||s.push(new e.i(r,n,'Either "url" or "tiles" is required.'))),a){case"vector":case"raster":case"raster-dem":case"raster-array":return s=s.concat(S({key:r,value:n,valueSpec:i["source_".concat(a.replace("-","_"))],style:t.style,styleSpec:i,objectElementValidators:B})),s;case"geojson":if(s=S({key:r,value:n,valueSpec:i.source_geojson,style:o,styleSpec:i,objectElementValidators:B}),n.cluster)for(const e in n.clusterProperties){const[t,i]=n.clusterProperties[e],o="string"==typeof t?[t,["accumulated"],["get",e]]:t;s.push(...T({key:"".concat(r,".").concat(e,".map"),value:i,expressionContext:"cluster-map"})),s.push(...T({key:"".concat(r,".").concat(e,".reduce"),value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return S({key:r,value:n,valueSpec:i.source_video,style:o,styleSpec:i});case"image":return S({key:r,value:n,valueSpec:i.source_image,style:o,styleSpec:i});case"canvas":return[new e.V(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return k({key:"".concat(r,".type"),value:n.type,valueSpec:{values:N(i)},style:o,styleSpec:i})}}function N(e){return e.source.reduce(((t,n)=>{const r=e[n];return"enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values))),t}),[])}function j(t){const n=t.value,r=t.styleSpec,i=r.light,o=t.style;let a=[];const s=e.j(n);if(void 0===n)return a;if("object"!==s)return a=a.concat([new e.V("light",n,"object expected, ".concat(s," found"))]),a;for(const l in n){const t=l.match(/^(.*)-transition$/);a=a.concat(t&&i[t[1]]&&i[t[1]].transition?W({key:l,value:n[l],valueSpec:r.transition,style:o,styleSpec:r}):i[l]?W({key:l,value:n[l],valueSpec:i[l],style:o,styleSpec:r}):[new e.V(l,n[l],'unknown property "'.concat(l,'"'))])}return a}function V(t){const n=t.value;let r=[];if(!n)return r;const i=e.j(n);if("object"!==i)return r=r.concat([new e.V("light-3d",n,"object expected, ".concat(i," found"))]),r;const o=t.styleSpec,a=o["light-3d"],s=t.key,l=t.style,c=t.style.lights;for(const d of["type","id"])if(!(d in n))return r=r.concat([new e.V("light-3d",n,"missing property ".concat(d," on light"))]),r;if(n.type&&c)for(let d=0;d[],array:M,boolean:function(t){const n=t.value,r=t.key,i=e.j(n);return"boolean"!==i?[new e.V(r,n,"boolean expected, ".concat(i," found"))]:[]},number:A,color:function(t){const n=t.key,r=t.value,i=e.j(r);return"string"!==i?[new e.V(n,r,"color expected, ".concat(i," found"))]:null===e.z(r)?[new e.V(n,r,'color expected, "'.concat(r,'" found'))]:[]},enum:k,filter:I,function:E,layer:O,object:S,source:F,model:e.F,light:j,"light-3d":V,terrain:U,fog:G,string:D,formatted:function(e){return 0===D(e).length?[]:T(e)},resolvedImage:function(e){return 0===D(e).length?[]:T(e)},projection:function(t){const n=t.value,r=t.styleSpec,i=r.projection,o=t.style;let a=[];const s=e.j(n);if("object"===s)for(const e in n)a=a.concat(W({key:e,value:n[e],valueSpec:i[e],style:o,styleSpec:r}));else"string"!==s&&(a=a.concat([new e.V("projection",n,"object or string expected, ".concat(s," found"))]));return a},import:function(t){const{value:n,styleSpec:r}=t,{data:i,...o}=n;Object.defineProperty(o,"__line__",{value:n.__line__,enumerable:!1});let a=S(e.k({},t,{value:o,valueSpec:r.import}));return""===e.u(o.id)&&a.push(new e.V("".concat(t.key,".id"),o,"import id can't be an empty string")),i&&(a=a.concat(Z(i,r,{key:"".concat(t.key,".data")}))),a}};function W(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=t.value,i=t.valueSpec,o=t.styleSpec;if(i.expression&&e.B(e.u(r)))return E(t);if(i.expression&&e.o(e.q(r)))return T(t);if(i.type&&q[i.type]){const r=q[i.type](t);return!0===n&&r.length>0&&"array"===e.j(t.value)?T(t):r}return S(e.k({},t,{valueSpec:i.type?o[i.type]:i}))}function H(t){const n=t.value,r=t.key,i=D(t);return i.length||(-1===n.indexOf("{fontstack}")&&i.push(new e.V(r,n,'"glyphs" url must include a "{fontstack}" token')),-1===n.indexOf("{range}")&&i.push(new e.V(r,n,'"glyphs" url must include a "{range}" token'))),i}function Z(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.G;return W({key:(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).key||"",value:t,valueSpec:n.$root,styleSpec:n,style:t,objectElementValidators:{glyphs:H,"*":()=>[]}})}function Y(t){return oe(Z(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.G))}const Q=e=>oe(F(e)),X=e=>oe(j(e)),K=e=>oe(V(e)),J=e=>oe(U(e)),$=e=>oe(G(e)),ee=e=>oe(O(e)),te=e=>oe(I(e)),ne=e=>oe(L(e)),re=e=>oe(z(e)),ie=t=>oe(e.F(t));function oe(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function ae(t,n){let r=!1;if(n&&n.length)for(const i of n)i instanceof e.i?e.w(i.message):(t.fire(new e.a(new Error(i.message))),r=!0);return r}const se=new e.H({anchor:new e.J(e.G.light.anchor),position:new e.K(e.G.light.position),color:new e.J(e.G.light.color),intensity:new e.J(e.G.light.intensity)});class le extends e.E{constructor(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"flat";super(),this._transitionable=new e.L(se),this.setLight(t,n),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._validate(X,e,n)||(this._transitionable.setTransitionOrValue(e),this.id=t)}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,n,r){return(!r||!1!==r.validate)&&ae(this,t.call(Y,e.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:e.G})))}}const ce=new e.H({source:new e.J(e.G.terrain.source),exaggeration:new e.J(e.G.terrain.exaggeration)});let ue=class extends e.E{constructor(t,n,r,i){super(),this.scope=r,this._transitionable=new e.L(ce,r,i),this._transitionable.setTransitionOrValue(t,i),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=n}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.N(t)).get("exaggeration")}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.Z}};const he=45,de=65,fe=.05;function pe(t,n,r,i){const o=e.S(he,de,r),[a,s]=me(t,i);let l=1-Math.min(1,Math.exp((n-a)/(s-a)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*o*t.alpha}function me(e,t){const n=.5/Math.tan(.5*t);return[e.range[0]+n,e.range[1]+n]}function ge(t,n,r,i,o){const a=e.Q.transformMat4([],[n,r,i],o.mercatorFogMatrix);return pe(t,e.Q.length(a),o.pitch,o._fov)}function _e(t,n,r,i,o,a,s){const l=[[r,i,0],[o,i,0],[o,a,0],[r,a,0]];let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(const h of l){const t=e.Q.transformMat4([],h,n),r=e.Q.length(t);c=Math.min(c,r),u=Math.max(u,r)}return[pe(t,c,s.pitch,s._fov),pe(t,u,s.pitch,s._fov)]}const ye=new e.H({range:new e.J(e.G.fog.range),color:new e.J(e.G.fog.color),"high-color":new e.J(e.G.fog["high-color"]),"space-color":new e.J(e.G.fog["space-color"]),"horizon-blend":new e.J(e.G.fog["horizon-blend"]),"star-intensity":new e.J(e.G.fog["star-intensity"]),"vertical-range":new e.J(e.G.fog["vertical-range"])});class ve extends e.E{constructor(t,n,r,i){super(),this._transitionable=new e.L(ye,r,new Map(i)),this.set(t,i),this._transitioning=this._transitionable.untransitioned(),this._transform=n,this.properties=new e.U(ye)}get state(){const t=this._transform,n="globe"===t.projection.name,r=e.W(t.zoom),i=this.properties.get("range"),o=[.5,3];return{range:n?[e.X(o[0],i[0],r),e.X(o[1],i[1],r)]:i,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._validate($,t,r))return;const i=e.e({},t);for(const o of Object.keys(e.G.fog))void 0===i[o]&&(i[o]=e.G.fog[o].default);this._options=i,this._transitionable.setTransitionOrValue(this._options,n)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const n=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.S(he,de,t))*n.a}getOpacityAtLatLng(t,n){return this._transform.projection.supportsFog?function(t,n,r){const i=e.O.fromLngLat(n),o=r.elevation?r.elevation.getAtPointOrZero(i):0;return ge(t,i.x,i.y,o,r)}(this.state,t,n):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const n=this._transform.calculateFogTileMatrix(t.toUnwrapped());return _e(this.state,n,0,0,e.Y,e.Y,this._transform)}getOpacityForBounds(e,t,n,r,i){return this._transform.projection.supportsFog?_e(this.state,e,t,n,r,i,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?me(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const n=[4,5,6,7];for(const r of n){const n=t.points[r];let i;if(n[2]>=0)i=n;else{const o=t.points[r-4];i=e._(o,n,o[2]/(o[2]-n[2]))}if(ge(this.state,i[0],i[1],0,this._transform)>=fe)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e))}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,n,r){return(!r||!1!==r.validate)&&ae(this,t.call(Y,e.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:e.G})))}}class xe extends e.E{constructor(t,n,r,i){super(),this.scope=r,this._options=t,this.properties=new e.U(n),this._transitionable=new e.L(n,r,new Map(i)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}const be=new e.H({color:new e.J(e.G.properties_light_ambient.color),intensity:new e.J(e.G.properties_light_ambient.intensity)}),we=new e.H({direction:new e.$(e.G.properties_light_directional.direction),color:new e.J(e.G.properties_light_directional.color),intensity:new e.J(e.G.properties_light_directional.intensity),"cast-shadows":new e.J(e.G.properties_light_directional["cast-shadows"]),"shadow-intensity":new e.J(e.G.properties_light_directional["shadow-intensity"])});class Se{constructor(e,t,n,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=n,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(t,n){let r,i;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);r=[o],i=n.isPointAboveHorizon(o)}else{const o=e.P.convert(t[0]),a=e.P.convert(t[1]);r=[o,a],i=e.a0(o,a).every((e=>n.isPointAboveHorizon(e)))}return new Se(r,n.getCameraPoint(),i,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.a0(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const n=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],i=e.a0(n,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=r.x?i[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(i[3]=this.cameraPoint)),e.a1(i,t)}bufferedCameraGeometryGlobe(t){const n=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],i=e.a0(n,r,t),o=this.cameraPoint.clone();switch(3*((o.y>n.y)+(o.y>r.y))+((o.x>n.x)+(o.x>r.x))){case 0:i[0]=o,i[4]=o.clone();break;case 1:i.splice(1,0,o);break;case 2:i[1]=o;break;case 3:i.splice(4,0,o);break;case 5:i.splice(2,0,o);break;case 6:i[3]=o;break;case 7:i.splice(3,0,o);break;case 8:i[2]=o}return i}containsTile(t,n,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const o=t.queryPadding/n._pixelsPerMercatorPixel+1,a=r?this._bufferedCameraMercator(o,n):this._bufferedScreenMercator(o,n);let s=t.tileID.wrap+(a.unwrapped?i:0);const l=a.polygon.map((n=>e.a2(t.tileTransform,n,s)));if(!e.a3(l,0,0,e.Y,e.Y))return;s=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?i:0);const c=this.screenGeometryMercator.polygon.map((n=>e.a4(t.tileTransform,n,s))),u=c.map((t=>new e.P(t[0],t[1]))),h=n.getFreeCameraOptions().position||new e.O(0,0,0),d=e.a4(t.tileTransform,h,s),f=c.map((t=>{const n=e.Q.sub(t,t,d);return e.Q.normalize(n,n),new e.a5(d,n)})),p=e.a6(t,1,n.zoom)*n._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:f,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.a7(l),m.min.x=e.ad(m.min.x,0,e.Y),m.min.y=e.ad(m.min.y,0,e.Y),m.max.x=e.ad(m.max.x,0,e.Y),m.max.y=e.ad(m.max.y,0,e.Y),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var m}_bufferedScreenMercator(e,t){const n=Ee(e);if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[n]=r,r}}_bufferedCameraMercator(e,t){const n=Ee(e);if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[n]=r,r}}_projectAndResample(t,n){const r=function(t,n){const r=e.a9.multiply([],n.pixelMatrix,n.globeMatrix),i=[0,-e.ae,0,1],o=[0,e.ae,0,1],a=[0,0,0,1];e.aa.transformMat4(i,i,r),e.aa.transformMat4(o,o,r),e.aa.transformMat4(a,a,r);const s=new e.P(i[0]/i[3],i[1]/i[3]),l=new e.P(o[0]/o[3],o[1]/o[3]),c=e.ab(t,s)&&i[3]1?Me(t.slice(0,d),n):[],m=dnew e.P(Ae(t.x),t.y))),m=m.map((t=>new e.P(Ae(t.x),t.y)));const g=[...p];0===g.length&&g.push(m[m.length-1]);const _=e.X(g[g.length-1].y,(0===m.length?p[0]:m[0]).y,f);let y;return y=c?[new e.P(0,_),new e.P(0,0),new e.P(1,0),new e.P(1,_)]:[new e.P(1,_),new e.P(1,1),new e.P(0,1),new e.P(0,_)],g.push(...y),0===m.length?g.push(p[0]):g.push(...m),{polygon:g.map((t=>new e.O(t.x,t.y))),unwrapped:!1}}(t,n);if(r)return r;const i=function(t,n){let r=!1,i=-1/0,o=0;for(let e=0;ei&&(i=t[e].x,o=e);for(let e=0;e.5&&(i.x{e.x-=1})),{polygon:t,unwrapped:r}}(Me(t,n).map((t=>new e.P(Ae(t.x),t.y))),n);return{polygon:i.polygon.map((t=>new e.O(t.x,t.y))),unwrapped:i.unwrapped}}}function Me(t,n){return e.ac(t,(e=>{const t=n.pointCoordinate3D(e);e.x=t.x,e.y=t.y}),1/256)}function Ae(e){return e<0?1+e%1:e%1}function Ee(e){return 100*e|0}function Te(t,n,r,i,o){const a=function(r,i){if(r)return o(r);if(i){t.url&&i.tiles&&t.tiles&&delete t.tiles;const r=e.af(e.e(i,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);i.vector_layers&&(r.vectorLayers=i.vector_layers,r.vectorLayerIds=r.vectorLayers.map((e=>e.id))),i.raster_layers&&(r.rasterLayers=i.raster_layers,r.rasterLayerIds=r.rasterLayers.map((e=>e.id))),r.tiles=n.canonicalizeTileset(r,t.url),o(null,r)}};return t.url?e.g(n.transformRequest(n.normalizeSourceURL(t.url,null,r,i),e.R.Source),a):e.f.frame((()=>a(null,t)))}class Ce{constructor(t,n,r){this.bounds=e.ag.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=r||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 n=Math.pow(2,t.z),r=Math.floor(e.a8(this.bounds.getWest())*n),i=Math.floor(e.ah(this.bounds.getNorth())*n),o=Math.ceil(e.a8(this.bounds.getEast())*n),a=Math.ceil(e.ah(this.bounds.getSouth())*n);return t.x>=r&&t.x=i&&t.y{this._tileJSONRequest=null,this._loaded=!0,i?(n&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ".concat(n)),r&&2!==r.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: ".concat(r)),this.fire(new e.a(i))):o&&(e.e(this,o),o.bounds&&(this.tileBounds=new Ce(o.bounds,this.minzoom,this.maxzoom)),e.am(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.aj(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.e({},this._options)}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),i={request:this.map._requestManager.transformRequest(r,e.R.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,scope:this.scope,pixelRatio:e.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster};if(i.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=n:t.request=t.actor.send("reloadTile",i,o.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",i,o.bind(this),void 0,!0);else{const n=e.ak.call({deduped:this._deduped},i,((e,n)=>{e||!n?o.call(this,e):(i.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},t.actor&&t.actor.send("loadTile",i,o.bind(this),void 0,!0))}),!0);t.request={cancel:n}}function o(r,i){return delete t.request,t.aborted?n(null):r&&404!==r.status?n(r):(i&&i.resourceTiming&&(t.resourceTiming=i.resourceTiming),this.map._refreshExpiredTiles&&i&&t.setExpiryData(i),t.loadVectorData(i,this.map.painter),e.al(this.dispatcher),n(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,scope:this.scope})}unloadTile(e){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Ie extends e.E{constructor(t,n,r,i){super(),this.id=t,this.dispatcher=r,this.setEventedParent(i),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},n),e.e(this,e.af(n,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"})),this._tileJSONRequest=Te(this._options,this.map._requestManager,null,null,((n,r)=>{this._tileJSONRequest=null,this._loaded=!0,n?this.fire(new e.a(n)):r&&(e.e(this,r),r.bounds&&(this.tileBounds=new Ce(r.bounds,this.minzoom,this.maxzoom)),e.am(r.tiles),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.aj(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const r=e.f.devicePixelRatio>=2,i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);t.request=e.d(this.map._requestManager.transformRequest(i,e.R.Tile),((r,i,o,a)=>(delete t.request,t.aborted?(t.state="unloaded",n(null)):r?(t.state="errored",n(r)):i?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:a}),t.setTexture(i,this.map.painter),t.state="loaded",e.al(this.dispatcher),void n(null)):n(null))))}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(t,n){t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),n()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Pe extends Ie{constructor(t,n,r,i){super(t,n,r,i),this.type="raster-array",this.maxzoom=22,this._options=e.e({type:"raster-array"},n)}triggerRepaint(e){const t=this.map.painter._terrain,n=this.map.style.getSourceCache(this.id);t&&t.enabled&&n&&t._clearRenderCacheForTile(n.id,e.tileID),this.map.triggerRepaint()}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),i=this.map._requestManager.transformRequest(r,e.R.Tile);t.requestParams=i,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,((e,r,i,o)=>{if(delete t.request,t.aborted)return t.state="unloaded",n(null);if(e){if(20===e.code)return;return t.state="errored",n(e)}this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:i,expires:o}),t.state="empty",n(null)}))}unloadTile(t){const n=t.texture;n&&n instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(n)):(t.destroy(),t.flushQueues(),t._isHeaderLoaded=!1,delete t._mrt,delete t.textureDescriptor),t.fbo&&(t.fbo.destroy(),delete t.fbo),delete t.request,delete t.requestParams,delete t.neighboringTiles,t.state="unloaded"}prepareTile(t,n,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(n,r,((n,r)=>{if(n)return t.state="errored",this.fire(new e.a(n)),void this.triggerRepaint(t);r&&(t.setTexture(r,this.map.painter),t.state="loaded",this.triggerRepaint(t))})))}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find((t=>{let{id:n}=t;return n===e})),n=t&&t.fields,r=n&&n.bands&&n.bands;return r?r[0]:0}getTextureDescriptor(t,n,r){if(!t)return;const i=n.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!i)return;let o=null;n instanceof e.aq?o=n.paint.get("raster-array-band"):n instanceof e.ar&&(o=n.paint.get("raster-particle-array-band"));const a=o||this.getInitialBand(i);if(null!=a)if(t.textureDescriptor){if(!t.updateNeeded(i,a)||r)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,i,a)}}const Re=32,Le=33,ze=new Uint16Array(8184);for(let ys=0;ys<2046;ys++){let e=ys+2,t=0,n=0,r=0,i=0,o=0,a=0;for(1&e?r=i=o=Re:t=n=a=Re;(e>>=1)>1;){const s=t+r>>1,l=n+i>>1;1&e?(r=t,i=n,t=o,n=a):(t=r,n=i,r=o,i=a),o=s,a=l}const s=4*ys;ze[s+0]=t,ze[s+1]=n,ze[s+2]=r,ze[s+3]=i}const Oe=new Uint16Array(2178),De=new Uint8Array(1089),Be=new Uint16Array(1089);function Fe(e){return 0===e?-.03125:32===e?.03125:0}class Ne{constructor(e,t,n,r){this.id=Ne.uniqueIdxCounter,Ne.uniqueIdxCounter++,this.context=e;const i=e.gl;this.buffer=i.createBuffer(),this.dynamicDraw=Boolean(n),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||r||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=Ne.uniqueIdxCounter,Ne.uniqueIdxCounter++;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)}}Ne.uniqueIdxCounter=0;const je={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ve{constructor(e,t,n,r,i,o){this.length=t.length,this.attributes=n,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.instanceCount=o,this.context=e;const a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||i||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 n=0;n0&&e.vertexAttribDivisor(i,n)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ue{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 Ge extends Ue{getDefault(){return e.aA.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 qe extends Ue{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class We extends Ue{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class He extends Ue{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 Ze extends Ue{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Ye extends Ue{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Qe extends Ue{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 Xe extends Ue{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 Ke extends Ue{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 Je extends Ue{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 $e extends Ue{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 et extends Ue{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class tt extends Ue{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 nt extends Ue{getDefault(){const e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}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.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class rt extends Ue{getDefault(){return e.aA.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 it extends Ue{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1)}}class ot extends Ue{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 at extends Ue{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class st extends Ue{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let lt=class extends Ue{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class ct extends Ue{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class ut extends Ue{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 ht extends Ue{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 dt extends Ue{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 ft extends Ue{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 pt extends Ue{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 mt extends Ue{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class gt extends Ue{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class _t extends Ue{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 yt extends Ue{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 vt extends Ue{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 xt extends Ue{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class bt extends xt{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 wt extends xt{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 St extends xt{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.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Mt extends wt{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class At{constructor(e,t,n,r,i){this.context=e,this.width=t,this.height=n;const o=this.framebuffer=e.gl.createFramebuffer();r&&(this.colorAttachment=new bt(e,o)),i&&(this.depthAttachmentType=i,this.depthAttachment="renderbuffer"===i?new wt(e,o):new St(e,o))}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}else{const t=this.depthAttachment.get();t&&e.deleteTexture(t)}e.deleteFramebuffer(this.framebuffer)}}class Et{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}Et.ReadOnly=!1,Et.ReadWrite=!0,Et.disabled=new Et(519,Et.ReadOnly,[0,1]);const Tt=7680;class Ct{constructor(e,t,n,r,i,o){this.test=e,this.ref=t,this.mask=n,this.fail=r,this.depthFail=i,this.pass=o}}Ct.disabled=new Ct({func:519,mask:0},0,0,Tt,Tt,Tt);const kt=771;class It{constructor(e,t,n,r){this.blendFunction=e,this.blendColor=t,this.mask=n,this.blendEquation=r}}It.Replace=[1,0,1,0],It.disabled=new It(It.Replace,e.aA.transparent,[!1,!1,!1,!1]),It.unblended=new It(It.Replace,e.aA.transparent,[!0,!0,!0,!0]),It.alphaBlended=new It([1,kt,1,kt],e.aA.transparent,[!0,!0,!0,!0]),It.multiply=new It([774,0,774,0],e.aA.transparent,[!0,!0,!0,!0]);const Pt=1029,Rt=2305;class Lt{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}Lt.disabled=new Lt(!1,Pt,Rt),Lt.backCCW=new Lt(!0,Pt,Rt),Lt.backCW=new Lt(!0,Pt,2304),Lt.frontCW=new Lt(!0,1028,2304),Lt.frontCCW=new Lt(!0,1028,Rt);class zt{constructor(e,t){this.gl=e,this.clearColor=new Ge(this),this.clearDepth=new qe(this),this.clearStencil=new We(this),this.colorMask=new He(this),this.depthMask=new Ze(this),this.stencilMask=new Ye(this),this.stencilFunc=new Qe(this),this.stencilOp=new Xe(this),this.stencilTest=new Ke(this),this.depthRange=new Je(this),this.depthTest=new $e(this),this.depthFunc=new et(this),this.blend=new tt(this),this.blendFunc=new nt(this),this.blendColor=new rt(this),this.blendEquation=new it(this),this.cullFace=new ot(this),this.cullFaceSide=new at(this),this.frontFace=new st(this),this.program=new lt(this),this.activeTexture=new ct(this),this.viewport=new ut(this),this.bindFramebuffer=new ht(this),this.bindRenderbuffer=new dt(this),this.bindTexture=new ft(this),this.bindVertexBuffer=new pt(this),this.bindElementBuffer=new mt(this),this.bindVertexArrayOES=new gt(this),this.pixelStoreUnpack=new _t(this),this.pixelStoreUnpackPremultiplyAlpha=new yt(this),this.pixelStoreUnpackFlipY=new vt(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(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.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1]}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.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t,n){return new Ne(this,e,t,n)}createVertexBuffer(e,t,n,r,i){return new Ve(this,e,t,n,r,i)}createRenderbuffer(e,t,n){const r=this.gl,i=r.createRenderbuffer();return this.bindRenderbuffer.set(i),r.renderbufferStorage(r.RENDERBUFFER,e,t,n),this.bindRenderbuffer.set(null),i}createFramebuffer(e,t,n,r){return new At(this,e,t,n,r)}clear(e){let{color:t,depth:n,stencil:r,colorMask:i}=e;const o=this.gl;let a=0;t&&(a|=o.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set(i||[!0,!0,!0,!0])),void 0!==n&&(a|=o.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),void 0!==r&&(a|=o.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),o.clear(a)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){t(e.blendFunction,It.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}var Ot=e.aB([{name:"a_index",type:"Int16",components:1}]);const Dt=.15000000000000002;class Bt{constructor(t,n,r,i){const o={width:r[0],height:r[1],data:null},a=t.gl;this.targetColorTexture=new e.T(t,o,a.RGBA,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,a.RGBA,{useMipmap:!1}),this.context=t,this.setParticleTextureDimension(n,i),this.lastInvalidatedAt=0}setParticleTextureDimension(t,n){if(this.particleTextureDimension===n)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const r=this.context.gl,i=n*n,o=new Uint8Array(4*i),a=.7692307692307692,s=e.aC(t.key);for(let e=0;e[[new e.P(0,0),new e.P(e.Y+1,0),new e.P(e.Y+1,e.Y+1),new e.P(0,e.Y+1),new e.P(0,0)]]};class Nt{constructor(t,n,r,i,o){this.tileID=t,this.uid=e.aF(),this.uses=0,this.tileSize=n,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,i&&i.style&&(this._lastUpdatedBrightness=i.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",i&&i.transform&&(this.projection=i.transform.projection)}registerFadeDuration(t){const n=t+this.timeAdded;nt.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)n[t.fqid]=r}}return n}(t.buckets,n.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const n=this.buckets[t];if(n instanceof e.aH){if(this.hasSymbolBuckets=!0,!r)break;n.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const n=this.buckets[t];if(n instanceof e.aH&&n.hasRTLText){this.hasRTLText=!0,e.aI();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e],r=n.style.getOwnLayer(e);if(!r)continue;const i=r.queryRadius(t);this.queryPadding=Math.max(this.queryPadding,i)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new e.aG}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.fqid]}upload(t){for(const e in this.buckets){const n=this.buckets[e];n.uploadPending()&&n.upload(t)}const n=t.gl,r=this.imageAtlas;if(r&&!r.uploaded){const i=!!Object.keys(r.patternPositions).length;this.imageAtlasTexture=new e.T(t,r.image,n.RGBA,{useMipmap:i}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,n.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new e.T(t,this.lineAtlas.image,n.R8),this.lineAtlas.uploaded=!0)}prepare(e,t,n){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,n),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const r=t.style.getBrightness();(this._lastUpdatedBrightness||r)&&(this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this._lastUpdatedBrightness=r,this.updateBuckets(void 0,t)))}queryRenderedFeatures(e,t,n,r,i,o,a,s){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:a,transform:o,params:i,tileTransform:this.tileTransform},e,t,n):{}}querySourceFeatures(t,n){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const i=r.loadVTLayers(),o=n?n.sourceLayer:"",a=i._geojsonTileLayer||i[o];if(!a)return;const s=e.aJ(n&&n.filter),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let d=0;de)t=!1;else if(n)if(this.expirationTime=0;e--){const t=4*e,n=ze[t+0],r=ze[t+1],i=ze[t+2],o=ze[t+3],a=n+i>>1,s=r+o>>1,l=a+s-r,c=s+n-a,u=r*Le+n,h=o*Le+i,d=s*Le+a,f=Math.hypot((Oe[2*u+0]+Oe[2*h+0])/2-Oe[2*d+0],(Oe[2*u+1]+Oe[2*h+1])/2-Oe[2*d+1])>=16;De[d]=De[d]||(f?1:0),e<1022&&(De[d]=De[d]||De[(r+c>>1)*Le+(n+l>>1)]||De[(o+c>>1)*Le+(i+l>>1)])}const o=new e.ay,a=new e.az;let s=0;function l(t,n){const r=n*Le+t;return 0===Be[r]&&(o.emplaceBack(Oe[2*r+0],Oe[2*r+1],t*e.Y/Re,n*e.Y/Re),Be[r]=++s),Be[r]-1}function c(e,t,n,r,i,o){const s=e+n>>1,u=t+r>>1;if(Math.abs(e-i)+Math.abs(t-o)>1&&De[u*Le+s])c(i,o,e,t,s,u),c(n,r,i,o,s,u);else{const s=l(e,t),c=l(n,r),u=l(i,o);a.emplaceBack(s,c,u)}}return c(0,0,Re,Re,Re,0),c(Re,Re,0,0,0,Re),{vertices:o,indices:a}}(this.tileID.canonical,n);i=t.vertices,o=t.indices}else{i=new e.ay,o=new e.az;for(const{x:e,y:n}of r)i.emplaceBack(e,n,0,0);const t=e.aT(i.int16,void 0,4);for(let e=0;e0&&(l=e.a9.invert(new Float64Array(16),n.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,i,n,a,l,s),this._makeGlobeTileDebugTextBuffer(t,i,n,a,l,s)}_globePoint(t,n,r,i,o,a,s){let l=e.aX(t,n,r);if(a){const o=1<.5?d=-1:h<-.5&&(d=1);let f=(t/e.Y+r.x)/o+d,p=(n/e.Y+r.y)/o;f=(f-c)*i._pixelsPerMercatorPixel+c,p=(p-u)*i._pixelsPerMercatorPixel+u;const m=[f*i.worldSize,p*i.worldSize,0];e.Q.transformMat4(m,m,a),l=e.aY(l,m,s)}return e.Q.transformMat4(l,l,o)}_makeGlobeTileDebugBorderBuffer(t,n,r,i,o,a){const s=new e.aQ,l=new e.aR,c=new e.aZ,u=(e,t,u,h,d)=>{const f=(u-e)/(d-1),p=(h-t)/(d-1),m=s.length;for(let g=0;gh*e+t;for(let e=0;e0&&void 0!==arguments[0]&&arguments[0];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(),delete this.imageAtlasTexture),this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),!t&&this.texture&&this.texture instanceof e.T&&(this.texture.destroy(),delete this.texture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}}const jt={vector:ke,raster:Ie,"raster-dem":class extends Ie{constructor(t,n,r,i){super(t,n,r,i),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(e,r){e&&(t.state="errored",n(e)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",n(null))}t.request=e.d(this.map._requestManager.transformRequest(r,e.R.Tile),function(r,o,a,s){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(r)t.state="errored",n(r);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:s});const n=ImageBitmap&&o instanceof ImageBitmap&&e.an(),r=1-(o.width-e.ao(o.width))/2;r<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=n?o:e.f.getImageData(o,r),c={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:l,encoding:this.encoding,padding:r};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",c,i.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const n=t.canonical,r=Math.pow(2,n.z),i=(n.x-1+r)%r,o=0===n.x?t.wrap-1:t.wrap,a=(n.x+1+r)%r,s=n.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.ap(t.overscaledZ,o,n.z,i,n.y).key]={backfilled:!1},l[new e.ap(t.overscaledZ,s,n.z,a,n.y).key]={backfilled:!1},n.y>0&&(l[new e.ap(t.overscaledZ,o,n.z,i,n.y-1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,s,n.z,a,n.y-1).key]={backfilled:!1}),n.y+10&&void 0!==arguments[0]&&arguments[0];if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.b("dataloading",{dataType:"source"})),this._loaded=!1;const n=e.e({append:t},this.workerOptions);n.scope=this.scope;const r=this._data;"string"==typeof r?(n.request=this.map._requestManager.transformRequest(e.f.resolveURL(r),e.R.Source),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(r),this._pendingLoad=this.actor.send("".concat(this.type,".loadData"),n,((n,r)=>{if(this._loaded=!0,this._pendingLoad=null,n)this.fire(new e.a(n));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.b("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,n){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const 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,scope:this.scope,pixelRatio:e.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};t.request=this.actor.send(r,i,((e,i)=>(delete t.request,t.destroy(),t.aborted?n(null):e?n(e):(t.loadVectorData(i,this.map.painter,"reloadTile"===r),n(null)))),void 0,"loadTile"===r)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.as{constructor(e,t,n,r){super(e,t,n,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,e.R.Source).url);e.at(this.urls,((t,n)=>{this._loaded=!0,t?this.fire(new e.a(t)):n&&(this.video=n,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 n=this.video.seekable;tn.end(0)?this.fire(new e.a(new e.V("sources.".concat(this.id),null,"Playback for this video can be set only between the ".concat(n.start(0)," and ").concat(n.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,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.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:e.as,model:class extends e.E{constructor(e,t,n,r){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t}load(){const t=[];for(const n in this._options.models){const r=this._options.models[n],i=e.l(this.map._requestManager.transformRequest(r.uri,e.R.Model).url).then((t=>{if(!t)return;const i=e.c(t),o=new e.M(n,r.position,r.orientation,i);o.computeBoundsAndApplyParent(),this.models.push(o)})).catch((t=>{this.fire(new e.a(new Error("Could not load model ".concat(n," from ").concat(r.uri,": ").concat(t.message))))}));t.push(i)}return Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"}))})).catch((t=>{this.fire(new e.a(new Error("Could not load models: ".concat(t.message))))}))}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return{type:"model"}}},"batched-model":class extends e.E{constructor(e,t,n,r){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=n,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(r)}onAdd(e){this.map=e,this.load()}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"}));const n=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map._worldview;this._tileJSONRequest=Te(this._options,this.map._requestManager,n,r,((i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?(n&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ".concat(n)),r&&2!==r.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: ".concat(r)),this.fire(new e.a(i))):o&&(e.e(this,o),o.bounds&&(this.tileBounds=new Ce(o.bounds,this.minzoom,this.maxzoom)),e.am(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)}))}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),i={request:this.map._requestManager.transformRequest(r,e.R.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,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=n;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",i,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",i,o.bind(this),void 0,!0);function o(e,r){return t.aborted?n(null):e&&404!==e.status?n(e):(r&&(r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(r),t.buckets={...t.buckets,...r.buckets},r.featureIndex&&(t.latestFeatureIndex=r.featureIndex)),t.state="loaded",void n(null))}}serialize(){return e.e({},this._options)}},canvas:class extends e.as{constructor(t,n,r,i){super(t,n,r,i),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.a(new e.V("sources.".concat(t),null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.a(new e.V("sources.".concat(t),null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new e.a(new e.V("sources.".concat(t),null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof HTMLCanvasElement||this.fire(new e.a(new e.V("sources.".concat(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.a(new e.V("sources.".concat(t),null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.a(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 n=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.au||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(n,this.canvas,n.gl.RGBA,{premultiply:!0}),this._prepareData(n)}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.E{constructor(t,n,r,i){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=n,this.setEventedParent(i),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.a(new Error("Missing implementation for ".concat(this.id," custom source")))),this._implementation.loadTile||this.fire(new e.a(new Error("Missing loadTile implementation for ".concat(this.id," custom source")))),this._implementation.bounds&&(this.tileBounds=new Ce(this._implementation.bounds,this.minzoom,this.maxzoom)),n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),e.e(this,e.af(n,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.af(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.b("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:n,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:n,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:n,y:r,z:i}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:n,y:r,z:i},{signal:o.signal})).then(function(n){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===n?(e.state="errored",t(null)):null===n?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(n)?(this.loadTileData(e,n),e.state="loaded",void t(null)):(e.state="errored",t(new Error("Can't infer data type for ".concat(this.id,", only raster data supported at the moment"))))}.bind(this)).catch((n=>{20!==n.code&&(e.state="errored",t(n))})),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this._map.painter)}unloadTile(t,n){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this._map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:n,z:r}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:n,z:r})}n()}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})))}_clearTiles(){const t=e.aj(this.id,this.scope);this._map.style.clearSource(t)}_update(){this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))}}},Vt=function(t,n,r,i){const o=new jt[n.type](t,n,r,i);if(o.id!==t)throw new Error("Expected Source id to be ".concat(t," instead of ").concat(o.id));return e.a$(["load","abort","unload","serialize","prepare"],o),o};function Ut(t,n){const r=e.a9.identity([]);return e.a9.scale(r,r,[.5*t.width,.5*-t.height,1]),e.a9.translate(r,r,[1,-1,0]),e.a9.multiply(r,r,t.calculateProjMatrix(n.toUnwrapped())),Float32Array.from(r)}function Gt(e,t,n,r,i,o,a){let s=arguments.length>7&&void 0!==arguments[7]&&arguments[7];const l=e.tilesIn(r,a,s);l.sort(Wt);const c=[];for(const h of l)c.push({wrappedTileID:h.tile.tileID.wrapped().key,queryResults:h.tile.queryRenderedFeatures(t,n,e._state,h,i,o,Ut(e.transform,h.tile.tileID),s)});const u=function(e){const t={},n={};for(const r of e){const e=r.queryResults,i=r.wrappedTileID,o=n[i]=n[i]||{};for(const n in e){const r=e[n],i=o[n]=o[n]||{},a=t[n]=t[n]||[];for(const e of r)i[e.featureIndex]||(i[e.featureIndex]=!0,a.push(e))}}return t}(c);for(const h in u)u[h].forEach((t=>{const n=t.feature,r=n.layer;r&&"background"!==r.type&&"sky"!==r.type&&"slot"!==r.type&&(n.source=r.source,r["source-layer"]&&(n.sourceLayer=r["source-layer"]),n.state=void 0!==n.id?e.getFeatureState(r["source-layer"],n.id):{})}));return u}function qt(e,t){const n=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],i={};for(let o=0;o0&&void 0!==arguments[0]?arguments[0]:16384,n=arguments.length>1?arguments[1]:void 0;const r=this._mrt=new e.b0(30),i=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=e.b1(i,((e,i,o,a)=>{if(e)n(e);else try{const e=r.getHeaderLength(i);if(e>t)return void(this.request=this.fetchHeader(e,n));r.parseHeader(i),this._isHeaderLoaded=!0;let s=0;for(const t of Object.values(r.layers))s=Math.max(s,t.dataIndex[t.dataIndex.length-1].last_byte);i.byteLength>=s&&(this.entireBuffer=i),n(null,this.entireBuffer||i,o,a)}catch(e){n(e)}})),this.request}fetchBand(t,n,r){const i=this._mrt;if(!this._isHeaderLoaded||!i)return void r(new Error("Tile header is not ready"));const o=this.actor;if(!o)return void r(new Error("Can't fetch tile band without an actor"));let a;const s=(e,i)=>{a.complete(e,i),e?r(e):(this.updateTextureDescriptor(t,n),r(null,this.textureDescriptor&&this.textureDescriptor.img))},l=(e,t)=>{if(e)return r(e);const n=o.send("decodeRasterArray",{buffer:t,task:a},s,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),a.cancel()}))},c=i.getLayer(t);if(!c)return void r(new Error('Unknown sourceLayer "'.concat(t,'"')));if(c.hasDataForBand(n))return this.updateTextureDescriptor(t,n),void r(null,this.textureDescriptor?this.textureDescriptor.img:null);const u=c.getDataRange([n]);if(a=i.createDecodingTask(u),!a||a.tasks.length)if(this.flushQueues(),this.entireBuffer)l(null,this.entireBuffer.slice(u.firstByte,u.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:"bytes=".concat(u.firstByte,"-").concat(u.lastByte)}}),n=e.b1(t,l);this._fetchQueue.push((()=>{n.cancel(),a.cancel()}))}else r(null)}updateNeeded(e,t){return(!this.textureDescriptor||this.textureDescriptor.band!==t||this.textureDescriptor.layer!==e)&&"errored"!==this.state}updateTextureDescriptor(t,n){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(n)||!r.hasDataForBand(n))return;const{bytes:i,tileSize:o,buffer:a,offset:s,scale:l}=r.getBandView(n),c=o+2*a,u={data:i,width:c,height:c},h=this.texture;h&&h instanceof e.T&&h.update(u,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:n,img:u,buffer:a,offset:s,tileSize:o,format:r.pixelFormat,mix:[l,256*l,65536*l,16777216*l]}}}class Zt{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,n){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const i={value:t,timeout:void 0};if(void 0!==n&&(i.timeout=setTimeout((()=>{this.remove(e,i)}),n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const n=e.wrapped().key,r=void 0===t?0:this.data[n].indexOf(t),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),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 n in this.data)for(const r of this.data[n])e(r.value)||t.push(r);for(const n of t)this.remove(n.value.tileID,n)}}class Yt extends e.E{constructor(e,t,n){super(),this.id=e,this._onlySymbols=n,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 Zt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new x,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===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("errored"!==t.state&&("loaded"!==t.state||!t.bucketsLoaded()))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,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],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){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const n=this._tiles[t];n.upload(e),n.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return e.b2(this._tiles).map((e=>e.tileID)).sort(Qt).map((e=>e.key))}getRenderableIds(t,n){const r=[];for(const e in this._tiles)this._isIdRenderable(+e,t,n)&&r.push(this._tiles[e]);return t?r.sort(((t,n)=>{const r=t.tileID,i=n.tileID,o=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),a=new e.P(i.canonical.x,i.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-i.overscaledZ||a.y-o.y||a.x-o.x})).map((e=>e.tileID.key)):r.map((e=>e.tileID)).sort(Qt).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(n||!this._shadowCasterTiles[e])}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 n=this._tiles[e];n&&("loading"!==n.state&&(n.state=t),this._loadTile(n,this._tileLoaded.bind(this,n,e,t)))}_tileLoaded(t,n,r,i){if(i)if(t.state="errored",404!==i.status)this._source.fire(new e.a(i,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new e.b("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));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 t.timeAdded=e.f.now(),"expired"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new e.b("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,n,r),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,n,r){for(const i in this._tiles){let o=this._tiles[i];if(r[i]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>n)continue;let a=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()&&(a=e)}let s=a;for(;s.overscaledZ>t;)if(s=s.scaledTo(s.overscaledZ-1),e[s.key]){r[a.key]=a;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=t?n:null}for(let n=e.overscaledZ-1;n>=t;n--){const t=e.scaledTo(n),r=this._getLoadedTile(t);if(r)return r}}_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 n=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,i=Math.floor(n*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,i):i,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const n in this._tiles){const r=this._tiles[n];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,n,r,i){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!r)return;let o;if(this.updateCacheSize(t,n),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain)if(this._source.tileID)o=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.ap(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const i=t.clone();i.tileCoverLift=this.tileCoverLift,o=i.coveringTiles({tileSize:n||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.minzoom<=1&&"globe"===t.projection.name&&(o.push(new e.ap(1,0,1,0,0)),o.push(new e.ap(1,0,1,1,0)),o.push(new e.ap(1,0,1,0,1)),o.push(new e.ap(1,0,1,1,1)))}else o=t.coveringTiles({tileSize:n||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&&(o=o.filter((e=>this._source.hasTile(e))));else o=[];if(o.length>0&&this.castsShadows&&i&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Xt(this._source.type)){const e=t.coveringZoomLevel({tileSize:n||this._source.tileSize,roundZoom:this._source.roundZoom&&!r}),a=Math.min(e,this._source.maxzoom),s=t.extendTileCoverForShadows(o,i,a);for(const t of s)this._shadowCasterTiles[t.key]=!0,o.push(t)}const a=this._updateRetainedTiles(o);if(Xt(this._source.type)&&0!==o.length){const t={},n={},r=Object.keys(a);for(const o of r){const r=a[o],i=this._tiles[o];if(!i||i.fadeEndTime&&i.fadeEndTime<=e.f.now())continue;const s=this.findLoadedParent(r,Math.max(r.overscaledZ-Yt.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),n[o]=r}const i=o[o.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(a[e]||!t.hasData())continue;let r=t.tileID;for(;r.overscaledZ>i;){r=r.scaledTo(r.overscaledZ-1);const i=this._tiles[r.key];if(i&&i.hasData()&&n[r.key]){a[e]=t.tileID;break}}}for(const e in t)a[e]||(this._coveredTiles[e]=!0,a[e]=t[e])}for(const e in a)this._tiles[e].clearFadeHold();const s=e.b3(this._tiles,a);for(const e of s){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 n={},r=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),i=e[0].overscaledZ,o=Math.max(i-Yt.maxOverzooming,this._source.minzoom),a=Math.max(i+Yt.maxUnderzooming,this._source.minzoom),s={};for(const l of e){const e=this._addTile(l);t[l.key]=l,e.hasData()||r=this._source.maxzoom){const e=l.children(this._source.maxzoom)[0],n=this.getTile(e);if(n&&n.hasData()){t[e.key]=e;continue}}else{const e=l.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let i=l.overscaledZ-1;i>=o;--i){const o=l.scaledTo(i);if(n[o.key])break;if(n[o.key]=!0,e=this.getTile(o),!e&&r&&(e=this._addTile(o)),e&&(t[o.key]=o,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let n,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){n=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(n=this._getLoadedTile(e),n)break;r=e}for(const e of t)this._loadedParentTiles[e]=n}}_addTile(t){let n=this._tiles[t.key];if(n)return!0!==n.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),n;n=this._cache.getAndRemove(t),n&&(this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,n)));const r=Boolean(n);if(!r){const e=this.map?this.map.painter:null,r=this._source.tileSize*t.overscaleFactor();n="raster-array"===this._source.type?new Ht(t,r,this.transform.tileZoom,e,this._isRaster):new Nt(t,r,this.transform.tileZoom,e,this._isRaster),this._loadTile(n,this._tileLoaded.bind(this,n,t.key,n.state))}return n?(n.uses++,this._tiles[t.key]=n,r||this._source.fire(new e.b("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const n=t.getExpiryTimeout();n&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),n))}_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||"empty"===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(t,n,r){const i=[],o=this.transform;if(!o)return i;const a="globe"===o.projection.name,s=e.a8(o.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(r&&c.clearQueryDebugViz(),c.holdingForFade())continue;let u;if(a){const t=c.tileID.canonical;if(0===t.z){const n=[Math.abs(e.ad(s,...Kt(t,-1))-s),Math.abs(e.ad(s,...Kt(t,1))-s)];u=[0,2*n.indexOf(Math.min(...n))-1]}else{const n=[Math.abs(e.ad(s,...Kt(t,-1))-s),Math.abs(e.ad(s,...Kt(t,0))-s),Math.abs(e.ad(s,...Kt(t,1))-s)];u=[n.indexOf(Math.min(...n))-1]}}else u=[0];for(const e of u){const r=t.containsTile(c,o,n,e);r&&i.push(r)}}return i}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const n=this.getRenderableIds(e,t).map((e=>this._tiles[e].tileID)),r="globe"===this.transform.projection.name;for(const i of n)i.projMatrix=this.transform.calculateProjMatrix(i.toUnwrapped()),i.expandedProjMatrix=r?this.transform.calculateProjMatrix(i.toUnwrapped(),!1,!0):i.projMatrix;return n}sortCoordinatesByDistance(e){const t=e.slice(),n=this.transform._camera.position,r=this.transform._camera.forward(),i={};for(const o of t){const e=1/(1<i[e.key]-i[t.key])),t}hasTransition(){if(this._source.hasTransition())return!0;if(Xt(this._source.type))for(const t in this._tiles){const n=this._tiles[t];if(void 0!==n.fadeEndTime&&n.fadeEndTime>=e.f.now())return!0}return!1}setFeatureState(e,t,n){this._state.updateState(e=e||"_geojsonTileLayer",t,n)}removeFeatureState(e,t,n){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,n)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,n){const r=this._tiles[e];r&&r.setDependencies(t,n)}reloadTilesForDependencies(e,t){for(const n in this._tiles)this._tiles[n].hasDependency(e,t)&&this._reloadTile(+n,"reloading");this._cache.filter((n=>!n.hasDependency(e,t)))}_preloadTiles(t,n){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,n))};return void this._source.on("data",e)}const r=new Map,i=Array.isArray(t)?t:[t],o=this.map.painter.terrain,a=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const e of i){const t=e.coveringTiles({tileSize:a,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)}const s=Array.from(r.values());e.b4(s,((e,t)=>{const n=new Nt(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(n,(e=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),t(e,n)}))}),n)}}function Qt(e,t){const n=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-n||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Xt(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function Kt(e,t){const n=1<0:"model"===n.type&&(r=!n.isHidden(e)&&n.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!r&&t.visible,t.visible=r}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const r of this.layers){const e=r.layer,n=this.style.getLayerSourceCache(e);let i=1;"fill-extrusion"===e.type&&(i=r.visible?e.paint.get("fill-extrusion-vertical-scale"):0);let o=n?n.getTile(t):null;if(!o&&n&&t.canonical.z>n.getSource().minzoom){let e=t.scaledTo(Math.min(n.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=n.getSource().minzoom&&(o=n.getTile(e),!o&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:o?o.getBucket(e):null,tileID:o?o.tileID:t,verticalScale:i})}e.hasAnyZOffset=!1;let n=!1;for(let r=0;r{e in n&&(r[e]=n[e])})),r}function en(e){e=e.slice();const t=Object.create(null);for(let n=0;n0?(i-a)/s:0;return this.points[o].mult(1-l).add(this.points[n].mult(l))}}class hn{constructor(e,t,n){const r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);for(let o=0;othis.width||r<0||t>this.height)return!i&&[];const a=[];if(e<=0&&t<=0&&this.width<=n&&this.height<=r){if(i)return!0;for(let e=0;e0:a}_queryCircle(e,t,n,r,i){const o=e-n,a=e+n,s=t-n,l=t+n;if(a<0||o>this.width||l<0||s>this.height)return!r&&[];const c=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:n},seenUids:{box:{},circle:{}}},i),r?c.length>0:c}query(e,t,n,r,i){return this._query(e,t,n,r,!1,i)}hitTest(e,t,n,r,i){return this._query(e,t,n,r,!0,i)}hitTestCircle(e,t,n,r){return this._queryCircle(e,t,n,!0,r)}_queryCell(e,t,n,r,i,o,a,s){const l=a.seenUids,c=this.boxCells[i];if(null!==c){const i=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=i[c+2]&&t<=i[c+3]&&n>=i[c+0]&&r>=i[c+1]&&(!s||s(this.boxKeys[u]))){if(a.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:i[c],y1:i[c+1],x2:i[c+2],y2:i[c+3]})}}}const u=this.circleCells[i];if(null!==u){const i=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(i[u],i[u+1],i[u+2],e,t,n,r)&&(!s||s(this.circleKeys[c]))){if(a.hitTest)return o.push(!0),!0;{const e=i[u],t=i[u+1],n=i[u+2];o.push({key:this.circleKeys[c],x1:e-n,y1:t-n,x2:e+n,y2:t+n})}}}}}_queryCellCircle(e,t,n,r,i,o,a,s){const l=a.circle,c=a.seenUids,u=this.boxCells[i];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const n=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[n+0],e[n+1],e[n+2],e[n+3])&&(!s||s(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[i];if(null!==h){const e=this.circles;for(const t of h)if(!c.circle[t]){c.circle[t]=!0;const n=3*t;if(this._circlesCollide(e[n],e[n+1],e[n+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,n,r,i,o,a,s){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(n),h=this._convertToYCellCoord(r);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(i.call(this,e,t,n,r,this.xCellCount*l+d,o,a,s))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,n,r,i,o){const a=r-e,s=i-t,l=n+o;return l*l>a*a+s*s}_circleAndRectCollide(e,t,n,r,i,o,a){const s=(o-r)/2,l=Math.abs(e-(r+s));if(l>s+n)return!1;const c=(a-i)/2,u=Math.abs(t-(i+c));if(u>c+n)return!1;if(l<=s||u<=c)return!0;const h=l-s,d=u-c;return h*h+d*d<=n*n}}const dn={unknown:0,flipRequired:1,flipNotRequired:2},fn=Math.tan(85*Math.PI/180);function pn(t,n,r,i,o,a,s){const l=e.a9.create();if(r)if("globe"===a.name){const t=e.b6(o,n);e.a9.multiply(l,l,t)}else{const t=e.b7.invert([],s);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],i||e.a9.rotateZ(l,l,o.angle)}else e.a9.multiply(l,o.labelPlaneMatrix,t);return l}function mn(e,t,n,r,i,o,a){const s=pn(e,t,n,r,i,o,a);return"globe"===o.name&&n||(s[2]=s[6]=s[10]=s[14]=0),s}function gn(t,n,r,i,o,a,s){if(r){if("globe"===a.name){const l=pn(t,n,r,i,o,a,s);return e.a9.invert(l,l),e.a9.multiply(l,t,l),l}{const n=e.a9.clone(t),r=e.a9.identity([]);return r[0]=s[0],r[1]=s[1],r[4]=s[2],r[5]=s[3],e.a9.multiply(n,n,r),i||e.a9.rotateZ(n,n,-o.angle),n}}return o.glCoordMatrix}function _n(t,n,r,i){const o=[t,n,r,1];r?e.aa.transformMat4(o,o,i):Cn(o,o,i);const a=o[3];return o[0]/=a,o[1]/=a,o[2]/=a,o}function yn(e,t){return Math.min(.5+e/t*.5,1.5)}function vn(e,t){const n=e[0]/e[3],r=e[1]/e[3];return n>=-t[0]&&n<=t[0]&&r>=-t[1]&&r<=t[1]}function xn(t,n,r,i,o,a,s,l,c,u){const h=r.transform,d=i?t.textSizeData:t.iconSizeData,f=e.b8(d,r.transform.zoom),p="globe"===h.projection.name,m=[256/r.width*2+1,256/r.height*2+1],g=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();let _=null;p&&(_=i?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=r.transform.width/r.transform.height;let b,w=!1;for(let S=0;SMath.abs(r)?{useVertical:!0}:t===e.b9.vertical?i>0?{needsFlipping:!0}:null:n!==dn.unknown&&function(e,t){return 0===e||Math.abs(t/e)>fn}(r,i)?n===dn.flipRequired?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function Sn(t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y,v){const x=n/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x,{lineStartIndex:S,glyphStartIndex:M,numGlyphs:A,segment:E,writingMode:T,flipState:C}=t,k=S+t.lineLength,I=t=>{if(h){const[n,r,i]=t.up,o=u.length;e.bb(h,o+0,n,r,i),e.bb(h,o+1,n,r,i),e.bb(h,o+2,n,r,i),e.bb(h,o+3,n,r,i)}const[n,r,i]=t.point;e.bc(u,n,r,i,t.angle)};if(A>1){const e=bn(x,l,b,w,r,d,f,t,c,a,p,g,!1,_,y,v);if(!e)return{notEnoughRoom:!0};if(i&&!r){let[n,r,i]=e.first.point,[o,a,l]=e.last.point;[n,r]=_n(n,r,i,s),[o,a]=_n(o,a,l,s);const c=wn(T,C,(o-n)*m,a-r);if(t.flipState=c&&c.needsFlipping?dn.flipRequired:dn.flipNotRequired,c)return c}I(e.first);for(let t=M+1;t0?a:An(f,i,n,1,o,void 0,_,y.canonical),l=wn(T,C,(s[0]-n[0])*m,s[1]-n[1]);if(t.flipState=l&&l.needsFlipping?dn.flipRequired:dn.flipNotRequired,l)return l}const n=En(x*l.getoffsetX(M),b,w,r,d,f,E,S,k,c,a,p,g,!1,!1,_,y,v);if(!n)return{notEnoughRoom:!0};I(n)}return{}}function Mn(e,t,n,r,i){const{x:o,y:a,z:s}=r.projectTilePoint(e.x,e.y,t);if(!i)return _n(o,a,s,n);const[l,c,u]=i(e);return _n(o+l,a+c,s+u,n)}function An(t,n,r,i,o,a,s,l){const c=Mn(t.sub(n)._unit()._add(t),l,o,s,a);return e.Q.sub(c,r,c),e.Q.normalize(c,c),e.Q.scaleAndAdd(c,r,c,i)}function En(t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y){const v=i?t-n:t+n;let x=v>0?1:-1,b=0;i&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=l+s+(x>0?0:1)|0,S=o,M=o,A=0,E=0;const T=Math.abs(v),C=[],k=[];let I=a,P=I;const R=()=>An(P,I,M,T-A+1,h,f,g,_.canonical);for(;A+E<=T;){if(w+=x,w=c)return null;if(M=S,P=I,C.push(M),p&&k.push(P),I=new e.P(u.getx(w),u.gety(w)),S=d[w],!S){const e=Mn(I,_.canonical,h,g,f);S=e[3]>0?d[w]=e:R()}A+=E,E=e.Q.distance(M,S)}m&&f&&(d[w]&&(S=R(),E=e.Q.distance(M,S)),d[w]=S);const L=(T-A)/E,z=I.sub(P)._mult(L)._add(P),O=e.Q.sub([],S,M),D=e.Q.scaleAndAdd([],M,O,L);let B=[0,0,1],F=O[0],N=O[1];if(y&&(B=g.upVector(_.canonical,z.x,z.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[B[2],0,-B[0]],n=e.Q.cross([],B,t);e.Q.normalize(t,t),e.Q.normalize(n,n),F=e.Q.dot(O,t),N=e.Q.dot(O,n)}if(r){const t=e.Q.cross([],B,O);e.Q.normalize(t,t),e.Q.scaleAndAdd(D,D,t,r*x)}const j=b+Math.atan2(N,F);return C.push(D),p&&k.push(z),{point:D,angle:j,path:C,tilePath:k,up:B}}function Tn(e,t){const n=t.length,r=n+4*e;t.resize(r),t.float32.fill(-1/0,4*n,4*r)}function Cn(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e[3]=n[3]*r+n[7]*i+n[15],e}const kn=100;class In{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new hn(e.width+200,e.height+200,25),r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new hn(e.width+200,e.height+200,25);this.transform=e,this.grid=n,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+kn,this.screenBottomBoundary=e.height+kn,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,n,r,i,o,a,s){let l=n.projectedAnchorX,c=n.projectedAnchorY,u=n.projectedAnchorZ;const h=n.elevation,d=n.tileID,f=e.getProjection();if(h&&d){const[e,t,r]=f.upVector(d.canonical,n.tileAnchorX,n.tileAnchorY),i=f.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*h*i,c+=t*h*i,u+=r*h*i}const p=this.projectAndGetPerspectiveRatio(a,l,c,u,n.tileID,"globe"===f.name||!!h||this.transform.pitch>0,f),m=o*p.perspectiveRatio,g=(n.x1*t+r.x-n.padding)*m+p.point.x,_=(n.y1*t+r.y-n.padding)*m+p.point.y,y=(n.x2*t+r.x+n.padding)*m+p.point.x,v=(n.y2*t+r.y+n.padding)*m+p.point.y,x=p.perspectiveRatio<=.55||p.occluded;return!this.isInsideGrid(g,_,y,v)||!i&&this.grid.hitTest(g,_,y,v,s)||x?{box:[],offscreen:!1,occluded:p.occluded}:{box:[g,_,y,v],offscreen:this.isOffscreen(g,_,y,v),occluded:!1}}placeCollisionCircles(t,n,r,i,o,a,s,l,c,u,h,d,f,p,m){const g=[],_=this.transform.elevation,y=t.getProjection(),v=_?_.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,x=new e.P(r.tileAnchorX,r.tileAnchorY);let{x:b,y:w,z:S}=y.projectTilePoint(x.x,x.y,m.canonical);if(v){const[e,t,n]=v(x);b+=e,w+=t,S+=n}const M="globe"===y.name,A=this.projectAndGetPerspectiveRatio(s,b,w,S,m,M||!!_||this.transform.pitch>0,y),{perspectiveRatio:E}=A,T=(h?a/E:a*E)/e.bf,C=_n(b,w,S,l),k=A.signedDistanceFromCamera>0?bn(T,o,r.lineOffsetX*T,r.lineOffsetY*T,!1,C,x,r,i,l,{},_&&!h?v:null,h&&!!_,y,m,h):null;let I=!1,P=!1,R=!0;if(k&&!A.occluded){const t=.5*f*E+p,r=new e.P(-100,-100),i=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new un,{first:a,last:s}=k,l=a.path.length;let h=[];for(let e=l-1;e>=1;e--)h.push(a.path[e]);for(let e=1;e{let[n,r,i]=e;return v&&!M&&(i=v(te[3]<=0))&&(h=[]));let _=[];if(h.length>0){let t=1/0,n=-1/0,o=1/0,a=-1/0;for(const e of h)t=Math.min(t,e[0]),o=Math.min(o,e[1]),n=Math.max(n,e[0]),a=Math.max(a,e[1]);n>=r.x&&t<=i.x&&a>=r.y&&o<=i.y&&(_=[h.map((t=>new e.P(t[0],t[1])))],(ti.x||oi.y)&&(_=e.bd(_,r.x,r.y,i.x,i.y)))}for(const e of _){o.reset(e,.25*t);let r=0;r=o.length<=.5*t?1:Math.ceil(o.paddedLength/m)+1;for(let e=0;e0){if(e.aa.transformMat4(l,l,t),this.fogState&&o&&"globe"!==s.name){const t=function(t,n,r,i,o,a){const s=a.calculateFogTileMatrix(o),l=[n,r,i];return e.Q.transformMat4(l,l,s),pe(t,e.Q.length(l),a.pitch,a._fov)}(this.fogState,n,r,i,o.toUnwrapped(),this.transform);c=t>.9}}else Cn(l,l,t);const u=l[3];return{point:new e.P((l[0]/u+1)/2*this.transform.width+kn,(-l[1]/u+1)/2*this.transform.height+kn),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/u*.5,1.5),signedDistanceFromCamera:u,occluded:a&&l[2]>u||c}}isOffscreen(e,t,n,r){return n=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,n,r){return n>=0&&e=0&&t5&&void 0!==arguments[5]&&arguments[5];this.text=new zn(e?e.text:null,t,n,i),this.icon=new zn(e?e.icon:null,t,r,i),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Dn{constructor(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.text=e,this.icon=t,this.skipFade=n,this.clipped=r}}class Bn{constructor(){this.invProjMatrix=e.a9.create(),this.viewportMatrix=e.a9.create(),this.circles=[]}}class Fn{constructor(e,t,n,r,i){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=n,this.bucketIndex=r,this.tileID=i}}class Nn{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 jn(t,n,r,i,o){const{horizontalAlign:a,verticalAlign:s}=e.bi(t),l=-(a-.5)*n,c=-(s-.5)*r,u=e.bh(t,i);return new e.P(l+u[0]*o,c+u[1]*o)}function Vn(t,n,r,i,o){const a=new e.P(t,n);return r&&a._rotate(i?o:-o),a}class Un{constructor(e,t,n,r,i,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new In(this.transform,i),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Nn(n),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,r,i){const o=r.getBucket(n),a=r.latestFeatureIndex;if(!o||!a||n.fqid!==o.layerIds[0])return;const s=o.layers[0].layout,l=r.collisionBoxArray,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/e.Y,h=r.tileID.toUnwrapped();this.transform.setProjection(o.projection);const d=(f=r.tileID,p=o.getProjection(),m=this.transform,p.name===this.projection?m.calculateProjMatrix(f.toUnwrapped()):Pn(m,p,f));var f,p,m;const g="map"===s.get("text-pitch-alignment"),_="map"===s.get("text-rotation-alignment");n.compileFilter();const y=n.dynamicFilter(),v=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(r),b=mn(d,r.tileID.canonical,g,_,this.transform,o.getProjection(),x);let w=null;if(g){const t=gn(d,r.tileID.canonical,g,_,this.transform,o.getProjection(),x);w=e.a9.multiply([],this.transform.labelPlaneMatrix,t)}let S=null;y&&r.latestFeatureIndex&&(S={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new Fn(o.bucketInstanceId,a,o.sourceLayerIndex,o.index,r.tileID);const M={bucket:o,layout:s,posMatrix:d,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:S,scale:c,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.b8(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.b8(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(i)for(const e of o.sortKeyRanges){const{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=e;t.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:M})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:M})}attemptAnchorPlacement(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_){const{textOffset0:y,textOffset1:v,crossTileID:x}=h,b=[y,v],w=jn(e,n,r,b,i),S=this.collisionIndex.placeCollisionBox(f,i,t,Vn(w.x,w.y,o,a,this.transform.angle),u,s,l,c.predicate);if(m){const e=f.getSymbolInstanceIconSize(_,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(f,e,m,Vn(w.x,w.y,o,a,this.transform.angle),u,s,l,c.predicate).box.length)return}if(S.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[x]&&this.prevPlacement.placements[x]&&this.prevPlacement.placements[x].text&&(t=this.prevPlacement.variableOffsets[x].anchor),this.variableOffsets[x]={textOffset:b,width:n,height:r,anchor:e,textScale:i,prevAnchor:t},this.markUsedJustification(f,e,h,p),f.allowVerticalPlacement&&(this.markUsedOrientation(f,p,h),this.placedOrientations[x]=p),{shift:w,placedGlyphBoxes:S}}}placeLayerBucketPart(t,n,r,i){const{bucket:o,layout:a,posMatrix:s,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:d,collisionBoxArray:f,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:m,collisionGroup:g}=t.parameters,_=a.get("text-optional"),y=a.get("icon-optional"),v=a.get("text-allow-overlap"),x=a.get("icon-allow-overlap"),b="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),S="viewport-y"===a.get("symbol-z-order"),M=a.get("symbol-z-elevate");this.transform.setProjection(o.projection);let A=v&&(x||!o.hasIconData()||y),E=x&&(v||!o.hasTextData()||_);!o.collisionArrays&&f&&o.deserializeCollisionBoxes(f),r&&i&&o.updateCollisionDebugBuffers(this.transform.zoom,f);const T=(t,i,f)=>{const{crossTileID:S,numVerticalGlyphVertices:M}=t;if(u){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let i=null;if(u.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];i=u.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(r,i,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[S]=new Dn(!1,!1,!1,!0),void n.add(S)}if(n.has(S))return;if(d)return void(this.placements[S]=new Dn(!1,!1,!1));let T=!1,C=!1,k=!0,I=!1,P=!1,R=null,L={box:null,offscreen:null,occluded:null},z={box:null,offscreen:null,occluded:null},O=null,D=null,B=null,F=0,N=0,j=0;f.textFeatureIndex?F=f.textFeatureIndex:t.useRuntimeCollisionCircles&&(F=t.featureIndex),f.verticalTextFeatureIndex&&(N=f.verticalTextFeatureIndex);const V=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const n=this.transform.elevation;e.elevation=t.zOffset+(n?n.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0)},U=f.textBox;if(U){V(U);const n=n=>{let r=e.b9.horizontal;if(o.allowVerticalPlacement&&!n&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[S];e&&(this.placedOrientations[S]=e,r=e,this.markUsedOrientation(o,r,t))}return r},r=(t,n)=>{if(o.allowVerticalPlacement&&M>0&&f.verticalTextBox){for(const r of o.writingModes)if(r===e.b9.vertical?(L=n(),z=L):L=t(),L&&L.box&&L.box.length)break}else L=t()};if(a.get("text-variable-anchor")){let l=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[S]){const e=this.prevPlacement.variableOffsets[S];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor))}const c=(e,n,r)=>{const a=o.getSymbolInstanceTextSize(p,t,this.transform.zoom,i),c=(e.x2-e.x1)*a+2*e.padding,u=(e.y2-e.y1)*a+2*e.padding,d=t.hasIconTextFit&&!x?n:null;d&&V(d);let f={box:[],offscreen:!1,occluded:!1};const _=v?2*l.length:l.length;for(let y=0;y<_;++y){const n=this.attemptAnchorPlacement(l[y%l.length],e,c,u,a,b,w,h,s,g,y>=l.length,t,i,o,r,d,p,m);if(n&&(f=n.placedGlyphBoxes,f&&f.box&&f.box.length)){T=!0,R=n.shift;break}}return f};r((()=>c(U,f.iconBox,e.b9.horizontal)),(()=>{const t=f.verticalTextBox;return t&&V(t),o.allowVerticalPlacement&&!(L&&L.box&&L.box.length)&&M>0&&t?c(t,f.verticalIconBox,e.b9.vertical):{box:null,offscreen:null,occluded:null}})),L&&(T=L.box,k=L.offscreen,I=L.occluded);const u=n(!(!L||!L.box));if(!T&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[S];e&&(this.variableOffsets[S]=e,this.markUsedJustification(o,e.anchor,t,u))}}else{const a=(n,r)=>{const a=o.getSymbolInstanceTextSize(p,t,this.transform.zoom,i),l=this.collisionIndex.placeCollisionBox(o,a,n,new e.P(0,0),v,h,s,g.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,r,t),this.placedOrientations[S]=r),l};r((()=>a(U,e.b9.horizontal)),(()=>{const t=f.verticalTextBox;return o.allowVerticalPlacement&&M>0&&t?(V(t),a(t,e.b9.vertical)):{box:null,offscreen:null,occluded:null}})),n(!!(L&&L.box&&L.box.length))}}if(O=L,T=O&&O.box&&O.box.length>0,k=O&&O.offscreen,I=O&&O.occluded,t.useRuntimeCollisionCircles){const n=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),i=e.ba(o.textSizeData,p,n),u=a.get("text-padding");D=this.collisionIndex.placeCollisionCircles(o,v,n,o.lineVertexArray,o.glyphOffsetArray,i,s,l,c,r,w,g.predicate,t.collisionCircleDiameter*i/e.bf,u,this.retainedQueryData[o.bucketInstanceId].tileID),T=v||D.circles.length>0&&!D.collisionDetected,k=k&&D.offscreen,I=D.occluded}if(f.iconFeatureIndex&&(j=f.iconFeatureIndex),f.iconBox){const n=n=>{V(n);const r=t.hasIconTextFit&&R?Vn(R.x,R.y,b,w,this.transform.angle):new e.P(0,0),i=o.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,i,n,r,x,h,s,g.predicate)};z&&z.box&&z.box.length&&f.verticalIconBox?(B=n(f.verticalIconBox),C=B.box.length>0):(B=n(f.iconBox),C=B.box.length>0),k=k&&B.offscreen,P=B.occluded}const G=_||0===t.numHorizontalGlyphVertices&&0===M,q=y||0===t.numIconVertices;if(G||q?q?G||(C=C&&T):T=C&&T:C=T=C&&T,T&&O&&O.box&&this.collisionIndex.insertCollisionBox(O.box,a.get("text-ignore-placement"),o.bucketInstanceId,z&&z.box&&N?N:F,g.ID),C&&B&&this.collisionIndex.insertCollisionBox(B.box,a.get("icon-ignore-placement"),o.bucketInstanceId,j,g.ID),D&&(T&&this.collisionIndex.insertCollisionCircles(D.circles,a.get("text-ignore-placement"),o.bucketInstanceId,F,g.ID),r)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new Bn);for(let n=0;n=0;--e){const n=t[e];T(o.symbolInstances.get(n),n,o.collisionArrays[n])}o.hasAnyZOffset&&e.w("".concat(o.layerIds[0]," layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y"))}else if(o.hasAnyZOffset){const e=o.getSortedIndexesByZOffset();for(let t=0;t=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(t,n,r){const i=n===e.b9.horizontal||n===e.b9.horizontalOnly?n:0,o=n===e.b9.vertical?n:0,{leftJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=r,u=t.text.placedSymbolArray;a>=0&&(u.get(a).placedOrientation=i),s>=0&&(u.get(s).placedOrientation=i),l>=0&&(u.get(l).placedOrientation=i),c>=0&&(u.get(c).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let n=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,i=t?t.opacities:{},o=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const s in this.placements){const e=this.placements[s],t=i[s];t?(this.opacities[s]=new On(t,r,e.text,e.icon,null,e.clipped),n=n||e.text!==t.text.placed||e.icon!==t.icon.placed):(this.opacities[s]=new On(null,r,e.text,e.icon,e.skipFade,e.clipped),n=n||e.text||e.icon)}for(const s in i){const e=i[s];if(!this.opacities[s]){const t=new On(e,r,!1,!1);t.isHidden()||(this.opacities[s]=t,n=n||e.text.placed||e.icon.placed)}}for(const s in o)this.variableOffsets[s]||!this.opacities[s]||this.opacities[s].isHidden()||(this.variableOffsets[s]=o[s]);for(const s in a)this.placedOrientations[s]||!this.opacities[s]||this.opacities[s].isHidden()||(this.placedOrientations[s]=a[s]);n?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const n=new Set;for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,n,r.collisionBoxArray),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,r.tileID),t.updateZOffset()))}}updateBucketOpacities(t,n,r){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 i=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),a=new On(null,0,!1,!1,!0),s=i.get("text-allow-overlap"),l=i.get("icon-allow-overlap"),c=i.get("text-variable-anchor"),u="map"===i.get("text-rotation-alignment"),h="map"===i.get("text-pitch-alignment"),d=new On(null,0,s&&(l||!t.hasIconData()||i.get("icon-optional")),l&&(s||!t.hasTextData()||i.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const f=(e,t,n)=>{for(let r=0;r0||s>0,x=g>0,b=this.placedOrientations[l],w=b===e.b9.vertical,S=b===e.b9.horizontal||b===e.b9.horizontalOnly;if(!v&&!x||y.isHidden()||p++,v){const e=Kn(y.text);f(t.text,i,w?Jn:e),f(t.text,s,S?Jn:e);const n=y.text.isHidden(),{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:c,verticalPlacedTextSymbolIndex:u}=r,h=t.text.placedSymbolArray,d=n||w?1:0;o>=0&&(h.get(o).hidden=d),a>=0&&(h.get(a).hidden=d),c>=0&&(h.get(c).hidden=d),u>=0&&(h.get(u).hidden=n||S?1:0);const p=this.variableOffsets[l];p&&this.markUsedJustification(t,p.anchor,r,b);const m=this.placedOrientations[l];m&&(this.markUsedJustification(t,"left",r,m),this.markUsedOrientation(t,m,r))}if(x){const e=Kn(y.icon),{placedIconSymbolIndex:n,verticalPlacedIconSymbolIndex:i}=r,o=t.icon.placedSymbolArray,a=y.icon.isHidden()?1:0;n>=0&&(f(t.icon,g,w?Jn:e),o.get(n).hidden=a),i>=0&&(f(t.icon,r.numVerticalIconVertices,S?Jn:e),o.get(i).hidden=a)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const n=t.collisionArrays[m];if(n){let i=new e.P(0,0),a=!0;if(n.textBox||n.verticalTextBox){if(c){const e=this.variableOffsets[l];e?(i=jn(e.anchor,e.width,e.height,e.textOffset,e.textScale),u&&i._rotate(h?this.transform.angle:-this.transform.angle)):a=!1}o&&(a=!y.clipped),n.textBox&&Gn(t.textCollisionBox.collisionVertexArray,y.text.placed,!a||w,i.x,i.y),n.verticalTextBox&&Gn(t.textCollisionBox.collisionVertexArray,y.text.placed,!a||S,i.x,i.y)}const s=a&&Boolean(!S&&n.verticalIconBox);n.iconBox&&Gn(t.iconCollisionBox.collisionVertexArray,y.icon.placed,s,r.hasIconTextFit?i.x:0,r.hasIconTextFit?i.y:0),n.verticalIconBox&&Gn(t.iconCollisionBox.collisionVertexArray,y.icon.placed,!s,r.hasIconTextFit?i.x:0,r.hasIconTextFit?i.y:0)}}}if(t.fullyClipped=0===p,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.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Gn(e,t,n,r,i){e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0)}const qn=Math.pow(2,25),Wn=Math.pow(2,24),Hn=Math.pow(2,17),Zn=Math.pow(2,16),Yn=Math.pow(2,9),Qn=Math.pow(2,8),Xn=Math.pow(2,1);function Kn(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,n=Math.floor(127*e.opacity);return n*qn+t*Wn+n*Hn+t*Zn+n*Yn+t*Qn+n*Xn+t}const Jn=0;class $n{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=new Set,this._bucketParts=[]}continuePlacement(e,t,n,r,i){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex{const t=e.f.now()-o;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const o=n[t[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if("symbol"===o.type&&(!o.minzoom||o.minzoom<=s)&&(!o.maxzoom||o.maxzoom>s)){const t=o,n=t.layout.get("symbol-z-elevate"),s=this._inProgressLayer=this._inProgressLayer||new $n(t),l=e.aj(o.source,o.scope);if(s.continuePlacement(n?i[l]:r[l],this.placement,this._showCollisionBoxes,o,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const tr=512/e.Y/2;class nr{constructor(t,n,r){this.tileID=t,this.bucketInstanceId=r,this.index=new e.bj(n.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const i=t.canonical.x*e.Y,o=t.canonical.y*e.Y;for(let e=0;ee.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let i=0;i{t[e]=!0}));for(const n in this.layerIndexes)t[n]||delete this.layerIndexes[n]}}class ar{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=n,this.right=r}interpolate(t,n,r){return null!=n.top&&null!=t.top&&(this.top=e.X(t.top,n.top,r)),null!=n.bottom&&null!=t.bottom&&(this.bottom=e.X(t.bottom,n.bottom,r)),null!=n.left&&null!=t.left&&(this.left=e.X(t.left,n.left,r)),null!=n.right&&null!=t.right&&(this.right=e.X(t.right,n.right,r)),this}getCenter(t,n){const r=e.ad((this.left+t-this.right)/2,0,t),i=e.ad((this.top+n-this.bottom)/2,0,n);return new e.P(r,i)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new ar(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function sr(t,n){const r=e.bn(t,3);e.a9.fromQuat(t,n),e.bp(t,3,r)}function lr(t,n){const r=e.bl.identity([]);return e.bl.rotateZ(r,r,-n),e.bl.rotateX(r,r,-t),r}function cr(t,n){const r=[t[0],t[1],0],i=[n[0],n[1],0];if(e.Q.length(r)>=1e-15){const t=e.Q.normalize([],r);e.Q.scale(i,t,e.Q.dot(i,t)),n[0]=i[0],n[1]=i[1]}const o=e.Q.cross([],n,t);if(e.Q.len(o)<1e-15)return null;const a=Math.atan2(-o[1],o[0]);return lr(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),a)}class ur{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const n=t instanceof e.O?t:new e.O(t[0],t[1],t[2]);this._renderWorldCopies&&(n.x=e.bk(n.x,0,1)),this._position=n}else this._position=null}lookAtPoint(t,n){if(this.orientation=null,!this.position)return;const r=this.position,i=this._elevation?this._elevation.getAtPointOrZero(e.O.fromLngLat(t)):0,o=e.O.fromLngLat(t,i),a=[o.x-r.x,o.y-r.y,o.z-r.z];n||(n=[0,0,1]),n[2]=Math.abs(n[2]),this.orientation=cr(a,n)}setPitchBearing(t,n){this.orientation=lr(e.bm(t),e.bm(-n))}}class hr{constructor(t,n){this._transform=e.a9.identity([]),this.orientation=n,this.position=t}get mercatorPosition(){const t=this.position;return new e.O(t[0],t[1],t[2])}get position(){const t=e.bn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var n;t&&e.bp(this._transform,3,[(n=t)[0],n[1],n[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.bl.identity([]),t&&sr(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=lr(e,t),sr(this._transform,this._orientation)}forward(){const t=e.bn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.bn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.bn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,n){const r=new Float64Array(16);return e.a9.invert(r,this.getWorldToCamera(t,n)),r}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,n,r){const i=this.position;e.Q.scale(i,i,-t);const o=new Float64Array(16);return e.a9.fromScaling(o,[r,r,r]),e.a9.translate(o,o,i),o[10]*=n,o}getWorldToCamera(t,n){const r=new Float64Array(16),i=new Float64Array(4),o=this.position;return e.bl.conjugate(i,this._orientation),e.Q.scale(o,o,-t),e.a9.fromQuat(r,i),e.a9.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=n,r[9]*=n,r[10]*=n,r[11]*=n,r}getCameraToClipPerspective(t,n,r,i){const o=new Float64Array(16);return e.a9.perspective(o,t,n,r,i),o}getCameraToClipOrthographic(t,n,r,i,o,a){const s=new Float64Array(16);return e.a9.ortho(s,t,n,r,i,o,a),s}getDistanceToElevation(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=0===t?0:e.bo(t,n?e.ax(this.position[1]):this.position[1]),i=this.forward();return(r-this.position[2])/i[2]}clone(){return new hr([...this.position],[...this.orientation])}}const dr=(e,t,n)=>(1-n)*e+n*t,fr=e=>e*e*e*e*e;class pr{constructor(t,n,r,i,o,a,s){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=null==r?0:r,this._maxPitch=null==i?60:i,this.setProjection(a),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new e.bq(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 ar,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new hr,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1}clone(){const e=new pr(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.mercatorFromTransition=this.mercatorFromTransition,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._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,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 isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||n)&&this._updateCameraOnTerrain(),(e||n)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return e.af(this.projection,["name","center","parallels"])}setProjection(n){this.projectionOptions=n||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=e.br(this.projectionOptions);const i=!t(r,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.br({name:"mercator"});const n=t!==this.projection.name;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 cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.bo(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.bk(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const n=-t*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=e.b7.create(),e.b7.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=e.ad(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.bm(t),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}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e)}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const n=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&n.exaggeration()&&this._centerAltitudeValidForExaggeration!==n.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*n.exaggeration(),this._centerAltitudeValidForExaggeration=n.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=n.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,n=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let i=0,o=0;for(let a=0;a0,u=t.y+10,d=a.wrap-(c?0:1),f=a.wrap+(l?0:1),p=c?t.x-1:s-1,m=l?t.x+1:0;n[0]<0?(i.push(new e.ap(r,f,t.z,m,t.y)),n[1]<0&&u&&(i.push(new e.ap(r,o,t.z,t.x,t.y+1)),i.push(new e.ap(r,f,t.z,m,t.y+1))),n[1]>0&&h&&(i.push(new e.ap(r,o,t.z,t.x,t.y-1)),i.push(new e.ap(r,f,t.z,m,t.y-1)))):n[0]>0?(i.push(new e.ap(r,d,t.z,p,t.y)),n[1]<0&&u&&(i.push(new e.ap(r,o,t.z,t.x,t.y+1)),i.push(new e.ap(r,d,t.z,p,t.y+1))),n[1]>0&&h&&(i.push(new e.ap(r,o,t.z,t.x,t.y-1)),i.push(new e.ap(r,d,t.z,p,t.y-1)))):n[1]<0&&u?i.push(new e.ap(r,o,t.z,t.x,t.y+1)):h&&i.push(new e.ap(r,o,t.z,t.x,t.y-1))}if(i.length>1){i.sort(((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y));let e=0,t=0;for(;te.isChildOf(t)))||o.push(e);return i=o.filter((e=>!t.some((t=>!!(e.overscaledZt.maxzoom&&(n=t.maxzoom);const s=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const n=1/4e4,r=new e.O(t.x+n,t.y,t.z),i=new e.O(t.x,t.y+n,t.z),o=t.toLngLat(),a=r.toLngLat(),s=i.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(a),u=this.locationCoordinate(s),h=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*d)*S/n},A=t=>{const n=b,r=w;return{aabb:e.bx(this,c,0,0,0,t,r,n,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:n,wrap:t,fullyVisible:!1}},E=[];let T=[];const C=n,k=t.reparseOverscaled?r:n,I=e=>e*e,P=I((g-this._centerAltitude)*m),R=e=>{if(!this._elevation||!e.tileID||!a)return;const t=this._elevation.getMinMaxForTile(e.tileID),n=e.aabb;t?(n.min[2]=t.min,n.max[2]=t.max,n.center[2]=(n.min[2]+n.max[2])/2):(e.shouldSplit=L(e),e.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},L=t=>{if(t.zoom=.9)return!0}else if(o&&(a=I(t.aabb.distanceZ(_)*m)),this.projection.isReprojectedInTileSpace&&r<=5){const n=Math.pow(2,t.zoom),r=M(new e.O((t.x+.5)/n,(t.y+.5)/n));s=r>.85?1:r}const c=n*n+i*i+a,u=I((1<{if(t*I(.707)0;){const r=E.pop(),i=r.x,s=r.y;let l=r.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===r.y||r.y===(1<>1),d={aabb:a?r.aabb.quadrant(t):e.bx(this,c,r.zoom+1,n,u,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:n,y:u,wrap:r.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};o&&!h&&(d.tileID=new e.ap(r.zoom+1===C?k:r.zoom+1,r.wrap,r.zoom+1,n,u),R(d)),E.push(d)}else{const o=r.zoom===C?k:r.zoom;if(t.minzoom&&t.minzoom>o)continue;if(!l){let t=y?r.aabb.intersectsPrecise(f):r.aabb.intersectsPreciseFlat(f);if(0===t&&d()){const n=new e.bv(r.zoom,i,s);t=e.bw(this,c,n,!0).intersectsPrecise(f)}if(0===t)continue}const a=u[0]-(.5+i+(r.wrap<{const o=[0,0,0,1],a=[e.Y,e.Y,0,1],s=this.calculateFogTileMatrix(i.tileID.toUnwrapped());e.aa.transformMat4(o,o,s),e.aa.transformMat4(a,a,s);const l=e.aa.min([],o,a),c=e.aa.max([],o,a),u=e.by(l,c);if(0===u)return!0;let h=!1;const d=this._elevation;if(d&&u>n&&0!==r){const n=this.calculateProjMatrix(i.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=d.getMinMaxForTile(i.tileID)),o||(o={min:w,max:b});const a=e.bK(this.rotation),s=[a[0]*e.Y,a[1]*e.Y,o.max];e.Q.transformMat4(s,s,n),h=(1-s[1])*this.height*.5e.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 n=e.ad(t.lat,-e.bz,e.bz),r=this.projection.project(t.lng,n);return new e.P(r.x*this.worldSize,r.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.bo(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,n){let r,i;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;r=(n.x-o.x)/e,i=(n.y-o.y)/e}else{const e=this.pointCoordinate(n),t=this.pointCoordinate(o);r=e.x-t.x,i=e.y-t.y}const a=this.locationCoordinate(t);this.setLocation(new e.O(a.x-r,a.y-i))}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,n){const r=n?e.bo(n,t.lat):void 0,i=this.projection.project(t.lng,t.lat);return new e.O(i.x,i.y,r)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,n){const r=null!=n?n:this._centerAltitude,i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.aa.transformMat4(i,i,this.pixelMatrixInverse),e.aa.transformMat4(o,o,this.pixelMatrixInverse);const a=o[3];e.aa.scale(i,i,1/i[3]),e.aa.scale(o,o,1/a);const s=i[2],l=o[2];return{p0:i,p1:o,t:s===l?0:(r-s)/(l-s)}}screenPointToMercatorRay(t){const n=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e.aa.transformMat4(n,n,this.pixelMatrixInverse),e.aa.transformMat4(r,r,this.pixelMatrixInverse),e.aa.scale(n,n,1/n[3]),e.aa.scale(r,r,1/r[3]),n[2]=e.bo(n[2],this._center.lat)*this.worldSize,r[2]=e.bo(r[2],this._center.lat)*this.worldSize,e.aa.scale(n,n,1/this.worldSize),e.aa.scale(r,r,1/this.worldSize),new e.a5([n[0],n[1],n[2]],e.Q.normalize([],e.Q.sub([],r,n)))}rayIntersectionCoordinate(t){const{p0:n,p1:r,t:i}=t,o=e.bo(n[2],this._center.lat),a=e.bo(r[2],this._center.lat);return new e.O(e.X(n[0],r[0],i)/this.worldSize,e.X(n[1],r[1],i)/this.worldSize,e.X(o,a,i))}pointCoordinate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._centerAltitude;return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let n=this.projection.pointCoordinate3D(this,t.x,t.y);if(n)return new e.O(n[0],n[1],n[2]);let r=0,i=this.horizonLineFromTop();if(t.y>i)return this.pointCoordinate(t);const o=.02*i,a=t.clone();for(let s=0;s<10&&i-r>o;s++){a.y=e.X(r,i,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(i=a.y,n=t):r=a.y}return n?new e.O(n[0],n[1],n[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.bA)return!this.isPointAboveHorizon(t);const n=this.pointCoordinate(t);return n.y>=0&&n.y<=1}_coordinatePoint(t,n){const r=n&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,i=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e.aa.transformMat4(i,i,this.pixelMatrix),i[3]>0?new e.P(i[0]/i[3],i[1]/i[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:n}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,i=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(n,t)),a=this.pointLocation3D(new e.P(i,t)),s=this.pointLocation3D(new e.P(i,r)),l=this.pointLocation3D(new e.P(n,r));let c=Math.min(o.lng,a.lng,s.lng,l.lng),u=Math.max(o.lng,a.lng,s.lng,l.lng),h=Math.min(o.lat,a.lat,s.lat,l.lat),d=Math.max(o.lat,a.lat,s.lat,l.lat);const f=Math.pow(2,-this.zoom)/16*270,p="globe"===this.projection.name?1:4,m=(t,n,r,i,o)=>{const a=(t+r)/2,s=(n+i)/2,l=new e.P(a,s),{lng:g,lat:_}=this.pointLocation3D(l),y=Math.max(0,c-g,h-_,g-u,_-d);c=Math.min(c,g),u=Math.max(u,g),h=Math.min(h,_),d=Math.max(d,_),(of)&&(m(t,n,a,s,o+1),m(a,s,r,i,o+1))};if(m(n,t,i,t,1),m(i,t,i,r,1),m(i,r,n,r,1),m(n,r,n,t,1),"globe"===this.projection.name){const[t,n]=e.bB(this);t?(d=90,u=180,c=-180):n&&(h=-90,u=180,c=-180)}return new e.ag(new e.bq(c,h),new e.bq(u,d))}_getBoundsRectangular(t,n){const{top:r,left:i}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,a=this.width-this._edgeInsets.right,s=new e.P(i,r),l=new e.P(a,r),c=new e.P(a,o),u=new e.P(i,o);let h=this.pointCoordinate(s,t),d=this.pointCoordinate(l,t);const f=this.pointCoordinate(c,n),p=this.pointCoordinate(u,n),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.O((1-p.y)/m(p,h)+p.x,1):h.y<0&&d.y<=1&&(h=new e.O(-p.y/m(p,h)+p.x,0)),d.y>1&&h.y>=0?d=new e.O((1-f.y)/m(f,d)+f.x,1):d.y<0&&h.y<=1&&(d=new e.O(-f.y/m(f,d)+f.x,0)),(new e.ag).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(f))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const n=t.dem.tree;e.min=Math.min(e.min,n.minimums[0]),e.max=Math.max(e.max,n.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,n=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,n):n}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.bz,this.maxLat=e.bz,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=t.key;let o;if(o=r?this._expandedProjMatrixCache:n?this._alignedProjMatrixCache:this._projMatrixCache,o[i])return o[i];const a=this.calculatePosMatrix(t,this.worldSize);let s;return s=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:r?this.expandedFarZProjMatrix:n?this.alignedProjMatrix:this.projMatrix,e.a9.multiply(a,s,a),o[i]=new Float32Array(a),o[i]}calculatePixelsToTileUnitsMatrix(t){const n=t.tileID.key,r=this._pixelsToTileUnitsCache;if(r[n])return r[n];const i=e.bC(t,this);return r[n]=i,r[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const t=1/this.worldSize,n=e.a9.fromScaling([],[t,t,t]);return e.a9.multiply(n,n,this.globeMatrix),n}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const t=this._elevation;this._updateCameraState();const n=e.bo(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(n),i=this._camera.forward(),o=e.bo(1,this._center.lat);r[2]/=o,i[2]/=o,e.Q.normalize(i,i);const a=t.raycast(r,i,t.exaggeration());if(a){const t=e.Q.scaleAndAdd([],r,i,a),n=new e.O(t[0],t[1],e.bo(t[2],e.ax(t[1]))),s=(n.z+e.Q.length([n.x-r[0],n.y-r[1],n.z-r[2]*o]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(s),this._centerAltitude=n.toAltitude(),this._center=this.coordinateLocation(n),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this._elevation)return;const n=this._elevation,r=e.bo(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(r),o=n.getAtPointOrZero(new e.O(...i)),a=this.pixelsPerMeter/this.worldSize*o,s=this._minimumHeightOverTerrain(),l=i[2]-a;if(l<=s)if(l<0||t){const t=this.locationCoordinate(this._center,this._centerAltitude),n=[i[0],i[1],t.z-i[2]],r=e.Q.length(n);n[2]-=(s-l)/this._pixelsPerMercatorPixel;const o=e.Q.length(n);if(0===o)return;e.Q.scale(n,n,r/o*this._pixelsPerMercatorPixel),this._camera.position=[i[0],i[1],t.z*this._pixelsPerMercatorPixel-n[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){const n=this.center;return n.lat=e.ad(n.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(n.lng=e.ad(n.lng,this.minLng,this.maxLng)),this.center=n,void(this._constraining=!1)}const n=this._unmodified,{x:r,y:i}=this.point;let o=0,a=r,s=i;const l=this.width/2,c=this.height/2,u=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(i-ch&&(s=h-c),h-ut&&(a=t-l),t-e{for(let i=0;i<16;i++)e[i]=dr(t[i],n[i],r)})(s,s,l,fr(this.pitch>=15?1:this.pitch/15))}else s=l;const c=e.a9.mul([],l,a);let u=e.a9.mul([],s,a);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),n=e.a9.identity([]);e.a9.translate(n,n,[t.x*this.worldSize,t.y*this.worldSize,0]),e.a9.multiply(n,n,e.bE(this)),e.a9.translate(n,n,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.a9.multiply(u,u,n),e.a9.multiply(c,c,n),this.inverseAdjustmentMatrix=e.bF(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.a9.scale([],u,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=u,this.invProjMatrix=e.a9.invert(new Float64Array(16),this.projMatrix),n){const n=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);n[8]=2*-t.x/this.width,n[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.a9.mul([],n,a)}else this.expandedFarZProjMatrix=this.projMatrix;const h=e.a9.invert([],s);this.frustumCorners=e.bG.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bt.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!n);const d=new Float32Array(16);e.a9.identity(d),e.a9.scale(d,d,[1,-1,1]),e.a9.rotateX(d,d,this._pitch),e.a9.rotateZ(d,d,this.angle);const f=e.a9.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.a9.clone(f);const p=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;f[8]=2*-t.x/this.width,f[9]=2*(t.y+p)/this.height,this.skyboxMatrix=e.a9.multiply(d,f,d);const m=this.point,g=m.x,_=m.y,y=this.width%2/2,v=this.height%2/2,x=Math.cos(this.angle),b=Math.sin(this.angle),w=g-Math.round(g)+x*y+b*v,S=_-Math.round(_)+x*v+b*y,M=new Float64Array(u);if(e.a9.translate(M,M,[w>.5?w-1:w,S>.5?S-1:S,0]),this.alignedProjMatrix=M,u=e.a9.create(),e.a9.scale(u,u,[this.width/2,-this.height/2,1]),e.a9.translate(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=e.a9.create(),e.a9.scale(u,u,[1,-1,1]),e.a9.translate(u,u,[-1,-1,0]),e.a9.scale(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=e.a9.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},u=e.a9.invert(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.bH(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.Q.transformMat4(t,t,a),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,n=this.cameraPixelsPerMeter,r=this._camera.position,i=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,n];e.Q.scale(o,o,i),e.Q.scale(r,r,-1),e.Q.multiply(r,r,o);const a=e.a9.create();e.a9.translate(a,a,r),e.a9.scale(a,a,o),this.mercatorFogMatrix=a,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,n,i)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,n=this._camera.forward(),r=this.point,i=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-n[0]*i,r.y/this.worldSize-n[1]*i,e/this.worldSize*this._centerAltitude-n[2]*i]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const n=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],i=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),i>0&&(o=Math.min((n-r)/i,1)),this._camera.position=e.Q.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,n=this._camera.forward(),{pitch:r,bearing:i}=this._camera.getPitchBearing(),o=e.bo(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,a=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.bm(this._maxPitch)),s=Math.max((t[2]-o)/Math.cos(r),a),l=this._zoomFromMercatorZ(s);e.Q.scaleAndAdd(t,t,n,s),this._pitch=e.ad(r,e.bm(this.minPitch),e.bm(this.maxPitch)),this.angle=e.bk(i,-Math.PI,Math.PI),this._setZoom(e.ad(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.O(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,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let n=0,r=e.bA,i=0,o=1/0;for(;r-n>1e-6&&r>n;){const e=n+.5*(r-n),a=this.tileSize*Math.pow(2,e),s=this.getCameraToCenterDistance(this.projection,e,a),l=this.scaleZoom(s/(t*this.tileSize)),c=Math.abs(e-l);cc||n.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.bI(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,n){const r=e.Q.length(e.Q.sub([],this._camera.position,t)),i=this._zoomFromMercatorZ(r)+n;return r-this._mercatorZfromZoom(i)}getCameraPoint(){if("globe"===this.projection.name){const t=function(t,n){let[r,i,o]=t;const a=[r,i,o,1];e.aa.transformMat4(a,a,n);const s=a[3]=Math.max(a[3],1e-6);return a[0]/=s,a[1]/=s,a[2]/=s,a}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.zoom,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.worldSize;const i=e.bD(t,n,this.width,this.height,1024),o=t.pixelSpaceConversion(this.center.lat,r,i);let a=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(a=dr(1,a,fr(this.pitch>=15?1:this.pitch/15))),a}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.a9.multiply(t,t,this.globeMatrix),t}getFrustum(t){return e.bt.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const mr={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,ShadowMap0:10},gr=(t,n)=>{if(n>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),n<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const r=t.transform,i=Math.max(Math.abs(r._zoom-(t.minCutoffZoom-1)),1),o=r.isLODDisabled(!1)?e.S(60,45,r.pitch):e.S(30,15,r.pitch),a=r._farZ-r._nearZ,s=n*r.height,l=((1-(c=o))*r.cameraToCenterDistance+c*(r._farZ+s))*i;var c;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[r._nearZ,r._farZ,(l-r._nearZ)/a,(l-s-r._nearZ)/a]}}},_r={cascadeCount:2,shadowMapResolution:2048};class yr{constructor(e,t){this.aabb=e,this.lastCascade=t}}class vr{add(e,t){const n=this.receivers[e.key];void 0!==n?(n.aabb.min[0]=Math.min(n.aabb.min[0],t.min[0]),n.aabb.min[1]=Math.min(n.aabb.min[1],t.min[1]),n.aabb.min[2]=Math.min(n.aabb.min[2],t.min[2]),n.aabb.max[0]=Math.max(n.aabb.max[0],t.max[0]),n.aabb.max[1]=Math.max(n.aabb.max[1],t.max[1]),n.aabb.max[2]=Math.max(n.aabb.max[2],t.max[2])):this.receivers[e.key]=new yr(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,n,r){const i=e.bV.fromPoints(t.points);let o=0;for(const a in this.receivers){const t=this.receivers[a];if(!t)continue;if(!i.intersectsAabb(t.aabb))continue;t.aabb.min=i.closestPoint(t.aabb.min),t.aabb.max=i.closestPoint(t.aabb.max);const s=t.aabb.getCorners();for(let i=0;i1||o[1]<-1||o[1]>1){a=!1;break}}if(t.lastCascade=i,o=Math.max(o,i),a)break}}return o+1}}class xr{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new vr,this._depthMode=new Et(e.context.gl.LEQUAL,Et.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1,e.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},(()=>{this.painter.style.map.triggerRepaint()})),e.tp.registerParameter(_r,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(_r,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,n){const r=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!n||!n.properties)return;const i=n.properties.get("shadow-intensity");if(!n.shadowsEnabled()||i<=0)return;if(this._shadowLayerCount=r.style.order.reduce(((e,n)=>{const i=r.style._mergedLayers[n];return e+(i.hasShadowPass()&&!i.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const o=r.context,a=_r.shadowMapResolution,s=_r.shadowMapResolution;if(0===this._cascades.length||_r.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;t<_r.cascadeCount;++t){const t=r._shadowMapDebug,n=o.gl,i=o.createFramebuffer(a,s,t,"texture"),l=new e.T(o,{width:a,height:s,data:null},n.DEPTH_COMPONENT);if(i.depthAttachment.set(l.texture),t){const t=new e.T(o,{width:a,height:s,data:null},n.RGBA);i.colorAttachment.set(t.texture)}this._cascades.push({framebuffer:i,texture:l,matrix:[],far:0,boundingSphereRadius:0,frustum:new e.bt,scale:0})}}this.shadowDirection=wr(n);let l=0;if(t.elevation){const e=t.elevation,n=[1e4,-1e4];e.visibleDemTiles.filter((e=>e.dem)).forEach((e=>{const t=e.dem.tree;n[0]=Math.min(n[0],t.minimums[0]),n[1]=Math.max(n[1],t.maximums[0])})),1e4!==n[0]&&(l=(n[1]-n[0])*e.exaggeration())}const c=1.5*t.cameraToCenterDistance,u=3*c,h=new Float64Array(16);for(let p=0;p3&&void 0!==arguments[3]?arguments[3]:0;if(!this.enabled)return;const o=this.painter.transform,a=this.painter.context,s=a.gl,l=this._uniformValues,c=new Float64Array(16),u=o.calculatePosMatrix(t,o.worldSize);for(let h=0;h2&&void 0!==arguments[2]&&arguments[2];if(!this.enabled)return;const i=this.painter.context,o=i.gl,a=this._uniformValues,s=new Float64Array(16);for(let l=0;l<_r.cascadeCount;l++)e.a9.multiply(s,this._cascades[l].matrix,t),a[0===l?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(s),i.activeTexture.set(o.TEXTURE0+mr.ShadowMap0+l),this._cascades[l].texture.bind(o.NEAREST,o.CLAMP_TO_EDGE);if(this.useNormalOffset=r,r){const e=5;a.u_shadow_normal_offset=[1,e,e],a.u_shadow_bias=[6e-5,.0012,.012]}else a.u_shadow_bias=[36e-5,.0012,.012];n.setShadowUniformValues(i,a)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(t,n,r,i){if(i[2]>=0)return{};const o=function(t,n,r){const i=r/(1<0&&(e.Q.add(o[1],o[1],[i[0]*a,0,0]),e.Q.add(o[2],o[2],[i[0]*a,0,0])),i[1]<0?(e.Q.add(o[0],o[0],[0,i[1]*a,0]),e.Q.add(o[1],o[1],[0,i[1]*a,0])):i[1]>0&&(e.Q.add(o[2],o[2],[0,i[1]*a,0]),e.Q.add(o[3],o[3],[0,i[1]*a,0]));const s={};return s.vertices=o,s.planes=[br(o[1],o[0],o[4]),br(o[2],o[1],o[5]),br(o[3],o[2],o[6]),br(o[0],o[3],o[7])],s}addShadowReceiver(t,n,r){this._receivers.add(t,e.bV.fromTileIdAndHeight(t,n,r))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function br(t,n,r){const i=e.Q.sub([],r,n),o=e.Q.sub([],t,n),a=e.Q.cross([],i,o),s=e.Q.length(a);return 0===s?[0,0,1,0]:(e.Q.scale(a,a,1/s),[a[0],a[1],a[2],-e.Q.dot(a,n)])}function wr(t){const n=t.properties.get("direction"),r=e.bT(n.x,n.y,n.z);r[2]=e.ad(r[2],0,75);const i=e.bW([r[0],r[1],r[2]]);return e.Q.fromValues(i.x,i.y,i.z)}function Sr(t,n){const r=t.properties.get("color"),i=t.properties.get("intensity"),o=t.properties.get("direction"),a=[o.x,o.y,o.z],s=n.properties.get("color"),l=n.properties.get("intensity"),c=Math.max(e.Q.dot([0,0,1],a),0),u=[0,0,0];e.Q.scale(u,s.toArray01Linear().slice(0,3),l);const h=[0,0,0];return e.Q.scale(h,r.toArray01Linear().slice(0,3),c*i),e.bX([u[0]>0?u[0]/(u[0]+h[0]):0,u[1]>0?u[1]/(u[1]+h[1]):0,u[2]>0?u[2]/(u[2]+h[2]):0])}function Mr(t,n,r,i,o,a){const s=t.zoom,l=t.scale,c=t.worldSize,u=1/c,h=t.aspect,d=Math.sqrt(1+h*h)*Math.tan(.5*t.fovX),f=d*d,p=i-r,m=i+r;let g,_;f>p/m?(g=i,_=i*d):(g=.5*m*(1+f),_=.5*Math.sqrt(p*p+2*(i*i+r*r)*f+m*m*f*f));const y=t.projection.pixelsPerMeter(t.center.lat,c),v=t._camera.getCameraToWorldMercator(),x=[0,0,-g*u];e.Q.transformMat4(x,x,v);let b=_*u;const w=t._edgeInsets;if(!(0===w.left&&0===w.top&&0===w.right&&0===w.bottom||w.left===w.right&&w.top===w.bottom)){const n=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?y:1),o=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,r,i);o[8]=2*-t.centerOffset.x/t.width,o[9]=2*t.centerOffset.y/t.height;const a=new Float64Array(16);e.a9.mul(a,o,n);const u=new Float64Array(16);e.a9.invert(u,a);const h=e.bt.fromInvProjectionMatrix(u,c,s,!0);for(const r of h.points){const n=((S=r)[0]/=l,S[1]/=l,S[2]=e.bo(S[2],t._center.lat),S);b=Math.max(b,e.Q.len(e.Q.subtract([],x,n)))}}var S;b*=o/(o-1);const M=Math.acos(n[2]),A=Math.atan2(-n[0],-n[1]),E=new hr;E.position=x,E.setPitchBearing(M,A);const T=E.getWorldToCamera(c,y),C=b*c,k=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*C),I=E.getCameraToClipOrthographic(-C,C,-C,C,k,(C+a*y)/n[2]),P=new Float64Array(16);e.a9.multiply(P,I,T);const R=e.Q.fromValues(Math.floor(1e6*x[0])/1e6*c,Math.floor(1e6*x[1])/1e6*c,0),L=.5*o,z=[0,0,0];e.Q.transformMat4(z,R,P),e.Q.scale(z,z,L);const O=[Math.floor(z[0]),Math.floor(z[1]),Math.floor(z[2])],D=[0,0,0];e.Q.sub(D,z,O),e.Q.scale(D,D,-1/L);const B=new Float64Array(16);return e.a9.identity(B),e.a9.translate(B,B,D),e.a9.multiply(P,B,P),[P,C]}const Ar=(e,t)=>ae(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),Er=e.af(tn,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),Tr=e.af(tn,["setCenter","setZoom","setBearing","setPitch"]),Cr={version:8,layers:[],sources:{}},kr={duration:300,delay:0};class Ir extends e.E{constructor(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this.map=t,this.scope=n.scope||"",this.globalId=null,this.fragments=[],this.importDepth=n.importDepth||0,this.importsCache=n.importsCache||new Map,this.resolvedImports=n.resolvedImports||new Set,this.transition=e.e({},kr),this._buildingIndex=new Jt(this),this.crossTileSymbolIndex=new or,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=n.styleChanges||new y,this.dispatcher=n.dispatcher?n.dispatcher:new e.bZ(e.b_(),this),n.imageManager?this.imageManager=n.imageManager:(this.imageManager=new w,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=n.glyphManager?n.glyphManager:new e.b$(t._requestManager,n.localFontFamily?e.c0.all:n.localIdeographFontFamily?e.c0.ideographs:e.c0.none,n.localFontFamily||n.localIdeographFontFamily),n.modelManager?this.modelManager=n.modelManager:(this.modelManager=new v(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this.options=n.configOptions?n.configOptions:new Map,this._configDependentLayers=n.configDependentLayers?n.configDependentLayers:new Set,this._config=n.config,this._initialConfig=n.initialConfig,this.dispatcher.broadcast("setReferrer",e.c1());const r=this;this._rtlTextPluginCallback=Ir.registerForPluginStateChange((t=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,n)=>{if(e.c2(t),n&&n.every((e=>e)))for(const e in r._sourceCaches){const t=r._sourceCaches[e],n=t.getSource().type;"vector"!==n&&"geojson"!==n||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const n in this._layers){const e=this._layers[n];e.source===t.id&&this._validateLayer(e)}}))}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.c3(t))return t;const n=e.c4(t);if(!n.startsWith("http"))try{return new URL(n,location.href).toString()}catch(e){return n}return n}return"json://".concat(e.c5(JSON.stringify(t)))}_diffStyle(t,n,r){this.globalId=this._getGlobalId(t);const i=(e,t)=>{try{t(null,this.setState(e,r))}catch(e){t(e,!1)}};if("string"==typeof t){const r=this.map._requestManager.normalizeStyleURL(t),o=this.map._requestManager.transformRequest(r,e.R.Style);e.g(o,((t,r)=>{t?this.fire(new e.a(t)):r&&i(r,n)}))}else"object"==typeof t&&i(t,n)}loadURL(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.fire(new e.b("dataloading",{dataType:"style"}));const r="boolean"==typeof n.validate?n.validate:!e.c3(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,n.accessToken),this.resolvedImports.add(t);const i=this.importsCache.get(t);if(i)return this._load(i,r);const o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.g(o,((n,i)=>{if(this._request=null,n)this.fire(new e.a(n));else if(i)return this.importsCache.set(t,i),this._load(i,r)}))}loadJSON(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.fire(new e.b("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.f.frame((()=>{this._request=null,this._load(t,!1!==n.validate)}))}loadEmpty(){this.fire(new e.b("dataloading",{dataType:"style"})),this._load(Cr,!1)}_loadImports(t,n,r){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const i=[];for(const e of t){const t=this._createFragmentStyle(e),o=new Promise((e=>{t.once("style.import.load",e),t.once("error",e)})).then((()=>this.mergeAll()));if(i.push(o),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const a=e.data||this.importsCache.get(e.url);a?(t.loadJSON(a,{validate:n}),this._isInternalStyle(a)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:n}):t.loadEmpty();const s={style:t,id:e.id,config:e.config};if(r){const e=this.fragments.findIndex((e=>{let{id:t}=e;return t===r}));this.fragments=this.fragments.slice(0,e).concat(s).concat(this.fragments.slice(e))}else this.fragments.push(s)}return Promise.allSettled(i)}getImportGlobalIds(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;for(const n of e.fragments)n.style.globalId&&t.add(n.style.globalId),this.getImportGlobalIds(n.style,t);return[...t.values()]}_createFragmentStyle(t){const n=this.scope?e.aj(t.id,this.scope):t.id;let r;const i=this._initialConfig&&this._initialConfig[n];(t.config||i)&&(r=e.e({},t.config,i));const o=new Ir(this.map,{scope:n,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:r,configOptions:this.options,configDependentLayers:this._configDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.isRootStyle()}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,n){const r=t.schema;if(this._isInternalStyle(t)){const r=e.e({},Cr,{imports:[{id:"basemap",data:t,url:""}]});return void this._load(r,n)}if(this.updateConfig(this._config,r),n&&Ar(this,Y(t)))return;this._loaded=!0,this.stylesheet=e.c6(t);for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(t.glyphs,this.scope);const i=en(this.stylesheet.layers);if(this._order=i.map((e=>e.id)),this.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new le(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new le(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const s of i){const t=e.c7(s,this.scope,this.options);t.isConfigDependent&&this._configDependentLayers.add(t.fqid),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize();const n=this.getOwnLayerSourceCache(t),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();n&&t.canCastShadows()&&r&&(n.castsShadows=!0)}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const o=this.stylesheet.terrain;o&&(void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.f.hasCanvasFingerprintNoise()),this.disableElevatedTerrain?e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."):this.terrainSetForDrapingOnly()||this._createTerrain(o,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.b("data",{dataType:"style"}));const a=this.isRootStyle();t.imports?this._loadImports(t.imports,n).then((()=>{this._reloadImports(),this.fire(new e.b(a?"style.load":"style.import.load"))})):(this._reloadImports(),this.fire(new e.b(a?"style.load":"style.import.load")))}isRootStyle(){return 0===this.importDepth}mergeAll(){let t,n,r,i,o,a,s,l;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((e=>{if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(const t of e.stylesheet.lights)"ambient"===t.type&&null!=e.ambientLight&&(n=e.ambientLight),"directional"===t.type&&null!=e.directionalLight&&(r=e.directionalLight);i=this._prioritizeTerrain(i,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(o=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(a=e.stylesheet.projection),null!=e.stylesheet.transition&&(s=e.stylesheet.transition)}})),this.light=t,this.ambientLight=n,this.directionalLight=r,this.fog=o,null===i?delete this.terrain:this.terrain=i,this.camera=l||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=e.e({},kr,s),this.mergeSources(),this.mergeLayers()}forEachFragmentStyle(e){const t=n=>{for(const e of n.fragments)t(e.style);e(n)};t(this)}_prioritizeTerrain(e,t,n){const r=e&&0===e.drapeRenderMode;return null===n?t&&0===t.drapeRenderMode?t:r?e:null:null!=t&&(!e||r||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain)})),null===e?delete this.terrain:this.terrain=e}mergeProjection(){let e;this.forEachFragmentStyle((t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)})),this.projection=e||{name:"mercator"}}mergeSources(){const t={},n={},r={};this.forEachFragmentStyle((i=>{for(const n in i._sourceCaches){const r=e.aj(n,i.scope);t[r]=i._sourceCaches[n]}for(const t in i._otherSourceCaches){const r=e.aj(t,i.scope);n[r]=i._otherSourceCaches[t]}for(const t in i._symbolSourceCaches){const n=e.aj(t,i.scope);r[n]=i._symbolSourceCaches[t]}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=n,this._mergedSymbolSourceCaches=r}mergeLayers(){var t=this;const n={},r=[],i={};this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((t=>{for(const i of t._order){const o=t._layers[i];if("slot"===o.type){const t=e.c8(i);if(n[t])continue;n[t]=[]}o.slot&&n[o.slot]?n[o.slot].push(o):r.push(o)}})),this._mergedOrder=[];const o=function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];for(const a of r)if("slot"===a.type){const t=e.c8(a.id);n[t]&&o(n[t])}else{const n=e.aj(a.id,a.scope);t._mergedOrder.push(n),i[n]=a,a.is3D()&&(t._has3DLayers=!0),"circle"===a.type&&(t._hasCircleLayers=!0),"symbol"===a.type&&(t._hasSymbolLayers=!0)}};o(r),this._mergedLayers=i,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=e.e({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?(this.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=function(t,n,r){let i,o,a;const s=e.f.devicePixelRatio>1?"@2x":"";let l=e.g(n.transformRequest(n.normalizeSpriteURL(t,s,".json"),e.R.SpriteJSON),((e,t)=>{l=null,a||(a=e,i=t,u())})),c=e.d(n.transformRequest(n.normalizeSpriteURL(t,s,".png"),e.R.SpriteImage),((e,t)=>{c=null,a||(a=e,o=t,u())}));function u(){if(a)r(a);else if(i&&o){const t=e.f.getImageData(o),n={};for(const r in i){const{width:o,height:a,x:s,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:f}=i[r],p=new e.h({width:o,height:a});e.h.copy(t,p,{x:s,y:l},{x:0,y:0},{width:o,height:a}),n[r]={data:p,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:f}}r(null,n)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,((t,n)=>{if(this._spriteRequest=null,t)this.fire(new e.a(t));else if(n)for(const e in n)this.imageManager.addImage(e,this.scope,n[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.b("data",{dataType:"style"}))}))}_validateLayer(t){const n=this.getOwnSource(t.source);if(!n)return;const r=t.sourceLayer;r&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new e.a(new Error('Source layer "'.concat(r,'" does not exist on source "').concat(n.id,'" as specified by style layer "').concat(t.id,'"'))))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;if(!this.imageManager.isLoaded())return!1;if(!this.modelManager.isLoaded())return!1;for(const{style:e}of this.fragments)if(!e.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map(((e,t)=>{const n=this.fragments[t];return n&&n.style&&(e.data=n.style.serialize()),e}))}_serializeSources(){const e={};for(const t in this._sourceCaches){const n=this._sourceCaches[t].getSource();e[n.id]||(e[n.id]=n.serialize())}return e}_serializeLayers(e){const t=[];for(const n of e){const e=this._layers[n];e&&"custom"!==e.type&&t.push(e.serialize())}return t}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())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.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const n=this.getOwnLayer(t);if(n)return n;this.fire(new e.a(new Error("The layer '".concat(t,"' does not exist in the map's style."))))}_checkSource(t){const n=this.getOwnSource(t);if(n)return n;this.fire(new e.a(new Error("The source '".concat(t,"' does not exist in the map's style."))))}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const n=this.calculateLightsBrightness();t.brightness=n||0,n!==this._brightness&&(this._brightness=n,this.dispatcher.broadcast("setBrightness",n));const r=this._changes.isDirty();if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:n,removedIds:r}=e[t];(n||r)&&this._updateWorkerLayers(t,n,r)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._changes.reset()}const i={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];i[e]=t.used,t.used=!1,t.tileCoverLift=0}for(const e of this._mergedOrder){const n=this._mergedLayers[e];if(n.recalculate(t,this._availableImages),!n.isHidden(t.zoom)){const e=this.getLayerSourceCache(n);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,n.tileCoverLift()))}if(!this._precompileDone&&this._shouldPrecompile)for(let e=n.minzoom||0;e<(n.maxzoom||25.5);e++){const e=this.map.painter;if(e){const r=n.getProgramIds();if(!r)continue;for(const i of r){const r=n.getDefaultProgramParams(i,t.zoom);r&&(e.style=this,this.fog&&(e._fogVisible=!0,r.overrideFog=!0,e.getOrCreateProgram(i,r)),e._fogVisible=!1,r.overrideFog=!1,e.getOrCreateProgram(i,r),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(r.overrideRtt=!0,e.getOrCreateProgram(i,r)))}}}}this._shouldPrecompile&&(this._precompileDone=!0);for(const o in i){const t=this._mergedSourceCaches[o];i[o]!==t.used&&t.getSource().fire(new e.b("data",{sourceDataType:"visibility",dataType:"source",sourceId:t.getSource().id}))}this.light&&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.b("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages()}}_updateWorkerLayers(e,t,n){const r=this.getFragmentStyle(e);r&&this.dispatcher.broadcast("updateLayers",{layers:t?r._serializeLayers(t):[],scope:e,removedIds:n||[],options:r.options})}setState(n,r){if(this._checkLoaded(),Ar(this,Y(n)))return!1;(n=e.c6(n)).layers=en(n.layers);const i=function(e,n){if(!e)return[{command:tn.setStyle,args:[n]}];let r=[];try{if(!t(e.version,n.version))return[{command:tn.setStyle,args:[n]}];t(e.center,n.center)||r.push({command:tn.setCenter,args:[n.center]}),t(e.zoom,n.zoom)||r.push({command:tn.setZoom,args:[n.zoom]}),t(e.bearing,n.bearing)||r.push({command:tn.setBearing,args:[n.bearing]}),t(e.pitch,n.pitch)||r.push({command:tn.setPitch,args:[n.pitch]}),t(e.sprite,n.sprite)||r.push({command:tn.setSprite,args:[n.sprite]}),t(e.glyphs,n.glyphs)||r.push({command:tn.setGlyphs,args:[n.glyphs]}),t(e.imports,n.imports)||function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;n=n||[];const i=(e=e||[]).map(ln),o=n.map(ln),a=e.reduce(cn,{}),s=n.reduce(cn,{}),l=i.slice();let c,u,h,d;for(c=0,u=0;c{e.source&&i[e.source]?r.push({command:tn.removeLayer,args:[e.id]}):a.push(e)}));let s=e.terrain;s&&i[s.source]&&(r.push({command:tn.setTerrain,args:[void 0]}),s=void 0),r=r.concat(o),t(s,n.terrain)||r.push({command:tn.setTerrain,args:[n.terrain]}),function(e,n,r){n=n||[];const i=(e=e||[]).map(ln),o=n.map(ln),a=e.reduce(cn,{}),s=n.reduce(cn,{}),l=i.slice(),c=Object.create(null);let u,h,d,f,p,m,g;for(u=0,h=0;u!(e.command in Tr)));if(0===i.length)return!1;const o=i.filter((e=>!(e.command in Er)));if(o.length>0)throw new Error("Unimplemented: ".concat(o.map((e=>e.command)).join(", "),"."));const a=[];return i.forEach((e=>{a.push(this[e.command].apply(this,e.args))})),r&&Promise.all(a).then(r),this.stylesheet=n,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(t,n){return this.getImage(t)?this.fire(new e.a(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,n),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t)}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._afterImageUpdated(t),this):this.fire(new e.a(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(t),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new e.b("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._checkLoaded(),this._validate(ie,"models.".concat(e),t,null,n)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope),this):this.fire(new e.a(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error('There is already a source with ID "'.concat(t,'".'));if(!n.type)throw new Error("The type property must be defined, but only the following properties were given: ".concat(Object.keys(n).join(", "),"."));if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(Q,"sources.".concat(t),n,null,r))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const i=Vt(t,n,this.dispatcher,this);i.scope=this.scope,i.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(i.id),source:i.serialize(),sourceId:i.id})));const o=t=>{const n=(t?"symbol:":"other:")+i.id,r=e.aj(n,this.scope),o=this._sourceCaches[n]=new Yt(r,i,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[i.id]=o,o.onAdd(this.map)};o(!1),"vector"!==n.type&&"geojson"!==n.type||o(!0),i.onAdd&&i.onAdd(this.map),r.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();const n=this.getOwnSource(t);if(!n)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.a(new Error('Source "'.concat(t,'" cannot be removed while layer "').concat(i,'" is using it.'))));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.a(new Error('Source "'.concat(t,'" cannot be removed while terrain is using it.'))));const r=this.getOwnSourceCaches(t);for(const i of r){const t=e.c8(i.id);delete this._sourceCaches[t],this._changes.discardSourceCacheUpdate(i.id),i.fire(new e.b("data",{sourceDataType:"metadata",dataType:"source",sourceId:i.getSource().id})),i.setEventedParent(null),i.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const n=this.getOwnSourceCache(t);n&&e.push(n.getSource())}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const n=e[t]._tiles;for(const e in n){const t=n[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}setLights(t){if(this._checkLoaded(),!t)return delete this.ambientLight,void delete this.directionalLight;const n=this._getTransitionParameters();for(const e of t){if(this._validate(K,"lights",e))return;switch(e.type){case"ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(n)}else this.ambientLight=new xe(e,be,this.scope,this.options);break;case"directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(n)}else this.directionalLight=new xe(e,we,this.scope,this.options)}}const r=new e.N(this.z||0,n);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,n=this.ambientLight;if(!t||!n)return;const r=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),i=t.properties.get("color").toArray01(),o=t.properties.get("intensity"),a=t.properties.get("direction"),s=1-e.bT(a.x,a.y,a.z)[2]/90,l=r(i)*o*s,c=n.properties.get("color").toArray01(),u=n.properties.get("intensity");return(l+r(c)*u)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(!t)return this;if(e.c9(t)){const n=e.ca(t),r=this.fragments.find((e=>{let{id:t}=e;return t===n}));if(!r)throw new Error("Style import not found: ".concat(t));const i=e.c8(t);return r.style.getFragmentStyle(i)}{const e=this.fragments.find((e=>{let{id:n}=e;return n===t}));if(!e)throw new Error("Style import not found: ".concat(t));return e.style}}getConfigProperty(t,n){const r=this.getFragmentStyle(t);if(!r)return null;const i=e.aj(n,r.scope),o=r.options.get(i),a=o?o.value||o.default:null;return a?a.serialize():null}setConfigProperty(t,n,r){const i=this.getFragmentStyle(t);if(!i)return;const o=i.stylesheet.schema;if(!o||!o[n])return;const a=e.t(r);if("success"!==a.result)return void Ar(this,a.value);const s=a.value.expression,l=e.aj(n,i.scope),c=i.options.get(l);if(!c)return;let u;const{minValue:h,maxValue:d,stepValue:f,type:p,values:m}=o[n],g=e.t(o[n].default);"success"===g.result&&(u=g.value.expression),u?(this.options.set(l,{...c,value:s,default:u,minValue:h,maxValue:d,stepValue:f,type:p,values:m}),this.updateConfigDependencies()):this.fire(new e.a(new Error('No schema defined for the config option "'.concat(n,'" in the "').concat(t,'" fragment.'))))}getConfig(t){const n=this.getFragmentStyle(t);if(!n)return null;const r=n.stylesheet.schema;if(!r)return null;const i={};for(const o in r){const t=e.aj(o,n.scope),r=n.options.get(t),a=r?r.value||r.default:null;i[o]=a?a.serialize():null}return i}setConfig(e,t){const n=this.getFragmentStyle(e);n&&(n.updateConfig(t,n.stylesheet.schema),this.updateConfigDependencies())}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const n=this.getFragmentStyle(e);n&&(n.stylesheet.schema=t,n.updateConfig(n._config,t),this.updateConfigDependencies())}updateConfig(t,n){if(this._config=t,t||n)if(n)for(const r in n){let i,o;const a=e.t(n[r].default);if("success"===a.result&&(i=a.value.expression),t&&void 0!==t[r]){const n=e.t(t[r]);"success"===n.result&&(o=n.value.expression)}const{minValue:s,maxValue:l,stepValue:c,type:u,values:h}=n[r];if(i){const t=e.aj(r,this.scope);this.options.set(t,{default:i,value:o,minValue:s,maxValue:l,stepValue:c,type:u,values:h})}else this.fire(new e.a(new Error('No schema defined for config option "'.concat(r,'".'))))}else this.fire(new e.a(new Error("Attempting to set config for a style without schema.")))}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t))}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this._changes.setDirty()}addLayer(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();const i=t.id;if(this._layers[i])return void this.fire(new e.a(new Error('Layer with id "'.concat(i,'" already exists on this map'))));let o;if("custom"===t.type){if(Ar(this,e.cb(t)))return;o=e.c7(t,this.scope,this.options)}else{if("object"==typeof t.source&&(this.addSource(i,t.source),t=e.c6(t),t=e.e(t,{source:i})),this._validate(ee,"layers.".concat(i),t,{arrayIndex:-1},r))return;o=e.c7(t,this.scope,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:i}}),this._serializedLayers[o.id]=o.serialize()}o.isConfigDependent&&this._configDependentLayers.add(o.fqid);let a=this._order.length;if(n){const t=this._order.indexOf(n);if(-1===t)return void this.fire(new e.a(new Error('Layer with id "'.concat(n,'" does not exist on this map.'))));o.slot===this._layers[n].slot?a=t:e.w('Layer with id "'.concat(n,'" has a different slot. Layers can only be rearranged within the same slot.'))}this._order.splice(a,0,i),this._layerOrderChanged=!0,this._layers[i]=o;const s=this.getOwnLayerSourceCache(o),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();s&&o.canCastShadows()&&l&&(s.castsShadows=!0);const c=this._changes.getRemovedLayer(o);if(c&&o.source&&s&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.aj(o.source,o.scope);c.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),s.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers()}moveLayer(t,n){this._checkLoaded();const r=this._checkLayer(t);if(!r)return;if(t===n)return;const i=this._order.indexOf(t);this._order.splice(i,1);let o=this._order.length;if(n){const t=this._order.indexOf(n);if(-1===t)return void this.fire(new e.a(new Error('Layer with id "'.concat(n,'" does not exist on this map.'))));r.slot===this._layers[n].slot?o=t:e.w('Layer with id "'.concat(n,'" has a different slot. Layers can only be rearranged within the same slot.'))}this._order.splice(o,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const n=this._order.indexOf(e);this._order.splice(n,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const r=this.getOwnLayerSourceCache(t);if(r&&r.castsShadows){let e=!1;for(const n in this._layers)if(this._layers[n].source===t.source&&this._layers[n].canCastShadows()){e=!0;break}r.castsShadows=e}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,n){this._checkLoaded();const r=this._checkLayer(e);r&&(r.minzoom===t&&r.maxzoom===n||(null!=t&&(r.minzoom=t),null!=n&&(r.maxzoom=n),this._updateLayer(r)))}setSlot(e,t){this._checkLoaded();const n=this._checkLayer(e);n&&n.slot!==t&&(n.slot=t,this._updateLayer(n))}setFilter(n,r){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();const o=this._checkLayer(n);if(o&&!t(o.filter,r))return null==r?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(te,"layers.".concat(o.id,".filter"),r,{layerType:o.type},i)||(o.filter=e.c6(r),this._updateLayer(o)))}getFilter(t){const n=this._checkLayer(t);if(n)return e.c6(n.filter)}setLayoutProperty(n,r,i){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this._checkLoaded();const a=this._checkLayer(n);if(a&&!t(a.getLayoutProperty(r),i)){if(null!=i&&(!o||!1!==o.validate)&&Ar(a,re.call(Y,{key:"layers.".concat(n,".layout.").concat(r),layerType:a.type,objectKey:r,value:i,styleSpec:e.G,style:{glyphs:!0,sprite:!0}})))return;a.setLayoutProperty(r,i),a.isConfigDependent&&this._configDependentLayers.add(a.fqid),this._updateLayer(a)}}getLayoutProperty(e,t){const n=this._checkLayer(e);if(n)return n.getLayoutProperty(t)}setPaintProperty(n,r,i){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this._checkLoaded();const a=this._checkLayer(n);if(!a)return;if(t(a.getPaintProperty(r),i))return;if(null!=i&&(!o||!1!==o.validate)&&Ar(a,ne.call(Y,{key:"layers.".concat(n,".paint.").concat(r),layerType:a.type,objectKey:r,value:i,styleSpec:e.G})))return;const s=a.setPaintProperty(r,i);a.isConfigDependent&&this._configDependentLayers.add(a.fqid),s&&this._updateLayer(a),this._changes.updatePaintProperties(a)}getPaintProperty(e,t){const n=this._checkLayer(e);if(n)return n.getPaintProperty(t)}setFeatureState(t,n){this._checkLoaded();const r=t.source,i=t.sourceLayer,o=this._checkSource(r);if(!o)return;const a=o.type;if("geojson"===a&&i)return void this.fire(new e.a(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===a&&!i)return void this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.a(new Error("The feature id parameter must be provided.")));const s=this.getOwnSourceCaches(r);for(const e of s)e.setFeatureState(i,t.id,n)}removeFeatureState(t,n){this._checkLoaded();const r=t.source,i=this._checkSource(r);if(!i)return;const o=i.type,a="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!a)return void this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.a(new Error("A feature id is required to remove its specific state property.")));const s=this.getOwnSourceCaches(r);for(const e of s)e.removeFeatureState(a,t.id,n)}getFeatureState(t){this._checkLoaded();const n=t.source,r=t.sourceLayer,i=this._checkSource(n);if(i){if("vector"!==i.type||r)return void 0===t.id&&this.fire(new e.a(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(n)[0].getFeatureState(r,t.id);this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(t){return this.stylesheet.transition=e.e({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return e.e({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),n=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.cc({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:n,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:this._serializeSources(),layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(t){this._changes.updateLayer(t);const n=this.getLayerSourceCache(t),r=e.aj(t.source,t.scope),i=this._changes.getUpdatedSourceCaches();t.source&&!i[r]&&n&&"raster"!==n.getSource().type&&(this._changes.updateSourceCache(r,"reload"),n.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._mergedLayers[e].type||"model"===this._mergedLayers[e].type,n=this.order,r={},i=[];for(let a=n.length-1;a>=0;a--){const o=n[a];if(t(o)){r[o]=a;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 o=[];for(let a=n.length-1;a>=0;a--){const s=n[a];if(t(s))for(let e=i.length-1;e>=0;e--){const t=i[e].feature;if(r[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),l=Se.createFromScreenPoints(t,r);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e].getSource();if(!t||t.scope!==n.scope)continue;const c=this._mergedSourceCaches[e].getSource().id;n.layers&&!i[c]||o.push(Gt(this._mergedSourceCaches[e],this._mergedLayers,a,l,n,r,s,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,n,r,i,o,a){const s={},l=o.queryRenderedSymbols(r),c=[];for(const u of Object.keys(l).map(Number))c.push(a[u]);c.sort(Wt);for(const u of c){const n=u.featureIndex.lookupSymbolFeatures(l[u.bucketInstanceId],t,u.bucketIndex,u.sourceLayerIndex,i.filter,i.layers,i.availableImages,e);for(const e in n){const t=s[e]=s[e]||[],r=n[e];r.sort(((e,t)=>{const n=u.featureSortOrder;if(n){const r=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-r}return t.featureIndex-e.featureIndex}));for(const e of r)t.push(e)}}for(const u in s)s[u].forEach((t=>{const r=t.feature,i=n(e[u]);if(!i)return;const o=i.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=o}));return s}(this._mergedLayers,a,this.getLayerSourceCache.bind(this),l.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,t){t&&t.filter&&this._validate(te,"querySourceFeatures.filter",t.filter,null,t);const n=this.getOwnSourceCaches(e);let r=[];for(const i of n)r=r.concat(qt(i,t));return r}addSourceType(e,t,n){return Ir.getSourceType(e)?n(new Error('A source type called "'.concat(e,'" already exists.'))):(Ir.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},n):n(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();const i=this.light.getLight();let o=!1;for(const s in e)if(!t(e[s],i[s])){o=!0;break}if(!o)return;const a=this._getTransitionParameters();this.light.setLight(e,n,r),this.light.updateTransitions(a)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(n){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this._checkLoaded(),!n)return this.terrainSetForDrapingOnly()&&0!==r||delete this.terrain,null===n?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let i=n;const o=null==n.source;if(1===r){if("object"==typeof i.source){const t="terrain-dem-src";this.addSource(t,i.source),i=e.c6(i),i=e.e(i,{source:t})}const t=e.e({},i),n={};if(this.terrain&&o){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(n.style=e.serialize())}if(this._validate(J,"terrain",t,n))return}if(!this.terrain||this.terrain.scope!==this.scope&&!o||this.terrain&&r!==this.terrain.drapeRenderMode){if(!i)return;this._createTerrain(i,r),this.fire(new e.b("data",{dataType:"style"}))}else{const r=this.terrain,o=r.get();for(const t of Object.keys(e.G.terrain))!i.hasOwnProperty(t)&&e.G.terrain[t].default&&(i[t]=e.G.terrain[t].default);for(const i in n)if(!t(n[i],o[i])){r.set(n,this.options),this.stylesheet.terrain=n;const t=this._getTransitionParameters({duration:0});r.updateTransitions(t),this.fire(new e.b("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new ve(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const n=this._getTransitionParameters({duration:0});t.updateTransitions(n)}_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 n=this.fog;if(!t(n.get(),e)){n.set(e,this.options),this.stylesheet.fog=n.get();const t=this._getTransitionParameters({duration:0});n.updateTransitions(t)}}else this._createFog(e);this._markersNeedUpdate=!0}_getTransitionParameters(t){return{now:e.f.now(),transition:e.e(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const n in this._mergedLayers)this.isLayerDraped(this._mergedLayers[n])?e.push(n):t.push(n);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const n=this.terrain=new ue(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const r=this._getTransitionParameters({duration:0});n.updateTransitions(r)}_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,n,r,i){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(o&&!1===o.validate)return!1;const a=e.e({},this.serialize());return Ar(this,t.call(Y,e.e({key:n,style:a,value:r,styleSpec:e.G},i)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.cd.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove())}clearSource(e){const t=this.getSourceCaches(e);for(const n of t)n.clearTiles()}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles()}reloadSource(e){const t=this.getSourceCaches(e);for(const n of t)n.resume(),n.reload()}reloadSources(){for(const e of this.getSources())e.reload&&e.reload()}updateSources(e){let t;this.directionalLight&&(t=wr(this.directionalLight));for(const n in this._mergedSourceCaches)this._mergedSourceCaches[n].update(e,void 0,void 0,t)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,n,r,i){let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=!1,s=!1;const l={},c={};for(const u of this._mergedOrder){const n=this._mergedLayers[u];if("symbol"!==n.type)continue;const r=e.aj(n.source,n.scope);let i=l[r];if(!i){const e=this.getLayerSourceCache(n);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));c[r]=t.slice(),i=l[r]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const o=this.crossTileSymbolIndex.addLayer(n,i,t.center.lng,t.projection);a=a||o}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),o=o||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.b("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.f.now(),t.zoom))&&(this.pauseablePlacement=new er(t,this._mergedOrder,o,n,r,i,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,l,c),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.f.now()),s=!0),a&&this.pauseablePlacement.placement.setStale()),s||a){this._buildingIndex.onNewFrame(t.zoom);for(const t of this._mergedOrder){const n=this._mergedLayers[t];"symbol"===n.type&&this.placement.updateLayerOpacities(n,l[e.aj(n.source,n.scope)])}}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.f.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}addImport(t,n){this._checkLoaded();const r=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==r.findIndex((e=>{let{id:n}=e;return n===t.id})))return void this.fire(new e.a(new Error("Import with id '".concat(t.id,"' already exists in the map's style."))));if(!n)return r.push(t),this._loadImports([t],!0);const i=r.findIndex((e=>{let{id:t}=e;return t===n}));return-1===i&&this.fire(new e.a(new Error('Import with id "'.concat(n,'" does not exist on this map.')))),this.stylesheet.imports=r.slice(0,i).concat(t).concat(r.slice(i)),this._loadImports([t],!0,n)}updateImport(e,n){this._checkLoaded();const r=this.stylesheet.imports||[],i=this.getImportIndex(e);return-1===i?this:"string"==typeof n?(this.setImportUrl(e,n),this):(n.url&&n.url!==r[i].url&&this.setImportUrl(e,n.url),t(n.config,r[i].config)||this.setImportConfig(e,n.config),t(n.data,r[i].data)||this.setImportData(e,n.data),this)}moveImport(e,t){this._checkLoaded();let n=this.stylesheet.imports||[];const r=this.getImportIndex(e);if(-1===r)return this;const i=this.getImportIndex(t);if(-1===i)return this;const o=n[r],a=this.fragments[r];return n=n.filter((t=>{let{id:n}=t;return n!==e})),this.fragments=this.fragments.filter((t=>{let{id:n}=t;return n!==e})),this.stylesheet.imports=n.slice(0,i).concat(o).concat(n.slice(i)),this.fragments=this.fragments.slice(0,i).concat(a).concat(this.fragments.slice(i)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const n=this.stylesheet.imports||[],r=this.getImportIndex(e);if(-1===r)return this;n[r].url=t;const i=this.fragments[r];return i.style=this._createFragmentStyle(n[r]),i.style.on("style.import.load",(()=>this.mergeAll())),i.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const n=this.getImportIndex(e),r=this.stylesheet.imports||[];return-1===n?this:t?(this.fragments[n].style.setState(t),this._reloadImports(),this):(delete r[n].data,this.setImportUrl(e,r[n].url))}setImportConfig(e,t){this._checkLoaded();const n=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===n)return this;t?r[n].config=t:delete r[n].config;const i=this.fragments[n],o=i.style.stylesheet&&i.style.stylesheet.schema;return i.config=t,i.style.updateConfig(t,o),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],n=this.getImportIndex(e);-1!==n&&(t.splice(n,1),this.fragments[n].style._remove(),this.fragments.splice(n,1),this._reloadImports())}getImportIndex(t){const n=(this.stylesheet.imports||[]).findIndex((e=>e.id===t));return-1===n&&this.fire(new e.a(new Error("Import '".concat(t,"' does not exist in the map's style and cannot be updated.")))),n}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const n=this._mergedOtherSourceCaches[t];n&&e.push(n.getSource())}return e}getSource(e,t){const n=this.getSourceCache(e,t);return n&&n.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,n){const r=e.aj(t,n);return this._mergedOtherSourceCaches[r]}getLayerSourceCache(t){const n=e.aj(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[n]:this._mergedOtherSourceCaches[n]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const n=e[t];"reload"===n?this.reloadSource(t):"clear"===n&&this.clearSource(t)}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const n of t){const t=this.getLayer(n);t&&t.updateTransitions(e)}}getImages(e,t,n){this.imageManager.getImages(t.icons,t.scope,n),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,n){this.glyphManager.getGlyphs(t.stacks,t.scope,n)}getResource(t,n,r){return e.ce(n,r)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const n=this.getOwnSourceCaches(t);return 0===n.length?(this.fire(new e.a(new Error("There is no source with ID '".concat(t,"'")))),!1):n.every((e=>e.loaded()))}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach((e=>{e.style._remove()})),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Ir.getSourceType=function(e){return jt[e]},Ir.setSourceType=function(e,t){jt[e]=t},Ir.registerForPluginStateChange=e.bY;var Pr="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",Rr="\nout vec4 glFragColor;highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,vec2 pos,vec2 lod_coord) {vec2 size=vec2(textureSize(image,0));vec2 dx=dFdx(lod_coord.xy*size);vec2 dy=dFdy(lod_coord.xy*size);float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}",Lr="\n#define EXTENT 8192.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\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;}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+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);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}",zr="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out 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;}",Or="\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\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;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 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*texture(u_dem,pos).r;\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=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;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*texture(u_dem_prev,pos).r;\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=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;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) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture(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(texture(u_depth,uv-df.xz)),unpack_depth(texture(u_depth,uv+df.xz)),unpack_depth(texture(u_depth,uv-df.zy)),unpack_depth(texture(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) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",Dr="#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;out 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",Br="highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in 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 opacity_limit) {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,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}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;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",Fr="#ifdef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",Nr="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec4 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=vec2(u_data_offset+dot(t.rg,u_data_scale.yx),-(u_data_offset+dot(t.ba,u_data_scale.yx)));velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}",jr="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif//RENDER_SHADOWS",Vr="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef NATIVE\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const Ur=[];Yr(Pr,Ur),Yr(Lr,Ur),Yr(Rr,Ur);const Gr={"_prelude_fog.vertex.glsl":Dr,"_prelude_terrain.vertex.glsl":Or,"_prelude_shadow.vertex.glsl":jr,"_prelude_fog.fragment.glsl":Br,"_prelude_shadow.fragment.glsl":Vr,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif//LIGHTING_3D_MODE","_prelude_raster_array.glsl":Fr,"_prelude_raster_particle.glsl":Nr},qr={};Qr("",Or),Qr(Br,Dr),Qr(Vr,jr),Qr(Fr,""),Qr(Nr,"");const Wr=Qr(Rr,Lr),Hr=Pr;var Zr={background:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void 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 LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\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;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\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);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);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();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;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:Qr("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Qr('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nout 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);vec3 pos;\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;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=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:Qr("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Qr("in float v_placed;in 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);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in float a_size_scale;in vec2 a_padding;in float a_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;out float v_placed;out float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+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:Qr("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in 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);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out 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:Qr("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout 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:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin 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:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\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 LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;out highp 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:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nuniform float u_emissive_strength;in float v_height;void main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,u_emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);cutoff=max(0.01,cutoff_opacity(u_cutoff_params,ground.z));if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff < 0.01 && centroid_pos.x !=0.0));gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillExtrusionDepth:Qr("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\nbase*=u_vertical_scale;height*=u_vertical_scale;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;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\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);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\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);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nout vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\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=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:Qr('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0)).r);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:Qr("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(1.0,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:Qr("precision highp float;uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(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);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out 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:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\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=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\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);trimmed=0.0;}}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) { \nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trimmed,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin 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;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\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\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\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 scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),linePattern:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform mediump float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 v_uv;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float pattern_x=v_linesofar/pattern_size.x*aspect;float x=mod(pattern_x,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\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) {color=vec4(0,0,0,0);}}\n#endif\n#ifdef LINE_JOIN_NONE\nfloat pattern_len=pattern_size.x/aspect;float segment_phase=pattern_len-mod((v_linesofar-v_pattern_data.x),pattern_len);float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_ground(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 a_packed;\n#endif\nin float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin vec2 a_pattern_data;out vec2 v_pattern_data;\n#endif\nuniform mat4 u_matrix;uniform mediump float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec4 v_uv;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\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\n#pragma mapbox: initialize lowp float pixel_ratio\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\n#ifdef RENDER_LINE_TRIM_OFFSET\nfloat a_uv_x=a_packed[0];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef LINE_JOIN_NONE\nv_width+=ANTIALIASING;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5/u_tile_units_to_pixels;v_linesofar+=line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),raster:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 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 LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),0.0).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nuv=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:Qr("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin float a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(a_index,u_particle_texture_side_len),a_index/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-vec2(1.0),0.0,1.0);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:Qr("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in vec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*a_pos+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Qr('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp float speed=velocity==INVALID_VELOCITY ? 0.0 : length(velocity);highp float reset_rate_bump=speed*u_reset_rate;highp vec2 particle_pos_min=-u_particle_pos_offset;highp vec2 particle_pos_max=vec2(1.0)+u_particle_pos_offset;highp vec2 pos_drop_rate=vec2(1.0)-step(particle_pos_min,pos)+step(particle_pos_max,pos);highp float drop_rate=max(u_reset_rate+reset_rate_bump,length(pos_drop_rate));highp float drop=step(1.0-drop_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbolIcon:Qr('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nin float v_fade_opacity;in vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\nout_color*=alpha;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\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\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\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;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_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);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_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 TERRAIN\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\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;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 out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\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,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;}'),symbolSDF:Qr('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\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;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in 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 bool u_is_halo;\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\nout float v_draw_halo;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\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;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_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);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_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 TERRAIN\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\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;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));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\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,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:Qr('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_halo;in float v_draw_halo;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=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;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in 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;uniform bool u_is_halo;\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\nout float v_draw_halo;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\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;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_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 TERRAIN\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\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;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\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\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,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);\n#endif\n}'),terrainDepth:Qr("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:Qr('#include "_prelude_fog.fragment.glsl"\nin 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=texture(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);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',zr),skyboxGradient:Qr('#include "_prelude_fog.fragment.glsl"\nin 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=texture(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);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',zr),skyboxCapture:Qr("\nin 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;precision highp float;\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;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out 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:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;uniform float u_far_z_cutoff;in 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() {vec4 color;\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=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nraster=apply_lighting_with_emission_ground(raster,raster.a);color=vec4(raster.rgb*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor=apply_lighting_with_emission_ground(color,color.a);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:Qr('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_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) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));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\nhorizon_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;\n#ifdef ALPHA_PASS\nfloat 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);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 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=c2;\n#ifndef NATIVE\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\n#endif\nglFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in 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;out highp vec3 v_ray_dir;out 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);}"),model:Qr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture(u_depthTexture,coord));return v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nreturn vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));n=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);color=mix(color,v_color_mix.rgb,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=u_matrix*pos;pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normalize(normal_3f));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:Qr("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=u_matrix*pos;\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:Qr("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}")};function Yr(e,t){const n=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let r of n)if(r=r.trim(),"#"===r[0]&&r.includes("if")&&!r.includes("endif")){r=r.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const e=r.split(" ");for(const n of e)t.includes(n)||t.push(n)}}function Qr(e,t){const n=/#include\s+"([^"]+)"/g,r=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let i=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);i&&(i=i.map((e=>{const t=e.split(" ");return t[t.length-1]})),i=[...new Set(i)]);const o={},a=[],s=[];if(e=e.replace(n,((e,t)=>(s.push(t),""))),(t=t.replace(n,((e,t)=>(a.push(t),"")))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let l=[...Ur];Yr(e,l),Yr(t,l);for(const c of[...a,...s])Gr[c]||console.error("Undefined include: ".concat(c)),qr[c]||(qr[c]=[],Yr(Gr[c],qr[c])),l=[...l,...qr[c]];return{fragmentSource:e=e.replace(r,((e,t,n,r,i)=>(o[i]=!0,"define"===t?"\n#ifndef HAS_UNIFORM_u_".concat(i,"\nin ").concat(n," ").concat(r," ").concat(i,";\n#else\nuniform ").concat(n," ").concat(r," u_").concat(i,";\n#endif\n"):"initialize"===t?"\n#ifdef HAS_UNIFORM_u_".concat(i,"\n ").concat(n," ").concat(r," ").concat(i," = u_").concat(i,";\n#endif\n"):"define-attribute"===t?"\n#ifdef HAS_ATTRIBUTE_a_".concat(i,"\n in ").concat(n," ").concat(r," ").concat(i,";\n#endif\n"):"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(r,((e,t,n,r,i)=>{const a="float"===r?"vec2":r,s=i.match(/color/)?"color":a;return"define-attribute-vertex-shader-only"===t?"\n#ifdef HAS_ATTRIBUTE_a_".concat(i,"\nin ").concat(n," ").concat(r," a_").concat(i,";\n#endif\n"):o[i]?"define"===t?"\n#ifndef HAS_UNIFORM_u_".concat(i,"\nuniform lowp float u_").concat(i,"_t;\nin ").concat(n," ").concat(a," a_").concat(i,";\nout ").concat(n," ").concat(r," ").concat(i,";\n#else\nuniform ").concat(n," ").concat(r," u_").concat(i,";\n#endif\n"):"initialize"===t?"vec4"===s?"\n#ifndef HAS_UNIFORM_u_".concat(i,"\n ").concat(i," = a_").concat(i,";\n#else\n ").concat(n," ").concat(r," ").concat(i," = u_").concat(i,";\n#endif\n"):"\n#ifndef HAS_UNIFORM_u_".concat(i,"\n ").concat(i," = unpack_mix_").concat(s,"(a_").concat(i,", u_").concat(i,"_t);\n#else\n ").concat(n," ").concat(r," ").concat(i," = u_").concat(i,";\n#endif\n"):"define-attribute"===t?"\n#ifdef HAS_ATTRIBUTE_a_".concat(i,"\n in ").concat(n," ").concat(r," a_").concat(i,";\n out ").concat(n," ").concat(r," ").concat(i,";\n#endif\n"):"initialize-attribute"===t?"\n#ifdef HAS_ATTRIBUTE_a_".concat(i,"\n ").concat(i," = a_").concat(i,";\n#endif\n"):void 0:"define"===t?"\n#ifndef HAS_UNIFORM_u_".concat(i,"\nuniform lowp float u_").concat(i,"_t;\nin ").concat(n," ").concat(a," a_").concat(i,";\n#else\nuniform ").concat(n," ").concat(r," u_").concat(i,";\n#endif\n"):"define-instanced"===t?"mat4"===s?"\n#ifdef INSTANCED_ARRAYS\nin vec4 a_".concat(i,"0;\nin vec4 a_").concat(i,"1;\nin vec4 a_").concat(i,"2;\nin vec4 a_").concat(i,"3;\n#else\nuniform ").concat(n," ").concat(r," u_").concat(i,";\n#endif\n"):"\n#ifdef INSTANCED_ARRAYS\nin ".concat(n," ").concat(a," a_").concat(i,";\n#else\nuniform ").concat(n," ").concat(r," u_").concat(i,";\n#endif\n"):"initialize-attribute-custom"===t?"\n#ifdef HAS_ATTRIBUTE_a_".concat(i,"\n ").concat(n," ").concat(r," ").concat(i," = a_").concat(i,";\n#endif\n"):"vec4"===s?"\n#ifndef HAS_UNIFORM_u_".concat(i,"\n ").concat(n," ").concat(r," ").concat(i," = a_").concat(i,";\n#else\n ").concat(n," ").concat(r," ").concat(i," = u_").concat(i,";\n#endif\n"):"\n#ifndef HAS_UNIFORM_u_".concat(i,"\n ").concat(n," ").concat(r," ").concat(i," = unpack_mix_").concat(s,"(a_").concat(i,", u_").concat(i,"_t);\n#else\n ").concat(n," ").concat(r," ").concat(i," = u_").concat(i,";\n#endif\n")})),staticAttributes:i,usedDefines:l,vertexIncludes:a,fragmentIncludes:s}}class Xr{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,n,r,i,o,a,s){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let u=0;!l&&u{const o=r.paint.get("hillshade-shadow-color"),a=r.paint.get("hillshade-highlight-color"),s=r.paint.get("hillshade-accent-color"),l=r.paint.get("hillshade-emissive-strength");let c=e.bm(r.paint.get("hillshade-illumination-direction"));if("viewport"===r.paint.get("hillshade-illumination-anchor"))c-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const n=t.style.directionalLight.properties.get("direction"),r=e.bT(n.x,n.y,n.z);c=e.bm(r[1])}const u=!t.options.moving;return{u_matrix:i||t.transform.calculateProjMatrix(n.tileID.toUnwrapped(),u),u_image:0,u_latrange:Kr(0,n.tileID),u_light:[r.paint.get("hillshade-exaggeration"),c],u_shadow:o,u_highlight:a,u_emissive_strength:l,u_accent:s}})(t,r,i,t.terrain?n.projMatrix:null);t.uploadCommonUniforms(l,d,n.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=t.getTileBoundsBuffers(r);d.draw(t,c.TRIANGLES,o,a,s,Lt.disabled,f,i.id,p,m,g)}function $r(t,n,r){if(!n.needsDEMTextureUpload)return;const i=t.context,o=i.gl;i.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||t.getTileTexture(r.stride);const a=r.getPixels();n.demTexture?n.demTexture.update(a,{premultiply:!1}):n.demTexture=new e.T(i,a,o.R32F,{premultiply:!1}),n.needsDEMTextureUpload=!1}function ei(t,n,r){const i=t.context,o=i.gl;if(!n.dem)return;const a=n.dem;if(i.activeTexture.set(o.TEXTURE1),$r(t,n,a),!n.demTexture)return;n.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const s=a.dim;i.activeTexture.set(o.TEXTURE0);let l=n.hillshadeFBO;if(!l){const t=new e.T(i,{width:s,height:s,data:null},o.RGBA);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),l=n.hillshadeFBO=i.createFramebuffer(s,s,!0,"renderbuffer"),l.colorAttachment.set(t.texture)}i.bindFramebuffer.set(l.framebuffer),i.viewport.set([0,0,s,s]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:u,tileBoundsSegments:h}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,o.TRIANGLES,Et.disabled,Ct.disabled,It.unblended,Lt.disabled,((t,n)=>{const r=n.stride,i=e.a9.create();return e.a9.ortho(i,0,e.Y,-e.Y,0,0,1),e.a9.translate(i,i,[0,-e.Y,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ}})(n.tileID,a),r.id,c,u,h),n.needsHillshadePrepare=!1}const ti=t=>({u_matrix:new e.bN(t),u_image0:new e.bR(t),u_skirt_height:new e.bQ(t),u_ground_shadow_factor:new e.bP(t)}),ni=(e,t,n)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:n}),ri=(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:n,u_zoom_transition:i,u_merc_center:o,u_image0:0,u_frustum_tl:a,u_frustum_tr:s,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:f,u_far_z_cutoff:p});function ii(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const oi=new class{constructor(){this.operations={}}newMorphing(e,t,n,r,i){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==n.tileID.key&&(t.queued=n)}else this.operations[e]={startTime:r,phase:0,duration:i,from:t,to:n,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 n=this.operations[t];for(n.phase=(e-n.startTime)/n.duration;n.phase>=1||!this._validOp(n);)if(!this._nextOp(n,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()}},ai={0:null,1:"TERRAIN_VERTEX_MORPHING"};function si(e,t,n){if(0===t)return 0;const r=t<1&&514===n?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*r}function li(e,t){const n=1<({u_matrix:e});function ui(t,n,r,i,o){if(o>0){const a=e.f.now(),s=(a-t.timeAdded)/o,l=n?(a-n.timeAdded)/o:-1,c=r.getSource(),u=i.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!n||Math.abs(n.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),d=h&&t.refreshedUponExpiration?1:e.ad(h?s:1-l,0,1);return t.refreshedUponExpiration&&s>=1&&(t.refreshedUponExpiration=!1),n?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class hi extends Yt{constructor(t){const n={type:"raster-dem",maxzoom:t.transform.maxZoom},r=new e.bZ(e.b_(),null),i=Vt("mock-dem",n,r,t.style);super("mock-dem",i,!1),i.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class di extends Yt{constructor(t){const n=Vt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.bZ(e.b_(),null),t.style);super("proxy",n,!1),n.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,t,n){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,n)=>{if(t[n.key]="",!this._tiles[n.key]){const t=new Nt(n,this._source.tileSize*n.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[n.key]=t}return t}),{});for(const i in this._tiles)i in r||(this.freeFBO(i),this._tiles[i].unloadVectorData(),delete this._tiles[i])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const n=Object.values(t);this.renderCachePool.push(...n),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class fi extends e.ap{constructor(e,t,n){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=n}}class pi extends e.cp{constructor(t,n){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},(()=>{this._style.map.triggerRepaint()})),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},(()=>{this._style.map.triggerRepaint()})),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",(()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()})),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,i,o]=function(t){const n=new e.aQ,r=new e.az,i=131;n.reserve(17161),r.reserve(33800);const o=e.Y/128,a=e.Y+o/2,s=a+o;for(let c=-o;ca||c<0||c>a?24575:0,i=e.ad(Math.round(t),0,e.Y),o=e.ad(Math.round(c),0,e.Y);n.emplaceBack(i+r,o)}const l=(e,t)=>{const n=t*i+e;r.emplaceBack(n+1,n,n+i),r.emplaceBack(n+i,n+i+1,n+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)})),[n,r,32768]}(),a=t.context;this.gridBuffer=a.createVertexBuffer(r,e.aS.members),this.gridIndexBuffer=a.createIndexBuffer(i),this.gridSegments=e.aE.simpleSegment(0,0,r.length,i.length),this.gridNoSkirtSegments=e.aE.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new di(n.map),this.orthoMatrix=e.a9.create(),e.a9.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.Y,0,e.Y,0,1);const s=a.gl;this._overlapStencilMode=new Ct({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=n,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new hi(n.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache()}))}update(t,n,r){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const i=t.terrain.properties,o=0===t.terrain.drapeRenderMode,a=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.f.now();const s=t.terrain&&t.terrain.scope,l=i.get("source"),c=o?this._mockSourceCache:t.getSourceCache(l,s);if(!c)return void e.w("Couldn't find terrain source \"".concat(l,'".'));if(this.sourceCache=c,this._exaggeration=a?this.calculateExaggeration(n):i.get("exaggeration"),!n.projection.requiresDraping&&a&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{this.sourceCache.used&&e.w("Raster DEM source '".concat(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(n,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,u(),this._initializing=!0),u(),n.updateElevation(!0,r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(n),this._emptyDEMTextureDirty=!0,this._previousZoom=n.zoom}else this._disable()}calculateExaggeration(t){const n=this._previousCameraAltitude,r=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=r;const i=null!=n?r-n:Number.MAX_VALUE;if(Math.abs(i)<2)return this._exaggeration;const o=t.zoom,a=this._style.terrain;if(!this._previousUpdateTimestamp)return a.getExaggeration(o);let s=o-this._previousZoom;const l=this._previousUpdateTimestamp;let c=o;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(o-c)>.5&&(s=.5*(o-c+s)),s*i<0&&(c+=s)),this._evaluationZoom=c;const u=a.getExaggeration(c),h=u===a.getExaggeration(Math.max(0,c-.1));if(h&&Math.abs(u-this._exaggeration)<.01)return u;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||u<.1||Math.abs(s)<1e-4)&&(d=Math.min(.2,4*d)),e.X(this._exaggeration,u,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[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),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const 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 n=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(e.O.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const i=this.proxyCoords=n.getIds().map((e=>{const t=n.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,n){const r=n.transform.pointCoordinate(n.transform.getCameraPoint()),i=new e.P(r.x,r.y);t.sort(((t,n)=>{if(n.overscaledZ-t.overscaledZ)return n.overscaledZ-t.overscaledZ;const r=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const a=this._style._mergedSourceCaches;for(const e in a){const n=a[e];if(!n.used)continue;if(n!==this.sourceCache&&this.resetTileLookupCache(n.id),this._setupProxiedCoordsForOrtho(n,t[e],o),n.usedForTerrain)continue;const r=t[e];n.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[n.id]=i.map((e=>new fi(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(i),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1;const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const n=t.tileID.key;n in s||(this._visibleDemTiles.push(t),s[n]=n)}}_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 n in this.terrainTileForTile){const r=this.terrainTileForTile[n],i=r.dem;!i||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),$r(this.painter,r,i))}}_prepareDemTileUniforms(e,t,n,r){if(!t||null==t.demTexture)return!1;const i=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-i.z),a=r||"";return n["u_dem_tl".concat(a)]=[i.x*o%1,i.y*o%1],n["u_dem_scale".concat(a)]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,n=t.gl;if(!this._emptyDepthBufferTexture){const r=new e.h({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.T(t,r,n.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,n)=>{if(!n.dem)return t;const r=n.dem.tree.minimums[0];return r>0&&e++,t+r}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,n=t.gl;t.activeTexture.set(n.TEXTURE2);const r=this._getLoadedAreaMinimum(),[i,o]=(()=>{const t=new e.cr({width:1,height:1},new Float32Array([r]));return[n.R32F,t]})();this._emptyDEMTextureDirty=!1;let a=this._emptyDEMTexture;return a?a.update(o,{premultiply:!1}):a=this._emptyDEMTexture=new e.T(t,o,i,{premultiply:!1}),a}setupElevationDraw(t,n,r){const i=this.painter.context,o=i.gl,a={u_dem:2,u_dem_prev:4,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};a.u_exaggeration=this.exaggeration();let s=null,l=null,c=1;if(r&&r.morphing&&this._useVertexMorphing){const e=r.morphing.srcDemTile,n=r.morphing.dstDemTile;c=r.morphing.phase,e&&n&&(this._prepareDemTileUniforms(t,e,a,"_prev")&&(l=e),this._prepareDemTileUniforms(t,n,a)&&(s=n))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST,h=e=>{a.u_dem_size=1===e.size[0]?1:e.size[0]-2};if(l&&s)i.activeTexture.set(o.TEXTURE2),s.demTexture.bind(u(s),o.CLAMP_TO_EDGE),i.activeTexture.set(o.TEXTURE4),l.demTexture.bind(u(l),o.CLAMP_TO_EDGE),s.demTexture&&h(s.demTexture),a.u_dem_lerp=c;else{s=this.terrainTileForTile[t.tileID.key],i.activeTexture.set(o.TEXTURE2);const e=this._prepareDemTileUniforms(t,s,a)?s.demTexture:this.emptyDEMTexture;e.bind(u(s),o.CLAMP_TO_EDGE),h(e)}if(i.activeTexture.set(o.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(a.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),a.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&s){const t=(1<{if(c===n)return;const r=[ai[n],"PROJECTION_GLOBE_VIEW"];h&&r.push("CUSTOM_ANTIALIASING");const i=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:r,overrideFog:i}),c=n},f=t.colorModeForRenderPass(),p=new Et(s.LEQUAL,Et.ReadWrite,t.depthRangeFor3D);oi.update(o);const m=e.cj(u),g=[e.a8(u.center.lng),e.ah(u.center.lat)],_=t.globeSharedBuffers,y=[u.width*e.f.devicePixelRatio,u.height*e.f.devicePixelRatio],v=Float32Array.from(u.globeMatrix),x={useDenormalizedUpVectorScale:!0};{const u=t.transform,h=si(u.zoom,n.exaggeration(),n.sourceCache._source.tileSize);c=-1;const b=s.TRIANGLES;for(const c of i){const i=r.getTile(c),w=Ct.disabled,S=n.prevTerrainTileForTile[c.key],M=n.terrainTileForTile[c.key];ii(S,M)&&oi.newMorphing(c.key,S,M,o,250),a.activeTexture.set(s.TEXTURE0),i.texture&&i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const A=oi.getMorphValuesForProxy(c.key),E=A?1:0;A&&e.k(x,{morphing:{srcDemTile:A.from,dstDemTile:A.to,phase:e.ch(A.phase)}});const T=e.ck(c.canonical),C=e.cl(T.getCenter().lat),k=e.cm(c.canonical,T,C,u.worldSize/u._pixelsPerMercatorPixel),I=e.aW(e.cn(c.canonical)),P=ri(u.expandedFarZProjMatrix,v,m,I,e.W(u.zoom),g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,y,h,u._farZ,k);if(d(c,E),l&&(n.setupElevationDraw(i,l,x),t.uploadCommonUniforms(a,l,c.toUnwrapped()),_)){const[e,n,r]=_.getGridBuffers(C,0!==h);l.draw(t,b,p,w,f,Lt.backCCW,P,"globe_raster",e,n,r)}}}if(_&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const c of i){const{x:i,y:o,z:h}=c.canonical,d=0===o,m=o===(1<e.draw(t,s.TRIANGLES,p,Ct.disabled,f,Lt.disabled,ri(u.expandedFarZProjMatrix,_,_,M,0,g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,y,0,u._farZ),"globe_pole_raster",n,w,S);n.setupElevationDraw(o,l,x),t.uploadCommonUniforms(a,l,c.toUnwrapped()),d&&t.renderDefaultNorthPole&&A(l,v),m&&t.renderDefaultSouthPole&&(_=e.a9.scale(e.a9.create(),_,[1,-1,1]),A(l,b))}}}}(t,n,r,i,o);else{const a=t.context,s=a.gl;let l,c;const u=t.shadowRenderer,h=gr(t,t.longestCutoffRange),d=e=>{if(c===e)return;const n=[];n.push(ai[e]),h.shouldRenderCutoff&&n.push("RENDER_CUTOFF"),l=t.getOrCreateProgram("terrainRaster",{defines:n}),c=e},f=t.colorModeForRenderPass(),p=new Et(s.LEQUAL,Et.ReadWrite,t.depthRangeFor3D);oi.update(o);const m=t.transform,g=si(m.zoom,n.exaggeration(),n.sourceCache._source.tileSize);let _=[0,0,0];if(u){const e=t.style.directionalLight,n=t.style.ambientLight;e&&n&&(_=Sr(e,n))}{c=-1;const y=s.TRIANGLES,[v,x]=[n.gridIndexBuffer,n.gridSegments];for(const c of i){const i=r.getTile(c),b=Ct.disabled,w=n.prevTerrainTileForTile[c.key],S=n.terrainTileForTile[c.key];ii(w,S)&&oi.newMorphing(c.key,w,S,o,250),a.activeTexture.set(s.TEXTURE0),i.texture&&i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const M=oi.getMorphValuesForProxy(c.key),A=M?1:0;let E;M&&(E={morphing:{srcDemTile:M.from,dstDemTile:M.to,phase:e.ch(M.phase)}});const T=ni(c.projMatrix,li(c.canonical,m.renderWorldCopies)?g/10:g,_);if(d(A),!l)continue;n.setupElevationDraw(i,l,E);const C=c.toUnwrapped();u&&u.setupShadows(C,l),t.uploadCommonUniforms(a,l,C,null,h),l.draw(t,y,p,b,f,Lt.backCCW,T,"terrain_raster",n.gridBuffer,v,x)}}}}(n,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,n.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const n=this.painter,r=this.painter.context,i=this.proxySourceCache,o=this.proxiedCoords[i.id],a=this._drapedRenderBatches.shift(),s=n.style.order,l=[];let c=0;for(const u of o){const o=i.getTileByID(u.proxyTileKey),h=i.proxyCachedFBO[u.key]?i.proxyCachedFBO[u.key][t]:void 0,d=void 0!==h?i.renderCache[h]:this.pool[c++],f=void 0!==h;if(o.texture=d.tex,f&&!d.dirty){l.push(o.tileID);continue}let p;r.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(r.clear({color:e.aA.transparent,stencil:0}),d.dirty=!1);for(let e=a.start;e<=a.end;++e){const t=n.style._mergedLayers[s[e]];if(t.isHidden(n.transform.zoom))continue;const i=n.style.getLayerSourceCache(t),o=i?this.proxyToSource[u.key][i.id]:[u];if(!o)continue;const a=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(i?i.id:null)&&(this._setupStencil(d,o,t,i),p=i?i.id:null),n.renderLayer(n,i,t,a)}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=n.style._mergedLayers[s[e]];if(t.isHidden(n.transform.zoom))continue;const i=n.style.getLayerSourceCache(t),o=i?this.proxyToSource[u.key][i.id]:[u];if(!o)continue;const a=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(i?i.id:null)&&(this._setupStencil(d,o,t,i),p=i?i.id:null),n.renderLayer(n,i,t,a)}this.renderedToTile?(d.dirty=!0,l.push(o.tileID)):f||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,n.width,n.height]),a.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let n=-1,r=t;for(let i=0;in}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,n){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((e=>e.dem)).map((r=>{const i=r.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const i of r){if(null==i.t)return null;const r=i.tile.dem.tree.raycast(i.minx,i.miny,i.maxx,i.maxy,e,t,n);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,n=t.gl,r=this.drapeBufferSize;t.activeTexture.set(n.TEXTURE0);const i=new e.T(t,{width:r[0],height:r[1],data:null},n.RGBA);i.bind(n.LINEAR,n.CLAMP_TO_EDGE);const o=t.createFramebuffer(r[0],r[1],!0,null);return o.colorAttachment.set(i.texture),o.depthAttachment=new Mt(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&n.texParameterf(n.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:i,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],n=t.isHidden(this.painter.transform.zoom);return"custom"===t.type?!n&&t.shouldRedrape():!n&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof ke){t=!0;break}if(!t)return;const n={};for(let r=0;re>t.end))||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}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 n=0;n=0;o--){const i=n[o];if(t.getTileByID(i.key),void 0!==t.proxyCachedFBO[i.key]){const n=e[i.key],o=this.proxyToSource[i.key];let a=0;for(const e in o){const t=o[e],i=n[e];if(!i||i.length!==t.length||t.some(((t,n)=>t!==i[n]||r[e]&&r[e].hasOwnProperty(t.key)))){a=-1;break}++a}for(const e in t.proxyCachedFBO[i.key])t.renderCache[t.proxyCachedFBO[i.key][e]].dirty=a<0||a!==Object.values(n).length}}const i=[...this._drapedRenderBatches];i.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const o of i)for(const e of n){if(t.proxyCachedFBO[e.key])continue;let n=t.renderCachePool.pop();void 0===n&&t.renderCache.length<50&&(n=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==n&&(t.proxyCachedFBO[e.key]={},t.proxyCachedFBO[e.key][o.start]=n,t.renderCache[n].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,n,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const i=this.painter.context,o=i.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let a;if(n.isTileClipped())a=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);a=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+a>255&&(i.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=a,this._overlapStencilMode.ref=this._stencilRef,n.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):Ct.disabled}_renderTileClippingMasks(e,t){const n=this.painter,r=this.painter.context,i=r.gl;n._tileClippingMaskIDs={},r.setColorMode(It.disabled),r.setDepthMode(Et.disabled);const o=n.getOrCreateProgram("clippingMask");for(const a of e){const e=n._tileClippingMaskIDs[a.key]=--t;o.draw(n,i.TRIANGLES,Et.disabled,new Ct({func:i.ALWAYS,mask:0},e,255,i.KEEP,i.KEEP,i.REPLACE),It.disabled,Lt.disabled,ci(a.projMatrix),"$clipping",n.tileExtentBuffer,n.quadTriangleIndexBuffer,n.tileExtentSegments)}}pointCoordinate(t){const n=this.painter.transform;if(t.x<0||t.x>n.width||t.y<0||t.y>n.height)return null;const r=[t.x,t.y,1,1];e.aa.transformMat4(r,r,n.pixelMatrixInverse),e.aa.scale(r,r,1/r[3]),r[0]/=n.worldSize,r[1]/=n.worldSize;const i=n._camera.position,o=e.bo(1,n.center.lat),a=[i[0],i[1],i[2]/o,0],s=e.Q.subtract([],r.slice(0,3),a);e.Q.normalize(s,s);const l=this.raycast(a,s,this._exaggeration);return null!==l&&l?(e.Q.scaleAndAdd(a,a,s,l),a[3]=a[2],a[2]*=o,a):null}drawDepth(){const t=this.painter,n=t.context,r=this.proxySourceCache,i=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===i&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=n.gl,r=n.createFramebuffer(i,o,!0,"renderbuffer");n.activeTexture.set(t.TEXTURE0);const a=new e.T(n,{width:i,height:o,data:null},t.RGBA);a.bind(t.NEAREST,t.CLAMP_TO_EDGE),r.colorAttachment.set(a.texture);const s=n.createRenderbuffer(n.gl.DEPTH_COMPONENT16,i,o);r.depthAttachment.set(s),this._depthFBO=r,this._depthTexture=a}n.bindFramebuffer.set(this._depthFBO.framebuffer),n.viewport.set([0,0,i,o]),function(e,t,n,r){if("globe"===e.transform.projection.name)return;const i=e.context,o=i.gl;i.clear({depth:1});const a=e.getOrCreateProgram("terrainDepth"),s=new Et(o.LESS,Et.ReadWrite,e.depthRangeFor3D);for(const l of r){const r=n.getTile(l),i=ni(l.projMatrix,0,[0,0,0]);t.setupElevationDraw(r,a),a.draw(e,o.TRIANGLES,s,Ct.disabled,It.unblended,Lt.backCCW,i,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments)}}(t,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,n,r){if(t.getSource()instanceof e.as)return this._setupProxiedCoordsForImageSource(t,n,r);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const i=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ))}_setupProxiedCoordsForImageSource(t,n,r){if(!t.getSource().loaded())return;const i=this.proxiedCoords[t.id]=[],o=this.proxyCoords,a=t.getSource(),s=a.tileID;if(!s)return;const l=new e.P(s.x,s.y)._div(1<(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e)),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,n)=>{const r=t.wrap+t.canonical.x/(1<a+c.max.x||i+os+c.max.y};for(let e=0;ee.key===n.tileID.key));if(e)return e}if(n.tileID.key!==t.key){const r=t.canonical.z-n.tileID.canonical.z;let o,a,s;i=e.a9.create();const l=n.tileID.wrap-t.wrap<0?(o=e.Y>>r,a=o*((n.tileID.canonical.x<=i){const r=t.canonical.z-i;n.getSource().reparseOverscaled?(s=Math.max(t.canonical.z+2,n.transform.tileZoom),a=new e.ap(s,t.wrap,i,t.canonical.x>>r,t.canonical.y>>r)):0!==r&&(s=i,a=new e.ap(s,t.wrap,i,t.canonical.x>>r,t.canonical.y>>r))}a.key!==t.key&&(c.push(a.key),r=n.getTile(a))}const u=e=>{c.forEach((t=>{i[t]=e})),c.length=0};for(s-=1;s>=l&&(!r||!r.hasData());s--){r&&u(r.tileID.key);const e=a.calculateScaledKey(s);if(r=n.getTileByID(e),r&&r.hasData())break;const t=i[e];if(null===t)break;void 0===t?c.push(e):r=n.getTileByID(t)}return u(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let n=this._tilesDirty[e];n||(n=this._tilesDirty[e]={}),n[t.key]=!0}}function mi(t,n,r){const i=function(t,n,r){const i=e.Q.dot(n,t),o=e.Q.dot(r,[.2126,.7152,.0722]),a=(e,t,n)=>(1-n)*e+n*t,s=a(1-.3*Math.min(o,1),1,Math.min(i+1,1));return a(.92,1,Math.asin(e.ad(n[2],-1,1))/Math.PI+.5)*s}(t,[0,0,1],n),o=[0,0,0];e.Q.scale(o,r.slice(0,3),i);const a=[0,0,0];e.Q.scale(a,n.slice(0,3),t[2]);const s=[0,0,0];return e.Q.add(s,o,a),e.bX(s)}const gi=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],_i=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class yi{static cacheKey(e,t,n,r){let i="".concat(t).concat(r?r.cacheKey:"");for(const o of n)e.usedDefines.includes(o)&&(i+="/".concat(o));return i}constructor(t,n,r,i,o,a){const s=t.gl;this.program=s.createProgram(),this.configuration=i,this.name=n,this.fixedDefines=[...a];const l=i?i.getBinderAttributes():[],c=(r.staticAttributes||[]).concat(l);let u=i?i.defines():[];u=u.concat(a.map((e=>"#define ".concat(e))));const h="#version 300 es\n";let d=h+u.concat("precision mediump float;",Hr,Wr.fragmentSource).join("\n");for(const e of r.fragmentIncludes)d+="\n".concat(Gr[e]);d+="\n".concat(r.fragmentSource);let f=h+u.concat("precision highp float;",Hr,Wr.vertexSource).join("\n");for(const e of r.vertexIncludes)f+="\n".concat(Gr[e]);f+="\n".concat(r.vertexSource);const p=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(p,d),s.compileShader(p),s.attachShader(this.program,p);const m=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())this.failedToCreate=!0;else{s.shaderSource(m,f),s.compileShader(m),s.attachShader(this.program,m),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new e.bR(t),u_dem_prev:new e.bR(t),u_dem_tl:new e.bO(t),u_dem_scale:new e.bQ(t),u_dem_tl_prev:new e.bO(t),u_dem_scale_prev:new e.bQ(t),u_dem_size:new e.bQ(t),u_dem_lerp:new e.bQ(t),u_exaggeration:new e.bQ(t),u_depth:new e.bR(t),u_depth_size_inv:new e.bO(t),u_meter_to_dem:new e.bQ(t),u_label_plane_matrix_inv:new e.bN(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.bP(t),u_tile_tr_up:new e.bP(t),u_tile_br_up:new e.bP(t),u_tile_bl_up:new e.bP(t),u_tile_up_scale:new e.bQ(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.bN(t),u_fog_range:new e.bO(t),u_fog_color:new e.bS(t),u_fog_horizon_blend:new e.bQ(t),u_fog_vertical_limit:new e.bO(t),u_fog_temporal_offset:new e.bQ(t),u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_globe_pos:new e.bP(t),u_globe_radius:new e.bQ(t),u_globe_transition:new e.bQ(t),u_is_globe:new e.bR(t),u_viewport:new e.bO(t)}))(t)),a.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.bS(t)}))(t)),a.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.bP(t),u_lighting_directional_dir:new e.bP(t),u_lighting_directional_color:new e.bP(t),u_ground_radiance:new e.bP(t)}))(t)),a.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.bN(t),u_light_matrix_1:new e.bN(t),u_fade_range:new e.bO(t),u_shadow_normal_offset:new e.bP(t),u_shadow_intensity:new e.bQ(t),u_shadow_texel_size:new e.bQ(t),u_shadow_map_resolution:new e.bQ(t),u_shadow_direction:new e.bP(t),u_shadow_bias:new e.bP(t),u_shadowmap_0:new e.bR(t),u_shadowmap_1:new e.bR(t)}))(t))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const n=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const n=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const n=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const n=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const n=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const n=this.shadowUniforms;e.program.set(this.program);for(const r in t)n[r].set(this.program,r,t[r])}_drawDebugWireframe(t,n,r,i,o,a,s,l,c,u){const h=t.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const d=t.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||t._terrain&&t._terrain.renderingToTexture||!gi.includes(this.name))||!(!h.layers3D||!_i.includes(this.name)))())return;const f=d.gl,p=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,d);if(!p)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const g=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(g.program);const _=(e,t,n)=>{if(t[e]&&n[e])for(const r in t[e])n[e][r]&&n[e][r].set(n.program,r,t[e][r].current)};c&&c.setUniforms(g.program,d,g.binderUniforms,s,{zoom:l}),_("fixedUniforms",this,g),_("terrainUniforms",this,g),_("globeUniforms",this,g),_("fogUniforms",this,g),_("lightsUniforms",this,g),_("shadowUniforms",this,g),p.bind(),d.setColorMode(new It([f.ONE,f.ONE_MINUS_SRC_ALPHA,f.ZERO,f.ONE],e.aA.transparent,[!0,!0,!0,!1])),d.setDepthMode(new Et(n.func===f.LESS?f.LEQUAL:n.func,Et.ReadOnly,n.range)),d.setStencilMode(Ct.disabled);const y=3*a.primitiveLength*2,v=3*a.primitiveOffset*2*2;u&&u>1?f.drawElementsInstanced(f.LINES,y,f.UNSIGNED_SHORT,v,u):f.drawElements(f.LINES,y,f.UNSIGNED_SHORT,v),o.bind(),d.program.set(this.program),d.setDepthMode(n),d.setStencilMode(r),d.setColorMode(i)}draw(e,t,n,r,i,o,a,s,l,c,u,h,d,f,p,m){const g=e.context,_=g.gl;if(this.failedToCreate)return;g.program.set(this.program),g.setDepthMode(n),g.setStencilMode(r),g.setColorMode(i),g.setCullFace(o);for(const x of Object.keys(this.fixedUniforms))this.fixedUniforms[x].set(this.program,x,a[x]);f&&f.setUniforms(this.program,g,this.binderUniforms,h,{zoom:d});const y={[_.POINTS]:1,[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[t],v=m&&m>0?1:void 0;for(const x of u.get()){const o=x.vaos||(x.vaos={});(o[s]||(o[s]=new Xr)).bind(g,this,l,f?f.getPaintVertexBuffers():[],c,x.vertexOffset,p||[],v),m&&m>1?_.drawElementsInstanced(t,x.primitiveLength*y,_.UNSIGNED_SHORT,x.primitiveOffset*y*2,m):c?_.drawElements(t,x.primitiveLength*y,_.UNSIGNED_SHORT,x.primitiveOffset*y*2):_.drawArrays(t,x.vertexOffset,x.vertexLength),t===_.TRIANGLES&&c&&this._drawDebugWireframe(e,n,r,i,c,x,h,d,f,m)}}}function vi(t,n){const r=Math.pow(2,n.tileID.overscaledZ),i=n.tileSize*Math.pow(2,t.transform.tileZoom)/r,o=i*(n.tileID.canonical.x+n.tileID.wrap*r),a=i*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.a6(n,1,t.transform.tileZoom),u_pixel_coord_upper:[o>>16,a>>16],u_pixel_coord_lower:[65535&o,65535&a]}}const xi=e.a9.create(),bi=(t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g)=>{const _=n.style.light,y=_.properties.get("position"),v=[y.x,y.y,y.z],x=e.ct.create();"viewport"===_.properties.get("anchor")&&(e.ct.fromRotation(x,-n.transform.angle),e.Q.transformMat3(v,v,x));const b=_.properties.get("color"),w=n.transform,S={u_matrix:t,u_lightpos:v,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+r,u_opacity:i,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:xi,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:a,u_flood_light_color:d,u_vertical_scale:f,u_flood_light_intensity:p,u_ground_shadow_factor:m,u_emissive_strength:g};return"globe"===w.projection.name&&(S.u_tile_id=[s.canonical.x,s.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_vertical_scale:n}),Si=(t,n,r,i,o,a,s,l,c,u,h,d,f,p)=>{const m=bi(t,n,r,i,o,a,s,c,u,h,d,f,p,1,[0,0,0],0),g={u_height_factor:-Math.pow(2,s.overscaledZ)/l.tileSize/8};return e.e(m,vi(n,l),g)},Mi=(e,t)=>({u_matrix:e,u_emissive_strength:t}),Ai=(t,n,r,i)=>e.e(Mi(t,n),vi(r,i)),Ei=(e,t,n)=>({u_matrix:e,u_world:n,u_emissive_strength:t}),Ti=(t,n,r,i,o)=>e.e(Ai(t,n,r,i),{u_world:o}),Ci=(t,n,r,i)=>{const o=e.Y/r.tileSize;return{u_matrix:t,u_camera_to_center_distance:n.getCameraToCenterDistance(i),u_extrude_scale:[n.pixelsToGLUnits[0]/o,n.pixelsToGLUnits[1]/o]}},ki=function(e,t){return{u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:arguments.length>2&&void 0!==arguments[2]?arguments[2]:1}},Ii=e.a9.create(),Pi=(t,n,r,i,o,a,s)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.cu(l.zoom,n.canonical)*l._pixelsPerMercatorPixel:e.a6(r,1,a),h={u_matrix:n.projMatrix,u_extrude_scale:u,u_intensity:s,u_inv_rot_matrix:Ii,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=i,h.u_merc_center=o,h.u_tile_id=[n.canonical.x,n.canonical.y,1<({u_matrix:t,u_normalize_matrix:n,u_globe_matrix:r,u_merc_matrix:i,u_grid_matrix:o,u_tl_parent:a,u_scale_parent:u,u_fade_t:h.mix,u_opacity:h.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:e.cv(d.paint.get("raster-saturation")),u_contrast_factor:e.cw(d.paint.get("raster-contrast")),u_spin_weights:Oi(d.paint.get("raster-hue-rotate")),u_perspective_transform:f,u_raster_elevation:p,u_zoom_transition:s,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:Ri(e.cx,g,y),u_colorization_offset:Li(e.cx,_,y),u_color_ramp:m,u_texture_offset:[x/(v+2*x),v/(v+2*x)],u_texture_res:[v+2*x,v+2*x],u_emissive_strength:b});function Oi(e){e*=Math.PI/180;const t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const Di=(e,t,n,r,i,o,a,s,l,c,u,h)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:n,u_merc_matrix:r,u_grid_matrix:i,u_tl_parent:o,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity,u_image0:0,u_image1:1,u_raster_elevation:h,u_zoom_transition:a,u_merc_center:s,u_cutoff_params:l}),Bi=(e,t,n,r,i,o,a,s,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:n,u_velocity:r,u_color_ramp:o,u_velocity_res:i,u_max_speed:a,u_uv_offset:s,u_data_scale:l,u_data_offset:c,u_particle_pos_scale:1.3,u_particle_pos_offset:[Dt,Dt]}),Fi=(e,t,n,r,i,o,a,s,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:n,u_velocity_res:r,u_max_speed:i,u_speed_factor:o,u_reset_rate:a,u_rand_seed:Math.random(),u_uv_offset:s,u_data_scale:l,u_data_offset:c,u_particle_pos_scale:1.3,u_particle_pos_offset:[Dt,Dt]}),Ni=e.a9.create(),ji=(t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y)=>{const v=o.transform,x={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:v.getCameraToCenterDistance(g),u_rotate_symbol:+r,u_aspect_ratio:v.width/v.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:s,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+i,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Ni,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Ni,u_up_vector:[0,-1,0],u_color_adj_mat:_,u_icon_transition:y||0};return"globe"===g.name&&(x.u_tile_id=[h.canonical.x,h.canonical.y,1<e.e(ji(t,n,r,i,o,a,s,l,c,u,d,f,p,m,g,_),{u_gamma_scale:i?o.transform.getCameraToCenterDistance(_)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.f.devicePixelRatio,u_is_halo:+h,undefined:void 0}),Ui=(t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g)=>e.e(Vi(t,n,r,i,o,a,s,l,!0,c,!0,h,d,f,p,m,g),{u_texsize_icon:u,u_texture_icon:1}),Gi=(e,t,n,r)=>({u_matrix:e,u_emissive_strength:t,u_opacity:n,u_color:r}),qi=(t,n,r,i,o,a,s)=>e.e(function(t,n,r,i){const o=r.imageManager.getPattern(t.toString(),n),{width:a,height:s}=r.imageManager.getPixelSize(n),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:o.tl,u_pattern_br:o.br,u_texsize:[a,s],u_pattern_size:o.displaySize,u_tile_units_to_pixels:1/e.a6(i,1,r.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(o,a,i,s),{u_matrix:t,u_emissive_strength:n,u_opacity:r}),Wi=new Float32Array(e.a9.identity([])),Hi=function(t,n,r,i,o,a,s,l,c,u,h,d,f){let p=arguments.length>13&&void 0!==arguments[13]?arguments[13]:[0,0,0],m=arguments.length>14?arguments[14]:void 0;const g=o.style.light,_=g.properties.get("position"),y=[-_.x,-_.y,_.z],v=e.ct.create();"viewport"===g.properties.get("anchor")&&(e.ct.fromRotation(v,-o.transform.angle),e.Q.transformMat3(y,y,v));const x="MASK"===h.alphaMode,b=g.properties.get("color"),w=f.paint.get("model-ambient-occlusion-intensity"),S=f.paint.get("model-color").constantOr(e.aA.white),M=f.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:t,u_lighting_matrix:n,u_normal_matrix:r,u_node_matrix:i||Wi,u_lightpos:y,u_lightintensity:g.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_camera_pos:p,u_opacity:a,u_baseTextureIsAlpha:0,u_alphaMask:+x,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:[s.r,s.g,s.b,s.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:c,u_roughnessFactor:u,u_baseColorTexture:mr.BaseColor,u_metallicRoughnessTexture:mr.MetallicRoughness,u_normalTexture:mr.Normal,u_occlusionTexture:mr.Occlusion,u_emissionTexture:mr.Emission,u_color_mix:[S.r,S.g,S.b,M],u_aoIntensity:w,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},Zi=function(e){return{u_matrix:e,u_instance:arguments.length>1&&void 0!==arguments[1]?arguments[1]:Wi,u_node_matrix:arguments.length>2&&void 0!==arguments[2]?arguments[2]:Wi}},Yi={fillExtrusion:t=>({u_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_vertical_gradient:new e.bQ(t),u_opacity:new e.bQ(t),u_edge_radius:new e.bQ(t),u_ao:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_up_dir:new e.bP(t),u_height_lift:new e.bQ(t),u_flood_light_color:new e.bP(t),u_vertical_scale:new e.bQ(t),u_flood_light_intensity:new e.bQ(t),u_ground_shadow_factor:new e.bP(t),u_emissive_strength:new e.bQ(t)}),fillExtrusionDepth:t=>({u_matrix:new e.bN(t),u_edge_radius:new e.bQ(t),u_vertical_scale:new e.bQ(t)}),fillExtrusionPattern:t=>({u_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_vertical_gradient:new e.bQ(t),u_height_factor:new e.bQ(t),u_edge_radius:new e.bQ(t),u_ao:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_up_dir:new e.bP(t),u_height_lift:new e.bQ(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t),u_opacity:new e.bQ(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.bN(t),u_opacity:new e.bQ(t),u_ao_pass:new e.bQ(t),u_meter_to_tile:new e.bQ(t),u_ao:new e.bO(t),u_flood_light_intensity:new e.bQ(t),u_flood_light_color:new e.bP(t),u_attenuation:new e.bQ(t),u_edge_radius:new e.bQ(t),u_fb:new e.bR(t),u_fb_size:new e.bQ(t)}),fill:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t)}),fillPattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),fillOutline:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_world:new e.bO(t)}),fillOutlinePattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_world:new e.bO(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),circle:e.cz,collisionBox:t=>({u_matrix:new e.bN(t),u_camera_to_center_distance:new e.bQ(t),u_extrude_scale:new e.bO(t)}),collisionCircle:t=>({u_matrix:new e.bN(t),u_inv_matrix:new e.bN(t),u_camera_to_center_distance:new e.bQ(t),u_viewport_size:new e.bO(t)}),debug:t=>({u_color:new e.cf(t),u_matrix:new e.bN(t),u_overlay:new e.bR(t),u_overlay_scale:new e.bQ(t)}),clippingMask:t=>({u_matrix:new e.bN(t)}),heatmap:t=>({u_extrude_scale:new e.bQ(t),u_intensity:new e.bQ(t),u_matrix:new e.bN(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_up_dir:new e.bP(t)}),heatmapTexture:t=>({u_image:new e.bR(t),u_color_ramp:new e.bR(t),u_opacity:new e.bQ(t)}),hillshade:t=>({u_matrix:new e.bN(t),u_image:new e.bR(t),u_latrange:new e.bO(t),u_light:new e.bO(t),u_shadow:new e.cf(t),u_highlight:new e.cf(t),u_emissive_strength:new e.bQ(t),u_accent:new e.cf(t)}),hillshadePrepare:t=>({u_matrix:new e.bN(t),u_image:new e.bR(t),u_dimension:new e.bO(t),u_zoom:new e.bQ(t)}),line:e.cA,linePattern:e.cB,raster:t=>({u_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_grid_matrix:new e.cg(t),u_tl_parent:new e.bO(t),u_scale_parent:new e.bQ(t),u_fade_t:new e.bQ(t),u_opacity:new e.bQ(t),u_image0:new e.bR(t),u_image1:new e.bR(t),u_brightness_low:new e.bQ(t),u_brightness_high:new e.bQ(t),u_saturation_factor:new e.bQ(t),u_contrast_factor:new e.bQ(t),u_spin_weights:new e.bP(t),u_perspective_transform:new e.bO(t),u_raster_elevation:new e.bQ(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_cutoff_params:new e.bS(t),u_colorization_mix:new e.bS(t),u_colorization_offset:new e.bQ(t),u_color_ramp:new e.bR(t),u_texture_offset:new e.bO(t),u_texture_res:new e.bO(t),u_emissive_strength:new e.bQ(t)}),rasterParticle:t=>({u_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_grid_matrix:new e.cg(t),u_tl_parent:new e.bO(t),u_scale_parent:new e.bQ(t),u_fade_t:new e.bQ(t),u_opacity:new e.bQ(t),u_image0:new e.bR(t),u_image1:new e.bR(t),u_raster_elevation:new e.bQ(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_cutoff_params:new e.bS(t)}),rasterParticleTexture:t=>({u_texture:new e.bR(t),u_opacity:new e.bQ(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.bR(t),u_particle_texture_side_len:new e.bQ(t),u_tile_offset:new e.bO(t),u_velocity:new e.bR(t),u_color_ramp:new e.bR(t),u_velocity_res:new e.bO(t),u_max_speed:new e.bQ(t),u_uv_offset:new e.bO(t),u_data_scale:new e.bS(t),u_data_offset:new e.bQ(t),u_particle_pos_scale:new e.bQ(t),u_particle_pos_offset:new e.bO(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.bR(t),u_particle_texture_side_len:new e.bQ(t),u_velocity:new e.bR(t),u_velocity_res:new e.bO(t),u_max_speed:new e.bQ(t),u_speed_factor:new e.bQ(t),u_reset_rate:new e.bQ(t),u_rand_seed:new e.bQ(t),u_uv_offset:new e.bO(t),u_data_scale:new e.bS(t),u_data_offset:new e.bQ(t),u_particle_pos_scale:new e.bQ(t),u_particle_pos_offset:new e.bO(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_camera_forward:new e.bP(t),u_tile_matrix:new e.bN(t),u_up_vector:new e.bP(t),u_ecef_origin:new e.bP(t),u_texture:new e.bR(t),u_icon_transition:new e.bQ(t),u_color_adj_mat:new e.bN(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_texture:new e.bR(t),u_gamma_scale:new e.bQ(t),u_device_pixel_ratio:new e.bQ(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_camera_forward:new e.bP(t),u_tile_matrix:new e.bN(t),u_up_vector:new e.bP(t),u_ecef_origin:new e.bP(t),u_is_halo:new e.bR(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_texsize_icon:new e.bO(t),u_texture:new e.bR(t),u_texture_icon:new e.bR(t),u_gamma_scale:new e.bQ(t),u_device_pixel_ratio:new e.bQ(t),u_is_halo:new e.bR(t)}),background:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_opacity:new e.bQ(t),u_color:new e.cf(t)}),backgroundPattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_opacity:new e.bQ(t),u_image:new e.bR(t),u_pattern_tl:new e.bO(t),u_pattern_br:new e.bO(t),u_texsize:new e.bO(t),u_pattern_size:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),terrainRaster:ti,terrainDepth:ti,skybox:t=>({u_matrix:new e.bN(t),u_sun_direction:new e.bP(t),u_cubemap:new e.bR(t),u_opacity:new e.bQ(t),u_temporal_offset:new e.bQ(t)}),skyboxGradient:t=>({u_matrix:new e.bN(t),u_color_ramp:new e.bR(t),u_center_direction:new e.bP(t),u_radius:new e.bQ(t),u_opacity:new e.bQ(t),u_temporal_offset:new e.bQ(t)}),skyboxCapture:t=>({u_matrix_3f:new e.cg(t),u_sun_direction:new e.bP(t),u_sun_intensity:new e.bQ(t),u_color_tint_r:new e.bS(t),u_color_tint_m:new e.bS(t),u_luminance:new e.bQ(t)}),globeRaster:t=>({u_proj_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_image0:new e.bR(t),u_grid_matrix:new e.cg(t),u_skirt_height:new e.bQ(t),u_far_z_cutoff:new e.bQ(t),u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_globe_pos:new e.bP(t),u_globe_radius:new e.bQ(t),u_viewport:new e.bO(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_horizon:new e.bQ(t),u_transition:new e.bQ(t),u_fadeout_range:new e.bQ(t),u_color:new e.bS(t),u_high_color:new e.bS(t),u_space_color:new e.bS(t),u_temporal_offset:new e.bQ(t),u_horizon_angle:new e.bQ(t)}),model:t=>({u_matrix:new e.bN(t),u_lighting_matrix:new e.bN(t),u_normal_matrix:new e.bN(t),u_node_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_camera_pos:new e.bP(t),u_opacity:new e.bQ(t),u_baseColorFactor:new e.bS(t),u_emissiveFactor:new e.bS(t),u_metallicFactor:new e.bQ(t),u_roughnessFactor:new e.bQ(t),u_baseTextureIsAlpha:new e.bR(t),u_alphaMask:new e.bR(t),u_alphaCutoff:new e.bQ(t),u_baseColorTexture:new e.bR(t),u_metallicRoughnessTexture:new e.bR(t),u_normalTexture:new e.bR(t),u_occlusionTexture:new e.bR(t),u_emissionTexture:new e.bR(t),u_color_mix:new e.bS(t),u_aoIntensity:new e.bQ(t),u_emissive_strength:new e.bQ(t),u_occlusionTextureTransform:new e.bS(t)}),modelDepth:t=>({u_matrix:new e.bN(t),u_instance:new e.bN(t),u_node_matrix:new e.bN(t)}),groundShadow:t=>({u_matrix:new e.bN(t),u_ground_shadow_factor:new e.bP(t)}),stars:t=>({u_matrix:new e.bN(t),u_up:new e.bP(t),u_right:new e.bP(t),u_intensity_multiplier:new e.bQ(t)})};let Qi;function Xi(t,n,r,i,o,a,s){const l=t.context,c=l.gl,u=t.transform,h=t.getOrCreateProgram("collisionBox"),d=[];let f=0,p=0;for(let b=0;b0){const t=e.a9.create(),n=y;e.a9.mul(t,g.placementInvProjMatrix,u.glCoordMatrix),e.a9.mul(t,t,g.placementViewportMatrix),d.push({circleArray:x,circleOffset:p,transform:n,invTransform:t,projection:g.getProjection()}),f+=x.length/4,p=f}v&&(t.terrain&&t.terrain.setupElevationDraw(m,h),h.draw(t,c.LINES,Et.disabled,Ct.disabled,t.colorModeForRenderPass(),Lt.disabled,Ci(y,u,m,g.getProjection()),r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,u.zoom,null,[v.collisionVertexBuffer,v.collisionVertexBufferExt]))}if(!s||!d.length)return;const m=t.getOrCreateProgram("collisionCircle"),g=new e.cC;g.resize(4*f),g._trim();let _=0;for(const e of d)for(let t=0;t=0&&(m[p.associatedIconIndex]={x:A,y:E,z:T,angle:R})}else Tn(S,f)}if(h){p.clear();const n=t.icon.placedSymbolArray;for(let t=0;t6&&void 0!==arguments[6]?arguments[6]:{};const l=r.paint.get("icon-translate"),c=r.paint.get("text-translate"),u=r.paint.get("icon-translate-anchor"),h=r.paint.get("text-translate-anchor"),d=r.layout.get("icon-rotation-alignment"),f=r.layout.get("text-rotation-alignment"),p=r.layout.get("icon-pitch-alignment"),m=r.layout.get("text-pitch-alignment"),g=r.layout.get("icon-keep-upright"),_=r.layout.get("text-keep-upright"),y=r.paint.get("icon-color-saturation"),v=r.paint.get("icon-color-contrast"),x=r.paint.get("icon-color-brightness-min"),b=r.paint.get("icon-color-brightness-max"),w=t.context,S=w.gl,M=t.transform,A="map"===d,E="map"===f,T="map"===p,C="map"===m,k=void 0!==r.layout.get("symbol-sort-key").constantOr(1);let I=!1;const P=t.depthModeForSublayer(0,Et.ReadOnly),R=[e.a8(M.center.lng),e.ah(M.center.lat)],L=r.layout.get("text-variable-anchor"),z="globe"===M.projection.name,O=[],D=[0,-1,0];for(const B of i){const i=n.getTile(B),o=i.getBucket(r);if(!o)continue;if("mercator"===o.projection.name&&z)continue;if(o.fullyClipped)continue;const a="globe"===o.projection.name,d=a?e.W(M.zoom):0,f=Ln(B,o.getProjection(),M),p=M.calculatePixelsToTileUnitsMatrix(i),m=L&&o.hasTextData(),w=o.hasIconTextFit()&&m&&o.hasIconData(),P=o.getProjection().createInversionMatrix(M,B.canonical),F=()=>{const n=A&&"point"!==r.layout.get("symbol-placement"),s=[],c=n||w,h=r.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&T&&s.push("PITCH_WITH_MAP_TERRAIN"),a&&(s.push("PROJECTION_GLOBE_VIEW"),c&&s.push("PROJECTED_POS_ON_VIEWPORT")),h>0&&s.push("ICON_TRANSITION"),o.icon.zOffsetVertexBuffer&&s.push("Z_OFFSET"),0===y&&0===v&&0===x&&1===b||s.push("COLOR_ADJUSTMENT");const m=o.icon.programConfigurations.get(r.id),_=t.getOrCreateProgram(o.sdfIcons?"symbolSDF":"symbolIcon",{config:m,defines:s});let E;const C=i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],k=o.iconSizeData,I=e.b8(k,M.zoom),L=T||0!==M.pitch,O=pn(f,i.tileID.canonical,T,A,M,o.getProjection(),p),F=gn(f,i.tileID.canonical,T,A,M,o.getProjection(),p),N=t.translatePosMatrix(F,i,l,u,!0),j=t.translatePosMatrix(f,i,l,u),V=c?Ki:O,U=A&&!T&&!n;let G=D;!z&&!M.mercatorFromTransition||A||(G=Ji(M));const q=a?G:D;if(o.sdfIcons&&!o.iconsInText)E=Vi(k.kind,I,U,T,t,j,V,N,!1,C,!0,B,d,R,P,q,o.getProjection());else{const e=r.getColorAdjustmentMatrix(y,v,x,b);E=ji(k.kind,I,U,T,t,j,V,N,!1,C,B,d,R,P,q,o.getProjection(),e,h)}const W=i.imageAtlasTexture?i.imageAtlasTexture:null,H=1!==r.layout.get("icon-size").constantOr(0)||o.iconsNeedLinear,Z=o.sdfIcons||t.options.rotating||t.options.zooming||H||L?S.LINEAR:S.NEAREST,Y=o.sdfIcons&&0!==r.paint.get("icon-halo-width").constantOr(1),Q=t.terrain&&T&&n?e.a9.invert(e.a9.create(),O):Ki;if(n&&o.icon){const e=M.elevation,n=e?e.getAtTileOffsetFunc(B,M.center.lat,M.worldSize,o.getProjection()):null,r=mn(f,i.tileID.canonical,T,A,M,o.getProjection(),p);xn(o,f,t,!1,r,F,T,g,n,B)}return{program:_,buffers:o.icon,uniformValues:E,atlasTexture:W,atlasTextureIcon:null,atlasInterpolation:Z,atlasInterpolationIcon:null,isSDF:o.sdfIcons,hasHalo:Y,tile:i,labelPlaneMatrixInv:Q}},N=()=>{const n=E&&"point"!==r.layout.get("symbol-placement"),s=[],l=n||L||w;t.terrainRenderModeElevated()&&C&&s.push("PITCH_WITH_MAP_TERRAIN"),a&&(s.push("PROJECTION_GLOBE_VIEW"),l&&s.push("PROJECTED_POS_ON_VIEWPORT")),o.text.zOffsetVertexBuffer&&s.push("Z_OFFSET");const u=o.text.programConfigurations.get(r.id),m=t.getOrCreateProgram(o.iconsInText?"symbolTextAndIcon":"symbolSDF",{config:u,defines:s});let g,y=[0,0],v=null;const x=o.textSizeData;o.iconsInText&&(y=i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],v=i.imageAtlasTexture?i.imageAtlasTexture:null,g=C||0!==M.pitch||t.options.rotating||t.options.zooming||"composite"===x.kind||"camera"===x.kind?S.LINEAR:S.NEAREST);const b=i.glyphAtlasTexture?i.glyphAtlasTexture.size:[0,0],A=e.b8(x,M.zoom),T=pn(f,i.tileID.canonical,C,E,M,o.getProjection(),p),k=gn(f,i.tileID.canonical,C,E,M,o.getProjection(),p),I=t.translatePosMatrix(k,i,c,h,!0),O=t.translatePosMatrix(f,i,c,h),F=l?Ki:T,N=E&&!C&&!n;let j=D;!z&&!M.mercatorFromTransition||E||(j=Ji(M));const V=a?j:D;let U;U=o.iconsInText?Ui(x.kind,A,N,C,t,O,F,I,b,y,B,d,R,P,V,o.getProjection()):Vi(x.kind,A,N,C,t,O,F,I,!0,b,!0,B,d,R,P,V,o.getProjection());const G=i.glyphAtlasTexture?i.glyphAtlasTexture:null,q=S.LINEAR,W=0!==r.paint.get("text-halo-width").constantOr(1),H=t.terrain&&C&&n?e.a9.invert(e.a9.create(),T):Ki;if(n&&o.text){const e=M.elevation,n=e?e.getAtTileOffsetFunc(B,M.center.lat,M.worldSize,o.getProjection()):null,r=mn(f,i.tileID.canonical,C,E,M,o.getProjection(),p);xn(o,f,t,!0,r,k,C,_,n,B)}return{program:m,buffers:o.text,uniformValues:U,atlasTexture:G,atlasTextureIcon:v,atlasInterpolation:q,atlasInterpolationIcon:g,isSDF:!0,hasHalo:W,tile:i,labelPlaneMatrixInv:H}},j=o.icon.segments.get().length,V=o.text.segments.get().length,U=j&&!s.onlyText?F():null,G=V&&!s.onlyIcons?N():null,q=r.paint.get("icon-opacity").constantOr(1),W=r.paint.get("text-opacity").constantOr(1);if(k&&o.canOverlap){I=!0;const t=q&&!s.onlyText?o.icon.segments.get():[],n=W&&!s.onlyIcons?o.text.segments.get():[];for(const r of t)O.push({segments:new e.aE([r]),sortKey:r.sortKey,state:U});for(const r of n)O.push({segments:new e.aE([r]),sortKey:r.sortKey,state:G})}else s.onlyText||O.push({segments:q?o.icon.segments:new e.aE([]),sortKey:0,state:U}),s.onlyIcons||O.push({segments:W?o.text.segments:new e.aE([]),sortKey:0,state:G})}I&&O.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of O){const n=e.state;if(n)if(t.terrain&&t.terrain.setupElevationDraw(n.tile,n.program,{useDepthForOcclusion:M.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:n.labelPlaneMatrixInv}),w.activeTexture.set(S.TEXTURE0),n.atlasTexture&&n.atlasTexture.bind(n.atlasInterpolation,S.CLAMP_TO_EDGE,!0),n.atlasTextureIcon&&(w.activeTexture.set(S.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,S.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,n.program),n.hasHalo){const i=n.uniformValues;i.u_is_halo=1,no(n.buffers,e.segments,r,t,n.program,P,o,a,i,2),i.u_is_halo=0}else{if(n.isSDF){const i=n.uniformValues;n.hasHalo&&(i.u_is_halo=1,no(n.buffers,e.segments,r,t,n.program,P,o,a,i,1)),i.u_is_halo=0}no(n.buffers,e.segments,r,t,n.program,P,o,a,n.uniformValues,1)}}}function no(e,t,n,r,i,o,a,s,l,c){const u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];i.draw(r,r.context.gl.TRIANGLES,o,a,s,Lt.disabled,l,n.id,e.layoutVertexBuffer,e.indexBuffer,t,n.paint,r.transform.zoom,e.programConfigurations.get(n.id),u,c)}function ro(e,t,n,r,i,o,a){const s=e.context.gl,l=n.paint.get("fill-pattern"),c=l&&l.constantOr(1);let u,h,d,f,p;a?(h=c&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",u=s.LINES):(h=c?"fillPattern":"fill",u=s.TRIANGLES);for(const m of r){const r=t.getTile(m);if(c&&!r.patternsLoaded())continue;const g=r.getBucket(n);if(!g)continue;e.prepareDrawTile();const _=g.programConfigurations.get(n.id),y=e.isTileAffectedByFog(m),v=e.getOrCreateProgram(h,{config:_,overrideFog:y});c&&(e.context.activeTexture.set(s.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),_.updatePaintBuffers());const x=l.constantOr(null);if(x&&r.imageAtlas){const e=r.imageAtlas.patternPositions[x.toString()];e&&_.setConstantPatternPositions(e)}const b=e.translatePosMatrix(m.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor")),w=n.paint.get("fill-emissive-strength");if(a){f=g.indexBuffer2,p=g.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[s.drawingBufferWidth,s.drawingBufferHeight];d="fillOutlinePattern"===h&&c?Ti(b,w,e,r,t):Ei(b,w,t)}else f=g.indexBuffer,p=g.segments,d=c?Ai(b,w,e,r):Mi(b,w);e.uploadCommonUniforms(e.context,v,m.toUnwrapped()),v.draw(e,u,i,e.stencilModeForClipping(m),o,Lt.disabled,d,n.id,g.layoutVertexBuffer,f,p,n.paint,e.transform.zoom,_,void 0)}}function io(t,n,r,i,o,a,s,l){r.resetLayerRenderingStats(t);const c=t.context,u=c.gl,h=t.transform,d=r.paint.get("fill-extrusion-pattern"),f=d.constantOr(1),p=r.paint.get("fill-extrusion-opacity"),m=t.style.enable3dLights(),g=r.paint.get(m&&!f?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),_=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),g],y=r.layout.get("fill-extrusion-edge-radius"),v=y>0&&!r.paint.get("fill-extrusion-rounded-roof"),x=v?0:y,b="globe"===h.projection.name?e.cM():0,w="globe"===h.projection.name,S=w?e.W(h.zoom):0,M=[e.a8(h.center.lng),e.ah(h.center.lat)],A=r.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),E=r.paint.get("fill-extrusion-flood-light-intensity"),T=r.paint.get("fill-extrusion-vertical-scale"),C=gr(t,r.paint.get("fill-extrusion-cutoff-fade-range")),k=r.paint.get("fill-extrusion-emissive-strength"),I=[];let P;w&&I.push("PROJECTION_GLOBE_VIEW"),_[0]>0&&I.push("FAUX_AO"),v&&I.push("ZERO_ROOF_RADIUS"),l&&I.push("HAS_CENTROID"),E>0&&I.push("FLOOD_LIGHT"),C.shouldRenderCutoff&&I.push("RENDER_CUTOFF");const R="shadow"===t.renderPass,L=t.shadowRenderer,z=R&&!!L;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let O=[0,0,0];if(L){const e=t.style.directionalLight,n=t.style.ambientLight;e&&n&&(O=Sr(e,n)),P=I.concat(["SHADOWS_SINGLE_CASCADE"])}const D=z?"fillExtrusionDepth":f?"fillExtrusionPattern":"fillExtrusion",B=r.getLayerRenderingStats();for(const e of i){const i=n.getTile(e),m=i.getBucket(r);if(!m||m.projection.name!==h.projection.name)continue;let g=!1;L&&(g=0===L.getMaxCascadeForTile(e.toUnwrapped()));const y=t.isTileAffectedByFog(e),v=m.programConfigurations.get(r.id),z=t.getOrCreateProgram(D,{config:v,defines:g?P:I,overrideFog:y});if(t.terrain&&t.terrain.setupElevationDraw(i,z,{useMeterToDem:!0}),!m.centroidVertexBuffer){const e=z.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}!R&&L&&L.setupShadows(i.tileID.toUnwrapped(),z,"vector-tile",i.tileID.overscaledZ),f&&(t.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture&&i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),v.updatePaintBuffers());const F=d.constantOr(null);if(F&&i.imageAtlas){const e=i.imageAtlas.patternPositions[F.toString()];e&&v.setConstantPatternPositions(e)}const N=r.paint.get("fill-extrusion-vertical-gradient");let j;if(R&&L){if(uo(i.tileID,m,t))continue;const e=L.calculateShadowPassMatrixFromTile(i.tileID.toUnwrapped());j=wi(e,x,T)}else{const n=t.translatePosMatrix(e.expandedProjMatrix,i,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),o=h.projection.createInversionMatrix(h,e.canonical);j=f?Si(n,t,N,p,_,x,e,i,b,S,M,o,A,T):bi(n,t,N,p,_,x,e,b,S,M,o,A,T,E,O,k)}t.uploadCommonUniforms(c,z,e.toUnwrapped(),null,C);let V=m.segments;if("mercator"===h.projection.name&&!R&&(V=m.getVisibleSegments(i.tileID,t.terrain,t.transform.getFrustum(0)),!V.get().length))continue;if(B)if(R)for(const e of V.get())B.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of V.get())B.numRenderedVerticesInTransparentPass+=e.primitiveLength;const U=[];(t.terrain||l)&&U.push(m.centroidVertexBuffer),w&&U.push(m.layoutVertexExtBuffer),z.draw(t,c.gl.TRIANGLES,o,a,s,Lt.backCCW,j,r.id,m.layoutVertexBuffer,m.indexBuffer,V,r.paint,t.transform.zoom,v,U)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}function oo(t,n,r,i,o,a,s,l,c,u,h,d,f,p,m,g,_,y,v){const x=t.context,b=x.gl,w=t.transform,S=t.transform.zoom,M=[],A=gr(t,r.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===u?(M.push("CLEAR_SUBPASS"),v&&(M.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(b.TEXTURE0),v.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===u&&M.push("SDF_SUBPASS"),_&&M.push("HAS_CENTROID"),A.shouldRenderCutoff&&M.push("RENDER_CUTOFF");const E=r.layout.get("fill-extrusion-edge-radius"),T=(e,n,i,u,y)=>{const b=n.programConfigurations.get(r.id),w=t.isTileAffectedByFog(e),T=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:M,overrideFog:w}),C=((e,t,n,r,i,o,a,s,l,c,u)=>({u_matrix:t,u_opacity:n,u_ao_pass:r?1:0,u_meter_to_tile:i,u_ao:o,u_flood_light_intensity:a,u_flood_light_color:s,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:u}))(0,u,h,c,y,[d,f*y],p,m,g,S>=17?0:E*y,v?v.size[0]:0),k=[];_&&k.push(n.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(x,T,e.toUnwrapped(),null,A),T.draw(t,x.gl.TRIANGLES,o,a,s,l,C,r.id,n.vertexBuffer,n.indexBuffer,i,r.paint,S,b,k)};for(const C of i){const i=n.getTile(C),o=i.getBucket(r);if(!o||o.projection.name!==w.projection.name||!o.groundEffect||o.groundEffect&&!o.groundEffect.hasData())continue;const a=o.groundEffect,s=1/o.tileToMeter;{const e=t.translatePosMatrix(C.projMatrix,i,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),n=a.getDefaultSegment();T(C,a,n,e,s)}if(y)for(let l=0;l<4;l++){const o=e.cN[l](C),a=n.getTile(o);if(!a)continue;const c=a.getBucket(r);if(!c||c.projection.name!==w.projection.name||!c.groundEffect||c.groundEffect&&!c.groundEffect.hasData())continue;const u=c.groundEffect;let h,d;0===l?(h=[-e.Y,0,0],d=1):1===l?(h=[e.Y,0,0],d=0):2===l?(h=[0,-e.Y,0],d=3):(h=[0,e.Y,0],d=2);const f=u.regionSegments[d];if(!f)continue;const p=new Float32Array(16);e.a9.translate(p,C.projMatrix,h),T(C,u,f,t.translatePosMatrix(p,i,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),s)}}}function ao(t,n,r,i,o,a,s){0===i.centroidVertexArray.length&&i.createCentroidsBuffer();const l=a?a.findDEMTileFor(r):null;if(!(l&&l.dem||s))return;const c=t=>new e.P(Math.ceil((t+e.cQ)*e.cR),0),u=e=>{const t=n.getSource().minzoom,r=e=>{const t=n.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},i=[0,-1,1];for(const n of i){if(e.overscaledZ+n(h[0]=Math.min(t.min.y,n.min.y),h[1]=Math.max(t.max.y,n.max.y),h[2]=e.Y-n.min.x>t.max.x?n.min.x-e.Y:t.max.x,h),f=(t,n)=>(h[0]=Math.min(t.min.x,n.min.x),h[1]=Math.max(t.max.x,n.max.x),h[2]=e.Y-n.min.y>t.max.y?n.min.y-e.Y:t.max.y,h),p=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>f(e,t),(e,t)=>f(t,e)],m=(t,n,i,o,s,c,u)=>{if(!a)return 0;const h=[[c?i:t,c?t:i,0],[c?i:n,c?n:i,0]],d=u<0?e.Y+u:u,f=[c?d:(t+n)/2,c?(t+n)/2:d,0];return 0===i&&u<0||0!==i&&u>0?a.getForTilePoints(s,[f],!0,o):h.push(f),a.getForTilePoints(r,h,!0,l),Math.max(h[0][2],h[1][2],f[2])/a.exaggeration()};for(let y=0;y<4;y++){const t=i.borderFeatureIndices[y];if(0===t.length)continue;const n=e.cN[y](r),o=u(n);if(!(o&&o instanceof e.cO))continue;if(i.borderDoneWithNeighborZ[y]===o.canonical.z)continue;0===o.centroidVertexArray.length&&o.createCentroidsBuffer();const l=a?a.findDEMTileFor(n):null;if(!(l&&l.dem||s))continue;const h=(y<2?1:5)-y,d=o.borderDoneWithNeighborZ[h]!==i.canonical.z,f=o.borderFeatureIndices[h];let v=0;if(i.canonical.z!==o.canonical.z){for(const e of t)i.showCentroid(i.featuresOnBorder[e]);if(d)for(const e of f)o.showCentroid(o.featuresOnBorder[e]);i.borderDoneWithNeighborZ[y]=o.canonical.z,o.borderDoneWithNeighborZ[h]=i.canonical.z}for(const r of t){const t=i.featuresOnBorder[r],a=i.centroidData[t.centroidDataIndex],u=t.borders[y];let d;for(;vu[0]+3||e[0]>u[0]-3)break;o.showCentroid(d),v++}if(d&&vu[1]-3)&&(x++,++v!==f.length);)d=o.featuresOnBorder[f[v]];if(d=o.featuresOnBorder[f[r]],x>1){const e=d.borders[h];Math.abs(u[0]-e[0])<3&&Math.abs(u[1]-e[1])<3&&(x=1,v=r+1)}else if(0===x){i.showCentroid(t);continue}const b=o.centroidData[d.centroidDataIndex];s&&1===x&&(((g=a).flags|(_=b).flags)&e.cP?(g.flags|=e.cP,_.flags|=e.cP):(g.flags&=~e.cP,_.flags&=~e.cP));const w=t.intersectsCount()>1||d.intersectsCount()>1;if(x>1)v=r,a.centroidXY=b.centroidXY=new e.P(0,0);else if(l&&l.dem&&!w){const t=p[y](a,b),r=y%2?e.Y-1:0,i=m(t[0],Math.min(e.Y-1,t[1]),r,l,n,y<2,t[2]);a.centroidXY=b.centroidXY=c(i)}else w?a.centroidXY=b.centroidXY=new e.P(0,0):(a.centroidXY=i.encodeBorderCentroid(t),b.centroidXY=o.encodeBorderCentroid(d));i.writeCentroidToBuffer(a),o.writeCentroidToBuffer(b)}else i.showCentroid(t)}i.borderDoneWithNeighborZ[y]=o.canonical.z,o.borderDoneWithNeighborZ[h]=i.canonical.z}var g,_;(i.needsCentroidUpdate||!i.centroidVertexBuffer&&0!==i.centroidVertexArray.length)&&i.uploadCentroid(t)}const so=[1,0,0],lo=[0,1,0],co=[0,0,1];function uo(t,n,r){const i=r.transform,o=r.shadowRenderer;if(!o)return!0;const a=t.toUnwrapped(),s=i.tileSize*o._cascades[r.currentShadowCascade].scale;let l=n.maxHeight;if(i.elevation){const e=i.elevation.getMinMaxForTile(t);e&&(l+=e.max)}const c=[...o.shadowDirection];c[2]=-c[2];const u=o.computeSimplifiedTileShadowVolume(a,l,s,c);if(!u)return!1;const h=[so,lo,co,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===i.projection.name,f=i.scaleZoom(s),p=e.bt.fromInvProjectionMatrix(i.invProjMatrix,i.worldSize,f,!d),m=o.getCurrentCascadeFrustum();return 0===p.intersectsPrecise(u.vertices,u.planes,h)||0===m.intersectsPrecise(u.vertices,u.planes,h)}function ho(t){return[t[0]*e.cS,t[1]*e.cS,t[2]*e.cS,0]}function fo(t,n,r,i,o,a,s,l,c){const u=i.getSource(),h=r.globeSharedBuffers;if(!h)return;let d,f,p;if(n&&(d=i.getTile(n)),u instanceof e.as?(f=u.texture,p=e.co(0,0,r.transform)):d&&n&&(f=d.texture,p=e.co(n.canonical.z,n.canonical.x,r.transform)),!f||!p)return;t||(p=e.a9.scale(e.a9.create(),p,[1,-1,1]));const m=r.context,g=m.gl,_="nearest"===o.paint.get("raster-resampling")?g.NEAREST:g.LINEAR,y=r.colorModeForDrapableLayerRenderPass(a),v=s.defines;v.push("GLOBE_POLES");const x=new Et(g.LEQUAL,Et.ReadWrite,r.depthRangeFor3D),b=Float32Array.from(r.transform.expandedFarZProjMatrix),w=Float32Array.from(e.aW(e.cn(new e.bv(0,0,0))));r.terrain&&r.terrain.prepareDrawTile(),m.activeTexture.set(g.TEXTURE0),f.bind(_,g.CLAMP_TO_EDGE),m.activeTexture.set(g.TEXTURE1),f.bind(_,g.CLAMP_TO_EDGE),f.useMipmap&&m.extTextureFilterAnisotropic&&r.transform.pitch>20&&g.texParameterf(g.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[S,M,A,E]=n?h.getPoleBuffers(n.canonical.z,!1):h.getPoleBuffers(0,!0),T=o.paint.get("raster-elevation");let C;t?(C=S,r.renderDefaultNorthPole=0!==T):(C=M,r.renderDefaultSouthPole=0!==T);const k=ho(s.mix),I=((e,t,n,r,i,o,a,s,l,c,u,h,d)=>zi(e,t,n,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0]||0,s,2,c,u,h,1,0,d))(b,w,p,e.W(r.transform.zoom),0,o,0,T,0,k,s.offset,s.range,a),P=r.getOrCreateProgram("raster",{defines:v});r.uploadCommonUniforms(m,P,null),P.draw(r,g.TRIANGLES,x,c,y,l,I,o.id,C,A,E)}function po(e){const t=e._nearZ,n=e.projection.farthestPixelDistance(e),r=n-t,i=.2*e.height,o=t+i;return[t,n,(o-i-t)/r,(o-t)/r]}function mo(e,t,n,r){if(e)return t instanceof Pe&&e instanceof Ht?t.getTextureDescriptor(e,n,!0):{texture:e.texture,mix:ho(r.mix),offset:r.offset,buffer:0,tileSize:1}}function go(t,n,r){if(!t)return null;const i=n.getTextureDescriptor(t,r,!0);if(!i)return null;let{texture:o,mix:a,offset:s,tileSize:l,buffer:c,format:u}=i;if(!o||!u)return null;let h=!1;return"uint32"===u&&(h=!0,a[3]=0,a=Ri(e.cT,a,[0,r.paint.get("raster-particle-max-speed")]),s=Li(e.cT,s,[0,r.paint.get("raster-particle-max-speed")])),{texture:o,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:h,scale:a,offset:s,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[u]]}}function _o(e){const t=e._nearZ,n=e.projection.farthestPixelDistance(e),r=n-t,i=.2*e.height,o=t+i;return[t,n,(o-i-t)/r,(o-t)/r]}const yo=new e.aA(1,0,0,1),vo=new e.aA(0,1,0,1),xo=new e.aA(0,0,1,1),bo=new e.aA(1,0,1,1),wo=new e.aA(0,1,1,1);function So(t,n,r,i,o,a,s){const l=t.context,c=t.transform,u=l.gl,h="globe"===c.projection.name,d=h?["PROJECTION_GLOBE_VIEW"]:[];let f=e.a9.clone(r.projMatrix);if(h&&e.W(c.zoom)>0){const t=e.aV(r.canonical,c),n=e.cU(t);f=e.a9.multiply(new Float32Array(16),c.globeMatrix,n),e.a9.multiply(f,c.projMatrix,f)}const p=e.a9.create();p[12]+=2*o/(e.f.devicePixelRatio*c.width),p[13]+=2*a/(e.f.devicePixelRatio*c.height),e.a9.multiply(f,p,f);const m=t.getOrCreateProgram("debug",{defines:d}),g=n.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(g,m);const _=Et.disabled,y=Ct.disabled,v=t.colorModeForRenderPass(),x="$debug";l.activeTexture.set(u.TEXTURE0),t.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),h?g._makeGlobeTileDebugBuffers(t.context,c):g._makeDebugTileBoundsBuffers(t.context,c.projection);const b=g._tileDebugBuffer||t.debugBuffer,w=g._tileDebugIndexBuffer||t.debugIndexBuffer,S=g._tileDebugSegments||t.debugSegments;if(m.draw(t,u.LINE_STRIP,_,y,v,Lt.disabled,ki(f,i),x,b,w,S,null,null,null,[g._globeTileDebugBorderBuffer]),s){const e=g.latestRawTileData,n=Math.floor((e&&e.byteLength||0)/1024);let i=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(i+=" => ".concat(r.overscaledZ)),i+=" ".concat(g.state),i+=" ".concat(n,"kb"),function(e,t){e.initDebugOverlayCanvas();const n=e.debugOverlayCanvas,r=e.context.gl,i=e.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,n.width,n.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,i)}const M=n.getTile(r).tileSize,A=512/Math.min(M,512)*(r.overscaledZ/c.zoom)*.5,E=g._tileDebugTextBuffer||t.debugBuffer,T=g._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,C=g._tileDebugTextSegments||t.debugSegments;m.draw(t,u.TRIANGLES,_,y,It.alphaBlended,Lt.disabled,ki(f,e.aA.transparent,A),x,E,T,C,null,null,null,[g._globeTileDebugTextBuffer])}function Mo(e,t,n,r){Eo(e,0,t+n/2,e.transform.width,n,r)}function Ao(e,t,n,r){Eo(e,t-n/2,0,n,e.transform.height,r)}function Eo(t,n,r,i,o,a){const s=t.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(n*e.f.devicePixelRatio,r*e.f.devicePixelRatio,i*e.f.devicePixelRatio,o*e.f.devicePixelRatio),s.clear({color:a}),l.disable(l.SCISSOR_TEST)}const To=e.aB([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Co}=To;function ko(e,t,n,r){e.emplaceBack(t,n,r)}class Io{constructor(t){this.vertexArray=new e.cV,this.indices=new e.az,ko(this.vertexArray,-1,-1,1),ko(this.vertexArray,1,-1,1),ko(this.vertexArray,-1,1,1),ko(this.vertexArray,1,1,1),ko(this.vertexArray,-1,-1,-1),ko(this.vertexArray,1,-1,-1),ko(this.vertexArray,-1,1,-1),ko(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,Co),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.aE.simpleSegment(0,0,36,12)}}function Po(t,n,r,i,o,a){const s=t.context.gl,l=n.paint.get("sky-atmosphere-color"),c=n.paint.get("sky-atmosphere-halo-color"),u=n.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,n,r,i)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:n,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[i.r,i.g,i.b,i.a],u_luminance:5e-5}))(e.ct.fromMat4(e.ct.create(),i),o,u,l,c);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+a,n.skyboxTexture,0),r.draw(t,s.TRIANGLES,Et.disabled,Ct.disabled,It.unblended,Lt.frontCW,h,"skyboxCapture",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}const Ro=e.aB([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Lo{constructor(t){const n=new e.cW;n.emplaceBack(-1,1,1,0,0),n.emplaceBack(1,1,1,1,0),n.emplaceBack(1,-1,1,1,1),n.emplaceBack(-1,-1,1,0,1);const r=new e.az;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(n,Ro.members),this.indexBuffer=t.createIndexBuffer(r),this.segments=e.aE.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const zo=e.aB([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class Oo{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class Do{constructor(t){this.colorModeAlphaBlendedWriteRGB=new It([1,kt,1,kt],e.aA.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new It([1,0,1,0],e.aA.transparent,[!1,!1,!1,!0]),this.params=new Oo,this.updateNeeded=!0,t.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},(()=>{this.updateNeeded=!0})),t.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),t.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},(()=>{this.updateNeeded=!0})),t.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},(()=>{this.updateNeeded=!0}))}update(t){const n=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Lo(n);const t=this.params.sizeRange,r=this.params.intensityRange,i=function(t){const n=e.aC(30),r=[];for(let i=0;i{const n="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&n.push("ALPHA_PASS");const h=t.getOrCreateProgram("globeAtmosphere",{defines:n}),f=((e,t,n,r,i,o,a,s,l,c,u,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:n,u_frustum_bl:r,u_horizon:i,u_transition:o,u_fadeout_range:a,u_color:s,u_high_color:l,u_space_color:c,u_temporal_offset:u,u_horizon_angle:h}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,s,d,l,c,u,p,_);t.uploadCommonUniforms(r,h);const m=this.atmosphereBuffer;m&&h.draw(t,i.TRIANGLES,a,Ct.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Lt.backCW,f,e?"atmosphere_glow_alpha":"atmosphere_glow",m.vertexBuffer,m.indexBuffer,m.segments)};y(!1),y(!0)}drawStars(t,n){const r=e.ad(n.properties.get("star-intensity"),0,1);if(0===r)return;const i=t.context,o=i.gl,a=t.transform,s=t.getOrCreateProgram("stars"),l=e.bl.identity([]);e.bl.rotateX(l,l,-a._pitch),e.bl.rotateZ(l,l,-a.angle),e.bl.rotateX(l,l,e.bm(a._center.lat)),e.bl.rotateY(l,l,-e.bm(a._center.lng));const c=e.a9.fromQuat(new Float32Array(16),l),u=e.a9.multiply([],a.starsProjMatrix,c),h=e.ct.fromMat4([],c),d=e.ct.invert([],h),f=[0,1,0];e.Q.transformMat3(f,f,d),e.Q.scale(f,f,this.params.sizeMultiplier);const p=[1,0,0];e.Q.transformMat3(p,p,d),e.Q.scale(p,p,this.params.sizeMultiplier);const m=(g=f,_=p,y=r,{u_matrix:Float32Array.from(u),u_up:g,u_right:_,u_intensity_multiplier:y});var g,_,y;t.uploadCommonUniforms(i,s),this.starsVx&&this.starsIdx&&s.draw(t,o.TRIANGLES,Et.disabled,Ct.disabled,this.colorModeAlphaBlendedWriteRGB,Lt.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}function Bo(t,n){const r=[...t],i=n.cameraWorldSizeForFog/n.worldSize,o=e.a9.identity([]);return e.a9.scale(o,o,[i,i,1]),e.a9.multiply(r,o,r),e.a9.multiply(r,n.worldToFogMatrix,r),r}function Fo(e,t,n,r){const i=n.material,o=r.context,{baseColorTexture:a,metallicRoughnessTexture:s}=i.pbrMetallicRoughness,{normalTexture:l,occlusionTexture:c,emissionTexture:u}=i;function h(t,n,r){if(t&&(e.push(n),o.activeTexture.set(o.gl.TEXTURE0+r),t.gfxTexture)){const{minFilter:e,magFilter:n,wrapS:r,wrapT:i}=t.sampler;t.gfxTexture.bindExtraParam(e,n,r,i)}}h(a,"HAS_TEXTURE_u_baseColorTexture",mr.BaseColor),h(s,"HAS_TEXTURE_u_metallicRoughnessTexture",mr.MetallicRoughness),h(l,"HAS_TEXTURE_u_normalTexture",mr.Normal),h(c,"HAS_TEXTURE_u_occlusionTexture",mr.Occlusion),h(u,"HAS_TEXTURE_u_emissionTexture",mr.Emission),n.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(n.texcoordBuffer)),n.colorBuffer&&(e.push(12===n.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(n.colorBuffer)),n.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(n.normalBuffer)),n.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(n.pbrBuffer)),"OPAQUE"!==i.alphaMode&&"MASK"!==i.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),i.defined||e.push("DIFFUSE_SHADED"),e.push("USE_STANDARD_DERIVATIVES")}function No(t,n,r,i,o,a){const s=r.paint.get("model-opacity"),l=n.context,c=new Et(n.context.gl.LEQUAL,Et.ReadWrite,n.depthRangeFor3D),u=n.transform,h=t.mesh,d=h.material,f=d.pbrMetallicRoughness,p=n.style.fog;let m;m="pixels"===n.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.a9.multiply([],i.zScaleMatrix,t.nodeModelMatrix),e.a9.multiply(m,i.negCameraPosMatrix,m);const g=e.a9.invert([],m);e.a9.transpose(g,g);const _=r.paint.get("model-emissive-strength").constantOr(0),y=Hi(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(g),null,n,s,f.baseColorFactor,d.emissiveFactor,f.metallicFactor,f.roughnessFactor,d,_,r),v={defines:[]},x=[];Fo(v.defines,x,h,n);const b=n.shadowRenderer;b&&(b.useNormalOffset=!1);let w=null;if(p){const e=Bo(t.nodeModelMatrix,n.transform);if(w=new Float32Array(e),"globe"!==u.projection.name){const t=h.aabb.min,n=h.aabb.max,[r,i]=p.getOpacityForBounds(e,t[0],t[1],n[0],n[1]);v.overrideFog=r>=fe||i>=fe}}const S=gr(n,r.paint.get("model-cutoff-fade-range"));S.shouldRenderCutoff&&v.defines.push("RENDER_CUTOFF");const M=n.getOrCreateProgram("model",v);n.uploadCommonUniforms(l,M,null,w,S),"shadow"!==n.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,M),M.draw(n,l.gl.TRIANGLES,c,o,a,h.material.doubleSided?Lt.disabled:Lt.backCCW,y,r.id,h.vertexBuffer,h.indexBuffer,h.segments,r.paint,n.transform.zoom,void 0,x)}function jo(t,n,r,i,o,a,s){let l;l="globe"===t.projection.name?e.c_(r,t):[...r],e.a9.multiply(l,l,n.matrix);const c=e.a9.multiply([],i,l);if(n.meshes)for(const u of n.meshes){if("BLEND"!==u.material.alphaMode){s.push({mesh:u,depth:0,modelIndex:o,worldViewProjection:c,nodeModelMatrix:l});continue}const t=e.Q.transformMat4([],u.centroid,c);t[2]>0&&a.push({mesh:u,depth:t[2],modelIndex:o,worldViewProjection:c,nodeModelMatrix:l})}if(n.children)for(const e of n.children)jo(t,e,r,i,o,a,s)}function Vo(e,t,n,r){const i=n.shadowRenderer;if(!i)return;const o=i.getShadowPassDepthMode(),a=i.getShadowPassColorMode(),s=i.calculateShadowPassMatrixFromMatrix(t),l=Zi(s);n.getOrCreateProgram("modelDepth",{defines:n._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(n,n.context.gl.TRIANGLES,o,Ct.disabled,a,Lt.backCCW,l,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,n.transform.zoom,void 0,void 0)}function Uo(t,n,r){const i=n.updateZoomBasedPaintProperties(),o=function(t,n,r){let i,o,a,s=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&s>0){const n=t.terrain,o=n.findDEMTileFor(r);o&&o.dem?i=e.d0.create(n,r,o):s=0}if(0===s&&(n.terrainElevationMin=0,n.terrainElevationMax=0),s===n.validForExaggeration&&(0===s||i&&i._demTile&&i._demTile.tileID===n.validForDEMTile.id&&i._dem._timestamp===n.validForDEMTile.timestamp))return!1;for(const e in n.instancesPerModel){const t=n.instancesPerModel[e];for(let e=0;eu&&(u=e.max)}const h=e.ad(i.x,a,s)-i.x,d=e.ad(i.y,l,c)-i.y,f=e.bo(u,n.center.lat)-i.z;return n._zoomFromMercatorZ(Math.sqrt(h*h+d*d+f*f))}function Wo(e,t,n,r,i,o,a){const s=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,u=l&&c?c.getShadowPassDepthMode():new Et(s.gl.LEQUAL,Et.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o);if(n.meshes)for(const d of n.meshes){const f=["MODEL_POSITION_ON_GPU"],p=[];let m,g,_;r.instancedDataArray.length>20&&f.push("INSTANCED_ARRAYS");const y=gr(e,t.paint.get("model-cutoff-fade-range"));if(y.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:f}),g=Zi(a.shadowTileMatrix,a.shadowTileMatrix,Float32Array.from(n.matrix)),_=c.getShadowPassColorMode();else{Fo(f,p,d,e),m=e.getOrCreateProgram("model",{defines:f,overrideFog:h});const r=d.material,l=r.pbrMetallicRoughness,u=t.paint.get("model-opacity"),v=t.paint.get("model-emissive-strength").constantOr(0);g=Hi(o.expandedProjMatrix,Float32Array.from(n.matrix),new Float32Array(16),null,e,u,l.baseColorFactor,r.emissiveFactor,l.metallicFactor,l.roughnessFactor,r,v,t,i),c&&(a.shadowUniformsInitialized?m.setShadowUniformValues(s,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),m,"model-tile",o.overscaledZ),a.shadowUniformsInitialized=!0)),_=y.shouldRenderCutoff||u<1||"OPAQUE"!==r.alphaMode?It.alphaBlended:It.unblended}e.uploadCommonUniforms(s,m,o.toUnwrapped(),null,y);const v=d.material.doubleSided?Lt.disabled:Lt.backCCW;if(r.instancedDataArray.length>20)p.push(r.instancedDataBuffer),m.draw(e,s.gl.TRIANGLES,u,Ct.disabled,_,v,g,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,p,r.instancedDataArray.length);else{const n=l?"u_instance":"u_normal_matrix";for(let i=0;i30&&(n.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}const Xo={symbol:function(t,n,r,i,o){if("translucent"!==t.renderPass)return;const a=Ct.disabled,s=t.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(t,n,r,i,o,a,s){const l=n.transform,c="map"===o,u="map"===a;for(const h of t){const t=i.getTile(h),n=t.getBucket(r);if(!n||!n.text||!n.text.segments.get().length)continue;const o=e.b8(n.textSizeData,l.zoom),a=Ln(h,n.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),f=pn(a,t.tileID.canonical,u,c,l,n.getProjection(),d),p=n.hasIconTextFit()&&n.hasIconData();if(o){const r=Math.pow(2,l.zoom-t.tileID.overscaledZ);eo(n,c,u,s,e.cE,l,f,h,r,o,p)}}}(i,t,r,n,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o);const l=0!==r.paint.get("icon-opacity").constantOr(1),c=0!==r.paint.get("text-opacity").constantOr(1);void 0!==r.layout.get("symbol-sort-key").constantOr(1)&&(l||c)?to(t,n,r,i,a,s):(l&&to(t,n,r,i,a,s,{onlyIcons:!0}),c&&to(t,n,r,i,a,s,{onlyText:!0})),n.map.showCollisionBoxes&&(Xi(t,n,r,i,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),Xi(t,n,r,i,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(t,n,r,i){if("translucent"!==t.renderPass)return;const o=r.paint.get("circle-opacity"),a=r.paint.get("circle-stroke-width"),s=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1),c=r.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===a.constantOr(1)||0===s.constantOr(1)))return;const u=t.context,h=u.gl,d=t.transform,f=t.depthModeForSublayer(0,Et.ReadOnly),p=Ct.disabled,m=t.colorModeForDrapableLayerRenderPass(c),g="globe"===d.projection.name,_=[e.a8(d.center.lng),e.ah(d.center.lat)],y=[];for(let x=0;xe.sortKey-t.sortKey));const v={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of y){const{programConfiguration:n,program:i,layoutVertexBuffer:o,globeExtVertexBuffer:a,indexBuffer:s,uniformValues:l,tile:c}=e.state,g=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,i,v),t.uploadCommonUniforms(u,i,c.tileID.toUnwrapped()),i.draw(t,h.TRIANGLES,f,p,m,Lt.disabled,l,r.id,o,s,g,r.paint,d.zoom,n,[a])}},heatmap:function(t,n,r,i){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,a=o.gl,s=Ct.disabled,l=new It([a.ONE,a.ONE,a.ONE,a.ONE],e.aA.transparent,[!0,!0,!0,!0]);!function(e,t,n,r){const i=e.gl,o=t.width*r,a=t.height*r;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,o,a]);let s=n.heatmapFbo;if(!s||s&&(s.width!==o||s.height!==a)){s&&s.destroy();const t=i.createTexture();i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),s=n.heatmapFbo=e.createFramebuffer(o,a,!0,null),function(e,t,n,r,i,o){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?a.RGBA16F:a.RGBA,i,o,0,a.RGBA,e.extRenderToTextureHalfFloat?a.HALF_FLOAT:a.UNSIGNED_BYTE,null),r.colorAttachment.set(n)}(e,0,t,s,o,a)}else i.bindTexture(i.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer)}(o,t,r,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.aA.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:[],d=u?Lt.frontCCW:Lt.disabled,f=[e.a8(c.center.lng),e.ah(c.center.lat)];for(let e=0;e({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,n),n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,n.paint,t.transform.zoom)}(t,r))},line:function(t,n,r,i){if("translucent"!==t.renderPass)return;const o=r.paint.get("line-opacity"),a=r.paint.get("line-width");if(0===o.constantOr(1)||0===a.constantOr(1))return;const s=r.paint.get("line-emissive-strength"),l=t.depthModeForSublayer(0,Et.ReadOnly),c=t.colorModeForDrapableLayerRenderPass(s),u=t.terrain&&t.terrain.renderingToTexture?1:e.f.devicePixelRatio,h=r.paint.get("line-dasharray"),d=h.constantOr(1),f=r.layout.get("line-cap"),p=r.paint.get("line-pattern"),m=p.constantOr(1),g=1!==r.paint.get("line-opacity").constantOr(1);let _=!m&&g;const y=r.paint.get("line-gradient"),v=m?"linePattern":"line",x=t.context,b=x.gl,w=e.cH(r);t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(_=!1);for(const S of i){const i=n.getTile(S);if(m&&!i.patternsLoaded())continue;const o=i.getBucket(r);if(!o)continue;t.prepareDrawTile();const a=o.programConfigurations.get(r.id),s=t.isTileAffectedByFog(S),g=t.getOrCreateProgram(v,{config:a,defines:w,overrideFog:s}),M=p.constantOr(null);if(M&&i.imageAtlas){const e=i.imageAtlas.patternPositions[M.toString()];e&&a.setConstantPatternPositions(e)}const A=h.constantOr(null),E=f.constantOr(null);if(!m&&A&&E&&i.lineAtlas){const e=i.lineAtlas.getDash(A,E);e&&a.setConstantPatternPositions(e)}let[T,C]=r.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;T!==C&&(0===T&&(T-=e),1===C&&(C+=e))}const k=t.terrain?S.projMatrix:null,I=m?e.cI(t,i,r,k,u,[T,C]):e.cJ(t,i,r,k,o.lineClipsArray.length,u,[T,C]);if(y){const i=o.gradients[r.id];let a=i.texture;if(r.gradientVersion!==i.version){let s=256;if(r.stepInterpolant){const r=n.getSource().maxzoom,i=S.canonical.z===r?Math.ceil(1<{g.draw(t,b.TRIANGLES,l,e,c,Lt.disabled,I,r.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,r.paint,t.transform.zoom,a,[o.layoutVertexBuffer2,o.patternVertexBuffer])};if(_){const e=t.stencilModeForClipping(S).ref;0===e&&t.terrain&&x.clear({stencil:0});const n={func:b.EQUAL,mask:255};I.u_alpha_discard_threshold=.8,P(new Ct(n,e,255,b.KEEP,b.KEEP,b.INVERT)),I.u_alpha_discard_threshold=0,P(new Ct(n,e,255,b.KEEP,b.KEEP,b.KEEP))}else P(t.stencilModeForClipping(S))}_&&(t.resetStencilClippingMasks(),t.terrain&&x.clear({stencil:0}))},fill:function(t,n,r,i){const o=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0===a.constantOr(1))return;const s=r.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(s),c=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.aA.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const e=t.depthModeForSublayer(1,"opaque"===t.renderPass?Et.ReadWrite:Et.ReadOnly);ro(t,n,r,i,e,l,!1)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const e=t.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,Et.ReadOnly);ro(t,n,r,i,e,l,!0)}},"fill-extrusion":function(t,n,r,i){const o=r.paint.get("fill-extrusion-opacity"),a=t.context,s=a.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const u=t.conflationActive&&t.layerUsedInConflation(r,n.getSource());if(u&&function(e,t,n,r){for(const i of r){const r=t.getTile(i).getBucket(n);r&&(r.updateReplacement(i,e.replacementSource),r.uploadCentroid(e.context))}}(t,n,r,i),l||u)for(const e of i){const i=n.getTile(e).getBucket(r);i&&ao(t.context,n,e,i,r,l,u)}if("shadow"===t.renderPass&&t.shadowRenderer){const a=t.shadowRenderer;if(l&&o<.65&&r._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.Z)return;const s=a.getShadowPassDepthMode(),c=a.getShadowPassColorMode();io(t,n,r,i,s,Ct.disabled,c,u)}else if("translucent"===t.renderPass){const h=!r.paint.get("fill-extrusion-pattern").constantOr(1),d=r.paint.get("fill-extrusion-color").constantOr(e.aA.white);if(!c&&0!==d.a){const e=new Et(t.context.gl.LEQUAL,Et.ReadWrite,t.depthRangeFor3D);1===o&&h?io(t,n,r,i,e,Ct.disabled,It.unblended,u):(io(t,n,r,i,e,Ct.disabled,It.disabled,u),io(t,n,r,i,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),u),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&h&&(!l&&"globe"!==t.transform.projection.name||c)){const o=r.paint.get("fill-extrusion-opacity"),h=r.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=r.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),f=r.paint.get("fill-extrusion-flood-light-intensity"),p=r.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),m=h>0&&d>0,g=f>0,_=(e,t,n)=>(1-n)*e+n*t,y=a=>{const l=t.depthModeForSublayer(1,Et.ReadOnly,s.LEQUAL,!0),c=r.paint.get(a?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),m=_(.1,3,c),g=t._showOverdrawInspector;if(!g){const c=new Ct({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),g=new It([s.ONE,s.ONE,s.ONE,s.ONE],e.aA.transparent,[!1,!1,!1,!0],s.MIN);oo(t,n,r,i,l,c,g,Lt.disabled,a,"sdf",o,h,d,f,p,m,u,!1)}{const c=g?Ct.disabled:new Ct({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),_=g?t.colorModeForRenderPass():new It([s.ONE_MINUS_DST_ALPHA,s.DST_ALPHA,s.ONE,s.ONE],e.aA.transparent,[!0,!0,!0,!0]);oo(t,n,r,i,l,c,_,Lt.disabled,a,"color",o,h,d,f,p,m,u,!1)}};if(c){const c=(a,l,c)=>{const m=t.depthModeForSublayer(1,Et.ReadOnly,s.LEQUAL,!1),g=r.paint.get(a?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),y=_(.1,3,g);{const c=new It([s.ONE,s.ONE,s.ONE,s.ONE],e.aA.transparent,[!1,!1,!1,!0]);oo(t,n,r,i,m,Ct.disabled,c,Lt.disabled,a,"clear",o,h,d,f,p,y,u,l)}{const c=new Ct({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),g=new It([s.ONE,s.ONE,s.ONE,s.ONE],e.aA.transparent,[!1,!1,!1,!0],s.MIN);oo(t,n,r,i,m,c,g,Lt.disabled,a,"sdf",o,h,d,f,p,y,u,l)}{const c=a?s.ZERO:s.ONE_MINUS_DST_ALPHA,g=new Ct({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),_=new It([c,s.DST_ALPHA,s.ONE_MINUS_DST_ALPHA,s.ZERO],e.aA.transparent,[!0,!0,!0,!0]);oo(t,n,r,i,m,g,_,Lt.disabled,a,"color",o,h,d,f,p,y,u,l)}{const g=new It([s.ONE,s.ONE,s.ONE,a?s.ZERO:s.ONE],e.aA.transparent,[!1,!1,!1,!0],a?s.FUNC_ADD:s.MAX);oo(t,n,r,i,m,Ct.disabled,g,Lt.disabled,a,"clear",o,h,d,f,p,y,u,l,c)}};if(m||g){let n;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],r=l.drapeBufferSize[1];n=l.framebufferCopyTexture,n&&(!n||n.size[0]===t&&n.size[1]===r)||(n&&n.destroy(),n=l.framebufferCopyTexture=new e.T(a,new e.h({width:t,height:r}),s.RGBA)),n.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGBA,0,0,t,r,0)}m&&c(!0,!1,n),g&&c(!1,!0,n)}}else m&&y(!0),g&&y(!1)}}},hillshade:function(e,t,n,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const i=e.context,o=e.terrain&&e.terrain.renderingToTexture,[a,s]="translucent"!==e.renderPass||o?[{},r]:e.stencilConfigForOverlap(r);for(const l of s){const r=t.getTile(l);if(r.needsHillshadePrepare&&"offscreen"===e.renderPass)ei(e,r,n);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Et.ReadOnly),i=n.paint.get("hillshade-emissive-strength"),s=e.colorModeForDrapableLayerRenderPass(i),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(l):a[l.overscaledZ];Jr(e,l,r,n,t,c,s)}}i.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(t,n,r,i,o,a){if("translucent"!==t.renderPass)return;if(0===r.paint.get("raster-opacity"))return;const s="globe"===t.transform.projection.name,l=0!==r.paint.get("raster-elevation"),c=l&&s;if(t.renderElevatedRasterBackface&&!c)return;const u=t.context,h=u.gl,d=n.getSource(),f=function(t,n,r,i){const o=n.paint.get("raster-color"),a="raster-array"===t.type,s=[],l=n.paint.get("raster-resampling"),c=n.paint.get("raster-color-mix");let u=n.paint.get("raster-color-range");const h=[c[0],c[1],c[2],0],d=c[3];let f="nearest"===l?i.NEAREST:i.LINEAR;if(a&&(s.push("RASTER_ARRAY"),o||s.push("RASTER_COLOR"),"linear"===l&&s.push("RASTER_ARRAY_LINEAR"),f=i.NEAREST,!u&&t.rasterLayers)){const e=t.rasterLayers.find((e=>{let{id:t}=e;return t===n.sourceLayer}));e&&e.fields&&e.fields.range&&(u=e.fields.range)}if(u=u||[0,1],o){s.push("RASTER_COLOR"),r.activeTexture.set(i.TEXTURE2),n.updateColorRamp(u);let t=n.colorRampTexture;t||(t=n.colorRampTexture=new e.T(r,n.colorRamp,i.RGBA)),t.bind(i.LINEAR,i.CLAMP_TO_EDGE)}return{mix:h,range:u,offset:d,defines:s,resampling:f}}(d,r,u,h);if(d instanceof e.as&&!i.length&&!s)return;const p=r.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(p),g=t.terrain&&t.terrain.renderingToTexture,_=!t.options.moving,y="nearest"===r.paint.get("raster-resampling")?h.NEAREST:h.LINEAR;if(d instanceof e.as&&!i.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():Ct.disabled;return void fo(!!d.onNorthPole,null,t,n,r,p,f,Lt.disabled,e)}if(!i.length)return;const[v,x]=d instanceof e.as||g?[{},i]:t.stencilConfigForOverlap(i),b=x[x.length-1].overscaledZ;c&&f.defines.push("PROJECTION_GLOBE_VIEW"),l&&f.defines.push("RENDER_CUTOFF");const w=(i,o,x)=>{for(const w of i){const i=w.toUnwrapped(),S=n.getTile(w);if(g&&(!S||!S.hasData()))continue;u.activeTexture.set(h.TEXTURE0);const M=mo(S,d,r,f);if(!M||!M.texture)continue;const{texture:A,mix:E,offset:T,tileSize:C,buffer:k}=M;let I,P;g?(I=Et.disabled,P=w.projMatrix):l?(I=new Et(h.LEQUAL,Et.ReadWrite,t.depthRangeFor3D),P=s?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(i,_)):(I=t.depthModeForSublayer(w.overscaledZ-b,1===r.paint.get("raster-opacity")?Et.ReadWrite:Et.ReadOnly,h.LESS),P=t.transform.calculateProjMatrix(i,_));const R=t.terrain&&g?t.terrain.stencilModeForRTTOverlap(w):v[w.overscaledZ],L=a?0:r.paint.get("raster-fade-duration");S.registerFadeDuration(L);const z=n.findLoadedParent(w,0),O=ui(S,z,n,t.transform,L);let D,B;t.terrain&&t.terrain.prepareDrawTile(),u.activeTexture.set(h.TEXTURE0),A.bind(y,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE1),z?(z.texture&&z.texture.bind(y,h.CLAMP_TO_EDGE),D=Math.pow(2,z.tileID.overscaledZ-S.tileID.overscaledZ),B=[S.tileID.canonical.x*D%1,S.tileID.canonical.y*D%1]):A.bind(y,h.CLAMP_TO_EDGE),A.useMipmap&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&h.texParameterf(h.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const F=t.transform;let N;const j=l?po(F):[0,0,0,0];let V,U,G,q,W,H=0;if(c&&d instanceof e.as&&d.coordinates.length>3)V=Float32Array.from(e.aW(e.cn(new e.bv(0,0,0)))),U=Float32Array.from(F.globeMatrix),G=Float32Array.from(e.cj(F)),q=[e.a8(F.center.lng),e.ah(F.center.lat)],N=d.elevatedGlobePerspectiveTransform,W=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.ck(w.canonical);H=e.cl(t.getCenter().lat),V=Float32Array.from(e.aW(e.cn(w.canonical))),U=Float32Array.from(F.globeMatrix),G=Float32Array.from(e.cj(F)),q=[e.a8(F.center.lng),e.ah(F.center.lat)],N=[0,0],W=Float32Array.from(e.cm(w.canonical,t,H,F.worldSize/F._pixelsPerMercatorPixel))}else N=d instanceof e.as?d.perspectiveTransform:[0,0],V=new Float32Array(16),U=new Float32Array(9),G=new Float32Array(16),q=[0,0],W=new Float32Array(9);const Z=zi(P,V,U,G,W,B||[0,0],e.W(t.transform.zoom),q,j,D||1,O,r,N,l?r.paint.get("raster-elevation"):0,2,E,T,f.range,C,k,p),Y=t.isTileAffectedByFog(w),Q=t.getOrCreateProgram("raster",{defines:f.defines,overrideFog:Y});if(t.uploadCommonUniforms(u,Q,i),d instanceof e.as){const n=d.elevatedGlobeVertexBuffer,i=d.elevatedGlobeIndexBuffer;if(g||!s)d.boundsBuffer&&d.boundsSegments&&Q.draw(t,h.TRIANGLES,I,Ct.disabled,m,Lt.disabled,Z,r.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(n&&i){const a=F.zoom<=e.bJ?d.elevatedGlobeSegments:d.getSegmentsForLongitude(F.center.lng);a&&Q.draw(t,h.TRIANGLES,I,Ct.disabled,m,o,Z,r.id,n,i,a)}}else if(c){I=new Et(h.LEQUAL,Et.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[n,i,a]=e.getGridBuffers(H,!1);Q.draw(t,h.TRIANGLES,I,x||R,t.colorModeForRenderPass(),o,Z,r.id,n,i,a)}}else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:n,tileBoundsSegments:i}=t.getTileBoundsBuffers(S);Q.draw(t,h.TRIANGLES,I,R,m,Lt.disabled,Z,r.id,e,n,i)}}if(!(d instanceof e.as)&&c)for(const e of i){const i=e.canonical.y===(1<e.cN[t](i)));p.push(i);const m=i.canonical.x,g=i.canonical.y;for(const e of p){const o=n.getTile(l?e.wrapped():e);if(!o)continue;const s=o.rasterParticleState;if(!s)continue;const u=e.canonical.x+(1<e.tileID))),h&&(s.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context,n.scope));for(const v of y){const d=e.isTileAffectedByFog(v),y=e.getOrCreateProgram(g,{overrideFog:d}),x=v.toUnwrapped(),b=r?v.projMatrix:e.transform.calculateProjMatrix(x);e.prepareDrawTile();const w=t?t.getTile(v):_?_[v.key]:new Nt(v,u,c.zoom,e),S=h?qi(b,a,o,e,h,n.scope,{tileID:v,tileSize:u}):Gi(b,a,o,i);e.uploadCommonUniforms(s,y,x);const{tileBoundsBuffer:M,tileBoundsIndexBuffer:A,tileBoundsSegments:E}=e.getTileBoundsBuffers(w);y.draw(e,l.TRIANGLES,p,f,m,Lt.disabled,S,n.id,M,A,E)}},sky:function(t,n,r){const i=t._atmosphere?e.W(t.transform.zoom):1,o=r.paint.get("sky-opacity")*i;if(0===o)return;const a=t.context,s=r.paint.get("sky-type"),l=new Et(a.gl.LEQUAL,Et.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===s?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&(function(t,n,r,i){const o=t.context,a=o.gl;let s=n.skyboxFbo;if(!s){s=n.skyboxFbo=o.createFramebuffer(32,32,!0,null),n.skyboxGeometry=new Io(o),n.skyboxTexture=o.gl.createTexture(),a.bindTexture(a.TEXTURE_CUBE_MAP,n.skyboxTexture),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR);for(let e=0;e<6;++e)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,a.RGBA,32,32,0,a.RGBA,a.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(s.framebuffer),o.viewport.set([0,0,32,32]);const l=n.getCenter(t,!0),c=t.getOrCreateProgram("skyboxCapture"),u=new Float64Array(16);e.a9.identity(u),e.a9.rotateY(u,u,.5*-Math.PI),Po(t,n,c,u,l,0),e.a9.identity(u),e.a9.rotateY(u,u,.5*Math.PI),Po(t,n,c,u,l,1),e.a9.identity(u),e.a9.rotateX(u,u,.5*-Math.PI),Po(t,n,c,u,l,2),e.a9.identity(u),e.a9.rotateX(u,u,.5*Math.PI),Po(t,n,c,u,l,3),e.a9.identity(u),Po(t,n,c,u,l,4),e.a9.identity(u),e.a9.rotateY(u,u,Math.PI),Po(t,n,c,u,l,5),o.viewport.set([0,0,t.width,t.height])}(t,r),r.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,n,r,i){const o=e.context,a=o.gl,s=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,n,r,i)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:i}))(s.skyboxMatrix,t.getCenter(e,!1),0,r,i);e.uploadCommonUniforms(o,l),l.draw(e,a.TRIANGLES,n,Ct.disabled,e.colorModeForRenderPass(),Lt.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(t,r,l,o,c):"gradient"===s&&"sky"===t.renderPass&&function(t,n,r,i,o){const a=t.context,s=a.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");n.skyboxGeometry||(n.skyboxGeometry=new Io(a)),a.activeTexture.set(s.TEXTURE0);let u=n.colorRampTexture;u||(u=n.colorRampTexture=new e.T(a,n.colorRamp,s.RGBA)),u.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=((t,n,r,i,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:n,u_radius:e.bm(r),u_opacity:i,u_temporal_offset:o}))(l.skyboxMatrix,n.getCenter(t,!1),n.paint.get("sky-gradient-radius"),i,o);t.uploadCommonUniforms(a,c),c.draw(t,s.TRIANGLES,r,Ct.disabled,t.colorModeForRenderPass(),Lt.backCW,h,"skyboxGradient",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,r,l,o,c)},debug:function(t,n,r,i,o,a){for(let s=0;s{s&&(s.useNormalOffset=!0,l||(s.enabled=!0))},u=n.getSource();if("light-beam"===t.renderPass&&"batched-model"!==u.type)return;if("vector"===u.type||"geojson"===u.type)return function(t,n,r,i,o){const a=t.transform;if("mercator"!==a.projection.name)return void e.w("Drawing 3D models for ".concat(a.projection.name," projection is not yet implemented"));const s=a.getFreeCameraOptions().position;if(!t.modelManager)return;const l=t.modelManager;r.modelManager=l;const c=t.shadowRenderer;if(!r._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const u=r._unevaluatedLayout._values["model-id"],h={...r.layout.get("model-id").parameters};for(const d of i){const i=n.getTile(d).getBucket(r);if(!i||i.projection.name!==a.projection.name)continue;const f=i.getModelUris();f&&!i.modelsRequested&&(l.addModelsFromBucket(f,o),i.modelsRequested=!0);const p=qo(d,a);h.zoom=p;const m=u.possiblyEvaluate(h);if(Uo(t,i,d),Go.shadowUniformsInitialized=!1,Go.useSingleShadowCascade=!!c&&0===c.getMaxCascadeForTile(d.toUnwrapped()),"shadow"===t.renderPass&&c){if(1===t.currentShadowCascade&&i.isInsideFirstShadowMapFrustum)continue;const n=a.calculatePosMatrix(d.toUnwrapped(),a.worldSize);if(Go.tileMatrix.set(n),Go.shadowTileMatrix=Float32Array.from(c.calculateShadowPassMatrixFromMatrix(n)),Go.aabb.min.fill(0),Go.aabb.max[0]=Go.aabb.max[1]=e.Y,Go.aabb.max[2]=0,Zo(i,Go,t,r.scope))continue}const g=1<0&&(e=m.evaluate(n.features[0].feature,{}));const a=l.getModel(e,o);if(a&&a.uploaded)for(const e of a.nodes)Wo(t,r,e,n,_,d,Go)}}}(t,n,r,i,"vector"===u.type?r.scope:""),void c();if(!u.loaded())return;if("batched-model"===u.type)return function(t,n,r,i){r.resetLayerRenderingStats(t);const o=t.context,a=t.transform,s=t.style.fog,l=t.shadowRenderer;if("mercator"!==a.projection.name)return void e.w("Drawing 3D landmark models for ".concat(a.projection.name," projection is not yet implemented"));const c=t.transform.getFreeCameraOptions().position,u=e.Q.scale([],[c.x,c.y,c.z],t.transform.worldSize);e.Q.negate(u,u);const h=e.a9.identity([]),d=e.cZ(a.center.lat,a.zoom),f=e.a9.fromScaling([],[1,1,1/d]);e.a9.translate(h,h,u);const p=r.paint.get("model-opacity"),m=new Et(o.gl.LEQUAL,Et.ReadWrite,t.depthRangeFor3D),g=new Et(o.gl.LEQUAL,Et.ReadOnly,t.depthRangeFor3D),_=new e.bV([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),y="shadow"===t.renderPass,v=y&&l?l.getCurrentCascadeFrustum():a.getFrustum(a.scaleZoom(a.worldSize)),x=r.getLayerRenderingStats(),b=function(c,u){for(const d of i){const i=n.getTile(d).getBucket(r);if(!i||!i.uploaded)continue;let b=!1;l&&(b=0===l.getMaxCascadeForTile(d.toUnwrapped()));const w=a.calculatePosMatrix(d.toUnwrapped(),a.worldSize),S=i.modelTraits;for(const n of i.getNodesInfo()){if(n.hiddenByReplacement)continue;if(!n.node.meshes)continue;const i=n.evaluatedScale,d=n.node;let M=0;if(t.terrain&&d.elevation&&(M=d.elevation*t.terrain.exaggeration()),i[0]<=1&&i[1]<=1&&i[2]<=1&&0===(()=>{const t=n.getLocalBounds();return _.min=[...t.min],_.max=[...t.max],_.min[2]+=M,_.max[2]+=M,e.Q.transformMat4(_.min,_.min,w),e.Q.transformMat4(_.max,_.max,w),_})().intersects(v))continue;const A=[...w];e.a9.translate(A,A,[(d.anchor?d.anchor[0]:0)*(i[0]-1),(d.anchor?d.anchor[1]:0)*(i[1]-1),M]),e.Q.exactEquals(i,e.c$)||e.a9.scale(A,A,i);const E=e.a9.multiply([],A,d.matrix);let T=e.a9.multiply([],f,A);e.a9.multiply(T,h,T);const C=e.a9.invert([],T);e.a9.transpose(C,C),e.a9.scale(C,C,Ho),T=e.a9.multiply(T,T,d.matrix);const k="light-beam"===t.renderPass,I=e.a9.multiply([],a.expandedFarZProjMatrix,E),P=e.a9.multiply([],a.expandedFarZProjMatrix,A),R=S&e.d1.HasMapboxMeshFeatures,L=R?0:n.evaluatedRMEA[0][2];for(let e=0;e=fe||o>=fe}}const S=i.material;let M;S.occlusionTexture&&S.occlusionTexture.offsetScale&&(M=S.occlusionTexture.offsetScale,_.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),!y&&l&&(l.useNormalOffset=!!i.normalBuffer);const z=t.getOrCreateProgram("model",_);!y&&l&&l.setupShadowsFromMatrix(A,z,l.useNormalOffset),t.uploadCommonUniforms(o,z,null,w);const O=S.pbrMetallicRoughness;O.metallicFactor=.9,O.roughnessFactor=.5;const D=Hi(new Float32Array(f),new Float32Array(T),new Float32Array(C),new Float32Array(d.matrix),t,p,O.baseColorFactor,S.emissiveFactor,O.metallicFactor,O.roughnessFactor,S,L,r,[0,0,0],M);z.draw(t,o.gl.TRIANGLES,u&&!h?m:g,Ct.disabled,c?h||p<1||n.hasTranslucentParts?It.alphaBlended:It.unblended:It.disabled,Lt.backCCW,D,r.id,i.vertexBuffer,i.indexBuffer,i.segments,r.paint,t.transform.zoom,void 0,v)}}}};(function(e,t,n,r){const i=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const a of r){const r=t.getTile(a).getBucket(n);r&&(e.conflationActive&&r.updateReplacement(a,e.replacementSource),r.evaluateScale(e,n),e.terrain&&i>0&&r.elevationUpdate(e.terrain,i,a,n.source),r.needsReEvaluation(e,o,n)&&r.evaluate(n))}})(t,n,r,i),1===p?b(!0,!0):(b(!1,!0),b(!0,!1))}(t,n,r,i),void c();const h=u.getModels(),d=[],f=t.transform.getFreeCameraOptions().position,p=e.Q.scale([],[f.x,f.y,f.z],t.transform.worldSize);e.Q.negate(p,p);const m=[],g=[];let _=0;for(const y of h){const n=r.paint.get("model-rotation").constantOr(null),i=r.paint.get("model-scale").constantOr(null),o=r.paint.get("model-translation").constantOr(null);y.computeModelMatrix(t,n,i,o,!0,!0,!1);const a=e.a9.identity([]),s=e.cZ(y.position.lat,t.transform.zoom),l=e.a9.fromScaling([],[1,1,1/s]);e.a9.translate(a,a,p),d.push({zScaleMatrix:l,negCameraPosMatrix:a});for(const e of y.nodes)jo(t.transform,e,y.matrix,t.transform.expandedFarZProjMatrix,_,m,g);_++}if(m.sort(((e,t)=>t.depth-e.depth)),"shadow"!==t.renderPass){if(1===o)for(const e of g)No(e,t,r,d[e.modelIndex],Ct.disabled,t.colorModeForRenderPass());else{for(const e of g)No(e,t,r,d[e.modelIndex],Ct.disabled,It.disabled);for(const e of g)No(e,t,r,d[e.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks()}for(const e of m)No(e,t,r,d[e.modelIndex],Ct.disabled,t.colorModeForRenderPass());c()}else{for(const e of g)Vo(e.mesh,e.nodeModelMatrix,t,r);for(const e of m)Vo(e.mesh,e.nodeModelMatrix,t,r);c()}}},Ko={model:function(e,t,n){const r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type)return void(n.modelManager&&n.modelManager.upload(n,"vector"===r.type?e.scope:""));if("batched-model"===r.type)return;const i=r.getModels();for(const o of i)o.upload(n.context)},raster:function(e,t,n){const r=t.getSource();if(!(r instanceof Pe&&r.loaded()))return;const i=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!i)return;const o=e.paint.get("raster-array-band")||r.getInitialBand(i);if(null==o)return;const a=t.getIds().map((e=>t.getTileByID(e)));for(const s of a)s.updateNeeded(i,o)&&r.prepareTile(s,i,o)},"raster-particle":function(e,t,n){const r=t.getSource();if(!(r instanceof Pe&&r.loaded()))return;const i=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!i)return;const o=e.paint.get("raster-particle-array-band")||r.getInitialBand(i);if(null==o)return;const a=t.getIds().map((e=>t.getTileByID(e)));for(const s of a)s.updateNeeded(i,o)&&r.prepareTile(s,i,o)}};class Jo{constructor(t,n,r,i){this.context=new zt(t,n),this.transform=r,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=i,this._timeStamp=(new Date).getTime(),this._averageFPS=0,this._fpsHistory=[],this._debugParams={showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const o=["fill","line","symbol","circle","heatmap","fill-extrusion","raster","raster-particle","hillshade","model","background","sky"];for(const e of o)this._debugParams.enabledLayers[e]=!0;i.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(()=>{this.style.map.triggerRepaint()})),i.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),i.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),i.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),i.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of o)i.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.setup(),this.numSublayers=Yt.maxUnderzooming+Yt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.d3,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new xr(this),this._wireframeDebugCache=new Qo,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0}updateTerrain(e,t){const n=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(n||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new pi(this,e));const r=this._terrain;this.transform.elevation=n?r:null,r.update(e,this.transform,t),this.transform.elevation&&!r.enabled&&(this.transform.elevation=null)}_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[n,r]=t.getFovAdjustedRange(this.transform._fov);if(n>r)return void(this.transform.fogCullDistSq=null);const i=n+.78*(r-n);this.transform.fogCullDistSq=i*i}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,n){if(this.width=t*e.f.devicePixelRatio,this.height=n*e.f.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize()}setup(){const t=this.context,n=new e.aQ;n.emplaceBack(0,0),n.emplaceBack(e.Y,0),n.emplaceBack(0,e.Y),n.emplaceBack(e.Y,e.Y),this.tileExtentBuffer=t.createVertexBuffer(n,e.aS.members),this.tileExtentSegments=e.aE.simpleSegment(0,0,4,2);const r=new e.aQ;r.emplaceBack(0,0),r.emplaceBack(e.Y,0),r.emplaceBack(0,e.Y),r.emplaceBack(e.Y,e.Y),this.debugBuffer=t.createVertexBuffer(r,e.aS.members),this.debugSegments=e.aE.simpleSegment(0,0,4,5);const i=new e.aQ;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(-1,1),i.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(i,e.aS.members),this.viewportSegments=e.aE.simpleSegment(0,0,4,2);const o=new e.ay;o.emplaceBack(0,0,0,0),o.emplaceBack(e.Y,0,e.Y,0),o.emplaceBack(0,e.Y,0,e.Y),o.emplaceBack(e.Y,e.Y,e.Y,e.Y),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.aU.members),this.mercatorBoundsSegments=e.aE.simpleSegment(0,0,4,2);const a=new e.az;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const s=new e.aR;for(const e of[0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(s),this.emptyTexture=new e.T(t,new e.h({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.a9.create();const l=this.context.gl;this.stencilClearMode=new Ct({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now())}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 e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,Et.disabled,this.stencilClearMode,It.disabled,Lt.disabled,ci(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,n){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!n||0===n.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of n)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const r=this.context,i=r.gl;this.nextStencilID+n.length>256&&this.clearStencil(),r.setColorMode(It.disabled),r.setDepthMode(Et.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const a of n){const e=t.getTile(a),n=this._tileClippingMaskIDs[a.key]=this.nextStencilID++,{tileBoundsBuffer:r,tileBoundsIndexBuffer:s,tileBoundsSegments:l}=this.getTileBoundsBuffers(e);o.draw(this,i.TRIANGLES,Et.disabled,new Ct({func:i.ALWAYS,mask:0},n,255,i.KEEP,i.KEEP,i.REPLACE),It.disabled,Lt.disabled,ci(a.projMatrix),"$clipping",r,s,l)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Ct({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new Ct({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,n=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(i>1){this.currentStencilSource=void 0,this.nextStencilID+i>256&&this.clearStencil();const e={};for(let n=0;nthis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new It([n.ONE,n.ONE_MINUS_SRC_ALPHA,n.CONSTANT_ALPHA,n.ONE_MINUS_SRC_ALPHA],new e.aA(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!this.opaquePassEnabledForLayer()&&!r)return Et.disabled;const i=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Et(n||this.context.gl.LEQUAL,t,[i,i])}opaquePassEnabledForLayer(){return this.currentLayerthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce(((e,t)=>e+t/this._fpsHistory.length),0))}render(t,n){this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=n;const r=this.style._mergedLayers,i=this.style.order.filter((e=>{const t=r[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]})),o=i.map((e=>r[e])),a=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.f.now()),this.imageManager.beginFrame();let s=0,l=!1;for(const e in a){const t=a[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++s)}for(const e of o)e.isHidden(this.transform.zoom)||this.prepareLayer(e);const c={},u={},h={},d={},f={};for(const e in a){const t=a[e];c[e]=t.getVisibleCoordinates(),u[e]=c[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse(),d[e]=t.getShadowCasterCoordinates(),f[e]=t.sortCoordinatesByDistance(c[e])}const p=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(s){const e=[];for(const t of o)this.layerUsedInConflation(t,p(t))&&e.push(t);if(e&&e.length>1){const t=[];for(const n of e){const e=this.style.getLayerSourceCache(n);e&&e.used&&e.getSource().usedInConflation&&t.push({layer:n.fqid,cache:e})}this.replacementSource.setSources(t),l=!0}}l||this.replacementSource.clear(),this.conflationActive=l,this.minCutoffZoom=0,this.longestCutoffRange=0;for(const e of o){const t=e.cutoffRange();if(this.longestCutoffRange=Math.max(t,this.longestCutoffRange),t>0){const t=p(e);t&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom)),e.minzoom&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom))}}this.opaquePassCutoff=1/0;for(let e=0;e{if(n.showOverdrawInspector)return e.aA.black;if(this.style.fog&&this.transform.projection.supportsFog&&!y){const t=this.style.fog.properties.get("color").toArray01();return new e.aA(...t)}if(this.style.fog&&this.transform.projection.supportsFog&&y){const t=this.style.fog.properties.get("space-color").toArray01();return new e.aA(...t)}return e.aA.transparent})();if(this.context.clear({color:v,depth:1}),this.clearStencil(),this._showOverdrawInspector=n.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){const e=o[this.currentLayer],n=t.getLayerSourceCache(e);if(e.isSky())continue;const r=n?(e.is3D()?f:u)[n.id]:void 0;this._renderTileClippingMasks(e,n,r),this.renderLayer(this,n,e,r)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.W(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer0&&e.hasShadowPass()&&0==--b&&(g.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=o[this.currentLayer];if(!e.hasLightBeamPass())continue;const n=t.getLayerSourceCache(e);this.renderLayer(this,n,e,n?u[n.id]:void 0)}this.currentLayer=e,this.renderPass="translucent"}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let n=null;o.forEach((e=>{const r=t.getLayerSourceCache(e);r&&!e.isHidden(this.transform.zoom)&&r.getVisibleCoordinates().length&&(!n||n.getSource().maxzoom0?t.pop():null}isPatternMissing(e,t){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString(),t)}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,n){const r=void 0===n?this.terrain&&this.terrain.renderingToTexture:n,i=this.terrain&&0===this.terrain.exaggeration(),o=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(o.push("LIGHTING_3D_MODE"),o.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):r||o.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||o.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?o.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):o.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(o.push("TERRAIN"),this.linearFloatFilteringSupported()&&o.push("TERRAIN_DEM_FLOAT_FORMAT"),i&&o.push("ZERO_EXAGGERATION")),"globe"===this.transform.projection.name&&o.push("GLOBE"),!this._fogVisible||r||void 0!==t&&!t||o.push("FOG","FOG_DITHERING"),r&&o.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&o.push("OVERDRAW_INSPECTOR"),o}getOrCreateProgram(e,t){this.cache=this.cache||{};const n=t&&t.defines||[],r=t&&t.config,i=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(n),o=yi.cacheKey(Zr[e],e,i,r);return this.cache[o]||(this.cache[o]=new yi(this.context,e,Zr[e],r,Yi[e],i)),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=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,n){if(this.style.enable3dLights()){const r=this.style.directionalLight,i=this.style.ambientLight;if(r&&i){const o=((t,n)=>{const r=t.properties.get("direction"),i=t.properties.get("color").toArray01(),o=t.properties.get("intensity"),a=n.properties.get("color").toArray01(),s=n.properties.get("intensity"),l=[r.x,r.y,r.z],c=e.cs(a,s),u=e.cs(i,o);return{u_lighting_ambient_color:c,u_lighting_directional_dir:l,u_lighting_directional_color:u,u_ground_radiance:mi(l,u,c)}})(r,i);n.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,n,r,i,o){if(this.uploadCommonLightUniforms(t,n),this.terrain&&this.terrain.renderingToTexture)return;const a=this.style.fog;if(a){const o=a.getOpacity(this.transform.pitch),s=((t,n,r,i,o,a,s,l,c,u,h,d)=>{const f=t.transform,p=n.properties.get("color").toArray01();p[3]=i;const m=t.frameCounter/1e3%1,[g,_]=n.properties.get("vertical-range");return{u_fog_matrix:r?f.calculateFogTileMatrix(r):d||t.identityMat,u_fog_range:n.getFovAdjustedRange(f._fov),u_fog_color:p,u_fog_horizon_blend:n.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(g,_),_],u_fog_temporal_offset:m,u_frustum_tl:o,u_frustum_tr:a,u_frustum_br:s,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.W(f.zoom),u_is_globe:+("globe"===f.projection.name)}})(this,a,r,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.f.devicePixelRatio,this.transform.height*e.f.devicePixelRatio],i);n.setFogUniformValues(t,s)}o&&n.setCutoffUniformValues(t,o.uniformValues)}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),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 e=this._backgroundTiles,t=this._backgroundTiles={},n=this.transform.coveringTiles({tileSize:512});for(const r of n)t[r.key]=e[r.key]||new Nt(r,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={}}layerUsedInConflation(e,t){return!(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||"building"!==e.sourceLayer&&(!t||"batched-model"!==t.type))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=fe||t[1]>=fe}}function $o(e,t){let n=!1,r=null;const i=()=>{r=null,n&&(e(),r=setTimeout(i,t),n=!1)};return()=>(n=!0,r||i(),r)}class ea{constructor(t){this._hashName=t&&encodeURIComponent(t),e.a$(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=$o(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return"";const t=ta(e);if(this._hashName){const e=this._hashName;let n=!1;const r=location.hash.slice(1).split("&").map((r=>{const i=r.split("=")[0];return i===e?(n=!0,"".concat(i,"=").concat(t)):r})).filter((e=>e));return n||r.push("".concat(e,"=").concat(t)),"#".concat(r.join("&"))}return"#".concat(t)}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const n=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:n,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function ta(e,t){const n=e.getCenter(),r=Math.round(100*e.getZoom())/100,i=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,i),a=Math.round(n.lng*o)/o,s=Math.round(n.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?"/".concat(a,"/").concat(s,"/").concat(r):"".concat(r,"/").concat(s,"/").concat(a);return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+="/".concat(Math.round(c))),u}const na={linearity:.3,easing:e.d6(0,0,.3,1)},ra=e.e({deceleration:2500,maxSpeed:1400},na),ia=e.e({deceleration:20,maxSpeed:1400},na),oa=e.e({deceleration:1e3,maxSpeed:360},na),aa=e.e({deceleration:1e3,maxSpeed:90},na);class sa{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.f.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=e.f.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,e.panDelta&&n.pan._add(e.panDelta),e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(n.pan.mag()){const o=ca(n.pan.mag(),r,e.e({},ra,t||{}));i.offset=n.pan.mult(o.amount/n.pan.mag()),i.center=this._map.transform.center,la(i,o)}if(n.zoom){const e=ca(n.zoom,r,ia);i.zoom=this._map.transform.zoom+e.amount,la(i,e)}if(n.bearing){const t=ca(n.bearing,r,oa);i.bearing=this._map.transform.bearing+e.ad(t.amount,-179,179),la(i,t)}if(n.pitch){const e=ca(n.pitch,r,aa);i.pitch=this._map.transform.pitch+e.amount,la(i,e)}if(i.zoom||i.bearing){const e=void 0===n.pinchAround?n.around:n.pinchAround;i.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),i.noMoveStart=!0,i}}function la(e,t){(!e.duration||e.duration3&&void 0!==arguments[3]?arguments[3]:{};const o=p(n.getCanvasContainer(),r),a=n.unproject(o);super(t,e.e({point:o,lngLat:a,originalEvent:r},i)),this._defaultPrevented=!1,this.target=n}}class ha extends e.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,r){const i="touchend"===t?r.changedTouches:r.touches,o=m(n.getCanvasContainer(),i),a=o.map((e=>n.unproject(e))),s=o.reduce(((e,t,n,r)=>e.add(t.div(r.length))),new e.P(0,0));super(t,{points:o,point:s,lngLats:a,lngLat:n.unproject(s),originalEvent:r}),this._defaultPrevented=!1}}class da extends e.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class fa{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new da(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ua(e.type,this._map,e))}mouseup(e){this._map.fire(new ua(e.type,this._map,e))}preclick(t){const n=e.e({},t);n.type="preclick",this._map.fire(new ua(n.type,this._map,n))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new ua(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new ua(e.type,this._map,e))}mouseover(e){this._map.fire(new ua(e.type,this._map,e))}mouseout(e){this._map.fire(new ua(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ha(e.type,this._map,e))}touchmove(e){this._map.fire(new ha(e.type,this._map,e))}touchend(e){this._map.fire(new ha(e.type,this._map,e))}touchcancel(e){this._map.fire(new ha(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pa{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new ua(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ua("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new ua(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ma{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 n=t,r=this._startPos,i=this._lastPos;if(!r||!i||i.equals(n)||!this._box&&n.dist(r){this._box&&(this._box.style.transform="translate(".concat(a,"px,").concat(l,"px)"),this._box.style.width=s-a+"px",this._box.style.height=c-l+"px")}))}mouseupWindow(t,n){if(!this._active)return;const r=this._startPos,i=n;if(r&&0===t.button){if(this.reset(),f(),r.x!==i.x||r.y!==i.y)return this._map.fire(new e.b("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(r,i,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,n){return this._map.fire(new e.b(t,{originalEvent:n}))}}function ga(e,t){const n={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){const n=new e.P(0,0);for(const e of t)n._add(e);return n.div(t.length)}(n),this.touches=ga(r,n)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;const r=ga(n,t);for(const i in this.touches){const e=r[i];(!e||e.dist(this.touches[i])>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class ya{constructor(e){this.singleTap=new _a(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,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){const r=this.singleTap.touchend(e,t,n);if(r){const t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class va{constructor(){this._zoomIn=new ya({numTouches:1,numTaps:2}),this._zoomOut=new ya({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,t,n){const r=this._zoomIn.touchend(e,t,n),i=this._zoomOut.touchend(e,t,n);return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):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})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const xa={0:1,2:2};class ba{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 n=g(e);this._correctButton(e,n)&&(this._lastPoint=t,this._eventButton=n)}mousemoveWindow(e,t){const n=this._lastPoint;if(n)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const n=xa[t];return void 0===e.buttons||(e.buttons&n)!==n}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(n)0&&(this._active=!0);const i=ga(r,n),o=new e.P(0,0),a=new e.P(0,0);let s=0;for(const e in i){const t=i[e],n=this._touches[e];n&&(o._add(t),a._add(t.sub(n)),s++,i[e]=t)}if(this._touches=i,s{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")}),500)}}class Ea{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,n){return{}}touchstart(e,t,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,n){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[i,o]=r,a=Ta(n,t,i),s=Ta(n,t,o);if(!a||!s)return;const l=this._aroundCenter?null:a.add(s).div(2);return this._move([a,s],l,e)}touchend(e,t,n){if(!this._firstTwoTouches)return;const[r,i]=this._firstTwoTouches,o=Ta(n,t,r),a=Ta(n,t,i);o&&a||(this._active&&f(),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 Ta(e,t,n){for(let r=0;rMath.abs(e.x)}class La extends Ea{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,Ra(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,n,r){const i=this._lastPoints;if(!i)return;const o=t[0].sub(i[0]),a=t[1].sub(i[1]);return this._map._cooperativeGestures&&!e.d7()&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(o,a,r.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+a.y)/2*-.5})}gestureBeginsVertically(e,t,n){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,i=t.mag()>=2;if(!r&&!i)return;if(!r||!i)return null==this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Ra(e)&&Ra(t)&&o}}const za={panStep:100,bearingStep:15,pitchStep:10};class Oa{constructor(){const e=za;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,n=0,r=0,i=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?n=-1:(e.preventDefault(),i=-1);break;case 39:e.shiftKey?n=1:(e.preventDefault(),i=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(n=0,r=0),{cameraAnimation:a=>{const s=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Da,zoom:t?Math.round(s)+t*(e.shiftKey?2:1):s,bearing:a.getBearing()+n*this._bearingStep,pitch:a.getPitch()+r*this._pitchStep,offset:[-i*this._panStep,-o*this._panStep],center:a.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 Da(e){return e*(2-e)}const Ba=4.000244140625,Fa=1/450;class Na{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._handler=n,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Fa,e.a$(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],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()||e.d7()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=e.f.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==n&&n%Ba==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,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=p(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;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const n=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Ba?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const i=n(),o=Math.pow(2,i),a="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(a*r))),"wheel"===this._type&&(this._startZoom=i,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:n(),i=this._startZoom,o=this._easing;let a,s=!1;if("wheel"===this._type&&i&&o){const t=Math.min((e.f.now()-this._lastWheelEventTime)/200,1),n=o(t);a=e.X(i,r,n),t<1?this._frameId||(this._frameId=!0):s=!0}else a=r,s=!0;this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200));let l=a-n();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!s,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=e.d8;if(this._prevEase){const t=this._prevEase,r=(e.f.now()-t.start)/t.duration,i=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(i*i+1e-4)*.01,a=Math.sqrt(.0729-o*o);n=e.d6(o,a,.25,1)}return this._prevEase={start:e.f.now(),duration:t,easing:n},n}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(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize="".concat(Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth))),"px"))}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")}),200)}}class ja{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 Va{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:n.getZoom()+(e.shiftKey?-1:1),around:n.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ua{constructor(){this._tap=new ya({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,n){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=t[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(e,t,n))}touchmove(e,t,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const r=t[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(e,t,n)}touchend(e,t,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(e,t,n)&&(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 Ga{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}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 qa{constructor(e,t,n){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=n}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 Wa{constructor(e,t,n,r){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("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 Ha=e=>e.zoom||e.drag||e.pitch||e.rotate;class Za extends e.b{}class Ya{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,n){const r=e.Q.sub([],n,t);this.radius=e.Q.length(r[2]<0?e.Q.div([],r,this.constants):[r[0],r[1],0])}projectRay(t){e.Q.div(t,t,this.constants),e.Q.normalize(t,t),e.Q.mul(t,t,this.constants);const n=e.Q.scale([],t,this.radius);if(n[2]>0){const t=e.Q.scale([],[0,0,1],e.Q.dot(n,[0,0,1])),r=e.Q.scale([],e.Q.normalize([],[n[0],n[1],0]),this.radius),i=e.Q.add([],n,e.Q.scale([],e.Q.sub([],e.Q.add([],r,t),n),2));n[0]=i[0],n[1]=i[1]}return n}}function Qa(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Xa{constructor(t,n){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new sa(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Ya,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(n),e.a$(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,i,o]of this._listeners){const t=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(i,t,o)}}destroy(){for(const[e,t,n]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,r,n)}}_addDefaultHandlers(e){const t=this._map,n=t.getCanvasContainer();this._add("mapEvent",new fa(t,e));const r=t.boxZoom=new ma(t,e);this._add("boxZoom",r);const i=new va,o=new Va;t.doubleClickZoom=new ja(o,i),this._add("tapZoom",i),this._add("clickZoom",o);const a=new Ua;this._add("tapDragZoom",a);const s=t.touchPitch=new La(t);this._add("touchPitch",s);const l=new Sa(e),c=new Ma(e);t.dragRotate=new qa(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new wa(e),h=new Aa(t,e);t.dragPan=new Ga(n,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new Pa,f=new ka;t.touchZoomRotate=new Wa(n,f,d,a),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),this._add("blockableMapEvent",new pa(t));const p=t.scrollZoom=new Na(t,this);this._add("scrollZoom",p,["mousePan"]);const m=t.keyboard=new Oa;this._add("keyboard",m);for(const g of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[g]&&t[g].enable(e[g])}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),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=[],this._originalZoom=void 0}}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!!Ha(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,n){for(const r in e)if(r!==n&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,"".concat(e.type,"Window"))}_getMapTouches(e){const t=[];for(const n of e)this._el.contains(n.target)&&t.push(n);return t}handleEvent(e,t){this._updatingCamera=!0;const n="renderFrame"===e.type,r=n?void 0:e,i={needsRenderFrame:!1},o={},a={},s=e.touches?this._getMapTouches(e.touches):void 0,l=s?m(this._el,s):n?void 0:p(this._el,e);for(const{handlerName:h,handler:d,allowed:f}of this._handlers){if(!d.isEnabled())continue;let n;this._blockedByActive(a,f,h)?d.reset():d[t||e.type]&&(n=d[t||e.type](e,l,s),this.mergeHandlerResult(i,o,n,h,r),n&&n.needsRenderFrame&&this._triggerRenderFrame()),(n||d.isActive())&&(a[h]=d)}const c={};for(const h in this._previousActiveHandlers)a[h]||(c[h]=r);this._previousActiveHandlers=a,(Object.keys(c).length||Qa(i))&&(this._changes.push([i,o,c]),this._triggerRenderFrame()),(Object.keys(a).length||Qa(i))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=i;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(t,n,r,i,o){if(!r)return;e.e(t,r);const a={handlerName:i,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(n.zoom=a),void 0!==r.panDelta&&(n.drag=a),void 0!==r.pitchDelta&&(n.pitch=a),void 0!==r.bearingDelta&&(n.rotate=a)}_applyChanges(){const t={},n={},r={};for(const[i,o,a]of this._changes)i.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(i.panDelta)),i.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+i.pitchDelta),void 0!==i.around&&(t.around=i.around),void 0!==i.aroundCoord&&(t.aroundCoord=i.aroundCoord),void 0!==i.pinchAround&&(t.pinchAround=i.pinchAround),i.noInertia&&(t.noInertia=i.noInertia),e.e(n,o),e.e(r,a);this._updateMapTransform(t,n,r),this._changes=[]}_updateMapTransform(t,n,r){const i=this._map,o=i.transform,a=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Qa(t)){const e=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&i._stop(!0),!Qa(t))return void this._fireEvents(n,r,!0);let{panDelta:s,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:d,pinchAround:f}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==f&&(h=f),(l||(e=>n[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=a(o.pointCoordinate3D(h)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",i._stop(!0),h=h||i.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const p=[0,0,0];if(s)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(s)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){s=s.rotate(-o.angle);const n=o._pixelsPerMercatorPixel/o.worldSize;p[0]=-s.x*e.d9(e.ax(t.y))*n,p[1]=-s.y*e.d9(o.center.lat)*n}else{const e=o.pointCoordinate(h.sub(s));t&&e&&(p[0]=e.x-t.x,p[1]=e.y-t.y)}}const m=o.zoom,g=[0,0,0];if(l){const t=a(d||o.pointCoordinate3D(h)),n={dir:e.Q.normalize([],e.Q.sub([],t,o._camera.position))};if(n.dir[2]<0){const r=o.zoomDeltaToMovement(t,l);e.Q.scale(g,n.dir,r)}}const _=e.Q.add(p,p,g);o._translateCameraConstrained(_),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,r,!0)}_fireEvents(t,n,r){const i=Ha(this._eventsInProgress),o=Ha(t),a={};for(const e in t){const{originalEvent:n}=t[e];this._eventsInProgress[e]||(a["".concat(e,"start")]=n),this._eventsInProgress[e]=t[e]}!i&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in a)this._fireEvent(e,a[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:n}=t[e];this._fireEvent(e,n)}const s={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=n[t]||r,s["".concat(e,"end")]=l)}for(const e in s)this._fireEvent(e,s[e]);const c=Ha(this._eventsInProgress);if(r&&(i||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Za("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Ka="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Ja extends e.E{constructor(t,n){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,this._respectPrefersReducedMotion=!1!==n.respectPrefersReducedMotion,e.a$(["_renderFrameCallback"],this)}getCenter(){return new e.bq(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,n,r){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},n),r)}panTo(t,n,r){return this.easeTo(e.e({center:t},n),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,n,r){return this.easeTo(e.e({zoom:t},n),r)}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,n,r){return this.easeTo(e.e({bearing:t},n),r)}resetNorth(t,n){return this.rotateTo(0,e.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?n/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,n,r,i,o,a){const s=t.clone(),l=this._extendCameraOptions(a);s.bearing=i,s.pitch=o;const c=e.bq.convert(n),u=e.bq.convert(r),h=.5*(c.lat+u.lat),d=.5*(c.lng+u.lng),f=e.da(h,d),p=e.Q.normalize([],f),m=e.Q.normalize([],e.Q.cross([],p,[0,1,0])),g=e.Q.cross([],m,p),_=[m[0],m[1],m[2],0,g[0],g[1],g[2],0,p[0],p[1],p[2],0,0,0,0,1],y=[f,e.da(c.lat,c.lng),e.da(u.lat,c.lng),e.da(u.lat,u.lng),e.da(c.lat,u.lng),e.da(h,c.lng),e.da(h,u.lng),e.da(c.lat,d),e.da(u.lat,d)];let v=e.bV.fromPoints(y.map((t=>[e.Q.dot(m,t),e.Q.dot(g,t),e.Q.dot(p,t)])));const x=e.Q.transformMat4([],v.center,_);0===e.Q.squaredLength(x)&&e.Q.set(x,0,0,1),e.Q.normalize(x,x),e.Q.scale(x,x,e.ae),s.center=e.db(x);const b=s.getWorldToCameraMatrix(),w=e.a9.invert(new Float64Array(16),b);v=e.bV.applyTransform(v,e.a9.multiply([],b,_));const S=this._extendAABB(v,s,l,i);if(!S)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=S,e.Q.transformMat4(x,x,b);const M=.5*(v.max[2]-v.min[2]),A=this._minimumAABBFrustumDistance(s,v),E=e.Q.scale([],[0,0,1],M),T=e.Q.add(E,x,E),C=A+(0===s.pitch?0:e.Q.distance(x,T)),k=s.globeCenterInViewSpace,I=e.Q.sub([],x,[k[0],k[1],k[2]]);e.Q.normalize(I,I),e.Q.scale(I,I,C);const P=e.Q.add([],x,I);e.Q.transformMat4(P,P,w);const R=e.dc/e.ae,L=e.Q.length(P),z=e.bo(Math.max(L*R-e.dc,Number.EPSILON),0),O=Math.min(s.zoomFromMercatorZAdjusted(z),l.maxZoom);return O>.5*(e.bJ+e.bA)?(s.setProjection({name:"mercator"}),s.zoom=O,this._cameraForBounds(s,n,r,i,o,a)):{center:s.center,zoom:O,bearing:i,pitch:o}}_extendAABB(t,n,r,i){const o=.5*((r.padding.left||0)+(r.padding.right||0)),a=.5*((r.padding.top||0)+(r.padding.bottom||0)),s=a,l=o,c=o,u=a,h=n.width-(l+c),d=n.height-(s+u),f=e.Q.sub([],t.max,t.min),p=Math.min(h/f[0],d/f[1]),m=Math.min(n.scaleZoom(n.scale*p),r.maxZoom);if(isNaN(m))return null;const g=n.scale/n.zoomScale(m),_=new e.bV([t.min[0]-l*g,t.min[1]-u*g,t.min[2]],[t.max[0]+c*g,t.max[1]+s*g,t.max[2]]),y=("number"==typeof r.offset.x&&"number"==typeof r.offset.y?new e.P(r.offset.x,r.offset.y):e.P.convert(r.offset)).rotate(-e.bm(i));return _.center[0]-=y.x*g,_.center[1]+=y.y*g,_}queryTerrainElevation(t,n){const r=this.transform.elevation;return r?(n=e.e({},{exaggerated:!0},n),r.getAtPoint(e.O.fromLngLat(t),null,n.exaggerated)):null}_cameraForBounds(t,n,r,i,o,a){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,n,r,i,o,a);const s=t.clone(),l=this._extendCameraOptions(a);s.bearing=i,s.pitch=o;const c=e.bq.convert(n),u=e.bq.convert(r),h=new e.bq(c.lng,u.lat),d=new e.bq(u.lng,c.lat),f=s.project(c),p=s.project(u),m=this.queryTerrainElevation(c),g=this.queryTerrainElevation(u),_=this.queryTerrainElevation(h),y=this.queryTerrainElevation(d),v=[[f.x,f.y,Math.min(m||0,g||0,_||0,y||0)],[p.x,p.y,Math.max(m||0,g||0,_||0,y||0)]];let x=e.bV.fromPoints(v);const b=s.getWorldToCameraMatrix(),w=e.a9.invert(new Float64Array(16),b);x=e.bV.applyTransform(x,b);const S=this._extendAABB(x,s,l,i);if(!S)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=S;const M=.5*e.Q.sub([],x.max,x.min)[2],A=this._minimumAABBFrustumDistance(s,x),E=[0,0,1,0];e.aa.transformMat4(E,E,b),e.aa.normalize(E,E);const T=e.Q.scale([],E,A+M),C=e.Q.add([],x.center,T);e.Q.transformMat4(x.center,x.center,w),e.Q.transformMat4(C,C,w);const k=[x.center[0],x.center[1],C[2]*s.pixelsPerMeter];e.Q.scale(k,k,1/s.worldSize);const I=e.aw(k[0]),P=e.ax(k[1]),R=Math.min(s._zoomFromMercatorZ(k[2]),l.maxZoom),L=new e.bq(I,P);return s.mercatorFromTransition&&R<.5*(e.bJ+e.bA)?(s.setProjection({name:"globe"}),s.zoom=R,this._cameraForBounds(s,n,r,i,o,a)):{center:L,zoom:R,bearing:i,pitch:o}}fitBounds(e,t,n){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,n)}fitScreenCoordinates(t,n,r,i,o){const a=e.P.convert(t),s=e.P.convert(n),l=new e.P(Math.min(a.x,s.x),Math.min(a.y,s.y)),c=new e.P(Math.max(a.x,s.x),Math.max(a.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(a,s))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),f=this.transform.pointLocation3D(new e.P(c.x,l.y)),p=[Math.min(u.lng,h.lng,d.lng,f.lng),Math.min(u.lat,h.lat,d.lat,f.lat)],m=[Math.max(u.lng,h.lng,d.lng,f.lng),Math.max(u.lat,h.lat,d.lat,f.lat)],g=i&&i.pitch?i.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,p,m,r,g,i);return this._fitInternal(_,i,o)}_fitInternal(t,n,r){return t?(n=e.e(t,n)).linear?this.easeTo(n,r):this.flyTo(n,r):this}jumpTo(t,n){this.stop();const r=t.preloadOnly?this.transform.clone():this.transform;let i=!1,o=!1,a=!1;return"zoom"in t&&r.zoom!==+t.zoom&&(i=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=e.bq.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(o=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(a=!0,r.pitch=+t.pitch),null==t.padding||r.isPaddingEqual(t.padding)||(r.padding=t.padding),t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new e.b("movestart",n)).fire(new e.b("move",n)),i&&this.fire(new e.b("zoomstart",n)).fire(new e.b("zoom",n)).fire(new e.b("zoomend",n)),o&&this.fire(new e.b("rotatestart",n)).fire(new e.b("rotate",n)).fire(new e.b("rotateend",n)),a&&this.fire(new e.b("pitchstart",n)).fire(new e.b("pitch",n)).fire(new e.b("pitchend",n)),this.fire(new e.b("moveend",n)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(Ka),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,n){const r=this.transform;if(!r.projection.supportsFreeCamera)return e.w(Ka),this;this.stop();const i=r.zoom,o=r.pitch,a=r.bearing;r.setFreeCameraOptions(t);const s=i!==r.zoom,l=o!==r.pitch,c=a!==r.bearing;return this.fire(new e.b("movestart",n)).fire(new e.b("move",n)),s&&this.fire(new e.b("zoomstart",n)).fire(new e.b("zoom",n)).fire(new e.b("zoomend",n)),c&&this.fire(new e.b("rotatestart",n)).fire(new e.b("rotate",n)).fire(new e.b("rotateend",n)),l&&this.fire(new e.b("pitchstart",n)).fire(new e.b("pitch",n)).fire(new e.b("pitchend",n)),this.fire(new e.b("moveend",n)),this}easeTo(t,n){this._stop(!1,t.easeId),(!1===(t=e.e({offset:[0,0],duration:500,easing:e.d8},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const r=this.transform,i=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in t?+t.zoom:i,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:a,h=this._extendPadding(t.padding),d=e.P.convert(t.offset);let f,p,m;if("globe"===r.projection.name){const n=e.O.fromLngLat(r.center),i=d.rotate(-r.angle);n.x+=i.x/r.worldSize,n.y+=i.y/r.worldSize;const o=n.toLngLat(),a=e.bq.convert(t.center||o);this._normalizeCenter(a),f=r.centerPoint.add(i),p=new e.P(n.x,n.y).mult(r.worldSize),m=new e.P(e.a8(a.lng),e.ah(a.lat)).mult(r.worldSize).sub(p)}else{f=r.centerPoint.add(d);const n=r.pointLocation(f),i=e.bq.convert(t.center||n);this._normalizeCenter(i),p=r.project(n),m=r.project(i).sub(p)}const g=r.zoomScale(l-i);let _,y;t.around&&(_=e.bq.convert(t.around),y=r.locationPoint(_));const v=this._zooming||l!==i,x=this._rotating||o!==c,b=this._pitching||u!==a,w=!r.isPaddingEqual(h),S=r=>S=>{if(v&&(r.zoom=e.X(i,l,S)),x&&(r.bearing=e.X(o,c,S)),b&&(r.pitch=e.X(a,u,S)),w&&(r.interpolatePadding(s,h,S),f=r.centerPoint.add(d)),_)r.setLocationAtPoint(_,y);else{const e=r.zoomScale(r.zoom-i),t=l>i?Math.min(2,g):Math.max(.5,g),n=Math.pow(t,1-S),o=r.unproject(p.add(m.mult(S*n)).mult(e));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,f)}return t.preloadOnly||this._fireMoveEvents(n),r};if(t.preloadOnly){const e=this._emulate(S,t.duration,r);return this._preloadTiles(e),this}const M={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(n,t.noMoveStart,M),this._ease(S(r),(e=>{"sea"===r.cameraElevationReference&&r.recenterOnTerrain(),this._afterEase(n,e)}),t),this}_prepareEase(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),n||r.moving||this.fire(new e.b("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.b("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.b("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.b("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.b("move",t)),this._zooming&&this.fire(new e.b("zoom",t)),this._rotating&&this.fire(new e.b("rotate",t)),this._pitching&&this.fire(new e.b("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,i=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.b("zoomend",t)),i&&this.fire(new e.b("rotateend",t)),o&&this.fire(new e.b("pitchend",t)),this.fire(new e.b("moveend",t))}flyTo(t,n){if(this._prefersReducedMotion(t)){const r=e.af(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,n)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.d8},t);const r=this.transform,i=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in t?e.ad(+t.zoom,r.minZoom,r.maxZoom):i,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:a,h=this._extendPadding(t.padding),d=r.zoomScale(l-i),f=e.P.convert(t.offset);let p=r.centerPoint.add(f);const m=r.pointLocation(p),g=e.bq.convert(t.center||m);this._normalizeCenter(g);const _=r.project(m),y=r.project(g).sub(_);let v=t.curve;const x=Math.max(r.width,r.height),b=x/d,w=y.mag();if("minZoom"in t){const n=e.ad(Math.min(t.minZoom,i,l),r.minZoom,r.maxZoom),o=x/r.zoomScale(n-i);v=Math.sqrt(o/w*2)}const S=v*v;function M(e){const t=(b*b-x*x+(e?-1:1)*S*S*w*w)/(2*(e?b:x)*S*w);return Math.log(Math.sqrt(t*t+1)-t)}function A(e){return(Math.exp(e)-Math.exp(-e))/2}function E(e){return(Math.exp(e)+Math.exp(-e))/2}const T=M(0);let C=function(e){return E(T)/E(T+v*e)},k=function(e){return x*((E(T)*(A(t=T+v*e)/E(t))-A(T))/S)/w;var t},I=(M(1)-T)/v;if(Math.abs(w)<1e-6||!isFinite(I)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,n);const e=bt.maxDuration&&(t.duration=0);const P=o!==c,R=u!==a,L=!r.isPaddingEqual(h),z=r=>d=>{const m=d*I,v=1/C(m);r.zoom=1===d?l:i+r.scaleZoom(v),P&&(r.bearing=e.X(o,c,d)),R&&(r.pitch=e.X(a,u,d)),L&&(r.interpolatePadding(s,h,d),p=r.centerPoint.add(f));const x=1===d?g:r.unproject(_.add(y.mult(k(m))).mult(v));return r.setLocationAtPoint(r.renderWorldCopies?x.wrap():x,p),r._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(n),r};if(t.preloadOnly){const e=this._emulate(z,t.duration,r);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=P,this._pitching=R,this._padding=L,this._prepareEase(n,!1),this._ease(z(r),(()=>this._afterEase(n)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_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,n,r){!1===r.animate||0===r.duration?(t(1),n()):(this._easeStart=e.f.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.f.now()-this._easeStart)/this._easeOptions.duration,1),n=this._onEaseFrame;n&&n(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,n){t=e.bk(t,-180,180);const r=Math.abs(t-n);return Math.abs(t-360-n)180?-360:n<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.f.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,n){const r=Math.ceil(15*t/1e3),i=[],o=e(n.clone());for(let a=0;a<=r;a++){const e=o(a/r);i.push(e.clone())}return i}_preloadTiles(e,t){}}class $a{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.options=t,e.a$(["_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),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 n=this._map._getUIString("AttributionControl.".concat(t));e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}_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 n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.dd.ACCESS_TOKEN}];if(t){const r=n.reduce(((e,t,r)=>(t.value&&(e+="".concat(t.key,"=").concat(t.value).concat(re.length-t.length)),e=e.filter(((t,n)=>{for(let r=n+1;r=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const n=e.join(" | ");n!==this._attribHTML&&(this._attribHTML=n,e.length?(this._innerContainer.innerHTML=n,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 es{constructor(){e.a$(["_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 n=e[t].getSource();if(n.hasOwnProperty("mapbox_logo")&&!n.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 ts{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,n=t?this._queue.concat(t):this._queue;for(const r of n)if(r.id===e)return void(r.cancelled=!0)}run(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const t=this._currentlyRunning=this._queue;this._queue=[];for(const n of t)if(!n.cancelled&&(n.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function ns(t,n,r){if(t=new e.bq(t.lng,t.lat),n){const i=new e.bq(t.lng-360,t.lat),o=new e.bq(t.lng+360,t.lat),a=360*Math.ceil(Math.abs(t.lng-r.center.lng)/360),s=r.locationPoint(t).distSqr(n),l=n.x<0||n.y<0||n.x>r.width||n.y>r.height;r.locationPoint(i).distSqr(n)180;){const e=r.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}const rs={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 is extends e.E{constructor(t,n){if(super(),(t instanceof HTMLElement||n)&&(t=e.e({element:t},n)),e.a$(["_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),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const n=41,r=27,i=a("svg",{display:"block",height:n*this._scale+"px",width:r*this._scale+"px",viewBox:"0 0 ".concat(r," ").concat(n)},this._element),s=a("radialGradient",{id:"shadowGradient"},a("defs",{},i));a("stop",{offset:"10%","stop-opacity":.4},s),a("stop",{offset:"100%","stop-opacity":.05},s),a("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},i),a("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"},i),a("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"},i),a("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},i),this._offset=e.P.convert(t&&t.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()}));const r=this._element.classList;for(const e in rs)r.remove("mapboxgl-marker-anchor-".concat(e));r.add("mapboxgl-marker-anchor-".concat(this._anchor));const i=t&&t.className?t.className.trim().split(/\s+/):[];r.add(...i),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.bq.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,n=13.5,r=Math.sqrt(Math.pow(n,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-n+r)],"bottom-right":[-r,-1*(t-n+r)],left:[n,-1*(t-n)],right:[-n,-1*(t-n)]}: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,n=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==n&&13!==n||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.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,t=this._pos;if(!e||!t)return!1;const n=e.unproject(t),r=e.getFreeCameraOptions();if(!r.position)return!1;const i=r.position.toLngLat();return i.distanceTo(n)<.9*i.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const n=this._pos;if(!n||n.x<0||n.x>t.transform.width||n.y<0||n.y>t.transform.height)return void this._clearFadeTimer();const r=t.unproject(n);let i;t._showingGlobe()&&e.de(t.transform,this._lngLat)?i=0:(i=1-t._queryFogOpacity(r),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(i*=this._occludedOpacity)),this._element.style.opacity="".concat(i),this._element.style.pointerEvents=i>0?"auto":"none",this._popup&&this._popup._setOpacity(i),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._offset.mult(this._scale);this._element.style.transform="\n translate(".concat(e.x,"px,").concat(e.y,"px)\n ").concat(rs[this._anchor],"\n ").concat(this._calculateXYTransform()," ").concat(this._calculateZTransform(),"\n translate(").concat(t.x,"px,").concat(t.y,"px)\n ")}_calculateXYTransform(){const t=this._pos,n=this._map,r=this.getPitchAlignment();if(!n||!t||"map"!==r)return"";if(!n._showingGlobe()){const e=n.getPitch();return e?"rotateX(".concat(e,"deg)"):""}const i=e.bI(e.df(n.transform,this._lngLat)),o=t.sub(e.dg(n.transform)),a=Math.abs(o.x)+Math.abs(o.y);if(0===a)return"";const s=i/a;return"rotateX(".concat(-o.y*s,"deg) rotateY(").concat(o.x*s,"deg)")}_calculateZTransform(){const t=this._pos,n=this._map;if(!n||!t)return"";let r=0;const i=this.getRotationAlignment();if("map"===i)if(n._showingGlobe()){const t=n.project(new e.bq(this._lngLat.lng,this._lngLat.lat+.001)),i=n.project(new e.bq(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);r=e.bI(Math.atan2(i.y,i.x))-90}else r=-n.getBearing();else if("horizon"===i){const i=e.S(4,6,n.getZoom()),o=e.dg(n.transform);o.y+=i*n.transform.height;const a=t.sub(o),s=e.bI(Math.atan2(a.y,a.x));r=(s>90?s-270:s+90)*(1-i)}return r+=this._rotation,r?"rotateZ(".concat(r,"deg)"):""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=ns(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),t._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const n=this._map;if(!n)return;const r=this._pointerdownPos,i=this._positionDelta;if(r&&i){if(!this._isDragging){const e=this._clickTolerance||n._clickTolerance;if(t.point.dist(r)0&&void 0!==arguments[0]?arguments[0]:new e.P(0,0),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"bottom";if("number"==typeof t){const r=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(n){case"top":return new e.P(0,t);case"top-left":return new e.P(r,r);case"top-right":return new e.P(-r,r);case"bottom":return new e.P(0,-t);case"bottom-left":return new e.P(r,-r);case"bottom-right":return new e.P(-r,-r);case"left":return new e.P(t,0);case"right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[n]||[0,0])}class ls{constructor(e){this.jumpTo(e)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const n=e.ch((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-n)+this._end*n}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,n){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+n}}class cs{registerParameter(e,t,n,r,i){}registerButton(e,t,n){}registerBinding(e,t,n,r){}refreshUI(){}}const us={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},hs={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1},ds={showCompass:!0,showZoom:!0,visualizePitch:!1};class fs{constructor(t,n){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this._clickTolerance=10,this.element=n,this.mouseRotate=new Sa({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new Ma({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.a$(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),n.addEventListener("mousedown",this.mousedown),n.addEventListener("touchstart",this.touchstart,{passive:!1}),n.addEventListener("touchmove",this.touchmove),n.addEventListener("touchend",this.touchend),n.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),u()}move(e,t){const n=this.map,r=this.mouseRotate.mousemoveWindow(e,t),i=r&&r.bearingDelta;if(i&&n.setBearing(n.getBearing()+i),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),i=r&&r.pitchDelta;i&&n.setPitch(n.getPitch()+i)}}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(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),p(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,p(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)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.dh(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new pr(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._repaint=!!t.repaint,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._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new ts,this._domRenderTaskQueue=new ts,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.aF(),this._locale=e.e({},us,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new ls(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new e.di(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?{...t.contextCreateOptions}:{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error("Container '".concat(t.container.toString(),"' not found."));this._container=e}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.w("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.a$(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp=t.devtools?new cs(this):new cs,this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},(()=>{this._update()})),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new Xa(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.dd.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new ea("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==n.center&&null==n.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const r=t.bounds;r&&(this.resize(),this.fitBounds(r,e.e({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new $a({customAttribution:t.customAttribution})),this._logoControl=new es,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent()})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.b("".concat(t.dataType,"data"),t))})),this.on("dataloading",(t=>{this.fire(new e.b("".concat(t.dataType,"dataloading"),t))}))}_getMapId(){return this._mapId}addControl(t,n){if(void 0===n&&(n=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.a(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const i=this._controlPositions[n];return-1!==n.indexOf("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.a(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(t);return n>-1&&this._controls.splice(n,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 n=!this._moving;return n&&this.fire(new e.b("movestart",t)).fire(new e.b("move",t)),this.fire(new e.b("resize",t)),n&&this.fire(new e.b("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.ag.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()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.b("zoomstart")).fire(new e.b("zoom")).fire(new e.b("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()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.b("pitchstart")).fire(new e.b("pitch")).fire(new e.b("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.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return"auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?navigator.language:e)):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const n of this._controls)n._setLanguage&&n._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,n=t.projection.name;let r;"globe"===n&&t.zoom>=e.bA?(t.setMercatorFromTransition(),r=!0):"mercator"===n&&t.zoom=e.bA?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),n&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t){return this.transform.locationPoint3D(e.bq.convert(t))}unproject(t){return this.transform.pointLocation3D(e.P.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}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,n){if("mouseenter"===e||"mouseover"===e){let r=!1;const i=i=>{const o=t.filter((e=>this.getLayer(e))),a=o.length?this.queryRenderedFeatures(i.point,{layers:o}):[];a.length?r||(r=!0,n.call(this,new ua(e,this,i.originalEvent,{features:a}))):r=!1},o=()=>{r=!1};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const i=i=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(i.point,{layers:o}):[]).length?r=!0:r&&(r=!1,n.call(this,new ua(e,this,i.originalEvent)))},o=t=>{r&&(r=!1,n.call(this,new ua(e,this,t.originalEvent)))};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:o}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),i=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];i.length&&(e.features=i,n.call(this,e),delete e.features)};return{layers:new Set(t),listener:n,delegates:{[e]:r}}}}on(e,t,n){if(void 0===n)return super.on(e,t);if(Array.isArray(t)||(t=[t]),t)for(const i of t)if(!this._isValidId(i))return this;const r=this._createDelegatedListener(e,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const i in r.delegates)this.on(i,r.delegates[i]);return this}once(e,t,n){if(void 0===n)return super.once(e,t);if(Array.isArray(t)||(t=[t]),t)for(const i of t)if(!this._isValidId(i))return this;const r=this._createDelegatedListener(e,t,n);for(const i in r.delegates)this.once(i,r.delegates[i]);return this}off(e,t,n){if(void 0===n)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);for(const o of t)if(!this._isValidId(o))return this;const r=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0},i=this._delegatedListeners?this._delegatedListeners[e]:void 0;return i&&(e=>{for(let i=0;i{r?(e.w("Unable to perform style diff: ".concat(String(r.message||r.error||r),". Rebuilding the style from scratch.")),this._updateStyle(t,n)):i&&this._update(!0)}),(()=>{this._postStyleLoadEvent()})),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._localFontFamily=n.localFontFamily,this._updateStyle(t,n))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error("Missing UI string '".concat(e,"'"));return t}_updateStyle(t,n){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t){const r=e.e({},n);n&&n.config&&(r.initialConfig=n.config,delete r.config),this.style=new Ir(this,r).setEventedParent(this,{style:this.style}).load(t)}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Ir(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.a(new Error("IDs can't be empty."))),!1):!e.c9(t)||(this.fire(new e.a(new Error("IDs can't contain special symbols: \"".concat(t,'".')))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return!!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,n){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,n)}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,n){let{pixelRatio:r=1,sdf:i=!1,stretchX:o,stretchY:a,content:s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._lazyInitEmptyStyle(),n instanceof HTMLImageElement||ImageBitmap&&n instanceof ImageBitmap){const{width:l,height:c,data:u}=e.f.getImageData(n);this.style.addImage(t,{data:new e.h({width:l,height:c},u),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0})}else if(void 0===n.width||void 0===n.height)this.fire(new e.a(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}=n,u=n;this.style.addImage(t,{data:new e.h({width:l,height:c},new Uint8Array(u.data)),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0,userImage:u}),u.onAdd&&u.onAdd(this,t)}}updateImage(t,n){this._lazyInitEmptyStyle();const r=this.style.getImage(t);if(!r)return void this.fire(new e.a(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const i=n instanceof HTMLImageElement||ImageBitmap&&n instanceof ImageBitmap?e.f.getImageData(n):n,{width:o,height:a}=i,s=i.data;if(void 0===o||void 0===a)return void this.fire(new e.a(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==r.data.width||a!==r.data.height)return void this.fire(new e.a(new Error("The width and height of the updated image (".concat(o,", ").concat(a,")\n must be that same as the previous version of the image\n (").concat(r.data.width,", ").concat(r.data.height,")"))));const l=!(n instanceof HTMLImageElement||ImageBitmap&&n instanceof ImageBitmap);r.data.replace(s,l),this.style.updateImage(t,r)}hasImage(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.a(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,n){e.d(this._requestManager.transformRequest(t,e.R.Image),((t,r)=>{n(t,r instanceof HTMLImageElement?e.f.getImageData(r):r)}))}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.a(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e)}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(e,t){return this.style.addImport(e,t),this}updateImport(e,t){return"string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){return this._isValidId(e)?this.style.getOwnLayer(e):null}setLayerZoomRange(e,t,n){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,n),this._update(!0)):this}setFilter(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._isValidId(e)?(this.style.setFilter(e,t,n),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this._isValidId(e)?(this.style.setPaintProperty(e,t,n,r),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this._isValidId(e)?(this.style.setLayoutProperty(e,t,n,r),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,n){return this.style.setConfigProperty(e,t,n),this._update(!0)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}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}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.bq.convert(t),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let n,r,i,o=this._container;for(;o&&(!r||!i);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(n=e.match(/matrix.*\((.+)\)/)[1].split(", "),n[0]&&"0"!==n[0]&&"1"!==n[0]&&(r=n[0]),n[3]&&"0"!==n[3]&&"1"!==n[3]&&(i=n[3])),o=o.parentElement}this._containerWidth=r?Math.abs(e/r):e,this._containerHeight=i?Math.abs(t/i):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("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._canvas=o("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const n=this._controlContainer=o("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{r[e]=o("div","mapboxgl-ctrl-".concat(e),n)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,n){const r=e.f.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*Math.ceil(n),this._canvas.style.width="".concat(t,"px"),this._canvas.style.height="".concat(n,"px")}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.e({},n.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl2",t);r?(e.dj(r,!0),this.painter=new Jo(r,this._contextCreateOptions,this.transform,this._tp),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),e.dk.testSupport(r)):this.fire(new e.a(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.b("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.b("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 n;this.fire(new e.b("renderstart"));const r=this.painter.context.extTimerQuery,i=e.f.now(),o=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(n=o.createQuery(),o.beginQuery(r.TIME_ELAPSED_EXT,n)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const a=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,n=this.transform.pitch,r=e.f.now(),i=new e.N(t,{now:r,fadeDuration:a,pitch:n,transition:this.style.transition});this.style.update(i)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(i),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):s=this._updateAverageElevation(i),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,a,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,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.b("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.b("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){const t=e.f.now()-i;o.endQuery(r.TIME_ELAPSED_EXT),setTimeout((()=>{const r=o.getQueryParameter(n,o.QUERY_RESULT)/1e6;o.deleteQuery(n),this.fire(new e.b("gpu-timing-frame",{cpuTime:t,gpuTime:r}))}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const n=this.painter.queryGpuTimers(t);this.fire(new e.b("gpu-timing-layer",{layerTimes:n}))}),50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const n=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.b("gpu-timing-deferred-render",{gpuTime:n}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(l||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(s=this._updateAverageElevation(i,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.b("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.b("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._performanceMetricsCollection&&e.dl(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&n(0);const r=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(r||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let i=this.transform.sampleAverageElevation();this.transform.elevation&&(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||r)return this._averageElevation.jumpTo(i),n(i);this._averageElevation.easeTo(i,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(i),n(i)}return!!this._averageElevation.isEasing(e)&&n(this._averageElevation.getValue(e))}_authenticate(){e.dm(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.dn||401===t.status)){const t=this.painter.context.gl;e.dj(t,!1),this._logoControl instanceof es&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.a(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.dp(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_postStyleLoadEvent(){this.style.globalId&&e.dq(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const n=this.painter.context.gl,r=n.createFramebuffer();function i(e){n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0);const t=new Uint8Array(n.drawingBufferWidth*n.drawingBufferHeight*4);return n.readPixels(0,0,n.drawingBufferWidth,n.drawingBufferHeight,n.RGBA,n.UNSIGNED_BYTE,t),t}return n.bindFramebuffer(n.FRAMEBUFFER,r),this._canvasPixelComparison(i(e),t.canvasCopies.map(i),t.timeStamps)}_canvasPixelComparison(e,t,n){let r=n[1]-n[0];const i=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(t){const n=this.style?this.style.getSourceCaches():[];return e.b4(n,((e,n)=>e._preloadTiles(t,n)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),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._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,this._tp.refreshUI(),e&&this._update())}_setCacheLimits(t,n){e.dv(t,n)}get version(){return e.du}},NavigationControl:class{constructor(t){this.options=e.e({},ds,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.a$(["_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.a$(["_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(),n=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?"scale(".concat(1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5),") rotateX(").concat(e.transform.pitch,"deg) rotateZ(").concat(e.transform.angle*(180/Math.PI),"deg)"):"rotate(".concat(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 fs(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 n=o("button",e,this._container);return n.type="button",n.addEventListener("click",t),n}_setButtonTitle(e,t){if(!this._map)return;const n=this._map._getUIString("NavigationControl.".concat(t));e.setAttribute("aria-label",n),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends e.E{constructor(t){super();const n=navigator.geolocation;this.options=e.e({geolocation:n},ps,t),e.a$(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=$o(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(e){var t=this;const n=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!!t.options.geolocation;t._supportsGeolocation=n,e(n)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then((e=>n("denied"!==e.state))).catch((()=>n())):n()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),n=e.coords;return!!t&&(n.longitudet.getEast()||n.latitudet.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.b("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._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.b("geolocate",t)),this._finish()}}_updateCamera(t){const n=new e.bq(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,i=this._map.getBearing(),o=e.e({bearing:i},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(r),o,{geolocateSource:!0})}_updateMarker(t){if(t){const n=new e.bq(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).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,n=e.bo(1,t._center.lat)*t.worldSize,r=Math.ceil(2*this._accuracy*n);this._circleElement.style.width="".concat(r,"px"),this._circleElement.style.height="".concat(r,"px")}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("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._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.b("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){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.w("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 is({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new is({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.b("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.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.b("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.b("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.b("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 e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),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:$a,ScaleControl:class{constructor(t){this.options=e.e({},ms,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.a$(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,n=t._containerHeight/2,r=t._containerWidth/2-e/2,i=t.unproject([r,n]),o=t.unproject([r+e,n]),a=i.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*a;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,a/1852,"nautical-mile"):a>=1e3?this._setScale(e,a/1e3,"kilometer"):this._setScale(e,a,"meter")}_setScale(e,t,n){this._map._requestDomTask((()=>{const r=function(e){const t=Math.pow(10,"".concat(Math.floor(e)).length-1);let n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(n),t*n}(t),i=r/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==n?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:n}).format(r):"".concat(r," ").concat(gs[n]),this._container.style.width=e*i+"px"}))}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 HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.a$(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in 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.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),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(){(document.fullscreenElement||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()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.E{constructor(t){super(),this.options=e.e(Object.create(os),t),e.a$(["_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(),t._addPopup(this),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.b("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),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.b("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.bq.convert(t),this._pos=null,this._trackPointer=!1,this._update();const n=this._map;return n&&(n.on("move",this._update),n.off("mousemove",this._onMouseEvent),n._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(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),n=document.createElement("body");let r;for(n.innerHTML=e;r=n.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}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="×",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,n=this._container,r=this._pos;if(!t||!n||!r)return"bottom";const i=n.offsetWidth,o=n.offsetHeight,a=r.xt.transform.width-i/2;if(r.y+et.transform.height-o){if(a)return"bottom-left";if(s)return"bottom-right"}return a?"left":s?"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-".concat(this._anchor)),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const n=this._map,r=this._content;if(!n||!this._lngLat&&!this._trackPointer||!r)return;let i=this._container;if(i||(i=this._container=o("div","mapboxgl-popup",n.getContainer()),this._tip=o("div","mapboxgl-popup-tip",i),i.appendChild(r)),this.options.maxWidth&&i.style.maxWidth!==this.options.maxWidth&&(i.style.maxWidth=this.options.maxWidth),n.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=ns(this._lngLat,this._pos,n.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:n.project(this._lngLat),r=ss(this.options.offset),i=this._anchor=this._getAnchor(r.y),o=ss(this.options.offset,i),a=e.add(o).round();n._requestDomTask((()=>{this._container&&i&&(this._container.style.transform="".concat(rs[i]," translate(").concat(a.x,"px,").concat(a.y,"px)"))}))}if(!this._marker&&n._showingGlobe()){const t=e.de(n.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(as);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity="".concat(e)),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:is,Style:Ir,LngLat:e.bq,LngLatBounds:e.ag,Point:e.P,MercatorCoordinate:e.O,FreeCameraOptions:ur,Evented:e.E,config:e.dd,prewarm:e.dy,clearPrewarmedResources:e.dz,get accessToken(){return e.dd.ACCESS_TOKEN},set accessToken(t){e.dd.ACCESS_TOKEN=t},get baseApiUrl(){return e.dd.API_URL},set baseApiUrl(t){e.dd.API_URL=t},get workerCount(){return e.dA.workerCount},set workerCount(t){e.dA.workerCount=t},get maxParallelImageRequests(){return e.dd.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.dd.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.dB(t)},get workerUrl(){return e.dC.workerUrl},set workerUrl(t){e.dC.workerUrl=t},get workerClass(){return e.dC.workerClass},set workerClass(t){e.dC.workerClass=t},get workerParams(){return e.dC.workerParams},set workerParams(t){e.dC.workerParams=t},get dracoUrl(){return e.dD()},set dracoUrl(t){e.dE(t)},get meshoptUrl(){return e.dF()},set meshoptUrl(t){e.dG(t)},setNow:e.f.setNow,restoreNow:e.f.restoreNow};return _s})),n}()},1174:(e,t)=>{var n=function(){},r="+",i="0",o="23456789CFGHJMPQRVWX",a=90,s=180,l=10,c=[20,1,.05,.0025,125e-6],u=125e-6;n.prototype.isValid=function(e){if(!e)return!1;if(-1==e.indexOf(r))return!1;if(e.indexOf(r)!=e.lastIndexOf(r))return!1;if(1==e.length)return!1;if(e.indexOf(r)>8||e.indexOf(r)%2==1)return!1;if(e.indexOf(i)>-1){if(0==e.indexOf(i))return!1;var t=e.match(new RegExp("(0+)","g"));if(t.length>1||t[0].length%2==1||t[0].length>6)return!1;if(e.charAt(e.length-1)!=r)return!1}if(e.length-e.indexOf(r)-1==1)return!1;for(var n=0,a=(e=e.replace(new RegExp("\\++"),"").replace(new RegExp("0+"),"")).length;n=0&&e.indexOf(r)<8)},n.prototype.isFull=function(e){if(!this.isValid(e))return!1;if(this.isShort(e))return!1;if(20*o.indexOf(e.charAt(0).toUpperCase())>=180)return!1;if(e.length>1&&20*o.indexOf(e.charAt(1).toUpperCase())>=360)return!1;return!0},n.prototype.encode=function(e,t,n){if("undefined"==typeof n&&(n=l),n<2||n<8&&n%2==1)throw"IllegalArgumentException: Invalid Open Location Code length";e=h(e),t=f(t),90==e&&(e-=d(n));var r=p(e,t,Math.min(n,l));return n>l&&(r+=m(e,t,n-l)),r},n.prototype.decode=function(e){if(!this.isFull(e))throw"IllegalArgumentException: Passed Open Location Code is not a valid full code: "+e;e=(e=(e=e.replace(r,"")).replace(new RegExp("0+"),"")).toUpperCase();var t=g(e.substring(0,l));if(e.length<=l)return t;var n=y(e.substring(l));return v(t.latitudeLo+n.latitudeLo,t.longitudeLo+n.longitudeLo,t.latitudeLo+n.latitudeHi,t.longitudeLo+n.longitudeHi,t.codeLength+n.codeLength)},n.prototype.recoverNearest=function(e,t,n){if(!this.isShort(e)){if(this.isFull(e))return e;throw"ValueError: Passed short code is not valid: "+e}t=h(t),n=f(n);var i=8-(e=e.toUpperCase()).indexOf(r),o=Math.pow(20,2-i/2),a=o/2,s=Math.floor(t/o)*o,l=Math.floor(n/o)*o,c=this.decode(this.encode(s,l).substr(0,i)+e),u=c.latitudeCenter-t;return u>a?c.latitudeCenter-=o:u<-a&&(c.latitudeCenter+=o),(u=c.longitudeCenter-n)>a?c.longitudeCenter-=o:u<-a&&(c.longitudeCenter+=o),this.encode(c.latitudeCenter,c.longitudeCenter,c.codeLength)},n.prototype.shorten=function(e,t,n){if(!this.isFull(e))throw"ValueError: Passed code is not valid and full: "+e;if(-1!=e.indexOf(i))throw"ValueError: Cannot shorten padded codes: "+e;e=e.toUpperCase();var r=this.decode(e);if(r.codeLength<6)throw"ValueError: Code length must be at least 6";t=h(t),n=f(n);for(var o=Math.max(Math.abs(r.latitudeCenter-t),Math.abs(r.longitudeCenter-n)),a=c.length-2;a>=1;a--)if(o<.3*c[a])return e.substring(2*(a+1));return e};var h=function(e){return Math.min(90,Math.max(-90,e))},d=function(e){return e<=10?Math.pow(20,Math.floor(e/-2+2)):Math.pow(20,-3)/Math.pow(5,e-10)},f=function(e){for(;e<-180;)e+=360;for(;e>=180;)e-=360;return e},p=function(e,t,n){for(var l="",u=e+a,h=t+s,d=0;d{"use strict";var r=n(5043),i=n(8853);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n