function xN(s,l){for(var p=0;p<l.length;p++){const x=l[p];if(typeof x!="string"&&!Array.isArray(x)){for(const T in x)if(T!=="default"&&!(T in s)){const C=Object.getOwnPropertyDescriptor(x,T);C&&Object.defineProperty(s,T,C.get?C:{enumerable:!0,get:()=>x[T]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const T of document.querySelectorAll('link[rel="modulepreload"]'))x(T);new MutationObserver(T=>{for(const C of T)if(C.type==="childList")for(const L of C.addedNodes)L.tagName==="LINK"&&L.rel==="modulepreload"&&x(L)}).observe(document,{childList:!0,subtree:!0});function p(T){const C={};return T.integrity&&(C.integrity=T.integrity),T.referrerPolicy&&(C.referrerPolicy=T.referrerPolicy),T.crossOrigin==="use-credentials"?C.credentials="include":T.crossOrigin==="anonymous"?C.credentials="omit":C.credentials="same-origin",C}function x(T){if(T.ep)return;T.ep=!0;const C=p(T);fetch(T.href,C)}})();var vN=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function DS(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var dD={exports:{}},O0={},fD={exports:{}},tn={};/**
 * @license React
 * react.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Ug=Symbol.for("react.element"),bN=Symbol.for("react.portal"),wN=Symbol.for("react.fragment"),TN=Symbol.for("react.strict_mode"),SN=Symbol.for("react.profiler"),EN=Symbol.for("react.provider"),IN=Symbol.for("react.context"),AN=Symbol.for("react.forward_ref"),CN=Symbol.for("react.suspense"),PN=Symbol.for("react.memo"),MN=Symbol.for("react.lazy"),SP=Symbol.iterator;function RN(s){return s===null||typeof s!="object"?null:(s=SP&&s[SP]||s["@@iterator"],typeof s=="function"?s:null)}var pD={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},mD=Object.assign,_D={};function vp(s,l,p){this.props=s,this.context=l,this.refs=_D,this.updater=p||pD}vp.prototype.isReactComponent={};vp.prototype.setState=function(s,l){if(typeof s!="object"&&typeof s!="function"&&s!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,s,l,"setState")};vp.prototype.forceUpdate=function(s){this.updater.enqueueForceUpdate(this,s,"forceUpdate")};function gD(){}gD.prototype=vp.prototype;function LS(s,l,p){this.props=s,this.context=l,this.refs=_D,this.updater=p||pD}var zS=LS.prototype=new gD;zS.constructor=LS;mD(zS,vp.prototype);zS.isPureReactComponent=!0;var EP=Array.isArray,yD=Object.prototype.hasOwnProperty,kS={current:null},xD={key:!0,ref:!0,__self:!0,__source:!0};function vD(s,l,p){var x,T={},C=null,L=null;if(l!=null)for(x in l.ref!==void 0&&(L=l.ref),l.key!==void 0&&(C=""+l.key),l)yD.call(l,x)&&!xD.hasOwnProperty(x)&&(T[x]=l[x]);var a=arguments.length-2;if(a===1)T.children=p;else if(1<a){for(var F=Array(a),H=0;H<a;H++)F[H]=arguments[H+2];T.children=F}if(s&&s.defaultProps)for(x in a=s.defaultProps,a)T[x]===void 0&&(T[x]=a[x]);return{$$typeof:Ug,type:s,key:C,ref:L,props:T,_owner:kS.current}}function DN(s,l){return{$$typeof:Ug,type:s.type,key:l,ref:s.ref,props:s.props,_owner:s._owner}}function FS(s){return typeof s=="object"&&s!==null&&s.$$typeof===Ug}function LN(s){var l={"=":"=0",":":"=2"};return"$"+s.replace(/[=:]/g,function(p){return l[p]})}var IP=/\/+/g;function Sw(s,l){return typeof s=="object"&&s!==null&&s.key!=null?LN(""+s.key):l.toString(36)}function $v(s,l,p,x,T){var C=typeof s;(C==="undefined"||C==="boolean")&&(s=null);var L=!1;if(s===null)L=!0;else switch(C){case"string":case"number":L=!0;break;case"object":switch(s.$$typeof){case Ug:case bN:L=!0}}if(L)return L=s,T=T(L),s=x===""?"."+Sw(L,0):x,EP(T)?(p="",s!=null&&(p=s.replace(IP,"$&/")+"/"),$v(T,l,p,"",function(H){return H})):T!=null&&(FS(T)&&(T=DN(T,p+(!T.key||L&&L.key===T.key?"":(""+T.key).replace(IP,"$&/")+"/")+s)),l.push(T)),1;if(L=0,x=x===""?".":x+":",EP(s))for(var a=0;a<s.length;a++){C=s[a];var F=x+Sw(C,a);L+=$v(C,l,p,F,T)}else if(F=RN(s),typeof F=="function")for(s=F.call(s),a=0;!(C=s.next()).done;)C=C.value,F=x+Sw(C,a++),L+=$v(C,l,p,F,T);else if(C==="object")throw l=String(s),Error("Objects are not valid as a React child (found: "+(l==="[object Object]"?"object with keys {"+Object.keys(s).join(", ")+"}":l)+"). If you meant to render a collection of children, use an array instead.");return L}function bv(s,l,p){if(s==null)return s;var x=[],T=0;return $v(s,x,"","",function(C){return l.call(p,C,T++)}),x}function zN(s){if(s._status===-1){var l=s._result;l=l(),l.then(function(p){(s._status===0||s._status===-1)&&(s._status=1,s._result=p)},function(p){(s._status===0||s._status===-1)&&(s._status=2,s._result=p)}),s._status===-1&&(s._status=0,s._result=l)}if(s._status===1)return s._result.default;throw s._result}var Gs={current:null},Hv={transition:null},kN={ReactCurrentDispatcher:Gs,ReactCurrentBatchConfig:Hv,ReactCurrentOwner:kS};function bD(){throw Error("act(...) is not supported in production builds of React.")}tn.Children={map:bv,forEach:function(s,l,p){bv(s,function(){l.apply(this,arguments)},p)},count:function(s){var l=0;return bv(s,function(){l++}),l},toArray:function(s){return bv(s,function(l){return l})||[]},only:function(s){if(!FS(s))throw Error("React.Children.only expected to receive a single React element child.");return s}};tn.Component=vp;tn.Fragment=wN;tn.Profiler=SN;tn.PureComponent=LS;tn.StrictMode=TN;tn.Suspense=CN;tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=kN;tn.act=bD;tn.cloneElement=function(s,l,p){if(s==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+s+".");var x=mD({},s.props),T=s.key,C=s.ref,L=s._owner;if(l!=null){if(l.ref!==void 0&&(C=l.ref,L=kS.current),l.key!==void 0&&(T=""+l.key),s.type&&s.type.defaultProps)var a=s.type.defaultProps;for(F in l)yD.call(l,F)&&!xD.hasOwnProperty(F)&&(x[F]=l[F]===void 0&&a!==void 0?a[F]:l[F])}var F=arguments.length-2;if(F===1)x.children=p;else if(1<F){a=Array(F);for(var H=0;H<F;H++)a[H]=arguments[H+2];x.children=a}return{$$typeof:Ug,type:s.type,key:T,ref:C,props:x,_owner:L}};tn.createContext=function(s){return s={$$typeof:IN,_currentValue:s,_currentValue2:s,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},s.Provider={$$typeof:EN,_context:s},s.Consumer=s};tn.createElement=vD;tn.createFactory=function(s){var l=vD.bind(null,s);return l.type=s,l};tn.createRef=function(){return{current:null}};tn.forwardRef=function(s){return{$$typeof:AN,render:s}};tn.isValidElement=FS;tn.lazy=function(s){return{$$typeof:MN,_payload:{_status:-1,_result:s},_init:zN}};tn.memo=function(s,l){return{$$typeof:PN,type:s,compare:l===void 0?null:l}};tn.startTransition=function(s){var l=Hv.transition;Hv.transition={};try{s()}finally{Hv.transition=l}};tn.unstable_act=bD;tn.useCallback=function(s,l){return Gs.current.useCallback(s,l)};tn.useContext=function(s){return Gs.current.useContext(s)};tn.useDebugValue=function(){};tn.useDeferredValue=function(s){return Gs.current.useDeferredValue(s)};tn.useEffect=function(s,l){return Gs.current.useEffect(s,l)};tn.useId=function(){return Gs.current.useId()};tn.useImperativeHandle=function(s,l,p){return Gs.current.useImperativeHandle(s,l,p)};tn.useInsertionEffect=function(s,l){return Gs.current.useInsertionEffect(s,l)};tn.useLayoutEffect=function(s,l){return Gs.current.useLayoutEffect(s,l)};tn.useMemo=function(s,l){return Gs.current.useMemo(s,l)};tn.useReducer=function(s,l,p){return Gs.current.useReducer(s,l,p)};tn.useRef=function(s){return Gs.current.useRef(s)};tn.useState=function(s){return Gs.current.useState(s)};tn.useSyncExternalStore=function(s,l,p){return Gs.current.useSyncExternalStore(s,l,p)};tn.useTransition=function(){return Gs.current.useTransition()};tn.version="18.3.1";fD.exports=tn;var Ge=fD.exports;const OS=DS(Ge),FN=xN({__proto__:null,default:OS},[Ge]);/**
 * @license React
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var ON=Ge,BN=Symbol.for("react.element"),NN=Symbol.for("react.fragment"),VN=Object.prototype.hasOwnProperty,UN=ON.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,jN={key:!0,ref:!0,__self:!0,__source:!0};function wD(s,l,p){var x,T={},C=null,L=null;p!==void 0&&(C=""+p),l.key!==void 0&&(C=""+l.key),l.ref!==void 0&&(L=l.ref);for(x in l)VN.call(l,x)&&!jN.hasOwnProperty(x)&&(T[x]=l[x]);if(s&&s.defaultProps)for(x in l=s.defaultProps,l)T[x]===void 0&&(T[x]=l[x]);return{$$typeof:BN,type:s,key:C,ref:L,props:T,_owner:UN.current}}O0.Fragment=NN;O0.jsx=wD;O0.jsxs=wD;dD.exports=O0;var J=dD.exports,yT={},TD={exports:{}},Co={},SD={exports:{}},ED={};/**
 * @license React
 * scheduler.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */(function(s){function l(Pt,$t){var Wt=Pt.length;Pt.push($t);e:for(;0<Wt;){var Ut=Wt-1>>>1,ii=Pt[Ut];if(0<T(ii,$t))Pt[Ut]=$t,Pt[Wt]=ii,Wt=Ut;else break e}}function p(Pt){return Pt.length===0?null:Pt[0]}function x(Pt){if(Pt.length===0)return null;var $t=Pt[0],Wt=Pt.pop();if(Wt!==$t){Pt[0]=Wt;e:for(var Ut=0,ii=Pt.length,mi=ii>>>1;Ut<mi;){var rn=2*(Ut+1)-1,ln=Pt[rn],sn=rn+1,Rr=Pt[sn];if(0>T(ln,Wt))sn<ii&&0>T(Rr,ln)?(Pt[Ut]=Rr,Pt[sn]=Wt,Ut=sn):(Pt[Ut]=ln,Pt[rn]=Wt,Ut=rn);else if(sn<ii&&0>T(Rr,Wt))Pt[Ut]=Rr,Pt[sn]=Wt,Ut=sn;else break e}}return $t}function T(Pt,$t){var Wt=Pt.sortIndex-$t.sortIndex;return Wt!==0?Wt:Pt.id-$t.id}if(typeof performance=="object"&&typeof performance.now=="function"){var C=performance;s.unstable_now=function(){return C.now()}}else{var L=Date,a=L.now();s.unstable_now=function(){return L.now()-a}}var F=[],H=[],ee=1,se=null,ue=3,Me=!1,Ve=!1,ke=!1,Ye=typeof setTimeout=="function"?setTimeout:null,Se=typeof clearTimeout=="function"?clearTimeout:null,ye=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function Ie(Pt){for(var $t=p(H);$t!==null;){if($t.callback===null)x(H);else if($t.startTime<=Pt)x(H),$t.sortIndex=$t.expirationTime,l(F,$t);else break;$t=p(H)}}function qe(Pt){if(ke=!1,Ie(Pt),!Ve)if(p(F)!==null)Ve=!0,ji(ot);else{var $t=p(H);$t!==null&&ti(qe,$t.startTime-Pt)}}function ot(Pt,$t){Ve=!1,ke&&(ke=!1,Se(Tt),Tt=-1),Me=!0;var Wt=ue;try{for(Ie($t),se=p(F);se!==null&&(!(se.expirationTime>$t)||Pt&&!Ji());){var Ut=se.callback;if(typeof Ut=="function"){se.callback=null,ue=se.priorityLevel;var ii=Ut(se.expirationTime<=$t);$t=s.unstable_now(),typeof ii=="function"?se.callback=ii:se===p(F)&&x(F),Ie($t)}else x(F);se=p(F)}if(se!==null)var mi=!0;else{var rn=p(H);rn!==null&&ti(qe,rn.startTime-$t),mi=!1}return mi}finally{se=null,ue=Wt,Me=!1}}var xt=!1,Rt=null,Tt=-1,li=5,Xt=-1;function Ji(){return!(s.unstable_now()-Xt<li)}function An(){if(Rt!==null){var Pt=s.unstable_now();Xt=Pt;var $t=!0;try{$t=Rt(!0,Pt)}finally{$t?gi():(xt=!1,Rt=null)}}else xt=!1}var gi;if(typeof ye=="function")gi=function(){ye(An)};else if(typeof MessageChannel<"u"){var Mr=new MessageChannel,Wn=Mr.port2;Mr.port1.onmessage=An,gi=function(){Wn.postMessage(null)}}else gi=function(){Ye(An,0)};function ji(Pt){Rt=Pt,xt||(xt=!0,gi())}function ti(Pt,$t){Tt=Ye(function(){Pt(s.unstable_now())},$t)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(Pt){Pt.callback=null},s.unstable_continueExecution=function(){Ve||Me||(Ve=!0,ji(ot))},s.unstable_forceFrameRate=function(Pt){0>Pt||125<Pt?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):li=0<Pt?Math.floor(1e3/Pt):5},s.unstable_getCurrentPriorityLevel=function(){return ue},s.unstable_getFirstCallbackNode=function(){return p(F)},s.unstable_next=function(Pt){switch(ue){case 1:case 2:case 3:var $t=3;break;default:$t=ue}var Wt=ue;ue=$t;try{return Pt()}finally{ue=Wt}},s.unstable_pauseExecution=function(){},s.unstable_requestPaint=function(){},s.unstable_runWithPriority=function(Pt,$t){switch(Pt){case 1:case 2:case 3:case 4:case 5:break;default:Pt=3}var Wt=ue;ue=Pt;try{return $t()}finally{ue=Wt}},s.unstable_scheduleCallback=function(Pt,$t,Wt){var Ut=s.unstable_now();switch(typeof Wt=="object"&&Wt!==null?(Wt=Wt.delay,Wt=typeof Wt=="number"&&0<Wt?Ut+Wt:Ut):Wt=Ut,Pt){case 1:var ii=-1;break;case 2:ii=250;break;case 5:ii=1073741823;break;case 4:ii=1e4;break;default:ii=5e3}return ii=Wt+ii,Pt={id:ee++,callback:$t,priorityLevel:Pt,startTime:Wt,expirationTime:ii,sortIndex:-1},Wt>Ut?(Pt.sortIndex=Wt,l(H,Pt),p(F)===null&&Pt===p(H)&&(ke?(Se(Tt),Tt=-1):ke=!0,ti(qe,Wt-Ut))):(Pt.sortIndex=ii,l(F,Pt),Ve||Me||(Ve=!0,ji(ot))),Pt},s.unstable_shouldYield=Ji,s.unstable_wrapCallback=function(Pt){var $t=ue;return function(){var Wt=ue;ue=$t;try{return Pt.apply(this,arguments)}finally{ue=Wt}}}})(ED);SD.exports=ED;var GN=SD.exports;/**
 * @license React
 * react-dom.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var $N=Ge,Io=GN;function Ot(s){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+s,p=1;p<arguments.length;p++)l+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+s+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var ID=new Set,_g={};function Qh(s,l){lp(s,l),lp(s+"Capture",l)}function lp(s,l){for(_g[s]=l,s=0;s<l.length;s++)ID.add(l[s])}var tc=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),xT=Object.prototype.hasOwnProperty,HN=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,AP={},CP={};function ZN(s){return xT.call(CP,s)?!0:xT.call(AP,s)?!1:HN.test(s)?CP[s]=!0:(AP[s]=!0,!1)}function qN(s,l,p,x){if(p!==null&&p.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return x?!1:p!==null?!p.acceptsBooleans:(s=s.toLowerCase().slice(0,5),s!=="data-"&&s!=="aria-");default:return!1}}function WN(s,l,p,x){if(l===null||typeof l>"u"||qN(s,l,p,x))return!0;if(x)return!1;if(p!==null)switch(p.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function $s(s,l,p,x,T,C,L){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=x,this.attributeNamespace=T,this.mustUseProperty=p,this.propertyName=s,this.type=l,this.sanitizeURL=C,this.removeEmptyString=L}var cs={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(s){cs[s]=new $s(s,0,!1,s,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(s){var l=s[0];cs[l]=new $s(l,1,!1,s[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(s){cs[s]=new $s(s,2,!1,s.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(s){cs[s]=new $s(s,2,!1,s,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(s){cs[s]=new $s(s,3,!1,s.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(s){cs[s]=new $s(s,3,!0,s,null,!1,!1)});["capture","download"].forEach(function(s){cs[s]=new $s(s,4,!1,s,null,!1,!1)});["cols","rows","size","span"].forEach(function(s){cs[s]=new $s(s,6,!1,s,null,!1,!1)});["rowSpan","start"].forEach(function(s){cs[s]=new $s(s,5,!1,s.toLowerCase(),null,!1,!1)});var BS=/[\-:]([a-z])/g;function NS(s){return s[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(s){var l=s.replace(BS,NS);cs[l]=new $s(l,1,!1,s,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(s){var l=s.replace(BS,NS);cs[l]=new $s(l,1,!1,s,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(s){var l=s.replace(BS,NS);cs[l]=new $s(l,1,!1,s,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(s){cs[s]=new $s(s,1,!1,s.toLowerCase(),null,!1,!1)});cs.xlinkHref=new $s("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(s){cs[s]=new $s(s,1,!1,s.toLowerCase(),null,!0,!0)});function VS(s,l,p,x){var T=cs.hasOwnProperty(l)?cs[l]:null;(T!==null?T.type!==0:x||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(WN(l,p,T,x)&&(p=null),x||T===null?ZN(l)&&(p===null?s.removeAttribute(l):s.setAttribute(l,""+p)):T.mustUseProperty?s[T.propertyName]=p===null?T.type===3?!1:"":p:(l=T.attributeName,x=T.attributeNamespace,p===null?s.removeAttribute(l):(T=T.type,p=T===3||T===4&&p===!0?"":""+p,x?s.setAttributeNS(x,l,p):s.setAttribute(l,p))))}var lc=$N.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,wv=Symbol.for("react.element"),Bf=Symbol.for("react.portal"),Nf=Symbol.for("react.fragment"),US=Symbol.for("react.strict_mode"),vT=Symbol.for("react.profiler"),AD=Symbol.for("react.provider"),CD=Symbol.for("react.context"),jS=Symbol.for("react.forward_ref"),bT=Symbol.for("react.suspense"),wT=Symbol.for("react.suspense_list"),GS=Symbol.for("react.memo"),tu=Symbol.for("react.lazy"),PD=Symbol.for("react.offscreen"),PP=Symbol.iterator;function N_(s){return s===null||typeof s!="object"?null:(s=PP&&s[PP]||s["@@iterator"],typeof s=="function"?s:null)}var mr=Object.assign,Ew;function W_(s){if(Ew===void 0)try{throw Error()}catch(p){var l=p.stack.trim().match(/\n( *(at )?)/);Ew=l&&l[1]||""}return`
`+Ew+s}var Iw=!1;function Aw(s,l){if(!s||Iw)return"";Iw=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(H){var x=H}Reflect.construct(s,[],l)}else{try{l.call()}catch(H){x=H}s.call(l.prototype)}else{try{throw Error()}catch(H){x=H}s()}}catch(H){if(H&&x&&typeof H.stack=="string"){for(var T=H.stack.split(`
`),C=x.stack.split(`
`),L=T.length-1,a=C.length-1;1<=L&&0<=a&&T[L]!==C[a];)a--;for(;1<=L&&0<=a;L--,a--)if(T[L]!==C[a]){if(L!==1||a!==1)do if(L--,a--,0>a||T[L]!==C[a]){var F=`
`+T[L].replace(" at new "," at ");return s.displayName&&F.includes("<anonymous>")&&(F=F.replace("<anonymous>",s.displayName)),F}while(1<=L&&0<=a);break}}}finally{Iw=!1,Error.prepareStackTrace=p}return(s=s?s.displayName||s.name:"")?W_(s):""}function XN(s){switch(s.tag){case 5:return W_(s.type);case 16:return W_("Lazy");case 13:return W_("Suspense");case 19:return W_("SuspenseList");case 0:case 2:case 15:return s=Aw(s.type,!1),s;case 11:return s=Aw(s.type.render,!1),s;case 1:return s=Aw(s.type,!0),s;default:return""}}function TT(s){if(s==null)return null;if(typeof s=="function")return s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case Nf:return"Fragment";case Bf:return"Portal";case vT:return"Profiler";case US:return"StrictMode";case bT:return"Suspense";case wT:return"SuspenseList"}if(typeof s=="object")switch(s.$$typeof){case CD:return(s.displayName||"Context")+".Consumer";case AD:return(s._context.displayName||"Context")+".Provider";case jS:var l=s.render;return s=s.displayName,s||(s=l.displayName||l.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case GS:return l=s.displayName||null,l!==null?l:TT(s.type)||"Memo";case tu:l=s._payload,s=s._init;try{return TT(s(l))}catch{}}return null}function YN(s){var l=s.type;switch(s.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return s=l.render,s=s.displayName||s.name||"",l.displayName||(s!==""?"ForwardRef("+s+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return TT(l);case 8:return l===US?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function _u(s){switch(typeof s){case"boolean":case"number":case"string":case"undefined":return s;case"object":return s;default:return""}}function MD(s){var l=s.type;return(s=s.nodeName)&&s.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function KN(s){var l=MD(s)?"checked":"value",p=Object.getOwnPropertyDescriptor(s.constructor.prototype,l),x=""+s[l];if(!s.hasOwnProperty(l)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var T=p.get,C=p.set;return Object.defineProperty(s,l,{configurable:!0,get:function(){return T.call(this)},set:function(L){x=""+L,C.call(this,L)}}),Object.defineProperty(s,l,{enumerable:p.enumerable}),{getValue:function(){return x},setValue:function(L){x=""+L},stopTracking:function(){s._valueTracker=null,delete s[l]}}}}function Tv(s){s._valueTracker||(s._valueTracker=KN(s))}function RD(s){if(!s)return!1;var l=s._valueTracker;if(!l)return!0;var p=l.getValue(),x="";return s&&(x=MD(s)?s.checked?"true":"false":s.value),s=x,s!==p?(l.setValue(s),!0):!1}function o0(s){if(s=s||(typeof document<"u"?document:void 0),typeof s>"u")return null;try{return s.activeElement||s.body}catch{return s.body}}function ST(s,l){var p=l.checked;return mr({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??s._wrapperState.initialChecked})}function MP(s,l){var p=l.defaultValue==null?"":l.defaultValue,x=l.checked!=null?l.checked:l.defaultChecked;p=_u(l.value!=null?l.value:p),s._wrapperState={initialChecked:x,initialValue:p,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function DD(s,l){l=l.checked,l!=null&&VS(s,"checked",l,!1)}function ET(s,l){DD(s,l);var p=_u(l.value),x=l.type;if(p!=null)x==="number"?(p===0&&s.value===""||s.value!=p)&&(s.value=""+p):s.value!==""+p&&(s.value=""+p);else if(x==="submit"||x==="reset"){s.removeAttribute("value");return}l.hasOwnProperty("value")?IT(s,l.type,p):l.hasOwnProperty("defaultValue")&&IT(s,l.type,_u(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(s.defaultChecked=!!l.defaultChecked)}function RP(s,l,p){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var x=l.type;if(!(x!=="submit"&&x!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+s._wrapperState.initialValue,p||l===s.value||(s.value=l),s.defaultValue=l}p=s.name,p!==""&&(s.name=""),s.defaultChecked=!!s._wrapperState.initialChecked,p!==""&&(s.name=p)}function IT(s,l,p){(l!=="number"||o0(s.ownerDocument)!==s)&&(p==null?s.defaultValue=""+s._wrapperState.initialValue:s.defaultValue!==""+p&&(s.defaultValue=""+p))}var X_=Array.isArray;function tp(s,l,p,x){if(s=s.options,l){l={};for(var T=0;T<p.length;T++)l["$"+p[T]]=!0;for(p=0;p<s.length;p++)T=l.hasOwnProperty("$"+s[p].value),s[p].selected!==T&&(s[p].selected=T),T&&x&&(s[p].defaultSelected=!0)}else{for(p=""+_u(p),l=null,T=0;T<s.length;T++){if(s[T].value===p){s[T].selected=!0,x&&(s[T].defaultSelected=!0);return}l!==null||s[T].disabled||(l=s[T])}l!==null&&(l.selected=!0)}}function AT(s,l){if(l.dangerouslySetInnerHTML!=null)throw Error(Ot(91));return mr({},l,{value:void 0,defaultValue:void 0,children:""+s._wrapperState.initialValue})}function DP(s,l){var p=l.value;if(p==null){if(p=l.children,l=l.defaultValue,p!=null){if(l!=null)throw Error(Ot(92));if(X_(p)){if(1<p.length)throw Error(Ot(93));p=p[0]}l=p}l==null&&(l=""),p=l}s._wrapperState={initialValue:_u(p)}}function LD(s,l){var p=_u(l.value),x=_u(l.defaultValue);p!=null&&(p=""+p,p!==s.value&&(s.value=p),l.defaultValue==null&&s.defaultValue!==p&&(s.defaultValue=p)),x!=null&&(s.defaultValue=""+x)}function LP(s){var l=s.textContent;l===s._wrapperState.initialValue&&l!==""&&l!==null&&(s.value=l)}function zD(s){switch(s){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function CT(s,l){return s==null||s==="http://www.w3.org/1999/xhtml"?zD(l):s==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":s}var Sv,kD=function(s){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,p,x,T){MSApp.execUnsafeLocalFunction(function(){return s(l,p,x,T)})}:s}(function(s,l){if(s.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in s)s.innerHTML=l;else{for(Sv=Sv||document.createElement("div"),Sv.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=Sv.firstChild;s.firstChild;)s.removeChild(s.firstChild);for(;l.firstChild;)s.appendChild(l.firstChild)}});function gg(s,l){if(l){var p=s.firstChild;if(p&&p===s.lastChild&&p.nodeType===3){p.nodeValue=l;return}}s.textContent=l}var tg={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},JN=["Webkit","ms","Moz","O"];Object.keys(tg).forEach(function(s){JN.forEach(function(l){l=l+s.charAt(0).toUpperCase()+s.substring(1),tg[l]=tg[s]})});function FD(s,l,p){return l==null||typeof l=="boolean"||l===""?"":p||typeof l!="number"||l===0||tg.hasOwnProperty(s)&&tg[s]?(""+l).trim():l+"px"}function OD(s,l){s=s.style;for(var p in l)if(l.hasOwnProperty(p)){var x=p.indexOf("--")===0,T=FD(p,l[p],x);p==="float"&&(p="cssFloat"),x?s.setProperty(p,T):s[p]=T}}var QN=mr({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function PT(s,l){if(l){if(QN[s]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(Ot(137,s));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(Ot(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(Ot(61))}if(l.style!=null&&typeof l.style!="object")throw Error(Ot(62))}}function MT(s,l){if(s.indexOf("-")===-1)return typeof l.is=="string";switch(s){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var RT=null;function $S(s){return s=s.target||s.srcElement||window,s.correspondingUseElement&&(s=s.correspondingUseElement),s.nodeType===3?s.parentNode:s}var DT=null,ip=null,np=null;function zP(s){if(s=$g(s)){if(typeof DT!="function")throw Error(Ot(280));var l=s.stateNode;l&&(l=j0(l),DT(s.stateNode,s.type,l))}}function BD(s){ip?np?np.push(s):np=[s]:ip=s}function ND(){if(ip){var s=ip,l=np;if(np=ip=null,zP(s),l)for(s=0;s<l.length;s++)zP(l[s])}}function VD(s,l){return s(l)}function UD(){}var Cw=!1;function jD(s,l,p){if(Cw)return s(l,p);Cw=!0;try{return VD(s,l,p)}finally{Cw=!1,(ip!==null||np!==null)&&(UD(),ND())}}function yg(s,l){var p=s.stateNode;if(p===null)return null;var x=j0(p);if(x===null)return null;p=x[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(x=!x.disabled)||(s=s.type,x=!(s==="button"||s==="input"||s==="select"||s==="textarea")),s=!x;break e;default:s=!1}if(s)return null;if(p&&typeof p!="function")throw Error(Ot(231,l,typeof p));return p}var LT=!1;if(tc)try{var V_={};Object.defineProperty(V_,"passive",{get:function(){LT=!0}}),window.addEventListener("test",V_,V_),window.removeEventListener("test",V_,V_)}catch{LT=!1}function e4(s,l,p,x,T,C,L,a,F){var H=Array.prototype.slice.call(arguments,3);try{l.apply(p,H)}catch(ee){this.onError(ee)}}var ig=!1,a0=null,l0=!1,zT=null,t4={onError:function(s){ig=!0,a0=s}};function i4(s,l,p,x,T,C,L,a,F){ig=!1,a0=null,e4.apply(t4,arguments)}function n4(s,l,p,x,T,C,L,a,F){if(i4.apply(this,arguments),ig){if(ig){var H=a0;ig=!1,a0=null}else throw Error(Ot(198));l0||(l0=!0,zT=H)}}function ed(s){var l=s,p=s;if(s.alternate)for(;l.return;)l=l.return;else{s=l;do l=s,l.flags&4098&&(p=l.return),s=l.return;while(s)}return l.tag===3?p:null}function GD(s){if(s.tag===13){var l=s.memoizedState;if(l===null&&(s=s.alternate,s!==null&&(l=s.memoizedState)),l!==null)return l.dehydrated}return null}function kP(s){if(ed(s)!==s)throw Error(Ot(188))}function r4(s){var l=s.alternate;if(!l){if(l=ed(s),l===null)throw Error(Ot(188));return l!==s?null:s}for(var p=s,x=l;;){var T=p.return;if(T===null)break;var C=T.alternate;if(C===null){if(x=T.return,x!==null){p=x;continue}break}if(T.child===C.child){for(C=T.child;C;){if(C===p)return kP(T),s;if(C===x)return kP(T),l;C=C.sibling}throw Error(Ot(188))}if(p.return!==x.return)p=T,x=C;else{for(var L=!1,a=T.child;a;){if(a===p){L=!0,p=T,x=C;break}if(a===x){L=!0,x=T,p=C;break}a=a.sibling}if(!L){for(a=C.child;a;){if(a===p){L=!0,p=C,x=T;break}if(a===x){L=!0,x=C,p=T;break}a=a.sibling}if(!L)throw Error(Ot(189))}}if(p.alternate!==x)throw Error(Ot(190))}if(p.tag!==3)throw Error(Ot(188));return p.stateNode.current===p?s:l}function $D(s){return s=r4(s),s!==null?HD(s):null}function HD(s){if(s.tag===5||s.tag===6)return s;for(s=s.child;s!==null;){var l=HD(s);if(l!==null)return l;s=s.sibling}return null}var ZD=Io.unstable_scheduleCallback,FP=Io.unstable_cancelCallback,s4=Io.unstable_shouldYield,o4=Io.unstable_requestPaint,Pr=Io.unstable_now,a4=Io.unstable_getCurrentPriorityLevel,HS=Io.unstable_ImmediatePriority,qD=Io.unstable_UserBlockingPriority,c0=Io.unstable_NormalPriority,l4=Io.unstable_LowPriority,WD=Io.unstable_IdlePriority,B0=null,ll=null;function c4(s){if(ll&&typeof ll.onCommitFiberRoot=="function")try{ll.onCommitFiberRoot(B0,s,void 0,(s.current.flags&128)===128)}catch{}}var Ma=Math.clz32?Math.clz32:d4,u4=Math.log,h4=Math.LN2;function d4(s){return s>>>=0,s===0?32:31-(u4(s)/h4|0)|0}var Ev=64,Iv=4194304;function Y_(s){switch(s&-s){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return s&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return s&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return s}}function u0(s,l){var p=s.pendingLanes;if(p===0)return 0;var x=0,T=s.suspendedLanes,C=s.pingedLanes,L=p&268435455;if(L!==0){var a=L&~T;a!==0?x=Y_(a):(C&=L,C!==0&&(x=Y_(C)))}else L=p&~T,L!==0?x=Y_(L):C!==0&&(x=Y_(C));if(x===0)return 0;if(l!==0&&l!==x&&!(l&T)&&(T=x&-x,C=l&-l,T>=C||T===16&&(C&4194240)!==0))return l;if(x&4&&(x|=p&16),l=s.entangledLanes,l!==0)for(s=s.entanglements,l&=x;0<l;)p=31-Ma(l),T=1<<p,x|=s[p],l&=~T;return x}function f4(s,l){switch(s){case 1:case 2:case 4:return l+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function p4(s,l){for(var p=s.suspendedLanes,x=s.pingedLanes,T=s.expirationTimes,C=s.pendingLanes;0<C;){var L=31-Ma(C),a=1<<L,F=T[L];F===-1?(!(a&p)||a&x)&&(T[L]=f4(a,l)):F<=l&&(s.expiredLanes|=a),C&=~a}}function kT(s){return s=s.pendingLanes&-1073741825,s!==0?s:s&1073741824?1073741824:0}function XD(){var s=Ev;return Ev<<=1,!(Ev&4194240)&&(Ev=64),s}function Pw(s){for(var l=[],p=0;31>p;p++)l.push(s);return l}function jg(s,l,p){s.pendingLanes|=l,l!==536870912&&(s.suspendedLanes=0,s.pingedLanes=0),s=s.eventTimes,l=31-Ma(l),s[l]=p}function m4(s,l){var p=s.pendingLanes&~l;s.pendingLanes=l,s.suspendedLanes=0,s.pingedLanes=0,s.expiredLanes&=l,s.mutableReadLanes&=l,s.entangledLanes&=l,l=s.entanglements;var x=s.eventTimes;for(s=s.expirationTimes;0<p;){var T=31-Ma(p),C=1<<T;l[T]=0,x[T]=-1,s[T]=-1,p&=~C}}function ZS(s,l){var p=s.entangledLanes|=l;for(s=s.entanglements;p;){var x=31-Ma(p),T=1<<x;T&l|s[x]&l&&(s[x]|=l),p&=~T}}var Fn=0;function YD(s){return s&=-s,1<s?4<s?s&268435455?16:536870912:4:1}var KD,qS,JD,QD,eL,FT=!1,Av=[],lu=null,cu=null,uu=null,xg=new Map,vg=new Map,nu=[],_4="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function OP(s,l){switch(s){case"focusin":case"focusout":lu=null;break;case"dragenter":case"dragleave":cu=null;break;case"mouseover":case"mouseout":uu=null;break;case"pointerover":case"pointerout":xg.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":vg.delete(l.pointerId)}}function U_(s,l,p,x,T,C){return s===null||s.nativeEvent!==C?(s={blockedOn:l,domEventName:p,eventSystemFlags:x,nativeEvent:C,targetContainers:[T]},l!==null&&(l=$g(l),l!==null&&qS(l)),s):(s.eventSystemFlags|=x,l=s.targetContainers,T!==null&&l.indexOf(T)===-1&&l.push(T),s)}function g4(s,l,p,x,T){switch(l){case"focusin":return lu=U_(lu,s,l,p,x,T),!0;case"dragenter":return cu=U_(cu,s,l,p,x,T),!0;case"mouseover":return uu=U_(uu,s,l,p,x,T),!0;case"pointerover":var C=T.pointerId;return xg.set(C,U_(xg.get(C)||null,s,l,p,x,T)),!0;case"gotpointercapture":return C=T.pointerId,vg.set(C,U_(vg.get(C)||null,s,l,p,x,T)),!0}return!1}function tL(s){var l=Vh(s.target);if(l!==null){var p=ed(l);if(p!==null){if(l=p.tag,l===13){if(l=GD(p),l!==null){s.blockedOn=l,eL(s.priority,function(){JD(p)});return}}else if(l===3&&p.stateNode.current.memoizedState.isDehydrated){s.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}s.blockedOn=null}function Zv(s){if(s.blockedOn!==null)return!1;for(var l=s.targetContainers;0<l.length;){var p=OT(s.domEventName,s.eventSystemFlags,l[0],s.nativeEvent);if(p===null){p=s.nativeEvent;var x=new p.constructor(p.type,p);RT=x,p.target.dispatchEvent(x),RT=null}else return l=$g(p),l!==null&&qS(l),s.blockedOn=p,!1;l.shift()}return!0}function BP(s,l,p){Zv(s)&&p.delete(l)}function y4(){FT=!1,lu!==null&&Zv(lu)&&(lu=null),cu!==null&&Zv(cu)&&(cu=null),uu!==null&&Zv(uu)&&(uu=null),xg.forEach(BP),vg.forEach(BP)}function j_(s,l){s.blockedOn===l&&(s.blockedOn=null,FT||(FT=!0,Io.unstable_scheduleCallback(Io.unstable_NormalPriority,y4)))}function bg(s){function l(T){return j_(T,s)}if(0<Av.length){j_(Av[0],s);for(var p=1;p<Av.length;p++){var x=Av[p];x.blockedOn===s&&(x.blockedOn=null)}}for(lu!==null&&j_(lu,s),cu!==null&&j_(cu,s),uu!==null&&j_(uu,s),xg.forEach(l),vg.forEach(l),p=0;p<nu.length;p++)x=nu[p],x.blockedOn===s&&(x.blockedOn=null);for(;0<nu.length&&(p=nu[0],p.blockedOn===null);)tL(p),p.blockedOn===null&&nu.shift()}var rp=lc.ReactCurrentBatchConfig,h0=!0;function x4(s,l,p,x){var T=Fn,C=rp.transition;rp.transition=null;try{Fn=1,WS(s,l,p,x)}finally{Fn=T,rp.transition=C}}function v4(s,l,p,x){var T=Fn,C=rp.transition;rp.transition=null;try{Fn=4,WS(s,l,p,x)}finally{Fn=T,rp.transition=C}}function WS(s,l,p,x){if(h0){var T=OT(s,l,p,x);if(T===null)Nw(s,l,x,d0,p),OP(s,x);else if(g4(T,s,l,p,x))x.stopPropagation();else if(OP(s,x),l&4&&-1<_4.indexOf(s)){for(;T!==null;){var C=$g(T);if(C!==null&&KD(C),C=OT(s,l,p,x),C===null&&Nw(s,l,x,d0,p),C===T)break;T=C}T!==null&&x.stopPropagation()}else Nw(s,l,x,null,p)}}var d0=null;function OT(s,l,p,x){if(d0=null,s=$S(x),s=Vh(s),s!==null)if(l=ed(s),l===null)s=null;else if(p=l.tag,p===13){if(s=GD(l),s!==null)return s;s=null}else if(p===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;s=null}else l!==s&&(s=null);return d0=s,null}function iL(s){switch(s){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(a4()){case HS:return 1;case qD:return 4;case c0:case l4:return 16;case WD:return 536870912;default:return 16}default:return 16}}var su=null,XS=null,qv=null;function nL(){if(qv)return qv;var s,l=XS,p=l.length,x,T="value"in su?su.value:su.textContent,C=T.length;for(s=0;s<p&&l[s]===T[s];s++);var L=p-s;for(x=1;x<=L&&l[p-x]===T[C-x];x++);return qv=T.slice(s,1<x?1-x:void 0)}function Wv(s){var l=s.keyCode;return"charCode"in s?(s=s.charCode,s===0&&l===13&&(s=13)):s=l,s===10&&(s=13),32<=s||s===13?s:0}function Cv(){return!0}function NP(){return!1}function Po(s){function l(p,x,T,C,L){this._reactName=p,this._targetInst=T,this.type=x,this.nativeEvent=C,this.target=L,this.currentTarget=null;for(var a in s)s.hasOwnProperty(a)&&(p=s[a],this[a]=p?p(C):C[a]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?Cv:NP,this.isPropagationStopped=NP,this}return mr(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Cv)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Cv)},persist:function(){},isPersistent:Cv}),l}var bp={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(s){return s.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},YS=Po(bp),Gg=mr({},bp,{view:0,detail:0}),b4=Po(Gg),Mw,Rw,G_,N0=mr({},Gg,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:KS,button:0,buttons:0,relatedTarget:function(s){return s.relatedTarget===void 0?s.fromElement===s.srcElement?s.toElement:s.fromElement:s.relatedTarget},movementX:function(s){return"movementX"in s?s.movementX:(s!==G_&&(G_&&s.type==="mousemove"?(Mw=s.screenX-G_.screenX,Rw=s.screenY-G_.screenY):Rw=Mw=0,G_=s),Mw)},movementY:function(s){return"movementY"in s?s.movementY:Rw}}),VP=Po(N0),w4=mr({},N0,{dataTransfer:0}),T4=Po(w4),S4=mr({},Gg,{relatedTarget:0}),Dw=Po(S4),E4=mr({},bp,{animationName:0,elapsedTime:0,pseudoElement:0}),I4=Po(E4),A4=mr({},bp,{clipboardData:function(s){return"clipboardData"in s?s.clipboardData:window.clipboardData}}),C4=Po(A4),P4=mr({},bp,{data:0}),UP=Po(P4),M4={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},R4={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},D4={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function L4(s){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(s):(s=D4[s])?!!l[s]:!1}function KS(){return L4}var z4=mr({},Gg,{key:function(s){if(s.key){var l=M4[s.key]||s.key;if(l!=="Unidentified")return l}return s.type==="keypress"?(s=Wv(s),s===13?"Enter":String.fromCharCode(s)):s.type==="keydown"||s.type==="keyup"?R4[s.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:KS,charCode:function(s){return s.type==="keypress"?Wv(s):0},keyCode:function(s){return s.type==="keydown"||s.type==="keyup"?s.keyCode:0},which:function(s){return s.type==="keypress"?Wv(s):s.type==="keydown"||s.type==="keyup"?s.keyCode:0}}),k4=Po(z4),F4=mr({},N0,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),jP=Po(F4),O4=mr({},Gg,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:KS}),B4=Po(O4),N4=mr({},bp,{propertyName:0,elapsedTime:0,pseudoElement:0}),V4=Po(N4),U4=mr({},N0,{deltaX:function(s){return"deltaX"in s?s.deltaX:"wheelDeltaX"in s?-s.wheelDeltaX:0},deltaY:function(s){return"deltaY"in s?s.deltaY:"wheelDeltaY"in s?-s.wheelDeltaY:"wheelDelta"in s?-s.wheelDelta:0},deltaZ:0,deltaMode:0}),j4=Po(U4),G4=[9,13,27,32],JS=tc&&"CompositionEvent"in window,ng=null;tc&&"documentMode"in document&&(ng=document.documentMode);var $4=tc&&"TextEvent"in window&&!ng,rL=tc&&(!JS||ng&&8<ng&&11>=ng),GP=" ",$P=!1;function sL(s,l){switch(s){case"keyup":return G4.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function oL(s){return s=s.detail,typeof s=="object"&&"data"in s?s.data:null}var Vf=!1;function H4(s,l){switch(s){case"compositionend":return oL(l);case"keypress":return l.which!==32?null:($P=!0,GP);case"textInput":return s=l.data,s===GP&&$P?null:s;default:return null}}function Z4(s,l){if(Vf)return s==="compositionend"||!JS&&sL(s,l)?(s=nL(),qv=XS=su=null,Vf=!1,s):null;switch(s){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return rL&&l.locale!=="ko"?null:l.data;default:return null}}var q4={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function HP(s){var l=s&&s.nodeName&&s.nodeName.toLowerCase();return l==="input"?!!q4[s.type]:l==="textarea"}function aL(s,l,p,x){BD(x),l=f0(l,"onChange"),0<l.length&&(p=new YS("onChange","change",null,p,x),s.push({event:p,listeners:l}))}var rg=null,wg=null;function W4(s){yL(s,0)}function V0(s){var l=Gf(s);if(RD(l))return s}function X4(s,l){if(s==="change")return l}var lL=!1;if(tc){var Lw;if(tc){var zw="oninput"in document;if(!zw){var ZP=document.createElement("div");ZP.setAttribute("oninput","return;"),zw=typeof ZP.oninput=="function"}Lw=zw}else Lw=!1;lL=Lw&&(!document.documentMode||9<document.documentMode)}function qP(){rg&&(rg.detachEvent("onpropertychange",cL),wg=rg=null)}function cL(s){if(s.propertyName==="value"&&V0(wg)){var l=[];aL(l,wg,s,$S(s)),jD(W4,l)}}function Y4(s,l,p){s==="focusin"?(qP(),rg=l,wg=p,rg.attachEvent("onpropertychange",cL)):s==="focusout"&&qP()}function K4(s){if(s==="selectionchange"||s==="keyup"||s==="keydown")return V0(wg)}function J4(s,l){if(s==="click")return V0(l)}function Q4(s,l){if(s==="input"||s==="change")return V0(l)}function eV(s,l){return s===l&&(s!==0||1/s===1/l)||s!==s&&l!==l}var Da=typeof Object.is=="function"?Object.is:eV;function Tg(s,l){if(Da(s,l))return!0;if(typeof s!="object"||s===null||typeof l!="object"||l===null)return!1;var p=Object.keys(s),x=Object.keys(l);if(p.length!==x.length)return!1;for(x=0;x<p.length;x++){var T=p[x];if(!xT.call(l,T)||!Da(s[T],l[T]))return!1}return!0}function WP(s){for(;s&&s.firstChild;)s=s.firstChild;return s}function XP(s,l){var p=WP(s);s=0;for(var x;p;){if(p.nodeType===3){if(x=s+p.textContent.length,s<=l&&x>=l)return{node:p,offset:l-s};s=x}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=WP(p)}}function uL(s,l){return s&&l?s===l?!0:s&&s.nodeType===3?!1:l&&l.nodeType===3?uL(s,l.parentNode):"contains"in s?s.contains(l):s.compareDocumentPosition?!!(s.compareDocumentPosition(l)&16):!1:!1}function hL(){for(var s=window,l=o0();l instanceof s.HTMLIFrameElement;){try{var p=typeof l.contentWindow.location.href=="string"}catch{p=!1}if(p)s=l.contentWindow;else break;l=o0(s.document)}return l}function QS(s){var l=s&&s.nodeName&&s.nodeName.toLowerCase();return l&&(l==="input"&&(s.type==="text"||s.type==="search"||s.type==="tel"||s.type==="url"||s.type==="password")||l==="textarea"||s.contentEditable==="true")}function tV(s){var l=hL(),p=s.focusedElem,x=s.selectionRange;if(l!==p&&p&&p.ownerDocument&&uL(p.ownerDocument.documentElement,p)){if(x!==null&&QS(p)){if(l=x.start,s=x.end,s===void 0&&(s=l),"selectionStart"in p)p.selectionStart=l,p.selectionEnd=Math.min(s,p.value.length);else if(s=(l=p.ownerDocument||document)&&l.defaultView||window,s.getSelection){s=s.getSelection();var T=p.textContent.length,C=Math.min(x.start,T);x=x.end===void 0?C:Math.min(x.end,T),!s.extend&&C>x&&(T=x,x=C,C=T),T=XP(p,C);var L=XP(p,x);T&&L&&(s.rangeCount!==1||s.anchorNode!==T.node||s.anchorOffset!==T.offset||s.focusNode!==L.node||s.focusOffset!==L.offset)&&(l=l.createRange(),l.setStart(T.node,T.offset),s.removeAllRanges(),C>x?(s.addRange(l),s.extend(L.node,L.offset)):(l.setEnd(L.node,L.offset),s.addRange(l)))}}for(l=[],s=p;s=s.parentNode;)s.nodeType===1&&l.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<l.length;p++)s=l[p],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var iV=tc&&"documentMode"in document&&11>=document.documentMode,Uf=null,BT=null,sg=null,NT=!1;function YP(s,l,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;NT||Uf==null||Uf!==o0(x)||(x=Uf,"selectionStart"in x&&QS(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),sg&&Tg(sg,x)||(sg=x,x=f0(BT,"onSelect"),0<x.length&&(l=new YS("onSelect","select",null,l,p),s.push({event:l,listeners:x}),l.target=Uf)))}function Pv(s,l){var p={};return p[s.toLowerCase()]=l.toLowerCase(),p["Webkit"+s]="webkit"+l,p["Moz"+s]="moz"+l,p}var jf={animationend:Pv("Animation","AnimationEnd"),animationiteration:Pv("Animation","AnimationIteration"),animationstart:Pv("Animation","AnimationStart"),transitionend:Pv("Transition","TransitionEnd")},kw={},dL={};tc&&(dL=document.createElement("div").style,"AnimationEvent"in window||(delete jf.animationend.animation,delete jf.animationiteration.animation,delete jf.animationstart.animation),"TransitionEvent"in window||delete jf.transitionend.transition);function U0(s){if(kw[s])return kw[s];if(!jf[s])return s;var l=jf[s],p;for(p in l)if(l.hasOwnProperty(p)&&p in dL)return kw[s]=l[p];return s}var fL=U0("animationend"),pL=U0("animationiteration"),mL=U0("animationstart"),_L=U0("transitionend"),gL=new Map,KP="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function vu(s,l){gL.set(s,l),Qh(l,[s])}for(var Fw=0;Fw<KP.length;Fw++){var Ow=KP[Fw],nV=Ow.toLowerCase(),rV=Ow[0].toUpperCase()+Ow.slice(1);vu(nV,"on"+rV)}vu(fL,"onAnimationEnd");vu(pL,"onAnimationIteration");vu(mL,"onAnimationStart");vu("dblclick","onDoubleClick");vu("focusin","onFocus");vu("focusout","onBlur");vu(_L,"onTransitionEnd");lp("onMouseEnter",["mouseout","mouseover"]);lp("onMouseLeave",["mouseout","mouseover"]);lp("onPointerEnter",["pointerout","pointerover"]);lp("onPointerLeave",["pointerout","pointerover"]);Qh("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Qh("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Qh("onBeforeInput",["compositionend","keypress","textInput","paste"]);Qh("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Qh("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Qh("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var K_="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),sV=new Set("cancel close invalid load scroll toggle".split(" ").concat(K_));function JP(s,l,p){var x=s.type||"unknown-event";s.currentTarget=p,n4(x,l,void 0,s),s.currentTarget=null}function yL(s,l){l=(l&4)!==0;for(var p=0;p<s.length;p++){var x=s[p],T=x.event;x=x.listeners;e:{var C=void 0;if(l)for(var L=x.length-1;0<=L;L--){var a=x[L],F=a.instance,H=a.currentTarget;if(a=a.listener,F!==C&&T.isPropagationStopped())break e;JP(T,a,H),C=F}else for(L=0;L<x.length;L++){if(a=x[L],F=a.instance,H=a.currentTarget,a=a.listener,F!==C&&T.isPropagationStopped())break e;JP(T,a,H),C=F}}}if(l0)throw s=zT,l0=!1,zT=null,s}function Qn(s,l){var p=l[$T];p===void 0&&(p=l[$T]=new Set);var x=s+"__bubble";p.has(x)||(xL(l,s,2,!1),p.add(x))}function Bw(s,l,p){var x=0;l&&(x|=4),xL(p,s,x,l)}var Mv="_reactListening"+Math.random().toString(36).slice(2);function Sg(s){if(!s[Mv]){s[Mv]=!0,ID.forEach(function(p){p!=="selectionchange"&&(sV.has(p)||Bw(p,!1,s),Bw(p,!0,s))});var l=s.nodeType===9?s:s.ownerDocument;l===null||l[Mv]||(l[Mv]=!0,Bw("selectionchange",!1,l))}}function xL(s,l,p,x){switch(iL(l)){case 1:var T=x4;break;case 4:T=v4;break;default:T=WS}p=T.bind(null,l,p,s),T=void 0,!LT||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(T=!0),x?T!==void 0?s.addEventListener(l,p,{capture:!0,passive:T}):s.addEventListener(l,p,!0):T!==void 0?s.addEventListener(l,p,{passive:T}):s.addEventListener(l,p,!1)}function Nw(s,l,p,x,T){var C=x;if(!(l&1)&&!(l&2)&&x!==null)e:for(;;){if(x===null)return;var L=x.tag;if(L===3||L===4){var a=x.stateNode.containerInfo;if(a===T||a.nodeType===8&&a.parentNode===T)break;if(L===4)for(L=x.return;L!==null;){var F=L.tag;if((F===3||F===4)&&(F=L.stateNode.containerInfo,F===T||F.nodeType===8&&F.parentNode===T))return;L=L.return}for(;a!==null;){if(L=Vh(a),L===null)return;if(F=L.tag,F===5||F===6){x=C=L;continue e}a=a.parentNode}}x=x.return}jD(function(){var H=C,ee=$S(p),se=[];e:{var ue=gL.get(s);if(ue!==void 0){var Me=YS,Ve=s;switch(s){case"keypress":if(Wv(p)===0)break e;case"keydown":case"keyup":Me=k4;break;case"focusin":Ve="focus",Me=Dw;break;case"focusout":Ve="blur",Me=Dw;break;case"beforeblur":case"afterblur":Me=Dw;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Me=VP;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Me=T4;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Me=B4;break;case fL:case pL:case mL:Me=I4;break;case _L:Me=V4;break;case"scroll":Me=b4;break;case"wheel":Me=j4;break;case"copy":case"cut":case"paste":Me=C4;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Me=jP}var ke=(l&4)!==0,Ye=!ke&&s==="scroll",Se=ke?ue!==null?ue+"Capture":null:ue;ke=[];for(var ye=H,Ie;ye!==null;){Ie=ye;var qe=Ie.stateNode;if(Ie.tag===5&&qe!==null&&(Ie=qe,Se!==null&&(qe=yg(ye,Se),qe!=null&&ke.push(Eg(ye,qe,Ie)))),Ye)break;ye=ye.return}0<ke.length&&(ue=new Me(ue,Ve,null,p,ee),se.push({event:ue,listeners:ke}))}}if(!(l&7)){e:{if(ue=s==="mouseover"||s==="pointerover",Me=s==="mouseout"||s==="pointerout",ue&&p!==RT&&(Ve=p.relatedTarget||p.fromElement)&&(Vh(Ve)||Ve[ic]))break e;if((Me||ue)&&(ue=ee.window===ee?ee:(ue=ee.ownerDocument)?ue.defaultView||ue.parentWindow:window,Me?(Ve=p.relatedTarget||p.toElement,Me=H,Ve=Ve?Vh(Ve):null,Ve!==null&&(Ye=ed(Ve),Ve!==Ye||Ve.tag!==5&&Ve.tag!==6)&&(Ve=null)):(Me=null,Ve=H),Me!==Ve)){if(ke=VP,qe="onMouseLeave",Se="onMouseEnter",ye="mouse",(s==="pointerout"||s==="pointerover")&&(ke=jP,qe="onPointerLeave",Se="onPointerEnter",ye="pointer"),Ye=Me==null?ue:Gf(Me),Ie=Ve==null?ue:Gf(Ve),ue=new ke(qe,ye+"leave",Me,p,ee),ue.target=Ye,ue.relatedTarget=Ie,qe=null,Vh(ee)===H&&(ke=new ke(Se,ye+"enter",Ve,p,ee),ke.target=Ie,ke.relatedTarget=Ye,qe=ke),Ye=qe,Me&&Ve)t:{for(ke=Me,Se=Ve,ye=0,Ie=ke;Ie;Ie=Ff(Ie))ye++;for(Ie=0,qe=Se;qe;qe=Ff(qe))Ie++;for(;0<ye-Ie;)ke=Ff(ke),ye--;for(;0<Ie-ye;)Se=Ff(Se),Ie--;for(;ye--;){if(ke===Se||Se!==null&&ke===Se.alternate)break t;ke=Ff(ke),Se=Ff(Se)}ke=null}else ke=null;Me!==null&&QP(se,ue,Me,ke,!1),Ve!==null&&Ye!==null&&QP(se,Ye,Ve,ke,!0)}}e:{if(ue=H?Gf(H):window,Me=ue.nodeName&&ue.nodeName.toLowerCase(),Me==="select"||Me==="input"&&ue.type==="file")var ot=X4;else if(HP(ue))if(lL)ot=Q4;else{ot=K4;var xt=Y4}else(Me=ue.nodeName)&&Me.toLowerCase()==="input"&&(ue.type==="checkbox"||ue.type==="radio")&&(ot=J4);if(ot&&(ot=ot(s,H))){aL(se,ot,p,ee);break e}xt&&xt(s,ue,H),s==="focusout"&&(xt=ue._wrapperState)&&xt.controlled&&ue.type==="number"&&IT(ue,"number",ue.value)}switch(xt=H?Gf(H):window,s){case"focusin":(HP(xt)||xt.contentEditable==="true")&&(Uf=xt,BT=H,sg=null);break;case"focusout":sg=BT=Uf=null;break;case"mousedown":NT=!0;break;case"contextmenu":case"mouseup":case"dragend":NT=!1,YP(se,p,ee);break;case"selectionchange":if(iV)break;case"keydown":case"keyup":YP(se,p,ee)}var Rt;if(JS)e:{switch(s){case"compositionstart":var Tt="onCompositionStart";break e;case"compositionend":Tt="onCompositionEnd";break e;case"compositionupdate":Tt="onCompositionUpdate";break e}Tt=void 0}else Vf?sL(s,p)&&(Tt="onCompositionEnd"):s==="keydown"&&p.keyCode===229&&(Tt="onCompositionStart");Tt&&(rL&&p.locale!=="ko"&&(Vf||Tt!=="onCompositionStart"?Tt==="onCompositionEnd"&&Vf&&(Rt=nL()):(su=ee,XS="value"in su?su.value:su.textContent,Vf=!0)),xt=f0(H,Tt),0<xt.length&&(Tt=new UP(Tt,s,null,p,ee),se.push({event:Tt,listeners:xt}),Rt?Tt.data=Rt:(Rt=oL(p),Rt!==null&&(Tt.data=Rt)))),(Rt=$4?H4(s,p):Z4(s,p))&&(H=f0(H,"onBeforeInput"),0<H.length&&(ee=new UP("onBeforeInput","beforeinput",null,p,ee),se.push({event:ee,listeners:H}),ee.data=Rt))}yL(se,l)})}function Eg(s,l,p){return{instance:s,listener:l,currentTarget:p}}function f0(s,l){for(var p=l+"Capture",x=[];s!==null;){var T=s,C=T.stateNode;T.tag===5&&C!==null&&(T=C,C=yg(s,p),C!=null&&x.unshift(Eg(s,C,T)),C=yg(s,l),C!=null&&x.push(Eg(s,C,T))),s=s.return}return x}function Ff(s){if(s===null)return null;do s=s.return;while(s&&s.tag!==5);return s||null}function QP(s,l,p,x,T){for(var C=l._reactName,L=[];p!==null&&p!==x;){var a=p,F=a.alternate,H=a.stateNode;if(F!==null&&F===x)break;a.tag===5&&H!==null&&(a=H,T?(F=yg(p,C),F!=null&&L.unshift(Eg(p,F,a))):T||(F=yg(p,C),F!=null&&L.push(Eg(p,F,a)))),p=p.return}L.length!==0&&s.push({event:l,listeners:L})}var oV=/\r\n?/g,aV=/\u0000|\uFFFD/g;function eM(s){return(typeof s=="string"?s:""+s).replace(oV,`
`).replace(aV,"")}function Rv(s,l,p){if(l=eM(l),eM(s)!==l&&p)throw Error(Ot(425))}function p0(){}var VT=null,UT=null;function jT(s,l){return s==="textarea"||s==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var GT=typeof setTimeout=="function"?setTimeout:void 0,lV=typeof clearTimeout=="function"?clearTimeout:void 0,tM=typeof Promise=="function"?Promise:void 0,cV=typeof queueMicrotask=="function"?queueMicrotask:typeof tM<"u"?function(s){return tM.resolve(null).then(s).catch(uV)}:GT;function uV(s){setTimeout(function(){throw s})}function Vw(s,l){var p=l,x=0;do{var T=p.nextSibling;if(s.removeChild(p),T&&T.nodeType===8)if(p=T.data,p==="/$"){if(x===0){s.removeChild(T),bg(l);return}x--}else p!=="$"&&p!=="$?"&&p!=="$!"||x++;p=T}while(p);bg(l)}function hu(s){for(;s!=null;s=s.nextSibling){var l=s.nodeType;if(l===1||l===3)break;if(l===8){if(l=s.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return s}function iM(s){s=s.previousSibling;for(var l=0;s;){if(s.nodeType===8){var p=s.data;if(p==="$"||p==="$!"||p==="$?"){if(l===0)return s;l--}else p==="/$"&&l++}s=s.previousSibling}return null}var wp=Math.random().toString(36).slice(2),al="__reactFiber$"+wp,Ig="__reactProps$"+wp,ic="__reactContainer$"+wp,$T="__reactEvents$"+wp,hV="__reactListeners$"+wp,dV="__reactHandles$"+wp;function Vh(s){var l=s[al];if(l)return l;for(var p=s.parentNode;p;){if(l=p[ic]||p[al]){if(p=l.alternate,l.child!==null||p!==null&&p.child!==null)for(s=iM(s);s!==null;){if(p=s[al])return p;s=iM(s)}return l}s=p,p=s.parentNode}return null}function $g(s){return s=s[al]||s[ic],!s||s.tag!==5&&s.tag!==6&&s.tag!==13&&s.tag!==3?null:s}function Gf(s){if(s.tag===5||s.tag===6)return s.stateNode;throw Error(Ot(33))}function j0(s){return s[Ig]||null}var HT=[],$f=-1;function bu(s){return{current:s}}function er(s){0>$f||(s.current=HT[$f],HT[$f]=null,$f--)}function qn(s,l){$f++,HT[$f]=s.current,s.current=l}var gu={},Ss=bu(gu),so=bu(!1),Wh=gu;function cp(s,l){var p=s.type.contextTypes;if(!p)return gu;var x=s.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===l)return x.__reactInternalMemoizedMaskedChildContext;var T={},C;for(C in p)T[C]=l[C];return x&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=l,s.__reactInternalMemoizedMaskedChildContext=T),T}function oo(s){return s=s.childContextTypes,s!=null}function m0(){er(so),er(Ss)}function nM(s,l,p){if(Ss.current!==gu)throw Error(Ot(168));qn(Ss,l),qn(so,p)}function vL(s,l,p){var x=s.stateNode;if(l=l.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var T in x)if(!(T in l))throw Error(Ot(108,YN(s)||"Unknown",T));return mr({},p,x)}function _0(s){return s=(s=s.stateNode)&&s.__reactInternalMemoizedMergedChildContext||gu,Wh=Ss.current,qn(Ss,s),qn(so,so.current),!0}function rM(s,l,p){var x=s.stateNode;if(!x)throw Error(Ot(169));p?(s=vL(s,l,Wh),x.__reactInternalMemoizedMergedChildContext=s,er(so),er(Ss),qn(Ss,s)):er(so),qn(so,p)}var Xl=null,G0=!1,Uw=!1;function bL(s){Xl===null?Xl=[s]:Xl.push(s)}function fV(s){G0=!0,bL(s)}function wu(){if(!Uw&&Xl!==null){Uw=!0;var s=0,l=Fn;try{var p=Xl;for(Fn=1;s<p.length;s++){var x=p[s];do x=x(!0);while(x!==null)}Xl=null,G0=!1}catch(T){throw Xl!==null&&(Xl=Xl.slice(s+1)),ZD(HS,wu),T}finally{Fn=l,Uw=!1}}return null}var Hf=[],Zf=0,g0=null,y0=0,ea=[],ta=0,Xh=null,Yl=1,Kl="";function Fh(s,l){Hf[Zf++]=y0,Hf[Zf++]=g0,g0=s,y0=l}function wL(s,l,p){ea[ta++]=Yl,ea[ta++]=Kl,ea[ta++]=Xh,Xh=s;var x=Yl;s=Kl;var T=32-Ma(x)-1;x&=~(1<<T),p+=1;var C=32-Ma(l)+T;if(30<C){var L=T-T%5;C=(x&(1<<L)-1).toString(32),x>>=L,T-=L,Yl=1<<32-Ma(l)+T|p<<T|x,Kl=C+s}else Yl=1<<C|p<<T|x,Kl=s}function e2(s){s.return!==null&&(Fh(s,1),wL(s,1,0))}function t2(s){for(;s===g0;)g0=Hf[--Zf],Hf[Zf]=null,y0=Hf[--Zf],Hf[Zf]=null;for(;s===Xh;)Xh=ea[--ta],ea[ta]=null,Kl=ea[--ta],ea[ta]=null,Yl=ea[--ta],ea[ta]=null}var So=null,To=null,or=!1,Pa=null;function TL(s,l){var p=ia(5,null,null,0);p.elementType="DELETED",p.stateNode=l,p.return=s,l=s.deletions,l===null?(s.deletions=[p],s.flags|=16):l.push(p)}function sM(s,l){switch(s.tag){case 5:var p=s.type;return l=l.nodeType!==1||p.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(s.stateNode=l,So=s,To=hu(l.firstChild),!0):!1;case 6:return l=s.pendingProps===""||l.nodeType!==3?null:l,l!==null?(s.stateNode=l,So=s,To=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(p=Xh!==null?{id:Yl,overflow:Kl}:null,s.memoizedState={dehydrated:l,treeContext:p,retryLane:1073741824},p=ia(18,null,null,0),p.stateNode=l,p.return=s,s.child=p,So=s,To=null,!0):!1;default:return!1}}function ZT(s){return(s.mode&1)!==0&&(s.flags&128)===0}function qT(s){if(or){var l=To;if(l){var p=l;if(!sM(s,l)){if(ZT(s))throw Error(Ot(418));l=hu(p.nextSibling);var x=So;l&&sM(s,l)?TL(x,p):(s.flags=s.flags&-4097|2,or=!1,So=s)}}else{if(ZT(s))throw Error(Ot(418));s.flags=s.flags&-4097|2,or=!1,So=s}}}function oM(s){for(s=s.return;s!==null&&s.tag!==5&&s.tag!==3&&s.tag!==13;)s=s.return;So=s}function Dv(s){if(s!==So)return!1;if(!or)return oM(s),or=!0,!1;var l;if((l=s.tag!==3)&&!(l=s.tag!==5)&&(l=s.type,l=l!=="head"&&l!=="body"&&!jT(s.type,s.memoizedProps)),l&&(l=To)){if(ZT(s))throw SL(),Error(Ot(418));for(;l;)TL(s,l),l=hu(l.nextSibling)}if(oM(s),s.tag===13){if(s=s.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(Ot(317));e:{for(s=s.nextSibling,l=0;s;){if(s.nodeType===8){var p=s.data;if(p==="/$"){if(l===0){To=hu(s.nextSibling);break e}l--}else p!=="$"&&p!=="$!"&&p!=="$?"||l++}s=s.nextSibling}To=null}}else To=So?hu(s.stateNode.nextSibling):null;return!0}function SL(){for(var s=To;s;)s=hu(s.nextSibling)}function up(){To=So=null,or=!1}function i2(s){Pa===null?Pa=[s]:Pa.push(s)}var pV=lc.ReactCurrentBatchConfig;function $_(s,l,p){if(s=p.ref,s!==null&&typeof s!="function"&&typeof s!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(Ot(309));var x=p.stateNode}if(!x)throw Error(Ot(147,s));var T=x,C=""+s;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===C?l.ref:(l=function(L){var a=T.refs;L===null?delete a[C]:a[C]=L},l._stringRef=C,l)}if(typeof s!="string")throw Error(Ot(284));if(!p._owner)throw Error(Ot(290,s))}return s}function Lv(s,l){throw s=Object.prototype.toString.call(l),Error(Ot(31,s==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":s))}function aM(s){var l=s._init;return l(s._payload)}function EL(s){function l(Se,ye){if(s){var Ie=Se.deletions;Ie===null?(Se.deletions=[ye],Se.flags|=16):Ie.push(ye)}}function p(Se,ye){if(!s)return null;for(;ye!==null;)l(Se,ye),ye=ye.sibling;return null}function x(Se,ye){for(Se=new Map;ye!==null;)ye.key!==null?Se.set(ye.key,ye):Se.set(ye.index,ye),ye=ye.sibling;return Se}function T(Se,ye){return Se=mu(Se,ye),Se.index=0,Se.sibling=null,Se}function C(Se,ye,Ie){return Se.index=Ie,s?(Ie=Se.alternate,Ie!==null?(Ie=Ie.index,Ie<ye?(Se.flags|=2,ye):Ie):(Se.flags|=2,ye)):(Se.flags|=1048576,ye)}function L(Se){return s&&Se.alternate===null&&(Se.flags|=2),Se}function a(Se,ye,Ie,qe){return ye===null||ye.tag!==6?(ye=Ww(Ie,Se.mode,qe),ye.return=Se,ye):(ye=T(ye,Ie),ye.return=Se,ye)}function F(Se,ye,Ie,qe){var ot=Ie.type;return ot===Nf?ee(Se,ye,Ie.props.children,qe,Ie.key):ye!==null&&(ye.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===tu&&aM(ot)===ye.type)?(qe=T(ye,Ie.props),qe.ref=$_(Se,ye,Ie),qe.return=Se,qe):(qe=t0(Ie.type,Ie.key,Ie.props,null,Se.mode,qe),qe.ref=$_(Se,ye,Ie),qe.return=Se,qe)}function H(Se,ye,Ie,qe){return ye===null||ye.tag!==4||ye.stateNode.containerInfo!==Ie.containerInfo||ye.stateNode.implementation!==Ie.implementation?(ye=Xw(Ie,Se.mode,qe),ye.return=Se,ye):(ye=T(ye,Ie.children||[]),ye.return=Se,ye)}function ee(Se,ye,Ie,qe,ot){return ye===null||ye.tag!==7?(ye=Hh(Ie,Se.mode,qe,ot),ye.return=Se,ye):(ye=T(ye,Ie),ye.return=Se,ye)}function se(Se,ye,Ie){if(typeof ye=="string"&&ye!==""||typeof ye=="number")return ye=Ww(""+ye,Se.mode,Ie),ye.return=Se,ye;if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case wv:return Ie=t0(ye.type,ye.key,ye.props,null,Se.mode,Ie),Ie.ref=$_(Se,null,ye),Ie.return=Se,Ie;case Bf:return ye=Xw(ye,Se.mode,Ie),ye.return=Se,ye;case tu:var qe=ye._init;return se(Se,qe(ye._payload),Ie)}if(X_(ye)||N_(ye))return ye=Hh(ye,Se.mode,Ie,null),ye.return=Se,ye;Lv(Se,ye)}return null}function ue(Se,ye,Ie,qe){var ot=ye!==null?ye.key:null;if(typeof Ie=="string"&&Ie!==""||typeof Ie=="number")return ot!==null?null:a(Se,ye,""+Ie,qe);if(typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case wv:return Ie.key===ot?F(Se,ye,Ie,qe):null;case Bf:return Ie.key===ot?H(Se,ye,Ie,qe):null;case tu:return ot=Ie._init,ue(Se,ye,ot(Ie._payload),qe)}if(X_(Ie)||N_(Ie))return ot!==null?null:ee(Se,ye,Ie,qe,null);Lv(Se,Ie)}return null}function Me(Se,ye,Ie,qe,ot){if(typeof qe=="string"&&qe!==""||typeof qe=="number")return Se=Se.get(Ie)||null,a(ye,Se,""+qe,ot);if(typeof qe=="object"&&qe!==null){switch(qe.$$typeof){case wv:return Se=Se.get(qe.key===null?Ie:qe.key)||null,F(ye,Se,qe,ot);case Bf:return Se=Se.get(qe.key===null?Ie:qe.key)||null,H(ye,Se,qe,ot);case tu:var xt=qe._init;return Me(Se,ye,Ie,xt(qe._payload),ot)}if(X_(qe)||N_(qe))return Se=Se.get(Ie)||null,ee(ye,Se,qe,ot,null);Lv(ye,qe)}return null}function Ve(Se,ye,Ie,qe){for(var ot=null,xt=null,Rt=ye,Tt=ye=0,li=null;Rt!==null&&Tt<Ie.length;Tt++){Rt.index>Tt?(li=Rt,Rt=null):li=Rt.sibling;var Xt=ue(Se,Rt,Ie[Tt],qe);if(Xt===null){Rt===null&&(Rt=li);break}s&&Rt&&Xt.alternate===null&&l(Se,Rt),ye=C(Xt,ye,Tt),xt===null?ot=Xt:xt.sibling=Xt,xt=Xt,Rt=li}if(Tt===Ie.length)return p(Se,Rt),or&&Fh(Se,Tt),ot;if(Rt===null){for(;Tt<Ie.length;Tt++)Rt=se(Se,Ie[Tt],qe),Rt!==null&&(ye=C(Rt,ye,Tt),xt===null?ot=Rt:xt.sibling=Rt,xt=Rt);return or&&Fh(Se,Tt),ot}for(Rt=x(Se,Rt);Tt<Ie.length;Tt++)li=Me(Rt,Se,Tt,Ie[Tt],qe),li!==null&&(s&&li.alternate!==null&&Rt.delete(li.key===null?Tt:li.key),ye=C(li,ye,Tt),xt===null?ot=li:xt.sibling=li,xt=li);return s&&Rt.forEach(function(Ji){return l(Se,Ji)}),or&&Fh(Se,Tt),ot}function ke(Se,ye,Ie,qe){var ot=N_(Ie);if(typeof ot!="function")throw Error(Ot(150));if(Ie=ot.call(Ie),Ie==null)throw Error(Ot(151));for(var xt=ot=null,Rt=ye,Tt=ye=0,li=null,Xt=Ie.next();Rt!==null&&!Xt.done;Tt++,Xt=Ie.next()){Rt.index>Tt?(li=Rt,Rt=null):li=Rt.sibling;var Ji=ue(Se,Rt,Xt.value,qe);if(Ji===null){Rt===null&&(Rt=li);break}s&&Rt&&Ji.alternate===null&&l(Se,Rt),ye=C(Ji,ye,Tt),xt===null?ot=Ji:xt.sibling=Ji,xt=Ji,Rt=li}if(Xt.done)return p(Se,Rt),or&&Fh(Se,Tt),ot;if(Rt===null){for(;!Xt.done;Tt++,Xt=Ie.next())Xt=se(Se,Xt.value,qe),Xt!==null&&(ye=C(Xt,ye,Tt),xt===null?ot=Xt:xt.sibling=Xt,xt=Xt);return or&&Fh(Se,Tt),ot}for(Rt=x(Se,Rt);!Xt.done;Tt++,Xt=Ie.next())Xt=Me(Rt,Se,Tt,Xt.value,qe),Xt!==null&&(s&&Xt.alternate!==null&&Rt.delete(Xt.key===null?Tt:Xt.key),ye=C(Xt,ye,Tt),xt===null?ot=Xt:xt.sibling=Xt,xt=Xt);return s&&Rt.forEach(function(An){return l(Se,An)}),or&&Fh(Se,Tt),ot}function Ye(Se,ye,Ie,qe){if(typeof Ie=="object"&&Ie!==null&&Ie.type===Nf&&Ie.key===null&&(Ie=Ie.props.children),typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case wv:e:{for(var ot=Ie.key,xt=ye;xt!==null;){if(xt.key===ot){if(ot=Ie.type,ot===Nf){if(xt.tag===7){p(Se,xt.sibling),ye=T(xt,Ie.props.children),ye.return=Se,Se=ye;break e}}else if(xt.elementType===ot||typeof ot=="object"&&ot!==null&&ot.$$typeof===tu&&aM(ot)===xt.type){p(Se,xt.sibling),ye=T(xt,Ie.props),ye.ref=$_(Se,xt,Ie),ye.return=Se,Se=ye;break e}p(Se,xt);break}else l(Se,xt);xt=xt.sibling}Ie.type===Nf?(ye=Hh(Ie.props.children,Se.mode,qe,Ie.key),ye.return=Se,Se=ye):(qe=t0(Ie.type,Ie.key,Ie.props,null,Se.mode,qe),qe.ref=$_(Se,ye,Ie),qe.return=Se,Se=qe)}return L(Se);case Bf:e:{for(xt=Ie.key;ye!==null;){if(ye.key===xt)if(ye.tag===4&&ye.stateNode.containerInfo===Ie.containerInfo&&ye.stateNode.implementation===Ie.implementation){p(Se,ye.sibling),ye=T(ye,Ie.children||[]),ye.return=Se,Se=ye;break e}else{p(Se,ye);break}else l(Se,ye);ye=ye.sibling}ye=Xw(Ie,Se.mode,qe),ye.return=Se,Se=ye}return L(Se);case tu:return xt=Ie._init,Ye(Se,ye,xt(Ie._payload),qe)}if(X_(Ie))return Ve(Se,ye,Ie,qe);if(N_(Ie))return ke(Se,ye,Ie,qe);Lv(Se,Ie)}return typeof Ie=="string"&&Ie!==""||typeof Ie=="number"?(Ie=""+Ie,ye!==null&&ye.tag===6?(p(Se,ye.sibling),ye=T(ye,Ie),ye.return=Se,Se=ye):(p(Se,ye),ye=Ww(Ie,Se.mode,qe),ye.return=Se,Se=ye),L(Se)):p(Se,ye)}return Ye}var hp=EL(!0),IL=EL(!1),x0=bu(null),v0=null,qf=null,n2=null;function r2(){n2=qf=v0=null}function s2(s){var l=x0.current;er(x0),s._currentValue=l}function WT(s,l,p){for(;s!==null;){var x=s.alternate;if((s.childLanes&l)!==l?(s.childLanes|=l,x!==null&&(x.childLanes|=l)):x!==null&&(x.childLanes&l)!==l&&(x.childLanes|=l),s===p)break;s=s.return}}function sp(s,l){v0=s,n2=qf=null,s=s.dependencies,s!==null&&s.firstContext!==null&&(s.lanes&l&&(ro=!0),s.firstContext=null)}function ra(s){var l=s._currentValue;if(n2!==s)if(s={context:s,memoizedValue:l,next:null},qf===null){if(v0===null)throw Error(Ot(308));qf=s,v0.dependencies={lanes:0,firstContext:s}}else qf=qf.next=s;return l}var Uh=null;function o2(s){Uh===null?Uh=[s]:Uh.push(s)}function AL(s,l,p,x){var T=l.interleaved;return T===null?(p.next=p,o2(l)):(p.next=T.next,T.next=p),l.interleaved=p,nc(s,x)}function nc(s,l){s.lanes|=l;var p=s.alternate;for(p!==null&&(p.lanes|=l),p=s,s=s.return;s!==null;)s.childLanes|=l,p=s.alternate,p!==null&&(p.childLanes|=l),p=s,s=s.return;return p.tag===3?p.stateNode:null}var iu=!1;function a2(s){s.updateQueue={baseState:s.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function CL(s,l){s=s.updateQueue,l.updateQueue===s&&(l.updateQueue={baseState:s.baseState,firstBaseUpdate:s.firstBaseUpdate,lastBaseUpdate:s.lastBaseUpdate,shared:s.shared,effects:s.effects})}function Jl(s,l){return{eventTime:s,lane:l,tag:0,payload:null,callback:null,next:null}}function du(s,l,p){var x=s.updateQueue;if(x===null)return null;if(x=x.shared,xn&2){var T=x.pending;return T===null?l.next=l:(l.next=T.next,T.next=l),x.pending=l,nc(s,p)}return T=x.interleaved,T===null?(l.next=l,o2(x)):(l.next=T.next,T.next=l),x.interleaved=l,nc(s,p)}function Xv(s,l,p){if(l=l.updateQueue,l!==null&&(l=l.shared,(p&4194240)!==0)){var x=l.lanes;x&=s.pendingLanes,p|=x,l.lanes=p,ZS(s,p)}}function lM(s,l){var p=s.updateQueue,x=s.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var T=null,C=null;if(p=p.firstBaseUpdate,p!==null){do{var L={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};C===null?T=C=L:C=C.next=L,p=p.next}while(p!==null);C===null?T=C=l:C=C.next=l}else T=C=l;p={baseState:x.baseState,firstBaseUpdate:T,lastBaseUpdate:C,shared:x.shared,effects:x.effects},s.updateQueue=p;return}s=p.lastBaseUpdate,s===null?p.firstBaseUpdate=l:s.next=l,p.lastBaseUpdate=l}function b0(s,l,p,x){var T=s.updateQueue;iu=!1;var C=T.firstBaseUpdate,L=T.lastBaseUpdate,a=T.shared.pending;if(a!==null){T.shared.pending=null;var F=a,H=F.next;F.next=null,L===null?C=H:L.next=H,L=F;var ee=s.alternate;ee!==null&&(ee=ee.updateQueue,a=ee.lastBaseUpdate,a!==L&&(a===null?ee.firstBaseUpdate=H:a.next=H,ee.lastBaseUpdate=F))}if(C!==null){var se=T.baseState;L=0,ee=H=F=null,a=C;do{var ue=a.lane,Me=a.eventTime;if((x&ue)===ue){ee!==null&&(ee=ee.next={eventTime:Me,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var Ve=s,ke=a;switch(ue=l,Me=p,ke.tag){case 1:if(Ve=ke.payload,typeof Ve=="function"){se=Ve.call(Me,se,ue);break e}se=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=ke.payload,ue=typeof Ve=="function"?Ve.call(Me,se,ue):Ve,ue==null)break e;se=mr({},se,ue);break e;case 2:iu=!0}}a.callback!==null&&a.lane!==0&&(s.flags|=64,ue=T.effects,ue===null?T.effects=[a]:ue.push(a))}else Me={eventTime:Me,lane:ue,tag:a.tag,payload:a.payload,callback:a.callback,next:null},ee===null?(H=ee=Me,F=se):ee=ee.next=Me,L|=ue;if(a=a.next,a===null){if(a=T.shared.pending,a===null)break;ue=a,a=ue.next,ue.next=null,T.lastBaseUpdate=ue,T.shared.pending=null}}while(!0);if(ee===null&&(F=se),T.baseState=F,T.firstBaseUpdate=H,T.lastBaseUpdate=ee,l=T.shared.interleaved,l!==null){T=l;do L|=T.lane,T=T.next;while(T!==l)}else C===null&&(T.shared.lanes=0);Kh|=L,s.lanes=L,s.memoizedState=se}}function cM(s,l,p){if(s=l.effects,l.effects=null,s!==null)for(l=0;l<s.length;l++){var x=s[l],T=x.callback;if(T!==null){if(x.callback=null,x=p,typeof T!="function")throw Error(Ot(191,T));T.call(x)}}}var Hg={},cl=bu(Hg),Ag=bu(Hg),Cg=bu(Hg);function jh(s){if(s===Hg)throw Error(Ot(174));return s}function l2(s,l){switch(qn(Cg,l),qn(Ag,s),qn(cl,Hg),s=l.nodeType,s){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:CT(null,"");break;default:s=s===8?l.parentNode:l,l=s.namespaceURI||null,s=s.tagName,l=CT(l,s)}er(cl),qn(cl,l)}function dp(){er(cl),er(Ag),er(Cg)}function PL(s){jh(Cg.current);var l=jh(cl.current),p=CT(l,s.type);l!==p&&(qn(Ag,s),qn(cl,p))}function c2(s){Ag.current===s&&(er(cl),er(Ag))}var dr=bu(0);function w0(s){for(var l=s;l!==null;){if(l.tag===13){var p=l.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if(l.flags&128)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===s)break;for(;l.sibling===null;){if(l.return===null||l.return===s)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var jw=[];function u2(){for(var s=0;s<jw.length;s++)jw[s]._workInProgressVersionPrimary=null;jw.length=0}var Yv=lc.ReactCurrentDispatcher,Gw=lc.ReactCurrentBatchConfig,Yh=0,pr=null,$r=null,Qr=null,T0=!1,og=!1,Pg=0,mV=0;function xs(){throw Error(Ot(321))}function h2(s,l){if(l===null)return!1;for(var p=0;p<l.length&&p<s.length;p++)if(!Da(s[p],l[p]))return!1;return!0}function d2(s,l,p,x,T,C){if(Yh=C,pr=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,Yv.current=s===null||s.memoizedState===null?xV:vV,s=p(x,T),og){C=0;do{if(og=!1,Pg=0,25<=C)throw Error(Ot(301));C+=1,Qr=$r=null,l.updateQueue=null,Yv.current=bV,s=p(x,T)}while(og)}if(Yv.current=S0,l=$r!==null&&$r.next!==null,Yh=0,Qr=$r=pr=null,T0=!1,l)throw Error(Ot(300));return s}function f2(){var s=Pg!==0;return Pg=0,s}function ol(){var s={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Qr===null?pr.memoizedState=Qr=s:Qr=Qr.next=s,Qr}function sa(){if($r===null){var s=pr.alternate;s=s!==null?s.memoizedState:null}else s=$r.next;var l=Qr===null?pr.memoizedState:Qr.next;if(l!==null)Qr=l,$r=s;else{if(s===null)throw Error(Ot(310));$r=s,s={memoizedState:$r.memoizedState,baseState:$r.baseState,baseQueue:$r.baseQueue,queue:$r.queue,next:null},Qr===null?pr.memoizedState=Qr=s:Qr=Qr.next=s}return Qr}function Mg(s,l){return typeof l=="function"?l(s):l}function $w(s){var l=sa(),p=l.queue;if(p===null)throw Error(Ot(311));p.lastRenderedReducer=s;var x=$r,T=x.baseQueue,C=p.pending;if(C!==null){if(T!==null){var L=T.next;T.next=C.next,C.next=L}x.baseQueue=T=C,p.pending=null}if(T!==null){C=T.next,x=x.baseState;var a=L=null,F=null,H=C;do{var ee=H.lane;if((Yh&ee)===ee)F!==null&&(F=F.next={lane:0,action:H.action,hasEagerState:H.hasEagerState,eagerState:H.eagerState,next:null}),x=H.hasEagerState?H.eagerState:s(x,H.action);else{var se={lane:ee,action:H.action,hasEagerState:H.hasEagerState,eagerState:H.eagerState,next:null};F===null?(a=F=se,L=x):F=F.next=se,pr.lanes|=ee,Kh|=ee}H=H.next}while(H!==null&&H!==C);F===null?L=x:F.next=a,Da(x,l.memoizedState)||(ro=!0),l.memoizedState=x,l.baseState=L,l.baseQueue=F,p.lastRenderedState=x}if(s=p.interleaved,s!==null){T=s;do C=T.lane,pr.lanes|=C,Kh|=C,T=T.next;while(T!==s)}else T===null&&(p.lanes=0);return[l.memoizedState,p.dispatch]}function Hw(s){var l=sa(),p=l.queue;if(p===null)throw Error(Ot(311));p.lastRenderedReducer=s;var x=p.dispatch,T=p.pending,C=l.memoizedState;if(T!==null){p.pending=null;var L=T=T.next;do C=s(C,L.action),L=L.next;while(L!==T);Da(C,l.memoizedState)||(ro=!0),l.memoizedState=C,l.baseQueue===null&&(l.baseState=C),p.lastRenderedState=C}return[C,x]}function ML(){}function RL(s,l){var p=pr,x=sa(),T=l(),C=!Da(x.memoizedState,T);if(C&&(x.memoizedState=T,ro=!0),x=x.queue,p2(zL.bind(null,p,x,s),[s]),x.getSnapshot!==l||C||Qr!==null&&Qr.memoizedState.tag&1){if(p.flags|=2048,Rg(9,LL.bind(null,p,x,T,l),void 0,null),es===null)throw Error(Ot(349));Yh&30||DL(p,l,T)}return T}function DL(s,l,p){s.flags|=16384,s={getSnapshot:l,value:p},l=pr.updateQueue,l===null?(l={lastEffect:null,stores:null},pr.updateQueue=l,l.stores=[s]):(p=l.stores,p===null?l.stores=[s]:p.push(s))}function LL(s,l,p,x){l.value=p,l.getSnapshot=x,kL(l)&&FL(s)}function zL(s,l,p){return p(function(){kL(l)&&FL(s)})}function kL(s){var l=s.getSnapshot;s=s.value;try{var p=l();return!Da(s,p)}catch{return!0}}function FL(s){var l=nc(s,1);l!==null&&Ra(l,s,1,-1)}function uM(s){var l=ol();return typeof s=="function"&&(s=s()),l.memoizedState=l.baseState=s,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Mg,lastRenderedState:s},l.queue=s,s=s.dispatch=yV.bind(null,pr,s),[l.memoizedState,s]}function Rg(s,l,p,x){return s={tag:s,create:l,destroy:p,deps:x,next:null},l=pr.updateQueue,l===null?(l={lastEffect:null,stores:null},pr.updateQueue=l,l.lastEffect=s.next=s):(p=l.lastEffect,p===null?l.lastEffect=s.next=s:(x=p.next,p.next=s,s.next=x,l.lastEffect=s)),s}function OL(){return sa().memoizedState}function Kv(s,l,p,x){var T=ol();pr.flags|=s,T.memoizedState=Rg(1|l,p,void 0,x===void 0?null:x)}function $0(s,l,p,x){var T=sa();x=x===void 0?null:x;var C=void 0;if($r!==null){var L=$r.memoizedState;if(C=L.destroy,x!==null&&h2(x,L.deps)){T.memoizedState=Rg(l,p,C,x);return}}pr.flags|=s,T.memoizedState=Rg(1|l,p,C,x)}function hM(s,l){return Kv(8390656,8,s,l)}function p2(s,l){return $0(2048,8,s,l)}function BL(s,l){return $0(4,2,s,l)}function NL(s,l){return $0(4,4,s,l)}function VL(s,l){if(typeof l=="function")return s=s(),l(s),function(){l(null)};if(l!=null)return s=s(),l.current=s,function(){l.current=null}}function UL(s,l,p){return p=p!=null?p.concat([s]):null,$0(4,4,VL.bind(null,l,s),p)}function m2(){}function jL(s,l){var p=sa();l=l===void 0?null:l;var x=p.memoizedState;return x!==null&&l!==null&&h2(l,x[1])?x[0]:(p.memoizedState=[s,l],s)}function GL(s,l){var p=sa();l=l===void 0?null:l;var x=p.memoizedState;return x!==null&&l!==null&&h2(l,x[1])?x[0]:(s=s(),p.memoizedState=[s,l],s)}function $L(s,l,p){return Yh&21?(Da(p,l)||(p=XD(),pr.lanes|=p,Kh|=p,s.baseState=!0),l):(s.baseState&&(s.baseState=!1,ro=!0),s.memoizedState=p)}function _V(s,l){var p=Fn;Fn=p!==0&&4>p?p:4,s(!0);var x=Gw.transition;Gw.transition={};try{s(!1),l()}finally{Fn=p,Gw.transition=x}}function HL(){return sa().memoizedState}function gV(s,l,p){var x=pu(s);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},ZL(s))qL(l,p);else if(p=AL(s,l,p,x),p!==null){var T=js();Ra(p,s,x,T),WL(p,l,x)}}function yV(s,l,p){var x=pu(s),T={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(ZL(s))qL(l,T);else{var C=s.alternate;if(s.lanes===0&&(C===null||C.lanes===0)&&(C=l.lastRenderedReducer,C!==null))try{var L=l.lastRenderedState,a=C(L,p);if(T.hasEagerState=!0,T.eagerState=a,Da(a,L)){var F=l.interleaved;F===null?(T.next=T,o2(l)):(T.next=F.next,F.next=T),l.interleaved=T;return}}catch{}finally{}p=AL(s,l,T,x),p!==null&&(T=js(),Ra(p,s,x,T),WL(p,l,x))}}function ZL(s){var l=s.alternate;return s===pr||l!==null&&l===pr}function qL(s,l){og=T0=!0;var p=s.pending;p===null?l.next=l:(l.next=p.next,p.next=l),s.pending=l}function WL(s,l,p){if(p&4194240){var x=l.lanes;x&=s.pendingLanes,p|=x,l.lanes=p,ZS(s,p)}}var S0={readContext:ra,useCallback:xs,useContext:xs,useEffect:xs,useImperativeHandle:xs,useInsertionEffect:xs,useLayoutEffect:xs,useMemo:xs,useReducer:xs,useRef:xs,useState:xs,useDebugValue:xs,useDeferredValue:xs,useTransition:xs,useMutableSource:xs,useSyncExternalStore:xs,useId:xs,unstable_isNewReconciler:!1},xV={readContext:ra,useCallback:function(s,l){return ol().memoizedState=[s,l===void 0?null:l],s},useContext:ra,useEffect:hM,useImperativeHandle:function(s,l,p){return p=p!=null?p.concat([s]):null,Kv(4194308,4,VL.bind(null,l,s),p)},useLayoutEffect:function(s,l){return Kv(4194308,4,s,l)},useInsertionEffect:function(s,l){return Kv(4,2,s,l)},useMemo:function(s,l){var p=ol();return l=l===void 0?null:l,s=s(),p.memoizedState=[s,l],s},useReducer:function(s,l,p){var x=ol();return l=p!==void 0?p(l):l,x.memoizedState=x.baseState=l,s={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:s,lastRenderedState:l},x.queue=s,s=s.dispatch=gV.bind(null,pr,s),[x.memoizedState,s]},useRef:function(s){var l=ol();return s={current:s},l.memoizedState=s},useState:uM,useDebugValue:m2,useDeferredValue:function(s){return ol().memoizedState=s},useTransition:function(){var s=uM(!1),l=s[0];return s=_V.bind(null,s[1]),ol().memoizedState=s,[l,s]},useMutableSource:function(){},useSyncExternalStore:function(s,l,p){var x=pr,T=ol();if(or){if(p===void 0)throw Error(Ot(407));p=p()}else{if(p=l(),es===null)throw Error(Ot(349));Yh&30||DL(x,l,p)}T.memoizedState=p;var C={value:p,getSnapshot:l};return T.queue=C,hM(zL.bind(null,x,C,s),[s]),x.flags|=2048,Rg(9,LL.bind(null,x,C,p,l),void 0,null),p},useId:function(){var s=ol(),l=es.identifierPrefix;if(or){var p=Kl,x=Yl;p=(x&~(1<<32-Ma(x)-1)).toString(32)+p,l=":"+l+"R"+p,p=Pg++,0<p&&(l+="H"+p.toString(32)),l+=":"}else p=mV++,l=":"+l+"r"+p.toString(32)+":";return s.memoizedState=l},unstable_isNewReconciler:!1},vV={readContext:ra,useCallback:jL,useContext:ra,useEffect:p2,useImperativeHandle:UL,useInsertionEffect:BL,useLayoutEffect:NL,useMemo:GL,useReducer:$w,useRef:OL,useState:function(){return $w(Mg)},useDebugValue:m2,useDeferredValue:function(s){var l=sa();return $L(l,$r.memoizedState,s)},useTransition:function(){var s=$w(Mg)[0],l=sa().memoizedState;return[s,l]},useMutableSource:ML,useSyncExternalStore:RL,useId:HL,unstable_isNewReconciler:!1},bV={readContext:ra,useCallback:jL,useContext:ra,useEffect:p2,useImperativeHandle:UL,useInsertionEffect:BL,useLayoutEffect:NL,useMemo:GL,useReducer:Hw,useRef:OL,useState:function(){return Hw(Mg)},useDebugValue:m2,useDeferredValue:function(s){var l=sa();return $r===null?l.memoizedState=s:$L(l,$r.memoizedState,s)},useTransition:function(){var s=Hw(Mg)[0],l=sa().memoizedState;return[s,l]},useMutableSource:ML,useSyncExternalStore:RL,useId:HL,unstable_isNewReconciler:!1};function Aa(s,l){if(s&&s.defaultProps){l=mr({},l),s=s.defaultProps;for(var p in s)l[p]===void 0&&(l[p]=s[p]);return l}return l}function XT(s,l,p,x){l=s.memoizedState,p=p(x,l),p=p==null?l:mr({},l,p),s.memoizedState=p,s.lanes===0&&(s.updateQueue.baseState=p)}var H0={isMounted:function(s){return(s=s._reactInternals)?ed(s)===s:!1},enqueueSetState:function(s,l,p){s=s._reactInternals;var x=js(),T=pu(s),C=Jl(x,T);C.payload=l,p!=null&&(C.callback=p),l=du(s,C,T),l!==null&&(Ra(l,s,T,x),Xv(l,s,T))},enqueueReplaceState:function(s,l,p){s=s._reactInternals;var x=js(),T=pu(s),C=Jl(x,T);C.tag=1,C.payload=l,p!=null&&(C.callback=p),l=du(s,C,T),l!==null&&(Ra(l,s,T,x),Xv(l,s,T))},enqueueForceUpdate:function(s,l){s=s._reactInternals;var p=js(),x=pu(s),T=Jl(p,x);T.tag=2,l!=null&&(T.callback=l),l=du(s,T,x),l!==null&&(Ra(l,s,x,p),Xv(l,s,x))}};function dM(s,l,p,x,T,C,L){return s=s.stateNode,typeof s.shouldComponentUpdate=="function"?s.shouldComponentUpdate(x,C,L):l.prototype&&l.prototype.isPureReactComponent?!Tg(p,x)||!Tg(T,C):!0}function XL(s,l,p){var x=!1,T=gu,C=l.contextType;return typeof C=="object"&&C!==null?C=ra(C):(T=oo(l)?Wh:Ss.current,x=l.contextTypes,C=(x=x!=null)?cp(s,T):gu),l=new l(p,C),s.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=H0,s.stateNode=l,l._reactInternals=s,x&&(s=s.stateNode,s.__reactInternalMemoizedUnmaskedChildContext=T,s.__reactInternalMemoizedMaskedChildContext=C),l}function fM(s,l,p,x){s=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,x),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,x),l.state!==s&&H0.enqueueReplaceState(l,l.state,null)}function YT(s,l,p,x){var T=s.stateNode;T.props=p,T.state=s.memoizedState,T.refs={},a2(s);var C=l.contextType;typeof C=="object"&&C!==null?T.context=ra(C):(C=oo(l)?Wh:Ss.current,T.context=cp(s,C)),T.state=s.memoizedState,C=l.getDerivedStateFromProps,typeof C=="function"&&(XT(s,l,C,p),T.state=s.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof T.getSnapshotBeforeUpdate=="function"||typeof T.UNSAFE_componentWillMount!="function"&&typeof T.componentWillMount!="function"||(l=T.state,typeof T.componentWillMount=="function"&&T.componentWillMount(),typeof T.UNSAFE_componentWillMount=="function"&&T.UNSAFE_componentWillMount(),l!==T.state&&H0.enqueueReplaceState(T,T.state,null),b0(s,p,T,x),T.state=s.memoizedState),typeof T.componentDidMount=="function"&&(s.flags|=4194308)}function fp(s,l){try{var p="",x=l;do p+=XN(x),x=x.return;while(x);var T=p}catch(C){T=`
Error generating stack: `+C.message+`
`+C.stack}return{value:s,source:l,stack:T,digest:null}}function Zw(s,l,p){return{value:s,source:null,stack:p??null,digest:l??null}}function KT(s,l){try{console.error(l.value)}catch(p){setTimeout(function(){throw p})}}var wV=typeof WeakMap=="function"?WeakMap:Map;function YL(s,l,p){p=Jl(-1,p),p.tag=3,p.payload={element:null};var x=l.value;return p.callback=function(){I0||(I0=!0,aS=x),KT(s,l)},p}function KL(s,l,p){p=Jl(-1,p),p.tag=3;var x=s.type.getDerivedStateFromError;if(typeof x=="function"){var T=l.value;p.payload=function(){return x(T)},p.callback=function(){KT(s,l)}}var C=s.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(p.callback=function(){KT(s,l),typeof x!="function"&&(fu===null?fu=new Set([this]):fu.add(this));var L=l.stack;this.componentDidCatch(l.value,{componentStack:L!==null?L:""})}),p}function pM(s,l,p){var x=s.pingCache;if(x===null){x=s.pingCache=new wV;var T=new Set;x.set(l,T)}else T=x.get(l),T===void 0&&(T=new Set,x.set(l,T));T.has(p)||(T.add(p),s=FV.bind(null,s,l,p),l.then(s,s))}function mM(s){do{var l;if((l=s.tag===13)&&(l=s.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return s;s=s.return}while(s!==null);return null}function _M(s,l,p,x,T){return s.mode&1?(s.flags|=65536,s.lanes=T,s):(s===l?s.flags|=65536:(s.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(l=Jl(-1,1),l.tag=2,du(p,l,1))),p.lanes|=1),s)}var TV=lc.ReactCurrentOwner,ro=!1;function Us(s,l,p,x){l.child=s===null?IL(l,null,p,x):hp(l,s.child,p,x)}function gM(s,l,p,x,T){p=p.render;var C=l.ref;return sp(l,T),x=d2(s,l,p,x,C,T),p=f2(),s!==null&&!ro?(l.updateQueue=s.updateQueue,l.flags&=-2053,s.lanes&=~T,rc(s,l,T)):(or&&p&&e2(l),l.flags|=1,Us(s,l,x,T),l.child)}function yM(s,l,p,x,T){if(s===null){var C=p.type;return typeof C=="function"&&!T2(C)&&C.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(l.tag=15,l.type=C,JL(s,l,C,x,T)):(s=t0(p.type,null,x,l,l.mode,T),s.ref=l.ref,s.return=l,l.child=s)}if(C=s.child,!(s.lanes&T)){var L=C.memoizedProps;if(p=p.compare,p=p!==null?p:Tg,p(L,x)&&s.ref===l.ref)return rc(s,l,T)}return l.flags|=1,s=mu(C,x),s.ref=l.ref,s.return=l,l.child=s}function JL(s,l,p,x,T){if(s!==null){var C=s.memoizedProps;if(Tg(C,x)&&s.ref===l.ref)if(ro=!1,l.pendingProps=x=C,(s.lanes&T)!==0)s.flags&131072&&(ro=!0);else return l.lanes=s.lanes,rc(s,l,T)}return JT(s,l,p,x,T)}function QL(s,l,p){var x=l.pendingProps,T=x.children,C=s!==null?s.memoizedState:null;if(x.mode==="hidden")if(!(l.mode&1))l.memoizedState={baseLanes:0,cachePool:null,transitions:null},qn(Xf,wo),wo|=p;else{if(!(p&1073741824))return s=C!==null?C.baseLanes|p:p,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:s,cachePool:null,transitions:null},l.updateQueue=null,qn(Xf,wo),wo|=s,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=C!==null?C.baseLanes:p,qn(Xf,wo),wo|=x}else C!==null?(x=C.baseLanes|p,l.memoizedState=null):x=p,qn(Xf,wo),wo|=x;return Us(s,l,T,p),l.child}function ez(s,l){var p=l.ref;(s===null&&p!==null||s!==null&&s.ref!==p)&&(l.flags|=512,l.flags|=2097152)}function JT(s,l,p,x,T){var C=oo(p)?Wh:Ss.current;return C=cp(l,C),sp(l,T),p=d2(s,l,p,x,C,T),x=f2(),s!==null&&!ro?(l.updateQueue=s.updateQueue,l.flags&=-2053,s.lanes&=~T,rc(s,l,T)):(or&&x&&e2(l),l.flags|=1,Us(s,l,p,T),l.child)}function xM(s,l,p,x,T){if(oo(p)){var C=!0;_0(l)}else C=!1;if(sp(l,T),l.stateNode===null)Jv(s,l),XL(l,p,x),YT(l,p,x,T),x=!0;else if(s===null){var L=l.stateNode,a=l.memoizedProps;L.props=a;var F=L.context,H=p.contextType;typeof H=="object"&&H!==null?H=ra(H):(H=oo(p)?Wh:Ss.current,H=cp(l,H));var ee=p.getDerivedStateFromProps,se=typeof ee=="function"||typeof L.getSnapshotBeforeUpdate=="function";se||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(a!==x||F!==H)&&fM(l,L,x,H),iu=!1;var ue=l.memoizedState;L.state=ue,b0(l,x,L,T),F=l.memoizedState,a!==x||ue!==F||so.current||iu?(typeof ee=="function"&&(XT(l,p,ee,x),F=l.memoizedState),(a=iu||dM(l,p,a,x,ue,F,H))?(se||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(l.flags|=4194308)):(typeof L.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=x,l.memoizedState=F),L.props=x,L.state=F,L.context=H,x=a):(typeof L.componentDidMount=="function"&&(l.flags|=4194308),x=!1)}else{L=l.stateNode,CL(s,l),a=l.memoizedProps,H=l.type===l.elementType?a:Aa(l.type,a),L.props=H,se=l.pendingProps,ue=L.context,F=p.contextType,typeof F=="object"&&F!==null?F=ra(F):(F=oo(p)?Wh:Ss.current,F=cp(l,F));var Me=p.getDerivedStateFromProps;(ee=typeof Me=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(a!==se||ue!==F)&&fM(l,L,x,F),iu=!1,ue=l.memoizedState,L.state=ue,b0(l,x,L,T);var Ve=l.memoizedState;a!==se||ue!==Ve||so.current||iu?(typeof Me=="function"&&(XT(l,p,Me,x),Ve=l.memoizedState),(H=iu||dM(l,p,H,x,ue,Ve,F)||!1)?(ee||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(x,Ve,F),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(x,Ve,F)),typeof L.componentDidUpdate=="function"&&(l.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof L.componentDidUpdate!="function"||a===s.memoizedProps&&ue===s.memoizedState||(l.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||a===s.memoizedProps&&ue===s.memoizedState||(l.flags|=1024),l.memoizedProps=x,l.memoizedState=Ve),L.props=x,L.state=Ve,L.context=F,x=H):(typeof L.componentDidUpdate!="function"||a===s.memoizedProps&&ue===s.memoizedState||(l.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||a===s.memoizedProps&&ue===s.memoizedState||(l.flags|=1024),x=!1)}return QT(s,l,p,x,C,T)}function QT(s,l,p,x,T,C){ez(s,l);var L=(l.flags&128)!==0;if(!x&&!L)return T&&rM(l,p,!1),rc(s,l,C);x=l.stateNode,TV.current=l;var a=L&&typeof p.getDerivedStateFromError!="function"?null:x.render();return l.flags|=1,s!==null&&L?(l.child=hp(l,s.child,null,C),l.child=hp(l,null,a,C)):Us(s,l,a,C),l.memoizedState=x.state,T&&rM(l,p,!0),l.child}function tz(s){var l=s.stateNode;l.pendingContext?nM(s,l.pendingContext,l.pendingContext!==l.context):l.context&&nM(s,l.context,!1),l2(s,l.containerInfo)}function vM(s,l,p,x,T){return up(),i2(T),l.flags|=256,Us(s,l,p,x),l.child}var eS={dehydrated:null,treeContext:null,retryLane:0};function tS(s){return{baseLanes:s,cachePool:null,transitions:null}}function iz(s,l,p){var x=l.pendingProps,T=dr.current,C=!1,L=(l.flags&128)!==0,a;if((a=L)||(a=s!==null&&s.memoizedState===null?!1:(T&2)!==0),a?(C=!0,l.flags&=-129):(s===null||s.memoizedState!==null)&&(T|=1),qn(dr,T&1),s===null)return qT(l),s=l.memoizedState,s!==null&&(s=s.dehydrated,s!==null)?(l.mode&1?s.data==="$!"?l.lanes=8:l.lanes=1073741824:l.lanes=1,null):(L=x.children,s=x.fallback,C?(x=l.mode,C=l.child,L={mode:"hidden",children:L},!(x&1)&&C!==null?(C.childLanes=0,C.pendingProps=L):C=W0(L,x,0,null),s=Hh(s,x,p,null),C.return=l,s.return=l,C.sibling=s,l.child=C,l.child.memoizedState=tS(p),l.memoizedState=eS,s):_2(l,L));if(T=s.memoizedState,T!==null&&(a=T.dehydrated,a!==null))return SV(s,l,L,x,a,T,p);if(C){C=x.fallback,L=l.mode,T=s.child,a=T.sibling;var F={mode:"hidden",children:x.children};return!(L&1)&&l.child!==T?(x=l.child,x.childLanes=0,x.pendingProps=F,l.deletions=null):(x=mu(T,F),x.subtreeFlags=T.subtreeFlags&14680064),a!==null?C=mu(a,C):(C=Hh(C,L,p,null),C.flags|=2),C.return=l,x.return=l,x.sibling=C,l.child=x,x=C,C=l.child,L=s.child.memoizedState,L=L===null?tS(p):{baseLanes:L.baseLanes|p,cachePool:null,transitions:L.transitions},C.memoizedState=L,C.childLanes=s.childLanes&~p,l.memoizedState=eS,x}return C=s.child,s=C.sibling,x=mu(C,{mode:"visible",children:x.children}),!(l.mode&1)&&(x.lanes=p),x.return=l,x.sibling=null,s!==null&&(p=l.deletions,p===null?(l.deletions=[s],l.flags|=16):p.push(s)),l.child=x,l.memoizedState=null,x}function _2(s,l){return l=W0({mode:"visible",children:l},s.mode,0,null),l.return=s,s.child=l}function zv(s,l,p,x){return x!==null&&i2(x),hp(l,s.child,null,p),s=_2(l,l.pendingProps.children),s.flags|=2,l.memoizedState=null,s}function SV(s,l,p,x,T,C,L){if(p)return l.flags&256?(l.flags&=-257,x=Zw(Error(Ot(422))),zv(s,l,L,x)):l.memoizedState!==null?(l.child=s.child,l.flags|=128,null):(C=x.fallback,T=l.mode,x=W0({mode:"visible",children:x.children},T,0,null),C=Hh(C,T,L,null),C.flags|=2,x.return=l,C.return=l,x.sibling=C,l.child=x,l.mode&1&&hp(l,s.child,null,L),l.child.memoizedState=tS(L),l.memoizedState=eS,C);if(!(l.mode&1))return zv(s,l,L,null);if(T.data==="$!"){if(x=T.nextSibling&&T.nextSibling.dataset,x)var a=x.dgst;return x=a,C=Error(Ot(419)),x=Zw(C,x,void 0),zv(s,l,L,x)}if(a=(L&s.childLanes)!==0,ro||a){if(x=es,x!==null){switch(L&-L){case 4:T=2;break;case 16:T=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:T=32;break;case 536870912:T=268435456;break;default:T=0}T=T&(x.suspendedLanes|L)?0:T,T!==0&&T!==C.retryLane&&(C.retryLane=T,nc(s,T),Ra(x,s,T,-1))}return w2(),x=Zw(Error(Ot(421))),zv(s,l,L,x)}return T.data==="$?"?(l.flags|=128,l.child=s.child,l=OV.bind(null,s),T._reactRetry=l,null):(s=C.treeContext,To=hu(T.nextSibling),So=l,or=!0,Pa=null,s!==null&&(ea[ta++]=Yl,ea[ta++]=Kl,ea[ta++]=Xh,Yl=s.id,Kl=s.overflow,Xh=l),l=_2(l,x.children),l.flags|=4096,l)}function bM(s,l,p){s.lanes|=l;var x=s.alternate;x!==null&&(x.lanes|=l),WT(s.return,l,p)}function qw(s,l,p,x,T){var C=s.memoizedState;C===null?s.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:x,tail:p,tailMode:T}:(C.isBackwards=l,C.rendering=null,C.renderingStartTime=0,C.last=x,C.tail=p,C.tailMode=T)}function nz(s,l,p){var x=l.pendingProps,T=x.revealOrder,C=x.tail;if(Us(s,l,x.children,p),x=dr.current,x&2)x=x&1|2,l.flags|=128;else{if(s!==null&&s.flags&128)e:for(s=l.child;s!==null;){if(s.tag===13)s.memoizedState!==null&&bM(s,p,l);else if(s.tag===19)bM(s,p,l);else if(s.child!==null){s.child.return=s,s=s.child;continue}if(s===l)break e;for(;s.sibling===null;){if(s.return===null||s.return===l)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}x&=1}if(qn(dr,x),!(l.mode&1))l.memoizedState=null;else switch(T){case"forwards":for(p=l.child,T=null;p!==null;)s=p.alternate,s!==null&&w0(s)===null&&(T=p),p=p.sibling;p=T,p===null?(T=l.child,l.child=null):(T=p.sibling,p.sibling=null),qw(l,!1,T,p,C);break;case"backwards":for(p=null,T=l.child,l.child=null;T!==null;){if(s=T.alternate,s!==null&&w0(s)===null){l.child=T;break}s=T.sibling,T.sibling=p,p=T,T=s}qw(l,!0,p,null,C);break;case"together":qw(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function Jv(s,l){!(l.mode&1)&&s!==null&&(s.alternate=null,l.alternate=null,l.flags|=2)}function rc(s,l,p){if(s!==null&&(l.dependencies=s.dependencies),Kh|=l.lanes,!(p&l.childLanes))return null;if(s!==null&&l.child!==s.child)throw Error(Ot(153));if(l.child!==null){for(s=l.child,p=mu(s,s.pendingProps),l.child=p,p.return=l;s.sibling!==null;)s=s.sibling,p=p.sibling=mu(s,s.pendingProps),p.return=l;p.sibling=null}return l.child}function EV(s,l,p){switch(l.tag){case 3:tz(l),up();break;case 5:PL(l);break;case 1:oo(l.type)&&_0(l);break;case 4:l2(l,l.stateNode.containerInfo);break;case 10:var x=l.type._context,T=l.memoizedProps.value;qn(x0,x._currentValue),x._currentValue=T;break;case 13:if(x=l.memoizedState,x!==null)return x.dehydrated!==null?(qn(dr,dr.current&1),l.flags|=128,null):p&l.child.childLanes?iz(s,l,p):(qn(dr,dr.current&1),s=rc(s,l,p),s!==null?s.sibling:null);qn(dr,dr.current&1);break;case 19:if(x=(p&l.childLanes)!==0,s.flags&128){if(x)return nz(s,l,p);l.flags|=128}if(T=l.memoizedState,T!==null&&(T.rendering=null,T.tail=null,T.lastEffect=null),qn(dr,dr.current),x)break;return null;case 22:case 23:return l.lanes=0,QL(s,l,p)}return rc(s,l,p)}var rz,iS,sz,oz;rz=function(s,l){for(var p=l.child;p!==null;){if(p.tag===5||p.tag===6)s.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===l)break;for(;p.sibling===null;){if(p.return===null||p.return===l)return;p=p.return}p.sibling.return=p.return,p=p.sibling}};iS=function(){};sz=function(s,l,p,x){var T=s.memoizedProps;if(T!==x){s=l.stateNode,jh(cl.current);var C=null;switch(p){case"input":T=ST(s,T),x=ST(s,x),C=[];break;case"select":T=mr({},T,{value:void 0}),x=mr({},x,{value:void 0}),C=[];break;case"textarea":T=AT(s,T),x=AT(s,x),C=[];break;default:typeof T.onClick!="function"&&typeof x.onClick=="function"&&(s.onclick=p0)}PT(p,x);var L;p=null;for(H in T)if(!x.hasOwnProperty(H)&&T.hasOwnProperty(H)&&T[H]!=null)if(H==="style"){var a=T[H];for(L in a)a.hasOwnProperty(L)&&(p||(p={}),p[L]="")}else H!=="dangerouslySetInnerHTML"&&H!=="children"&&H!=="suppressContentEditableWarning"&&H!=="suppressHydrationWarning"&&H!=="autoFocus"&&(_g.hasOwnProperty(H)?C||(C=[]):(C=C||[]).push(H,null));for(H in x){var F=x[H];if(a=T!=null?T[H]:void 0,x.hasOwnProperty(H)&&F!==a&&(F!=null||a!=null))if(H==="style")if(a){for(L in a)!a.hasOwnProperty(L)||F&&F.hasOwnProperty(L)||(p||(p={}),p[L]="");for(L in F)F.hasOwnProperty(L)&&a[L]!==F[L]&&(p||(p={}),p[L]=F[L])}else p||(C||(C=[]),C.push(H,p)),p=F;else H==="dangerouslySetInnerHTML"?(F=F?F.__html:void 0,a=a?a.__html:void 0,F!=null&&a!==F&&(C=C||[]).push(H,F)):H==="children"?typeof F!="string"&&typeof F!="number"||(C=C||[]).push(H,""+F):H!=="suppressContentEditableWarning"&&H!=="suppressHydrationWarning"&&(_g.hasOwnProperty(H)?(F!=null&&H==="onScroll"&&Qn("scroll",s),C||a===F||(C=[])):(C=C||[]).push(H,F))}p&&(C=C||[]).push("style",p);var H=C;(l.updateQueue=H)&&(l.flags|=4)}};oz=function(s,l,p,x){p!==x&&(l.flags|=4)};function H_(s,l){if(!or)switch(s.tailMode){case"hidden":l=s.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?s.tail=null:p.sibling=null;break;case"collapsed":p=s.tail;for(var x=null;p!==null;)p.alternate!==null&&(x=p),p=p.sibling;x===null?l||s.tail===null?s.tail=null:s.tail.sibling=null:x.sibling=null}}function vs(s){var l=s.alternate!==null&&s.alternate.child===s.child,p=0,x=0;if(l)for(var T=s.child;T!==null;)p|=T.lanes|T.childLanes,x|=T.subtreeFlags&14680064,x|=T.flags&14680064,T.return=s,T=T.sibling;else for(T=s.child;T!==null;)p|=T.lanes|T.childLanes,x|=T.subtreeFlags,x|=T.flags,T.return=s,T=T.sibling;return s.subtreeFlags|=x,s.childLanes=p,l}function IV(s,l,p){var x=l.pendingProps;switch(t2(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return vs(l),null;case 1:return oo(l.type)&&m0(),vs(l),null;case 3:return x=l.stateNode,dp(),er(so),er(Ss),u2(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(s===null||s.child===null)&&(Dv(l)?l.flags|=4:s===null||s.memoizedState.isDehydrated&&!(l.flags&256)||(l.flags|=1024,Pa!==null&&(uS(Pa),Pa=null))),iS(s,l),vs(l),null;case 5:c2(l);var T=jh(Cg.current);if(p=l.type,s!==null&&l.stateNode!=null)sz(s,l,p,x,T),s.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!x){if(l.stateNode===null)throw Error(Ot(166));return vs(l),null}if(s=jh(cl.current),Dv(l)){x=l.stateNode,p=l.type;var C=l.memoizedProps;switch(x[al]=l,x[Ig]=C,s=(l.mode&1)!==0,p){case"dialog":Qn("cancel",x),Qn("close",x);break;case"iframe":case"object":case"embed":Qn("load",x);break;case"video":case"audio":for(T=0;T<K_.length;T++)Qn(K_[T],x);break;case"source":Qn("error",x);break;case"img":case"image":case"link":Qn("error",x),Qn("load",x);break;case"details":Qn("toggle",x);break;case"input":MP(x,C),Qn("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!C.multiple},Qn("invalid",x);break;case"textarea":DP(x,C),Qn("invalid",x)}PT(p,C),T=null;for(var L in C)if(C.hasOwnProperty(L)){var a=C[L];L==="children"?typeof a=="string"?x.textContent!==a&&(C.suppressHydrationWarning!==!0&&Rv(x.textContent,a,s),T=["children",a]):typeof a=="number"&&x.textContent!==""+a&&(C.suppressHydrationWarning!==!0&&Rv(x.textContent,a,s),T=["children",""+a]):_g.hasOwnProperty(L)&&a!=null&&L==="onScroll"&&Qn("scroll",x)}switch(p){case"input":Tv(x),RP(x,C,!0);break;case"textarea":Tv(x),LP(x);break;case"select":case"option":break;default:typeof C.onClick=="function"&&(x.onclick=p0)}x=T,l.updateQueue=x,x!==null&&(l.flags|=4)}else{L=T.nodeType===9?T:T.ownerDocument,s==="http://www.w3.org/1999/xhtml"&&(s=zD(p)),s==="http://www.w3.org/1999/xhtml"?p==="script"?(s=L.createElement("div"),s.innerHTML="<script><\/script>",s=s.removeChild(s.firstChild)):typeof x.is=="string"?s=L.createElement(p,{is:x.is}):(s=L.createElement(p),p==="select"&&(L=s,x.multiple?L.multiple=!0:x.size&&(L.size=x.size))):s=L.createElementNS(s,p),s[al]=l,s[Ig]=x,rz(s,l,!1,!1),l.stateNode=s;e:{switch(L=MT(p,x),p){case"dialog":Qn("cancel",s),Qn("close",s),T=x;break;case"iframe":case"object":case"embed":Qn("load",s),T=x;break;case"video":case"audio":for(T=0;T<K_.length;T++)Qn(K_[T],s);T=x;break;case"source":Qn("error",s),T=x;break;case"img":case"image":case"link":Qn("error",s),Qn("load",s),T=x;break;case"details":Qn("toggle",s),T=x;break;case"input":MP(s,x),T=ST(s,x),Qn("invalid",s);break;case"option":T=x;break;case"select":s._wrapperState={wasMultiple:!!x.multiple},T=mr({},x,{value:void 0}),Qn("invalid",s);break;case"textarea":DP(s,x),T=AT(s,x),Qn("invalid",s);break;default:T=x}PT(p,T),a=T;for(C in a)if(a.hasOwnProperty(C)){var F=a[C];C==="style"?OD(s,F):C==="dangerouslySetInnerHTML"?(F=F?F.__html:void 0,F!=null&&kD(s,F)):C==="children"?typeof F=="string"?(p!=="textarea"||F!=="")&&gg(s,F):typeof F=="number"&&gg(s,""+F):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(_g.hasOwnProperty(C)?F!=null&&C==="onScroll"&&Qn("scroll",s):F!=null&&VS(s,C,F,L))}switch(p){case"input":Tv(s),RP(s,x,!1);break;case"textarea":Tv(s),LP(s);break;case"option":x.value!=null&&s.setAttribute("value",""+_u(x.value));break;case"select":s.multiple=!!x.multiple,C=x.value,C!=null?tp(s,!!x.multiple,C,!1):x.defaultValue!=null&&tp(s,!!x.multiple,x.defaultValue,!0);break;default:typeof T.onClick=="function"&&(s.onclick=p0)}switch(p){case"button":case"input":case"select":case"textarea":x=!!x.autoFocus;break e;case"img":x=!0;break e;default:x=!1}}x&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return vs(l),null;case 6:if(s&&l.stateNode!=null)oz(s,l,s.memoizedProps,x);else{if(typeof x!="string"&&l.stateNode===null)throw Error(Ot(166));if(p=jh(Cg.current),jh(cl.current),Dv(l)){if(x=l.stateNode,p=l.memoizedProps,x[al]=l,(C=x.nodeValue!==p)&&(s=So,s!==null))switch(s.tag){case 3:Rv(x.nodeValue,p,(s.mode&1)!==0);break;case 5:s.memoizedProps.suppressHydrationWarning!==!0&&Rv(x.nodeValue,p,(s.mode&1)!==0)}C&&(l.flags|=4)}else x=(p.nodeType===9?p:p.ownerDocument).createTextNode(x),x[al]=l,l.stateNode=x}return vs(l),null;case 13:if(er(dr),x=l.memoizedState,s===null||s.memoizedState!==null&&s.memoizedState.dehydrated!==null){if(or&&To!==null&&l.mode&1&&!(l.flags&128))SL(),up(),l.flags|=98560,C=!1;else if(C=Dv(l),x!==null&&x.dehydrated!==null){if(s===null){if(!C)throw Error(Ot(318));if(C=l.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(Ot(317));C[al]=l}else up(),!(l.flags&128)&&(l.memoizedState=null),l.flags|=4;vs(l),C=!1}else Pa!==null&&(uS(Pa),Pa=null),C=!0;if(!C)return l.flags&65536?l:null}return l.flags&128?(l.lanes=p,l):(x=x!==null,x!==(s!==null&&s.memoizedState!==null)&&x&&(l.child.flags|=8192,l.mode&1&&(s===null||dr.current&1?Hr===0&&(Hr=3):w2())),l.updateQueue!==null&&(l.flags|=4),vs(l),null);case 4:return dp(),iS(s,l),s===null&&Sg(l.stateNode.containerInfo),vs(l),null;case 10:return s2(l.type._context),vs(l),null;case 17:return oo(l.type)&&m0(),vs(l),null;case 19:if(er(dr),C=l.memoizedState,C===null)return vs(l),null;if(x=(l.flags&128)!==0,L=C.rendering,L===null)if(x)H_(C,!1);else{if(Hr!==0||s!==null&&s.flags&128)for(s=l.child;s!==null;){if(L=w0(s),L!==null){for(l.flags|=128,H_(C,!1),x=L.updateQueue,x!==null&&(l.updateQueue=x,l.flags|=4),l.subtreeFlags=0,x=p,p=l.child;p!==null;)C=p,s=x,C.flags&=14680066,L=C.alternate,L===null?(C.childLanes=0,C.lanes=s,C.child=null,C.subtreeFlags=0,C.memoizedProps=null,C.memoizedState=null,C.updateQueue=null,C.dependencies=null,C.stateNode=null):(C.childLanes=L.childLanes,C.lanes=L.lanes,C.child=L.child,C.subtreeFlags=0,C.deletions=null,C.memoizedProps=L.memoizedProps,C.memoizedState=L.memoizedState,C.updateQueue=L.updateQueue,C.type=L.type,s=L.dependencies,C.dependencies=s===null?null:{lanes:s.lanes,firstContext:s.firstContext}),p=p.sibling;return qn(dr,dr.current&1|2),l.child}s=s.sibling}C.tail!==null&&Pr()>pp&&(l.flags|=128,x=!0,H_(C,!1),l.lanes=4194304)}else{if(!x)if(s=w0(L),s!==null){if(l.flags|=128,x=!0,p=s.updateQueue,p!==null&&(l.updateQueue=p,l.flags|=4),H_(C,!0),C.tail===null&&C.tailMode==="hidden"&&!L.alternate&&!or)return vs(l),null}else 2*Pr()-C.renderingStartTime>pp&&p!==1073741824&&(l.flags|=128,x=!0,H_(C,!1),l.lanes=4194304);C.isBackwards?(L.sibling=l.child,l.child=L):(p=C.last,p!==null?p.sibling=L:l.child=L,C.last=L)}return C.tail!==null?(l=C.tail,C.rendering=l,C.tail=l.sibling,C.renderingStartTime=Pr(),l.sibling=null,p=dr.current,qn(dr,x?p&1|2:p&1),l):(vs(l),null);case 22:case 23:return b2(),x=l.memoizedState!==null,s!==null&&s.memoizedState!==null!==x&&(l.flags|=8192),x&&l.mode&1?wo&1073741824&&(vs(l),l.subtreeFlags&6&&(l.flags|=8192)):vs(l),null;case 24:return null;case 25:return null}throw Error(Ot(156,l.tag))}function AV(s,l){switch(t2(l),l.tag){case 1:return oo(l.type)&&m0(),s=l.flags,s&65536?(l.flags=s&-65537|128,l):null;case 3:return dp(),er(so),er(Ss),u2(),s=l.flags,s&65536&&!(s&128)?(l.flags=s&-65537|128,l):null;case 5:return c2(l),null;case 13:if(er(dr),s=l.memoizedState,s!==null&&s.dehydrated!==null){if(l.alternate===null)throw Error(Ot(340));up()}return s=l.flags,s&65536?(l.flags=s&-65537|128,l):null;case 19:return er(dr),null;case 4:return dp(),null;case 10:return s2(l.type._context),null;case 22:case 23:return b2(),null;case 24:return null;default:return null}}var kv=!1,ws=!1,CV=typeof WeakSet=="function"?WeakSet:Set,ui=null;function Wf(s,l){var p=s.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){xr(s,l,x)}else p.current=null}function nS(s,l,p){try{p()}catch(x){xr(s,l,x)}}var wM=!1;function PV(s,l){if(VT=h0,s=hL(),QS(s)){if("selectionStart"in s)var p={start:s.selectionStart,end:s.selectionEnd};else e:{p=(p=s.ownerDocument)&&p.defaultView||window;var x=p.getSelection&&p.getSelection();if(x&&x.rangeCount!==0){p=x.anchorNode;var T=x.anchorOffset,C=x.focusNode;x=x.focusOffset;try{p.nodeType,C.nodeType}catch{p=null;break e}var L=0,a=-1,F=-1,H=0,ee=0,se=s,ue=null;t:for(;;){for(var Me;se!==p||T!==0&&se.nodeType!==3||(a=L+T),se!==C||x!==0&&se.nodeType!==3||(F=L+x),se.nodeType===3&&(L+=se.nodeValue.length),(Me=se.firstChild)!==null;)ue=se,se=Me;for(;;){if(se===s)break t;if(ue===p&&++H===T&&(a=L),ue===C&&++ee===x&&(F=L),(Me=se.nextSibling)!==null)break;se=ue,ue=se.parentNode}se=Me}p=a===-1||F===-1?null:{start:a,end:F}}else p=null}p=p||{start:0,end:0}}else p=null;for(UT={focusedElem:s,selectionRange:p},h0=!1,ui=l;ui!==null;)if(l=ui,s=l.child,(l.subtreeFlags&1028)!==0&&s!==null)s.return=l,ui=s;else for(;ui!==null;){l=ui;try{var Ve=l.alternate;if(l.flags&1024)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Ve!==null){var ke=Ve.memoizedProps,Ye=Ve.memoizedState,Se=l.stateNode,ye=Se.getSnapshotBeforeUpdate(l.elementType===l.type?ke:Aa(l.type,ke),Ye);Se.__reactInternalSnapshotBeforeUpdate=ye}break;case 3:var Ie=l.stateNode.containerInfo;Ie.nodeType===1?Ie.textContent="":Ie.nodeType===9&&Ie.documentElement&&Ie.removeChild(Ie.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ot(163))}}catch(qe){xr(l,l.return,qe)}if(s=l.sibling,s!==null){s.return=l.return,ui=s;break}ui=l.return}return Ve=wM,wM=!1,Ve}function ag(s,l,p){var x=l.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var T=x=x.next;do{if((T.tag&s)===s){var C=T.destroy;T.destroy=void 0,C!==void 0&&nS(l,p,C)}T=T.next}while(T!==x)}}function Z0(s,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var p=l=l.next;do{if((p.tag&s)===s){var x=p.create;p.destroy=x()}p=p.next}while(p!==l)}}function rS(s){var l=s.ref;if(l!==null){var p=s.stateNode;switch(s.tag){case 5:s=p;break;default:s=p}typeof l=="function"?l(s):l.current=s}}function az(s){var l=s.alternate;l!==null&&(s.alternate=null,az(l)),s.child=null,s.deletions=null,s.sibling=null,s.tag===5&&(l=s.stateNode,l!==null&&(delete l[al],delete l[Ig],delete l[$T],delete l[hV],delete l[dV])),s.stateNode=null,s.return=null,s.dependencies=null,s.memoizedProps=null,s.memoizedState=null,s.pendingProps=null,s.stateNode=null,s.updateQueue=null}function lz(s){return s.tag===5||s.tag===3||s.tag===4}function TM(s){e:for(;;){for(;s.sibling===null;){if(s.return===null||lz(s.return))return null;s=s.return}for(s.sibling.return=s.return,s=s.sibling;s.tag!==5&&s.tag!==6&&s.tag!==18;){if(s.flags&2||s.child===null||s.tag===4)continue e;s.child.return=s,s=s.child}if(!(s.flags&2))return s.stateNode}}function sS(s,l,p){var x=s.tag;if(x===5||x===6)s=s.stateNode,l?p.nodeType===8?p.parentNode.insertBefore(s,l):p.insertBefore(s,l):(p.nodeType===8?(l=p.parentNode,l.insertBefore(s,p)):(l=p,l.appendChild(s)),p=p._reactRootContainer,p!=null||l.onclick!==null||(l.onclick=p0));else if(x!==4&&(s=s.child,s!==null))for(sS(s,l,p),s=s.sibling;s!==null;)sS(s,l,p),s=s.sibling}function oS(s,l,p){var x=s.tag;if(x===5||x===6)s=s.stateNode,l?p.insertBefore(s,l):p.appendChild(s);else if(x!==4&&(s=s.child,s!==null))for(oS(s,l,p),s=s.sibling;s!==null;)oS(s,l,p),s=s.sibling}var os=null,Ca=!1;function Qc(s,l,p){for(p=p.child;p!==null;)cz(s,l,p),p=p.sibling}function cz(s,l,p){if(ll&&typeof ll.onCommitFiberUnmount=="function")try{ll.onCommitFiberUnmount(B0,p)}catch{}switch(p.tag){case 5:ws||Wf(p,l);case 6:var x=os,T=Ca;os=null,Qc(s,l,p),os=x,Ca=T,os!==null&&(Ca?(s=os,p=p.stateNode,s.nodeType===8?s.parentNode.removeChild(p):s.removeChild(p)):os.removeChild(p.stateNode));break;case 18:os!==null&&(Ca?(s=os,p=p.stateNode,s.nodeType===8?Vw(s.parentNode,p):s.nodeType===1&&Vw(s,p),bg(s)):Vw(os,p.stateNode));break;case 4:x=os,T=Ca,os=p.stateNode.containerInfo,Ca=!0,Qc(s,l,p),os=x,Ca=T;break;case 0:case 11:case 14:case 15:if(!ws&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){T=x=x.next;do{var C=T,L=C.destroy;C=C.tag,L!==void 0&&(C&2||C&4)&&nS(p,l,L),T=T.next}while(T!==x)}Qc(s,l,p);break;case 1:if(!ws&&(Wf(p,l),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(a){xr(p,l,a)}Qc(s,l,p);break;case 21:Qc(s,l,p);break;case 22:p.mode&1?(ws=(x=ws)||p.memoizedState!==null,Qc(s,l,p),ws=x):Qc(s,l,p);break;default:Qc(s,l,p)}}function SM(s){var l=s.updateQueue;if(l!==null){s.updateQueue=null;var p=s.stateNode;p===null&&(p=s.stateNode=new CV),l.forEach(function(x){var T=BV.bind(null,s,x);p.has(x)||(p.add(x),x.then(T,T))})}}function Ea(s,l){var p=l.deletions;if(p!==null)for(var x=0;x<p.length;x++){var T=p[x];try{var C=s,L=l,a=L;e:for(;a!==null;){switch(a.tag){case 5:os=a.stateNode,Ca=!1;break e;case 3:os=a.stateNode.containerInfo,Ca=!0;break e;case 4:os=a.stateNode.containerInfo,Ca=!0;break e}a=a.return}if(os===null)throw Error(Ot(160));cz(C,L,T),os=null,Ca=!1;var F=T.alternate;F!==null&&(F.return=null),T.return=null}catch(H){xr(T,l,H)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)uz(l,s),l=l.sibling}function uz(s,l){var p=s.alternate,x=s.flags;switch(s.tag){case 0:case 11:case 14:case 15:if(Ea(l,s),rl(s),x&4){try{ag(3,s,s.return),Z0(3,s)}catch(ke){xr(s,s.return,ke)}try{ag(5,s,s.return)}catch(ke){xr(s,s.return,ke)}}break;case 1:Ea(l,s),rl(s),x&512&&p!==null&&Wf(p,p.return);break;case 5:if(Ea(l,s),rl(s),x&512&&p!==null&&Wf(p,p.return),s.flags&32){var T=s.stateNode;try{gg(T,"")}catch(ke){xr(s,s.return,ke)}}if(x&4&&(T=s.stateNode,T!=null)){var C=s.memoizedProps,L=p!==null?p.memoizedProps:C,a=s.type,F=s.updateQueue;if(s.updateQueue=null,F!==null)try{a==="input"&&C.type==="radio"&&C.name!=null&&DD(T,C),MT(a,L);var H=MT(a,C);for(L=0;L<F.length;L+=2){var ee=F[L],se=F[L+1];ee==="style"?OD(T,se):ee==="dangerouslySetInnerHTML"?kD(T,se):ee==="children"?gg(T,se):VS(T,ee,se,H)}switch(a){case"input":ET(T,C);break;case"textarea":LD(T,C);break;case"select":var ue=T._wrapperState.wasMultiple;T._wrapperState.wasMultiple=!!C.multiple;var Me=C.value;Me!=null?tp(T,!!C.multiple,Me,!1):ue!==!!C.multiple&&(C.defaultValue!=null?tp(T,!!C.multiple,C.defaultValue,!0):tp(T,!!C.multiple,C.multiple?[]:"",!1))}T[Ig]=C}catch(ke){xr(s,s.return,ke)}}break;case 6:if(Ea(l,s),rl(s),x&4){if(s.stateNode===null)throw Error(Ot(162));T=s.stateNode,C=s.memoizedProps;try{T.nodeValue=C}catch(ke){xr(s,s.return,ke)}}break;case 3:if(Ea(l,s),rl(s),x&4&&p!==null&&p.memoizedState.isDehydrated)try{bg(l.containerInfo)}catch(ke){xr(s,s.return,ke)}break;case 4:Ea(l,s),rl(s);break;case 13:Ea(l,s),rl(s),T=s.child,T.flags&8192&&(C=T.memoizedState!==null,T.stateNode.isHidden=C,!C||T.alternate!==null&&T.alternate.memoizedState!==null||(x2=Pr())),x&4&&SM(s);break;case 22:if(ee=p!==null&&p.memoizedState!==null,s.mode&1?(ws=(H=ws)||ee,Ea(l,s),ws=H):Ea(l,s),rl(s),x&8192){if(H=s.memoizedState!==null,(s.stateNode.isHidden=H)&&!ee&&s.mode&1)for(ui=s,ee=s.child;ee!==null;){for(se=ui=ee;ui!==null;){switch(ue=ui,Me=ue.child,ue.tag){case 0:case 11:case 14:case 15:ag(4,ue,ue.return);break;case 1:Wf(ue,ue.return);var Ve=ue.stateNode;if(typeof Ve.componentWillUnmount=="function"){x=ue,p=ue.return;try{l=x,Ve.props=l.memoizedProps,Ve.state=l.memoizedState,Ve.componentWillUnmount()}catch(ke){xr(x,p,ke)}}break;case 5:Wf(ue,ue.return);break;case 22:if(ue.memoizedState!==null){IM(se);continue}}Me!==null?(Me.return=ue,ui=Me):IM(se)}ee=ee.sibling}e:for(ee=null,se=s;;){if(se.tag===5){if(ee===null){ee=se;try{T=se.stateNode,H?(C=T.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none"):(a=se.stateNode,F=se.memoizedProps.style,L=F!=null&&F.hasOwnProperty("display")?F.display:null,a.style.display=FD("display",L))}catch(ke){xr(s,s.return,ke)}}}else if(se.tag===6){if(ee===null)try{se.stateNode.nodeValue=H?"":se.memoizedProps}catch(ke){xr(s,s.return,ke)}}else if((se.tag!==22&&se.tag!==23||se.memoizedState===null||se===s)&&se.child!==null){se.child.return=se,se=se.child;continue}if(se===s)break e;for(;se.sibling===null;){if(se.return===null||se.return===s)break e;ee===se&&(ee=null),se=se.return}ee===se&&(ee=null),se.sibling.return=se.return,se=se.sibling}}break;case 19:Ea(l,s),rl(s),x&4&&SM(s);break;case 21:break;default:Ea(l,s),rl(s)}}function rl(s){var l=s.flags;if(l&2){try{e:{for(var p=s.return;p!==null;){if(lz(p)){var x=p;break e}p=p.return}throw Error(Ot(160))}switch(x.tag){case 5:var T=x.stateNode;x.flags&32&&(gg(T,""),x.flags&=-33);var C=TM(s);oS(s,C,T);break;case 3:case 4:var L=x.stateNode.containerInfo,a=TM(s);sS(s,a,L);break;default:throw Error(Ot(161))}}catch(F){xr(s,s.return,F)}s.flags&=-3}l&4096&&(s.flags&=-4097)}function MV(s,l,p){ui=s,hz(s)}function hz(s,l,p){for(var x=(s.mode&1)!==0;ui!==null;){var T=ui,C=T.child;if(T.tag===22&&x){var L=T.memoizedState!==null||kv;if(!L){var a=T.alternate,F=a!==null&&a.memoizedState!==null||ws;a=kv;var H=ws;if(kv=L,(ws=F)&&!H)for(ui=T;ui!==null;)L=ui,F=L.child,L.tag===22&&L.memoizedState!==null?AM(T):F!==null?(F.return=L,ui=F):AM(T);for(;C!==null;)ui=C,hz(C),C=C.sibling;ui=T,kv=a,ws=H}EM(s)}else T.subtreeFlags&8772&&C!==null?(C.return=T,ui=C):EM(s)}}function EM(s){for(;ui!==null;){var l=ui;if(l.flags&8772){var p=l.alternate;try{if(l.flags&8772)switch(l.tag){case 0:case 11:case 15:ws||Z0(5,l);break;case 1:var x=l.stateNode;if(l.flags&4&&!ws)if(p===null)x.componentDidMount();else{var T=l.elementType===l.type?p.memoizedProps:Aa(l.type,p.memoizedProps);x.componentDidUpdate(T,p.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var C=l.updateQueue;C!==null&&cM(l,C,x);break;case 3:var L=l.updateQueue;if(L!==null){if(p=null,l.child!==null)switch(l.child.tag){case 5:p=l.child.stateNode;break;case 1:p=l.child.stateNode}cM(l,L,p)}break;case 5:var a=l.stateNode;if(p===null&&l.flags&4){p=a;var F=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":F.autoFocus&&p.focus();break;case"img":F.src&&(p.src=F.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var H=l.alternate;if(H!==null){var ee=H.memoizedState;if(ee!==null){var se=ee.dehydrated;se!==null&&bg(se)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ot(163))}ws||l.flags&512&&rS(l)}catch(ue){xr(l,l.return,ue)}}if(l===s){ui=null;break}if(p=l.sibling,p!==null){p.return=l.return,ui=p;break}ui=l.return}}function IM(s){for(;ui!==null;){var l=ui;if(l===s){ui=null;break}var p=l.sibling;if(p!==null){p.return=l.return,ui=p;break}ui=l.return}}function AM(s){for(;ui!==null;){var l=ui;try{switch(l.tag){case 0:case 11:case 15:var p=l.return;try{Z0(4,l)}catch(F){xr(l,p,F)}break;case 1:var x=l.stateNode;if(typeof x.componentDidMount=="function"){var T=l.return;try{x.componentDidMount()}catch(F){xr(l,T,F)}}var C=l.return;try{rS(l)}catch(F){xr(l,C,F)}break;case 5:var L=l.return;try{rS(l)}catch(F){xr(l,L,F)}}}catch(F){xr(l,l.return,F)}if(l===s){ui=null;break}var a=l.sibling;if(a!==null){a.return=l.return,ui=a;break}ui=l.return}}var RV=Math.ceil,E0=lc.ReactCurrentDispatcher,g2=lc.ReactCurrentOwner,na=lc.ReactCurrentBatchConfig,xn=0,es=null,Or=null,ls=0,wo=0,Xf=bu(0),Hr=0,Dg=null,Kh=0,q0=0,y2=0,lg=null,no=null,x2=0,pp=1/0,Wl=null,I0=!1,aS=null,fu=null,Fv=!1,ou=null,A0=0,cg=0,lS=null,Qv=-1,e0=0;function js(){return xn&6?Pr():Qv!==-1?Qv:Qv=Pr()}function pu(s){return s.mode&1?xn&2&&ls!==0?ls&-ls:pV.transition!==null?(e0===0&&(e0=XD()),e0):(s=Fn,s!==0||(s=window.event,s=s===void 0?16:iL(s.type)),s):1}function Ra(s,l,p,x){if(50<cg)throw cg=0,lS=null,Error(Ot(185));jg(s,p,x),(!(xn&2)||s!==es)&&(s===es&&(!(xn&2)&&(q0|=p),Hr===4&&ru(s,ls)),ao(s,x),p===1&&xn===0&&!(l.mode&1)&&(pp=Pr()+500,G0&&wu()))}function ao(s,l){var p=s.callbackNode;p4(s,l);var x=u0(s,s===es?ls:0);if(x===0)p!==null&&FP(p),s.callbackNode=null,s.callbackPriority=0;else if(l=x&-x,s.callbackPriority!==l){if(p!=null&&FP(p),l===1)s.tag===0?fV(CM.bind(null,s)):bL(CM.bind(null,s)),cV(function(){!(xn&6)&&wu()}),p=null;else{switch(YD(x)){case 1:p=HS;break;case 4:p=qD;break;case 16:p=c0;break;case 536870912:p=WD;break;default:p=c0}p=xz(p,dz.bind(null,s))}s.callbackPriority=l,s.callbackNode=p}}function dz(s,l){if(Qv=-1,e0=0,xn&6)throw Error(Ot(327));var p=s.callbackNode;if(op()&&s.callbackNode!==p)return null;var x=u0(s,s===es?ls:0);if(x===0)return null;if(x&30||x&s.expiredLanes||l)l=C0(s,x);else{l=x;var T=xn;xn|=2;var C=pz();(es!==s||ls!==l)&&(Wl=null,pp=Pr()+500,$h(s,l));do try{zV();break}catch(a){fz(s,a)}while(!0);r2(),E0.current=C,xn=T,Or!==null?l=0:(es=null,ls=0,l=Hr)}if(l!==0){if(l===2&&(T=kT(s),T!==0&&(x=T,l=cS(s,T))),l===1)throw p=Dg,$h(s,0),ru(s,x),ao(s,Pr()),p;if(l===6)ru(s,x);else{if(T=s.current.alternate,!(x&30)&&!DV(T)&&(l=C0(s,x),l===2&&(C=kT(s),C!==0&&(x=C,l=cS(s,C))),l===1))throw p=Dg,$h(s,0),ru(s,x),ao(s,Pr()),p;switch(s.finishedWork=T,s.finishedLanes=x,l){case 0:case 1:throw Error(Ot(345));case 2:Oh(s,no,Wl);break;case 3:if(ru(s,x),(x&130023424)===x&&(l=x2+500-Pr(),10<l)){if(u0(s,0)!==0)break;if(T=s.suspendedLanes,(T&x)!==x){js(),s.pingedLanes|=s.suspendedLanes&T;break}s.timeoutHandle=GT(Oh.bind(null,s,no,Wl),l);break}Oh(s,no,Wl);break;case 4:if(ru(s,x),(x&4194240)===x)break;for(l=s.eventTimes,T=-1;0<x;){var L=31-Ma(x);C=1<<L,L=l[L],L>T&&(T=L),x&=~C}if(x=T,x=Pr()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*RV(x/1960))-x,10<x){s.timeoutHandle=GT(Oh.bind(null,s,no,Wl),x);break}Oh(s,no,Wl);break;case 5:Oh(s,no,Wl);break;default:throw Error(Ot(329))}}}return ao(s,Pr()),s.callbackNode===p?dz.bind(null,s):null}function cS(s,l){var p=lg;return s.current.memoizedState.isDehydrated&&($h(s,l).flags|=256),s=C0(s,l),s!==2&&(l=no,no=p,l!==null&&uS(l)),s}function uS(s){no===null?no=s:no.push.apply(no,s)}function DV(s){for(var l=s;;){if(l.flags&16384){var p=l.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var x=0;x<p.length;x++){var T=p[x],C=T.getSnapshot;T=T.value;try{if(!Da(C(),T))return!1}catch{return!1}}}if(p=l.child,l.subtreeFlags&16384&&p!==null)p.return=l,l=p;else{if(l===s)break;for(;l.sibling===null;){if(l.return===null||l.return===s)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function ru(s,l){for(l&=~y2,l&=~q0,s.suspendedLanes|=l,s.pingedLanes&=~l,s=s.expirationTimes;0<l;){var p=31-Ma(l),x=1<<p;s[p]=-1,l&=~x}}function CM(s){if(xn&6)throw Error(Ot(327));op();var l=u0(s,0);if(!(l&1))return ao(s,Pr()),null;var p=C0(s,l);if(s.tag!==0&&p===2){var x=kT(s);x!==0&&(l=x,p=cS(s,x))}if(p===1)throw p=Dg,$h(s,0),ru(s,l),ao(s,Pr()),p;if(p===6)throw Error(Ot(345));return s.finishedWork=s.current.alternate,s.finishedLanes=l,Oh(s,no,Wl),ao(s,Pr()),null}function v2(s,l){var p=xn;xn|=1;try{return s(l)}finally{xn=p,xn===0&&(pp=Pr()+500,G0&&wu())}}function Jh(s){ou!==null&&ou.tag===0&&!(xn&6)&&op();var l=xn;xn|=1;var p=na.transition,x=Fn;try{if(na.transition=null,Fn=1,s)return s()}finally{Fn=x,na.transition=p,xn=l,!(xn&6)&&wu()}}function b2(){wo=Xf.current,er(Xf)}function $h(s,l){s.finishedWork=null,s.finishedLanes=0;var p=s.timeoutHandle;if(p!==-1&&(s.timeoutHandle=-1,lV(p)),Or!==null)for(p=Or.return;p!==null;){var x=p;switch(t2(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&m0();break;case 3:dp(),er(so),er(Ss),u2();break;case 5:c2(x);break;case 4:dp();break;case 13:er(dr);break;case 19:er(dr);break;case 10:s2(x.type._context);break;case 22:case 23:b2()}p=p.return}if(es=s,Or=s=mu(s.current,null),ls=wo=l,Hr=0,Dg=null,y2=q0=Kh=0,no=lg=null,Uh!==null){for(l=0;l<Uh.length;l++)if(p=Uh[l],x=p.interleaved,x!==null){p.interleaved=null;var T=x.next,C=p.pending;if(C!==null){var L=C.next;C.next=T,x.next=L}p.pending=x}Uh=null}return s}function fz(s,l){do{var p=Or;try{if(r2(),Yv.current=S0,T0){for(var x=pr.memoizedState;x!==null;){var T=x.queue;T!==null&&(T.pending=null),x=x.next}T0=!1}if(Yh=0,Qr=$r=pr=null,og=!1,Pg=0,g2.current=null,p===null||p.return===null){Hr=1,Dg=l,Or=null;break}e:{var C=s,L=p.return,a=p,F=l;if(l=ls,a.flags|=32768,F!==null&&typeof F=="object"&&typeof F.then=="function"){var H=F,ee=a,se=ee.tag;if(!(ee.mode&1)&&(se===0||se===11||se===15)){var ue=ee.alternate;ue?(ee.updateQueue=ue.updateQueue,ee.memoizedState=ue.memoizedState,ee.lanes=ue.lanes):(ee.updateQueue=null,ee.memoizedState=null)}var Me=mM(L);if(Me!==null){Me.flags&=-257,_M(Me,L,a,C,l),Me.mode&1&&pM(C,H,l),l=Me,F=H;var Ve=l.updateQueue;if(Ve===null){var ke=new Set;ke.add(F),l.updateQueue=ke}else Ve.add(F);break e}else{if(!(l&1)){pM(C,H,l),w2();break e}F=Error(Ot(426))}}else if(or&&a.mode&1){var Ye=mM(L);if(Ye!==null){!(Ye.flags&65536)&&(Ye.flags|=256),_M(Ye,L,a,C,l),i2(fp(F,a));break e}}C=F=fp(F,a),Hr!==4&&(Hr=2),lg===null?lg=[C]:lg.push(C),C=L;do{switch(C.tag){case 3:C.flags|=65536,l&=-l,C.lanes|=l;var Se=YL(C,F,l);lM(C,Se);break e;case 1:a=F;var ye=C.type,Ie=C.stateNode;if(!(C.flags&128)&&(typeof ye.getDerivedStateFromError=="function"||Ie!==null&&typeof Ie.componentDidCatch=="function"&&(fu===null||!fu.has(Ie)))){C.flags|=65536,l&=-l,C.lanes|=l;var qe=KL(C,a,l);lM(C,qe);break e}}C=C.return}while(C!==null)}_z(p)}catch(ot){l=ot,Or===p&&p!==null&&(Or=p=p.return);continue}break}while(!0)}function pz(){var s=E0.current;return E0.current=S0,s===null?S0:s}function w2(){(Hr===0||Hr===3||Hr===2)&&(Hr=4),es===null||!(Kh&268435455)&&!(q0&268435455)||ru(es,ls)}function C0(s,l){var p=xn;xn|=2;var x=pz();(es!==s||ls!==l)&&(Wl=null,$h(s,l));do try{LV();break}catch(T){fz(s,T)}while(!0);if(r2(),xn=p,E0.current=x,Or!==null)throw Error(Ot(261));return es=null,ls=0,Hr}function LV(){for(;Or!==null;)mz(Or)}function zV(){for(;Or!==null&&!s4();)mz(Or)}function mz(s){var l=yz(s.alternate,s,wo);s.memoizedProps=s.pendingProps,l===null?_z(s):Or=l,g2.current=null}function _z(s){var l=s;do{var p=l.alternate;if(s=l.return,l.flags&32768){if(p=AV(p,l),p!==null){p.flags&=32767,Or=p;return}if(s!==null)s.flags|=32768,s.subtreeFlags=0,s.deletions=null;else{Hr=6,Or=null;return}}else if(p=IV(p,l,wo),p!==null){Or=p;return}if(l=l.sibling,l!==null){Or=l;return}Or=l=s}while(l!==null);Hr===0&&(Hr=5)}function Oh(s,l,p){var x=Fn,T=na.transition;try{na.transition=null,Fn=1,kV(s,l,p,x)}finally{na.transition=T,Fn=x}return null}function kV(s,l,p,x){do op();while(ou!==null);if(xn&6)throw Error(Ot(327));p=s.finishedWork;var T=s.finishedLanes;if(p===null)return null;if(s.finishedWork=null,s.finishedLanes=0,p===s.current)throw Error(Ot(177));s.callbackNode=null,s.callbackPriority=0;var C=p.lanes|p.childLanes;if(m4(s,C),s===es&&(Or=es=null,ls=0),!(p.subtreeFlags&2064)&&!(p.flags&2064)||Fv||(Fv=!0,xz(c0,function(){return op(),null})),C=(p.flags&15990)!==0,p.subtreeFlags&15990||C){C=na.transition,na.transition=null;var L=Fn;Fn=1;var a=xn;xn|=4,g2.current=null,PV(s,p),uz(p,s),tV(UT),h0=!!VT,UT=VT=null,s.current=p,MV(p),o4(),xn=a,Fn=L,na.transition=C}else s.current=p;if(Fv&&(Fv=!1,ou=s,A0=T),C=s.pendingLanes,C===0&&(fu=null),c4(p.stateNode),ao(s,Pr()),l!==null)for(x=s.onRecoverableError,p=0;p<l.length;p++)T=l[p],x(T.value,{componentStack:T.stack,digest:T.digest});if(I0)throw I0=!1,s=aS,aS=null,s;return A0&1&&s.tag!==0&&op(),C=s.pendingLanes,C&1?s===lS?cg++:(cg=0,lS=s):cg=0,wu(),null}function op(){if(ou!==null){var s=YD(A0),l=na.transition,p=Fn;try{if(na.transition=null,Fn=16>s?16:s,ou===null)var x=!1;else{if(s=ou,ou=null,A0=0,xn&6)throw Error(Ot(331));var T=xn;for(xn|=4,ui=s.current;ui!==null;){var C=ui,L=C.child;if(ui.flags&16){var a=C.deletions;if(a!==null){for(var F=0;F<a.length;F++){var H=a[F];for(ui=H;ui!==null;){var ee=ui;switch(ee.tag){case 0:case 11:case 15:ag(8,ee,C)}var se=ee.child;if(se!==null)se.return=ee,ui=se;else for(;ui!==null;){ee=ui;var ue=ee.sibling,Me=ee.return;if(az(ee),ee===H){ui=null;break}if(ue!==null){ue.return=Me,ui=ue;break}ui=Me}}}var Ve=C.alternate;if(Ve!==null){var ke=Ve.child;if(ke!==null){Ve.child=null;do{var Ye=ke.sibling;ke.sibling=null,ke=Ye}while(ke!==null)}}ui=C}}if(C.subtreeFlags&2064&&L!==null)L.return=C,ui=L;else e:for(;ui!==null;){if(C=ui,C.flags&2048)switch(C.tag){case 0:case 11:case 15:ag(9,C,C.return)}var Se=C.sibling;if(Se!==null){Se.return=C.return,ui=Se;break e}ui=C.return}}var ye=s.current;for(ui=ye;ui!==null;){L=ui;var Ie=L.child;if(L.subtreeFlags&2064&&Ie!==null)Ie.return=L,ui=Ie;else e:for(L=ye;ui!==null;){if(a=ui,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Z0(9,a)}}catch(ot){xr(a,a.return,ot)}if(a===L){ui=null;break e}var qe=a.sibling;if(qe!==null){qe.return=a.return,ui=qe;break e}ui=a.return}}if(xn=T,wu(),ll&&typeof ll.onPostCommitFiberRoot=="function")try{ll.onPostCommitFiberRoot(B0,s)}catch{}x=!0}return x}finally{Fn=p,na.transition=l}}return!1}function PM(s,l,p){l=fp(p,l),l=YL(s,l,1),s=du(s,l,1),l=js(),s!==null&&(jg(s,1,l),ao(s,l))}function xr(s,l,p){if(s.tag===3)PM(s,s,p);else for(;l!==null;){if(l.tag===3){PM(l,s,p);break}else if(l.tag===1){var x=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(fu===null||!fu.has(x))){s=fp(p,s),s=KL(l,s,1),l=du(l,s,1),s=js(),l!==null&&(jg(l,1,s),ao(l,s));break}}l=l.return}}function FV(s,l,p){var x=s.pingCache;x!==null&&x.delete(l),l=js(),s.pingedLanes|=s.suspendedLanes&p,es===s&&(ls&p)===p&&(Hr===4||Hr===3&&(ls&130023424)===ls&&500>Pr()-x2?$h(s,0):y2|=p),ao(s,l)}function gz(s,l){l===0&&(s.mode&1?(l=Iv,Iv<<=1,!(Iv&130023424)&&(Iv=4194304)):l=1);var p=js();s=nc(s,l),s!==null&&(jg(s,l,p),ao(s,p))}function OV(s){var l=s.memoizedState,p=0;l!==null&&(p=l.retryLane),gz(s,p)}function BV(s,l){var p=0;switch(s.tag){case 13:var x=s.stateNode,T=s.memoizedState;T!==null&&(p=T.retryLane);break;case 19:x=s.stateNode;break;default:throw Error(Ot(314))}x!==null&&x.delete(l),gz(s,p)}var yz;yz=function(s,l,p){if(s!==null)if(s.memoizedProps!==l.pendingProps||so.current)ro=!0;else{if(!(s.lanes&p)&&!(l.flags&128))return ro=!1,EV(s,l,p);ro=!!(s.flags&131072)}else ro=!1,or&&l.flags&1048576&&wL(l,y0,l.index);switch(l.lanes=0,l.tag){case 2:var x=l.type;Jv(s,l),s=l.pendingProps;var T=cp(l,Ss.current);sp(l,p),T=d2(null,l,x,s,T,p);var C=f2();return l.flags|=1,typeof T=="object"&&T!==null&&typeof T.render=="function"&&T.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,oo(x)?(C=!0,_0(l)):C=!1,l.memoizedState=T.state!==null&&T.state!==void 0?T.state:null,a2(l),T.updater=H0,l.stateNode=T,T._reactInternals=l,YT(l,x,s,p),l=QT(null,l,x,!0,C,p)):(l.tag=0,or&&C&&e2(l),Us(null,l,T,p),l=l.child),l;case 16:x=l.elementType;e:{switch(Jv(s,l),s=l.pendingProps,T=x._init,x=T(x._payload),l.type=x,T=l.tag=VV(x),s=Aa(x,s),T){case 0:l=JT(null,l,x,s,p);break e;case 1:l=xM(null,l,x,s,p);break e;case 11:l=gM(null,l,x,s,p);break e;case 14:l=yM(null,l,x,Aa(x.type,s),p);break e}throw Error(Ot(306,x,""))}return l;case 0:return x=l.type,T=l.pendingProps,T=l.elementType===x?T:Aa(x,T),JT(s,l,x,T,p);case 1:return x=l.type,T=l.pendingProps,T=l.elementType===x?T:Aa(x,T),xM(s,l,x,T,p);case 3:e:{if(tz(l),s===null)throw Error(Ot(387));x=l.pendingProps,C=l.memoizedState,T=C.element,CL(s,l),b0(l,x,null,p);var L=l.memoizedState;if(x=L.element,C.isDehydrated)if(C={element:x,isDehydrated:!1,cache:L.cache,pendingSuspenseBoundaries:L.pendingSuspenseBoundaries,transitions:L.transitions},l.updateQueue.baseState=C,l.memoizedState=C,l.flags&256){T=fp(Error(Ot(423)),l),l=vM(s,l,x,p,T);break e}else if(x!==T){T=fp(Error(Ot(424)),l),l=vM(s,l,x,p,T);break e}else for(To=hu(l.stateNode.containerInfo.firstChild),So=l,or=!0,Pa=null,p=IL(l,null,x,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(up(),x===T){l=rc(s,l,p);break e}Us(s,l,x,p)}l=l.child}return l;case 5:return PL(l),s===null&&qT(l),x=l.type,T=l.pendingProps,C=s!==null?s.memoizedProps:null,L=T.children,jT(x,T)?L=null:C!==null&&jT(x,C)&&(l.flags|=32),ez(s,l),Us(s,l,L,p),l.child;case 6:return s===null&&qT(l),null;case 13:return iz(s,l,p);case 4:return l2(l,l.stateNode.containerInfo),x=l.pendingProps,s===null?l.child=hp(l,null,x,p):Us(s,l,x,p),l.child;case 11:return x=l.type,T=l.pendingProps,T=l.elementType===x?T:Aa(x,T),gM(s,l,x,T,p);case 7:return Us(s,l,l.pendingProps,p),l.child;case 8:return Us(s,l,l.pendingProps.children,p),l.child;case 12:return Us(s,l,l.pendingProps.children,p),l.child;case 10:e:{if(x=l.type._context,T=l.pendingProps,C=l.memoizedProps,L=T.value,qn(x0,x._currentValue),x._currentValue=L,C!==null)if(Da(C.value,L)){if(C.children===T.children&&!so.current){l=rc(s,l,p);break e}}else for(C=l.child,C!==null&&(C.return=l);C!==null;){var a=C.dependencies;if(a!==null){L=C.child;for(var F=a.firstContext;F!==null;){if(F.context===x){if(C.tag===1){F=Jl(-1,p&-p),F.tag=2;var H=C.updateQueue;if(H!==null){H=H.shared;var ee=H.pending;ee===null?F.next=F:(F.next=ee.next,ee.next=F),H.pending=F}}C.lanes|=p,F=C.alternate,F!==null&&(F.lanes|=p),WT(C.return,p,l),a.lanes|=p;break}F=F.next}}else if(C.tag===10)L=C.type===l.type?null:C.child;else if(C.tag===18){if(L=C.return,L===null)throw Error(Ot(341));L.lanes|=p,a=L.alternate,a!==null&&(a.lanes|=p),WT(L,p,l),L=C.sibling}else L=C.child;if(L!==null)L.return=C;else for(L=C;L!==null;){if(L===l){L=null;break}if(C=L.sibling,C!==null){C.return=L.return,L=C;break}L=L.return}C=L}Us(s,l,T.children,p),l=l.child}return l;case 9:return T=l.type,x=l.pendingProps.children,sp(l,p),T=ra(T),x=x(T),l.flags|=1,Us(s,l,x,p),l.child;case 14:return x=l.type,T=Aa(x,l.pendingProps),T=Aa(x.type,T),yM(s,l,x,T,p);case 15:return JL(s,l,l.type,l.pendingProps,p);case 17:return x=l.type,T=l.pendingProps,T=l.elementType===x?T:Aa(x,T),Jv(s,l),l.tag=1,oo(x)?(s=!0,_0(l)):s=!1,sp(l,p),XL(l,x,T),YT(l,x,T,p),QT(null,l,x,!0,s,p);case 19:return nz(s,l,p);case 22:return QL(s,l,p)}throw Error(Ot(156,l.tag))};function xz(s,l){return ZD(s,l)}function NV(s,l,p,x){this.tag=s,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ia(s,l,p,x){return new NV(s,l,p,x)}function T2(s){return s=s.prototype,!(!s||!s.isReactComponent)}function VV(s){if(typeof s=="function")return T2(s)?1:0;if(s!=null){if(s=s.$$typeof,s===jS)return 11;if(s===GS)return 14}return 2}function mu(s,l){var p=s.alternate;return p===null?(p=ia(s.tag,l,s.key,s.mode),p.elementType=s.elementType,p.type=s.type,p.stateNode=s.stateNode,p.alternate=s,s.alternate=p):(p.pendingProps=l,p.type=s.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=s.flags&14680064,p.childLanes=s.childLanes,p.lanes=s.lanes,p.child=s.child,p.memoizedProps=s.memoizedProps,p.memoizedState=s.memoizedState,p.updateQueue=s.updateQueue,l=s.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=s.sibling,p.index=s.index,p.ref=s.ref,p}function t0(s,l,p,x,T,C){var L=2;if(x=s,typeof s=="function")T2(s)&&(L=1);else if(typeof s=="string")L=5;else e:switch(s){case Nf:return Hh(p.children,T,C,l);case US:L=8,T|=8;break;case vT:return s=ia(12,p,l,T|2),s.elementType=vT,s.lanes=C,s;case bT:return s=ia(13,p,l,T),s.elementType=bT,s.lanes=C,s;case wT:return s=ia(19,p,l,T),s.elementType=wT,s.lanes=C,s;case PD:return W0(p,T,C,l);default:if(typeof s=="object"&&s!==null)switch(s.$$typeof){case AD:L=10;break e;case CD:L=9;break e;case jS:L=11;break e;case GS:L=14;break e;case tu:L=16,x=null;break e}throw Error(Ot(130,s==null?s:typeof s,""))}return l=ia(L,p,l,T),l.elementType=s,l.type=x,l.lanes=C,l}function Hh(s,l,p,x){return s=ia(7,s,x,l),s.lanes=p,s}function W0(s,l,p,x){return s=ia(22,s,x,l),s.elementType=PD,s.lanes=p,s.stateNode={isHidden:!1},s}function Ww(s,l,p){return s=ia(6,s,null,l),s.lanes=p,s}function Xw(s,l,p){return l=ia(4,s.children!==null?s.children:[],s.key,l),l.lanes=p,l.stateNode={containerInfo:s.containerInfo,pendingChildren:null,implementation:s.implementation},l}function UV(s,l,p,x,T){this.tag=l,this.containerInfo=s,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pw(0),this.expirationTimes=Pw(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pw(0),this.identifierPrefix=x,this.onRecoverableError=T,this.mutableSourceEagerHydrationData=null}function S2(s,l,p,x,T,C,L,a,F){return s=new UV(s,l,p,a,F),l===1?(l=1,C===!0&&(l|=8)):l=0,C=ia(3,null,null,l),s.current=C,C.stateNode=s,C.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},a2(C),s}function jV(s,l,p){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Bf,key:x==null?null:""+x,children:s,containerInfo:l,implementation:p}}function vz(s){if(!s)return gu;s=s._reactInternals;e:{if(ed(s)!==s||s.tag!==1)throw Error(Ot(170));var l=s;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(oo(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(Ot(171))}if(s.tag===1){var p=s.type;if(oo(p))return vL(s,p,l)}return l}function bz(s,l,p,x,T,C,L,a,F){return s=S2(p,x,!0,s,T,C,L,a,F),s.context=vz(null),p=s.current,x=js(),T=pu(p),C=Jl(x,T),C.callback=l??null,du(p,C,T),s.current.lanes=T,jg(s,T,x),ao(s,x),s}function X0(s,l,p,x){var T=l.current,C=js(),L=pu(T);return p=vz(p),l.context===null?l.context=p:l.pendingContext=p,l=Jl(C,L),l.payload={element:s},x=x===void 0?null:x,x!==null&&(l.callback=x),s=du(T,l,L),s!==null&&(Ra(s,T,L,C),Xv(s,T,L)),L}function P0(s){if(s=s.current,!s.child)return null;switch(s.child.tag){case 5:return s.child.stateNode;default:return s.child.stateNode}}function MM(s,l){if(s=s.memoizedState,s!==null&&s.dehydrated!==null){var p=s.retryLane;s.retryLane=p!==0&&p<l?p:l}}function E2(s,l){MM(s,l),(s=s.alternate)&&MM(s,l)}function GV(){return null}var wz=typeof reportError=="function"?reportError:function(s){console.error(s)};function I2(s){this._internalRoot=s}Y0.prototype.render=I2.prototype.render=function(s){var l=this._internalRoot;if(l===null)throw Error(Ot(409));X0(s,l,null,null)};Y0.prototype.unmount=I2.prototype.unmount=function(){var s=this._internalRoot;if(s!==null){this._internalRoot=null;var l=s.containerInfo;Jh(function(){X0(null,s,null,null)}),l[ic]=null}};function Y0(s){this._internalRoot=s}Y0.prototype.unstable_scheduleHydration=function(s){if(s){var l=QD();s={blockedOn:null,target:s,priority:l};for(var p=0;p<nu.length&&l!==0&&l<nu[p].priority;p++);nu.splice(p,0,s),p===0&&tL(s)}};function A2(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11)}function K0(s){return!(!s||s.nodeType!==1&&s.nodeType!==9&&s.nodeType!==11&&(s.nodeType!==8||s.nodeValue!==" react-mount-point-unstable "))}function RM(){}function $V(s,l,p,x,T){if(T){if(typeof x=="function"){var C=x;x=function(){var H=P0(L);C.call(H)}}var L=bz(l,x,s,0,null,!1,!1,"",RM);return s._reactRootContainer=L,s[ic]=L.current,Sg(s.nodeType===8?s.parentNode:s),Jh(),L}for(;T=s.lastChild;)s.removeChild(T);if(typeof x=="function"){var a=x;x=function(){var H=P0(F);a.call(H)}}var F=S2(s,0,!1,null,null,!1,!1,"",RM);return s._reactRootContainer=F,s[ic]=F.current,Sg(s.nodeType===8?s.parentNode:s),Jh(function(){X0(l,F,p,x)}),F}function J0(s,l,p,x,T){var C=p._reactRootContainer;if(C){var L=C;if(typeof T=="function"){var a=T;T=function(){var F=P0(L);a.call(F)}}X0(l,L,s,T)}else L=$V(p,l,s,T,x);return P0(L)}KD=function(s){switch(s.tag){case 3:var l=s.stateNode;if(l.current.memoizedState.isDehydrated){var p=Y_(l.pendingLanes);p!==0&&(ZS(l,p|1),ao(l,Pr()),!(xn&6)&&(pp=Pr()+500,wu()))}break;case 13:Jh(function(){var x=nc(s,1);if(x!==null){var T=js();Ra(x,s,1,T)}}),E2(s,1)}};qS=function(s){if(s.tag===13){var l=nc(s,134217728);if(l!==null){var p=js();Ra(l,s,134217728,p)}E2(s,134217728)}};JD=function(s){if(s.tag===13){var l=pu(s),p=nc(s,l);if(p!==null){var x=js();Ra(p,s,l,x)}E2(s,l)}};QD=function(){return Fn};eL=function(s,l){var p=Fn;try{return Fn=s,l()}finally{Fn=p}};DT=function(s,l,p){switch(l){case"input":if(ET(s,p),l=p.name,p.type==="radio"&&l!=null){for(p=s;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<p.length;l++){var x=p[l];if(x!==s&&x.form===s.form){var T=j0(x);if(!T)throw Error(Ot(90));RD(x),ET(x,T)}}}break;case"textarea":LD(s,p);break;case"select":l=p.value,l!=null&&tp(s,!!p.multiple,l,!1)}};VD=v2;UD=Jh;var HV={usingClientEntryPoint:!1,Events:[$g,Gf,j0,BD,ND,v2]},Z_={findFiberByHostInstance:Vh,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ZV={bundleType:Z_.bundleType,version:Z_.version,rendererPackageName:Z_.rendererPackageName,rendererConfig:Z_.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:lc.ReactCurrentDispatcher,findHostInstanceByFiber:function(s){return s=$D(s),s===null?null:s.stateNode},findFiberByHostInstance:Z_.findFiberByHostInstance||GV,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ov=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ov.isDisabled&&Ov.supportsFiber)try{B0=Ov.inject(ZV),ll=Ov}catch{}}Co.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=HV;Co.createPortal=function(s,l){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!A2(l))throw Error(Ot(200));return jV(s,l,null,p)};Co.createRoot=function(s,l){if(!A2(s))throw Error(Ot(299));var p=!1,x="",T=wz;return l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(x=l.identifierPrefix),l.onRecoverableError!==void 0&&(T=l.onRecoverableError)),l=S2(s,1,!1,null,null,p,!1,x,T),s[ic]=l.current,Sg(s.nodeType===8?s.parentNode:s),new I2(l)};Co.findDOMNode=function(s){if(s==null)return null;if(s.nodeType===1)return s;var l=s._reactInternals;if(l===void 0)throw typeof s.render=="function"?Error(Ot(188)):(s=Object.keys(s).join(","),Error(Ot(268,s)));return s=$D(l),s=s===null?null:s.stateNode,s};Co.flushSync=function(s){return Jh(s)};Co.hydrate=function(s,l,p){if(!K0(l))throw Error(Ot(200));return J0(null,s,l,!0,p)};Co.hydrateRoot=function(s,l,p){if(!A2(s))throw Error(Ot(405));var x=p!=null&&p.hydratedSources||null,T=!1,C="",L=wz;if(p!=null&&(p.unstable_strictMode===!0&&(T=!0),p.identifierPrefix!==void 0&&(C=p.identifierPrefix),p.onRecoverableError!==void 0&&(L=p.onRecoverableError)),l=bz(l,null,s,1,p??null,T,!1,C,L),s[ic]=l.current,Sg(s),x)for(s=0;s<x.length;s++)p=x[s],T=p._getVersion,T=T(p._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[p,T]:l.mutableSourceEagerHydrationData.push(p,T);return new Y0(l)};Co.render=function(s,l,p){if(!K0(l))throw Error(Ot(200));return J0(null,s,l,!1,p)};Co.unmountComponentAtNode=function(s){if(!K0(s))throw Error(Ot(40));return s._reactRootContainer?(Jh(function(){J0(null,null,s,!1,function(){s._reactRootContainer=null,s[ic]=null})}),!0):!1};Co.unstable_batchedUpdates=v2;Co.unstable_renderSubtreeIntoContainer=function(s,l,p,x){if(!K0(p))throw Error(Ot(200));if(s==null||s._reactInternals===void 0)throw Error(Ot(38));return J0(s,l,p,!1,x)};Co.version="18.3.1-next-f1338f8080-20240426";function Tz(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Tz)}catch(s){console.error(s)}}Tz(),TD.exports=Co;var qV=TD.exports,DM=qV;yT.createRoot=DM.createRoot,yT.hydrateRoot=DM.hydrateRoot;/**
 * @remix-run/router v1.23.2
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */function Lg(){return Lg=Object.assign?Object.assign.bind():function(s){for(var l=1;l<arguments.length;l++){var p=arguments[l];for(var x in p)Object.prototype.hasOwnProperty.call(p,x)&&(s[x]=p[x])}return s},Lg.apply(this,arguments)}var au;(function(s){s.Pop="POP",s.Push="PUSH",s.Replace="REPLACE"})(au||(au={}));const LM="popstate";function WV(s){s===void 0&&(s={});function l(x,T){let{pathname:C,search:L,hash:a}=x.location;return hS("",{pathname:C,search:L,hash:a},T.state&&T.state.usr||null,T.state&&T.state.key||"default")}function p(x,T){return typeof T=="string"?T:Sz(T)}return YV(l,p,null,s)}function Br(s,l){if(s===!1||s===null||typeof s>"u")throw new Error(l)}function C2(s,l){if(!s){typeof console<"u"&&console.warn(l);try{throw new Error(l)}catch{}}}function XV(){return Math.random().toString(36).substr(2,8)}function zM(s,l){return{usr:s.state,key:s.key,idx:l}}function hS(s,l,p,x){return p===void 0&&(p=null),Lg({pathname:typeof s=="string"?s:s.pathname,search:"",hash:""},typeof l=="string"?Tp(l):l,{state:p,key:l&&l.key||x||XV()})}function Sz(s){let{pathname:l="/",search:p="",hash:x=""}=s;return p&&p!=="?"&&(l+=p.charAt(0)==="?"?p:"?"+p),x&&x!=="#"&&(l+=x.charAt(0)==="#"?x:"#"+x),l}function Tp(s){let l={};if(s){let p=s.indexOf("#");p>=0&&(l.hash=s.substr(p),s=s.substr(0,p));let x=s.indexOf("?");x>=0&&(l.search=s.substr(x),s=s.substr(0,x)),s&&(l.pathname=s)}return l}function YV(s,l,p,x){x===void 0&&(x={});let{window:T=document.defaultView,v5Compat:C=!1}=x,L=T.history,a=au.Pop,F=null,H=ee();H==null&&(H=0,L.replaceState(Lg({},L.state,{idx:H}),""));function ee(){return(L.state||{idx:null}).idx}function se(){a=au.Pop;let Ye=ee(),Se=Ye==null?null:Ye-H;H=Ye,F&&F({action:a,location:ke.location,delta:Se})}function ue(Ye,Se){a=au.Push;let ye=hS(ke.location,Ye,Se);H=ee()+1;let Ie=zM(ye,H),qe=ke.createHref(ye);try{L.pushState(Ie,"",qe)}catch(ot){if(ot instanceof DOMException&&ot.name==="DataCloneError")throw ot;T.location.assign(qe)}C&&F&&F({action:a,location:ke.location,delta:1})}function Me(Ye,Se){a=au.Replace;let ye=hS(ke.location,Ye,Se);H=ee();let Ie=zM(ye,H),qe=ke.createHref(ye);L.replaceState(Ie,"",qe),C&&F&&F({action:a,location:ke.location,delta:0})}function Ve(Ye){let Se=T.location.origin!=="null"?T.location.origin:T.location.href,ye=typeof Ye=="string"?Ye:Sz(Ye);return ye=ye.replace(/ $/,"%20"),Br(Se,"No window.location.(origin|href) available to create URL for href: "+ye),new URL(ye,Se)}let ke={get action(){return a},get location(){return s(T,L)},listen(Ye){if(F)throw new Error("A history only accepts one active listener");return T.addEventListener(LM,se),F=Ye,()=>{T.removeEventListener(LM,se),F=null}},createHref(Ye){return l(T,Ye)},createURL:Ve,encodeLocation(Ye){let Se=Ve(Ye);return{pathname:Se.pathname,search:Se.search,hash:Se.hash}},push:ue,replace:Me,go(Ye){return L.go(Ye)}};return ke}var kM;(function(s){s.data="data",s.deferred="deferred",s.redirect="redirect",s.error="error"})(kM||(kM={}));function KV(s,l,p){return p===void 0&&(p="/"),JV(s,l,p)}function JV(s,l,p,x){let T=typeof l=="string"?Tp(l):l,C=Az(T.pathname||"/",p);if(C==null)return null;let L=Ez(s);QV(L);let a=null;for(let F=0;a==null&&F<L.length;++F){let H=h5(C);a=l5(L[F],H)}return a}function Ez(s,l,p,x){l===void 0&&(l=[]),p===void 0&&(p=[]),x===void 0&&(x="");let T=(C,L,a)=>{let F={relativePath:a===void 0?C.path||"":a,caseSensitive:C.caseSensitive===!0,childrenIndex:L,route:C};F.relativePath.startsWith("/")&&(Br(F.relativePath.startsWith(x),'Absolute route path "'+F.relativePath+'" nested under path '+('"'+x+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),F.relativePath=F.relativePath.slice(x.length));let H=Zh([x,F.relativePath]),ee=p.concat(F);C.children&&C.children.length>0&&(Br(C.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+H+'".')),Ez(C.children,l,ee,H)),!(C.path==null&&!C.index)&&l.push({path:H,score:o5(H,C.index),routesMeta:ee})};return s.forEach((C,L)=>{var a;if(C.path===""||!((a=C.path)!=null&&a.includes("?")))T(C,L);else for(let F of Iz(C.path))T(C,L,F)}),l}function Iz(s){let l=s.split("/");if(l.length===0)return[];let[p,...x]=l,T=p.endsWith("?"),C=p.replace(/\?$/,"");if(x.length===0)return T?[C,""]:[C];let L=Iz(x.join("/")),a=[];return a.push(...L.map(F=>F===""?C:[C,F].join("/"))),T&&a.push(...L),a.map(F=>s.startsWith("/")&&F===""?"/":F)}function QV(s){s.sort((l,p)=>l.score!==p.score?p.score-l.score:a5(l.routesMeta.map(x=>x.childrenIndex),p.routesMeta.map(x=>x.childrenIndex)))}const e5=/^:[\w-]+$/,t5=3,i5=2,n5=1,r5=10,s5=-2,FM=s=>s==="*";function o5(s,l){let p=s.split("/"),x=p.length;return p.some(FM)&&(x+=s5),l&&(x+=i5),p.filter(T=>!FM(T)).reduce((T,C)=>T+(e5.test(C)?t5:C===""?n5:r5),x)}function a5(s,l){return s.length===l.length&&s.slice(0,-1).every((x,T)=>x===l[T])?s[s.length-1]-l[l.length-1]:0}function l5(s,l,p){let{routesMeta:x}=s,T={},C="/",L=[];for(let a=0;a<x.length;++a){let F=x[a],H=a===x.length-1,ee=C==="/"?l:l.slice(C.length)||"/",se=c5({path:F.relativePath,caseSensitive:F.caseSensitive,end:H},ee),ue=F.route;if(!se)return null;Object.assign(T,se.params),L.push({params:T,pathname:Zh([C,se.pathname]),pathnameBase:_5(Zh([C,se.pathnameBase])),route:ue}),se.pathnameBase!=="/"&&(C=Zh([C,se.pathnameBase]))}return L}function c5(s,l){typeof s=="string"&&(s={path:s,caseSensitive:!1,end:!0});let[p,x]=u5(s.path,s.caseSensitive,s.end),T=l.match(p);if(!T)return null;let C=T[0],L=C.replace(/(.)\/+$/,"$1"),a=T.slice(1);return{params:x.reduce((H,ee,se)=>{let{paramName:ue,isOptional:Me}=ee;if(ue==="*"){let ke=a[se]||"";L=C.slice(0,C.length-ke.length).replace(/(.)\/+$/,"$1")}const Ve=a[se];return Me&&!Ve?H[ue]=void 0:H[ue]=(Ve||"").replace(/%2F/g,"/"),H},{}),pathname:C,pathnameBase:L,pattern:s}}function u5(s,l,p){l===void 0&&(l=!1),p===void 0&&(p=!0),C2(s==="*"||!s.endsWith("*")||s.endsWith("/*"),'Route path "'+s+'" will be treated as if it were '+('"'+s.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+s.replace(/\*$/,"/*")+'".'));let x=[],T="^"+s.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(L,a,F)=>(x.push({paramName:a,isOptional:F!=null}),F?"/?([^\\/]+)?":"/([^\\/]+)"));return s.endsWith("*")?(x.push({paramName:"*"}),T+=s==="*"||s==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):p?T+="\\/*$":s!==""&&s!=="/"&&(T+="(?:(?=\\/|$))"),[new RegExp(T,l?void 0:"i"),x]}function h5(s){try{return s.split("/").map(l=>decodeURIComponent(l).replace(/\//g,"%2F")).join("/")}catch(l){return C2(!1,'The URL path "'+s+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+l+").")),s}}function Az(s,l){if(l==="/")return s;if(!s.toLowerCase().startsWith(l.toLowerCase()))return null;let p=l.endsWith("/")?l.length-1:l.length,x=s.charAt(p);return x&&x!=="/"?null:s.slice(p)||"/"}const d5=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,f5=s=>d5.test(s);function p5(s,l){l===void 0&&(l="/");let{pathname:p,search:x="",hash:T=""}=typeof s=="string"?Tp(s):s,C;if(p)if(f5(p))C=p;else{if(p.includes("//")){let L=p;p=p.replace(/\/\/+/g,"/"),C2(!1,"Pathnames cannot have embedded double slashes - normalizing "+(L+" -> "+p))}p.startsWith("/")?C=OM(p.substring(1),"/"):C=OM(p,l)}else C=l;return{pathname:C,search:g5(x),hash:y5(T)}}function OM(s,l){let p=l.replace(/\/+$/,"").split("/");return s.split("/").forEach(T=>{T===".."?p.length>1&&p.pop():T!=="."&&p.push(T)}),p.length>1?p.join("/"):"/"}function Yw(s,l,p,x){return"Cannot include a '"+s+"' character in a manually specified "+("`to."+l+"` field ["+JSON.stringify(x)+"].  Please separate it out to the ")+("`to."+p+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function m5(s){return s.filter((l,p)=>p===0||l.route.path&&l.route.path.length>0)}function Cz(s,l){let p=m5(s);return l?p.map((x,T)=>T===p.length-1?x.pathname:x.pathnameBase):p.map(x=>x.pathnameBase)}function Pz(s,l,p,x){x===void 0&&(x=!1);let T;typeof s=="string"?T=Tp(s):(T=Lg({},s),Br(!T.pathname||!T.pathname.includes("?"),Yw("?","pathname","search",T)),Br(!T.pathname||!T.pathname.includes("#"),Yw("#","pathname","hash",T)),Br(!T.search||!T.search.includes("#"),Yw("#","search","hash",T)));let C=s===""||T.pathname==="",L=C?"/":T.pathname,a;if(L==null)a=p;else{let se=l.length-1;if(!x&&L.startsWith("..")){let ue=L.split("/");for(;ue[0]==="..";)ue.shift(),se-=1;T.pathname=ue.join("/")}a=se>=0?l[se]:"/"}let F=p5(T,a),H=L&&L!=="/"&&L.endsWith("/"),ee=(C||L===".")&&p.endsWith("/");return!F.pathname.endsWith("/")&&(H||ee)&&(F.pathname+="/"),F}const Zh=s=>s.join("/").replace(/\/\/+/g,"/"),_5=s=>s.replace(/\/+$/,"").replace(/^\/*/,"/"),g5=s=>!s||s==="?"?"":s.startsWith("?")?s:"?"+s,y5=s=>!s||s==="#"?"":s.startsWith("#")?s:"#"+s;function x5(s){return s!=null&&typeof s.status=="number"&&typeof s.statusText=="string"&&typeof s.internal=="boolean"&&"data"in s}const Mz=["post","put","patch","delete"];new Set(Mz);const v5=["get",...Mz];new Set(v5);/**
 * React Router v6.30.3
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */function zg(){return zg=Object.assign?Object.assign.bind():function(s){for(var l=1;l<arguments.length;l++){var p=arguments[l];for(var x in p)Object.prototype.hasOwnProperty.call(p,x)&&(s[x]=p[x])}return s},zg.apply(this,arguments)}const P2=Ge.createContext(null),b5=Ge.createContext(null),Zg=Ge.createContext(null),Q0=Ge.createContext(null),Tu=Ge.createContext({outlet:null,matches:[],isDataRoute:!1}),Rz=Ge.createContext(null);function qg(){return Ge.useContext(Q0)!=null}function e1(){return qg()||Br(!1),Ge.useContext(Q0).location}function Dz(s){Ge.useContext(Zg).static||Ge.useLayoutEffect(s)}function t1(){let{isDataRoute:s}=Ge.useContext(Tu);return s?k5():w5()}function w5(){qg()||Br(!1);let s=Ge.useContext(P2),{basename:l,future:p,navigator:x}=Ge.useContext(Zg),{matches:T}=Ge.useContext(Tu),{pathname:C}=e1(),L=JSON.stringify(Cz(T,p.v7_relativeSplatPath)),a=Ge.useRef(!1);return Dz(()=>{a.current=!0}),Ge.useCallback(function(H,ee){if(ee===void 0&&(ee={}),!a.current)return;if(typeof H=="number"){x.go(H);return}let se=Pz(H,JSON.parse(L),C,ee.relative==="path");s==null&&l!=="/"&&(se.pathname=se.pathname==="/"?l:Zh([l,se.pathname])),(ee.replace?x.replace:x.push)(se,ee.state,ee)},[l,x,L,C,s])}function T5(){let{matches:s}=Ge.useContext(Tu),l=s[s.length-1];return l?l.params:{}}function S5(s,l){return E5(s,l)}function E5(s,l,p,x){qg()||Br(!1);let{navigator:T}=Ge.useContext(Zg),{matches:C}=Ge.useContext(Tu),L=C[C.length-1],a=L?L.params:{};L&&L.pathname;let F=L?L.pathnameBase:"/";L&&L.route;let H=e1(),ee;if(l){var se;let Ye=typeof l=="string"?Tp(l):l;F==="/"||(se=Ye.pathname)!=null&&se.startsWith(F)||Br(!1),ee=Ye}else ee=H;let ue=ee.pathname||"/",Me=ue;if(F!=="/"){let Ye=F.replace(/^\//,"").split("/");Me="/"+ue.replace(/^\//,"").split("/").slice(Ye.length).join("/")}let Ve=KV(s,{pathname:Me}),ke=M5(Ve&&Ve.map(Ye=>Object.assign({},Ye,{params:Object.assign({},a,Ye.params),pathname:Zh([F,T.encodeLocation?T.encodeLocation(Ye.pathname).pathname:Ye.pathname]),pathnameBase:Ye.pathnameBase==="/"?F:Zh([F,T.encodeLocation?T.encodeLocation(Ye.pathnameBase).pathname:Ye.pathnameBase])})),C,p,x);return l&&ke?Ge.createElement(Q0.Provider,{value:{location:zg({pathname:"/",search:"",hash:"",state:null,key:"default"},ee),navigationType:au.Pop}},ke):ke}function I5(){let s=z5(),l=x5(s)?s.status+" "+s.statusText:s instanceof Error?s.message:JSON.stringify(s),p=s instanceof Error?s.stack:null,T={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return Ge.createElement(Ge.Fragment,null,Ge.createElement("h2",null,"Unexpected Application Error!"),Ge.createElement("h3",{style:{fontStyle:"italic"}},l),p?Ge.createElement("pre",{style:T},p):null,null)}const A5=Ge.createElement(I5,null);class C5 extends Ge.Component{constructor(l){super(l),this.state={location:l.location,revalidation:l.revalidation,error:l.error}}static getDerivedStateFromError(l){return{error:l}}static getDerivedStateFromProps(l,p){return p.location!==l.location||p.revalidation!=="idle"&&l.revalidation==="idle"?{error:l.error,location:l.location,revalidation:l.revalidation}:{error:l.error!==void 0?l.error:p.error,location:p.location,revalidation:l.revalidation||p.revalidation}}componentDidCatch(l,p){console.error("React Router caught the following error during render",l,p)}render(){return this.state.error!==void 0?Ge.createElement(Tu.Provider,{value:this.props.routeContext},Ge.createElement(Rz.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function P5(s){let{routeContext:l,match:p,children:x}=s,T=Ge.useContext(P2);return T&&T.static&&T.staticContext&&(p.route.errorElement||p.route.ErrorBoundary)&&(T.staticContext._deepestRenderedBoundaryId=p.route.id),Ge.createElement(Tu.Provider,{value:l},x)}function M5(s,l,p,x){var T;if(l===void 0&&(l=[]),p===void 0&&(p=null),x===void 0&&(x=null),s==null){var C;if(!p)return null;if(p.errors)s=p.matches;else if((C=x)!=null&&C.v7_partialHydration&&l.length===0&&!p.initialized&&p.matches.length>0)s=p.matches;else return null}let L=s,a=(T=p)==null?void 0:T.errors;if(a!=null){let ee=L.findIndex(se=>se.route.id&&(a==null?void 0:a[se.route.id])!==void 0);ee>=0||Br(!1),L=L.slice(0,Math.min(L.length,ee+1))}let F=!1,H=-1;if(p&&x&&x.v7_partialHydration)for(let ee=0;ee<L.length;ee++){let se=L[ee];if((se.route.HydrateFallback||se.route.hydrateFallbackElement)&&(H=ee),se.route.id){let{loaderData:ue,errors:Me}=p,Ve=se.route.loader&&ue[se.route.id]===void 0&&(!Me||Me[se.route.id]===void 0);if(se.route.lazy||Ve){F=!0,H>=0?L=L.slice(0,H+1):L=[L[0]];break}}}return L.reduceRight((ee,se,ue)=>{let Me,Ve=!1,ke=null,Ye=null;p&&(Me=a&&se.route.id?a[se.route.id]:void 0,ke=se.route.errorElement||A5,F&&(H<0&&ue===0?(F5("route-fallback"),Ve=!0,Ye=null):H===ue&&(Ve=!0,Ye=se.route.hydrateFallbackElement||null)));let Se=l.concat(L.slice(0,ue+1)),ye=()=>{let Ie;return Me?Ie=ke:Ve?Ie=Ye:se.route.Component?Ie=Ge.createElement(se.route.Component,null):se.route.element?Ie=se.route.element:Ie=ee,Ge.createElement(P5,{match:se,routeContext:{outlet:ee,matches:Se,isDataRoute:p!=null},children:Ie})};return p&&(se.route.ErrorBoundary||se.route.errorElement||ue===0)?Ge.createElement(C5,{location:p.location,revalidation:p.revalidation,component:ke,error:Me,children:ye(),routeContext:{outlet:null,matches:Se,isDataRoute:!0}}):ye()},null)}var Lz=function(s){return s.UseBlocker="useBlocker",s.UseRevalidator="useRevalidator",s.UseNavigateStable="useNavigate",s}(Lz||{}),zz=function(s){return s.UseBlocker="useBlocker",s.UseLoaderData="useLoaderData",s.UseActionData="useActionData",s.UseRouteError="useRouteError",s.UseNavigation="useNavigation",s.UseRouteLoaderData="useRouteLoaderData",s.UseMatches="useMatches",s.UseRevalidator="useRevalidator",s.UseNavigateStable="useNavigate",s.UseRouteId="useRouteId",s}(zz||{});function R5(s){let l=Ge.useContext(P2);return l||Br(!1),l}function D5(s){let l=Ge.useContext(b5);return l||Br(!1),l}function L5(s){let l=Ge.useContext(Tu);return l||Br(!1),l}function kz(s){let l=L5(),p=l.matches[l.matches.length-1];return p.route.id||Br(!1),p.route.id}function z5(){var s;let l=Ge.useContext(Rz),p=D5(),x=kz();return l!==void 0?l:(s=p.errors)==null?void 0:s[x]}function k5(){let{router:s}=R5(Lz.UseNavigateStable),l=kz(zz.UseNavigateStable),p=Ge.useRef(!1);return Dz(()=>{p.current=!0}),Ge.useCallback(function(T,C){C===void 0&&(C={}),p.current&&(typeof T=="number"?s.navigate(T):s.navigate(T,zg({fromRouteId:l},C)))},[s,l])}const BM={};function F5(s,l,p){BM[s]||(BM[s]=!0)}function O5(s,l){s==null||s.v7_startTransition,s==null||s.v7_relativeSplatPath}function ug(s){let{to:l,replace:p,state:x,relative:T}=s;qg()||Br(!1);let{future:C,static:L}=Ge.useContext(Zg),{matches:a}=Ge.useContext(Tu),{pathname:F}=e1(),H=t1(),ee=Pz(l,Cz(a,C.v7_relativeSplatPath),F,T==="path"),se=JSON.stringify(ee);return Ge.useEffect(()=>H(JSON.parse(se),{replace:p,state:x,relative:T}),[H,se,T,p,x]),null}function sl(s){Br(!1)}function B5(s){let{basename:l="/",children:p=null,location:x,navigationType:T=au.Pop,navigator:C,static:L=!1,future:a}=s;qg()&&Br(!1);let F=l.replace(/^\/*/,"/"),H=Ge.useMemo(()=>({basename:F,navigator:C,static:L,future:zg({v7_relativeSplatPath:!1},a)}),[F,a,C,L]);typeof x=="string"&&(x=Tp(x));let{pathname:ee="/",search:se="",hash:ue="",state:Me=null,key:Ve="default"}=x,ke=Ge.useMemo(()=>{let Ye=Az(ee,F);return Ye==null?null:{location:{pathname:Ye,search:se,hash:ue,state:Me,key:Ve},navigationType:T}},[F,ee,se,ue,Me,Ve,T]);return ke==null?null:Ge.createElement(Zg.Provider,{value:H},Ge.createElement(Q0.Provider,{children:p,value:ke}))}function N5(s){let{children:l,location:p}=s;return S5(dS(l),p)}new Promise(()=>{});function dS(s,l){l===void 0&&(l=[]);let p=[];return Ge.Children.forEach(s,(x,T)=>{if(!Ge.isValidElement(x))return;let C=[...l,T];if(x.type===Ge.Fragment){p.push.apply(p,dS(x.props.children,C));return}x.type!==sl&&Br(!1),!x.props.index||!x.props.children||Br(!1);let L={id:x.props.id||C.join("-"),caseSensitive:x.props.caseSensitive,element:x.props.element,Component:x.props.Component,index:x.props.index,path:x.props.path,loader:x.props.loader,action:x.props.action,errorElement:x.props.errorElement,ErrorBoundary:x.props.ErrorBoundary,hasErrorBoundary:x.props.ErrorBoundary!=null||x.props.errorElement!=null,shouldRevalidate:x.props.shouldRevalidate,handle:x.props.handle,lazy:x.props.lazy};x.props.children&&(L.children=dS(x.props.children,C)),p.push(L)}),p}/**
 * React Router DOM v6.30.3
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */const V5="6";try{window.__reactRouterVersion=V5}catch{}const U5="startTransition",NM=FN[U5];function j5(s){let{basename:l,children:p,future:x,window:T}=s,C=Ge.useRef();C.current==null&&(C.current=WV({window:T,v5Compat:!0}));let L=C.current,[a,F]=Ge.useState({action:L.action,location:L.location}),{v7_startTransition:H}=x||{},ee=Ge.useCallback(se=>{H&&NM?NM(()=>F(se)):F(se)},[F,H]);return Ge.useLayoutEffect(()=>L.listen(ee),[L,ee]),Ge.useEffect(()=>O5(x),[x]),Ge.createElement(B5,{basename:l,children:p,location:a.location,navigationType:a.action,navigator:L,future:x})}var VM;(function(s){s.UseScrollRestoration="useScrollRestoration",s.UseSubmit="useSubmit",s.UseSubmitFetcher="useSubmitFetcher",s.UseFetcher="useFetcher",s.useViewTransitionState="useViewTransitionState"})(VM||(VM={}));var UM;(function(s){s.UseFetcher="useFetcher",s.UseFetchers="useFetchers",s.UseScrollRestoration="useScrollRestoration"})(UM||(UM={}));const G5={},jM=s=>{let l;const p=new Set,x=(ee,se)=>{const ue=typeof ee=="function"?ee(l):ee;if(!Object.is(ue,l)){const Me=l;l=se??(typeof ue!="object"||ue===null)?ue:Object.assign({},l,ue),p.forEach(Ve=>Ve(l,Me))}},T=()=>l,F={setState:x,getState:T,getInitialState:()=>H,subscribe:ee=>(p.add(ee),()=>p.delete(ee)),destroy:()=>{(G5?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),p.clear()}},H=l=s(x,T,F);return F},$5=s=>s?jM(s):jM;var Fz={exports:{}},Oz={},Bz={exports:{}},Nz={};/**
 * @license React
 * use-sync-external-store-shim.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var mp=Ge;function H5(s,l){return s===l&&(s!==0||1/s===1/l)||s!==s&&l!==l}var Z5=typeof Object.is=="function"?Object.is:H5,q5=mp.useState,W5=mp.useEffect,X5=mp.useLayoutEffect,Y5=mp.useDebugValue;function K5(s,l){var p=l(),x=q5({inst:{value:p,getSnapshot:l}}),T=x[0].inst,C=x[1];return X5(function(){T.value=p,T.getSnapshot=l,Kw(T)&&C({inst:T})},[s,p,l]),W5(function(){return Kw(T)&&C({inst:T}),s(function(){Kw(T)&&C({inst:T})})},[s]),Y5(p),p}function Kw(s){var l=s.getSnapshot;s=s.value;try{var p=l();return!Z5(s,p)}catch{return!0}}function J5(s,l){return l()}var Q5=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?J5:K5;Nz.useSyncExternalStore=mp.useSyncExternalStore!==void 0?mp.useSyncExternalStore:Q5;Bz.exports=Nz;var eU=Bz.exports;/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var i1=Ge,tU=eU;function iU(s,l){return s===l&&(s!==0||1/s===1/l)||s!==s&&l!==l}var nU=typeof Object.is=="function"?Object.is:iU,rU=tU.useSyncExternalStore,sU=i1.useRef,oU=i1.useEffect,aU=i1.useMemo,lU=i1.useDebugValue;Oz.useSyncExternalStoreWithSelector=function(s,l,p,x,T){var C=sU(null);if(C.current===null){var L={hasValue:!1,value:null};C.current=L}else L=C.current;C=aU(function(){function F(Me){if(!H){if(H=!0,ee=Me,Me=x(Me),T!==void 0&&L.hasValue){var Ve=L.value;if(T(Ve,Me))return se=Ve}return se=Me}if(Ve=se,nU(ee,Me))return Ve;var ke=x(Me);return T!==void 0&&T(Ve,ke)?(ee=Me,Ve):(ee=Me,se=ke)}var H=!1,ee,se,ue=p===void 0?null:p;return[function(){return F(l())},ue===null?void 0:function(){return F(ue())}]},[l,p,x,T]);var a=rU(s,C[0],C[1]);return oU(function(){L.hasValue=!0,L.value=a},[a]),lU(a),a};Fz.exports=Oz;var cU=Fz.exports;const uU=DS(cU),Vz={},{useDebugValue:hU}=OS,{useSyncExternalStoreWithSelector:dU}=uU;let GM=!1;const fU=s=>s;function pU(s,l=fU,p){(Vz?"production":void 0)!=="production"&&p&&!GM&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),GM=!0);const x=dU(s.subscribe,s.getState,s.getServerState||s.getInitialState,l,p);return hU(x),x}const $M=s=>{(Vz?"production":void 0)!=="production"&&typeof s!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const l=typeof s=="function"?$5(s):s,p=(x,T)=>pU(l,x,T);return Object.assign(p,l),p},Sp=s=>s?$M(s):$M,mU="https://api.delivra.ng";async function ul(s,l={}){const p=localStorage.getItem("delivara_token"),x={...l.headers};p&&(x.Authorization=`Bearer ${p}`),l.body instanceof FormData||(x["Content-Type"]="application/json");const T=await fetch(`${mU}${s}`,{...l,headers:x});if(T.status===401)throw localStorage.removeItem("delivara_token"),window.location.href="/login",new Error("Session expired. Please log in again.");const C=await T.text(),L=C?JSON.parse(C):{};if(!T.ok)throw new Error(L.error||"Request failed");return L}const sc=Sp(s=>({token:localStorage.getItem("delivara_token"),user:JSON.parse(localStorage.getItem("delivara_user")||"null"),loading:!1,error:null,clearError:()=>s({error:null}),requestOtp:async(l,p,x="phone")=>(s({error:null}),(await ul("/api/auth/request-otp",{method:"POST",body:JSON.stringify(x==="email"?{email:l,role:p}:{phone:l,role:p})})).dev_code),verifyOtp:async(l,p,x,T,C="phone")=>{s({loading:!0,error:null});try{const a=await ul("/api/auth/verify-otp",{method:"POST",body:JSON.stringify(C==="email"?{email:l,code:p,role:x,referral_code:T}:{phone:l,code:p,role:x,referral_code:T})});localStorage.setItem("delivara_token",a.token),localStorage.setItem("delivara_user",JSON.stringify(a.user)),s({token:a.token,user:a.user,loading:!1})}catch(L){const a=L instanceof Error?L.message:"Verification failed";throw s({loading:!1,error:a}),L}},loadUser:async()=>{try{const l=await ul("/api/me");localStorage.setItem("delivara_user",JSON.stringify(l)),s({user:l})}catch{s({token:null,user:null}),localStorage.removeItem("delivara_token"),localStorage.removeItem("delivara_user")}},logout:()=>{localStorage.removeItem("delivara_token"),localStorage.removeItem("delivara_user"),s({token:null,user:null,error:null})}})),M2=Ge.createContext({});function R2(s){const l=Ge.useRef(null);return l.current===null&&(l.current=s()),l.current}const n1=Ge.createContext(null),D2=Ge.createContext({transformPagePoint:s=>s,isStatic:!1,reducedMotion:"never"});class _U extends Ge.Component{getSnapshotBeforeUpdate(l){const p=this.props.childRef.current;if(p&&l.isPresent&&!this.props.isPresent){const x=this.props.sizeRef.current;x.height=p.offsetHeight||0,x.width=p.offsetWidth||0,x.top=p.offsetTop,x.left=p.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function gU({children:s,isPresent:l}){const p=Ge.useId(),x=Ge.useRef(null),T=Ge.useRef({width:0,height:0,top:0,left:0}),{nonce:C}=Ge.useContext(D2);return Ge.useInsertionEffect(()=>{const{width:L,height:a,top:F,left:H}=T.current;if(l||!x.current||!L||!a)return;x.current.dataset.motionPopId=p;const ee=document.createElement("style");return C&&(ee.nonce=C),document.head.appendChild(ee),ee.sheet&&ee.sheet.insertRule(`
          [data-motion-pop-id="${p}"] {
            position: absolute !important;
            width: ${L}px !important;
            height: ${a}px !important;
            top: ${F}px !important;
            left: ${H}px !important;
          }
        `),()=>{document.head.removeChild(ee)}},[l]),J.jsx(_U,{isPresent:l,childRef:x,sizeRef:T,children:Ge.cloneElement(s,{ref:x})})}const yU=({children:s,initial:l,isPresent:p,onExitComplete:x,custom:T,presenceAffectsLayout:C,mode:L})=>{const a=R2(xU),F=Ge.useId(),H=Ge.useCallback(se=>{a.set(se,!0);for(const ue of a.values())if(!ue)return;x&&x()},[a,x]),ee=Ge.useMemo(()=>({id:F,initial:l,isPresent:p,custom:T,onExitComplete:H,register:se=>(a.set(se,!1),()=>a.delete(se))}),C?[Math.random(),H]:[p,H]);return Ge.useMemo(()=>{a.forEach((se,ue)=>a.set(ue,!1))},[p]),Ge.useEffect(()=>{!p&&!a.size&&x&&x()},[p]),L==="popLayout"&&(s=J.jsx(gU,{isPresent:p,children:s})),J.jsx(n1.Provider,{value:ee,children:s})};function xU(){return new Map}function Uz(s=!0){const l=Ge.useContext(n1);if(l===null)return[!0,null];const{isPresent:p,onExitComplete:x,register:T}=l,C=Ge.useId();Ge.useEffect(()=>{s&&T(C)},[s]);const L=Ge.useCallback(()=>s&&x&&x(C),[C,x,s]);return!p&&x?[!1,L]:[!0]}const Bv=s=>s.key||"";function HM(s){const l=[];return Ge.Children.forEach(s,p=>{Ge.isValidElement(p)&&l.push(p)}),l}const L2=typeof window<"u",jz=L2?Ge.useLayoutEffect:Ge.useEffect,oc=({children:s,custom:l,initial:p=!0,onExitComplete:x,presenceAffectsLayout:T=!0,mode:C="sync",propagate:L=!1})=>{const[a,F]=Uz(L),H=Ge.useMemo(()=>HM(s),[s]),ee=L&&!a?[]:H.map(Bv),se=Ge.useRef(!0),ue=Ge.useRef(H),Me=R2(()=>new Map),[Ve,ke]=Ge.useState(H),[Ye,Se]=Ge.useState(H);jz(()=>{se.current=!1,ue.current=H;for(let qe=0;qe<Ye.length;qe++){const ot=Bv(Ye[qe]);ee.includes(ot)?Me.delete(ot):Me.get(ot)!==!0&&Me.set(ot,!1)}},[Ye,ee.length,ee.join("-")]);const ye=[];if(H!==Ve){let qe=[...H];for(let ot=0;ot<Ye.length;ot++){const xt=Ye[ot],Rt=Bv(xt);ee.includes(Rt)||(qe.splice(ot,0,xt),ye.push(xt))}C==="wait"&&ye.length&&(qe=ye),Se(HM(qe)),ke(H);return}const{forceRender:Ie}=Ge.useContext(M2);return J.jsx(J.Fragment,{children:Ye.map(qe=>{const ot=Bv(qe),xt=L&&!a?!1:H===Ye||ee.includes(ot),Rt=()=>{if(Me.has(ot))Me.set(ot,!0);else return;let Tt=!0;Me.forEach(li=>{li||(Tt=!1)}),Tt&&(Ie==null||Ie(),Se(ue.current),L&&(F==null||F()),x&&x())};return J.jsx(yU,{isPresent:xt,initial:!se.current||p?void 0:!1,custom:xt?void 0:l,presenceAffectsLayout:T,mode:C,onExitComplete:xt?void 0:Rt,children:qe},ot)})})},Eo=s=>s;let Gz=Eo;function z2(s){let l;return()=>(l===void 0&&(l=s()),l)}const _p=(s,l,p)=>{const x=l-s;return x===0?1:(p-s)/x},Ql=s=>s*1e3,ec=s=>s/1e3,vU={useManualTiming:!1};function bU(s){let l=new Set,p=new Set,x=!1,T=!1;const C=new WeakSet;let L={delta:0,timestamp:0,isProcessing:!1};function a(H){C.has(H)&&(F.schedule(H),s()),H(L)}const F={schedule:(H,ee=!1,se=!1)=>{const Me=se&&x?l:p;return ee&&C.add(H),Me.has(H)||Me.add(H),H},cancel:H=>{p.delete(H),C.delete(H)},process:H=>{if(L=H,x){T=!0;return}x=!0,[l,p]=[p,l],l.forEach(a),l.clear(),x=!1,T&&(T=!1,F.process(H))}};return F}const Nv=["read","resolveKeyframes","update","preRender","render","postRender"],wU=40;function $z(s,l){let p=!1,x=!0;const T={delta:0,timestamp:0,isProcessing:!1},C=()=>p=!0,L=Nv.reduce((Se,ye)=>(Se[ye]=bU(C),Se),{}),{read:a,resolveKeyframes:F,update:H,preRender:ee,render:se,postRender:ue}=L,Me=()=>{const Se=performance.now();p=!1,T.delta=x?1e3/60:Math.max(Math.min(Se-T.timestamp,wU),1),T.timestamp=Se,T.isProcessing=!0,a.process(T),F.process(T),H.process(T),ee.process(T),se.process(T),ue.process(T),T.isProcessing=!1,p&&l&&(x=!1,s(Me))},Ve=()=>{p=!0,x=!0,T.isProcessing||s(Me)};return{schedule:Nv.reduce((Se,ye)=>{const Ie=L[ye];return Se[ye]=(qe,ot=!1,xt=!1)=>(p||Ve(),Ie.schedule(qe,ot,xt)),Se},{}),cancel:Se=>{for(let ye=0;ye<Nv.length;ye++)L[Nv[ye]].cancel(Se)},state:T,steps:L}}const{schedule:tr,cancel:yu,state:as,steps:Jw}=$z(typeof requestAnimationFrame<"u"?requestAnimationFrame:Eo,!0),Hz=Ge.createContext({strict:!1}),ZM={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},gp={};for(const s in ZM)gp[s]={isEnabled:l=>ZM[s].some(p=>!!l[p])};function TU(s){for(const l in s)gp[l]={...gp[l],...s[l]}}const SU=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function M0(s){return s.startsWith("while")||s.startsWith("drag")&&s!=="draggable"||s.startsWith("layout")||s.startsWith("onTap")||s.startsWith("onPan")||s.startsWith("onLayout")||SU.has(s)}let Zz=s=>!M0(s);function EU(s){s&&(Zz=l=>l.startsWith("on")?!M0(l):s(l))}try{EU(require("@emotion/is-prop-valid").default)}catch{}function IU(s,l,p){const x={};for(const T in s)T==="values"&&typeof s.values=="object"||(Zz(T)||p===!0&&M0(T)||!l&&!M0(T)||s.draggable&&T.startsWith("onDrag"))&&(x[T]=s[T]);return x}function AU(s){if(typeof Proxy>"u")return s;const l=new Map,p=(...x)=>s(...x);return new Proxy(p,{get:(x,T)=>T==="create"?s:(l.has(T)||l.set(T,s(T)),l.get(T))})}const r1=Ge.createContext({});function kg(s){return typeof s=="string"||Array.isArray(s)}function s1(s){return s!==null&&typeof s=="object"&&typeof s.start=="function"}const k2=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],F2=["initial",...k2];function o1(s){return s1(s.animate)||F2.some(l=>kg(s[l]))}function qz(s){return!!(o1(s)||s.variants)}function CU(s,l){if(o1(s)){const{initial:p,animate:x}=s;return{initial:p===!1||kg(p)?p:void 0,animate:kg(x)?x:void 0}}return s.inherit!==!1?l:{}}function PU(s){const{initial:l,animate:p}=CU(s,Ge.useContext(r1));return Ge.useMemo(()=>({initial:l,animate:p}),[qM(l),qM(p)])}function qM(s){return Array.isArray(s)?s.join(" "):s}const MU=Symbol.for("motionComponentSymbol");function Yf(s){return s&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"current")}function RU(s,l,p){return Ge.useCallback(x=>{x&&s.onMount&&s.onMount(x),l&&(x?l.mount(x):l.unmount()),p&&(typeof p=="function"?p(x):Yf(p)&&(p.current=x))},[l])}const O2=s=>s.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),DU="framerAppearId",Wz="data-"+O2(DU),{schedule:B2}=$z(queueMicrotask,!1),Xz=Ge.createContext({});function LU(s,l,p,x,T){var C,L;const{visualElement:a}=Ge.useContext(r1),F=Ge.useContext(Hz),H=Ge.useContext(n1),ee=Ge.useContext(D2).reducedMotion,se=Ge.useRef(null);x=x||F.renderer,!se.current&&x&&(se.current=x(s,{visualState:l,parent:a,props:p,presenceContext:H,blockInitialAnimation:H?H.initial===!1:!1,reducedMotionConfig:ee}));const ue=se.current,Me=Ge.useContext(Xz);ue&&!ue.projection&&T&&(ue.type==="html"||ue.type==="svg")&&zU(se.current,p,T,Me);const Ve=Ge.useRef(!1);Ge.useInsertionEffect(()=>{ue&&Ve.current&&ue.update(p,H)});const ke=p[Wz],Ye=Ge.useRef(!!ke&&!(!((C=window.MotionHandoffIsComplete)===null||C===void 0)&&C.call(window,ke))&&((L=window.MotionHasOptimisedAnimation)===null||L===void 0?void 0:L.call(window,ke)));return jz(()=>{ue&&(Ve.current=!0,window.MotionIsMounted=!0,ue.updateFeatures(),B2.render(ue.render),Ye.current&&ue.animationState&&ue.animationState.animateChanges())}),Ge.useEffect(()=>{ue&&(!Ye.current&&ue.animationState&&ue.animationState.animateChanges(),Ye.current&&(queueMicrotask(()=>{var Se;(Se=window.MotionHandoffMarkAsComplete)===null||Se===void 0||Se.call(window,ke)}),Ye.current=!1))}),ue}function zU(s,l,p,x){const{layoutId:T,layout:C,drag:L,dragConstraints:a,layoutScroll:F,layoutRoot:H}=l;s.projection=new p(s.latestValues,l["data-framer-portal-id"]?void 0:Yz(s.parent)),s.projection.setOptions({layoutId:T,layout:C,alwaysMeasureLayout:!!L||a&&Yf(a),visualElement:s,animationType:typeof C=="string"?C:"both",initialPromotionConfig:x,layoutScroll:F,layoutRoot:H})}function Yz(s){if(s)return s.options.allowProjection!==!1?s.projection:Yz(s.parent)}function kU({preloadedFeatures:s,createVisualElement:l,useRender:p,useVisualState:x,Component:T}){var C,L;s&&TU(s);function a(H,ee){let se;const ue={...Ge.useContext(D2),...H,layoutId:FU(H)},{isStatic:Me}=ue,Ve=PU(H),ke=x(H,Me);if(!Me&&L2){OU();const Ye=BU(ue);se=Ye.MeasureLayout,Ve.visualElement=LU(T,ke,ue,l,Ye.ProjectionNode)}return J.jsxs(r1.Provider,{value:Ve,children:[se&&Ve.visualElement?J.jsx(se,{visualElement:Ve.visualElement,...ue}):null,p(T,H,RU(ke,Ve.visualElement,ee),ke,Me,Ve.visualElement)]})}a.displayName=`motion.${typeof T=="string"?T:`create(${(L=(C=T.displayName)!==null&&C!==void 0?C:T.name)!==null&&L!==void 0?L:""})`}`;const F=Ge.forwardRef(a);return F[MU]=T,F}function FU({layoutId:s}){const l=Ge.useContext(M2).id;return l&&s!==void 0?l+"-"+s:s}function OU(s,l){Ge.useContext(Hz).strict}function BU(s){const{drag:l,layout:p}=gp;if(!l&&!p)return{};const x={...l,...p};return{MeasureLayout:l!=null&&l.isEnabled(s)||p!=null&&p.isEnabled(s)?x.MeasureLayout:void 0,ProjectionNode:x.ProjectionNode}}const NU=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function N2(s){return typeof s!="string"||s.includes("-")?!1:!!(NU.indexOf(s)>-1||/[A-Z]/u.test(s))}function WM(s){const l=[{},{}];return s==null||s.values.forEach((p,x)=>{l[0][x]=p.get(),l[1][x]=p.getVelocity()}),l}function V2(s,l,p,x){if(typeof l=="function"){const[T,C]=WM(x);l=l(p!==void 0?p:s.custom,T,C)}if(typeof l=="string"&&(l=s.variants&&s.variants[l]),typeof l=="function"){const[T,C]=WM(x);l=l(p!==void 0?p:s.custom,T,C)}return l}const fS=s=>Array.isArray(s),VU=s=>!!(s&&typeof s=="object"&&s.mix&&s.toValue),UU=s=>fS(s)?s[s.length-1]||0:s,Ts=s=>!!(s&&s.getVelocity);function i0(s){const l=Ts(s)?s.get():s;return VU(l)?l.toValue():l}function jU({scrapeMotionValuesFromProps:s,createRenderState:l,onUpdate:p},x,T,C){const L={latestValues:GU(x,T,C,s),renderState:l()};return p&&(L.onMount=a=>p({props:x,current:a,...L}),L.onUpdate=a=>p(a)),L}const Kz=s=>(l,p)=>{const x=Ge.useContext(r1),T=Ge.useContext(n1),C=()=>jU(s,l,x,T);return p?C():R2(C)};function GU(s,l,p,x){const T={},C=x(s,{});for(const ue in C)T[ue]=i0(C[ue]);let{initial:L,animate:a}=s;const F=o1(s),H=qz(s);l&&H&&!F&&s.inherit!==!1&&(L===void 0&&(L=l.initial),a===void 0&&(a=l.animate));let ee=p?p.initial===!1:!1;ee=ee||L===!1;const se=ee?a:L;if(se&&typeof se!="boolean"&&!s1(se)){const ue=Array.isArray(se)?se:[se];for(let Me=0;Me<ue.length;Me++){const Ve=V2(s,ue[Me]);if(Ve){const{transitionEnd:ke,transition:Ye,...Se}=Ve;for(const ye in Se){let Ie=Se[ye];if(Array.isArray(Ie)){const qe=ee?Ie.length-1:0;Ie=Ie[qe]}Ie!==null&&(T[ye]=Ie)}for(const ye in ke)T[ye]=ke[ye]}}}return T}const Ep=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],td=new Set(Ep),Jz=s=>l=>typeof l=="string"&&l.startsWith(s),Qz=Jz("--"),$U=Jz("var(--"),U2=s=>$U(s)?HU.test(s.split("/*")[0].trim()):!1,HU=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ek=(s,l)=>l&&typeof s=="number"?l.transform(s):s,ac=(s,l,p)=>p>l?l:p<s?s:p,Ip={test:s=>typeof s=="number",parse:parseFloat,transform:s=>s},Fg={...Ip,transform:s=>ac(0,1,s)},Vv={...Ip,default:1},Wg=s=>({test:l=>typeof l=="string"&&l.endsWith(s)&&l.split(" ").length===1,parse:parseFloat,transform:l=>`${l}${s}`}),eu=Wg("deg"),hl=Wg("%"),Di=Wg("px"),ZU=Wg("vh"),qU=Wg("vw"),XM={...hl,parse:s=>hl.parse(s)/100,transform:s=>hl.transform(s*100)},WU={borderWidth:Di,borderTopWidth:Di,borderRightWidth:Di,borderBottomWidth:Di,borderLeftWidth:Di,borderRadius:Di,radius:Di,borderTopLeftRadius:Di,borderTopRightRadius:Di,borderBottomRightRadius:Di,borderBottomLeftRadius:Di,width:Di,maxWidth:Di,height:Di,maxHeight:Di,top:Di,right:Di,bottom:Di,left:Di,padding:Di,paddingTop:Di,paddingRight:Di,paddingBottom:Di,paddingLeft:Di,margin:Di,marginTop:Di,marginRight:Di,marginBottom:Di,marginLeft:Di,backgroundPositionX:Di,backgroundPositionY:Di},XU={rotate:eu,rotateX:eu,rotateY:eu,rotateZ:eu,scale:Vv,scaleX:Vv,scaleY:Vv,scaleZ:Vv,skew:eu,skewX:eu,skewY:eu,distance:Di,translateX:Di,translateY:Di,translateZ:Di,x:Di,y:Di,z:Di,perspective:Di,transformPerspective:Di,opacity:Fg,originX:XM,originY:XM,originZ:Di},YM={...Ip,transform:Math.round},j2={...WU,...XU,zIndex:YM,size:Di,fillOpacity:Fg,strokeOpacity:Fg,numOctaves:YM},YU={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},KU=Ep.length;function JU(s,l,p){let x="",T=!0;for(let C=0;C<KU;C++){const L=Ep[C],a=s[L];if(a===void 0)continue;let F=!0;if(typeof a=="number"?F=a===(L.startsWith("scale")?1:0):F=parseFloat(a)===0,!F||p){const H=ek(a,j2[L]);if(!F){T=!1;const ee=YU[L]||L;x+=`${ee}(${H}) `}p&&(l[L]=H)}}return x=x.trim(),p?x=p(l,T?"":x):T&&(x="none"),x}function G2(s,l,p){const{style:x,vars:T,transformOrigin:C}=s;let L=!1,a=!1;for(const F in l){const H=l[F];if(td.has(F)){L=!0;continue}else if(Qz(F)){T[F]=H;continue}else{const ee=ek(H,j2[F]);F.startsWith("origin")?(a=!0,C[F]=ee):x[F]=ee}}if(l.transform||(L||p?x.transform=JU(l,s.transform,p):x.transform&&(x.transform="none")),a){const{originX:F="50%",originY:H="50%",originZ:ee=0}=C;x.transformOrigin=`${F} ${H} ${ee}`}}const QU={offset:"stroke-dashoffset",array:"stroke-dasharray"},ej={offset:"strokeDashoffset",array:"strokeDasharray"};function tj(s,l,p=1,x=0,T=!0){s.pathLength=1;const C=T?QU:ej;s[C.offset]=Di.transform(-x);const L=Di.transform(l),a=Di.transform(p);s[C.array]=`${L} ${a}`}function KM(s,l,p){return typeof s=="string"?s:Di.transform(l+p*s)}function ij(s,l,p){const x=KM(l,s.x,s.width),T=KM(p,s.y,s.height);return`${x} ${T}`}function $2(s,{attrX:l,attrY:p,attrScale:x,originX:T,originY:C,pathLength:L,pathSpacing:a=1,pathOffset:F=0,...H},ee,se){if(G2(s,H,se),ee){s.style.viewBox&&(s.attrs.viewBox=s.style.viewBox);return}s.attrs=s.style,s.style={};const{attrs:ue,style:Me,dimensions:Ve}=s;ue.transform&&(Ve&&(Me.transform=ue.transform),delete ue.transform),Ve&&(T!==void 0||C!==void 0||Me.transform)&&(Me.transformOrigin=ij(Ve,T!==void 0?T:.5,C!==void 0?C:.5)),l!==void 0&&(ue.x=l),p!==void 0&&(ue.y=p),x!==void 0&&(ue.scale=x),L!==void 0&&tj(ue,L,a,F,!1)}const H2=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),tk=()=>({...H2(),attrs:{}}),Z2=s=>typeof s=="string"&&s.toLowerCase()==="svg";function ik(s,{style:l,vars:p},x,T){Object.assign(s.style,l,T&&T.getProjectionStyles(x));for(const C in p)s.style.setProperty(C,p[C])}const nk=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function rk(s,l,p,x){ik(s,l,void 0,x);for(const T in l.attrs)s.setAttribute(nk.has(T)?T:O2(T),l.attrs[T])}const R0={};function nj(s){Object.assign(R0,s)}function sk(s,{layout:l,layoutId:p}){return td.has(s)||s.startsWith("origin")||(l||p!==void 0)&&(!!R0[s]||s==="opacity")}function q2(s,l,p){var x;const{style:T}=s,C={};for(const L in T)(Ts(T[L])||l.style&&Ts(l.style[L])||sk(L,s)||((x=p==null?void 0:p.getValue(L))===null||x===void 0?void 0:x.liveStyle)!==void 0)&&(C[L]=T[L]);return C}function ok(s,l,p){const x=q2(s,l,p);for(const T in s)if(Ts(s[T])||Ts(l[T])){const C=Ep.indexOf(T)!==-1?"attr"+T.charAt(0).toUpperCase()+T.substring(1):T;x[C]=s[T]}return x}function rj(s,l){try{l.dimensions=typeof s.getBBox=="function"?s.getBBox():s.getBoundingClientRect()}catch{l.dimensions={x:0,y:0,width:0,height:0}}}const JM=["x","y","width","height","cx","cy","r"],sj={useVisualState:Kz({scrapeMotionValuesFromProps:ok,createRenderState:tk,onUpdate:({props:s,prevProps:l,current:p,renderState:x,latestValues:T})=>{if(!p)return;let C=!!s.drag;if(!C){for(const a in T)if(td.has(a)){C=!0;break}}if(!C)return;let L=!l;if(l)for(let a=0;a<JM.length;a++){const F=JM[a];s[F]!==l[F]&&(L=!0)}L&&tr.read(()=>{rj(p,x),tr.render(()=>{$2(x,T,Z2(p.tagName),s.transformTemplate),rk(p,x)})})}})},oj={useVisualState:Kz({scrapeMotionValuesFromProps:q2,createRenderState:H2})};function ak(s,l,p){for(const x in l)!Ts(l[x])&&!sk(x,p)&&(s[x]=l[x])}function aj({transformTemplate:s},l){return Ge.useMemo(()=>{const p=H2();return G2(p,l,s),Object.assign({},p.vars,p.style)},[l])}function lj(s,l){const p=s.style||{},x={};return ak(x,p,s),Object.assign(x,aj(s,l)),x}function cj(s,l){const p={},x=lj(s,l);return s.drag&&s.dragListener!==!1&&(p.draggable=!1,x.userSelect=x.WebkitUserSelect=x.WebkitTouchCallout="none",x.touchAction=s.drag===!0?"none":`pan-${s.drag==="x"?"y":"x"}`),s.tabIndex===void 0&&(s.onTap||s.onTapStart||s.whileTap)&&(p.tabIndex=0),p.style=x,p}function uj(s,l,p,x){const T=Ge.useMemo(()=>{const C=tk();return $2(C,l,Z2(x),s.transformTemplate),{...C.attrs,style:{...C.style}}},[l]);if(s.style){const C={};ak(C,s.style,s),T.style={...C,...T.style}}return T}function hj(s=!1){return(p,x,T,{latestValues:C},L)=>{const F=(N2(p)?uj:cj)(x,C,L,p),H=IU(x,typeof p=="string",s),ee=p!==Ge.Fragment?{...H,...F,ref:T}:{},{children:se}=x,ue=Ge.useMemo(()=>Ts(se)?se.get():se,[se]);return Ge.createElement(p,{...ee,children:ue})}}function dj(s,l){return function(x,{forwardMotionProps:T}={forwardMotionProps:!1}){const L={...N2(x)?sj:oj,preloadedFeatures:s,useRender:hj(T),createVisualElement:l,Component:x};return kU(L)}}function lk(s,l){if(!Array.isArray(l))return!1;const p=l.length;if(p!==s.length)return!1;for(let x=0;x<p;x++)if(l[x]!==s[x])return!1;return!0}function a1(s,l,p){const x=s.getProps();return V2(x,l,p!==void 0?p:x.custom,s)}const fj=z2(()=>window.ScrollTimeline!==void 0);class pj{constructor(l){this.stop=()=>this.runAll("stop"),this.animations=l.filter(Boolean)}get finished(){return Promise.all(this.animations.map(l=>"finished"in l?l.finished:l))}getAll(l){return this.animations[0][l]}setAll(l,p){for(let x=0;x<this.animations.length;x++)this.animations[x][l]=p}attachTimeline(l,p){const x=this.animations.map(T=>{if(fj()&&T.attachTimeline)return T.attachTimeline(l);if(typeof p=="function")return p(T)});return()=>{x.forEach((T,C)=>{T&&T(),this.animations[C].stop()})}}get time(){return this.getAll("time")}set time(l){this.setAll("time",l)}get speed(){return this.getAll("speed")}set speed(l){this.setAll("speed",l)}get startTime(){return this.getAll("startTime")}get duration(){let l=0;for(let p=0;p<this.animations.length;p++)l=Math.max(l,this.animations[p].duration);return l}runAll(l){this.animations.forEach(p=>p[l]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class mj extends pj{then(l,p){return Promise.all(this.animations).then(l).catch(p)}}function W2(s,l){return s?s[l]||s.default||s:void 0}const pS=2e4;function ck(s){let l=0;const p=50;let x=s.next(l);for(;!x.done&&l<pS;)l+=p,x=s.next(l);return l>=pS?1/0:l}function X2(s){return typeof s=="function"}function QM(s,l){s.timeline=l,s.onfinish=null}const Y2=s=>Array.isArray(s)&&typeof s[0]=="number",_j={linearEasing:void 0};function gj(s,l){const p=z2(s);return()=>{var x;return(x=_j[l])!==null&&x!==void 0?x:p()}}const D0=gj(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),uk=(s,l,p=10)=>{let x="";const T=Math.max(Math.round(l/p),2);for(let C=0;C<T;C++)x+=s(_p(0,T-1,C))+", ";return`linear(${x.substring(0,x.length-2)})`};function hk(s){return!!(typeof s=="function"&&D0()||!s||typeof s=="string"&&(s in mS||D0())||Y2(s)||Array.isArray(s)&&s.every(hk))}const J_=([s,l,p,x])=>`cubic-bezier(${s}, ${l}, ${p}, ${x})`,mS={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:J_([0,.65,.55,1]),circOut:J_([.55,0,1,.45]),backIn:J_([.31,.01,.66,-.59]),backOut:J_([.33,1.53,.69,.99])};function dk(s,l){if(s)return typeof s=="function"&&D0()?uk(s,l):Y2(s)?J_(s):Array.isArray(s)?s.map(p=>dk(p,l)||mS.easeOut):mS[s]}const Ia={x:!1,y:!1};function fk(){return Ia.x||Ia.y}function yj(s,l,p){var x;if(s instanceof Element)return[s];if(typeof s=="string"){let T=document;const C=(x=void 0)!==null&&x!==void 0?x:T.querySelectorAll(s);return C?Array.from(C):[]}return Array.from(s)}function pk(s,l){const p=yj(s),x=new AbortController,T={passive:!0,...l,signal:x.signal};return[p,T,()=>x.abort()]}function eR(s){return l=>{l.pointerType==="touch"||fk()||s(l)}}function xj(s,l,p={}){const[x,T,C]=pk(s,p),L=eR(a=>{const{target:F}=a,H=l(a);if(typeof H!="function"||!F)return;const ee=eR(se=>{H(se),F.removeEventListener("pointerleave",ee)});F.addEventListener("pointerleave",ee,T)});return x.forEach(a=>{a.addEventListener("pointerenter",L,T)}),C}const mk=(s,l)=>l?s===l?!0:mk(s,l.parentElement):!1,K2=s=>s.pointerType==="mouse"?typeof s.button!="number"||s.button<=0:s.isPrimary!==!1,vj=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function bj(s){return vj.has(s.tagName)||s.tabIndex!==-1}const Q_=new WeakSet;function tR(s){return l=>{l.key==="Enter"&&s(l)}}function Qw(s,l){s.dispatchEvent(new PointerEvent("pointer"+l,{isPrimary:!0,bubbles:!0}))}const wj=(s,l)=>{const p=s.currentTarget;if(!p)return;const x=tR(()=>{if(Q_.has(p))return;Qw(p,"down");const T=tR(()=>{Qw(p,"up")}),C=()=>Qw(p,"cancel");p.addEventListener("keyup",T,l),p.addEventListener("blur",C,l)});p.addEventListener("keydown",x,l),p.addEventListener("blur",()=>p.removeEventListener("keydown",x),l)};function iR(s){return K2(s)&&!fk()}function Tj(s,l,p={}){const[x,T,C]=pk(s,p),L=a=>{const F=a.currentTarget;if(!iR(a)||Q_.has(F))return;Q_.add(F);const H=l(a),ee=(Me,Ve)=>{window.removeEventListener("pointerup",se),window.removeEventListener("pointercancel",ue),!(!iR(Me)||!Q_.has(F))&&(Q_.delete(F),typeof H=="function"&&H(Me,{success:Ve}))},se=Me=>{ee(Me,p.useGlobalTarget||mk(F,Me.target))},ue=Me=>{ee(Me,!1)};window.addEventListener("pointerup",se,T),window.addEventListener("pointercancel",ue,T)};return x.forEach(a=>{!bj(a)&&a.getAttribute("tabindex")===null&&(a.tabIndex=0),(p.useGlobalTarget?window:a).addEventListener("pointerdown",L,T),a.addEventListener("focus",H=>wj(H,T),T)}),C}function Sj(s){return s==="x"||s==="y"?Ia[s]?null:(Ia[s]=!0,()=>{Ia[s]=!1}):Ia.x||Ia.y?null:(Ia.x=Ia.y=!0,()=>{Ia.x=Ia.y=!1})}const _k=new Set(["width","height","top","left","right","bottom",...Ep]);let n0;function Ej(){n0=void 0}const dl={now:()=>(n0===void 0&&dl.set(as.isProcessing||vU.useManualTiming?as.timestamp:performance.now()),n0),set:s=>{n0=s,queueMicrotask(Ej)}};function J2(s,l){s.indexOf(l)===-1&&s.push(l)}function Q2(s,l){const p=s.indexOf(l);p>-1&&s.splice(p,1)}class eE{constructor(){this.subscriptions=[]}add(l){return J2(this.subscriptions,l),()=>Q2(this.subscriptions,l)}notify(l,p,x){const T=this.subscriptions.length;if(T)if(T===1)this.subscriptions[0](l,p,x);else for(let C=0;C<T;C++){const L=this.subscriptions[C];L&&L(l,p,x)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function gk(s,l){return l?s*(1e3/l):0}const nR=30,Ij=s=>!isNaN(parseFloat(s));class Aj{constructor(l,p={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(x,T=!0)=>{const C=dl.now();this.updatedAt!==C&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(x),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),T&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(l),this.owner=p.owner}setCurrent(l){this.current=l,this.updatedAt=dl.now(),this.canTrackVelocity===null&&l!==void 0&&(this.canTrackVelocity=Ij(this.current))}setPrevFrameValue(l=this.current){this.prevFrameValue=l,this.prevUpdatedAt=this.updatedAt}onChange(l){return this.on("change",l)}on(l,p){this.events[l]||(this.events[l]=new eE);const x=this.events[l].add(p);return l==="change"?()=>{x(),tr.read(()=>{this.events.change.getSize()||this.stop()})}:x}clearListeners(){for(const l in this.events)this.events[l].clear()}attach(l,p){this.passiveEffect=l,this.stopPassiveEffect=p}set(l,p=!0){!p||!this.passiveEffect?this.updateAndNotify(l,p):this.passiveEffect(l,this.updateAndNotify)}setWithVelocity(l,p,x){this.set(p),this.prev=void 0,this.prevFrameValue=l,this.prevUpdatedAt=this.updatedAt-x}jump(l,p=!0){this.updateAndNotify(l),this.prev=l,this.prevUpdatedAt=this.prevFrameValue=void 0,p&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const l=dl.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||l-this.updatedAt>nR)return 0;const p=Math.min(this.updatedAt-this.prevUpdatedAt,nR);return gk(parseFloat(this.current)-parseFloat(this.prevFrameValue),p)}start(l){return this.stop(),new Promise(p=>{this.hasAnimated=!0,this.animation=l(p),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Og(s,l){return new Aj(s,l)}function Cj(s,l,p){s.hasValue(l)?s.getValue(l).set(p):s.addValue(l,Og(p))}function Pj(s,l){const p=a1(s,l);let{transitionEnd:x={},transition:T={},...C}=p||{};C={...C,...x};for(const L in C){const a=UU(C[L]);Cj(s,L,a)}}function Mj(s){return!!(Ts(s)&&s.add)}function _S(s,l){const p=s.getValue("willChange");if(Mj(p))return p.add(l)}function yk(s){return s.props[Wz]}const xk=(s,l,p)=>(((1-3*p+3*l)*s+(3*p-6*l))*s+3*l)*s,Rj=1e-7,Dj=12;function Lj(s,l,p,x,T){let C,L,a=0;do L=l+(p-l)/2,C=xk(L,x,T)-s,C>0?p=L:l=L;while(Math.abs(C)>Rj&&++a<Dj);return L}function Xg(s,l,p,x){if(s===l&&p===x)return Eo;const T=C=>Lj(C,0,1,s,p);return C=>C===0||C===1?C:xk(T(C),l,x)}const vk=s=>l=>l<=.5?s(2*l)/2:(2-s(2*(1-l)))/2,bk=s=>l=>1-s(1-l),wk=Xg(.33,1.53,.69,.99),tE=bk(wk),Tk=vk(tE),Sk=s=>(s*=2)<1?.5*tE(s):.5*(2-Math.pow(2,-10*(s-1))),iE=s=>1-Math.sin(Math.acos(s)),Ek=bk(iE),Ik=vk(iE),Ak=s=>/^0[^.\s]+$/u.test(s);function zj(s){return typeof s=="number"?s===0:s!==null?s==="none"||s==="0"||Ak(s):!0}const hg=s=>Math.round(s*1e5)/1e5,nE=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function kj(s){return s==null}const Fj=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,rE=(s,l)=>p=>!!(typeof p=="string"&&Fj.test(p)&&p.startsWith(s)||l&&!kj(p)&&Object.prototype.hasOwnProperty.call(p,l)),Ck=(s,l,p)=>x=>{if(typeof x!="string")return x;const[T,C,L,a]=x.match(nE);return{[s]:parseFloat(T),[l]:parseFloat(C),[p]:parseFloat(L),alpha:a!==void 0?parseFloat(a):1}},Oj=s=>ac(0,255,s),eT={...Ip,transform:s=>Math.round(Oj(s))},Gh={test:rE("rgb","red"),parse:Ck("red","green","blue"),transform:({red:s,green:l,blue:p,alpha:x=1})=>"rgba("+eT.transform(s)+", "+eT.transform(l)+", "+eT.transform(p)+", "+hg(Fg.transform(x))+")"};function Bj(s){let l="",p="",x="",T="";return s.length>5?(l=s.substring(1,3),p=s.substring(3,5),x=s.substring(5,7),T=s.substring(7,9)):(l=s.substring(1,2),p=s.substring(2,3),x=s.substring(3,4),T=s.substring(4,5),l+=l,p+=p,x+=x,T+=T),{red:parseInt(l,16),green:parseInt(p,16),blue:parseInt(x,16),alpha:T?parseInt(T,16)/255:1}}const gS={test:rE("#"),parse:Bj,transform:Gh.transform},Kf={test:rE("hsl","hue"),parse:Ck("hue","saturation","lightness"),transform:({hue:s,saturation:l,lightness:p,alpha:x=1})=>"hsla("+Math.round(s)+", "+hl.transform(hg(l))+", "+hl.transform(hg(p))+", "+hg(Fg.transform(x))+")"},bs={test:s=>Gh.test(s)||gS.test(s)||Kf.test(s),parse:s=>Gh.test(s)?Gh.parse(s):Kf.test(s)?Kf.parse(s):gS.parse(s),transform:s=>typeof s=="string"?s:s.hasOwnProperty("red")?Gh.transform(s):Kf.transform(s)},Nj=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Vj(s){var l,p;return isNaN(s)&&typeof s=="string"&&(((l=s.match(nE))===null||l===void 0?void 0:l.length)||0)+(((p=s.match(Nj))===null||p===void 0?void 0:p.length)||0)>0}const Pk="number",Mk="color",Uj="var",jj="var(",rR="${}",Gj=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Bg(s){const l=s.toString(),p=[],x={color:[],number:[],var:[]},T=[];let C=0;const a=l.replace(Gj,F=>(bs.test(F)?(x.color.push(C),T.push(Mk),p.push(bs.parse(F))):F.startsWith(jj)?(x.var.push(C),T.push(Uj),p.push(F)):(x.number.push(C),T.push(Pk),p.push(parseFloat(F))),++C,rR)).split(rR);return{values:p,split:a,indexes:x,types:T}}function Rk(s){return Bg(s).values}function Dk(s){const{split:l,types:p}=Bg(s),x=l.length;return T=>{let C="";for(let L=0;L<x;L++)if(C+=l[L],T[L]!==void 0){const a=p[L];a===Pk?C+=hg(T[L]):a===Mk?C+=bs.transform(T[L]):C+=T[L]}return C}}const $j=s=>typeof s=="number"?0:s;function Hj(s){const l=Rk(s);return Dk(s)(l.map($j))}const xu={test:Vj,parse:Rk,createTransformer:Dk,getAnimatableNone:Hj},Zj=new Set(["brightness","contrast","saturate","opacity"]);function qj(s){const[l,p]=s.slice(0,-1).split("(");if(l==="drop-shadow")return s;const[x]=p.match(nE)||[];if(!x)return s;const T=p.replace(x,"");let C=Zj.has(l)?1:0;return x!==p&&(C*=100),l+"("+C+T+")"}const Wj=/\b([a-z-]*)\(.*?\)/gu,yS={...xu,getAnimatableNone:s=>{const l=s.match(Wj);return l?l.map(qj).join(" "):s}},Xj={...j2,color:bs,backgroundColor:bs,outlineColor:bs,fill:bs,stroke:bs,borderColor:bs,borderTopColor:bs,borderRightColor:bs,borderBottomColor:bs,borderLeftColor:bs,filter:yS,WebkitFilter:yS},sE=s=>Xj[s];function Lk(s,l){let p=sE(s);return p!==yS&&(p=xu),p.getAnimatableNone?p.getAnimatableNone(l):void 0}const Yj=new Set(["auto","none","0"]);function Kj(s,l,p){let x=0,T;for(;x<s.length&&!T;){const C=s[x];typeof C=="string"&&!Yj.has(C)&&Bg(C).values.length&&(T=s[x]),x++}if(T&&p)for(const C of l)s[C]=Lk(p,T)}const sR=s=>s===Ip||s===Di,oR=(s,l)=>parseFloat(s.split(", ")[l]),aR=(s,l)=>(p,{transform:x})=>{if(x==="none"||!x)return 0;const T=x.match(/^matrix3d\((.+)\)$/u);if(T)return oR(T[1],l);{const C=x.match(/^matrix\((.+)\)$/u);return C?oR(C[1],s):0}},Jj=new Set(["x","y","z"]),Qj=Ep.filter(s=>!Jj.has(s));function e6(s){const l=[];return Qj.forEach(p=>{const x=s.getValue(p);x!==void 0&&(l.push([p,x.get()]),x.set(p.startsWith("scale")?1:0))}),l}const yp={width:({x:s},{paddingLeft:l="0",paddingRight:p="0"})=>s.max-s.min-parseFloat(l)-parseFloat(p),height:({y:s},{paddingTop:l="0",paddingBottom:p="0"})=>s.max-s.min-parseFloat(l)-parseFloat(p),top:(s,{top:l})=>parseFloat(l),left:(s,{left:l})=>parseFloat(l),bottom:({y:s},{top:l})=>parseFloat(l)+(s.max-s.min),right:({x:s},{left:l})=>parseFloat(l)+(s.max-s.min),x:aR(4,13),y:aR(5,14)};yp.translateX=yp.x;yp.translateY=yp.y;const qh=new Set;let xS=!1,vS=!1;function zk(){if(vS){const s=Array.from(qh).filter(x=>x.needsMeasurement),l=new Set(s.map(x=>x.element)),p=new Map;l.forEach(x=>{const T=e6(x);T.length&&(p.set(x,T),x.render())}),s.forEach(x=>x.measureInitialState()),l.forEach(x=>{x.render();const T=p.get(x);T&&T.forEach(([C,L])=>{var a;(a=x.getValue(C))===null||a===void 0||a.set(L)})}),s.forEach(x=>x.measureEndState()),s.forEach(x=>{x.suspendedScrollY!==void 0&&window.scrollTo(0,x.suspendedScrollY)})}vS=!1,xS=!1,qh.forEach(s=>s.complete()),qh.clear()}function kk(){qh.forEach(s=>{s.readKeyframes(),s.needsMeasurement&&(vS=!0)})}function t6(){kk(),zk()}class oE{constructor(l,p,x,T,C,L=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...l],this.onComplete=p,this.name=x,this.motionValue=T,this.element=C,this.isAsync=L}scheduleResolve(){this.isScheduled=!0,this.isAsync?(qh.add(this),xS||(xS=!0,tr.read(kk),tr.resolveKeyframes(zk))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:l,name:p,element:x,motionValue:T}=this;for(let C=0;C<l.length;C++)if(l[C]===null)if(C===0){const L=T==null?void 0:T.get(),a=l[l.length-1];if(L!==void 0)l[0]=L;else if(x&&p){const F=x.readValue(p,a);F!=null&&(l[0]=F)}l[0]===void 0&&(l[0]=a),T&&L===void 0&&T.set(l[0])}else l[C]=l[C-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),qh.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,qh.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const Fk=s=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(s),i6=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function n6(s){const l=i6.exec(s);if(!l)return[,];const[,p,x,T]=l;return[`--${p??x}`,T]}function Ok(s,l,p=1){const[x,T]=n6(s);if(!x)return;const C=window.getComputedStyle(l).getPropertyValue(x);if(C){const L=C.trim();return Fk(L)?parseFloat(L):L}return U2(T)?Ok(T,l,p+1):T}const Bk=s=>l=>l.test(s),r6={test:s=>s==="auto",parse:s=>s},Nk=[Ip,Di,hl,eu,qU,ZU,r6],lR=s=>Nk.find(Bk(s));class Vk extends oE{constructor(l,p,x,T,C){super(l,p,x,T,C,!0)}readKeyframes(){const{unresolvedKeyframes:l,element:p,name:x}=this;if(!p||!p.current)return;super.readKeyframes();for(let F=0;F<l.length;F++){let H=l[F];if(typeof H=="string"&&(H=H.trim(),U2(H))){const ee=Ok(H,p.current);ee!==void 0&&(l[F]=ee),F===l.length-1&&(this.finalKeyframe=H)}}if(this.resolveNoneKeyframes(),!_k.has(x)||l.length!==2)return;const[T,C]=l,L=lR(T),a=lR(C);if(L!==a)if(sR(L)&&sR(a))for(let F=0;F<l.length;F++){const H=l[F];typeof H=="string"&&(l[F]=parseFloat(H))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:l,name:p}=this,x=[];for(let T=0;T<l.length;T++)zj(l[T])&&x.push(T);x.length&&Kj(l,x,p)}measureInitialState(){const{element:l,unresolvedKeyframes:p,name:x}=this;if(!l||!l.current)return;x==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=yp[x](l.measureViewportBox(),window.getComputedStyle(l.current)),p[0]=this.measuredOrigin;const T=p[p.length-1];T!==void 0&&l.getValue(x,T).jump(T,!1)}measureEndState(){var l;const{element:p,name:x,unresolvedKeyframes:T}=this;if(!p||!p.current)return;const C=p.getValue(x);C&&C.jump(this.measuredOrigin,!1);const L=T.length-1,a=T[L];T[L]=yp[x](p.measureViewportBox(),window.getComputedStyle(p.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),!((l=this.removedTransforms)===null||l===void 0)&&l.length&&this.removedTransforms.forEach(([F,H])=>{p.getValue(F).set(H)}),this.resolveNoneKeyframes()}}const cR=(s,l)=>l==="zIndex"?!1:!!(typeof s=="number"||Array.isArray(s)||typeof s=="string"&&(xu.test(s)||s==="0")&&!s.startsWith("url("));function s6(s){const l=s[0];if(s.length===1)return!0;for(let p=0;p<s.length;p++)if(s[p]!==l)return!0}function o6(s,l,p,x){const T=s[0];if(T===null)return!1;if(l==="display"||l==="visibility")return!0;const C=s[s.length-1],L=cR(T,l),a=cR(C,l);return!L||!a?!1:s6(s)||(p==="spring"||X2(p))&&x}const a6=s=>s!==null;function l1(s,{repeat:l,repeatType:p="loop"},x){const T=s.filter(a6),C=l&&p!=="loop"&&l%2===1?0:T.length-1;return!C||x===void 0?T[C]:x}const l6=40;class Uk{constructor({autoplay:l=!0,delay:p=0,type:x="keyframes",repeat:T=0,repeatDelay:C=0,repeatType:L="loop",...a}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=dl.now(),this.options={autoplay:l,delay:p,type:x,repeat:T,repeatDelay:C,repeatType:L,...a},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>l6?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&t6(),this._resolved}onKeyframesResolved(l,p){this.resolvedAt=dl.now(),this.hasAttemptedResolve=!0;const{name:x,type:T,velocity:C,delay:L,onComplete:a,onUpdate:F,isGenerator:H}=this.options;if(!H&&!o6(l,x,T,C))if(L)this.options.duration=0;else{F&&F(l1(l,this.options,p)),a&&a(),this.resolveFinishedPromise();return}const ee=this.initPlayback(l,p);ee!==!1&&(this._resolved={keyframes:l,finalKeyframe:p,...ee},this.onPostResolved())}onPostResolved(){}then(l,p){return this.currentFinishedPromise.then(l,p)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(l=>{this.resolveFinishedPromise=l})}}const fr=(s,l,p)=>s+(l-s)*p;function tT(s,l,p){return p<0&&(p+=1),p>1&&(p-=1),p<1/6?s+(l-s)*6*p:p<1/2?l:p<2/3?s+(l-s)*(2/3-p)*6:s}function c6({hue:s,saturation:l,lightness:p,alpha:x}){s/=360,l/=100,p/=100;let T=0,C=0,L=0;if(!l)T=C=L=p;else{const a=p<.5?p*(1+l):p+l-p*l,F=2*p-a;T=tT(F,a,s+1/3),C=tT(F,a,s),L=tT(F,a,s-1/3)}return{red:Math.round(T*255),green:Math.round(C*255),blue:Math.round(L*255),alpha:x}}function L0(s,l){return p=>p>0?l:s}const iT=(s,l,p)=>{const x=s*s,T=p*(l*l-x)+x;return T<0?0:Math.sqrt(T)},u6=[gS,Gh,Kf],h6=s=>u6.find(l=>l.test(s));function uR(s){const l=h6(s);if(!l)return!1;let p=l.parse(s);return l===Kf&&(p=c6(p)),p}const hR=(s,l)=>{const p=uR(s),x=uR(l);if(!p||!x)return L0(s,l);const T={...p};return C=>(T.red=iT(p.red,x.red,C),T.green=iT(p.green,x.green,C),T.blue=iT(p.blue,x.blue,C),T.alpha=fr(p.alpha,x.alpha,C),Gh.transform(T))},d6=(s,l)=>p=>l(s(p)),Yg=(...s)=>s.reduce(d6),bS=new Set(["none","hidden"]);function f6(s,l){return bS.has(s)?p=>p<=0?s:l:p=>p>=1?l:s}function p6(s,l){return p=>fr(s,l,p)}function aE(s){return typeof s=="number"?p6:typeof s=="string"?U2(s)?L0:bs.test(s)?hR:g6:Array.isArray(s)?jk:typeof s=="object"?bs.test(s)?hR:m6:L0}function jk(s,l){const p=[...s],x=p.length,T=s.map((C,L)=>aE(C)(C,l[L]));return C=>{for(let L=0;L<x;L++)p[L]=T[L](C);return p}}function m6(s,l){const p={...s,...l},x={};for(const T in p)s[T]!==void 0&&l[T]!==void 0&&(x[T]=aE(s[T])(s[T],l[T]));return T=>{for(const C in x)p[C]=x[C](T);return p}}function _6(s,l){var p;const x=[],T={color:0,var:0,number:0};for(let C=0;C<l.values.length;C++){const L=l.types[C],a=s.indexes[L][T[L]],F=(p=s.values[a])!==null&&p!==void 0?p:0;x[C]=F,T[L]++}return x}const g6=(s,l)=>{const p=xu.createTransformer(l),x=Bg(s),T=Bg(l);return x.indexes.var.length===T.indexes.var.length&&x.indexes.color.length===T.indexes.color.length&&x.indexes.number.length>=T.indexes.number.length?bS.has(s)&&!T.values.length||bS.has(l)&&!x.values.length?f6(s,l):Yg(jk(_6(x,T),T.values),p):L0(s,l)};function Gk(s,l,p){return typeof s=="number"&&typeof l=="number"&&typeof p=="number"?fr(s,l,p):aE(s)(s,l)}const y6=5;function $k(s,l,p){const x=Math.max(l-y6,0);return gk(p-s(x),l-x)}const yr={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},nT=.001;function x6({duration:s=yr.duration,bounce:l=yr.bounce,velocity:p=yr.velocity,mass:x=yr.mass}){let T,C,L=1-l;L=ac(yr.minDamping,yr.maxDamping,L),s=ac(yr.minDuration,yr.maxDuration,ec(s)),L<1?(T=H=>{const ee=H*L,se=ee*s,ue=ee-p,Me=wS(H,L),Ve=Math.exp(-se);return nT-ue/Me*Ve},C=H=>{const se=H*L*s,ue=se*p+p,Me=Math.pow(L,2)*Math.pow(H,2)*s,Ve=Math.exp(-se),ke=wS(Math.pow(H,2),L);return(-T(H)+nT>0?-1:1)*((ue-Me)*Ve)/ke}):(T=H=>{const ee=Math.exp(-H*s),se=(H-p)*s+1;return-nT+ee*se},C=H=>{const ee=Math.exp(-H*s),se=(p-H)*(s*s);return ee*se});const a=5/s,F=b6(T,C,a);if(s=Ql(s),isNaN(F))return{stiffness:yr.stiffness,damping:yr.damping,duration:s};{const H=Math.pow(F,2)*x;return{stiffness:H,damping:L*2*Math.sqrt(x*H),duration:s}}}const v6=12;function b6(s,l,p){let x=p;for(let T=1;T<v6;T++)x=x-s(x)/l(x);return x}function wS(s,l){return s*Math.sqrt(1-l*l)}const w6=["duration","bounce"],T6=["stiffness","damping","mass"];function dR(s,l){return l.some(p=>s[p]!==void 0)}function S6(s){let l={velocity:yr.velocity,stiffness:yr.stiffness,damping:yr.damping,mass:yr.mass,isResolvedFromDuration:!1,...s};if(!dR(s,T6)&&dR(s,w6))if(s.visualDuration){const p=s.visualDuration,x=2*Math.PI/(p*1.2),T=x*x,C=2*ac(.05,1,1-(s.bounce||0))*Math.sqrt(T);l={...l,mass:yr.mass,stiffness:T,damping:C}}else{const p=x6(s);l={...l,...p,mass:yr.mass},l.isResolvedFromDuration=!0}return l}function Hk(s=yr.visualDuration,l=yr.bounce){const p=typeof s!="object"?{visualDuration:s,keyframes:[0,1],bounce:l}:s;let{restSpeed:x,restDelta:T}=p;const C=p.keyframes[0],L=p.keyframes[p.keyframes.length-1],a={done:!1,value:C},{stiffness:F,damping:H,mass:ee,duration:se,velocity:ue,isResolvedFromDuration:Me}=S6({...p,velocity:-ec(p.velocity||0)}),Ve=ue||0,ke=H/(2*Math.sqrt(F*ee)),Ye=L-C,Se=ec(Math.sqrt(F/ee)),ye=Math.abs(Ye)<5;x||(x=ye?yr.restSpeed.granular:yr.restSpeed.default),T||(T=ye?yr.restDelta.granular:yr.restDelta.default);let Ie;if(ke<1){const ot=wS(Se,ke);Ie=xt=>{const Rt=Math.exp(-ke*Se*xt);return L-Rt*((Ve+ke*Se*Ye)/ot*Math.sin(ot*xt)+Ye*Math.cos(ot*xt))}}else if(ke===1)Ie=ot=>L-Math.exp(-Se*ot)*(Ye+(Ve+Se*Ye)*ot);else{const ot=Se*Math.sqrt(ke*ke-1);Ie=xt=>{const Rt=Math.exp(-ke*Se*xt),Tt=Math.min(ot*xt,300);return L-Rt*((Ve+ke*Se*Ye)*Math.sinh(Tt)+ot*Ye*Math.cosh(Tt))/ot}}const qe={calculatedDuration:Me&&se||null,next:ot=>{const xt=Ie(ot);if(Me)a.done=ot>=se;else{let Rt=0;ke<1&&(Rt=ot===0?Ql(Ve):$k(Ie,ot,xt));const Tt=Math.abs(Rt)<=x,li=Math.abs(L-xt)<=T;a.done=Tt&&li}return a.value=a.done?L:xt,a},toString:()=>{const ot=Math.min(ck(qe),pS),xt=uk(Rt=>qe.next(ot*Rt).value,ot,30);return ot+"ms "+xt}};return qe}function fR({keyframes:s,velocity:l=0,power:p=.8,timeConstant:x=325,bounceDamping:T=10,bounceStiffness:C=500,modifyTarget:L,min:a,max:F,restDelta:H=.5,restSpeed:ee}){const se=s[0],ue={done:!1,value:se},Me=Tt=>a!==void 0&&Tt<a||F!==void 0&&Tt>F,Ve=Tt=>a===void 0?F:F===void 0||Math.abs(a-Tt)<Math.abs(F-Tt)?a:F;let ke=p*l;const Ye=se+ke,Se=L===void 0?Ye:L(Ye);Se!==Ye&&(ke=Se-se);const ye=Tt=>-ke*Math.exp(-Tt/x),Ie=Tt=>Se+ye(Tt),qe=Tt=>{const li=ye(Tt),Xt=Ie(Tt);ue.done=Math.abs(li)<=H,ue.value=ue.done?Se:Xt};let ot,xt;const Rt=Tt=>{Me(ue.value)&&(ot=Tt,xt=Hk({keyframes:[ue.value,Ve(ue.value)],velocity:$k(Ie,Tt,ue.value),damping:T,stiffness:C,restDelta:H,restSpeed:ee}))};return Rt(0),{calculatedDuration:null,next:Tt=>{let li=!1;return!xt&&ot===void 0&&(li=!0,qe(Tt),Rt(Tt)),ot!==void 0&&Tt>=ot?xt.next(Tt-ot):(!li&&qe(Tt),ue)}}}const E6=Xg(.42,0,1,1),I6=Xg(0,0,.58,1),Zk=Xg(.42,0,.58,1),A6=s=>Array.isArray(s)&&typeof s[0]!="number",C6={linear:Eo,easeIn:E6,easeInOut:Zk,easeOut:I6,circIn:iE,circInOut:Ik,circOut:Ek,backIn:tE,backInOut:Tk,backOut:wk,anticipate:Sk},pR=s=>{if(Y2(s)){Gz(s.length===4);const[l,p,x,T]=s;return Xg(l,p,x,T)}else if(typeof s=="string")return C6[s];return s};function P6(s,l,p){const x=[],T=p||Gk,C=s.length-1;for(let L=0;L<C;L++){let a=T(s[L],s[L+1]);if(l){const F=Array.isArray(l)?l[L]||Eo:l;a=Yg(F,a)}x.push(a)}return x}function M6(s,l,{clamp:p=!0,ease:x,mixer:T}={}){const C=s.length;if(Gz(C===l.length),C===1)return()=>l[0];if(C===2&&l[0]===l[1])return()=>l[1];const L=s[0]===s[1];s[0]>s[C-1]&&(s=[...s].reverse(),l=[...l].reverse());const a=P6(l,x,T),F=a.length,H=ee=>{if(L&&ee<s[0])return l[0];let se=0;if(F>1)for(;se<s.length-2&&!(ee<s[se+1]);se++);const ue=_p(s[se],s[se+1],ee);return a[se](ue)};return p?ee=>H(ac(s[0],s[C-1],ee)):H}function R6(s,l){const p=s[s.length-1];for(let x=1;x<=l;x++){const T=_p(0,l,x);s.push(fr(p,1,T))}}function D6(s){const l=[0];return R6(l,s.length-1),l}function L6(s,l){return s.map(p=>p*l)}function z6(s,l){return s.map(()=>l||Zk).splice(0,s.length-1)}function z0({duration:s=300,keyframes:l,times:p,ease:x="easeInOut"}){const T=A6(x)?x.map(pR):pR(x),C={done:!1,value:l[0]},L=L6(p&&p.length===l.length?p:D6(l),s),a=M6(L,l,{ease:Array.isArray(T)?T:z6(l,T)});return{calculatedDuration:s,next:F=>(C.value=a(F),C.done=F>=s,C)}}const k6=s=>{const l=({timestamp:p})=>s(p);return{start:()=>tr.update(l,!0),stop:()=>yu(l),now:()=>as.isProcessing?as.timestamp:dl.now()}},F6={decay:fR,inertia:fR,tween:z0,keyframes:z0,spring:Hk},O6=s=>s/100;class lE extends Uk{constructor(l){super(l),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:F}=this.options;F&&F()};const{name:p,motionValue:x,element:T,keyframes:C}=this.options,L=(T==null?void 0:T.KeyframeResolver)||oE,a=(F,H)=>this.onKeyframesResolved(F,H);this.resolver=new L(C,a,p,x,T),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(l){const{type:p="keyframes",repeat:x=0,repeatDelay:T=0,repeatType:C,velocity:L=0}=this.options,a=X2(p)?p:F6[p]||z0;let F,H;a!==z0&&typeof l[0]!="number"&&(F=Yg(O6,Gk(l[0],l[1])),l=[0,100]);const ee=a({...this.options,keyframes:l});C==="mirror"&&(H=a({...this.options,keyframes:[...l].reverse(),velocity:-L})),ee.calculatedDuration===null&&(ee.calculatedDuration=ck(ee));const{calculatedDuration:se}=ee,ue=se+T,Me=ue*(x+1)-T;return{generator:ee,mirroredGenerator:H,mapPercentToKeyframes:F,calculatedDuration:se,resolvedDuration:ue,totalDuration:Me}}onPostResolved(){const{autoplay:l=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!l?this.pause():this.state=this.pendingPlayState}tick(l,p=!1){const{resolved:x}=this;if(!x){const{keyframes:Tt}=this.options;return{done:!0,value:Tt[Tt.length-1]}}const{finalKeyframe:T,generator:C,mirroredGenerator:L,mapPercentToKeyframes:a,keyframes:F,calculatedDuration:H,totalDuration:ee,resolvedDuration:se}=x;if(this.startTime===null)return C.next(0);const{delay:ue,repeat:Me,repeatType:Ve,repeatDelay:ke,onUpdate:Ye}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,l):this.speed<0&&(this.startTime=Math.min(l-ee/this.speed,this.startTime)),p?this.currentTime=l:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(l-this.startTime)*this.speed;const Se=this.currentTime-ue*(this.speed>=0?1:-1),ye=this.speed>=0?Se<0:Se>ee;this.currentTime=Math.max(Se,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=ee);let Ie=this.currentTime,qe=C;if(Me){const Tt=Math.min(this.currentTime,ee)/se;let li=Math.floor(Tt),Xt=Tt%1;!Xt&&Tt>=1&&(Xt=1),Xt===1&&li--,li=Math.min(li,Me+1),!!(li%2)&&(Ve==="reverse"?(Xt=1-Xt,ke&&(Xt-=ke/se)):Ve==="mirror"&&(qe=L)),Ie=ac(0,1,Xt)*se}const ot=ye?{done:!1,value:F[0]}:qe.next(Ie);a&&(ot.value=a(ot.value));let{done:xt}=ot;!ye&&H!==null&&(xt=this.speed>=0?this.currentTime>=ee:this.currentTime<=0);const Rt=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&xt);return Rt&&T!==void 0&&(ot.value=l1(F,this.options,T)),Ye&&Ye(ot.value),Rt&&this.finish(),ot}get duration(){const{resolved:l}=this;return l?ec(l.calculatedDuration):0}get time(){return ec(this.currentTime)}set time(l){l=Ql(l),this.currentTime=l,this.holdTime!==null||this.speed===0?this.holdTime=l:this.driver&&(this.startTime=this.driver.now()-l/this.speed)}get speed(){return this.playbackSpeed}set speed(l){const p=this.playbackSpeed!==l;this.playbackSpeed=l,p&&(this.time=ec(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:l=k6,onPlay:p,startTime:x}=this.options;this.driver||(this.driver=l(C=>this.tick(C))),p&&p();const T=this.driver.now();this.holdTime!==null?this.startTime=T-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=T):this.startTime=x??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var l;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(l=this.currentTime)!==null&&l!==void 0?l:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:l}=this.options;l&&l()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(l){return this.startTime=0,this.tick(l,!0)}}const B6=new Set(["opacity","clipPath","filter","transform"]);function N6(s,l,p,{delay:x=0,duration:T=300,repeat:C=0,repeatType:L="loop",ease:a="easeInOut",times:F}={}){const H={[l]:p};F&&(H.offset=F);const ee=dk(a,T);return Array.isArray(ee)&&(H.easing=ee),s.animate(H,{delay:x,duration:T,easing:Array.isArray(ee)?"linear":ee,fill:"both",iterations:C+1,direction:L==="reverse"?"alternate":"normal"})}const V6=z2(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),k0=10,U6=2e4;function j6(s){return X2(s.type)||s.type==="spring"||!hk(s.ease)}function G6(s,l){const p=new lE({...l,keyframes:s,repeat:0,delay:0,isGenerator:!0});let x={done:!1,value:s[0]};const T=[];let C=0;for(;!x.done&&C<U6;)x=p.sample(C),T.push(x.value),C+=k0;return{times:void 0,keyframes:T,duration:C-k0,ease:"linear"}}const qk={anticipate:Sk,backInOut:Tk,circInOut:Ik};function $6(s){return s in qk}class mR extends Uk{constructor(l){super(l);const{name:p,motionValue:x,element:T,keyframes:C}=this.options;this.resolver=new Vk(C,(L,a)=>this.onKeyframesResolved(L,a),p,x,T),this.resolver.scheduleResolve()}initPlayback(l,p){let{duration:x=300,times:T,ease:C,type:L,motionValue:a,name:F,startTime:H}=this.options;if(!a.owner||!a.owner.current)return!1;if(typeof C=="string"&&D0()&&$6(C)&&(C=qk[C]),j6(this.options)){const{onComplete:se,onUpdate:ue,motionValue:Me,element:Ve,...ke}=this.options,Ye=G6(l,ke);l=Ye.keyframes,l.length===1&&(l[1]=l[0]),x=Ye.duration,T=Ye.times,C=Ye.ease,L="keyframes"}const ee=N6(a.owner.current,F,l,{...this.options,duration:x,times:T,ease:C});return ee.startTime=H??this.calcStartTime(),this.pendingTimeline?(QM(ee,this.pendingTimeline),this.pendingTimeline=void 0):ee.onfinish=()=>{const{onComplete:se}=this.options;a.set(l1(l,this.options,p)),se&&se(),this.cancel(),this.resolveFinishedPromise()},{animation:ee,duration:x,times:T,type:L,ease:C,keyframes:l}}get duration(){const{resolved:l}=this;if(!l)return 0;const{duration:p}=l;return ec(p)}get time(){const{resolved:l}=this;if(!l)return 0;const{animation:p}=l;return ec(p.currentTime||0)}set time(l){const{resolved:p}=this;if(!p)return;const{animation:x}=p;x.currentTime=Ql(l)}get speed(){const{resolved:l}=this;if(!l)return 1;const{animation:p}=l;return p.playbackRate}set speed(l){const{resolved:p}=this;if(!p)return;const{animation:x}=p;x.playbackRate=l}get state(){const{resolved:l}=this;if(!l)return"idle";const{animation:p}=l;return p.playState}get startTime(){const{resolved:l}=this;if(!l)return null;const{animation:p}=l;return p.startTime}attachTimeline(l){if(!this._resolved)this.pendingTimeline=l;else{const{resolved:p}=this;if(!p)return Eo;const{animation:x}=p;QM(x,l)}return Eo}play(){if(this.isStopped)return;const{resolved:l}=this;if(!l)return;const{animation:p}=l;p.playState==="finished"&&this.updateFinishedPromise(),p.play()}pause(){const{resolved:l}=this;if(!l)return;const{animation:p}=l;p.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:l}=this;if(!l)return;const{animation:p,keyframes:x,duration:T,type:C,ease:L,times:a}=l;if(p.playState==="idle"||p.playState==="finished")return;if(this.time){const{motionValue:H,onUpdate:ee,onComplete:se,element:ue,...Me}=this.options,Ve=new lE({...Me,keyframes:x,duration:T,type:C,ease:L,times:a,isGenerator:!0}),ke=Ql(this.time);H.setWithVelocity(Ve.sample(ke-k0).value,Ve.sample(ke).value,k0)}const{onStop:F}=this.options;F&&F(),this.cancel()}complete(){const{resolved:l}=this;l&&l.animation.finish()}cancel(){const{resolved:l}=this;l&&l.animation.cancel()}static supports(l){const{motionValue:p,name:x,repeatDelay:T,repeatType:C,damping:L,type:a}=l;if(!p||!p.owner||!(p.owner.current instanceof HTMLElement))return!1;const{onUpdate:F,transformTemplate:H}=p.owner.getProps();return V6()&&x&&B6.has(x)&&!F&&!H&&!T&&C!=="mirror"&&L!==0&&a!=="inertia"}}const H6={type:"spring",stiffness:500,damping:25,restSpeed:10},Z6=s=>({type:"spring",stiffness:550,damping:s===0?2*Math.sqrt(550):30,restSpeed:10}),q6={type:"keyframes",duration:.8},W6={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},X6=(s,{keyframes:l})=>l.length>2?q6:td.has(s)?s.startsWith("scale")?Z6(l[1]):H6:W6;function Y6({when:s,delay:l,delayChildren:p,staggerChildren:x,staggerDirection:T,repeat:C,repeatType:L,repeatDelay:a,from:F,elapsed:H,...ee}){return!!Object.keys(ee).length}const cE=(s,l,p,x={},T,C)=>L=>{const a=W2(x,s)||{},F=a.delay||x.delay||0;let{elapsed:H=0}=x;H=H-Ql(F);let ee={keyframes:Array.isArray(p)?p:[null,p],ease:"easeOut",velocity:l.getVelocity(),...a,delay:-H,onUpdate:ue=>{l.set(ue),a.onUpdate&&a.onUpdate(ue)},onComplete:()=>{L(),a.onComplete&&a.onComplete()},name:s,motionValue:l,element:C?void 0:T};Y6(a)||(ee={...ee,...X6(s,ee)}),ee.duration&&(ee.duration=Ql(ee.duration)),ee.repeatDelay&&(ee.repeatDelay=Ql(ee.repeatDelay)),ee.from!==void 0&&(ee.keyframes[0]=ee.from);let se=!1;if((ee.type===!1||ee.duration===0&&!ee.repeatDelay)&&(ee.duration=0,ee.delay===0&&(se=!0)),se&&!C&&l.get()!==void 0){const ue=l1(ee.keyframes,a);if(ue!==void 0)return tr.update(()=>{ee.onUpdate(ue),ee.onComplete()}),new mj([])}return!C&&mR.supports(ee)?new mR(ee):new lE(ee)};function K6({protectedKeys:s,needsAnimating:l},p){const x=s.hasOwnProperty(p)&&l[p]!==!0;return l[p]=!1,x}function Wk(s,l,{delay:p=0,transitionOverride:x,type:T}={}){var C;let{transition:L=s.getDefaultTransition(),transitionEnd:a,...F}=l;x&&(L=x);const H=[],ee=T&&s.animationState&&s.animationState.getState()[T];for(const se in F){const ue=s.getValue(se,(C=s.latestValues[se])!==null&&C!==void 0?C:null),Me=F[se];if(Me===void 0||ee&&K6(ee,se))continue;const Ve={delay:p,...W2(L||{},se)};let ke=!1;if(window.MotionHandoffAnimation){const Se=yk(s);if(Se){const ye=window.MotionHandoffAnimation(Se,se,tr);ye!==null&&(Ve.startTime=ye,ke=!0)}}_S(s,se),ue.start(cE(se,ue,Me,s.shouldReduceMotion&&_k.has(se)?{type:!1}:Ve,s,ke));const Ye=ue.animation;Ye&&H.push(Ye)}return a&&Promise.all(H).then(()=>{tr.update(()=>{a&&Pj(s,a)})}),H}function TS(s,l,p={}){var x;const T=a1(s,l,p.type==="exit"?(x=s.presenceContext)===null||x===void 0?void 0:x.custom:void 0);let{transition:C=s.getDefaultTransition()||{}}=T||{};p.transitionOverride&&(C=p.transitionOverride);const L=T?()=>Promise.all(Wk(s,T,p)):()=>Promise.resolve(),a=s.variantChildren&&s.variantChildren.size?(H=0)=>{const{delayChildren:ee=0,staggerChildren:se,staggerDirection:ue}=C;return J6(s,l,ee+H,se,ue,p)}:()=>Promise.resolve(),{when:F}=C;if(F){const[H,ee]=F==="beforeChildren"?[L,a]:[a,L];return H().then(()=>ee())}else return Promise.all([L(),a(p.delay)])}function J6(s,l,p=0,x=0,T=1,C){const L=[],a=(s.variantChildren.size-1)*x,F=T===1?(H=0)=>H*x:(H=0)=>a-H*x;return Array.from(s.variantChildren).sort(Q6).forEach((H,ee)=>{H.notify("AnimationStart",l),L.push(TS(H,l,{...C,delay:p+F(ee)}).then(()=>H.notify("AnimationComplete",l)))}),Promise.all(L)}function Q6(s,l){return s.sortNodePosition(l)}function e8(s,l,p={}){s.notify("AnimationStart",l);let x;if(Array.isArray(l)){const T=l.map(C=>TS(s,C,p));x=Promise.all(T)}else if(typeof l=="string")x=TS(s,l,p);else{const T=typeof l=="function"?a1(s,l,p.custom):l;x=Promise.all(Wk(s,T,p))}return x.then(()=>{s.notify("AnimationComplete",l)})}const t8=F2.length;function Xk(s){if(!s)return;if(!s.isControllingVariants){const p=s.parent?Xk(s.parent)||{}:{};return s.props.initial!==void 0&&(p.initial=s.props.initial),p}const l={};for(let p=0;p<t8;p++){const x=F2[p],T=s.props[x];(kg(T)||T===!1)&&(l[x]=T)}return l}const i8=[...k2].reverse(),n8=k2.length;function r8(s){return l=>Promise.all(l.map(({animation:p,options:x})=>e8(s,p,x)))}function s8(s){let l=r8(s),p=_R(),x=!0;const T=F=>(H,ee)=>{var se;const ue=a1(s,ee,F==="exit"?(se=s.presenceContext)===null||se===void 0?void 0:se.custom:void 0);if(ue){const{transition:Me,transitionEnd:Ve,...ke}=ue;H={...H,...ke,...Ve}}return H};function C(F){l=F(s)}function L(F){const{props:H}=s,ee=Xk(s.parent)||{},se=[],ue=new Set;let Me={},Ve=1/0;for(let Ye=0;Ye<n8;Ye++){const Se=i8[Ye],ye=p[Se],Ie=H[Se]!==void 0?H[Se]:ee[Se],qe=kg(Ie),ot=Se===F?ye.isActive:null;ot===!1&&(Ve=Ye);let xt=Ie===ee[Se]&&Ie!==H[Se]&&qe;if(xt&&x&&s.manuallyAnimateOnMount&&(xt=!1),ye.protectedKeys={...Me},!ye.isActive&&ot===null||!Ie&&!ye.prevProp||s1(Ie)||typeof Ie=="boolean")continue;const Rt=o8(ye.prevProp,Ie);let Tt=Rt||Se===F&&ye.isActive&&!xt&&qe||Ye>Ve&&qe,li=!1;const Xt=Array.isArray(Ie)?Ie:[Ie];let Ji=Xt.reduce(T(Se),{});ot===!1&&(Ji={});const{prevResolvedValues:An={}}=ye,gi={...An,...Ji},Mr=ti=>{Tt=!0,ue.has(ti)&&(li=!0,ue.delete(ti)),ye.needsAnimating[ti]=!0;const Pt=s.getValue(ti);Pt&&(Pt.liveStyle=!1)};for(const ti in gi){const Pt=Ji[ti],$t=An[ti];if(Me.hasOwnProperty(ti))continue;let Wt=!1;fS(Pt)&&fS($t)?Wt=!lk(Pt,$t):Wt=Pt!==$t,Wt?Pt!=null?Mr(ti):ue.add(ti):Pt!==void 0&&ue.has(ti)?Mr(ti):ye.protectedKeys[ti]=!0}ye.prevProp=Ie,ye.prevResolvedValues=Ji,ye.isActive&&(Me={...Me,...Ji}),x&&s.blockInitialAnimation&&(Tt=!1),Tt&&(!(xt&&Rt)||li)&&se.push(...Xt.map(ti=>({animation:ti,options:{type:Se}})))}if(ue.size){const Ye={};ue.forEach(Se=>{const ye=s.getBaseTarget(Se),Ie=s.getValue(Se);Ie&&(Ie.liveStyle=!0),Ye[Se]=ye??null}),se.push({animation:Ye})}let ke=!!se.length;return x&&(H.initial===!1||H.initial===H.animate)&&!s.manuallyAnimateOnMount&&(ke=!1),x=!1,ke?l(se):Promise.resolve()}function a(F,H){var ee;if(p[F].isActive===H)return Promise.resolve();(ee=s.variantChildren)===null||ee===void 0||ee.forEach(ue=>{var Me;return(Me=ue.animationState)===null||Me===void 0?void 0:Me.setActive(F,H)}),p[F].isActive=H;const se=L(F);for(const ue in p)p[ue].protectedKeys={};return se}return{animateChanges:L,setActive:a,setAnimateFunction:C,getState:()=>p,reset:()=>{p=_R(),x=!0}}}function o8(s,l){return typeof l=="string"?l!==s:Array.isArray(l)?!lk(l,s):!1}function kh(s=!1){return{isActive:s,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function _R(){return{animate:kh(!0),whileInView:kh(),whileHover:kh(),whileTap:kh(),whileDrag:kh(),whileFocus:kh(),exit:kh()}}class Su{constructor(l){this.isMounted=!1,this.node=l}update(){}}class a8 extends Su{constructor(l){super(l),l.animationState||(l.animationState=s8(l))}updateAnimationControlsSubscription(){const{animate:l}=this.node.getProps();s1(l)&&(this.unmountControls=l.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:l}=this.node.getProps(),{animate:p}=this.node.prevProps||{};l!==p&&this.updateAnimationControlsSubscription()}unmount(){var l;this.node.animationState.reset(),(l=this.unmountControls)===null||l===void 0||l.call(this)}}let l8=0;class c8 extends Su{constructor(){super(...arguments),this.id=l8++}update(){if(!this.node.presenceContext)return;const{isPresent:l,onExitComplete:p}=this.node.presenceContext,{isPresent:x}=this.node.prevPresenceContext||{};if(!this.node.animationState||l===x)return;const T=this.node.animationState.setActive("exit",!l);p&&!l&&T.then(()=>p(this.id))}mount(){const{register:l}=this.node.presenceContext||{};l&&(this.unmount=l(this.id))}unmount(){}}const u8={animation:{Feature:a8},exit:{Feature:c8}};function Ng(s,l,p,x={passive:!0}){return s.addEventListener(l,p,x),()=>s.removeEventListener(l,p)}function Kg(s){return{point:{x:s.pageX,y:s.pageY}}}const h8=s=>l=>K2(l)&&s(l,Kg(l));function dg(s,l,p,x){return Ng(s,l,h8(p),x)}const gR=(s,l)=>Math.abs(s-l);function d8(s,l){const p=gR(s.x,l.x),x=gR(s.y,l.y);return Math.sqrt(p**2+x**2)}class Yk{constructor(l,p,{transformPagePoint:x,contextWindow:T,dragSnapToOrigin:C=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const se=sT(this.lastMoveEventInfo,this.history),ue=this.startEvent!==null,Me=d8(se.offset,{x:0,y:0})>=3;if(!ue&&!Me)return;const{point:Ve}=se,{timestamp:ke}=as;this.history.push({...Ve,timestamp:ke});const{onStart:Ye,onMove:Se}=this.handlers;ue||(Ye&&Ye(this.lastMoveEvent,se),this.startEvent=this.lastMoveEvent),Se&&Se(this.lastMoveEvent,se)},this.handlePointerMove=(se,ue)=>{this.lastMoveEvent=se,this.lastMoveEventInfo=rT(ue,this.transformPagePoint),tr.update(this.updatePoint,!0)},this.handlePointerUp=(se,ue)=>{this.end();const{onEnd:Me,onSessionEnd:Ve,resumeAnimation:ke}=this.handlers;if(this.dragSnapToOrigin&&ke&&ke(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const Ye=sT(se.type==="pointercancel"?this.lastMoveEventInfo:rT(ue,this.transformPagePoint),this.history);this.startEvent&&Me&&Me(se,Ye),Ve&&Ve(se,Ye)},!K2(l))return;this.dragSnapToOrigin=C,this.handlers=p,this.transformPagePoint=x,this.contextWindow=T||window;const L=Kg(l),a=rT(L,this.transformPagePoint),{point:F}=a,{timestamp:H}=as;this.history=[{...F,timestamp:H}];const{onSessionStart:ee}=p;ee&&ee(l,sT(a,this.history)),this.removeListeners=Yg(dg(this.contextWindow,"pointermove",this.handlePointerMove),dg(this.contextWindow,"pointerup",this.handlePointerUp),dg(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(l){this.handlers=l}end(){this.removeListeners&&this.removeListeners(),yu(this.updatePoint)}}function rT(s,l){return l?{point:l(s.point)}:s}function yR(s,l){return{x:s.x-l.x,y:s.y-l.y}}function sT({point:s},l){return{point:s,delta:yR(s,Kk(l)),offset:yR(s,f8(l)),velocity:p8(l,.1)}}function f8(s){return s[0]}function Kk(s){return s[s.length-1]}function p8(s,l){if(s.length<2)return{x:0,y:0};let p=s.length-1,x=null;const T=Kk(s);for(;p>=0&&(x=s[p],!(T.timestamp-x.timestamp>Ql(l)));)p--;if(!x)return{x:0,y:0};const C=ec(T.timestamp-x.timestamp);if(C===0)return{x:0,y:0};const L={x:(T.x-x.x)/C,y:(T.y-x.y)/C};return L.x===1/0&&(L.x=0),L.y===1/0&&(L.y=0),L}const Jk=1e-4,m8=1-Jk,_8=1+Jk,Qk=.01,g8=0-Qk,y8=0+Qk;function Ao(s){return s.max-s.min}function x8(s,l,p){return Math.abs(s-l)<=p}function xR(s,l,p,x=.5){s.origin=x,s.originPoint=fr(l.min,l.max,s.origin),s.scale=Ao(p)/Ao(l),s.translate=fr(p.min,p.max,s.origin)-s.originPoint,(s.scale>=m8&&s.scale<=_8||isNaN(s.scale))&&(s.scale=1),(s.translate>=g8&&s.translate<=y8||isNaN(s.translate))&&(s.translate=0)}function fg(s,l,p,x){xR(s.x,l.x,p.x,x?x.originX:void 0),xR(s.y,l.y,p.y,x?x.originY:void 0)}function vR(s,l,p){s.min=p.min+l.min,s.max=s.min+Ao(l)}function v8(s,l,p){vR(s.x,l.x,p.x),vR(s.y,l.y,p.y)}function bR(s,l,p){s.min=l.min-p.min,s.max=s.min+Ao(l)}function pg(s,l,p){bR(s.x,l.x,p.x),bR(s.y,l.y,p.y)}function b8(s,{min:l,max:p},x){return l!==void 0&&s<l?s=x?fr(l,s,x.min):Math.max(s,l):p!==void 0&&s>p&&(s=x?fr(p,s,x.max):Math.min(s,p)),s}function wR(s,l,p){return{min:l!==void 0?s.min+l:void 0,max:p!==void 0?s.max+p-(s.max-s.min):void 0}}function w8(s,{top:l,left:p,bottom:x,right:T}){return{x:wR(s.x,p,T),y:wR(s.y,l,x)}}function TR(s,l){let p=l.min-s.min,x=l.max-s.max;return l.max-l.min<s.max-s.min&&([p,x]=[x,p]),{min:p,max:x}}function T8(s,l){return{x:TR(s.x,l.x),y:TR(s.y,l.y)}}function S8(s,l){let p=.5;const x=Ao(s),T=Ao(l);return T>x?p=_p(l.min,l.max-x,s.min):x>T&&(p=_p(s.min,s.max-T,l.min)),ac(0,1,p)}function E8(s,l){const p={};return l.min!==void 0&&(p.min=l.min-s.min),l.max!==void 0&&(p.max=l.max-s.min),p}const SS=.35;function I8(s=SS){return s===!1?s=0:s===!0&&(s=SS),{x:SR(s,"left","right"),y:SR(s,"top","bottom")}}function SR(s,l,p){return{min:ER(s,l),max:ER(s,p)}}function ER(s,l){return typeof s=="number"?s:s[l]||0}const IR=()=>({translate:0,scale:1,origin:0,originPoint:0}),Jf=()=>({x:IR(),y:IR()}),AR=()=>({min:0,max:0}),Cr=()=>({x:AR(),y:AR()});function Jo(s){return[s("x"),s("y")]}function eF({top:s,left:l,right:p,bottom:x}){return{x:{min:l,max:p},y:{min:s,max:x}}}function A8({x:s,y:l}){return{top:l.min,right:s.max,bottom:l.max,left:s.min}}function C8(s,l){if(!l)return s;const p=l({x:s.left,y:s.top}),x=l({x:s.right,y:s.bottom});return{top:p.y,left:p.x,bottom:x.y,right:x.x}}function oT(s){return s===void 0||s===1}function ES({scale:s,scaleX:l,scaleY:p}){return!oT(s)||!oT(l)||!oT(p)}function Bh(s){return ES(s)||tF(s)||s.z||s.rotate||s.rotateX||s.rotateY||s.skewX||s.skewY}function tF(s){return CR(s.x)||CR(s.y)}function CR(s){return s&&s!=="0%"}function F0(s,l,p){const x=s-p,T=l*x;return p+T}function PR(s,l,p,x,T){return T!==void 0&&(s=F0(s,T,x)),F0(s,p,x)+l}function IS(s,l=0,p=1,x,T){s.min=PR(s.min,l,p,x,T),s.max=PR(s.max,l,p,x,T)}function iF(s,{x:l,y:p}){IS(s.x,l.translate,l.scale,l.originPoint),IS(s.y,p.translate,p.scale,p.originPoint)}const MR=.999999999999,RR=1.0000000000001;function P8(s,l,p,x=!1){const T=p.length;if(!T)return;l.x=l.y=1;let C,L;for(let a=0;a<T;a++){C=p[a],L=C.projectionDelta;const{visualElement:F}=C.options;F&&F.props.style&&F.props.style.display==="contents"||(x&&C.options.layoutScroll&&C.scroll&&C!==C.root&&ep(s,{x:-C.scroll.offset.x,y:-C.scroll.offset.y}),L&&(l.x*=L.x.scale,l.y*=L.y.scale,iF(s,L)),x&&Bh(C.latestValues)&&ep(s,C.latestValues))}l.x<RR&&l.x>MR&&(l.x=1),l.y<RR&&l.y>MR&&(l.y=1)}function Qf(s,l){s.min=s.min+l,s.max=s.max+l}function DR(s,l,p,x,T=.5){const C=fr(s.min,s.max,T);IS(s,l,p,C,x)}function ep(s,l){DR(s.x,l.x,l.scaleX,l.scale,l.originX),DR(s.y,l.y,l.scaleY,l.scale,l.originY)}function nF(s,l){return eF(C8(s.getBoundingClientRect(),l))}function M8(s,l,p){const x=nF(s,p),{scroll:T}=l;return T&&(Qf(x.x,T.offset.x),Qf(x.y,T.offset.y)),x}const rF=({current:s})=>s?s.ownerDocument.defaultView:null,R8=new WeakMap;class D8{constructor(l){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Cr(),this.visualElement=l}start(l,{snapToCursor:p=!1}={}){const{presenceContext:x}=this.visualElement;if(x&&x.isPresent===!1)return;const T=ee=>{const{dragSnapToOrigin:se}=this.getProps();se?this.pauseAnimation():this.stopAnimation(),p&&this.snapToCursor(Kg(ee).point)},C=(ee,se)=>{const{drag:ue,dragPropagation:Me,onDragStart:Ve}=this.getProps();if(ue&&!Me&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Sj(ue),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Jo(Ye=>{let Se=this.getAxisMotionValue(Ye).get()||0;if(hl.test(Se)){const{projection:ye}=this.visualElement;if(ye&&ye.layout){const Ie=ye.layout.layoutBox[Ye];Ie&&(Se=Ao(Ie)*(parseFloat(Se)/100))}}this.originPoint[Ye]=Se}),Ve&&tr.postRender(()=>Ve(ee,se)),_S(this.visualElement,"transform");const{animationState:ke}=this.visualElement;ke&&ke.setActive("whileDrag",!0)},L=(ee,se)=>{const{dragPropagation:ue,dragDirectionLock:Me,onDirectionLock:Ve,onDrag:ke}=this.getProps();if(!ue&&!this.openDragLock)return;const{offset:Ye}=se;if(Me&&this.currentDirection===null){this.currentDirection=L8(Ye),this.currentDirection!==null&&Ve&&Ve(this.currentDirection);return}this.updateAxis("x",se.point,Ye),this.updateAxis("y",se.point,Ye),this.visualElement.render(),ke&&ke(ee,se)},a=(ee,se)=>this.stop(ee,se),F=()=>Jo(ee=>{var se;return this.getAnimationState(ee)==="paused"&&((se=this.getAxisMotionValue(ee).animation)===null||se===void 0?void 0:se.play())}),{dragSnapToOrigin:H}=this.getProps();this.panSession=new Yk(l,{onSessionStart:T,onStart:C,onMove:L,onSessionEnd:a,resumeAnimation:F},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:H,contextWindow:rF(this.visualElement)})}stop(l,p){const x=this.isDragging;if(this.cancel(),!x)return;const{velocity:T}=p;this.startAnimation(T);const{onDragEnd:C}=this.getProps();C&&tr.postRender(()=>C(l,p))}cancel(){this.isDragging=!1;const{projection:l,animationState:p}=this.visualElement;l&&(l.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:x}=this.getProps();!x&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),p&&p.setActive("whileDrag",!1)}updateAxis(l,p,x){const{drag:T}=this.getProps();if(!x||!Uv(l,T,this.currentDirection))return;const C=this.getAxisMotionValue(l);let L=this.originPoint[l]+x[l];this.constraints&&this.constraints[l]&&(L=b8(L,this.constraints[l],this.elastic[l])),C.set(L)}resolveConstraints(){var l;const{dragConstraints:p,dragElastic:x}=this.getProps(),T=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(l=this.visualElement.projection)===null||l===void 0?void 0:l.layout,C=this.constraints;p&&Yf(p)?this.constraints||(this.constraints=this.resolveRefConstraints()):p&&T?this.constraints=w8(T.layoutBox,p):this.constraints=!1,this.elastic=I8(x),C!==this.constraints&&T&&this.constraints&&!this.hasMutatedConstraints&&Jo(L=>{this.constraints!==!1&&this.getAxisMotionValue(L)&&(this.constraints[L]=E8(T.layoutBox[L],this.constraints[L]))})}resolveRefConstraints(){const{dragConstraints:l,onMeasureDragConstraints:p}=this.getProps();if(!l||!Yf(l))return!1;const x=l.current,{projection:T}=this.visualElement;if(!T||!T.layout)return!1;const C=M8(x,T.root,this.visualElement.getTransformPagePoint());let L=T8(T.layout.layoutBox,C);if(p){const a=p(A8(L));this.hasMutatedConstraints=!!a,a&&(L=eF(a))}return L}startAnimation(l){const{drag:p,dragMomentum:x,dragElastic:T,dragTransition:C,dragSnapToOrigin:L,onDragTransitionEnd:a}=this.getProps(),F=this.constraints||{},H=Jo(ee=>{if(!Uv(ee,p,this.currentDirection))return;let se=F&&F[ee]||{};L&&(se={min:0,max:0});const ue=T?200:1e6,Me=T?40:1e7,Ve={type:"inertia",velocity:x?l[ee]:0,bounceStiffness:ue,bounceDamping:Me,timeConstant:750,restDelta:1,restSpeed:10,...C,...se};return this.startAxisValueAnimation(ee,Ve)});return Promise.all(H).then(a)}startAxisValueAnimation(l,p){const x=this.getAxisMotionValue(l);return _S(this.visualElement,l),x.start(cE(l,x,0,p,this.visualElement,!1))}stopAnimation(){Jo(l=>this.getAxisMotionValue(l).stop())}pauseAnimation(){Jo(l=>{var p;return(p=this.getAxisMotionValue(l).animation)===null||p===void 0?void 0:p.pause()})}getAnimationState(l){var p;return(p=this.getAxisMotionValue(l).animation)===null||p===void 0?void 0:p.state}getAxisMotionValue(l){const p=`_drag${l.toUpperCase()}`,x=this.visualElement.getProps(),T=x[p];return T||this.visualElement.getValue(l,(x.initial?x.initial[l]:void 0)||0)}snapToCursor(l){Jo(p=>{const{drag:x}=this.getProps();if(!Uv(p,x,this.currentDirection))return;const{projection:T}=this.visualElement,C=this.getAxisMotionValue(p);if(T&&T.layout){const{min:L,max:a}=T.layout.layoutBox[p];C.set(l[p]-fr(L,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:l,dragConstraints:p}=this.getProps(),{projection:x}=this.visualElement;if(!Yf(p)||!x||!this.constraints)return;this.stopAnimation();const T={x:0,y:0};Jo(L=>{const a=this.getAxisMotionValue(L);if(a&&this.constraints!==!1){const F=a.get();T[L]=S8({min:F,max:F},this.constraints[L])}});const{transformTemplate:C}=this.visualElement.getProps();this.visualElement.current.style.transform=C?C({},""):"none",x.root&&x.root.updateScroll(),x.updateLayout(),this.resolveConstraints(),Jo(L=>{if(!Uv(L,l,null))return;const a=this.getAxisMotionValue(L),{min:F,max:H}=this.constraints[L];a.set(fr(F,H,T[L]))})}addListeners(){if(!this.visualElement.current)return;R8.set(this.visualElement,this);const l=this.visualElement.current,p=dg(l,"pointerdown",F=>{const{drag:H,dragListener:ee=!0}=this.getProps();H&&ee&&this.start(F)}),x=()=>{const{dragConstraints:F}=this.getProps();Yf(F)&&F.current&&(this.constraints=this.resolveRefConstraints())},{projection:T}=this.visualElement,C=T.addEventListener("measure",x);T&&!T.layout&&(T.root&&T.root.updateScroll(),T.updateLayout()),tr.read(x);const L=Ng(window,"resize",()=>this.scalePositionWithinConstraints()),a=T.addEventListener("didUpdate",({delta:F,hasLayoutChanged:H})=>{this.isDragging&&H&&(Jo(ee=>{const se=this.getAxisMotionValue(ee);se&&(this.originPoint[ee]+=F[ee].translate,se.set(se.get()+F[ee].translate))}),this.visualElement.render())});return()=>{L(),p(),C(),a&&a()}}getProps(){const l=this.visualElement.getProps(),{drag:p=!1,dragDirectionLock:x=!1,dragPropagation:T=!1,dragConstraints:C=!1,dragElastic:L=SS,dragMomentum:a=!0}=l;return{...l,drag:p,dragDirectionLock:x,dragPropagation:T,dragConstraints:C,dragElastic:L,dragMomentum:a}}}function Uv(s,l,p){return(l===!0||l===s)&&(p===null||p===s)}function L8(s,l=10){let p=null;return Math.abs(s.y)>l?p="y":Math.abs(s.x)>l&&(p="x"),p}class z8 extends Su{constructor(l){super(l),this.removeGroupControls=Eo,this.removeListeners=Eo,this.controls=new D8(l)}mount(){const{dragControls:l}=this.node.getProps();l&&(this.removeGroupControls=l.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Eo}unmount(){this.removeGroupControls(),this.removeListeners()}}const LR=s=>(l,p)=>{s&&tr.postRender(()=>s(l,p))};class k8 extends Su{constructor(){super(...arguments),this.removePointerDownListener=Eo}onPointerDown(l){this.session=new Yk(l,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:rF(this.node)})}createPanHandlers(){const{onPanSessionStart:l,onPanStart:p,onPan:x,onPanEnd:T}=this.node.getProps();return{onSessionStart:LR(l),onStart:LR(p),onMove:x,onEnd:(C,L)=>{delete this.session,T&&tr.postRender(()=>T(C,L))}}}mount(){this.removePointerDownListener=dg(this.node.current,"pointerdown",l=>this.onPointerDown(l))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const r0={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function zR(s,l){return l.max===l.min?0:s/(l.max-l.min)*100}const q_={correct:(s,l)=>{if(!l.target)return s;if(typeof s=="string")if(Di.test(s))s=parseFloat(s);else return s;const p=zR(s,l.target.x),x=zR(s,l.target.y);return`${p}% ${x}%`}},F8={correct:(s,{treeScale:l,projectionDelta:p})=>{const x=s,T=xu.parse(s);if(T.length>5)return x;const C=xu.createTransformer(s),L=typeof T[0]!="number"?1:0,a=p.x.scale*l.x,F=p.y.scale*l.y;T[0+L]/=a,T[1+L]/=F;const H=fr(a,F,.5);return typeof T[2+L]=="number"&&(T[2+L]/=H),typeof T[3+L]=="number"&&(T[3+L]/=H),C(T)}};class O8 extends Ge.Component{componentDidMount(){const{visualElement:l,layoutGroup:p,switchLayoutGroup:x,layoutId:T}=this.props,{projection:C}=l;nj(B8),C&&(p.group&&p.group.add(C),x&&x.register&&T&&x.register(C),C.root.didUpdate(),C.addEventListener("animationComplete",()=>{this.safeToRemove()}),C.setOptions({...C.options,onExitComplete:()=>this.safeToRemove()})),r0.hasEverUpdated=!0}getSnapshotBeforeUpdate(l){const{layoutDependency:p,visualElement:x,drag:T,isPresent:C}=this.props,L=x.projection;return L&&(L.isPresent=C,T||l.layoutDependency!==p||p===void 0?L.willUpdate():this.safeToRemove(),l.isPresent!==C&&(C?L.promote():L.relegate()||tr.postRender(()=>{const a=L.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:l}=this.props.visualElement;l&&(l.root.didUpdate(),B2.postRender(()=>{!l.currentAnimation&&l.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:l,layoutGroup:p,switchLayoutGroup:x}=this.props,{projection:T}=l;T&&(T.scheduleCheckAfterUnmount(),p&&p.group&&p.group.remove(T),x&&x.deregister&&x.deregister(T))}safeToRemove(){const{safeToRemove:l}=this.props;l&&l()}render(){return null}}function sF(s){const[l,p]=Uz(),x=Ge.useContext(M2);return J.jsx(O8,{...s,layoutGroup:x,switchLayoutGroup:Ge.useContext(Xz),isPresent:l,safeToRemove:p})}const B8={borderRadius:{...q_,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:q_,borderTopRightRadius:q_,borderBottomLeftRadius:q_,borderBottomRightRadius:q_,boxShadow:F8};function N8(s,l,p){const x=Ts(s)?s:Og(s);return x.start(cE("",x,l,p)),x.animation}function V8(s){return s instanceof SVGElement&&s.tagName!=="svg"}const U8=(s,l)=>s.depth-l.depth;class j8{constructor(){this.children=[],this.isDirty=!1}add(l){J2(this.children,l),this.isDirty=!0}remove(l){Q2(this.children,l),this.isDirty=!0}forEach(l){this.isDirty&&this.children.sort(U8),this.isDirty=!1,this.children.forEach(l)}}function G8(s,l){const p=dl.now(),x=({timestamp:T})=>{const C=T-p;C>=l&&(yu(x),s(C-l))};return tr.read(x,!0),()=>yu(x)}const oF=["TopLeft","TopRight","BottomLeft","BottomRight"],$8=oF.length,kR=s=>typeof s=="string"?parseFloat(s):s,FR=s=>typeof s=="number"||Di.test(s);function H8(s,l,p,x,T,C){T?(s.opacity=fr(0,p.opacity!==void 0?p.opacity:1,Z8(x)),s.opacityExit=fr(l.opacity!==void 0?l.opacity:1,0,q8(x))):C&&(s.opacity=fr(l.opacity!==void 0?l.opacity:1,p.opacity!==void 0?p.opacity:1,x));for(let L=0;L<$8;L++){const a=`border${oF[L]}Radius`;let F=OR(l,a),H=OR(p,a);if(F===void 0&&H===void 0)continue;F||(F=0),H||(H=0),F===0||H===0||FR(F)===FR(H)?(s[a]=Math.max(fr(kR(F),kR(H),x),0),(hl.test(H)||hl.test(F))&&(s[a]+="%")):s[a]=H}(l.rotate||p.rotate)&&(s.rotate=fr(l.rotate||0,p.rotate||0,x))}function OR(s,l){return s[l]!==void 0?s[l]:s.borderRadius}const Z8=aF(0,.5,Ek),q8=aF(.5,.95,Eo);function aF(s,l,p){return x=>x<s?0:x>l?1:p(_p(s,l,x))}function BR(s,l){s.min=l.min,s.max=l.max}function Ko(s,l){BR(s.x,l.x),BR(s.y,l.y)}function NR(s,l){s.translate=l.translate,s.scale=l.scale,s.originPoint=l.originPoint,s.origin=l.origin}function VR(s,l,p,x,T){return s-=l,s=F0(s,1/p,x),T!==void 0&&(s=F0(s,1/T,x)),s}function W8(s,l=0,p=1,x=.5,T,C=s,L=s){if(hl.test(l)&&(l=parseFloat(l),l=fr(L.min,L.max,l/100)-L.min),typeof l!="number")return;let a=fr(C.min,C.max,x);s===C&&(a-=l),s.min=VR(s.min,l,p,a,T),s.max=VR(s.max,l,p,a,T)}function UR(s,l,[p,x,T],C,L){W8(s,l[p],l[x],l[T],l.scale,C,L)}const X8=["x","scaleX","originX"],Y8=["y","scaleY","originY"];function jR(s,l,p,x){UR(s.x,l,X8,p?p.x:void 0,x?x.x:void 0),UR(s.y,l,Y8,p?p.y:void 0,x?x.y:void 0)}function GR(s){return s.translate===0&&s.scale===1}function lF(s){return GR(s.x)&&GR(s.y)}function $R(s,l){return s.min===l.min&&s.max===l.max}function K8(s,l){return $R(s.x,l.x)&&$R(s.y,l.y)}function HR(s,l){return Math.round(s.min)===Math.round(l.min)&&Math.round(s.max)===Math.round(l.max)}function cF(s,l){return HR(s.x,l.x)&&HR(s.y,l.y)}function ZR(s){return Ao(s.x)/Ao(s.y)}function qR(s,l){return s.translate===l.translate&&s.scale===l.scale&&s.originPoint===l.originPoint}class J8{constructor(){this.members=[]}add(l){J2(this.members,l),l.scheduleRender()}remove(l){if(Q2(this.members,l),l===this.prevLead&&(this.prevLead=void 0),l===this.lead){const p=this.members[this.members.length-1];p&&this.promote(p)}}relegate(l){const p=this.members.findIndex(T=>l===T);if(p===0)return!1;let x;for(let T=p;T>=0;T--){const C=this.members[T];if(C.isPresent!==!1){x=C;break}}return x?(this.promote(x),!0):!1}promote(l,p){const x=this.lead;if(l!==x&&(this.prevLead=x,this.lead=l,l.show(),x)){x.instance&&x.scheduleRender(),l.scheduleRender(),l.resumeFrom=x,p&&(l.resumeFrom.preserveOpacity=!0),x.snapshot&&(l.snapshot=x.snapshot,l.snapshot.latestValues=x.animationValues||x.latestValues),l.root&&l.root.isUpdating&&(l.isLayoutDirty=!0);const{crossfade:T}=l.options;T===!1&&x.hide()}}exitAnimationComplete(){this.members.forEach(l=>{const{options:p,resumingFrom:x}=l;p.onExitComplete&&p.onExitComplete(),x&&x.options.onExitComplete&&x.options.onExitComplete()})}scheduleRender(){this.members.forEach(l=>{l.instance&&l.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Q8(s,l,p){let x="";const T=s.x.translate/l.x,C=s.y.translate/l.y,L=(p==null?void 0:p.z)||0;if((T||C||L)&&(x=`translate3d(${T}px, ${C}px, ${L}px) `),(l.x!==1||l.y!==1)&&(x+=`scale(${1/l.x}, ${1/l.y}) `),p){const{transformPerspective:H,rotate:ee,rotateX:se,rotateY:ue,skewX:Me,skewY:Ve}=p;H&&(x=`perspective(${H}px) ${x}`),ee&&(x+=`rotate(${ee}deg) `),se&&(x+=`rotateX(${se}deg) `),ue&&(x+=`rotateY(${ue}deg) `),Me&&(x+=`skewX(${Me}deg) `),Ve&&(x+=`skewY(${Ve}deg) `)}const a=s.x.scale*l.x,F=s.y.scale*l.y;return(a!==1||F!==1)&&(x+=`scale(${a}, ${F})`),x||"none"}const Nh={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},eg=typeof window<"u"&&window.MotionDebug!==void 0,aT=["","X","Y","Z"],eG={visibility:"hidden"},WR=1e3;let tG=0;function lT(s,l,p,x){const{latestValues:T}=l;T[s]&&(p[s]=T[s],l.setStaticValue(s,0),x&&(x[s]=0))}function uF(s){if(s.hasCheckedOptimisedAppear=!0,s.root===s)return;const{visualElement:l}=s.options;if(!l)return;const p=yk(l);if(window.MotionHasOptimisedAnimation(p,"transform")){const{layout:T,layoutId:C}=s.options;window.MotionCancelOptimisedAnimation(p,"transform",tr,!(T||C))}const{parent:x}=s;x&&!x.hasCheckedOptimisedAppear&&uF(x)}function hF({attachResizeListener:s,defaultParent:l,measureScroll:p,checkIsScrollRoot:x,resetTransform:T}){return class{constructor(L={},a=l==null?void 0:l()){this.id=tG++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,eg&&(Nh.totalNodes=Nh.resolvedTargetDeltas=Nh.recalculatedProjection=0),this.nodes.forEach(rG),this.nodes.forEach(cG),this.nodes.forEach(uG),this.nodes.forEach(sG),eg&&window.MotionDebug.record(Nh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=L,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let F=0;F<this.path.length;F++)this.path[F].shouldResetTransform=!0;this.root===this&&(this.nodes=new j8)}addEventListener(L,a){return this.eventHandlers.has(L)||this.eventHandlers.set(L,new eE),this.eventHandlers.get(L).add(a)}notifyListeners(L,...a){const F=this.eventHandlers.get(L);F&&F.notify(...a)}hasListeners(L){return this.eventHandlers.has(L)}mount(L,a=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=V8(L),this.instance=L;const{layoutId:F,layout:H,visualElement:ee}=this.options;if(ee&&!ee.current&&ee.mount(L),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),a&&(H||F)&&(this.isLayoutDirty=!0),s){let se;const ue=()=>this.root.updateBlockedByResize=!1;s(L,()=>{this.root.updateBlockedByResize=!0,se&&se(),se=G8(ue,250),r0.hasAnimatedSinceResize&&(r0.hasAnimatedSinceResize=!1,this.nodes.forEach(YR))})}F&&this.root.registerSharedNode(F,this),this.options.animate!==!1&&ee&&(F||H)&&this.addEventListener("didUpdate",({delta:se,hasLayoutChanged:ue,hasRelativeTargetChanged:Me,layout:Ve})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const ke=this.options.transition||ee.getDefaultTransition()||mG,{onLayoutAnimationStart:Ye,onLayoutAnimationComplete:Se}=ee.getProps(),ye=!this.targetLayout||!cF(this.targetLayout,Ve)||Me,Ie=!ue&&Me;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||Ie||ue&&(ye||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(se,Ie);const qe={...W2(ke,"layout"),onPlay:Ye,onComplete:Se};(ee.shouldReduceMotion||this.options.layoutRoot)&&(qe.delay=0,qe.type=!1),this.startAnimation(qe)}else ue||YR(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=Ve})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const L=this.getStack();L&&L.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,yu(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(hG),this.animationId++)}getTransformTemplate(){const{visualElement:L}=this.options;return L&&L.getProps().transformTemplate}willUpdate(L=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&uF(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let ee=0;ee<this.path.length;ee++){const se=this.path[ee];se.shouldResetTransform=!0,se.updateScroll("snapshot"),se.options.layoutRoot&&se.willUpdate(!1)}const{layoutId:a,layout:F}=this.options;if(a===void 0&&!F)return;const H=this.getTransformTemplate();this.prevTransformTemplateValue=H?H(this.latestValues,""):void 0,this.updateSnapshot(),L&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(XR);return}this.isUpdating||this.nodes.forEach(aG),this.isUpdating=!1,this.nodes.forEach(lG),this.nodes.forEach(iG),this.nodes.forEach(nG),this.clearAllSnapshots();const a=dl.now();as.delta=ac(0,1e3/60,a-as.timestamp),as.timestamp=a,as.isProcessing=!0,Jw.update.process(as),Jw.preRender.process(as),Jw.render.process(as),as.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,B2.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(oG),this.sharedNodes.forEach(dG)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,tr.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){tr.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let F=0;F<this.path.length;F++)this.path[F].updateScroll();const L=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Cr(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,L?L.layoutBox:void 0)}updateScroll(L="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===L&&(a=!1),a){const F=x(this.instance);this.scroll={animationId:this.root.animationId,phase:L,isRoot:F,offset:p(this.instance),wasRoot:this.scroll?this.scroll.isRoot:F}}}resetTransform(){if(!T)return;const L=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!lF(this.projectionDelta),F=this.getTransformTemplate(),H=F?F(this.latestValues,""):void 0,ee=H!==this.prevTransformTemplateValue;L&&(a||Bh(this.latestValues)||ee)&&(T(this.instance,H),this.shouldResetTransform=!1,this.scheduleRender())}measure(L=!0){const a=this.measurePageBox();let F=this.removeElementScroll(a);return L&&(F=this.removeTransform(F)),_G(F),{animationId:this.root.animationId,measuredBox:a,layoutBox:F,latestValues:{},source:this.id}}measurePageBox(){var L;const{visualElement:a}=this.options;if(!a)return Cr();const F=a.measureViewportBox();if(!(((L=this.scroll)===null||L===void 0?void 0:L.wasRoot)||this.path.some(gG))){const{scroll:ee}=this.root;ee&&(Qf(F.x,ee.offset.x),Qf(F.y,ee.offset.y))}return F}removeElementScroll(L){var a;const F=Cr();if(Ko(F,L),!((a=this.scroll)===null||a===void 0)&&a.wasRoot)return F;for(let H=0;H<this.path.length;H++){const ee=this.path[H],{scroll:se,options:ue}=ee;ee!==this.root&&se&&ue.layoutScroll&&(se.wasRoot&&Ko(F,L),Qf(F.x,se.offset.x),Qf(F.y,se.offset.y))}return F}applyTransform(L,a=!1){const F=Cr();Ko(F,L);for(let H=0;H<this.path.length;H++){const ee=this.path[H];!a&&ee.options.layoutScroll&&ee.scroll&&ee!==ee.root&&ep(F,{x:-ee.scroll.offset.x,y:-ee.scroll.offset.y}),Bh(ee.latestValues)&&ep(F,ee.latestValues)}return Bh(this.latestValues)&&ep(F,this.latestValues),F}removeTransform(L){const a=Cr();Ko(a,L);for(let F=0;F<this.path.length;F++){const H=this.path[F];if(!H.instance||!Bh(H.latestValues))continue;ES(H.latestValues)&&H.updateSnapshot();const ee=Cr(),se=H.measurePageBox();Ko(ee,se),jR(a,H.latestValues,H.snapshot?H.snapshot.layoutBox:void 0,ee)}return Bh(this.latestValues)&&jR(a,this.latestValues),a}setTargetDelta(L){this.targetDelta=L,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(L){this.options={...this.options,...L,crossfade:L.crossfade!==void 0?L.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==as.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(L=!1){var a;const F=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=F.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=F.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=F.isSharedProjectionDirty);const H=!!this.resumingFrom||this!==F;if(!(L||H&&this.isSharedProjectionDirty||this.isProjectionDirty||!((a=this.parent)===null||a===void 0)&&a.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:se,layoutId:ue}=this.options;if(!(!this.layout||!(se||ue))){if(this.resolvedRelativeTargetAt=as.timestamp,!this.targetDelta&&!this.relativeTarget){const Me=this.getClosestProjectingParent();Me&&Me.layout&&this.animationProgress!==1?(this.relativeParent=Me,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Cr(),this.relativeTargetOrigin=Cr(),pg(this.relativeTargetOrigin,this.layout.layoutBox,Me.layout.layoutBox),Ko(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Cr(),this.targetWithTransforms=Cr()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),v8(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ko(this.target,this.layout.layoutBox),iF(this.target,this.targetDelta)):Ko(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const Me=this.getClosestProjectingParent();Me&&!!Me.resumingFrom==!!this.resumingFrom&&!Me.options.layoutScroll&&Me.target&&this.animationProgress!==1?(this.relativeParent=Me,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Cr(),this.relativeTargetOrigin=Cr(),pg(this.relativeTargetOrigin,this.target,Me.target),Ko(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}eg&&Nh.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||ES(this.parent.latestValues)||tF(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var L;const a=this.getLead(),F=!!this.resumingFrom||this!==a;let H=!0;if((this.isProjectionDirty||!((L=this.parent)===null||L===void 0)&&L.isProjectionDirty)&&(H=!1),F&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(H=!1),this.resolvedRelativeTargetAt===as.timestamp&&(H=!1),H)return;const{layout:ee,layoutId:se}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(ee||se))return;Ko(this.layoutCorrected,this.layout.layoutBox);const ue=this.treeScale.x,Me=this.treeScale.y;P8(this.layoutCorrected,this.treeScale,this.path,F),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=Cr());const{target:Ve}=a;if(!Ve){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(NR(this.prevProjectionDelta.x,this.projectionDelta.x),NR(this.prevProjectionDelta.y,this.projectionDelta.y)),fg(this.projectionDelta,this.layoutCorrected,Ve,this.latestValues),(this.treeScale.x!==ue||this.treeScale.y!==Me||!qR(this.projectionDelta.x,this.prevProjectionDelta.x)||!qR(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",Ve)),eg&&Nh.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(L=!0){var a;if((a=this.options.visualElement)===null||a===void 0||a.scheduleRender(),L){const F=this.getStack();F&&F.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Jf(),this.projectionDelta=Jf(),this.projectionDeltaWithTransform=Jf()}setAnimationOrigin(L,a=!1){const F=this.snapshot,H=F?F.latestValues:{},ee={...this.latestValues},se=Jf();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const ue=Cr(),Me=F?F.source:void 0,Ve=this.layout?this.layout.source:void 0,ke=Me!==Ve,Ye=this.getStack(),Se=!Ye||Ye.members.length<=1,ye=!!(ke&&!Se&&this.options.crossfade===!0&&!this.path.some(pG));this.animationProgress=0;let Ie;this.mixTargetDelta=qe=>{const ot=qe/1e3;KR(se.x,L.x,ot),KR(se.y,L.y,ot),this.setTargetDelta(se),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(pg(ue,this.layout.layoutBox,this.relativeParent.layout.layoutBox),fG(this.relativeTarget,this.relativeTargetOrigin,ue,ot),Ie&&K8(this.relativeTarget,Ie)&&(this.isProjectionDirty=!1),Ie||(Ie=Cr()),Ko(Ie,this.relativeTarget)),ke&&(this.animationValues=ee,H8(ee,H,this.latestValues,ot,ye,Se)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=ot},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(L){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(yu(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=tr.update(()=>{r0.hasAnimatedSinceResize=!0,this.currentAnimation=N8(0,WR,{...L,onUpdate:a=>{this.mixTargetDelta(a),L.onUpdate&&L.onUpdate(a)},onComplete:()=>{L.onComplete&&L.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const L=this.getStack();L&&L.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(WR),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const L=this.getLead();let{targetWithTransforms:a,target:F,layout:H,latestValues:ee}=L;if(!(!a||!F||!H)){if(this!==L&&this.layout&&H&&dF(this.options.animationType,this.layout.layoutBox,H.layoutBox)){F=this.target||Cr();const se=Ao(this.layout.layoutBox.x);F.x.min=L.target.x.min,F.x.max=F.x.min+se;const ue=Ao(this.layout.layoutBox.y);F.y.min=L.target.y.min,F.y.max=F.y.min+ue}Ko(a,F),ep(a,ee),fg(this.projectionDeltaWithTransform,this.layoutCorrected,a,ee)}}registerSharedNode(L,a){this.sharedNodes.has(L)||this.sharedNodes.set(L,new J8),this.sharedNodes.get(L).add(a);const H=a.options.initialPromotionConfig;a.promote({transition:H?H.transition:void 0,preserveFollowOpacity:H&&H.shouldPreserveFollowOpacity?H.shouldPreserveFollowOpacity(a):void 0})}isLead(){const L=this.getStack();return L?L.lead===this:!0}getLead(){var L;const{layoutId:a}=this.options;return a?((L=this.getStack())===null||L===void 0?void 0:L.lead)||this:this}getPrevLead(){var L;const{layoutId:a}=this.options;return a?(L=this.getStack())===null||L===void 0?void 0:L.prevLead:void 0}getStack(){const{layoutId:L}=this.options;if(L)return this.root.sharedNodes.get(L)}promote({needsReset:L,transition:a,preserveFollowOpacity:F}={}){const H=this.getStack();H&&H.promote(this,F),L&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const L=this.getStack();return L?L.relegate(this):!1}resetSkewAndRotation(){const{visualElement:L}=this.options;if(!L)return;let a=!1;const{latestValues:F}=L;if((F.z||F.rotate||F.rotateX||F.rotateY||F.rotateZ||F.skewX||F.skewY)&&(a=!0),!a)return;const H={};F.z&&lT("z",L,H,this.animationValues);for(let ee=0;ee<aT.length;ee++)lT(`rotate${aT[ee]}`,L,H,this.animationValues),lT(`skew${aT[ee]}`,L,H,this.animationValues);L.render();for(const ee in H)L.setStaticValue(ee,H[ee]),this.animationValues&&(this.animationValues[ee]=H[ee]);L.scheduleRender()}getProjectionStyles(L){var a,F;if(!this.instance||this.isSVG)return;if(!this.isVisible)return eG;const H={visibility:""},ee=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,H.opacity="",H.pointerEvents=i0(L==null?void 0:L.pointerEvents)||"",H.transform=ee?ee(this.latestValues,""):"none",H;const se=this.getLead();if(!this.projectionDelta||!this.layout||!se.target){const ke={};return this.options.layoutId&&(ke.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,ke.pointerEvents=i0(L==null?void 0:L.pointerEvents)||""),this.hasProjected&&!Bh(this.latestValues)&&(ke.transform=ee?ee({},""):"none",this.hasProjected=!1),ke}const ue=se.animationValues||se.latestValues;this.applyTransformsToTarget(),H.transform=Q8(this.projectionDeltaWithTransform,this.treeScale,ue),ee&&(H.transform=ee(ue,H.transform));const{x:Me,y:Ve}=this.projectionDelta;H.transformOrigin=`${Me.origin*100}% ${Ve.origin*100}% 0`,se.animationValues?H.opacity=se===this?(F=(a=ue.opacity)!==null&&a!==void 0?a:this.latestValues.opacity)!==null&&F!==void 0?F:1:this.preserveOpacity?this.latestValues.opacity:ue.opacityExit:H.opacity=se===this?ue.opacity!==void 0?ue.opacity:"":ue.opacityExit!==void 0?ue.opacityExit:0;for(const ke in R0){if(ue[ke]===void 0)continue;const{correct:Ye,applyTo:Se}=R0[ke],ye=H.transform==="none"?ue[ke]:Ye(ue[ke],se);if(Se){const Ie=Se.length;for(let qe=0;qe<Ie;qe++)H[Se[qe]]=ye}else H[ke]=ye}return this.options.layoutId&&(H.pointerEvents=se===this?i0(L==null?void 0:L.pointerEvents)||"":"none"),H}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(L=>{var a;return(a=L.currentAnimation)===null||a===void 0?void 0:a.stop()}),this.root.nodes.forEach(XR),this.root.sharedNodes.clear()}}}function iG(s){s.updateLayout()}function nG(s){var l;const p=((l=s.resumeFrom)===null||l===void 0?void 0:l.snapshot)||s.snapshot;if(s.isLead()&&s.layout&&p&&s.hasListeners("didUpdate")){const{layoutBox:x,measuredBox:T}=s.layout,{animationType:C}=s.options,L=p.source!==s.layout.source;C==="size"?Jo(se=>{const ue=L?p.measuredBox[se]:p.layoutBox[se],Me=Ao(ue);ue.min=x[se].min,ue.max=ue.min+Me}):dF(C,p.layoutBox,x)&&Jo(se=>{const ue=L?p.measuredBox[se]:p.layoutBox[se],Me=Ao(x[se]);ue.max=ue.min+Me,s.relativeTarget&&!s.currentAnimation&&(s.isProjectionDirty=!0,s.relativeTarget[se].max=s.relativeTarget[se].min+Me)});const a=Jf();fg(a,x,p.layoutBox);const F=Jf();L?fg(F,s.applyTransform(T,!0),p.measuredBox):fg(F,x,p.layoutBox);const H=!lF(a);let ee=!1;if(!s.resumeFrom){const se=s.getClosestProjectingParent();if(se&&!se.resumeFrom){const{snapshot:ue,layout:Me}=se;if(ue&&Me){const Ve=Cr();pg(Ve,p.layoutBox,ue.layoutBox);const ke=Cr();pg(ke,x,Me.layoutBox),cF(Ve,ke)||(ee=!0),se.options.layoutRoot&&(s.relativeTarget=ke,s.relativeTargetOrigin=Ve,s.relativeParent=se)}}}s.notifyListeners("didUpdate",{layout:x,snapshot:p,delta:F,layoutDelta:a,hasLayoutChanged:H,hasRelativeTargetChanged:ee})}else if(s.isLead()){const{onExitComplete:x}=s.options;x&&x()}s.options.transition=void 0}function rG(s){eg&&Nh.totalNodes++,s.parent&&(s.isProjecting()||(s.isProjectionDirty=s.parent.isProjectionDirty),s.isSharedProjectionDirty||(s.isSharedProjectionDirty=!!(s.isProjectionDirty||s.parent.isProjectionDirty||s.parent.isSharedProjectionDirty)),s.isTransformDirty||(s.isTransformDirty=s.parent.isTransformDirty))}function sG(s){s.isProjectionDirty=s.isSharedProjectionDirty=s.isTransformDirty=!1}function oG(s){s.clearSnapshot()}function XR(s){s.clearMeasurements()}function aG(s){s.isLayoutDirty=!1}function lG(s){const{visualElement:l}=s.options;l&&l.getProps().onBeforeLayoutMeasure&&l.notify("BeforeLayoutMeasure"),s.resetTransform()}function YR(s){s.finishAnimation(),s.targetDelta=s.relativeTarget=s.target=void 0,s.isProjectionDirty=!0}function cG(s){s.resolveTargetDelta()}function uG(s){s.calcProjection()}function hG(s){s.resetSkewAndRotation()}function dG(s){s.removeLeadSnapshot()}function KR(s,l,p){s.translate=fr(l.translate,0,p),s.scale=fr(l.scale,1,p),s.origin=l.origin,s.originPoint=l.originPoint}function JR(s,l,p,x){s.min=fr(l.min,p.min,x),s.max=fr(l.max,p.max,x)}function fG(s,l,p,x){JR(s.x,l.x,p.x,x),JR(s.y,l.y,p.y,x)}function pG(s){return s.animationValues&&s.animationValues.opacityExit!==void 0}const mG={duration:.45,ease:[.4,0,.1,1]},QR=s=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(s),eD=QR("applewebkit/")&&!QR("chrome/")?Math.round:Eo;function tD(s){s.min=eD(s.min),s.max=eD(s.max)}function _G(s){tD(s.x),tD(s.y)}function dF(s,l,p){return s==="position"||s==="preserve-aspect"&&!x8(ZR(l),ZR(p),.2)}function gG(s){var l;return s!==s.root&&((l=s.scroll)===null||l===void 0?void 0:l.wasRoot)}const yG=hF({attachResizeListener:(s,l)=>Ng(s,"resize",l),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),cT={current:void 0},fF=hF({measureScroll:s=>({x:s.scrollLeft,y:s.scrollTop}),defaultParent:()=>{if(!cT.current){const s=new yG({});s.mount(window),s.setOptions({layoutScroll:!0}),cT.current=s}return cT.current},resetTransform:(s,l)=>{s.style.transform=l!==void 0?l:"none"},checkIsScrollRoot:s=>window.getComputedStyle(s).position==="fixed"}),xG={pan:{Feature:k8},drag:{Feature:z8,ProjectionNode:fF,MeasureLayout:sF}};function iD(s,l,p){const{props:x}=s;s.animationState&&x.whileHover&&s.animationState.setActive("whileHover",p==="Start");const T="onHover"+p,C=x[T];C&&tr.postRender(()=>C(l,Kg(l)))}class vG extends Su{mount(){const{current:l}=this.node;l&&(this.unmount=xj(l,p=>(iD(this.node,p,"Start"),x=>iD(this.node,x,"End"))))}unmount(){}}class bG extends Su{constructor(){super(...arguments),this.isActive=!1}onFocus(){let l=!1;try{l=this.node.current.matches(":focus-visible")}catch{l=!0}!l||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Yg(Ng(this.node.current,"focus",()=>this.onFocus()),Ng(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function nD(s,l,p){const{props:x}=s;s.animationState&&x.whileTap&&s.animationState.setActive("whileTap",p==="Start");const T="onTap"+(p==="End"?"":p),C=x[T];C&&tr.postRender(()=>C(l,Kg(l)))}class wG extends Su{mount(){const{current:l}=this.node;l&&(this.unmount=Tj(l,p=>(nD(this.node,p,"Start"),(x,{success:T})=>nD(this.node,x,T?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const AS=new WeakMap,uT=new WeakMap,TG=s=>{const l=AS.get(s.target);l&&l(s)},SG=s=>{s.forEach(TG)};function EG({root:s,...l}){const p=s||document;uT.has(p)||uT.set(p,{});const x=uT.get(p),T=JSON.stringify(l);return x[T]||(x[T]=new IntersectionObserver(SG,{root:s,...l})),x[T]}function IG(s,l,p){const x=EG(l);return AS.set(s,p),x.observe(s),()=>{AS.delete(s),x.unobserve(s)}}const AG={some:0,all:1};class CG extends Su{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:l={}}=this.node.getProps(),{root:p,margin:x,amount:T="some",once:C}=l,L={root:p?p.current:void 0,rootMargin:x,threshold:typeof T=="number"?T:AG[T]},a=F=>{const{isIntersecting:H}=F;if(this.isInView===H||(this.isInView=H,C&&!H&&this.hasEnteredView))return;H&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",H);const{onViewportEnter:ee,onViewportLeave:se}=this.node.getProps(),ue=H?ee:se;ue&&ue(F)};return IG(this.node.current,L,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:l,prevProps:p}=this.node;["amount","margin","root"].some(PG(l,p))&&this.startObserver()}unmount(){}}function PG({viewport:s={}},{viewport:l={}}={}){return p=>s[p]!==l[p]}const MG={inView:{Feature:CG},tap:{Feature:wG},focus:{Feature:bG},hover:{Feature:vG}},RG={layout:{ProjectionNode:fF,MeasureLayout:sF}},CS={current:null},pF={current:!1};function DG(){if(pF.current=!0,!!L2)if(window.matchMedia){const s=window.matchMedia("(prefers-reduced-motion)"),l=()=>CS.current=s.matches;s.addListener(l),l()}else CS.current=!1}const LG=[...Nk,bs,xu],zG=s=>LG.find(Bk(s)),rD=new WeakMap;function kG(s,l,p){for(const x in l){const T=l[x],C=p[x];if(Ts(T))s.addValue(x,T);else if(Ts(C))s.addValue(x,Og(T,{owner:s}));else if(C!==T)if(s.hasValue(x)){const L=s.getValue(x);L.liveStyle===!0?L.jump(T):L.hasAnimated||L.set(T)}else{const L=s.getStaticValue(x);s.addValue(x,Og(L!==void 0?L:T,{owner:s}))}}for(const x in p)l[x]===void 0&&s.removeValue(x);return l}const sD=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class FG{scrapeMotionValuesFromProps(l,p,x){return{}}constructor({parent:l,props:p,presenceContext:x,reducedMotionConfig:T,blockInitialAnimation:C,visualState:L},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=oE,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const Me=dl.now();this.renderScheduledAt<Me&&(this.renderScheduledAt=Me,tr.render(this.render,!1,!0))};const{latestValues:F,renderState:H,onUpdate:ee}=L;this.onUpdate=ee,this.latestValues=F,this.baseTarget={...F},this.initialValues=p.initial?{...F}:{},this.renderState=H,this.parent=l,this.props=p,this.presenceContext=x,this.depth=l?l.depth+1:0,this.reducedMotionConfig=T,this.options=a,this.blockInitialAnimation=!!C,this.isControllingVariants=o1(p),this.isVariantNode=qz(p),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(l&&l.current);const{willChange:se,...ue}=this.scrapeMotionValuesFromProps(p,{},this);for(const Me in ue){const Ve=ue[Me];F[Me]!==void 0&&Ts(Ve)&&Ve.set(F[Me],!1)}}mount(l){this.current=l,rD.set(l,this),this.projection&&!this.projection.instance&&this.projection.mount(l),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((p,x)=>this.bindToMotionValue(x,p)),pF.current||DG(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:CS.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){rD.delete(this.current),this.projection&&this.projection.unmount(),yu(this.notifyUpdate),yu(this.render),this.valueSubscriptions.forEach(l=>l()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const l in this.events)this.events[l].clear();for(const l in this.features){const p=this.features[l];p&&(p.unmount(),p.isMounted=!1)}this.current=null}bindToMotionValue(l,p){this.valueSubscriptions.has(l)&&this.valueSubscriptions.get(l)();const x=td.has(l),T=p.on("change",a=>{this.latestValues[l]=a,this.props.onUpdate&&tr.preRender(this.notifyUpdate),x&&this.projection&&(this.projection.isTransformDirty=!0)}),C=p.on("renderRequest",this.scheduleRender);let L;window.MotionCheckAppearSync&&(L=window.MotionCheckAppearSync(this,l,p)),this.valueSubscriptions.set(l,()=>{T(),C(),L&&L(),p.owner&&p.stop()})}sortNodePosition(l){return!this.current||!this.sortInstanceNodePosition||this.type!==l.type?0:this.sortInstanceNodePosition(this.current,l.current)}updateFeatures(){let l="animation";for(l in gp){const p=gp[l];if(!p)continue;const{isEnabled:x,Feature:T}=p;if(!this.features[l]&&T&&x(this.props)&&(this.features[l]=new T(this)),this.features[l]){const C=this.features[l];C.isMounted?C.update():(C.mount(),C.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Cr()}getStaticValue(l){return this.latestValues[l]}setStaticValue(l,p){this.latestValues[l]=p}update(l,p){(l.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=l,this.prevPresenceContext=this.presenceContext,this.presenceContext=p;for(let x=0;x<sD.length;x++){const T=sD[x];this.propEventSubscriptions[T]&&(this.propEventSubscriptions[T](),delete this.propEventSubscriptions[T]);const C="on"+T,L=l[C];L&&(this.propEventSubscriptions[T]=this.on(T,L))}this.prevMotionValues=kG(this,this.scrapeMotionValuesFromProps(l,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(l){return this.props.variants?this.props.variants[l]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(l){const p=this.getClosestVariantNode();if(p)return p.variantChildren&&p.variantChildren.add(l),()=>p.variantChildren.delete(l)}addValue(l,p){const x=this.values.get(l);p!==x&&(x&&this.removeValue(l),this.bindToMotionValue(l,p),this.values.set(l,p),this.latestValues[l]=p.get())}removeValue(l){this.values.delete(l);const p=this.valueSubscriptions.get(l);p&&(p(),this.valueSubscriptions.delete(l)),delete this.latestValues[l],this.removeValueFromRenderState(l,this.renderState)}hasValue(l){return this.values.has(l)}getValue(l,p){if(this.props.values&&this.props.values[l])return this.props.values[l];let x=this.values.get(l);return x===void 0&&p!==void 0&&(x=Og(p===null?void 0:p,{owner:this}),this.addValue(l,x)),x}readValue(l,p){var x;let T=this.latestValues[l]!==void 0||!this.current?this.latestValues[l]:(x=this.getBaseTargetFromProps(this.props,l))!==null&&x!==void 0?x:this.readValueFromInstance(this.current,l,this.options);return T!=null&&(typeof T=="string"&&(Fk(T)||Ak(T))?T=parseFloat(T):!zG(T)&&xu.test(p)&&(T=Lk(l,p)),this.setBaseTarget(l,Ts(T)?T.get():T)),Ts(T)?T.get():T}setBaseTarget(l,p){this.baseTarget[l]=p}getBaseTarget(l){var p;const{initial:x}=this.props;let T;if(typeof x=="string"||typeof x=="object"){const L=V2(this.props,x,(p=this.presenceContext)===null||p===void 0?void 0:p.custom);L&&(T=L[l])}if(x&&T!==void 0)return T;const C=this.getBaseTargetFromProps(this.props,l);return C!==void 0&&!Ts(C)?C:this.initialValues[l]!==void 0&&T===void 0?void 0:this.baseTarget[l]}on(l,p){return this.events[l]||(this.events[l]=new eE),this.events[l].add(p)}notify(l,...p){this.events[l]&&this.events[l].notify(...p)}}class mF extends FG{constructor(){super(...arguments),this.KeyframeResolver=Vk}sortInstanceNodePosition(l,p){return l.compareDocumentPosition(p)&2?1:-1}getBaseTargetFromProps(l,p){return l.style?l.style[p]:void 0}removeValueFromRenderState(l,{vars:p,style:x}){delete p[l],delete x[l]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:l}=this.props;Ts(l)&&(this.childSubscription=l.on("change",p=>{this.current&&(this.current.textContent=`${p}`)}))}}function OG(s){return window.getComputedStyle(s)}class BG extends mF{constructor(){super(...arguments),this.type="html",this.renderInstance=ik}readValueFromInstance(l,p){if(td.has(p)){const x=sE(p);return x&&x.default||0}else{const x=OG(l),T=(Qz(p)?x.getPropertyValue(p):x[p])||0;return typeof T=="string"?T.trim():T}}measureInstanceViewportBox(l,{transformPagePoint:p}){return nF(l,p)}build(l,p,x){G2(l,p,x.transformTemplate)}scrapeMotionValuesFromProps(l,p,x){return q2(l,p,x)}}class NG extends mF{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Cr}getBaseTargetFromProps(l,p){return l[p]}readValueFromInstance(l,p){if(td.has(p)){const x=sE(p);return x&&x.default||0}return p=nk.has(p)?p:O2(p),l.getAttribute(p)}scrapeMotionValuesFromProps(l,p,x){return ok(l,p,x)}build(l,p,x){$2(l,p,this.isSVGTag,x.transformTemplate)}renderInstance(l,p,x,T){rk(l,p,x,T)}mount(l){this.isSVGTag=Z2(l.tagName),super.mount(l)}}const VG=(s,l)=>N2(s)?new NG(l):new BG(l,{allowProjection:s!==Ge.Fragment}),UG=dj({...u8,...MG,...xG,...RG},VG),bi=AU(UG);function jG({length:s=6,value:l,onChange:p}){const x=Ge.useRef([]),T=(a,F)=>{var se;if(!/^\d*$/.test(F))return;const H=l.padEnd(s,"").split("");H[a]=F.slice(-1);const ee=H.join("").slice(0,s);p(ee),F&&a<s-1&&((se=x.current[a+1])==null||se.focus())},C=(a,F)=>{var H,ee,se;if(F.key==="Backspace")if(l[a]){const ue=l.padEnd(s,"").split("");ue[a]="",p(ue.join(""))}else a>0&&((H=x.current[a-1])==null||H.focus());else F.key==="ArrowLeft"&&a>0?(ee=x.current[a-1])==null||ee.focus():F.key==="ArrowRight"&&a<s-1&&((se=x.current[a+1])==null||se.focus())},L=a=>{var ee;a.preventDefault();const F=a.clipboardData.getData("text").replace(/\D/g,"").slice(0,s);if(!F)return;p(F.padEnd(s,"").slice(0,s));const H=Math.min(F.length,s-1);(ee=x.current[H])==null||ee.focus()};return J.jsx("div",{className:"flex gap-3 justify-center",children:Array.from({length:s},(a,F)=>J.jsx("input",{ref:H=>{x.current[F]=H},type:"text",inputMode:"numeric",maxLength:1,value:l[F]||"",onChange:H=>T(F,H.target.value),onKeyDown:H=>C(F,H),onPaste:L,className:"w-12 h-14 text-center text-xl font-mono glass rounded-xl text-text-primary focus:border-accent-primary/50 focus:glow-primary outline-none transition-all"},F))})}var _F={exports:{}};(function(s,l){(function(p,x){s.exports=x()})(vN,function(){let p,x,T;function C(a,F){if(!p)p=F;else if(!x)x=F;else{const H={};p(H),T=F(H);const ee="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 = {}; ("+p+")(sharedChunk); ("+x+")(undefined, sharedChunk); self.onerror = null;";typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(T.workerUrl=window.URL.createObjectURL(new Blob([ee],{type:"text/javascript"})))}}C(["exports"],function(a){var F=1e-6,H=typeof Float32Array<"u"?Float32Array:Array;function ee(n,e){var t=e[0],r=e[1],c=e[2],h=e[3],f=t*h-c*r;return f?(n[0]=h*(f=1/f),n[1]=-r*f,n[2]=-c*f,n[3]=t*f,n):null}function se(){var n=new H(9);return H!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function ue(n,e){var t=e[0],r=e[1],c=e[2],h=e[3],f=e[4],_=e[5],g=e[6],b=e[7],S=e[8];return n[0]=f*S-_*b,n[1]=c*b-r*S,n[2]=r*_-c*f,n[3]=_*g-h*S,n[4]=t*S-c*g,n[5]=c*h-t*_,n[6]=h*b-f*g,n[7]=r*g-t*b,n[8]=t*f-r*h,n}function Me(n,e,t){var r=e[0],c=e[1],h=e[2],f=e[3],_=e[4],g=e[5],b=e[6],S=e[7],I=e[8],A=t[0],M=t[1],D=t[2],z=t[3],B=t[4],V=t[5],Z=t[6],G=t[7],Y=t[8];return n[0]=A*r+M*f+D*b,n[1]=A*c+M*_+D*S,n[2]=A*h+M*g+D*I,n[3]=z*r+B*f+V*b,n[4]=z*c+B*_+V*S,n[5]=z*h+B*g+V*I,n[6]=Z*r+G*f+Y*b,n[7]=Z*c+G*_+Y*S,n[8]=Z*h+G*g+Y*I,n}function Ve(){var n=new H(16);return H!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0),n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function ke(n){var e=new H(16);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],e}function Ye(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Se(n,e){var t=e[0],r=e[1],c=e[2],h=e[3],f=e[4],_=e[5],g=e[6],b=e[7],S=e[8],I=e[9],A=e[10],M=e[11],D=e[12],z=e[13],B=e[14],V=e[15],Z=t*_-r*f,G=t*g-c*f,Y=t*b-h*f,Q=r*g-c*_,te=r*b-h*_,me=c*b-h*g,ce=S*z-I*D,pe=S*B-A*D,he=S*V-M*D,de=I*B-A*z,Be=I*V-M*z,je=A*V-M*B,He=Z*je-G*Be+Y*de+Q*he-te*pe+me*ce;return He?(n[0]=(_*je-g*Be+b*de)*(He=1/He),n[1]=(c*Be-r*je-h*de)*He,n[2]=(z*me-B*te+V*Q)*He,n[3]=(A*te-I*me-M*Q)*He,n[4]=(g*he-f*je-b*pe)*He,n[5]=(t*je-c*he+h*pe)*He,n[6]=(B*Y-D*me-V*G)*He,n[7]=(S*me-A*Y+M*G)*He,n[8]=(f*Be-_*he+b*ce)*He,n[9]=(r*he-t*Be-h*ce)*He,n[10]=(D*te-z*Y+V*Z)*He,n[11]=(I*Y-S*te-M*Z)*He,n[12]=(_*pe-f*de-g*ce)*He,n[13]=(t*de-r*pe+c*ce)*He,n[14]=(z*G-D*Q-B*Z)*He,n[15]=(S*Q-I*G+A*Z)*He,n):null}function ye(n,e,t){var r=e[0],c=e[1],h=e[2],f=e[3],_=e[4],g=e[5],b=e[6],S=e[7],I=e[8],A=e[9],M=e[10],D=e[11],z=e[12],B=e[13],V=e[14],Z=e[15],G=t[0],Y=t[1],Q=t[2],te=t[3];return n[0]=G*r+Y*_+Q*I+te*z,n[1]=G*c+Y*g+Q*A+te*B,n[2]=G*h+Y*b+Q*M+te*V,n[3]=G*f+Y*S+Q*D+te*Z,n[4]=(G=t[4])*r+(Y=t[5])*_+(Q=t[6])*I+(te=t[7])*z,n[5]=G*c+Y*g+Q*A+te*B,n[6]=G*h+Y*b+Q*M+te*V,n[7]=G*f+Y*S+Q*D+te*Z,n[8]=(G=t[8])*r+(Y=t[9])*_+(Q=t[10])*I+(te=t[11])*z,n[9]=G*c+Y*g+Q*A+te*B,n[10]=G*h+Y*b+Q*M+te*V,n[11]=G*f+Y*S+Q*D+te*Z,n[12]=(G=t[12])*r+(Y=t[13])*_+(Q=t[14])*I+(te=t[15])*z,n[13]=G*c+Y*g+Q*A+te*B,n[14]=G*h+Y*b+Q*M+te*V,n[15]=G*f+Y*S+Q*D+te*Z,n}function Ie(n,e,t){var r,c,h,f,_,g,b,S,I,A,M,D,z=t[0],B=t[1],V=t[2];return e===n?(n[12]=e[0]*z+e[4]*B+e[8]*V+e[12],n[13]=e[1]*z+e[5]*B+e[9]*V+e[13],n[14]=e[2]*z+e[6]*B+e[10]*V+e[14],n[15]=e[3]*z+e[7]*B+e[11]*V+e[15]):(c=e[1],h=e[2],f=e[3],_=e[4],g=e[5],b=e[6],S=e[7],I=e[8],A=e[9],M=e[10],D=e[11],n[0]=r=e[0],n[1]=c,n[2]=h,n[3]=f,n[4]=_,n[5]=g,n[6]=b,n[7]=S,n[8]=I,n[9]=A,n[10]=M,n[11]=D,n[12]=r*z+_*B+I*V+e[12],n[13]=c*z+g*B+A*V+e[13],n[14]=h*z+b*B+M*V+e[14],n[15]=f*z+S*B+D*V+e[15]),n}function qe(n,e,t){var r=t[0],c=t[1],h=t[2];return n[0]=e[0]*r,n[1]=e[1]*r,n[2]=e[2]*r,n[3]=e[3]*r,n[4]=e[4]*c,n[5]=e[5]*c,n[6]=e[6]*c,n[7]=e[7]*c,n[8]=e[8]*h,n[9]=e[9]*h,n[10]=e[10]*h,n[11]=e[11]*h,n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}function ot(n,e,t){var r=Math.sin(t),c=Math.cos(t),h=e[4],f=e[5],_=e[6],g=e[7],b=e[8],S=e[9],I=e[10],A=e[11];return e!==n&&(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[4]=h*c+b*r,n[5]=f*c+S*r,n[6]=_*c+I*r,n[7]=g*c+A*r,n[8]=b*c-h*r,n[9]=S*c-f*r,n[10]=I*c-_*r,n[11]=A*c-g*r,n}function xt(n,e,t){var r=Math.sin(t),c=Math.cos(t),h=e[0],f=e[1],_=e[2],g=e[3],b=e[8],S=e[9],I=e[10],A=e[11];return e!==n&&(n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=h*c-b*r,n[1]=f*c-S*r,n[2]=_*c-I*r,n[3]=g*c-A*r,n[8]=h*r+b*c,n[9]=f*r+S*c,n[10]=_*r+I*c,n[11]=g*r+A*c,n}function Rt(n,e,t){var r=Math.sin(t),c=Math.cos(t),h=e[0],f=e[1],_=e[2],g=e[3],b=e[4],S=e[5],I=e[6],A=e[7];return e!==n&&(n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15]),n[0]=h*c+b*r,n[1]=f*c+S*r,n[2]=_*c+I*r,n[3]=g*c+A*r,n[4]=b*c-h*r,n[5]=S*c-f*r,n[6]=I*c-_*r,n[7]=A*c-g*r,n}function Tt(n,e){return n[0]=e[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function li(n,e,t){var r,c,h,f=t[0],_=t[1],g=t[2],b=Math.sqrt(f*f+_*_+g*g);return b<F?null:(f*=b=1/b,_*=b,g*=b,r=Math.sin(e),c=Math.cos(e),n[0]=f*f*(h=1-c)+c,n[1]=_*f*h+g*r,n[2]=g*f*h-_*r,n[3]=0,n[4]=f*_*h-g*r,n[5]=_*_*h+c,n[6]=g*_*h+f*r,n[7]=0,n[8]=f*g*h+_*r,n[9]=_*g*h-f*r,n[10]=g*g*h+c,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n)}function Xt(n,e){var t=e[0],r=e[1],c=e[2],h=e[4],f=e[5],_=e[6],g=e[8],b=e[9],S=e[10];return n[0]=Math.sqrt(t*t+r*r+c*c),n[1]=Math.sqrt(h*h+f*f+_*_),n[2]=Math.sqrt(g*g+b*b+S*S),n}function Ji(n,e){var t=e[0],r=e[1],c=e[2],h=e[3],f=t+t,_=r+r,g=c+c,b=t*f,S=r*f,I=r*_,A=c*f,M=c*_,D=c*g,z=h*f,B=h*_,V=h*g;return n[0]=1-I-D,n[1]=S+V,n[2]=A-B,n[3]=0,n[4]=S-V,n[5]=1-b-D,n[6]=M+z,n[7]=0,n[8]=A+B,n[9]=M-z,n[10]=1-b-I,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}var An=ye;function gi(){var n=new H(3);return H!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function Mr(n){var e=new H(3);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e}function Wn(n){var e=n[0],t=n[1],r=n[2];return Math.sqrt(e*e+t*t+r*r)}function ji(n,e,t){var r=new H(3);return r[0]=n,r[1]=e,r[2]=t,r}function ti(n,e,t,r){return n[0]=e,n[1]=t,n[2]=r,n}function Pt(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n[2]=e[2]+t[2],n}function $t(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n[2]=e[2]-t[2],n}function Wt(n,e,t){return n[0]=e[0]*t[0],n[1]=e[1]*t[1],n[2]=e[2]*t[2],n}function Ut(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n}function ii(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n}function mi(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n}function rn(n,e,t,r){return n[0]=e[0]+t[0]*r,n[1]=e[1]+t[1]*r,n[2]=e[2]+t[2]*r,n}function ln(n,e){var t=e[0]-n[0],r=e[1]-n[1],c=e[2]-n[2];return Math.sqrt(t*t+r*r+c*c)}function sn(n,e){var t=e[0]-n[0],r=e[1]-n[1],c=e[2]-n[2];return t*t+r*r+c*c}function Rr(n){var e=n[0],t=n[1],r=n[2];return e*e+t*t+r*r}function lo(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n}function zi(n,e){var t=e[0],r=e[1],c=e[2],h=t*t+r*r+c*c;return h>0&&(h=1/Math.sqrt(h)),n[0]=e[0]*h,n[1]=e[1]*h,n[2]=e[2]*h,n}function pn(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function On(n,e,t){var r=e[0],c=e[1],h=e[2],f=t[0],_=t[1],g=t[2];return n[0]=c*g-h*_,n[1]=h*f-r*g,n[2]=r*_-c*f,n}function oa(n,e,t,r){var c=e[0],h=e[1],f=e[2];return n[0]=c+r*(t[0]-c),n[1]=h+r*(t[1]-h),n[2]=f+r*(t[2]-f),n}function mn(n,e,t){var r=e[0],c=e[1],h=e[2],f=t[3]*r+t[7]*c+t[11]*h+t[15];return n[0]=(t[0]*r+t[4]*c+t[8]*h+t[12])/(f=f||1),n[1]=(t[1]*r+t[5]*c+t[9]*h+t[13])/f,n[2]=(t[2]*r+t[6]*c+t[10]*h+t[14])/f,n}function Mo(n,e,t){var r=e[0],c=e[1],h=e[2];return n[0]=r*t[0]+c*t[3]+h*t[6],n[1]=r*t[1]+c*t[4]+h*t[7],n[2]=r*t[2]+c*t[5]+h*t[8],n}function co(n,e,t){var r=t[0],c=t[1],h=t[2],f=t[3],_=e[0],g=e[1],b=e[2],S=c*b-h*g,I=h*_-r*b,A=r*g-c*_;return n[0]=_+f*(S+=S)+c*(A+=A)-h*(I+=I),n[1]=g+f*I+h*S-r*A,n[2]=b+f*A+r*I-c*S,n}function cc(n){return n[0]=0,n[1]=0,n[2]=0,n}function Hs(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]}var Ln=$t,id=Wt,La=Wn;function Zr(){var n=new H(4);return H!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function nd(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n[2]=e[2]*t,n[3]=e[3]*t,n}function za(n,e){var t=e[0],r=e[1],c=e[2],h=e[3],f=t*t+r*r+c*c+h*h;return f>0&&(f=1/Math.sqrt(f)),n[0]=t*f,n[1]=r*f,n[2]=c*f,n[3]=h*f,n}function Ro(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]*e[3]}function vr(n,e,t){var r=e[0],c=e[1],h=e[2],f=e[3];return n[0]=t[0]*r+t[4]*c+t[8]*h+t[12]*f,n[1]=t[1]*r+t[5]*c+t[9]*h+t[13]*f,n[2]=t[2]*r+t[6]*c+t[10]*h+t[14]*f,n[3]=t[3]*r+t[7]*c+t[11]*h+t[15]*f,n}function Es(){var n=new H(4);return H!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function aa(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function uc(n,e,t){t*=.5;var r=e[0],c=e[1],h=e[2],f=e[3],_=Math.sin(t),g=Math.cos(t);return n[0]=r*g+f*_,n[1]=c*g+h*_,n[2]=h*g-c*_,n[3]=f*g-r*_,n}function hc(n,e,t){t*=.5;var r=e[0],c=e[1],h=e[2],f=e[3],_=Math.sin(t),g=Math.cos(t);return n[0]=r*g-h*_,n[1]=c*g+f*_,n[2]=h*g+r*_,n[3]=f*g-c*_,n}gi(),Zr();var Nr,dc,fc,br=za,Eu=(Nr=gi(),dc=ji(1,0,0),fc=ji(0,1,0),function(n,e,t){var r=pn(e,t);return r<-.999999?(On(Nr,dc,e),La(Nr)<1e-6&&On(Nr,fc,e),zi(Nr,Nr),function(c,h,f){f*=.5;var _=Math.sin(f);c[0]=_*h[0],c[1]=_*h[1],c[2]=_*h[2],c[3]=Math.cos(f)}(n,Nr,Math.PI),n):r>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(On(Nr,e,t),n[0]=Nr[0],n[1]=Nr[1],n[2]=Nr[2],n[3]=1+r,br(n,n))});function Dr(){var n=new H(2);return H!=Float32Array&&(n[0]=0,n[1]=0),n}function Do(n,e){var t=new H(2);return t[0]=n,t[1]=e,t}function ka(n,e,t){return n[0]=e,n[1]=t,n}function Is(n,e,t){return n[0]=e[0]+t[0],n[1]=e[1]+t[1],n}function Lo(n,e,t){return n[0]=e[0]-t[0],n[1]=e[1]-t[1],n}function fl(n,e,t){return n[0]=e[0]*t,n[1]=e[1]*t,n}function pl(n){var e=n[0],t=n[1];return Math.sqrt(e*e+t*t)}function ml(n,e){var t=e[0],r=e[1],c=t*t+r*r;return c>0&&(c=1/Math.sqrt(c)),n[0]=e[0]*c,n[1]=e[1]*c,n}function uo(n,e){return n[0]*e[0]+n[1]*e[1]}Es(),Es(),se();var _l,Iu,Ap=Lo;function Fa(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}Dr();var rd=function(){if(Iu)return _l;function n(e,t,r,c){this.cx=3*e,this.bx=3*(r-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(c-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=r,this.p2y=c}return Iu=1,_l=n,n.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(t===void 0&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var r=e,c=0;c<8;c++){var h=this.sampleCurveX(r)-e;if(Math.abs(h)<t)return r;var f=this.sampleCurveDerivativeX(r);if(Math.abs(f)<1e-6)break;r-=h/f}var _=0,g=1;for(r=e,c=0;c<20&&(h=this.sampleCurveX(r),!(Math.abs(h-e)<t));c++)e>h?_=r:g=r,r=.5*(g-_)+_;return r},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},_l}(),Au=Fa(rd);function it(n,e){this.x=n,this.y=e}function zo(n,e){if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!zo(n[t],e[t]))return!1;return!0}if(typeof n=="object"&&n!==null&&e!==null){if(typeof e!="object"||Object.keys(n).length!==Object.keys(e).length)return!1;for(const t in n)if(!zo(n[t],e[t]))return!1;return!0}return n===e}it.prototype={clone(){return new it(this.x,this.y)},add(n){return this.clone()._add(n)},sub(n){return this.clone()._sub(n)},multByPoint(n){return this.clone()._multByPoint(n)},divByPoint(n){return this.clone()._divByPoint(n)},mult(n){return this.clone()._mult(n)},div(n){return this.clone()._div(n)},rotate(n){return this.clone()._rotate(n)},rotateAround(n,e){return this.clone()._rotateAround(n,e)},matMult(n){return this.clone()._matMult(n)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(n){return this.x===n.x&&this.y===n.y},dist(n){return Math.sqrt(this.distSqr(n))},distSqr(n){const e=n.x-this.x,t=n.y-this.y;return e*e+t*t},angle(){return Math.atan2(this.y,this.x)},angleTo(n){return Math.atan2(this.y-n.y,this.x-n.x)},angleWith(n){return this.angleWithSep(n.x,n.y)},angleWithSep(n,e){return Math.atan2(this.x*e-this.y*n,this.x*n+this.y*e)},_matMult(n){const e=n[2]*this.x+n[3]*this.y;return this.x=n[0]*this.x+n[1]*this.y,this.y=e,this},_add(n){return this.x+=n.x,this.y+=n.y,this},_sub(n){return this.x-=n.x,this.y-=n.y,this},_mult(n){return this.x*=n,this.y*=n,this},_div(n){return this.x/=n,this.y/=n,this},_multByPoint(n){return this.x*=n.x,this.y*=n.y,this},_divByPoint(n){return this.x/=n.x,this.y/=n.y,this},_unit(){return this._div(this.mag()),this},_perp(){const n=this.y;return this.y=this.x,this.x=-n,this},_rotate(n){const e=Math.cos(n),t=Math.sin(n),r=t*this.x+e*this.y;return this.x=e*this.x-t*this.y,this.y=r,this},_rotateAround(n,e){const t=Math.cos(n),r=Math.sin(n),c=e.y+r*(this.x-e.x)+t*(this.y-e.y);return this.x=e.x+t*(this.x-e.x)-r*(this.y-e.y),this.y=c,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:it},it.convert=function(n){if(n instanceof it)return n;if(Array.isArray(n))return new it(+n[0],+n[1]);if(n.x!==void 0&&n.y!==void 0)return new it(+n.x,+n.y);throw new Error("Expected [x, y] or {x, y} point format")};const vn=Math.PI/180,wr=180/Math.PI;function Ei(n){return n*vn}function _r(n){return n*wr}const Zs=[[0,0],[1,0],[1,1],[0,1]];function Cu(n){if(n<=0)return 0;if(n>=1)return 1;const e=n*n,t=e*n;return 4*(n<.5?t:3*(n-e)+t-.75)}function Re(n,e,t,r){const c=new Au(n,e,t,r);return function(h){return c.solve(h)}}const $=Re(.25,.1,.25,1);function q(n,e,t){return Math.min(t,Math.max(e,n))}function oe(n,e,t){return(t=q((t-n)/(e-n),0,1))*t*(3-2*t)}function ge(n,e,t){const r=t-e,c=((n-e)%r+r)%r+e;return c===e?t:c}function be(n,e,t){if(!n.length)return t(null,[]);let r=n.length;const c=new Array(n.length);let h=null;n.forEach((f,_)=>{e(f,(g,b)=>{g&&(h=g),c[_]=b,--r===0&&t(h,c)})})}let Te=1;function De(){return Te++}function Ae(n){return n<=1?1:Math.pow(2,Math.ceil(Math.log2(n)))}function Le(n,e){n.forEach(t=>{e[t]&&(e[t]=e[t].bind(e))})}function rt(n,e,t){const r={};for(const c in n)r[c]=e.call(this,n[c],c,n);return r}function Ke(n,e,t){const r={};for(const c in n)e.call(this,n[c],c,n)&&(r[c]=n[c]);return r}function gt(n){return Array.isArray(n)?n.map(gt):typeof n=="object"&&n?rt(n,gt):n}function Lt(n,e){for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>=0)return!0;return!1}const Bt={};function zt(n){Bt[n]||(typeof console<"u"&&console.warn(n),Bt[n]=!0)}function Kt(n,e,t){return(t.y-n.y)*(e.x-n.x)>(e.y-n.y)*(t.x-n.x)}function hi(n){let e=0;for(let t,r,c=0,h=n.length,f=h-1;c<h;f=c++)t=n[c],r=n[f],e+=(r.x-t.x)*(t.y+r.y);return e}function _i([n,e,t]){const r=Ei(e+90),c=Ei(t);return{x:n*Math.cos(r)*Math.sin(c),y:n*Math.sin(r)*Math.sin(c),z:n*Math.cos(c),azimuthal:e,polar:t}}function Wi(n){return(typeof self<"u"||n!==void 0)&&typeof WorkerGlobalScope<"u"&&(n!==void 0?n:self)instanceof WorkerGlobalScope}function zn(n){const e={};if(n.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(t,r,c,h)=>{const f=c||h;return e[r]=!f||f.toLowerCase(),""}),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let Cn,bn=null;function Ni(n,e){return[n[4*e],n[4*e+1],n[4*e+2],n[4*e+3]]}function cn(n,e,t,r){for(;e<t;){const c=e+t>>1;n[c]<r?e=c+1:t=c}return e}function jn(n,e,t,r){for(;e<t;){const c=e+t>>1;n[c]<=r?e=c+1:t=c}return e}function Xi(n){return n>0?1/(1.001-n):1+n}function un(n){return n>0?1-1/(1.001-n):-n}function wn(n,e,t){return(n-e.min)*(t.max-t.min)/(e.max-e.min)+t.min}const yi={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},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(!yi.API_URL)return null;try{const n=new URL(yi.API_URL);return n.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":n.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",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:"/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1",TILE_PROVIDER_URLS:Object.assign(Object.create(null),{pmtiles:"/mapbox-gl-js/mapbox-gl-pmtiles-provider-v0.0.1.js"})};function Xn(){return new URL(yi.DRACO_URL,yi.API_URL).href}function Tr(){if(typeof WebAssembly!="object")throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return new URL(function(){if(Cn===void 0){if(typeof WebAssembly!="object")return!1;const n=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]);Cn=WebAssembly.validate(n)}return Cn}()?yi.MESHOPT_SIMD_URL:yi.MESHOPT_URL,yi.API_URL).href}function gr(){return new URL(yi.BUILDING_GEN_URL,yi.API_URL).href}function us(n){return yi.API_URL_REGEX.test(n)}function hs(n){return yi.API_SPRITE_REGEX.test(n)}let ko,qr,ds,Fo,As,Oo;function qs(){return ko==null&&(ko=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),ko}const ts={now:()=>Fo!==void 0?Fo:performance.now(),setNow(n){Fo=n},restoreNow(){Fo=void 0},frame(n){const e=requestAnimationFrame(n);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(n,e=0){const{width:t,height:r}=n;As||(As=document.createElement("canvas"));const c=As.getContext("2d",{willReadFrequently:!0});if(!c)throw new Error("failed to create canvas 2d context");return(t>As.width||r>As.height)&&(As.width=t,As.height=r),c.clearRect(-e,-e,t+2*e,r+2*e),c.drawImage(n,0,0,t,r),c.getImageData(-e,-e,t+2*e,r+2*e)},resolveURL:n=>(qr||(qr=document.createElement("a")),qr.href=n,qr.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(ds==null&&(ds=window.matchMedia("(prefers-reduced-motion: reduce)")),ds.matches)},hasCanvasFingerprintNoise(){if(Oo!==void 0)return Oo;if(!qs())return Oo=!1,!1;const n=new OffscreenCanvas(85,1),e=n.getContext("2d",{willReadFrequently:!0});let t=0;for(let c=0;c<n.width;++c)e.fillStyle=`rgba(${t++},${t++},${t++}, 255)`,e.fillRect(c,0,1,1);const r=e.getImageData(0,0,n.width,n.height);t=0;for(let c=0;c<r.data.length;++c)if(c%4!=3&&t++!==r.data[c])return Oo=!0,!0;return Oo=!1,!1}};function Pu(n,e){const t=n.indexOf("?");if(t<0)return`${n}?${new URLSearchParams(e).toString()}`;const r=new URLSearchParams(n.slice(t));for(const c in e)r.set(c,e[c]);return`${n.slice(0,t)}?${r.toString()}`}function Cp(n,e={persistentParams:[]}){const t=n.indexOf("?");if(t<0)return n;const r=new URLSearchParams,c=new URLSearchParams(n.slice(t));for(const f of e.persistentParams){const _=c.get(f);_&&r.set(f,_)}const h=r.toString();return`${n.slice(0,t)}${h.length>0?`?${h}`:""}`}const gl="mapbox-tiles";let sd=500,od=50;const Pp=["language","worldview","jobid"];let Bo;function ty(){try{return caches}catch{}}function ad(){const n=ty();n&&Bo==null&&(Bo=n.open(gl))}let Mp=1/0;const ld={supported:!1,testSupport:function(n){!Rp&&pc&&(Ws?mc(n):yl=n)}};let yl,pc,Rp=!1,Ws=!1;const Dp=typeof self<"u"?self:{};function mc(n){const e=n.createTexture();n.bindTexture(n.TEXTURE_2D,e);try{if(n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,pc),n.isContextLost())return;ld.supported=!0}catch{}n.deleteTexture(e),Rp=!0}Dp.document&&(pc=Dp.document.createElement("img"),pc.onload=function(){yl&&mc(yl),yl=null,Ws=!0},pc.onerror=function(){Rp=!0,yl=null},pc.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Mu={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(Mu);class Lp extends Error{constructor(e,t,r){t===401&&us(r)&&(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=r}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}function zp(n){return typeof n=="object"&&n!==null&&"status"in n&&n.status===404}const Ai=Wi()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,_c=function(n,e){return/^file:/.test(t=n.url)||/^file:/.test(Ai())&&!/^\w+:/.test(t)?function(r,c){const h=new XMLHttpRequest;h.open(r.method||"GET",r.url,!0),r.type==="arrayBuffer"&&(h.responseType="arraybuffer");for(const f in r.headers)h.setRequestHeader(f,r.headers[f]);return r.type==="json"&&(h.responseType="text",h.setRequestHeader("Accept","application/json")),h.withCredentials=r.credentials==="include",h.onerror=()=>{c(new Error(h.statusText))},h.onload=()=>{if((h.status>=200&&h.status<300||h.status===0)&&h.response!==null){let f=h.response;if(r.type==="json")try{f=JSON.parse(h.response)}catch(g){return c(g)}const _=new Headers;h.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(g=>{const b=g.split(": "),S=b.shift(),I=b.join(": ");_.append(S,I)}),c(null,f,_)}else c(new Lp(h.statusText,h.status,r.url))},h.send(r.body),{cancel:()=>h.abort()}}(n,e):function(r,c){const h=new AbortController,f=new Request(r.url,{method:r.method||"GET",body:r.body,credentials:r.credentials,headers:r.headers,referrer:Ai(),referrerPolicy:r.referrerPolicy,signal:h.signal});let _=!1,g=!1;const b=(S=f.url).indexOf("sku=")>0&&us(S);var S;r.type==="json"&&f.headers.set("Accept","application/json");const I=(M,D,z)=>{if(g)return;if(M&&M.message!=="SecurityError"&&zt(M.toString()),D&&z)return A(D);const B=Date.now();fetch(f).then(V=>{if(V.ok){const Z=b?V.clone():null;return A(V,Z,B)}return c(new Lp(V.statusText,V.status,r.url))}).catch(V=>{V.name!=="AbortError"&&c(new Error(`${V.message} ${r.url}`))})},A=(M,D,z)=>{(r.type==="arrayBuffer"?M.arrayBuffer():r.type==="json"?M.json():M.text()).then(B=>{g||(D&&z&&function(V,Z,G){if(ad(),Bo==null)return;const Y=zn(Z.headers.get("cache-control")||"");if(Y["no-store"])return;const Q={status:Z.status,statusText:Z.statusText,headers:new Headers};Z.headers.forEach((he,de)=>Q.headers.set(de,he)),Y["max-age"]&&Q.headers.set("Expires",new Date(G+1e3*Y["max-age"]).toUTCString());const te=Q.headers.get("expires");if(!te||new Date(te).getTime()-G<42e4)return;let me=Cp(V.url,{persistentParams:Pp});if(Z.status===206){const he=V.headers.get("Range");if(!he)return;Q.status=200,me=Pu(me,{range:he})}const ce=new Response((pe=Z.status)!==200&&pe!==404&&[101,103,204,205,304].includes(pe)?null:Z.body,Q);var pe;ad(),Bo!=null&&Bo.then(he=>he.put(me,ce)).catch(he=>zt(he.message))}(f,D,z),_=!0,c(null,B,M.headers))}).catch(B=>{g||c(new Error(B.message))})};return b?function(M,D){if(ad(),Bo==null)return D(null);Bo.then(z=>{let B=Cp(M.url,{persistentParams:Pp});const V=M.headers.get("Range");V&&(B=Pu(B,{range:V})),z.match(B).then(Z=>{const G=function(Y){if(!Y)return!1;const Q=new Date(Y.headers.get("expires")||0),te=zn(Y.headers.get("cache-control")||"");return Number(Q)>Date.now()&&!te["no-cache"]}(Z);z.delete(B).catch(D),G&&z.put(B,Z.clone()).catch(D),D(null,Z,G)}).catch(D)}).catch(D)}(f,I):I(null,null),{cancel:()=>{g=!0,_||h.abort()}}}(n,e);var t},gc=function(n,e){return _c(Object.assign(n,{type:"arrayBuffer"}),e)};function u1(n){const e=document.createElement("a");return e.href=n,e.protocol===location.protocol&&e.host===location.host}let cd,Oa;cd=[],Oa=0;const yc=function(n,e){if(ld.supported&&(n.headers||(n.headers={}),n.headers.accept="image/webp,*/*"),Oa>=yi.MAX_PARALLEL_IMAGE_REQUESTS){const h={requestParameters:n,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return cd.push(h),h}Oa++;let t=!1;const r=()=>{if(!t)for(t=!0,Oa--;cd.length&&Oa<yi.MAX_PARALLEL_IMAGE_REQUESTS;){const h=cd.shift(),{requestParameters:f,callback:_,cancelled:g}=h;g||(h.cancel=yc(f,_).cancel)}},c=gc(n,(h,f,_)=>{r(),h?e(h):f&&function(g,b){const S=new Blob([new Uint8Array(g)],{type:"image/png"});createImageBitmap(S).then(I=>{b(null,I)}).catch(I=>{b(new Error(`Could not load image because of ${I.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(f,(g,b)=>e(g,b,_))});return{cancel:()=>{c.cancel(),r()}}};var Ru,ud,iy,xl={exports:{}},ny={exports:{}},kp={exports:{}},h1=function(){if(iy)return xl.exports;iy=1;var n=(Ru||(Ru=1,ny.exports=function(t,r){var c,h,f,_,g,b,S,I;for(h=t.length-(c=3&t.length),f=r,g=3432918353,b=461845907,I=0;I<h;)S=255&t.charCodeAt(I)|(255&t.charCodeAt(++I))<<8|(255&t.charCodeAt(++I))<<16|(255&t.charCodeAt(++I))<<24,++I,f=27492+(65535&(_=5*(65535&(f=(f^=S=(65535&(S=(S=(65535&S)*g+(((S>>>16)*g&65535)<<16)&4294967295)<<15|S>>>17))*b+(((S>>>16)*b&65535)<<16)&4294967295)<<13|f>>>19))+((5*(f>>>16)&65535)<<16)&4294967295))+(((_>>>16)+58964&65535)<<16);switch(S=0,c){case 3:S^=(255&t.charCodeAt(I+2))<<16;case 2:S^=(255&t.charCodeAt(I+1))<<8;case 1:f^=S=(65535&(S=(S=(65535&(S^=255&t.charCodeAt(I)))*g+(((S>>>16)*g&65535)<<16)&4294967295)<<15|S>>>17))*b+(((S>>>16)*b&65535)<<16)&4294967295}return f^=t.length,f=2246822507*(65535&(f^=f>>>16))+((2246822507*(f>>>16)&65535)<<16)&4294967295,f=3266489909*(65535&(f^=f>>>13))+((3266489909*(f>>>16)&65535)<<16)&4294967295,(f^=f>>>16)>>>0}),ny.exports),e=(ud||(ud=1,kp.exports=function(t,r){for(var c,h=t.length,f=r^h,_=0;h>=4;)c=1540483477*(65535&(c=255&t.charCodeAt(_)|(255&t.charCodeAt(++_))<<8|(255&t.charCodeAt(++_))<<16|(255&t.charCodeAt(++_))<<24))+((1540483477*(c>>>16)&65535)<<16),f=1540483477*(65535&f)+((1540483477*(f>>>16)&65535)<<16)^(c=1540483477*(65535&(c^=c>>>24))+((1540483477*(c>>>16)&65535)<<16)),h-=4,++_;switch(h){case 3:f^=(255&t.charCodeAt(_+2))<<16;case 2:f^=(255&t.charCodeAt(_+1))<<8;case 1:f=1540483477*(65535&(f^=255&t.charCodeAt(_)))+((1540483477*(f>>>16)&65535)<<16)}return f=1540483477*(65535&(f^=f>>>13))+((1540483477*(f>>>16)&65535)<<16),(f^=f>>>15)>>>0}),kp.exports);return xl.exports=n,xl.exports.murmur3=n,xl.exports.murmur2=e,xl.exports}(),Ba=Fa(h1);class ho{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e}}class xc extends ho{constructor(e,t={}){super("error",Object.assign({error:e},t))}}function Xs(n,e,t){t[n]&&t[n].indexOf(e)!==-1||(t[n]=t[n]||[],t[n].push(e))}function hd(n,e,t){if(t&&t[n]){const r=t[n].indexOf(e);r!==-1&&t[n].splice(r,1)}}class Du{on(e,t){return this._listeners=this._listeners||{},Xs(e,t,this._listeners),this}off(e,t){return hd(e,t,this._listeners),hd(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Xs(e,t,this._oneTimeListeners),this):new Promise(r=>{this.once(e,r)})}fire(e,t){const r=typeof e=="string"?new ho(e,t):e,c=r.type;if(this.listens(c)){r.target=this;const h=this._listeners&&this._listeners[c]?this._listeners[c].slice():[];for(const g of h)g.call(this,r);const f=this._oneTimeListeners&&this._oneTimeListeners[c]?this._oneTimeListeners[c].slice():[];for(const g of f)hd(c,g,this._oneTimeListeners),g.call(this,r);const _=this._eventedParent;if(_){const g=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(r,g),_.fire(r)}}else r instanceof xc&&console.error(r.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}}class fs{constructor(e){typeof e=="string"?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new fs(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,r]=e.split("");return new fs({name:t,iconsetId:r})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return fs.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var Fp,dd={},Op=function(){if(Fp)return dd;Fp=1;var n={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 e(h){return(h=Math.round(h))<0?0:h>255?255:h}function t(h){return e(h[h.length-1]==="%"?parseFloat(h)/100*255:parseInt(h))}function r(h){return(f=h[h.length-1]==="%"?parseFloat(h)/100:parseFloat(h))<0?0:f>1?1:f;var f}function c(h,f,_){return _<0?_+=1:_>1&&(_-=1),6*_<1?h+(f-h)*_*6:2*_<1?f:3*_<2?h+(f-h)*(2/3-_)*6:h}try{dd.parseCSSColor=function(h){var f,_=h.replace(/ /g,"").toLowerCase();if(_ in n)return n[_].slice();if(_[0]==="#")return _.length===4?(f=parseInt(_.substr(1),16))>=0&&f<=4095?[(3840&f)>>4|(3840&f)>>8,240&f|(240&f)>>4,15&f|(15&f)<<4,1]:null:_.length===7&&(f=parseInt(_.substr(1),16))>=0&&f<=16777215?[(16711680&f)>>16,(65280&f)>>8,255&f,1]:null;var g=_.indexOf("("),b=_.indexOf(")");if(g!==-1&&b+1===_.length){var S=_.substr(0,g),I=_.substr(g+1,b-(g+1)).split(","),A=1;switch(S){case"rgba":if(I.length!==4)return null;A=r(I.pop());case"rgb":return I.length!==3?null:[t(I[0]),t(I[1]),t(I[2]),A];case"hsla":if(I.length!==4)return null;A=r(I.pop());case"hsl":if(I.length!==3)return null;var M=(parseFloat(I[0])%360+360)%360/360,D=r(I[1]),z=r(I[2]),B=z<=.5?z*(D+1):z+D-z*D,V=2*z-B;return[e(255*c(V,B,M+1/3)),e(255*c(V,B,M)),e(255*c(V,B,M-1/3)),A];default:return null}}return null}}catch{}return dd}();class Ii{constructor(e,t,r,c=1){this.r=e,this.g=t,this.b=r,this.a=c}static parse(e){if(!e)return;if(e instanceof Ii)return e;if(typeof e!="string")return;const t=Op.parseCSSColor(e);return t?new Ii(t[0]/255,t[1]/255,t[2]/255,t[3]):void 0}toString(){const[e,t,r,c]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*r)},${c})`}toNonPremultipliedRenderColor(e){const{r:t,g:r,b:c,a:h}=this;return new fd(e,t,r,c,h)}toPremultipliedRenderColor(e){const{r:t,g:r,b:c,a:h}=this;return new vc(e,t*h,r*h,c*h,h)}clone(){return new Ii(this.r,this.g,this.b,this.a)}}class Bp{constructor(e,t,r,c,h,f=!1){if(this.premultiplied=!1,this.premultiplied=f,e){const _=e.image.height,g=_*_;this.premultiplied?(t=h===0?0:t/h*(_-1),r=h===0?0:r/h*(_-1),c=h===0?0:c/h*(_-1)):(t*=_-1,r*=_-1,c*=_-1),t=Math.max(0,Math.min(_-1,t)),r=Math.max(0,Math.min(_-1,r)),c=Math.max(0,Math.min(_-1,c));const b=Math.floor(t),S=Math.floor(r),I=Math.floor(c),A=Math.ceil(t),M=Math.ceil(r),D=Math.ceil(c),z=t-b,B=r-S,V=c-I,Z=e.image.data,G=4*(b+S*g+I*_),Y=4*(b+S*g+D*_),Q=4*(b+M*g+I*_),te=4*(b+M*g+D*_),me=4*(A+S*g+I*_),ce=4*(A+S*g+D*_),pe=4*(A+M*g+I*_),he=4*(A+M*g+D*_);this.r=Gt(Gt(Gt(Z[G],Z[Y],V),Gt(Z[Q],Z[te],V),B),Gt(Gt(Z[me],Z[ce],V),Gt(Z[pe],Z[he],V),B),z)/255*(this.premultiplied?h:1),this.g=Gt(Gt(Gt(Z[G+1],Z[Y+1],V),Gt(Z[Q+1],Z[te+1],V),B),Gt(Gt(Z[me+1],Z[ce+1],V),Gt(Z[pe+1],Z[he+1],V),B),z)/255*(this.premultiplied?h:1),this.b=Gt(Gt(Gt(Z[G+2],Z[Y+2],V),Gt(Z[Q+2],Z[te+2],V),B),Gt(Gt(Z[me+2],Z[ce+2],V),Gt(Z[pe+2],Z[he+2],V),B),z)/255*(this.premultiplied?h:1),this.a=h}else this.r=t,this.g=r,this.b=c,this.a=h}toArray(){const{r:e,g:t,b:r,a:c}=this;return[255*e,255*t,255*r,c]}toHslaArray(){let{r:e,g:t,b:r,a:c}=this;if(this.premultiplied){if(c===0)return[0,0,0,0];const D=1/c;e*=D,t*=D,r*=D}const h=Math.min(Math.max(e,0),1),f=Math.min(Math.max(t,0),1),_=Math.min(Math.max(r,0),1),g=Math.min(h,f,_),b=Math.max(h,f,_),S=b-g,I=.5*(g+b);if(S===0)return[0,0,100*I,c];const A=I>.5?S/(2-b-g):S/(b+g);let M;switch(b){case h:M=60*((f-_)/S+(f<_?6:0));break;case f:M=60*((_-h)/S+2);break;default:M=60*((h-f)/S+4)}return[M,100*A,100*I,c]}toArray01(){const{r:e,g:t,b:r,a:c}=this;return[e,t,r,c]}toArray01Scaled(e){const{r:t,g:r,b:c}=this;return[t*e,r*e,c*e]}toArray01Linear(){const{r:e,g:t,b:r,a:c}=this;return[Math.pow(e,2.2),Math.pow(t,2.2),Math.pow(r,2.2),c]}}class fd extends Bp{constructor(e,t,r,c,h){super(e,t,r,c,h,!1)}}class vc extends Bp{constructor(e,t,r,c,h){super(e,t,r,c,h,!0)}}function Gt(n,e,t){return n*(1-t)+e*t}function fo(n,e,t){return n.map((r,c)=>Gt(r,e[c],t))}Ii.black=new Ii(0,0,0,1),Ii.white=new Ii(1,1,1,1),Ii.transparent=new Ii(0,0,0,0),Ii.red=new Ii(1,0,0,1),Ii.blue=new Ii(0,0,1,1);var pd=Object.freeze({__proto__:null,array:fo,color:function(n,e,t){return new Ii(Gt(n.r,e.r,t),Gt(n.g,e.g,t),Gt(n.b,e.b,t),Gt(n.a,e.a,t))},number:Gt});class Ys extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class vl{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[r,c]of t)this.bindings[r]=c}concat(e){return new vl(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const la={kind:"null"},Dt={kind:"number"},ki={kind:"string"},Fi={kind:"boolean"},Wr={kind:"color"},Na={kind:"object"},Oi={kind:"value"},bl={kind:"collator"},Lu={kind:"formatted"},zu={kind:"resolvedImage"};function Vr(n,e){return{kind:"array",itemType:n,N:e}}function Gn(n){if(n.kind==="array"){const e=Gn(n.itemType);return typeof n.N=="number"?`array<${e}, ${n.N}>`:n.itemType.kind==="value"?"array":`array<${e}>`}return n.kind}const d1=[la,Dt,ki,Fi,Wr,Lu,Na,Vr(Oi),zu];function ku(n,e){if(e.kind==="error")return null;if(n.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!ku(n.itemType,e.itemType))&&(typeof n.N!="number"||n.N===e.N))return null}else{if(n.kind===e.kind)return null;if(n.kind==="value"){for(const t of d1)if(!ku(t,e))return null}}return`Expected ${Gn(n)} but found ${Gn(e)} instead.`}function Np(n,e){return e.some(t=>t.kind===n.kind)}function bc(n,e){return e.some(t=>t==="null"?n===null:t==="array"?Array.isArray(n):t==="object"?n&&!Array.isArray(n)&&typeof n=="object":t===typeof n)}function ca(n,e){return n.kind==="array"&&e.kind==="array"?n.N===e.N&&ca(n.itemType,e.itemType):n.kind===e.kind}class Vp{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Fu{constructor(e,t,r,c,h){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=r,this.fontStack=c,this.textColor=h}}class Lr{constructor(e){this.sections=e}static fromString(e){return new Lr([new Fu(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof Lr?e:Lr.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){const c=t.image.getPrimary().id.toString();e.push(["image",c]);continue}e.push(t.text);const r={};t.fontStack&&(r["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(r["font-scale"]=t.scale),t.textColor&&(r["text-color"]=["rgba"].concat(t.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(r)}return e}}class Ks{constructor(e,t={}){this.id=fs.from(e),this.params=t.params,this.sx=t.sx||1,this.sy=t.sy||1}toString(){return JSON.stringify(this)}static parse(e){let t,r,c,h;try{({id:t,params:r,sx:c,sy:h}=JSON.parse(e)||{})}catch{return null}return t?new Ks(t,{params:r,sx:c,sy:h}):null}scaleSelf(e,t=e){return this.sx*=e,this.sy*=t,this}}class is{constructor(e,t,r,c,h=!1){this.primaryId=fs.from(e),this.primaryOptions=t,r&&(this.secondaryId=fs.from(r)),this.secondaryOptions=c,this.available=h}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new Ks(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Ks(this.secondaryId,this.secondaryOptions):null}static from(e){return typeof e=="string"?is.build({name:e}):e}static build(e,t,r,c){return!e||typeof e=="object"&&!("name"in e)?null:new is(e,r,t,c)}}function ry(n,e,t,r){return typeof n=="number"&&n>=0&&n<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof t=="number"&&t>=0&&t<=255?r===void 0||typeof r=="number"&&r>=0&&r<=1?null:`Invalid rgba value [${[n,e,t,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof r=="number"?[n,e,t,r]:[n,e,t]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function wc(n){if(n===null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||n instanceof Ii||n instanceof Vp||n instanceof Lr||n instanceof is)return!0;if(Array.isArray(n)){for(const e of n)if(!wc(e))return!1;return!0}if(typeof n=="object"){for(const e in n)if(!wc(n[e]))return!1;return!0}return!1}function Pn(n){if(n===null)return la;if(typeof n=="string")return ki;if(typeof n=="boolean")return Fi;if(typeof n=="number")return Dt;if(n instanceof Ii)return Wr;if(n instanceof Vp)return bl;if(n instanceof Lr)return Lu;if(n instanceof is)return zu;if(Array.isArray(n)){const e=n.length;let t;for(const r of n){const c=Pn(r);if(t){if(t===c)continue;t=Oi;break}t=c}return Vr(t||Oi,e)}return Na}function jt(n){const e=typeof n;return n===null?"":e==="string"||e==="number"||e==="boolean"?String(n):n instanceof Lr||n instanceof is||n instanceof Ii?n.toString():JSON.stringify(n)}class At{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(e.length!==2)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!wc(e[1]))return t.error("invalid value");const r=e[1];let c=Pn(r);const h=t.expectedType;return c.kind!=="array"||c.N!==0||!h||h.kind!=="array"||typeof h.N=="number"&&h.N!==0||(c=h),new At(c,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Ii?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Lr?this.value.serialize():this.value}}class Nn{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const Ht={string:ki,number:Dt,boolean:Fi,object:Na};class Cs{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r,c=1;const h=e[0];if(h==="array"){let _,g;if(e.length>2){const b=e[1];if(typeof b!="string"||!(b in Ht)||b==="object")return t.error('The item type argument of "array" must be one of string, number, boolean',1);_=Ht[b],c++}else _=Oi;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);g=e[2],c++}r=Vr(_,g)}else r=Ht[h];const f=[];for(;c<e.length;c++){const _=t.parse(e[c],c,Oi);if(!_)return null;f.push(_)}return new Cs(r,f)}evaluate(e){for(let t=0;t<this.args.length;t++){const r=this.args[t].evaluate(e);if(!ku(this.type,Pn(r)))return r;if(t===this.args.length-1)throw new Nn(`The expression ${JSON.stringify(this.args[t].serialize())} evaluated to ${Gn(Pn(r))} but was expected to be of type ${Gn(this.type)}.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,t=[e.kind];if(e.kind==="array"){const r=e.itemType;if(r.kind==="string"||r.kind==="number"||r.kind==="boolean"){t.push(r.kind);const c=e.N;(typeof c=="number"||this.args.length>1)&&t.push(c)}}return t.concat(this.args.map(r=>r.serialize()))}}class wl{constructor(e){this.type=Lu,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&typeof r=="object")return t.error("First argument must be an image or text section.");const c=[];let h=!1;for(let f=1;f<=e.length-1;++f){const _=e[f];if(h&&typeof _=="object"&&!Array.isArray(_)){h=!1;let g=null;if(_["font-scale"]&&(g=t.parseObjectValue(_["font-scale"],f,"font-scale",Dt),!g))return null;let b=null;if(_["text-font"]&&(b=t.parseObjectValue(_["text-font"],f,"text-font",Vr(ki)),!b))return null;let S=null;if(_["text-color"]&&(S=t.parseObjectValue(_["text-color"],f,"text-color",Wr),!S))return null;const I=c[c.length-1];I.scale=g,I.font=b,I.textColor=S}else{const g=t.parse(e[f],f,Oi);if(!g)return null;const b=g.type.kind;if(b!=="string"&&b!=="value"&&b!=="null"&&b!=="resolvedImage")return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,c.push({content:g,scale:null,font:null,textColor:null})}}return new wl(c)}evaluate(e){return new Lr(this.sections.map(t=>{const r=t.content.evaluate(e);return ca(Pn(r),zu)?new Fu("",r,null,null,null):new Fu(jt(r),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const r={};t.scale&&(r["font-scale"]=t.scale.serialize()),t.font&&(r["text-font"]=t.font.serialize()),t.textColor&&(r["text-color"]=t.textColor.serialize()),e.push(r)}return e}}class Nt{constructor(e,t,r,c){this._imageWarnHistory={},this.type=zu,this.namePrimary=e,this.nameSecondary=t,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),c&&(this.paramsSecondary=c.params,this.iconsetIdSecondary=c.iconset?c.iconset.id:void 0)}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let r=1;const c=[];function h(){if(r<e.length){const _=t.parse(e[r],r++,ki);return _?(c.push({image:_,options:{}}),!0):(t.error(c.length?"Secondary image variant is not a string.":"No image name provided."),!1)}return!0}function f(){if(r<e.length){const g=e[r];if((_=g)===null||typeof _!="object"||Array.isArray(_))return!0;const b=g.params,S=g.iconset,I=t.concat(r);if(!b&&!S)return r++,!0;if(b){if(typeof b!="object"||b.constructor!==Object)return I.error('Image options "params" should be an object'),!1;const A={},M=I.concat(void 0,"params");for(const D in b){if(!D)return M.error("Image parameter name should be non-empty"),!1;const z=M.concat(void 0,D).parse(b[D],void 0,Wr,void 0,{typeAnnotation:"coerce"});if(!z)return!1;A[D]=z}c[c.length-1].options.params=A}if(S){if(typeof S!="object"||S.constructor!==Object)return I.error('Image options "iconset" should be an object'),!1;if(!S.id)return I.error('Image options "iconset" should have an "id" property'),!1;c[c.length-1].options.iconset=S}return r++,!0}var _;return!0}for(let _=0;_<2;_++)if(!h()||!f())return;return new Nt(c[0].image,c[1]?c[1].image:void 0,c[0].options,c[1]?c[1].options:void 0)}evaluateParams(e,t){const r={};if(t){for(const c in t)if(t[c])try{r[c]=t[c].evaluate(e)}catch{continue}if(Object.keys(r).length!==0)return{params:r}}}evaluate(e){const t={name:this.namePrimary.evaluate(e),iconsetId:this.iconsetIdPrimary},r=this.nameSecondary?{name:this.nameSecondary.evaluate(e),iconsetId:this.iconsetIdSecondary}:void 0,c=is.build(t,r,this.paramsPrimary?this.evaluateParams(e,this.paramsPrimary):void 0,this.paramsSecondary?this.evaluateParams(e,this.paramsSecondary):void 0);if(c&&e.availableImages){const h=c.getPrimary().id;if(c.available=e.availableImages.some(f=>fs.isEqual(f,h)),c.available){const f=c.getSecondary()?c.getSecondary().id:null;f&&(c.available=e.availableImages.some(_=>fs.isEqual(_,f)))}}return c}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(const t in this.paramsPrimary)this.paramsPrimary[t]&&e(this.paramsPrimary[t]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(const t in this.paramsSecondary)this.paramsSecondary[t]&&e(this.paramsSecondary[t])}outputDefined(){return!1}serializeOptions(e,t){const r={};if(t&&(r.iconset={id:t}),e){r.params={};for(const c in e)e[c]&&(r.params[c]=e[c].serialize())}return Object.keys(r).length>0?r:void 0}serialize(){const e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const t=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);t&&e.push(t)}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const t=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);t&&e.push(t)}return e}}function Ou(n){return _d(n)?"string":Bu(n)?"number":Nu(n)?"boolean":Array.isArray(n)?"array":n===null?"null":md(n)?"object":typeof n}function md(n){return n!=null&&!Array.isArray(n)&&typeof n!="function"&&!(n instanceof String||n instanceof Number||n instanceof Boolean)&&typeof n=="object"}function _d(n){return typeof n=="string"||n instanceof String}function Bu(n){return typeof n=="number"||n instanceof Number}function Nu(n){return typeof n=="boolean"||n instanceof Boolean}const f1={"to-boolean":Fi,"to-color":Wr,"to-number":Dt,"to-string":ki};class po{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[0],c=[];let h=la;if(r==="to-array"){if(!Array.isArray(e[1]))return null;const f=e[1].length;if(t.expectedType){if(t.expectedType.kind!=="array")return t.error(`Expected ${t.expectedType.kind} but found array.`);h=Vr(t.expectedType.itemType,f)}else{if(!(f>0&&wc(e[1][0])))return null;h=Vr(Pn(e[1][0]),f)}for(let _=0;_<f;_++){const g=e[1][_];let b;if(Array.isArray(g))b=t.parse(g,void 0,h.itemType);else{const S=Ou(g);if(S!==h.itemType.kind)return t.error(`Expected ${h.itemType.kind} but found ${S}.`);b=t.registry.literal.parse(["literal",g===void 0?null:g],t)}if(!b)return null;c.push(b)}}else{if((r==="to-boolean"||r==="to-string")&&e.length!==2)return t.error("Expected one argument.");h=f1[r];for(let f=1;f<e.length;f++){const _=t.parse(e[f],f,Oi);if(!_)return null;c.push(_)}}return new po(h,c)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let t,r;for(const c of this.args){if(t=c.evaluate(e),r=null,t instanceof Ii)return t;if(typeof t=="string"){const h=e.parseColor(t);if(h)return h}else if(Array.isArray(t)&&(r=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:ry(t[0],t[1],t[2],t[3]),!r))return new Ii(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Nn(r||`Could not parse color from value '${typeof t=="string"?t:String(JSON.stringify(t))}'`)}if(this.type.kind==="number"){let t=null;for(const r of this.args){if(t=r.evaluate(e),t===null)return 0;const c=Number(t);if(!isNaN(c))return c}throw new Nn(`Could not convert ${JSON.stringify(t)} to number.`)}return this.type.kind==="formatted"?Lr.fromString(jt(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?is.build(jt(this.args[0].evaluate(e))):this.type.kind==="array"?this.args.map(t=>t.evaluate(e)):jt(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new wl([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Nt(this.args[0]).serialize();const e=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize())}),e}}const Tl=["Unknown","Point","LineString","Polygon"];class Vu{constructor(e,t,r){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,this.iconImageUseTheme=r}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Tl[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:r,y:c}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*t-e[0])+this.featureDistanceData.bearing[1]*(c*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Ii.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class ir{constructor(e,t,r,c,h){this.name=e,this.type=t,this._evaluate=r,this.args=c,this._overloadIndex=h}evaluate(e){if(!this._evaluate){const t=ir.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.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 r=e[0],c=ir.definitions[r];if(!c)return t.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const h=Array.isArray(c)?c[0]:c.type,f=Array.isArray(c)?[[c[1],c[2]]]:c.overloads,_=[];let g=null,b=-1;for(const[S,I]of f){if(Array.isArray(S)&&S.length!==e.length-1)continue;_.push(S),b++,g=new Sd(t.registry,t.path,null,t.scope,void 0,t._scope,t.options,t.iconImageUseTheme);const A=[];let M=!1;for(let D=1;D<e.length;D++){const z=e[D],B=Array.isArray(S)?S[D-1]:S.type,V=g.parse(z,1+A.length,B);if(!V){M=!0;break}A.push(V)}if(!M)if(Array.isArray(S)&&S.length!==A.length)g.error(`Expected ${S.length} arguments, but found ${A.length} instead.`);else{for(let D=0;D<A.length;D++){const z=Array.isArray(S)?S[D]:S.type,B=A[D];g.concat(D+1).checkSubtype(z,B.type)}if(g.errors.length===0)return new ir(r,h,I,A,b)}}if(_.length===1)t.errors.push(...g.errors);else{const S=(_.length?_:f.map(([A])=>A)).map(Va).join(" | "),I=[];for(let A=1;A<e.length;A++){const M=t.parse(e[A],1+I.length);if(!M)return null;I.push(Gn(M.type))}t.error(`Expected arguments of type ${S}, but found (${I.join(", ")}) instead.`)}return null}static register(e,t){ir.definitions=t;for(const r in t)e[r]=ir}}function Va(n){return Array.isArray(n)?`(${n.map(Gn).join(", ")})`:`(${Gn(n.type)}...)`}class gd{constructor(e,t,r){this.type=bl,this.locale=r,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(e.length!==2)return t.error("Expected one argument."),null;const r=e[1];if(typeof r!="object"||Array.isArray(r))return t.error("Collator options argument must be an object."),null;const c=r["case-sensitive"]===void 0?t.parse(!1,1,Fi):t.parseObjectValue(r["case-sensitive"],1,"case-sensitive",Fi);if(!c)return null;const h=r["diacritic-sensitive"]===void 0?t.parse(!1,1,Fi):t.parseObjectValue(r["diacritic-sensitive"],1,"diacritic-sensitive",Fi);if(!h)return null;let f=null;return r.locale&&(f=t.parseObjectValue(r.locale,1,"locale",ki),!f)?null:new gd(c,h,f)}evaluate(e){return new Vp(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}function sy(n,e,t=0,r=n.length-1,c=yd){for(;r>t;){if(r-t>600){const g=r-t+1,b=e-t+1,S=Math.log(g),I=.5*Math.exp(2*S/3),A=.5*Math.sqrt(S*I*(g-I)/g)*(b-g/2<0?-1:1);sy(n,e,Math.max(t,Math.floor(e-b*I/g+A)),Math.min(r,Math.floor(e+(g-b)*I/g+A)),c)}const h=n[e];let f=t,_=r;for(Uu(n,t,e),c(n[r],h)>0&&Uu(n,t,r);f<_;){for(Uu(n,f,_),f++,_--;c(n[f],h)<0;)f++;for(;c(n[_],h)>0;)_--}c(n[t],h)===0?Uu(n,t,_):(_++,Uu(n,_,r)),_<=e&&(t=_+1),e<=_&&(r=_-1)}}function Uu(n,e,t){const r=n[e];n[e]=n[t],n[t]=r}function yd(n,e){return n<e?-1:n>e?1:0}function oy(n){let e=0;for(let t,r,c=0,h=n.length,f=h-1;c<h;f=c++)t=n[c],r=n[f],e+=(r.x-t.x)*(t.y+r.y);return e}function mo(n,e){n[0]=Math.min(n[0],e[0]),n[1]=Math.min(n[1],e[1]),n[2]=Math.max(n[2],e[0]),n[3]=Math.max(n[3],e[1])}function ju(n,e){return!(n[0]<=e[0]||n[2]>=e[2]||n[1]<=e[1]||n[3]>=e[3])}function p1(n,e,t){const r=n[0]-e[0],c=n[1]-e[1],h=n[0]-t[0],f=n[1]-t[1];return r*f-h*c===0&&r*h<=0&&c*f<=0}function Up(n,e,t){return e[1]>n[1]!=t[1]>n[1]&&n[0]<(t[0]-e[0])*(n[1]-e[1])/(t[1]-e[1])+e[0]}function Tc(n,e,t=!1){let r=!1;for(let c=0,h=e.length;c<h;c++){const f=e[c];for(let _=0,g=f.length,b=g-1;_<g;b=_++){const S=f[b],I=f[_];if(p1(n,S,I))return t;Up(n,S,I)&&(r=!r)}}return r}function ay(n,e,t,r){const c=r[0]-t[0],h=r[1]-t[1],f=(n[0]-t[0])*h-c*(n[1]-t[1]),_=(e[0]-t[0])*h-c*(e[1]-t[1]);return f>0&&_<0||f<0&&_>0}function Gu(n,e,t,r){return(c=[r[0]-t[0],r[1]-t[1]])[0]*(h=[e[0]-n[0],e[1]-n[1]])[1]-c[1]*h[0]!==0&&!(!ay(n,e,t,r)||!ay(t,r,n,e));var c,h}function jp(n){const e=new it(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),t=new it(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const r of n[0])e.x>r.x&&(e.x=r.x),e.y>r.y&&(e.y=r.y),t.x<r.x&&(t.x=r.x),t.y<r.y&&(t.y=r.y);return{min:e,max:t}}const Ua=8192;function m1(n,e){const t=(180+n[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n[1]*Math.PI/360)))/360,c=Math.pow(2,e.z);return[Math.round(t*c*Ua),Math.round(r*c*Ua)]}function Sl(n,e){for(let t=0;t<e.length;t++)if(Tc(n,e[t]))return!0;return!1}function _1(n,e,t){for(const r of t)for(let c=0,h=r.length,f=h-1;c<h;f=c++)if(Gu(n,e,r[f],r[c]))return!0;return!1}function ly(n,e){for(let t=0;t<n.length;++t)if(!Tc(n[t],e))return!1;for(let t=0;t<n.length-1;++t)if(_1(n[t],n[t+1],e))return!1;return!0}function Gp(n,e){for(let t=0;t<e.length;t++)if(ly(n,e[t]))return!0;return!1}function xd(n,e,t){const r=[];for(let c=0;c<n.length;c++){const h=[];for(let f=0;f<n[c].length;f++){const _=m1(n[c][f],t);mo(e,_),h.push(_)}r.push(h)}return r}function $p(n,e,t){const r=[];for(let c=0;c<n.length;c++){const h=xd(n[c],e,t);r.push(h)}return r}function Js(n,e,t,r){if(n[0]<t[0]||n[0]>t[2]){const c=.5*r;let h=n[0]-t[0]>c?-r:t[0]-n[0]>c?r:0;h===0&&(h=n[0]-t[2]>c?-r:t[2]-n[0]>c?r:0),n[0]+=h}mo(e,n)}function Hp(n,e,t,r){const c=Math.pow(2,r.z)*Ua,h=[r.x*Ua,r.y*Ua],f=[];if(!n)return f;for(const _ of n)for(const g of _){const b=[g.x+h[0],g.y+h[1]];Js(b,e,t,c),f.push(b)}return f}function Zp(n,e,t,r){const c=Math.pow(2,r.z)*Ua,h=[r.x*Ua,r.y*Ua],f=[];if(!n)return f;for(const g of n){const b=[];for(const S of g){const I=[S.x+h[0],S.y+h[1]];mo(e,I),b.push(I)}f.push(b)}if(e[2]-e[0]<=c/2){(_=e)[0]=_[1]=1/0,_[2]=_[3]=-1/0;for(const g of f)for(const b of g)Js(b,e,t,c)}var _;return f}class ja{constructor(e,t){this.type=Fi,this.geojson=e,this.geometries=t}static parse(e,t){if(e.length!==2)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(wc(e[1])){const r=e[1];if(r.type==="FeatureCollection")for(let c=0;c<r.features.length;++c){const h=r.features[c].geometry.type;if(h==="Polygon"||h==="MultiPolygon")return new ja(r,r.features[c].geometry)}else if(r.type==="Feature"){const c=r.geometry.type;if(c==="Polygon"||c==="MultiPolygon")return new ja(r,r.geometry)}else if(r.type==="Polygon"||r.type==="MultiPolygon")return new ja(r,r)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(t,r){const c=[1/0,1/0,-1/0,-1/0],h=[1/0,1/0,-1/0,-1/0],f=t.canonicalID();if(!f)return!1;if(r.type==="Polygon"){const _=xd(r.coordinates,h,f),g=Hp(t.geometry(),c,h,f);if(!ju(c,h))return!1;for(const b of g)if(!Tc(b,_))return!1}if(r.type==="MultiPolygon"){const _=$p(r.coordinates,h,f),g=Hp(t.geometry(),c,h,f);if(!ju(c,h))return!1;for(const b of g)if(!Sl(b,_))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(t,r){const c=[1/0,1/0,-1/0,-1/0],h=[1/0,1/0,-1/0,-1/0],f=t.canonicalID();if(!f)return!1;if(r.type==="Polygon"){const _=xd(r.coordinates,h,f),g=Zp(t.geometry(),c,h,f);if(!ju(c,h))return!1;for(const b of g)if(!ly(b,_))return!1}if(r.type==="MultiPolygon"){const _=$p(r.coordinates,h,f),g=Zp(t.geometry(),c,h,f);if(!ju(c,h))return!1;for(const b of g)if(!Gp(b,_))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}const $u={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},qp=1/298.257223563,Wp=qp*(2-qp),Sc=Math.PI/180;class Ec{static fromTile(e,t,r){const c=Math.PI*(1-2*(e+.5)/Math.pow(2,t)),h=Math.atan(.5*(Math.exp(c)-Math.exp(-c)))/Sc;return new Ec(h,r)}static get units(){return $u}constructor(e,t){if(e===void 0)throw new Error("No latitude given.");if(t&&!$u[t])throw new Error(`Unknown unit ${t}. Use one of: ${Object.keys($u).join(", ")}`);const r=6378.137*Sc*(t?$u[t]:1),c=Math.cos(e*Sc),h=1/(1-Wp*(1-c*c)),f=Math.sqrt(h);this.kx=r*f*c,this.ky=r*f*h*(1-Wp)}distance(e,t){const r=Ps(e[0]-t[0])*this.kx,c=(e[1]-t[1])*this.ky;return Math.sqrt(r*r+c*c)}bearing(e,t){const r=Ps(t[0]-e[0])*this.kx;return Math.atan2(r,(t[1]-e[1])*this.ky)/Sc}destination(e,t,r){const c=r*Sc;return this.offset(e,Math.sin(c)*t,Math.cos(c)*t)}offset(e,t,r){return[e[0]+t/this.kx,e[1]+r/this.ky]}lineDistance(e){let t=0;for(let r=0;r<e.length-1;r++)t+=this.distance(e[r],e[r+1]);return t}area(e){let t=0;for(let r=0;r<e.length;r++){const c=e[r];for(let h=0,f=c.length,_=f-1;h<f;_=h++)t+=Ps(c[h][0]-c[_][0])*(c[h][1]+c[_][1])*(r?-1:1)}return Math.abs(t)/2*this.kx*this.ky}along(e,t){let r=0;if(t<=0)return e[0];for(let c=0;c<e.length-1;c++){const h=e[c],f=e[c+1],_=this.distance(h,f);if(r+=_,r>t)return vd(h,f,(t-(r-_))/_)}return e[e.length-1]}pointToSegmentDistance(e,t,r){let[c,h]=t,f=Ps(r[0]-c)*this.kx,_=(r[1]-h)*this.ky;if(f!==0||_!==0){const g=(Ps(e[0]-c)*this.kx*f+(e[1]-h)*this.ky*_)/(f*f+_*_);g>1?(c=r[0],h=r[1]):g>0&&(c+=f/this.kx*g,h+=_/this.ky*g)}return f=Ps(e[0]-c)*this.kx,_=(e[1]-h)*this.ky,Math.sqrt(f*f+_*_)}pointOnLine(e,t){let r=1/0,c=e[0][0],h=e[0][1],f=0,_=0;for(let g=0;g<e.length-1;g++){let b=e[g][0],S=e[g][1],I=Ps(e[g+1][0]-b)*this.kx,A=(e[g+1][1]-S)*this.ky,M=0;I===0&&A===0||(M=(Ps(t[0]-b)*this.kx*I+(t[1]-S)*this.ky*A)/(I*I+A*A),M>1?(b=e[g+1][0],S=e[g+1][1]):M>0&&(b+=I/this.kx*M,S+=A/this.ky*M)),I=Ps(t[0]-b)*this.kx,A=(t[1]-S)*this.ky;const D=I*I+A*A;D<r&&(r=D,c=b,h=S,f=g,_=M)}return{point:[c,h],index:f,t:Math.max(0,Math.min(1,_))}}lineSlice(e,t,r){let c=this.pointOnLine(r,e),h=this.pointOnLine(r,t);if(c.index>h.index||c.index===h.index&&c.t>h.t){const b=c;c=h,h=b}const f=[c.point],_=c.index+1,g=h.index;!Xp(r[_],f[0])&&_<=g&&f.push(r[_]);for(let b=_+1;b<=g;b++)f.push(r[b]);return Xp(r[g],h.point)||f.push(h.point),f}lineSliceAlong(e,t,r){let c=0;const h=[];for(let f=0;f<r.length-1;f++){const _=r[f],g=r[f+1],b=this.distance(_,g);if(c+=b,c>e&&h.length===0&&h.push(vd(_,g,(e-(c-b))/b)),c>=t)return h.push(vd(_,g,(t-(c-b))/b)),h;c>e&&h.push(g)}return h}bufferPoint(e,t){const r=t/this.ky,c=t/this.kx;return[e[0]-c,e[1]-r,e[0]+c,e[1]+r]}bufferBBox(e,t){const r=t/this.ky,c=t/this.kx;return[e[0]-c,e[1]-r,e[2]+c,e[3]+r]}insideBBox(e,t){return Ps(e[0]-t[0])>=0&&Ps(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}function Xp(n,e){return n[0]===e[0]&&n[1]===e[1]}function vd(n,e,t){const r=Ps(e[0]-n[0]);return[n[0]+r*t,n[1]+(e[1]-n[1])*t]}function Ps(n){for(;n<-180;)n+=360;for(;n>180;)n-=360;return n}class Hu{constructor(e=[],t=(r,c)=>r<c?-1:r>c?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let r=(this.length>>1)-1;r>=0;r--)this._down(r)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,c=t[e];for(;e>0;){const h=e-1>>1,f=t[h];if(r(c,f)>=0)break;t[e]=f,e=h}t[e]=c}_down(e){const{data:t,compare:r}=this,c=this.length>>1,h=t[e];for(;e<c;){let f=1+(e<<1);const _=f+1;if(_<this.length&&r(t[_],t[f])<0&&(f=_),r(t[f],h)>=0)break;t[e]=t[f],e=f}t[e]=h}}var _t=8192;function cy(n,e){return e.dist-n.dist}function uy(n){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function El(n){return n[1]-n[0]+1}function _o(n,e){const t=n[1]>=n[0]&&n[1]<e;return t||console.warn("Distance Expression: Index is out of range"),t}function Ic(n,e){if(n[0]>n[1])return[null,null];const t=El(n);if(e){if(t===2)return[n,null];const r=Math.floor(t/2);return[[n[0],n[0]+r],[n[0]+r,n[1]]]}{if(t===1)return[n,null];const r=Math.floor(t/2)-1;return[[n[0],n[0]+r],[n[0]+r+1,n[1]]]}}function Ga(n,e){const t=[1/0,1/0,-1/0,-1/0];if(!_o(e,n.length))return t;for(let r=e[0];r<=e[1];++r)mo(t,n[r]);return t}function Zu(n){const e=[1/0,1/0,-1/0,-1/0];for(let t=0;t<n.length;++t)for(let r=0;r<n[t].length;++r)mo(e,n[t][r]);return e}function Ac(n,e,t){if(uy(n)||uy(e))return NaN;let r=0,c=0;return n[2]<e[0]&&(r=e[0]-n[2]),n[0]>e[2]&&(r=n[0]-e[2]),n[1]>e[3]&&(c=n[1]-e[3]),n[3]<e[1]&&(c=e[1]-n[3]),t.distance([0,0],[r,c])}function g1(n){return 360*n-180}function hy(n){return 360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90}function ua(n,e,t=8192){const r=Math.pow(2,e.z),c=(n.y/t+e.y)/r;return[g1((n.x/t+e.x)/r),hy(c)]}function dy(n,e){const t=[];for(let r=0;r<n.length;++r)t.push(ua(n[r],e));return t}function xi(n,e,t){const r=t.pointOnLine(e,n).point;return t.distance(n,r)}function fy(n,e,t,r,c){const h=t.slice(r[0],r[1]+1);let f=1/0;for(let _=e[0];_<=e[1];++_)if((f=Math.min(f,xi(n[_],h,c)))===0)return 0;return f}function Yp(n,e,t,r,c){const h=Math.min(c.pointToSegmentDistance(n,t,r),c.pointToSegmentDistance(e,t,r)),f=Math.min(c.pointToSegmentDistance(t,n,e),c.pointToSegmentDistance(r,n,e));return Math.min(h,f)}function y1(n,e,t,r,c){if(!_o(e,n.length)||!_o(r,t.length))return NaN;let h=1/0;for(let f=e[0];f<e[1];++f)for(let _=r[0];_<r[1];++_){if(Gu(n[f],n[f+1],t[_],t[_+1]))return 0;h=Math.min(h,Yp(n[f],n[f+1],t[_],t[_+1],c))}return h}function py(n,e,t,r,c){if(!_o(e,n.length)||!_o(r,t.length))return NaN;let h=1/0;for(let f=e[0];f<=e[1];++f)for(let _=r[0];_<=r[1];++_)if((h=Math.min(h,c.distance(n[f],t[_])))===0)return h;return h}function x1(n,e,t){if(Tc(n,e,!0))return 0;let r=1/0;for(const c of e){const h=c.length;if(h<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(c[0]!==c[h-1]&&(r=Math.min(r,t.pointToSegmentDistance(n,c[h-1],c[0])))===0||(r=Math.min(r,xi(n,c,t)))===0)return r}return r}function hn(n,e,t,r){if(!_o(e,n.length))return NaN;for(let h=e[0];h<=e[1];++h)if(Tc(n[h],t,!0))return 0;let c=1/0;for(let h=e[0];h<e[1];++h)for(const f of t)for(let _=0,g=f.length,b=g-1;_<g;b=_++){if(Gu(n[h],n[h+1],f[b],f[_]))return 0;c=Math.min(c,Yp(n[h],n[h+1],f[b],f[_],r))}return c}function my(n,e){for(const t of n)for(let r=0;r<=t.length-1;++r)if(Tc(t[r],e,!0))return!0;return!1}function v1(n,e,t,r=1/0){const c=Zu(n),h=Zu(e);if(r!==1/0&&Ac(c,h,t)>=r)return r;if(ju(c,h)){if(my(n,e))return 0}else if(my(e,n))return 0;let f=r;for(const _ of n)for(let g=0,b=_.length,S=b-1;g<b;S=g++)for(const I of e)for(let A=0,M=I.length,D=M-1;A<M;D=A++){if(Gu(_[S],_[g],I[D],I[A]))return 0;f=Math.min(f,Yp(_[S],_[g],I[D],I[A],t))}return f}function bd(n,e,t,r,c,h,f){if(h===null||f===null)return;const _=Ac(Ga(r,h),Ga(c,f),t);_<e&&n.push({dist:_,range1:h,range2:f})}function b1(n,e,t,r,c=1/0){let h=Math.min(r.distance(n[0],t[0][0]),c);if(h===0)return h;const f=new Hu([{dist:0,range1:[0,n.length-1],range2:[0,0]}],cy),_=e?50:100,g=Zu(t);for(;f.length;){const b=f.pop();if(b.dist>=h)continue;const S=b.range1;if(El(S)<=_){if(!_o(S,n.length))return NaN;if(e){const I=hn(n,S,t,r);if((h=Math.min(h,I))===0)return h}else for(let I=S[0];I<=S[1];++I){const A=x1(n[I],t,r);if((h=Math.min(h,A))===0)return h}}else{const I=Ic(S,e);if(I[0]!==null){const A=Ac(Ga(n,I[0]),g,r);A<h&&f.push({dist:A,range1:I[0],range2:[0,0]})}if(I[1]!==null){const A=Ac(Ga(n,I[1]),g,r);A<h&&f.push({dist:A,range1:I[1],range2:[0,0]})}}}return h}function _y(n,e,t,r,c,h=1/0){let f=Math.min(h,c.distance(n[0],t[0]));if(f===0)return f;const _=new Hu([{dist:0,range1:[0,n.length-1],range2:[0,t.length-1]}],cy),g=e?50:100,b=r?50:100;for(;_.length;){const S=_.pop();if(S.dist>=f)continue;const I=S.range1,A=S.range2;if(El(I)<=g&&El(A)<=b){if(!_o(I,n.length)||!_o(A,t.length))return NaN;if(e&&r?f=Math.min(f,y1(n,I,t,A,c)):e||r?e&&!r?f=Math.min(f,fy(t,A,n,I,c)):!e&&r&&(f=Math.min(f,fy(n,I,t,A,c))):f=Math.min(f,py(n,I,t,A,c)),f===0)return f}else{const M=Ic(I,e),D=Ic(A,r);bd(_,f,c,n,t,M[0],D[0]),bd(_,f,c,n,t,M[0],D[1]),bd(_,f,c,n,t,M[1],D[0]),bd(_,f,c,n,t,M[1],D[1])}}return f}function Kp(n,e,t,r,c=1/0){let h=c;const f=Ga(n,[0,n.length-1]);for(const _ of t)if(!(h!==1/0&&Ac(f,Ga(_,[0,_.length-1]),r)>=h)&&(h=Math.min(h,_y(n,e,_,!0,r,h)),h===0))return h;return h}function wd(n,e,t,r,c=1/0){let h=c;const f=Ga(n,[0,n.length-1]);for(const _ of t){if(h!==1/0&&Ac(f,Zu(_),r)>=h)continue;const g=b1(n,e,_,r,h);if(isNaN(g))return g;if((h=Math.min(h,g))===0)return h}return h}function Jp(n){return n==="Point"||n==="MultiPoint"||n==="LineString"||n==="MultiLineString"||n==="Polygon"||n==="MultiPolygon"}class Il{constructor(e,t){this.type=Dt,this.geojson=e,this.geometries=t}static parse(e,t){if(e.length!==2)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(wc(e[1])){const r=e[1];if(r.type==="FeatureCollection"){for(let c=0;c<r.features.length;++c)if(Jp(r.features[c].geometry.type))return new Il(r,r.features[c].geometry)}else if(r.type==="Feature"){if(Jp(r.geometry.type))return new Il(r,r.geometry)}else if(Jp(r.type))return new Il(r,r)}return t.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){const t=e.geometry(),r=e.canonicalID();if(t!=null&&r!=null){if(e.geometryType()==="Point")return function(c,h,f){const _=[];for(const b of c)for(const S of b)_.push(ua(S,h));const g=new Ec(_[0][1],"meters");return f.type==="Point"||f.type==="MultiPoint"||f.type==="LineString"?_y(_,!1,f.type==="Point"?[f.coordinates]:f.coordinates,f.type==="LineString",g):f.type==="MultiLineString"?Kp(_,!1,f.coordinates,g):f.type==="Polygon"||f.type==="MultiPolygon"?wd(_,!1,f.type==="Polygon"?[f.coordinates]:f.coordinates,g):null}(t,r,this.geometries);if(e.geometryType()==="LineString")return function(c,h,f){const _=[];for(const b of c){const S=[];for(const I of b)S.push(ua(I,h));_.push(S)}const g=new Ec(_[0][0][1],"meters");if(f.type==="Point"||f.type==="MultiPoint"||f.type==="LineString")return Kp(f.type==="Point"?[f.coordinates]:f.coordinates,f.type==="LineString",_,g);if(f.type==="MultiLineString"){let b=1/0;for(let S=0;S<f.coordinates.length;S++){const I=Kp(f.coordinates[S],!0,_,g,b);if(isNaN(I))return I;if((b=Math.min(b,I))===0)return b}return b}if(f.type==="Polygon"||f.type==="MultiPolygon"){let b=1/0;for(let S=0;S<_.length;S++){const I=wd(_[S],!0,f.type==="Polygon"?[f.coordinates]:f.coordinates,g,b);if(isNaN(I))return I;if((b=Math.min(b,I))===0)return b}return b}return null}(t,r,this.geometries);if(e.geometryType()==="Polygon")return function(c,h,f){const _=[];for(const b of function(S){const I=S.length;if(I<=1)return[S];const A=[];let M,D;for(let z=0;z<I;z++){const B=oy(S[z]);B!==0&&(S[z].area=Math.abs(B),D===void 0&&(D=B<0),D===B<0?(M&&A.push(M),M=[S[z]]):M.push(S[z]))}return M&&A.push(M),A}(c)){const S=[];for(let I=0;I<b.length;++I)S.push(dy(b[I],h));_.push(S)}const g=new Ec(_[0][0][0][1],"meters");if(f.type==="Point"||f.type==="MultiPoint"||f.type==="LineString")return wd(f.type==="Point"?[f.coordinates]:f.coordinates,f.type==="LineString",_,g);if(f.type==="MultiLineString"){let b=1/0;for(let S=0;S<f.coordinates.length;S++){const I=wd(f.coordinates[S],!0,_,g,b);if(isNaN(I))return I;if((b=Math.min(b,I))===0)return b}return b}return f.type==="Polygon"||f.type==="MultiPolygon"?function(b,S,I){let A=1/0;for(const M of b)for(const D of S){const z=v1(M,D,I,A);if(isNaN(z))return z;if((A=Math.min(A,z))===0)return A}return A}(f.type==="Polygon"?[f.coordinates]:f.coordinates,_,g):null}(t,r,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.")}else console.warn("Distance Expression: requires valid feature and canonical information.");return null}eachChild(){}outputDefined(){return!0}serialize(){return["distance",this.geojson]}}function Al(n){if(n instanceof ir&&(n.name==="get"&&n.args.length===1||n.name==="feature-state"||n.name==="has"&&n.args.length===1||n.name==="properties"||n.name==="geometry-type"||n.name==="id"||/^filter-/.test(n.name))||n instanceof ja||n instanceof Il)return!1;if(n instanceof Pc)return n.featureConstant;let e=!0;return n.eachChild(t=>{e&&!Al(t)&&(e=!1)}),e}function Cc(n){if(n instanceof ir&&n.name==="feature-state")return!1;let e=!0;return n.eachChild(t=>{e&&!Cc(t)&&(e=!1)}),e}function No(n,e){if(n instanceof ir&&e.indexOf(n.name)>=0)return!1;let t=!0;return n.eachChild(r=>{t&&!No(r,e)&&(t=!1)}),t}function gy(n,e,t){return[n,e,t].filter(Boolean).join("")}function Qp(n,e){switch(n){case"string":return jt(e);case"number":return+e;case"boolean":return!!e;case"color":return Ii.parse(e);case"formatted":return Lr.fromString(jt(e));case"resolvedImage":return is.build(jt(e))}return e}function yy(n,e,t,r){return r!==void 0&&(n=r*Math.round(n/r)),e!==void 0&&n<e&&(n=e),t!==void 0&&n>t&&(n=t),n}class Pc{constructor(e,t,r,c=!1){this.type=e,this.key=t,this.scope=r,this.featureConstant=c}static parse(e,t){let r=t.expectedType;if(r==null&&(r=Oi),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const c=t.parse(e[1],1);if(!(c instanceof At))return t.error("Key name of 'config' expression must be a string literal.");let h,f=!0;const _=jt(c.value);if(e.length>=3){const g=t.parse(e[2],2);if(!(g instanceof At))return t.error("Scope of 'config' expression must be a string literal.");h=jt(g.value)}if(t.options){const g=gy(_,h,t._scope),b=t.options.get(g);b&&(f=Al(b.value||b.default))}return new Pc(r,_,h,f)}evaluate(e){const t=gy(this.key,this.scope,e.scope),r=e.getConfig(t);if(!r)return null;const{type:c,value:h,values:f,minValue:_,maxValue:g,stepValue:b}=r,S=r.default.evaluate(e);let I=S;if(h){const A=e.scope;e.scope=(A||"").split("").slice(1).join(""),I=h.evaluate(e),e.scope=A}return c&&(I=Qp(c,I)),I===void 0||_===void 0&&g===void 0&&b===void 0||(typeof I=="number"?I=yy(I,_,g,b):Array.isArray(I)&&(I=I.map(A=>typeof A=="number"?yy(A,_,g,b):A))),h!==void 0&&I!==void 0&&f&&!f.includes(I)&&(I=S,c&&(I=Qp(c,I))),(c&&c!==this.type||I!==void 0&&!ca(Pn(I),this.type))&&(I=Qp(this.type.kind,I)),I}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class Td{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(e.length!==2||typeof e[1]!="string")return t.error("'var' expression requires exactly one string literal argument.");const r=e[1];return t.scope.has(r)?new Td(r,t.scope.get(r)):t.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class Sd{constructor(e,t=[],r,c=new vl,h=[],f,_,g){this.registry=e,this.path=t,this.key=t.map(b=>typeof b=="string"?`['${b}']`:`[${b}]`).join(""),this.scope=c,this.errors=h,this.expectedType=r,this._scope=f,this.options=_,this.iconImageUseTheme=g}parse(e,t,r,c,h={}){return t||r?this.concat(t,null,r,c)._parse(e,h):this._parse(e,h)}parseObjectValue(e,t,r,c,h,f={}){return this.concat(t,r,c,h)._parse(e,f)}_parse(e,t){function r(c,h,f){return f==="assert"?new Cs(h,[c]):f==="coerce"?new po(h,[c]):c}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const c=typeof e[0]=="string"?this.registry[e[0]]:void 0;if(c){let h=c.parse(e,this);if(!h)return null;if(this.expectedType){const f=this.expectedType,_=h.type;if(f.kind!=="string"&&f.kind!=="number"&&f.kind!=="boolean"&&f.kind!=="object"&&f.kind!=="array"||_.kind!=="value")if(f.kind!=="color"&&f.kind!=="formatted"&&f.kind!=="resolvedImage"||_.kind!=="value"&&_.kind!=="string"){if(this.checkSubtype(f,_))return null}else h=r(h,f,t.typeAnnotation||"coerce");else h=r(h,f,t.typeAnnotation||"assert")}if(!(h instanceof At)&&h.type.kind!=="resolvedImage"&&em(h)){const f=new Vu(this._scope,this.options,this.iconImageUseTheme);try{h=new At(h.type,h.evaluate(f))}catch(_){return this.error(_.message),null}}return h}return po.parse(["to-array",e],this)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,r,c){let h=typeof e=="number"?this.path.concat(e):this.path;h=typeof t=="string"?h.concat(t):h;const f=c?this.scope.concat(c):this.scope;return new Sd(this.registry,h,r||null,f,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(e,...t){const r=`${this.key}${t.map(c=>`[${c}]`).join("")}`;this.errors.push(new Ys(r,e))}checkSubtype(e,t){const r=ku(e,t);return r&&this.error(r),r}}function em(n){if(n instanceof Td)return em(n.boundExpression);if(n instanceof ir&&n.name==="error"||n instanceof gd||n instanceof ja||n instanceof Il||n instanceof Pc)return!1;const e=n instanceof po||n instanceof Cs;let t=!0;return n.eachChild(r=>{t=e?t&&em(r):t&&r instanceof At}),!!t&&Al(n)&&No(n,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"])}function Ed(n,e){const t=n.length-1;let r,c,h=0,f=t,_=0;for(;h<=f;)if(_=Math.floor((h+f)/2),r=n[_],c=n[_+1],r<=e){if(_===t||e<c)return _;h=_+1}else{if(!(r>e))throw new Nn("Input is not a number.");f=_-1}return 0}class qu{constructor(e,t,r){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[c,h]of r)this.labels.push(c),this.outputs.push(h)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const r=t.parse(e[1],1,Dt);if(!r)return null;const c=[];let h=null;t.expectedType&&t.expectedType.kind!=="value"&&(h=t.expectedType);for(let f=1;f<e.length;f+=2){const _=f===1?-1/0:e[f],g=e[f+1],b=f,S=f+1;if(typeof _!="number")return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',b);if(c.length&&c[c.length-1][0]>=_)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',b);const I=t.parse(g,S,h);if(!I)return null;h=h||I.type,c.push([_,I])}return new qu(h,r,c)}evaluate(e){const t=this.labels,r=this.outputs;if(t.length===1)return r[0].evaluate(e);const c=this.input.evaluate(e);if(c<=t[0])return r[0].evaluate(e);const h=t.length;return c>=t[h-1]?r[h-1].evaluate(e):r[Ed(t,c)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const xy=.95047,vy=1.08883,by=4/29,Mc=6/29,wy=3*Mc*Mc,w1=Mc*Mc*Mc,T1=Math.PI/180,S1=180/Math.PI;function tm(n){return n>w1?Math.pow(n,1/3):n/wy+by}function im(n){return n>Mc?n*n*n:wy*(n-by)}function Wu(n){return 255*(n<=.0031308?12.92*n:1.055*Math.pow(n,1/2.4)-.055)}function Rc(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function nm(n){const e=Rc(n.r),t=Rc(n.g),r=Rc(n.b),c=tm((.4124564*e+.3575761*t+.1804375*r)/xy),h=tm((.2126729*e+.7151522*t+.072175*r)/1);return{l:116*h-16,a:500*(c-h),b:200*(h-tm((.0193339*e+.119192*t+.9503041*r)/vy)),alpha:n.a}}function Ty(n){let e=(n.l+16)/116,t=isNaN(n.a)?e:e+n.a/500,r=isNaN(n.b)?e:e-n.b/200;return e=1*im(e),t=xy*im(t),r=vy*im(r),new Ii(Wu(3.2404542*t-1.5371385*e-.4985314*r),Wu(-.969266*t+1.8760108*e+.041556*r),Wu(.0556434*t-.2040259*e+1.0572252*r),n.alpha)}function E1(n,e,t){const r=e-n;return n+t*(r>180||r<-180?r-360*Math.round(r/360):r)}const Xu={forward:nm,reverse:Ty,interpolate:function(n,e,t){return{l:Gt(n.l,e.l,t),a:Gt(n.a,e.a,t),b:Gt(n.b,e.b,t),alpha:Gt(n.alpha,e.alpha,t)}}},Dc={forward:function(n){const{l:e,a:t,b:r}=nm(n),c=Math.atan2(r,t)*S1;return{h:c<0?c+360:c,c:Math.sqrt(t*t+r*r),l:e,alpha:n.a}},reverse:function(n){const e=n.h*T1,t=n.c;return Ty({l:n.l,a:Math.cos(e)*t,b:Math.sin(e)*t,alpha:n.alpha})},interpolate:function(n,e,t){return{h:E1(n.h,e.h,t),c:Gt(n.c,e.c,t),l:Gt(n.l,e.l,t),alpha:Gt(n.alpha,e.alpha,t)}}};var rm=Object.freeze({__proto__:null,hcl:Dc,lab:Xu});class zr{constructor(e,t,r,c,h){this.type=e,this.operator=t,this.interpolation=r,this.input=c,this.labels=[],this.outputs=[];for(const[f,_]of h)this.labels.push(f),this.outputs.push(_)}static interpolationFactor(e,t,r,c){let h=0;if(e.name==="exponential")h=Id(t,e.base,r,c);else if(e.name==="linear")h=Id(t,1,r,c);else if(e.name==="cubic-bezier"){const f=e.controlPoints;h=new Au(f[0],f[1],f[2],f[3]).solve(Id(t,1,r,c))}return h}static parse(e,t){let[r,c,h,...f]=e;if(!Array.isArray(c)||c.length===0)return t.error("Expected an interpolation type expression.",1);if(c[0]==="linear")c={name:"linear"};else if(c[0]==="exponential"){const b=c[1];if(typeof b!="number")return t.error("Exponential interpolation requires a numeric base.",1,1);c={name:"exponential",base:b}}else{if(c[0]!=="cubic-bezier")return t.error(`Unknown interpolation type ${String(c[0])}`,1,0);{const b=c.slice(1);if(b.length!==4||b.some(S=>typeof S!="number"||S<0||S>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);c={name:"cubic-bezier",controlPoints:b}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(h=t.parse(h,2,Dt),!h)return null;const _=[];let g=null;r==="interpolate-hcl"||r==="interpolate-lab"?g=Wr:t.expectedType&&t.expectedType.kind!=="value"&&(g=t.expectedType);for(let b=0;b<f.length;b+=2){const S=f[b],I=f[b+1],A=b+3,M=b+4;if(typeof S!="number")return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',A);if(_.length&&_[_.length-1][0]>=S)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',A);const D=t.parse(I,M,g);if(!D)return null;g=g||D.type,_.push([S,D])}return g.kind==="number"||g.kind==="color"||g.kind==="array"&&g.itemType.kind==="number"&&typeof g.N=="number"?new zr(g,r,c,h,_):t.error(`Type ${Gn(g)} is not interpolatable.`)}evaluate(e){const t=this.labels,r=this.outputs;if(t.length===1)return r[0].evaluate(e);const c=this.input.evaluate(e);if(c<=t[0])return r[0].evaluate(e);const h=t.length;if(c>=t[h-1])return r[h-1].evaluate(e);const f=Ed(t,c),_=zr.interpolationFactor(this.interpolation,c,t[f],t[f+1]),g=r[f].evaluate(e),b=r[f+1].evaluate(e);return this.operator==="interpolate"?pd[this.type.kind.toLowerCase()](g,b,_):this.operator==="interpolate-hcl"?Dc.reverse(Dc.interpolate(Dc.forward(g),Dc.forward(b),_)):Xu.reverse(Xu.interpolate(Xu.forward(g),Xu.forward(b),_))}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=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const t=[this.operator,e,this.input.serialize()];for(let r=0;r<this.labels.length;r++)t.push(this.labels[r],this.outputs[r].serialize());return t}}function Id(n,e,t,r){const c=r-t,h=n-t;return c===0?0:e===1?h/c:(Math.pow(e,h)-1)/(Math.pow(e,c)-1)}class Yu{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument."),null;let r=null;const c=t.expectedType;c&&c.kind!=="value"&&(r=c);const h=[];for(const _ of e.slice(1)){const g=t.parse(_,1+h.length,r,void 0,{typeAnnotation:"omit"});if(!g)return null;r=r||g.type,h.push(g)}const f=c&&h.some(_=>ku(c,_.type));return new Yu(f?Oi:r,h)}evaluate(e){let t,r=null,c=0;for(const h of this.args){if(c++,r=h.evaluate(e),r&&r instanceof is&&!r.available&&(t||(t=r),r=null,c===this.args.length))return t;if(r!==null)break}return r}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize())}),e}}class Ad{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let h=1;h<e.length-1;h+=2){const f=e[h];if(typeof f!="string")return t.error(`Expected string, but found ${typeof f} instead.`,h);if(/[^a-zA-Z0-9_]/.test(f))return t.error("Variable names must contain only alphanumeric characters or '_'.",h);const _=t.parse(e[h+1],h+1);if(!_)return null;r.push([f,_])}const c=t.parse(e[e.length-1],e.length-1,t.expectedType,r);return c?new Ad(r,c):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,r]of this.bindings)e.push(t,r.serialize());return e.push(this.result.serialize()),e}}class Ku{constructor(e,t,r){this.type=e,this.index=t,this.input=r}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,Dt),c=t.parse(e[2],2,Vr(t.expectedType||Oi));return r&&c?new Ku(c.type.itemType,r,c):null}evaluate(e){const t=this.index.evaluate(e),r=this.input.evaluate(e);if(t<0)throw new Nn("Array index out of bounds: negative index");if(t>=r.length)throw new Nn("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new Nn("Array index must be an integer. Use at-interpolated for fractional indices");return r[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Ju{constructor(e,t,r){this.type=e,this.index=t,this.input=r}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,Dt),c=t.parse(e[2],2,Vr(t.expectedType||Oi));return r&&c?new Ju(c.type.itemType,r,c):null}evaluate(e){const t=this.index.evaluate(e),r=this.input.evaluate(e);if(t<0)throw new Nn(`Array index out of bounds: ${t} < 0.`);if(t>r.length-1)throw new Nn(`Array index out of bounds: ${t} > ${r.length-1}.`);if(t===Math.floor(t))return r[t];const c=Math.floor(t),h=Math.ceil(t),f=r[c],_=r[h];if(typeof f!="number"||typeof _!="number")throw new Nn(`Cannot interpolate between non-number values at index ${t}.`);const g=t-c;return f*(1-g)+_*g}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class Qu{constructor(e,t){this.type=Fi,this.needle=e,this.haystack=t}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Oi),c=t.parse(e[2],2,Oi);return r&&c?Np(r.type,[Fi,ki,Dt,la,Oi])?new Qu(r,c):(t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Gn(r.type)} instead`),null):null}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(r==null)return!1;if(!bc(t,["boolean","string","number","null"]))throw new Nn(`Expected first argument to be of type boolean, string, number or null, but found ${Gn(Pn(t))} instead.`);if(!bc(r,["string","array"]))throw new Nn(`Expected second argument to be of type array or string, but found ${Gn(Pn(r))} instead.`);return r.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class Cd{constructor(e,t,r){this.type=Dt,this.needle=e,this.haystack=t,this.fromIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Oi),c=t.parse(e[2],2,Oi);if(!r||!c)return null;if(!Np(r.type,[Fi,ki,Dt,la,Oi]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Gn(r.type)} instead`),null;if(e.length===4){const h=t.parse(e[3],3,Dt);return h?new Cd(r,c,h):null}return new Cd(r,c)}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!bc(t,["boolean","string","number","null"]))throw new Nn(`Expected first argument to be of type boolean, string, number or null, but found ${Gn(Pn(t))} instead.`);if(!bc(r,["string","array"]))throw new Nn(`Expected second argument to be of type array or string, but found ${Gn(Pn(r))} instead.`);if(this.fromIndex){const c=this.fromIndex.evaluate(e);return r.indexOf(t,c)}return r.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class sm{constructor(e,t,r,c,h,f){this.inputType=e,this.type=t,this.input=r,this.cases=c,this.outputs=h,this.otherwise=f}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let r,c;t.expectedType&&t.expectedType.kind!=="value"&&(c=t.expectedType);const h={},f=[];for(let b=2;b<e.length-1;b+=2){let S=e[b];const I=e[b+1];Array.isArray(S)||(S=[S]);const A=t.concat(b);if(S.length===0)return A.error("Expected at least one branch label.");for(const D of S){if(typeof D!="number"&&typeof D!="string")return A.error("Branch labels must be numbers or strings.");if(typeof D=="number"&&Math.abs(D)>Number.MAX_SAFE_INTEGER)return A.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof D=="number"&&Math.floor(D)!==D)return A.error("Numeric branch labels must be integer values.");if(r){if(A.checkSubtype(r,Pn(D)))return null}else r=Pn(D);if(h[String(D)]!==void 0)return A.error("Branch labels must be unique.");h[String(D)]=f.length}const M=t.parse(I,b,c);if(!M)return null;c=c||M.type,f.push(M)}const _=t.parse(e[1],1,Oi);if(!_)return null;const g=t.parse(e[e.length-1],e.length-1,c);return g?_.type.kind!=="value"&&t.concat(1).checkSubtype(r,_.type)?null:new sm(r,c,_,h,f,g):null}evaluate(e){const t=this.input.evaluate(e);return(ca(Pn(t),this.inputType)&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),r=[],c={};for(const f of t){const _=c[this.cases[f]];_===void 0?(c[this.cases[f]]=r.length,r.push([this.cases[f],[f]])):r[_][1].push(f)}const h=f=>this.inputType.kind==="number"?Number(f):f;for(const[f,_]of r)e.push(_.length===1?h(_[0]):_.map(h)),e.push(this.outputs[f].serialize());return e.push(this.otherwise.serialize()),e}}class Pd{constructor(e,t,r){this.type=e,this.branches=t,this.otherwise=r}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`),null;if(e.length%2!=0)return t.error("Expected an odd number of arguments."),null;let r;t.expectedType&&t.expectedType.kind!=="value"&&(r=t.expectedType);const c=[];for(let f=1;f<e.length-1;f+=2){const _=t.parse(e[f],f,Fi);if(!_)return null;const g=t.parse(e[f+1],f+1,r);if(!g)return null;c.push([_,g]),r=r||g.type}const h=t.parse(e[e.length-1],e.length-1,r);return h?new Pd(r,c,h):null}evaluate(e){for(const[t,r]of this.branches)if(t.evaluate(e))return r.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,r]of this.branches)e(t),e(r);e(this.otherwise)}outputDefined(){return this.branches.every(([e,t])=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}class eh{constructor(e,t,r,c){this.type=e,this.input=t,this.beginIndex=r,this.endIndex=c}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1,Oi),c=t.parse(e[2],2,Dt);if(!r||!c)return null;if(!Np(r.type,[Vr(Oi),ki,Oi]))return t.error(`Expected first argument to be of type array or string, but found ${Gn(r.type)} instead`),null;if(e.length===4){const h=t.parse(e[3],3,Dt);return h?new eh(r.type,r,c,h):null}return new eh(r.type,r,c)}evaluate(e){const t=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(!bc(t,["string","array"]))throw new Nn(`Expected first argument to be of type array or string, but found ${Gn(Pn(t))} instead.`);if(this.endIndex){const c=this.endIndex.evaluate(e);return t.slice(r,c)}return t.slice(r)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}class om{constructor(e,t){this.type=Vr(ki),this.str=e,this.delimiter=t}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,ki),c=t.parse(e[2],2,ki);return r&&c?new om(r,c):void 0}evaluate(e){const t=this.str.evaluate(e),r=this.delimiter.evaluate(e);return t.split(r)}eachChild(e){e(this.str),e(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function Sy(n,e){return n==="=="||n==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Ey(n,e,t,r){return r.compare(e,t)===0}function Cl(n,e,t){const r=n!=="=="&&n!=="!=";return class gF{constructor(h,f,_){this.type=Fi,this.lhs=h,this.rhs=f,this.collator=_,this.hasUntypedArgument=h.type.kind==="value"||f.type.kind==="value"}static parse(h,f){if(h.length!==3&&h.length!==4)return f.error("Expected two or three arguments.");const _=h[0];let g=f.parse(h[1],1,Oi);if(!g)return null;if(!Sy(_,g.type))return f.concat(1).error(`"${_}" comparisons are not supported for type '${Gn(g.type)}'.`);let b=f.parse(h[2],2,Oi);if(!b)return null;if(!Sy(_,b.type))return f.concat(2).error(`"${_}" comparisons are not supported for type '${Gn(b.type)}'.`);if(g.type.kind!==b.type.kind&&g.type.kind!=="value"&&b.type.kind!=="value")return f.error(`Cannot compare types '${Gn(g.type)}' and '${Gn(b.type)}'.`);r&&(g.type.kind==="value"&&b.type.kind!=="value"?g=new Cs(b.type,[g]):g.type.kind!=="value"&&b.type.kind==="value"&&(b=new Cs(g.type,[b])));let S=null;if(h.length===4){if(g.type.kind!=="string"&&b.type.kind!=="string"&&g.type.kind!=="value"&&b.type.kind!=="value")return f.error("Cannot use collator to compare non-string types.");if(S=f.parse(h[3],3,bl),!S)return null}return new gF(g,b,S)}evaluate(h){const f=this.lhs.evaluate(h),_=this.rhs.evaluate(h);if(r&&this.hasUntypedArgument){const g=Pn(f),b=Pn(_);if(g.kind!==b.kind||g.kind!=="string"&&g.kind!=="number")throw new Nn(`Expected arguments for "${n}" to be (string, string) or (number, number), but found (${g.kind}, ${b.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const g=Pn(f),b=Pn(_);if(g.kind!=="string"||b.kind!=="string")return e(h,f,_)}return this.collator?t(h,f,_,this.collator.evaluate(h)):e(h,f,_)}eachChild(h){h(this.lhs),h(this.rhs),this.collator&&h(this.collator)}outputDefined(){return!0}serialize(){const h=[n];return this.eachChild(f=>{h.push(f.serialize())}),h}}}const Iy=Cl("==",function(n,e,t){return e===t},Ey),Md=Cl("!=",function(n,e,t){return e!==t},function(n,e,t,r){return!Ey(0,e,t,r)}),I1=Cl("<",function(n,e,t){return e<t},function(n,e,t,r){return r.compare(e,t)<0}),Ay=Cl(">",function(n,e,t){return e>t},function(n,e,t,r){return r.compare(e,t)>0}),A1=Cl("<=",function(n,e,t){return e<=t},function(n,e,t,r){return r.compare(e,t)<=0}),C1=Cl(">=",function(n,e,t){return e>=t},function(n,e,t,r){return r.compare(e,t)>=0});class Rd{constructor(e,t,r,c,h,f){this.type=ki,this.number=e,this.locale=t,this.currency=r,this.unit=c,this.minFractionDigits=h,this.maxFractionDigits=f}static parse(e,t){if(e.length!==3)return t.error("Expected two arguments.");const r=t.parse(e[1],1,Dt);if(!r)return null;const c=e[2];if(typeof c!="object"||Array.isArray(c))return t.error("NumberFormat options argument must be an object.");let h=null;if(c.locale&&(h=t.parseObjectValue(c.locale,2,"locale",ki),!h))return null;let f=null;if(c.currency&&(f=t.parseObjectValue(c.currency,2,"currency",ki),!f))return null;let _=null;if(c.unit&&(_=t.parseObjectValue(c.unit,2,"unit",ki),!_))return null;let g=null;if(c["min-fraction-digits"]&&(g=t.parseObjectValue(c["min-fraction-digits"],2,"min-fraction-digits",Dt),!g))return null;let b=null;return c["max-fraction-digits"]&&(b=t.parseObjectValue(c["max-fraction-digits"],2,"max-fraction-digits",Dt),!b)?null:new Rd(r,h,f,_,g,b)}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 Dd{constructor(e){this.type=Dt,this.input=e}static parse(e,t){if(e.length!==2)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`),null;const r=t.parse(e[1],1);return r?r.type.kind!=="array"&&r.type.kind!=="string"&&r.type.kind!=="value"?(t.error(`Expected argument of type string or array, but found ${Gn(r.type)} instead.`),null):new Dd(r):null}evaluate(e){const t=this.input.evaluate(e);if(typeof t=="string"||Array.isArray(t))return t.length;throw new Nn(`Expected value to be of type string or array, but found ${Gn(Pn(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}function Cy(n){return function(){n=1831565813+(n|=0)|0;let e=Math.imul(n^n>>>15,1|n);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Lc={"==":Iy,"!=":Md,">":Ay,"<":I1,">=":C1,"<=":A1,array:Cs,at:Ku,"at-interpolated":Ju,boolean:Cs,case:Pd,coalesce:Yu,collator:gd,format:wl,image:Nt,in:Qu,"index-of":Cd,interpolate:zr,"interpolate-hcl":zr,"interpolate-lab":zr,length:Dd,let:Ad,literal:At,match:sm,number:Cs,"number-format":Rd,object:Cs,slice:eh,step:qu,string:Cs,"to-boolean":po,"to-color":po,"to-number":po,"to-string":po,var:Td,within:ja,distance:Il,config:Pc,split:om};function Py(n,[e,t,r,c]){e=e.evaluate(n),t=t.evaluate(n),r=r.evaluate(n);const h=c?c.evaluate(n):1,f=ry(e,t,r,h);if(f)throw new Nn(f);return new Ii(e/255,t/255,r/255,h)}function My(n,[e,t,r,c]){e=e.evaluate(n),t=t.evaluate(n),r=r.evaluate(n);const h=c?c.evaluate(n):1,f=function(b,S,I,A){return typeof b=="number"&&b>=0&&b<=360?typeof S=="number"&&S>=0&&S<=100&&typeof I=="number"&&I>=0&&I<=100?A===void 0||typeof A=="number"&&A>=0&&A<=1?null:`Invalid hsla value [${[b,S,I,A].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof A=="number"?[b,S,I,A]:[b,S,I]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof A=="number"?[b,S,I,A]:[b,S,I]).join(", ")}]: 'h' must be between 0 and 360.`}(e,t,r,h);if(f)throw new Nn(f);const _=`hsla(${e}, ${t}%, ${r}%, ${h})`,g=Ii.parse(_);if(!g)throw new Nn(`Failed to parse HSLA color: ${_}`);return g}function th(n,e){return n in e}function Ld(n,e){const t=e[n];return t===void 0?null:t}function $a(n){return{type:n}}function zd(n){if(n instanceof Pc)return new Set([n.key]);let e=new Set;return n.eachChild(t=>{e=new Set([...e,...zd(t)])}),e}function kd(n){if(n instanceof ir&&n.name==="is-active-floor")return!0;let e=!1;return n.eachChild(t=>{!e&&kd(t)&&(e=!0)}),e}function Ry(n){return{result:"success",value:n}}function Ha(n){return{result:"error",value:n}}function ih(n,e){return!!n&&!!n.parameters&&n.parameters.indexOf(e)>-1}function Fd(n){return n["property-type"]==="data-driven"}function Dy(n){return ih(n.expression,"measure-light")}function am(n){return ih(n.expression,"zoom")}function Od(n){return!!n.expression&&n.expression.interpolated}function lm(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Ly(n){return n}function zy(n,e){const t=e.type==="color",r=n.stops&&typeof n.stops[0][0]=="object",c=r||!(r||n.property!==void 0),h=n.type||(Od(e)?"exponential":"interval");if(t&&((n=Object.assign({},n)).stops&&(n.stops=n.stops.map(b=>[b[0],Ii.parse(b[1])])),n.default=Ii.parse(n.default?n.default:e.default)),n.colorSpace&&n.colorSpace!=="rgb"&&!rm[n.colorSpace])throw new Error(`Unknown color space: ${n.colorSpace}`);let f,_,g;if(h==="exponential")f=ky;else if(h==="interval")f=M1;else if(h==="categorical"){f=P1,_=Object.create(null);for(const b of n.stops)_[b[0]]=b[1];g=typeof n.stops[0][0]}else{if(h!=="identity")throw new Error(`Unknown function type "${h}"`);f=Fy}if(r){const b={},S=[];for(let M=0;M<n.stops.length;M++){const D=n.stops[M],z=D[0].zoom;b[z]===void 0&&(b[z]={zoom:z,type:n.type,property:n.property,default:n.default,stops:[]},S.push(z)),b[z].stops.push([D[0].value,D[1]])}const I=[];for(const M of S)I.push([b[M].zoom,zy(b[M],e)]);const A={name:"linear"};return{kind:"composite",interpolationType:A,interpolationFactor:zr.interpolationFactor.bind(void 0,A),zoomStops:I.map(M=>M[0]),evaluate:({zoom:M},D)=>ky({stops:I,base:n.base},e,M).evaluate(M,D)}}if(c){const b=h==="exponential"?{name:"exponential",base:n.base!==void 0?n.base:1}:null;return{kind:"camera",interpolationType:b,interpolationFactor:zr.interpolationFactor.bind(void 0,b),zoomStops:n.stops.map(S=>S[0]),evaluate:({zoom:S})=>f(n,e,S,_,g)}}return{kind:"source",evaluate(b,S){const I=S&&S.properties?S.properties[n.property]:void 0;return I===void 0?Vo(n.default,e.default):f(n,e,I,_,g)}}}function Vo(n,e,t){return n!==void 0?n:e!==void 0?e:t!==void 0?t:void 0}function P1(n,e,t,r,c){return Vo(typeof t===c?r[t]:void 0,n.default,e.default)}function M1(n,e,t){if(!Bu(t))return Vo(n.default,e.default);const r=n.stops.length;if(r===1||t<=n.stops[0][0])return n.stops[0][1];if(t>=n.stops[r-1][0])return n.stops[r-1][1];const c=Ed(n.stops.map(h=>h[0]),t);return n.stops[c][1]}function ky(n,e,t){const r=n.base!==void 0?n.base:1;if(!Bu(t))return Vo(n.default,e.default);const c=n.stops.length;if(c===1||t<=n.stops[0][0])return n.stops[0][1];if(t>=n.stops[c-1][0])return n.stops[c-1][1];const h=Ed(n.stops.map(S=>S[0]),t),f=function(S,I,A,M){const D=M-A,z=S-A;return D===0?0:I===1?z/D:(Math.pow(I,z)-1)/(Math.pow(I,D)-1)}(t,r,n.stops[h][0],n.stops[h+1][0]),_=n.stops[h][1],g=n.stops[h+1][1];let b=pd[e.type]||Ly;if(n.colorSpace&&n.colorSpace!=="rgb"){const S=rm[n.colorSpace];b=(I,A)=>S.reverse(S.interpolate(S.forward(I),S.forward(A),f))}return typeof _.evaluate=="function"?{evaluate(...S){const I=_.evaluate.apply(void 0,S),A=g.evaluate.apply(void 0,S);if(I!==void 0&&A!==void 0)return b(I,A,f)}}:b(_,g,f)}function Fy(n,e,t){return e.type==="color"?t=Ii.parse(t):e.type==="formatted"?t=Lr.fromString(t.toString()):e.type==="resolvedImage"?t=is.build(t.toString()):Ou(t)===e.type||e.type==="enum"&&e.values[t]||(t=void 0),Vo(t,n.default,e.default)}ir.register(Lc,{error:[{kind:"error"},[ki],(n,[e])=>{throw new Nn(e.evaluate(n))}],typeof:[ki,[Oi],(n,[e])=>Gn(Pn(e.evaluate(n)))],"to-rgba":[Vr(Dt,4),[Wr],(n,[e])=>e.evaluate(n).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Vr(Dt,4),[Wr],(n,[e])=>e.evaluate(n).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[Wr,[Dt,Dt,Dt],Py],rgba:[Wr,[Dt,Dt,Dt,Dt],Py],hsl:[Wr,[Dt,Dt,Dt],My],hsla:[Wr,[Dt,Dt,Dt,Dt],My],has:{type:Fi,overloads:[[[ki],(n,[e])=>th(e.evaluate(n),n.properties())],[[ki,Na],(n,[e,t])=>th(e.evaluate(n),t.evaluate(n))]]},get:{type:Oi,overloads:[[[ki],(n,[e])=>Ld(e.evaluate(n),n.properties())],[[ki,Na],(n,[e,t])=>Ld(e.evaluate(n),t.evaluate(n))]]},"feature-state":[Oi,[ki],(n,[e])=>Ld(e.evaluate(n),n.featureState||{})],properties:[Na,[],n=>n.properties()],"geometry-type":[ki,[],n=>n.geometryType()],worldview:[ki,[],n=>n.globals.worldview||""],"is-active-floor":[Fi,$a(ki),(n,e)=>{if(!(n.globals&&n.globals.activeFloors&&n.globals.activeFloors.size>0))return!1;if(e.length===0)return!0;const t=n.globals.activeFloors;return e.some(r=>{const c=r.evaluate(n);return t.has(c)})}],id:[Oi,[],n=>n.id()],zoom:[Dt,[],n=>n.globals.zoom],pitch:[Dt,[],n=>n.globals.pitch||0],"distance-from-center":[Dt,[],n=>n.distanceFromCenter()],"measure-light":[Dt,[ki],(n,[e])=>n.measureLight(e.evaluate(n))],"heatmap-density":[Dt,[],n=>n.globals.heatmapDensity||0],"line-progress":[Dt,[],n=>n.globals.lineProgress||0],"raster-value":[Dt,[],n=>n.globals.rasterValue||0],"raster-particle-speed":[Dt,[],n=>n.globals.rasterParticleSpeed||0],"sky-radial-progress":[Dt,[],n=>n.globals.skyRadialProgress||0],accumulated:[Oi,[],n=>n.globals.accumulated===void 0?null:n.globals.accumulated],"+":[Dt,$a(Dt),(n,e)=>{let t=0;for(const r of e)t+=r.evaluate(n);return t}],"*":[Dt,$a(Dt),(n,e)=>{let t=1;for(const r of e)t*=r.evaluate(n);return t}],"-":{type:Dt,overloads:[[[Dt,Dt],(n,[e,t])=>e.evaluate(n)-t.evaluate(n)],[[Dt],(n,[e])=>-e.evaluate(n)]]},"/":[Dt,[Dt,Dt],(n,[e,t])=>e.evaluate(n)/t.evaluate(n)],"%":[Dt,[Dt,Dt],(n,[e,t])=>e.evaluate(n)%t.evaluate(n)],ln2:[Dt,[],()=>Math.LN2],pi:[Dt,[],()=>Math.PI],e:[Dt,[],()=>Math.E],"^":[Dt,[Dt,Dt],(n,[e,t])=>Math.pow(e.evaluate(n),t.evaluate(n))],sqrt:[Dt,[Dt],(n,[e])=>Math.sqrt(e.evaluate(n))],log10:[Dt,[Dt],(n,[e])=>Math.log(e.evaluate(n))/Math.LN10],ln:[Dt,[Dt],(n,[e])=>Math.log(e.evaluate(n))],log2:[Dt,[Dt],(n,[e])=>Math.log2(e.evaluate(n))],sin:[Dt,[Dt],(n,[e])=>Math.sin(e.evaluate(n))],cos:[Dt,[Dt],(n,[e])=>Math.cos(e.evaluate(n))],tan:[Dt,[Dt],(n,[e])=>Math.tan(e.evaluate(n))],asin:[Dt,[Dt],(n,[e])=>Math.asin(e.evaluate(n))],acos:[Dt,[Dt],(n,[e])=>Math.acos(e.evaluate(n))],atan:[Dt,[Dt],(n,[e])=>Math.atan(e.evaluate(n))],min:[Dt,$a(Dt),(n,e)=>Math.min(...e.map(t=>t.evaluate(n)))],max:[Dt,$a(Dt),(n,e)=>Math.max(...e.map(t=>t.evaluate(n)))],abs:[Dt,[Dt],(n,[e])=>Math.abs(e.evaluate(n))],round:[Dt,[Dt],(n,[e])=>{const t=e.evaluate(n);return t<0?-Math.round(-t):Math.round(t)}],floor:[Dt,[Dt],(n,[e])=>Math.floor(e.evaluate(n))],ceil:[Dt,[Dt],(n,[e])=>Math.ceil(e.evaluate(n))],"filter-==":[Fi,[ki,Oi],(n,[e,t])=>n.properties()[e.value]===t.value],"filter-id-==":[Fi,[Oi],(n,[e])=>n.id()===e.value],"filter-type-==":[Fi,[ki],(n,[e])=>n.geometryType()===e.value],"filter-<":[Fi,[ki,Oi],(n,[e,t])=>{const r=n.properties()[e.value],c=t.value;return typeof r==typeof c&&r<c}],"filter-id-<":[Fi,[Oi],(n,[e])=>{const t=n.id(),r=e.value;return typeof t==typeof r&&t<r}],"filter->":[Fi,[ki,Oi],(n,[e,t])=>{const r=n.properties()[e.value],c=t.value;return typeof r==typeof c&&r>c}],"filter-id->":[Fi,[Oi],(n,[e])=>{const t=n.id(),r=e.value;return typeof t==typeof r&&t>r}],"filter-<=":[Fi,[ki,Oi],(n,[e,t])=>{const r=n.properties()[e.value],c=t.value;return typeof r==typeof c&&r<=c}],"filter-id-<=":[Fi,[Oi],(n,[e])=>{const t=n.id(),r=e.value;return typeof t==typeof r&&t<=r}],"filter->=":[Fi,[ki,Oi],(n,[e,t])=>{const r=n.properties()[e.value],c=t.value;return typeof r==typeof c&&r>=c}],"filter-id->=":[Fi,[Oi],(n,[e])=>{const t=n.id(),r=e.value;return typeof t==typeof r&&t>=r}],"filter-has":[Fi,[Oi],(n,[e])=>e.value in n.properties()],"filter-has-id":[Fi,[],n=>n.id()!==null&&n.id()!==void 0],"filter-type-in":[Fi,[Vr(ki)],(n,[e])=>e.value.indexOf(n.geometryType())>=0],"filter-id-in":[Fi,[Vr(Oi)],(n,[e])=>e.value.indexOf(n.id())>=0],"filter-in-small":[Fi,[ki,Vr(Oi)],(n,[e,t])=>t.value.indexOf(n.properties()[e.value])>=0],"filter-in-large":[Fi,[ki,Vr(Oi)],(n,[e,t])=>function(r,c,h,f){for(;h<=f;){const _=h+f>>1;if(c[_]===r)return!0;c[_]>r?f=_-1:h=_+1}return!1}(n.properties()[e.value],t.value,0,t.value.length-1)],all:{type:Fi,overloads:[[[Fi,Fi],(n,[e,t])=>e.evaluate(n)&&t.evaluate(n)],[$a(Fi),(n,e)=>{for(const t of e)if(!t.evaluate(n))return!1;return!0}]]},any:{type:Fi,overloads:[[[Fi,Fi],(n,[e,t])=>e.evaluate(n)||t.evaluate(n)],[$a(Fi),(n,e)=>{for(const t of e)if(t.evaluate(n))return!0;return!1}]]},"!":[Fi,[Fi],(n,[e])=>!e.evaluate(n)],"is-supported-script":[Fi,[ki],(n,[e])=>{const t=n.globals&&n.globals.isSupportedScript;return!t||t(e.evaluate(n))}],upcase:[ki,[ki],(n,[e])=>e.evaluate(n).toUpperCase()],downcase:[ki,[ki],(n,[e])=>e.evaluate(n).toLowerCase()],concat:[ki,$a(Oi),(n,e)=>e.map(t=>jt(t.evaluate(n))).join("")],"resolved-locale":[ki,[bl],(n,[e])=>e.evaluate(n).resolvedLocale()],random:[Dt,[Dt,Dt,Oi],(n,e)=>{const[t,r,c]=e.map(f=>f.evaluate(n));if(t>r||t===r)return t;let h;if(typeof c=="string")h=function(f){let _=0;if(f.length===0)return _;for(let g=0;g<f.length;g++)_=(_<<5)-_+f.charCodeAt(g),_&=_;return _}(c);else{if(typeof c!="number")throw new Nn(`Invalid seed input: ${c}`);h=c}return t+Cy(h)()*(r-t)}]});class Bd{constructor(e,t,r,c,h){this.expression=e,this._warningHistory={},this._scope=r,this._options=c,this._iconImageUseTheme=h,this._evaluator=new Vu(r,c,h),this._defaultValue=t?function(f){return f.type==="color"&&(lm(f.default)||Array.isArray(f.default))?new Ii(0,0,0,0):f.type==="color"?Ii.parse(f.default)||null:f.default===void 0?null:f.default}(t):null,this._enumValues=t&&t.type==="enum"?t.values:null,this.configDependencies=zd(e),this.isIndoorDependent=kd(e)}evaluateWithoutErrorHandling(e,t,r,c,h,f,_,g){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=r,this._evaluator.canonical=c||null,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=f,this._evaluator.featureTileCoord=_||null,this._evaluator.featureDistanceData=g||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,r,c,h,f,_,g,b){this._evaluator||(this._evaluator=new Vu(this._scope,this._options,this._iconImageUseTheme)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=r||null,this._evaluator.canonical=c||null,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=f||null,this._evaluator.featureTileCoord=_||null,this._evaluator.featureDistanceData=g||null,this._evaluator.iconImageUseTheme=b||null;try{const S=this.expression.evaluate(this._evaluator);if(S==null||typeof S=="number"&&S!=S)return this._defaultValue;if(this._enumValues&&!(S in this._enumValues))throw new Nn(`Expected value to be one of ${Object.keys(this._enumValues).map(I=>JSON.stringify(I)).join(", ")}, but found ${JSON.stringify(S)} instead.`);return S}catch(S){const I=S;return this._warningHistory[I.message]||(this._warningHistory[I.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${I.message}`)),this._defaultValue}}}function nh(n){return Array.isArray(n)&&n.length>0&&typeof n[0]=="string"&&n[0]in Lc}function Za(n,e,t,r,c){const h=new Sd(Lc,[],e?function(_){const g={color:Wr,string:ki,number:Dt,enum:ki,boolean:Fi,formatted:Lu,resolvedImage:zu};return _.type==="array"?Vr(g[_.value]||Oi,_.length):g[_.type]}(e):void 0,void 0,void 0,t,r,c),f=h.parse(n,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return f?Ry(new Bd(f,e,t,r,c)):Ha(h.errors)}class zc{constructor(e,t,r,c){this.kind=e,this._styleExpression=t,this.isLightConstant=r,this.isLineProgressConstant=c,this.isStateDependent=e!=="constant"&&!Cc(t.expression),this.configDependencies=zd(t.expression),this.isIndoorDependent=kd(t.expression)}evaluateWithoutErrorHandling(e,t,r,c,h,f){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,c,h,f)}evaluate(e,t,r,c,h,f,_){return this._styleExpression.evaluate(e,t,r,c,h,f,void 0,void 0,_)}}class Pl{constructor(e,t,r,c,h,f){this.kind=e,this.zoomStops=r,this._styleExpression=t,this.isStateDependent=e!=="camera"&&!Cc(t.expression),this.isIndoorDependent=kd(t.expression),this.isLightConstant=h,this.isLineProgressConstant=f,this.configDependencies=zd(t.expression),this.interpolationType=c}evaluateWithoutErrorHandling(e,t,r,c,h,f){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,c,h,f)}evaluate(e,t,r,c,h,f){return this._styleExpression.evaluate(e,t,r,c,h,f)}interpolationFactor(e,t,r){return this.interpolationType?zr.interpolationFactor(this.interpolationType,e,t,r):0}}function cm(n,e,t,r,c){if((n=Za(n,e,t,r,c)).result==="error")return n;const h=n.value.expression,f=Al(h);if(!f&&!Fd(e))return Ha([new Ys("","data expressions not supported")]);const _=No(h,["zoom","pitch","distance-from-center"]);if(!_&&!am(e))return Ha([new Ys("","zoom expressions not supported")]);const g=No(h,["measure-light"]);if(!g&&!Dy(e))return Ha([new Ys("","measure-light expression not supported")]);const b=No(h,["line-progress"]);if(!b&&!function(A){return ih(A.expression,"line-progress")}(e))return Ha([new Ys("","line-progress expression not supported")]);const S=e.expression&&e.expression.relaxZoomRestriction,I=go(h);return I||_||S?I instanceof Ys?Ha([I]):I instanceof zr&&!Od(e)?Ha([new Ys("",'"interpolate" expressions cannot be used with this property')]):Ry(I?new Pl(f&&b?"camera":"composite",n.value,I.labels,I instanceof zr?I.interpolation:void 0,g,b):new zc(f&&b?"constant":"source",n.value,g,b)):Ha([new Ys("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Nd{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,zy(this._parameters,this._specification))}static deserialize(e){return new Nd(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function go(n){let e=null;if(n instanceof Ad)e=go(n.result);else if(n instanceof Yu){for(const t of n.args)if(e=go(t),e)break}else(n instanceof qu||n instanceof zr)&&n.input instanceof ir&&n.input.name==="zoom"&&(e=n);return e instanceof Ys||n.eachChild(t=>{const r=go(t);r instanceof Ys?e=r:e&&r&&e!==r&&(e=new Ys("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}var um,Oy,rh=function(){if(Oy)return um;Oy=1,um=e;var n=3;function e(t,r,c){var h=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var f=new Int32Array(this.arrayBuffer);t=f[0],this.d=(r=f[1])+2*(c=f[2]);for(var _=0;_<this.d*this.d;_++){var g=f[n+_],b=f[n+_+1];h.push(g===b?null:f.subarray(g,b))}var S=f[n+h.length+1];this.keys=f.subarray(f[n+h.length],S),this.bboxes=f.subarray(S),this.insert=this._insertReadonly}else{this.d=r+2*c;for(var I=0;I<this.d*this.d;I++)h.push([]);this.keys=[],this.bboxes=[]}this.n=r,this.extent=t,this.padding=c,this.scale=r/t,this.uid=0;var A=c/r*t;this.min=-A,this.max=t+A}return e.prototype.insert=function(t,r,c,h,f){this._forEachCell(r,c,h,f,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(r),this.bboxes.push(c),this.bboxes.push(h),this.bboxes.push(f)},e.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},e.prototype._insertCell=function(t,r,c,h,f,_){this.cells[f].push(_)},e.prototype.query=function(t,r,c,h,f){var _=this.min,g=this.max;if(t<=_&&r<=_&&g<=c&&g<=h&&!f)return Array.prototype.slice.call(this.keys);var b=[];return this._forEachCell(t,r,c,h,this._queryCell,b,{},f),b},e.prototype._queryCell=function(t,r,c,h,f,_,g,b){var S=this.cells[f];if(S!==null)for(var I=this.keys,A=this.bboxes,M=0;M<S.length;M++){var D=S[M];if(g[D]===void 0){var z=4*D;(b?b(A[z+0],A[z+1],A[z+2],A[z+3]):t<=A[z+2]&&r<=A[z+3]&&c>=A[z+0]&&h>=A[z+1])?(g[D]=!0,_.push(I[D])):g[D]=!1}}},e.prototype._forEachCell=function(t,r,c,h,f,_,g,b){for(var S=this._convertToCellCoord(t),I=this._convertToCellCoord(r),A=this._convertToCellCoord(c),M=this._convertToCellCoord(h),D=S;D<=A;D++)for(var z=I;z<=M;z++){var B=this.d*z+D;if((!b||b(this._convertFromCellCoord(D),this._convertFromCellCoord(z),this._convertFromCellCoord(D+1),this._convertFromCellCoord(z+1)))&&f.call(this,t,r,c,h,B,_,g,b))return}},e.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},e.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},e.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,r=n+this.cells.length+1+1,c=0,h=0;h<this.cells.length;h++)c+=this.cells[h].length;var f=new Int32Array(r+c+this.keys.length+this.bboxes.length);f[0]=this.extent,f[1]=this.n,f[2]=this.padding;for(var _=r,g=0;g<t.length;g++){var b=t[g];f[n+g]=_,f.set(b,_),_+=b.length}return f[n+t.length]=_,f.set(this.keys,_),f[n+t.length+1]=_+=this.keys.length,f.set(this.bboxes,_),_+=this.bboxes.length,f.buffer},um}(),kc=Fa(rh);const Ml={};function wt(n,e,t={}){Object.defineProperty(n,"_classRegistryKey",{value:e,writable:!1}),Ml[e]={klass:n,omit:t.omit||[]}}wt(Object,"Object"),kc.serialize=function(n,e){const t=n.toArrayBuffer();return e&&e.add(t),{buffer:t}},kc.deserialize=function(n){return new kc(n.buffer)},Object.defineProperty(kc,"name",{value:"Grid"}),wt(kc,"Grid"),delete it.prototype.constructor,wt(Ii,"Color"),wt(Error,"Error"),wt(Lr,"Formatted"),wt(Fu,"FormattedSection"),wt(Lp,"AJAXError"),wt(is,"ResolvedImage"),wt(Nd,"StylePropertyFunction"),wt(Bd,"StyleExpression",{omit:["_evaluator"]}),wt(fs,"ImageId"),wt(Ks,"ImageVariant"),wt(Pl,"ZoomDependentExpression"),wt(zc,"ZoomConstantExpression"),wt(ir,"CompoundExpression",{omit:["_evaluate"]});for(const n in Lc)Ml[Lc[n]._classRegistryKey]||wt(Lc[n],`Expression${n}`);function sh(n){return n&&(n instanceof ArrayBuffer||n.constructor&&n.constructor.name==="ArrayBuffer")}function ha(n,e){if(n==null||typeof n=="boolean"||typeof n=="number"||typeof n=="string"||n instanceof Boolean||n instanceof Number||n instanceof String||n instanceof Date||n instanceof RegExp)return n;if(sh(n)||n instanceof ImageBitmap)return e&&e.add(n),n;if(ArrayBuffer.isView(n))return e&&e.add(n.buffer),n;if(n instanceof ImageData)return e&&e.add(n.data.buffer),n;if(Array.isArray(n)){const t=[];for(const r of n)t.push(ha(r,e));return t}if(n instanceof Map){const t={$name:"Map",entries:[]};for(const[r,c]of n.entries())t.entries.push(ha(r),ha(c,e));return t}if(n instanceof Set){const t={$name:"Set"};let r=0;for(const c of n.values())t[++r]=ha(c);return t}if(typeof n=="bigint")return{$name:"BigInt",value:n.toString()};if(typeof n=="object"){const t=n.constructor,r=t._classRegistryKey;if(!r)throw new Error(`Can't serialize object of unregistered class "${t.name}".`);const c=t.serialize?t.serialize(n,e):{};if(!t.serialize){for(const h in n)n.hasOwnProperty(h)&&(Ml[r].omit.indexOf(h)>=0||(c[h]=ha(n[h],e)));n instanceof Error&&(c.message=n.message)}if(c.$name)throw new Error("$name property is reserved for worker serialization logic.");return r!=="Object"&&(c.$name=r),c}throw new Error("can't serialize object of type "+typeof n)}function qa(n){if(n==null||typeof n=="boolean"||typeof n=="number"||typeof n=="string"||n instanceof Boolean||n instanceof Number||n instanceof String||n instanceof Date||n instanceof RegExp||sh(n)||n instanceof ImageBitmap||ArrayBuffer.isView(n)||n instanceof ImageData)return n;if(Array.isArray(n))return n.map(qa);if(typeof n=="object"){const e=n.$name||"Object";if(e==="Map"){const c=n.entries||[],h=new Map;for(let f=0;f<c.length;f+=2)h.set(qa(c[f]),qa(c[f+1]));return h}if(e==="Set"){const c=new Set;for(const h of Object.keys(n))h!=="$name"&&c.add(qa(n[h]));return c}if(e==="BigInt")return BigInt(n.value);const{klass:t}=Ml[e];if(!t)throw new Error(`Can't deserialize unregistered class "${e}".`);if(t.deserialize)return t.deserialize(n);const r=Object.create(t.prototype);for(const c of Object.keys(n))c!=="$name"&&(r[c]=qa(n[c]));return r}throw new Error("can't deserialize object of type "+typeof n)}const By=n=>n>=1536&&n<=1791,Vd=n=>n>=1872&&n<=1919,Ud=n=>n>=2208&&n<=2303,jd=n=>n>=11904&&n<=12031,da=n=>n>=12032&&n<=12255,hm=n=>n>=12272&&n<=12287,oh=n=>n>=12288&&n<=12351,ah=n=>n>=12352&&n<=12447,Rl=n=>n>=12448&&n<=12543,dm=n=>n>=12544&&n<=12591,Gd=n=>n>=12704&&n<=12735,Uo=n=>n>=12736&&n<=12783,Ny=n=>n>=12784&&n<=12799,Vy=n=>n>=12800&&n<=13055,Uy=n=>n>=13056&&n<=13311,fm=n=>n>=13312&&n<=19903,$d=n=>n>=19968&&n<=40959,lh=n=>n>=40960&&n<=42127,pm=n=>n>=42128&&n<=42191,mm=n=>n>=44032&&n<=55215,Hd=n=>n>=63744&&n<=64255,_m=n=>n>=64336&&n<=65023,jy=n=>n>=65040&&n<=65055,gm=n=>n>=65072&&n<=65103,Gy=n=>n>=65104&&n<=65135,ym=n=>n>=65136&&n<=65279,xm=n=>n>=65280&&n<=65519;function vm(n){for(const e of n)if(bm(e.charCodeAt(0)))return!0;return!1}function R1(n){for(const e of n)if(!D1(e.charCodeAt(0)))return!1;return!0}function D1(n){return!(By(n)||Vd(n)||Ud(n)||_m(n)||ym(n))}function L1(n){return!(n<11904||!(Gd(n)||dm(n)||gm(n)||Hd(n)||Uy(n)||jd(n)||Uo(n)||oh(n)||fm(n)||$d(n)||Vy(n)||xm(n)||ah(n)||hm(n)||da(n)||Ny(n)||Rl(n)||jy(n)||pm(n)||lh(n)))}function bm(n){return!(n!==746&&n!==747&&(n<4352||!(Gd(n)||dm(n)||gm(n)&&!(n>=65097&&n<=65103)||Hd(n)||Uy(n)||jd(n)||Uo(n)||!(!oh(n)||n>=12296&&n<=12305||n>=12308&&n<=12319||n===12336)||fm(n)||$d(n)||Vy(n)||(e=>e>=12592&&e<=12687)(n)||(e=>e>=43360&&e<=43391)(n)||(e=>e>=55216&&e<=55295)(n)||(e=>e>=4352&&e<=4607)(n)||mm(n)||ah(n)||hm(n)||(e=>e>=12688&&e<=12703)(n)||da(n)||Ny(n)||Rl(n)&&n!==12540||!(!xm(n)||n===65288||n===65289||n===65293||n>=65306&&n<=65310||n===65339||n===65341||n===65343||n>=65371&&n<=65503||n===65507||n>=65512&&n<=65519)||!(!Gy(n)||n>=65112&&n<=65118||n>=65123&&n<=65126)||(e=>e>=5120&&e<=5759)(n)||(e=>e>=6320&&e<=6399)(n)||jy(n)||(e=>e>=19904&&e<=19967)(n)||lh(n)||pm(n))))}function $y(n){return n===12312||n===12313||n===12316||n===12540||n===12448}function Dl(n){return!(bm(n)||function(e){return!!((t=>t>=128&&t<=255)(e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||(t=>t>=8192&&t<=8303)(e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||(t=>t>=8448&&t<=8527)(e)||(t=>t>=8528&&t<=8591)(e)||(t=>t>=8960&&t<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||(t=>t>=9216&&t<=9279)(e)&&e!==9251||(t=>t>=9280&&t<=9311)(e)||(t=>t>=9312&&t<=9471)(e)||(t=>t>=9632&&t<=9727)(e)||(t=>t>=9728&&t<=9983)(e)&&!(e>=9754&&e<=9759)||(t=>t>=11008&&t<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||oh(e)||Rl(e)||(t=>t>=57344&&t<=63743)(e)||gm(e)||Gy(e)||xm(e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(n))}function Hy(n){return By(n)||Vd(n)||Ud(n)||_m(n)||ym(n)}function wm(n){return n>=1424&&n<=2303||_m(n)||ym(n)}function Zd(n,e){return!(!e&&wm(n)||n>=2304&&n<=3583||n>=3840&&n<=4255||(t=>t>=6016&&t<=6143)(n))}function z1(n){for(const e of n)if(wm(e.charCodeAt(0)))return!0;return!1}const ps={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let jo=null,Ur=ps.unavailable,Ms=null;const Zy=function(n){n&&typeof n=="string"&&n.indexOf("NetworkError")>-1&&(Ur=ps.error),jo&&jo(n)};function Tm(){Sm.fire(new ho("pluginStateChange",{pluginStatus:Ur,pluginURL:Ms}))}const Sm=new Du,Em=function(){return Ur},qy=function(){if(Ur!==ps.deferred||!Ms)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Ur=ps.loading,Tm(),Ms&&gc({url:Ms},n=>{n?Zy(n):(Ur=ps.loaded,Tm())})},fa={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Ur===ps.loaded||fa.applyArabicShaping!=null,isLoading:()=>Ur===ps.loading,setState(n){Ur=n.pluginStatus,Ms=n.pluginURL},isParsing:()=>Ur===ps.parsing,isParsed:()=>Ur===ps.parsed,getPluginURL:()=>Ms},Wy=function(){fa.isLoading()||fa.isLoaded()||Em()!=="deferred"||qy()};class Mi{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.worldview=t.worldview,this.activeFloors=t.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(t,r){for(const c of t)if(!Zd(c.charCodeAt(0),r))return!1;return!0}(e,fa.isLoaded())}}class Fc{constructor(e,t,r,c,h){this.property=e,this.value=t,this.expression=function(f,_,g,b,S){if(lm(f))return new Nd(f,_);if(nh(f)||Array.isArray(f)&&f.length>0){const I=cm(f,_,g,b,S);if(I.result==="error")throw new Error(I.value.map(A=>`${A.key}: ${A.message}`).join(", "));return I.value}{let I=f;return typeof f=="string"&&_.type==="color"&&(I=Ii.parse(f)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>I}}}(t===void 0?e.specification.default:t,e.specification,r,c,h)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,t,r,c){return this.property.possiblyEvaluate(this,e,t,r,c)}}class qd{constructor(e,t,r,c){this.property=e,this.value=new Fc(e,void 0,t,r,c)}transitioned(e,t){return new Oc(this.property,this.value,t,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new Oc(this.property,this.value,null,{},0)}}class Wd{constructor(e,t,r,c){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=r,this._iconImageUseTheme=c,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return gt(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new qd(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new Fc(this._values[e].property,t===null?void 0:gt(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].value.isIndoorDependent())}setTransitionOrValue(e,t){t&&(this._options=t);const r=this._properties.properties;if(e)for(const c in e){const h=e[c];if(c.endsWith("-transition")){const f=c.slice(0,-11);r[f]&&this.setTransition(f,h)}else r.hasOwnProperty(c)&&this.setValue(c,h)}}getTransition(e){return gt(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new qd(this._values[e].property)),this._values[e].transition=gt(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);r!==void 0&&(e[t]=r);const c=this.getTransition(t);c!==void 0&&(e[`${t}-transition`]=c)}return e}transitioned(e,t){const r=new Im(this._properties);for(const c of Object.keys(this._values))r._values[c]=this._values[c].transitioned(e,t._values[c]);return r}untransitioned(){const e=new Im(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class Oc{constructor(e,t,r,c,h){const f=c.delay||0,_=c.duration||0;h=h||0,this.property=e,this.value=t,this.begin=h+f,this.end=this.begin+_,e.specification.transition&&(c.delay||c.duration)&&(this.prior=r)}possiblyEvaluate(e,t,r){const c=e.now||0,h=this.value.possiblyEvaluate(e,t,r),f=this.prior;if(f){if(c>this.end)return this.prior=null,h;if(this.value.isDataDriven())return this.prior=null,h;if(c<this.begin)return f.possiblyEvaluate(e,t,r);{const _=(c-this.begin)/(this.end-this.begin);return this.property.interpolate(f.possiblyEvaluate(e,t,r),h,Cu(_))}}return h}}class Im{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,r){const c=new pa(this._properties);for(const h of Object.keys(this._values))c._values[h]=this._values[h].possiblyEvaluate(e,t,r);return c}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Am{constructor(e,t,r,c){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._scope=t,this._options=r,this._iconImageUseTheme=c,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return gt(this._values[e].value)}setValue(e,t){this._values[e]=new Fc(this._values[e].property,t===null?void 0:gt(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].isIndoorDependent())}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);r!==void 0&&(e[t]=r)}return e}possiblyEvaluate(e,t,r,c){const h=new pa(this._properties);for(const f of Object.keys(this._values))h._values[f]=this._values[f].possiblyEvaluate(e,t,r,c);return h}isIndoorDependent(){return this._isIndoorDependent}}class Ll{constructor(e,t,r,c){this.property=e,this.value=t,this.parameters=r,this.iconImageUseTheme=c}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,t,r,c,h){return this.property.evaluate(this.value,this.parameters,e,t,r,c,this.iconImageUseTheme,h)}}class pa{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class dt{constructor(e){this.specification=e}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,r){const c=pd[this.specification.type];return c?c(e,t,r):e}}class at{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,r,c,h){return e.expression.kind==="constant"||e.expression.kind==="camera"?new Ll(this,{kind:"constant",value:e.expression.evaluate(t,null,{},r,c,void 0,h)},t):new Ll(this,e.expression,t,h)}interpolate(e,t,r){if(e.value.kind!=="constant"||t.value.kind!=="constant")return e;if(e.value.value===void 0||t.value.value===void 0)return new Ll(this,{kind:"constant",value:void 0},e.parameters);const c=pd[this.specification.type];return c?new Ll(this,{kind:"constant",value:c(e.value.value,t.value.value,r)},e.parameters):e}evaluate(e,t,r,c,h,f,_,g){return e.kind==="constant"?e.value:e.evaluate(t,r,c,h,f,g,_)}}class Bc{constructor(e){this.specification=e}possiblyEvaluate(e,t,r,c){return!!e.expression.evaluate(t,null,{},r,c)}interpolate(){return!1}}class on{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new Mi(0,{});for(const r in e){const c=e[r],h=c.specification;h&&h.overridable&&this.overridableProperties.push(r);const f=this.defaultPropertyValues[r]=new Fc(c,void 0),_=this.defaultTransitionablePropertyValues[r]=new qd(c);this.defaultTransitioningPropertyValues[r]=_.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=f.possiblyEvaluate(t)}}}wt(at,"DataDrivenProperty"),wt(dt,"DataConstantProperty"),wt(Bc,"ColorRampProperty");var Ee=JSON.parse('{"$version":8,"$root":{"version":{"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"snow":{"type":"snow"},"rain":{"type":"rain"},"camera":{"type":"camera"},"color-theme":{"type":"colorTheme"},"indoor":{"type":"indoor"},"imports":{"type":"array","value":"import"},"iconsets":{"type":"iconsets"},"schema":{"type":"schema"},"sources":{"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"type":"array","value":"layer"},"models":{"type":"models"},"featuresets":{"type":"featuresets"}},"featuresets":{"*":{"type":"featureset"}},"featureset":{"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"layer":{"type":"string"},"properties":{"type":"selectorProperty"},"featureNamespace":{"type":"string"},"_uniqueFeatureID":{"type":"boolean"}},"selectorProperty":{"*":{"type":"*"}},"model":{"type":"string"},"import":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"config"},"data":{"type":"$root"},"color-theme":{"type":"colorTheme","optional":true}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","expression":{}},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string"},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false},"shadow-quality":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"parameters":["zoom"]}},"shadow-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"shadow-draw-before-layer":{"type":"string"}},"properties_light_ambient":{"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"iconsets":{"*":{"type":"iconset"}},"iconset":["iconset_sprite","iconset_source"],"iconset_sprite":{"type":{"type":"enum","values":{"sprite":1}},"url":{"type":"string"}},"iconset_source":{"type":{"type":"enum","values":{"source":1}},"source":{"type":"string"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"extra_bounds":{"type":"array","value":{"type":"array","value":"number","length":4}},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"},"dynamic":{"type":"boolean","default":false}},"source_video":{"type":{"type":"enum","values":{"video":1}},"urls":{"type":"array","value":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"type":"enum","values":{"image":1}},"url":{"type":"string"},"coordinates":{"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"modelNodeOverride":{"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360}},"modelNodeOverrides":{"*":{"type":"modelNodeOverride"}},"modelMaterialOverride":{"model-color":{"type":"color"},"model-color-mix-intensity":{"type":"number"},"model-opacity":{"type":"number"},"model-emissive-strength":{"type":"number"}},"modelMaterialOverrides":{"*":{"type":"modelMaterialOverride"}},"modelSourceModel":{"uri":{"type":"string"},"position":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[-180,-90],"maximum":[180,90]},"orientation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360},"nodeOverrides":{"type":"modelNodeOverrides"},"materialOverrides":{"type":"modelMaterialOverrides"},"nodeOverrideNames":{"type":"array","value":"string"},"materialOverrideNames":{"type":"array","value":"string"},"featureProperties":{"type":"*"}},"modelSourceModels":{"*":{"type":"modelSourceModel"}},"source_model":{"type":{"type":"enum","values":{"model":1,"batched-model":1}},"url":{"type":"string"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"},"models":{"type":"modelSourceModels"}},"layer":{"id":{"type":"string"},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"building":{},"raster":{},"raster-particle":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{},"clip":{}}},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"},"appearances":{"type":"array","value":"appearance","supported-layer-types":["symbol"]}},"appearance":{"condition":{"type":"boolean","expression":{"interpolated":true,"parameters":["zoom","pitch","feature","feature-state","measure-light","distance-from-center"]},"property-type":"data-driven"},"name":{"type":"string"},"properties":{"type":"*"}},"layout":["layout_clip","layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_building","layout_symbol","layout_raster","layout_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"model-allow-density-reduction":{"type":"boolean","default":true}},"layout_clip":{"clip-layer-types":{"type":"array","value":"enum","values":{"model":1,"symbol":1},"default":[],"expression":{}},"clip-layer-scope":{"type":"array","value":"string","default":[],"expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"default":"none","expression":{}},"fill-construct-bridge-guard-rail":{"type":"boolean","default":"true","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"circle-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-markup":1},"default":"none","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"fill-extrusion-edge-radius":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"source-max-zoom":{"type":"number","minimum":0,"maximum":24}},"layout_building":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"building-facade":{"type":"boolean","default":false,"expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-facade-floors":{"type":"number","minimum":1,"maximum":200,"default":3,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-unit-width":{"type":"number","minimum":1,"maximum":20,"default":3.1,"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-facade-window":{"type":"array","length":2,"value":"number","minimum":0.1,"maximum":1,"default":[0.9,0.9],"property-type":"data-driven","expression":{"parameters":["feature"]}},"building-roof-shape":{"type":"enum","values":{"flat":1,"hipped":1,"gabled":1,"parapet":1,"mansard":1,"skillion":1,"pyramidal":1},"default":"flat","expression":{"parameters":["feature"]},"property-type":"data-driven"},"building-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{},"property-type":"data-driven"},"building-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"building-flip-roof-orientation":{"property-type":"data-driven","type":"boolean","default":false,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1,"none":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","default":0,"expression":{"parameters":["zoom","feature","line-progress"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"default":"none","expression":{}},"line-cross-slope":{"type":"number","expression":{}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}},"line-width-unit":{"type":"enum","values":{"pixels":1,"meters":1},"default":"pixels","expression":{"parameters":["zoom"]}},"line-elevation-ground-scale":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","line-progress"]},"transition":true,"property-type":"data-driven"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]}},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]}},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]}},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{"parameters":["zoom"]}},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"icon-size":{"type":"number","default":1,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"appearance":true,"use-theme":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]}},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":[0.1,0.1],"maximum":[10,10],"expression":{}},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]}},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]}},"text-rotate":{"type":"number","default":0,"period":360,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]}},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_raster-particle":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{}}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_hillshade":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster-particle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_clip":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_model":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_building":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":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":"*"}},"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","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","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","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","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","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"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","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_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"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","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"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"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"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"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"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-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"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":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"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","use-theme":true,"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"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"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-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"line-blend-mode":{"type":"enum","values":{"default":1,"multiply":1,"additive":1},"default":"default","expression":{"parameters":["zoom"]}}},"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","use-theme":true,"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"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"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","use-theme":true,"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"]}}},"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"]}},"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"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"appearance":true,"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"appearance":true,"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"]},"appearance":true,"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"]},"appearance":true,"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"appearance":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"sea","expression":{}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"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"]},"use-theme":true,"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"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"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":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}},"model-ignore-line-cutout":{"type":"boolean","default":false,"expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function Xy(n){return n instanceof Number||n instanceof String||n instanceof Boolean?n.valueOf():n}function Xd(n){if(Array.isArray(n))return n.map(Xd);if(n instanceof Object&&!(n instanceof Number||n instanceof String||n instanceof Boolean)){const e={};for(const t in n)e[t]=Xd(n[t]);return e}return Xy(n)}function Cm(n){if(n===!0||n===!1)return!0;if(!Array.isArray(n)||n.length===0)return!1;switch(n[0]){case"has":return n.length>=2&&n[1]!=="$id"&&n[1]!=="$type";case"in":return n.length>=3&&(typeof n[1]!="string"||Array.isArray(n[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return n.length!==3||Array.isArray(n[1])||Array.isArray(n[2]);case"any":case"all":for(const e of n.slice(1))if(!Cm(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function Yd(n,e="",t=null,r="fill"){if(n==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Cm(n)||(n=Kd(n));const c=n;let h=!0;try{h=function(S){if(!Nc(S))return S;let I=Xd(S);return Ky(I),I=Yy(I),I}(c)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
and paste the contents of this message in the report.
Thank you!
Filter Expression:
${JSON.stringify(c,null,2)}
        `)}let f=null,_=null;if(r!=="background"&&r!=="sky"&&r!=="slot"){_=Ee[`filter_${r}`];const S=Za(h,_,e,t);if(S.result==="error")throw new Error(S.value.map(I=>`${I.key}: ${I.message}`).join(", "));f=(I,A,M)=>S.value.evaluate(I,A,{},M)}let g=null,b=null;if(h!==c){const S=Za(c,_,e,t);if(S.result==="error")throw new Error(S.value.map(I=>`${I.key}: ${I.message}`).join(", "));g=(I,A,M,D,z)=>S.value.evaluate(I,A,{},M,void 0,void 0,D,z),b=!Al(S.value.expression)}return{filter:f,dynamicFilter:g||void 0,needGeometry:Qy(h),needFeature:!!b}}function Yy(n){if(!Array.isArray(n))return n;const e=function(t){if(Jy.has(t[0])){for(let r=1;r<t.length;r++)if(Nc(t[r]))return!0}return t}(n);return e===!0?e:e.map(t=>Yy(t))}function Ky(n){let e=!1;const t=[];if(n[0]==="case"){for(let r=1;r<n.length-1;r+=2)e=e||Nc(n[r]),t.push(n[r+1]);t.push(n[n.length-1])}else if(n[0]==="match"){e=e||Nc(n[1]);for(let r=2;r<n.length-1;r+=2)t.push(n[r+1]);t.push(n[n.length-1])}else if(n[0]==="step"){e=e||Nc(n[1]);for(let r=1;r<n.length-1;r+=2)t.push(n[r+1])}e&&(n.length=0,n.push("any",...t));for(let r=1;r<n.length;r++)Ky(n[r])}function Nc(n){if(!Array.isArray(n))return!1;if((e=n[0])==="pitch"||e==="distance-from-center")return!0;var e;for(let t=1;t<n.length;t++)if(Nc(n[t]))return!0;return!1}const Jy=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function k1(n,e){return n<e?-1:n>e?1:0}function Qy(n){if(!Array.isArray(n))return!1;if(n[0]==="within"||n[0]==="distance")return!0;for(let e=1;e<n.length;e++)if(Qy(n[e]))return!0;return!1}function Kd(n){if(!n)return!0;const e=n[0];return n.length<=1?e!=="any":e==="=="?Jd(n[1],n[2],"=="):e==="!="?ch(Jd(n[1],n[2],"==")):e==="<"||e===">"||e==="<="||e===">="?Jd(n[1],n[2],e):e==="any"?(t=n.slice(1),["any"].concat(t.map(Kd))):e==="all"?["all"].concat(n.slice(1).map(Kd)):e==="none"?["all"].concat(n.slice(1).map(Kd).map(ch)):e==="in"?Pm(n[1],n.slice(2)):e==="!in"?ch(Pm(n[1],n.slice(2))):e==="has"?ma(n[1]):e!=="!has"||ch(ma(n[1]));var t}function Jd(n,e,t){switch(n){case"$type":return[`filter-type-${t}`,e];case"$id":return[`filter-id-${t}`,e];default:return[`filter-${t}`,n,e]}}function Pm(n,e){if(e.length===0)return!1;switch(n){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(t=>typeof t!=typeof e[0])?["filter-in-large",n,["literal",e.sort(k1)]]:["filter-in-small",n,["literal",e]]}}function ma(n){switch(n){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",n]}}function ch(n){return["!",n]}const uh="";function zl(n,e){return e?`${n}${uh}${e}`:n}function ex(n){const e=n.indexOf(uh);return e>=0?n.slice(e+1):""}let tx;const Mm=()=>tx||(tx=new on({"icon-size":new at(Ee.layout_symbol["icon-size"]),"icon-image":new at(Ee.layout_symbol["icon-image"]),"icon-rotate":new at(Ee.layout_symbol["icon-rotate"]),"icon-offset":new at(Ee.layout_symbol["icon-offset"]),"text-size":new at(Ee.layout_symbol["text-size"]),"text-rotate":new at(Ee.layout_symbol["text-rotate"]),"text-offset":new at(Ee.layout_symbol["text-offset"])}));let Rm;const Dm=()=>Rm||(Rm=new on({"icon-opacity":new at(Ee.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new at(Ee.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new at(Ee.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new at(Ee.paint_symbol["text-emissive-strength"]),"icon-color":new at(Ee.paint_symbol["icon-color"]),"icon-halo-color":new at(Ee.paint_symbol["icon-halo-color"]),"icon-halo-width":new at(Ee.paint_symbol["icon-halo-width"]),"icon-halo-blur":new at(Ee.paint_symbol["icon-halo-blur"]),"icon-translate":new at(Ee.paint_symbol["icon-translate"]),"text-opacity":new at(Ee.paint_symbol["text-opacity"]),"text-occlusion-opacity":new at(Ee.paint_symbol["text-occlusion-opacity"]),"text-color":new at(Ee.paint_symbol["text-color"],{runtimeType:Wr,getOverride:n=>n.textColor,hasOverride:n=>!!n.textColor}),"text-halo-color":new at(Ee.paint_symbol["text-halo-color"]),"text-halo-width":new at(Ee.paint_symbol["text-halo-width"]),"text-halo-blur":new at(Ee.paint_symbol["text-halo-blur"]),"text-translate":new at(Ee.paint_symbol["text-translate"]),"symbol-z-offset":new at(Ee.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}));class F1{constructor(e,t,r,c,h,f){this._conditionSpec=e,this._propertiesSpec=r;const _=Za(e,Ee.appearance.condition);if(_.result==="success"&&(this.condition=_.value),this.name=t,r){this.layoutProperties=new pa(Mm()),this.unevaluatedLayout=new Am(Mm(),c,h,f),this.paintProperties=new pa(Dm()),this.unevaluatedPaint=new Am(Dm(),c,h,"");for(const g in r)g in this.unevaluatedLayout._values?this.unevaluatedLayout.setValue(g,r[g]):g in this.unevaluatedPaint._values&&this.unevaluatedPaint.setValue(g,r[g])}}isActive(e){return!(this.condition||!e.isHidden||this.name!=="hidden")||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getLayoutProperty(e){return this.layoutProperties.get(e)}getPaintProperty(e){return this.paintProperties.get(e)}getUnevaluatedLayoutProperties(){return this.unevaluatedLayout}getUnevaluatedLayoutProperty(e){return this.unevaluatedLayout._values[e]}getUnevaluatedPaintProperty(e){return this.unevaluatedPaint._values[e]}recalculate(e,t,r){this.unevaluatedLayout&&(this.layoutProperties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,r)),this.unevaluatedPaint&&(this.paintProperties=this.unevaluatedPaint.possiblyEvaluate(e,void 0,t,""))}serialize(){const e={};e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name);const t=this.unevaluatedLayout?this.unevaluatedLayout.serialize():{},r=this.unevaluatedPaint?this.unevaluatedPaint.serialize():{},c=Object.assign({},t,r);return Object.keys(c).length>0&&(e.properties=c),e}hasIconLayoutProperties(){const e=this.hasLayoutProperty("icon-image"),t=this.hasLayoutProperty("icon-size"),r=this.hasLayoutProperty("icon-offset"),c=this.hasLayoutProperty("icon-rotate");return e||t||r||c}hasTextLayoutProperties(){const e=this.hasLayoutProperty("text-size"),t=this.hasLayoutProperty("text-offset"),r=this.hasLayoutProperty("text-rotate");return e||t||r}hasIconPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("icon-")||e==="symbol-z-offset")&&this.hasPaintProperty(e))}hasTextPaintProperties(){return!!this.unevaluatedPaint&&Object.keys(this.unevaluatedPaint._values).filter(e=>!e.endsWith("-use-theme")).some(e=>(e.startsWith("text-")||e==="symbol-z-offset")&&this.hasPaintProperty(e))}hasLayoutProperty(e){return this.unevaluatedLayout&&this.unevaluatedLayout._values[e].value!==void 0}hasPaintProperty(e){return this.unevaluatedPaint&&this.unevaluatedPaint._values[e].value!==void 0}}const Lm="-transition",O1=new Set(["fill","line","background","hillshade","raster"]);class jr extends Du{constructor(e,t,r,c,h,f){if(super(),this.id=e.id,this.fqid=zl(this.id,r),this.type=e.type,this.scope=r,this.lut=c,this.options=h,this.iconImageUseTheme=f,this.appearances=new Array,this.appearancesVersion=0,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},e.type!=="custom"){if(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&e.type!=="background"&&e.type!=="sky"&&e.type!=="slot"){this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter;const _=Za(this.filter,Ee[`filter_${e.type}`]);_.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,..._.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||_.value.isIndoorDependent)}if(e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),t.layout&&(this._unevaluatedLayout=new Am(t.layout,this.scope,h,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),t.paint){this._transitionablePaint=new Wd(t.paint,this.scope,h);for(const _ in e.paint)this.setPaintProperty(_,e.paint[_]);for(const _ in e.layout)this.setLayoutProperty(_,e.layout[_]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new pa(t.paint)}}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D(!0)&&O1.has(this.type)}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if(this.type==="custom"&&e==="visibility")return void(this.visibility=t);const r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),e==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(e){this.appearances=[],e.forEach(t=>{this.appearances.push(new F1(t.condition,t.name,t.properties,this.scope,this.options,this.iconImageUseTheme))}),this.appearancesVersion++}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(e){return e.endsWith(Lm)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return!!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,t){const r=this._transitionablePaint,c=r._properties.properties;if(e.endsWith(Lm)){const I=e.slice(0,-11);return c[I]&&r.setTransition(I,t||void 0),!1}if(!c[e])return!1;const h=r._values[e],f=h.value.isDataDriven(),_=h.value;r.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(e);const g=r._values[e].value,b=g.isDataDriven(),S=e.endsWith("pattern")||e==="line-dasharray";return b||f||S||this._handleOverridablePaintPropertyUpdate(e,_,g)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,r){return null}_handleOverridablePaintPropertyUpdate(e,t,r){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={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()};return this.appearances.length!==0&&(e.appearances=this.appearances.map(t=>t.serialize())),Ke(e,(t,r)=>!(t===void 0||r==="layout"&&!Object.keys(t).length||r==="paint"&&!Object.keys(t).length))}is3D(e){return!1}hasElevation(){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(){}_clear(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Ll&&Fd(t.property.specification)&&(t.value.kind==="source"||t.value.kind==="composite")&&t.value.isStateDependent)return!0}for(const e of this.appearances)if(!Cc(e.condition.expression))return!0;return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=Yd(this.filter,this.scope,e),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&(e.renderPass==="shadow"?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}getAppearances(){return this.appearances}queryRenderedFeatures(e,t,r){return{}}queryRadius(e){}queryIntersectsFeature(e,t,r,c,h,f,_,g,b,S){}}const Qd={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class hh{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}}const B1=new ArrayBuffer(0);class Qi{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(e,t){return e._trim(),t&&e.arrayBuffer&&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,e.arrayBuffer?t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement:(t.capacity=0,t.arrayBuffer=B1),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._reallocCount++,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)}}reserveForAdditional(e){this.reserve(this.length+e)}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){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 pi(n,e=1){let t=0,r=0;return{members:n.map(c=>{const h=Qd[c.type].BYTES_PER_ELEMENT,f=t=ix(t,Math.max(e,h)),_=c.components||1;return r=Math.max(r,h),t+=h*_,{name:c.name,type:c.type,components:_,offset:f}}),size:ix(t,Math.max(r,e)),alignment:e}}function ix(n,e){return Math.ceil(n/e)*e}class ms extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const c=2*e;return this.int16[c+0]=t,this.int16[c+1]=r,e}}ms.prototype.bytesPerElement=4,wt(ms,"StructArrayLayout2i4");class Go extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,r)}emplace(e,t,r,c){const h=3*e;return this.int16[h+0]=t,this.int16[h+1]=r,this.int16[h+2]=c,e}}Go.prototype.bytesPerElement=6,wt(Go,"StructArrayLayout3i6");class Sr extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,r,c)}emplace(e,t,r,c,h){const f=4*e;return this.int16[f+0]=t,this.int16[f+1]=r,this.uint16[f+2]=c,this.uint16[f+3]=h,e}}Sr.prototype.bytesPerElement=8,wt(Sr,"StructArrayLayout2i2ui8");class Rs extends Qi{_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}}Rs.prototype.bytesPerElement=4,wt(Rs,"StructArrayLayout1f4");class zm extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,r)}emplace(e,t,r,c){const h=4*e,f=2*e;return this.int16[h+0]=t,this.int16[h+1]=r,this.float32[f+1]=c,e}}zm.prototype.bytesPerElement=8,wt(zm,"StructArrayLayout2i1f8");class km extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,r)}emplace(e,t,r,c){const h=4*e;return this.int16[h+0]=t,this.int16[h+1]=r,this.int16[h+2]=c,e}}km.prototype.bytesPerElement=8,wt(km,"StructArrayLayout3i8");class Fm extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,r,c)}emplace(e,t,r,c,h){const f=4*e;return this.int16[f+0]=t,this.int16[f+1]=r,this.int16[f+2]=c,this.int16[f+3]=h,e}}Fm.prototype.bytesPerElement=8,wt(Fm,"StructArrayLayout4i8");class Om extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,t,r,c,h)}emplace(e,t,r,c,h,f){const _=5*e;return this.int16[_+0]=t,this.int16[_+1]=r,this.int16[_+2]=c,this.int16[_+3]=h,this.int16[_+4]=f,e}}Om.prototype.bytesPerElement=10,wt(Om,"StructArrayLayout5i10");class dh extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,r,c,h,f,_)}emplace(e,t,r,c,h,f,_,g){const b=6*e,S=12*e,I=3*e;return this.int16[b+0]=t,this.int16[b+1]=r,this.uint8[S+4]=c,this.uint8[S+5]=h,this.uint8[S+6]=f,this.uint8[S+7]=_,this.float32[I+2]=g,e}}dh.prototype.bytesPerElement=12,wt(dh,"StructArrayLayout2i4ub1f12");class Qs extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,r)}emplace(e,t,r,c){const h=3*e;return this.float32[h+0]=t,this.float32[h+1]=r,this.float32[h+2]=c,e}}Qs.prototype.bytesPerElement=12,wt(Qs,"StructArrayLayout3f12");class $o extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,t,r,c,h)}emplace(e,t,r,c,h,f){const _=6*e,g=3*e;return this.uint16[_+0]=t,this.uint16[_+1]=r,this.uint16[_+2]=c,this.uint16[_+3]=h,this.float32[g+2]=f,e}}$o.prototype.bytesPerElement=12,wt($o,"StructArrayLayout4ui1f12");class Vc extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,r,c)}emplace(e,t,r,c,h){const f=4*e;return this.uint16[f+0]=t,this.uint16[f+1]=r,this.uint16[f+2]=c,this.uint16[f+3]=h,e}}Vc.prototype.bytesPerElement=8,wt(Vc,"StructArrayLayout4ui8");class ef extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,r,c,h,f)}emplace(e,t,r,c,h,f,_){const g=6*e;return this.int16[g+0]=t,this.int16[g+1]=r,this.int16[g+2]=c,this.int16[g+3]=h,this.int16[g+4]=f,this.int16[g+5]=_,e}}ef.prototype.bytesPerElement=12,wt(ef,"StructArrayLayout6i12");class Bm extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f,_,g,b,S,I,A){const M=this.length;return this.resize(M+1),this.emplace(M,e,t,r,c,h,f,_,g,b,S,I,A)}emplace(e,t,r,c,h,f,_,g,b,S,I,A,M){const D=12*e;return this.int16[D+0]=t,this.int16[D+1]=r,this.int16[D+2]=c,this.int16[D+3]=h,this.uint16[D+4]=f,this.uint16[D+5]=_,this.uint16[D+6]=g,this.uint16[D+7]=b,this.int16[D+8]=S,this.int16[D+9]=I,this.int16[D+10]=A,this.int16[D+11]=M,e}}Bm.prototype.bytesPerElement=24,wt(Bm,"StructArrayLayout4i4ui4i24");class Nm extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,r,c,h,f)}emplace(e,t,r,c,h,f,_){const g=10*e,b=5*e;return this.int16[g+0]=t,this.int16[g+1]=r,this.int16[g+2]=c,this.float32[b+2]=h,this.float32[b+3]=f,this.float32[b+4]=_,e}}Nm.prototype.bytesPerElement=20,wt(Nm,"StructArrayLayout3i3f20");class _a extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,r,c)}emplace(e,t,r,c,h){const f=4*e;return this.float32[f+0]=t,this.float32[f+1]=r,this.float32[f+2]=c,this.float32[f+3]=h,e}}_a.prototype.bytesPerElement=16,wt(_a,"StructArrayLayout4f16");class fh extends Qi{_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}}fh.prototype.bytesPerElement=4,wt(fh,"StructArrayLayout1ul4");class eo extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const c=2*e;return this.uint16[c+0]=t,this.uint16[c+1]=r,e}}eo.prototype.bytesPerElement=4,wt(eo,"StructArrayLayout2ui4");class tf extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f,_,g,b,S,I,A,M){const D=this.length;return this.resize(D+1),this.emplace(D,e,t,r,c,h,f,_,g,b,S,I,A,M)}emplace(e,t,r,c,h,f,_,g,b,S,I,A,M,D){const z=20*e,B=10*e;return this.int16[z+0]=t,this.int16[z+1]=r,this.int16[z+2]=c,this.int16[z+3]=h,this.int16[z+4]=f,this.float32[B+3]=_,this.float32[B+4]=g,this.float32[B+5]=b,this.float32[B+6]=S,this.int16[z+14]=I,this.uint32[B+8]=A,this.uint16[z+18]=M,this.uint16[z+19]=D,e}}tf.prototype.bytesPerElement=40,wt(tf,"StructArrayLayout5i4f1i1ul2ui40");class ph extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,r,c,h,f,_)}emplace(e,t,r,c,h,f,_,g){const b=8*e;return this.int16[b+0]=t,this.int16[b+1]=r,this.int16[b+2]=c,this.int16[b+4]=h,this.int16[b+5]=f,this.int16[b+6]=_,this.int16[b+7]=g,e}}ph.prototype.bytesPerElement=16,wt(ph,"StructArrayLayout3i2i2i16");class Vm extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,t,r,c,h)}emplace(e,t,r,c,h,f){const _=4*e,g=8*e;return this.float32[_+0]=t,this.float32[_+1]=r,this.float32[_+2]=c,this.int16[g+6]=h,this.int16[g+7]=f,e}}Vm.prototype.bytesPerElement=16,wt(Vm,"StructArrayLayout2f1f2i16");class mh extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,r,c,h,f)}emplace(e,t,r,c,h,f,_){const g=20*e,b=5*e;return this.uint8[g+0]=t,this.uint8[g+1]=r,this.float32[b+1]=c,this.float32[b+2]=h,this.float32[b+3]=f,this.float32[b+4]=_,e}}mh.prototype.bytesPerElement=20,wt(mh,"StructArrayLayout2ub4f20");class Tn extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,r)}emplace(e,t,r,c){const h=3*e;return this.uint16[h+0]=t,this.uint16[h+1]=r,this.uint16[h+2]=c,e}}Tn.prototype.bytesPerElement=6,wt(Tn,"StructArrayLayout3ui6");class nf extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B,V,Z,G,Y,Q){const te=this.length;return this.resize(te+1),this.emplace(te,e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B,V,Z,G,Y,Q)}emplace(e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B,V,Z,G,Y,Q,te){const me=30*e,ce=15*e,pe=60*e;return this.int16[me+0]=t,this.int16[me+1]=r,this.int16[me+2]=c,this.float32[ce+2]=h,this.float32[ce+3]=f,this.uint16[me+8]=_,this.uint16[me+9]=g,this.uint32[ce+5]=b,this.uint32[ce+6]=S,this.uint32[ce+7]=I,this.uint16[me+16]=A,this.uint16[me+17]=M,this.uint16[me+18]=D,this.float32[ce+10]=z,this.float32[ce+11]=B,this.uint8[pe+48]=V,this.uint8[pe+49]=Z,this.uint8[pe+50]=G,this.uint32[ce+13]=Y,this.int16[me+28]=Q,this.uint8[pe+58]=te,e}}nf.prototype.bytesPerElement=60,wt(nf,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Um extends Qi{_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,r,c,h,f,_,g,b,S,I,A,M,D,z,B,V,Z,G,Y,Q,te,me,ce,pe,he,de,Be,je,He,Xe,Ze,nt){const Fe=this.length;return this.resize(Fe+1),this.emplace(Fe,e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B,V,Z,G,Y,Q,te,me,ce,pe,he,de,Be,je,He,Xe,Ze,nt)}emplace(e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B,V,Z,G,Y,Q,te,me,ce,pe,he,de,Be,je,He,Xe,Ze,nt,Fe){const We=20*e,Qe=40*e,st=80*e;return this.float32[We+0]=t,this.float32[We+1]=r,this.int16[Qe+4]=c,this.int16[Qe+5]=h,this.int16[Qe+6]=f,this.int16[Qe+7]=_,this.int16[Qe+8]=g,this.int16[Qe+9]=b,this.int16[Qe+10]=S,this.int16[Qe+11]=I,this.int16[Qe+12]=A,this.uint16[Qe+13]=M,this.uint16[Qe+14]=D,this.uint16[Qe+15]=z,this.uint16[Qe+16]=B,this.uint16[Qe+17]=V,this.uint16[Qe+18]=Z,this.uint16[Qe+19]=G,this.uint16[Qe+20]=Y,this.uint16[Qe+21]=Q,this.uint16[Qe+22]=te,this.uint16[Qe+23]=me,this.uint16[Qe+24]=ce,this.uint16[Qe+25]=pe,this.uint16[Qe+26]=he,this.uint16[Qe+27]=de,this.uint32[We+14]=Be,this.float32[We+15]=je,this.float32[We+16]=He,this.float32[We+17]=Xe,this.float32[We+18]=Ze,this.uint8[st+76]=nt,this.uint16[Qe+39]=Fe,e}}Um.prototype.bytesPerElement=80,wt(Um,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class rf extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,r,c,h,f)}emplace(e,t,r,c,h,f,_){const g=6*e;return this.float32[g+0]=t,this.float32[g+1]=r,this.float32[g+2]=c,this.float32[g+3]=h,this.float32[g+4]=f,this.float32[g+5]=_,e}}rf.prototype.bytesPerElement=24,wt(rf,"StructArrayLayout6f24");class kl extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h){const f=this.length;return this.resize(f+1),this.emplace(f,e,t,r,c,h)}emplace(e,t,r,c,h,f){const _=5*e;return this.float32[_+0]=t,this.float32[_+1]=r,this.float32[_+2]=c,this.float32[_+3]=h,this.float32[_+4]=f,e}}kl.prototype.bytesPerElement=20,wt(kl,"StructArrayLayout5f20");class _h extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,r,c,h,f,_)}emplace(e,t,r,c,h,f,_,g){const b=7*e;return this.float32[b+0]=t,this.float32[b+1]=r,this.float32[b+2]=c,this.float32[b+3]=h,this.float32[b+4]=f,this.float32[b+5]=_,this.float32[b+6]=g,e}}_h.prototype.bytesPerElement=28,wt(_h,"StructArrayLayout7f28");class jm extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f,_,g,b,S,I){const A=this.length;return this.resize(A+1),this.emplace(A,e,t,r,c,h,f,_,g,b,S,I)}emplace(e,t,r,c,h,f,_,g,b,S,I,A){const M=11*e;return this.float32[M+0]=t,this.float32[M+1]=r,this.float32[M+2]=c,this.float32[M+3]=h,this.float32[M+4]=f,this.float32[M+5]=_,this.float32[M+6]=g,this.float32[M+7]=b,this.float32[M+8]=S,this.float32[M+9]=I,this.float32[M+10]=A,e}}jm.prototype.bytesPerElement=44,wt(jm,"StructArrayLayout11f44");class Gm extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f,_,g,b){const S=this.length;return this.resize(S+1),this.emplace(S,e,t,r,c,h,f,_,g,b)}emplace(e,t,r,c,h,f,_,g,b,S){const I=9*e;return this.float32[I+0]=t,this.float32[I+1]=r,this.float32[I+2]=c,this.float32[I+3]=h,this.float32[I+4]=f,this.float32[I+5]=_,this.float32[I+6]=g,this.float32[I+7]=b,this.float32[I+8]=S,e}}Gm.prototype.bytesPerElement=36,wt(Gm,"StructArrayLayout9f36");class Fl extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const c=2*e;return this.float32[c+0]=t,this.float32[c+1]=r,e}}Fl.prototype.bytesPerElement=8,wt(Fl,"StructArrayLayout2f8");class $m extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,r,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,r,c)}emplace(e,t,r,c,h){const f=6*e;return this.uint32[3*e+0]=t,this.uint16[f+2]=r,this.uint16[f+3]=c,this.uint16[f+4]=h,e}}$m.prototype.bytesPerElement=12,wt($m,"StructArrayLayout1ul3ui12");class Ol extends Qi{_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}}Ol.prototype.bytesPerElement=2,wt(Ol,"StructArrayLayout1ui2");class Hm extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B){const V=this.length;return this.resize(V+1),this.emplace(V,e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B)}emplace(e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B,V){const Z=16*e;return this.float32[Z+0]=t,this.float32[Z+1]=r,this.float32[Z+2]=c,this.float32[Z+3]=h,this.float32[Z+4]=f,this.float32[Z+5]=_,this.float32[Z+6]=g,this.float32[Z+7]=b,this.float32[Z+8]=S,this.float32[Z+9]=I,this.float32[Z+10]=A,this.float32[Z+11]=M,this.float32[Z+12]=D,this.float32[Z+13]=z,this.float32[Z+14]=B,this.float32[Z+15]=V,e}}Hm.prototype.bytesPerElement=64,wt(Hm,"StructArrayLayout16f64");class sf extends Qi{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,r,c,h,f,_){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,r,c,h,f,_)}emplace(e,t,r,c,h,f,_,g){const b=10*e,S=5*e;return this.uint16[b+0]=t,this.uint16[b+1]=r,this.uint16[b+2]=c,this.uint16[b+3]=h,this.float32[S+2]=f,this.float32[S+3]=_,this.float32[S+4]=g,e}}sf.prototype.bytesPerElement=20,wt(sf,"StructArrayLayout4ui3f20");class of extends Qi{_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}}of.prototype.bytesPerElement=2,wt(of,"StructArrayLayout1i2");class af extends Qi{_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}}af.prototype.bytesPerElement=1,wt(af,"StructArrayLayout1ub1");class nx extends hh{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]}}nx.prototype.size=40;class Zm extends tf{get(e){return new nx(this,e)}}wt(Zm,"CollisionBoxArray");class rx extends hh{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}}rx.prototype.size=60;class sx extends nf{get(e){return new rx(this,e)}}wt(sx,"PlacedSymbolArray");class gh extends hh{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]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}gh.prototype.size=80;class ox extends Um{get(e){return new gh(this,e)}}wt(ox,"SymbolInstanceArray");class ax extends Rs{getoffsetX(e){return this.float32[1*e+0]}}wt(ax,"GlyphOffsetArray");class yh extends ms{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}wt(yh,"SymbolLineVertexArray");class lx extends hh{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]}}lx.prototype.size=12;class qm extends $m{get(e){return new lx(this,e)}}wt(qm,"FeatureIndexArray");class cx extends eo{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}wt(cx,"FillExtrusionCentroidArray");class Wm extends hh{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}Wm.prototype.size=6;class Xm extends Go{get(e){return new Wm(this,e)}}wt(Xm,"FillExtrusionWallArray");const ux=pi([{name:"a_pos",components:2,type:"Int16"}],4),N1=pi([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),V1=pi([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class $i{constructor(e=[]){this.segments=e}_prepareSegment(e,t,r,c,h){let f=this.segments[this.segments.length-1];return e>$i.MAX_VERTEX_ARRAY_LENGTH&&zt(`Max vertices per segment is ${$i.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!f||f.vertexLength+e>$i.MAX_VERTEX_ARRAY_LENGTH||f.sortKey!==c||h!==void 0&&f&&f.batchIndex!==void 0&&f.batchIndex!==h)&&(f={vertexOffset:t,primitiveOffset:r,vertexLength:0,primitiveLength:0},c!==void 0&&(f.sortKey=c),h!==void 0&&(f.batchIndex=h),this.segments.push(f)),f}prepareSegment(e,t,r,c,h){return this._prepareSegment(e,t.length,r.length,c,h)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,r,c){return new $i([{vertexOffset:e,primitiveOffset:t,vertexLength:r,primitiveLength:c,vaos:{},sortKey:0}])}}function lf(n,e){return 256*(n=q(Math.floor(n),0,255))+q(Math.floor(e),0,255)}$i.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,wt($i,"SegmentVector");const U1=pi([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),j1=pi([{name:"a_pattern_b",components:4,type:"Uint16"}]),G1=pi([{name:"a_dash",components:4,type:"Uint16"}]);class xh{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,r,c){this.ids.push(Ym(e)),this.positions.push(t,r,c)}eachPosition(e,t){const r=Ym(e);let c=0,h=this.ids.length-1;for(;c<h;){const f=c+h>>1;this.ids[f]>=r?h=f:c=f+1}for(;this.ids[c]===r;)t(this.positions[3*c],this.positions[3*c+1],this.positions[3*c+2]),c++}static serialize(e,t){const r=new Float64Array(e.ids),c=new Uint32Array(e.positions);return vh(r,c,0,r.length-1),t&&(t.add(r.buffer),t.add(c.buffer)),{ids:r,positions:c}}static deserialize(e){const t=new xh;let r;t.ids=e.ids,t.positions=e.positions;for(const c of t.ids)c!==r&&t.uniqueIds.push(c),r=c;return t.indexed=!0,t}}function Ym(n){const e=+n;return Number.isSafeInteger(e)?e:Ba(String(n))}function vh(n,e,t,r){for(;t<r;){const c=n[t+r>>1];let h=t-1,f=r+1;for(;;){do h++;while(n[h]<c);do f--;while(n[f]>c);if(h>=f)break;Ds(n,h,f),Ds(e,3*h,3*f),Ds(e,3*h+1,3*f+1),Ds(e,3*h+2,3*f+2)}f-t<r-f?(vh(n,e,t,f),t=f+1):(vh(n,e,f+1,r),r=f)}}function Ds(n,e,t){const r=n[e];n[e]=n[t],n[t]=r}wt(xh,"FeaturePositionMap");class to{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,t){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,t),this.initialized=!0),!!this.location}set(e,t,r){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class bh extends to{constructor(e){super(e),this.current=0}set(e,t,r){this.fetchUniformLocation(e,t)&&this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}}class $n extends to{constructor(e){super(e),this.current=0}set(e,t,r){this.fetchUniformLocation(e,t)&&this.current!==r&&(this.current=r,this.gl.uniform1f(this.location,r))}}class io extends to{constructor(e){super(e),this.current=[0,0]}set(e,t,r){this.fetchUniformLocation(e,t)&&(r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1])))}}class wh extends to{constructor(e){super(e),this.current=[0,0,0]}set(e,t,r){this.fetchUniformLocation(e,t)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2])))}}class $1 extends to{constructor(e){super(e),this.current=[0,0,0,0]}set(e,t,r){this.fetchUniformLocation(e,t)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4ui(this.location,r[0],r[1],r[2],r[3])))}}class cf extends to{constructor(e){super(e),this.current=[0,0,0,0]}set(e,t,r){this.fetchUniformLocation(e,t)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4f(this.location,r[0],r[1],r[2],r[3])))}}class H1 extends to{constructor(e){super(e),this.current=Ii.transparent.toPremultipliedRenderColor(null)}set(e,t,r){this.fetchUniformLocation(e,t)&&(r.r===this.current.r&&r.g===this.current.g&&r.b===this.current.b&&r.a===this.current.a||(this.current=r,this.gl.uniform4f(this.location,r.r,r.g,r.b,r.a)))}}const u=new Float32Array(16);class i extends to{constructor(e){super(e),this.current=u}set(e,t,r){if(this.fetchUniformLocation(e,t)){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let c=1;c<16;c++)if(r[c]!==this.current[c]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}}}const o=new Float32Array(9),d=new Float32Array(4);class m extends to{constructor(e){super(e),this.current=d}set(e,t,r){if(this.fetchUniformLocation(e,t)){for(let c=0;c<4;c++)if(r[c]!==this.current[c]){this.current=r,this.gl.uniformMatrix2fv(this.location,!1,r);break}}}}function y(n){return[lf(255*n.r,255*n.g),lf(255*n.b,255*n.a)]}function v(n,e,t,r,c,h,f,_){return!!n&&(n.kind==="composite"||n.kind==="source"?n.evaluate(new Mi(0,{brightness:h,worldview:_}),e,t,c,r,f)==="none":n.value==="none")}class w{constructor(e,t,r,c){this.value=e,this.uniformNames=t.map(h=>`u_${h}`),this.type=r,this.context=c}setUniform(e,t,r,c,h){const f=c.constantOr(this.value);t.set(e,h,f instanceof Ii?f.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):f)}getBinding(e,t){return this.type==="color"?new H1(e):new $n(e)}}class E{constructor(e,t){this.uniformNames=t.map(r=>`u_${r}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(e,t){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=t?t.tl.concat(t.br):this.pattern}setUniform(e,t,r,c,h){let f=null;h!=="u_pattern"&&h!=="u_dash"||(f=this.pattern),h==="u_pattern_b"&&(f=this.patternTransition),h==="u_pixel_ratio"&&(f=this.pixelRatio),f&&t.set(e,h,f)}getBinding(e,t){return t==="u_pattern"||t==="u_pattern_b"||t==="u_dash"?new $1(e):new $n(e)}}class P{constructor(e,t,r,c){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=t.map(h=>({name:`a_${h}`,type:"Float32",components:r==="color"?2:1,offset:0})),this.paintVertexArray=new c}populatePaintArray(e,t,r,c,h,f,_,g){const b=this.paintVertexArray.length,S=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Mi(0,{brightness:f,worldview:g}),t,{},h,c,_):this.expression.kind==="constant"&&this.expression.value,I=v(this.lutExpression,t,{},c,h,f,_,g);this.paintVertexArray.resize(e),this._setPaintValue(b,e,S,I?null:this.context.lut)}updatePaintArray(e,t,r,c,h,f,_,g){const b=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:_,worldview:g},r,c,void 0,h):this.expression.kind==="constant"&&this.expression.value,S=v(this.lutExpression,r,c,h,void 0,_,void 0,g);this._setPaintValue(e,t,b,S?null:this.context.lut)}_setPaintValue(e,t,r,c){if(this.type==="color"){const h=y(r.toPremultipliedRenderColor(c));for(let f=e;f<t;f++)this.paintVertexArray.emplace(f,h[0],h[1])}else{for(let h=e;h<t;h++)this.paintVertexArray.emplace(h,r);this.maxValue=Math.max(this.maxValue,Math.abs(r))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.lutExpression&&this.lutExpression.kind!=="constant"&&(this.lutExpression.isStateDependent||!this.lutExpression.isLightConstant)||this.expression.kind!=="constant"&&(this.expression.isStateDependent||!this.expression.isLightConstant)))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class R{constructor(e,t,r,c,h,f){this.expression=e,this.uniformNames=t.map(_=>`u_${_}_t`),this.type=r,this.useIntegerZoom=c,this.context=h,this.maxValue=0,this.paintVertexAttributes=t.map(_=>({name:`a_${_}`,type:"Float32",components:r==="color"?4:2,offset:0})),this.paintVertexArray=new f}populatePaintArray(e,t,r,c,h,f,_,g){const b=this.expression.evaluate(new Mi(this.context.zoom,{brightness:f,worldview:g}),t,{},h,c,_),S=this.expression.evaluate(new Mi(this.context.zoom+1,{brightness:f,worldview:g}),t,{},h,c,_),I=v(this.lutExpression,t,{},c,h,f,_,g),A=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(A,e,b,S,I?null:this.context.lut)}updatePaintArray(e,t,r,c,h,f,_,g){const b=this.expression.evaluate({zoom:this.context.zoom,brightness:_,worldview:g},r,c,void 0,h),S=this.expression.evaluate({zoom:this.context.zoom+1,brightness:_,worldview:g},r,c,void 0,h),I=v(this.lutExpression,r,c,h,void 0,_,void 0,g);this._setPaintValue(e,t,b,S,I?null:this.context.lut)}_setPaintValue(e,t,r,c,h){if(this.type==="color"){const f=y(r.toPremultipliedRenderColor(h)),_=y(c.toPremultipliedRenderColor(h));for(let g=e;g<t;g++)this.paintVertexArray.emplace(g,f[0],f[1],_[0],_[1])}else{for(let f=e;f<t;f++)this.paintVertexArray.emplace(f,r,c);this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(c))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t,r,c,h){const f=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,_=q(this.expression.interpolationFactor(f,this.context.zoom,this.context.zoom+1),0,1);t.set(e,h,_)}getBinding(e,t){return new $n(e)}}class O{constructor(e,t,r,c,h){this.expression=e,this.layerId=h,this.paintVertexAttributes=(r==="array"?G1:U1).members;for(let f=0;f<t.length;++f);this.paintVertexArray=new c,this.paintTransitionVertexArray=new Vc}populatePaintArray(e,t,r,c){const h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(h,e,t.patterns&&t.patterns[this.layerId],r)}updatePaintArray(e,t,r,c,h,f,_){this._setPaintValues(e,t,r.patterns&&r.patterns[this.layerId],f)}_setPaintValues(e,t,r,c){if(!c||!r)return;const h=c[r[0]],f=c[r[1]];if(h){if(h){const{tl:_,br:g,pixelRatio:b}=h;for(let S=e;S<t;S++)this.paintVertexArray.emplace(S,_[0],_[1],g[0],g[1],b)}if(f){this.paintTransitionVertexArray.resize(this.paintVertexArray.length);const{tl:_,br:g}=f;for(let b=e;b<t;b++)this.paintTransitionVertexArray.emplace(b,_[0],_[1],g[0],g[1])}}}upload(e){const t=this.expression.isStateDependent||!this.expression.isLightConstant;this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,t)),this.paintTransitionVertexArray&&this.paintTransitionVertexArray.length&&(this.paintTransitionVertexBuffer=e.createVertexBuffer(this.paintTransitionVertexArray,j1.members,t))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy(),this.paintTransitionVertexBuffer&&this.paintTransitionVertexBuffer.destroy()}}class k{constructor(e,t,r=()=>!0){this.binders={},this._buffers=[],this.context=t;const c=[],h=e;for(const f in e.paint._values){const _=h.paint.get(f);if(f.endsWith("-use-theme")||!r(f)||!(_ instanceof Ll&&Fd(_.property.specification)))continue;const g=U(f,e.type),b=_.value,S=_.property.specification.type,I=!!_.property.useIntegerZoom,A=f==="line-dasharray"||f.endsWith("pattern"),M=h.paint.get(`${f}-use-theme`),D=f==="line-dasharray"&&h.layout.get("line-cap").value.kind!=="constant"||M&&M.value.kind!=="constant";if(b.kind!=="constant"||D)if(b.kind==="source"||D||A){const z=ie(f,S,"source");this.binders[f]=A?new O(b,g,S,z,e.id):new P(b,g,S,z),c.push(`/a_${f}`)}else{const z=ie(f,S,"composite");this.binders[f]=new R(b,g,S,I,t,z),c.push(`/z_${f}`)}else this.binders[f]=A?new E(b.value,g):new w(b.value,g,S,t),c.push(`/u_${f}`);M&&(this.binders[f].lutExpression=M.value)}this.cacheKey=c.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof P||t instanceof R?t.maxValue:0}populatePaintArrays(e,t,r,c,h,f,_,g){for(const b in this.binders){const S=this.binders[b];S.context=this.context,(S instanceof P||S instanceof R||S instanceof O)&&S.populatePaintArray(e,t,r,c,h,f,_,g)}}setConstantPatternPositions(e,t){for(const r in this.binders){const c=this.binders[r];c instanceof E&&c.setConstantPatternPositions(e,t)}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof O?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,r,c,h,f,_,g,b,S){let I=!1;const A=Object.keys(e),M=A.length!==0&&!g,D=M?A:t.uniqueIds;this.context.lut=h.lut;for(const z in this.binders){const B=this.binders[z];if(B.context=this.context,(B instanceof P||B instanceof R||B instanceof O)&&B.expression&&B.expression.kind&&B.expression.kind!=="constant"&&(B.expression.isStateDependent===!0||B.expression.isLightConstant===!1)){const V=h.paint.get(z);B.expression=V.value;for(const Z of D){const G=e[Z.toString()];t.eachPosition(Z,(Y,Q,te)=>{const me=c.feature(Y);B.updatePaintArray(Q,te,me,G,f,_,b,S)})}if(!M)for(const Z of r.uniqueIds){const G=e[Z.toString()];r.eachPosition(Z,(Y,Q,te)=>{const me=c.feature(Y);B.updatePaintArray(Q,te,me,G,f,_,b,S)})}I=!0}}return I}defines(){const e=[];for(const t in this.binders){const r=this.binders[t];(r instanceof w||r instanceof E)&&e.push(...r.uniformNames.map(c=>`#define HAS_UNIFORM_${c}`))}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const r in this.binders){const c=this.binders[r];if(c instanceof w||c instanceof E||c instanceof R)for(const h of c.uniformNames)t.push({name:h,property:r,binding:c.getBinding(e,h)})}return t}setUniforms(e,t,r,c,h){for(const{name:f,property:_,binding:g}of r)this.binders[_].setUniform(e,g,h,c.get(_),f)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof P||t instanceof R||t instanceof O)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof O&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer)}}upload(e){for(const t in this.binders){const r=this.binders[t];(r instanceof P||r instanceof R||r instanceof O)&&r.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof P||t instanceof R||t instanceof O)&&t.destroy()}}}class N{constructor(e,t,r=()=>!0){this.programConfigurations={};for(const c of e)this.programConfigurations[c.id]=new k(c,t,r);this.needsUpload=!1,this._featureMap=new xh,this._featureMapWithoutIds=new xh,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,r,c,h,f,_,g,b){for(const S in this.programConfigurations)this.programConfigurations[S].populatePaintArrays(e,t,c,h,f,_,g,b);t.id!==void 0?this._featureMap.add(t.id,r,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,r,c,h,f,_,g){for(const b of r)this.needsUpload=this.programConfigurations[b.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,b,c,h,f,_||0,g)||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 j={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_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"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function U(n,e){return j[n]||[n.replace(`${e}-`,"").replace(/-/g,"_")]}const X={"line-pattern":{source:$o,composite:$o},"fill-pattern":{source:$o,composite:$o},"fill-extrusion-pattern":{source:$o,composite:$o},"line-dasharray":{source:Vc,composite:Vc}},W={color:{source:Fl,composite:_a},number:{source:Rs,composite:Fl}};function ie(n,e,t){const r=X[n];return r&&r[t]||W[e][t]}wt(w,"ConstantBinder"),wt(E,"PatternConstantBinder"),wt(P,"SourceExpressionBinder"),wt(O,"PatternCompositeBinder"),wt(R,"CompositeExpressionBinder"),wt(k,"ProgramConfiguration",{omit:["_buffers"]}),wt(N,"ProgramConfigurationSet");const ne=_t/Math.PI/2,K=64,xe=[K,32,16],le=-ne,_e=ne;function re(n,e,t,r=ne){return t=Ei(t),[n*Math.sin(t)*r,-e*r,n*Math.cos(t)*r]}function ae(n,e,t){return re(Math.cos(Ei(n)),Math.sin(Ei(n)),e,t)}const fe=63710088e-1,Ce=2*Math.PI*fe;class ve{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new ve(ge(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,r=this.lat*t,c=e.lat*t,h=Math.sin(r)*Math.sin(c)+Math.cos(r)*Math.cos(c)*Math.cos((e.lng-this.lng)*t);return fe*Math.acos(Math.min(h,1))}toBounds(e=0){const t=360*e/40075017,r=t/Math.cos(Math.PI/180*this.lat);return new Ne({lng:this.lng-r,lat:this.lat-t},{lng:this.lng+r,lat:this.lat+t})}toEcef(e){return ae(this.lat,this.lng,ne+e*ne/fe)}static convert(e){if(e instanceof ve)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new ve(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new ve(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class Ne{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof ve?new ve(e.lng,e.lat):ve.convert(e),this}setSouthWest(e){return this._sw=e instanceof ve?new ve(e.lng,e.lat):ve.convert(e),this}extend(e){const t=this._sw,r=this._ne;let c,h;if(e instanceof ve)c=e,h=e;else{if(!(e instanceof Ne))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(Ne.convert(e)):this.extend(ve.convert(e)):typeof e=="object"&&e!==null&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(ve.convert(e)):this;if(c=e._sw,h=e._ne,!c||!h)return this}return t||r?(t.lng=Math.min(c.lng,t.lng),t.lat=Math.min(c.lat,t.lat),r.lng=Math.max(h.lng,r.lng),r.lat=Math.max(h.lat,r.lat)):(this._sw=new ve(c.lng,c.lat),this._ne=new ve(h.lng,h.lat)),this}getCenter(){return new ve((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 ve(this.getWest(),this.getNorth())}getSouthEast(){return new ve(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:r}=ve.convert(e);let c=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&c}static convert(e){if(e)return e instanceof Ne?e:new Ne(e)}}function ze(n){return Ce*Math.cos(n*Math.PI/180)}function Je(n){return(180+n)/360}function tt(n){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n*Math.PI/360)))/360}function Pe(n,e){return n/ze(e)}function we(n){return 360*n-180}function Oe(n){return 360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90}function Ue(n,e){return n*ze(Oe(e))}const $e=85.051129;function ft(n){return Math.cos(Ei(q(n,-85.051129,$e)))}function lt(n,e){const t=q(e,0,25.5),r=Math.pow(2,t);return ft(n)*Ce/(512*r)}function ct(n){return 1/Math.cos(n*Math.PI/180)}function et(n,e=0){const t=Math.exp(Math.PI*(1-(n.y+e/_t)/(1<<n.z)*2));return 80150034*t/(t*t+1)/_t/(1<<n.z)}class Et{constructor(e,t,r=0){this.x=+e,this.y=+t,this.z=+r}static fromLngLat(e,t=0){const r=ve.convert(e);return new Et(Je(r.lng),tt(r.lat),Pe(t,r.lat))}toLngLat(){return new ve(we(this.x),Oe(this.y))}toAltitude(){return Ue(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ce*ct(Oe(this.y))}}function Mt(n,e,t,r,c,h,f,_,g){const b=(e+r)/2,S=(t+c)/2,I=new it(b,S);_(I),function(A,M,D,z,B,V){const Z=D-B,G=z-V;return Math.abs((z-M)*Z-(D-A)*G)/Math.hypot(Z,G)}(I.x,I.y,h.x,h.y,f.x,f.y)>=g?(Mt(n,e,t,b,S,h,I,_,g),Mt(n,b,S,r,c,I,f,_,g)):n.push(f)}function vt(n,e,t){let r=n[0],c=r.x,h=r.y;e(r);const f=[r];for(let _=1;_<n.length;_++){const g=n[_],{x:b,y:S}=g;e(g),Mt(f,c,h,b,S,r,g,e,t),c=b,h=S,r=g}return f}function St(n,e,t,r){if(r(e,t)){const c=e.add(t)._mult(.5);St(n,e,c,r),St(n,c,t,r)}else n.push(t)}function Vt(n,e){let t=n[0];const r=[t];for(let c=1;c<n.length;c++){const h=n[c];St(r,t,h,e),t=h}return r}const Yt=Math.pow(2,14)-1,Zt=-Yt-1;function si(n,e){const t=Math.round(n.x*e),r=Math.round(n.y*e);return n.x=q(t,Zt,Yt),n.y=q(r,Zt,Yt),(t<n.x||t>n.x+1||r<n.y||r>n.y+1)&&zt("Geometry exceeds allowed extent, reduce your vector tile buffer size"),n}function Ft(n,e,t){const r=n.loadGeometry(),c=n.extent,h=_t/c;if(e&&t&&t.projection.isReprojectedInTileSpace){const f=1<<e.z,{scale:_,x:g,y:b,projection:S}=t,I=A=>{const M=we((e.x+A.x/c)/f),D=Oe((e.y+A.y/c)/f),z=S.project(M,D);A.x=(z.x*_-g)*c,A.y=(z.y*_-b)*c};for(let A=0;A<r.length;A++)if(n.type!==1)r[A]=vt(r[A],I,1);else{const M=[];for(const D of r[A])D.x<0||D.x>=c||D.y<0||D.y>=c||(I(D),M.push(D));r[A]=M}}for(const f of r)for(const _ of f)si(_,h);return r}function oi(n,e){return{type:n.type,id:n.id,properties:n.properties,geometry:e?Ft(n):[]}}class qt{constructor(e,t,r,c,h){this.properties={},this.extent=r,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=c,this._values=h,e.readFields(Ti,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,r=[];let c,h=1,f=0,_=0,g=0;for(;e.pos<t;){if(f<=0){const b=e.readVarint();h=7&b,f=b>>3}if(f--,h===1||h===2)_+=e.readSVarint(),g+=e.readSVarint(),h===1&&(c&&r.push(c),c=[]),c&&c.push(new it(_,g));else{if(h!==7)throw new Error(`unknown command ${h}`);c&&c.push(c[0].clone())}}return c&&r.push(c),r}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let r=1,c=0,h=0,f=0,_=1/0,g=-1/0,b=1/0,S=-1/0;for(;e.pos<t;){if(c<=0){const I=e.readVarint();r=7&I,c=I>>3}if(c--,r===1||r===2)h+=e.readSVarint(),f+=e.readSVarint(),h<_&&(_=h),h>g&&(g=h),f<b&&(b=f),f>S&&(S=f);else if(r!==7)throw new Error(`unknown command ${r}`)}return[_,b,g,S]}toGeoJSON(e,t,r){const c=this.extent*Math.pow(2,r),h=this.extent*e,f=this.extent*t,_=this.loadGeometry();function g(A){return[360*(A.x+h)/c-180,360/Math.PI*Math.atan(Math.exp((1-2*(A.y+f)/c)*Math.PI))-90]}function b(A){return A.map(g)}let S;if(this.type===1){const A=[];for(const D of _)A.push(D[0]);const M=b(A);S=A.length===1?{type:"Point",coordinates:M[0]}:{type:"MultiPoint",coordinates:M}}else if(this.type===2){const A=_.map(b);S=A.length===1?{type:"LineString",coordinates:A[0]}:{type:"MultiLineString",coordinates:A}}else{if(this.type!==3)throw new Error("unknown feature type");{const A=function(D){const z=D.length;if(z<=1)return[D];const B=[];let V,Z;for(let G=0;G<z;G++){const Y=Vi(D[G]);Y!==0&&(Z===void 0&&(Z=Y<0),Z===Y<0?(V&&B.push(V),V=[D[G]]):V&&V.push(D[G]))}return V&&B.push(V),B}(_),M=[];for(const D of A)M.push(D.map(b));S=M.length===1?{type:"Polygon",coordinates:M[0]}:{type:"MultiPolygon",coordinates:M}}}const I={type:"Feature",geometry:S,properties:this.properties};return this.id!=null&&(I.id=this.id),I}}function Ti(n,e,t){n===1?e.id=t.readVarint():n===2?function(r,c){const h=r.readVarint()+r.pos;for(;r.pos<h;){const f=c._keys[r.readVarint()],_=c._values[r.readVarint()];c.properties[f]=_}}(t,e):n===3?e.type=t.readVarint():n===4&&(e._geometry=t.pos)}function Vi(n){let e=0;for(let t,r,c=0,h=n.length,f=h-1;c<h;f=c++)t=n[c],r=n[f],e+=(r.x-t.x)*(t.y+r.y);return e}qt.types=["Unknown","Point","LineString","Polygon"];class nn{constructor(e,t){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(Hi,this,t),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new qt(this._pbf,t,this.extent,this._keys,this._values)}}function Hi(n,e,t){n===15?e.version=t.readVarint():n===1?e.name=t.readString():n===5?e.extent=t.readVarint():n===2?e._features.push(t.pos):n===3?e._keys.push(t.readString()):n===4&&e._values.push(function(r){let c=null;const h=r.readVarint()+r.pos;for(;r.pos<h;){const f=r.readVarint()>>3;c=f===1?r.readString():f===2?r.readFloat():f===3?r.readDouble():f===4?r.readVarint64():f===5?r.readVarint():f===6?r.readSVarint():f===7?r.readBoolean():null}if(c==null)throw new Error("unknown feature value");return c}(t))}class Ci{constructor(e,t){this.layers=e.readFields(ni,{},t)}}function ni(n,e,t){if(n===3){const r=new nn(t,t.readVarint()+t.pos);r.length&&(e[r.name]=r)}}const ri="3d_elevation_id",Zi="level";class an{constructor(){this._valid=!1}reset(e){return this.feature=e,this._valid=!0,this._geometry=e.loadGeometry(),this._geometry.length!==0&&this._geometry[0].length!==0||(this._valid=!1),this}geometry(e,t){return this._valid&&e(t(this._geometry)),this}require(e,t,r){return this.get(e,!0,t,r)}optional(e,t,r){return this.get(e,!1,t,r)}success(){return this._valid}get(e,t,r,c){const h=this.feature.properties.hasOwnProperty(e)?+this.feature.properties[e]:void 0;return this._valid&&h!==void 0&&!Number.isNaN(h)?r(c?c(h):h):t&&(this._valid=!1),this}}class Pi{constructor(e,t){this.featureFunc=e,this.vertexFunc=t}parseFeature(e,t,r){return this.featureFunc(e,t,r)}parseVertex(e,t,r){return this.vertexFunc(e,t,r)}}const Jt=new Pi((n,e,t)=>n.reset(e).require(ri,r=>{t.id=r}).optional("fixed_height_relative",r=>{t.constantHeight=r},Ui.decodeRelativeHeight).geometry(r=>{t.bounds=r},jp).success(),(n,e,t)=>n.reset(e).require(ri,r=>{t.id=r}).require("elevation_idx",r=>{t.idx=r}).require("extent",r=>{t.extent=r}).require("height_relative",r=>{t.height=r},Ui.decodeRelativeHeight).geometry(r=>{t.position=r},Ui.getPoint).success()),en=new Pi((n,e,t)=>n.reset(e).require(ri,r=>{t.id=r}).optional("fixed_height",r=>{t.constantHeight=r},Ui.decodeMetricHeight).geometry(r=>{t.bounds=r},jp).success(),(n,e,t)=>n.reset(e).require(ri,r=>{t.id=r}).require("elevation_idx",r=>{t.idx=r}).require("extent",r=>{t.extent=r}).require("height",r=>{t.height=r},Ui.decodeMetricHeight).geometry(r=>{t.position=r},Ui.getPoint).success());class Ui{static getPoint(e){return Do(e[0][0].x,e[0][0].y)}static decodeRelativeHeight(e){return 1e-4*e*5}static decodeMetricHeight(e){return 1e-4*e}static getVersionSchema(e){return e?e==="1.0.1"?en:void 0:Jt}static parse(e){const t=[],r=[],c=e.length,h=new an;for(let f=0;f<c;f++){const _=e.feature(f),g=_.properties.version,b=Ui.getVersionSchema(g);if(b===void 0){zt(`Unknown elevation feature version number ${g||"(unknown)"}`);continue}const S=_.properties.type;if(!S)continue;const I=qt.types[_.type];if(I==="Point"&&S==="curve_point"){const A={};b.parseVertex(h,_,A)&&t.push(A)}else if(I==="Polygon"&&S==="curve_meta"){const A={};b.parseFeature(h,_,A)&&r.push(A)}}return{vertices:t,features:r}}}class kn{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,r){const c=uo(t,this.dir);if(Math.abs(c)<1e-6)return!1;const h=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1])/c;return r[0]=this.pos[0]+this.dir[0]*h,r[1]=this.pos[1]+this.dir[1]*h,!0}}class fi{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,r){const c=pn(t,this.dir);if(Math.abs(c)<1e-6)return!1;const h=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/c;return r[0]=this.pos[0]+this.dir[0]*h,r[1]=this.pos[1]+this.dir[1]*h,r[2]=this.pos[2]+this.dir[2]*h,!0}closestPointOnSphere(e,t,r){if(function(M,D){var z=M[0],B=M[1],V=M[2],Z=D[0],G=D[1],Y=D[2];return Math.abs(z-Z)<=F*Math.max(1,Math.abs(z),Math.abs(Z))&&Math.abs(B-G)<=F*Math.max(1,Math.abs(B),Math.abs(G))&&Math.abs(V-Y)<=F*Math.max(1,Math.abs(V),Math.abs(Y))}(this.pos,e)||t===0)return r[0]=r[1]=r[2]=0,!1;const[c,h,f]=this.dir,_=this.pos[0]-e[0],g=this.pos[1]-e[1],b=this.pos[2]-e[2],S=c*c+h*h+f*f,I=2*(_*c+g*h+b*f),A=I*I-4*S*(_*_+g*g+b*b-t*t);if(A<0){const M=Math.max(-I/2,0),D=_+c*M,z=g+h*M,B=b+f*M,V=Math.hypot(D,z,B);return r[0]=D*t/V,r[1]=z*t/V,r[2]=B*t/V,!1}{const M=(-I-Math.sqrt(A))/(2*S);if(M<0){const D=Math.hypot(_,g,b);return r[0]=_*t/D,r[1]=g*t/D,r[2]=b*t/D,!1}return r[0]=_+c*M,r[1]=g+h*M,r[2]=b+f*M,!0}}}class Gi{constructor(e,t,r,c,h){this.TL=e,this.TR=t,this.BR=r,this.BL=c,this.horizon=h}static fromInvProjectionMatrix(e,t,r){const c=[-1,1,1],h=[1,1,1],f=[1,-1,1],_=[-1,-1,1],g=mn(c,c,e),b=mn(h,h,e),S=mn(f,f,e),I=mn(_,_,e);return new Gi(g,b,S,I,t/r)}}function Vn(n,e,t){let r=1/0,c=-1/0;const h=[];for(const f of n){Ln(h,f,e);const _=pn(h,t);r=Math.min(r,_),c=Math.max(c,_)}return[r,c]}function Er(n,e){let t=!0;for(let r=0;r<n.planes.length;r++){const c=n.planes[r];let h=0;for(let f=0;f<e.length;f++)h+=+(pn(c,e[f])+c[3]>=0);if(h===0)return 0;h!==e.length&&(t=!1)}return t?2:1}function Hn(n,e){for(const t of n.projections){const r=Vn(e,n.points[0],t.axis);if(t.projection[1]<r[0]||t.projection[0]>r[1])return 0}return 1}function ar(n,e){let t=0;const r=[0,0,0,0];for(let c=0;c<n.length;c++)r[0]=n[c][0],r[1]=n[c][1],r[2]=n[c][2],r[3]=1,Ro(r,e)>=0&&t++;return t}class _s{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=Li.fromPoints(this.points),this.projections=[],this.frustumEdges=[Ln([],this.points[2],this.points[3]),Ln([],this.points[0],this.points[3]),Ln([],this.points[4],this.points[0]),Ln([],this.points[5],this.points[1]),Ln([],this.points[6],this.points[2]),Ln([],this.points[7],this.points[3])];for(const r of this.frustumEdges){const c=[0,-r[2],r[1]],h=[r[2],0,-r[0]];this.projections.push({axis:c,projection:Vn(this.points,this.points[0],c)}),this.projections.push({axis:h,projection:Vn(this.points,this.points[0],h)})}}static fromInvProjectionMatrix(e,t,r,c){const h=Math.pow(2,r),f=[[-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(b=>{const S=vr([],b,e),I=1/S[3]/t*h;return(A=S)[0]=(M=S)[0]*(D=[I,I,c?1/S[3]:I,I])[0],A[1]=M[1]*D[1],A[2]=M[2]*D[2],A[3]=M[3]*D[3],A;var A,M,D}),_=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(b=>{const S=zi([],On([],Ln([],f[b[0]],f[b[1]]),Ln([],f[b[2]],f[b[1]]))),I=-pn(S,f[b[1]]);return S.concat(I)}),g=[];for(let b=0;b<f.length;b++)g.push([f[b][0],f[b][1],f[b][2]]);return new _s(g,_)}intersectsPrecise(e,t,r){for(let c=0;c<t.length;c++)if(!ar(e,t[c]))return 0;for(let c=0;c<this.planes.length;c++)if(!ar(e,this.planes[c]))return 0;for(const c of r)for(const h of this.frustumEdges){const f=On([],c,h),_=Wn(f);if(_===0)continue;mi(f,f,1/_);const g=Vn(this.points,this.points[0],f),b=Vn(e,this.points[0],f);if(g[0]>b[1]||b[0]>g[1])return 0}return 1}containsPoint(e){for(const t of this.planes){const r=t[3];if(pn([t[0],t[1],t[2]],e)+r<0)return!1}return!0}}class Li{static fromPoints(e){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const c of e)Ut(t,t,c),ii(r,r,c);return new Li(t,r)}static fromTileIdAndHeight(e,t,r){const c=1<<e.canonical.z,h=e.canonical.x,f=e.canonical.y;return new Li([h/c,f/c,t],[(h+1)/c,(f+1)/c,r])}static applyTransform(e,t){const r=e.getCorners();for(let c=0;c<r.length;++c)mn(r[c],r[c],t);return Li.fromPoints(r)}static applyTransformFast(e,t){const r=[t[12],t[13],t[14]],c=[...r];for(let h=0;h<3;h++)for(let f=0;f<3;f++){const _=t[4*f+h],g=_*e.min[f],b=_*e.max[f];r[h]+=Math.min(g,b),c[h]+=Math.max(g,b)}return new Li(r,c)}static projectAabbCorners(e,t){const r=e.getCorners();for(let c=0;c<r.length;++c)mn(r[c],r[c],t);return r}constructor(e,t){this.min=e,this.max=t,this.center=mi([],Pt([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],r=Mr(this.min),c=Mr(this.max);for(let h=0;h<t.length;h++)r[h]=t[h]?this.min[h]:this.center[h],c[h]=t[h]?this.center[h]:this.max[h];return c[2]=this.max[2],new Li(r,c)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return[[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?Er(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?Er(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(e,t){return t||this.intersects(e)?Hn(e,this.getCorners()):0}intersectsPreciseFlat(e,t){return t||this.intersectsFlat(e)?Hn(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(e){for(let t=0;t<3;++t)if(this.min[t]>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])]}}wt(Li,"Aabb");class Ls{constructor(e,t){this.feature=e,this.metersToTile=t,this.index=0}get(){const e=this.feature.vertices[this.index],t=this.feature.vertexProps[this.index].dir,r=t[1],c=-t[0],h=(e.extent+1)*this.metersToTile;return[new it(Math.trunc(e.position[0]+r*h),Math.trunc(e.position[1]+c*h)),new it(Math.trunc(e.position[0]-r*h),Math.trunc(e.position[1]-c*h))]}next(){this.index++}valid(){return this.index<this.feature.vertices.length}}class zs{constructor(e,t,r,c,h,f){if(this.vertices=new Array,this.vertexProps=new Array,this.edges=new Array,this.edgeProps=new Array,this._tmpVec2=[Dr(),Dr(),Dr(),Dr(),Dr(),Dr(),Dr()],this.id=e,this.heightRange={min:r,max:r},this.safeArea=t,this.constantHeight=r,this.constantHeight==null&&(this.constantHeight!=null||c.length!==0)){this.vertices=c,this.edges=h,this.edges=this.edges.filter(_=>{return _.a<this.vertices.length&&_.b<this.vertices.length&&!((g=this.vertices[_.a].position)[0]===(b=this.vertices[_.b].position)[0]&&g[1]===b[1]);var g,b}),this.heightRange={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};for(const _ of this.vertices)this.vertexProps.push({dir:Do(0,0)}),this.heightRange.min=Math.min(this.heightRange.min,_.height),this.heightRange.max=Math.max(this.heightRange.max,_.height);for(const _ of this.edges){const g=this.vertices[_.a].position,b=this.vertices[_.b].position,S=Lo(Dr(),b,g),I=pl(S),A=fl(Dr(),S,1/I);this.edgeProps.push({vec:S,dir:A,len:I});const M=this.vertexProps[_.a].dir,D=this.vertexProps[_.b].dir;Is(M,M,A),Is(D,D,A)}for(const _ of this.vertexProps)_.dir[0]===0&&_.dir[1]===0||ml(_.dir,_.dir);this.tessellate(f)}}pointElevation(e){if(this.constantHeight!=null)return this.constantHeight;const t=this.getClosestEdge(e);if(t==null)return 0;const[r,c]=t;return Gt(this.vertices[this.edges[r].a].height,this.vertices[this.edges[r].b].height,c)}computeSlopeNormal(e,t){const r=this.getClosestEdge(e);if(!r)return ji(0,0,1);const c=r[0],h=this.edges[c],f=this.edgeProps[c].vec,_=ji(f[0],f[1],(this.vertices[h.b].height-this.vertices[h.a].height)*t),g=ji(_[1],-_[0],0);On(g,g,_);const b=Wn(g);return b>0?mi(g,g,1/b):ti(g,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(this.edges.length===0)return;let t=0,r=Number.POSITIVE_INFINITY,c=0;const[h,f,_,g,b,S,I]=this._tmpVec2;ka(I,e.x,e.y);const A=new kn(I,null);for(let M=0;M<this.edges.length;M++){const D=this.edges[M],z=this.edgeProps[M].dir;A.dir=z;const B=this.vertices[D.a].position,V=this.vertices[D.b].position,Z=A.intersectsPlane(B,this.vertexProps[D.a].dir,h),G=A.intersectsPlane(V,this.vertexProps[D.b].dir,f);if(!Z||!G)continue;Lo(_,f,h),Lo(g,I,h);const Y=uo(_,_),Q=Y>0?uo(g,_)/Y:0,te=q(Q,0,1),me=Math.abs((Q-te)*this.edgeProps[M].len);Lo(b,I,B),ka(S,z[1],-z[0]);const ce=me+Math.abs(uo(b,S));ce<r&&(t=M,r=ce,c=te)}return[t,c]}tessellate(e){const t=gi(),r=gi(),c=gi(),h=gi();for(let f=this.edges.length-1;f>=0;--f){const _=this.edges[f].a,g=this.edges[f].b,{position:b,height:S,extent:I}=this.vertices[_],{position:A,height:M,extent:D}=this.vertices[g],z=this.vertexProps[_].dir,B=this.vertexProps[g].dir;if(ti(t,b[0]/e,b[1]/e,S),ti(r,A[0]/e,A[1]/e,M),ti(c,z[1],-z[0],0),mi(c,c,I),ti(h,B[1],-B[0],0),mi(h,h,D),this.distSqLines(ji(t[0]+.5*c[0],t[1]+.5*c[1],t[2]+.5*c[2]),ji(r[0]-.5*h[0],r[1]-.5*h[1],r[2]-.5*h[2]),ji(t[0]-.5*c[0],t[1]-.5*c[1],t[2]-.5*c[2]),ji(r[0]+.5*h[0],r[1]+.5*h[1],r[2]+.5*h[2]))<=.0025000000000000005)continue;const V=this.vertices.length,Z=Is(Dr(),b,A);this.vertices.push({position:fl(Z,Z,.5),height:.5*(S+M),extent:.5*(I+D)});const G=Is(Dr(),z,B);this.vertexProps.push({dir:ml(G,G)}),this.edges.splice(f,1),this.edgeProps.splice(f,1),this.edges.push({a:_,b:V}),this.edges.push({a:V,b:g});const Y=Lo(Dr(),this.vertices[V].position,b),Q=pl(Y),te={vec:Y,dir:fl(Dr(),Y,1/Q),len:Q};this.edgeProps.push(te),this.edgeProps.push(te)}}distSqLines(e,t,r,c){const h=$t(gi(),t,e),f=$t(gi(),c,r),_=$t(gi(),e,r),g=pn(h,h),b=pn(h,f),S=pn(h,_),I=pn(f,f),A=pn(f,_),M=g*I-b*b;if(M===0)return sn(oa(h,r,c,pn(_,f)/pn(f,f)),e);const D=(g*A-b*S)/M;return sn(oa(h,e,t,(b*A-S*I)/M),oa(f,r,c,D))}}class Yi{static parseFrom(e,t){const r=Ui.parse(e);if(!r)return[];let{vertices:c,features:h}=r;const f=1/et(t);h.sort((S,I)=>S.id-I.id),c.sort((S,I)=>S.id-I.id||S.idx-I.idx),c=c.filter((S,I,A)=>I===A.findIndex(M=>M.id===S.id&&M.idx===S.idx));const _=new Array;let g=0;const b=c.length;for(const S of h){if(S.constantHeight){_.push(new zs(S.id,S.bounds,S.constantHeight));continue}for(;g!==b&&c[g].id<S.id;)g++;if(g===b||c[g].id!==S.id)continue;const I=new Array,A=new Array,M=g;for(;g!==b&&c[g].id===S.id;){const D=c[g];if(I.push({position:D.position,height:D.height,extent:D.extent}),g!==M&&c[g-1].idx===D.idx-1){const z=g-M;A.push({a:z-1,b:z})}g++}_.push(new zs(S.id,S.bounds,void 0,I,A,f))}return _}static getElevationFeature(e,t){if(!t)return;const r=+e.properties[ri];return Number.isNaN(r)?void 0:t.find(c=>c.id===r)}}class Ki{constructor(e,t){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(t)||(this.zScale=Math.pow(2,t.z-e.z),this.xOffset=(e.x*this.zScale-t.x)*_t,this.yOffset=(e.y*this.zScale-t.y)*_t)}constantElevation(e,t){if(e.constantHeight!=null)return this.computeBiasedHeight(e.constantHeight,t)}pointElevation(e,t,r){const c=this.constantElevation(t,r);return c??(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(t.pointElevation(e),r))}computeBiasedHeight(e,t){return t<=0?e:e+t*oe(0,t,e>=0?e:Math.abs(.5*e))}}wt(zs,"ElevationFeature");class Bi{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new ms,this.indexArray=new Tn,this.segments=new $i,this.programConfigurations=new N(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new Rs),this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,r,c){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,c){const h=this.layers[0],f=[];let _=null;h.type==="circle"&&(_=h.layout.get("circle-sort-key"));for(const{feature:b,id:S,index:I,sourceLayerIndex:A}of e){const M=this.layers[0]._featureFilter.needGeometry,D=oi(b,M);if(!this.layers[0]._featureFilter.filter(new Mi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),D,r))continue;const z=_?_.evaluate(D,{},r):void 0,B={id:S,properties:b.properties,type:b.type,sourceLayerIndex:A,index:I,geometry:M?D.geometry:Ft(b,r,c),patterns:{},sortKey:z};f.push(B)}_&&f.sort((b,S)=>b.sortKey-S.sortKey);let g=null;c.projection.name==="globe"&&(this.globeExtVertexArray=new ef,g=c.projection);for(const b of f){const{geometry:S,index:I,sourceLayerIndex:A}=b,M=e[I].feature;this.addFeature(b,S,I,t.availableImages,r,g,t.brightness,t.elevationFeatures),t.featureIndex.insert(M,S,I,A,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(e,t,r,c,h,f,_){this.programConfigurations.updatePaintArrays(e,t,h,r,c,f,_,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ux.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,V1.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,N1.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(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(e,t,r,c,h,f,_,g){let b;this.elevationMode!=="none"&&(b=Yi.getElevationFeature(e,g));for(const S of t)for(const I of S){const A=I.x,M=I.y;if(A<0||A>=_t||M<0||M>=_t)continue;if(f){const B=f.projectTilePoint(A,M,h),V=f.upVector(h,A,M);this.addGlobeExtVertex(B,V),this.addGlobeExtVertex(B,V),this.addGlobeExtVertex(B,V),this.addGlobeExtVertex(B,V)}const D=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),z=D.vertexLength;if(this.addCircleVertex(A,M,-1,-1),this.addCircleVertex(A,M,1,-1),this.addCircleVertex(A,M,1,1),this.addCircleVertex(A,M,-1,1),this.elevationMode!=="none"){const B=b?b.pointElevation(new it(A,M)):0;this.hasElevation=this.hasElevation||B!==0;for(let V=0;V<4;V++)this.elevatedLayoutVertexArray.emplaceBack(B)}this.indexArray.emplaceBack(z,z+1,z+2),this.indexArray.emplaceBack(z,z+2,z+3),D.vertexLength+=4,D.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},c,h,_,void 0,this.worldview)}addCircleVertex(e,t,r,c){this.layoutVertexArray.emplaceBack(2*e+(r+1)/2,2*t+(c+1)/2)}addGlobeExtVertex(e,t){this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,t[0]*16384,t[1]*16384,t[2]*16384)}}function Mn(n,e){for(let t=0;t<n.length;t++)if(ns(e,n[t]))return!0;for(let t=0;t<e.length;t++)if(ns(n,e[t]))return!0;return!!Wa(n,e)}function kr(n,e,t){return!!ns(n,e)||!!ga(e,n,t)}function _n(n,e){if(n.length===1)return jc(e,n[0]);for(let t=0;t<e.length;t++){const r=e[t];for(let c=0;c<r.length;c++)if(ns(n,r[c]))return!0}for(let t=0;t<n.length;t++)if(jc(e,n[t]))return!0;for(let t=0;t<e.length;t++)if(Wa(n,e[t]))return!0;return!1}function gs(n,e,t){if(n.length>1){if(Wa(n,e))return!0;for(let r=0;r<e.length;r++)if(ga(e[r],n,t))return!0}for(let r=0;r<n.length;r++)if(ga(n[r],e,t))return!0;return!1}function Wa(n,e){if(n.length===0||e.length===0)return!1;for(let t=0;t<n.length-1;t++){const r=n[t],c=n[t+1];for(let h=0;h<e.length-1;h++)if(Bl(r,c,e[h],e[h+1]))return!0}return!1}function Bl(n,e,t,r){return Kt(n,t,r)!==Kt(e,t,r)&&Kt(n,e,t)!==Kt(n,e,r)}function Nl(n,e,t){return(n.x-t.x)*(e.y-t.y)-(n.y-t.y)*(e.x-t.x)}function Uc(n,e,t,r){const c=Nl(n,e,r),h=Nl(n,e,t);if(Math.sign(c)===Math.sign(h))return;const f=Nl(t,r,n),_=f+h-c;return Math.sign(f)!==Math.sign(_)?[f/(f-_),h/(h-c)]:void 0}function ga(n,e,t){const r=t*t;if(e.length===1)return n.distSqr(e[0])<r;for(let c=1;c<e.length;c++)if(Ho(n,e[c-1],e[c])<r)return!0;return!1}function Ho(n,e,t){const r=e.distSqr(t);if(r===0)return n.distSqr(e);const c=((n.x-e.x)*(t.x-e.x)+(n.y-e.y)*(t.y-e.y))/r;return n.distSqr(c<0?e:c>1?t:t.sub(e)._mult(c)._add(e))}function jc(n,e){let t,r,c,h=!1;for(let f=0;f<n.length;f++){t=n[f];for(let _=0,g=t.length-1;_<t.length;g=_++)r=t[_],c=t[g],r.y>e.y!=c.y>e.y&&e.x<(c.x-r.x)*(e.y-r.y)/(c.y-r.y)+r.x&&(h=!h)}return h}function ns(n,e){let t=!1;for(let r=0,c=n.length-1;r<n.length;c=r++){const h=n[r],f=n[c];h.y>e.y!=f.y>e.y&&e.x<(f.x-h.x)*(e.y-h.y)/(f.y-h.y)+h.x&&(t=!t)}return t}function Xa(n,e,t,r,c){for(const f of n)if(e<=f.x&&t<=f.y&&r>=f.x&&c>=f.y)return!0;const h=[new it(e,t),new it(e,c),new it(r,c),new it(r,t)];if(n.length>2){for(const f of h)if(ns(n,f))return!0}for(let f=0;f<n.length-1;f++)if(Ya(n[f],n[f+1],h))return!0;return!1}function Ya(n,e,t){const r=t[0],c=t[2];if(n.x<r.x&&e.x<r.x||n.x>c.x&&e.x>c.x||n.y<r.y&&e.y<r.y||n.y>c.y&&e.y>c.y)return!1;const h=Kt(n,e,t[0]);return h!==Kt(n,e,t[1])||h!==Kt(n,e,t[2])||h!==Kt(n,e,t[3])}function Ka(n,e,t,r,c,h){let f=e.y-n.y,_=n.x-e.x;if(h=h||0){const g=f*f+_*_;if(g===0)return!0;const b=Math.sqrt(g);f/=b,_/=b}return!((t.x-n.x)*f+(t.y-n.y)*_-h<0||(r.x-n.x)*f+(r.y-n.y)*_-h<0||(c.x-n.x)*f+(c.y-n.y)*_-h<0)}function uf(n,e,t,r,c,h,f){return!(Ka(n,e,r,c,h,f)||Ka(e,t,r,c,h,f)||Ka(t,n,r,c,h,f)||Ka(r,c,n,e,t,f)||Ka(c,h,n,e,t,f)||Ka(h,r,n,e,t,f))}function Gc(n,e,t){const r=e.paint.get(n).value;return r.kind==="constant"?r.value:t.programConfigurations.get(e.id).getMaxValue(n)}function hx(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1])}function dE(n,e,t,r,c){if(!e[0]&&!e[1])return n;const h=it.convert(e)._mult(c);t==="viewport"&&h._rotate(-r);const f=[];for(let _=0;_<n.length;_++)f.push(n[_].sub(h));return f}function fE(n,e,t,r){const c=it.convert(n)._mult(r);return e==="viewport"&&c._rotate(-t),c}let pE,mE;wt(Bi,"CircleBucket",{omit:["layers"]});class Th{constructor(e,t,r){this.z=e,this.x=t,this.y=r,this.key=hf(0,e,e,t,r)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}isChildOf(e){const t=this.z-e.z;return e.z===0||e.z<this.z&&e.x===this.x>>t&&e.y===this.y>>t}url(e,t){const r=function(h,f,_){const g=2**_,b=2*Math.PI*6378137,S=b*(h/g-.5),I=b*(.5-(f+1)/g);return`${S},${I},${S+b/g},${I+b/g}`}(this.x,this.y,this.z),c=function(h,f,_){let g,b="";for(let S=h;S>0;S--)g=1<<S-1,b+=(f&g?1:0)+(_&g?2:0);return b}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(t==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",c).replace("{bbox-epsg-3857}",r)}toString(){return`${this.z}/${this.x}/${this.y}`}}class _E{constructor(e,t){this.wrap=e,this.canonical=t,this.key=hf(e,t.z,t.z,t.x,t.y)}}class Xr{constructor(e,t,r,c,h){this.overscaledZ=e,this.wrap=t,this.canonical=new Th(r,+c,+h),this.key=t===0&&e===r?this.canonical.key:hf(t,e,r,c,h)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new Xr(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Xr(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return hf(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-e;return hf(this.wrap*+t,e,e,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Xr(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,r=2*this.canonical.x,c=2*this.canonical.y;return[new Xr(t,this.wrap,t,r,c),new Xr(t,this.wrap,t,r+1,c),new Xr(t,this.wrap,t,r,c+1),new Xr(t,this.wrap,t,r+1,c+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Xr(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Xr(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new _E(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function hf(n,e,t,r,c){const h=1<<Math.min(t,22);let f=h*(c%h)+r%h;return n&&t<22&&(f+=h*h*((n<0?-2*n-1:2*n)%(1<<2*(22-t)))),16*(32*f+t)+(e-t)}const vF=[n=>{let e=n.canonical.x-1,t=n.wrap;return e<0&&(e=(1<<n.canonical.z)-1,t--),new Xr(n.overscaledZ,t,n.canonical.z,e,n.canonical.y)},n=>{let e=n.canonical.x+1,t=n.wrap;return e===1<<n.canonical.z&&(e=0,t++),new Xr(n.overscaledZ,t,n.canonical.z,e,n.canonical.y)},n=>new Xr(n.overscaledZ,n.wrap,n.canonical.z,n.canonical.x,(n.canonical.y===0?1<<n.canonical.z:n.canonical.y)-1),n=>new Xr(n.overscaledZ,n.wrap,n.canonical.z,n.canonical.x,n.canonical.y===(1<<n.canonical.z)-1?0:n.canonical.y+1)];wt(Th,"CanonicalTileID"),wt(Xr,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const bF=pi([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:dx}=bF,gE=pi([{name:"a_pos_3",components:3,type:"Int16"}]);var Km=pi([{name:"a_pos",type:"Int16",components:2}]);function fx(n){return n*ne/fe}const wF=[new Li([le,le,le],[_e,_e,_e]),new Li([le,le,le],[0,0,_e]),new Li([0,le,le],[_e,0,_e]),new Li([le,0,le],[0,_e,_e]),new Li([0,0,le],[_e,_e,_e])];function yE(n,e,t,r=!0){const c=mi([],n._camera.position,n.worldSize),h=[e,t,1,1];vr(h,h,n.pixelMatrixInverse),nd(h,h,1/h[3]);const f=zi([],Ln([],h,c)),_=n.globeMatrix,g=[_[12],_[13],_[14]],b=Ln([],g,c),S=Wn(b),I=zi([],b),A=n.worldSize/(2*Math.PI),M=pn(I,f),D=Math.asin(A/S);if(D<Math.acos(M)){if(!r)return null;const he=[],de=[];mi(he,f,S/M),zi(de,Ln(de,he,b)),zi(f,Pt(f,b,mi(f,de,Math.tan(D)*S)))}const z=[];new fi(c,f).closestPointOnSphere(g,A,z);const B=zi([],Ni(_,0)),V=zi([],Ni(_,1)),Z=zi([],Ni(_,2)),G=pn(B,z),Y=pn(V,z),Q=pn(Z,z),te=_r(Math.asin(-Y/A));let me=_r(Math.atan2(G,Q));me=n.center.lng+function(he,de){const Be=(de-he+180)%360-180;return Be<-180?Be+360:Be}(n.center.lng,me);const ce=Je(me),pe=q(tt(te),0,1);return new Et(ce,pe)}class TF{constructor(e,t,r){this.a=Ln([],e,r),this.b=Ln([],t,r),this.center=r;const c=zi([],this.a),h=zi([],this.b);this.angle=Math.acos(pn(c,h))}}function Z1(n,e){if(n.angle===0)return null;let t;return t=n.a[e]===0?1/n.angle*.5*Math.PI:1/n.angle*Math.atan(n.b[e]/n.a[e]/Math.sin(n.angle)-1/Math.tan(n.angle)),t<0||t>1?null:function(r,c,h,f){const _=Math.sin(h);return r*(Math.sin((1-f)*h)/_)+c*(Math.sin(f*h)/_)}(n.a[e],n.b[e],n.angle,q(t,0,1))+n.center[e]}function Ja(n){if(n.z<=1)return wF[n.z+2*n.y+n.x];const e=q1(px(n));return Li.fromPoints(e)}function Vl(n,e,t){return mi(n,n,1-t),rn(n,n,e,t)}function xE(n,e){const t=Ul(e.zoom);if(t===0)return Ja(n);const r=px(n),c=q1(r),h=Je(r.getWest())*e.worldSize,f=Je(r.getEast())*e.worldSize,_=tt(r.getNorth())*e.worldSize,g=tt(r.getSouth())*e.worldSize,b=[h,_,0],S=[f,_,0],I=[h,g,0],A=[f,g,0],M=Se([],e.globeMatrix);return mn(b,b,M),mn(S,S,M),mn(I,I,M),mn(A,A,M),c[0]=Vl(c[0],I,t),c[1]=Vl(c[1],A,t),c[2]=Vl(c[2],S,t),c[3]=Vl(c[3],b,t),Li.fromPoints(c)}function vE(n,e,t){for(const r of n)mn(r,r,e),mi(r,r,t)}function bE(n,e,t,r){const c=e/n.worldSize,h=n.globeMatrix;if(t.z<=1){const pe=Ja(t).getCorners();return vE(pe,h,c),Li.fromPoints(pe)}const f=px(t,r),_=q1(f,ne+fx(n._tileCoverLift));vE(_,h,c);const g=Number.MAX_VALUE,b=[-g,-g,-g],S=[g,g,g];if(f.contains(n.center)){for(const de of _)Ut(S,S,de),ii(b,b,de);b[2]=0;const pe=n.point,he=[pe.x*c,pe.y*c,0];return Ut(S,S,he),ii(b,b,he),new Li(S,b)}if(n._tileCoverLift>0){for(const pe of _)Ut(S,S,pe),ii(b,b,pe);return new Li(S,b)}const I=[h[12]*c,h[13]*c,h[14]*c],A=f.getCenter(),M=q(n.center.lat,-85.051129,$e),D=q(A.lat,-85.051129,$e),z=Je(n.center.lng),B=tt(M);let V=z-Je(A.lng);const Z=B-tt(D);V>.5?V-=1:V<-.5&&(V+=1);let G=0;Math.abs(V)>Math.abs(Z)?G=V>=0?1:3:(G=Z>=0?0:2,rn(I,I,[h[4]*c,h[5]*c,h[6]*c],-Math.sin(Ei(Z>=0?f.getSouth():f.getNorth()))*ne));const Y=_[G],Q=_[(G+1)%4],te=new TF(Y,Q,I),me=[Z1(te,0)||Y[0],Z1(te,1)||Y[1],Z1(te,2)||Y[2]],ce=Ul(n.zoom);if(ce>0){const pe=function({x:de,y:Be,z:je},He,Xe,Ze,nt){const Fe=1/(1<<je);let We=de*Fe,Qe=We+Fe,st=Be*Fe,ut=st+Fe,bt=0;const mt=(We+Qe)/2-Ze;return mt>.5?bt=-1:mt<-.5&&(bt=1),We=((We+bt)*He-(Ze*=He))*Xe+Ze,Qe=((Qe+bt)*He-Ze)*Xe+Ze,st=(st*He-(nt*=He))*Xe+nt,ut=(ut*He-nt)*Xe+nt,[[We,ut,0],[Qe,ut,0],[Qe,st,0],[We,st,0]]}(t,e,n._pixelsPerMercatorPixel,z,B);for(let de=0;de<_.length;de++)Vl(_[de],pe[de],ce);const he=Pt([],pe[G],pe[(G+1)%4]);mi(he,he,.5),Vl(me,he,ce)}for(const pe of _)Ut(S,S,pe),ii(b,b,pe);return S[2]=Math.min(Y[2],Q[2]),Ut(S,S,me),ii(b,b,me),new Li(S,b)}function px({x:n,y:e,z:t},r=!1){const c=1/(1<<t),h=new ve(we(n*c),e===(1<<t)-1&&r?-90:Oe((e+1)*c)),f=new ve(we((n+1)*c),e===0&&r?90:Oe(e*c));return new Ne(h,f)}function q1(n,e=ne){const t=Ei(n.getNorth()),r=Ei(n.getSouth()),c=Math.cos(t),h=Math.cos(r),f=Math.sin(t),_=Math.sin(r),g=n.getWest(),b=n.getEast();return[re(h,_,g,e),re(h,_,b,e),re(c,f,b,e),re(c,f,g,e)]}function Jm(n,e,t,r){const c=1<<t.z,h=(n/_t+t.x)/c;return ae(Oe((e/_t+t.y)/c),we(h),r)}function mx({min:n,max:e}){return 16383/Math.max(e[0]-n[0],e[1]-n[1],e[2]-n[2])}const wE=new Float64Array(16);function Qm(n){const e=mx(n),t=Tt(wE,[e,e,e]);return Ie(t,t,lo([],n.min))}function W1(n){const e=function(r,c){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=c[0],r[13]=c[1],r[14]=c[2],r[15]=1,r}(wE,n.min),t=1/mx(n);return qe(e,e,[t,t,t])}function X1(n){const e=_t/(2*Math.PI);return n/(2*Math.PI)/e}function TE(n,e){return _t/(512*Math.pow(2,n))*mx(Ja(e))}function SE(n,e,t,r,c){const h=X1(t),f=[n,e,-t/(2*Math.PI)],_=Ye(new Float64Array(16));return Ie(_,_,f),qe(_,_,[h,h,h]),ot(_,_,Ei(-c)),xt(_,_,Ei(-r)),_}function Ul(n){return oe(5,6,n)}function EE(n,e){const t=ae(e.lat,e.lng),r=function(D){const z=ae(D._center.lat,D._center.lng);let B=On([],ji(0,1,0),z);const V=li([],-D.angle,z);B=mn(B,B,V),li(V,-D._pitch,B);const Z=zi([],z);return mi(Z,Z,fx(D.cameraToCenterDistance/D.pixelsPerMeter)),mn(Z,Z,V),Pt([],z,Z)}(n);return f=(c=$t([],r,t))[0],_=c[1],g=c[2],b=(h=t)[0],S=h[1],I=h[2],M=(A=Math.sqrt((f*f+_*_+g*g)*(b*b+S*S+I*I)))&&pn(c,h)/A,Math.acos(Math.min(Math.max(M,-1),1));var c,h,f,_,g,b,S,I,A,M}function Y1(n,e){return EE(n,e)>Math.PI/2*1.01}const IE=Ei(85),SF=Math.cos(IE),EF=Math.sin(IE),IF=Ve(),AE=n=>{const e=[];return n.paint.get("circle-pitch-alignment")==="map"&&e.push("PITCH_WITH_MAP"),n.paint.get("circle-pitch-scale")==="map"&&e.push("SCALE_WITH_MAP"),e};function CE(n,e,t,r,c,h,f,_,g){if(h&&n.queryGeometry.isAboveHorizon)return!1;h&&(g*=n.pixelToTileUnitsFactor);const b=n.tileID.canonical,S=t.projection.upVectorScale(b,t.center.lat,t.worldSize).metersToTile;for(const I of e)for(const A of I){const M=A.add(_),D=c&&t.elevation?t.elevation.exaggeration()*c.getElevationAt(M.x,M.y,!0):0,z=t.projection.projectTilePoint(M.x,M.y,b);if(D>0){const G=t.projection.upVector(b,M.x,M.y);z.x+=G[0]*S*D,z.y+=G[1]*S*D,z.z+=G[2]*S*D}const B=h?M:AF(z.x,z.y,z.z,r),V=h?n.tilespaceRays.map(G=>PF(G,D)):n.queryGeometry.screenGeometry,Z=vr([],[z.x,z.y,z.z,1],r);if(!f&&h?g*=Z[3]/t.cameraToCenterDistance:f&&!h&&(g*=t.cameraToCenterDistance/Z[3]),h){const G=Oe((A.y/_t+b.y)/(1<<b.z));g/=t.projection.pixelsPerMeter(G,1)/Pe(1,G)}if(kr(V,B,g))return!0}return!1}function AF(n,e,t,r){const c=vr([],[n,e,t,1],r);return new it(c[0]/c[3],c[1]/c[3])}const PE=ji(0,0,0),CF=ji(0,0,1);function PF(n,e){const t=gi();return PE[2]=e,n.intersectsPlane(PE,CF,t),new it(t[0],t[1])}class ME extends Bi{}let RE,DE,LE,zE;function kE(n,{width:e,height:t},r,c){if(c){if(c instanceof Uint8ClampedArray)c=new Uint8Array(c.buffer);else if(c.length!==e*t*r)throw new RangeError("mismatched image size")}else c=new Uint8Array(e*t*r);return n.width=e,n.height=t,n.data=c,n}function FE(n,e,t){const{width:r,height:c}=e;r===n.width&&c===n.height||(K1(n,e,{x:0,y:0},{x:0,y:0},{width:Math.min(n.width,r),height:Math.min(n.height,c)},t,null),n.width=r,n.height=c,n.data=e.data)}function K1(n,e,t,r,c,h,f,_){if(c.width===0||c.height===0)return e;if(c.width>n.width||c.height>n.height||t.x>n.width-c.width||t.y>n.height-c.height)throw new RangeError("out of range source coordinates for image copy");if(c.width>e.width||c.height>e.height||r.x>e.width-c.width||r.y>e.height-c.height)throw new RangeError("out of range destination coordinates for image copy");const g=n.data,b=e.data,S=h===4&&_;for(let I=0;I<c.height;I++){const A=((t.y+I)*n.width+t.x)*h,M=((r.y+I)*e.width+r.x)*h;if(S)for(let D=0;D<c.width;D++){const z=A+D*h+3,B=M+D*h;b[B+0]=255,b[B+1]=255,b[B+2]=255,b[B+3]=g[z]}else if(f)for(let D=0;D<c.width;D++){const z=A+D*h,B=M+D*h,V=new Ii(g[z+0]/255,g[z+1]/255,g[z+2]/255,g[z+3]).toNonPremultipliedRenderColor(f).toArray();b[B+0]=V[0],b[B+1]=V[1],b[B+2]=V[2],b[B+3]=V[3]}else for(let D=0;D<c.width*h;D++)b[M+D]=g[A+D]}return e}wt(ME,"HeatmapBucket",{omit:["layers"]});class $c{constructor(e,t){kE(this,e,1,t)}resize(e){FE(this,new $c(e),1)}clone(){return new $c({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,r,c,h){K1(e,t,r,c,h,1,null)}}class Fr{constructor(e,t){kE(this,e,4,t)}resize(e){FE(this,new Fr(e),4)}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new Fr({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,r,c,h,f,_){K1(e,t,r,c,h,4,f,_)}}class OE{constructor(e,t){this.width=e.width,this.height=e.height,this.data=t instanceof Uint8Array?new Float32Array(t.buffer):t}}function e_(n){const e={},t=n.resolution||256,r=n.clips?n.clips.length:1,c=n.image||new Fr({width:t,height:r}),h=(f,_,g)=>{e[n.evaluationKey]=g;const b=n.expression.evaluate(e),S=b?b.toNonPremultipliedRenderColor(null):null;S&&(c.data[f+_+0]=Math.floor(255*S.r),c.data[f+_+1]=Math.floor(255*S.g),c.data[f+_+2]=Math.floor(255*S.b),c.data[f+_+3]=Math.floor(255*S.a))};if(n.clips)for(let f=0,_=0;f<r;++f,_+=4*t)for(let g=0,b=0;g<t;g++,b+=4){const S=g/(t-1),{start:I,end:A}=n.clips[f];h(_,b,I*(1-S)+A*S)}else for(let f=0,_=0;f<t;f++,_+=4)h(0,_,f/(t-1));return c}wt($c,"AlphaImage"),wt(Fr,"RGBAImage");const MF=pi([{name:"a_pos",components:2,type:"Int16"}],4),RF=pi([{name:"a_road_z_offset",components:1,type:"Float32"}],4),DF=pi([{name:"a_pos",components:2,type:"Int16"},{name:"a_height",components:1,type:"Float32"}],4),LF=pi([{name:"a_pos_normal_3",components:3,type:"Int16"}],4);function df(n,e,t=2){const r=e&&e.length,c=r?e[0]*t:n.length;let h=BE(n,0,c,t,!0);const f=[];if(!h||h.next===h.prev)return f;let _,g,b;if(r&&(h=function(S,I,A,M){const D=[];for(let z=0,B=I.length;z<B;z++){const V=BE(S,I[z]*M,z<B-1?I[z+1]*M:S.length,M,!1);V===V.next&&(V.steiner=!0),D.push(UF(V))}D.sort(BF);for(let z=0;z<D.length;z++)A=NF(D[z],A);return A}(n,e,h,t)),n.length>80*t){_=n[0],g=n[1];let S=_,I=g;for(let A=t;A<c;A+=t){const M=n[A],D=n[A+1];M<_&&(_=M),D<g&&(g=D),M>S&&(S=M),D>I&&(I=D)}b=Math.max(S-_,I-g),b=b!==0?32767/b:0}return t_(h,f,t,_,g,b,0),f}function BE(n,e,t,r,c){let h;if(c===function(f,_,g,b){let S=0;for(let I=_,A=g-b;I<g;I+=b)S+=(f[A]-f[I])*(f[I+1]+f[A+1]),A=I;return S}(n,e,t,r)>0)for(let f=e;f<t;f+=r)h=jE(f/r|0,n[f],n[f+1],h);else for(let f=t-r;f>=e;f-=r)h=jE(f/r|0,n[f],n[f+1],h);return h&&ff(h,h.next)&&(r_(h),h=h.next),h}function Sh(n,e){if(!n)return n;e||(e=n);let t,r=n;do if(t=!1,r.steiner||!ff(r,r.next)&&lr(r.prev,r,r.next)!==0)r=r.next;else{if(r_(r),r=e=r.prev,r===r.next)break;t=!0}while(t||r!==e);return e}function t_(n,e,t,r,c,h,f){if(!n)return;!f&&h&&function(g,b,S,I){let A=g;do A.z===0&&(A.z=J1(A.x,A.y,b,S,I)),A.prevZ=A.prev,A.nextZ=A.next,A=A.next;while(A!==g);A.prevZ.nextZ=null,A.prevZ=null,function(M){let D,z=1;do{let B,V=M;M=null;let Z=null;for(D=0;V;){D++;let G=V,Y=0;for(let te=0;te<z&&(Y++,G=G.nextZ,G);te++);let Q=z;for(;Y>0||Q>0&&G;)Y!==0&&(Q===0||!G||V.z<=G.z)?(B=V,V=V.nextZ,Y--):(B=G,G=G.nextZ,Q--),Z?Z.nextZ=B:M=B,B.prevZ=Z,Z=B;V=G}Z.nextZ=null,z*=2}while(D>1)}(A)}(n,r,c,h);let _=n;for(;n.prev!==n.next;){const g=n.prev,b=n.next;if(h?kF(n,r,c,h):zF(n))e.push(g.i,n.i,b.i),r_(n),n=b.next,_=b.next;else if((n=b)===_){f?f===1?t_(n=FF(Sh(n),e),e,t,r,c,h,2):f===2&&OF(n,e,t,r,c,h):t_(Sh(n),e,t,r,c,h,1);break}}}function zF(n){const e=n.prev,t=n,r=n.next;if(lr(e,t,r)>=0)return!1;const c=e.x,h=t.x,f=r.x,_=e.y,g=t.y,b=r.y,S=Math.min(c,h,f),I=Math.min(_,g,b),A=Math.max(c,h,f),M=Math.max(_,g,b);let D=r.next;for(;D!==e;){if(D.x>=S&&D.x<=A&&D.y>=I&&D.y<=M&&i_(c,_,h,g,f,b,D.x,D.y)&&lr(D.prev,D,D.next)>=0)return!1;D=D.next}return!0}function kF(n,e,t,r){const c=n.prev,h=n,f=n.next;if(lr(c,h,f)>=0)return!1;const _=c.x,g=h.x,b=f.x,S=c.y,I=h.y,A=f.y,M=Math.min(_,g,b),D=Math.min(S,I,A),z=Math.max(_,g,b),B=Math.max(S,I,A),V=J1(M,D,e,t,r),Z=J1(z,B,e,t,r);let G=n.prevZ,Y=n.nextZ;for(;G&&G.z>=V&&Y&&Y.z<=Z;){if(G.x>=M&&G.x<=z&&G.y>=D&&G.y<=B&&G!==c&&G!==f&&i_(_,S,g,I,b,A,G.x,G.y)&&lr(G.prev,G,G.next)>=0||(G=G.prevZ,Y.x>=M&&Y.x<=z&&Y.y>=D&&Y.y<=B&&Y!==c&&Y!==f&&i_(_,S,g,I,b,A,Y.x,Y.y)&&lr(Y.prev,Y,Y.next)>=0))return!1;Y=Y.nextZ}for(;G&&G.z>=V;){if(G.x>=M&&G.x<=z&&G.y>=D&&G.y<=B&&G!==c&&G!==f&&i_(_,S,g,I,b,A,G.x,G.y)&&lr(G.prev,G,G.next)>=0)return!1;G=G.prevZ}for(;Y&&Y.z<=Z;){if(Y.x>=M&&Y.x<=z&&Y.y>=D&&Y.y<=B&&Y!==c&&Y!==f&&i_(_,S,g,I,b,A,Y.x,Y.y)&&lr(Y.prev,Y,Y.next)>=0)return!1;Y=Y.nextZ}return!0}function FF(n,e){let t=n;do{const r=t.prev,c=t.next.next;!ff(r,c)&&VE(r,t,t.next,c)&&n_(r,c)&&n_(c,r)&&(e.push(r.i,t.i,c.i),r_(t),r_(t.next),t=n=c),t=t.next}while(t!==n);return Sh(t)}function OF(n,e,t,r,c,h){let f=n;do{let _=f.next.next;for(;_!==f.prev;){if(f.i!==_.i&&jF(f,_)){let g=UE(f,_);return f=Sh(f,f.next),g=Sh(g,g.next),t_(f,e,t,r,c,h,0),void t_(g,e,t,r,c,h,0)}_=_.next}f=f.next}while(f!==n)}function BF(n,e){let t=n.x-e.x;return t===0&&(t=n.y-e.y,t===0)&&(t=(n.next.y-n.y)/(n.next.x-n.x)-(e.next.y-e.y)/(e.next.x-e.x)),t}function NF(n,e){const t=function(c,h){let f=h;const _=c.x,g=c.y;let b,S=-1/0;if(ff(c,f))return f;do{if(ff(c,f.next))return f.next;if(g<=f.y&&g>=f.next.y&&f.next.y!==f.y){const z=f.x+(g-f.y)*(f.next.x-f.x)/(f.next.y-f.y);if(z<=_&&z>S&&(S=z,b=f.x<f.next.x?f:f.next,z===_))return b}f=f.next}while(f!==h);if(!b)return null;const I=b,A=b.x,M=b.y;let D=1/0;f=b;do{if(_>=f.x&&f.x>=A&&_!==f.x&&NE(g<M?_:S,g,A,M,g<M?S:_,g,f.x,f.y)){const z=Math.abs(g-f.y)/(_-f.x);n_(f,c)&&(z<D||z===D&&(f.x>b.x||f.x===b.x&&VF(b,f)))&&(b=f,D=z)}f=f.next}while(f!==I);return b}(n,e);if(!t)return e;const r=UE(t,n);return Sh(r,r.next),Sh(t,t.next)}function VF(n,e){return lr(n.prev,n,e.prev)<0&&lr(e.next,n,n.next)<0}function J1(n,e,t,r,c){return(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-t)*c|0)|n<<8))|n<<4))|n<<2))|n<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*c|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function UF(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function NE(n,e,t,r,c,h,f,_){return(c-f)*(e-_)>=(n-f)*(h-_)&&(n-f)*(r-_)>=(t-f)*(e-_)&&(t-f)*(h-_)>=(c-f)*(r-_)}function i_(n,e,t,r,c,h,f,_){return!(n===f&&e===_)&&NE(n,e,t,r,c,h,f,_)}function jF(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!function(t,r){let c=t;do{if(c.i!==t.i&&c.next.i!==t.i&&c.i!==r.i&&c.next.i!==r.i&&VE(c,c.next,t,r))return!0;c=c.next}while(c!==t);return!1}(n,e)&&(n_(n,e)&&n_(e,n)&&function(t,r){let c=t,h=!1;const f=(t.x+r.x)/2,_=(t.y+r.y)/2;do c.y>_!=c.next.y>_&&c.next.y!==c.y&&f<(c.next.x-c.x)*(_-c.y)/(c.next.y-c.y)+c.x&&(h=!h),c=c.next;while(c!==t);return h}(n,e)&&(lr(n.prev,n,e.prev)||lr(n,e.prev,e))||ff(n,e)&&lr(n.prev,n,n.next)>0&&lr(e.prev,e,e.next)>0)}function lr(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function ff(n,e){return n.x===e.x&&n.y===e.y}function VE(n,e,t,r){const c=gx(lr(n,e,t)),h=gx(lr(n,e,r)),f=gx(lr(t,r,n)),_=gx(lr(t,r,e));return c!==h&&f!==_||!(c!==0||!_x(n,t,e))||!(h!==0||!_x(n,r,e))||!(f!==0||!_x(t,n,r))||!(_!==0||!_x(t,e,r))}function _x(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function gx(n){return n>0?1:n<0?-1:0}function n_(n,e){return lr(n.prev,n,n.next)<0?lr(n,e,n.next)>=0&&lr(n,n.prev,e)>=0:lr(n,e,n.prev)<0||lr(n,n.next,e)<0}function UE(n,e){const t=Q1(n.i,n.x,n.y),r=Q1(e.i,e.x,e.y),c=n.next,h=e.prev;return n.next=e,e.prev=n,t.next=c,c.prev=t,r.next=t,t.prev=r,h.next=r,r.prev=h,r}function jE(n,e,t,r){const c=Q1(n,e,t);return r?(c.next=r.next,c.prev=r,r.next.prev=c,r.next=c):(c.prev=c,c.next=c),c}function r_(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Q1(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function s_(n,e){const t=n.length;if(t<=1)return[n];const r=[];let c,h;for(let f=0;f<t;f++){const _=hi(n[f]);_!==0&&(n[f].area=Math.abs(_),h===void 0&&(h=_<0),h===_<0?(c&&r.push(c),c=[n[f]]):c.push(n[f]))}if(c&&r.push(c),e>1)for(let f=0;f<r.length;f++)r[f].length<=e||(sy(r[f],e,1,r[f].length-1,GF),r[f]=r[f].slice(0,e));return r}function GF(n,e){return e.area-n.area}function GE(n,e,t=1){if(!n)return null;const r=typeof n=="string"?is.from(n).getPrimary():n.getPrimary(),c=typeof n=="string"?null:n.getSecondary();for(const h of[r,c]){if(!h)continue;const f=h.id.toString();e.has(f)||e.set(f,[]),h.scaleSelf(t),e.get(f).push(h)}return{primary:r.toString(),secondary:c?c.toString():null}}function eb(n,e,t,r){const c=r.patternDependencies;let h=!1;for(const f of e){const _=f.paint.get(`${n}-pattern`);_.isConstant()||(h=!0),GE(_.constantOr(null),c,t)&&(h=!0)}return h}function tb(n,e,t,r,c,h){const f=h.patternDependencies;for(const _ of e){const g=_.paint.get(`${n}-pattern`).value;if(g.kind!=="constant"){const b=GE(g.evaluate({zoom:r},t,{},void 0,h.availableImages),f,c);if(!b)continue;const{primary:S,secondary:I}=b;S&&(t.patterns[_.id]=[S,I].filter(Boolean))}}return t}class jl{constructor(){this.portals=[]}static isOnBorder(e,t){return e<=0&&t<=0||e>=_t&&t>=_t}static evaluate(e){if(e.length===0)return new jl;let t=[];for(const g of e)t.push(...g.portals);if(t.length===0)return new jl;for(const g of t){const b=g.va,S=g.vb;(jl.isOnBorder(b.x,S.x)||jl.isOnBorder(b.y,S.y))&&(g.type="border")}const r=t.filter(g=>g.type!=="unevaluated"),c=t.filter(g=>g.type==="unevaluated");if(c.length===0)return new jl;c.sort((g,b)=>g.hash===b.hash?g.isTunnel===b.isTunnel?0:g.isTunnel?-1:1:g.hash<b.hash?1:-1),t=r.concat(c);let h=r.length,f=h,_=h;do if(f++,f===t.length||t[h].hash!==t[f].hash){if(f-h===2){_<h&&(t[_]=t[h],t[h]=null);const g=t[_],b=t[f-1];g.type=g.isTunnel!==b.isTunnel?"tunnel":"polygon",g.connection={a:g.connection.a,b:b.connection.a},_++}h=f}while(h!==t.length);return t.splice(_),t.sort((g,b)=>g.hash<b.hash?1:-1),{portals:t}}}wt(jl,"ElevationPortalGraph");class $F{constructor(e,t,r){this.outPositions=e,this.outNormals=t,this.outIndices=r,this.vertexLookup=new Map}addVertex(e,t,r){let c=e[2];r!=null&&(c*=r);const h=`${e[0]},${e[1]},${e[2]},${t[0]},${t[1]},${t[2]}`,f=this.vertexLookup.get(h);if(f!=null)return f;const _=this.outPositions.length;this.vertexLookup.set(h,_);const g=Math.trunc(16384*t[0]),b=Math.trunc(16384*t[1]),S=Math.trunc(16384*t[2]);return this.outPositions.emplaceBack(e[0],e[1],c),this.outNormals.emplaceBack(g,b,S),_}addTriangle(e,t,r){this.outIndices.emplaceBack(e,t,r)}addTriangles(e,t,r){if(e.length===0)return;const c=r.length===1,h=gi(),f=gi();for(let _=0;_<e.length;_+=3){const g=t[e[_+0]],b=t[e[_+1]],S=t[e[_+2]],I=c?r[0]:r[e[_+1]],A=c?r[0]:r[e[_+2]];ti(h,g.x,g.y,c?r[0]:r[e[_+0]]);const M=this.addVertex(h,f);ti(h,b.x,b.y,I);const D=this.addVertex(h,f);ti(h,S.x,S.y,A);const z=this.addVertex(h,f);this.outIndices.emplaceBack(M,D,z)}}addQuad(e,t,r,c,h,f){const _=this.addVertex(e,h,f),g=this.addVertex(t,h,f),b=this.addVertex(r,h,f),S=this.addVertex(c,h,f);this.addTriangle(_,g,b),this.addTriangle(b,S,_)}getVertexCount(){return this.outPositions.length}clearVertexLookup(){this.vertexLookup.clear()}}class ks{constructor(e,t,r,c){this.unevaluatedPortals=new jl,this.bridgeFeatureSections=[],this.tunnelFeatureSections=[],this.vertexHashLookup=new Map,this.unevalVertices=[],this.unevalHeights=[],this.unevalTriangles=[],this.unevalTunnelTriangles=[],this.unevalEdges=[],this.vertexPositions=new zm,this.vertexNormals=new km,this.indexArray=new Tn,this.tileToMeters=et(e),this.bridgeProgramConfigurations=new N(t,{zoom:r,lut:c},h=>h!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new N(t,{zoom:r,lut:c},h=>h!=="fill-bridge-guard-rail-color")}addVertices(e,t){const r=this.unevalVertices.length;for(let c=0;c<e.length;c++)this.unevalVertices.push(e[c]),this.unevalHeights.push(t[c]);return r}addTriangles(e,t,r){const c=r?this.unevalTunnelTriangles:this.unevalTriangles;for(const h of e)c.push(h+t)}addRenderableRing(e,t,r,c,h,f){const _=[new it(h.min.x,h.min.y),new it(h.max.x,h.min.y),new it(h.max.x,h.max.y),new it(h.min.x,h.max.y)];for(let g=0;g<r-1;g++){const b=t+g,S=b+1,I=this.unevalVertices[b],A=this.unevalVertices[S];if(!(I.x>=h.min.x&&I.x<=h.max.x&&I.y>=h.min.y&&I.y<=h.max.y||A.x>=h.min.x&&A.x<=h.max.x&&A.y>=h.min.y&&A.y<=h.max.y||Ya(I,A,_))||this.isOnBorder(I.x,A.x)||this.isOnBorder(I.y,A.y))continue;const M=ks.computeEdgeHash(this.unevalVertices[b],this.unevalVertices[S]);let D,z=this.vertexHashLookup.get(ks.computePosHash(I));z!=null?D=z.next:(z=this.vertexHashLookup.get(ks.computePosHash(A)),D=z!=null?z.prev:M),this.unevalEdges.push({polygonIdx:e,a:b,b:S,hash:M,portalHash:D,isTunnel:c,type:"unevaluated",featureInfo:f})}}addPortalCandidates(e,t,r,c,h){if(t.length!==0){this.vertexHashLookup.clear();for(const f of t){if(f.length===0)continue;const _=f[0];let g=ks.computeEdgeHash(_[_.length-2],_[_.length-1]);for(let b=0;b<_.length-1;b++){const S=_[b+0],I=_[b+1],A=Do(I.x-S.x,I.y-S.y),M=pl(A);if(M===0)continue;let D="unevaluated";const z=c.pointElevation(S),B=c.pointElevation(I);Math.abs(z)<.01&&Math.abs(B)<.01?D="entrance":(this.isOnBorder(S.x,I.x)||this.isOnBorder(S.y,I.y))&&(D="border");const V=ks.computeEdgeHash(S,I);this.unevaluatedPortals.portals.push({connection:{a:e,b:void 0},va:S,vb:I,vab:A,length:M,hash:V,isTunnel:r,type:D});const Z=ks.computePosHash(S);this.vertexHashLookup.set(Z,{prev:g,next:V}),g=V}}}}construct(e){if(this.unevalVertices.length===0)return;const t=()=>({vertexOffset:0,primitiveOffset:this.indexArray.length}),r=A=>{A.primitiveLength=this.indexArray.length-A.primitiveOffset},c=new $F(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const h=t(),f=t(),_=t(),g=(A,M)=>{A.sort((z,B)=>z.type===M&&B.type!==M?-1:z.type!==M&&B.type===M?1:0);const D=A.findIndex(z=>z.type!==M);return D>=0?D:A.length};let b=0;this.unevalEdges.length>0&&(b=g(this.unevalEdges,"none"),this.constructBridgeStructures(c,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:b},this.tileToMeters)),r(_);const S=t(),I=t();if(this.unevalEdges.length>0){const A=this.unevalEdges.splice(b),M=g(A,"tunnel")+b;this.unevalEdges.push(...A),this.constructTunnelStructures(c,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:b},{min:b,max:M})}r(S),c.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),r(I),c.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),r(f),c.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),r(h),this.maskSegments=$i.simpleSegment(0,I.primitiveOffset,0,I.primitiveLength),this.depthSegments=$i.simpleSegment(0,f.primitiveOffset,0,f.primitiveLength),this.renderableBridgeSegments=$i.simpleSegment(0,_.primitiveOffset,0,_.primitiveLength),this.renderableTunnelSegments=$i.simpleSegment(0,S.primitiveOffset,0,S.primitiveLength),this.shadowCasterSegments=$i.simpleSegment(0,h.primitiveOffset,0,h.primitiveLength)}update(e,t,r,c,h,f,_,g){this.bridgeProgramConfigurations.updatePaintArrays(e,t,h,r,c,f,_,g),this.tunnelProgramConfigurations.updatePaintArrays(e,t,h,r,c,f,_,g)}upload(e){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,DF.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,LF.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(e),this.tunnelProgramConfigurations.upload(e))}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy()}populatePaintArrays(e,t,r,c,h){const f=(_,g)=>{for(let b=0;b<g.length-1;b++){const S=g[b].featureIndex,I=g[b+1].vertexStart,A=e.feature(S);_.populatePaintArrays(I,A,S,{},r,t,c,void 0,h)}};f(this.bridgeProgramConfigurations,this.bridgeFeatureSections),f(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(e,t,r,c,h){const f=new Map;for(let _=c;_<h;_++){const g=r[_],b=g.a,S=g.b,I=ks.computePosHash(e[b]),A=ks.computePosHash(e[S]);let M=f.get(I);M||(M={},f.set(I,M));let D=f.get(A);D||(D={},f.set(A,D)),t[b]<=0&&t[S]<=0||(M.to=S,D.from=b)}return f}isTerminalVertex(e,t){const r=ks.computePosHash(this.unevalVertices[e]),c=t.get(r);return!c||!c.from||!c.to}constructBridgeStructures(e,t,r,c,h,f){e.clearVertexLookup();const _=this.computeVertexConnections(t,r,c,h.min,h.max),g=1/f,b=.5*g,S=(Xe,Ze)=>ti(Xe,t[Ze].x,t[Ze].y,r[Ze]*g),I=gi(),A=gi(),M=gi(),D=gi(),z=gi(),B=(Xe,Ze)=>{const nt=_.get(ks.computePosHash(t[Ze])),Fe=nt.from,We=nt.to;if(!Fe||!We)return;S(I,Fe),S(A,Ze),S(M,We),cc(D),Hs(I,A)||(Ln(z,A,I),zi(D,z)),Hs(M,A)||(Ln(z,M,A),Pt(D,D,zi(z,z)));const Qe=La(D);return Qe>0?mi(Xe,D,1/Qe):void 0};let V=Number.POSITIVE_INFINITY;this.sortSubarray(c,h.min,h.max,(Xe,Ze)=>Xe.featureInfo.featureIndex-Ze.featureInfo.featureIndex);const Z=gi(),G=gi(),Y=gi(),Q=gi(),te=gi(),me=gi(),ce=gi(),pe=gi(),he=gi(),de=[gi(),gi(),gi(),gi()],Be=[gi(),gi(),gi(),gi()],je=[{coord:new it(0,0),height:0},{coord:new it(0,0),height:0}],He=(Xe,Ze)=>Xe>Ze;for(let Xe=h.min;Xe<h.max;Xe++){const Ze=c[Xe];if(!Ze.featureInfo.guardRailEnabled||!this.prepareEdgePoints(je,t,r,Ze,He))continue;const[nt,Fe]=je;if(ti(Z,nt.coord.x,nt.coord.y,g*nt.height),ti(G,Fe.coord.x,Fe.coord.y,g*Fe.height),Hs(Z,G))continue;Ln(Y,G,Z),zi(Y,Y);const We=B(pe,Ze.a)||Y,Qe=B(he,Ze.b)||Y;ti(Q,We[1],-We[0],0),zi(Q,Q),ti(te,Qe[1],-Qe[0],0),zi(te,te),On(pe,Q,We),zi(me,pe),On(pe,te,Qe),zi(ce,pe),Pt(de[0],Z,mi(pe,Ln(pe,Q,me),b)),Pt(de[1],Z,mi(pe,Pt(pe,Q,me),b)),Pt(de[2],Z,mi(pe,me,b)),de[3]=Z,Pt(Be[0],G,mi(pe,Ln(pe,te,ce),b)),Pt(Be[1],G,mi(pe,Pt(pe,te,ce),b)),Pt(Be[2],G,mi(pe,ce,b)),Be[3]=G,V=this.addFeatureSection(Ze.featureInfo.featureIndex,V,this.bridgeFeatureSections,e);const st=e.addVertex(de[0],Q,f),ut=e.addVertex(de[1],Q,f),bt=e.addVertex(Be[0],te,f),mt=e.addVertex(Be[1],te,f);e.addTriangle(st,ut,bt),e.addTriangle(ut,mt,bt);const pt=e.addVertex(de[1],me,f),ht=e.addVertex(de[2],me,f),yt=e.addVertex(Be[1],ce,f),It=e.addVertex(Be[2],ce,f);e.addTriangle(pt,ht,yt),e.addTriangle(ht,It,yt),lo(Q,Q),lo(te,te);const kt=e.addVertex(de[2],Q,f),Ct=e.addVertex(de[3],Q,f),Qt=e.addVertex(Be[2],te,f),vi=e.addVertex(Be[3],te,f);e.addTriangle(kt,Ct,Qt),e.addTriangle(Ct,vi,Qt);const ei=this.isTerminalVertex(Ze.a,_),wi=this.isTerminalVertex(Ze.b,_);nt.height<.01&&ei&&e.addQuad(de[3],de[2],de[1],de[0],lo(We,We),f),Fe.height<.01&&wi&&e.addQuad(Be[0],Be[1],Be[2],Be[3],Qe,f)}this.bridgeFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}constructTunnelStructures(e,t,r,c,h,f){e.clearVertexLookup();let _=Number.POSITIVE_INFINITY;const g=(V,Z)=>V.featureInfo.featureIndex-Z.featureInfo.featureIndex;this.sortSubarray(c,h.min,h.max,g),this.sortSubarray(c,f.min,f.max,g);const b=V=>zi(V,V),S=[{coord:new it(0,0),height:0},{coord:new it(0,0),height:0}],I=(V,Z)=>V<Z,A=gi(),M=gi(),D=gi(),z=gi(),B=gi();for(let V=h.min;V<h.max;V++){if(!this.prepareEdgePoints(S,t,r,c[V],I))continue;const[Z,G]=S,Y=b(ti(B,-(G.coord.y-Z.coord.y),G.coord.x-Z.coord.x,0));_=this.addFeatureSection(c[V].featureInfo.featureIndex,_,this.tunnelFeatureSections,e),e.addQuad(ti(A,Z.coord.x,Z.coord.y,Z.height),ti(M,G.coord.x,G.coord.y,G.height),ti(D,G.coord.x,G.coord.y,c[V].isTunnel?-.1:0),ti(z,Z.coord.x,Z.coord.y,c[V].isTunnel?-.1:0),Y)}for(let V=f.min;V<f.max;V++){const Z=c[V];Z.isTunnel&&([Z.a,Z.b]=[Z.b,Z.a]);const G=t[Z.a],Y=t[Z.b],Q=b(ti(B,-(Y.y-G.y),Y.x-G.x,0));_=this.addFeatureSection(Z.featureInfo.featureIndex,_,this.tunnelFeatureSections,e),e.addQuad(ti(A,Y.x,Y.y,0),ti(M,G.x,G.y,0),ti(D,G.x,G.y,r[Z.a]+4),ti(z,Y.x,Y.y,r[Z.b]+4),Q),e.addQuad(ti(A,G.x,G.y,0),ti(M,Y.x,Y.y,0),ti(D,Y.x,Y.y,r[Z.b]+4),ti(z,G.x,G.y,r[Z.a]+4),Q)}this.tunnelFeatureSections.push({featureIndex:Number.POSITIVE_INFINITY,vertexStart:e.getVertexCount()})}setElevatedPoint(e,t,r,c){e.coord.x=t,e.coord.y=r,e.height=c}prepareEdgePoints(e,t,r,c,h){let f=t[c.a].x,_=t[c.a].y,g=t[c.b].x,b=t[c.b].y,S=r[c.a],I=r[c.b];const A=h(S,0),M=h(I,0);if(A&&M)return this.setElevatedPoint(e[0],f,_,S),this.setElevatedPoint(e[1],g,b,I),!0;if(!A&&!M)return!1;if(A){if(!M){const D=I/(I-S);g=Gt(g,f,D),b=Gt(b,_,D),I=Gt(I,S,D)}}else{const D=S/(S-I);f=Gt(f,g,D),_=Gt(_,b,D),S=Gt(S,I,D)}return this.setElevatedPoint(e[0],f,_,S),this.setElevatedPoint(e[1],g,b,I),!0}prepareEdges(e,t){if(t.length===0)return;t.sort((_,g)=>_.hash===g.hash?g.polygonIdx-_.polygonIdx:g.hash>_.hash?1:-1);let r=0,c=0,h=0,f=t[r].polygonIdx;do c++,(c===t.length||t[r].hash!==t[c].hash)&&((c-r===1||t[c-1].polygonIdx!==f)&&(h<r&&(t[h]=t[r],t[r]=null),t[h].type="none",h++),r=c,r!==t.length&&(f=t[r].polygonIdx));while(r!==t.length);if(t.splice(h),t.length!==0&&e.length!==0){t.sort((b,S)=>b.portalHash<S.portalHash?1:-1);let _=0,g=0;for(;_!==t.length&&g!==e.length;){const b=t[_],S=e[g];b.portalHash>S.hash?_++:S.hash>b.portalHash?g++:(b.type=S.type,_++)}}}isOnBorder(e,t){return e<=0&&t<=0||e>=_t&&t>=_t}addFeatureSection(e,t,r,c){return e!==t&&(t=e,r.push({featureIndex:e,vertexStart:c.getVertexCount()}),c.clearVertexLookup()),t}sortSubarray(e,t,r,c){const h=e.slice(t,r);h.sort(c),e.splice(t,h.length,...h)}static computeEdgeHash(e,t){return(e.y===t.y&&e.x>t.x||e.y>t.y)&&([e,t]=[t,e]),BigInt(ks.computePosHash(e))<<32n|BigInt(ks.computePosHash(t))}static computePosHash(e){return((65535&e.x)<<16|65535&e.y)>>>0}}function HF(n,e){return n>e?1:n<e?-1:0}class ib{constructor(e=HF,t=!1){this._compare=e,this._root=null,this._size=0,this._noDuplicates=!!t}rotateLeft(e){var t=e.right;t&&(e.right=t.left,t.left&&(t.left.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.left=e),e.parent=t}rotateRight(e){var t=e.left;t&&(e.left=t.right,t.right&&(t.right.parent=e),t.parent=e.parent),e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.right=e),e.parent=t}_splay(e){for(;e.parent;){var t=e.parent;t.parent?t.left===e&&t.parent.left===t?(this.rotateRight(t.parent),this.rotateRight(t)):t.right===e&&t.parent.right===t?(this.rotateLeft(t.parent),this.rotateLeft(t)):t.left===e&&t.parent.right===t?(this.rotateRight(t),this.rotateLeft(t)):(this.rotateLeft(t),this.rotateRight(t)):t.left===e?this.rotateRight(t):this.rotateLeft(t)}}splay(e){for(var t,r,c,h,f;e.parent;)(r=(t=e.parent).parent)&&r.parent?((c=r.parent).left===r?c.left=e:c.right=e,e.parent=c):(e.parent=null,this._root=e),h=e.left,f=e.right,e===t.left?(r&&(r.left===t?(t.right?(r.left=t.right,r.left.parent=r):r.left=null,t.right=r,r.parent=t):(h?(r.right=h,h.parent=r):r.right=null,e.left=r,r.parent=e)),f?(t.left=f,f.parent=t):t.left=null,e.right=t,t.parent=e):(r&&(r.right===t?(t.left?(r.right=t.left,r.right.parent=r):r.right=null,t.left=r,r.parent=t):(f?(r.left=f,f.parent=r):r.left=null,e.right=r,r.parent=e)),h?(t.right=h,h.parent=t):t.right=null,e.left=t,t.parent=e)}replace(e,t){e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.parent=e.parent)}minNode(e=this._root){if(e)for(;e.left;)e=e.left;return e}maxNode(e=this._root){if(e)for(;e.right;)e=e.right;return e}insert(e,t){var r=this._root,c=null,h=this._compare;if(this._noDuplicates)for(;r;){if(c=r,h(r.key,e)===0)return;r=h(r.key,e)<0?r.right:r.left}else for(;r;)c=r,r=h(r.key,e)<0?r.right:r.left;return r={key:e,data:t,left:null,right:null,parent:c},c?h(c.key,r.key)<0?c.right=r:c.left=r:this._root=r,this.splay(r),this._size++,r}find(e){for(var t=this._root,r=this._compare;t;){var c=r(t.key,e);if(c<0)t=t.right;else{if(!(c>0))return t;t=t.left}}return null}contains(e){for(var t=this._root,r=this._compare;t;){var c=r(e,t.key);if(c===0)return!0;t=c<0?t.left:t.right}return!1}remove(e){var t=this.find(e);if(!t)return!1;if(this.splay(t),t.left)if(t.right){var r=this.minNode(t.right);r.parent!==t&&(this.replace(r,r.right),r.right=t.right,r.right.parent=r),this.replace(t,r),r.left=t.left,r.left.parent=r}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}removeNode(e){if(!e)return!1;if(this.splay(e),e.left)if(e.right){var t=this.minNode(e.right);t.parent!==e&&(this.replace(t,t.right),t.right=e.right,t.right.parent=t),this.replace(e,t),t.left=e.left,t.left.parent=t}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var t=this.find(e);if(t){this.splay(t);var r=t.left,c=t.right,h=null;r&&(r.parent=null,h=this.maxNode(r),this.splay(h),this._root=h),c&&(r?h.right=c:this._root=c,c.parent=h),this._size--}}pop(){var e=this._root,t=null;if(e){for(;e.left;)e=e.left;t={key:e.key,data:e.data},this.remove(e.key)}return t}next(e){var t=e;if(t)if(t.right)for(t=t.right;t&&t.left;)t=t.left;else for(t=e.parent;t&&t.right===e;)e=t,t=t.parent;return t}prev(e){var t=e;if(t)if(t.left)for(t=t.left;t&&t.right;)t=t.right;else for(t=e.parent;t&&t.left===e;)e=t,t=t.parent;return t}forEach(e){for(var t=this._root,r=[],c=!1,h=0;!c;)t?(r.push(t),t=t.left):r.length>0?(e(t=r.pop(),h++),t=t.right):c=!0;return this}range(e,t,r,c){const h=[],f=this._compare;let _,g=this._root;for(;h.length!==0||g;)if(g)h.push(g),g=g.left;else{if(g=h.pop(),_=f(g.key,t),_>0)break;if(f(g.key,e)>=0&&r.call(c,g))return this;g=g.right}return this}keys(){for(var e=this._root,t=[],r=[],c=!1;!c;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),r.push(e.key),e=e.right):c=!0;return r}values(){for(var e=this._root,t=[],r=[],c=!1;!c;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),r.push(e.data),e=e.right):c=!0;return r}at(e){for(var t=this._root,r=[],c=!1,h=0;!c;)if(t)r.push(t),t=t.left;else if(r.length>0){if(t=r.pop(),h===e)return t;h++,t=t.right}else c=!0;return null}load(e=[],t=[],r=!1){if(this._size!==0)throw new Error("bulk-load: tree is not empty");const c=e.length;return r&&rb(e,t,0,c-1,this._compare),this._root=nb(null,e,t,0,c),this._size=c,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return this._root===null}get size(){return this._size}static createTree(e,t,r,c,h){return new ib(r,h).load(e,t,c)}}function nb(n,e,t,r,c){const h=c-r;if(h>0){const f=r+Math.floor(h/2),_={key:e[f],data:t[f],parent:n};return _.left=nb(_,e,t,r,f),_.right=nb(_,e,t,f+1,c),_}return null}function rb(n,e,t,r,c){if(t>=r)return;const h=n[t+r>>1];let f=t-1,_=r+1;for(;;){do f++;while(c(n[f],h)<0);do _--;while(c(n[_],h)>0);if(f>=_)break;let g=n[f];n[f]=n[_],n[_]=g,g=e[f],e[f]=e[_],e[_]=g}rb(n,e,t,_,c),rb(n,e,_+1,r,c)}const $E=11102230246251565e-32,ys=134217729,ZF=(3+8*$E)*$E;function sb(n,e,t,r,c){let h,f,_,g,b=e[0],S=r[0],I=0,A=0;S>b==S>-b?(h=b,b=e[++I]):(h=S,S=r[++A]);let M=0;if(I<n&&A<t)for(S>b==S>-b?(f=b+h,_=h-(f-b),b=e[++I]):(f=S+h,_=h-(f-S),S=r[++A]),h=f,_!==0&&(c[M++]=_);I<n&&A<t;)S>b==S>-b?(f=h+b,g=f-h,_=h-(f-g)+(b-g),b=e[++I]):(f=h+S,g=f-h,_=h-(f-g)+(S-g),S=r[++A]),h=f,_!==0&&(c[M++]=_);for(;I<n;)f=h+b,g=f-h,_=h-(f-g)+(b-g),b=e[++I],h=f,_!==0&&(c[M++]=_);for(;A<t;)f=h+S,g=f-h,_=h-(f-g)+(S-g),S=r[++A],h=f,_!==0&&(c[M++]=_);return h===0&&M!==0||(c[M++]=h),M}function o_(n){return new Float64Array(n)}const pf=o_(4),HE=o_(8),ZE=o_(12),qE=o_(16),Fs=o_(4);function a_(n,e,t){e===null?(n.inOut=!1,n.otherInOut=!0):(n.isSubject===e.isSubject?(n.inOut=!e.inOut,n.otherInOut=e.otherInOut):(n.inOut=!e.otherInOut,n.otherInOut=e.isVertical()?!e.inOut:e.inOut),e&&(n.prevInResult=!WE(e,t)||e.isVertical()?e.prevInResult:e)),n.resultTransition=WE(n,t)?function(r,c){let h,f=!r.inOut,_=!r.otherInOut;switch(c){case 0:h=f&&_;break;case 1:h=f||_;break;case 3:h=f!==_;break;case 2:h=r.isSubject?f&&!_:_&&!f}return h?1:-1}(n,t):0}function WE(n,e){switch(n.type){case 0:switch(e){case 0:return!n.otherInOut;case 1:return n.otherInOut;case 2:return n.isSubject&&n.otherInOut||!n.isSubject&&!n.otherInOut;case 3:return!0}break;case 2:return e===0||e===1;case 3:return e===2;case 1:return!1}return!1}class mf{constructor(e,t,r,c,h){this.left=t,this.point=e,this.otherEvent=r,this.isSubject=c??!1,this.type=h||0,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0}isBelow(e){const t=this.point,r=this.otherEvent.point;return this.left?(t[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(t[1]-e[1])>0:(r[0]-e[0])*(t[1]-e[1])-(t[0]-e[0])*(r[1]-e[1])>0}isAbove(e){return!this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return this.resultTransition!==0}clone(){const e=new mf(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function Qa(n,e){return n[0]===e[0]&&n[1]===e[1]}function ob(n,e,t){const r=function(c,h,f,_,g,b){const S=(h-b)*(f-g),I=(c-g)*(_-b),A=S-I;if(S===0||I===0||S>0!=I>0)return A;const M=Math.abs(S+I);return Math.abs(A)>=33306690738754716e-32*M?A:-function(D,z,B,V,Z,G,Y){let Q,te,me,ce,pe,he,de,Be,je,He,Xe,Ze,nt,Fe,We,Qe,st,ut;const bt=D-Z,mt=B-Z,pt=z-G,ht=V-G;Fe=bt*ht,he=ys*bt,de=he-(he-bt),Be=bt-de,he=ys*ht,je=he-(he-ht),He=ht-je,We=Be*He-(Fe-de*je-Be*je-de*He),Qe=pt*mt,he=ys*pt,de=he-(he-pt),Be=pt-de,he=ys*mt,je=he-(he-mt),He=mt-je,st=Be*He-(Qe-de*je-Be*je-de*He),Xe=We-st,pe=We-Xe,pf[0]=We-(Xe+pe)+(pe-st),Ze=Fe+Xe,pe=Ze-Fe,nt=Fe-(Ze-pe)+(Xe-pe),Xe=nt-Qe,pe=nt-Xe,pf[1]=nt-(Xe+pe)+(pe-Qe),ut=Ze+Xe,pe=ut-Ze,pf[2]=Ze-(ut-pe)+(Xe-pe),pf[3]=ut;let yt=function(vi,ei){let wi=ei[0];for(let ai=1;ai<4;ai++)wi+=ei[ai];return wi}(0,pf),It=22204460492503146e-32*Y;if(yt>=It||-yt>=It||(pe=D-bt,Q=D-(bt+pe)+(pe-Z),pe=B-mt,me=B-(mt+pe)+(pe-Z),pe=z-pt,te=z-(pt+pe)+(pe-G),pe=V-ht,ce=V-(ht+pe)+(pe-G),Q===0&&te===0&&me===0&&ce===0)||(It=11093356479670487e-47*Y+ZF*Math.abs(yt),yt+=bt*ce+ht*Q-(pt*me+mt*te),yt>=It||-yt>=It))return yt;Fe=Q*ht,he=ys*Q,de=he-(he-Q),Be=Q-de,he=ys*ht,je=he-(he-ht),He=ht-je,We=Be*He-(Fe-de*je-Be*je-de*He),Qe=te*mt,he=ys*te,de=he-(he-te),Be=te-de,he=ys*mt,je=he-(he-mt),He=mt-je,st=Be*He-(Qe-de*je-Be*je-de*He),Xe=We-st,pe=We-Xe,Fs[0]=We-(Xe+pe)+(pe-st),Ze=Fe+Xe,pe=Ze-Fe,nt=Fe-(Ze-pe)+(Xe-pe),Xe=nt-Qe,pe=nt-Xe,Fs[1]=nt-(Xe+pe)+(pe-Qe),ut=Ze+Xe,pe=ut-Ze,Fs[2]=Ze-(ut-pe)+(Xe-pe),Fs[3]=ut;const kt=sb(4,pf,4,Fs,HE);Fe=bt*ce,he=ys*bt,de=he-(he-bt),Be=bt-de,he=ys*ce,je=he-(he-ce),He=ce-je,We=Be*He-(Fe-de*je-Be*je-de*He),Qe=pt*me,he=ys*pt,de=he-(he-pt),Be=pt-de,he=ys*me,je=he-(he-me),He=me-je,st=Be*He-(Qe-de*je-Be*je-de*He),Xe=We-st,pe=We-Xe,Fs[0]=We-(Xe+pe)+(pe-st),Ze=Fe+Xe,pe=Ze-Fe,nt=Fe-(Ze-pe)+(Xe-pe),Xe=nt-Qe,pe=nt-Xe,Fs[1]=nt-(Xe+pe)+(pe-Qe),ut=Ze+Xe,pe=ut-Ze,Fs[2]=Ze-(ut-pe)+(Xe-pe),Fs[3]=ut;const Ct=sb(kt,HE,4,Fs,ZE);Fe=Q*ce,he=ys*Q,de=he-(he-Q),Be=Q-de,he=ys*ce,je=he-(he-ce),He=ce-je,We=Be*He-(Fe-de*je-Be*je-de*He),Qe=te*me,he=ys*te,de=he-(he-te),Be=te-de,he=ys*me,je=he-(he-me),He=me-je,st=Be*He-(Qe-de*je-Be*je-de*He),Xe=We-st,pe=We-Xe,Fs[0]=We-(Xe+pe)+(pe-st),Ze=Fe+Xe,pe=Ze-Fe,nt=Fe-(Ze-pe)+(Xe-pe),Xe=nt-Qe,pe=nt-Xe,Fs[1]=nt-(Xe+pe)+(pe-Qe),ut=Ze+Xe,pe=ut-Ze,Fs[2]=Ze-(ut-pe)+(Xe-pe),Fs[3]=ut;const Qt=sb(Ct,ZE,4,Fs,qE);return qE[Qt-1]}(c,h,f,_,g,b,M)}(n[0],n[1],e[0],e[1],t[0],t[1]);return r>0?-1:r<0?1:0}function Hc(n,e){const t=n.point,r=e.point;return t[0]>r[0]?1:t[0]<r[0]?-1:t[1]!==r[1]?t[1]>r[1]?1:-1:function(c,h,f){return c.left!==h.left?c.left?1:-1:ob(f,c.otherEvent.point,h.otherEvent.point)!==0?c.isBelow(h.otherEvent.point)?-1:1:!c.isSubject&&h.isSubject?1:-1}(n,e,t)}function Zc(n,e,t){const r=new mf(e,!1,n,n.isSubject),c=new mf(e,!0,n.otherEvent,n.isSubject);return Qa(n.point,n.otherEvent.point)&&console.warn("what is that, a collapsed segment?",n),r.contourId=c.contourId=n.contourId,Hc(c,n.otherEvent)>0&&(n.otherEvent.left=!0,c.left=!1),n.otherEvent.otherEvent=c,n.otherEvent=r,t.push(c),t.push(r),t}function yx(n,e){return n[0]*e[1]-n[1]*e[0]}function ab(n,e){return n[0]*e[0]+n[1]*e[1]}function lb(n,e,t){const r=function(g,b,S,I){const A=[b[0]-g[0],b[1]-g[1]],M=[I[0]-S[0],I[1]-S[1]];function D(me,ce,pe){return[me[0]+ce*pe[0],me[1]+ce*pe[1]]}const z=[S[0]-g[0],S[1]-g[1]];let B=yx(A,M),V=B*B;const Z=ab(A,A);if(V>0){const me=yx(z,M)/B;if(me<0||me>1)return null;const ce=yx(z,A)/B;return ce<0||ce>1?null:me===0||me===1?[D(g,me,A)]:ce===0||ce===1?[D(S,ce,M)]:[D(g,me,A)]}if(B=yx(z,A),V=B*B,V>0)return null;const G=ab(A,z)/Z,Y=G+ab(A,M)/Z,Q=Math.min(G,Y),te=Math.max(G,Y);return Q<=1&&te>=0?Q===1?[D(g,Q>0?Q:0,A)]:te===0?[D(g,te<1?te:1,A)]:[D(g,Q>0?Q:0,A),D(g,te<1?te:1,A)]:null}(n.point,n.otherEvent.point,e.point,e.otherEvent.point),c=r?r.length:0;if(c===0||c===1&&(Qa(n.point,e.point)||Qa(n.otherEvent.point,e.otherEvent.point))||c===2&&n.isSubject===e.isSubject)return 0;if(c===1)return!Qa(n.point,r[0])&&!Qa(n.otherEvent.point,r[0])&&Zc(n,r[0],t),!Qa(e.point,r[0])&&!Qa(e.otherEvent.point,r[0])&&Zc(e,r[0],t),1;const h=[];let f=!1,_=!1;return Qa(n.point,e.point)?f=!0:Hc(n,e)===1?h.push(e,n):h.push(n,e),Qa(n.otherEvent.point,e.otherEvent.point)?_=!0:Hc(n.otherEvent,e.otherEvent)===1?h.push(e.otherEvent,n.otherEvent):h.push(n.otherEvent,e.otherEvent),f&&_||f?(e.type=1,n.type=e.inOut===n.inOut?2:3,f&&!_&&Zc(h[1].otherEvent,h[0].point,t),2):_?(Zc(h[0],h[1].point,t),3):h[0]!==h[3].otherEvent?(Zc(h[0],h[1].point,t),Zc(h[1],h[2].point,t),3):(Zc(h[0],h[1].point,t),Zc(h[3].otherEvent,h[2].point,t),3)}function qF(n,e){if(n===e)return 0;if(ob(n.point,n.otherEvent.point,e.point)!==0||ob(n.point,n.otherEvent.point,e.otherEvent.point)!==0)return Qa(n.point,e.point)?n.isBelow(e.otherEvent.point)?-1:1:n.point[0]===e.point[0]?n.point[1]<e.point[1]?-1:1:Hc(n,e)===1?e.isAbove(n.point)?-1:1:n.isBelow(e.point)?-1:1;if(n.isSubject!==e.isSubject)return n.isSubject?-1:1;{let t=n.point,r=e.point;if(t[0]===r[0]&&t[1]===r[1])return t=n.otherEvent.point,r=e.otherEvent.point,t[0]===r[0]&&t[1]===r[1]?0:(n.contourId??0)>(e.contourId??0)?1:-1}return Hc(n,e)===1?1:-1}class WF{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null}isExterior(){return this.holeOf==null}}function XF(n,e,t,r){let c,h=n+1,f=e[n].point;const _=e.length;for(h<_&&(c=e[h].point);h<_&&c[0]===f[0]&&c[1]===f[1];){if(!t[h])return h;h++,h<_&&(c=e[h].point)}for(h=n-1;t[h]&&h>r;)h--;return h}function YF(n,e,t){const r=new WF;if(n.prevInResult!=null){const c=n.prevInResult,h=c.outputContourId;if(c.resultTransition>0){const f=e[h];if(f.holeOf!=null){const _=f.holeOf;e[_].holeIds.push(t),r.holeOf=_,r.depth=e[h].depth}else e[h].holeIds.push(t),r.holeOf=h,r.depth=e[h].depth+1}else r.holeOf=null,r.depth=e[h].depth}else r.holeOf=null,r.depth=0;return r}const XE=Math.max,YE=Math.min;let xx=0;function KE(n,e,t,r,c,h){let f,_,g,b,S,I;for(f=0,_=n.length-1;f<_;f++){if(g=n[f],b=n[f+1],S=new mf(g,!1,void 0,e),I=new mf(b,!1,S,e),S.otherEvent=I,g[0]===b[0]&&g[1]===b[1])continue;S.contourId=I.contourId=t,h||(S.isExteriorRing=!1,I.isExteriorRing=!1),Hc(S,I)>0?I.left=!0:S.left=!0;const A=g[0],M=g[1];c[0]=YE(c[0],A),c[1]=YE(c[1],M),c[2]=XE(c[2],A),c[3]=XE(c[3],M),r.push(S),r.push(I)}}const vx=[];function JE(n,e,t){let r=n,c=e;typeof n[0][0][0]=="number"&&(r=[n]),typeof e[0][0][0]=="number"&&(c=[e]);let h=function(A,M,D){let z=null;return A.length*M.length===0&&(D===0?z=vx:D===2?z=A:(D===1||D===3)&&(z=A.length===0?M:A)),z}(r,c,t);if(h)return h===vx?null:h;const f=[1/0,1/0,-1/0,-1/0],_=[1/0,1/0,-1/0,-1/0],g=function(A,M,D,z,B){const V=new Hu(void 0,Hc);let Z,G,Y,Q,te,me;for(Y=0,Q=A.length;Y<Q;Y++)for(Z=A[Y],te=0,me=Z.length;te<me;te++)G=te===0,G&&xx++,KE(Z[te],!0,xx,V,D,G);for(Y=0,Q=M.length;Y<Q;Y++)for(Z=M[Y],te=0,me=Z.length;te<me;te++)G=te===0,B===2&&(G=!1),G&&xx++,KE(Z[te],!1,xx,V,z,G);return V}(r,c,f,_,t);if(h=function(A,M,D,z,B){let V=null;return(D[0]>z[2]||z[0]>D[2]||D[1]>z[3]||z[1]>D[3])&&(B===0?V=vx:B===2?V=A:(B===1||B===3)&&(V=A.concat(M))),V}(r,c,f,_,t),h)return h===vx?null:h;const b=function(A,M,D,z,B,V){const Z=new ib(qF),G=[],Y=Math.min(z[2],B[2]);let Q,te,me;for(;A.length!==0;){let ce=A.pop();if(G.push(ce),V===0&&ce.point[0]>Y||V===2&&ce.point[0]>z[2])break;if(ce.left){te=Q=Z.insert(ce),me=Z.minNode(),Q=Q!==me?Z.prev(Q):null,te=Z.next(te);const pe=Q?Q.key:null;let he;if(a_(ce,pe,V),te&&lb(ce,te.key,A)===2&&(a_(ce,pe,V),a_(te.key,ce,V)),Q&&lb(Q.key,ce,A)===2){let de=Q;de=de!==me?Z.prev(de):null,he=de?de.key:null,a_(pe,he,V),a_(ce,pe,V)}}else ce=ce.otherEvent,te=Q=Z.find(ce),Q&&te&&(Q=Q!==me?Z.prev(Q):null,te=Z.next(te),Z.remove(ce),te&&Q&&lb(Q.key,te.key,A))}return G}(g,0,0,f,_,t),S=function(A){let M,D;const z=function(Z){let G,Y,Q,te,me;const ce=[];for(Y=0,Q=Z.length;Y<Q;Y++)G=Z[Y],(G.left&&G.inResult||!G.left&&G.otherEvent.inResult)&&ce.push(G);let pe=!1;for(;!pe;)for(pe=!0,Y=0,Q=ce.length;Y<Q;Y++)Y+1<Q&&Hc(ce[Y],ce[Y+1])===1&&(te=ce[Y],ce[Y]=ce[Y+1],ce[Y+1]=te,pe=!1);for(Y=0,Q=ce.length;Y<Q;Y++)G=ce[Y],G.otherPos=Y;for(Y=0,Q=ce.length;Y<Q;Y++)G=ce[Y],G.left||(me=G.otherPos,G.otherPos=G.otherEvent.otherPos,G.otherEvent.otherPos=me);return ce}(A),B={},V=[];for(M=0,D=z.length;M<D;M++){if(B[M])continue;const Z=V.length,G=YF(z[M],V,Z),Y=me=>{B[me]=!0,me<z.length&&z[me]&&(z[me].outputContourId=Z)};let Q=M,te=M;for(G.points.push(z[M].point);Y(Q),Q=z[Q].otherPos,Y(Q),G.points.push(z[Q].point),Q=XF(Q,z,B,te),!(Q==te||Q>=z.length)&&z[Q];);V.push(G)}return V}(b),I=[];for(let A=0;A<S.length;A++){let M=S[A];if(M.isExterior()){let D=[M.points];for(let z=0;z<M.holeIds.length;z++)D.push(S[M.holeIds[z]].points);I.push(D)}}return I}function bx(n,e,t,r){const c=[],h=r===0?(f,_,g,b,S,I)=>{f.push(new it(I,g+(I-_)/(b-_)*(S-g)))}:(f,_,g,b,S,I)=>{f.push(new it(_+(I-g)/(S-g)*(b-_),I))};for(const f of n){const _=[];for(const g of f){if(g.length<=2)continue;const b=[];for(let A=0;A<g.length-1;A++){const M=g[A].x,D=g[A].y,z=g[A+1].x,B=g[A+1].y,V=r===0?M:D,Z=r===0?z:B;V<e?Z>e&&h(b,M,D,z,B,e):V>t?Z<t&&h(b,M,D,z,B,t):b.push(g[A]),Z<e&&V>=e&&h(b,M,D,z,B,e),Z>t&&V<=t&&h(b,M,D,z,B,t)}let S=g[g.length-1];const I=r===0?S.x:S.y;I>=e&&I<=t&&b.push(S),b.length&&(S=b[b.length-1],b[0].x===S.x&&b[0].y===S.y||b.push(b[0]),_.push(b))}_.length&&c.push(_)}return c}function KF(n,e){const t=JE(cb(n),cb([e]),0);return t==null?[]:QE(t)}function JF(n,e,t=0){let c=cb(n,65536);const h=[];for(;e.valid();e.next()){const[f,_]=e.get();let g=f.x*65536,b=f.y*65536,S=_.x*65536,I=_.y*65536;const A=S-g,M=I-b,D=Math.hypot(A,M);if(D===0)continue;g-=A*t,b-=M*t,S+=A*t,I+=M*t;const z=Math.trunc(M/D*3),B=-Math.trunc(A/D*3);h.push([[[g,b],[S,I],[S+z,I+B],[g+z,b+B],[g,b]]])}return h.length>0&&(c=JE(c,h,2)),QE(c,1/65536,128)}function cb(n,e=1){return[n.map(t=>t.map(r=>[r.x*e,r.y*e]))]}function QE(n,e=1,t){return n.map(r=>r.map((c,h)=>{const f=c.map(_=>{let g=_[0],b=_[1];return t&&(g=Math.round(g/t)*t,b=Math.round(b/t)*t),new it(g*e,b*e)._round()});return h>0&&f.reverse(),f}))}class ub{constructor(e,t){this.layoutVertexArray=new ms,this.indexArray=new Tn,this.lineIndexArray=new eo,this.triangleSegments=new $i,this.lineSegments=new $i,this.programConfigurations=new N(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,t&&(this.elevatedLayoutVertexArray=new Rs)}update(e,t,r,c,h,f,_,g){this.programConfigurations.updatePaintArrays(e,t,h,r,c,f,_,g)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,MF.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,RF.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(e,t,r,c,h,f,_){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,r,c,h,f,void 0,_)}}class wx{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new ub(e,!1),this.elevationBufferData=new ub(e,!0),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.projection=e.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=e.sourceLayerIndex,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,r,c){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,c){this.hasPattern=eb("fill",this.layers,this.pixelRatio,t);const h=this.layers[0].layout.get("fill-sort-key"),f=[];for(const{feature:_,id:g,index:b,sourceLayerIndex:S}of e){const I=this.layers[0]._featureFilter.needGeometry,A=oi(_,I);if(!this.layers[0]._featureFilter.filter(new Mi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),A,r))continue;const M=h?h.evaluate(A,{},r,t.availableImages):void 0,D={id:g,properties:_.properties,type:_.type,sourceLayerIndex:S,index:b,geometry:I?A.geometry:Ft(_,r,c),patterns:{},sortKey:M};f.push(D)}h&&f.sort((_,g)=>_.sortKey-g.sortKey);for(const _ of f){const{geometry:g,index:b,sourceLayerIndex:S}=_;if(this.hasPattern){const I=tb("fill",this.layers,_,this.zoom,this.pixelRatio,t);this.patternFeatures.push(I)}else this.addFeature(_,g,b,r,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[b].feature,g,b,S,this.index)}}update(e,t,r,c,h,f,_){this.bufferData.update(e,t,r,c,h,f,_,this.worldview),this.elevationBufferData.update(e,t,r,c,h,f,_,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,t,r,c,h,f,_,this.worldview)}addFeatures(e,t,r,c,h,f){for(const _ of this.patternFeatures)this.addFeature(_,_.geometry,_.index,t,r,c,f,e.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(e){this.bufferData.upload(e),this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(e,t,r,c,h,f=[],_,g){const b=s_(t,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(e,b,c,r,g):this.addGeometry(b,this.bufferData),this.bufferData.populatePaintArrays(e,r,h,f,c,_,this.worldview),this.elevationBufferData.populatePaintArrays(e,r,h,f,c,_,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,t,r,c,h){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,r,c,h,this.worldview))}addElevatedRoadFeature(e,t,r,c,h){const f=new Array,_=Yi.getElevationFeature(e,h);if(!_)return void this.addGeometry(t,this.bufferData);{const b=this.clipPolygonsToTile(t,1);b.length>0&&f.push({polygons:b,elevationFeature:_,elevationTileID:r})}const g={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},r),featureIndex:c};for(const b of f)if(b.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new ks(b.elevationTileID,this.layers,this.zoom,this.lut));const I=b.elevationFeature.isTunnel();let A=0;e.properties.hasOwnProperty(Zi)&&(A=+e.properties[Zi]),this.elevatedStructures.addPortalCandidates(b.elevationFeature.id,b.polygons,I,b.elevationFeature,A)}b.elevationFeature.constantHeight==null&&(b.polygons=this.prepareElevatedPolygons(b.polygons,b.elevationFeature,b.elevationTileID));const S=new Ki(r,b.elevationTileID);this.addElevatedGeometry(b.polygons,S,b.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,c,g)}}addElevatedGeometry(e,t,r,c,h,f){const _={elevation:r,elevationSampler:t,bias:c,index:h,featureInfo:f},[g,b]=this.addGeometry(e,this.elevationBufferData,_);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:g,max:b}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,g),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,b))}addGeometry(e,t,r){let c=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,f=null;r&&(f=r.elevationSampler.constantElevation(r.elevation,r.bias),f!=null&&(c=f,h=f));const _=(g,b,S)=>{if(r!=null)if(b.push(g),f!=null)t.elevatedLayoutVertexArray.emplaceBack(f),S.push(f);else{const I=r.elevationSampler.pointElevation(g,r.elevation,r.bias);t.elevatedLayoutVertexArray.emplaceBack(I),S.push(I),c=Math.min(c,I),h=Math.max(h,I)}};for(const g of e){let b=0;for(const G of g)b+=G.length;const S=t.triangleSegments.prepareSegment(b,t.layoutVertexArray,t.indexArray),I=S.vertexLength,A=[],M=[],D=[],z=[],B=[],V=t.layoutVertexArray.length;for(const G of g){if(G.length===0)continue;G!==g[0]&&M.push(A.length/2);const Y=t.lineSegments.prepareSegment(G.length,t.layoutVertexArray,t.lineIndexArray),Q=Y.vertexLength;r&&B.push(t.layoutVertexArray.length-V),_(G[0],D,z),t.layoutVertexArray.emplaceBack(G[0].x,G[0].y),t.lineIndexArray.emplaceBack(Q+G.length-1,Q),A.push(G[0].x),A.push(G[0].y);for(let te=1;te<G.length;te++)_(G[te],D,z),t.layoutVertexArray.emplaceBack(G[te].x,G[te].y),t.lineIndexArray.emplaceBack(Q+te-1,Q+te),A.push(G[te].x),A.push(G[te].y);Y.vertexLength+=G.length,Y.primitiveLength+=G.length}const Z=df(A,M);for(let G=0;G<Z.length;G+=3)t.indexArray.emplaceBack(I+Z[G],I+Z[G+1],I+Z[G+2]);if(Z.length>0&&r&&this.elevationMode==="hd-road-base"){const G=r.elevation.isTunnel(),Y=r.elevation.safeArea,Q=this.elevatedStructures.addVertices(D,z);this.elevatedStructures.addTriangles(Z,Q,G);const te=B.length;if(te>0){for(let me=0;me<te-1;me++)this.elevatedStructures.addRenderableRing(r.index,B[me]+Q,B[me+1]-B[me],G,Y,r.featureInfo);this.elevatedStructures.addRenderableRing(r.index,B[te-1]+Q,D.length-B[te-1],G,Y,r.featureInfo)}}S.vertexLength+=b,S.primitiveLength+=Z.length/3}return[c,h]}prepareElevatedPolygons(e,t,r){const c=1/et(r),h=[];for(const f of e){const _=JF(f,new Ls(t,c),.1);h.push(..._)}return h}clipPolygonsToTile(e,t){const r=-t,c=-t,h=_t+t,f=_t+t;let _=0;const g=[],b=[];for(;_<e.length;_++){const A=e[_],M=jp(A);(M.min.x>=r&&M.max.x<=h&&M.min.y>=c&&M.max.y<=f?g:b).push(A)}if(g.length===e.length)return e;const S=[new it(r,c),new it(h,c),new it(h,f),new it(r,f),new it(r,c)],I=g;for(const A of b)I.push(...KF(A,S));return I}}let eI,tI,iI,nI;wt(wx,"FillBucket",{omit:["layers","patternFeatures"]}),wt(ub,"FillBufferData"),wt(ks,"ElevatedStructures");class Tx{constructor(e,t,r,c){if(this.triangleCount=t.length/3,this.min=new it(0,0),this.max=new it(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],this.triangleCount===0||e.length===0)return;const[h,f]=[e[0].clone(),e[0].clone()];for(let I=1;I<e.length;++I){const A=e[I];h.x=Math.min(h.x,A.x),h.y=Math.min(h.y,A.y),f.x=Math.max(f.x,A.x),f.y=Math.max(f.y,A.y)}if(c){const I=Math.ceil(Math.max(f.x-h.x,f.y-h.y)/c);r=Math.max(r,I)}if(r===0)return;this.min=h,this.max=f;const _=this.max.sub(this.min);_.x=Math.max(_.x,1),_.y=Math.max(_.y,1);const g=Math.max(_.x,_.y)/r;this.cellsX=Math.max(1,Math.ceil(_.x/g)),this.cellsY=Math.max(1,Math.ceil(_.y/g)),this.xScale=1/g,this.yScale=1/g;const b=[];for(let I=0;I<this.triangleCount;I++){const A=e[t[3*I+0]].sub(this.min),M=e[t[3*I+1]].sub(this.min),D=e[t[3*I+2]].sub(this.min),z=el(Math.floor(Math.min(A.x,M.x,D.x)),this.xScale,this.cellsX),B=el(Math.floor(Math.max(A.x,M.x,D.x)),this.xScale,this.cellsX),V=el(Math.floor(Math.min(A.y,M.y,D.y)),this.yScale,this.cellsY),Z=el(Math.floor(Math.max(A.y,M.y,D.y)),this.yScale,this.cellsY),G=new it(0,0),Y=new it(0,0),Q=new it(0,0),te=new it(0,0);for(let me=V;me<=Z;++me){G.y=Y.y=me*g,Q.y=te.y=(me+1)*g;for(let ce=z;ce<=B;++ce)G.x=Q.x=ce*g,Y.x=te.x=(ce+1)*g,(uf(A,M,D,G,Y,te)||uf(A,M,D,G,te,Q))&&b.push({cellIdx:me*this.cellsX+ce,triIdx:I})}}if(b.length===0)return;b.sort((I,A)=>I.cellIdx-A.cellIdx||I.triIdx-A.triIdx);let S=0;for(;S<b.length;){const I=b[S].cellIdx,A={start:this.payload.length,len:0};for(;S<b.length&&b[S].cellIdx===I;)++A.len,this.payload.push(b[S++].triIdx);this.cells[I]=A}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0)}queryPoint(e,t){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const r=el(e.x-this.min.x,this.xScale,this.cellsX),c=el(e.y-this.min.y,this.yScale,this.cellsY),h=this.cells[c*this.cellsX+r];if(h){this._lazyInitLookup();for(let f=0;f<h.len;f++){const _=this.payload[h.start+f],g=Math.floor(_/8),b=1<<_%8;if(!(this.lookup[g]&b)&&(this.lookup[g]|=b,t.push(_),t.length===this.triangleCount))return}}}query(e,t,r){if(this.triangleCount===0||this.cells.length===0||e.x>this.max.x||this.min.x>t.x||e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const c=el(e.x-this.min.x,this.xScale,this.cellsX),h=el(t.x-this.min.x,this.xScale,this.cellsX),f=el(e.y-this.min.y,this.yScale,this.cellsY),_=el(t.y-this.min.y,this.yScale,this.cellsY);for(let g=f;g<=_;g++)for(let b=c;b<=h;b++){const S=this.cells[g*this.cellsX+b];if(S)for(let I=0;I<S.len;I++){const A=this.payload[S.start+I],M=Math.floor(A/8),D=1<<A%8;if(!(this.lookup[M]&D)&&(this.lookup[M]|=D,r.push(A),r.length===this.triangleCount))return}}}}function el(n,e,t){return Math.max(0,Math.min(t-1,Math.floor(n*e)))}wt(Tx,"TriangleGridIndex");class rI{constructor(e){this.zoom=e.zoom,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){for(const r of this.footprints)t.push({footprint:r,id:e})}updateAppearances(e,t,r,c){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,c){const h=[];for(const{feature:f,id:_,index:g,sourceLayerIndex:b}of e){const S=this.layers[0]._featureFilter.needGeometry,I=oi(f,S);if(!this.layers[0]._featureFilter.filter(new Mi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),I,r))continue;const A={id:_,properties:f.properties,type:f.type,sourceLayerIndex:b,index:g,geometry:S?I.geometry:Ft(f,r,c),patterns:{}};h.push(A)}for(const f of h){const{geometry:_,index:g,sourceLayerIndex:b}=f;this.addFeature(f,_,g,r,{},t.availableImages,t.brightness),t.featureIndex.insert(e[g].feature,_,g,b,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(e){}update(e,t,r,c,h,f,_){}destroy(){}addFeature(e,t,r,c,h,f=[],_){for(const g of s_(t,2)){const b=[],S=[],I=[],A=new it(1/0,1/0),M=new it(-1/0,-1/0);for(const B of g)if(B.length!==0){B!==g[0]&&I.push(S.length/2);for(let V=0;V<B.length;V++)S.push(B[V].x),S.push(B[V].y),b.push(B[V]),A.x=Math.min(A.x,B[V].x),A.y=Math.min(A.y,B[V].y),M.x=Math.max(M.x,B[V].x),M.y=Math.max(M.y,B[V].y)}const D=df(S,I),z=new Tx(b,D,8,256);this.footprints.push({vertices:b,indices:D,grid:z,min:A,max:M})}}}wt(rI,"ClipBucket",{omit:["layers"]});const QF=pi([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),eO=pi([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),tO=pi([{name:"a_flood_light_ground_radius",components:1,type:"Float32"}]),iO=pi([{name:"a_centroid_pos",components:2,type:"Uint16"}]),nO=pi([{name:"a_join_normal_inside",components:3,type:"Int16"}]),rO=pi([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),sO=pi([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:oO}=QF,l_=Number.MAX_SAFE_INTEGER,aO=l_-1;function sI(n,e,t,r){return n.order<e||n.order===l_||!(n.clipMask&t)||function(c,h){if(h.length===0)return!1;let f=c;for(;f!=="";){if(h.includes(f))return!1;f=ex(f)}return!0}(r,n.clipScope)}function Sx(n,e){return n.x-e.x||n.y-e.y}function oI(n,e){return Sx(n.min,e.min)===0&&Sx(n.max,e.max)===0}function hb(n,e){return!(n.min.x>e.max.x||n.max.x<e.min.x||n.min.y>e.max.y||n.max.y<e.min.y)}function Ex(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t].sourceId!==e[t].sourceId||!oI(n[t],e[t])||n[t].order!==e[t].order||n[t].clipMask!==e[t].clipMask||!zo(n[t].clipScope,e[t].clipScope))return!1;return!0}function aI(n,e,t){const r=1/_t,c=1/(1<<t.canonical.z),h=(e.x*r+t.canonical.x)*c+t.wrap,f=(e.y*r+t.canonical.y)*c;return{min:new it((n.x*r+t.canonical.x)*c+t.wrap,(n.y*r+t.canonical.y)*c),max:new it(h,f)}}function lO(n,e,t){const r=1<<t.canonical.z,c=((e.x-t.wrap)*r-t.canonical.x)*_t,h=(e.y*r-t.canonical.y)*_t;return{min:new it(((n.x-t.wrap)*r-t.canonical.x)*_t,(n.y*r-t.canonical.y)*_t),max:new it(c,h)}}function db(n,e,t,r,c,h,f){const _=n.indices,g=n.vertices,b=[];for(let S=r;S<r+c;S+=3){const I=e[t[S+0]+h],A=e[t[S+1]+h],M=e[t[S+2]+h],D=Math.min(I.x,A.x,M.x),z=Math.max(I.x,A.x,M.x),B=Math.min(I.y,A.y,M.y),V=Math.max(I.y,A.y,M.y);b.length=0,n.grid.query(new it(D,B),new it(z,V),b);for(let Z=0;Z<b.length;Z++){const G=b[Z];if(uf(g[_[3*G+0]],g[_[3*G+1]],g[_[3*G+2]],I,A,M,f))return!0}}return!1}function lI(n,e,t,r){if(!n||!t)return!1;let c=n.vertices;if(!e.canonical.equals(r.canonical)||e.wrap!==r.wrap){if(t.vertices.length<n.vertices.length)return lI(t,r,n,e);const h=e.canonical,f=r.canonical,_=Math.pow(2,f.z-h.z);c=n.vertices.map(g=>new it((g.x+h.x*_t)*_-f.x*_t,(g.y+h.y*_t)*_-f.y*_t))}return db(t,c,n.indices,0,n.indices.length,0,0)}function cI(n,e,t,r){const c=Math.pow(2,r.z-t.z);return new it((n+t.x*_t)*c-r.x*_t,(e+t.y*_t)*c-r.y*_t)}function uI(n,e){const t=[];e.grid.queryPoint(n,t);const r=e.indices,c=e.vertices;for(let h=0;h<t.length;h++){const f=t[h];if(ns([c[r[3*f+0]],c[r[3*f+1]],c[r[3*f+2]]],n))return!0}return!1}const Ix={None:0,Model:1,Symbol:2,FillExtrusion:4},fb=[new it(0,0),new it(_t,0),new it(_t,_t),new it(0,_t)];function hI(n,e){const t=[];let r=[];if(!e||n.length<2)return[n];if(n.length===2)return Ya(n[0],n[1],fb)?[n]:[];for(let c=0;c<n.length+2;c++){const h=n[c%n.length],f=n[(c+1)%n.length],_=Ya(c===0?n[n.length-1]:n[(c-1)%n.length],h,fb),g=Ya(h,f,fb),b=_||g;b&&r.push(h),b&&g||r.length>0&&(r.length>1&&t.push(r),r=[])}return r.length>1&&t.push(r),t}const pb=qt.types,cO=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],uO=["fill-extrusion-flood-light-ground-radius"],hO=Math.pow(2,13),dO=Math.pow(2,15)-1,Ax=new it(0,1),Gl=2147483648,Cx=1073741824;function c_(n,e,t,r,c,h,f,_){n.emplaceBack((e<<1)+f,(t<<1)+h,(Math.floor(r*hO)<<1)+c,Math.round(_))}function u_(n,e,t){n.emplaceBack(e.x*_t,e.y*_t,t?1:0)}function Px(n,e,t,r,c,h){n.emplaceBack(e.x,e.y,(t.x<<1)+r,(t.y<<1)+c,h)}function h_(n,e,t){n.emplaceBack(e.x,e.y,e.z,t[0]*16384,t[1]*16384,t[2]*16384)}class dI{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class mb{constructor(){this.centroidXY=new it(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new it(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new it(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0,this.groupCentroidPos=new it(0,0)}span(){return new it(this.max.x-this.min.x,this.max.y-this.min.y)}}class _b{constructor(){this.acc=new it(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y)}appendEdge(e,t,r){this.accCount++,this.acc._add(t);let c=!!this.borders;t.x<e.min.x?(e.min.x=t.x,c=!0):t.x>e.max.x&&(e.max.x=t.x,c=!0),t.y<e.min.y?(e.min.y=t.y,c=!0):t.y>e.max.y&&(e.max.y=t.y,c=!0),((t.x===0||t.x===_t)&&t.x===r.x)!=((t.y===0||t.y===_t)&&t.y===r.y)&&this.processBorderOverlap(t,r),c&&this.checkBorderIntersection(t,r)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,Gt(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>_t!=e.x>_t&&this.addBorderIntersection(1,Gt(t.y,e.y,(_t-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Gt(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>_t!=e.y>_t&&this.addBorderIntersection(3,Gt(t.x,e.x,(_t-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const r=this.borders[e];t<r[0]&&(r[0]=t),t>r[1]&&(r[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const r=e.x===0?0:1;this.addBorderIntersection(r,t.y),this.addBorderIntersection(r,e.y)}else{const r=e.y===0?2:3;this.addBorderIntersection(r,t.x),this.addBorderIntersection(r,e.x)}}centroid(){return this.accCount===0?new it(0,0):new it(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 fI(n,e){const t=n.add(e)._unit(),r=q(n.x*t.x+n.y*t.y,-1,1);var c,h,f;return f=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(f)))/4*dO*((c=n).x*(h=e).y-c.y*h.x<0?-1:1)}const fO=[n=>n.x<0,n=>n.x>_t,n=>n.y<0,n=>n.y>_t];function pO(n,e,t,r){const c=[4];if(r===0)return c;t._mult(r);const h=n.sub(t),f=e.sub(t),_=[n,e,h,f];for(let g=0;g<4;g++)for(const b of _)if(fO[g](b)){c.push(g);break}return c}class gb{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new Om,this.indexArray=new Tn,this.programConfigurations=new N(e.layers,{zoom:e.zoom,lut:e.lut},t=>uO.includes(t)),this._segments=new $i,this.hiddenByLandmarkVertexArray=new af,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new $i}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(e,t,r,c=!1){const h=e.length;if(h>2){let f=Math.max(0,this._segments.get().length-1);const _=this._segments._prepareSegment(4*h,this.vertexArray.length,2*this._segmentToGroundQuads[f].length);let g;f!==this._segments.get().length-1&&(f++,this._segmentToGroundQuads[f]=[],this._segmentToRegionTriCounts[f]=[0,0,0,0,0]);{const b=e[0],S=e[1];g=fI(b.sub(e[h-1])._perp()._unit(),S.sub(b)._perp()._unit())}for(let b=0;b<h;b++){const S=b===h-1?0:b+1,I=e[b],A=e[S],M=e[S===h-1?0:S+1],D=A.sub(I)._perp()._unit(),z=fI(D,M.sub(A)._perp()._unit()),B=g,V=z;if(yb(I,A,t)||c&&_I(I,t)&&_I(A,t)){g=z;continue}const Z=_.vertexLength;Px(this.vertexArray,I,A,1,1,B),Px(this.vertexArray,I,A,1,0,B),Px(this.vertexArray,I,A,0,1,V),Px(this.vertexArray,I,A,0,0,V),_.vertexLength+=4;const G=pO(I,A,D,r);for(const Y of G)this._segmentToGroundQuads[f].push({id:Z,region:Y}),this._segmentToRegionTriCounts[f][Y]+=2,_.primitiveLength+=2;g=z}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),t=e.length;for(let r=0;r<t;r++)this._segmentToGroundQuads[r].sort((c,h)=>c.region-h.region);for(let r=0;r<t;r++){const c=this._segmentToGroundQuads[r],h=e[r],f=this._segmentToRegionTriCounts[r];f.reduce((g,b)=>g+b,0);let _=0;for(let g=0;g<=4;g++){const b=f[g];if(b!==0){let S=this.regionSegments[g];S||(S=this.regionSegments[g]=new $i);const I={vertexOffset:h.vertexOffset,primitiveOffset:h.primitiveOffset+_,vertexLength:h.vertexLength,primitiveLength:b};S.get().push(I)}_+=b}for(let g=0;g<c.length;g++){const b=c[g].id;this.indexArray.emplaceBack(b,b+1,b+3),this.indexArray.emplaceBack(b,b+3,b+2)}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null}addPaintPropertiesData(e,t,r,c,h,f,_){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,t,r,c,h,f,void 0,_)}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,eO.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.groundRadiusArray!=null&&(this.groundRadiusBuffer=e.createVertexBuffer(this.groundRadiusArray,tO.members)))}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e)}update(e,t,r,c,h,f,_,g){this.hasData()&&this.programConfigurations.updatePaintArrays(e,t,r,c,h,f,_,g)}updateHiddenByLandmark(e){this.updateHiddenByLandmarkRange(e.groundVertexArrayOffset,e.groundVertexCount,!!(e.flags&Gl||e.flags&Cx))}updateHiddenByLandmarkRange(e,t,r){if(!this.hasData())return;const c=t+e;if(t!==0){for(let h=e;h<c;++h)this.hiddenByLandmarkVertexArray.emplace(h,r?1:0);this._needsHiddenByLandmarkUpdate=!0}}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,rO.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.groundRadiusBuffer&&this.groundRadiusBuffer.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 Mx{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,this.layerIds=this.layers.map(t=>t.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 Tn,this.footprintVertices=new ms,this.footprintSegments=[],this.layoutVertexArray=new Fm,this.centroidVertexArray=new cx,this.wallVertexArray=new Xm,this.indexArray=new Tn,this.programConfigurations=new N(e.layers,{zoom:e.zoom,lut:e.lut},t=>cO.includes(t)),this.segments=new $i,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.groundEffect=new gb(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.buildingGroups=new Map,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,r,c){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,c){this.features=[],this.hasPattern=eb("fill-extrusion",this.layers,this.pixelRatio,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=et(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1)!==0;for(const{feature:h,id:f,index:_,sourceLayerIndex:g}of e){const b=this.layers[0]._featureFilter.needGeometry,S=oi(h,b);if(!this.layers[0]._featureFilter.filter(new Mi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),S,r))continue;const I={id:f,sourceLayerIndex:g,index:_,geometry:b?S.geometry:Ft(h,r,c),properties:h.properties,type:h.type,patterns:{}},A=this.layoutVertexArray.length,M=pb[I.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:h.id,feature:tb("fill-extrusion",this.layers,I,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const D of I.geometry)for(const z of hI(D,M))this.addFeature(h.id,I,[z],_,r,{},t.availableImages,c,t.brightness);else this.addFeature(h.id,I,I.geometry,_,r,{},t.availableImages,c,t.brightness);t.featureIndex.insert(h,I.geometry,_,g,this.index,A)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,r,c,h,f){for(const{featureId:_,feature:g}of this.features){const b=pb[g.type]==="Polygon",{geometry:S}=g;if(this.wallMode)for(const I of S)for(const A of hI(I,b))this.addFeature(_,g,[A],g.index,t,r,c,h,f);else this.addFeature(_,g,S,g.index,t,r,c,h,f)}this._finalizeBuildingGroups(),this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(e,t,r,c,h,f,_){this.programConfigurations.updatePaintArrays(e,t,h,r,c,f,_,this.worldview),this.groundEffect.update(e,t,h,r,c,f,_,this.worldview)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,oO),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,nO.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,sO.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,iO.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,r,c,h,f,_,g,b){const S=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,I=[new it(0,0),new it(_t,_t)],A=g.projection,M=A.name==="globe",D=this.wallMode||pb[t.type]==="Polygon",z=new _b;z.centroidDataIndex=this.centroidData.length;const B=new mb;B.buildingId=e,t.properties&&t.properties.hasOwnProperty("building_id")&&(B.buildingId=Number(t.properties.building_id)),z.buildingId=B.buildingId;const V=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},h)<=0,Z=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},h);let G;if(B.height=Z,B.vertexArrayOffset=this.layoutVertexArray.length,B.groundVertexArrayOffset=this.groundEffect.vertexArray.length,M&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new ef),this.wallMode){if(M)return void zt("Non zero fill-extrusion-line-width is not yet supported on globe.");if(r.length!==1)return;G=function(he){const de=he[0].x===he[he.length-1].x&&he[0].y===he[he.length-1].y;(function(pt){let ht=0;const yt=pt.length;for(let It=0;It<yt;It++)ht+=(pt[(It+1)%yt].x-pt[It].x)*(pt[(It+1)%yt].y+pt[It].y);return ht>=0})(he)||(he=he.reverse());const je={geometry:[],joinNormals:[],indices:[]},He=[],Xe=[],Ze=[];let nt=he.length;for(;nt>=2&&he[nt-1].equals(he[nt-2]);)nt--;if(nt<(de?3:2))return je;let Fe,We,Qe,st,ut,bt=0;for(;bt<nt-1&&he[bt].equals(he[bt+1]);)bt++;de&&(Fe=he[nt-2],ut=he[bt].sub(Fe)._unit()._perp());for(let pt=bt;pt<nt;pt++){if(Qe=pt===nt-1?de?he[bt+1]:void 0:he[pt+1],Qe&&he[pt].equals(Qe))continue;ut&&(st=ut),Fe&&(We=Fe),Fe=he[pt],ut=Qe?Qe.sub(Fe)._unit()._perp():st,st=st||ut;let ht=st.add(ut);ht.x===0&&ht.y===0||ht._unit();const yt=ht.x*ut.x+ht.y*ut.y,It=yt!==0?1/yt:1/0,kt=st.x*ut.y-st.y*ut.x>0;let Ct="miter";const Qt=2;Ct==="miter"&&It>Qt&&(Ct="bevel"),Ct==="bevel"&&(It>100&&(Ct="flipbevel"),It<Qt&&(Ct="miter"));const vi=(ei,wi,ai,gn)=>{const Ri=new it(ei.x,ei.y),Si=new it(ei.x,ei.y);Ri.x+=wi.x*gn,Ri.y+=wi.y*gn,Si.x-=wi.x*Math.max(ai,1),Si.y-=wi.y*Math.max(ai,1),Ze.push(wi),He.push(Ri),Xe.push(Si)};if(Ct==="miter")ht._mult(It),vi(Fe,ht,0,0);else if(Ct==="flipbevel")ht=ut.mult(-1),vi(Fe,ht,0,0),vi(Fe,ht.mult(-1),0,0);else{const ei=-Math.sqrt(It*It-1),wi=kt?ei:0,ai=kt?0:ei;We&&vi(Fe,st,wi,ai),Qe&&vi(Fe,ut,wi,ai)}}je.geometry=[...He,...Xe.reverse(),He[0]],je.joinNormals=[...Ze,...Ze.reverse(),Ze[Ze.length-1]];const mt=je.geometry.length-1;for(let pt=0;pt<mt/2;pt++)if(pt+1<mt/2){let ht=pt,yt=pt+1,It=mt-1-pt,kt=mt-2-pt;ht=ht===0?mt-1:ht-1,yt=yt===0?mt-1:yt-1,It=It===0?mt-1:It-1,kt=kt===0?mt-1:kt-1,je.indices.push(It),je.indices.push(yt),je.indices.push(ht),je.indices.push(It),je.indices.push(kt),je.indices.push(yt)}return je}(r[0]),r=[G.geometry]}const Y=(he,de)=>he<(de.length-1)/2||he===de.length-1,Q=this.wallMode?[r]:s_(r,500);for(let he=Q.length-1;he>=0;he--){const de=Q[he];(de.length===0||_O(de[0]))&&Q.splice(he,1)}let te;if(M)te=vI(Q,I,h);else{te=[];for(const he of Q)te.push({polygon:he,bounds:I})}const me=D?this.edgeRadius:0,ce=me>0&&this.zoom<17,pe=(he,de)=>{if(he.length===0)return!1;const Be=he[he.length-1];return de.x===Be.x&&de.y===Be.y};for(const{polygon:he,bounds:de}of te){let Be=0,je=0;for(const nt of he)D&&!nt[0].equals(nt[nt.length-1])&&nt.push(nt[0]),je+=D?nt.length-1:nt.length;const He=this.segments.prepareSegment((D?5:4)*je,this.layoutVertexArray,this.indexArray);B.footprintSegIdx<0&&(B.footprintSegIdx=this.footprintSegments.length),B.polygonSegIdx<0&&(B.polygonSegIdx=this.polygonSegments.length);const Xe={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Ze=new dI;if(Ze.vertexOffset=this.footprintVertices.length,Ze.indexOffset=3*this.footprintIndices.length,Ze.ringIndices=[],D){const nt=[],Fe=[];Be=He.vertexLength;for(let Qe=0;Qe<he.length;Qe++){const st=he[Qe];st.length&&Qe!==0&&Fe.push(nt.length/2);const ut=[];let bt,mt;bt=st[1].sub(st[0])._perp()._unit(),Ze.ringIndices.push(st.length-1);for(let pt=1;pt<st.length;pt++){const ht=st[pt],yt=st[pt===st.length-1?1:pt+1],It=ht.clone();if(me){mt=yt.sub(ht)._perp()._unit();const kt=bt.add(mt)._unit(),Ct=me*Math.min(4,1/(bt.x*kt.x+bt.y*kt.y));It.x+=Ct*kt.x,It.y+=Ct*kt.y,It.x=Math.round(It.x),It.y=Math.round(It.y),bt=mt}if(!V||me!==0&&!ce||pe(ut,It)||ut.push(It),c_(this.layoutVertexArray,It.x,It.y,0,0,1,1,0),this.wallMode){const kt=Y(pt,st);u_(this.wallVertexArray,G.joinNormals[pt],!kt)}He.vertexLength++,this.footprintVertices.emplaceBack(ht.x,ht.y),nt.push(ht.x,ht.y),M&&h_(this.layoutVertexExtArray,A.projectTilePoint(It.x,It.y,h),A.upVector(h,It.x,It.y))}V&&(me===0||ce)&&(ut.length!==0&&pe(ut,ut[0])&&ut.pop(),this.groundEffect.addData(ut,de,S))}const We=this.wallMode?G.indices:df(nt,Fe);for(let Qe=0;Qe<We.length;Qe+=3)this.footprintIndices.emplaceBack(Ze.vertexOffset+We[Qe+0],Ze.vertexOffset+We[Qe+1],Ze.vertexOffset+We[Qe+2]),this.indexArray.emplaceBack(Be+We[Qe],Be+We[Qe+2],Be+We[Qe+1]),He.primitiveLength++;Ze.indexCount+=We.length,Ze.vertexCount+=this.footprintVertices.length-Ze.vertexOffset}for(let nt=0;nt<he.length;nt++){const Fe=he[nt];z.startRing(B,Fe[0]);let We=Fe.length>4&&gI(Fe[Fe.length-2],Fe[0],Fe[1]),Qe=me?mO(Fe[Fe.length-2],Fe[0],Fe[1],me):0;const st=[];let ut,bt,mt;bt=Fe[1].sub(Fe[0])._perp()._unit();let pt=!0;for(let ht=1,yt=0;ht<Fe.length;ht++){let It=Fe[ht-1],kt=Fe[ht];const Ct=Fe[ht===Fe.length-1?1:ht+1];if(z.appendEdge(B,kt,It),yb(kt,It,de)){me&&(bt=Ct.sub(kt)._perp()._unit(),pt=!pt);continue}const Qt=kt.sub(It)._perp(),vi=Qt.x/(Math.abs(Qt.x)+Math.abs(Qt.y)),ei=Qt.y>0?1:0,wi=It.dist(kt);if(yt+wi>32768&&(yt=0),me){mt=Ct.sub(kt)._perp()._unit();let Si=mI(It,kt,Ct,pI(bt,mt),me);isNaN(Si)&&(Si=0);const qi=kt.sub(It)._unit();It=It.add(qi.mult(Qe))._round(),kt=kt.add(qi.mult(-Si))._round(),Qe=Si,bt=mt,V&&this.zoom>=17&&(pe(st,It)||st.push(It),pe(st,kt)||st.push(kt))}const ai=He.vertexLength,gn=Fe.length>4&&gI(It,kt,Ct);let Ri=yI(yt,We,pt);if(c_(this.layoutVertexArray,It.x,It.y,vi,ei,0,0,Ri),c_(this.layoutVertexArray,It.x,It.y,vi,ei,0,1,Ri),this.wallMode){const Si=Y(ht-1,Fe),qi=G.joinNormals[ht-1];u_(this.wallVertexArray,qi,Si),u_(this.wallVertexArray,qi,Si)}if(yt+=wi,Ri=yI(yt,gn,!pt),We=gn,c_(this.layoutVertexArray,kt.x,kt.y,vi,ei,0,0,Ri),c_(this.layoutVertexArray,kt.x,kt.y,vi,ei,0,1,Ri),this.wallMode){const Si=Y(ht,Fe),qi=G.joinNormals[ht];u_(this.wallVertexArray,qi,Si),u_(this.wallVertexArray,qi,Si)}if(He.vertexLength+=4,this.indexArray.emplaceBack(ai+0,ai+1,ai+2),this.indexArray.emplaceBack(ai+1,ai+3,ai+2),He.primitiveLength+=2,me){const Si=Be+(ht===1?Fe.length-2:ht-2),qi=ht===1?Be:Si+1;if(this.indexArray.emplaceBack(ai+1,Si,ai+3),this.indexArray.emplaceBack(Si,qi,ai+3),He.primitiveLength+=2,ut===void 0&&(ut=ai),!yb(Ct,Fe[ht],de)){const dn=ht===Fe.length-1?ut:He.vertexLength;this.indexArray.emplaceBack(ai+2,ai+3,dn),this.indexArray.emplaceBack(ai+3,dn+1,dn),this.indexArray.emplaceBack(ai+3,qi,dn+1),He.primitiveLength+=3}pt=!pt}if(M){const Si=this.layoutVertexExtArray,qi=A.projectTilePoint(It.x,It.y,h),dn=A.projectTilePoint(kt.x,kt.y,h),rr=A.upVector(h,It.x,It.y),fn=A.upVector(h,kt.x,kt.y);h_(Si,qi,rr),h_(Si,qi,rr),h_(Si,dn,fn),h_(Si,dn,fn)}}D&&(Be+=Fe.length-1),V&&me&&this.zoom>=17&&(st.length!==0&&pe(st,st[0])&&st.pop(),this.groundEffect.addData(st,de,S,me>0))}this.footprintSegments.push(Ze),Xe.triangleCount=this.indexArray.length-Xe.triangleArrayOffset,this.polygonSegments.push(Xe),++B.footprintSegLen,++B.polygonSegLen}if(B.vertexCount=this.layoutVertexArray.length-B.vertexArrayOffset,B.groundVertexCount=this.groundEffect.vertexArray.length-B.groundVertexArrayOffset,B.vertexCount!==0){if(B.centroidXY=z.borders?Ax:this.encodeCentroid(z,B),t.properties&&t.properties.hasOwnProperty("building_id")){const he=B.buildingId;let de=this.buildingGroups.get(he);de||(de={accX:0,accY:0,accCount:0,mergedMin:new it(Number.MAX_VALUE,Number.MAX_VALUE),mergedMax:new it(-Number.MAX_VALUE,-Number.MAX_VALUE),partIndices:[]},this.buildingGroups.set(he,de)),de.accX+=z.acc.x,de.accY+=z.acc.y,de.accCount+=z.accCount,de.mergedMin.x=Math.min(de.mergedMin.x,B.min.x),de.mergedMin.y=Math.min(de.mergedMin.y,B.min.y),de.mergedMax.x=Math.max(de.mergedMax.x,B.max.x),de.mergedMax.y=Math.max(de.mergedMax.y,B.max.y),de.partIndices.push(this.centroidData.length)}if(this.centroidData.push(B),z.borders){this.featuresOnBorder.push(z);const he=this.featuresOnBorder.length-1;for(let de=0;de<z.borders.length;de++)z.borders[de][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[de].push(he)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,c,f,_,h,b,void 0,this.worldview),this.groundEffect.addPaintPropertiesData(t,c,f,_,h,b,this.worldview),this.maxHeight=Math.max(this.maxHeight,Z)}}_finalizeBuildingGroups(){for(const[,e]of this.buildingGroups){if(e.partIndices.length===0)continue;const t=new _b;t.acc=new it(e.accX,e.accY),t.accCount=e.accCount;const r=new mb;r.min=e.mergedMin,r.max=e.mergedMax;const c=this.encodeCentroid(t,r),h=t.centroid();for(const f of e.partIndices){const _=this.centroidData[f];_.centroidXY.x===Ax.x&&_.centroidXY.y===Ax.y||(_.centroidXY=c),_.min=e.mergedMin,_.max=e.mergedMax,_.groupCentroidPos=h}}this.buildingGroups.clear()}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort((t,r)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[r].borders[e][0])}splitToSubtiles(){const e=[];for(let _=0;_<this.centroidData.length;_++){const g=this.centroidData[_],b=+(g.min.y+g.max.y>_t),S=2*b+(+(g.min.x+g.max.x>_t)^b);for(let I=0;I<g.polygonSegLen;I++){const A=g.polygonSegIdx+I;e.push({centroidIdx:_,subtile:S,polygonSegmentIdx:A,triangleSegmentIdx:this.polygonSegments[A].triangleSegIdx})}}const t=new Tn;e.sort((_,g)=>_.triangleSegmentIdx===g.triangleSegmentIdx?_.subtile-g.subtile:_.triangleSegmentIdx-g.triangleSegmentIdx);let r=0,c=0,h=0;for(const _ of e){if(_.triangleSegmentIdx!==r)break;h++}const f=e.length;for(;c!==e.length;){r=e[c].triangleSegmentIdx;let _=0,g=c,b=c;for(let S=g;S<h&&e[S].subtile===_;S++)b++;for(;g!==h;){const S=e[g];_=S.subtile;const I=this.centroidData[S.centroidIdx].min.clone(),A=this.centroidData[S.centroidIdx].max.clone(),M={vertexOffset:this.segments.segments[r].vertexOffset,primitiveOffset:t.length,vertexLength:this.segments.segments[r].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let D=g;D<b;D++){const z=e[D],B=this.polygonSegments[z.polygonSegmentIdx],V=this.centroidData[z.centroidIdx].min,Z=this.centroidData[z.centroidIdx].max,G=this.indexArray.uint16;for(let Y=B.triangleArrayOffset;Y<B.triangleArrayOffset+B.triangleCount;Y++)t.emplaceBack(G[3*Y],G[3*Y+1],G[3*Y+2]);M.primitiveLength+=B.triangleCount,I.x=Math.min(I.x,V.x),I.y=Math.min(I.y,V.y),A.x=Math.max(A.x,Z.x),A.y=Math.max(A.y,Z.y)}M.primitiveLength>0&&this.triangleSubSegments.push({segment:M,min:I,max:A}),g=b;for(let D=g;D<h&&e[D].subtile===e[g].subtile;D++)b++}c=h;for(let S=c;S<f&&e[S].triangleSegmentIdx===e[c].triangleSegmentIdx;S++)h++}t._trim(),this.indexArray=t}getVisibleSegments(e,t,r){const c=new $i;if(this.wallMode){for(const z of this.triangleSubSegments)c.segments.push(z.segment);return c}let h=0,f=0;const _=1<<e.canonical.z;if(t){const z=t.getMinMaxForTile(e);z&&(h=z.min,f=z.max)}f+=this.maxHeight;const g=e.toUnwrapped();let b;const S=[g.canonical.x/_+g.wrap,g.canonical.y/_],I=[(g.canonical.x+1)/_+g.wrap,(g.canonical.y+1)/_],A=(z,B,V)=>[z[0]*(1-V[0])+B[0]*V[0],z[1]*(1-V[1])+B[1]*V[1]],M=[],D=[];for(const z of this.triangleSubSegments){M[0]=z.min.x/_t,M[1]=z.min.y/_t,D[0]=z.max.x/_t,D[1]=z.max.y/_t;const B=A(S,I,M),V=A(S,I,D);if(new Li([B[0],B[1],h],[V[0],V[1],f]).intersectsPrecise(r)===0){b&&(c.segments.push(b),b=void 0);continue}const Z=z.segment;b&&b.vertexOffset!==Z.vertexOffset&&(c.segments.push(b),b=void 0),b?(b.vertexLength+=Z.vertexLength,b.primitiveLength+=Z.primitiveLength):b={vertexOffset:Z.vertexOffset,primitiveLength:Z.primitiveLength,vertexLength:Z.vertexLength,primitiveOffset:Z.primitiveOffset,sortKey:void 0,vaos:{}}}return b&&c.segments.push(b),c}encodeCentroid(e,t){const r=e.centroid(),c=t.span(),h=Math.min(7,Math.round(c.x*this.tileToMeter/10)),f=Math.min(6,Math.round(c.y*this.tileToMeter/10));return new it(q(r.x,1,8191)<<3|h,q(r.y,1,8191)<<3|f)}encodeBorderCentroid(e){if(!e.borders)return new it(0,0);const t=e.borders,r=Number.MAX_VALUE;if(t[0][0]!==r||t[1][0]!==r){const c=t[0][0]!==r?0:1;return new it(6|(t[0][0]!==r?0:65528),(t[c][0]+t[c][1])/2<<3|6)}{const c=t[2][0]!==r?2:3;return new it((t[c][0]+t[c][1])/2<<3|6,6|(t[2][0]!==r?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];if(t.flags&=Gl,t.groupCentroidPos.x!==0||t.groupCentroidPos.y!==0){const r=t.span(),c=Math.min(7,Math.round(r.x*this.tileToMeter/10)),h=Math.min(6,Math.round(r.y*this.tileToMeter/10));t.centroidXY=new it(q(t.groupCentroidPos.x,1,8191)<<3|c,q(t.groupCentroidPos.y,1,8191)<<3|h)}else t.centroidXY=new it(0,0);this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,r=e.vertexCount+e.vertexArrayOffset,c=-1073741824&e.flags?Ax:e.centroidXY,h=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==c.y||h!==c.x){for(let f=t;f<r;++f)this.centroidVertexArray.emplace(f,c.x,c.y);this.needsCentroidUpdate=!0}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.centroidData)this.writeCentroidToBuffer(e)}updateReplacement(e,t,r){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const c=t.getReplacementRegionsForTile(e.toUnwrapped());if(Ex(this.activeReplacements,c))return;if(this.activeReplacements=c,this.centroidVertexArray.length===0)this.createCentroidsBuffer();else for(const f of this.centroidData)f.flags&=1073741823;const h=[];for(const f of this.activeReplacements){if(f.order<r)continue;const _=Math.max(1,Math.pow(2,f.footprintTileId.canonical.z-e.canonical.z));if(f.footprint.buildingIds)for(const g of this.centroidData)g.flags&Gl||g.flags&Cx||f.min.x>g.max.x||g.min.x>f.max.x||f.min.y>g.max.y||g.min.y>f.max.y||f.footprint.buildingIds.has(g.buildingId)&&(g.flags|=f.clipMask!==Ix.None?-1073741824:Gl);else for(const g of this.centroidData)if(!(g.flags&Gl||g.flags&Cx||f.min.x>g.max.x||g.min.x>f.max.x||f.min.y>g.max.y||g.min.y>f.max.y))for(let b=0;b<g.footprintSegLen;b++){const S=this.footprintSegments[g.footprintSegIdx+b];if(h.length=0,gO(this.footprintVertices,S.vertexOffset,S.vertexCount,f.footprintTileId.canonical,e.canonical,h),db(f.footprint,h,this.footprintIndices.uint16,S.indexOffset,S.indexCount,-S.vertexOffset,-_)){g.flags|=f.clipMask!==Ix.None?-1073741824:Gl;break}}}for(const f of this.centroidData)this.writeCentroidToBuffer(f);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(e,t,r){let c=!1;for(let h=0;h<r.footprintSegLen;h++){const f=this.footprintSegments[r.footprintSegIdx+h];let _=0;for(const g of f.ringIndices){for(let b=_,S=g+_-1;b<g+_;S=b++){const I=this.footprintVertices.int16[2*(b+f.vertexOffset)+0],A=this.footprintVertices.int16[2*(b+f.vertexOffset)+1],M=this.footprintVertices.int16[2*(S+f.vertexOffset)+1];A>t!=M>t&&e<(this.footprintVertices.int16[2*(S+f.vertexOffset)+0]-I)*(t-A)/(M-A)+I&&(c=!c)}_=g}}return c}getHeightAtTileCoord(e,t){let r=Number.NEGATIVE_INFINITY,c=!0;const h=4*(e+_t)*_t+(t+_t);if(this.partLookup.hasOwnProperty(h)){const f=this.partLookup[h];return f?{height:f.height,hidden:!!(f.flags&Gl)}:void 0}for(const f of this.centroidData)e>f.max.x||f.min.x>e||t>f.max.y||f.min.y>t||f.height<=r||this.footprintContainsPoint(e,t,f)&&(r=f.height,this.partLookup[h]=f,c=!!(f.flags&Gl));if(r!==Number.NEGATIVE_INFINITY)return{height:r,hidden:c};this.partLookup[h]=void 0}}function pI(n,e){const t=n.add(e)._unit();return n.x*t.x+n.y*t.y}function mO(n,e,t,r){const c=e.sub(n)._perp()._unit(),h=t.sub(e)._perp()._unit();return mI(n,e,t,pI(c,h),r)}function mI(n,e,t,r,c){const h=Math.sqrt(1-r*r);return Math.min(n.dist(e)/3,e.dist(t)/3,c*h/r)}function yb(n,e,t){return n.x<t[0].x&&e.x<t[0].x||n.x>t[1].x&&e.x>t[1].x||n.y<t[0].y&&e.y<t[0].y||n.y>t[1].y&&e.y>t[1].y}function _I(n,e){return n.x<e[0].x||n.x>e[1].x||n.y<e[0].y||n.y>e[1].y}function _O(n){return n.every(e=>e.x<=0)||n.every(e=>e.x>=_t)||n.every(e=>e.y<=0)||n.every(e=>e.y>=_t)}function gI(n,e,t){if(n.x<0||n.x>=_t||e.x<0||e.x>=_t||t.x<0||t.x>=_t)return!1;const r=t.sub(e),c=r.perp(),h=n.sub(e);return(r.x*h.x+r.y*h.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(h.x*h.x+h.y*h.y))>-.866&&c.x*h.x+c.y*h.y<0}function yI(n,e,t){const r=e?2|n:-3&n;return t?1|r:-2&r}function xI(){const n=Math.PI/32,e=Math.tan(n),t=fe;return t*Math.sqrt(1+2*e*e)-t}function vI(n,e,t){const r=1<<t.z,c=we(t.x/r),h=we((t.x+1)/r),f=Oe(t.y/r),_=Oe((t.y+1)/r);return function(g,b,S,I,A=0,M){const D=[];if(!g.length||!S||!I)return D;const z=(te,me)=>{for(const ce of te)D.push({polygon:ce,bounds:me})},B=Math.ceil(Math.log2(S)),V=Math.ceil(Math.log2(I)),Z=B-V,G=[];for(let te=0;te<Math.abs(Z);te++)G.push(Z>0?0:1);for(let te=0;te<Math.min(B,V);te++)G.push(0),G.push(1);let Y=g;if(Y=bx(Y,b[0].y-A,b[1].y+A,1),Y=bx(Y,b[0].x-A,b[1].x+A,0),!Y.length)return D;const Q=[];for(G.length?Q.push({polygons:Y,bounds:b,depth:0}):z(Y,b);Q.length;){const te=Q.pop(),me=te.depth,ce=G[me],pe=te.bounds[0],he=te.bounds[1],de=ce===0?pe.x:pe.y,Be=ce===0?he.x:he.y,je=M?M(ce,de,Be):.5*(de+Be),He=bx(te.polygons,de-A,je+A,ce),Xe=bx(te.polygons,je-A,Be+A,ce);if(He.length){const Ze=[pe,new it(ce===0?je:he.x,ce===1?je:he.y)];G.length>me+1?Q.push({polygons:He,bounds:Ze,depth:me+1}):z(He,Ze)}if(Xe.length){const Ze=[new it(ce===0?je:pe.x,ce===1?je:pe.y),he];G.length>me+1?Q.push({polygons:Xe,bounds:Ze,depth:me+1}):z(Xe,Ze)}}return D}(n,e,Math.ceil((h-c)/11.25),Math.ceil((f-_)/11.25),1,(g,b,S)=>{if(g===0)return .5*(b+S);{const I=Oe((t.y+b/_t)/r);return(tt(.5*(Oe((t.y+S/_t)/r)+I))*r-t.y)*_t}})}function gO(n,e,t,r,c,h){const f=Math.pow(2,r.z-c.z);for(let _=0;_<t;_++){let g=n.int16[2*(_+e)+0],b=n.int16[2*(_+e)+1];g=(g+c.x*_t)*f-r.x*_t,b=(b+c.y*_t)*f-r.y*_t,h.push(new it(g,b))}}let bI,wI;wt(Mx,"FillExtrusionBucket",{omit:["layers","features"]}),wt(mb,"PartData"),wt(dI,"FootprintSegment"),wt(_b,"BorderCentroidData"),wt(gb,"GroundEffect");class Eh extends it{constructor(e,t,r){super(e,t),this.z=r}}class TI extends Eh{constructor(e,t,r,c){super(e,t,r),this.w=c}}function SI(n,e,t,r){const c=t==="x"?"y":"x",h=(r-n[t])/(e[t]-n[t]);n[c]=Math.round(n[c]+(e[c]-n[c])*h),n[t]=r,n.hasOwnProperty("z")&&(n.z=Gt(n.z,e.z,h)),n.hasOwnProperty("w")&&(n.w=Gt(n.w,e.w,h))}function EI(n,e,t,r){const c=t,h=r;for(const f of["x","y"]){let _=n,g=e;_[f]>=g[f]&&(_=e,g=n),_[f]<c&&g[f]>c&&SI(_,g,f,c),_[f]<h&&g[f]>h&&SI(g,_,f,h)}}function Rx(n,e,t,r,c,h){const f=[];for(let _=0;_<n.length;_++){const g=n[_];let b;const S=f.length;let I=0;for(let A=0;A<g.length-1;A++){let M=g[A],D=g[A+1],z=0;const B=I;let V,Z;h&&(z=Math.hypot(D.x-M.x,D.y-M.y),I+=z,V=M,Z=D),M.x<e&&D.x<e||(M.x<e?M=new it(e,M.y+(e-M.x)/(D.x-M.x)*(D.y-M.y))._round():D.x<e&&(D=new it(e,M.y+(e-M.x)/(D.x-M.x)*(D.y-M.y))._round()),M.y<t&&D.y<t||(M.y<t?M=new it(M.x+(t-M.y)/(D.y-M.y)*(D.x-M.x),t)._round():D.y<t&&(D=new it(M.x+(t-M.y)/(D.y-M.y)*(D.x-M.x),t)._round()),M.x>=r&&D.x>=r||(M.x>=r?M=new it(r,M.y+(r-M.x)/(D.x-M.x)*(D.y-M.y))._round():D.x>=r&&(D=new it(r,M.y+(r-M.x)/(D.x-M.x)*(D.y-M.y))._round()),M.y>=c&&D.y>=c||(M.y>=c?M=new it(M.x+(c-M.y)/(D.y-M.y)*(D.x-M.x),c)._round():D.y>=c&&(D=new it(M.x+(c-M.y)/(D.y-M.y)*(D.x-M.x),c)._round()),b&&M.equals(b[b.length-1])||(b=[M],f.push(b),h&&h.push({progress:{min:B+II(V,Z,M)*z,max:1},parentIndex:_,prevPoint:V,nextPoint:Z})),b.push(D),h&&(h[h.length-1].progress.max=B+II(V,Z,D)*z,h[h.length-1].nextPoint=Z)))))}if(h&&I>0)for(let A=S;A<f.length;A++)h[A].progress.min/=I,h[A].progress.max/=I}return f}function yO(n,e,t,r,c){if(n.length<2)return void r.push(n);const h=[];for(;e.valid();){const[b,S]=e.get();for(let I=0;I<n.length-1;I++){const A=n[I],M=n[I+1],D=Uc(A,M,b,S);if(D){const[z]=D,B=new it(Gt(A.x,M.x,z),Gt(A.y,M.y,z));h.push({t:I+z,distance:0,point:B})}}e.next()}if(h.length===0)return void r.push(n);h.sort((b,S)=>b.t-S.t);let f=0,_=0,g=[];for(r.push(g);f!==n.length;){if(_===h.length){for(;f!==n.length;)g.length!==0&&g[g.length-1].equals(n[f])||g.push(n[f]),f++;break}h[_].t<=f?(g.length!==0&&g[g.length-1].equals(h[_].point)||g.push(h[_].point),Math.trunc(h[_].t),_++):(g.length!==0&&g[g.length-1].equals(n[f])||g.push(n[f]),f++)}}function II(n,e,t){return n.x!==e.x?(t.x-n.x)/(e.x-n.x):n.y!==e.y?(t.y-n.y)/(e.y-n.y):0}function d_(n,e){return n.x*e.x+n.y*e.y}function AI(n,e){if(n.length===1){let t=0;const r=e[t++];let c;for(;!c||r.equals(c);)if(c=e[t++],!c)return 1/0;for(;t<e.length;t++){const h=e[t],f=n[0],_=c.sub(r),g=h.sub(r),b=f.sub(r),S=d_(_,_),I=d_(_,g),A=d_(g,g),M=d_(b,_),D=d_(b,g),z=S*A-I*I,B=(A*M-I*D)/z,V=(S*D-I*M)/z,Z=r.z*(1-B-V)+c.z*B+h.z*V;if(isFinite(Z))return Z}return 1/0}{let t=1/0;for(const r of e)t=Math.min(t,r.z);return t}}function CI(n,e,t){let r=1/0;_n(t,e)&&(r=AI(t,e[0]));for(let c=0;c<e.length;c++){const h=e[c],f=n[c];for(let _=0;_<h.length-1;_++){const g=h[_],b=[g,h[_+1],f[_+1],f[_],g];Mn(t,b)&&(r=Math.min(r,AI(t,b)))}}return r!==1/0&&r}function PI(n,e,t,r,c,h,f,_,g,b,S){return n.projection.name==="globe"?function(I,A,M,D,z,B,V,Z,G,Y,Q){const te=[],me=[],ce=I.projection.upVectorScale(Q,I.center.lat,I.worldSize).metersToTile,pe=[0,0,0,1],he=[0,0,0,1],de=(je,He,Xe,Ze)=>{je[0]=He,je[1]=Xe,je[2]=Ze,je[3]=1},Be=xI();M>0&&(M+=Be),D+=Be;for(const je of A){const He=[],Xe=[];for(const Ze of je){const nt=Ze.x+z.x,Fe=Ze.y+z.y,We=I.projection.projectTilePoint(nt,Fe,Q),Qe=I.projection.upVector(Q,Ze.x,Ze.y);let st=M,ut=D;if(V){const bt=MI(nt,Fe,M,D,V,Z,G,Y);st+=bt.base,ut+=bt.top}M!==0?de(pe,We.x+Qe[0]*ce*st,We.y+Qe[1]*ce*st,We.z+Qe[2]*ce*st):de(pe,We.x,We.y,We.z),de(he,We.x+Qe[0]*ce*ut,We.y+Qe[1]*ce*ut,We.z+Qe[2]*ce*ut),mn(pe,pe,B),mn(he,he,B),He.push(new Eh(pe[0],pe[1],pe[2])),Xe.push(new Eh(he[0],he[1],he[2]))}te.push(He),me.push(Xe)}return[te,me]}(n,e,t,r,c,h,f,_,g,b,S):f?function(I,A,M,D,z,B,V,Z,G){const Y=[],Q=[],te=[0,0,0,1];for(const me of I){const ce=[],pe=[];for(const he of me){const de=he.x+D.x,Be=he.y+D.y,je=MI(de,Be,A,M,B,V,Z,G);te[0]=de,te[1]=Be,te[2]=je.base,te[3]=1,vr(te,te,z),te[3]=Math.max(te[3],1e-5);const He=new Eh(te[0]/te[3],te[1]/te[3],te[2]/te[3]);te[0]=de,te[1]=Be,te[2]=je.top,te[3]=1,vr(te,te,z),te[3]=Math.max(te[3],1e-5);const Xe=new Eh(te[0]/te[3],te[1]/te[3],te[2]/te[3]);ce.push(He),pe.push(Xe)}Y.push(ce),Q.push(pe)}return[Y,Q]}(e,t,r,c,h,f,_,g,b):function(I,A,M,D,z){const B=[],V=[],Z=z[8]*A,G=z[9]*A,Y=z[10]*A,Q=z[11]*A,te=z[8]*M,me=z[9]*M,ce=z[10]*M,pe=z[11]*M;for(const he of I){const de=[],Be=[];for(const je of he){const He=je.x+D.x,Xe=je.y+D.y,Ze=z[0]*He+z[4]*Xe+z[12],nt=z[1]*He+z[5]*Xe+z[13],Fe=z[2]*He+z[6]*Xe+z[14],We=z[3]*He+z[7]*Xe+z[15],Qe=Ze+Z,st=nt+G,ut=Fe+Y,bt=Math.max(We+Q,1e-5),mt=Ze+te,pt=nt+me,ht=Fe+ce,yt=Math.max(We+pe,1e-5);de.push(new Eh(Qe/bt,st/bt,ut/bt)),Be.push(new Eh(mt/yt,pt/yt,ht/yt))}B.push(de),V.push(Be)}return[B,V]}(e,t,r,c,h)}function MI(n,e,t,r,c,h,f,_){const g=f*c.getElevationAt(n,e,!0,!0),b=h[0]!==0,S=b?h[1]===0?f*(h[0]/7-450):f*function(I,A,M){const D=Math.floor(A[0]/8),z=Math.floor(A[1]/8),B=10*(A[0]-8*D),V=10*(A[1]-8*z),Z=I.getElevationAt(D,z,!0,!0),G=I.getMeterToDEM(M),Y=Math.floor(.5*(B*G-1)),Q=Math.floor(.5*(V*G-1)),te=I.tileCoordToPixel(D,z),me=2*Y+1,ce=2*Q+1,pe=function(Xe,Ze,nt,Fe,We){return[Xe.getElevationAtPixel(Ze,nt,!0),Xe.getElevationAtPixel(Ze+We,nt,!0),Xe.getElevationAtPixel(Ze,nt+We,!0),Xe.getElevationAtPixel(Ze+Fe,nt+We,!0)]}(I,te.x-Y,te.y-Q,me,ce),he=Math.abs(pe[0]-pe[1]),de=Math.abs(pe[2]-pe[3]),Be=Math.abs(pe[0]-pe[2])+Math.abs(pe[1]-pe[3]),je=Math.min(.25,.5*G*(he+de)/me),He=Math.min(.25,.5*G*Be/ce);return Z+Math.max(je*B,He*V)}(c,h,_):g;return{base:g+(t===0?-1:t),top:b?Math.max(S+r,g+t+2):g+r}}const xb=4096;class xO{constructor(e){this.module=e,this.memoryStack=this.module.malloc(xb),this.memoryStackNextFree=this.memoryStack}createIntArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>xb?-1:(new Int32Array(this.module.heap32.buffer,t,e.length).set(e),t)}createFloatArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>xb?-1:(new Float32Array(this.module.heapF32.buffer,t,e.length).set(e),t)}readStringBuffer(e){let t="";for(;this.module.heapU8[e]!==0;)t+=String.fromCharCode(this.module.heapU8[e]),++e;return t}setStyle(e){const t=e.normalScale;this.module.setStyle(t[0],t[1],t[2],e.tileToMeters)}setAOOptions(e,t){this.module.setAOOptions(e?1:0,t)}setMetricOptions(e,t){this.module.setMetricOptions(e?1:0,t)}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0)}setFacadeOptions(e,t){this.module.setFacadeOptions(e,t?1:0)}setFauxFacadeOptions(e,t,r){this.module.setFauxFacadeOptions(e?1:0,t?1:0,r)}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e)}generateMesh(e,t){this.memoryStackNextFree=this.memoryStack;for(const _ of e){const g=this.createIntArray(_.ringIndices),b=this.createFloatArray(_.coordinates);if(g===-1||b===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(_.id,_.sourceId,_.minHeight,_.height,_.roofType,b,g,_.ringIndices.length-1)}for(const _ of t){let g;g=_.entrances?JSON.parse(_.entrances):[];const b=this.createFloatArray(g),S=this.createFloatArray(_.coordinates);if(b===-1||S===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(_.sourceId,_.crossPerc,_.distanceToRoad,b,g.length,S,_.coordinates.length)}if(!this.module.generateMesh()){const _=this.module.getLastError();return this.readStringBuffer(_)}const r=this.module.getMeshCount(),c=new Array(r);for(let _=0;_<r;_++){const g=this.module.getPositionsPtr(_),b=this.module.getPositionsLength(_),S=new Float32Array(this.module.heapF32.buffer,g,b),I=this.module.getNormalsPtr(_),A=this.module.getNormalsLength(_),M=new Float32Array(this.module.heapF32.buffer,I,A),D=this.module.getAOPtr(_),z=this.module.getAOLength(_),B=new Float32Array(this.module.heapF32.buffer,D,z),V=this.module.getUVPtr(_),Z=this.module.getUVLength(_),G=new Float32Array(this.module.heapF32.buffer,V,Z),Y=this.module.getFauxFacadePtr(_),Q=this.module.getFauxFacadeLength(_),te=new Uint8Array(this.module.heapU8.buffer,Y,Q),me=this.module.getIndicesPtr(_),ce=this.module.getIndicesLength(_),pe=new Int16Array(this.module.heap16.buffer,me,ce),he=this.module.getBuildingPart(_);c[_]={positions:S,normals:M,ao:B,uv:G,isFauxFacade:te,indices:pe,buildingPart:he}}const h=this.module.getRingCount(),f=[];for(let _=0;_<h;_++){const g=this.module.getRingPtr(_),b=this.module.getRingLength(_),S=new Float32Array(this.module.heapF32.buffer,g,b);f.push(S)}return{meshes:c,outerRingLength:this.module.getOuterRingLength(),modifiedPolygonRings:f}}}let f_,ya=null,vb=null,Dx=null,RI=null,_f=null;function vO(){return Dx}const DI=5120,LI=5121,zI=5122,kI=5123,FI=5125,OI=5126,Lx={[DI]:Int8Array,[LI]:Uint8Array,[zI]:Int16Array,[kI]:Uint16Array,[FI]:Uint32Array,[OI]:Float32Array},bO={[DI]:"DT_INT8",[LI]:"DT_UINT8",[zI]:"DT_INT16",[kI]:"DT_UINT16",[FI]:"DT_UINT32",[OI]:"DT_FLOAT32"},p_={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function BI(n,e,t){const r=t.json.bufferViews.length,c=t.buffers.length;e.bufferView=r,t.json.bufferViews[r]={buffer:c,byteLength:n.byteLength},t.buffers[c]=n}const bb="KHR_draco_mesh_compression";function wO(n,e){const t=n.extensions&&n.extensions[bb];if(!t)return;const r=new ya.Decoder,c=jI(e,t.bufferView),h=new ya.Mesh;if(!r.DecodeArrayToMesh(c,c.byteLength,h))throw new Error("Failed to decode Draco mesh");const f=e.json.accessors[n.indices],_=Lx[f.componentType],g=f.count*_.BYTES_PER_ELEMENT,b=ya._malloc(g);_===Uint16Array?r.GetTrianglesUInt16Array(h,g,b):r.GetTrianglesUInt32Array(h,g,b),BI(ya.memory.buffer.slice(b,b+g),f,e),ya._free(b);for(const S of Object.keys(t.attributes)){const I=r.GetAttributeByUniqueId(h,t.attributes[S]),A=e.json.accessors[n.attributes[S]],M=bO[A.componentType],D=A.count*p_[A.type]*Lx[A.componentType].BYTES_PER_ELEMENT,z=ya._malloc(D);r.GetAttributeDataArrayForAllPoints(h,I,ya[M],D,z),BI(ya.memory.buffer.slice(z,z+D),A,e),ya._free(z)}r.destroy(),h.destroy(),delete n.extensions[bb]}const zx="EXT_meshopt_compression";function TO(n,e){if(!n.extensions||!n.extensions[zx])return;const t=n.extensions[zx],r=new Uint8Array(e.buffers[t.buffer],t.byteOffset||0,t.byteLength||0),c=new Uint8Array(t.count*t.byteStride);vb.decodeGltfBuffer(c,t.count,t.byteStride,r,t.mode,t.filter),n.buffer=e.buffers.length,n.byteOffset=0,e.buffers[n.buffer]=c.buffer,delete n.extensions[zx]}const NI=1179937895,VI=new TextDecoder("utf8");function UI(n,e){return new URL(n,e).href}async function SO(n,e,t,r,c){const h=await fetch(UI(n.uri,r),{signal:c}),f=await h.arrayBuffer();e.buffers[t]=f}function jI(n,e){const t=n.json.bufferViews[e];return new Uint8Array(n.buffers[t.buffer],t.byteOffset||0,t.byteLength)}async function EO(n,e,t,r,c){if(n.uri){const h=UI(n.uri,r),f=await fetch(h,{signal:c}),_=await f.blob(),g=await createImageBitmap(_);e.images[t]=g}else if(n.bufferView!==void 0){const h=jI(e,n.bufferView),f=new Blob([h],{type:n.mimeType}),_=await createImageBitmap(f);e.images[t]=_}}async function GI(n,e=0,t,r){const c={json:null,images:[],buffers:[]};if(new Uint32Array(n,e,1)[0]===NI){const M=new Uint32Array(n,e);let D=2;const z=(M[D++]>>2)-3,B=M[D++]>>2;if(D++,c.json=JSON.parse(VI.decode(M.subarray(D,D+B))),D+=B,D<z){const V=M[D++];D++;const Z=e+(D<<2);c.buffers[0]=n.slice(Z,Z+V)}}else c.json=JSON.parse(VI.decode(new Uint8Array(n,e)));const{buffers:h,images:f,meshes:_,extensionsUsed:g,bufferViews:b}=c.json;if(h){const M=[];for(let D=0;D<h.length;D++){const z=h[D];z.uri?M.push(SO(z,c,D,t,r)):c.buffers[D]||(c.buffers[D]=null)}await Promise.all(M)}if(r&&r.aborted)throw new DOMException("Aborted","AbortError");const S=[],I=g&&g.includes(bb),A=g&&g.includes(zx);if(I&&S.push(function(){if(!ya)return f_??(f_=function(M){let D,z=null;function B(){D=new Uint8Array(z.buffer)}function V(){throw new Error("Unexpected Draco error.")}const Z={a:{a:V,d:function(G,Y,Q){return D.copyWithin(G,Y,Y+Q)},c:function(G){const Y=D.length,Q=Math.max(G>>>0,Math.ceil(1.2*Y)),te=Math.ceil((Q-Y)/65536);try{return z.grow(te),B(),!0}catch{return!1}},b:V}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(M,Z):M.then(G=>G.arrayBuffer()).then(G=>WebAssembly.instantiate(G,Z))).then(G=>{const{Rb:Y,Qb:Q,P:te,T:me,X:ce,Ja:pe,La:he,Qa:de,Va:Be,Wa:je,eb:He,jb:Xe,f:Ze,e:nt,yb:Fe,zb:We,Ab:Qe,Bb:st,Db:ut,Gb:bt}=G.instance.exports;z=nt;const mt=(()=>{let pt=0,ht=0,yt=0,It=0;return kt=>{yt&&(Y(It),Y(pt),ht+=yt,yt=pt=0),pt||(ht+=128,pt=Q(ht));const Ct=kt.length+7&-8;let Qt=pt;Ct>=ht&&(yt=Ct,Qt=It=Q(Ct));for(let vi=0;vi<kt.length;vi++)D[Qt+vi]=kt[vi];return Qt}})();return B(),Ze(),{memory:nt,_free:Y,_malloc:Q,Mesh:class{constructor(){this.ptr=te()}destroy(){me(this.ptr)}},Decoder:class{constructor(){this.ptr=pe()}destroy(){Xe(this.ptr)}DecodeArrayToMesh(pt,ht,yt){const It=mt(pt),kt=he(this.ptr,It,ht,yt.ptr);return!!ce(kt)}GetAttributeByUniqueId(pt,ht){return{ptr:de(this.ptr,pt.ptr,ht)}}GetTrianglesUInt16Array(pt,ht,yt){Be(this.ptr,pt.ptr,ht,yt)}GetTrianglesUInt32Array(pt,ht,yt){je(this.ptr,pt.ptr,ht,yt)}GetAttributeDataArrayForAllPoints(pt,ht,yt,It,kt){He(this.ptr,pt.ptr,ht.ptr,yt,It,kt)}},DT_INT8:Fe(),DT_UINT8:We(),DT_INT16:Qe(),DT_UINT16:st(),DT_UINT32:ut(),DT_FLOAT32:bt()}})}(fetch(Xn())),f_.then(M=>{ya=M,f_=void 0}))}()),A&&S.push(function(){if(vb)return;const M=function(D){let z;const B=WebAssembly.instantiateStreaming(D,{}).then(G=>{z=G.instance,z.exports.__wasm_call_ctors()}),V={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Z={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:B,supported:!0,decodeGltfBuffer(G,Y,Q,te,me,ce){(function(pe,he,de,Be,je,He,Xe){const Ze=pe.exports.sbrk,nt=Be+3&-4,Fe=Ze(nt*je),We=Ze(He.length),Qe=new Uint8Array(pe.exports.memory.buffer);Qe.set(He,We);const st=he(Fe,Be,je,We,He.length);if(st===0&&Xe&&Xe(Fe,nt,je),de.set(Qe.subarray(Fe,Fe+Be*je)),Ze(Fe-Ze(0)),st!==0)throw new Error(`Malformed buffer data: ${st}`)})(z,z.exports[Z[me]],G,Y,Q,te,z.exports[V[ce]])}}}(fetch(Tr()));return M.ready.then(()=>{vb=M})}()),f)for(let M=0;M<f.length;M++)S.push(EO(f[M],c,M,t,r));if(S.length&&await Promise.all(S),r&&r.aborted)throw new DOMException("Aborted","AbortError");if(I&&_)for(const{primitives:M}of _)for(const D of M)wO(D,c);if(A&&_&&b)for(const M of b)TO(M,c);return c}async function $I(n,e){const t=await async function(r,c){if(c&&c.aborted)throw new DOMException("Aborted","AbortError");return new Promise((h,f)=>{const _=_c(r,(g,b)=>{g?f(g):h(b)});c&&c.addEventListener("abort",()=>{_.cancel(),f(new DOMException("Aborted","AbortError"))},{once:!0})})}({url:n,type:"arrayBuffer"},e);return GI(t,0,n,e)}function wb(n){switch(n){case WebGL2RenderingContext.RGBA8:case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Tb(n){switch(n){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.RGBA16F:return WebGL2RenderingContext.HALF_FLOAT;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class tl{constructor(e,t,r,c){this.context=e,this.format=r,this.useMipmap=c&&c.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:c&&c.premultiply})}update(e,t){const r=e&&e instanceof HTMLVideoElement&&e.width===0?e.videoWidth:e.width,c=e&&e instanceof HTMLVideoElement&&e.height===0?e.videoHeight:e.height,{context:h}=this,{gl:f}=h,{x:_,y:g}=t&&t.position?t.position:{x:0,y:0},b=_+r,S=g+c;this.size&&(this.size[0]!==b||this.size[1]!==S)&&(!t||t.recreateWhenResize===void 0||t.recreateWhenResize)&&(f.bindTexture(f.TEXTURE_2D,null),f.deleteTexture(this.texture),this.texture=f.createTexture(),this.size=null),f.bindTexture(f.TEXTURE_2D,this.texture),h.pixelStoreUnpackFlipY.set(!1),h.pixelStoreUnpack.set(1),h.pixelStoreUnpackPremultiplyAlpha.set(this.format===f.RGBA8&&(!t||t.premultiply!==!1));const I=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&b>0&&S>0){const A=this.useMipmap?Math.floor(Math.log2(Math.max(b,S)))+1:1;f.texStorage2D(f.TEXTURE_2D,A,this.format,b,S),this.size=[b,S]}this.size&&(I?f.texSubImage2D(f.TEXTURE_2D,0,_,g,wb(this.format),Tb(this.format),e):"data"in e&&e.data&&f.texSubImage2D(f.TEXTURE_2D,0,_,g,r,c,wb(this.format),Tb(this.format),e.data)),this.useMipmap&&f.generateMipmap(f.TEXTURE_2D)}bind(e,t,r=!1){const{context:c}=this,{gl:h}=c;h.bindTexture(h.TEXTURE_2D,this.texture),e!==this.minFilter&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,e),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,this.useMipmap&&!r?e===h.NEAREST?h.NEAREST_MIPMAP_NEAREST:h.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,t),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,t),this.wrapS=t)}bindExtraParam(e,t,r,c,h){const{context:f}=this,{gl:_}=f;_.bindTexture(_.TEXTURE_2D,this.texture),t!==this.magFilter&&(_.texParameteri(_.TEXTURE_2D,_.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(_.texParameteri(_.TEXTURE_2D,_.TEXTURE_MIN_FILTER,this.useMipmap?e===_.NEAREST?_.NEAREST_MIPMAP_NEAREST:_.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),r!==this.wrapS&&(_.texParameteri(_.TEXTURE_2D,_.TEXTURE_WRAP_S,r),this.wrapS=r),c!==this.wrapT&&(_.texParameteri(_.TEXTURE_2D,_.TEXTURE_WRAP_T,c),this.wrapT=c),h!==this.compareMode&&(h?(_.texParameteri(_.TEXTURE_2D,_.TEXTURE_COMPARE_MODE,_.COMPARE_REF_TO_TEXTURE),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_COMPARE_FUNC,h)):_.texParameteri(_.TEXTURE_2D,_.TEXTURE_COMPARE_MODE,_.NONE),this.compareMode=h)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class m_{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:r}=this,{gl:c}=r;c.bindTexture(c.TEXTURE_2D,this.texture),e!==this.minFilter&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,e),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,t),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,t),this.wrapS=t)}}const IO=pi([{name:"a_pos_3f",components:3,type:"Float32"}]),AO=pi([{name:"a_color_3f",components:3,type:"Float32"}]),CO=pi([{name:"a_color_4f",components:4,type:"Float32"}]),PO=pi([{name:"a_uv_2f",components:2,type:"Float32"}]),MO=pi([{name:"a_normal_3f",components:3,type:"Float32"}]),RO=pi([{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"}]),DO=pi([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function HI(n,e){const t=kx(n.projection,n.zoom,n.width,n.height),r=function(h,f,_,g,b){const S=new ve(_.lng-180*qc,_.lat),I=new ve(_.lng+180*qc,_.lat),A=h.project(S.lng,S.lat),M=h.project(I.lng,I.lat),D=-Math.atan2(M.y-A.y,M.x-A.x),z=Et.fromLngLat(_);z.y=q(z.y,-1+qc,1-qc);const B=z.toLngLat(),V=h.project(B.lng,B.lat),Z=Et.fromLngLat(B);Z.x+=qc;const G=Z.toLngLat(),Y=h.project(G.lng,G.lat),Q=qI(Y.x-V.x,Y.y-V.y,D),te=Et.fromLngLat(B);te.y+=qc;const me=te.toLngLat(),ce=h.project(me.lng,me.lat),pe=qI(ce.x-V.x,ce.y-V.y,D),he=Math.abs(Q.x)/Math.abs(pe.y),de=Ye([]);Rt(de,de,-D*(1-(b?0:g)));const Be=Ye([]);return qe(Be,Be,[1,1-(1-he)*g,1]),Be[4]=-pe.x/pe.y*g,Rt(Be,Be,D),ye(Be,de,Be),Be}(n.projection,0,n.center,t,e),c=ZI(n);return qe(r,r,[c,c,1]),r}function ZI(n){const e=n.projection,t=kx(n.projection,n.zoom,n.width,n.height),r=Sb(e,n.center),c=Sb(e,ve.convert(e.center));return Math.pow(2,r*t+(1-t)*c)}function kx(n,e,t,r,c=1/0){const h=n.range;if(!h)return 0;const f=Math.min(c,Math.max(t,r)),_=Math.log2(f/1024);return oe(h[0]+_,h[1]+_,e)}const qc=1/4e4;function Sb(n,e){const t=q(e.lat,-85.051129,$e),r=new ve(e.lng-180*qc,t),c=new ve(e.lng+180*qc,t),h=n.project(r.lng,t),f=n.project(c.lng,t),_=Et.fromLngLat(r),g=Et.fromLngLat(c),b=f.x-h.x,S=f.y-h.y,I=g.x-_.x,A=g.y-_.y,M=Math.sqrt((I*I+A*A)/(b*b+S*S));return Math.log2(M)}function qI(n,e,t){const r=Math.cos(t),c=Math.sin(t);return{x:n*r-e*c,y:n*c+e*r}}function WI(n,e,t){Ye(n),Rt(n,n,Ei(e[2])),ot(n,n,Ei(e[0])),xt(n,n,Ei(e[1])),qe(n,n,t),ye(n,n,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function Fx(n,e,t,r,c,h,f,_){const g=[t[0]-e[0],t[1]-e[1],0],b=[r[0]-e[0],r[1]-e[1],0];if(Wn(g)<1e-12||Wn(b)<1e-12)return aa(n);const S=On([],g,b);zi(S,S),$t(b,r,e),g[2]=(h-c)*_,b[2]=(f-c)*_;const I=g;return On(I,g,b),zi(I,I),Eu(n,S,I)}function Ox(n,e,t=!1){const r=Ul(e.zoom),c=function(h,f,_){const g=f.worldSize,b=[h[12],h[13],h[14]],S=Oe(b[1]/g),I=we(b[0]/g),A=Ye([]),M=Pe(1,S)*g,D=Pe(1,0)*g*lt(S,f.zoom),z=1/X1(g);let B=D*z;if(_){const Y=kx(f.projection,f.zoom,f.width,f.height,1024);B=z*f.projection.pixelSpaceConversion(f.center.lat,g,Y)}const V=ae(S,I);Pt(V,V,mi([],zi([],V),M*B*b[2]));const Z=function(Y){const Q=[Y[0],Y[1],Y[2]];let te=[0,1,0];const me=On([],te,Q);return On(te,Q,me),Rr(te)===0&&(te=[0,1,0],On(me,Q,te)),zi(me,me),zi(te,te),zi(Q,Q),[me[0],me[1],me[2],0,te[0],te[1],te[2],0,Q[0],Q[1],Q[2],0,Y[0],Y[1],Y[2],1]}(V);qe(A,A,[B,B,B*M]),Ie(A,A,[-b[0],-b[1],-b[2]]);const G=ye([],f.globeMatrix,Z);return ye(G,G,A),ye(G,G,h),G}(n,e,t);if(r>0){const h=function(f,_){const g=_.worldSize,b=Pe(1,0)*g*lt(_.center.lat,_.zoom)/X1(g),S=Pe(1,_.center.lat)*g,I=Ye([]);xt(I,I,Ei(_.center.lng)),ot(I,I,Ei(_.center.lat)),Ie(I,I,[0,0,ne]),qe(I,I,[b,b,b*S]);const A=_.point;return Ie(I,I,[-A.x,-A.y,0]),ye(I,I,f),ye(I,_.globeMatrix,I)}(n,e);return function(f,_,g){const b=(D,z,B)=>{const V=Wn(D),Z=Wn(z),G=Vl(D,z,B);return mi(G,G,1/Wn(G)*Gt(V,Z,B))},S=b([f[0],f[1],f[2]],[_[0],_[1],_[2]],g),I=b([f[4],f[5],f[6]],[_[4],_[5],_[6]],g),A=b([f[8],f[9],f[10]],[_[8],_[9],_[10]],g),M=Vl([f[12],f[13],f[14]],[_[12],_[13],_[14]],g);return[S[0],S[1],S[2],0,I[0],I[1],I[2],0,A[0],A[1],A[2],0,M[0],M[1],M[2],1]}(c,h,r)}return c}function Eb(n,e,t,r){const c=Li.projectAabbCorners(r,t);let h=Number.MAX_VALUE;for(let _=0;_<c.length;++_){const g=c[_];g[0]=(.5*g[0]+.5)*e.width,g[1]=(.5-.5*g[1])*e.height,g[2]<h&&(h=g[2])}const f=function(_){const g=[];let b=0;for(let M=1;M<_.length;M++)(_[M][0]<_[b][0]||_[M][0]===_[b][0]&&_[M][1]<_[b][1])&&(b=M);let S,I=b;const A=new Uint8Array(_.length);do{if(A[I])break;g.push(new it(_[I][0],_[I][1])),A[I]=1,S=(I+1)%_.length;for(let M=0;M<_.length;M++){if(_[M][0]===_[S][0]&&_[M][1]===_[S][1]||_[M][0]===_[I][0]&&_[M][1]===_[I][1])continue;const D=[_[M][0]-_[I][0],_[M][1]-_[I][1]],z=[_[S][0]-_[I][0],_[S][1]-_[I][1]],B=D[0]*z[1]-D[1]*z[0];(B>0||B===0&&D[0]*z[0]+D[1]*z[1]>=0&&D[0]*D[0]+D[1]*D[1]>z[0]*z[0]+z[1]*z[1])&&(S=M)}I=S}while(I!==b);return g.length>0&&g.push(g[0]),g}(c);if(Mn(n,f))return h}const Ih=64,gf={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Bx(n,e,t,r,c,h,f,_,g,b=!1){const S=t.zoom,I=t.project(r),A=lt(r.lat,S),M=1/A;Ye(n),Ie(n,n,[I.x+f[0]*M,I.y+f[1]*M,f[2]]);let D=1,z=1;const B=t.worldSize;if(b){if(t.projection.name==="mercator"){let Y=0;t.elevation&&(Y=t.elevation.getAtPointOrZero(new Et(I.x/B,I.y/B),0));const Q=vr([],[I.x,I.y,Y,1],t.projMatrix)[3]/t.cameraToCenterDistance;D=Q,z=Q*lt(t.center.lat,S)}else if(t.projection.name==="globe"){const Y=Ox(n,t),Q=[0,0,0,1];vr(Q,Q,ye([],t.projMatrix,Y));const te=Q[3]/t.cameraToCenterDistance,me=Ul(S),ce=t.projection.pixelsPerMeter(r.lat,B)*lt(r.lat,S),pe=t.projection.pixelsPerMeter(t.center.lat,B)*lt(t.center.lat,S);D=te/Gt(ce,ft(t.center.lat),me),z=te*A/ce,D*=pe,z*=pe}}else D=M;qe(n,n,[D,D,z]);const V=[...n],Z=e.orientation,G=[];if(WI(G,[Z[0]+(c?c[0]:0),Z[1]+(c?c[1]:0),Z[2]+(c?c[2]:0)],h),ye(n,V,G),_&&t.elevation){let Y=0;const Q=[];if(g&&t.elevation){Y=function(me,ce,pe,he,de){const Be=ce.elevation;if(!Be)return 0;const je=Li.projectAabbCorners(pe,he),He=Pe(1,de.lat)*ce.worldSize,Xe=function(ht,yt){const It=[0,0,1],kt=[{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 Ct of kt){const Qt=ht[Ct.corners[0]],vi=ht[Ct.corners[1]],ei=ht[Ct.corners[2]],wi=[vi[0]-Qt[0],vi[1]-Qt[1],yt*(vi[2]-Qt[2])],ai=On(wi,wi,[ei[0]-Qt[0],ei[1]-Qt[1],yt*(ei[2]-Qt[2])]);zi(ai,ai),Ct.dotProductWithUp=pn(ai,It)}return kt.sort((Ct,Qt)=>Ct.dotProductWithUp-Qt.dotProductWithUp),kt[0].corners}(je,He),Ze=je[Xe[0]],nt=je[Xe[1]],Fe=je[Xe[2]],We=je[Xe[3]],Qe=Be.getAtPointOrZero(new Et(Ze[0]/ce.worldSize,Ze[1]/ce.worldSize),0),st=Be.getAtPointOrZero(new Et(nt[0]/ce.worldSize,nt[1]/ce.worldSize),0),ut=Be.getAtPointOrZero(new Et(Fe[0]/ce.worldSize,Fe[1]/ce.worldSize),0),bt=Be.getAtPointOrZero(new Et(We[0]/ce.worldSize,We[1]/ce.worldSize),0),mt=(Qe+bt)/2,pt=(st+ut)/2;return mt>pt?st<ut?Fx(me,nt,We,Ze,st,bt,Qe,He):Fx(me,Fe,Ze,We,ut,Qe,bt,He):Qe<bt?Fx(me,Ze,nt,Fe,Qe,st,ut,He):Fx(me,We,Fe,nt,bt,ut,st,He),Math.max(mt,pt)}(Q,t,e.aabb,n,r);const te=ye([],Ji([],Q),G);ye(n,V,te)}else Y=t.elevation.getAtPointOrZero(new Et(I.x/B,I.y/B),0);Y!==0&&(n[14]+=Y)}}class XI{constructor(e,t,r,c,h){this.materialOverrides=new Map,this.nodeOverrides=new Map,this.materialOverrideNames=[],this.nodeOverrideNames=[],this.featureProperties={},this.id=e,this.uri=t,this.position=r!=null?new ve(r[0],r[1]):new ve(0,0),this.orientation=c??[0,0,0],this.nodes=h,this.uploaded=!1,this.aabb=new Li([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,t){ye(e.globalMatrix,t,e.localMatrix);const r=this.nodeOverrides.get(e.name);if(r!==void 0){const f=[];h=r.orientation,Ye(c=f),xt(c,c,Ei(h[1])),Rt(c,c,Ei(h[2])),ot(c,c,Ei(h[0])),ye(e.globalMatrix,e.globalMatrix,f)}var c,h;if(e.meshes)for(const f of e.meshes){const _=Li.applyTransformFast(f.aabb,e.globalMatrix);this.aabb.encapsulate(_)}if(e.children)for(const f of e.children)this._applyTransformations(f,e.globalMatrix)}computeBoundsAndApplyParent(){const e=Ye([]);this.aabb=new Li([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const t of this.nodes)this._applyTransformations(t,e)}computeModelMatrix(e,t,r,c,h,f,_=!1){Bx(this.matrix,this,e.transform,this.position,t,r,c,h,f,_)}upload(e){if(!this.uploaded){for(const t of this.nodes)Ib(t,e);for(const t of this.nodes)Nx(t);this.uploaded=!0}}destroy(){for(const e of this.nodes)Ab(e)}}function __(n,e,t=!1){n.uploaded||(n.gfxTexture=new tl(e,n.image,t?e.gl.R8:e.gl.RGBA8,{useMipmap:n.sampler.minFilter>=e.gl.NEAREST_MIPMAP_NEAREST}),n.uploaded=!0,n.image=null)}function LO(n,e,t){n.indexBuffer=e.createIndexBuffer(n.indexArray,!1,!0),n.vertexBuffer=e.createVertexBuffer(n.vertexArray,IO.members,!1,!0),n.normalArray&&(n.normalBuffer=e.createVertexBuffer(n.normalArray,MO.members,!1,!0)),n.texcoordArray&&(n.texcoordBuffer=e.createVertexBuffer(n.texcoordArray,PO.members,!1,!0)),n.colorArray&&(n.colorBuffer=e.createVertexBuffer(n.colorArray,(n.colorArray.bytesPerElement===12?AO:CO).members,!1,!0)),n.featureArray&&(n.pbrBuffer=e.createVertexBuffer(n.featureArray,DO.members,!0)),n.segments=$i.simpleSegment(0,0,n.vertexArray.length,n.indexArray.length);const r=n.material;r.pbrMetallicRoughness.baseColorTexture&&__(r.pbrMetallicRoughness.baseColorTexture,e),r.pbrMetallicRoughness.metallicRoughnessTexture&&__(r.pbrMetallicRoughness.metallicRoughnessTexture,e),r.normalTexture&&__(r.normalTexture,e),r.occlusionTexture&&__(r.occlusionTexture,e,t),r.emissionTexture&&__(r.emissionTexture,e)}function Ib(n,e,t){if(n.meshes)for(const r of n.meshes)LO(r,e,t);if(n.children)for(const r of n.children)Ib(r,e,t)}function Nx(n){if(n.meshes)for(const e of n.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(n.children)for(const e of n.children)Nx(e)}function zO(n){n.pbrMetallicRoughness.baseColorTexture&&n.pbrMetallicRoughness.baseColorTexture.gfxTexture&&n.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),n.pbrMetallicRoughness.metallicRoughnessTexture&&n.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&n.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),n.normalTexture&&n.normalTexture.gfxTexture&&n.normalTexture.gfxTexture.destroy(),n.emissionTexture&&n.emissionTexture.gfxTexture&&n.emissionTexture.gfxTexture.destroy(),n.occlusionTexture&&n.occlusionTexture.gfxTexture&&n.occlusionTexture.gfxTexture.destroy()}function Ab(n){if(n.meshes)for(const e of n.meshes)e.vertexBuffer&&(e.vertexBuffer.destroy(),e.indexBuffer.destroy(),e.normalBuffer&&e.normalBuffer.destroy(),e.texcoordBuffer&&e.texcoordBuffer.destroy(),e.colorBuffer&&e.colorBuffer.destroy(),e.pbrBuffer&&e.pbrBuffer.destroy(),e.segments.destroy(),e.material&&zO(e.material));if(n.footprintDebugMesh&&(n.footprintDebugMesh.vertexBuffer.destroy(),n.footprintDebugMesh.indexBuffer.destroy(),n.footprintDebugMesh.segments.destroy()),n.children)for(const e of n.children)Ab(e)}function Ah(n,e){const t=n.json.bufferViews[e.bufferView],r=Lx[e.componentType];return new r(n.buffers[t.buffer],(e.byteOffset||0)+(t.byteOffset||0),e.count*(t.byteStride&&t.byteStride!==p_[e.type]*r.BYTES_PER_ELEMENT?t.byteStride/r.BYTES_PER_ELEMENT:p_[e.type]))}function Cb(n,e,t,r){const c=Lx[e.componentType],h=function(S){switch(S){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(c),f=n.json.bufferViews[e.bufferView],_=f.byteStride?f.byteStride/c.BYTES_PER_ELEMENT:p_[e.type],g=t.float32,b=g.length/t.capacity;for(let S=0,I=0;S<e.count*_;S+=_,I+=b)for(let A=0;A<b;A++)g[I+A]=r[S+A]*h;t._trim()}function kO(n,e,t){const r=n.indices,c=n.attributes,h={};h.indexArray=new Tn;const f=e.json.accessors[r],_=f.count/3;h.indexArray.reserve(_);const g=Ah(e,f);for(let A=0;A<_;A++)h.indexArray.emplaceBack(g[3*A],g[3*A+1],g[3*A+2]);h.indexArray._trim(),h.vertexArray=new Qs;const b=e.json.accessors[c.POSITION];h.vertexArray.reserve(b.count);const S=Ah(e,b);for(let A=0;A<b.count;A++)h.vertexArray.emplaceBack(S[3*A],S[3*A+1],S[3*A+2]);if(h.vertexArray._trim(),h.aabb=new Li(b.min,b.max),h.centroid=function(A,M){const D=[0,0,0],z=A.length;if(z>0){for(let B=0;B<z;B++){const V=3*A[B];D[0]+=M[V],D[1]+=M[V+1],D[2]+=M[V+2]}D[0]/=z,D[1]/=z,D[2]/=z}return D}(g,S),c.COLOR_0!==void 0){const A=e.json.accessors[c.COLOR_0],M=p_[A.type],D=Ah(e,A);h.colorArray=M===3?new Qs:new _a,h.colorArray.resize(A.count),Cb(e,A,h.colorArray,D)}if(c.NORMAL!==void 0){h.normalArray=new Qs;const A=e.json.accessors[c.NORMAL];h.normalArray.resize(A.count);const M=Ah(e,A);Cb(e,A,h.normalArray,M)}if(c.TEXCOORD_0!==void 0&&t.length>0){h.texcoordArray=new Fl;const A=e.json.accessors[c.TEXCOORD_0];h.texcoordArray.resize(A.count);const M=Ah(e,A);Cb(e,A,h.texcoordArray,M)}if(c._FEATURE_ID_RGBA4444!==void 0){const A=e.json.accessors[c._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(h.featureData=Ah(e,A))}c._FEATURE_RGBA4444!==void 0&&(h.featureData=new Uint32Array(Ah(e,e.json.accessors[c._FEATURE_RGBA4444]).buffer));const I=n.material;return h.material=function(A,M){const{emissiveFactor:D=[0,0,0],alphaMode:z="OPAQUE",alphaCutoff:B=.5,normalTexture:V,occlusionTexture:Z,emissiveTexture:G,doubleSided:Y,name:Q}=A,{baseColorFactor:te=[1,1,1,1],metallicFactor:me=1,roughnessFactor:ce=1,baseColorTexture:pe,metallicRoughnessTexture:he}=A.pbrMetallicRoughness||{},de=Z?M[Z.index]:void 0;if(Z&&Z.extensions&&Z.extensions.KHR_texture_transform&&de){const Be=Z.extensions.KHR_texture_transform;de.offsetScale=[Be.offset[0],Be.offset[1],Be.scale[0],Be.scale[1]]}return{name:Q,pbrMetallicRoughness:{baseColorFactor:new Ii(...te),metallicFactor:me,roughnessFactor:ce,baseColorTexture:pe?M[pe.index]:void 0,metallicRoughnessTexture:he?M[he.index]:void 0},doubleSided:Y,emissiveFactor:new Ii(...D),alphaMode:z,alphaCutoff:B,normalTexture:V?M[V.index]:void 0,occlusionTexture:de,emissionTexture:G?M[G.index]:void 0,defined:A.defined===void 0}}(I!==void 0?e.json.materials[I]:{defined:!1},t),h}function YI(n,e,t){const{matrix:r,rotation:c,translation:h,scale:f,mesh:_,extras:g,children:b,name:S}=n,I={};if(I.name=S,I.localMatrix=r||function(A,M,D,z){var B=M[0],V=M[1],Z=M[2],G=M[3],Y=B+B,Q=V+V,te=Z+Z,me=B*Y,ce=B*Q,pe=B*te,he=V*Q,de=V*te,Be=Z*te,je=G*Y,He=G*Q,Xe=G*te,Ze=z[0],nt=z[1],Fe=z[2];return A[0]=(1-(he+Be))*Ze,A[1]=(ce+Xe)*Ze,A[2]=(pe-He)*Ze,A[3]=0,A[4]=(ce-Xe)*nt,A[5]=(1-(me+Be))*nt,A[6]=(de+je)*nt,A[7]=0,A[8]=(pe+He)*Fe,A[9]=(de-je)*Fe,A[10]=(1-(me+he))*Fe,A[11]=0,A[12]=D[0],A[13]=D[1],A[14]=D[2],A[15]=1,A}([],c||[0,0,0,1],h||[0,0,0],f||[1,1,1]),I.globalMatrix=ke(I.localMatrix),_!==void 0){I.meshes=t[_];const A=I.anchor=[0,0];for(const M of I.meshes){const{min:D,max:z}=M.aabb;A[0]+=D[0]+z[0],A[1]+=D[1]+z[1]}A[0]=Math.floor(A[0]/I.meshes.length/2),A[1]=Math.floor(A[1]/I.meshes.length/2)}if(g&&(g.id&&(I.id=g.id),g.lights&&(I.lights=function(A){if(!A.length)return[];const M=function(Z){const G=atob(Z),Y=new Uint8Array(G.length);for(let Q=0;Q<G.length;Q++)Y[Q]=G.codePointAt(Q);return Y}(A),D=[],z=M.length/24,B=new Uint16Array(M.buffer),V=new Float32Array(M.buffer);for(let Z=0;Z<z;Z++){const G=B[2*Z*6]/30,Y=B[2*Z*6+1]/30,Q=B[2*Z*6+10]/100,te=V[6*Z+1],me=V[6*Z+2],ce=V[6*Z+3],pe=V[6*Z+4],he=ce-te,de=pe-me,Be=Math.hypot(he,de);D.push({pos:[te+.5*he,me+.5*de,Y],normal:[de/Be,-he/Be,0],width:Be,height:G,depth:Q,points:[te,me,ce,pe]})}return D}(g.lights)),g.MAPBOX_geometry_bloom&&(I.isGeometryBloom=g.MAPBOX_geometry_bloom)),b){const A=[];for(const M of b)A.push(YI(e.json.nodes[M],e,t));I.children=A}return I}function FO(n){if(n.vertices.length===0||n.indices.length===0)return null;const e=new Tx(n.vertices,n.indices,8,256),[t,r]=[e.min.clone(),e.max.clone()];return{vertices:n.vertices,indices:n.indices,grid:e,min:t,max:r}}function OO(n){if(!n.extras||!n.extras.ground)return null;const e=n.extras.ground;if(!e||!Array.isArray(e)||e.length===0)return null;const t=e[0];if(!t||!Array.isArray(t)||t.length===0)return null;const r=[];for(const f of t){if(!Array.isArray(f)||f.length!==2)continue;const _=f[0],g=f[1];typeof _=="number"&&typeof g=="number"&&r.push(new it(_,g))}if(r.length<3)return null;r.length>1&&r[r.length-1].equals(r[0])&&r.pop();let c=0;for(let f=0;f<r.length;f++){const _=r[f],g=r[(f+1)%r.length],b=r[(f+2)%r.length];c+=(_.x-g.x)*(b.y-g.y)-(b.x-g.x)*(_.y-g.y)}c>0&&r.reverse();const h=df(r.flatMap(f=>[f.x,f.y]),[]);return h.length===0?null:{vertices:r,indices:h}}function BO(n,e){const t=[],r=[];let c=0;const h=[];for(const f of n){c=t.length;const _=f.vertexArray.float32,g=f.indexArray.uint16;for(let b=0;b<f.vertexArray.length;b++)h[0]=_[3*b+0],h[1]=_[3*b+1],h[2]=_[3*b+2],mn(h,h,e),t.push(new it(h[0],h[1]));for(let b=0;b<3*f.indexArray.length;b++)r.push(g[b]+c)}if(r.length%3!=0)return null;for(let f=0;f<r.length;f+=3){const _=t[r[f+0]],g=t[r[f+1]],b=t[r[f+2]];(_.x-g.x)*(b.y-g.y)-(b.x-g.x)*(_.y-g.y)>0&&([r[f+1],r[f+2]]=[r[f+2],r[f+1]])}return{vertices:t,indices:r}}function Pb(n){const e=function(g,b){const S=[],I=WebGL2RenderingContext;if(g.json.textures)for(const A of g.json.textures){const M={magFilter:I.LINEAR,minFilter:I.NEAREST,wrapS:I.REPEAT,wrapT:I.REPEAT};A.sampler!==void 0&&Object.assign(M,g.json.samplers[A.sampler]),S.push({image:b[A.source],sampler:M,uploaded:!1})}return S}(n,n.images),t=function(g,b){const S=[];for(const I of g.json.meshes){const A=[];for(const M of I.primitives)A.push(kO(M,g,b));S.push(A)}return S}(n,e),{scenes:r,scene:c,nodes:h}=n.json,f=r?r[c||0].nodes:[...h.keys()],_=[];for(const g of f)_.push(YI(h[g],n,t));return function(g,b,S){const I={},A=new Set;for(let M=0;M<g.length;M++){const D=S[b[M]];if(!D.extras)continue;const z=D.extras["mapbox:footprint:version"],B=D.extras["mapbox:footprint:id"];(z||B)&&A.add(M),z==="1.0.0"&&B&&(I[B]=M)}for(let M=0;M<g.length;M++){if(A.has(M))continue;const D=g[M],z=S[b[M]];if(!z.extras)continue;let B=null;D.id in I&&(B=BO(g[I[D.id]].meshes,D.localMatrix)),B||(B=OO(z)),B&&(D.footprint=FO(B))}if(A.size>0){const M=Array.from(A.values()).sort((D,z)=>D-z);for(let D=M.length-1;D>=0;D--)g.splice(M[D],1)}}(_,f,n.json.nodes),_}function NO(n){n.heightmap=new Float32Array(4096),n.heightmap.fill(-1);const e=n.vertexArray.float32,t=n.aabb.min[0]-1,r=n.aabb.min[1]-1,c=Ih/(n.aabb.max[0]-t+2),h=Ih/(n.aabb.max[1]-r+2);for(let f=0;f<e.length;f+=3){const _=e[f+2],g=(e[f+0]-t)*c|0,b=(e[f+1]-r)*h|0;_>n.heightmap[b*Ih+g]&&(n.heightmap[b*Ih+g]=_)}}function KI(n,e,t,r,c){t.reserve(t.length+4*n.length),r.reserve(r.length+10*n.length),c.reserve(c.length+10*n.length);let h=r.length;for(const f of n){const _=Math.min(10,Math.max(4,1.3*f.height))*e,g=[-f.normal[1],f.normal[0],0],b=Math.min(.29,.1*f.width/f.depth),S=f.width-2*f.depth*e*(b+.01),I=rn([],f.pos,g,S/2),A=rn([],f.pos,g,-S/2),M=[I[0],I[1],I[2]+f.height],D=[A[0],A[1],A[2]+f.height],z=rn([],f.normal,g,b);mi(z,z,_);const B=rn([],f.normal,g,-b);mi(B,B,_),Pt(z,I,z),Pt(B,A,B),I[2]+=.1,A[2]+=.1,r.emplaceBack(z[0],z[1],z[2]),r.emplaceBack(B[0],B[1],B[2]),r.emplaceBack(I[0],I[1],I[2]),r.emplaceBack(A[0],A[1],A[2]),r.emplaceBack(M[0],M[1],M[2]),r.emplaceBack(D[0],D[1],D[2]),r.emplaceBack(I[0],I[1],I[2]),r.emplaceBack(A[0],A[1],A[2]),r.emplaceBack(z[0],z[1],z[2]),r.emplaceBack(B[0],B[1],B[2]);const V=S/_/2;c.emplaceBack(-V-b,-1,V,.8),c.emplaceBack(V+b,-1,V,.8),c.emplaceBack(-V,0,V,1.3),c.emplaceBack(V,0,V,1.3),c.emplaceBack(V+b,-.8,V,.7),c.emplaceBack(V+b,-.8,V,.7),c.emplaceBack(0,0,V,1.3),c.emplaceBack(0,0,V,1.3),c.emplaceBack(V+b,-1.2,V,.8),c.emplaceBack(V+b,-1.2,V,.8),t.emplaceBack(6+h,4+h,8+h),t.emplaceBack(7+h,9+h,5+h),t.emplaceBack(0+h,1+h,2+h),t.emplaceBack(1+h,3+h,2+h),h+=10}}function VO(n,e){const t={};t.indexArray=new Tn,t.vertexArray=new Qs,t.colorArray=new _a,KI(n,e,t.indexArray,t.vertexArray,t.colorArray);const r={defined:!0};r.emissiveFactor=Ii.black;const c={};return c.baseColorFactor=Ii.white,r.pbrMetallicRoughness=c,t.material=r,t.aabb=new Li([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),t}const JI=pi([{name:"a_pos_3f",components:3,type:"Float32"}]),UO=pi([{name:"a_normal_3",components:3,type:"Int16"}]),jO=pi([{name:"a_centroid_3",components:3,type:"Int16"}]),QI=pi([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),GO=pi([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),$O=pi([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),HO=pi([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),ZO=pi([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),qO=pi([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Int16"}]),eA=qt.types,Vx=32767;function WO(n,e){const t=_t+e;for(const r of n)for(const c of r)if(c.x<-e||c.x>t||c.y<-e||c.y>t)return!1;return!0}function XO(n){switch(n){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${n}`)}}class Mb{constructor(){this.layoutVertexArray=new Qs,this.layoutAttenuationArray=new _a,this.layoutColorArray=new eo,this.indexArray=new Tn,this.indexArrayForConflation=new Tn,this.segmentsBucket=new $i}}class Rb{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new $i,this.entranceBloom=new Mb;const t=66560;this.layoutVertexArray=new Qs,this.layoutVertexArray.reserve(t),this.layoutNormalArray=new Go,this.layoutNormalArray.reserve(t),this.layoutCentroidArray=new Go,this.layoutCentroidArray.reserve(t),this.layoutColorArray=new eo,this.layoutColorArray.reserve(t),this.layoutFloodLightDataArray=new of,this.layoutFloodLightDataArray.reserve(t),this.layoutAOArray=new af,this.layoutAOArray.reserve(t),this.indexArray=new Tn,this.indexArray.reserve(66560),this.indexArrayForConflation=new Tn,this.segmentsBucket=new $i,this.entranceBloom=new Mb,e&&(this.layoutFacadePaintArray=new eo,this.layoutFacadeDataArray=new Vc,this.layoutFacadeVerticalRangeArray=new eo)}reserve(e,t,r){this.layoutVertexArray.reserveForAdditional(e),this.layoutCentroidArray.reserveForAdditional(e),this.layoutFloodLightDataArray.reserveForAdditional(e),this.layoutNormalArray.reserveForAdditional(e),this.layoutAOArray.reserveForAdditional(e),this.layoutColorArray.reserveForAdditional(e),this.indexArray.reserveForAdditional(t),r&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e))}}class tA{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Fl,this.footprintsIndices=new Ol,this.footprintsMin=new it(1/0,1/0),this.footprintsMax=new it(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Rb(!1),this.buildingWithFacade=new Rb(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new N(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.projection=e.projection,this.groundEffect=new gb(e),this.groundEffect.groundRadiusArray=new Rs,this.hasAppearances=null}updateFootprints(e,t){const r=new Tx([],[],1),c={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};t.push({footprint:c,id:e})}updateAppearances(e,t,r,c){return{hasLayoutChanges:!1,hasUboChanges:!1}}prepare(){return function(){if(Dx!=null||RI!=null)return null;if(_f!=null)return _f;const e=fetch(gr());return _f=function(t){let r,c,h,f,_;function g(){r=new Uint8Array(_.buffer),c=new Int16Array(_.buffer),h=new Int32Array(_.buffer),f=new Float32Array(_.buffer)}function b(){throw new Error("Unexpected BuildingGen error.")}const S=()=>{},I={a:{a:b,f:function(A){const M=r.length,D=Math.max(A>>>0,Math.ceil(1.2*M)),z=Math.ceil((D-M)/65536);try{return _.grow(z),g(),!0}catch{return!1}},g:b,b:S,c:S,d:S,e:S}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,I):t.then(A=>A.arrayBuffer()).then(A=>WebAssembly.instantiate(A,I))).then(A=>{const M=A.instance.exports;return(0,M.g)(),_=M.f,g(),new xO({setStyle:M.h,setAOOptions:M.i,setMetricOptions:M.j,setStructuralOptions:M.k,setFacadeOptions:M.l,setFauxFacadeOptions:M.m,setFacadeClassifierOptions:M.n,addFeature:M.o,addFacade:M.p,generateMesh:M.q,getLastError:M.r,getOuterRingLength:M.s,getMeshCount:M.t,getPositionsPtr:M.u,getPositionsLength:M.v,getNormalsPtr:M.w,getNormalsLength:M.x,getAOPtr:M.y,getAOLength:M.z,getUVPtr:M.A,getUVLength:M.B,getFauxFacadePtr:M.C,getFauxFacadeLength:M.D,getIndicesPtr:M.E,getIndicesLength:M.F,getBuildingPart:M.G,getRingCount:M.H,getRingPtr:M.I,getRingLength:M.J,malloc:M.K,free:M.L,heapU8:r,heap16:c,heap32:h,heapF32:f})})}(e).then(t=>(_f=null,Dx=t,Dx)).catch(t=>{zt("Could not load building-gen"),_f=null,RI=t instanceof Error?t:new Error("Unknown error")}),_f}()}populate(e,t,r,c){const h=vO();if(!h)return;const f=et(r);this.tileToMeter=f,this.brightness=t.brightness,h.setStyle({normalScale:[1,-1,f],tileToMeters:f}),h.setAOOptions(!1,.3),h.setMetricOptions(!1,16),h.setStructuralOptions(!0),h.setFacadeClassifierOptions(3);const _=new Map,g=new Map;let b=0;for(const{feature:V}of e){if(eA[V.type]!=="LineString"){_.set(V.id,V.properties.source_id);continue}const Z=this.layers[0]._featureFilter.needGeometry;if(Z&&!this.layers[0]._featureFilter.filter(new Mi(this.zoom),V,r))continue;const G=oi(V,Z);if(!Z&&!this.layers[0]._featureFilter.filter(new Mi(this.zoom),G,r))continue;const Y=Z?G.geometry:Ft(V,r,c),Q=[];for(const pe of Y)for(const he of pe)Q.push(he.x),Q.push(he.y);const te={coordinates:Q,crossPerc:V.properties.cross_perc,distanceToRoad:V.properties.distance_to_road,entrances:V.properties.entrances,sourceId:0},me=V.properties.source_id;let ce=g.get(me);ce||(ce=[],g.set(me,ce)),ce.push(te),++b}this.maxHeight=0;const S=new Array,I=new Set,A=V=>{V!=null&&I.add(V)},M=(V,Z)=>{V!=null&&S.push({buildingId:V,footprintIndex:Z})},D=64*(e.length-b),z=D/2;this.buildingWithFacade.reserve(D,z,!0),this.buildingWithoutFacade.reserve(2*D,2*z,!1),this.footprintsIndices.reserve(16*(e.length-b)),this.footprintsVertices.reserve(8*(e.length-b));for(const{feature:V,id:Z,index:G,sourceLayerIndex:Y}of e){if(eA[V.type]==="LineString")continue;const Q=this.layers[0]._featureFilter.needGeometry;if(Q&&!this.layers[0]._featureFilter.filter(new Mi(this.zoom),V,r))continue;let te=null;if(V.properties&&V.properties.hasOwnProperty("building_id")&&(te=Number(V.properties.building_id),I.has(te)))continue;const me=oi(V,Q);if(!Q&&!this.layers[0]._featureFilter.filter(new Mi(this.zoom),me,r))continue;const ce=Q?me.geometry:Ft(V,r,c),pe=s_(ce,500);let he=!1;for(const di of pe)if(di.length!==1){he=!0;break}if(he){A(te);continue}if(!WO(ce,163)){A(te);continue}const de=this.layers[0],Be=XO(de.layout.get("building-roof-shape").evaluate(V,{},r)),je=de.layout.get("building-base").evaluate(V,{},r),He=de.layout.get("building-height").evaluate(V,{},r),Xe=de.layout.get("building-flood-light-ground-radius").evaluate(V,{},r),Ze=de.paint.get("building-ambient-occlusion-intensity"),nt=Xe/this.tileToMeter;V.properties["building-part"]="roof";const Fe=de.paint.get("building-color").evaluate(V,{},this.canonical).toPremultipliedRenderColor(this.lut),We=de.paint.get("building-emissive-strength").evaluate(V,{},this.canonical);V.properties["building-part"]="wall";const Qe=de.paint.get("building-color").evaluate(V,{},this.canonical).toPremultipliedRenderColor(this.lut),st=de.paint.get("building-emissive-strength").evaluate(V,{},this.canonical);V.properties["building-part"]="window";const ut=de.paint.get("building-color").evaluate(V,{},this.canonical).toPremultipliedRenderColor(this.lut),bt=de.paint.get("building-emissive-strength").evaluate(V,{},this.canonical);V.properties["building-part"]="door";const mt=de.paint.get("building-color").evaluate(V,{},this.canonical).toPremultipliedRenderColor(this.lut),pt=de.paint.get("building-emissive-strength").evaluate(V,{},this.canonical);let ht=de.layout.get("building-flood-light-wall-radius").evaluate(V,{},r);ht=q(ht,0,2048);const yt=ht/2048*Vx,It=_.get(Z),kt=g.get(It)||[],Ct=kt.length!==0&&de.layout.get("building-facade").evaluate(V,{},r);h.setFacadeOptions(4,!0),h.setFauxFacadeOptions(Ct,!1,1);let Qt=0,vi=0,ei=0,wi=0,ai=0,gn=0,Ri=0,Si=0,qi=0,dn=0,rr=0;if(Ct){let di=Math.round(de.layout.get("building-facade-floors").evaluate(V,{},r));if(je===0){di=Math.max(1,di-(kt.length>0?1:0));let In=4;if(He>100){const Kn=[10,13,15];In=Kn[V.id?V.id%Kn.length:0]}else He<=10&&(In=3);h.setFacadeOptions(In,!0),ai=(He<15?1.3:1.61803)*In/f}else ai=je/f;gn=He/f,ai=Math.min(ai,gn),ei=de.layout.get("building-facade-unit-width").evaluate(V,{},r)/f,wi=(gn-ai)/di,h.setFauxFacadeOptions(!0,!0,ei);const hr=de.layout.get("building-facade-window").evaluate(V,{},r);Qt=hr[0],vi=hr[1],Ri=Math.floor(65535*Math.min(1,ai/_t)),Si=Math.floor(65535*Math.min(1,gn/_t)),qi=Math.floor(255*Qt)<<8|Math.floor(255*vi),dn=Math.floor(65535*Math.min(1,ei/_t)),rr=Math.floor(65535*Math.min(1,wi/_t))}const fn=Array(pe.length),Sn={x:1/0,y:1/0},Bn={x:-1/0,y:-1/0},En={x:0,y:0};let Ir=0;for(let di=0;di<pe.length;di++){const hr=pe[di];if(hr.length>0){const In=[],Kn=Array(hr.length+1);Kn[0]=0;for(let bo=0;bo<hr.length;bo++){const Bs=hr[bo];for(let Ns=0;Ns<Bs.length;Ns++){const Vs=Bs[Bs.length-Ns-1];Sn.x=Math.min(Sn.x,Vs.x),Sn.y=Math.min(Sn.y,Vs.y),Bn.x=Math.max(Bn.x,Vs.x),Bn.y=Math.max(Bn.y,Vs.y),En.x+=Vs.x,En.y+=Vs.y,Ir++,In.push(Vs.x),In.push(Vs.y)}Kn[bo+1]=In.length}fn[di]={id:V.id?V.id:0,height:He,minHeight:je,sourceId:0,roofType:Be,coordinates:In,ringIndices:Kn}}}En.x/=Ir||1,En.y/=Ir||1;const sr=h.generateMesh(fn,kt);if(typeof sr=="string"){zt(`Unable to generate building ${V.id}: ${sr}`),A(te);continue}if(sr.meshes.length===0||sr.modifiedPolygonRings.length===0){A(te);continue}const ci=Ct?this.buildingWithFacade:this.buildingWithoutFacade;let Yr=0;for(const di of sr.meshes)Yr+=di.positions.length/3;const Rn=ci.segmentsBucket.prepareSegment(Yr,ci.layoutVertexArray,ci.indexArray),cr=[];let Kr=null,Ar=0,yn=-1;const Gr=ci.layoutVertexArray.length,ur=Gr+Yr;ci.layoutVertexArray.resize(ur),ci.layoutCentroidArray.resize(ur),ci.layoutNormalArray.resize(ur),ci.layoutAOArray.resize(ur),ci.layoutColorArray.resize(ur),ci.layoutFloodLightDataArray.resize(ur),Ct&&(ci.layoutFacadePaintArray.resize(ur),ci.layoutFacadeDataArray.resize(ur),ci.layoutFacadeVerticalRangeArray.resize(ur));const mv=ci.indexArray.length;let Pf=0,rs=Gr;for(const di of sr.meshes){let hr,In;if(di.buildingPart===1)hr=Fe,In=We;else if(di.buildingPart===0)hr=Qe,In=st;else if(di.buildingPart===2)hr=ut,In=bt;else{if(di.buildingPart!==3)continue;hr=mt,In=pt}if(In=q(In,0,1),di.buildingPart===3){const Zn=new Array;for(let Dn=0;Dn<di.positions.length;Dn+=12){const Jr=di.positions[Dn+0],ss=di.positions[Dn+1],Yo=di.positions[Dn+3],gv=di.positions[Dn+4],yv=di.positions[Dn+2],ww=di.positions[Dn+8]-yv,xv=1,Sa=Yo-Jr,B_=gv-ss,zf=Math.hypot(Sa,B_);Zn.push({pos:[Jr+.5*Sa,ss+.5*B_,yv],normal:[B_/zf,-Sa/zf,0],width:zf,height:ww,depth:xv,points:[Jr,ss,Yo,gv]})}const Un=ci.entranceBloom.segmentsBucket.prepareSegment(10*Zn.length,ci.entranceBloom.layoutVertexArray,ci.entranceBloom.indexArray),Jn=ci.entranceBloom.layoutVertexArray.length;Ar=ci.entranceBloom.indexArray.length,KI(Zn,.5/this.tileToMeter,ci.entranceBloom.indexArray,ci.entranceBloom.layoutVertexArray,ci.entranceBloom.layoutAttenuationArray);const Xo=ci.entranceBloom.layoutVertexArray.length-Jn;yn=ci.entranceBloom.indexArray.length-Ar;for(let Dn=0;Dn<Xo;Dn++)ci.entranceBloom.layoutColorArray.emplaceBack(255*mt.r<<8|255*mt.g,255*mt.b<<8|51*pt);Un.vertexLength+=Xo,Un.primitiveLength+=yn,Kr={part:di.buildingPart,vertexOffset:Jn,vertexLength:Xo}}ci.layoutVertexArray.float32.set(di.positions,3*rs);const Kn=di.positions.length/3;for(let Zn=0;Zn<Kn;++Zn){const Un=3*Zn;Pf=Math.max(Pf,di.positions[Un+2]);const Jn=di.normals[Un+1]*Vx,Xo=di.normals[Un+2]*Vx,Dn=3*(rs+Zn);ci.layoutNormalArray.int16[Dn]=di.normals[Un]*Vx,ci.layoutNormalArray.int16[Dn+1]=Jn,ci.layoutNormalArray.int16[Dn+2]=Xo;const Jr=di.ao[Zn];ci.layoutAOArray.uint8[rs+Zn]=255*Jr;const ss=1+(Jr-1)*Ze,Yo=255*hr.b*ss<<8|255*In;ci.layoutColorArray.uint16[2*(rs+Zn)]=255*hr.r*ss<<8|255*hr.g*ss,ci.layoutColorArray.uint16[2*(rs+Zn)+1]=Yo}const bo=Math.min(8191,Math.max(0,Math.floor(En.x))),Bs=Math.min(8191,Math.max(0,Math.floor(En.y))),Ns=Math.floor(He),Vs=20,Wo=4*bo+Math.min(3,Math.round((Bn.x-Sn.x)*this.tileToMeter/Vs)),_v=4*Bs+Math.min(3,Math.round((Bn.y-Sn.y)*this.tileToMeter/Vs));for(let Zn=0;Zn<Kn;++Zn){const Un=3*(rs+Zn);ci.layoutCentroidArray.int16[Un]=Wo,ci.layoutCentroidArray.int16[Un+1]=_v,ci.layoutCentroidArray.int16[Un+2]=Ns}if(ci.layoutFloodLightDataArray.int16.fill(di.buildingPart===0?yt:0,rs,rs+Kn),Ct){const Zn=255*ut.r<<8|255*ut.g,Un=255*ut.b<<8|255*bt;for(let Jn=0;Jn<Kn;++Jn){const Xo=2*(rs+Jn);ci.layoutFacadePaintArray.uint16[Xo]=Zn,ci.layoutFacadePaintArray.uint16[Xo+1]=Un}for(let Jn=0;Jn<Kn;++Jn)if(di.isFauxFacade[Jn]){const Xo=Math.min(65535,Math.floor(di.uv[2*Jn]*sr.outerRingLength));ci.layoutFacadeDataArray.emplace(rs+Jn,1|Xo,qi,dn,rr),ci.layoutFacadeVerticalRangeArray.emplace(rs+Jn,Ri,Si)}else ci.layoutFacadeDataArray.emplace(rs+Jn,0,0,0,0),ci.layoutFacadeVerticalRangeArray.emplace(rs+Jn,0,0)}const Ta=Rn.vertexLength,Df=di.indices.length/3,Lf=ci.indexArray.length;ci.indexArray.resize(Lf+Df);for(let Zn=0;Zn<Df;++Zn){const Un=3*Zn,Jn=3*Lf+Un;ci.indexArray.uint16[Jn]=Ta+di.indices[Un],ci.indexArray.uint16[Jn+1]=Ta+di.indices[Un+1],ci.indexArray.uint16[Jn+2]=Ta+di.indices[Un+2]}di.buildingPart!==1&&di.buildingPart!==0&&di.buildingPart!==2&&di.buildingPart!==3||cr.push({part:di.buildingPart,vertexOffset:rs,vertexLength:di.positions.length/3}),rs+=Kn,Rn.vertexLength+=Kn,Rn.primitiveLength+=di.indices.length/3}this.maxHeight=Math.max(this.maxHeight,Pf);const bw=ci.indexArray.length-mv,Mf=this.footprintsIndices.length,Zl=this.footprintsVertices.length,ql=[],xo=new it(1/0,1/0),vo=new it(-1/0,-1/0),zh=this.groundEffect.vertexArray.length;for(const di of sr.modifiedPolygonRings){const hr=[],In=new it(1/0,1/0),Kn=new it(-1/0,-1/0);for(let bo=0;bo<di.length;bo+=2){const Bs=di.length-bo-2;In.x=Math.min(In.x,di[Bs]),In.y=Math.min(In.y,di[Bs+1]),Kn.x=Math.max(Kn.x,di[Bs]),Kn.y=Math.max(Kn.y,di[Bs+1]);const Ns=new it(di[Bs],di[Bs+1]);hr.push(Ns),ql.push(Ns.x,Ns.y),this.footprintsVertices.emplaceBack(Ns.x,Ns.y)}xo.x=Math.min(xo.x,In.x),xo.y=Math.min(xo.y,In.y),vo.x=Math.max(vo.x,Kn.x),vo.y=Math.max(vo.y,Kn.y),this.groundEffect.addData(hr,[In,Kn],nt)}const Rf=this.groundEffect.vertexArray.length-zh;this.groundEffect.groundRadiusArray.reserveForAdditional(Rf);for(let di=0;di<Rf;di++)this.groundEffect.groundRadiusArray.emplaceBack(Xe);(Sn.x<0||Bn.x>_t||Sn.y<0||Bn.y>_t)&&this.featuresOnBorder.push({featureId:V.id,footprintIndex:this.footprints.length});{const di=df(ql,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+di.length),this.footprintsIndices.uint16.set(di,Mf),this.buildingIds.add(te??V.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,xo.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,xo.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,vo.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,vo.y);const hr={footprintVertexOffset:Zl,footprintVertexLength:this.footprintsVertices.length-Zl,footprintIndexOffset:Mf,footprintIndexLength:this.footprintsIndices.length-Mf,min:xo,max:vo,hiddenFlags:0,indicesOffset:mv,indicesLength:bw,bloomIndicesOffset:Ar,bloomIndicesLength:yn,groundEffectVertexOffset:zh,groundEffectVertexLength:Rf,hasFauxFacade:Ct,height:Pf,promoteId:Z,feature:me,parts:cr,buildingBloom:Kr},In=this.footprints.length;V.id!==void 0&&this.featureFootprintLookup.set(V.id,In),M(te,In),this.footprints.push(hr)}this.programConfigurations.populatePaintArrays(ci.layoutVertexArray.length,V,G,{},t.availableImages,r,t.brightness),this.groundEffect.addPaintPropertiesData(V,G,{},t.availableImages,r,t.brightness),t.featureIndex.insert(V,ce,G,Y,this.index,Gr)}S.forEach(({buildingId:V,footprintIndex:Z})=>{I.has(V)&&(this.footprints[Z].hiddenFlags|=4)});const B=new Set;this.buildingIds.forEach((V,Z,G)=>{I.has(V)||B.add(V)}),this.buildingIds=B,this.groundEffect.prepareBorderSegments()}update(e,t,r,c,h,f,_){this.programConfigurations.updatePaintArrays(e,t,h,r,c,f,_),this.groundEffect.update(e,t,h,r,c,f,_),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1}isEmpty(){return this.buildingWithoutFacade.layoutVertexArray.length===0&&this.buildingWithFacade.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){const t=r=>{r.layoutVertexBuffer=e.createVertexBuffer(r.layoutVertexArray,JI.members),r.layoutNormalBuffer=e.createVertexBuffer(r.layoutNormalArray,UO.members),r.layoutCentroidBuffer=e.createVertexBuffer(r.layoutCentroidArray,jO.members),r.layoutFloodLightDataBuffer=e.createVertexBuffer(r.layoutFloodLightDataArray,qO.members),r.layoutFacadeDataArray&&r.layoutFacadeDataArray.length&&(r.layoutFacadeDataBuffer=e.createVertexBuffer(r.layoutFacadeDataArray,$O.members)),r.layoutFacadeVerticalRangeArray&&r.layoutFacadeVerticalRangeArray.length&&(r.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(r.layoutFacadeVerticalRangeArray,HO.members)),r.entranceBloom.layoutVertexArray.length&&(r.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(r.entranceBloom.layoutVertexArray,JI.members),r.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(r.entranceBloom.layoutAttenuationArray,ZO.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e)};this.uploaded||(t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){const e=t=>{t.layoutVertexBuffer&&(t.layoutVertexBuffer.destroy(),t.layoutNormalBuffer.destroy(),t.layoutColorBuffer.destroy(),t.segmentsBucket.destroy(),t.indexBuffer&&t.indexBuffer.destroy(),t.entranceBloom.layoutVertexBuffer&&(t.entranceBloom.layoutVertexBuffer.destroy(),t.entranceBloom.layoutColorBuffer.destroy(),t.entranceBloom.layoutAttenuationBuffer.destroy(),t.entranceBloom.indexBuffer.destroy(),t.entranceBloom.segmentsBucket.destroy()))};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(e,t,r=!0){let c=!1;const h=r?t:0,f=0|(r?-1:~t);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const _ of e){const g=this.footprints[_],b=g.hiddenFlags&f|h;g.hiddenFlags!==b&&(g.hiddenFlags=b,c=!0,this.groundEffect.updateHiddenByLandmarkRange(g.groundEffectVertexOffset,g.groundEffectVertexLength,g.hiddenFlags!==0))}return c&&(this.indexArrayForConflationUploaded=!1),c}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const t=c=>{c.indexArray.length!==0&&(c.indexArrayForConflation.resize(c.indexArray.length),c.indexArrayForConflation.uint16.set(c.indexArray.uint16),c.entranceBloom.indexArrayForConflation.resize(c.entranceBloom.indexArray.length),c.entranceBloom.indexArrayForConflation.uint16.set(c.entranceBloom.indexArray.uint16))};t(this.buildingWithoutFacade),t(this.buildingWithFacade);for(const c of this.footprints){const h=c.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,f=c.indicesOffset+c.indicesLength;if(c.hiddenFlags!==0){for(let g=c.indicesOffset;g<f;g++)h.indexArrayForConflation.uint16[3*g+0]=0,h.indexArrayForConflation.uint16[3*g+1]=0,h.indexArrayForConflation.uint16[3*g+2]=0;const _=c.bloomIndicesOffset+c.bloomIndicesLength;for(let g=c.bloomIndicesOffset;g<_;g++)h.entranceBloom.indexArrayForConflation.uint16[3*g+0]=0,h.entranceBloom.indexArrayForConflation.uint16[3*g+1]=0,h.entranceBloom.indexArrayForConflation.uint16[3*g+2]=0}}const r=c=>{c.indexArray.length!==0&&(c.indexBuffer?c.indexBuffer.updateData(c.indexArrayForConflation):c.indexBuffer=e.createIndexBuffer(c.indexArrayForConflation,!0),c.entranceBloom.indexBuffer?c.entranceBloom.indexBuffer.updateData(c.entranceBloom.indexArrayForConflation):c.entranceBloom.indexBuffer=e.createIndexBuffer(c.entranceBloom.indexArrayForConflation,!0))};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(e){const t=r=>{r.layoutColorBuffer?r.layoutColorBuffer.updateData(r.layoutColorArray):r.layoutColorBuffer=e.createVertexBuffer(r.layoutColorArray,QI.members,!0),r.layoutFacadePaintArray&&(r.layoutFacadePaintBuffer?r.layoutFacadePaintBuffer.updateData(r.layoutFacadePaintArray):r.layoutFacadePaintBuffer=e.createVertexBuffer(r.layoutFacadePaintArray,GO.members,!0)),r.entranceBloom.layoutColorBuffer?r.entranceBloom.layoutColorBuffer.updateData(r.entranceBloom.layoutColorArray):r.entranceBloom.layoutColorBuffer=e.createVertexBuffer(r.entranceBloom.layoutColorArray,QI.members,!0)};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(e,t){const r=e.paint.get("building-ambient-occlusion-intensity");for(const c of this.footprints){if(4&c.hiddenFlags)continue;const h=t[c.promoteId],f=c.feature;f.properties["building-part"]="roof";const _=e.paint.get("building-color").evaluate(f,h,this.canonical).toPremultipliedRenderColor(this.lut),g=e.paint.get("building-emissive-strength").evaluate(f,h,this.canonical);f.properties["building-part"]="wall";const b=e.paint.get("building-color").evaluate(f,h,this.canonical).toPremultipliedRenderColor(this.lut),S=e.paint.get("building-emissive-strength").evaluate(f,h,this.canonical);f.properties["building-part"]="window";const I=e.paint.get("building-color").evaluate(f,h,this.canonical).toPremultipliedRenderColor(this.lut),A=e.paint.get("building-emissive-strength").evaluate(f,h,this.canonical);f.properties["building-part"]="door";const M=e.paint.get("building-color").evaluate(f,h,this.canonical).toPremultipliedRenderColor(this.lut),D=e.paint.get("building-emissive-strength").evaluate(f,h,this.canonical),z=c.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const V of c.parts){let Z,G=_;V.part===1?(G=_,Z=g):V.part===0?(G=b,Z=S):V.part===2?(G=I,Z=A):V.part===3&&(G=M,Z=D),Z=q(Z,0,1);for(let Y=0;Y<V.vertexLength;Y++){const Q=V.vertexOffset+Y,te=1+(z.layoutAOArray.uint8[Q]/255-1)*r;z.layoutColorArray.emplace(Q,G.r*te*255<<8|G.g*te*255,G.b*te*255<<8|255*Z),c.hasFauxFacade&&z.layoutFacadePaintArray.emplace(Q,255*I.r<<8|255*I.g,255*I.b<<8|255*A)}}const B=c.buildingBloom;if(B)for(let V=0;V<B.vertexLength;V++)z.entranceBloom.layoutColorArray.emplace(B.vertexOffset+V,255*M.r<<8|255*M.g,255*M.b<<8|51*D)}}needsEvaluation(){return!this.colorBufferUploaded}updateReplacement(e,t,r){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const c=t.getReplacementRegionsForTile(e.toUnwrapped());if(Ex(this.activeReplacements,c))return;this.activeReplacements=c;for(const f of this.footprints)f.hiddenFlags&=-2;const h=[];for(const f of this.activeReplacements){if(f.order<r)continue;const _=Math.max(1,Math.pow(2,f.footprintTileId.canonical.z-e.canonical.z));for(const g of this.footprints)g.min.x>f.max.x||g.max.x<f.min.x||g.min.y>f.max.y||g.max.y<f.min.y||(h.length=0,KO(this.footprintsVertices,g.footprintVertexOffset,g.footprintVertexLength,f.footprintTileId.canonical,e.canonical,h),db(f.footprint,h,this.footprintsIndices.uint16,g.footprintIndexOffset,g.footprintIndexLength,0,-_)&&(g.hiddenFlags|=1))}this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const f of this.footprints)this.groundEffect.updateHiddenByLandmarkRange(f.groundEffectVertexOffset,f.groundEffectVertexLength,f.hiddenFlags!==0);this.indexArrayForConflationUploaded=!1}getFootprint(e){if(e.id!==void 0){const t=this.featureFootprintLookup.get(e.id);return this.footprints[t]}return null}getHeightAtTileCoord(e,t){let r=Number.NEGATIVE_INFINITY,c=!0;const h=4*(e+_t)*_t+(t+_t);if(this.footprintLookup.hasOwnProperty(h)){const _=this.footprintLookup[h];return _?{height:_.height,hidden:_.hiddenFlags!==0}:void 0}const f=new it(e,t);for(const _ of this.footprints)e>_.max.x||_.min.x>e||t>_.max.y||_.min.y>t||_.height<=r||YO(f,this.footprintsVertices.float32.subarray(2*_.footprintVertexOffset,2*(_.footprintVertexOffset+_.footprintVertexLength)),this.footprintsIndices.uint16.subarray(_.footprintIndexOffset,_.footprintIndexOffset+_.footprintIndexLength))&&(r=_.height,this.footprintLookup[h]=_,c=_.hiddenFlags!==0);if(r!==Number.NEGATIVE_INFINITY)return{height:r,hidden:c};this.footprintLookup[h]=void 0}}function YO(n,e,t){for(let r=0;r<t.length;r+=3){const c=t[r],h=t[r+1],f=t[r+2],_=e[2*c+0],g=e[2*c+1],b=e[2*h+0],S=e[2*h+1],I=e[2*f+0],A=e[2*f+1],M=(_-I)*(n.y-A)-(g-A)*(n.x-I),D=(b-_)*(n.y-g)-(S-g)*(n.x-_);if(M<0!=D<0&&M!==0&&D!==0)continue;const z=(I-b)*(n.y-S)-(A-S)*(n.x-b);if(z===0||z<0==M+D<=0)return!0}return!1}function KO(n,e,t,r,c,h){const f=Math.pow(2,r.z-c.z);for(let _=0;_<t;_++){let g=n.float32[2*(_+e)+0],b=n.float32[2*(_+e)+1];g=(g+c.x*_t)*f-r.x*_t,b=(b+c.y*_t)*f-r.y*_t,h.push(new it(g,b))}}let iA,nA;wt(tA,"BuildingBucket",{omit:["layers"]}),wt(Rb,"BuildingGeometry"),wt(Mb,"BuildingBloomGeometry");const JO=pi([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),QO=pi([{name:"a_z_offset_width",components:3,type:"Float32"}],4),eB=pi([{name:"a_elevation_ground_scale",components:1,type:"Float32"}],4),{members:tB}=JO,iB=pi([{name:"a_packed",components:3,type:"Float32"}]),{members:nB}=iB,rB=pi([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:sB}=rB;class rA{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new $c({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const r=this.getKey(e,t);return this.positions[r]}trim(){const e=this.width,t=this.height=Ae(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,r){const c=[];let h=e.length%2==1?-e[e.length-1]*r:0,f=e[0]*r,_=!0;c.push({left:h,right:f,isDash:_,zeroLength:e[0]===0});let g=e[0];for(let b=1;b<e.length;b++){_=!_;const S=e[b];h=g*r,g+=S,f=g*r,c.push({left:h,right:f,isDash:_,zeroLength:S===0})}return c}addRoundDash(e,t,r){const c=t/2;for(let h=-r;h<=r;h++){const f=this.width*(this.nextRow+r+h);let _=0,g=e[_];for(let b=0;b<this.width;b++){b/g.right>1&&(g=e[++_]);const S=Math.abs(b-g.left),I=Math.abs(b-g.right),A=Math.min(S,I);let M;const D=h/r*(c+1);if(g.isDash){const z=c-Math.abs(D);M=Math.sqrt(A*A+z*z)}else M=c-Math.sqrt(A*A+D*D);this.image.data[f+b]=Math.max(0,Math.min(255,M+128))}}}addRegularDash(e,t){for(let g=e.length-1;g>=0;--g){const b=e[g],S=e[g+1];b.zeroLength?e.splice(g,1):S&&S.isDash===b.isDash&&(S.left=b.left,e.splice(g,1))}const r=e[0],c=e[e.length-1];r.isDash===c.isDash&&(r.left=c.left-this.width,c.right=r.right+this.width);const h=this.width*this.nextRow;let f=0,_=e[f];for(let g=0;g<this.width;g++){g/_.right>1&&(_=e[++f]);const b=Math.abs(g-_.left),S=Math.abs(g-_.right),I=Math.min(b,S);this.image.data[h+g]=Math.max(0,Math.min(255,(_.isDash?I:-I)+t+128))}}addDash(e,t){const r=this.getKey(e,t);if(this.positions[r])return this.positions[r];const c=t==="round",h=c?7:0,f=2*h+1;if(this.nextRow+f>this.height)return zt("LineAtlas out of space"),null;e.length===0&&e.push(1);let _=0;for(let I=0;I<e.length;I++)e[I]<0&&(zt("Negative value is found in line dasharray, replacing values with 0"),e[I]=0),_+=e[I];if(_!==0){const I=this.width/_,A=this.getDashRanges(e,this.width,I);c?this.addRoundDash(A,I,h):this.addRegularDash(A,t==="square"?.5*I:0)}const g=this.nextRow+h;this.nextRow+=f;const b=Math.floor(_),S={tl:[g,h],br:[b,Math.round(65535*(_-b))]};return this.positions[r]=S,S}}wt(rA,"LineAtlas");const oB=qt.types,aB=Math.cos(Math.PI/180*37.5),lB=Math.cos(Math.PI/180*5);class Ux{constructor(e){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.elevationType="none",this.isSeaLevelReference=!1,this.zoom=e.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=e.overscaling,this.pixelRatio=e.pixelRatio,this.layers=e.layers,this.layerIds=this.layers.map(t=>t.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(t=>{this.gradients[t.id]={}}),this.layoutVertexArray=new dh,this.layoutVertexArray2=new Qs,this.patternVertexArray=new Qs,this.indexArray=new Tn,this.programConfigurations=new N(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new $i,this.maxLineLength=0,this.zOffsetVertexArray=new Qs,this.elevationGroundScaleVertexArray=new Rs,this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,r,c){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,c){this.hasPattern=eb("line",this.layers,this.pixelRatio,t);const h=this.layers[0].layout.get("line-sort-key");this.tileToMeter=et(r);const f=this.layers[0].layout.get("line-elevation-reference");if(f==="hd-road-markup")this.elevationType="road";else{const A=this.layers[0].layout.get("line-z-offset"),M=A.isConstant()&&!A.constantOr(0);this.elevationType=f!=="sea"&&f!=="ground"&&M?"none":"offset",this.elevationType==="offset"&&f==="none"&&zt(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference=f==="sea"}const _=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&_!==void 0;const g=[];for(const{feature:A,id:M,index:D,sourceLayerIndex:z}of e){const B=this.layers[0]._featureFilter.needGeometry,V=oi(A,B);if(!this.layers[0]._featureFilter.filter(new Mi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),V,r))continue;const Z=h?h.evaluate(V,{},r):void 0,G={id:M,properties:A.properties,type:A.type,sourceLayerIndex:z,index:D,geometry:B?V.geometry:Ft(A,r,c),patterns:{},sortKey:Z};g.push(G)}h&&g.sort((A,M)=>A.sortKey-M.sortKey);const{lineAtlas:b,featureIndex:S}=t,I=this.addConstantDashes(b);for(const A of g){const{geometry:M,index:D,sourceLayerIndex:z}=A;if(I&&this.addFeatureDashes(A,b),this.hasPattern){const B=tb("line",this.layers,A,this.zoom,this.pixelRatio,t);this.patternFeatures.push(B)}else this.addFeature(A,M,D,r,b.positions,t.availableImages,t.brightness,t.elevationFeatures);S.insert(e[D].feature,M,D,z,this.index)}}addConstantDashes(e){let t=!1;for(const r of this.layers){const c=r.paint.get("line-dasharray").value,h=r.layout.get("line-cap").value;if(c.kind!=="constant"||h.kind!=="constant")t=!0;else{const f=h.value,_=c.value;if(!_)continue;e.addDash(_,f)}}return t}addFeatureDashes(e,t){const r=this.zoom;for(const c of this.layers){const h=c.paint.get("line-dasharray").value,f=c.layout.get("line-cap").value;if(h.kind==="constant"&&f.kind==="constant")continue;let _,g;if(h.kind==="constant"){if(_=h.value,!_)continue}else _=h.evaluate({zoom:r},e);g=f.kind==="constant"?f.value:f.evaluate({zoom:r},e),t.addDash(_,g),e.patterns[c.id]=[t.getKey(_,g)]}}update(e,t,r,c,h,f,_,g,b){this.programConfigurations.updatePaintArrays(e,t,h,r,c,f,_,b)}addFeatures(e,t,r,c,h,f){for(const _ of this.patternFeatures)this.addFeature(_,_.geometry,_.index,t,r,c,f,e.elevationFeatures)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,nB)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,sB)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,QO.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,eB.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,tB),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e,t){let r,c;if(t&&t>0?(r=`mapbox_clip_start_${t}`,c=`mapbox_clip_end_${t}`):(r="mapbox_clip_start",c="mapbox_clip_end"),e.properties&&e.properties.hasOwnProperty(r)&&e.properties.hasOwnProperty(c))return{start:+e.properties[r],end:+e.properties[c]}}addFeature(e,t,r,c,h,f,_,g){const b=this.layers[0].layout,S=b.get("line-join").evaluate(e,{}),I=b.get("line-cap").evaluate(e,{}),A=b.get("line-miter-limit"),M=b.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const D=!(!e.properties||!e.properties.hasOwnProperty("mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=b.get("line-z-offset").value;const z=this.layers[0].paint.get("line-width").value;if(z.kind!=="constant"&&z.isLineProgressConstant===!1&&(this.variableWidthValue=z),this.isSeaLevelReference){const B=b.get("line-elevation-ground-scale").value;B.kind==="constant"&&B.value===0||(this.elevationGroundScaleValue=B)}if(this.elevationType==="road"){const B=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,t,c,g,S,I,A,M)){const[V,Z]=this.clipRuntimeLinesToTile(t,1);for(let G=0;G<V.length;G++){const Y=V[G],Q=Z[G],te={progress:{min:Q.progress.min,max:Q.progress.max},nextDir:this.computeSegNextDir(Q,Y),prevDir:this.computeSegPrevDir(Q,Y)};this.addLine(Y,e,c,S,I,A,M,te,D&&Q.parentIndex>0?Q.parentIndex:null)}this.fillNonElevatedRoadSegment(B)}}else for(let B=0;B<t.length;B++)this.addLine(t[B],e,c,S,I,A,M,void 0,D&&B>0?B:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,h,f,c,_,void 0,this.worldview)}computeSegNextDir(e,t){return e.nextPoint.sub(t.at(-2)).unit()}computeSegPrevDir(e,t){return t[1].sub(e.prevPoint).unit()}clipLinesToTile(e,t){return Rx(e,-t,-t,_t+t,_t+t)}clipRuntimeLinesToTile(e,t){const r=[];return[Rx(e,-t,-t,_t+t,_t+t,r),r]}addElevatedRoadFeature(e,t,r,c,h,f,_,g){const b=[],S=Yi.getElevationFeature(e,c);if(S){const I=this.clipLinesToTile(t,1),A=this.prepareElevatedLines(I,S,r);for(const M of A)b.push({geometry:M,elevation:S,elevationTileID:r,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(b.length===0)return!1;for(const I of b){const A=this.layoutVertexArray.length;this.addLine(I.geometry,e,r,h,f,_,g);const M=new Ki(r,I.elevationTileID);if(I.elevation)for(let D=A;D<this.layoutVertexArray.length;D++){const z=new it(this.layoutVertexArray.int16[6*D]>>1,this.layoutVertexArray.int16[6*D+1]>>1),B=M.pointElevation(z,I.elevation,.05);this.updateHeightRange(B),this.zOffsetVertexArray.emplaceBack(B,0,0)}else this.fillNonElevatedRoadSegment(A)}return!0}prepareElevatedLines(e,t,r){if(t.constantHeight!=null)return e;const c=[],h=1/et(r);for(const f of e)yO(f,new Ls(t,h),0,c);return c}fillNonElevatedRoadSegment(e){for(let t=e;t<this.layoutVertexArray.length;t++)this.zOffsetVertexArray.emplaceBack(0,0,0)}updateHeightRange(e){this.heightRange?(this.heightRange.min=Math.min(this.heightRange.min,e),this.heightRange.max=Math.max(this.heightRange.max,e)):this.heightRange={min:e,max:e}}addLine(e,t,r,c,h,f,_,g,b){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0,this.lineClips=b?this.lineFeatureClips(t,b):this.lineClips;const S=c==="none";this.patternJoinNone=this.hasPattern&&S,this.currentLineJoinType=c,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[];const I=g&&g.progress.min>0,A=g&&g.progress.max<1;if(this.lineClips){let pe={min:this.lineClips.start,max:this.lineClips.end},he=1;if(g){const je=this.lineClips.end-this.lineClips.start;pe=function(He,Xe,Ze){return{min:wn(He.min,Xe,Ze),max:wn(He.max,Xe,Ze)}}(g.progress,{min:0,max:1},pe),je>0&&(he=(pe.max-pe.min)/je)}const de=+t.properties.mapbox_clip_feature_len,Be=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(de)||Number.isNaN(Be)){for(let He=0;He<e.length-1;He++)this.totalDistance+=e[He].dist(e[He+1]);const je=this.totalDistance/(pe.max-pe.min);this.totalFeatureLength=Number.isFinite(je)?je:0,this.lineClips.start=pe.min,this.lineClips.end=pe.max,this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}else this.totalFeatureLength=de,this.distance=Be*he,this.lineClips.start=pe.min,this.lineClips.end=pe.max,this.maxLineLength=Math.max(this.maxLineLength,this.distance);this.lineClipsArray.push(this.lineClips),this.updateScaledDistance()}const M=oB[t.type]==="Polygon";let D=e.length;for(;D>=2&&e[D-1].equals(e[D-2]);)D--;let z=0;for(;z<D-1&&e[z].equals(e[z+1]);)z++;if(D<(M?3:2))return;c==="bevel"&&(f=1.05);const B=this.segments.prepareSegment(10*D,this.layoutVertexArray,this.indexArray);let V,Z,G,Y,Q,te,me,ce;g&&g.prevDir&&(te=g.prevDir.perp()),g&&g.nextDir&&(me=g.nextDir.perp()),this.e1=this.e2=-1,M&&(V=e[D-2],Q=e[z].sub(V)._unit()._perp());for(let pe=z;pe<D;pe++){if(G=pe===D-1?M?e[z+1]:void 0:e[pe+1],G&&e[pe].equals(G))continue;Q&&(Y=Q),V&&(Z=V),V=e[pe],ce=this.evaluateLineProgressFeatures(Z?Z.dist(V):0),Q=G?G.sub(V)._unit()._perp():Y,Y=Y||Q;const he=Z&&G;let de=he?c:M||S?"butt":h;const Be=Y.x*Q.x+Y.y*Q.y;if(S){const Qe=function(st){if(st.patternJoinNone){const ut=st.segmentPoints.length/2,bt=st.lineSoFar-st.segmentStart;for(let mt=0;mt<ut;++mt){const pt=st.segmentPoints[2*mt+1],ht=Math.round(st.segmentPoints[2*mt])+.5+.25*pt;st.patternVertexArray.emplaceBack(ht,bt,st.segmentStart),st.patternVertexArray.emplaceBack(ht,bt,st.segmentStart)}st.segmentPoints.length=0}st.e1=st.e2=-1};if(he&&Be<lB){this.updateDistance(Z,V),this.addCurrentVertex(V,Y,1,1,B,ce),Qe(this),this.addCurrentVertex(V,Q,-1,-1,B,ce);continue}if(Z){if(!G){this.updateDistance(Z,V),this.addCurrentVertex(V,Y,1,1,B,ce),Qe(this);continue}de="miter"}}let je=Y.add(Q);je.x===0&&je.y===0||je._unit();const He=je.x*Q.x+je.y*Q.y,Xe=He!==0?1/He:1/0,Ze=2*Math.sqrt(2-2*He),nt=He<aB&&Z&&G,Fe=Y.x*Q.y-Y.y*Q.x>0,We=this.overscaling<=16?122880/(512*this.overscaling):0;if(he&&de==="round"){if(Xe<_)de="miter";else if(Xe<=2){const Qe=Db(V,-10,8202);de=this.elevationType==="offset"&&(Qe||this.hasCrossSlope)?"miter":"fakeround"}}if(de==="miter"&&Xe>f&&(de="bevel"),de==="bevel"&&(Xe>2&&(de="flipbevel"),Xe<f&&(de="miter")),Z&&!(de==="miter"&&nt)&&this.updateDistance(Z,V),de==="miter")if(nt){const Qe=V.dist(Z);if(Qe>2*We){const ut=V.sub(V.sub(Z)._mult(We/Qe)._round());this.updateDistance(Z,ut),this.addCurrentVertex(ut,Y,0,0,B,ce),Z=ut}this.updateDistance(Z,V),je._mult(Xe),this.addCurrentVertex(V,je,0,0,B,ce);const st=V.dist(G);if(st>2*We){const ut=V.add(G.sub(V)._mult(We/st)._round());this.updateDistance(V,ut),this.addCurrentVertex(ut,Q,0,0,B,ce),V=ut}}else je._mult(Xe),this.addCurrentVertex(V,je,0,0,B,ce);else if(de==="flipbevel"){if(Xe>100)je=Q.mult(-1);else{const Qe=Xe*Y.add(Q).mag()/Y.sub(Q).mag();je._perp()._mult(Qe*(Fe?-1:1))}this.addCurrentVertex(V,je,0,0,B,ce),this.addCurrentVertex(V,je.mult(-1),0,0,B,ce)}else if(de==="bevel"||de==="fakeround"){const Qe=V.dist(Z);let st=1;if(this.elevationType==="offset"&&de==="bevel"&&this.currentLineJoinType!=="round"&&!this.patternJoinNone&&ce!=null&&Z&&G){const yt=4*We;Qe<yt&&(st=Math.max(0,Qe/yt))}ce!=null&&Z&&this.addCurrentVertex(V,me||Y,-st,-st,B,ce);const ut=Qe<=2*We&&de!=="bevel",bt=je.mult(Fe?1:-1);bt._mult(Xe);const mt=Q.mult(Fe?-1:1),pt=Y.mult(Fe?-1:1),ht=this.evaluateLineProgressFeatures(this.distance);if(ce==null&&(this.addHalfVertex(V,bt.x,bt.y,!1,!Fe,0,B,ht),ut||this.addHalfVertex(V,bt.x+2*pt.x,bt.y+2*pt.y,!1,Fe,0,B,ht)),de==="fakeround"){const yt=Math.round(180*Ze/Math.PI/20);this.addHalfVertex(V,pt.x,pt.y,!1,Fe,0,B,ht);for(let It=0;It<yt;It++){let kt=It/yt;if(kt!==.5){const Qt=kt-.5;kt+=kt*Qt*(kt-1)*((1.0904+Be*(Be*(3.55645-1.43519*Be)-3.2452))*Qt*Qt+(.848013+Be*(.215638*Be-1.06021)))}const Ct=mt.sub(pt)._mult(kt)._add(pt)._unit();this.addHalfVertex(V,Ct.x,Ct.y,!1,Fe,0,B,ht)}this.addHalfVertex(V,mt.x,mt.y,!1,Fe,0,B,ht)}ut||ce!=null||this.addHalfVertex(V,bt.x+2*mt.x,bt.y+2*mt.y,!1,Fe,0,B,ht),ce!=null&&G&&this.addCurrentVertex(V,te||Q,st,st,B,ce)}else if(de==="butt")this.addCurrentVertex(V,je,0,0,B,ce);else if(de==="square"){if(!Z){const Qe=I?0:-1;this.addCurrentVertex(V,je,Qe,Qe,B,ce)}if(this.addCurrentVertex(V,je,0,0,B,ce),Z){const Qe=A?0:1;this.addCurrentVertex(V,je,Qe,Qe,B,ce)}}else if(de==="round"){if(Z){const Qe=!he&&me?me:Y;this.addCurrentVertex(V,Qe,0,0,B,ce),!he&&A||this.addCurrentVertex(V,Qe,1,1,B,ce,!0)}if(G){const Qe=!he&&te?te:Q;!he&&I||this.addCurrentVertex(V,Qe,-1,-1,B,ce,!0),this.addCurrentVertex(V,Qe,0,0,B,ce)}}}}addVerticesTo(e,t,r,c,h,f,_,g,b,S){const I=(t.w-e.w)/this.tessellationStep|0;let A=0;const M=this.scaledDistance;if(I>1){this.lineSoFar=e.w;const z=(t.x-e.x)/I,B=(t.y-e.y)/I,V=(t.z-e.z)/I,Z=(t.w-e.w)/I,G=t.x-e.x,Y=t.y-e.y,Q=Math.sqrt(G*G+Y*Y);if(Q===0)return;const te=-Y/Q,me=G/Q,ce=te,pe=me,he=-te,de=-me;for(let Be=1;Be<I;++Be){e.x+=z,e.y+=B,e.z+=V,this.lineSoFar+=Z,A+=Z;const je=this.evaluateLineProgressFeatures(this.prevDistance+A);this.scaledDistance=(this.prevDistance+A)/this.totalDistance,this.addHalfVertex(e,ce,pe,S,!1,0,b,je),this.addHalfVertex(e,he,de,S,!0,0,b,je)}}this.lineSoFar=t.w,this.scaledDistance=M;const D=this.evaluateLineProgressFeatures(this.distance);this.addHalfVertex(t,r,c,S,!1,_,b,D),this.addHalfVertex(t,h,f,S,!0,-g,b,D)}evaluateLineProgressFeatures(e){if(!this.variableWidthValue&&this.elevationType!=="offset")return null;this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+e)/this.totalFeatureLength):zt(`line-progress evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`);let t=0;this.variableWidthValue&&this.variableWidthValue.kind!=="constant"&&(t=this.variableWidthValue.evaluate(this.evaluationGlobals,this.lineFeature)||0);const r=this.evaluateElevationGroundScale();return this.elevationType!=="offset"?{zOffset:0,variableWidth:t,elevationGroundScale:r}:this.zOffsetValue.kind==="constant"?{zOffset:this.zOffsetValue.value,variableWidth:t,elevationGroundScale:r}:{zOffset:this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0,variableWidth:t,elevationGroundScale:r}}evaluateElevationGroundScale(){return this.elevationGroundScaleValue?this.elevationGroundScaleValue.kind==="constant"?this.elevationGroundScaleValue.value:this.elevationGroundScaleValue.evaluate(this.evaluationGlobals,this.lineFeature)||0:0}addCurrentVertex(e,t,r,c,h,f,_=!1){const g=t.x+t.y*r,b=t.y-t.x*r,S=t.y*c-t.x,I=-t.y-t.x*c;if(f!=null){const A=this.elevationType==="offset",M=this.elevationType==="offset"?2:10,D=-M,z=_t+M,B=f.zOffset,V=new TI(e.x,e.y,B,this.lineSoFar),Z=!!A&&Db(e,D,z),G=this.lineSoFar,Y=this.distance;if(this.currentVertex)if(Z){const Q=this.currentVertexIsOutside,te=this.currentVertex,me=new TI(e.x,e.y,B,this.lineSoFar);if(EI(te,me,D,z),!Db(me,D,z)){if(Q){this.e1=this.e2=-1,this.distance-=te.dist(V),this.lineSoFar=te.w;const ce=this.evaluateLineProgressFeatures(te.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(te,g,b,_,!1,r,h,ce),this.addHalfVertex(te,S,I,_,!0,-c,h,ce),this.prevDistance=this.distance}this.distance=this.prevDistance+te.dist(me),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(te,me,g,b,S,I,r,c,h,_),this.distance=Y,this.scaledDistance=this.distance/this.totalDistance}}else{const Q=this.currentVertex;if(this.currentVertexIsOutside){EI(Q,V,D,z),this.e1=this.e2=-1,this.distance-=Q.dist(V),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=Q.w;const te=this.evaluateLineProgressFeatures(Q.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(Q,g,b,_,!1,r,h,te),this.addHalfVertex(Q,S,I,_,!0,-c,h,te),this.prevDistance=this.distance,this.distance=Y,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(Q,V,g,b,S,I,r,c,h,_)}else Z||(this.addHalfVertex(e,g,b,_,!1,r,h,f),this.addHalfVertex(e,S,I,_,!0,-c,h,f));this.currentVertex=V,this.currentVertexIsOutside=Z,this.lineSoFar=G}else this.addHalfVertex(e,g,b,_,!1,r,h,f),this.addHalfVertex(e,S,I,_,!0,-c,h,f)}addHalfVertex({x:e,y:t},r,c,h,f,_,g,b){if(this.patternJoinNone&&(this.segmentPoints.length===0&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),f||this.segmentPoints.push(this.lineSoFar-this.segmentStart,_)),this.layoutVertexArray.emplaceBack((e<<1)+(h?1:0),(t<<1)+(f?1:0),Math.round(63*r)+128,Math.round(63*c)+128,1+(_===0?0:_<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips){const I=Gt(this.lineClips.start,this.lineClips.end,this.scaledDistance);this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,I)}const S=g.vertexLength++;if(this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,S),g.primitiveLength++),f?this.e2=S:this.e1=S,b!=null&&this.zOffsetVertexArray.emplaceBack(b.zOffset,b.variableWidth,b.variableWidth),this.elevationGroundScaleValue){const I=b?b.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(I)}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance()}}function Db(n,e,t){return n.x<e||n.x>t||n.y<e||n.y>t}let sA,oA;function aA(n,e,t){return e*(_t/(n.tileSize*Math.pow(2,t-n.tileID.overscaledZ)))}wt(Ux,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const lA=(n,e,t)=>(1-t)*n+t*e;function cA(n,e){return 1/aA(n,1,e.tileZoom)}function uA(n,e,t,r){return n.translatePosMatrix(r||e.tileID.projMatrix,e,t.paint.get("line-translate"),t.paint.get("line-translate-anchor"))}const hA=n=>{const e=[];dA(n)&&e.push("RENDER_LINE_DASH"),n.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT"),n.paint.get("line-blend-mode")==="multiply"&&e.push("LINE_BLEND_MULTIPLY");const t=n.paint.get("line-trim-offset");t[0]===0&&t[1]===0||e.push("RENDER_LINE_TRIM_OFFSET"),n.paint.get("line-border-width").constantOr(1)!==0&&e.push("RENDER_LINE_BORDER");const r=n.layout.get("line-join").constantOr("miter")==="none",c=!!n.paint.get("line-pattern").constantOr(1);return r&&c&&e.push("LINE_JOIN_NONE"),e};function dA(n){const e=n.paint.get("line-dasharray").value;return e.kind!=="constant"||e.value}let Lb;const fA=()=>Lb||(Lb={layout:sA||(sA=new on({"line-cap":new at(Ee.layout_line["line-cap"]),"line-join":new at(Ee.layout_line["line-join"]),"line-miter-limit":new dt(Ee.layout_line["line-miter-limit"]),"line-round-limit":new dt(Ee.layout_line["line-round-limit"]),"line-sort-key":new at(Ee.layout_line["line-sort-key"]),"line-z-offset":new at(Ee.layout_line["line-z-offset"]),"line-elevation-reference":new dt(Ee.layout_line["line-elevation-reference"]),"line-cross-slope":new dt(Ee.layout_line["line-cross-slope"]),visibility:new dt(Ee.layout_line.visibility),"line-width-unit":new dt(Ee.layout_line["line-width-unit"]),"line-elevation-ground-scale":new at(Ee.layout_line["line-elevation-ground-scale"])})),paint:oA||(oA=new on({"line-opacity":new at(Ee.paint_line["line-opacity"]),"line-color":new at(Ee.paint_line["line-color"]),"line-translate":new dt(Ee.paint_line["line-translate"]),"line-translate-anchor":new dt(Ee.paint_line["line-translate-anchor"]),"line-width":new at(Ee.paint_line["line-width"]),"line-gap-width":new at(Ee.paint_line["line-gap-width"]),"line-offset":new at(Ee.paint_line["line-offset"]),"line-blur":new at(Ee.paint_line["line-blur"]),"line-dasharray":new at(Ee.paint_line["line-dasharray"]),"line-pattern":new at(Ee.paint_line["line-pattern"]),"line-pattern-cross-fade":new dt(Ee.paint_line["line-pattern-cross-fade"]),"line-gradient":new Bc(Ee.paint_line["line-gradient"]),"line-trim-offset":new dt(Ee.paint_line["line-trim-offset"]),"line-trim-fade-range":new dt(Ee.paint_line["line-trim-fade-range"]),"line-trim-color":new dt(Ee.paint_line["line-trim-color"]),"line-emissive-strength":new at(Ee.paint_line["line-emissive-strength"]),"line-border-width":new at(Ee.paint_line["line-border-width"]),"line-border-color":new at(Ee.paint_line["line-border-color"]),"line-occlusion-opacity":new dt(Ee.paint_line["line-occlusion-opacity"]),"line-blend-mode":new dt(Ee.paint_line["line-blend-mode"]),"line-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},Lb);class cB extends at{possiblyEvaluate(e,t){return t=new Mi(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,r,c){return t=Object.assign({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,r,c)}}let g_;function pA(n,e){return e>0?e+2*n:n}const uB=pi([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),hB=pi([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),dB=pi([{name:"a_projected_pos",components:4,type:"Float32"}],4);pi([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const fB=pi([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),pB=pi([{name:"a_feature_index",components:1,type:"Float32"}],4),mB=pi([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),_B=pi([{name:"a_texb",components:2,type:"Uint16"}]),gB=pi([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),yB=pi([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);pi([{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 mA=pi([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),xB=pi([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);pi([{name:"triangle",components:3,type:"Uint16"}]),pi([{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"}]),pi([{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"},{type:"Uint16",name:"elevationFeatureIndex"}]),pi([{type:"Float32",name:"offsetX"}]),pi([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const zb=class s0{constructor(e=null,t=0,r=4096){this.batchIndex=t,this.headerBuffer=null,this.propertiesBuffer=null,this.blockIndicesBuffer=null,this.context=e||null,this.propsDwords=r,this.totalBytes=4*this.propsDwords,this.headerData=new Uint32Array(s0.HEADER_DWORDS),this.propertiesData=new Float32Array(this.propsDwords),this.blockIndicesData=new Uint32Array(this.propsDwords);for(let c=0;c<this.propsDwords;c++)this.blockIndicesData[c]=c;e&&this._initBuffers(e)}_initBuffers(e){const t=e.gl;if(this.totalBytes>e.maxUniformBlockSize)throw new Error(`UBO size ${this.totalBytes} exceeds device limit ${e.maxUniformBlockSize}`);if(this.headerBuffer=t.createBuffer(),!this.headerBuffer)throw new Error("Failed to create header UBO buffer");if(t.bindBuffer(t.UNIFORM_BUFFER,this.headerBuffer),t.bufferData(t.UNIFORM_BUFFER,s0.HEADER_BYTES,t.DYNAMIC_DRAW),this.propertiesBuffer=t.createBuffer(),!this.propertiesBuffer)throw new Error("Failed to create properties UBO buffer");if(t.bindBuffer(t.UNIFORM_BUFFER,this.propertiesBuffer),t.bufferData(t.UNIFORM_BUFFER,this.totalBytes,t.DYNAMIC_DRAW),this.blockIndicesBuffer=t.createBuffer(),!this.blockIndicesBuffer)throw new Error("Failed to create block-indices UBO buffer");t.bindBuffer(t.UNIFORM_BUFFER,this.blockIndicesBuffer),t.bufferData(t.UNIFORM_BUFFER,this.totalBytes,t.DYNAMIC_DRAW),t.bindBuffer(t.UNIFORM_BUFFER,null)}writeHeader(e){const t=this.headerData;t[0]=e.dataDrivenMask,t[1]=e.zoomDependentMask,t[2]=e.dataDrivenBlockSizeVec4,t[3]=e.offsets[0],t[4]=e.offsets[1],t[5]=e.offsets[2],t[6]=e.offsets[3],t[7]=e.offsets[4],t[8]=e.offsets[5],t[9]=e.offsets[6],t[10]=e.offsets[7],t[11]=e.offsets[8]}writeDataDrivenBlock(e,t,r){const c=4*r.dataDrivenBlockSizeVec4;if(c===0)return;const h=t*c;if(h+c>this.propertiesData.length)throw new Error(`UBO write out of bounds: feature index ${t} exceeds propertiesData capacity`);for(let f=0;f<9;f++)r.dataDrivenMask&1<<f&&e[f]!=null&&this._writeProperty(h+r.offsets[f],f,e[f],r.zoomDependentMask)}static getMaxFeatureCount(e,t=4096-s0.HEADER_DWORDS){const r=4*e.dataDrivenBlockSizeVec4;return r===0?1/0:Math.floor(t/r)}_writeProperty(e,t,r,c){const h=this.propertiesData,f=t===8,_=!!(c&1<<t);if(t<2){const g=r;h[e]=g[0],h[e+1]=g[1],h[e+2]=g[2],h[e+3]=g[3]}else if(f&&_){const g=r;h[e]=g[0],h[e+1]=g[1],h[e+2]=g[2],h[e+3]=g[3]}else if(f){const g=r;h[e]=g[0],h[e+1]=g[1]}else if(_){const g=r;h[e]=g[0],h[e+1]=g[1]}else h[e]=r}upload(e){this.context||(this.context=e);const t=e.gl;this.headerBuffer&&this.propertiesBuffer&&this.blockIndicesBuffer||this._initBuffers(e),t.bindBuffer(t.UNIFORM_BUFFER,this.headerBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.headerData),t.bindBuffer(t.UNIFORM_BUFFER,this.propertiesBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.propertiesData),t.bindBuffer(t.UNIFORM_BUFFER,this.blockIndicesBuffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.blockIndicesData),t.bindBuffer(t.UNIFORM_BUFFER,null)}bind(e,t){const r=e.gl,c=(f,_,g)=>{if(!_)return;const b=r.getUniformBlockIndex(t,f);b!==r.INVALID_INDEX&&(r.uniformBlockBinding(t,b,g),r.bindBufferBase(r.UNIFORM_BUFFER,g,_))},h=3*this.batchIndex;c("SymbolPaintPropertiesHeaderUniform",this.headerBuffer,h),c("SymbolPaintPropertiesUniform",this.propertiesBuffer,h+1),c("SymbolPaintPropertiesIndexUniform",this.blockIndicesBuffer,h+2)}destroy(){if(this.context){const e=this.context.gl;this.headerBuffer&&(e.deleteBuffer(this.headerBuffer),this.headerBuffer=null),this.propertiesBuffer&&(e.deleteBuffer(this.propertiesBuffer),this.propertiesBuffer=null),this.blockIndicesBuffer&&(e.deleteBuffer(this.blockIndicesBuffer),this.blockIndicesBuffer=null)}}};zb.HEADER_DWORDS=12,zb.HEADER_BYTES=48;let kb=zb;function Fb(n,e,t,r){return[lf(255*n,255*e),lf(255*t,255*r)]}function _A(n,e,t,r,c,h,f,_){return!!n&&(n.kind==="constant"?n.value==="none":n.kind==="composite"||n.kind==="source"?n.evaluate({zoom:0,brightness:h,worldview:_},e,t,c,r,f)==="none":typeof n=="string"&&n==="none")}wt(kb,"SymbolPropertiesUBO",{omit:["headerBuffer","propertiesBuffer","blockIndicesBuffer"]});class Ob{constructor(e,t,r,c,h="",f,_){this.layer=e,this.zoom=t,this.lut=r,this.isText=c,this.propDefs=this._getPropDefs(),this.worldview=h,this.maxUniformBufferBindings=f||24,this.uboSizeDwords=_||4096,this.featureVertexRangesFromId=new Map,this.allFeatures=[],this.ubos=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex=new Map,this.canDeduplicate=this._checkIfAllPropertiesAreConstant(e,c),this.cachedParams=null,this.cachedParamsNext=null,this.cachedBrightness=void 0,this.cachedConstantUniforms=null,this.cachedConstantRenderZoom=null,this.cachedConstantBrightness=void 0,this.activeAppearanceByVtIndex=new Map}_getPropDefs(){const e=this.isText?"text":"icon";return[{name:`${e}-color`,useThemeName:`${e}-color-use-theme`,isColor:!0},{name:`${e}-halo-color`,useThemeName:`${e}-halo-color-use-theme`,isColor:!0},{name:`${e}-opacity`,useThemeName:null,isColor:!1},{name:`${e}-halo-width`,useThemeName:null,isColor:!1},{name:`${e}-halo-blur`,useThemeName:null,isColor:!1},{name:`${e}-emissive-strength`,useThemeName:null,isColor:!1},{name:`${e}-occlusion-opacity`,useThemeName:null,isColor:!1},{name:"symbol-z-offset",useThemeName:null,isColor:!1},{name:`${e}-translate`,useThemeName:null,isColor:!1,isVec2:!0}]}buildHeader(){const e=this.layer.paint,t=this.propDefs;let r=0,c=0,h=0,f=0;const _=[0,0,0,0,0,0,0,0,0];for(let g=0;g<9;g++){const{name:b,isColor:S,isVec2:I}=t[g],A=e.get(b),M=!(!A||typeof A.isConstant!="function"||A.isConstant()),D=this._appearancesHavePaintProperties(b),z=M||D,B=!(!A||!A.value||A.value.kind!=="composite"),V=this.layer._transitionablePaint._values[b],Z=!z&&(V&&V.value&&V.value.expression&&V.value.expression.kind)==="camera";z?(r|=1<<g,B&&(c|=1<<g),S?(f%4!=0&&(f=f+3&-4),_[g]=f,f+=4):I?B?(f%4!=0&&(f=f+3&-4),_[g]=f,f+=4):(f%4==3&&f++,_[g]=f,f+=2):(_[g]=f,f+=B?2:1)):Z&&(h|=1<<g)}return{dataDrivenMask:r,zoomDependentMask:c,cameraMask:h,dataDrivenBlockSizeVec4:(f===0?0:f+3&-4)/4,offsets:_}}get hasCameraExpression(){return!(!this.cachedHeader||!this.cachedHeader.cameraMask)}evaluateAllProperties(e,t,r,c,h,f,_){const{params:g,paramsNext:b}=this._getCachedParams(h),S={feature:e,featureState:t,canonical:r,availableImages:c,params:g,paramsNext:b,formattedSection:f},I=this.cachedHeader,A=this.propDefs,M=new Array(9).fill(null);for(let D=0;D<9;D++){const{name:z,useThemeName:B,isColor:V,isVec2:Z}=A[D],G=!!(I&&I.zoomDependentMask&1<<D);M[D]=V?this._evaluateColorValue(z,B,S,h,G,_):Z?this._evaluateTranslateValue(z,G,S,_):this._evaluateFloatValue(z,G,S,_)}return M}_evaluateColorValue(e,t,r,c,h,f){const _=this.layer.paint,g=e,b=f&&f.hasPaintProperty(g)?f.paintProperties.get(g):_.get(e),S=t,I=t&&f&&f.hasPaintProperty(S)?f.paintProperties.get(S):t?_.get(t):void 0;if(!b)return[0,0,0,1];const A=_A(I&&typeof I!="string"?I.value:void 0,r.feature,r.featureState,r.availableImages,r.canonical,c,r.formattedSection,this.worldview)?null:this.lut;let M,D;b.isConstant()?M=D=b.constantOr(Ii.transparent):(M=b.property.evaluate(b.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,b.iconImageUseTheme,r.formattedSection),D=h?b.property.evaluate(b.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,b.iconImageUseTheme,r.formattedSection):M);const z=(M||Ii.transparent).toNonPremultipliedRenderColor(A),B=(D||Ii.transparent).toNonPremultipliedRenderColor(A);if(h){const[G,Y]=Fb(z.r,z.g,z.b,z.a),[Q,te]=Fb(B.r,B.g,B.b,B.a);return[G,Y,Q,te]}const[V,Z]=Fb(z.r,z.g,z.b,z.a);return[V,Z,0,0]}_evaluateFloatValue(e,t,r,c){const h=this.layer.paint,f=e.endsWith("opacity")?1:0,_=e,g=c&&c.hasPaintProperty(_)?c.paintProperties.get(_):h.get(e);if(!g)return f;if(g.isConstant())return g.constantOr(f);const b=g.property.evaluate(g.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,g.iconImageUseTheme,r.formattedSection),S=b??f;if(t){const I=g.property.evaluate(g.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,g.iconImageUseTheme,r.formattedSection);return[S,I??f]}return S}_evaluateTranslateValue(e,t,r,c){const h=this.layer.paint,f=e,_=c&&c.hasPaintProperty(f)?c.paintProperties.get(f):h.get(e);if(!_)return[0,0];if(typeof _.isConstant!="function")return _||[0,0];if(_.isConstant())return _.constantOr([0,0]);const g=_.property.evaluate(_.value,r.params,r.feature,r.featureState,r.canonical,r.availableImages,_.iconImageUseTheme,r.formattedSection)||[0,0];if(t){const b=_.property.evaluate(_.value,r.paramsNext,r.feature,r.featureState,r.canonical,r.availableImages,_.iconImageUseTheme,r.formattedSection)||[0,0];return[g[0],g[1],b[0],b[1]]}return g}_getCachedParams(e){return this.cachedParams&&this.cachedParamsNext&&this.cachedBrightness===e||(this.cachedParams=new Mi(this.zoom,{brightness:e,worldview:this.worldview}),this.cachedParamsNext=new Mi(this.zoom+1,{brightness:e,worldview:this.worldview}),this.cachedBrightness=e),{params:this.cachedParams,paramsNext:this.cachedParamsNext}}_appearancesHavePaintProperties(e){return this.layer.getAppearances().some(e!==void 0?t=>t.hasPaintProperty(e):this.isText?t=>t.hasTextPaintProperties():t=>t.hasIconPaintProperties())}_checkIfAllPropertiesAreConstant(e,t){const r=e.paint,c=t?"text":"icon",h=[`${c}-color`,`${c}-halo-color`,`${c}-opacity`,`${c}-halo-width`,`${c}-halo-blur`,`${c}-emissive-strength`,`${c}-occlusion-opacity`,"symbol-z-offset",`${c}-translate`];for(const f of h){const _=r.get(f);if(_&&typeof _=="object"&&"isConstant"in _&&!_.isConstant())return!1}return!this._appearancesHavePaintProperties()}_hashDataDrivenValues(e,t){if(t.dataDrivenMask===0)return"";const r=[];for(let c=0;c<9;c++){if(!(t.dataDrivenMask&1<<c))continue;const h=e[c];h==null?r.push("null"):Array.isArray(h)?r.push(h.join(",")):r.push(String(h))}return r.join("|")}getCurrentBatchIndex(){return this.cachedHeader&&this.maxFeaturesPerBatch!==0?Math.floor(this.featureCount/this.maxFeaturesPerBatch):0}populateUBO(e,t,r,c,h,f,_){const g=e.id;if(!this.cachedHeader){this.cachedHeader=this.buildHeader();const B=kb.getMaxFeatureCount(this.cachedHeader,this.uboSizeDwords);this.maxFeaturesPerBatch=isFinite(B)?B:Number.MAX_SAFE_INTEGER}const b=this.cachedHeader,S=this.evaluateAllProperties(e,{},r,c,h,f);if(this.canDeduplicate){const B=this._hashDataDrivenValues(S,b),V=this.propertyHashToUBOIndex.get(B);if(V!==void 0){const Z=isFinite(this.maxFeaturesPerBatch)?Math.floor(V/this.maxFeaturesPerBatch):0,G=isFinite(this.maxFeaturesPerBatch)?V%this.maxFeaturesPerBatch:V,Y={batchIndex:Z,localFeatureIndex:G,vtFeatureIndex:t,featureId:g};return this.allFeatures.push(Y),g!=null&&(this.featureVertexRangesFromId.has(g)||this.featureVertexRangesFromId.set(g,[]),this.featureVertexRangesFromId.get(g).push(Y)),G}this.propertyHashToUBOIndex.set(B,this.featureCount)}const I=this.featureCount++,A=isFinite(this.maxFeaturesPerBatch)?Math.floor(I/this.maxFeaturesPerBatch):0,M=isFinite(this.maxFeaturesPerBatch)?I%this.maxFeaturesPerBatch:I,D=_?_.maxUniformBufferBindings:this.maxUniformBufferBindings;if(3*A+2>=D){zt(`Too many symbol features: batch ${A} requires binding points up to ${3*A+2}, device limit ${D}. Some features will render incorrectly.`);const B={batchIndex:0,localFeatureIndex:0,vtFeatureIndex:t,featureId:g};return this.allFeatures.push(B),g!=null&&(this.featureVertexRangesFromId.has(g)||this.featureVertexRangesFromId.set(g,[]),this.featureVertexRangesFromId.get(g).push(B)),0}this.ubos[A]||(this.ubos[A]=new kb(_,A,this.uboSizeDwords),this.ubos[A].writeHeader(b)),this.ubos[A].writeDataDrivenBlock(S,M,b);const z={batchIndex:A,localFeatureIndex:M,vtFeatureIndex:t,featureId:g};return this.allFeatures.push(z),g!=null&&(this.featureVertexRangesFromId.has(g)||this.featureVertexRangesFromId.set(g,[]),this.featureVertexRangesFromId.get(g).push(z)),M}updateFeatures(e,t,r,c,h,f,_){if(this.layer=t,this.cachedConstantUniforms=null,!this.cachedHeader)return;const g=this.cachedHeader;for(const b of e){const S=this.featureVertexRangesFromId.get(b);if(!S)continue;const I=f[b]||{};for(const A of S){if(!r)continue;const M=r.feature(A.vtFeatureIndex);if(!M)continue;const D={type:M.type,id:b,properties:M.properties||{},geometry:[]},z=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(A.vtFeatureIndex):void 0,B=this.evaluateAllProperties(D,I,c,h,_,void 0,z);this.ubos[A.batchIndex]&&this.ubos[A.batchIndex].writeDataDrivenBlock(B,A.localFeatureIndex,g)}}}updateDynamicExpressions(e,t,r,c,h,f){if(this.layer=e,this.cachedConstantUniforms=null,!this.cachedHeader)return;const _=this.cachedHeader;for(const g of this.allFeatures){if(!t)continue;const b=t.feature(g.vtFeatureIndex);if(!b)continue;const S=g.featureId!=null&&h[g.featureId]||{},I={type:b.type,id:g.featureId,properties:b.properties||{},geometry:[]},A=this.activeAppearanceByVtIndex?this.activeAppearanceByVtIndex.get(g.vtFeatureIndex):void 0,M=this.evaluateAllProperties(I,S,r,c,f,void 0,A);this.ubos[g.batchIndex]&&this.ubos[g.batchIndex].writeDataDrivenBlock(M,g.localFeatureIndex,_)}}updateFeaturePaintForAppearance(e,t,r,c,h,f,_){if(!this.layer||(this.activeAppearanceByVtIndex||(this.activeAppearanceByVtIndex=new Map),this.activeAppearanceByVtIndex.set(e,_||null),!this.cachedHeader))return!1;const g=this.cachedHeader;if(g.dataDrivenMask===0)return!1;let b=!1;for(const S of this.allFeatures){if(S.vtFeatureIndex!==e)continue;const I=this.evaluateAllProperties(t,r,c,h,f,void 0,_);this.ubos[S.batchIndex]&&(this.ubos[S.batchIndex].writeDataDrivenBlock(I,S.localFeatureIndex,g),b=!0)}return b}getConstantUniformValues(e,t){const r=this.cachedHeader,c=!(!r||!r.cameraMask);if(this.cachedConstantUniforms&&this.cachedConstantBrightness===t&&(!c||this.cachedConstantRenderZoom===e))return this.cachedConstantUniforms;const h=this.layer.paint,f=this.propDefs,_=c?new Mi(e,{brightness:t,worldview:this.worldview}):null,g={type:1,id:void 0,properties:{},geometry:[]},b=A=>{const M=f[A],D=h.get(M.name);if(!D)return[0,0,0,1];const z=M.useThemeName?h.get(M.useThemeName):void 0,B=_A(z&&typeof z!="string"?z.value:void 0,g,{},[],void 0,t,void 0,this.worldview)?null:this.lut;let V;V=r&&r.cameraMask&1<<A&&_?D.property.evaluate(D.value,_,g,{},void 0,[]):D.constantOr(Ii.transparent);const Z=(V||Ii.transparent).toNonPremultipliedRenderColor(B);return[Z.r,Z.g,Z.b,Z.a]},S=(A,M)=>{const D=h.get(f[A].name);if(!D)return M;if(r&&r.cameraMask&1<<A&&_){const z=D.property.evaluate(D.value,_,g,{},void 0,[]);return z??M}return D.constantOr(M)},I={fill_np_color:b(0),halo_np_color:b(1),opacity:S(2,1),halo_width:S(3,0),halo_blur:S(4,0),emissive_strength:S(5,0),occlusion_opacity:S(6,1),z_offset:S(7,0)};return this.cachedConstantUniforms=I,this.cachedConstantRenderZoom=e,this.cachedConstantBrightness=t,I}upload(e){for(const t of this.ubos)t.upload(e)}bind(e,t,r=0){this.ubos[r]&&this.ubos[r].bind(e,t)}destroy(){for(const e of this.ubos)e.destroy();this.ubos=[],this.featureVertexRangesFromId.clear(),this.allFeatures=[],this.featureCount=0,this.cachedHeader=null,this.maxFeaturesPerBatch=0,this.propertyHashToUBOIndex&&this.propertyHashToUBOIndex.clear()}}wt(Ob,"SymbolPropertyBinderUBO",{omit:["layer","cachedParams","cachedParamsNext","cachedBrightness","propertyHashToUBOIndex","cachedConstantUniforms","cachedConstantRenderZoom","cachedConstantBrightness","activeAppearanceByVtIndex"]});var nr=24;function vB(n,e,t){return n.sections.forEach(r=>{r.text=function(c,h,f){const _=h.layout.get("text-transform").evaluate(f,{});return _==="uppercase"?c=c.toLocaleUpperCase():_==="lowercase"&&(c=c.toLocaleLowerCase()),fa.applyArabicShaping&&(c=fa.applyArabicShaping(c)),c}(r.text,e,t)}),n}const y_={"!":"︕","#":"＃",$:"＄","%":"％","&":"＆","(":"︵",")":"︶","*":"＊","+":"＋",",":"︐","-":"︲",".":"・","/":"／",":":"︓",";":"︔","<":"︿","=":"＝",">":"﹀","?":"︖","@":"＠","[":"﹇","\\":"＼","]":"﹈","^":"＾",_:"︳","`":"｀","{":"︷","|":"―","}":"︸","~":"～","¢":"￠","£":"￡","¥":"￥","¦":"￤","¬":"￢","¯":"￣","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"￦","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","！":"︕","（":"︵","）":"︶","，":"︐","－":"︲","．":"・","：":"︓","；":"︔","＜":"︿","＞":"﹀","？":"︖","［":"﹇","］":"﹈","＿":"︳","｛":"︷","｜":"―","｝":"︸","｟":"︵","｠":"︶","｡":"︒","｢":"﹁","｣":"﹂","←":"↑","→":"↓"};function bB(n){return n==="︶"||n==="﹈"||n==="︸"||n==="﹄"||n==="﹂"||n==="︾"||n==="︼"||n==="︺"||n==="︘"||n==="﹀"||n==="︐"||n==="︓"||n==="︔"||n==="｀"||n==="￣"||n==="︑"||n==="︒"}function wB(n){return n==="︵"||n==="﹇"||n==="︷"||n==="﹃"||n==="﹁"||n==="︽"||n==="︻"||n==="︹"||n==="︗"||n==="︿"}const Bb=4294967296,gA=1/Bb,yA=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let jx=class{constructor(n=new Uint8Array(16)){this.buf=ArrayBuffer.isView(n)?n:new Uint8Array(n),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(n,e,t=this.length){for(;this.pos<t;){const r=this.readVarint(),c=r>>3,h=this.pos;this.type=7&r,n(c,e,this),this.pos===h&&this.skip(r)}return e}readMessage(n,e){return this.readFields(n,e,this.readVarint()+this.pos)}readFixed32(){const n=this.dataView.getUint32(this.pos,!0);return this.pos+=4,n}readSFixed32(){const n=this.dataView.getInt32(this.pos,!0);return this.pos+=4,n}readFixed64(){const n=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Bb;return this.pos+=8,n}readSFixed64(){const n=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Bb;return this.pos+=8,n}readFloat(){const n=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,n}readDouble(){const n=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,n}readVarint(n){const e=this.buf;let t,r;return r=e[this.pos++],t=127&r,r<128?t:(r=e[this.pos++],t|=(127&r)<<7,r<128?t:(r=e[this.pos++],t|=(127&r)<<14,r<128?t:(r=e[this.pos++],t|=(127&r)<<21,r<128?t:(r=e[this.pos],t|=(15&r)<<28,function(c,h,f){const _=f.buf;let g,b;if(b=_[f.pos++],g=(112&b)>>4,b<128||(b=_[f.pos++],g|=(127&b)<<3,b<128)||(b=_[f.pos++],g|=(127&b)<<10,b<128)||(b=_[f.pos++],g|=(127&b)<<17,b<128)||(b=_[f.pos++],g|=(127&b)<<24,b<128)||(b=_[f.pos++],g|=(1&b)<<31,b<128))return yf(c,g,h);throw new Error("Expected varint not more than 10 bytes")}(t,n,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const n=this.readVarint();return n%2==1?(n+1)/-2:n/2}readBoolean(){return!!this.readVarint()}readString(){const n=this.readVarint()+this.pos,e=this.pos;return this.pos=n,n-e>=12&&yA?yA.decode(this.buf.subarray(e,n)):function(t,r,c){let h="",f=r;for(;f<c;){const _=t[f];let g,b,S,I=null,A=_>239?4:_>223?3:_>191?2:1;if(f+A>c)break;A===1?_<128&&(I=_):A===2?(g=t[f+1],(192&g)==128&&(I=(31&_)<<6|63&g,I<=127&&(I=null))):A===3?(g=t[f+1],b=t[f+2],(192&g)==128&&(192&b)==128&&(I=(15&_)<<12|(63&g)<<6|63&b,(I<=2047||I>=55296&&I<=57343)&&(I=null))):A===4&&(g=t[f+1],b=t[f+2],S=t[f+3],(192&g)==128&&(192&b)==128&&(192&S)==128&&(I=(15&_)<<18|(63&g)<<12|(63&b)<<6|63&S,(I<=65535||I>=1114112)&&(I=null))),I===null?(I=65533,A=1):I>65535&&(I-=65536,h+=String.fromCharCode(I>>>10&1023|55296),I=56320|1023&I),h+=String.fromCharCode(I),f+=A}return h}(this.buf,e,n)}readBytes(){const n=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,n);return this.pos=n,e}readPackedVarint(n=[],e){const t=this.readPackedEnd();for(;this.pos<t;)n.push(this.readVarint(e));return n}readPackedSVarint(n=[]){const e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readSVarint());return n}readPackedBoolean(n=[]){const e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readBoolean());return n}readPackedFloat(n=[]){const e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readFloat());return n}readPackedDouble(n=[]){const e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readDouble());return n}readPackedFixed32(n=[]){const e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readFixed32());return n}readPackedSFixed32(n=[]){const e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readSFixed32());return n}readPackedFixed64(n=[]){const e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readFixed64());return n}readPackedSFixed64(n=[]){const e=this.readPackedEnd();for(;this.pos<e;)n.push(this.readSFixed64());return n}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(n){const e=7&n;if(e===0)for(;this.buf[this.pos++]>127;);else if(e===2)this.pos=this.readVarint()+this.pos;else if(e===5)this.pos+=4;else{if(e!==1)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}writeTag(n,e){this.writeVarint(n<<3|e)}realloc(n){let e=this.length||16;for(;e<this.pos+n;)e*=2;if(e!==this.length){const t=new Uint8Array(e);t.set(this.buf),this.buf=t,this.dataView=new DataView(t.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(n){this.realloc(4),this.dataView.setInt32(this.pos,n,!0),this.pos+=4}writeSFixed32(n){this.realloc(4),this.dataView.setInt32(this.pos,n,!0),this.pos+=4}writeFixed64(n){this.realloc(8),this.dataView.setInt32(this.pos,-1&n,!0),this.dataView.setInt32(this.pos+4,Math.floor(n*gA),!0),this.pos+=8}writeSFixed64(n){this.realloc(8),this.dataView.setInt32(this.pos,-1&n,!0),this.dataView.setInt32(this.pos+4,Math.floor(n*gA),!0),this.pos+=8}writeVarint(n){(n=+n||0)>268435455||n<0?function(e,t){let r,c;if(e>=0?(r=e%4294967296|0,c=e/4294967296|0):(r=~(-e%4294967296),c=~(-e/4294967296),4294967295^r?r=r+1|0:(r=0,c=c+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(h,f,_){_.buf[_.pos++]=127&h|128,h>>>=7,_.buf[_.pos++]=127&h|128,h>>>=7,_.buf[_.pos++]=127&h|128,h>>>=7,_.buf[_.pos++]=127&h|128,_.buf[_.pos]=127&(h>>>=7)}(r,0,t),function(h,f){const _=(7&h)<<4;f.buf[f.pos++]|=_|((h>>>=3)?128:0),h&&(f.buf[f.pos++]=127&h|((h>>>=7)?128:0),h&&(f.buf[f.pos++]=127&h|((h>>>=7)?128:0),h&&(f.buf[f.pos++]=127&h|((h>>>=7)?128:0),h&&(f.buf[f.pos++]=127&h|((h>>>=7)?128:0),h&&(f.buf[f.pos++]=127&h)))))}(c,t)}(n,this):(this.realloc(4),this.buf[this.pos++]=127&n|(n>127?128:0),n<=127||(this.buf[this.pos++]=127&(n>>>=7)|(n>127?128:0),n<=127||(this.buf[this.pos++]=127&(n>>>=7)|(n>127?128:0),n<=127||(this.buf[this.pos++]=n>>>7&127))))}writeSVarint(n){this.writeVarint(n<0?2*-n-1:2*n)}writeBoolean(n){this.writeVarint(+n)}writeString(n){n=String(n),this.realloc(4*n.length),this.pos++;const e=this.pos;this.pos=function(r,c,h){for(let f,_,g=0;g<c.length;g++){if(f=c.charCodeAt(g),f>55295&&f<57344){if(!_){f>56319||g+1===c.length?(r[h++]=239,r[h++]=191,r[h++]=189):_=f;continue}if(f<56320){r[h++]=239,r[h++]=191,r[h++]=189,_=f;continue}f=_-55296<<10|f-56320|65536,_=null}else _&&(r[h++]=239,r[h++]=191,r[h++]=189,_=null);f<128?r[h++]=f:(f<2048?r[h++]=f>>6|192:(f<65536?r[h++]=f>>12|224:(r[h++]=f>>18|240,r[h++]=f>>12&63|128),r[h++]=f>>6&63|128),r[h++]=63&f|128)}return h}(this.buf,n,this.pos);const t=this.pos-e;t>=128&&xA(e,t,this),this.pos=e-1,this.writeVarint(t),this.pos+=t}writeFloat(n){this.realloc(4),this.dataView.setFloat32(this.pos,n,!0),this.pos+=4}writeDouble(n){this.realloc(8),this.dataView.setFloat64(this.pos,n,!0),this.pos+=8}writeBytes(n){const e=n.length;this.writeVarint(e),this.realloc(e);for(let t=0;t<e;t++)this.buf[this.pos++]=n[t]}writeRawMessage(n,e){this.pos++;const t=this.pos;n(e,this);const r=this.pos-t;r>=128&&xA(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r}writeMessage(n,e,t){this.writeTag(n,2),this.writeRawMessage(e,t)}writePackedVarint(n,e){e.length&&this.writeMessage(n,TB,e)}writePackedSVarint(n,e){e.length&&this.writeMessage(n,SB,e)}writePackedBoolean(n,e){e.length&&this.writeMessage(n,AB,e)}writePackedFloat(n,e){e.length&&this.writeMessage(n,EB,e)}writePackedDouble(n,e){e.length&&this.writeMessage(n,IB,e)}writePackedFixed32(n,e){e.length&&this.writeMessage(n,CB,e)}writePackedSFixed32(n,e){e.length&&this.writeMessage(n,PB,e)}writePackedFixed64(n,e){e.length&&this.writeMessage(n,MB,e)}writePackedSFixed64(n,e){e.length&&this.writeMessage(n,RB,e)}writeBytesField(n,e){this.writeTag(n,2),this.writeBytes(e)}writeFixed32Field(n,e){this.writeTag(n,5),this.writeFixed32(e)}writeSFixed32Field(n,e){this.writeTag(n,5),this.writeSFixed32(e)}writeFixed64Field(n,e){this.writeTag(n,1),this.writeFixed64(e)}writeSFixed64Field(n,e){this.writeTag(n,1),this.writeSFixed64(e)}writeVarintField(n,e){this.writeTag(n,0),this.writeVarint(e)}writeSVarintField(n,e){this.writeTag(n,0),this.writeSVarint(e)}writeStringField(n,e){this.writeTag(n,2),this.writeString(e)}writeFloatField(n,e){this.writeTag(n,5),this.writeFloat(e)}writeDoubleField(n,e){this.writeTag(n,1),this.writeDouble(e)}writeBooleanField(n,e){this.writeVarintField(n,+e)}};function yf(n,e,t){return t?4294967296*e+(n>>>0):4294967296*(e>>>0)+(n>>>0)}function xA(n,e,t){const r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));t.realloc(r);for(let c=t.pos-1;c>=n;c--)t.buf[c+r]=t.buf[c]}function TB(n,e){for(let t=0;t<n.length;t++)e.writeVarint(n[t])}function SB(n,e){for(let t=0;t<n.length;t++)e.writeSVarint(n[t])}function EB(n,e){for(let t=0;t<n.length;t++)e.writeFloat(n[t])}function IB(n,e){for(let t=0;t<n.length;t++)e.writeDouble(n[t])}function AB(n,e){for(let t=0;t<n.length;t++)e.writeBoolean(n[t])}function CB(n,e){for(let t=0;t<n.length;t++)e.writeFixed32(n[t])}function PB(n,e){for(let t=0;t<n.length;t++)e.writeSFixed32(n[t])}function MB(n,e){for(let t=0;t<n.length;t++)e.writeFixed64(n[t])}function RB(n,e){for(let t=0;t<n.length;t++)e.writeSFixed64(n[t])}function DB(n,e,t){e.glyphs=[],n===1&&t.readMessage(LB,e)}function LB(n,e,t){if(n===3){const{id:r,bitmap:c,width:h,height:f,left:_,top:g,advance:b}=t.readMessage(zB,{});e.glyphs.push({id:r,bitmap:new $c({width:h+6,height:f+6},c),metrics:{width:h,height:f,left:_,top:g,advance:b}})}else n===4?e.ascender=t.readSVarint():n===5&&(e.descender=t.readSVarint())}function zB(n,e,t){n===1?e.id=t.readVarint():n===2?e.bitmap=t.readBytes():n===3?e.width=t.readVarint():n===4?e.height=t.readVarint():n===5?e.left=t.readSVarint():n===6?e.top=t.readSVarint():n===7&&(e.advance=t.readVarint())}const Os={horizontal:1,vertical:2,horizontalOnly:3};class x_{constructor(){this.scale=1,this.fontStack="",this.image=null}static forText(e,t){const r=new x_;return r.scale=e||1,r.fontStack=t,r}static forImage(e){const t=new x_;return t.image=e,t}}class xf{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t,r,c=1){const h=new xf;for(let f=0;f<e.sections.length;f++){const _=e.sections[f];_.image?h.addImageSection(_,r,c):h.addTextSection(_,t)}return h}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCodePoint(e){return this.text.codePointAt(e)}verticalizePunctuation(e){this.text=function(t,r){let c="";for(let h=0;h<t.length;h++){const f=t.charCodeAt(h+1)||null,_=t.charCodeAt(h-1)||null;c+=!r&&(f&&Dl(f)&&!y_[t[h+1]]||_&&Dl(_)&&!y_[t[h-1]])||!y_[t[h]]?t[h]:y_[t[h]]}return c}(this.text,e)}trim(){let e=0;for(let r=0;r<this.text.length&&Gx[this.text.charCodeAt(r)];r++)e++;let t=this.text.length;for(let r=this.text.length-1;r>=0&&r>=e&&Gx[this.text.charCodeAt(r)];r--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const r=new xf;return r.text=this.text.substring(e,t),r.sectionIndex=this.sectionIndex.slice(e,t),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(x_.forText(e.scale,e.fontStack||t));const r=this.sections.length-1;for(let c=0;c<e.text.length;++c)this.sectionIndex.push(r)}addImageSection(e,t,r=1){const c=e.image?e.image.getPrimary():null;if(!c)return void zt("Can't add FormattedSection with an empty image.");c.scaleSelf(t*r);const h=this.getNextImageSectionCharCode();h?(this.text+=String.fromCodePoint(h),this.sections.push(x_.forImage(c)),this.sectionIndex.push(this.sections.length-1)):zt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Nb(n,e,t,r,c,h,f,_,g,b,S,I,A,M,D,z=1,B=1){const V=xf.fromFeature(n,c,z,B);I===Os.vertical&&V.verticalizePunctuation(A);let Z=[];const G=function(ce,pe,he,de,Be,je,He=1){if(!ce)return[];const Xe=[],Ze=function(We,Qe,st,ut,bt,mt,pt=1){let ht=0;for(let yt=0;yt<We.length();yt++){const It=We.getSection(yt);ht+=vA(We.getCodePoint(yt),It,ut,bt,Qe,mt,pt)}return ht/Math.max(1,Math.ceil(ht/st))}(ce,pe,he,de,Be,je,He),nt=ce.text.indexOf("​")>=0;let Fe=0;for(let We=0;We<ce.length();We++){const Qe=ce.getSection(We),st=ce.getCodePoint(We);if(Gx[st]||(Fe+=vA(st,Qe,de,Be,pe,je,He)),We<ce.length()-1){const ut=L1(st);(kB[st]||ut||Qe.image)&&Xe.push(wA(We+1,Fe,Ze,Xe,FB(st,ce.getCodePoint(We+1),ut&&nt),!1))}}return TA(wA(ce.length(),Fe,Ze,Xe,0,!0))}(V,b,h,e,r,M,B),{processBidirectionalText:Y,processStyledBidirectionalText:Q}=fa;if(Y&&V.sections.length===1){const ce=Y(V.toString(),G);for(const pe of ce){const he=new xf;he.text=pe,he.sections=V.sections;for(let de=0;de<pe.length;de++)he.sectionIndex.push(0);Z.push(he)}}else if(Q){const ce=Q(V.text,V.sectionIndex,G);for(const pe of ce){const he=new xf;he.text=pe[0],he.sectionIndex=pe[1],he.sections=V.sections,Z.push(he)}}else Z=function(ce,pe){const he=[],de=ce.text;let Be=0;for(const je of pe)he.push(ce.substring(Be,je)),Be=je;return Be<de.length&&he.push(ce.substring(Be,de.length)),he}(V,G);const te=[],me={positionedLines:te,text:V.toString(),top:S[1],bottom:S[1],left:S[0],right:S[0],writingMode:I,iconsInText:!1,verticalizable:!1,hasBaseline:!1};if(function(ce,pe,he,de,Be,je,He,Xe,Ze,nt,Fe,We,Qe=1){let st=0,ut=0,bt=0;const mt=Xe==="right"?1:Xe==="left"?0:.5;let pt=!1;for(const Ct of Be){const Qt=Ct.getSections();for(const vi of Qt){if(vi.image)continue;const ei=pe[vi.fontStack];if(ei&&(pt=ei.ascender!==void 0&&ei.descender!==void 0,!pt))break}if(!pt)break}let ht=0;for(const Ct of Be){Ct.trim();const Qt=Ct.getMaxScale(),vi=(Qt-1)*nr,ei={positionedGlyphs:[],lineOffset:0};ce.positionedLines[ht]=ei;const wi=ei.positionedGlyphs;let ai=0;if(!Ct.length()){ut+=je,++ht;continue}let gn=0,Ri=0;for(let qi=0;qi<Ct.length();qi++){const dn=Ct.getSection(qi),rr=Ct.getSectionIndex(qi),fn=Ct.getCodePoint(qi);let Sn=dn.scale,Bn=null,En=null,Ir=null,sr=nr,ci=0,Yr=Ze;Yr===Os.vertical&&$y(fn)&&(Yr=Os.horizontal);const Rn=!(Yr===Os.horizontal||!Fe&&!bm(fn)||Fe&&(Gx[fn]||Hy(fn)));if(dn.image){const cr=de.get(dn.image.toString());if(!cr)continue;Ir=dn.image,ce.iconsInText=ce.iconsInText||!0,En=cr.paddedRect;const Kr=cr.displaySize,Ar=Kr[0]*Qe,yn=Kr[1]*Qe;Sn=Sn*nr/We,Bn={width:Ar,height:yn,left:0,top:-3,advance:Rn?yn:Ar,localGlyph:!1},ci=pt?-Bn.height*Sn:Qt*nr-17-yn*Sn,sr=Bn.advance;const Gr=(Rn?Ar:yn)*Sn-nr*Qt;Gr>0&&Gr>ai&&(ai=Gr)}else{const cr=he[dn.fontStack];if(!cr)continue;cr[fn]&&(En=cr[fn]);const Kr=pe[dn.fontStack];if(!Kr)continue;const Ar=Kr.glyphs[fn];if(!Ar)continue;if(Bn=Ar.metrics,sr=fn!==8203?nr:0,pt){const yn=Kr.ascender!==void 0?Math.abs(Kr.ascender):0,Gr=Kr.descender!==void 0?Math.abs(Kr.descender):0,ur=(yn+Gr)*Sn;gn<ur&&(gn=ur,Ri=(yn-Gr)/2*Sn),ci=-yn*Sn}else ci=(Qt-Sn)*nr-17}Rn?(ce.verticalizable=!0,wi.push({glyph:fn,image:Ir,x:st,y:ut+ci,vertical:Rn,scale:Sn,localGlyph:Bn.localGlyph,fontStack:dn.fontStack,sectionIndex:rr,metrics:Bn,rect:En}),st+=sr*Sn+nt):(wi.push({glyph:fn,image:Ir,x:st,y:ut+ci,vertical:Rn,scale:Sn,localGlyph:Bn.localGlyph,fontStack:dn.fontStack,sectionIndex:rr,metrics:Bn,rect:En}),st+=Bn.advance*Sn+nt)}wi.length!==0&&(bt=Math.max(st-nt,bt),pt?SA(wi,mt,ai,Ri,je*Qt/2):SA(wi,mt,ai,0,je/2)),st=0;const Si=je*Qt+ai;ei.lineOffset=Math.max(ai,vi),ut+=Si,++ht}const yt=ut,{horizontalAlign:It,verticalAlign:kt}=Vb(He);(function(Ct,Qt,vi,ei,wi,ai){const gn=(Qt-vi)*wi,Ri=-ai*ei;for(const Si of Ct)for(const qi of Si.positionedGlyphs)qi.x+=gn,qi.y+=Ri})(ce.positionedLines,mt,It,kt,bt,yt),ce.top+=-kt*yt,ce.bottom=ce.top+yt,ce.left+=-It*bt,ce.right=ce.left+bt,ce.hasBaseline=pt}(me,e,t,r,Z,f,_,g,I,b,A,D,B),!function(ce){for(const pe of ce)if(pe.positionedGlyphs.length!==0)return!1;return!0}(te))return me}const Gx={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},kB={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function vA(n,e,t,r,c,h,f=1){if(e.image){const _=r.get(e.image.toString());return _?_.displaySize[0]*f*e.scale*nr/h+c:0}{const _=t[e.fontStack],g=_&&_.glyphs[n];return g?g.metrics.advance*e.scale+c:0}}function bA(n,e,t,r){const c=Math.pow(n-e,2);return r?n<e?c/2:2*c:c+Math.abs(t)*t}function FB(n,e,t){let r=0;return n===10&&(r-=1e4),t&&(r+=150),n!==40&&n!==65288||(r+=50),e!==41&&e!==65289||(r+=50),r}function wA(n,e,t,r,c,h){let f=null,_=bA(e,t,c,h);for(const g of r){const b=bA(e-g.x,t,c,h)+g.badness;b<=_&&(f=g,_=b)}return{index:n,x:e,priorBreak:f,badness:_}}function TA(n){return n?TA(n.priorBreak).concat(n.index):[]}function Vb(n){let e=.5,t=.5;switch(n){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(n){case"bottom":case"bottom-right":case"bottom-left":t=1;break;case"top":case"top-right":case"top-left":t=0}return{horizontalAlign:e,verticalAlign:t}}function SA(n,e,t,r,c){if(!(e||t||r||c))return;const h=n.length-1,f=n[h],_=(f.x+f.metrics.advance*f.scale)*e;for(let g=0;g<=h;g++)n[g].x-=_,n[g].y+=t+r+c}function Ub(n){return n.imagePrimary!==void 0&&n.top!==void 0&&n.bottom!==void 0&&n.left!==void 0&&n.right!==void 0}function $x(n,e,t,r){const{horizontalAlign:c,verticalAlign:h}=Vb(r),f=t[0]-n.displaySize[0]*c,_=t[1]-n.displaySize[1]*h;return{imagePrimary:n,imageSecondary:e,top:_,bottom:_+n.displaySize[1],left:f,right:f+n.displaySize[0]}}function jb(n,e,t,r,c,h){const f=n.imagePrimary;let _;if(f.content){const B=f.content,V=f.pixelRatio||1;_=[B[0]/V,B[1]/V,f.displaySize[0]-B[2]/V,f.displaySize[1]-B[3]/V]}const g=e.left*h,b=e.right*h;let S,I,A,M;t==="width"||t==="both"?(M=c[0]+g-r[3],I=c[0]+b+r[1]):(M=c[0]+(g+b-f.displaySize[0])/2,I=M+f.displaySize[0]);const D=e.top*h,z=e.bottom*h;return t==="height"||t==="both"?(S=c[1]+D-r[0],A=c[1]+z+r[2]):(S=c[1]+(D+z-f.displaySize[1])/2,A=S+f.displaySize[1]),{imagePrimary:f,imageSecondary:void 0,top:S,right:I,bottom:A,left:M,collisionPadding:_}}function EA(n){return!n.imagePrimary.stretchX}function IA(n){return!n.imagePrimary.stretchY}function AA(n){return{width:n.right-n.left,height:n.bottom-n.top}}const $l=128;function Ch(n,e,t,r){const{expression:c}=e;if(c.kind==="constant")return{kind:"constant",layoutSize:c.evaluate(new Mi(n+1,{worldview:t}),void 0,void 0,void 0,r)};if(c.kind==="source")return{kind:"source"};{const{zoomStops:h,interpolationType:f}=c;let _=0;for(;_<h.length&&h[_]<=n;)_++;_=Math.max(0,_-1);let g=_;for(;g<h.length&&h[g]<n+1;)g++;g=Math.min(h.length-1,g);const b=h[_],S=h[g];return c.kind==="composite"?{kind:"composite",minZoom:b,maxZoom:S,interpolationType:f}:{kind:"camera",minZoom:b,maxZoom:S,minSize:c.evaluate(new Mi(b,{worldview:t}),void 0,void 0,void 0,r),maxSize:c.evaluate(new Mi(S,{worldview:t}),void 0,void 0,void 0,r),interpolationType:f}}}function Gb(n,{uSize:e,uSizeT:t},{lowerSize:r,upperSize:c}){return n.kind==="source"?r/$l:n.kind==="composite"?Gt(r/$l,c/$l,t):e}function vf(n,e,t=1){let r=0,c=0;if(n.kind==="constant")c=n.layoutSize*t;else if(n.kind!=="source"){const{interpolationType:h,minZoom:f,maxZoom:_}=n,g=h?q(zr.interpolationFactor(h,e,f,_),0,1):0;n.kind==="camera"?c=Gt(n.minSize,n.maxSize,g)*t:r=g*t}return{uSizeT:r,uSize:c}}class Hl extends it{constructor(e,t,r,c,h){super(e,t),this.angle=c,this.z=r,h!==void 0&&(this.segment=h)}clone(){return new Hl(this.x,this.y,this.z,this.angle,this.segment)}}function CA(n,e,t,r,c){if(e.segment===void 0)return!0;let h=e,f=e.segment+1,_=0;for(;_>-t/2;){if(f--,f<0)return!1;_-=n[f].dist(h),h=n[f]}_+=n[f].dist(n[f+1]),f++;const g=[];let b=0;for(;_<t/2;){const S=n[f],I=n[f+1];if(!I)return!1;let A=n[f-1].angleTo(S)-S.angleTo(I);for(A=Math.abs((A+3*Math.PI)%(2*Math.PI)-Math.PI),g.push({distance:_,angleDelta:A}),b+=A;_-g[0].distance>r;)b-=g.shift().angleDelta;if(b>c)return!1;f++,_+=S.dist(I)}return!0}function PA(n){let e=0;for(let t=0;t<n.length-1;t++)e+=n[t].dist(n[t+1]);return e}function MA(n,e,t){return n?.6*e*t:0}function RA(n,e){return Math.max(n?n.right-n.left:0,e?e.right-e.left:0)}function OB(n,e,t,r,c,h){const f=MA(t,c,h),_=RA(t,r)*h;let g=0;const b=PA(n)/2;for(let S=0;S<n.length-1;S++){const I=n[S],A=n[S+1],M=I.dist(A);if(g+M>b){const D=(b-g)/M,z=Gt(I.x,A.x,D),B=Gt(I.y,A.y,D),V=new Hl(z,B,0,A.angleTo(I),S);return!f||CA(n,V,_,f,e)?V:void 0}g+=M}}function BB(n,e,t,r,c,h,f,_,g){const b=MA(r,h,f),S=RA(r,c),I=S*f,A=n[0].x===0||n[0].x===g||n[0].y===0||n[0].y===g;return e-I<e/4&&(e=I+e/4),DA(n,A?e/2*_%e:(S/2+2*h)*f*_%e,e,b,t,I,A,!1,g)}function DA(n,e,t,r,c,h,f,_,g){const b=h/2,S=PA(n);let I=0,A=e-t,M=[];for(let D=0;D<n.length-1;D++){const z=n[D],B=n[D+1],V=z.dist(B),Z=B.angleTo(z);for(;A+t<I+V;){A+=t;const G=(A-I)/V,Y=Gt(z.x,B.x,G),Q=Gt(z.y,B.y,G);if(Y>=0&&Y<g&&Q>=0&&Q<g&&A-b>=0&&A+b<=S){const te=new Hl(Y,Q,0,Z,D);r&&!CA(n,te,h,r,c)||M.push(te)}}I+=V}return _||M.length||f||(M=DA(n,I/2,t,r,c,h,f,!0,g)),M}function LA(n){let e=0,t=0;for(const f of n)e+=f.w*f.h,t=Math.max(t,f.w);n.sort((f,_)=>_.h-f.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),t),h:1/0}];let c=0,h=0;for(const f of n)for(let _=r.length-1;_>=0;_--){const g=r[_];if(!(f.w>g.w||f.h>g.h)){if(f.x=g.x,f.y=g.y,h=Math.max(h,f.y+f.h),c=Math.max(c,f.x+f.w),f.w===g.w&&f.h===g.h){const b=r.pop();b&&_<r.length&&(r[_]=b)}else f.h===g.h?(g.x+=f.w,g.w-=f.w):f.w===g.w?(g.y+=f.h,g.h-=f.h):(r.push({x:g.x+f.w,y:g.y,w:g.w-f.w,h:f.h}),g.y+=f.h,g.h-=f.h);break}}return{w:c,h,fill:e/(c*h)||0}}function Hx(n,e){return n.id<e.id?-1:n.id>e.id?1:n.version<e.version?-1:n.version>e.version?1:n.sx<e.sx?-1:n.sx>e.sx?1:n.sy<e.sy?-1:n.sy>e.sy?1:0}function $b(n){let e=0;for(let t=0;t<n.length;t++)e=(e<<5)-e+n.charCodeAt(t),e&=e;return e}function xa(n,e){return(n<<5)-n+e}function zA(n,e,t,r){for(const[c]of n.entries()){const h=r&&r.get(c)||Ks.parse(c),f=h.id.toString(),_=e.get(f)||0;t.push({id:c,version:_,sx:h.sx,sy:h.sy})}}wt(Hl,"Anchor");class Hb{constructor(e,t,r,c,h){this.iconDescriptors=[],this.patternDescriptors=[],this.requiresMipMaps=t.size>0,zA(e,r,this.iconDescriptors,h),zA(t,r,this.patternDescriptors,h),this.iconDescriptors.sort(Hx),this.patternDescriptors.sort(Hx);let f=0;const _=c?c.data:"";_&&(f=xa(f,$b(_))),f=xa(f,1);for(const g of this.iconDescriptors)f=xa(f,$b(g.id)),f=xa(f,g.version),f=xa(f,g.sx),f=xa(f,g.sy);f=xa(f,1);for(const g of this.patternDescriptors)f=xa(f,$b(g.id)),f=xa(f,g.version),f=xa(f,g.sx),f=xa(f,g.sy);this.hash=f}subsetOf(e){return this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,Hx)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,Hx)}isSubsetArray(e,t,r){let c=0,h=0;if(e.length>t.length)return!1;for(;c<e.length&&h<t.length;){const f=r(e[c],t[h]);if(f===0)c++,h++;else{if(f<0)return!1;h++}}return c===e.length}}wt(Hb,"AtlasContentDescriptor");class v_{static getImagePositionScale(e,t,r){if(t&&e){const{sx:c,sy:h}=e;return{x:c,y:h}}return{x:r,y:r}}constructor(e,t,r,c){this.paddedRect=e;const{pixelRatio:h,version:f,stretchX:_,stretchY:g,content:b,sdf:S,usvg:I}=t;this.pixelRatio=h,this.stretchX=_,this.stretchY=g,this.content=b,this.version=f,this.padding=r,this.sdf=S,this.usvg=I,this.scale=v_.getImagePositionScale(c,I,h)}get tl(){return[this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return[this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return[(this.paddedRect.w-2*this.padding)/this.scale.x,(this.paddedRect.h-2*this.padding)/this.scale.y]}}function Zb(n,e,t){const r=Ks.parse(n),c=function(h,f,_=[1,1]){return{x:0,y:0,w:(h.data?h.data.width:h.width*_[0])+2*f,h:(h.data?h.data.height:h.height*_[1])+2*f}}(e,t,[r.sx,r.sy]);return{bin:c,imagePosition:new v_(c,e,t,r),imageVariant:r}}function qb(n,e){const t=[];for(const[c,h]of n.entries()){const f=Ks.parse(c);f&&(t.push({key:c,value:h,variant:f}),e&&e.set(c,f))}t.sort((c,h)=>{const f=c.variant.id.toString().localeCompare(h.variant.id.toString());return f!==0?f:c.variant.sx!==h.variant.sx?c.variant.sx-h.variant.sx:c.variant.sy!==h.variant.sy?c.variant.sy-h.variant.sy:0});const r=new Map;for(const c of t)r.set(c.key,c.value);return r}class kA{constructor(e){this.sourceAtlasHash=e}}class FA{constructor(e,t,r,c){const h=new Map,f=new Map;this.haveRenderCallbacks=[];const _=[],g=c!==void 0,b=g?new Map:void 0,S=g?qb(e,b):e,I=g?qb(t,b):t;this.addImages(S,h,1,_),this.addImages(I,f,2,_);const{w:A,h:M}=LA(_),D=new Fr({width:A||1,height:M||1});for(const[z,B]of S.entries()){const V=h.get(z).paddedRect;Fr.copy(B.data,D,{x:0,y:0},{x:V.x+1,y:V.y+1},B.data,null,B.sdf)}for(const[z,B]of I.entries()){const V=f.get(z),Z=V.paddedRect;let G=V.padding;const Y=Z.x+G,Q=Z.y+G,te=B.data.width,me=B.data.height;G=G>1?G-1:G,Fr.copy(B.data,D,{x:0,y:0},{x:Y,y:Q},B.data,r),Fr.copy(B.data,D,{x:0,y:me-G},{x:Y,y:Q-G},{width:te,height:G},r),Fr.copy(B.data,D,{x:0,y:0},{x:Y,y:Q+me},{width:te,height:G},r),Fr.copy(B.data,D,{x:te-G,y:0},{x:Y-G,y:Q},{width:G,height:me},r),Fr.copy(B.data,D,{x:0,y:0},{x:Y+te,y:Q},{width:G,height:me},r),Fr.copy(B.data,D,{x:te-G,y:me-G},{x:Y-G,y:Q-G},{width:G,height:G},r),Fr.copy(B.data,D,{x:0,y:me-G},{x:Y+te,y:Q-G},{width:G,height:G},r),Fr.copy(B.data,D,{x:0,y:0},{x:Y+te,y:Q+me},{width:G,height:G},r),Fr.copy(B.data,D,{x:te-G,y:0},{x:Y-G,y:Q+me},{width:G,height:G},r)}this.lut=r,this.image=D,this.iconPositions=h,this.patternPositions=f,g&&(this.contentDescriptor=new Hb(S,I,c,r,b))}addImages(e,t,r,c){for(const[h,f]of e.entries()){const{bin:_,imagePosition:g,imageVariant:b}=Zb(h,f,r);t.set(h,g),c.push(_),f.hasRenderCallback&&this.haveRenderCallbacks.push(b.id)}}patchUpdatedImages(e,t,r,c){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(h=>e.hasImage(h,r)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(const h of e.getUpdatedImages(r)){for(const f of this.iconPositions.keys()){const _=Ks.parse(f);if(fs.isEqual(_.id,h)){const g=e.getImage(h,r);this.patchUpdatedImage(this.iconPositions.get(f),g,t,null)}}for(const f of this.patternPositions.keys()){const _=Ks.parse(f);if(fs.isEqual(_.id,h)){const g=e.getImage(h,r);this.patchUpdatedImage(this.patternPositions.get(f),g,t,c||this.lut)}}}}patchUpdatedImage(e,t,r,c=null){if(!e||!t||e.version===t.version)return;e.version=t.version;const[h,f]=e.tl,_=e.sdf;if(this.lut||_){const g={width:t.data.width,height:t.data.height},b=new Fr(g);Fr.copy(t.data,b,{x:0,y:0},{x:0,y:0},g,c,_),r.update(b,{position:{x:h,y:f},recreateWhenResize:!1})}else r.update(t.data,{position:{x:h,y:f},recreateWhenResize:!1})}}wt(v_,"ImagePosition"),wt(FA,"ImageAtlas",{omit:["lut"]}),wt(kA,"ImageAtlasReference");class b_{constructor(e){this.pendingRequests=new Map,this.cachedRanges=new Map,this.useServerFontComposition=!e||e.useServerFontComposition===void 0||e.useServerFontComposition}loadGlyphRange(e,t,r,c,h){if(this.useServerFontComposition)return void b_.loadGlyphRange(e,t,r,c,h);const f=e.split(",").map(_=>_.trim()).filter(_=>_.length>0);f.length!==0?f.length!==1?this._loadMultipleFonts(f,t,r,c,h):this._loadFont(f[0],t,r,c,h):h(new Error("Empty fontstack"))}_loadMultipleFonts(e,t,r,c,h){const f=e.map(()=>null),_={completed:0,firstError:null,callbackCalled:!1},g=(b,S,I)=>{if(!_.callbackCalled&&(S&&!_.firstError&&(_.firstError=S),I&&(f[b]=I),_.completed++,_.completed===e.length)){_.callbackCalled=!0;const A=f.filter(D=>D!==null);if(A.length===0)return void h(_.firstError||new Error("All fonts failed to load"));const M=this._composeGlyphs(A);h(null,M)}};for(let b=0;b<e.length;b++)this._loadFont(e[b],t,r,c,(S,I)=>{g(b,S,I)})}_loadFont(e,t,r,c,h){const f=`${e}:${t}`;if(this.cachedRanges.has(f)){const g=this.cachedRanges.get(f);return void ts.frame(()=>h(null,g))}const _=this.pendingRequests.get(f);_?_.push(h):(this.pendingRequests.set(f,[h]),b_.loadGlyphRange(e,t,r,c,(g,b)=>{g||this.cachedRanges.set(f,b||null);const S=this.pendingRequests.get(f);if(this.pendingRequests.delete(f),S)for(const I of S)I(g,b)}))}_composeGlyphs(e){const t={};let r,c;for(const h of e)if(r===void 0&&h.ascender!==void 0&&(r=h.ascender),c===void 0&&h.descender!==void 0&&(c=h.descender),h.glyphs)for(const f in h.glyphs)t[f]===void 0&&(t[f]=h.glyphs[f]);return{glyphs:t,ascender:r,descender:c}}}b_.loadGlyphRange=function(n,e,t,r,c){const h=256*e,f=h+255,_=r.transformRequest(r.normalizeGlyphsURL(t).replace("{fontstack}",n).replace("{range}",`${h}-${f}`),Mu.Glyphs);gc(_,(g,b)=>{if(g)c(g);else if(b){const S={},I=function(A){return new jx(A).readFields(DB,{})}(b);for(const A of I.glyphs)S[A.id]=A;c(null,{glyphs:S,ascender:I.ascender,descender:I.descender})}})};const w_=1e20;function OA(n,e,t,r,c,h,f,_,g){for(let b=e;b<e+r;b++)BA(n,t*h+b,h,c,f,_,g);for(let b=t;b<t+c;b++)BA(n,b*h+e,1,r,f,_,g)}function BA(n,e,t,r,c,h,f){h[0]=0,f[0]=-w_,f[1]=w_,c[0]=n[e];for(let _=1,g=0,b=0;_<r;_++){c[_]=n[e+_*t];const S=_*_;do{const I=h[g];b=(c[_]-c[I]+S-I*I)/(_-I)/2}while(b<=f[g]&&--g>-1);g++,h[g]=_,f[g]=b,f[g+1]=w_}for(let _=0,g=0;_<r;_++){for(;f[g+1]<_;)g++;const b=h[g],S=_-b;n[e+_*t]=c[b]+S*S}}const Wb={none:0,ideographs:1,all:2};class Zx{constructor(e,t,r,c){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=r,this.url="",this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}},this.glyphLoader=new b_({useServerFontComposition:c})}setURL(e){this.url=e}prefetchRange(e,t){const r=this.url||yi.GLYPHS_URL;if(!r)return;let c=this.entries[e];c||(c=this.entries[e]={glyphs:{},requests:{},ranges:{}}),c.ranges[t]||c.requests[t]||(c.requests[t]=[],this.glyphLoader.loadGlyphRange(e,t,r,this.requestManager,(h,f)=>{if(f){c.ascender=f.ascender,c.descender=f.descender;for(const _ in f.glyphs)this._doesCharSupportLocalGlyph(+_)||(c.glyphs[+_]=f.glyphs[+_]);c.ranges[t]=!0}for(const _ of c.requests[t]||[])_(h,f);delete c.requests[t]}))}getGlyphs(e,t){const r=[],c=this.url||yi.GLYPHS_URL;for(const h in e)for(const f of e[h])r.push({stack:h,id:f});be(r,({stack:h,id:f},_)=>{let g=this.entries[h];g||(g=this.entries[h]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let b=g.glyphs[f];if(b!==void 0)return void _(null,{stack:h,id:f,glyph:b});if(b=this._tinySDF(g,h,f),b)return g.glyphs[f]=b,void _(null,{stack:h,id:f,glyph:b});const S=Math.floor(f/256);if(256*S>65535)return zt("glyphs > 65535 not supported"),void _(null,{stack:h,id:f,glyph:b});if(g.ranges[S])return void _(null,{stack:h,id:f,glyph:b});let I=g.requests[S];I||(I=g.requests[S]=[],this.glyphLoader.loadGlyphRange(h,S,c,this.requestManager,(A,M)=>{if(M){g.ascender=M.ascender,g.descender=M.descender;for(const D in M.glyphs)this._doesCharSupportLocalGlyph(+D)||(g.glyphs[+D]=M.glyphs[+D]);g.ranges[S]=!0}for(const D of I)D(A,M);delete g.requests[S]})),I.push((A,M)=>{A?_(A):M&&_(null,{stack:h,id:f,glyph:M.glyphs[f]||null})})},(h,f)=>{if(h)t(h);else if(f){const _={};for(const{stack:g,id:b,glyph:S}of f)_[g]===void 0&&(_[g]={}),_[g].glyphs===void 0&&(_[g].glyphs={}),_[g].glyphs[b]=S&&{id:S.id,bitmap:S.bitmap.clone(),metrics:S.metrics},_[g].ascender=this.entries[g].ascender,_[g].descender=this.entries[g].descender;t(null,_)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Wb.none&&(this.localGlyphMode===Wb.all?!!this.localFontFamily:!!this.localFontFamily&&($d(e)||mm(e)||ah(e)||Rl(e)||oh(e)||fm(e)||(t=e)>=131072&&t<=173791||(r=>r>=66736&&r<=66815)(e)));var t}_tinySDF(e,t,r){const c=this.localFontFamily;if(!c||!this._doesCharSupportLocalGlyph(r))return;let h=e.tinySDF;if(!h){let B="400";/bold/i.test(t)?B="900":/medium/i.test(t)?B="500":/light/i.test(t)&&(B="200"),h=e.tinySDF=new Zx.TinySDF({fontFamily:c,fontWeight:B,fontSize:48,buffer:6,radius:16}),h.fontWeight=B}const f=h.fontWeight;if(this.localGlyphs[f][r])return this.localGlyphs[f][r];const _=String.fromCodePoint(r),{data:g,width:b,height:S,glyphWidth:I,glyphHeight:A,glyphLeft:M,glyphTop:D,glyphAdvance:z}=h.draw(_);return this.localGlyphs[f][r]={id:r,bitmap:new $c({width:b,height:S},g),metrics:{width:I/2,height:A/2,left:M/2,top:D/2-27,advance:z/2,localGlyph:!0}}}}function NA(n,e){return n+e[1]-e[0]}function Xb(n,e,t,r,c=1){const h=[],f=n.imagePrimary,_=f.pixelRatio,g=f.paddedRect.w-2,b=f.paddedRect.h-2,S=(n.right-n.left)*c,I=(n.bottom-n.top)*c,A=f.stretchX||[[0,g]],M=f.stretchY||[[0,b]],D=A.reduce(NA,0),z=M.reduce(NA,0),B=g-D,V=b-z;let Z=0,G=D,Y=0,Q=z,te=0,me=B,ce=0,pe=V;if(f.content&&r){const de=f.content;Z=qx(A,0,de[0]),Y=qx(M,0,de[1]),G=qx(A,de[0],de[2]),Q=qx(M,de[1],de[3]),te=de[0]-Z,ce=de[1]-Y,me=de[2]-de[0]-G,pe=de[3]-de[1]-Q}const he=(de,Be,je,He)=>{const Xe=Wx(de.stretch-Z,G,S,n.left*c),Ze=Xx(de.fixed-te,me,de.stretch,D),nt=Wx(Be.stretch-Y,Q,I,n.top*c),Fe=Xx(Be.fixed-ce,pe,Be.stretch,z),We=Wx(je.stretch-Z,G,S,n.left*c),Qe=Xx(je.fixed-te,me,je.stretch,D),st=Wx(He.stretch-Y,Q,I,n.top*c),ut=Xx(He.fixed-ce,pe,He.stretch,z),bt=new it(Xe,nt),mt=new it(We,nt),pt=new it(We,st),ht=new it(Xe,st),yt=new it(Ze/_,Fe/_),It=new it(Qe/_,ut/_),kt=e*Math.PI/180;if(kt){const ai=Math.sin(kt),gn=Math.cos(kt),Ri=[gn,-ai,ai,gn];bt._matMult(Ri),mt._matMult(Ri),ht._matMult(Ri),pt._matMult(Ri)}const Ct=de.stretch+de.fixed,Qt=je.stretch+je.fixed,vi=Be.stretch+Be.fixed,ei=He.stretch+He.fixed,wi=n.imageSecondary;return{tl:bt,tr:mt,bl:ht,br:pt,texPrimary:{x:f.paddedRect.x+1+Ct,y:f.paddedRect.y+1+vi,w:Qt-Ct,h:ei-vi},texSecondary:wi?{x:wi.paddedRect.x+1+Ct,y:wi.paddedRect.y+1+vi,w:Qt-Ct,h:ei-vi}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:yt,pixelOffsetBR:It,minFontScaleX:me/_/S,minFontScaleY:pe/_/I,isSDF:t}};if(f.stretchX||f.stretchY){const de=VA(A,B,D),Be=VA(M,V,z);for(let je=0;je<de.length-1;je++){const He=de[je],Xe=de[je+1];for(let Ze=0;Ze<Be.length-1;Ze++)h.push(he(He,Be[Ze],Xe,Be[Ze+1]))}}else h.push(he({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:g+1},{fixed:0,stretch:b+1}));return h}function NB(n,e){const t=n.stretchY||[[0,n.paddedRect.h-2]];return n.stretchX||n.stretchY?UA(n.stretchX||[[0,n.paddedRect.w-2]])*UA(t):1}function qx(n,e,t){let r=0;for(const c of n)r+=Math.max(e,Math.min(t,c[1]))-Math.max(e,Math.min(t,c[0]));return r}function VA(n,e,t){const r=[{fixed:-1,stretch:0}];for(const[c,h]of n){const f=r[r.length-1];r.push({fixed:c-f.stretch,stretch:f.stretch}),r.push({fixed:c-f.stretch,stretch:f.stretch+(h-c)})}return r.push({fixed:e+1,stretch:t}),r}function UA(n){return 2*n.length+1}function Wx(n,e,t,r){return n/e*t+r}function Xx(n,e,t,r){return n-e*t/r}function VB(n,e,t,r){const c=e+n.positionedLines[r].lineOffset;return r===0?t+c/2:t+(c+(e+n.positionedLines[r-1].lineOffset))/2}function jA(n,e,t,r,c,h,f,_,g,b=1){const S=[];if(e.positionedLines.length===0)return S;const I=(g!==void 0?g:r.layout.get("text-rotate").evaluate(h,{}))*Math.PI/180,A=function(V){const Z=V[0],G=V[1],Y=Z*G;return Y>0?[Z,-G]:Y<0?[-Z,G]:Z===0?[G,Z]:[G,-Z]}(t);let M=Math.abs(e.top-e.bottom);for(const V of e.positionedLines)M-=V.lineOffset;const D=e.positionedLines.length,z=M/D;let B=e.top-t[1];for(let V=0;V<D;++V){const Z=e.positionedLines[V];B=VB(e,z,B,V);for(const G of Z.positionedGlyphs){if(!G.rect)continue;const Y=G.rect||{};let Q=4,te=!0,me=1,ce=0;if(G.image){const pt=f.get(G.image.toString());if(!pt)continue;if(pt.sdf){zt("SDF images are not supported in formatted text and will be ignored.");continue}te=!1,me=pt.pixelRatio,Q=1/me,pt.usvg||(me/=b)}const pe=(c||_)&&G.vertical,he=G.metrics.advance*G.scale/2,de=G.metrics,Be=G.rect;if(Be===null)continue;_&&e.verticalizable&&(ce=G.image?he-G.metrics.width*G.scale/2:0);const je=c?[G.x+he,G.y]:[0,0];let He=[0,0],Xe=[0,0],Ze=!1;c||(pe?(Xe=[G.x+he+A[0],G.y+A[1]-ce],Ze=!0):He=[G.x+he+t[0],G.y+t[1]-ce]);const nt=Be.w*G.scale/(me*(G.localGlyph?2:1)),Fe=Be.h*G.scale/(me*(G.localGlyph?2:1));let We,Qe,st,ut;if(pe){const pt=G.y-B,ht=new it(-he,he-pt),yt=-Math.PI/2,It=new it(...Xe);We=new it(-he+He[0],He[1]),We._rotateAround(yt,ht)._add(It),We.x+=-pt+he,We.y-=(de.left-Q)*G.scale;const kt=G.image?de.advance*G.scale:nr*G.scale,Ct=String.fromCodePoint(G.glyph);bB(Ct)?We.x+=(1-Q)*G.scale:wB(Ct)?We.x+=kt-de.height*G.scale+(-Q-1)*G.scale:We.x+=G.image||de.width+2*Q===Be.w&&de.height+2*Q===Be.h?(kt-Fe)/2:(kt-(de.height+2*Q)*G.scale)/2,Qe=new it(We.x,We.y-nt),st=new it(We.x+Fe,We.y),ut=new it(We.x+Fe,We.y-nt)}else{const pt=(de.left-Q)*G.scale-he+He[0],ht=(-de.top-Q)*G.scale+He[1],yt=pt+nt,It=ht+Fe;We=new it(pt,ht),Qe=new it(yt,ht),st=new it(pt,It),ut=new it(yt,It)}if(I){let pt;pt=c?new it(0,0):Ze?new it(A[0],A[1]):new it(t[0],t[1]),We._rotateAround(I,pt),Qe._rotateAround(I,pt),st._rotateAround(I,pt),ut._rotateAround(I,pt)}const bt=new it(0,0),mt=new it(0,0);S.push({tl:We,tr:Qe,bl:st,br:ut,texPrimary:Y,texSecondary:void 0,writingMode:e.writingMode,glyphOffset:je,sectionIndex:G.sectionIndex,isSDF:te,pixelOffsetTL:bt,pixelOffsetBR:mt,minFontScaleX:0,minFontScaleY:0})}}return S}function UB(n,e=1,t=!1){let r=1/0,c=1/0,h=-1/0,f=-1/0;const _=n[0];for(let M=0;M<_.length;M++){const D=_[M];(!M||D.x<r)&&(r=D.x),(!M||D.y<c)&&(c=D.y),(!M||D.x>h)&&(h=D.x),(!M||D.y>f)&&(f=D.y)}const g=Math.min(h-r,f-c);let b=g/2;const S=new Hu([],jB);if(g===0)return new it(r,c);for(let M=r;M<h;M+=g)for(let D=c;D<f;D+=g)S.push(new bf(M+b,D+b,b,n));let I=function(M){let D=0,z=0,B=0;const V=M[0];for(let Z=0,G=V.length,Y=G-1;Z<G;Y=Z++){const Q=V[Z],te=V[Y],me=Q.x*te.y-te.x*Q.y;z+=(Q.x+te.x)*me,B+=(Q.y+te.y)*me,D+=3*me}return new bf(z/D,B/D,0,M)}(n),A=S.length;for(;S.length;){const M=S.pop();(M.d>I.d||!I.d)&&(I=M,t&&console.log("found best %d after %d probes",Math.round(1e4*M.d)/1e4,A)),M.max-I.d<=e||(b=M.h/2,S.push(new bf(M.p.x-b,M.p.y-b,b,n)),S.push(new bf(M.p.x+b,M.p.y-b,b,n)),S.push(new bf(M.p.x-b,M.p.y+b,b,n)),S.push(new bf(M.p.x+b,M.p.y+b,b,n)),A+=4)}return t&&(console.log(`num probes: ${A}`),console.log(`best distance: ${I.d}`)),I.p}function jB(n,e){return e.max-n.max}Zx.TinySDF=class{constructor({fontSize:n=24,buffer:e=3,radius:t=8,cutoff:r=.25,fontFamily:c="sans-serif",fontWeight:h="normal",fontStyle:f="normal",lang:_=null}={}){this.buffer=e,this.cutoff=r,this.radius=t,this.lang=_;const g=this.size=n+4*e,b=this._createCanvas(g),S=this.ctx=b.getContext("2d",{willReadFrequently:!0});S.font=`${f} ${h} ${n}px ${c}`,S.textBaseline="alphabetic",S.textAlign="left",S.fillStyle="black",this.gridOuter=new Float64Array(g*g),this.gridInner=new Float64Array(g*g),this.f=new Float64Array(g),this.z=new Float64Array(g+1),this.v=new Uint16Array(g)}_createCanvas(n){const e=document.createElement("canvas");return e.width=e.height=n,e}draw(n){const{width:e,actualBoundingBoxAscent:t,actualBoundingBoxDescent:r,actualBoundingBoxLeft:c,actualBoundingBoxRight:h}=this.ctx.measureText(n),f=Math.ceil(t),_=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(h-c))),g=Math.min(this.size-this.buffer,f+Math.ceil(r)),b=_+2*this.buffer,S=g+2*this.buffer,I=Math.max(b*S,0),A=new Uint8ClampedArray(I),M={data:A,width:b,height:S,glyphWidth:_,glyphHeight:g,glyphTop:f,glyphLeft:0,glyphAdvance:e};if(_===0||g===0)return M;const{ctx:D,buffer:z,gridInner:B,gridOuter:V}=this;this.lang&&(D.lang=this.lang),D.clearRect(z,z,_,g),D.fillText(n,z,z+f);const Z=D.getImageData(z,z,_,g);V.fill(w_,0,I),B.fill(0,0,I);for(let G=0;G<g;G++)for(let Y=0;Y<_;Y++){const Q=Z.data[4*(G*_+Y)+3]/255;if(Q===0)continue;const te=(G+z)*b+Y+z;if(Q===1)V[te]=0,B[te]=w_;else{const me=.5-Q;V[te]=me>0?me*me:0,B[te]=me<0?me*me:0}}OA(V,0,0,b,S,b,this.f,this.v,this.z),OA(B,z,z,_,g,b,this.f,this.v,this.z);for(let G=0;G<I;G++){const Y=Math.sqrt(V[G])-Math.sqrt(B[G]);A[G]=Math.round(255-255*(Y/this.radius+this.cutoff))}return M}};class bf{constructor(e,t,r,c){this.p=new it(e,t),this.h=r,this.d=function(h,f){let _=!1,g=1/0;for(let b=0;b<f.length;b++){const S=f[b];for(let I=0,A=S.length,M=A-1;I<A;M=I++){const D=S[I],z=S[M];D.y>h.y!=z.y>h.y&&h.x<(z.x-D.x)*(h.y-D.y)/(z.y-D.y)+D.x&&(_=!_),g=Math.min(g,Ho(h,D,z))}}return(_?1:-1)*Math.sqrt(g)}(this.p,c),this.max=this.d+this.h*Math.SQRT2}}const GB=Object.keys,Yb=Number.POSITIVE_INFINITY,$B=Math.sqrt(2);function Wc(n,e,t,r,c,h){const f=Ub(n)&&n.collisionPadding?n.collisionPadding:[0,0,0,0],_={top:n.top-f[1],bottom:n.bottom+f[3],left:n.left-f[0],right:n.right+f[2],scaled:!1};return r!==void 0&&function(g,b){g.top*=b,g.bottom*=b,g.left*=b,g.right*=b,g.scaled=!0}(_,r),h&&(_.left+=h[0],_.right+=h[0],_.top+=h[1],_.bottom+=h[1]),t&&function(g,b,S){if(!b)return;const I=Ei(b),A=new it(S?S[0]:0,S?S[1]:0),M=new it(g.left,g.top),D=new it(g.right,g.top),z=new it(g.left,g.bottom),B=new it(g.right,g.bottom);M._rotateAround(I,A),D._rotateAround(I,A),z._rotateAround(I,A),B._rotateAround(I,A),g.left=Math.min(M.x,D.x,z.x,B.x),g.right=Math.max(M.x,D.x,z.x,B.x),g.top=Math.min(M.y,D.y,z.y,B.y),g.bottom=Math.max(M.y,D.y,z.y,B.y)}(_,t,c),e?{top:Math.min(e.top,_.top),bottom:Math.max(e.bottom,_.bottom),left:Math.min(e.left,_.left),right:Math.max(e.right,_.right),scaled:e.scaled||_.scaled}:_}function GA(n,[e,t]){let r=0,c=0;if(t===Yb){e<0&&(e=0);const h=e/$B;switch(n){case"top-right":case"top-left":c=h-7;break;case"bottom-right":case"bottom-left":c=7-h;break;case"bottom":c=7-e;break;case"top":c=e-7}switch(n){case"top-right":case"bottom-right":r=-h;break;case"top-left":case"bottom-left":r=h;break;case"left":r=e;break;case"right":r=-e}}else{switch(e=Math.abs(e),t=Math.abs(t),n){case"top-right":case"top-left":case"top":c=t-7;break;case"bottom-right":case"bottom-left":case"bottom":c=7-t}switch(n){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}}return[r,c]}function HB(n,e,t,r,c,h,f,_,g,b,S,I,A,M,D){const z=n.layers[0],B=z.appearances;if(B.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const V={iconBBox:null,iconVerticalBBox:null},Z={textBBox:null,textVerticalBBox:null},{baseIconRotate:G,baseTextRotate:Y,iconScaleFactor:Q}=function(me,ce,pe){const he=me.get("icon-rotate").evaluate(ce,{},pe),de=me.get("text-rotate").evaluate(ce,{},pe),[Be,je]=me.get("icon-size-scale-range");return{baseIconRotate:he,baseTextRotate:de,iconScaleFactor:q(1,Be,je)}}(r,c,h);e&&(V.iconBBox=Wc(e,V.iconBBox,G),t)&&(V.iconVerticalBBox=Wc(t,V.iconVerticalBBox,G+90));const te=Kx(I.horizontal);te&&(Z.textBBox=Wc(te,Z.textBBox,Y,1,M)),I.vertical&&(Z.textVerticalBBox=Wc(I.vertical,Z.textVerticalBBox,Y+90,1,M));for(const me of B)me.hasIconLayoutProperties()&&ZB(V,n,z,me,c,h,_,G,f,g,e,b,Q,S,D),me.hasTextLayoutProperties()&&qB(Z,z,me,c,h,M,Y,A,te,I.vertical);return{iconBBox:V.iconBBox,iconVerticalBBox:V.iconVerticalBBox,textBBox:Z.textBBox,textVerticalBBox:Z.textVerticalBBox}}function ZB(n,e,t,r,c,h,f,_,g,b,S,I,A,M,D){const{appearanceIconOffset:z,appearanceIconRotate:B,appearanceIconSize:V}=$A(r,t,c,h,f,_,g,b.iconScaleFactor);let Z=null,G=null,Y=null;r.hasLayoutProperty("icon-image")?Y=function(te,me,ce,pe,he,de,Be,je){let He=null;const Xe=me.getAppearanceValueAndResolveTokens(ce,"icon-image",pe,he,je);if(Xe){const Ze=te.getResolvedImageFromTokens(Xe),nt=ce.hasLayoutProperty("icon-size")?ce.getUnevaluatedLayoutProperty("icon-size"):me._unevaluatedLayout._values["icon-size"],Fe=T_(Ze,Ch(te.zoom,nt,te.worldview,je),nt,he,te.zoom,pe,te.pixelRatio,Be,te.worldview,je);He=de.get(Fe.iconPrimary.toString())}return He}(e,t,r,c,h,I,A,D):S&&(Y=S.imagePrimary),Y&&(Z=$x(Y,null,z,M),e.allowVerticalPlacement&&(G=$x(Y,null,z,M)));const Q=g>0?V/g:1;Z&&(n.iconBBox=Wc(Z,n.iconBBox,B,Q!==1?Q:void 0)),G&&(n.iconVerticalBBox=Wc(G,n.iconVerticalBBox,B+90,Q!==1?Q:void 0))}function $A(n,e,t,r,c,h,f,_){const g=n.hasLayoutProperty("icon-offset")?e.getAppearanceValueAndResolveTokens(n,"icon-offset",t,r,[]):null,b=g&&Array.isArray(g)?g:c,S=n.hasLayoutProperty("icon-rotate")?e.getAppearanceValueAndResolveTokens(n,"icon-rotate",t,r,[]):null,I=typeof S=="number"?S:h,A=n.hasLayoutProperty("icon-size")?e.getAppearanceValueAndResolveTokens(n,"icon-size",t,r,[]):null;return{appearanceIconOffset:b,appearanceIconRotate:I,appearanceIconSize:typeof A=="number"?A*_:f}}function qB(n,e,t,r,c,h,f,_,g,b){const{appearanceTextOffset:S,appearanceTextRotate:I,appearanceTextSize:A}=HA(t,e,r,c,h,f,_),M=A/_,D=[(S[0]-h[0])*M,(S[1]-h[1])*M],z=D[0]!==0||D[1]!==0;g&&(n.textBBox=Wc(g,n.textBBox,I,M,S,z?D:void 0)),b&&(n.textVerticalBBox=Wc(b,n.textVerticalBBox,I+90,M,S,z?D:void 0))}function HA(n,e,t,r,c,h,f){const _=n.hasLayoutProperty("text-offset")?e.getAppearanceValueAndResolveTokens(n,"text-offset",t,r,[]):null,g=_&&Array.isArray(_)?[_[0]*nr,_[1]*nr]:c,b=n.hasLayoutProperty("text-rotate")?e.getAppearanceValueAndResolveTokens(n,"text-rotate",t,r,[]):null,S=typeof b=="number"?b:h,I=n.hasLayoutProperty("text-size")?e.getAppearanceValueAndResolveTokens(n,"text-size",t,r,[]):null;return{appearanceTextOffset:g,appearanceTextRotate:S,appearanceTextSize:typeof I=="number"?I:f}}function Yx(n,e,t,r,c,h,f,_,g){if(!e||!e.usvg)return;const b=AA(r),S=AA(c),I=h!=="both"&&h!=="width"||!EA(r)?1:S.width/b.width,A=h!=="both"&&h!=="height"||!IA(r)?1:S.height/b.height;t.scaleSelf(I,A);const M=t.toString();f.set(M,t),_.set(M,e);const{imagePosition:D}=Zb(M,e,1);g.set(M,D)}function ZA(n,e,t,r,c,h,f,_,g,b){if(!n)return;const S=function(I,A,M,D,z,B,V){if(I.kind==="camera")return I.maxSize;if(I.kind==="composite"){const Z=A.possiblyEvaluate(new Mi(I.maxZoom,{worldview:B}),M,V).evaluate(z,{},M,V),G=A.possiblyEvaluate(new Mi(I.minZoom,{worldview:B}),M,V).evaluate(z,{},M,V);return Math.max(Z,G)}return A.possiblyEvaluate(new Mi(D,{worldview:B}),M,V).evaluate(z,{},M,V)}(e,t,r,c,h,g,b);return n.scaleSelf(S*_*f)}function T_(n,e,t,r,c,h,f,_,g,b){return{iconPrimary:ZA(n.getPrimary(),e,t,r,c,h,f,_,g,b),iconSecondary:ZA(n.getSecondary(),e,t,r,c,h,f,_,g,b)}}function WB(n,e,t){if(!e)return;const r=t.get(n.toString()),c=t.get(e.toString());r&&c&&(r.paddedRect.w===c.paddedRect.w&&r.paddedRect.h===c.paddedRect.h||zt(`Mismatch in icon variant sizes: ${n.toString()} and ${e.toString()}`),r.usvg!==c.usvg&&zt(`Mismatch in icon variant image types: ${n.id} and ${e.id}`))}function qA(n,e,t,r){if(!n)return;const c=e.get(t.toString());if(c&&(n.imagePrimary=c),r){const h=e.get(r.toString());n.imageSecondary=h}}function XB(n,e){for(const t in n.horizontal)WA(n.horizontal[t],e);WA(n.vertical,e)}function WA(n,e){if(n){for(const t of n.positionedLines)for(const r of t.positionedGlyphs)if(r.image!==null){const c=r.image.toString();r.rect=e.get(c).paddedRect}}}function Kb(n){switch(n){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function YB(n,e,t,r,c,h,f,_,g){const b=Kx(h.horizontal)||h.vertical,S=t.get("icon-text-fit-padding").evaluate(r,{},c);let I,A=e;return e&&g!=="none"&&(n.allowVerticalPlacement&&h.vertical&&(I=jb(e,h.vertical,g,S,_,f)),b&&(A=jb(e,b,g,S,_,f))),{defaultShapedIcon:A,verticallyShapedIcon:I}}function XA(n,e){return n*e/24}function KB(n,e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B,V,Z,G,Y,Q,te,me){let ce=f.textMaxSize.evaluate(e,{},A);ce===void 0?ce=_*f.textScaleFactor:ce*=f.textScaleFactor;const pe=n.layers[0].layout,he=XA(_,f.textScaleFactor),de=Kx(t.horizontal)||t.vertical,Be=n.hasAnyAppearanceLayoutProperty(["text-size","text-offset","text-rotate"]),je=n.getAppearanceFeatureData(e.index);(B!=="none"||Be)&&je&&(je.textShaping=de,je.iconTextFitPadding=pe.get("icon-text-fit-padding").evaluate(e,{},A),je.fontScale=he,je.textScaleFactor=f.textScaleFactor);const He=M.name==="globe",Xe=n.tilePixelRatio*ce/24,Ze=(ut=n.overscaling,n.zoom>18&&ut>2&&(ut>>=1),Math.max(_t/(512*ut),1)*pe.get("symbol-spacing")),nt=pe.get("text-padding")*n.tilePixelRatio,Fe=pe.get("icon-padding")*n.tilePixelRatio,We=Ei(pe.get("text-max-angle")),Qe=pe.get("icon-rotation-alignment")==="map"&&G!=="point",st=Ze/2;var ut;n.hasAnyIconTextFit===!1&&B!=="none"&&(n.hasAnyIconTextFit=!0);const bt=e.properties?+e.properties[ri]:null,mt=bt&&n.elevationFeatureIdToIndex?n.elevationFeatureIdToIndex.get(bt):65535,pt=(ht,yt,It)=>{if(yt.x<0||yt.x>=_t||yt.y<0||yt.y>=_t)return;let kt=null;if(He){const{x:Ct,y:Qt,z:vi}=M.projectTilePoint(yt.x,yt.y,It);kt={anchor:new Hl(Ct,Qt,vi,0,void 0),up:M.upVector(It,yt.x,yt.y)}}(function(Ct,Qt,vi,ei,wi,ai,gn,Ri,Si,qi,dn,rr,fn,Sn,Bn,En,Ir,sr,ci,Yr,Rn,cr,Kr,Ar,yn,Gr,ur,mv,Pf,rs,bw,Mf){const Zl=Ct.addToLineVertexArray(Qt,ei);let ql,xo,vo,zh,Rf,di,hr,In=0,Kn=0,bo=0,Bs=0,Ns=-1,Vs=-1;const Wo={};let _v=Ba("");const Ta=vi?vi.anchor:Qt,Df=mv!=="none";let Lf=0,Zn=0;if(Si._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Dn=Si.layout.get("text-offset").evaluate(Rn,{},yn);Lf=Dn[0]*nr,Zn=Dn[1]*nr}else Lf=Si.layout.get("text-radial-offset").evaluate(Rn,{},yn)*nr,Zn=Yb;if(Ct.allowVerticalPlacement&&wi.vertical){const Dn=wi.vertical;if(Bn)di=ew(Dn),Ri&&(hr=ew(Ri));else{const Jr=Si.layout.get("text-rotate").evaluate(Rn,{},yn)+90;vo=Jx(qi,Ta,Qt,dn,rr,fn,Dn,Sn,Jr,En,Mf),Ri&&(zh=Jx(qi,Ta,Qt,dn,rr,fn,Ri,sr,Jr,null,bw))}}if(ai){const Dn=Si.layout.get("icon-rotate").evaluate(Rn,{},yn),Jr=Xb(ai,Dn,Kr,Df,cr.iconScaleFactor),ss=Ri?Xb(Ri,Dn,Kr,Df,cr.iconScaleFactor):void 0;xo=Jx(qi,Ta,Qt,dn,rr,fn,ai,sr,Dn,null,rs);const Yo=function(Sa,B_,zf,dN,fN,_P,gP,pN,x$,Tw){const yP=Sa.layers[0],xP=yP.appearances;let kf=B_.length;if(zf&&(kf=Math.max(kf,zf.length)),xP.length===0)return kf;const[mN,_N]=dN.get("icon-size-scale-range"),gN=q(1,mN,_N);for(const vv of xP)if(vv.hasLayoutProperty("icon-image")){const vP=yP.getAppearanceValueAndResolveTokens(vv,"icon-image",_P,gP,Tw);if(vP){const bP=Sa.getResolvedImageFromTokens(vP);if(bP){const wP=vv.hasLayoutProperty("icon-size")?vv.getUnevaluatedLayoutProperty("icon-size"):fN._values["icon-size"],yN=T_(bP,Ch(Sa.zoom,wP,Sa.worldview,Tw),wP,gP,Sa.zoom,_P,Sa.pixelRatio,gN,Sa.worldview,Tw),TP=pN.get(yN.iconPrimary.toString());TP&&(kf=Math.max(kf,NB(TP)))}}}return kf}(Ct,Jr,ss,Si.layout,Si._unevaluatedLayout,Rn,yn,Ct.iconAtlasPositions,0,Ar);In=4*Yo;const gv=Si.layout.get("icon-size").evaluate(Rn,{},yn,Ar),yv=cr.compositeIconSizes?cr.compositeIconSizes[0].evaluate(Rn,{},yn,Ar):0,ww=cr.compositeIconSizes?cr.compositeIconSizes[1].evaluate(Rn,{},yn,Ar):0,xv=Qb(Ct.layerIds[0],Ct.iconSizeData,gv,cr.iconScaleFactor,yv,ww);Ct.addSymbols(Ct.icon,Jr,xv,Yr,ci,Rn,void 0,vi,Qt,Zl.lineStartIndex,Zl.lineLength,-1,Ar,yn,Gr,ur,Ct.symbolInstances.length,Yo),Ns=Ct.icon.placedSymbolArray.length-1,ss&&(Kn=4*Yo,Ct.addSymbols(Ct.icon,ss,xv,Yr,ci,Rn,Os.vertical,vi,Qt,Zl.lineStartIndex,Zl.lineLength,-1,Ar,yn,Gr,ur,Ct.symbolInstances.length,Yo),Vs=Ct.icon.placedSymbolArray.length-1)}for(const Dn in wi.horizontal){const Jr=Dn,ss=wi.horizontal[Jr];ql||(_v=Ba(ss.text),Bn?Rf=ew(ss):ql=Jx(qi,Ta,Qt,dn,rr,fn,ss,Sn,Si.layout.get("text-rotate").evaluate(Rn,{},yn),En,Mf));const Yo=ss.positionedLines.length===1;if(bo+=YA(Ct,vi,Qt,ss,gn,Si,Bn,Rn,En,Zl,wi.vertical?Os.horizontal:Os.horizontalOnly,Yo?GB(wi.horizontal):[Jr],Wo,Ns,cr,Ar,yn,Ct.symbolInstances.length,Gr),Yo)break}wi.vertical&&(Bs+=YA(Ct,vi,Qt,wi.vertical,gn,Si,Bn,Rn,En,Zl,Os.vertical,["vertical"],Wo,Vs,cr,Ar,yn,Ct.symbolInstances.length,Gr));let Un=-1;const Jn=(Dn,Jr)=>Dn?Math.max(Dn,Jr):Jr;Un=Jn(Rf,Un),Un=Jn(di,Un),Un=Jn(hr,Un);const Xo=Un>-1?1:0;Ct.glyphOffsetArray.length>=65535&&zt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Rn.sortKey!==void 0&&Ct.addToSortKeyRanges(Ct.symbolInstances.length,Rn.sortKey),Ct.symbolInstances.emplaceBack(Qt.x,Qt.y,Ta.x,Ta.y,Ta.z,Wo.right>=0?Wo.right:-1,Wo.center>=0?Wo.center:-1,Wo.left>=0?Wo.left:-1,Wo.vertical>=0?Wo.vertical:-1,Ns,Vs,_v,ql!==void 0?ql:Ct.collisionBoxArray.length,ql!==void 0?ql+1:Ct.collisionBoxArray.length,vo!==void 0?vo:Ct.collisionBoxArray.length,vo!==void 0?vo+1:Ct.collisionBoxArray.length,xo!==void 0?xo:Ct.collisionBoxArray.length,xo!==void 0?xo+1:Ct.collisionBoxArray.length,zh||Ct.collisionBoxArray.length,zh?zh+1:Ct.collisionBoxArray.length,dn,bo,Bs,In,Kn,Xo,0,Lf,Zn,Un,0,Df?1:0,Pf)})(n,yt,kt,ht,t,r,h,c,n.layers[0],n.collisionBoxArray,e.index,e.sourceLayerIndex,n.index,nt,Z,b,0,Fe,Qe,V,e,f,S,I,A,D,z,B,mt,Y,Q,te)};if(G==="line")for(const ht of Rx(e.geometry,0,0,_t,_t)){const yt=BB(ht,Ze,We,t.vertical||de,r,24,Xe,n.overscaling,_t);for(const It of yt)de&&JB(n,de.text,st,It)||pt(ht,It,A)}else if(G==="line-center"){for(const ht of e.geometry)if(ht.length>1){const yt=OB(ht,We,t.vertical||de,r,24,Xe);yt&&pt(ht,yt,A)}}else if(e.type==="Polygon")for(const ht of s_(e.geometry,0)){const yt=UB(ht,16);pt(ht[0],new Hl(yt.x,yt.y,0,0,void 0),A)}else if(e.type==="LineString")for(const ht of e.geometry)pt(ht,new Hl(ht[0].x,ht[0].y,0,0,void 0),A);else if(e.type==="Point")for(const ht of e.geometry)for(const yt of ht)pt([yt],new Hl(yt.x,yt.y,0,0,void 0),A)}const Jb=255,Ph=Jb*$l;function YA(n,e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B,V,Z){const G=jA(0,r,g,h,f,_,c,n.allowVerticalPlacement,void 0,D.textScaleFactor),Y=h.layout.get("text-size").evaluate(_,{},B),Q=D.compositeTextSizes?D.compositeTextSizes[0].evaluate(_,{},B):0,te=D.compositeTextSizes?D.compositeTextSizes[1].evaluate(_,{},B):0,me=Qb(n.layerIds[0],n.textSizeData,Y,D.textScaleFactor,Q,te);n.addSymbols(n.text,G,me,g,f,_,S,e,t,b.lineStartIndex,b.lineLength,M,z,B,Z,!1,V,G.length);for(const ce of I)A[ce]=n.text.placedSymbolArray.length-1;return 4*G.length}function Qb(n,e,t,r,c,h){const f=e;let _=null;return f.kind==="source"?(_=[$l*t*r],_[0]>Ph&&zt(`${n}: Value for "text-size" is >= ${Jb}. Reduce your "text-size".`)):f.kind==="composite"&&(_=[$l*c*r,$l*h*r],(_[0]>Ph||_[1]>Ph)&&zt(`${n}: Value for "text-size" is >= ${Jb}. Reduce your "text-size".`)),_}function Kx(n){for(const e in n)return n[e];return null}function Jx(n,e,t,r,c,h,f,_,g,b,S){let I,A,M,D;if(I=S?S.top:f.top,A=S?S.bottom:f.bottom,M=S?S.left:f.left,D=S?S.right:f.right,Ub(f)&&f.collisionPadding){const z=f.collisionPadding;M-=z[0],I-=z[1],D+=z[2],A+=z[3]}if(g){const z=new it(M,I),B=new it(D,I),V=new it(M,A),Z=new it(D,A),G=Ei(g);let Y=new it(0,0);b&&(Y=new it(b[0],b[1])),z._rotateAround(G,Y),B._rotateAround(G,Y),V._rotateAround(G,Y),Z._rotateAround(G,Y),M=Math.min(z.x,B.x,V.x,Z.x),D=Math.max(z.x,B.x,V.x,Z.x),I=Math.min(z.y,B.y,V.y,Z.y),A=Math.max(z.y,B.y,V.y,Z.y)}return n.emplaceBack(e.x,e.y,e.z,t.x,t.y,M,I,D,A,_,r,c,h),n.length-1}function ew(n){Ub(n)&&n.collisionPadding&&(n.top-=n.collisionPadding[1],n.bottom+=n.collisionPadding[3]);const e=n.bottom-n.top;return e>0?Math.max(10,e):null}function JB(n,e,t,r){const c=n.compareText;if(e in c){const h=c[e];for(let f=h.length-1;f>=0;f--)if(r.dist(h[f])<t)return!0}else c[e]=[];return c[e].push(r),!1}function KA(n,e){const t=n.fovAboveCenter,r=n.elevation?n.elevation.getMinElevationBelowMSL()*e:0,c=Math.min(r,n.isOrthographic?-10*e:0),h=(n._camera.position[2]*n.worldSize-c)/Math.cos(n._pitch),f=Math.sin(t)*h/Math.sin(Math.max(Math.PI/2-n._pitch-t,.01));let _=Math.sin(n._pitch)*f+h;const g=h*(1/n._horizonShift);if(!n.elevation||n.elevation.exaggeration()===0){let b=Math.max(n.zoom-17,0);n.isOrthographic&&(b/=10),_*=1+b}return Math.min(1.01*_,g)}function Mh(n,e){if(!e.isReprojectedInTileSpace)return{scale:1<<n.z,x:n.x,y:n.y,x2:n.x+1,y2:n.y+1,projection:e};const t=Math.pow(2,-n.z),r=n.x*t,c=(n.x+1)*t,h=n.y*t,f=(n.y+1)*t,_=we(r),g=we(c),b=Oe(h),S=Oe(f),I=e.project(_,b),A=e.project(g,b),M=e.project(g,S),D=e.project(_,S);let z=Math.min(I.x,A.x,M.x,D.x),B=Math.min(I.y,A.y,M.y,D.y),V=Math.max(I.x,A.x,M.x,D.x),Z=Math.max(I.y,A.y,M.y,D.y);const G=t/16;function Y(te,me,ce,pe,he,de){const Be=(ce+he)/2,je=(pe+de)/2,He=e.project(we(Be),Oe(je)),Xe=Math.max(0,z-He.x,B-He.y,He.x-V,He.y-Z);z=Math.min(z,He.x),V=Math.max(V,He.x),B=Math.min(B,He.y),Z=Math.max(Z,He.y),Xe>G&&(Y(te,He,ce,pe,Be,je),Y(He,me,Be,je,he,de))}Y(I,A,r,h,c,h),Y(A,M,c,h,c,f),Y(M,D,c,f,r,f),Y(D,I,r,f,r,h),z-=G,B-=G,V+=G,Z+=G;const Q=1/Math.max(V-z,Z-B);return{scale:Q,x:z*Q,y:B*Q,x2:V*Q,y2:Z*Q,projection:e}}function JA(n,{x:e,y:t},r=0){return new it(((e-r)*n.scale-n.x)*_t,(t*n.scale-n.y)*_t)}const QB=Ye(new Float32Array(16));class Xc{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 ve(0,0)}projectTilePoint(e,t,r){return{x:e,y:t,z:0}}locationPoint(e,t,r,c=!0){return e._coordinatePoint(e.locationCoordinate(t,r),c)}pixelsPerMeter(e,t){return Pe(1,e)*t}pixelSpaceConversion(e,t,r){return 1}farthestPixelDistance(e){return KA(e,e.pixelsPerMeter)}pointCoordinate(e,t,r,c){const h=e.horizonLineFromTop(!1),f=new it(t,Math.max(h,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(f,c))}pointCoordinate3D(e,t,r){const c=new it(t,r);if(e.elevation)return e.elevation.pointCoordinate(c);{const h=this.pointCoordinate(e,c.x,c.y,0);return[h.x,h.y,h.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,t.x,t.y);const r=e.horizonLineFromTop();return t.y<r}createInversionMatrix(e,t){return QB}createTileMatrix(e,t,r){let c,h,f;const _=r.canonical,g=Ye(new Float64Array(16));if(this.isReprojectedInTileSpace){const b=Mh(_,this);c=1,h=b.x+r.wrap*b.scale,f=b.y,qe(g,g,[c/b.scale,c/b.scale,e.pixelsPerMeter/t])}else c=t/e.zoomScale(_.z),h=(_.x+Math.pow(2,_.z)*r.wrap)*c,f=_.y*c;return Ie(g,g,[h,f,0]),qe(g,g,[c/_t,c/_t,1]),g}upVector(e,t,r){return[0,0,1]}upVectorScale(e,t,r){return{metersToTile:1}}}class e3 extends Xc{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,r]=this.parallels=e.parallels||[29.5,45.5],c=Math.sin(Ei(t));this.n=(c+Math.sin(Ei(r)))/2,this.c=1+c*(2*this.n-c),this.r0=Math.sqrt(this.c)/this.n}project(e,t){const{n:r,c,r0:h}=this,f=Ei(e-this.center[0]),_=Ei(t),g=Math.sqrt(c-2*r*Math.sin(_))/r;return{x:g*Math.sin(f*r),y:g*Math.cos(f*r)-h,z:0}}unproject(e,t){const{n:r,c,r0:h}=this,f=h+t;let _=Math.atan2(e,Math.abs(f))*Math.sign(f);f*r<0&&(_-=Math.PI*Math.sign(e)*Math.sign(f));const g=Ei(this.center[0])*r;_=ge(_,-Math.PI-g,Math.PI-g);const b=q(_r(_/r)+this.center[0],-180,180),S=Math.asin(q((c-(e*e+f*f)*r*r)/(2*r),-1,1)),I=q(_r(S),-85.051129,$e);return new ve(b,I)}}const S_=1.340264,E_=-.081106,I_=893e-6,A_=.003796,Qx=Math.sqrt(3)/2;class t3 extends Xc{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const r=Math.asin(Qx*Math.sin(t)),c=r*r,h=c*c*c;return{x:.5*(e*Math.cos(r)/(Qx*(S_+3*E_*c+h*(7*I_+9*A_*c)))/Math.PI+.5),y:1-.5*(r*(S_+E_*c+h*(I_+A_*c))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let r=t=(2*(1-t)-1)*Math.PI,c=r*r,h=c*c*c;for(let S,I,A,M=0;M<12&&(I=r*(S_+E_*c+h*(I_+A_*c))-t,A=S_+3*E_*c+h*(7*I_+9*A_*c),S=I/A,r=q(r-S,-Math.PI/3,Math.PI/3),c=r*r,h=c*c*c,!(Math.abs(S)<1e-12));++M);const f=Qx*e*(S_+3*E_*c+h*(7*I_+9*A_*c))/Math.cos(r),_=Math.asin(Math.sin(r)/Qx),g=q(180*f/Math.PI,-180,180),b=q(180*_/Math.PI,-85.051129,$e);return new ve(g,b)}}class i3 extends Xc{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){return{x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const r=360*(e-.5),c=q(360*(.5-t),-85.051129,$e);return new ve(r,c)}}const wf=Math.PI/2;function ev(n){return Math.tan((wf+n)/2)}class n3 extends Xc{constructor(e){super(e),this.center=e.center||[0,30];const[t,r]=this.parallels=e.parallels||[30,30];let c=Ei(t),h=Ei(r);this.southernCenter=c+h<0,this.southernCenter&&(c=-c,h=-h);const f=Math.cos(c),_=ev(c);this.n=c===h?Math.sin(c):Math.log(f/Math.cos(h))/Math.log(ev(h)/_),this.f=f*Math.pow(ev(c),this.n)/this.n}project(e,t){t=Ei(t),this.southernCenter&&(t=-t),e=Ei(e-this.center[0]);const r=1e-6,{n:c,f:h}=this;h>0?t<-wf+r&&(t=-wf+r):t>wf-r&&(t=wf-r);const f=h/Math.pow(ev(t),c);let _=f*Math.sin(c*e),g=h-f*Math.cos(c*e);return _=.5*(_/Math.PI+.5),g=.5*(g/Math.PI+.5),{x:_,y:this.southernCenter?g:1-g,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:r,f:c}=this,h=c-t,f=Math.sign(h),_=Math.sign(r)*Math.sqrt(e*e+h*h);let g=Math.atan2(e,Math.abs(h))*f;h*r<0&&(g-=Math.PI*Math.sign(e)*f);const b=q(_r(g/r)+this.center[0],-180,180),S=q(_r(2*Math.atan(Math.pow(c/_,1/r))-wf),-85.051129,$e);return new ve(b,this.southernCenter?-S:S)}}class QA extends Xc{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:Je(e),y:tt(t),z:0}}unproject(e,t){const r=we(e),c=Oe(t);return new ve(r,c)}}const eC=Ei($e);class r3 extends Xc{project(e,t){const r=(t=Ei(t))*t,c=r*r;return{x:.5*((e=Ei(e))*(.8707-.131979*r+c*(c*(.003971*r-.001529*c)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+r*(.015085+c*(.028874*r-.044475-.005916*c)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let r=t=(2*(1-t)-1)*Math.PI,c=25,h=0,f=r*r;do{f=r*r;const b=f*f;h=(r*(1.007226+f*(.015085+b*(.028874*f-.044475-.005916*b)))-t)/(1.007226+f*(.045255+b*(.259866*f-.311325-.005916*11*b))),r=q(r-h,-eC,eC)}while(Math.abs(h)>1e-6&&--c>0);f=r*r;const _=q(_r(e/(.8707+f*(f*(f*f*f*(.003971-.001529*f)-.013791)-.131979))),-180,180),g=_r(r);return new ve(_,g)}}const tC=Ei($e);class s3 extends Xc{project(e,t){t=Ei(t),e=Ei(e);const r=Math.cos(t),c=2/Math.PI,h=Math.acos(r*Math.cos(e/2)),f=Math.sin(h)/h,_=.5*(e*c+2*r*Math.sin(e/2)/f)||0,g=.5*(t+Math.sin(t)/f)||0;return{x:.5*(_/Math.PI+.5),y:1-.5*(g/Math.PI+1),z:0}}unproject(e,t){let r=e=(2*e-.5)*Math.PI,c=t=(2*(1-t)-1)*Math.PI,h=25;const f=1e-6;let _=0,g=0;do{const b=Math.cos(c),S=Math.sin(c),I=2*S*b,A=S*S,M=b*b,D=Math.cos(r/2),z=Math.sin(r/2),B=2*D*z,V=z*z,Z=1-M*D*D,G=Z?1/Z:0,Y=Z?Math.acos(b*D)*Math.sqrt(1/Z):0,Q=.5*(2*Y*b*z+2*r/Math.PI)-e,te=.5*(Y*S+c)-t,me=.5*G*(M*V+Y*b*D*A)+1/Math.PI,ce=G*(B*I/4-Y*S*z),pe=.125*G*(I*z-Y*S*M*B),he=.5*G*(A*D+Y*V*b)+.5,de=ce*pe-he*me;_=(te*ce-Q*he)/de,g=(Q*pe-te*me)/de,r=q(r-_,-Math.PI,Math.PI),c=q(c-g,-tC,tC)}while((Math.abs(_)>f||Math.abs(g)>f)&&--h>0);return new ve(_r(r),_r(c))}}class iC extends Xc{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ei(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:r,cosPhi:c}=this;return{x:Ei(e)*c*r+.5,y:-Math.sin(Ei(t))/c*r+.5,z:0}}unproject(e,t){const{scale:r,cosPhi:c}=this,h=-(t-.5)/r,f=q(_r((e-.5)/r)/c,-180,180),_=Math.asin(q(h*c,-1,1)),g=q(_r(_),-85.051129,$e);return new ve(f,g)}}class o3 extends QA{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,t,r){const c=Jm(e,t,r);return mn(c,c,Qm(Ja(r))),{x:c[0],y:c[1],z:c[2]}}locationPoint(e,t,r){const c=ae(t.lat,t.lng),h=zi([],c),f=r?e._centerAltitude+r:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;rn(c,c,h,Pe(1,0)*_t*f);const _=Ye(new Float64Array(16));return ye(_,e.pixelMatrix,e.globeMatrix),mn(c,c,_),new it(c[0],c[1])}pixelsPerMeter(e,t){return Pe(1,0)*t}pixelSpaceConversion(e,t,r){const c=Pe(1,e)*t,h=Gt(Pe(1,45)*t,c,r);return this.pixelsPerMeter(e,t)/h}createTileMatrix(e,t,r){const c=W1(Ja(r.canonical));return ye(new Float64Array(16),e.globeMatrix,c)}createInversionMatrix(e,t){const{center:r}=e,c=Qm(Ja(t));return xt(c,c,Ei(r.lng)),ot(c,c,Ei(r.lat)),qe(c,c,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(c)}pointCoordinate(e,t,r,c){return yE(e,t,r,!0)||new Et(0,0)}pointCoordinate3D(e,t,r){const c=this.pointCoordinate(e,t,r,0);return[c.x,c.y,c.z]}isPointAboveHorizon(e,t){return!yE(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(c,h){const f=c.cameraToCenterDistance,_=c._centerAltitude*h,g=c._camera,b=c._camera.forward(),S=Pt([],mi([],b,-f),[0,0,_]),I=c.worldSize/(2*Math.PI),A=[0,0,-I],M=c.width/c.height,D=Math.tan(c.fovAboveCenter),z=mi([],g.up(),D),B=mi([],g.right(),D*M),V=zi([],Pt([],Pt([],b,z),B)),Z=[];let G;if(new fi(S,V).closestPointOnSphere(A,I,Z)){const Y=Pt([],Z,A),Q=Ln([],Y,S);G=Math.cos(c.fovAboveCenter)*Wn(Q)}else{const Y=Ln([],S,A),Q=Ln([],A,S);zi(Q,Q);const te=Wn(Y)-I;G=Math.sqrt(te*(te+2*I));const me=Math.acos(G/(I+te))-Math.acos(pn(b,Q));G*=Math.cos(me)}return 1.01*G}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=Ul(e.zoom);if(r>0){const c=KA(e,Pe(1,e.center.lat)*e.worldSize),h=e.worldSize/(2*Math.PI),f=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Gt(t,c+h*(1-Math.cos(f)),Math.pow(r,10))}return t}upVector(e,t,r){return Jm(t,r,e,1)}upVectorScale(e){return{metersToTile:fx(mx(Ja(e)))}}}function nC(n){const e=n.parallels,t=!!e&&Math.abs(e[0]+e[1])<.01;switch(n.name){case"mercator":return new QA(n);case"equirectangular":return new i3(n);case"naturalEarth":return new r3(n);case"equalEarth":return new t3(n);case"winkelTripel":return new s3(n);case"albers":return t?new iC(n):new e3(n);case"lambertConformalConic":return t?new iC(n):new n3(n);case"globe":return new o3(n)}throw new Error(`Invalid projection name: ${n.name}`)}class a3{constructor(e,t){this.lastParams=null,this.lastAllFeaturesIndex=-2,this.appearancesVersion=t,this.appearances=e;const r=e.map(c=>function(h){if(!h.condition)return{featureDependent:!1,stateDependent:!1,zoomDependent:!1,pitchDependent:!1,brightnessDependent:!1,worldviewDependent:!1};const f=h.condition.expression;return{featureDependent:!Al(f),stateDependent:!Cc(f),zoomDependent:!No(f,["zoom"]),pitchDependent:!No(f,["pitch"]),brightnessDependent:!No(f,["brightness","measure-light"]),worldviewDependent:!No(f,["worldview"])}}(c));this.anyFeatureDependent=r.some(c=>c.featureDependent),this.anyStateDependent=r.some(c=>c.stateDependent)}update(e,t){const r=this.lastParams,c=!r||r.zoom!==e.zoom||r.pitch!==(e.pitch||0)||r.brightness!==(e.brightness||0)||r.worldview!==e.worldview;this.lastParams={zoom:e.zoom,pitch:e.pitch||0,brightness:e.brightness||0,worldview:e.worldview};const h=t&&this.anyStateDependent;if(!c&&!h&&this.lastAllFeaturesIndex!==-2)return{kind:"no-changes"};if(!this.anyFeatureDependent&&!h){const f=this.evaluateAllFeatures(e);return f===this.lastAllFeaturesIndex?{kind:"no-changes"}:(this.lastAllFeaturesIndex=f,{kind:"all-features",appearanceIndex:f})}return{kind:"per-feature"}}evaluateAllFeatures(e){for(let t=0;t<this.appearances.length;t++){const r=this.appearances[t];if(r.condition&&r.condition.evaluate(e,void 0,void 0,void 0))return t}return-1}}const l3=qt.types,c3=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function C_(n,e,t,r,c,h,f,_,g,b,S,I,A){const M=_?Math.min(Ph,Math.round(_[0])):0,D=_?Math.min(Ph,Math.round(_[1])):0;n.emplaceBack(e,t,Math.round(32*r),Math.round(32*c),h,f,(M<<1)+(g?1:0),0+(D<<1),16*b,16*S,256*I,256*A)}function P_(n,e,t){n.emplaceBack(e,t)}function M_(n,e,t,r,c,h,f){n.emplaceBack(e,t,r,c,h,f)}const tv=(n,e,t,r)=>{for(let c=0;c<e;c++)n.emplaceBack(t[0],t[1],t[2],r[0],r[1],r[2])};function Tf(n,e,t,r,c){n.emplaceBack(e,t,r,c),n.emplaceBack(e,t,r,c),n.emplaceBack(e,t,r,c),n.emplaceBack(e,t,r,c)}function u3(n){for(const e of n.sections)if(z1(e.text))return!0;return!1}const Sf=12;class tw{constructor(e){this.layoutVertexArray=new Bm,this.indexArray=new Tn,this.programConfigurations=e,this.segments=new $i,this.dynamicLayoutVertexArray=new _a,this.opacityVertexArray=new fh,this.placedSymbolArray=new sx,this.iconTransitioningVertexArray=new eo,this.globeExtVertexArray=new Nm,this.zOffsetVertexArray=new Rs,this.orientationVertexArray=new rf,this.symbolInstanceIndices=[],this.uboBinder=null,this.featureIdArray=new Rs,this.featureIdBuffer=null,this.cachedBatchIndices=null,this.cachedBatchSegments=null}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0&&this.iconTransitioningVertexArray.length===0}getBatchGrouping(e){const t=e.get().length===this.segments.get().length;if(t&&this.cachedBatchIndices&&this.cachedBatchSegments)return{batchIndices:this.cachedBatchIndices,batchSegments:this.cachedBatchSegments};const r=new Map;for(const f of e.get()){const _=f.batchIndex!==void 0?f.batchIndex:0;r.has(_)||r.set(_,[]),r.get(_).push(f)}const c=Array.from(r.keys()).sort((f,_)=>f-_),h=new Map;for(const f of c){const _=r.get(f);h.set(f,new $i(_))}return t&&(this.cachedBatchIndices=c,this.cachedBatchSegments=h),{batchIndices:c,batchSegments:h}}snapshotSymbolVertexData(e,t){const r=e*Sf;return this.layoutVertexArray.uint16.slice(r,r+t*Sf)}restoreSymbolVertexData(e,t){this.layoutVertexArray.uint16.set(t,e*Sf)}updateSymbolVertexData(e,t,r,c,h,f,_,g,b,S,I,A,M){const D=this.layoutVertexArray.uint16,z=e*Sf;D[z]=t,D[z+1]=r,D[z+2]=c,D[z+3]=h,D[z+4]=f,D[z+5]=_,D[z+6]=g,D[z+7]=b,D[z+8]=S,D[z+9]=I,D[z+10]=A,D[z+11]=M}upload(e,t,r,c,h,f){this.isEmpty()||(r&&(this.cachedBatchIndices=null,this.cachedBatchSegments=null,this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,uB.members,!!f),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,dB.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,c3,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,_B.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,hB.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||h)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,fB.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,mB.members,!0)),this.opacityVertexBuffer.itemSize=1,this.featureIdArray&&this.featureIdArray.length>0&&(this.featureIdBuffer=e.createVertexBuffer(this.featureIdArray,pB.members,!1))),(r||c)&&(this.programConfigurations.upload(e),this.uboBinder&&this.uboBinder.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(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy(),this.featureIdBuffer&&this.featureIdBuffer.destroy(),this.uboBinder&&this.uboBinder.destroy())}}wt(tw,"SymbolBuffers",{omit:["cachedBatchIndices","cachedBatchSegments"]});class iw{constructor(e,t,r){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new r,this.segments=new $i,this.collisionVertexArray=new mh,this.collisionVertexArrayExt=new _a}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,gB.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,yB.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}wt(iw,"CollisionBuffers");class va{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(f=>f.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Ye([]),this.placementViewportMatrix=Ye([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSizeDwords=e.maxUniformBlockSizeDwords,this.disableSymbolUBO=e.disableSymbolUBO,this.textSizeData=Ch(this.zoom,t["text-size"],this.worldview,e.availableImages),this.iconSizeData=Ch(this.zoom,t["icon-size"],this.worldview,e.availableImages);const r=this.layers[0].layout,c=r.get("symbol-sort-key"),h=r.get("symbol-z-order");this.lut=e.lut,this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey=h!=="viewport-y"&&c.constantOr(1)!==void 0,this.sortFeaturesByY=(h==="viewport-y"||h==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map(f=>Os[f]),this.stateDependentLayerIds=this.layers.filter(f=>f.isStateDependent()).map(f=>f.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.featureAppearances=null,this.featureAppearanceData=new Map}hasAnyAppearanceLayoutProperty(e){const t=this.layers[0].getAppearances();if(!t||t.length===0)return!1;const r=Array.isArray(e)?e:[e];return t.some(c=>r.some(h=>c.hasLayoutProperty(h)))}getAppearanceFeatureData(e){return this.featureAppearanceData.get(e)}createArrays(){this.text=new tw(new N(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new tw(new N(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.disableSymbolUBO||(this.text.uboBinder=new Ob(this.layers[0],this.zoom,this.lut,!0,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords),this.icon.uboBinder=new Ob(this.layers[0],this.zoom,this.lut,!1,"",this.maxUniformBufferBindings,this.maxUniformBlockSizeDwords)),this.glyphOffsetArray=new ax,this.lineVertexArray=new yh,this.symbolInstances=new ox}calculateGlyphDependencies(e,t,r,c,h){for(const f of e){const _=f.codePointAt(0);if(_===void 0)break;if(t[_]=!0,c&&h&&_<=65535){const g=y_[f];g&&(t[g.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,t,r,c,h,f,_){if(!e.hasLayoutProperty("icon-size"))return _*f;let g=1;const b=e.getUnevaluatedLayoutProperty("icon-size"),S=Ch(this.zoom,b,this.worldview,h),I=vf(S,t);if(S.kind!=="constant"&&S.kind!=="camera"||(g=I.uSize),S.kind==="composite"){const{minZoom:A,maxZoom:M}=S,D=b.possiblyEvaluate(new Mi(A,{worldview:this.worldview}),c),z=b.possiblyEvaluate(new Mi(M,{worldview:this.worldview}),c),B=D.evaluate(r,{},c,h);g=B+(z.evaluate(r,{},c,h)-B)*I.uSizeT}return S.kind==="source"&&(g=b.possiblyEvaluate(new Mi(this.zoom,{worldview:this.worldview}),c).evaluate(r,{},c,h)),g*f}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!Ex(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}getResolvedImageFromTokens(e){return typeof e=="string"?is.build(e):e}populate(e,t,r,c){const h=this.layers[0],f=h.layout,_=this.projection.name==="globe",g=f.get("text-font"),b=f.get("text-field"),S=f.get("icon-image"),[I,A]=f.get("icon-size-scale-range"),M=q(t.scaleFactor||1,I,A),[D,z]=f.get("text-size-scale-range"),B=q(t.scaleFactor||1,D,z),V=(b.value.kind!=="constant"||b.value.value instanceof Lr&&!b.value.value.isEmpty()||b.value.value.toString().length>0)&&(g.value.kind!=="constant"||g.value.value.length>0),Z=S.value.kind!=="constant"||!!S.value.value||Object.keys(S.parameters).length>0,G=this.hasAnyAppearanceLayoutProperty("icon-image"),Y=f.get("symbol-sort-key");if(this.features=[],this.featureAppearanceData=new Map,!V&&!Z&&!G)return;const Q=t.iconDependencies,te=t.glyphDependencies,me=t.availableImages,ce=new Mi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),pe=he=>{const de=he.id.toString();Q.has(de)?Q.get(de).push(he):Q.set(de,[he])};for(const he of e){const{feature:de,id:Be,index:je,sourceLayerIndex:He}=he,Xe=h._featureFilter.needGeometry,Ze=oi(de,Xe);if(!h._featureFilter.filter(ce,Ze,r))continue;if(Xe||(Ze.geometry=Ft(de,r,c)),_&&de.type!==1&&r.z<=5){const mt=Ze.geometry,pt=.98078528056,ht=(yt,It)=>pn(Jm(yt.x,yt.y,r,1),Jm(It.x,It.y,r,1))<pt;for(let yt=0;yt<mt.length;yt++)mt[yt]=Vt(mt[yt],ht)}let nt,Fe;if(V){const mt=h.getValueAndResolveTokens("text-field",Ze,r,me),pt=Lr.factory(mt);u3(pt)&&(this.hasRTLText=!0),(!this.hasRTLText||Em()==="unavailable"||this.hasRTLText&&fa.isParsed())&&(nt=vB(pt,h,Ze))}if(Z){const mt=h.getValueAndResolveTokens("icon-image",Ze,r,me);Fe=this.getResolvedImageFromTokens(mt)}const We=this.layers[0];let Qe=!1;if(!Fe&&G){const mt=We.getAppearances();for(const pt of mt)if(pt.getLayoutProperty("icon-image")){const ht=We.getAppearanceValueAndResolveTokens(pt,"icon-image",Ze,r,me);if(ht){Fe=this.getResolvedImageFromTokens(ht),Qe=!0;break}}}if(!nt&&!Fe)continue;const st=this.sortFeaturesByKey?Y.evaluate(Ze,{},r):void 0,ut={id:Be,text:nt,icon:Fe,index:je,sourceLayerIndex:He,geometry:Ze.geometry,properties:de.properties,type:l3[de.type],sortKey:st};if(this.features.push(ut),this.featureAppearanceData.set(je,{id:Be,properties:de.properties,usesAppearanceIconAsPlaceholder:Qe,isUsingAppearanceIconVertexData:!1,isUsingAppearanceTextVertexData:!1,layoutBasedIconVertexData:new Uint16Array(0),layoutBasedTextVertexData:new Uint16Array(0),activeAppearanceIndex:-2}),Fe){const mt=We._unevaluatedLayout._values,{iconPrimary:pt,iconSecondary:ht}=T_(Fe,this.iconSizeData,mt["icon-size"],r,this.zoom,ut,this.pixelRatio,M,this.worldview,me);pe(pt),ht&&(this.hasAnySecondaryIcon=!0,pe(ht))}const bt=We.getAppearances();if(bt.length!==0&&bt.forEach(mt=>{if(!mt.getLayoutProperty("icon-image"))return;const pt=this.getCombinedIconPrimary(mt,We,Ze,r,me,ut,M);pt&&pe(pt)}),nt){const mt=g.evaluate(Ze,{},r).join(","),pt=f.get("text-rotation-alignment")==="map"&&f.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Os.vertical)>=0;for(const ht of nt.sections)if(ht.image){const yt=ht.image.getPrimary().scaleSelf(this.pixelRatio*B),It=yt.id.toString(),kt=Q.get(It)||[];kt.push(yt),Q.set(It,kt)}else{const yt=vm(nt.toString()),It=ht.fontStack||mt,kt=te[It]=te[It]||{};this.calculateGlyphDependencies(ht.text,kt,pt,this.allowVerticalPlacement,yt)}}}if(f.get("symbol-placement")==="line"&&(this.features=function(he){const de={},Be={},je=[];let He=0;function Xe(We){je.push(he[We]),He++}function Ze(We,Qe,st){const ut=Be[We];return delete Be[We],Be[Qe]=ut,je[ut].geometry[0].pop(),je[ut].geometry[0]=je[ut].geometry[0].concat(st[0]),ut}function nt(We,Qe,st){const ut=de[Qe];return delete de[Qe],de[We]=ut,je[ut].geometry[0].shift(),je[ut].geometry[0]=st[0].concat(je[ut].geometry[0]),ut}function Fe(We,Qe,st){const ut=st?Qe[0][Qe[0].length-1]:Qe[0][0];return`${We}:${ut.x}:${ut.y}`}for(let We=0;We<he.length;We++){const Qe=he[We],st=Qe.geometry,ut=Qe.text?Qe.text.toString():null;if(!ut){Xe(We);continue}const bt=Fe(ut,st),mt=Fe(ut,st,!0);if(bt in Be&&mt in de&&Be[bt]!==de[mt]){const pt=nt(bt,mt,st),ht=Ze(bt,mt,je[pt].geometry);delete de[bt],delete Be[mt],Be[Fe(ut,je[ht].geometry,!0)]=ht,je[pt].geometry=null}else bt in Be?Ze(bt,mt,st):mt in de?nt(bt,mt,st):(Xe(We),de[bt]=He-1,Be[mt]=He-1)}return je.filter(We=>We.geometry)}(this.features)),f.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",t.elevationFeatures){!this.elevationFeatures&&t.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const he of t.elevationFeatures)this.elevationFeatureIdToIndex.set(he.id,this.elevationFeatures.length),this.elevationFeatures.push(he)}}else f.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((he,de)=>he.sortKey-de.sortKey)}getCombinedIconPrimary(e,t,r,c,h,f,_){let g,b;if(e.hasLayoutProperty("icon-image")){const S=t.getAppearanceValueAndResolveTokens(e,"icon-image",r,c,h);g=this.getResolvedImageFromTokens(S)}else{const S=t.getValueAndResolveTokens("icon-image",r,c,h);g=this.getResolvedImageFromTokens(S)}if(g){const S=e.hasLayoutProperty("icon-size")?e.getUnevaluatedLayoutProperty("icon-size"):t._unevaluatedLayout._values["icon-size"];b=T_(g,Ch(this.zoom,S,this.worldview,h),S,c,this.zoom,f,this.pixelRatio,_,this.worldview,h).iconPrimary}return b}updateSymbolInstanceIconVertices(e,t,r,c,h,f){const{canonical:_,availableImages:g,globalProperties:b,layer:S,iconScaleFactor:I,featureState:A,layoutIconOffset:M,layoutIconSize:D,layoutIconRotate:z}=f;if(e.placedIconSymbolIndex<0)return{vertexOffsetDelta:0,hasChanges:!1};if(t.activeAppearanceIndex===r)return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1};const B=r>=0?S.appearances[r]:null;if(B){const V=this.getCombinedIconPrimary(B,S,c,_,g,{sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:t.properties,type:"Point",id:t.id},I);if(!V)return{vertexOffsetDelta:0,hasChanges:!1};const Z=V.toString(),G=this.iconAtlasPositions&&this.iconAtlasPositions.get(Z);if(G){const{appearanceIconOffset:Y,appearanceIconRotate:Q}=$A(B,S,c,_,M,z,D,I);let te=$x(G,void 0,Y,S.layout.get("icon-anchor").evaluate(c,A,_));const me=G.sdf,ce=S.layout.get("icon-text-fit").constantOr("none");ce!=="none"&&t.textShaping&&t.iconTextFitPadding&&t.fontScale&&(te=jb(te,t.textShaping,ce,t.iconTextFitPadding,Y,t.fontScale));const pe=this.calculateEffectiveAppearanceIconSize(B,b.zoom,c,_,g,I,D),he=0,de=1+(Math.min(Ph,Math.round(pe*$l))<<1),Be=Xb(te,Q,me,ce!=="none",I);t.isUsingAppearanceIconVertexData||(t.isUsingAppearanceIconVertexData=!0,t.layoutBasedIconVertexData=this.icon.snapshotSymbolVertexData(h,e.numIconVertices));const je=Math.floor(e.numIconVertices/4),He=Math.min(Be.length,je);let Xe=h;for(let nt=0;nt<He;++nt){const Fe=Be[nt],We=t.layoutBasedIconVertexData[0]||e.tileAnchorX,Qe=t.layoutBasedIconVertexData[1]||e.tileAnchorY,st=16*Fe.pixelOffsetTL.x,ut=16*Fe.pixelOffsetTL.y,bt=16*Fe.pixelOffsetBR.x,mt=16*Fe.pixelOffsetBR.y,pt=16*Fe.minFontScaleX,ht=16*Fe.minFontScaleY;this.icon.updateSymbolVertexData(Xe,We,Qe,Math.round(32*Fe.tl.x),Math.round(32*Fe.tl.y),Fe.texPrimary.x,Fe.texPrimary.y,he,de,st,ut,pt,ht),this.icon.updateSymbolVertexData(Xe+1,We,Qe,Math.round(32*Fe.tr.x),Math.round(32*Fe.tr.y),Fe.texPrimary.x+Fe.texPrimary.w,Fe.texPrimary.y,he,de,bt,ut,pt,ht),this.icon.updateSymbolVertexData(Xe+2,We,Qe,Math.round(32*Fe.bl.x),Math.round(32*Fe.bl.y),Fe.texPrimary.x,Fe.texPrimary.y+Fe.texPrimary.h,he,de,st,mt,pt,ht),this.icon.updateSymbolVertexData(Xe+3,We,Qe,Math.round(32*Fe.br.x),Math.round(32*Fe.br.y),Fe.texPrimary.x+Fe.texPrimary.w,Fe.texPrimary.y+Fe.texPrimary.h,he,de,bt,mt,pt,ht),Xe+=4}const Ze=e.numIconVertices-4*He;for(let nt=0;nt<Ze;++nt)this.icon.updateSymbolVertexData(Xe+nt,0,0,0,0,0,0,0,0,0,0,0,0);return{vertexOffsetDelta:e.numIconVertices,hasChanges:!0}}}else{if(t.usesAppearanceIconAsPlaceholder)return this.icon.updateSymbolVertexData(h,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(h+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(h+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(h+3,0,0,0,0,0,0,0,0,0,0,0,0),{vertexOffsetDelta:e.numIconVertices,hasChanges:!0};if(t.isUsingAppearanceIconVertexData)return this.icon.restoreSymbolVertexData(h,t.layoutBasedIconVertexData),t.isUsingAppearanceIconVertexData=!1,{vertexOffsetDelta:t.layoutBasedIconVertexData.length/Sf,hasChanges:!0}}return{vertexOffsetDelta:e.numIconVertices,hasChanges:!1}}updateSymbolInstanceTextVertices(e,t,r,c,h,f){const{canonical:_,layer:g,textScaleFactor:b,imageMap:S,featureState:I,layoutTextOffset:A,layoutTextSize:M,layoutTextRotate:D,layoutMinZoomSize:z,layoutMaxZoomSize:B,layoutTextSizeMinZoom:V,layoutTextSizeMaxZoom:Z,availableImages:G}=f,Y=e.numHorizontalGlyphVertices>0||e.numVerticalGlyphVertices>0;if(!Y)return{vertexOffsetDelta:Y?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(t.activeAppearanceIndex===r)return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};const Q=r>=0?g.appearances[r]:null;if(Q&&t.textShaping){const{appearanceTextOffset:te,appearanceTextRotate:me,appearanceTextSize:ce}=HA(Q,g,c,_,A,D,M);t.fontScale=XA(ce,t.textScaleFactor);const pe=Q.getUnevaluatedLayoutProperty("text-size");let he=this.textSizeData,de=V,Be=Z;Q.hasLayoutProperty("text-size")&&(he=Ch(this.zoom,pe,this.worldview,G),de=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,Be=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0);const je=t.textShaping.bottom-A[1],He=t.textShaping.left-A[0],Xe=t.textShaping.right-A[0];t.textShaping.top=te[1]+(t.textShaping.top-A[1]),t.textShaping.bottom=te[1]+je,t.textShaping.left=te[0]+He,t.textShaping.right=te[0]+Xe;const Ze=jA(0,t.textShaping,te,g,!1,c,S,this.allowVerticalPlacement,me),nt=ce&&he.kind==="composite"?pe.possiblyEvaluate(new Mi(de,{}),_).evaluate(c,I,_):z,Fe=ce&&he.kind==="composite"?pe.possiblyEvaluate(new Mi(Be,{}),_).evaluate(c,I,_):B,We=Qb(Q.name,he,ce,b,nt,Fe),Qe=Array.isArray(We)?We[1]:ce,st=0,ut=1+(Math.min(Ph,Math.round(Qe*$l))<<1);t.isUsingAppearanceTextVertexData||(t.isUsingAppearanceTextVertexData=!0,t.layoutBasedTextVertexData=this.text.snapshotSymbolVertexData(h,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let bt=0;bt<Ze.length&&bt<(e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices)/4;++bt){const mt=Ze[bt],pt=mt.glyphOffset[1],ht=e.tileAnchorX,yt=e.tileAnchorY,It=h+4*bt;this.text.updateSymbolVertexData(It,ht,yt,Math.round(32*mt.tl.x),Math.round(32*(pt+mt.tl.y)),mt.texPrimary.x,mt.texPrimary.y,st,ut,mt.pixelOffsetTL.x,mt.pixelOffsetTL.y,mt.minFontScaleX,mt.minFontScaleY),this.text.updateSymbolVertexData(It+1,ht,yt,Math.round(32*mt.tr.x),Math.round(32*(pt+mt.tr.y)),mt.texPrimary.x+mt.texPrimary.w,mt.texPrimary.y,st,ut,mt.pixelOffsetBR.x,mt.pixelOffsetTL.y,mt.minFontScaleX,mt.minFontScaleY),this.text.updateSymbolVertexData(It+2,ht,yt,Math.round(32*mt.bl.x),Math.round(32*(pt+mt.bl.y)),mt.texPrimary.x,mt.texPrimary.y+mt.texPrimary.h,st,ut,mt.pixelOffsetTL.x,mt.pixelOffsetBR.y,mt.minFontScaleX,mt.minFontScaleY),this.text.updateSymbolVertexData(It+3,ht,yt,Math.round(32*mt.br.x),Math.round(32*(pt+mt.br.y)),mt.texPrimary.x+mt.texPrimary.w,mt.texPrimary.y+mt.texPrimary.h,st,ut,mt.pixelOffsetBR.x,mt.pixelOffsetBR.y,mt.minFontScaleX,mt.minFontScaleY)}return{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!0}}return t.isUsingAppearanceTextVertexData?(this.text.restoreSymbolVertexData(h,t.layoutBasedTextVertexData),t.isUsingAppearanceTextVertexData=!1,{vertexOffsetDelta:t.layoutBasedTextVertexData.length/Sf,hasChanges:!0}):{vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1}}update(e,t,r,c,h,f,_,g){if(this.text.programConfigurations.updatePaintArrays(e,t,h,r,c,f,_,this.worldview),this.icon.programConfigurations.updatePaintArrays(e,t,h,r,c,f,_,this.worldview),g){if(f)this.text.uboBinder&&this.text.uboBinder.updateDynamicExpressions(h[0],t,g,r,e,_),this.icon.uboBinder&&this.icon.uboBinder.updateDynamicExpressions(h[0],t,g,r,e,_);else if(Object.keys(e).length>0){const b=new Set(Object.keys(e).map(S=>{const I=Number(S);return!isNaN(I)&&Number.isSafeInteger(I)&&String(I)===S?I:S}));this.text.uboBinder&&this.text.uboBinder.updateFeatures(b,h[0],t,g,r,e,_),this.icon.uboBinder&&this.icon.uboBinder.updateFeatures(b,h[0],t,g,r,e,_)}}}updateRoadElevation(e){if(this.elevationType!=="road"||!this.elevationFeatures||this.elevationStateComplete)return;this.elevationStateComplete=!0,this.hasAnyZOffset=!1;let t=!1;const r=et(e),c=1/r;let h=!1,f=!1;for(let _=0;_<this.symbolInstances.length;_++){const g=this.symbolInstances.get(_),b=ji(1,0,0),S=ji(0,1,0),{numHorizontalGlyphVertices:I,numVerticalGlyphVertices:A,numIconVertices:M,numVerticalIconVertices:D}=g,z=I>0||A>0,B=M>0,V=this.elevationFeatures[g.elevationFeatureIndex];if(V){const Z=new it(g.tileAnchorX,g.tileAnchorY),G=.075+V.pointElevation(Z);g.zOffset!==G&&(t=!0,g.zOffset=G),G!==0&&(this.hasAnyZOffset=!0);const Y=V.computeSlopeNormal(Z,c),Q=Eu(Es(),ji(0,0,1),Y);co(b,b,Q),co(S,S,Q),b[2]*=r,S[2]*=r,b[0]===1&&b[1]===0&&b[2]===0&&S[0]===0&&S[1]===1&&S[2]===0||(h=h||z,f=f||B)}if(z&&(tv(this.text.orientationVertexArray,I,b,S),tv(this.text.orientationVertexArray,A,b,S)),B){const{placedIconSymbolIndex:Z,verticalPlacedIconSymbolIndex:G}=g;Z>=0&&tv(this.icon.orientationVertexArray,M,b,S),G>=0&&tv(this.icon.orientationVertexArray,D,b,S)}}h||(this.text.orientationVertexArray=void 0),f||(this.icon.orientationVertexArray=void 0),t&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const e=(h,f,_)=>{r+=f,r>h.length&&h.resize(r);for(let g=-f;g<0;g++)h.emplace(g+r,_)},t=(h,f,_)=>{c+=f,c>h.length&&h.resize(c);for(let g=-f;g<0;g++)h.emplace(g+c,_)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,c=0;for(let h=0;h<this.symbolInstances.length;h++){const f=this.symbolInstances.get(h),{numHorizontalGlyphVertices:_,numVerticalGlyphVertices:g,numIconVertices:b}=f,S=f.zOffset,I=b>0;if((_>0||g>0)&&(e(this.text.zOffsetVertexArray,_,S),e(this.text.zOffsetVertexArray,g,S)),I){const{placedIconSymbolIndex:A,verticalPlacedIconSymbolIndex:M}=f;A>=0&&t(this.icon.zOffsetVertexArray,b,S),M>=0&&t(this.icon.zOffsetVertexArray,f.numVerticalIconVertices,S)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e,t,r,c,h){!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.hasAppearances),this.hasAppearances===null&&(this.hasAppearances=this.layers.some(f=>f.appearances&&f.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(e,t,r,c,h,f=!1){const _={hasLayoutChanges:!1,hasUboChanges:!1};if(!e||!r||!this.featureAppearanceData)return _;const g=t||{},b=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,S=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!b&&!S)return _;const I=this.layers[0],A=I.layout;this.featureAppearances&&this.featureAppearances.appearancesVersion===I.appearancesVersion||(this.featureAppearances=new a3(I.appearances,I.appearancesVersion));const M=this.featureAppearances.update(c,f);if(M.kind==="no-changes")return _;let D=1,z=0,B=!1,V=!1;if(b){const[te,me]=A.get("icon-size-scale-range");D=q(1,te,me)}let Z=1,G=0,Y=!1;if(S){const[te,me]=A.get("text-size-scale-range");Z=q(1,te,me)}const Q=new Map;if(h&&r)for(const te of r){const me=h.getImage(te,I.scope);if(me){const ce=new Ks(te.toString());Q.set(ce.toString(),me)}}for(let te=0;te<this.symbolInstances.length;te++){const me=this.symbolInstances.get(te),ce=this.getAppearanceFeatureData(me.featureIndex);if(!ce)continue;const pe=ce.id,he=pe!==void 0?g[String(pe)]:void 0,de={type:"Point",id:ce.id,properties:ce.properties,geometry:[]};let Be;if(M.kind==="all-features")Be=M.appearanceIndex;else{const He=I.appearances?I.appearances.findIndex(Xe=>Xe.isActive({globals:c,feature:de,canonical:e,featureState:he})):-1;Be=He>=0?He:-1}const je=ce.activeAppearanceIndex!==Be;if(S){const He=A.get("text-size"),Xe=this.textSizeData.kind==="composite"?this.textSizeData.minZoom:0,Ze=this.textSizeData.kind==="composite"?this.textSizeData.maxZoom:0,nt={canonical:e,layer:I,featureState:he,availableImages:r,textScaleFactor:Z,imageMap:Q,layoutTextOffset:A.get("text-offset").evaluate(de,he,e).map(We=>We*nr),layoutTextSize:He.evaluate(de,he,e),layoutTextRotate:A.get("text-rotate").evaluate(de,he,e),layoutMinZoomSize:He.evaluate(de,{zoom:Xe},e),layoutMaxZoomSize:He.evaluate(de,{zoom:Ze},e),layoutTextSizeMinZoom:Xe,layoutTextSizeMaxZoom:Ze},Fe=this.updateSymbolInstanceTextVertices(me,ce,Be,de,G,nt);G+=Fe.vertexOffsetDelta,Y=Y||Fe.hasChanges}if(b){const He={canonical:e,layer:I,featureState:he,availableImages:r,globalProperties:c,iconScaleFactor:D,layoutIconOffset:A.get("icon-offset").evaluate(de,he,e),layoutIconSize:A.get("icon-size").evaluate(de,he,e,r),layoutIconRotate:A.get("icon-rotate").evaluate(de,he,e)},Xe=this.updateSymbolInstanceIconVertices(me,ce,Be,de,z,He);z+=Xe.vertexOffsetDelta,B=B||Xe.hasChanges}if(je){const He=me.featureIndex,Xe=c?c.brightness:null,Ze=he||{},nt=Be>=0?I.appearances[Be]:null;this.text.uboBinder&&(this.text.uboBinder.layer=I,V=this.text.uboBinder.updateFeaturePaintForAppearance(He,de,Ze,e,r,Xe,nt)||V),this.icon.uboBinder&&(this.icon.uboBinder.layer=I,V=this.icon.uboBinder.updateFeaturePaintForAppearance(He,de,Ze,e,r,Xe,nt)||V)}ce.activeAppearanceIndex=Be}return B&&this.icon.layoutVertexBuffer&&this.icon.layoutVertexArray.arrayBuffer!==null&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),Y&&this.text.layoutVertexBuffer&&this.text.layoutVertexArray.arrayBuffer!==null&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),{hasLayoutChanges:B||Y,hasUboChanges:V}}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=nC(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const r=this.lineVertexArray.length;if(e.segment!==void 0)for(const{x:c,y:h}of t)this.lineVertexArray.emplaceBack(c,h);return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,t,r,c,h,f,_,g,b,S,I,A,M,D,z,B,V,Z){const G=e.indexArray,Y=e.layoutVertexArray,Q=e.globeExtVertexArray,te=Z,me=e.uboBinder?e.uboBinder.getCurrentBatchIndex():void 0,ce=e.segments.prepareSegment(4*te,Y,G,this.canOverlap?f.sortKey:void 0,me),pe=this.glyphOffsetArray.length,he=ce.vertexLength,de=this.allowVerticalPlacement&&_===Os.vertical?Math.PI/2:0,Be=f.text&&f.text.sections;let je=Y.length,He=-1;for(let nt=0;nt<t.length;nt++){const{tl:Fe,tr:We,bl:Qe,br:st,texPrimary:ut,texSecondary:bt,pixelOffsetTL:mt,pixelOffsetBR:pt,minFontScaleX:ht,minFontScaleY:yt,glyphOffset:It,isSDF:kt,sectionIndex:Ct}=t[nt],Qt=ce.vertexLength,vi=It[1];if(C_(Y,b.x,b.y,Fe.x,vi+Fe.y,ut.x,ut.y,r,kt,mt.x,mt.y,ht,yt),C_(Y,b.x,b.y,We.x,vi+We.y,ut.x+ut.w,ut.y,r,kt,pt.x,mt.y,ht,yt),C_(Y,b.x,b.y,Qe.x,vi+Qe.y,ut.x,ut.y+ut.h,r,kt,mt.x,pt.y,ht,yt),C_(Y,b.x,b.y,st.x,vi+st.y,ut.x+ut.w,ut.y+ut.h,r,kt,pt.x,pt.y,ht,yt),g){const{x:ei,y:wi,z:ai}=g.anchor,[gn,Ri,Si]=g.up;M_(Q,ei,wi,ai,gn,Ri,Si),M_(Q,ei,wi,ai,gn,Ri,Si),M_(Q,ei,wi,ai,gn,Ri,Si),M_(Q,ei,wi,ai,gn,Ri,Si),Tf(e.dynamicLayoutVertexArray,ei,wi,ai,de)}else Tf(e.dynamicLayoutVertexArray,b.x,b.y,b.z,de);if(B){const ei=bt||ut;P_(e.iconTransitioningVertexArray,ei.x,ei.y),P_(e.iconTransitioningVertexArray,ei.x+ei.w,ei.y),P_(e.iconTransitioningVertexArray,ei.x,ei.y+ei.h),P_(e.iconTransitioningVertexArray,ei.x+ei.w,ei.y+ei.h)}if(G.emplaceBack(Qt,Qt+1,Qt+2),G.emplaceBack(Qt+1,Qt+2,Qt+3),ce.vertexLength+=4,ce.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(It[0]),(nt===t.length-1||Ct!==t[nt+1].sectionIndex)&&(e.programConfigurations.populatePaintArrays(Y.length,f,f.index,{},M,D,z,Be&&Be[Ct],this.worldview),e.uboBinder&&e.featureIdArray)){const ei=e.uboBinder.populateUBO(f,f.index,D,M,z,Be&&Be[Ct],void 0);He=ei;const wi=Y.length-je;for(let ai=0;ai<wi;ai++)e.featureIdArray.emplaceBack(ei);je=Y.length}}const Xe=Z-t.length;if(Xe!==0&&(this._addNullVertices(Xe,Y,r,g,Q,e,B,ce,G),e.uboBinder&&e.featureIdArray&&He>=0)){const nt=4*Xe;for(let Fe=0;Fe<nt;Fe++)e.featureIdArray.emplaceBack(He)}const Ze=g?g.anchor:b;e.placedSymbolArray.emplaceBack(Ze.x,Ze.y,Ze.z,b.x,b.y,pe,this.glyphOffsetArray.length-pe,he,S,I,b.segment,r?r[0]:0,r?r[1]:0,c[0],c[1],_,0,0,0,A,0),e.symbolInstanceIndices.push(V)}_addNullVertices(e,t,r,c,h,f,_,g,b){for(let S=0;S<e;S++){for(let A=0;A<4;A++)C_(t,0,0,0,0,0,0,r,!1,0,0,0,0),c&&M_(h,0,0,0,0,0,0),Tf(f.dynamicLayoutVertexArray,0,0,0,0),_&&P_(f.iconTransitioningVertexArray,0,0);const I=g.vertexLength;b.emplaceBack(I,I+1,I+2),b.emplaceBack(I+1,I+2,I+3),g.vertexLength+=4,g.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(0)}}_commitLayoutVertex(e,t,r,c,h,f,_){e.emplaceBack(t,r,c,h,f,Math.round(_.x),Math.round(_.y))}_addCollisionDebugVertices(e,t,r,c,h,f,_){const g=r.segments.prepareSegment(4,r.layoutVertexArray,r.indexArray),b=g.vertexLength,S=_.tileAnchorX,I=_.tileAnchorY;for(let M=0;M<4;M++)r.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(r.collisionVertexArrayExt,t,e.padding,_.zOffset),this._commitLayoutVertex(r.layoutVertexArray,c,h,f,S,I,new it(e.x1,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,c,h,f,S,I,new it(e.x2,e.y1)),this._commitLayoutVertex(r.layoutVertexArray,c,h,f,S,I,new it(e.x2,e.y2)),this._commitLayoutVertex(r.layoutVertexArray,c,h,f,S,I,new it(e.x1,e.y2)),g.vertexLength+=4;const A=r.indexArray;A.emplaceBack(b,b+1),A.emplaceBack(b+1,b+2),A.emplaceBack(b+2,b+3),A.emplaceBack(b+3,b),g.primitiveLength+=4}_addTextDebugCollisionBoxes(e,t,r,c,h,f){for(let _=c;_<h;_++){const g=r.get(_),b=this.getSymbolInstanceTextSize(e,f,t,_);this._addCollisionDebugVertices(g,b,this.textCollisionBox,g.projectedAnchorX,g.projectedAnchorY,g.projectedAnchorZ,f)}}_addIconDebugCollisionBoxes(e,t,r,c,h,f){for(let _=c;_<h;_++){const g=r.get(_),b=this.getSymbolInstanceIconSize(e,t,f.placedIconSymbolIndex);this._addCollisionDebugVertices(g,b,this.iconCollisionBox,g.projectedAnchorX,g.projectedAnchorY,g.projectedAnchorZ,f)}}generateCollisionDebugBuffers(e,t,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new iw(ph,mA.members,eo),this.iconCollisionBox=new iw(ph,mA.members,eo);const c=vf(this.iconSizeData,e),h=vf(this.textSizeData,e,r);for(let f=0;f<this.symbolInstances.length;f++){const _=this.symbolInstances.get(f);this._addTextDebugCollisionBoxes(h,e,t,_.textBoxStartIndex,_.textBoxEndIndex,_),this._addTextDebugCollisionBoxes(h,e,t,_.verticalTextBoxStartIndex,_.verticalTextBoxEndIndex,_),this._addIconDebugCollisionBoxes(c,e,t,_.iconBoxStartIndex,_.iconBoxEndIndex,_),this._addIconDebugCollisionBoxes(c,e,t,_.verticalIconBoxStartIndex,_.verticalIconBoxEndIndex,_)}}getSymbolInstanceTextSize(e,t,r,c){const h=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:c),f=Gb(this.textSizeData,e,h)/nr;return this.tilePixelRatio*f}getSymbolInstanceIconSize(e,t,r){const c=this.icon.placedSymbolArray.get(r),h=Gb(this.iconSizeData,e,c);return this.tilePixelRatio*h}_commitDebugCollisionVertexUpdate(e,t,r,c){e.emplaceBack(t,-r,-r,c),e.emplaceBack(t,r,-r,c),e.emplaceBack(t,r,r,c),e.emplaceBack(t,-r,r,c)}_updateTextDebugCollisionBoxes(e,t,r,c,h,f,_){for(let g=c;g<h;g++){const b=r.get(g),S=this.getSymbolInstanceTextSize(e,f,t,g);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,S,b.padding,f.zOffset)}}_updateIconDebugCollisionBoxes(e,t,r,c,h,f,_){for(let g=c;g<h;g++){const b=r.get(g),S=this.getSymbolInstanceIconSize(e,t,f.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,S,b.padding,f.zOffset)}}updateCollisionDebugBuffers(e,t,r,c){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const h=vf(this.iconSizeData,e,c),f=vf(this.textSizeData,e,r);for(let _=0;_<this.symbolInstances.length;_++){const g=this.symbolInstances.get(_);this._updateTextDebugCollisionBoxes(f,e,t,g.textBoxStartIndex,g.textBoxEndIndex,g,r),this._updateTextDebugCollisionBoxes(f,e,t,g.verticalTextBoxStartIndex,g.verticalTextBoxEndIndex,g,r),this._updateIconDebugCollisionBoxes(h,e,t,g.iconBoxStartIndex,g.iconBoxEndIndex,g,c),this._updateIconDebugCollisionBoxes(h,e,t,g.verticalIconBoxStartIndex,g.verticalIconBoxEndIndex,g,c)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,t,r,c,h,f,_,g,b){const S={};if(t<r){const{x1:I,y1:A,x2:M,y2:D,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:Z,tileAnchorX:G,tileAnchorY:Y,featureIndex:Q}=e.get(t);S.textBox={x1:I,y1:A,x2:M,y2:D,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:Z,tileAnchorX:G,tileAnchorY:Y},S.textFeatureIndex=Q}if(c<h){const{x1:I,y1:A,x2:M,y2:D,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:Z,tileAnchorX:G,tileAnchorY:Y,featureIndex:Q}=e.get(c);S.verticalTextBox={x1:I,y1:A,x2:M,y2:D,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:Z,tileAnchorX:G,tileAnchorY:Y},S.verticalTextFeatureIndex=Q}if(f<_){const{x1:I,y1:A,x2:M,y2:D,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:Z,tileAnchorX:G,tileAnchorY:Y,featureIndex:Q}=e.get(f);S.iconBox={x1:I,y1:A,x2:M,y2:D,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:Z,tileAnchorX:G,tileAnchorY:Y},S.iconFeatureIndex=Q}if(g<b){const{x1:I,y1:A,x2:M,y2:D,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:Z,tileAnchorX:G,tileAnchorY:Y,featureIndex:Q}=e.get(g);S.verticalIconBox={x1:I,y1:A,x2:M,y2:D,padding:z,projectedAnchorX:B,projectedAnchorY:V,projectedAnchorZ:Z,tileAnchorX:G,tileAnchorY:Y},S.verticalIconFeatureIndex=Q}return S}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const r=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const r=e.placedSymbolArray.get(t),c=r.vertexStartIndex+4*r.numGlyphs;for(let h=r.vertexStartIndex;h<c;h+=4)e.indexArray.emplaceBack(h,h+1,h+2),e.indexArray.emplaceBack(h+1,h+2,h+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const t=Math.sin(e),r=Math.cos(e),c=[],h=[],f=[];for(let _=0;_<this.symbolInstances.length;++_){f.push(_);const g=this.symbolInstances.get(_);c.push(0|Math.round(t*g.tileAnchorX+r*g.tileAnchorY)),h.push(g.featureIndex)}return f.sort((_,g)=>c[_]-c[g]||h[g]-h[_]),f}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;e<this.symbolInstances.length;++e)this.symbolInstanceIndexesSortedZOffset.push(e)}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort((e,t)=>this.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,t){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===t?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesWithinSegments();else{this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const r=this.symbolInstances.get(t);this.featureSortOrder.push(r.featureIndex);const{rightJustifiedTextSymbolIndex:c,centerJustifiedTextSymbolIndex:h,leftJustifiedTextSymbolIndex:f,verticalPlacedTextSymbolIndex:_,placedIconSymbolIndex:g,verticalPlacedIconSymbolIndex:b}=r;c>=0&&this.addIndicesForPlacedSymbol(this.text,c),h>=0&&h!==c&&this.addIndicesForPlacedSymbol(this.text,h),f>=0&&f!==h&&f!==c&&this.addIndicesForPlacedSymbol(this.text,f),_>=0&&this.addIndicesForPlacedSymbol(this.text,_),g>=0&&this.addIndicesForPlacedSymbol(this.icon,g),b>=0&&this.addIndicesForPlacedSymbol(this.icon,b)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getOrCreateSortedSymbolsByBatch(e,t){const r=(this.text.uboBinder&&this.text.uboBinder.maxFeaturesPerBatch>0?this.text.uboBinder:this.icon.uboBinder&&this.icon.uboBinder.maxFeaturesPerBatch>0?this.icon.uboBinder:null).maxFeaturesPerBatch;if(this.symbolsByBatch)for(const c of this.symbolsByBatch.values())for(const h of c){const f=this.symbolInstances.get(h.index);h.rotatedY=0|Math.round(e*f.tileAnchorX+t*f.tileAnchorY)}else{this.symbolsByBatch=new Map;for(let c=0;c<this.symbolInstances.length;c++){const h=this.symbolInstances.get(c),f=Math.floor(c/r),_=0|Math.round(e*h.tileAnchorX+t*h.tileAnchorY);this.symbolsByBatch.has(f)||this.symbolsByBatch.set(f,[]),this.symbolsByBatch.get(f).push({index:c,rotatedY:_,featureIndex:h.featureIndex})}}for(const c of this.symbolsByBatch.values())c.sort((h,f)=>h.rotatedY-f.rotatedY||f.featureIndex-h.featureIndex);return this.symbolsByBatch}rebuildTextSegmentIndices(e,t){for(const r of e){const c=r.batchIndex;if(c===void 0)continue;const h=t.get(c);if(!h){r.primitiveOffset=this.text.indexArray.length,r.primitiveLength=0;continue}r.primitiveOffset=this.text.indexArray.length;const f=this.text.indexArray.length;for(const{index:_}of h){const g=this.symbolInstances.get(_),{rightJustifiedTextSymbolIndex:b,centerJustifiedTextSymbolIndex:S,leftJustifiedTextSymbolIndex:I,verticalPlacedTextSymbolIndex:A}=g;b>=0&&this.addIndicesForPlacedSymbol(this.text,b),S>=0&&S!==b&&this.addIndicesForPlacedSymbol(this.text,S),I>=0&&I!==S&&I!==b&&this.addIndicesForPlacedSymbol(this.text,I),A>=0&&this.addIndicesForPlacedSymbol(this.text,A)}r.primitiveLength=this.text.indexArray.length-f}}rebuildIconSegmentIndices(e,t){for(const r of e){const c=r.batchIndex;if(c===void 0)continue;const h=t.get(c);if(!h){r.primitiveOffset=this.icon.indexArray.length,r.primitiveLength=0;continue}r.primitiveOffset=this.icon.indexArray.length;const f=this.icon.indexArray.length;for(const{index:_}of h){const g=this.symbolInstances.get(_),{placedIconSymbolIndex:b,verticalPlacedIconSymbolIndex:S}=g;b>=0&&this.addIndicesForPlacedSymbol(this.icon,b),S>=0&&this.addIndicesForPlacedSymbol(this.icon,S)}r.primitiveLength=this.icon.indexArray.length-f}}sortFeaturesWithinSegments(){this.featureSortOrder=[];const e=Math.sin(this.sortedAngle),t=Math.cos(this.sortedAngle),r=this.getOrCreateSortedSymbolsByBatch(e,t),c=Array.from(r.keys()).sort((h,f)=>h-f);for(const h of c){const f=r.get(h);for(const{index:_}of f){const g=this.symbolInstances.get(_);this.featureSortOrder.push(g.featureIndex)}}this.text.indexArray.clear(),this.icon.indexArray.clear(),this.rebuildTextSegmentIndices(this.text.segments.get(),r),this.rebuildIconSegmentIndices(this.icon.segments.get(),r),this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}getElevationFeatureForText(e){const t=this.symbolInstances.get(this.text.symbolInstanceIndices[e]).elevationFeatureIndex;let r;return this.elevationFeatures&&t<this.elevationFeatures.length&&(r=this.elevationFeatures[t]),r}}function rC(n,e){return e.replace(/{([^{}]+)}/g,(t,r)=>r in n?String(n[r]):"")}let sC,oC,nw;wt(va,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),va.addDynamicAttributes=Tf;class aC{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:la,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}}wt(aC,"FormatSectionOverride",{omit:["defaultValue"]});const rw=()=>nw||(nw={layout:sC||(sC=new on({"symbol-placement":new dt(Ee.layout_symbol["symbol-placement"]),"symbol-spacing":new dt(Ee.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new dt(Ee.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new at(Ee.layout_symbol["symbol-sort-key"]),"symbol-z-order":new dt(Ee.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new dt(Ee.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new dt(Ee.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new dt(Ee.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new dt(Ee.layout_symbol["icon-ignore-placement"]),"icon-optional":new dt(Ee.layout_symbol["icon-optional"]),"icon-rotation-alignment":new dt(Ee.layout_symbol["icon-rotation-alignment"]),"icon-size":new at(Ee.layout_symbol["icon-size"]),"icon-size-scale-range":new dt(Ee.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new at(Ee.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new at(Ee.layout_symbol["icon-text-fit-padding"]),"icon-image":new at(Ee.layout_symbol["icon-image"]),"icon-image-use-theme":new dt({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new at(Ee.layout_symbol["icon-rotate"]),"icon-padding":new dt(Ee.layout_symbol["icon-padding"]),"icon-keep-upright":new dt(Ee.layout_symbol["icon-keep-upright"]),"icon-offset":new at(Ee.layout_symbol["icon-offset"]),"icon-anchor":new at(Ee.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new dt(Ee.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new dt(Ee.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new dt(Ee.layout_symbol["text-rotation-alignment"]),"text-field":new at(Ee.layout_symbol["text-field"]),"text-font":new at(Ee.layout_symbol["text-font"]),"text-size":new at(Ee.layout_symbol["text-size"]),"text-size-scale-range":new dt(Ee.layout_symbol["text-size-scale-range"]),"text-max-width":new at(Ee.layout_symbol["text-max-width"]),"text-line-height":new at(Ee.layout_symbol["text-line-height"]),"text-letter-spacing":new at(Ee.layout_symbol["text-letter-spacing"]),"text-justify":new at(Ee.layout_symbol["text-justify"]),"text-radial-offset":new at(Ee.layout_symbol["text-radial-offset"]),"text-variable-anchor":new dt(Ee.layout_symbol["text-variable-anchor"]),"text-anchor":new at(Ee.layout_symbol["text-anchor"]),"text-max-angle":new dt(Ee.layout_symbol["text-max-angle"]),"text-writing-mode":new dt(Ee.layout_symbol["text-writing-mode"]),"text-rotate":new at(Ee.layout_symbol["text-rotate"]),"text-padding":new dt(Ee.layout_symbol["text-padding"]),"text-keep-upright":new dt(Ee.layout_symbol["text-keep-upright"]),"text-transform":new at(Ee.layout_symbol["text-transform"]),"text-offset":new at(Ee.layout_symbol["text-offset"]),"text-allow-overlap":new dt(Ee.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new dt(Ee.layout_symbol["text-ignore-placement"]),"text-optional":new dt(Ee.layout_symbol["text-optional"]),visibility:new dt(Ee.layout_symbol.visibility)})),paint:oC||(oC=new on({"icon-opacity":new at(Ee.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new at(Ee.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new at(Ee.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new at(Ee.paint_symbol["text-emissive-strength"]),"icon-color":new at(Ee.paint_symbol["icon-color"]),"icon-halo-color":new at(Ee.paint_symbol["icon-halo-color"]),"icon-halo-width":new at(Ee.paint_symbol["icon-halo-width"]),"icon-halo-blur":new at(Ee.paint_symbol["icon-halo-blur"]),"icon-translate":new dt(Ee.paint_symbol["icon-translate"]),"icon-translate-anchor":new dt(Ee.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new dt(Ee.paint_symbol["icon-image-cross-fade"]),"text-opacity":new at(Ee.paint_symbol["text-opacity"]),"text-occlusion-opacity":new at(Ee.paint_symbol["text-occlusion-opacity"]),"text-color":new at(Ee.paint_symbol["text-color"],{runtimeType:Wr,getOverride:n=>n.textColor,hasOverride:n=>!!n.textColor}),"text-halo-color":new at(Ee.paint_symbol["text-halo-color"]),"text-halo-width":new at(Ee.paint_symbol["text-halo-width"]),"text-halo-blur":new at(Ee.paint_symbol["text-halo-blur"]),"text-translate":new dt(Ee.paint_symbol["text-translate"]),"text-translate-anchor":new dt(Ee.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new dt(Ee.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new dt(Ee.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new dt(Ee.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new dt(Ee.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new at(Ee.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},nw);class iv extends jr{constructor(e,t,r,c){super(e,rw(),t,r,c,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=Ye([]),this.hasOcclusionOpacityProperties=e.paint!==void 0&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}_handleSpecialPaintPropertyUpdate(e){e!=="icon-occlusion-opacity"&&e!=="text-occlusion-opacity"||(this.hasOcclusionOpacityProperties=!0)}recalculate(e,t){super.recalculate(e,t),this.appearances&&this.appearances.forEach(c=>{c.recalculate(e,t,this.iconImageUseTheme)}),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const r=this.layout.get("text-writing-mode");if(r){const c=[];for(const h of r)c.indexOf(h)<0&&c.push(h);this.layout._values["text-writing-mode"]=c}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(e,t,r,c){return this._saturation===e&&this._contrast===t&&this._brightnessMin===r&&this._brightnessMax===c||(this._colorAdjustmentMatrix=function(h,f,_,g){h=un(h),f=Xi(f);const b=Ve(),S=h/3,I=1-2*S,A=[I,S,S,0,S,I,S,0,S,S,I,0,0,0,0,1],M=.5-.5*f,D=g-_;return ye(b,[D,0,0,0,0,D,0,0,0,0,D,0,_,_,_,1],[f,0,0,0,0,f,0,0,0,0,f,0,M,M,M,1]),ye(b,b,A),b}(e,t,r,c),this._saturation=e,this._contrast=t,this._brightnessMin=r,this._brightnessMax=c),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,r,c){const h=this.layout.get(e).evaluate(t,{},r,c),f=this._unevaluatedLayout._values[e];return f.isDataDriven()||nh(f.value)||!h?h:rC(t.properties,h)}getAppearanceValueAndResolveTokens(e,t,r,c,h){const f=e.getLayoutProperty(t);if(!f)return;const _=f.evaluate(r,{},c,h),g=e.getUnevaluatedLayoutProperties()._values[t];return g.isDataDriven()||nh(g.value)||!_||typeof _!="string"?_:rC(r.properties,_)}createBucket(e){return new va(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of rw().paint.overridableProperties){if(!iv.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),r=new aC(t),c=new Bd(r,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let h=null;h=t.value.kind==="constant"||t.value.kind==="source"?new zc("source",c):new Pl("composite",c,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new Ll(t.property,h,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,r){return!(!this.layout||t.isDataDriven()||r.isDataDriven())&&iv.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const r=e.get("text-field"),c=rw().paint.properties[t];let h=!1;const f=_=>{for(const g of _)if(c.overrides&&c.overrides.hasOverride(g))return void(h=!0)};if(r.value.kind==="constant"&&r.value.value instanceof Lr)f(r.value.value.sections);else if(r.value.kind==="source"){const _=b=>{h||(b instanceof At&&Pn(b.value)===Lu?f(b.value.sections):b instanceof wl?f(b.sections):b.eachChild(_))},g=r.value;g._styleExpression&&_(g._styleExpression.expression)}return h}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,t,r){return{config:new k(this,{zoom:t,lut:r}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let lC,cC,uC,hC;var nv=pi([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Uint16",components:2}]);function rv(n,e,t,r,c,h,f,_){const g=[n,e,1,t,r,1,c,h,1],b=[f,_,1],S=ue([],g),[I,A,M]=Mo(b,b,S);return Me(g,g,[I,0,0,0,A,0,0,0,M])}function dC(n,e,t,r,c,h,f,_){const g=function(b,S,I,A,M,D,z,B){const V=rv(0,0,1,0,1,1,0,1),Z=rv(b,S,I,A,M,D,z,B);return Me(Z,Z,ue([],V))}(n,e,t,r,c,h,f,_);return[g[2]/g[8]/_t,g[5]/g[8]/_t]}function sv(n){return[n[0],Math.min(Math.max(n[1],-85.051129),$e)]}class fC extends Du{constructor(e,t,r,c){super(),this.id=e,this.dispatcher=r,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(c),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new ho("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=yc(this.map._requestManager.transformRequest(this.url,Mu.Image),(r,c)=>{this._imageRequest=null,this._loaded=!0,r?this.fire(new xc(r)):c&&(this.image=c,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 m_(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 ho("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof m_||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],r=e[0][1];for(const h of e)h[1]>r&&(r=h[1]),h[1]<t&&(t=h[1]);const c=(r+t)/2;if(c>$e?this.onNorthPole=!0:c<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const h=e.map(Et.fromLngLat);this.tileID=function(f){let _=1/0,g=1/0,b=-1/0,S=-1/0;for(const z of f)_=Math.min(_,z.x),g=Math.min(g,z.y),b=Math.max(b,z.x),S=Math.max(S,z.y);const I=Math.max(b-_,S-g),A=Math.max(0,Math.floor(-Math.log2(I))),M=Math.pow(2,A);let D=Math.floor((_+b)/2*M);return D>1&&(D-=1),new Th(A,D,Math.floor((g+S)/2*M))}(h),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new ho("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof m_||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const B in this.tiles){const V=this.tiles[B];V.state!=="loaded"&&(V.state="loaded",V.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const t=Mh(new Th(0,0,0),this.map.transform.projection),r=[t.projection.project(this.coordinates[0][0],this.coordinates[0][1]),t.projection.project(this.coordinates[1][0],this.coordinates[1][1]),t.projection.project(this.coordinates[2][0],this.coordinates[2][1]),t.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(B){const V=B[1].x-B[0].x,Z=B[1].y-B[0].y,G=B[2].x-B[1].x,Y=B[2].y-B[1].y,Q=B[3].x-B[2].x,te=B[3].y-B[2].y,me=B[0].x-B[3].x,ce=B[0].y-B[3].y,pe=V*Y-G*Z,he=G*te-Q*Y,de=Q*ce-me*te,Be=me*Z-V*ce;return pe>0&&he>0&&de>0&&Be>0||pe<0&&he<0&&de<0&&Be<0}(r))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const c=Mh(this.tileID,this.map.transform.projection),[h,f,_,g]=this.coordinates.map(B=>{const V=c.projection.project(B[0],B[1]);return JA(c,V)._round()});this.perspectiveTransform=dC(h.x,h.y,f.x,f.y,_.x,_.y,g.x,g.y);const b=this._boundsArray=new Sr;b.emplaceBack(h.x,h.y,0,0),b.emplaceBack(f.x,f.y,_t,0),b.emplaceBack(g.x,g.y,0,_t),b.emplaceBack(_.x,_.y,_t,_t),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(b,nv.members),this.boundsSegments=$i.simpleSegment(0,0,4,2);const S=[],I=function(B){return[sv(B[0]),sv(B[1]),sv(B[2]),sv(B[3])]}(this.coordinates),[A,M,D,z]=function(B){let V=B[0][0],Z=V,G=B[0][1],Y=G;for(let Q=1;Q<B.length;Q++)B[Q][0]<V?V=B[Q][0]:B[Q][0]>Z&&(Z=B[Q][0]),B[Q][1]<G?G=B[Q][1]:B[Q][1]>Y&&(Y=B[Q][1]);return[V,G,Z-V,Y-G]}(I);{const B=new Sr,[V,Z,G,Y]=function(Ze){let nt=Ze[0].x,Fe=nt,We=Ze[0].y,Qe=We;for(let st=1;st<Ze.length;st++)Ze[st].x<nt?nt=Ze[st].x:Ze[st].x>Fe&&(Fe=Ze[st].x),Ze[st].y<We?We=Ze[st].y:Ze[st].y>Qe&&(Qe=Ze[st].y);return[nt,We,Fe-nt,Qe-We]}(r),Q=Ze=>[(Ze.x-V)/G,(Ze.y-Z)/Y],[te,me,ce,pe]=r.map(Q),he=function(Ze,nt,Fe,We,Qe,st,ut,bt){const mt=rv(0,0,1,0,1,1,0,1);return Me(mt,mt,ue([],rv(Ze,nt,Fe,We,Qe,st,ut,bt)))}(te[0],te[1],me[0],me[1],ce[0],ce[1],pe[0],pe[1]);this.elevatedGlobePerspectiveTransform=dC(te[0],te[1],me[0],me[1],ce[0],ce[1],pe[0],pe[1]);const de=(Ze,nt)=>{S.push(Ze.lng);const Fe=Math.round((Ze.lng-A)/D*_t),We=Math.round((Ze.lat-M)/z*_t),Qe=Q(nt),st=Mo([],[Qe[0],Qe[1],1],he),ut=Math.round(st[0]/st[2]*_t),bt=Math.round(st[1]/st[2]*_t);B.emplaceBack(Fe,We,ut,bt)},Be=r[3].x-r[0].x,je=r[3].y-r[0].y,He=r[2].x-r[1].x,Xe=r[2].y-r[1].y;for(let Ze=0;Ze<65;Ze++){const nt=Ze/64,Fe=[r[0].x+nt*Be,r[0].y+nt*je],We=[r[1].x+nt*He,r[1].y+nt*Xe],Qe=We[0]-Fe[0],st=We[1]-Fe[1];for(let ut=0;ut<65;ut++){const bt=ut/64,mt={x:Fe[0]+Qe*bt,y:Fe[1]+st*bt};de(t.projection.unproject(mt.x,mt.y),mt)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(B,nv.members)}{this.maxLongitudeTriangleSize=0;let B=[],V=new Tn;const Z=(G,Y,Q)=>{V.emplaceBack(G,Y,Q);const te=S[G],me=S[Y],ce=S[Q],pe=Math.min(Math.min(te,me),ce),he=Math.max(Math.max(te,me),ce)-pe;he>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=he),B.push(pe+he/2)};for(let G=0;G<64;G++)for(let Y=0;Y<64;Y++){const Q=65*G+Y,te=Q+1,me=Q+65,ce=me+1;Z(Q,me,te),Z(te,me,ce)}[B,V]=function(G,Y){const Q=Array.from({length:G.length},(ce,pe)=>pe);Q.sort((ce,pe)=>G[ce]-G[pe]);const te=[],me=new Tn;for(let ce=0;ce<Q.length;ce++){const pe=Q[ce];te.push(G[pe]);const he=3*pe,de=he+1;me.emplaceBack(Y.uint16[he],Y.uint16[de],Y.uint16[de+1])}return[te,me]}(B,V),this.elevatedGlobeTrianglesCenterLongitudes=B,this.elevatedGlobeIndexBuffer=e.createIndexBuffer(V)}this.elevatedGlobeSegments=$i.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,D/_t,0,z/_t,0,0,M,A,0])}prepare(){const e=Object.keys(this.tiles).length!==0;if(this.tileID&&!e)return;const t=this.map.painter.context,r=t.gl;!this._dirty||this.texture instanceof m_||(this.texture?this.texture.update(this.image):(this.texture=new tl(t,this.image,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(t)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}getSegmentsForLongitude(e){const t=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!t)return null;const r=this.elevatedGlobeTrianglesCenterLongitudes;let c=(h=e+180)+360*Math.round((r[0]-h)/360);var h;const f=new $i,_=(I,A)=>{f.segments.push({vertexOffset:0,primitiveOffset:I,vertexLength:t.segments[0].vertexLength,primitiveLength:A,sortKey:void 0,vaos:{}})},g=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-c)<=g){const I=jn(r,0,r.length,c+g);return I===r.length||_(I,cn(r,I+1,r.length,c+360-g)-I),f}c<r[0]&&(c+=360);const b=cn(r,0,r.length,c-g);if(b===r.length)return _(0,r.length),f;_(0,b-0);const S=jn(r,b+1,r.length,c+g);return S!==r.length&&_(S,r.length-S),f}}const sw=1024,h3=(Math.pow(sw,2)-1)/268170240;class pC extends jr{constructor(e,t,r,c){super(e,{layout:uC||(uC=new on({visibility:new dt(Ee.layout_raster.visibility)})),paint:hC||(hC=new on({"raster-opacity":new dt(Ee.paint_raster["raster-opacity"]),"raster-color":new Bc(Ee.paint_raster["raster-color"]),"raster-color-mix":new dt(Ee.paint_raster["raster-color-mix"]),"raster-color-range":new dt(Ee.paint_raster["raster-color-range"]),"raster-hue-rotate":new dt(Ee.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new dt(Ee.paint_raster["raster-brightness-min"]),"raster-brightness-max":new dt(Ee.paint_raster["raster-brightness-max"]),"raster-saturation":new dt(Ee.paint_raster["raster-saturation"]),"raster-contrast":new dt(Ee.paint_raster["raster-contrast"]),"raster-resampling":new dt(Ee.paint_raster["raster-resampling"]),"raster-fade-duration":new dt(Ee.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new dt(Ee.paint_raster["raster-emissive-strength"]),"raster-array-band":new dt(Ee.paint_raster["raster-array-band"]),"raster-elevation":new dt(Ee.paint_raster["raster-elevation"]),"raster-elevation-reference":new dt(Ee.paint_raster["raster-elevation-reference"]),"raster-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},t,r,c),this.updateColorRamp(),this._curRampRange=[NaN,NaN]}getProgramIds(){return["raster"]}hasColorMap(){return!!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isDraped(e){return!(e&&e._source instanceof fC&&(e._source.onNorthPole||e._source.onSouthPole))&&this.paint.get("raster-elevation")===0}_handleSpecialPaintPropertyUpdate(e){e!=="raster-color"&&e!=="raster-color-range"||(this._curRampRange=[NaN,NaN],this.updateColorRamp())}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}updateColorRamp(e){if(!this.hasColorMap()||!this._curRampRange)return;const t=this._transitionablePaint._values["raster-color"].value.expression,[r,c]=e||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(r)&&isNaN(c)||r===this._curRampRange[0]&&c===this._curRampRange[1]||(this.colorRamp=e_({expression:t,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:r,end:c}],resolution:sw}),this.colorRampTexture=null,this._curRampRange=[r,c])}is3D(e){return this.paint.get("raster-elevation")>0}}let mC,_C,gC,yC,xC,vC,bC;class wC extends jr{constructor(e,t,r,c){super(e,{layout:mC||(mC=new on({visibility:new dt(Ee["layout_raster-particle"].visibility)})),paint:_C||(_C=new on({"raster-particle-array-band":new dt(Ee["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new dt(Ee["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new Bc(Ee["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new dt(Ee["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new dt(Ee["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new dt(Ee["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new dt(Ee["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new dt(Ee["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},t,r,c),this._updateColorRamp(),this.lastInvalidatedAt=ts.now()}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null)}onRemove(e){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy()}hasColorMap(){return!!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return["rasterParticle"]}hasOffscreenPass(){return this.visibility!=="none"}isDraped(e){return!1}_handleSpecialPaintPropertyUpdate(e){e!=="raster-particle-color"&&e!=="raster-particle-max-speed"||(this._updateColorRamp(),this._invalidateAnimationState()),e==="raster-particle-count"&&this._invalidateAnimationState()}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,t=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=e_({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:t}],resolution:256}),this.colorRampTexture=null}_invalidateAnimationState(){this.lastInvalidatedAt=ts.now()}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class d3 extends jr{constructor(e,t){super(e,{},t,null),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(e){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isDraped(e){return this.implementation.renderToTile!==void 0}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}function ow(n,e,t){const r=[0,0,1],c=aa([]);return hc(c,c,t?-Ei(n)+Math.PI:Ei(n)),uc(c,c,-Ei(e)),co(r,r,c),zi(r,r)}class ov{constructor(e,t,r,c){this.message=(e?`${e}: `:"")+r,c&&(this.identifier=c),t!=null&&t.__line__&&(this.line=t.__line__)}}function aw(n,e){const t=n.indexOf("://")===-1;try{return new URL(n,t&&e?"http://example.com":void 0),!0}catch{return!1}}class TC{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 SC{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new Hm,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}colorForInstance(e){const t=16*e,r=this.instancedDataArray.float32;let c=Math.floor(r[t+2]);const h=1.05*(r[t+2]-c);return c/=100,[r[t]%1*1.05,r[t+1]%1*1.05,h,c]}tileCoordinatesForInstance(e){const t=16*e,r=this.instancedDataArray.float32;let c=r[t+0];return c=c>_t?c-_t:c,new it(Math.trunc(c),Math.trunc(r[t+1]))}translationForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return[r[t+4],r[t+5],r[t+6]]}rotationScaleForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return[r[t+7],r[t+8],r[t+9],r[t+10],r[t+11],r[t+12],r[t+13],r[t+14],r[t+15]]}transformForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return[r[t+7],r[t+8],r[t+9],r[t+4],r[t+10],r[t+11],r[t+12],r[t+5],r[t+13],r[t+14],r[t+15],r[t+6],0,0,0,1]}}class lw{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(t=>t.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(t=>t.isStateDependent()).map(t=>t.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+1?0: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,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,r,c){return{hasLayoutChanges:!1,hasUboChanges:!1}}populate(e,t,r,c){this.tileToMeter=et(r);const h=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const f=this.layers[0].paint.get("model-elevation-reference")==="hd-road-markup"?t.elevationFeatures:void 0;for(const{feature:_,id:g,index:b,sourceLayerIndex:S}of e){const I=g??(_.properties&&_.properties.hasOwnProperty("id")?_.properties.id:void 0),A=oi(_,h);if(!this.layers[0]._featureFilter.filter(new Mi(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),A,r))continue;const M={id:I,sourceLayerIndex:S,index:b,geometry:h?A.geometry:Ft(_,r,c),properties:_.properties,type:_.type,patterns:{}},D=this.addFeature(M,M.geometry,A,f,r);D&&t.featureIndex.insert(_,M.geometry,b,S,this.index,this.instancesPerModel[D].instancedDataArray.length,256)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let r=0;for(const c of this.modelUris){const h=e.getModel(c,t);if(!h)continue;const f=this.instancesPerModel[c];if(f){const _=.5*ln(h.aabb.max,h.aabb.min)*f.maxScale+f.maxXYTranslationDistance,g=Math.min(_t,Math.max(_/this.tileToMeter,256));r=Math.max(g,r)}}return r}update(e,t,r,c){for(const h in this.instancesPerModel){const f=this.instancesPerModel[h];for(const _ in e)f.idToFeaturesIndex.hasOwnProperty(_)&&(this.evaluate(f.features[f.idToFeaturesIndex[_]],e[_],f,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];for(const c of r.features){const h=this.layers[0],f=c.feature,_=this.canonical,g=h.paint.get("model-rotation").evaluate(f,{},_),b=h.paint.get("model-scale").evaluate(f,{},_),S=h.paint.get("model-translation").evaluate(f,{},_);Hs(c.rotation,g)&&Hs(c.scale,b)&&Hs(c.translation,S)||(this.evaluate(c,c.featureStates,r,!0),e=!0)}}return e}updateReplacement(e,t,r,c){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const h=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(Ex(this.activeReplacements,h))return!1;this.activeReplacements=h;let f=!1;for(const _ in this.instancesPerModel){const g=this.instancesPerModel[_],b=g.instancedDataArray;for(const S of g.features){const I=S.instancedDataOffset,A=S.instancedDataCount;for(let M=0;M<A;M++){const D=16*(M+I);let z=b.float32[D+0];const B=z>_t;z=B?z-_t:z;const V=Math.floor(z),Z=Math.floor(b.float32[D+1]);let G=!1;for(const Y of this.activeReplacements)if(!sI(Y,r,Ix.Model,c)&&!(Y.min.x>V||V>Y.max.x||Y.min.y>Z||Z>Y.max.y)&&(G=uI(cI(V,Z,e.canonical,Y.footprintTileId.canonical),Y.footprint),G))break;b.float32[D]=G?z+_t:z,f=f||G!==B}}}return f}isEmpty(){for(const e in this.instancesPerModel)if(this.instancesPerModel[e].instancedDataArray.length!==0)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];r.instancedDataArray.length<0||r.instancedDataArray.length===0||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=e.createVertexBuffer(r.instancedDataArray,RO.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(e){for(const r in this.instancesPerModel){const c=this.instancesPerModel[r];c.instancedDataArray.length!==0&&c.instancedDataBuffer&&c.instancedDataBuffer.destroy()}const t=this.layers[0].modelManager;if(e&&t&&this.modelUris&&this.modelsRequested)for(const r of this.modelUris)t.removeModel(r,"",!0)}addFeature(e,t,r,c,h){const f=this.layers[0],_=f.layout.get("model-id"),g=f.layout.get("model-allow-density-reduction"),b=_.evaluate(r,{},this.canonical);if(!b)return zt(`modelId is not evaluated for layer ${f.id} and it is not going to get rendered.`),b;(aw(b,!1)||this.styleDefinedModelURLs[b]!==void 0)&&(this.modelUris.includes(b)||this.modelUris.push(b)),this.instancesPerModel[b]||(this.instancesPerModel[b]=new SC);const S=this.instancesPerModel[b],I=S.instancedDataArray,A=new TC(r,I.length);let M;c&&(M=Yi.getElevationFeature(e,c));for(const D of t)for(const z of D){if(z.x<0||z.x>=_t||z.y<0||z.y>=_t)continue;if(this.lookupDim!==0&&g){const V=(this.lookupDim-1)/_t,Z=this.lookupDim*(z.y*V|0)+z.x*V|0;if(this.lookup){if(this.lookup[Z]!==0)continue;this.lookup[Z]=1}}this.instanceCount++;const B=I.length;if(I.resize(B+1),c){S.instancesRoadElevation||(S.instancesRoadElevation=[]);const V=M?M.pointElevation(new it(z.x,z.y)):0;S.instancesRoadElevation.push(V)}S.instancesEvaluatedElevation.push(0),I.float32[16*B]=z.x,I.float32[16*B+1]=z.y}return A.instancedDataCount=S.instancedDataArray.length-A.instancedDataOffset,A.instancedDataCount>0&&(e.id&&(S.idToFeaturesIndex[e.id]=S.features.length),S.features.push(A),this.evaluate(A,{},S,!1)),b}getModelUris(){return this.modelUris}evaluate(e,t,r,c){const h=this.layers[0],f=e.feature,_=this.canonical,g=e.rotation=h.paint.get("model-rotation").evaluate(f,t,_),b=e.scale=h.paint.get("model-scale").evaluate(f,t,_),S=e.translation=h.paint.get("model-translation").evaluate(f,t,_),I=Object.assign({},h.paint.get("model-color").evaluate(f,t,_));I.a=h.paint.get("model-color-mix-intensity").evaluate(f,t,_);const A=[];this.maxVerticalOffset<S[2]&&(this.maxVerticalOffset=S[2]);const M=S[0]*S[0]+S[1]*S[1],D=M>0?Math.sqrt(M):0;r.maxScale=Math.max(Math.max(r.maxScale,b[0]),Math.max(b[1],b[2])),r.maxXYTranslationDistance=Math.max(r.maxXYTranslationDistance,D),this.maxScale=Math.max(Math.max(this.maxScale,b[0]),Math.max(b[1],b[2])),WI(A,g,b);const z=Math.round(100*I.a)+I.b/1.05;for(let B=0;B<e.instancedDataCount;++B){const V=e.instancedDataOffset+B,Z=16*V,G=r.instancedDataArray.float32;let Y=0;c&&(Y=G[Z+6]-r.instancesEvaluatedElevation[V]);const Q=0|G[Z+1];G[Z]=(0|G[Z])+I.r/1.05,G[Z+1]=Q+I.g/1.05,G[Z+2]=z,G[Z+3]=1/(_.z>10?this.tileToMeter:et(_,Q)),G[Z+4]=S[0],G[Z+5]=S[1],G[Z+6]=S[2]+(r.instancesRoadElevation?r.instancesRoadElevation[V]:0)+Y,G[Z+7]=A[0],G[Z+8]=A[1],G[Z+9]=A[2],G[Z+10]=A[4],G[Z+11]=A[5],G[Z+12]=A[6],G[Z+13]=A[8],G[Z+14]=A[9],G[Z+15]=A[10],r.instancesEvaluatedElevation[V]=S[2]}}}wt(lw,"ModelBucket",{omit:["layers"]}),wt(SC,"PerModelAttributes"),wt(TC,"ModelFeature");class Ef{constructor(e,t,r){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=r}static create(e,t,r){const c=r||e.findDEMTileFor(t);if(!c||!c.dem)return;const h=c.dem,f=c.tileID,_=1<<t.canonical.z-f.canonical.z;return new Ef(c,h.dim/_t/_,[(t.canonical.x/_-f.canonical.x)*h.dim,(t.canonical.y/_-f.canonical.y)*h.dim])}tileCoordToPixel(e,t){const r=t*this._scale+this._offset[1];return new it(Math.floor(e*this._scale+this._offset[0]),Math.floor(r))}getElevationAt(e,t,r,c){const h=e*this._scale+this._offset[0],f=t*this._scale+this._offset[1],_=Math.floor(h),g=Math.floor(f),b=this._dem;return c=!!c,r?Gt(Gt(b.get(_,g,c),b.get(_,g+1,c),f-g),Gt(b.get(_+1,g,c),b.get(_+1,g+1,c),f-g),h-_):b.get(_,g,c)}getElevationAtPixel(e,t,r){return this._dem.get(e,t,!!r)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Pe(1,e)*this._dem.stride}}const cw=new Float32Array(262144),Rh=new Uint8Array(262144);function EC(n){let e=0;if(n.meshes)for(const t of n.meshes)e=Math.max(e,t.aabb.max[2]);if(n.children)for(const t of n.children)e=Math.max(e,EC(t));return e}function IC(n,e,t){if(n.meshes)for(const r of n.meshes){if(r.aabb.min[0]===1/0)continue;const c=Li.applyTransform(r.aabb,n.globalMatrix);t.insert(e,c.min[0],c.min[1],c.max[0],c.max[1])}if(n.children)for(const r of n.children)IC(r,e,t)}const AC=["","wall","door","roof","window","lamp","logo"];class CC{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.evaluatedTranslation=[0,0,0],this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.cameraCollisionOpacity=1,this.feature={type:"Point",id:e.id,geometry:[],properties:{height:EC(e)}},this.aabb=this._getLocalBounds(),this.state=null}_getLocalBounds(){if(!this.node.meshes)return new Li([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let e=0;const t=new Li([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const r of this.node.meshes)this.node.lightMeshIndex!==e&&(r.transformedAabb=Li.applyTransformFast(r.aabb,this.node.globalMatrix),t.encapsulate(r.transformedAabb)),e++;this.aabb=t}return this.aabb}}class av{constructor(e,t,r,c,h,f,_,g){this.id=r,this.layers=e,this.layerIds=this.layers.map(b=>b.fqid),this.stateDependentLayerIds=this.layers.filter(b=>b.isStateDependent()).map(b=>b.id),this.modelTraits|=gf.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,c&&(this.modelTraits|=gf.HasMapboxMeshFeatures),h&&(this.modelTraits|=gf.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=f,this.worldview=g,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const b of t)this.nodesInfo.push(new CC(b)),IC(b,_.featureIndexArray.length,_.grid),_.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,_.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(e,t){for(const r of this.getNodesInfo()){const c=r.node;c.footprint&&t.push({footprint:c.footprint,id:e})}}updateAppearances(e,t,r,c){return{hasLayoutChanges:!1,hasUboChanges:!1}}update(e){const t=Object.keys(e).length!==0;if(t&&!this.stateDependentLayers.length)return;const r=t?this.stateDependentLayers:this.layers;if(!zo(e,this.states))for(const c of r)this.evaluate(c,e);this.states=structuredClone(e)}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 r of t){const c=r.node;this.uploaded?this.updatePbrBuffer(c):Ib(c,e,!0)}for(const r of t)Nx(r.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const r of e.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),t=!0);return t}needsReEvaluation(e,t,r){const c=e.transform.projectionOptions,h=e.style.getBrightness(),f=this.brightness!==h;if(!this.uploaded||this.dirty||c.name!==this.projection.name||R_(r.paint.get("model-color").value,f)||R_(r.paint.get("model-color-mix-intensity").value,f)||R_(r.paint.get("model-roughness").value,f)||R_(r.paint.get("model-emissive-strength").value,f)||R_(r.paint.get("model-height-based-emissive-strength-multiplier").value,f)){this.projection=c,this.brightness=h;const _=this.getNodesInfo();for(const g of _)g.state=null;return!0}return!1}evaluateTransform(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const r=this.getNodesInfo(),c=this.id.canonical;for(const h of r){const f=h.feature;h.evaluatedTranslation=t.paint.get("model-translation").evaluate(f,{},c),h.evaluatedScale=t.paint.get("model-scale").evaluate(f,{},c)}}evaluate(e,t){const r=this.getNodesInfo();for(const c of r){if(!c.node.meshes)continue;const h=c.feature,f=t&&t[h.id];if(zo(f,c.state))continue;c.state=structuredClone(f);const _=c.node.meshes&&c.node.meshes[0].featureData,g=c.evaluatedColor[2],b=c.evaluatedRMEA[2],S=this.id.canonical;if(c.hasTranslucentParts=!1,_){for(let I=0;I<AC.length;I++){const A=AC[I];A.length&&(h.properties.part=A);const M=e.paint.get("model-color").evaluate(h,f,S).toPremultipliedRenderColor(null),D=e.paint.get("model-color-mix-intensity").evaluate(h,f,S);c.evaluatedColor[I]=[M.r,M.g,M.b,D],c.evaluatedRMEA[I][0]=e.paint.get("model-roughness").evaluate(h,f,S),c.evaluatedRMEA[I][2]=e.paint.get("model-emissive-strength").evaluate(h,f,S),c.evaluatedRMEA[I][3]=M.a,c.emissionHeightBasedParams[I]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(h,f,S),!c.hasTranslucentParts&&M.a<1&&(c.hasTranslucentParts=!0)}delete h.properties.part,p3(c,g!==c.evaluatedColor[2]||b!==c.evaluatedRMEA[2],this.modelTraits)}else c.evaluatedRMEA[0][2]=e.paint.get("model-emissive-strength").evaluate(h,f,S);c.evaluatedTranslation=e.paint.get("model-translation").evaluate(h,f,S),c.evaluatedScale=e.paint.get("model-scale").evaluate(h,f,S),this.updatePbrBuffer(c.node)||(this.needsUpload=!0)}this.dirty=!1}elevationUpdate(e,t,r,c){const h=e.findDEMTileFor(r);if(h&&(h.tileID.canonical!==this.terrainTile||t!==this.terrainExaggeration)){if(h.dem&&h.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=h.tileID.overscaledZ;const f=Ef.create(e,r,h);if(!f)return;this.modelTraits&gf.HasMapboxMeshFeatures&&this.updateDEM(e,f,r,c);for(const _ of this.getNodesInfo()){const g=_.node;if(!g.footprint||!g.footprint.vertices||!g.footprint.vertices.length)continue;const b=g.footprint.vertices;let S=f.getElevationAt(b[0].x,b[0].y,!0,!0);for(let I=1;I<b.length;I++)S=Math.min(S,f.getElevationAt(b[I].x,b[I].y,!0,!0));g.elevation=S}}this.terrainTile=h.tileID.canonical,this.terrainExaggeration=t}}updateDEM(e,t,r,c){let h=t._dem._modifiedForSources[c];if(h===void 0&&(t._dem._modifiedForSources[c]=[],h=t._dem._modifiedForSources[c]),h.includes(r.canonical))return;const f=t._dem.dim;h.push(r.canonical);let _=!1;for(const g of this.getNodesInfo()){const b=g.node;if(!b.footprint||!b.footprint.grid)continue;const S=b.footprint.grid,I=t.tileCoordToPixel(S.min.x,S.min.y),A=t.tileCoordToPixel(S.max.x,S.max.y),M=Math.min(Math.min(f-A.y,I.x),Math.min(I.y,f-A.x));if(M<0)continue;const D=q(M,2,5);let z=Math.max(0,I.x-D),B=Math.max(0,I.y-D),V=Math.min(A.x+D,f-1),Z=Math.min(A.y+D,f-1);for(let te=B;te<=Z;++te)for(let me=z;me<=V;++me)Rh[te*f+me]=255;let G=0,Y=0;for(let te=0;te<S.cellsY;++te)for(let me=0;me<S.cellsX;++me){if(!S.cells[te*S.cellsX+me])continue;const ce=t.tileCoordToPixel(S.min.x+me/S.xScale,S.min.y+te/S.yScale),pe=t.tileCoordToPixel(S.min.x+(me+1)/S.xScale,S.min.y+(te+1)/S.yScale);for(let he=ce.y;he<=Math.min(pe.y+1,f-1);++he)for(let de=ce.x;de<=Math.min(pe.x+1,f-1);++de)Rh[he*f+de]===255&&(Rh[he*f+de]=0,G+=t.getElevationAtPixel(de,he),Y++)}const Q=G/Y;z=Math.max(1,I.x-D),B=Math.max(1,I.y-D),V=Math.min(A.x+D,f-2),Z=Math.min(A.y+D,f-2),_=!0;for(let te=B;te<=Z;++te)for(let me=z;me<=V;++me)Rh[te*f+me]===0&&(cw[te*f+me]=t._dem.set(me,te,Q));for(let te=1;te<D;++te){z=Math.max(1,I.x-te),B=Math.max(1,I.y-te),V=Math.min(A.x+te,f-2),Z=Math.min(A.y+te,f-2);for(let me=B;me<=Z;++me)for(let ce=z;ce<=V;++ce){const pe=me*f+ce;if(Rh[pe]===255){let he=0,de=0,Be=-1,je=-1;for(let He=-1;He<=1;++He)for(let Xe=-1;Xe<=1;++Xe){const Ze=(me+He)*f+ce+Xe;if(Rh[Ze]>=te)continue;const nt=cw[Ze],Fe=Math.abs(nt);Fe>de&&(he=nt,de=Fe,Be=Xe,je=He)}if(de>.1){const He=1-(te+.5*Math.abs(Be*je))/D;let Xe=t._dem.get(ce,me)+he*He;const Ze=t._dem.get(ce+Be,me+je),nt=t._dem.get(ce-Be,me-je,!0);(Xe-Ze)*(Xe-nt)>0&&(Xe=(Ze+nt)/2),cw[pe]=t._dem.set(ce,me,Xe),Rh[pe]=te}}}}}_&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=ts.now())}setFilter(e){this.filter=e?Yd(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Mi(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)Nx(t.node),Ab(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped());for(const c of this.getNodesInfo()){const h=c.node.footprint;c.hiddenByReplacement=!!h&&!r.find(f=>f.footprint===h)}}getHeightAtTileCoord(e,t){const r=[],c=[0,0,0],h=Ye([]);for(const f of this.getNodesInfo()){const _=f.node.meshes[0],g=_.transformedAabb;if(e<g.min[0]||t<g.min[1]||e>g.max[0]||t>g.max[1])continue;if(f.node.hidden===!0)return{height:1/0,maxHeight:f.feature.properties.height,hidden:!1,verticalScale:f.evaluatedScale[2]};Se(h,f.node.globalMatrix),c[0]=e,c[1]=t,mn(c,c,h);const b=(c[0]-_.aabb.min[0])/(_.aabb.max[0]-_.aabb.min[0])*Ih|0,S=Math.min(63,(c[1]-_.aabb.min[1])/(_.aabb.max[1]-_.aabb.min[1])*Ih|0)*Ih+Math.min(63,b),I=_.heightmap[S];if(!(I<0&&f.node.footprint))return f.hiddenByReplacement?void 0:{height:I,maxHeight:f.feature.properties.height,hidden:!1,verticalScale:f.evaluatedScale[2]};if(f.node.footprint.grid.query(new it(e,t),new it(e,t),r),r.length>0)return{height:void 0,maxHeight:f.feature.properties.height,hidden:f.hiddenByReplacement,verticalScale:f.evaluatedScale[2]}}}}function R_(n,e){return n instanceof zc&&!n.isLightConstant&&e}function f3(n,e,t,r,c,h,f,_){let g=(61440&e|(61440&e)>>4)>>8,b=(3840&e|(3840&e)>>4)>>4,S=240&e|(240&e)>>4;t[3]>0&&(g=Gt(g,255*t[0],t[3]),b=Gt(b,255*t[1],t[3]),S=Gt(S,255*t[2],t[3]));const I=g<<8|b,A=S<<8|Math.floor(255*r[3]),M=function(te){const me=q(te,0,2);return Math.min(Math.round(.5*me*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],D=q(c[0],0,1),z=q(c[1],0,1),B=q(c[2],0,1),V=q(c[3],0,1);let Z,G,Y,Q;if(D!==z&&f!==h&&z!==D){const te=f-h;G=1/(te*(z-D)),Y=-(h+te*D)/(te*(z-D));const me=q(c[4],-1,1);Q=Math.pow(10,me),Z=255*B<<8|255*V}else Z=65535,G=0,Y=1,Q=1;if(n.emplaceBack(I,A,M,Z,G,Y,Q),_){const te=_.length;_.clear();for(let me=0;me<te;me++)_.emplaceBack(I,A,M,Z,G,Y,Q)}}function p3(n,e,t){const r=n.node;let c=0;const h=t&gf.HasMeshoptCompression;for(const f of r.meshes){if(r.lights&&r.lightMeshIndex===c||!f.featureData)continue;f.featureArray=new sf,f.featureArray.reserve(f.featureData.length);let _=e;for(const g of f.featureData){const b=h?65535&g:g>>16&65535,S=h?g>>16&65535:65535&g,I=(15&S)<8?15&S:0,A=n.evaluatedRMEA[I],M=n.evaluatedColor[I],D=n.emissionHeightBasedParams[I];let z;if(_&&I===2&&r.lights&&(z=new sf,z.resize(10*r.lights.length)),f3(f.featureArray,b,M,A,D,f.aabb.min[2],f.aabb.max[2],z),z&&_){_=!1;const B=r.meshes[r.lightMeshIndex];B.featureArray=z,B.featureArray._trim()}}f.featureArray._trim(),c++}}wt(av,"Tiled3dModelBucket",{omit:["layers"]}),wt(CC,"Tiled3dModelFeature");const m3=["id","tile","layer","source","sourceLayer","state"];class Dh{constructor(e,t,r,c,h){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=r,this._y=c,this.properties=e?e.properties:{},this.id=h}clone(){const e=new Dh(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state=Object.assign({},this.state)),this.layer&&(e.layer=Object.assign({},this.layer)),this.source&&(e.source=this.source),this.sourceLayer&&(e.sourceLayer=this.sourceLayer),e}get geometry(){return this._geometry===void 0&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const t of m3)this[t]!==void 0&&(e[t]=this[t]);return e}}class Lh extends Du{constructor(e,t,r,c){super(),this.id=e,this.type="model",this.models=[],this._options=t,this._modelsInfo=new Map,this._abortController=null}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null)}loadGLTFFromURI(e,t){return $I(this.map._requestManager.transformRequest(e,Mu.Model).url,t)}async loadModel(e,t,r){try{const c=await this.loadGLTFFromURI(t.uri,r);if(r.aborted)return;const h=this._modelsInfo.get(e);if(!h)return;const f=Pb(c),_=h.modelSpec,g=new XI(e,_.uri,_.position,_.orientation,f);Lh.applyModelSpecification(g,_),g.computeBoundsAndApplyParent(),this.models.push(g),h.model=g}catch(c){if(c instanceof Error&&c.name==="AbortError")return;const h=c instanceof Error?c.message:"Unknown error";this.fire(new xc(new Error(`Could not load model ${e} from ${t.uri}: ${h}`)))}}async load(){this._abortController||(this._abortController=new AbortController);const e=this._abortController.signal,t=[];for(const r in this._options.models){const c=this._options.models[r],h=this._modelsInfo.get(r);if(h&&h.model){h.modelSpec=c;const f=h.model;f.position=c.position!=null?new ve(c.position[0],c.position[1]):new ve(0,0),f.orientation=c.orientation!=null?c.orientation:[0,0,0],Lh.applyModelSpecification(f,c),f.computeBoundsAndApplyParent(),this.models.push(f)}else h?h.modelSpec=c:(this._modelsInfo.set(r,{modelSpec:c,model:null}),t.push(this.loadModel(r,c,e)))}t.length!==0?(await Promise.allSettled(t),e.aborted||this.fire(new ho("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new ho("data",{dataType:"source",sourceDataType:"metadata"}))}static applyModelSpecification(e,t){t.nodeOverrides&&Lh.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&Lh.convertMaterialOverrides(e,t.materialOverrides),t.nodeOverrideNames&&(e.nodeOverrideNames=[...t.nodeOverrideNames]),t.materialOverrideNames&&(e.materialOverrideNames=[...t.materialOverrideNames]),t.featureProperties&&(e.featureProperties=t.featureProperties)}static convertNodeOverrides(e,t){if(Array.isArray(t)&&t.every(r=>typeof r=="string")){e.nodeOverrideNames=[];for(const r of t)e.nodeOverrideNames.push(r)}else Object.entries(t).forEach(([r,c])=>{const h={orientation:[0,0,0]};if(c.hasOwnProperty("orientation")){const f=c.orientation;f&&(h.orientation=f)}e.nodeOverrides.set(r,h)})}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every(r=>typeof r=="string")){e.materialOverrideNames=[];for(const r of t)e.materialOverrideNames.push(r)}else Object.entries(t).forEach(([r,c])=>{const h={color:new Ii(1,1,1),colorMix:0,emissionStrength:0,opacity:1},f=c["model-color"];f!==void 0&&(h.color.r=f[0],h.color.g=f[1],h.color.b=f[2]);const _=c["model-color-mix-intensity"];_!==void 0&&(h.colorMix=_);const g=c["model-emissive-strength"];g!==void 0&&(h.emissionStrength=g);const b=c["model-opacity"];b!==void 0&&(h.opacity=b),e.materialOverrides.set(r,h)})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){if(this._modelsInfo.size===0)return!0;for(const e of this._modelsInfo.values())if(e.model==null)return!1;return!0}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return!1}reload(){this.cancelModelRequests();const e=zl(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load()}onRemove(e){this.cancelModelRequests()}setModels(e){this.models=[];const t=new Map;for(const r in e){const c=e[r],h=this._modelsInfo.get(r);h&&h.modelSpec.uri===c.uri&&t.set(r,h)}if(this._modelsInfo.size!==t.size){this.cancelModelRequests();for(const[r,c]of t)c.model||t.delete(r)}this._modelsInfo=t,this._options.models=e,this.load()}}function uw(n,e,t,r){const c=1<<n.z;e.lat=Oe((r/_t+n.y)/c),e.lng=we((t/_t+n.x)/c)}function _3(n,e,t,r){const c=n.getNodesInfo()[e];if(!c||c.hiddenByReplacement||!c.node.meshes)return;let h=Number.MAX_VALUE;const f=c.node,_=t.tile,g=r.calculatePosMatrix(_.tileID.toUnwrapped(),r.worldSize),b=c.evaluatedScale;let S=0;r.elevation&&f.elevation&&(S=f.elevation*r.elevation.exaggeration()),Ie(g,g,[(f.anchor?f.anchor[0]:0)*(b[0]-1),(f.anchor?f.anchor[1]:0)*(b[1]-1),S]),qe(g,g,b);const I=t.queryGeometry,A=I.isPointQuery()?I.screenBounds:I.screenGeometry,M=function(z){const B=ye([],g,z.globalMatrix);ye(B,r.expandedFarZProjMatrix,B);for(let V=0;V<z.meshes.length;++V){const Z=z.meshes[V];if(V===z.lightMeshIndex)continue;const G=Eb(A,r,B,Z.aabb);G!=null&&(h=Math.min(G,h))}if(z.children)for(const V of z.children)M(V)};if(M(f),h===Number.MAX_VALUE)return;const D=new ve(0,0);return uw(_.tileID.canonical,D,c.node.anchor[0],c.node.anchor[1]),{intersectionZ:h,position:D,feature:c.feature}}const g3={circle:class extends jr{constructor(n,e,t,r){super(n,{layout:pE||(pE=new on({"circle-sort-key":new at(Ee.layout_circle["circle-sort-key"]),"circle-elevation-reference":new dt(Ee.layout_circle["circle-elevation-reference"]),visibility:new dt(Ee.layout_circle.visibility)})),paint:mE||(mE=new on({"circle-radius":new at(Ee.paint_circle["circle-radius"]),"circle-color":new at(Ee.paint_circle["circle-color"]),"circle-blur":new at(Ee.paint_circle["circle-blur"]),"circle-opacity":new at(Ee.paint_circle["circle-opacity"]),"circle-translate":new dt(Ee.paint_circle["circle-translate"]),"circle-translate-anchor":new dt(Ee.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new dt(Ee.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new dt(Ee.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new at(Ee.paint_circle["circle-stroke-width"]),"circle-stroke-color":new at(Ee.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new at(Ee.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new dt(Ee.paint_circle["circle-emissive-strength"]),"circle-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"circle-stroke-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},e,t,r)}createBucket(n){return new Bi(n)}queryRadius(n){const e=n;return Gc("circle-radius",this,e)+Gc("circle-stroke-width",this,e)+hx(this.paint.get("circle-translate"))}queryIntersectsFeature(n,e,t,r,c,h,f,_){const g=fE(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),h.angle,n.pixelToTileUnitsFactor),b=this.paint.get("circle-radius").evaluate(e,t)+this.paint.get("circle-stroke-width").evaluate(e,t);return CE(n,r,h,f,_,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",g,b)}getProgramIds(){return["circle"]}getDefaultProgramParams(n,e,t){const r=AE(this);return{config:new k(this,{zoom:e,lut:t}),defines:r,overrideFog:!1}}is3D(n){return!n&&!!this.layout&&this.layout.get("circle-elevation-reference")!=="none"}hasElevation(){return this.layout&&this.layout.get("circle-elevation-reference")!=="none"}},heatmap:class extends jr{createBucket(n){return new ME(n)}constructor(n,e,t,r){super(n,{layout:RE||(RE=new on({visibility:new dt(Ee.layout_heatmap.visibility)})),paint:DE||(DE=new on({"heatmap-radius":new at(Ee.paint_heatmap["heatmap-radius"]),"heatmap-weight":new at(Ee.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new dt(Ee.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Bc(Ee.paint_heatmap["heatmap-color"]),"heatmap-opacity":new dt(Ee.paint_heatmap["heatmap-opacity"]),"heatmap-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},e,t,r),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(n){n==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=e_({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}_clear(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}queryRadius(n){return Gc("heatmap-radius",this,n)}queryIntersectsFeature(n,e,t,r,c,h,f,_){const g=this.paint.get("heatmap-radius").evaluate(e,t);return CE(n,r,h,f,_,!0,!0,new it(0,0),g)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getDefaultProgramParams(n,e,t){return n==="heatmap"?{config:new k(this,{zoom:e,lut:t}),overrideFog:!1}:{}}},hillshade:class extends jr{constructor(n,e,t,r){super(n,{layout:LE||(LE=new on({visibility:new dt(Ee.layout_hillshade.visibility)})),paint:zE||(zE=new on({"hillshade-illumination-direction":new dt(Ee.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new dt(Ee.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new dt(Ee.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new dt(Ee.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new dt(Ee.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new dt(Ee.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new dt(Ee.paint_hillshade["hillshade-emissive-strength"]),"hillshade-shadow-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"hillshade-highlight-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"hillshade-accent-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},e,t,r)}shouldRedrape(){return this.hasOffscreenPass()&&this.paint.get("hillshade-illumination-anchor")==="viewport"}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(n,e,t){return{overrideFog:!1}}},fill:class extends jr{constructor(n,e,t,r){super(n,{layout:eI||(eI=new on({"fill-sort-key":new at(Ee.layout_fill["fill-sort-key"]),visibility:new dt(Ee.layout_fill.visibility),"fill-elevation-reference":new dt(Ee.layout_fill["fill-elevation-reference"]),"fill-construct-bridge-guard-rail":new at(Ee.layout_fill["fill-construct-bridge-guard-rail"])})),paint:tI||(tI=new on({"fill-antialias":new dt(Ee.paint_fill["fill-antialias"]),"fill-opacity":new at(Ee.paint_fill["fill-opacity"]),"fill-color":new at(Ee.paint_fill["fill-color"]),"fill-outline-color":new at(Ee.paint_fill["fill-outline-color"]),"fill-translate":new dt(Ee.paint_fill["fill-translate"]),"fill-translate-anchor":new dt(Ee.paint_fill["fill-translate-anchor"]),"fill-pattern":new at(Ee.paint_fill["fill-pattern"]),"fill-pattern-cross-fade":new dt(Ee.paint_fill["fill-pattern-cross-fade"]),"fill-emissive-strength":new dt(Ee.paint_fill["fill-emissive-strength"]),"fill-z-offset":new at(Ee.paint_fill["fill-z-offset"]),"fill-bridge-guard-rail-color":new at(Ee.paint_fill["fill-bridge-guard-rail-color"]),"fill-tunnel-structure-color":new at(Ee.paint_fill["fill-tunnel-structure-color"]),"fill-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"fill-outline-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"fill-bridge-guard-rail-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"fill-tunnel-structure-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},e,t,r)}getProgramIds(){const n=this.paint.get("fill-pattern"),e=n&&n.constantOr(1),t=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&t.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),t}getDefaultProgramParams(n,e,t){return{config:new k(this,{zoom:e,lut:t}),overrideFog:!1}}recalculate(n,e){super.recalculate(n,e);const t=this.paint._values["fill-outline-color"];t.value.kind==="constant"&&t.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(n){return new wx(n)}queryRadius(){return hx(this.paint.get("fill-translate"))}queryIntersectsFeature(n,e,t,r,c,h){return!n.queryGeometry.isAboveHorizon&&_n(dE(n.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),h.angle,n.pixelToTileUnitsFactor),r)}isTileClipped(){return this.paint.get("fill-z-offset").constantOr(1)===0}is3D(n){if(this.paint.get("fill-z-offset").constantOr(1)!==0)return!0;const e=this.layout&&this.layout.get("fill-elevation-reference")!=="none";return n!=null?e&&!n:e}hasElevation(){return this.layout&&this.layout.get("fill-elevation-reference")!=="none"}hasShadowPass(){return this.layout&&this.layout.get("fill-elevation-reference")!=="none"}},"fill-extrusion":class extends jr{constructor(n,e,t,r){super(n,{layout:bI||(bI=new on({visibility:new dt(Ee["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new dt(Ee["layout_fill-extrusion"]["fill-extrusion-edge-radius"]),"source-max-zoom":new dt(Ee["layout_fill-extrusion"]["source-max-zoom"])})),paint:wI||(wI=new on({"fill-extrusion-opacity":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new at(Ee["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new at(Ee["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-pattern-cross-fade":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-pattern-cross-fade"]),"fill-extrusion-height":new at(Ee["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new at(Ee["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new at(Ee["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new at(Ee["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-front-cutoff":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-front-cutoff"]),"fill-extrusion-emissive-strength":new at(Ee["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new at(Ee["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new dt(Ee["paint_fill-extrusion"]["fill-extrusion-cast-shadows"]),"fill-extrusion-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"fill-extrusion-flood-light-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},e,t,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(n){return new Mx(n)}queryRadius(){return hx(this.paint.get("fill-extrusion-translate"))}is3D(n){return!0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(n,e,t,r,c,h,f,_,g){const b=fE(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),h.angle,n.pixelToTileUnitsFactor),S=this.paint.get("fill-extrusion-height").evaluate(e,t),I=this.paint.get("fill-extrusion-base").evaluate(e,t),A=[0,0],M=_&&h.elevation,D=h.elevation?h.elevation.exaggeration():1,z=n.tile.getBucket(this);if(z instanceof Mx){const Y=z.centroidData.find(Q=>g>=Q.vertexArrayOffset&&g<Q.vertexArrayOffset+Q.vertexCount);if(Y&&Y.flags&Cx)return!1;if(M){const Q=z.centroidVertexArray,te=g+1;te<Q.length&&(A[0]=Q.geta_centroid_pos0(te),A[1]=Q.geta_centroid_pos1(te))}}if(A[0]===0&&A[1]===1)return!1;h.projection.name==="globe"&&(r=vI([r],[new it(0,0),new it(_t,_t)],n.tileID.canonical).map(Y=>Y.polygon).flat());const B=M?_:null,[V,Z]=PI(h,r,I,S,b,f,B,A,D,h.center.lat,n.tileID.canonical),G=n.queryGeometry;return CI(V,Z,G.isPointQuery()?G.screenBounds:G.screenGeometry)}},building:class extends jr{constructor(n,e,t,r){super(n,{layout:iA||(iA=new on({visibility:new dt(Ee.layout_building.visibility),"building-facade":new at(Ee.layout_building["building-facade"]),"building-facade-floors":new at(Ee.layout_building["building-facade-floors"]),"building-facade-unit-width":new at(Ee.layout_building["building-facade-unit-width"]),"building-facade-window":new at(Ee.layout_building["building-facade-window"]),"building-roof-shape":new at(Ee.layout_building["building-roof-shape"]),"building-height":new at(Ee.layout_building["building-height"]),"building-base":new at(Ee.layout_building["building-base"]),"building-flood-light-wall-radius":new at(Ee.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new at(Ee.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new at(Ee.layout_building["building-flip-roof-orientation"])})),paint:nA||(nA=new on({"building-opacity":new dt(Ee.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new dt(Ee.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new dt(Ee.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new dt(Ee.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new dt(Ee.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new dt(Ee.paint_building["building-vertical-scale"]),"building-cast-shadows":new dt(Ee.paint_building["building-cast-shadows"]),"building-color":new at(Ee.paint_building["building-color"]),"building-emissive-strength":new at(Ee.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new dt(Ee.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new dt(Ee.paint_building["building-cutoff-fade-range"]),"building-front-cutoff":new dt(Ee.paint_building["building-front-cutoff"]),"building-flood-light-color":new dt(Ee.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new dt(Ee.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new dt(Ee.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},e,t,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(n){return new tA(n)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(n){return!0}queryRadius(n){return 0}queryIntersectsFeature(n,e,t,r,c,h,f,_,g,b){let S=this.layout.get("building-height").evaluate(e,t);const I=this.layout.get("building-base").evaluate(e,t),A=n.tile.getBucket(this).getFootprint(e);if(A){if(A.hiddenFlags!==0)return!1;S=A.height}const[M,D]=PI(h,r,I,S,new it(0,0),f,null,[0,0],1,h.center.lat,n.tileID.canonical),z=n.queryGeometry;return CI(M,D,z.isPointQuery()?z.screenBounds:z.screenGeometry)}},line:class extends jr{constructor(n,e,t,r){const c=fA();super(n,c,e,t,r),c.layout&&(this.layout=new pa(c.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(n){if(n==="line-gradient"){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof qu,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(n,e){super.recalculate(n,e),this.paint._values["line-floorwidth"]=(()=>{if(g_)return g_;const t=fA();return g_=new cB(t.paint.properties["line-width"].specification),g_.useIntegerZoom=!0,g_})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,n)}createBucket(n){return new Ux(n)}getProgramIds(){const n=[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"];return this.paint.get("line-blend-mode")!=="default"&&n.push("lineBlendComposite"),n}getDefaultProgramParams(n,e,t){if(n==="lineBlendComposite")return{};const r=hA(this);return{config:new k(this,{zoom:e,lut:t}),defines:r,overrideFog:!1}}queryRadius(n){const e=n,t=pA(Gc("line-width",this,e),Gc("line-gap-width",this,e)),r=Gc("line-offset",this,e);return t/2+Math.abs(r)+hx(this.paint.get("line-translate"))}queryIntersectsFeature(n,e,t,r,c,h){if(n.queryGeometry.isAboveHorizon)return!1;const f=dE(n.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),h.angle,n.pixelToTileUnitsFactor),_=n.pixelToTileUnitsFactor/2*pA(this.paint.get("line-width").evaluate(e,t),this.paint.get("line-gap-width").evaluate(e,t)),g=this.paint.get("line-offset").evaluate(e,t);return g&&(r=function(b,S){const I=[],A=new it(0,0);for(let M=0;M<b.length;M++){const D=b[M],z=[];for(let B=0;B<D.length;B++){const V=D[B],Z=D[B+1],G=B===0?A:V.sub(D[B-1])._unit()._perp(),Y=B===D.length-1?A:Z.sub(V)._unit()._perp(),Q=G._add(Y)._unit();Q._mult(1/(Q.x*Y.x+Q.y*Y.y)),z.push(Q._mult(S)._add(V))}I.push(z)}return I}(r,g*n.pixelToTileUnitsFactor)),function(b,S,I){for(let A=0;A<S.length;A++){const M=S[A];if(b.length>=3){for(let D=0;D<M.length;D++)if(ns(b,M[D]))return!0}if(gs(b,M,I))return!0}return!1}(f,r,_)}isTileClipped(){return this.hasNonElevatedBuckets}isDraped(n){return!this.hasElevatedBuckets||this.layout&&this.layout.get("line-elevation-reference")==="hd-road-markup"}hasElevation(){return this.layout&&this.layout.get("line-elevation-reference")!=="none"}hasOffscreenPass(){return this.paint.get("line-blend-mode")!=="default"&&this.paint.get("line-opacity").constantOr(1)!==0&&this.paint.get("line-width").constantOr(1)!==0&&this.visibility!=="none"}resize(){this._destroyLineBlendFbo()}_clear(){this._destroyLineBlendFbo()}_destroyLineBlendFbo(){this.lineBlendFbo&&(this.lineBlendFbo.destroy(),this.lineBlendFbo=null),this.lineBlendStencil=null,this.lineBlendDrapeFbo&&(this.lineBlendDrapeFbo.destroy(),this.lineBlendDrapeFbo=null),this.lineBlendDrapeStencil=null}},symbol:iv,background:class extends jr{constructor(n,e,t,r){super(n,{layout:lC||(lC=new on({visibility:new dt(Ee.layout_background.visibility)})),paint:cC||(cC=new on({"background-pitch-alignment":new dt(Ee.paint_background["background-pitch-alignment"]),"background-color":new dt(Ee.paint_background["background-color"]),"background-pattern":new dt(Ee.paint_background["background-pattern"]),"background-opacity":new dt(Ee.paint_background["background-opacity"]),"background-emissive-strength":new dt(Ee.paint_background["background-emissive-strength"]),"background-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},e,t,r)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(n,e,t){return{overrideFog:!1}}is3D(n){return this.paint.get("background-pitch-alignment")==="viewport"}},raster:pC,"raster-particle":wC,sky:class extends jr{constructor(n,e,t,r){super(n,{layout:gC||(gC=new on({visibility:new dt(Ee.layout_sky.visibility)})),paint:yC||(yC=new on({"sky-type":new dt(Ee.paint_sky["sky-type"]),"sky-atmosphere-sun":new dt(Ee.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new dt(Ee.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new dt(Ee.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new dt(Ee.paint_sky["sky-gradient-radius"]),"sky-gradient":new Bc(Ee.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new dt(Ee.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new dt(Ee.paint_sky["sky-atmosphere-color"]),"sky-opacity":new dt(Ee.paint_sky["sky-opacity"]),"sky-gradient-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-halo-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"}),"sky-atmosphere-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},e,t,r),this._updateColorRamp()}_clear(){this.skyboxFbo&&(this.skyboxFbo.destroy(),this.skyboxFbo=null),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this._skyboxInvalidated=!0}_handleSpecialPaintPropertyUpdate(n){n==="sky-gradient"?this._updateColorRamp():n!=="sky-atmosphere-sun"&&n!=="sky-atmosphere-halo-color"&&n!=="sky-atmosphere-color"&&n!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=e_({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(n){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=n.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(n,e){if(this.paint.get("sky-type")==="atmosphere"){const r=this.paint.get("sky-atmosphere-sun"),c=!r,h=n.style.light,f=h.properties.get("position");return c&&h.properties.get("anchor")==="viewport"&&zt("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),c?ow(f.azimuthal,90-f.polar,e):ow(r[0],90-r[1],e)}const t=this.paint.get("sky-gradient-center");return ow(t[0],90-t[1],e)}isSky(){return!0}markSkyboxValid(n){this._skyboxInvalidated=!1,this._lightPosition=n.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const n=this.paint.get("sky-type");return n==="atmosphere"?["skyboxCapture","skybox"]:n==="gradient"?["skyboxGradient"]:null}},slot:class extends jr{constructor(n,e,t,r){super(n,{paint:xC||(xC=new on({}))},e,null)}},model:class extends jr{constructor(n,e,t,r){super(n,{layout:vC||(vC=new on({visibility:new dt(Ee.layout_model.visibility),"model-id":new at(Ee.layout_model["model-id"]),"model-allow-density-reduction":new dt(Ee.layout_model["model-allow-density-reduction"])})),paint:bC||(bC=new on({"model-opacity":new at(Ee.paint_model["model-opacity"]),"model-rotation":new at(Ee.paint_model["model-rotation"]),"model-scale":new at(Ee.paint_model["model-scale"]),"model-translation":new at(Ee.paint_model["model-translation"]),"model-color":new at(Ee.paint_model["model-color"]),"model-color-mix-intensity":new at(Ee.paint_model["model-color-mix-intensity"]),"model-type":new dt(Ee.paint_model["model-type"]),"model-cast-shadows":new dt(Ee.paint_model["model-cast-shadows"]),"model-receive-shadows":new dt(Ee.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new dt(Ee.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new at(Ee.paint_model["model-emissive-strength"]),"model-roughness":new at(Ee.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new at(Ee.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new dt(Ee.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new dt(Ee.paint_model["model-front-cutoff"]),"model-elevation-reference":new dt(Ee.paint_model["model-elevation-reference"]),"model-ignore-line-cutout":new dt(Ee.paint_model["model-ignore-line-cutout"]),"model-color-use-theme":new at({type:"string",default:"default","property-type":"data-driven"})}))},e,t,r),this.layer=n,this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(n){return new lw(n)}getProgramIds(){return["model"]}is3D(n){return!0}hasShadowPass(){return!0}canCastShadows(){return!0}hasLightBeamPass(){return!0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(n){return n instanceof av?8191:0}queryRenderedFeatures(n,e,t){const r=e.getSource();if(!(r&&r instanceof Lh))return{};const c=r,h={};h[this.id]=[];const f=h[this.id];let _=0;for(const g of c.models){const b=e.getFeatureState(this.sourceLayer,g.id),S={type:"Unknown",id:g.id,properties:g.featureProperties},I=this.paint.get("model-rotation").evaluate(S,b),A=this.paint.get("model-scale").evaluate(S,b),M=this.paint.get("model-translation").evaluate(S,b),D=this.paint.get("model-elevation-reference");let z=[];Bx(z,g,t,g.position,I,A,M,D==="ground",D==="ground",!1),t.projection.name==="globe"&&(z=Ox(z,t));const B=ye([],t.projMatrix,z),V=Eb(n.isPointQuery()?n.screenBounds:n.screenGeometry,t,B,g.aabb);if(V!=null){const Z=new Dh(void 0,0,0,0,g.id);Z.layer=this.layer,Z.properties=structuredClone(g.featureProperties),Z.properties.layer=this.id,Z.properties.uri=g.uri,Z.properties.orientation=g.orientation,Z.sourceLayer=this.sourceLayer,Z.geometry={type:"Point",coordinates:[g.position.lng,g.position.lat]},Z.state=b,Z.source=this.source,f.push({featureIndex:_,feature:Z,intersectionZ:V})}++_}return h}queryIntersectsFeature(n,e,t,r,c,h,f,_,g,b){if(!this.modelManager)return!1;const S=this.modelManager,I=n.tile.getBucket(this);if(!(I&&I instanceof lw))return!1;for(const A in I.instancesPerModel){const M=I.instancesPerModel[A],D=e.id!==void 0?e.id:e.properties&&e.properties.hasOwnProperty("id")?e.properties.id:void 0;if(M.idToFeaturesIndex.hasOwnProperty(D)){const z=M.features[M.idToFeaturesIndex[D]],B=S.getModel(A,b||this.scope);if(!B)return!1;let V=[];const Z=new ve(0,0),G=I.canonical;let Y=Number.MAX_VALUE;for(let Q=0;Q<z.instancedDataCount;++Q){const te=16*(z.instancedDataOffset+Q),me=M.instancedDataArray.float32,ce=[me[te+4],me[te+5],me[te+6]];uw(G,Z,Math.floor(me[te]),Math.floor(me[te+1])),Bx(V,B,h,Z,z.rotation,z.scale,ce,!1,!1,!1),h.projection.name==="globe"&&(V=Ox(V,h));const pe=ye([],h.projMatrix,V),he=n.queryGeometry,de=Eb(he.isPointQuery()?he.screenBounds:he.screenGeometry,h,pe,B.aabb);de!=null&&(Y=Math.min(de,Y))}return Y!==Number.MAX_VALUE&&Y}}return!1}_handleOverridablePaintPropertyUpdate(n,e,t){return!(!this.layout||e.isDataDriven()||t.isDataDriven()||n!=="model-color"&&n!=="model-color-mix-intensity"&&n!=="model-rotation"&&n!=="model-scale"&&n!=="model-translation"&&n!=="model-emissive-strength")}_isPropertyZoomDependent(n){const e=this._transitionablePaint._values[n];return e!=null&&e.value!=null&&e.value.expression!=null&&e.value.expression instanceof Pl}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}},clip:class extends jr{constructor(n,e,t,r){super(n,{layout:iI||(iI=new on({"clip-layer-types":new dt(Ee.layout_clip["clip-layer-types"]),"clip-layer-scope":new dt(Ee.layout_clip["clip-layer-scope"]),visibility:new dt(Ee.layout_clip.visibility)})),paint:nI||(nI=new on({}))},e,t,r)}recalculate(n,e){super.recalculate(n,e)}createBucket(n){return new rI(n)}is3D(n){return!0}}};class y3{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class PC{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const r=e[t];this._stringToNumber[r]=t,this._numberToString[t]=r}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}class MC{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new kc(_t,16,0),this.featureIndexArray=new qm,this.promoteId=t,this.is3DTile=!1,this.serializedLayersCache=new Map}insert(e,t,r,c,h,f=0,_=0){const g=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,c,h,f);const b=this.grid;for(let S=0;S<t.length;S++){const I=t[S],A=[1/0,1/0,-1/0,-1/0];for(let M=0;M<I.length;M++){const D=I[M];A[0]=Math.min(A[0],D.x),A[1]=Math.min(A[1],D.y),A[2]=Math.max(A[2],D.x),A[3]=Math.max(A[3],D.y)}_!==0&&(A[0]-=_,A[1]-=_,A[2]+=_,A[3]+=_),A[0]<_t&&A[1]<_t&&A[2]>=0&&A[3]>=0&&b.insert(g,A[0],A[1],A[2],A[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Ci(new jx(this.rawTileData)).layers,this.sourceLayerCoder=new PC(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){const{tilespaceGeometry:r,transform:c,tileTransform:h,pixelPosMatrix:f,availableImages:_,worldview:g}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const b=t.queryRadius?t.queryRadius:0,S=r.bufferedTilespaceBounds,I=this.grid.query(S.min.x,S.min.y,S.max.x,S.max.y,(z,B,V,Z)=>Xa(r.bufferedTilespaceGeometry,z-b,B-b,V+b,Z+b));I.sort(x3);let A=null;c.elevation&&I.length>0&&(A=Ef.create(c.elevation,this.tileID));const M={};let D;for(let z=0;z<I.length;z++){const B=I[z];if(B===D)continue;D=B;const V=this.featureIndexArray.get(B);let Z=null;this.is3DTile?this.loadMatchingModelFeature(M,V,e,r,c,g):this.loadMatchingFeature(M,V,e,_,g,(G,Y,Q,te=0)=>(Z||(Z=Ft(G,this.tileID.canonical,h)),Y.queryIntersectsFeature(r,G,Q,Z,this.z,c,f,A,te,t.scope)))}return M}loadMatchingFeature(e,t,r,c,h,f){const{featureIndex:_,bucketIndex:g,sourceLayerIndex:b,layoutVertexArrayOffset:S}=t,I=this.bucketLayerIDs[g],A=r.layers,M=Object.keys(A);if(M.length&&!Lt(M,I))return;const D=r.sourceCache,z=this.sourceLayerCoder.decode(b),B=this.vtLayers[z].feature(_),V=this.getId(B,z);for(let Z=0;Z<I.length;Z++){const G=I[Z];if(!A[G])continue;const{styleLayer:Y,targets:Q}=A[G];let te={};V!==void 0&&(te=D.getFeatureState(Y.sourceLayer,V));const me=!f||f(B,Y,te,S);if(!me)continue;const ce=new Dh(B,this.z,this.x,this.y,V);ce.tile=this.tileID.canonical,ce.state=te;let pe=this.serializedLayersCache.get(G);pe||(pe=Y.serialize(),pe.id=G,this.serializedLayersCache.set(G,pe)),ce.source=pe.source,ce.sourceLayer=pe["source-layer"],ce.layer=Object.assign({},pe),ce.layer.paint=RC(pe.paint,Y.paint,B,te,c),ce.layer.layout=RC(pe.layout,Y.layout,B,te,c);let he=!1;for(const de of Q){this.updateFeatureProperties(ce,de);const{filter:Be}=de;if(Be){if(B.properties=ce.properties,Be.needGeometry){const je=oi(B,!0);if(!Be.filter(new Mi(this.tileID.overscaledZ,{worldview:h}),je,this.tileID.canonical))continue}else if(!Be.filter(new Mi(this.tileID.overscaledZ,{worldview:h}),B))continue}he=!0,de.targetId&&this.addFeatureVariant(ce,de)}he&&this.appendToResult(e,G,_,ce,me)}}loadMatchingModelFeature(e,t,r,c,h,f){const{featureIndex:_,bucketIndex:g}=t,b=this.bucketLayerIDs[g],S=r.layers,I=Object.keys(S);if(!I.length||Lt(I,b))for(let A=0;A<b.length;A++){const M=b[A],{styleLayer:D,targets:z}=S[M];if(D.type!=="model")continue;const B=c.tile,V=B.getBucket(D);if(!(V&&V instanceof av))continue;const Z=_3(V,_,c,h);if(!Z)continue;const{z:G,x:Y,y:Q}=B.tileID.canonical,{feature:te,intersectionZ:me,position:ce}=Z;let pe={};te.id!==void 0&&(pe=r.sourceCache.getFeatureState(D.sourceLayer,te.id));const he=new Dh({},G,Y,Q,te.id);he.tile=this.tileID.canonical,he.state=pe,he.properties=te.properties,he.geometry={type:"Point",coordinates:[ce.lng,ce.lat]};let de=this.serializedLayersCache.get(M);de||(de=D.serialize(),de.id=M,this.serializedLayersCache.set(M,de)),he.source=de.source,he.sourceLayer=de["source-layer"],he.layer=Object.assign({},de);let Be=!1;for(const je of z){this.updateFeatureProperties(he,je);const{filter:He}=je;if(He){if(te.properties=he.properties,He.needGeometry){if(!He.filter(new Mi(this.tileID.overscaledZ,{worldview:f}),te,this.tileID.canonical))continue}else if(!He.filter(new Mi(this.tileID.overscaledZ,{worldview:f}),te))continue}Be=!0,je.targetId&&this.addFeatureVariant(he,je)}Be&&this.appendToResult(e,M,_,he,me)}}updateFeatureProperties(e,t,r){if(t.properties){const c={};for(const h in t.properties){const f=t.properties[h].evaluate({zoom:this.z},e._vectorTileFeature,e.state,e.tile,r);f!=null&&(c[h]=f)}e.properties=c}}addFeatureVariant(e,t,r){const c={target:t.target,namespace:t.namespace,uniqueFeatureID:t.uniqueFeatureID};t.properties&&(c.properties=e.properties),e.variants=e.variants||{},e.variants[t.targetId]=e.variants[t.targetId]||[],e.variants[t.targetId].push(c)}appendToResult(e,t,r,c,h){let f=e[t];f===void 0&&(f=e[t]=[]),f.push({featureIndex:r,feature:c,intersectionZ:h})}lookupSymbolFeatures(e,t,r,c,h,f){const _={};this.loadVTLayers();for(const g of e)this.loadMatchingFeature(_,{bucketIndex:t,sourceLayerIndex:r,featureIndex:g,layoutVertexArrayOffset:0},c,h,f);return _}loadFeature(e){const{featureIndex:t,sourceLayerIndex:r}=e;this.loadVTLayers();const c=this.sourceLayerCoder.decode(r),h=this.vtFeatures[c];if(h[t])return h[t];const f=this.vtLayers[c].feature(t);return h[t]=f,f}hasLayer(e){for(const t of this.bucketLayerIDs)for(const r of t)if(e===r)return!0;return!1}getId(e,t){let r=e.id;if(this.promoteId){const c=Array.isArray(this.promoteId)||typeof this.promoteId!="object"?this.promoteId:this.promoteId[t];if(c!=null)if(Array.isArray(c)){if(!this.promoteIdExpression){const h=Za(c);if(h.result!=="success"){const f=h.value.map(_=>`${_.key}: ${_.message}`).join(", ");return void zt(`Failed to create expression for promoteId: ${f}`)}this.promoteIdExpression=h.value}r=this.promoteIdExpression.evaluate({zoom:0},e)}else r=e.properties[c];typeof r=="boolean"&&(r=Number(r))}return r}}function RC(n,e,t,r,c){return rt(n,(h,f)=>{const _=e instanceof pa?e.get(f):null;return _&&_.evaluate?_.evaluate(t,r,void 0,c):_})}function x3(n,e){return e-n}function DC(n,e){const t={};if(!e)return t;for(const r of n){const c=r.layerIds.map(h=>e.getLayer(h)).filter(Boolean);if(c.length!==0){r.layers=c,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(h=>c.filter(f=>f.id===h)[0]));for(const h of c)t[h.fqid]=r}}return t}wt(MC,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Zo=32,il=33,Yc=new Uint16Array(8184);for(let n=0;n<2046;n++){let e=n+2,t=0,r=0,c=0,h=0,f=0,_=0;for(1&e?c=h=f=Zo:t=r=_=Zo;(e>>=1)>1;){const b=t+c>>1,S=r+h>>1;1&e?(c=t,h=r,t=f,r=_):(t=c,r=h,c=f,h=_),f=b,_=S}const g=4*n;Yc[g+0]=t,Yc[g+1]=r,Yc[g+2]=c,Yc[g+3]=h}const nl=new Uint16Array(2178),Kc=new Uint8Array(1089),lv=new Uint16Array(1089);function LC(n){return n===0?-.03125:n===32?.03125:0}const zC={Other:0,Symbol:1,FillExtrusion:2},kC={type:2,extent:_t,loadGeometry:()=>[[new it(0,0),new it(8193,0),new it(8193,8193),new it(0,8193),new it(0,0)]]};class v3{constructor(){this.tasks={},this.taskQueue=[],Le(["process"],this),this.invoker=new y3(this.process),this.nextId=0}add(e,t){const r=this.nextId++,c=function({type:h,renderSourceType:f,zoom:_}){_=_||0;const g=f===zC.Symbol;return h==="message"?0:h!=="maybePrepare"||g?h!=="parseTile"||g?h==="parseTile"&&g?300-_:h==="maybePrepare"&&g?400-_:500:200-_:100-_}(t);if(c===0){try{e()}finally{}return null}return this.tasks[r]={fn:e,metadata:t,priority:c,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(r=>!!this.tasks[r]),!this.taskQueue.length)return;const e=this.pick();if(e===null)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 c=0;c<this.taskQueue.length;c++){const h=this.tasks[this.taskQueue[c]];h.priority<t&&(t=h.priority,e=c)}if(e===null)return null;const r=this.taskQueue[e];return this.taskQueue.splice(e,1),r}remove(){this.invoker.remove()}}const hw=new Ii(0,0,0);function b3(n,e,t){n===1&&e.icons.push(function(r,c){return function(h){if(h.usvg_tree.height||(h.usvg_tree.height=h.usvg_tree.width),!h.metadata)return h;const{metadata:f}=h;if(f.content_area){const{content_area:_}=f;_.left==null&&(_.left=0),_.top==null&&(_.top=_.left),_.width==null&&(_.width=h.usvg_tree.width),_.height==null&&(_.height=_.width)}if(f.text_placeholder){const{text_placeholder:_}=f;_.top==null&&(_.top=_.left),_.height==null&&(_.height=_.width)}return f.stretch_x&&f.stretch_x.length&&FC(f,"x"),f.stretch_y&&f.stretch_y.length&&FC(f,"y"),h}(r.readFields(w3,{name:void 0},c))}(t,t.readVarint()+t.pos))}function FC(n,e){const t=[],r=n[`stretch_${e}`];let c=null;for(let h=0;h<r.length;h++)c===null?c=t.length===0?r[0]:t[t.length-1][1]+r[h]:(t.push([c,c+r[h]]),c=null);n[`stretch_${e}_areas`]=t}function w3(n,e,t){n===1?e.name=t.readString():n===2?e.metadata=function(r,c){return r.readFields(T3,{stretch_x:null,stretch_y:null,stretch_x_areas:null,stretch_y_areas:null,variables:[]},c)}(t,t.readVarint()+t.pos):n===3&&(e.usvg_tree=function(r,c){return r.readFields(I3,{width:20,children:[],linear_gradients:[],radial_gradients:[],clip_paths:[],masks:[]},c)}(t,t.readVarint()+t.pos),e.data="usvg_tree")}function T3(n,e,t){n===1?e.stretch_x=t.readPackedVarint():n===2?e.stretch_y=t.readPackedVarint():n===3?e.content_area=OC(t,t.readVarint()+t.pos):n===4?e.variables.push(function(r,c){return r.readFields(E3,{name:void 0},c)}(t,t.readVarint()+t.pos)):n===5&&(e.text_placeholder=OC(t,t.readVarint()+t.pos))}function OC(n,e){return n.readFields(S3,{},e)}function S3(n,e,t){n===1?e.left=t.readVarint():n===2?e.width=t.readVarint():n===3?e.top=t.readVarint():n===4&&(e.height=t.readVarint())}function E3(n,e,t){n===1?e.name=t.readString():n===2&&(e.rgb_color=hv(t.readVarint()),e.value="rgb_color")}function I3(n,e,t){n===1?e.width=e.height=t.readVarint():n===2?e.height=t.readVarint():n===3?e.children.push(cv(t,t.readVarint()+t.pos)):n===4?e.linear_gradients.push(function(r,c){return r.readFields(L3,{spread_method:1,stops:[],x1:0,y1:0,x2:1,y2:0},c)}(t,t.readVarint()+t.pos)):n===5?e.radial_gradients.push(function(r,c){return r.readFields(k3,{spread_method:1,stops:[],cx:.5,cy:.5,r:.5,fx:.5,fy:.5,fr:0},c)}(t,t.readVarint()+t.pos)):n===7?e.clip_paths.push(function(r,c){return r.readFields(F3,{children:[]},c)}(t,t.readVarint()+t.pos)):n===8&&e.masks.push(function(r,c){const h=r.readFields(O3,{left:0,width:20,mask_type:1,children:[]},c);return h.height==null&&(h.height=h.width),h.top==null&&(h.top=h.left),h}(t,t.readVarint()+t.pos))}function cv(n,e){return n.readFields(A3,{},e)}function A3(n,e,t){n===1?(e.group=function(r,c){return r.readFields(C3,{opacity:255,children:[]},c)}(t,t.readVarint()+t.pos),e.node="group"):n===2&&(e.path=function(r,c){return r.readFields(M3,{paint_order:1,commands:[],step:1,diffs:[],rule:1},c)}(t,t.readVarint()+t.pos),e.node="path")}function C3(n,e,t){n===1?e.transform=uv(t,t.readVarint()+t.pos):n===2?e.opacity=t.readVarint():n===5?e.clip_path_idx=t.readVarint():n===6?e.mask_idx=t.readVarint():n===7&&e.children.push(cv(t,t.readVarint()+t.pos))}function uv(n,e){return n.readFields(P3,{sx:1,ky:0,kx:0,sy:1,tx:0,ty:0},e)}function P3(n,e,t){n===1?e.sx=t.readFloat():n===2?e.ky=t.readFloat():n===3?e.kx=t.readFloat():n===4?e.sy=t.readFloat():n===5?e.tx=t.readFloat():n===6&&(e.ty=t.readFloat())}function M3(n,e,t){n===1?e.fill=function(r,c){return r.readFields(R3,{rgb_color:hw,paint:"rgb_color",opacity:255},c)}(t,t.readVarint()+t.pos):n===2?e.stroke=function(r,c){return r.readFields(D3,{rgb_color:hw,paint:"rgb_color",dasharray:[],dashoffset:0,miterlimit:4,opacity:255,width:1,linecap:1,linejoin:1},c)}(t,t.readVarint()+t.pos):n===3?e.paint_order=t.readVarint():n===5?t.readPackedVarint(e.commands):n===6?e.step=t.readFloat():n===7?t.readPackedSVarint(e.diffs):n===8&&(e.rule=t.readVarint())}function R3(n,e,t){n===1?(e.rgb_color=hv(t.readVarint()),e.paint="rgb_color"):n===2?(e.linear_gradient_idx=t.readVarint(),e.paint="linear_gradient_idx"):n===3?(e.radial_gradient_idx=t.readVarint(),e.paint="radial_gradient_idx"):n===5&&(e.opacity=t.readVarint())}function hv(n){return new Ii((n>>16&255)/255,(n>>8&255)/255,(255&n)/255,1)}function D3(n,e,t){n===1?(e.rgb_color=hv(t.readVarint()),e.paint="rgb_color"):n===2?(e.linear_gradient_idx=t.readVarint(),e.paint="linear_gradient_idx"):n===3?(e.radial_gradient_idx=t.readVarint(),e.paint="radial_gradient_idx"):n===5?t.readPackedFloat(e.dasharray):n===6?e.dashoffset=t.readFloat():n===7?e.miterlimit=t.readFloat():n===8?e.opacity=t.readVarint():n===9?e.width=t.readFloat():n===10?e.linecap=t.readVarint():n===11&&(e.linejoin=t.readVarint())}function L3(n,e,t){n===1?e.transform=uv(t,t.readVarint()+t.pos):n===2?e.spread_method=t.readVarint():n===3?e.stops.push(BC(t,t.readVarint()+t.pos)):n===4?e.x1=t.readFloat():n===5?e.y1=t.readFloat():n===6?e.x2=t.readFloat():n===7&&(e.y2=t.readFloat())}function BC(n,e){return n.readFields(z3,{offset:0,opacity:255,rgb_color:hw},e)}function z3(n,e,t){n===1?e.offset=t.readFloat():n===2?e.opacity=t.readVarint():n===3&&(e.rgb_color=hv(t.readVarint()))}function k3(n,e,t){n===1?e.transform=uv(t,t.readVarint()+t.pos):n===2?e.spread_method=t.readVarint():n===3?e.stops.push(BC(t,t.readVarint()+t.pos)):n===4?e.cx=t.readFloat():n===5?e.cy=t.readFloat():n===6?e.r=t.readFloat():n===7?e.fx=t.readFloat():n===8?e.fy=t.readFloat():n===9&&(e.fr=t.readFloat())}function F3(n,e,t){n===1?e.transform=uv(t,t.readVarint()+t.pos):n===2?e.clip_path_idx=t.readVarint():n===3&&e.children.push(cv(t,t.readVarint()+t.pos))}function O3(n,e,t){n===1?e.left=e.top=t.readFloat():n===2?e.width=e.height=t.readFloat():n===3?e.top=t.readFloat():n===4?e.height=t.readFloat():n===5?e.mask_type=t.readVarint():n===6?e.mask_idx=t.readVarint():n===7&&e.children.push(cv(t,t.readVarint()+t.pos))}class B3{static calculate(e={},t=[]){const r=new Map,c=new Map;if(Object.keys(e).length===0)return r;t.forEach(h=>{c.set(h.name,h.rgb_color||new Ii(0,0,0))});for(const[h,f]of Object.entries(e))c.has(h)?r.set(c.get(h).toString(),f):console.warn(`Ignoring unknown image variable "${h}"`);return r}}function If(n,e=255,t){const r=e/255,c=n.toString(),h=t.has(c)?t.get(c).clone():n.clone();return h.a*=r,h.toString()}function D_(n,e){if(!qs()){const t=document.createElement("canvas");return t.width=n,t.height=e,t}return new OffscreenCanvas(n,e)}let dw,L_=null;function fw(n,e,t,r,c){for(const h of r.children)NC(n,e,t,h,c)}function NC(n,e,t,r,c){r.group?(n.save(),function(h,f,_,g,b){const S=g.mask_idx!=null?_.masks[g.mask_idx]:null,I=g.clip_path_idx!=null?_.clip_paths[g.clip_path_idx]:null;if(g.transform&&(f=Af(g.transform).preMultiplySelf(f)),!function(D,z,B){return D.opacity!==255||z||B}(g,I!=null,S!=null))return void fw(h,f,_,g,b);const A=D_(h.canvas.width,h.canvas.height),M=A.getContext("2d");fw(M,f,_,g,b),I&&ZC(M,f,_,I),S&&qC(M,f,_,S,b),h.globalAlpha=g.opacity/255,h.drawImage(A,0,0)}(n,e,t,r.group,c),n.restore()):r.path&&(n.save(),function(h,f,_,g,b){h.setTransform(f),g.paint_order===1?(VC(h,_,g,b),jC(h,_,g,b)):(jC(h,_,g,b),VC(h,_,g,b))}(n,e,t,r.path,c),n.restore())}function VC(n,e,t,r){const c=t.fill;if(!c)return;const h=c.opacity/255;switch(n.save(),n.beginPath(),WC(t,n),c.paint){case"rgb_color":n.fillStyle=If(c.rgb_color,c.opacity,r);break;case"linear_gradient_idx":{const f=e.linear_gradients[c.linear_gradient_idx];f.transform&&n.setTransform(Af(f.transform).preMultiplySelf(n.getTransform())),n.fillStyle=GC(n,f,h,r);break}case"radial_gradient_idx":{const f=e.radial_gradients[c.radial_gradient_idx];f.transform&&n.setTransform(Af(f.transform).preMultiplySelf(n.getTransform())),n.fillStyle=$C(n,f,h,r)}}n.fill(UC(t)),n.restore()}function UC(n){return n.rule===1?"nonzero":n.rule===2?"evenodd":void 0}function jC(n,e,t,r){const c=t.stroke;if(!c)return;const h=XC(t);n.lineWidth=c.width,n.miterLimit=c.miterlimit,n.setLineDash(c.dasharray),n.lineDashOffset=c.dashoffset;const f=c.opacity/255;switch(c.paint){case"rgb_color":n.strokeStyle=If(c.rgb_color,c.opacity,r);break;case"linear_gradient_idx":n.strokeStyle=GC(n,e.linear_gradients[c.linear_gradient_idx],f,r,!0);break;case"radial_gradient_idx":n.strokeStyle=$C(n,e.radial_gradients[c.radial_gradient_idx],f,r,!0)}switch(c.linejoin){case 2:case 1:n.lineJoin="miter";break;case 3:n.lineJoin="round";break;case 4:n.lineJoin="bevel"}switch(c.linecap){case 1:n.lineCap="butt";break;case 2:n.lineCap="round";break;case 3:n.lineCap="square"}n.stroke(h)}function GC(n,e,t,r,c=!1){if(e.stops.length===1){const A=e.stops[0];return If(A.rgb_color,A.opacity*t,r)}const{x1:h,y1:f,x2:_,y2:g}=e;let b=new DOMPoint(h,f),S=new DOMPoint(_,g);if(c){const A=Af(e.transform);b=A.transformPoint(b),S=A.transformPoint(S)}const I=n.createLinearGradient(b.x,b.y,S.x,S.y);for(const A of e.stops)I.addColorStop(A.offset,If(A.rgb_color,A.opacity*t,r));return I}function $C(n,e,t,r,c=!1){if(e.stops.length===1){const V=e.stops[0];return If(V.rgb_color,V.opacity*t,r)}const h=Af(e.transform),{fx:f,fy:_,fr:g,cx:b,cy:S,r:I}=e;let A=new DOMPoint(f,_),M=new DOMPoint(b,S),D=g,z=I;if(c){A=h.transformPoint(A),M=h.transformPoint(M);const V=(h.a+h.d)/2;D=g*V,z=e.r*V}const B=n.createRadialGradient(A.x,A.y,D,M.x,M.y,z);for(const V of e.stops)B.addColorStop(V.offset,If(V.rgb_color,V.opacity*t,r));return B}function HC(n,e,t,r){const c=r.transform?Af(r.transform).preMultiplySelf(e):e,h=D_(n.canvas.width,n.canvas.height),f=h.getContext("2d");for(const g of r.children)if(g.group)HC(f,c,t,g.group);else if(g.path){const b=g.path,S=new Path2D;S.addPath(XC(b),c),f.fill(S,UC(b))}const _=r.clip_path_idx!=null?t.clip_paths[r.clip_path_idx]:null;_&&ZC(f,c,t,_),n.globalCompositeOperation="source-over",n.drawImage(h,0,0)}function ZC(n,e,t,r){const c=D_(n.canvas.width,n.canvas.height);HC(c.getContext("2d"),e,t,r),n.globalCompositeOperation="destination-in",n.drawImage(c,0,0)}function qC(n,e,t,r,c){if(r.children.length===0)return;const h=r.mask_idx!=null?t.masks[r.mask_idx]:null;h&&qC(n,e,t,h,c);const f=n.canvas.width,_=n.canvas.height,g=D_(f,_),b=g.getContext("2d"),S=r.width,I=r.height,A=r.left,M=r.top,D=new Path2D,z=new Path2D;z.rect(A,M,S,I),D.addPath(z,e),b.clip(D);for(const Z of r.children)NC(b,e,t,Z,c);const B=b.getImageData(0,0,f,_),V=B.data;if(r.mask_type===1)for(let Z=0;Z<V.length;Z+=4)V[Z+3]=V[Z+3]/255*(.2126*V[Z]+.7152*V[Z+1]+.0722*V[Z+2]);b.putImageData(B,0,0),n.globalCompositeOperation="destination-in",n.drawImage(g,0,0)}function Af(n){return n?new DOMMatrix([n.sx,n.ky,n.kx,n.sy,n.tx,n.ty]):new DOMMatrix}function WC(n,e){const t=n.step;let r=n.diffs[0]*t,c=n.diffs[1]*t;e.moveTo(r,c);for(let h=0,f=2;h<n.commands.length;h++)switch(n.commands[h]){case 1:r+=n.diffs[f++]*t,c+=n.diffs[f++]*t,e.moveTo(r,c);break;case 2:r+=n.diffs[f++]*t,c+=n.diffs[f++]*t,e.lineTo(r,c);break;case 3:{const _=r+n.diffs[f++]*t,g=c+n.diffs[f++]*t;r=_+n.diffs[f++]*t,c=g+n.diffs[f++]*t,e.quadraticCurveTo(_,g,r,c);break}case 4:{const _=r+n.diffs[f++]*t,g=c+n.diffs[f++]*t,b=_+n.diffs[f++]*t,S=g+n.diffs[f++]*t;r=b+n.diffs[f++]*t,c=S+n.diffs[f++]*t,e.bezierCurveTo(_,g,b,S,r,c);break}case 5:e.closePath();break}return e}function XC(n){return WC(n,new Path2D)}class dv{constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}put(e,t){this.cache.has(e)?this.cache.delete(e):this.cache.size===this.capacity&&this.cache.delete(this.cache.keys().next().value),this.cache.set(e,t)}delete(e){this.cache.delete(e)}}wt(dv,"LRUCache");class pw{constructor(){this.cacheMap=new Map,this.cacheDependenciesMap=new Map}static _getImage(e){return new Fr(e,e.data)}getFromCache(e,t,r){return this.cacheMap.has(r)||this.cacheMap.set(r,new dv(150)),this.cacheMap.get(r).get(zl(e.toString(),t))}setInCache(e,t,r,c){this.cacheDependenciesMap.has(c)||this.cacheDependenciesMap.set(c,new Map),this.cacheMap.has(c)||this.cacheMap.set(c,new dv(150));const h=this.cacheDependenciesMap.get(c),f=zl(e.id.toString(),r);h.get(f)||h.set(f,new Set);const _=this.cacheMap.get(c),g=e.toString();h.get(f).add(g),_.put(zl(e.toString(),r),t)}removeImagesFromCacheByIds(e,t,r=0){if(!this.cacheMap.has(r)||!this.cacheDependenciesMap.has(r))return;const c=this.cacheMap.get(r),h=this.cacheDependenciesMap.get(r);for(const f of e){const _=zl(f.toString(),t);if(h.has(_)){for(const g of h.get(_))c.delete(g);h.delete(_)}}}rasterize(e,t,r,c){const h=this.getFromCache(e,r,c);if(h)return h.clone();const f=function(g,b){const S=B3.calculate(b.params,g.metadata?g.metadata.variables:[]),I=g.usvg_tree,A=I.width,M=I.height,D=Math.max(1,Math.round(A*b.sx)),z=Math.max(1,Math.round(M*b.sy)),B=new DOMMatrix([D/A,0,0,z/M,0,0]);return L_===null&&(L_=D_(10,10),dw=L_.getContext("2d",{willReadFrequently:!0})),L_.width=D,L_.height=z,fw(dw,B,I,I,S),dw.getImageData(0,0,D,z)}(t.icon,e),_=pw._getImage(f);return this.setInCache(e,_,r,c),_.clone()}}class YC{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const r=this.toIdx(e,t);return{min:this.minimums[r],max:this.maximums[r]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function KC(n,e,t,r){let c=0,h=Number.MAX_VALUE;for(let f=0;f<3;f++)if(Math.abs(r[f])<1e-15){if(t[f]<n[f]||t[f]>e[f])return null}else{const _=1/r[f];let g=(n[f]-t[f])*_,b=(e[f]-t[f])*_;if(g>b){const S=g;g=b,b=S}if(g>c&&(c=g),b<h&&(h=b),c>h)return null}return c}function JC(n,e,t,r,c,h,f,_,g,b,S){const I=r-n,A=c-e,M=h-t,D=f-n,z=_-e,B=g-t,V=S[1]*B-S[2]*z,Z=S[2]*D-S[0]*B,G=S[0]*z-S[1]*D,Y=I*V+A*Z+M*G;if(Math.abs(Y)<1e-15)return null;const Q=1/Y,te=b[0]-n,me=b[1]-e,ce=b[2]-t,pe=(te*V+me*Z+ce*G)*Q;if(pe<0||pe>1)return null;const he=me*M-ce*A,de=ce*I-te*M,Be=te*A-me*I,je=(S[0]*he+S[1]*de+S[2]*Be)*Q;return je<0||pe+je>1?null:(D*he+z*de+B*Be)*Q}function QC(n,e,t){return(n-e)/(t-e)}function eP(n,e,t,r,c,h,f,_,g){const b=1<<t,S=h-r,I=f-c,A=(n+1)/b*S+r,M=(e+0)/b*I+c,D=(e+1)/b*I+c;_[0]=(n+0)/b*S+r,_[1]=M,g[0]=A,g[1]=D}class tP{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(h){const f=Math.ceil(Math.log2(h.dim/8)),_=[];let g=Math.ceil(Math.pow(2,f));const b=1/g,S=(M,D,z,B,V)=>{const Z=B?1:0,G=(M+1)*z-Z,Y=D*z,Q=(D+1)*z-Z;V[0]=M*z,V[1]=Y,V[2]=G,V[3]=Q};let I=new YC(g);const A=[];for(let M=0;M<g*g;M++){S(M%g,Math.floor(M/g),b,!1,A);const D=Jc(A[0],A[1],h),z=Jc(A[2],A[1],h),B=Jc(A[2],A[3],h),V=Jc(A[0],A[3],h);I.minimums.push(Math.min(D,z,B,V)),I.maximums.push(Math.max(D,z,B,V)),I.leaves.push(1)}for(_.push(I),g/=2;g>=1;g/=2){const M=_[_.length-1];I=new YC(g);for(let D=0;D<g*g;D++){S(D%g,Math.floor(D/g),2,!0,A);const z=M.getElevation(A[0],A[1]),B=M.getElevation(A[2],A[1]),V=M.getElevation(A[2],A[3]),Z=M.getElevation(A[0],A[3]),G=M.isLeaf(A[0],A[1]),Y=M.isLeaf(A[2],A[1]),Q=M.isLeaf(A[2],A[3]),te=M.isLeaf(A[0],A[3]),me=Math.min(z.min,B.min,V.min,Z.min),ce=Math.max(z.max,B.max,V.max,Z.max),pe=G&&Y&&Q&&te;I.maximums.push(ce),I.minimums.push(me),I.leaves.push(ce-me<=5&&pe?1:0)}_.push(I)}return _}(this.dem),r=t.length-1,c=t[r];this._addNode(c.minimums[0],c.maximums[0],c.leaves[0]),this._construct(t,0,0,r,0)}raycastRoot(e,t,r,c,h,f,_=1){return KC([e,t,-100],[r,c,this.maximums[0]*_],h,f)}raycast(e,t,r,c,h,f,_=1){if(!this.nodeCount)return null;const g=this.raycastRoot(e,t,r,c,h,f,_);if(g==null)return null;const b=[],S=[],I=[],A=[],M=[{idx:0,t:g,nodex:0,nodey:0,depth:0}];for(;M.length>0;){const{idx:D,t:z,nodex:B,nodey:V,depth:Z}=M.pop();if(this.leaves[D]){eP(B,V,Z,e,t,r,c,I,A);const Y=1<<Z,Q=(B+0)/Y,te=(B+1)/Y,me=(V+0)/Y,ce=(V+1)/Y,pe=Jc(Q,me,this.dem)*_,he=Jc(te,me,this.dem)*_,de=Jc(te,ce,this.dem)*_,Be=Jc(Q,ce,this.dem)*_,je=JC(I[0],I[1],pe,A[0],I[1],he,A[0],A[1],de,h,f),He=JC(A[0],A[1],de,I[0],A[1],Be,I[0],I[1],pe,h,f),Xe=Math.min(je!==null?je:Number.MAX_VALUE,He!==null?He:Number.MAX_VALUE);if(Xe!==Number.MAX_VALUE)return Xe;{const Ze=rn([],h,f,z);if(iP(pe,he,Be,de,QC(Ze[0],I[0],A[0]),QC(Ze[1],I[1],A[1]))>=Ze[2])return z}continue}let G=0;for(let Y=0;Y<this._siblingOffset.length;Y++){eP((B<<1)+this._siblingOffset[Y][0],(V<<1)+this._siblingOffset[Y][1],Z+1,e,t,r,c,I,A),I[2]=-100,A[2]=this.maximums[this.childOffsets[D]+Y]*_;const Q=KC(I,A,h,f);if(Q!=null){const te=Q;b[Y]=te;let me=!1;for(let ce=0;ce<G&&!me;ce++)te>=b[S[ce]]&&(S.splice(ce,0,Y),me=!0);me||(S[G]=Y),G++}}for(let Y=0;Y<G;Y++){const Q=S[Y];M.push({idx:this.childOffsets[D]+Q,t:b[Q],nodex:(B<<1)+this._siblingOffset[Q][0],nodey:(V<<1)+this._siblingOffset[Q][1],depth:Z+1})}}return null}_addNode(e,t,r){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(r),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,r,c,h){if(e[c].isLeaf(t,r)===1)return;this.childOffsets[h]||(this.childOffsets[h]=this.nodeCount);const f=c-1,_=e[f];let g=0,b=0;for(let S=0;S<this._siblingOffset.length;S++){const I=2*t+this._siblingOffset[S][0],A=2*r+this._siblingOffset[S][1],M=_.getElevation(I,A),D=_.isLeaf(I,A),z=this._addNode(M.min,M.max,D);D&&(g|=1<<S),b||(b=z)}for(let S=0;S<this._siblingOffset.length;S++)g&1<<S||this._construct(e,2*t+this._siblingOffset[S][0],2*r+this._siblingOffset[S][1],f,b+S)}}function iP(n,e,t,r,c,h){return Gt(Gt(n,t,h),Gt(e,r,h),c)}function Jc(n,e,t){const r=t.dim,c=q(n*r-.5,0,r-1),h=q(e*r-.5,0,r-1),f=Math.floor(c),_=Math.floor(h),g=Math.min(f+1,r-1),b=Math.min(_+1,r-1);return iP(t.get(f,_),t.get(g,_),t.get(f,b),t.get(g,b),c-f,h-_)}const N3={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function V3(n,e,t){return(256*n*256+256*e+t)/10-1e4}function U3(n,e,t){return 256*n+e+t/256-32768}class fv{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,r,c=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(r&&r!=="mapbox"&&r!=="terrarium")return void zt(`"${r}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const h=this.dim=t.height-2,f=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.floatView=new Float32Array(t.data.buffer),this.borderReady=c,this._modifiedForSources={},!c){for(let g=0;g<h;g++)f[this._idx(-1,g)]=f[this._idx(0,g)],f[this._idx(h,g)]=f[this._idx(h-1,g)],f[this._idx(g,-1)]=f[this._idx(g,0)],f[this._idx(g,h)]=f[this._idx(g,h-1)];f[this._idx(-1,-1)]=f[this._idx(0,0)],f[this._idx(h,-1)]=f[this._idx(h-1,0)],f[this._idx(-1,h)]=f[this._idx(0,h-1)],f[this._idx(h,h)]=f[this._idx(h-1,h-1)]}const _=r==="terrarium"?U3:V3;for(let g=0;g<f.length;++g){const b=4*g;this.floatView[g]=_(this.pixels[b],this.pixels[b+1],this.pixels[b+2])}this._timestamp=ts.now()}_buildQuadTree(){this._tree=new tP(this)}get(e,t,r=!1){r&&(e=q(e,-1,this.dim),t=q(t,-1,this.dim));const c=this._idx(e,t);return this.floatView[c]}set(e,t,r){const c=this._idx(e,t),h=this.floatView[c];return this.floatView[c]=r,r-h}static getUnpackVector(e){return N3[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 r=[0,0,0,0],c=fv.getUnpackVector(t);let h=Math.floor((e+c[3])/c[2]);return r[2]=h%256,h=Math.floor(h/256),r[1]=h%256,h=Math.floor(h/256),r[0]=h,r}getPixels(){return new OE({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let c=t*this.dim,h=t*this.dim+this.dim,f=r*this.dim,_=r*this.dim+this.dim;switch(t){case-1:c=h-1;break;case 1:h=c+1}switch(r){case-1:f=_-1;break;case 1:_=f+1}const g=-t*this.dim,b=-r*this.dim;for(let S=f;S<_;S++)for(let I=c;I<h;I++){const A=4*this._idx(I,S),M=4*this._idx(I+g,S+b);this.pixels[A+0]=e.pixels[M+0],this.pixels[A+1]=e.pixels[M+1],this.pixels[A+2]=e.pixels[M+2],this.pixels[A+3]=e.pixels[M+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}function j3(n,e,t){n===1?e.headerLength=t.readFixed32():n===2?e.x=t.readVarint():n===3?e.y=t.readVarint():n===4?e.z=t.readVarint():n===5&&e.layers.push(function(r,c){return r.readFields(q3,{version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]},c)}(t,t.readVarint()+t.pos))}function G3(n,e,t){n===1?(e.delta_filter=function(r,c){return r.readFields($3,{blockSize:0},c)}(t,t.readVarint()+t.pos),e.filter="delta_filter"):n===2?(t.readVarint(),e.filter="zigzag_filter"):n===3?(t.readVarint(),e.filter="bitshuffle_filter"):n===4&&(t.readVarint(),e.filter="byteshuffle_filter")}function $3(n,e,t){n===1&&(e.blockSize=t.readVarint())}function H3(n,e,t){n===1?(t.readVarint(),e.codec="gzip_data"):n===2?(t.readVarint(),e.codec="jpeg_image"):n===3?(t.readVarint(),e.codec="webp_image"):n===4&&(t.readVarint(),e.codec="png_image")}function Z3(n,e,t){let r=0,c=0;n===1?e.firstByte=t.readFixed64():n===2?e.lastByte=t.readFixed64():n===3?e.filters.push(function(h,f){return h.readFields(G3,{},f)}(t,t.readVarint()+t.pos)):n===4?e.codec=function(h,f){return h.readFields(H3,{},f)}(t,t.readVarint()+t.pos):n===5?c=t.readFloat():n===6?r=t.readFloat():n===7?e.bands.push(t.readString()):n===8?e.offset=t.readDouble():n===9&&(e.scale=t.readDouble()),e.offset===0&&(e.offset=c),e.scale===0&&(e.scale=r)}function q3(n,e,t){n===1?e.version=t.readVarint():n===2?e.name=t.readString():n===3?e.units=t.readString():n===4?e.tileSize=t.readVarint():n===5?e.buffer=t.readVarint():n===6?e.pixelFormat=t.readVarint():n===7&&e.dataIndex.push(function(r,c){return r.readFields(Z3,{firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},c)}(t,t.readVarint()+t.pos))}function W3(n,e,t){if(n===2)(function(r,c,h){r.readFields(X3,h,c)})(t,t.readVarint()+t.pos,e);else if(n===3)throw new Error("Not implemented")}function X3(n,e,t){if(n===1){let r=0;const c=t.readVarint()+t.pos;for(;t.pos<c;)e[r++]=t.readVarint()}}function Y3(n,e){if(e.length!==4)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let t=e[3];for(let r=2;r>=1;r--){const c=r===1?1:0,h=r===2?1:0;for(let f=0;f<e[0];f++){const _=e[1]*f;for(let g=c;g<e[1];g++){const b=e[2]*(g+_);for(let S=h;S<e[2];S++){const I=e[3]*(S+b);for(let A=0;A<e[3];A++){const M=I+A;n[M]+=n[M-t]}}}}t*=e[r]}return n}function K3(n){for(let e=0,t=n.length;e<t;e++)n[e]=n[e]>>>1^-(1&n[e]);return n}function J3(n,e){switch(e){case"uint32":return n;case"uint16":for(let t=0;t<n.length;t+=2){const r=n[t],c=n[t+1];n[t]=(240&r)>>4|(61440&r)>>8|(240&c)<<4|61440&c,n[t+1]=15&r|(3840&r)>>4|(15&c)<<8|(3840&c)<<4}return n;case"uint8":for(let t=0;t<n.length;t+=4){const r=n[t],c=n[t+1],h=n[t+2],f=n[t+3];n[t+0]=(192&r)>>6|(192&c)>>4|(192&h)>>2|192&f,n[t+1]=(48&r)>>4|(48&c)>>2|48&h|(48&f)<<2,n[t+2]=(12&r)>>2|12&c|(12&h)<<2|(12&f)<<4,n[t+3]=3&r|(3&c)<<2|(3&h)<<4|(3&f)<<6}return n;default:throw new Error(`Invalid pixel format, "${e}"`)}}wt(fv,"DEMData"),wt(tP,"DemMinMaxQuadTree",{omit:["dem"]});var yo=Uint8Array,z_=Uint16Array,Q3=Int32Array,nP=new yo([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]),rP=new yo([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]),eN=new yo([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),sP=function(n,e){for(var t=new z_(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];var c=new Q3(t[30]);for(r=1;r<30;++r)for(var h=t[r];h<t[r+1];++h)c[h]=h-t[r]<<5|r;return{b:t,r:c}},oP=sP(nP,2),aP=oP.b,tN=oP.r;aP[28]=258,tN[258]=28;for(var iN=sP(rP,0).b,lP=new z_(32768),Yn=0;Yn<32768;++Yn){var Cf=(43690&Yn)>>1|(21845&Yn)<<1;lP[Yn]=((65280&(Cf=(61680&(Cf=(52428&Cf)>>2|(13107&Cf)<<2))>>4|(3855&Cf)<<4))>>8|(255&Cf)<<8)>>1}var k_=function(n,e,t){for(var r=n.length,c=0,h=new z_(e);c<r;++c)n[c]&&++h[n[c]-1];var f,_=new z_(e);for(c=1;c<e;++c)_[c]=_[c-1]+h[c-1]<<1;f=new z_(1<<e);var g=15-e;for(c=0;c<r;++c)if(n[c])for(var b=c<<4|n[c],S=e-n[c],I=_[n[c]-1]++<<S,A=I|(1<<S)-1;I<=A;++I)f[lP[I]>>g]=b;return f},F_=new yo(288);for(Yn=0;Yn<144;++Yn)F_[Yn]=8;for(Yn=144;Yn<256;++Yn)F_[Yn]=9;for(Yn=256;Yn<280;++Yn)F_[Yn]=7;for(Yn=280;Yn<288;++Yn)F_[Yn]=8;var cP=new yo(32);for(Yn=0;Yn<32;++Yn)cP[Yn]=5;var nN=k_(F_,9),rN=k_(cP,5),mw=function(n){for(var e=n[0],t=1;t<n.length;++t)n[t]>e&&(e=n[t]);return e},ba=function(n,e,t){var r=e/8|0;return(n[r]|n[r+1]<<8)>>(7&e)&t},_w=function(n,e){var t=e/8|0;return(n[t]|n[t+1]<<8|n[t+2]<<16)>>(7&e)},sN=function(n){return(n+7)/8|0},oN=["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"],wa=function(n,e,t){var r=new Error(e||oN[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,wa),!t)throw r;return r},aN=new yo(0),lN=typeof TextDecoder<"u"&&new TextDecoder;try{lN.decode(aN,{stream:!0})}catch{}const cN={gzip_data:"gzip"};class qo extends Error{constructor(e){super(e),this.name="MRTError"}}const uN={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},uP={uint32:1,uint16:2,uint8:4},hN={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let gw;class pv{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){const t=this.layers[e];if(!t)throw new qo(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),r=new DataView(e);if(t[0]!==13)throw new qo("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),r=this.getHeaderLength(e);if(t.length<r)throw new qo(`Expected header with length >= ${r} but got buffer of length ${t.length}`);const c=new gw(t.subarray(0,r)).readFields(j3,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==c.x||this.y!==c.y||this.z!==c.z))throw new qo(`Invalid attempt to parse header ${c.z}/${c.x}/${c.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=c.x,this.y=c.y,this.z=c.z;for(const h of c.layers)this.layers[h.name]=new hP(h,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],r=this.getLayer(e.layerName);for(let c of e.blockIndices){const h=r.dataIndex[c],f=h.firstByte-e.firstByte,_=h.lastByte-e.firstByte;if(r._blocksInProgress.has(c))continue;const g={layerName:r.name,firstByte:f,lastByte:_,pixelFormat:r.pixelFormat,blockIndex:c,blockShape:[h.bands.length].concat(r.bandShape),buffer:r.buffer,codec:h.codec.codec,filters:h.filters.map(b=>b.filter)};r._blocksInProgress.add(c),t.push(g)}return new dP(t,()=>{t.forEach(c=>r._blocksInProgress.delete(c.blockIndex))},(c,h)=>{if(t.forEach(f=>r._blocksInProgress.delete(f.blockIndex)),c)throw c;h.forEach(f=>{this.getLayer(f.layerName).processDecodedData(f)})})}}class hP{constructor({version:e,name:t,units:r,tileSize:c,pixelFormat:h,buffer:f,dataIndex:_},g){if(this.version=e,this.version!==1)throw new qo(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=r,this.tileSize=c,this.buffer=f,this.pixelFormat=uN[h],this.dataIndex=_,this.bandShape=[c+2*f,c+2*f,uP[this.pixelFormat]],this._decodedBlocks=new dv(g?g.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return uP[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[r,c]of this.dataIndex.entries()){for(const[h,f]of c.bands.entries())if(f===e)return{bandIndex:t+h,blockIndex:r,blockBandIndex:h};t+=c.bands.length}break;case"number":for(const[r,c]of this.dataIndex.entries()){if(e>=t&&e<t+c.bands.length)return{bandIndex:e,blockIndex:r,blockBandIndex:e-t};t+=c.bands.length}break;default:throw new qo(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}return{blockIndex:-1,blockBandIndex:-1}}getDataRange(e){let t=1/0,r=-1/0;const c=[],h=new Set;for(const f of e){const{blockIndex:_}=this.getBlockForBand(f);if(_<0)throw new qo(`Invalid band: ${JSON.stringify(f)}`);const g=this.dataIndex[_];c.includes(_)||c.push(_),h.add(_),t=Math.min(t,g.firstByte),r=Math.max(r,g.lastByte)}if(h.size>this.cacheSize)throw new qo(`Number of blocks to decode (${h.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:t,lastByte:r,blockIndices:c}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:r}=this.getBlockForBand(e);if(t<0)throw new qo(`Band not found: ${JSON.stringify(e)}`);const c=this._decodedBlocks.get(t.toString());if(!c)throw new qo(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const h=this.dataIndex[t],f=this.bandShape.reduce((b,S)=>b*S,1),_=r*f,g=c.subarray(_,_+f);return{data:g,bytes:new Uint8Array(g.buffer).subarray(g.byteOffset,g.byteOffset+g.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:h.offset,scale:h.scale}}}pv.setPbf=function(n){gw=n};class dP{constructor(e,t,r){this.tasks=e,this._onCancel=t,this._onComplete=r,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}pv.performDecoding=function(n,e){const t=new Uint8Array(n);return Promise.all(e.tasks.map(r=>{const{layerName:c,firstByte:h,lastByte:f,pixelFormat:_,blockShape:g,blockIndex:b,filters:S,codec:I}=r,A=t.subarray(h,f+1),M=new Uint32Array(g[0]*g[1]*g[2]);let D;if(I!=="gzip_data")throw new qo(`Unhandled codec: ${I}`);return D=function(z,B){if(!globalThis.DecompressionStream&&B==="gzip_data")return Promise.resolve((Q=function(ce){ce[0]==31&&ce[1]==139&&ce[2]==8||wa(6,"invalid gzip data");var pe=ce[3],he=10;4&pe&&(he+=2+(ce[10]|ce[11]<<8));for(var de=(pe>>3&1)+(pe>>4&1);de>0;de-=!ce[he++]);return he+(2&pe)}(V=z),Q+8>V.length&&wa(6,"invalid gzip data"),function(ce,pe,he,de){var Be=ce.length;if(!Be||pe.f&&!pe.l)return he||new yo(0);var je=!he,He=je||pe.i!=2,Xe=pe.i;je&&(he=new yo(3*Be));var Ze=function(yn){var Gr=he.length;if(yn>Gr){var ur=new yo(Math.max(2*Gr,yn));ur.set(he),he=ur}},nt=pe.f||0,Fe=pe.p||0,We=pe.b||0,Qe=pe.l,st=pe.d,ut=pe.m,bt=pe.n,mt=8*Be;do{if(!Qe){nt=ba(ce,Fe,1);var pt=ba(ce,Fe+1,3);if(Fe+=3,!pt){var ht=ce[(Ri=sN(Fe)+4)-4]|ce[Ri-3]<<8,yt=Ri+ht;if(yt>Be){Xe&&wa(0);break}He&&Ze(We+ht),he.set(ce.subarray(Ri,yt),We),pe.b=We+=ht,pe.p=Fe=8*yt,pe.f=nt;continue}if(pt==1)Qe=nN,st=rN,ut=9,bt=5;else if(pt==2){var It=ba(ce,Fe,31)+257,kt=ba(ce,Fe+10,15)+4,Ct=It+ba(ce,Fe+5,31)+1;Fe+=14;for(var Qt=new yo(Ct),vi=new yo(19),ei=0;ei<kt;++ei)vi[eN[ei]]=ba(ce,Fe+3*ei,7);Fe+=3*kt;var wi=mw(vi),ai=(1<<wi)-1,gn=k_(vi,wi);for(ei=0;ei<Ct;){var Ri,Si=gn[ba(ce,Fe,ai)];if(Fe+=15&Si,(Ri=Si>>4)<16)Qt[ei++]=Ri;else{var qi=0,dn=0;for(Ri==16?(dn=3+ba(ce,Fe,3),Fe+=2,qi=Qt[ei-1]):Ri==17?(dn=3+ba(ce,Fe,7),Fe+=3):Ri==18&&(dn=11+ba(ce,Fe,127),Fe+=7);dn--;)Qt[ei++]=qi}}var rr=Qt.subarray(0,It),fn=Qt.subarray(It);ut=mw(rr),bt=mw(fn),Qe=k_(rr,ut),st=k_(fn,bt)}else wa(1);if(Fe>mt){Xe&&wa(0);break}}He&&Ze(We+131072);for(var Sn=(1<<ut)-1,Bn=(1<<bt)-1,En=Fe;;En=Fe){var Ir=(qi=Qe[_w(ce,Fe)&Sn])>>4;if((Fe+=15&qi)>mt){Xe&&wa(0);break}if(qi||wa(2),Ir<256)he[We++]=Ir;else{if(Ir==256){En=Fe,Qe=null;break}var sr=Ir-254;Ir>264&&(sr=ba(ce,Fe,(1<<(Rn=nP[ei=Ir-257]))-1)+aP[ei],Fe+=Rn);var ci=st[_w(ce,Fe)&Bn],Yr=ci>>4;if(ci||wa(3),Fe+=15&ci,fn=iN[Yr],Yr>3){var Rn=rP[Yr];fn+=_w(ce,Fe)&(1<<Rn)-1,Fe+=Rn}if(Fe>mt){Xe&&wa(0);break}He&&Ze(We+131072);var cr=We+sr;if(We<fn){var Kr=0-fn,Ar=Math.min(fn,cr);for(Kr+We<0&&wa(3);We<Ar;++We)he[We]=de[Kr+We]}for(;We<cr;++We)he[We]=he[We-fn]}}pe.l=Qe,pe.p=En,pe.b=We,pe.f=nt,Qe&&(nt=1,pe.m=ut,pe.d=st,pe.n=bt)}while(!nt);return We!=he.length&&je?function(yn,Gr,ur){return(ur==null||ur>yn.length)&&(ur=yn.length),new yo(yn.subarray(0,ur))}(he,0,We):he.subarray(0,We)}(V.subarray(Q,-8),{i:2},new yo(((G=V)[(Y=G.length)-4]|G[Y-3]<<8|G[Y-2]<<16|G[Y-1]<<24)>>>0),Z)));var V,Z,G,Y,Q;const te=cN[B];if(!te)throw new Error(`Unhandled codec: ${B}`);const me=new globalThis.DecompressionStream(te);return new Response(new Blob([z]).stream().pipeThrough(me)).arrayBuffer().then(ce=>new Uint8Array(ce))}(A,I).then(z=>(function(B,V){B.readFields(W3,V)}(new gw(z),M),new hN[_](M.buffer))),D.then(z=>{for(let B=S.length-1;B>=0;B--)switch(S[B]){case"delta_filter":Y3(z,g);break;case"zigzag_filter":K3(z);break;case"bitshuffle_filter":J3(z,_);break;default:throw new qo(`Unhandled filter "${S[B]}"`)}return{layerName:c,blockIndex:b,data:z}}).catch(z=>{throw z})}))},wt(dP,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),wt(pv,"MapboxRasterTile"),wt(hP,"MapboxRasterLayer",{omit:["_blocksInProgress"]});const fP=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class yw{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,r]=new Uint8Array(e,0,2);if(t!==219)throw new Error("Data does not appear to be in a KDBush format.");const c=r>>4;if(c!==1)throw new Error(`Got v${c} data when expected v1.`);const h=fP[15&r];if(!h)throw new Error("Unrecognized array type.");const[f]=new Uint16Array(e,2,1),[_]=new Uint32Array(e,4,1);return new yw(_,f,h,e)}constructor(e,t=64,r=Float64Array,c){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const h=fP.indexOf(this.ArrayType),f=2*e*this.ArrayType.BYTES_PER_ELEMENT,_=e*this.IndexArrayType.BYTES_PER_ELEMENT,g=(8-_%8)%8;if(h<0)throw new Error(`Unexpected typed array class: ${r}.`);c&&c instanceof ArrayBuffer?(this.data=c,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+_+g,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+f+_+g),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+_+g,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+h]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=t,r}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return xw(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,r,c){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:h,coords:f,nodeSize:_}=this,g=[0,h.length-1,0],b=[];for(;g.length;){const S=g.pop()||0,I=g.pop()||0,A=g.pop()||0;if(I-A<=_){for(let B=A;B<=I;B++){const V=f[2*B],Z=f[2*B+1];V>=e&&V<=r&&Z>=t&&Z<=c&&b.push(h[B])}continue}const M=A+I>>1,D=f[2*M],z=f[2*M+1];D>=e&&D<=r&&z>=t&&z<=c&&b.push(h[M]),(S===0?e<=D:t<=z)&&(g.push(A),g.push(M-1),g.push(1-S)),(S===0?r>=D:c>=z)&&(g.push(M+1),g.push(I),g.push(1-S))}return b}within(e,t,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:h,nodeSize:f}=this,_=[0,c.length-1,0],g=[],b=r*r;for(;_.length;){const S=_.pop()||0,I=_.pop()||0,A=_.pop()||0;if(I-A<=f){for(let B=A;B<=I;B++)mP(h[2*B],h[2*B+1],e,t)<=b&&g.push(c[B]);continue}const M=A+I>>1,D=h[2*M],z=h[2*M+1];mP(D,z,e,t)<=b&&g.push(c[M]),(S===0?e-r<=D:t-r<=z)&&(_.push(A),_.push(M-1),_.push(1-S)),(S===0?e+r>=D:t+r>=z)&&(_.push(M+1),_.push(I),_.push(1-S))}return g}}function xw(n,e,t,r,c,h){if(c-r<=t)return;const f=r+c>>1;pP(n,e,f,r,c,h),xw(n,e,t,r,f-1,1-h),xw(n,e,t,f+1,c,1-h)}function pP(n,e,t,r,c,h){for(;c>r;){if(c-r>600){const b=c-r+1,S=t-r+1,I=Math.log(b),A=.5*Math.exp(2*I/3),M=.5*Math.sqrt(I*A*(b-A)/b)*(S-b/2<0?-1:1);pP(n,e,t,Math.max(r,Math.floor(t-S*A/b+M)),Math.min(c,Math.floor(t+(b-S)*A/b+M)),h)}const f=e[2*t+h];let _=r,g=c;for(O_(n,e,r,t),e[2*c+h]>f&&O_(n,e,r,c);_<g;){for(O_(n,e,_,g),_++,g--;e[2*_+h]<f;)_++;for(;e[2*g+h]>f;)g--}e[2*r+h]===f?O_(n,e,r,g):(g++,O_(n,e,g,c)),g<=t&&(r=g+1),t<=g&&(c=g-1)}}function O_(n,e,t,r){vw(n,t,r),vw(e,2*t,2*r),vw(e,2*t+1,2*r+1)}function vw(n,e,t){const r=n[e];n[e]=n[t],n[t]=r}function mP(n,e,t,r){const c=n-t,h=e-r;return c*c+h*h}a.$=Cc,a.A=class{constructor(n,e,t){this.target=n,this.parent=e,this.mapId=t,this.callbacks={},this.cancelCallbacks={},Le(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new v3}send(n,e,t,r,c=!1,h){const f=Math.round(1e18*Math.random()).toString(36).substring(0,10);t&&(t.metadata=h,this.callbacks[f]=t);const _=new Set;return this.target.postMessage({id:f,type:n,hasCallback:!!t,targetMapId:r,mustQueue:c,sourceMapId:this.mapId,data:ha(e,_)},_),{cancel:()=>{t&&delete this.callbacks[f],this.target.postMessage({id:f,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(n){const e=n.data;if(!e)return;const t=e.id;if(t&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type==="<cancel>"){const r=this.cancelCallbacks[t];delete this.cancelCallbacks[t],r&&r.cancel()}else if(e.mustQueue||Wi(self)){const r=this.callbacks[t],c=this.scheduler.add(()=>this.processTask(t,e),r&&r.metadata||{type:"message"});c&&(this.cancelCallbacks[t]=c)}else this.processTask(t,e)}processTask(n,e){if(delete this.cancelCallbacks[n],e.type==="<response>"){const t=this.callbacks[n];delete this.callbacks[n],t&&(e.error?t(qa(e.error)):t(null,qa(e.data)))}else{const t=new Set,r=e.hasCallback?(h,f)=>{this.target.postMessage({id:n,type:"<response>",sourceMapId:this.mapId,error:h?ha(h):null,data:ha(f,t)},t)}:()=>{},c=qa(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,c,r);else if(this.parent.getWorkerSource){const h=e.type.split("."),{source:f,scope:_}=c;this.parent.getWorkerSource(e.sourceMapId,{type:h[0],source:f,scope:_,uid:0})[h[1]](c,r)}else r(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.B=xc,a.C=ho,a.D=Ks,a.E=Du,a.F=zl,a.G=2,a.H=v_,a.I=fs,a.J=LA,a.K=md,a.L=Xy,a.M=Ou,a.N=Bu,a.O=Od,a.P=it,a.Q=Fd,a.R=Mu,a.S=am,a.T=tl,a.U=nh,a.V=ov,a.W=Xd,a.X=Za,a.Y=cm,a.Z=No,a._=Al,a.a=function(n){return yi.API_CDN_URL_REGEX.test(n)},a.a$=jx,a.a0=ir,a.a1=Nu,a.a2=_d,a.a3=Op,a.a4=Cm,a.a5=class extends ov{},a.a6=lm,a.a7=Dy,a.a8=Ee,a.a9=function(n){const e=n.value;return e?_d(e)?aw(e,!0)?[]:[new ov(n.key,e,`invalid url "${e}"`)]:[new ov(n.key,e,`string expected, "${Ou(e)}" found`)]:[]},a.aA=aA,a.aB=function(n){let e=1/0,t=1/0,r=-1/0,c=-1/0;for(const h of n)e=Math.min(e,h.x),t=Math.min(t,h.y),r=Math.max(r,h.x),c=Math.max(c,h.y);return{min:new it(e,t),max:new it(r,c)}},a.aC=q,a.aD=ye,a.aE=vr,a.aF=ne,a.aG=ns,a.aH=Je,a.aI=vt,a.aJ=function(n,e){const t={};for(let r=0;r<e.length;r++){const c=e[r];c in n&&(t[c]=n[c])}return t},a.aK=Ne,a.aL=tt,a.aM=function(n){try{const e=new URL(n).pathname.split("/").pop()||"",t=e.lastIndexOf(".");return t>=0?e.slice(t+1):""}catch{return""}},a.aN=class{constructor(n){this.entries={},this.scheduler=n}request(n,e,t,r){const c=this.entries[n]=this.entries[n]||{callbacks:[]};if(c.result){const[h,f]=c.result;return this.scheduler?this.scheduler.add(()=>{r(h,f)},e):r(h,f),()=>{}}return c.callbacks.push(r),c.cancel||(c.cancel=t((h,f)=>{c.result=[h,f];for(const _ of c.callbacks)this.scheduler?this.scheduler.add(()=>{_(h,f)},e):_(h,f);setTimeout(()=>delete this.entries[n],3e3)})),()=>{c.result||(c.callbacks=c.callbacks.filter(h=>h!==r),c.callbacks.length||(c.cancel(),delete this.entries[n]))}}},a.aO=function(n,e,t){const r=JSON.stringify(n.request);return n.data&&(this.deduped.entries[r]={result:[null,n.data]}),this.deduped.request(r,{type:"parseTile",renderSourceType:n.renderSourceType,zoom:n.tileZoom},c=>{const h=gc(n.request,(f,_,g)=>{f?zp(f)?c(null,null):c(f):_&&c(null,{rawData:_,vectorTile:t?void 0:new Ci(new jx(_)),responseHeaders:new Map(g.entries())})});return()=>{h.cancel(),c(null,null)}},e)},a.aP=function(n){return n?{cacheControl:n.get("cache-control"),expires:n.get("expires")}:{cacheControl:void 0,expires:void 0}},a.aQ=function(n){Mp++,Mp>od&&(n.getActor().send("enforceCacheSizeLimit",sd),Mp=0)},a.aR=Xr,a.aS=pC,a.aT=wC,a.aU=ve,a.aV=fC,a.aW=function(n,e){const t=document.createElement("video");t.muted=!0,t.onloadstart=function(){e(null,t)};for(let r=0;r<n.length;r++){const c=document.createElement("source");u1(n[r])||(t.crossOrigin="Anonymous"),c.src=n[r],t.appendChild(c)}return{cancel:()=>{}}},a.aX=m_,a.aY=Lh,a.aZ=Le,a.a_=pv,a.aa=Wd,a.ab=on,a.ac=dt,a.ad=class{constructor(n){this.specification=n}possiblyEvaluate(n,e){return _i(n.expression.evaluate(e))}interpolate(n,e,t){return{x:Gt(n.x,e.x,t),y:Gt(n.y,e.y,t),z:Gt(n.z,e.z,t),azimuthal:Gt(n.azimuthal,e.azimuthal,t),polar:Gt(n.polar,e.polar,t)}}},a.ae=Mi,a.af=Pl,a.ag=Et,a.ah=mn,a.ai=Wn,a.aj=oe,a.ak=pa,a.al=Ul,a.am=Gt,a.an=_t,a.ao=fo,a.ap=Ei,a.aq=Ii,a.ar=class{constructor(n){this.specification=n}possiblyEvaluate(n,e){return function([t,r]){const c=_i([1,t,r]);return{x:c.x,y:c.y,z:c.z}}(n.expression.evaluate(e))}interpolate(n,e,t){return{x:Gt(n.x,e.x,t),y:Gt(n.y,e.y,t),z:Gt(n.z,e.z,t)}}},a.as=function(n,e,t=0,r=!0){const c=new it(t,t),h=n.sub(c),f=e.add(c),_=[h,new it(f.x,h.y),f,new it(h.x,f.y)];return r&&_.push(h.clone()),_},a.at=function(n,e){const t=[];for(let r=0;r<n.length;r++){const c=ge(r-1,-1,n.length-1),h=ge(r+1,-1,n.length-1),f=n[r],_=n[h],g=n[c].sub(f).unit(),b=_.sub(f).unit(),S=b.angleWithSep(g.x,g.y),I=g.add(b).unit().mult(-1*e/Math.sin(S/2));t.push(f.add(I))}return t},a.au=JA,a.av=Xa,a.aw=function(n,e,t=0){return ji(((e.x-t)*n.scale-n.x)*_t,(e.y*n.scale-n.y)*_t,Ue(e.z,e.y))},a.ax=Ln,a.ay=zi,a.az=fi,a.b=function(n){return yi.API_FONTS_REGEX.test(n)},a.b$=i,a.b0=class{constructor(n,e,t,r,c,h){this.tileID=n,this.uid=De(),this.uses=0,this.tileSize=e,this.tileZoom=t,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=c,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this._lastAvailableImagesCount=0,this._firstPrepareComplete=!1,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection),this.worldview=h,this._hasAppearances=null}registerFadeDuration(n){const e=n+this.timeAdded;e<ts.now()||this.fadeEndTime!==void 0&&e<this.fadeEndTime||(this.fadeEndTime=e)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=Mh(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(n,e,t){if(this.unloadVectorData(),this.state="loaded",n){n.featureIndex&&(this.latestFeatureIndex=n.featureIndex,n.rawTileData?(this.latestRawTileData=n.rawTileData,this.latestFeatureIndex.rawTileData=n.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=n.collisionBoxArray,this.buckets=DC(n.buckets,e.style),this.hasSymbolBuckets=!1,this.hasTunnelGeometry=!!n.hasTunnelGeometry;for(const r in this.buckets){const c=this.buckets[r];if(c instanceof va){if(this.hasSymbolBuckets=!0,!t)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const r in this.buckets){const c=this.buckets[r];if(c instanceof va&&c.hasRTLText){this.hasRTLText=!0,Wy();break}}this.queryPadding=0;for(const r in this.buckets){const c=this.buckets[r],h=e.style.getOwnLayer(r);if(!h)continue;const f=h.queryRadius(c)||0;this.queryPadding=Math.max(this.queryPadding,f)}n.imageAtlas&&(this.imageAtlas=e.style.imageManager.imageAtlasCache.getOrCache(n.imageAtlas)),n.glyphAtlasImage&&(this.glyphAtlasImage=n.glyphAtlasImage),n.lineAtlas&&(this.lineAtlas=n.lineAtlas),this._lastUpdatedBrightness=n.brightness}else this.collisionBoxArray=new Zm}unloadVectorData(){if(this.hasData()){for(const n in this.buckets)this.buckets[n].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture=null),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"}}loadModelData(n,e,t){n&&(n.resourceTiming&&(this.resourceTiming=n.resourceTiming),this.buckets=Object.assign({},this.buckets,DC(n.buckets,e.style)),n.featureIndex&&(this.latestFeatureIndex=n.featureIndex))}getBucket(n){return this.buckets[n.fqid]}upload(n,e){for(const c in this.buckets){const h=this.buckets[c];if(h.uploadPending()){let f={},_=[],g={zoom:0,pitch:0,brightness:0,worldview:""};if(e){if(e.style){_=e.style.listImages();const b=h.layers[0],S=b.sourceLayer||"_geojsonTileLayer",I=e.style.getLayerSourceCache(b);I&&(f=I._state.getState(S,void 0))}g={zoom:e.transform.zoom||0,pitch:e.transform.pitch||0,brightness:e.style.getBrightness()||0,worldview:e.worldview||""}}h.upload(n,this.tileID.canonical,f,_,g)}}const t=n.gl,r=this.imageAtlas;!r||this.imageAtlasTexture&&r.uploaded||(this.imageAtlasTexture=null,this.imageAtlasTexture=e.style.imageManager.imageAtlasCache.getTextureForAtlas(r,n,t.RGBA8),r.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new tl(n,this.glyphAtlasImage,t.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new tl(n,this.lineAtlas.image,t.R8),this.lineAtlas.uploaded=!0)}prepare(n,e,t){if(this.imageAtlas&&this.imageAtlasTexture&&e){const I=e.style.getLut(t);this.imageAtlas.patchUpdatedImages(n,this.imageAtlasTexture,t,I)}if(!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const r=e.style.getBrightness(),c=e.style.listImages(),h=c.length,f=e.style._changes.getUpdatedPaintProperties(),_=Object.keys(this.buckets).some(I=>this.buckets[I].layers.some(A=>f.has(A.fqid))),g=Object.keys(this.buckets).some(I=>this.buckets[I].layers.some(A=>A.hasTransition&&A.hasTransition())),b=this._firstPrepareComplete&&h!==this._lastAvailableImagesCount;this._hasAppearances===null&&(this._hasAppearances=this.hasAppearances(e));const S=this._lastUpdatedBrightness!==r;this._lastAvailableImagesCount=h,this._firstPrepareComplete=!0,(this._lastUpdatedBrightness||r||this._hasAppearances||_||g||b)&&(!(this._hasAppearances||_||g||b)&&this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this.updateBuckets(e,S,void 0,b||_||g,f,c),this._lastUpdatedBrightness=r))}evaluateQueryRenderedFeaturePadding(){let n=0;for(const e in this.buckets){const t=this.buckets[e];t.evaluateQueryRenderedFeaturePadding&&(n=Math.max(n,t.evaluateQueryRenderedFeaturePadding()))}return n}queryRenderedFeatures(n,e,t,r,c,h,f){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile)return{};const _=this.evaluateQueryRenderedFeaturePadding(),g=function(b,S){const I=Tt([],[.5*b.width,.5*-b.height,1]);return Ie(I,I,[1,-1,0]),ye(I,I,b.calculateProjMatrix(S.toUnwrapped())),Float32Array.from(I)}(c,this.tileID);return this.latestFeatureIndex.query(n,{tilespaceGeometry:e,pixelPosMatrix:g,transform:r,availableImages:t,tileTransform:this.tileTransform,worldview:this.worldview,queryRadius:_,scope:f})}querySourceFeatures(n,e){const t=this.latestFeatureIndex;if(!t||!t.rawTileData)return;const r=t.loadVTLayers(),c=e?e.sourceLayer:"",h=r._geojsonTileLayer||r[c];if(!h)return;const f=Yd(e&&e.filter),{z:_,x:g,y:b}=this.tileID.canonical,S={z:_,x:g,y:b};for(let I=0;I<h.length;I++){const A=h.feature(I);if(f.needGeometry){const z=oi(A,!0);if(!f.filter(new Mi(this.tileID.overscaledZ,{worldview:this.worldview}),z,this.tileID.canonical))continue}else if(!f.filter(new Mi(this.tileID.overscaledZ,{worldview:this.worldview}),A))continue;const M=t.getId(A,c),D=new Dh(A,_,g,b,M);D.tile=S,n.push(D)}}loaded(){return this.state==="loaded"||this.state==="errored"}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!this.imageAtlas.patternPositions.size}setExpiryData(n){const e=this.expirationTime;if(n.cacheControl){const t=zn(n.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"])}else n.expires&&(this.expirationTime=new Date(n.expires).getTime());if(this.expirationTime){const t=Date.now();let r=!1;if(this.expirationTime>t)r=!1;else if(e)if(this.expirationTime<e)r=!0;else{const c=this.expirationTime-e;c?this.expirationTime=t+Math.max(c,3e4):r=!0}else r=!0;r?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}refreshFeatureState(n,e){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData&&!this.latestFeatureIndex.is3DTile||!n)return;const t=n.style.listImages();this.updateBuckets(n,!1,e,void 0,void 0,t)}hasAppearances(n){for(const e in this.buckets)if(n.style.hasLayer(e)&&this.buckets[e].layers.some(t=>t.appearances&&t.appearances.length>0))return!0;return!1}updateBuckets(n,e,t,r,c,h){if(!this.latestFeatureIndex||!n.style)return;const f=h||n.style.listImages(),_=n.style.getBrightness(),g=c||new Set;for(const b in this.buckets){if(!n.style.hasLayer(b))continue;const S=this.buckets[b],I=S.layers[0],A=I.sourceLayer||"_geojsonTileLayer",M=n.style.getLayerSourceCache(I),D=S.layers.some(Q=>g.has(Q.fqid)),z=(r||D)&&S instanceof va?n.style.getOwnLayer(b):void 0;let B=t&&t[A]||{};M&&!t&&(B=M._state.getState(A,void 0));const V=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},Z=Object.keys(B).length>0&&!e;S.hasAppearances=S.layers.some(Q=>Q.appearances&&Q.appearances.length>0);const G=Z?S.stateDependentLayers:S.layers;if(Z&&S.stateDependentLayers.length!==0||e||D||r){const Q=this.latestFeatureIndex.loadVTLayers()[A];if(S.update(B,Q,f,V,G,e,_,this.tileID.canonical),(r||D)&&!e&&S instanceof va&&z&&z.type==="symbol"){const te=S;te.text&&te.text.uboBinder&&te.text.uboBinder.updateDynamicExpressions(z,Q,this.tileID.canonical,f,B,_),te.icon&&te.icon.uboBinder&&te.icon.uboBinder.updateDynamicExpressions(z,Q,this.tileID.canonical,f,B,_)}if(S instanceof va){const te=S,me=n.context;te.text&&te.text.uboBinder&&te.text.uboBinder.upload(me),te.icon&&te.icon.uboBinder&&te.icon.uboBinder.upload(me)}}if(Z&&S.stateDependentLayers.length!==0||e||S.hasAppearances){const Q={zoom:n.transform.zoom,pitch:n.transform.pitch,brightness:n.style.getBrightness()||0,worldview:n.worldview},te=S.updateAppearances(this.tileID.canonical,B,f,Q,n.imageManager,Z&&S.stateDependentLayers.length!==0);if(te&&te.hasUboChanges){const me=n.context;S instanceof va&&S.text&&S.text.uboBinder&&S.text.uboBinder.upload(me),S instanceof va&&S.icon&&S.icon.uboBinder&&S.icon.uboBinder.upload(me)}}(S instanceof Ux||S instanceof wx)&&n._terrain&&n._terrain.enabled&&M&&S.uploadPending()&&n._terrain._clearRenderCacheForTile(M.id,this.tileID);const Y=n&&n.style&&n.style.getOwnLayer(b);Y&&(this.queryPadding=Math.max(this.queryPadding,Y.queryRadius(S)||0))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<ts.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(n){this.symbolFadeHoldUntil=ts.now()+n}setTexture(n,e){const t=e.context,r=t.gl;this.texture=this.texture||e.getTileTexture(n.width),this.texture&&this.texture instanceof tl?this.texture.update(n):(this.texture=new tl(t,n,r.RGBA8,{useMipmap:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE))}setDependencies(n,e){const t={};for(const r of e)t[r]=!0;this.dependencies[n]=t}hasDependency(n,e){for(const t of n){const r=this.dependencies[t];if(r){for(const c of e)if(r[c])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(n,e){if(!e||e.name==="mercator"||this._tileDebugBuffer)return;const t=Ft(kC,this.tileID.canonical,this.tileTransform)[0],r=new ms,c=new Ol;for(let h=0;h<t.length;h++){const{x:f,y:_}=t[h];r.emplaceBack(f,_),c.emplaceBack(h)}c.emplaceBack(0),this._tileDebugIndexBuffer=n.createIndexBuffer(c),this._tileDebugBuffer=n.createVertexBuffer(r,Km.members),this._tileDebugSegments=$i.simpleSegment(0,0,r.length,c.length)}_makeTileBoundsBuffers(n,e){if(this._tileBoundsBuffer||!e||e.name==="mercator")return;const t=Ft(kC,this.tileID.canonical,this.tileTransform)[0];let r,c;if(this.isRaster){const h=function(f,_){const g=Mh(f,_),b=Math.pow(2,f.z);for(let z=0;z<il;z++)for(let B=0;B<il;B++){const V=we((f.x+(B+LC(B))/Zo)/b),Z=Oe((f.y+(z+LC(z))/Zo)/b),G=_.project(V,Z),Y=z*il+B;nl[2*Y+0]=Math.round((G.x*g.scale-g.x)*_t),nl[2*Y+1]=Math.round((G.y*g.scale-g.y)*_t)}Kc.fill(0),lv.fill(0);for(let z=2045;z>=0;z--){const B=4*z,V=Yc[B+0],Z=Yc[B+1],G=Yc[B+2],Y=Yc[B+3],Q=V+G>>1,te=Z+Y>>1,me=Q+te-Z,ce=te+V-Q,pe=Z*il+V,he=Y*il+G,de=te*il+Q,Be=Math.hypot((nl[2*pe+0]+nl[2*he+0])/2-nl[2*de+0],(nl[2*pe+1]+nl[2*he+1])/2-nl[2*de+1])>=16;Kc[de]=Kc[de]||(Be?1:0),z<1022&&(Kc[de]=Kc[de]||Kc[(Z+ce>>1)*il+(V+me>>1)]||Kc[(Y+ce>>1)*il+(G+me>>1)])}const S=new Sr,I=new Tn;let A=0;function M(z,B){const V=B*il+z;return lv[V]===0&&(S.emplaceBack(nl[2*V+0],nl[2*V+1],z*_t/Zo,B*_t/Zo),lv[V]=++A),lv[V]-1}function D(z,B,V,Z,G,Y){const Q=z+V>>1,te=B+Z>>1;if(Math.abs(z-G)+Math.abs(B-Y)>1&&Kc[te*il+Q])D(G,Y,z,B,Q,te),D(V,Z,G,Y,Q,te);else{const me=M(z,B),ce=M(V,Z),pe=M(G,Y);I.emplaceBack(me,ce,pe)}}return D(0,0,Zo,Zo,Zo,0),D(Zo,Zo,0,0,0,Zo),{vertices:S,indices:I}}(this.tileID.canonical,e);r=h.vertices,c=h.indices}else{r=new Sr,c=new Tn;for(const{x:f,y:_}of t)r.emplaceBack(f,_,0,0);const h=df(r.int16.subarray(0,4*r.length),void 0,4);for(let f=0;f<h.length;f+=3)c.emplaceBack(h[f],h[f+1],h[f+2])}this._tileBoundsBuffer=n.createVertexBuffer(r,nv.members),this._tileBoundsIndexBuffer=n.createIndexBuffer(c),this._tileBoundsSegments=$i.simpleSegment(0,0,r.length,c.length)}_makeGlobeTileDebugBuffers(n,e){const t=e.projection;if(!t||t.name!=="globe"||e.freezeTileCoverage)return;const r=this.tileID.canonical,c=Qm(xE(r,e)),h=Ul(e.zoom);let f;h>0&&(f=Se(new Float64Array(16),e.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(n,r,e,c,f,h),this._makeGlobeTileDebugTextBuffer(n,r,e,c,f,h)}_globePoint(n,e,t,r,c,h,f){let _=Jm(n,e,t);if(h){const g=1<<t.z,b=Je(r.center.lng),S=tt(r.center.lat),I=(t.x+.5)/g-b;let A=0;I>.5?A=-1:I<-.5&&(A=1);let M=(n/_t+t.x)/g+A,D=(e/_t+t.y)/g;M=(M-b)*r._pixelsPerMercatorPixel+b,D=(D-S)*r._pixelsPerMercatorPixel+S;const z=[M*r.worldSize,D*r.worldSize,0];mn(z,z,h),_=Vl(_,z,f)}return mn(_,_,c)}_makeGlobeTileDebugBorderBuffer(n,e,t,r,c,h){const f=new ms,_=new Ol,g=new Go,b=(I,A,M,D,z)=>{const B=(M-I)/(z-1),V=(D-A)/(z-1),Z=f.length;for(let G=0;G<z;G++){const Y=I+G*B,Q=A+G*V;f.emplaceBack(Y,Q);const te=this._globePoint(Y,Q,e,t,r,c,h);g.emplaceBack(te[0],te[1],te[2]),_.emplaceBack(Z+G)}},S=_t;b(0,0,S,0,16),b(S,0,S,S,16),b(S,S,0,S,16),b(0,S,0,0,16),this._tileDebugIndexBuffer=n.createIndexBuffer(_),this._tileDebugBuffer=n.createVertexBuffer(f,Km.members),this._globeTileDebugBorderBuffer=n.createVertexBuffer(g,gE.members),this._tileDebugSegments=$i.simpleSegment(0,0,f.length,_.length)}_makeGlobeTileDebugTextBuffer(n,e,t,r,c,h){const f=new ms,_=new Tn,g=new Go,b=25;_.reserve(32),f.reserve(b),g.reserve(b);const S=(I,A)=>b*I+A;for(let I=0;I<b;I++){const A=2048*I;for(let M=0;M<b;M++){const D=2048*M;f.emplaceBack(D,A);const z=this._globePoint(D,A,e,t,r,c,h);g.emplaceBack(z[0],z[1],z[2])}}for(let I=0;I<4;I++)for(let A=0;A<4;A++){const M=S(I,A),D=S(I,A+1),z=S(I+1,A),B=S(I+1,A+1);_.emplaceBack(M,D,z),_.emplaceBack(z,D,B)}this._tileDebugTextIndexBuffer=n.createIndexBuffer(_),this._tileDebugTextBuffer=n.createVertexBuffer(f,Km.members),this._globeTileDebugTextBuffer=n.createVertexBuffer(g,gE.members),this._tileDebugTextSegments=$i.simpleSegment(0,0,b,32)}destroy(n=!0){for(const e in this.buckets)this.buckets[e].destroy(n);this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&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),n&&this.texture&&this.texture instanceof tl&&(this.texture.destroy(),delete this.texture),this.emissiveTexture&&this.emissiveTexture instanceof tl&&(this.emissiveTexture.destroy(),delete this.emissiveTexture),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"}},a.b1=gc,a.b2=zp,a.b3=function(n,e){const t=[];for(const r in n)r in e||t.push(r);return t},a.b4=zC,a.b5=["type","source","source-layer","minzoom","maxzoom","filter","layout"],a.b6=zo,a.b7=Se,a.b8=ke,a.b9=Ye,a.bA=Ix,a.bB=cI,a.bC=uI,a.bD=oi,a.bE=Zr,a.bF=Vb,a.bG=GA,a.bH=Kb,a.bI=yw,a.bJ=mi,a.bK=La,a.bL=aa,a.bM=function(n,e,t){t*=.5;var r=e[0],c=e[1],h=e[2],f=e[3],_=Math.sin(t),g=Math.cos(t);return n[0]=r*g+c*_,n[1]=c*g-r*_,n[2]=h*g+f*_,n[3]=f*g-h*_,n},a.bN=uc,a.bO=Ni,a.bP=Tt,a.bQ=function(n,e){return n[0]=-e[0],n[1]=-e[1],n[2]=-e[2],n[3]=e[3],n},a.bR=Ji,a.bS=function(n,e,t,r,c){var h=1/Math.tan(e/2);if(n[0]=h/t,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=h,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,c!=null&&c!==1/0){var f=1/(r-c);n[10]=(c+r)*f,n[14]=2*c*r*f}else n[10]=-1,n[14]=-2*r;return n},a.bT=function(n,e,t,r,c,h,f){var _=1/(e-t),g=1/(r-c),b=1/(h-f);return n[0]=-2*_,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*g,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*b,n[11]=0,n[12]=(e+t)*_,n[13]=(c+r)*g,n[14]=(f+h)*b,n[15]=1,n},a.bU=Pe,a.bV=Oe,a.bW=function(n,e,t){n[4*e+0]=t[0],n[4*e+1]=t[1],n[4*e+2]=t[2],n[4*e+3]=t[3]},a.bX=bh,a.bY=wh,a.bZ=$n,a.b_=io,a.ba=Rt,a.bb=Ve,a.bc=function(n,e){const{x:t,y:r}=n.point,c=SE(t,r,n.worldSize/n._pixelsPerMercatorPixel,0,0);return ye(c,c,W1(Ja(e)))},a.bd=ee,a.be=cc,a.bf=ln,a.bg=rn,a.bh=On,a.bi=pn,a.bj=vf,a.bk=Os,a.bl=Gb,a.bm=function(n,e,t,r,c){const h=5*e+2;n.float32[h+0]=t,n.float32[h+1]=r,n.float32[h+2]=c},a.bn=Tf,a.bo=Do,a.bp=fl,a.bq=Is,a.br=Ap,a.bs=ge,a.bt=function(n,e,t,r){var c=new H(4);return c[0]=n,c[1]=e,c[2]=t,c[3]=r,c},a.bu=class{isDataAvailableAtPoint(n){const e=this._source();if(this.isUsingMockSource()||!e||n.y<0||n.y>1)return!1;const t=e.getSource().maxzoom,r=1<<t,c=Math.floor(n.x),h=Math.floor((n.x-c)*r),f=Math.floor(n.y*r),_=this.findDEMTileFor(new Xr(t,c,t,h,f));return!(!_||!_.dem)}getAtPointOrZero(n,e=0){return this.getAtPoint(n,e)||0}getAtPoint(n,e,t=!0){if(this.isUsingMockSource())return null;e==null&&(e=null);const r=this._source();if(!r||n.y<0||n.y>1)return e;const c=r.getSource().maxzoom,h=1<<c,f=Math.floor(n.x),_=n.x-f,g=new Xr(c,f,c,Math.floor(_*h),Math.floor(n.y*h)),b=this.findDEMTileFor(g);if(!b||!b.dem)return e;const S=b.dem,I=1<<b.tileID.canonical.z,A=(_*I-b.tileID.canonical.x)*S.dim,M=(n.y*I-b.tileID.canonical.y)*S.dim,D=Math.floor(A),z=Math.floor(M);return(t?this.exaggeration():1)*Gt(Gt(S.get(D,z),S.get(D,z+1),M-z),Gt(S.get(D+1,z),S.get(D+1,z+1),M-z),A-D)}static getAtTileOffset(n,e,t,r){const c=1<<n.canonical.z;return r?r.pointElevation(e):t?t.getAtPointOrZero(new Et(n.wrap+(n.canonical.x+e.x/_t)/c,(n.canonical.y+e.y/_t)/c)):0}static getAtTileOffsetFunc(n,e,t,r){return(c,h,f)=>{const _=this.getAtTileOffset(n,c,h,f),g=r.upVector(n.canonical,c.x,c.y);return mi(g,g,_*r.upVectorScale(n.canonical,e,t).metersToTile),g}}getForTilePoints(n,e,t,r){if(this.isUsingMockSource())return!1;const c=Ef.create(this,n,r);return!!c&&(e.forEach(h=>{h[2]=this.exaggeration()*c.getElevationAt(h[0],h[1],t)}),!0)}getMinMaxForTile(n){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(n);if(!e||!e.dem)return null;const t=e.dem.tree,r=e.tileID,c=1<<n.canonical.z-r.canonical.z;let h=n.canonical.x/c-r.canonical.x,f=n.canonical.y/c-r.canonical.y,_=0;for(let g=0;g<n.canonical.z-r.canonical.z&&!t.leaves[_];g++){h*=2,f*=2;const b=2*Math.floor(f)+Math.floor(h);_=t.childOffsets[_]+b,h%=1,f%=1}return{min:this.exaggeration()*t.minimums[_],max:this.exaggeration()*t.maximums[_]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(n,e,t){throw new Error("Pure virtual method called.")}pointCoordinate(n){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(n){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const n=this.visibleDemTiles;if(n.length===0)return null;let e=!1,t=Number.MAX_VALUE,r=Number.MIN_VALUE;for(const c of n){const h=this.getMinMaxForTile(c.tileID);h&&(t=Math.min(t,h.min),r=Math.max(r,h.max),e=!0)}return e?{min:t,max:r}:null}},a.bv=Rx,a.bw=Mn,a.bx=Ie,a.by=nr,a.bz=sI,a.c=hs,a.c$=function(n,e){return n.readFields(b3,{icons:[]},e)},a.c0=nC,a.c1=function(){var n=new H(4);return H!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n},a.c2=function(n,e,t){var r=e[0],c=e[1],h=e[2],f=e[3],_=Math.sin(t),g=Math.cos(t);return n[0]=r*g+h*_,n[1]=c*g+f*_,n[2]=r*-_+h*g,n[3]=c*-_+f*g,n},a.c3=function(n,e){return n[0]===e[0]&&n[1]===e[1]&&n[2]===e[2]&&n[3]===e[3]},a.c4=Hs,a.c5=function(n){var e=n[0],t=n[1],r=n[2],c=n[3];return Math.sqrt(e*e+t*t+r*r+c*c)},a.c6=br,a.c7=co,a.c8=_E,a.c9=3,a.cA=HI,a.cB=function(n){const e=HI(n,!0);return ee([],[e[0],e[1],e[4],e[5]])},a.cC=qe,a.cD=Gi,a.cE=ot,a.cF=function(n){const{x:e,y:t}=n.point,{lng:r,lat:c}=n._center;return SE(e,t,n.worldSize,r,c)},a.cG=Wt,a.cH=_r,a.cI=Ya,a.cJ=5,a.cK=function(n,e,t){let r=0;for(let c=0;c<2;++c)n[c]>0&&(r+=(n[c]-0)*(n[c]-0)),e[c]<0&&(r+=(0-e[c])*(0-e[c]));return r},a.cL=function(n){return n*n*n*n*n},a.cM=ze,a.cN=45,a.cO=cf,a.cP=function(n,e,t){const r=Math.sqrt(n*n+e*e+t*t),c=r>0?Math.acos(t/r)*wr:0;let h=n!==0||e!==0?Math.atan2(-e,-n)*wr+90:0;return h<0&&(h+=360),[r,h,c]},a.cQ=ji,a.cR=_i,a.cS=et,a.cT=Pt,a.cU=Li,a.cV=$t,a.cW=function(n){return[Math.pow(n[0],1/2.2),Math.pow(n[1],1/2.2),Math.pow(n[2],1/2.2)]},a.cX=$I,a.cY=Pb,a.cZ=XI,a.c_=aw,a.ca=2,a.cb=7,a.cc=6,a.cd=oa,a.ce=gi,a.cf=Mr,a.cg=0,a.ch=1,a.ci=4,a.cj=5,a.ck=hf,a.cl=_s,a.cm=ZI,a.cn=Th,a.co=bE,a.cp=function(n,e,t,r,c,h,f,_,g){if(g.name==="globe")return bE(n,e,new Th(t,r,c),!1);const b=Mh({z:t,x:r,y:c},g);return new Li([(h+b.x/b.scale)*e,e*(b.y/b.scale),f],[(h+b.x2/b.scale)*e,e*(b.y2/b.scale),_])},a.cq=function(n,e,t){return n[0]=Math.min(e[0],t[0]),n[1]=Math.min(e[1],t[1]),n[2]=Math.min(e[2],t[2]),n[3]=Math.min(e[3],t[3]),n},a.cr=function(n,e,t){return n[0]=Math.max(e[0],t[0]),n[1]=Math.max(e[1],t[1]),n[2]=Math.max(e[2],t[2]),n[3]=Math.max(e[3],t[3]),n},a.cs=function(n){const e=Math.round((n+45+360)%360/90)%4;return Zs[e]},a.ct=$e,a.cu=nd,a.cv=6,a.cw=function(n){const e=Ye(new Float64Array(16));ye(e,n.pixelMatrix,n.globeMatrix);const t=[0,le,0],r=[0,_e,0];return mn(t,t,e),mn(r,r,e),[t[0]>0&&t[0]<=n.width&&t[1]>0&&t[1]<=n.height&&!Y1(n,new ve(n.center.lat,90)),r[0]>0&&r[0]<=n.width&&r[1]>0&&r[1]<=n.height&&!Y1(n,new ve(n.center.lat,-90))]},a.cx=function(n,e){const{scale:t}=n.tileTransform,r=t*_t/(n.tileSize*Math.pow(2,e.zoom-n.tileID.overscaledZ+n.tileID.canonical.z));return function(c,h,f){var _=h[1],g=h[2],b=h[3],S=f[0],I=f[1];return c[0]=h[0]*S,c[1]=_*S,c[2]=g*I,c[3]=b*I,c}(new Float32Array(4),e.inverseAdjustmentMatrix,[r,r])},a.cy=kx,a.cz=An,a.d=function(n){return yi.API_TILEJSON_REGEX.test(n)},a.d$=vF,a.d0=_n,a.d1=class{static calculate(n,e,t){const r=new Set,c=new Map,h=new Set,f=new Set;for(const g of Object.values(n))for(const[b,S]of Object.entries(g.floors)){h.add(b),S.isDefault&&f.add(b),S.conflicts&&c.set(b,S.conflicts);const I=b===e,A=S.connections&&e&&S.connections.has(e);(I||A)&&r.add(b)}const _=g=>{const b=c.get(g)||new Set;for(const S of r)if((c.get(S)||new Set).has(g)||b.has(S))return!0;return!1};if(t)for(const g of t)h.has(g)&&(_(g)||r.add(g));for(const g of f)r.has(g)||_(g)||r.add(g);return r}},a.d2=Zx,a.d3=Wb,a.d4=Ai,a.d5=function(){return{API_URL:yi.API_URL,DRACO_URL:yi.DRACO_URL,MESHOPT_URL:yi.MESHOPT_URL,MESHOPT_SIMD_URL:yi.MESHOPT_SIMD_URL,BUILDING_GEN_URL:yi.BUILDING_GEN_URL}},a.d6=Zy,a.d7=Cp,a.d8=Ba,a.d9=gt,a.dA=fx,a.dB=ms,a.dC=Tn,a.dD=function(n,e){return[Math.pow(n[0],2.2)*e,Math.pow(n[1],2.2)*e,Math.pow(n[2],2.2)*e]},a.dE=se,a.dF=function(n,e){var t=Math.sin(e),r=Math.cos(e);return n[0]=r,n[1]=t,n[2]=0,n[3]=-t,n[4]=r,n[5]=0,n[6]=0,n[7]=0,n[8]=1,n},a.dG=Mo,a.dH=TE,a.dI=Xi,a.dJ=un,a.dK=sw,a.dL=function(n,e){const t=[0,0,0];return mn(t,t,Qm(Ja(e.canonical))),mn(t,t,n),t},a.dM=n=>({u_matrix:new i(n),u_texsize:new io(n),u_pixels_to_tile_units:new m(n),u_device_pixel_ratio:new $n(n),u_width_scale:new $n(n),u_floor_width_scale:new $n(n),u_image:new bh(n),u_units_to_pixels:new io(n),u_tile_units_to_pixels:new $n(n),u_alpha_discard_threshold:new $n(n),u_trim_offset:new io(n),u_trim_fade_range:new io(n),u_trim_gradient_mix_range:new io(n),u_trim_color:new cf(n),u_zbias_factor:new $n(n),u_tile_to_meter:new $n(n),u_ground_shadow_factor:new wh(n),u_pattern_transition:new $n(n)}),a.dN=n=>({u_matrix:new i(n),u_pixels_to_tile_units:new m(n),u_device_pixel_ratio:new $n(n),u_width_scale:new $n(n),u_floor_width_scale:new $n(n),u_units_to_pixels:new io(n),u_dash_image:new bh(n),u_gradient_image:new bh(n),u_image_height:new $n(n),u_texsize:new io(n),u_tile_units_to_pixels:new $n(n),u_alpha_discard_threshold:new $n(n),u_trim_offset:new io(n),u_trim_fade_range:new io(n),u_trim_gradient_mix_range:new io(n),u_trim_color:new cf(n),u_zbias_factor:new $n(n),u_tile_to_meter:new $n(n),u_ground_shadow_factor:new wh(n)}),a.dO=n=>({u_camera_to_center_distance:new $n(n),u_extrude_scale:new m(n),u_device_pixel_ratio:new $n(n),u_matrix:new i(n),u_inv_rot_matrix:new i(n),u_merc_center:new io(n),u_tile_id:new wh(n),u_zoom_transition:new $n(n),u_up_dir:new wh(n),u_emissive_strength:new $n(n)}),a.dP=Vm,a.dQ=xB,a.dR=class{constructor(n,e,t,r){this.context=n,this.format=r,this.size=t,this.texture=n.gl.createTexture();const[c,h,f]=this.size,{gl:_}=n;_.bindTexture(_.TEXTURE_3D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in e&&e.data&&_.texImage3D(_.TEXTURE_3D,0,this.format,c,h,f,0,wb(this.format),Tb(this.format),e.data)}bind(n,e){const{context:t}=this,{gl:r}=t;r.bindTexture(r.TEXTURE_3D,this.texture),n!==this.minFilter&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MAG_FILTER,n),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MIN_FILTER,n),this.minFilter=n),e!==this.wrapS&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_S,e),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_T,e),this.wrapS=e)}destroy(){const{gl:n}=this.context;n.deleteTexture(this.texture),this.texture=null}},a.dS=AE,a.dT=(n,e,t,r,c,h)=>{const f=n.transform,_=f.projection.name==="globe";let g;if(h.paint.get("circle-pitch-alignment")==="map")if(_){const S=TE(f.zoom,e.canonical)*f._pixelsPerMercatorPixel;g=Float32Array.from([S,0,0,S])}else g=f.calculatePixelsToTileUnitsMatrix(t);else g=new Float32Array([f.pixelsToGLUnits[0],0,0,f.pixelsToGLUnits[1]]);const b={u_camera_to_center_distance:n.transform.getCameraToCenterDistance(f.projection),u_matrix:n.translatePosMatrix(e.projMatrix,t,h.paint.get("circle-translate"),h.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ts.devicePixelRatio,u_extrude_scale:g,u_inv_rot_matrix:IF,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:h.paint.get("circle-emissive-strength")};if(_){b.u_inv_rot_matrix=r,b.u_merc_center=c,b.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],b.u_zoom_transition=Ul(f.zoom);const S=c[0]*_t,I=c[1]*_t;b.u_up_dir=f.projection.upVector(new Th(0,0,0),S,I)}return b},a.dU=hA,a.dV=is,a.dW=(n,e,t,r,c,h,f,_,g,b)=>{const S=n.transform,I=S.pitch<15?lA(.07,.7,q((14-S.zoom)/5,0,1)):.07,A=t.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:uA(n,e,t,r),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:S.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:c,u_width_scale:h,u_floor_width_scale:f,u_image:0,u_tile_units_to_pixels:cA(e,S),u_units_to_pixels:[1/S.pixelsToGLUnits[0],1/S.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:_,u_trim_fade_range:t.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:t.paint.get("line-trim-color").toPremultipliedRenderColor(A?null:t.lut).toArray01(),u_zbias_factor:I,u_tile_to_meter:et(e.tileID.canonical,0),u_ground_shadow_factor:g,u_pattern_transition:b}},a.dX=(n,e,t,r,c,h,f,_,g,b)=>{const S=n.transform,I=S.calculatePixelsToTileUnitsMatrix(e),A=t.paint.get("line-trim-color-use-theme").constantOr("default")==="none",M=S.pitch<15?lA(.07,.7,q((14-S.zoom)/5,0,1)):.07;return{u_matrix:uA(n,e,t,r),u_pixels_to_tile_units:I,u_device_pixel_ratio:h,u_width_scale:f,u_floor_width_scale:_,u_units_to_pixels:[1/S.pixelsToGLUnits[0],1/S.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:c,u_texsize:dA(t)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:cA(e,n.transform),u_alpha_discard_threshold:0,u_trim_offset:g,u_trim_fade_range:t.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:t.paint.get("line-trim-color").toPremultipliedRenderColor(A?null:t.lut).toArray01(),u_zbias_factor:M,u_tile_to_meter:et(e.tileID.canonical,0),u_ground_shadow_factor:b}},a.dY=Ae,a.dZ=e_,a.d_=Ue,a.da=function(n){const e=n.indexOf(uh);return e>=0?n.slice(0,e):n},a.db=function(n){return n.indexOf(uh)>=0},a.dc=function(n){const e=n.lastIndexOf(uh);return e>=0?n.slice(e+1):""},a.dd=function(n){const e=[],t=n.id;return t===void 0&&e.push({message:`layers.${t}: missing required property "id"`}),n.render===void 0&&e.push({message:`layers.${t}: missing required method "render"`}),n.renderingMode&&n.renderingMode!=="2d"&&n.renderingMode!=="3d"&&e.push({message:`layers.${t}: property "renderingMode" must be either "2d" or "3d"`}),e},a.de=function(n,e,t,r){return n.type==="custom"?new d3(n,e):new g3[n.type](n,e,t,r)},a.df=Ke,a.dg=Yd,a.dh=ex,a.di=class extends Dh{constructor(n,e){super(n._vectorTileFeature,n._z,n._x,n._y,n.id),n.state&&(this.state=Object.assign({},n.state)),this.target=e.target,this.namespace=e.namespace,e.properties&&(this.properties=e.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=n.source,this.sourceLayer=n.sourceLayer,this.layer=n.layer)}toJSON(){const n=super.toJSON();return n.target=this.target,n.namespace=this.namespace,n}},a.dj=Sm,a.dk=function(n){return n({pluginStatus:Ur,pluginURL:Ms}),Sm.on("pluginStateChange",n),n},a.dl=H1,a.dm=class extends to{constructor(n){super(n),this.current=o}set(n,e,t){if(this.fetchUniformLocation(n,e)){for(let r=0;r<9;r++)if(t[r]!==this.current[r]){this.current=t,this.gl.uniformMatrix3fv(this.location,!1,t);break}}}},a.dn=Cu,a.dp=function(n,e,t){const r=Ul(t.zoom),c=n.style.map._antialias,h=n.terrain&&n.terrain.exaggeration()>0;return r===0&&!c&&!h},a.dq=function(n){const e=n.pixelsPerMeter,t=e/Pe(1,n.center.lat),r=Ye(new Float64Array(16));return Ie(r,r,[n.point.x,n.point.y,0]),qe(r,r,[t,t,e]),Float32Array.from(r)},a.dr=px,a.ds=function(n){const e=80.051129;n=q(n,-80.051129,e)/e*90;const t=Math.pow(Math.abs(Math.sin(Ei(n))),3);return Math.round(t*(xe.length-1))},a.dt=function(n,e,t,r){const c=e.getNorth(),h=e.getSouth(),f=e.getWest(),_=e.getEast(),g=1<<n.z,b=_-f,S=c-h,I=b/K,A=-S/xe[t],M=[0,I,0,A,0,0,c,f,0];if(n.z>0){const D=180/r;Me(M,M,[D/b+1,0,0,0,D/S+1,0,-.5*D/I,.5*D/A,1])}return M[2]=g,M[5]=n.x,M[8]=n.y,M},a.du=Qm,a.dv=Ja,a.dw=function(n,e,t){const r=Ye(new Float64Array(16)),c=(e/(1<<n)-.5)*Math.PI*2;return xt(r,t.globeMatrix,c),Float32Array.from(r)},a.dx=Km,a.dy=$i,a.dz=OE,a.e=function(n){return n.indexOf("mapbox:")===0},a.e$=Y1,a.e0=Mx,a.e1=xI,a.e2=lt,a.e3=Gl,a.e4=450,a.e5=7,a.e6=function(n,e){if(n===e){var t=e[1],r=e[2],c=e[3],h=e[6],f=e[7],_=e[11];n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=t,n[6]=e[9],n[7]=e[13],n[8]=r,n[9]=h,n[11]=e[14],n[12]=c,n[13]=f,n[14]=_}else n[0]=e[0],n[1]=e[4],n[2]=e[8],n[3]=e[12],n[4]=e[1],n[5]=e[5],n[6]=e[9],n[7]=e[13],n[8]=e[2],n[9]=e[6],n[10]=e[10],n[11]=e[14],n[12]=e[3],n[13]=e[7],n[14]=e[11],n[15]=e[15];return n},a.e7=h3,a.e8=pi,a.e9=of,a.eA=eo,a.eB=Fl,a.eC=function(n,e,t,r,c,h,f,_,g,b,S,I,A,M,D,z){var B=new H(16);return B[0]=n,B[1]=e,B[2]=t,B[3]=r,B[4]=c,B[5]=h,B[6]=f,B[7]=_,B[8]=g,B[9]=b,B[10]=S,B[11]=I,B[12]=A,B[13]=M,B[14]=D,B[15]=z,B},a.eD=fe,a.eE=Gm,a.eF=jm,a.eG=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new it(1/0,1/0),max:new it(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(n,e=!1){const t=aI(new it(0,0),new it(_t,_t),n),r=[];if(e&&!hb(t,this._globalClipBounds))return r;for(const c of this._activeRegions){if(c.hiddenByOverlap||!hb(t,c))continue;const h=lO(c.min,c.max,n);r.push({min:h.min,max:h.max,sourceId:this._sourceIds[c.priority],footprint:c.footprint,footprintTileId:c.tileId,order:c.order,clipMask:c.clipMask,clipScope:c.clipScope})}return r}setSources(n){this._setSources(n.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const r of e.cache.getVisibleCoordinates()){const c=e.cache.getTile(r).buckets[e.layer];c&&c.updateFootprints(r.toUnwrapped(),t)}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})))}_addSource(n){const e=n.getFootprints();if(e.length===0)return;const t=n.getOrder(),r=n.getClipMask(),c=n.getClipScope();for(const h of e){if(!h.footprint)continue;const f=aI(h.footprint.min,h.footprint.max,h.id);this._activeRegions.push({min:f.min,max:f.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:h.id,footprint:h.footprint,order:t,clipMask:r,clipScope:c})}this._sourceIds.push(n.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Sx(e.min,t.min)||Sx(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(r,c){const h=(f,_)=>f+_;return r.length-c.length||r.reduce(h,"").localeCompare(c.reduce(h,""))}(e.clipScope,t.clipScope));let n=this._activeRegions.length!==this._prevRegions.length;if(!n){let e=0;for(;!n&&e!==this._activeRegions.length;){const t=this._activeRegions[e],r=this._prevRegions[e];n=t.priority!==r.priority||!oI(t,r)||t.order!==r.order||t.clipMask!==r.clipMask||!zo(t.clipScope,r.clipScope),this._activeRegions[e].hiddenByOverlap=r.hiddenByOverlap,++e}}if(n){++this._updateTime;for(const t of this._activeRegions)t.order!==l_&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const e=t=>{const r=this._activeRegions;if(t>=r.length)return t;const c=r[t].priority;for(;t<r.length&&r[t].priority===c;)++t;return t};if(this._sourceIds.length>1){let t=0,r=e(t);for(;t!==r;){let c=t;const h=t;for(;c!==r;){const f=this._activeRegions[c];f.hiddenByOverlap=!1;for(let _=0;_<h;_++){const g=this._activeRegions[_];if(!g.hiddenByOverlap&&f.order===l_&&hb(f,g)&&(f.hiddenByOverlap=lI(f.footprint,f.tileId,g.footprint,g.tileId),f.hiddenByOverlap))break}++c}t=r,r=e(t)}}}}_setSources(n){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let e=n.length-1;e>=0;e--)this._addSource(n[e]);this._computeReplacement()}},a.eH=Sr,a.eI=nv,a.eJ=Ol,a.eK=l_,a.eL=class{constructor(n){this._createGrid(n),this._createPoles(n)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const n of this._poleSegments)n.destroy();for(const n of this._gridSegments)n.withSkirts.destroy(),n.withoutSkirts.destroy()}_fillGridMeshWithLods(n,e){const t=new ms,r=new Tn,c=[],h=n+1+2,f=e[0]+1,_=e[0]+1+(1+e.length),g=(b,S,I)=>{let A=b===h-1?b-2:b===0?b:b-1;return A+=I?24575:0,[A,S]};for(let b=0;b<h;++b)t.emplaceBack(...g(b,0,!0));for(let b=0;b<f;++b)for(let S=0;S<h;++S)t.emplaceBack(...g(S,b,(S===0||S===h-1)&&!0));for(let b=0;b<e.length;++b){const S=e[b];for(let I=0;I<h;++I)t.emplaceBack(...g(I,S,!0))}for(let b=0;b<e.length;++b){const S=r.length,I=e[b]+1+2,A=new Tn;for(let z=0;z<I-1;z++){const B=z===I-2,V=B?h*(_-e.length+b-z):h;for(let Z=0;Z<h-1;Z++){const G=z*h+Z;z===0||B||Z===0||Z===h-2?(A.emplaceBack(G+1,G,G+V),A.emplaceBack(G+V,G+V+1,G+1)):(r.emplaceBack(G+1,G,G+V),r.emplaceBack(G+V,G+V+1,G+1))}}const M=$i.simpleSegment(0,S,t.length,r.length-S);for(let z=0;z<A.uint16.length;z+=3)r.emplaceBack(A.uint16[z],A.uint16[z+1],A.uint16[z+2]);const D=$i.simpleSegment(0,S,t.length,r.length-S);c.push({withoutSkirts:M,withSkirts:D})}return{vertices:t,indices:r,segments:c}}_createGrid(n){const e=this._fillGridMeshWithLods(K,xe);this._gridSegments=e.segments,this._gridBuffer=n.createVertexBuffer(e.vertices,Km.members),this._gridIndexBuffer=n.createIndexBuffer(e.indices,!0)}_createPoles(n){const e=new Tn;for(let f=0;f<=K;f++)e.emplaceBack(0,f+1,f+2);this._poleIndexBuffer=n.createIndexBuffer(e,!0);const t=new kl,r=new kl,c=new kl,h=new kl;this._poleSegments=[];for(let f=0,_=0;f<6;f++){const g=360/(1<<f);t.emplaceBack(0,-ne,0,.5,0),r.emplaceBack(0,-ne,0,.5,1),c.emplaceBack(0,-ne,0,.5,.5),h.emplaceBack(0,-ne,0,.5,.5);for(let b=0;b<=K;b++){let S=b/K,I=0;const A=Gt(0,g,S),[M,D,z]=re(SF,EF,A,ne);t.emplaceBack(M,D,z,S,I),r.emplaceBack(M,D,z,S,1-I);const B=Ei(A);S=.5+.5*Math.sin(B),I=.5+.5*Math.cos(B),c.emplaceBack(M,D,z,S,I),h.emplaceBack(M,D,z,S,1-I)}this._poleSegments.push($i.simpleSegment(_,0,66,64)),_+=66}this._poleNorthVertexBuffer=n.createVertexBuffer(t,dx,!1),this._poleSouthVertexBuffer=n.createVertexBuffer(r,dx,!1),this._texturedPoleNorthVertexBuffer=n.createVertexBuffer(c,dx,!1),this._texturedPoleSouthVertexBuffer=n.createVertexBuffer(h,dx,!1)}getGridBuffers(n,e){return[this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[n].withSkirts:this._gridSegments[n].withoutSkirts]}getPoleBuffers(n,e){return[e?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,e?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[n]]}},a.eM=aO,a.eN=Re,a.eO=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},a.eP=$,a.eQ=ct,a.eR=function(n,e,t){return n[0]=e[0]/t[0],n[1]=e[1]/t[1],n[2]=e[2]/t[2],n},a.eS=id,a.eT=ae,a.eU=Rr,a.eV=ti,a.eW=function([n,e,t]){const r=Math.hypot(n,e,t),c=Math.atan2(n,t),h=.5*Math.PI-Math.acos(-e/r);return new ve(_r(c),_r(h))},a.eX=za,a.eY=Sb,a.eZ=function(n){const e=n.navigator?n.navigator.userAgent:null;return!!function(t){if(bn==null){const r=t.navigator?t.navigator.userAgent:null;bn=!!t.safari||!(!r||!(/\b(iPad|iPhone|iPod)\b/.test(r)||r.match("Safari")&&!r.match("Chrome")))}return bn}(n)&&!(!e||!(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},a.e_=function(n,e){sd=n,od=e},a.ea=256,a.eb=function(n){return n>>>=0,n=Math.imul(2747636419^n,2654435769)>>>0,n=Math.imul(n^n>>>16,2654435769)>>>0,(n=Math.imul(n^n>>>16,2654435769)>>>0)/4294967296},a.ec=xE,a.ed=W1,a.ee=Qs,a.ef=xt,a.eg=function(n,e){return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[4],n[4]=e[5],n[5]=e[6],n[6]=e[8],n[7]=e[9],n[8]=e[10],n},a.eh=kl,a.ei=_h,a.ej=function(n,e,t,r,c){return q((n-e)/(t-e)*(c-r)+r,r,c)},a.ek=hc,a.el=function(n,e){var t=e[0],r=e[1],c=e[2],h=e[3],f=e[4],_=e[5],g=e[6],b=e[7],S=e[8],I=S*f-_*b,A=-S*h+_*g,M=b*h-f*g,D=t*I+r*A+c*M;return D?(n[0]=I*(D=1/D),n[1]=(-S*r+c*b)*D,n[2]=(_*r-c*f)*D,n[3]=A*D,n[4]=(S*t-c*g)*D,n[5]=(-_*t+c*h)*D,n[6]=M*D,n[7]=(-b*t+r*g)*D,n[8]=(f*t-r*h)*D,n):null},a.em=Cy,a.en=2,a.eo=lo,a.ep=Es,a.eq=Xt,a.er=function(n,e){var t=new H(3);Xt(t,e);var r=1/t[0],c=1/t[1],h=1/t[2],f=e[0]*r,_=e[1]*c,g=e[2]*h,b=e[4]*r,S=e[5]*c,I=e[6]*h,A=e[8]*r,M=e[9]*c,D=e[10]*h,z=f+S+D,B=0;return z>0?(B=2*Math.sqrt(z+1),n[3]=.25*B,n[0]=(I-M)/B,n[1]=(A-g)/B,n[2]=(_-b)/B):f>S&&f>D?(B=2*Math.sqrt(1+f-S-D),n[3]=(I-M)/B,n[0]=.25*B,n[1]=(_+b)/B,n[2]=(A+g)/B):S>D?(B=2*Math.sqrt(1+S-f-D),n[3]=(A-g)/B,n[0]=(_+b)/B,n[1]=.25*B,n[2]=(I+M)/B):(B=2*Math.sqrt(1+D-f-S),n[3]=(_-b)/B,n[0]=(A+g)/B,n[1]=(I+M)/B,n[2]=.25*B),n},a.es=function(n,e){var t=2*Math.acos(e[3]),r=Math.sin(t/2);return r>F?(n[0]=e[0]/r,n[1]=e[1]/r,n[2]=e[2]/r):(n[0]=1,n[1]=0,n[2]=0),t},a.et=uw,a.eu=Bx,a.ev=Ox,a.ew=[1,1,1],a.ex=Ef,a.ey=function(n,e,t,r){var c=e[0],h=e[1],f=e[2],_=e[3];return n[0]=c+r*(t[0]-c),n[1]=h+r*(t[1]-h),n[2]=f+r*(t[2]-f),n[3]=_+r*(t[3]-_),n},a.ez=gf,a.f=us,a.f0=EE,a.f1=function(n){const e=[0,0,0],t=Ye(new Float64Array(16));return ye(t,n.pixelMatrix,n.globeMatrix),mn(e,e,t),new it(e[0],e[1])},a.f2=Em,a.f3=function(n,e,t=!1){if(Ur===ps.deferred||Ur===ps.loading||Ur===ps.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Ms=ts.resolveURL(n),Ur=ps.deferred,jo=e,Tm(),t||qy()},a.f4=gr,a.f5=Tr,a.f6=Xn,a.f7=function(n){const e=ty();if(!e)return;const t=e.delete(gl);n&&t.then(()=>n()).catch(n)},a.f8=wt,a.f9=$c,a.fA=qt,a.fB=function(n){let e=0;if(new Uint32Array(n,0,1)[0]!==NI){const t=new Uint32Array(n,0,7),[,,r,c,h,f]=t;e=t.byteLength+c+h+f+h,(r!==n.byteLength||e>=n.byteLength)&&zt("Invalid b3dm header information.")}return GI(n,e)},a.fC=function(n,e){const t=Pb(n);for(const r of t){for(const c of r.meshes)NO(c);r.lights&&(r.lightMeshIndex=r.meshes.length,r.meshes.push(VO(r.lights,e)))}return t},a.fD=av,a.fE=Wi,a.fF=fa,a.fG=ps,a.fH=function(n){ad(),Bo!=null&&Bo.then(e=>{e.keys().then(t=>{for(let r=0;r<t.length-n;r++)e.delete(t[r]).catch(c=>zt(c.message))}).catch(t=>zt(t.message))}).catch(e=>zt(e.message))},a.fa=2,a.fb=ua,a.fc=Mh,a.fd=Zm,a.fe=PC,a.ff=MC,a.fg=rA,a.fh=ri,a.fi="hd_road_elevation",a.fj=Yi,a.fk=rt,a.fl=wx,a.fm=jl,a.fn=Zb,a.fo=1,a.fp=va,a.fq=function(n,e,t,r,c,h,f,_=1,g,b,S,I){n.createArrays(),n.tilePixelRatio=_t/(512*n.overscaling),n.compareText={},n.iconsNeedLinear=!1;const A=n.layers[0].layout,M=n.layers[0]._unevaluatedLayout._values,D={};D.scaleFactor=_,D.textSizeScaleRange=A.get("text-size-scale-range"),D.iconSizeScaleRange=A.get("icon-size-scale-range");const[z,B]=D.textSizeScaleRange,[V,Z]=D.iconSizeScaleRange;D.textScaleFactor=q(D.scaleFactor,z,B),D.iconScaleFactor=q(D.scaleFactor,V,Z);const G=M["text-size"],Y=M["icon-size"];if(n.textSizeData.kind==="composite"){const{minZoom:he,maxZoom:de}=n.textSizeData;D.compositeTextSizes=[G.possiblyEvaluate(new Mi(he,{worldview:S}),h),G.possiblyEvaluate(new Mi(de,{worldview:S}),h)]}if(n.iconSizeData.kind==="composite"){const{minZoom:he,maxZoom:de}=n.iconSizeData;D.compositeIconSizes=[Y.possiblyEvaluate(new Mi(he,{worldview:S}),h,I),Y.possiblyEvaluate(new Mi(de,{worldview:S}),h,I)]}D.layoutTextSize=G.possiblyEvaluate(new Mi(f+1,{worldview:S}),h),D.layoutIconSize=Y.possiblyEvaluate(new Mi(f+1,{worldview:S}),h,I),D.textMaxSize=G.possiblyEvaluate(new Mi(18,{worldview:S}),h);const Q=A.get("symbol-placement"),te=A.get("text-rotation-alignment")==="map"&&Q!=="point",me=A.get("text-size");let ce=!1;const pe=[];for(const he of n.features){const de=A.get("text-font").evaluate(he,{},h).join(","),Be=me.evaluate(he,{},h)*D.textScaleFactor,je=D.layoutTextSize.evaluate(he,{},h)*D.textScaleFactor,He=D.layoutIconSize.evaluate(he,{},h,I)*D.iconScaleFactor,Xe={horizontal:{},vertical:void 0},Ze=he.text;let nt,Fe=[0,0];if(Ze){const ai=Ze.toString(),gn=A.get("text-letter-spacing").evaluate(he,{},h)*nr,Ri=A.get("text-line-height").evaluate(he,{},h)*nr,Si=R1(ai)?gn:0,qi=A.get("text-anchor").evaluate(he,{},h),dn=A.get("text-variable-anchor");if(!dn){const En=A.get("text-radial-offset").evaluate(he,{},h);if(En)Fe=GA(qi,[En*nr,Yb]);else{const Ir=A.get("text-offset").evaluate(he,{},h);Fe=[Ir[0]*nr,Ir[1]*nr]}}let rr=te?"center":A.get("text-justify").evaluate(he,{},h);const fn=Q==="point",Sn=fn?A.get("text-max-width").evaluate(he,{},h)*nr:1/0,Bn=En=>{n.allowVerticalPlacement&&vm(ai)&&(Xe.vertical=Nb(Ze,e,t,c,de,Sn,Ri,qi,En,Si,Fe,Os.vertical,!0,je,Be,g,D.textScaleFactor))};if(!te&&dn){const En=rr==="auto"?dn.map(sr=>Kb(sr)):[rr];let Ir=!1;for(let sr=0;sr<En.length;sr++){const ci=En[sr];if(!Xe.horizontal[ci])if(Ir)Xe.horizontal[ci]=Xe.horizontal[0];else{const Yr=Nb(Ze,e,t,c,de,Sn,Ri,"center",ci,Si,Fe,Os.horizontal,!1,je,Be,g,D.textScaleFactor);Yr&&(Xe.horizontal[ci]=Yr,Ir=Yr.positionedLines.length===1)}}Bn("left")}else{if(rr==="auto"&&(rr=Kb(qi)),fn||A.get("text-writing-mode").indexOf("horizontal")>=0||!vm(ai)){const En=Nb(Ze,e,t,c,de,Sn,Ri,qi,rr,Si,Fe,Os.horizontal,!1,je,Be,g,D.textScaleFactor);En&&(Xe.horizontal[rr]=En)}Bn(fn?"left":rr)}}let We,Qe,st,ut,bt,mt,pt=!1;const ht=A.get("icon-text-fit").evaluate(he,{},h);if(he.icon&&he.icon.hasPrimary()){const ai=T_(he.icon,n.iconSizeData,M["icon-size"],h,n.zoom,he,g,D.iconScaleFactor,S,I);We=ai.iconPrimary,st=ai.iconSecondary;const gn=We.toString();if(Qe=r.get(gn),Qe&&(bt=A.get("icon-offset").evaluate(he,{},h),mt=A.get("icon-anchor").evaluate(he,{},h),nt=$x(c.get(gn),st?c.get(st.toString()):void 0,bt,mt),pt=Qe.sdf,n.sdfIcons===void 0?n.sdfIcons=Qe.sdf:n.sdfIcons!==Qe.sdf&&zt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Qe.pixelRatio!==n.pixelRatio||A.get("icon-rotate").constantOr(1)!==0)&&(n.iconsNeedLinear=!0)),st){const Ri=st.toString();ut=r.get(Ri)}}ce=ce||!(!he.icon||!he.icon.hasSecondary());const yt=Kx(Xe.horizontal)||Xe.vertical;n.iconsInText||(n.iconsInText=!!yt&&yt.iconsInText);const It=je*D.textScaleFactor/nr,{defaultShapedIcon:kt,verticallyShapedIcon:Ct}=YB(n,nt,A,he,h,Xe,It,bt,ht);ht!=="none"&&nt&&(EA(nt)||IA(nt))&&(Yx(0,Qe,We,nt,kt,ht,b,r,c),Yx(0,ut,st,nt,kt,ht,b,r,c),Ct&&(Yx(0,Qe,We,nt,Ct,ht,b,r,c),Yx(0,ut,st,nt,Ct,ht,b,r,c))),nt=kt;const{iconBBox:Qt,iconVerticalBBox:vi,textBBox:ei,textVerticalBBox:wi}=HB(n,nt,Ct,A,he,h,He,bt,D,c,mt,Xe,je,Fe,I);pe.push({feature:he,shapedTextOrientations:Xe,shapedText:yt,shapedIcon:nt,iconPrimary:We,iconSecondary:st,iconOffset:bt,iconAnchor:mt,verticallyShapedIcon:Ct,layoutTextSize:je,layoutIconSize:He,textOffset:Fe,isSDFIcon:pt,iconTextFit:ht,iconCollisionBounds:Qt,iconVerticalCollisionBounds:vi,textCollisionBounds:ei,textVerticalCollisionBounds:wi})}return{featureData:pe,sizes:D,hasAnySecondaryIcon:ce,textAlongLine:te,symbolPlacement:Q}},a.fr=qb,a.fs=Hb,a.ft=kA,a.fu=FA,a.fv=function(n,e,t,r,c,h,f,_,g,b){n.iconAtlasPositions=b.iconPositions;const{featureData:S,hasAnySecondaryIcon:I,sizes:A,textAlongLine:M,symbolPlacement:D}=e;for(const z of S){const{shapedIcon:B,verticallyShapedIcon:V,feature:Z,shapedTextOrientations:G,shapedText:Y,layoutTextSize:Q,textOffset:te,isSDFIcon:me,iconPrimary:ce,iconSecondary:pe,iconTextFit:he,iconOffset:de,iconCollisionBounds:Be,iconVerticalCollisionBounds:je,textCollisionBounds:He}=z;qA(B,b.iconPositions,ce,pe),qA(V,b.iconPositions,ce,pe),XB(G,b.iconPositions),WB(ce,pe,b.iconPositions),(Y||B)&&KB(n,Z,G,B,V,g,A,Q,0,te,me,r,c,f,_,I,he,de,M,D,Be,je,He)}t&&n.generateCollisionDebugBuffers(h,n.collisionBoxArray,A.textScaleFactor)},a.fw=Ux,a.fx=Ci,a.fy=function(n){return n<=1?1:Math.pow(2,Math.floor(Math.log2(n)))},a.fz=fv,a.g=yi,a.h=function(n,e){return _c(Object.assign(n,{method:"GET"}),e)},a.i=function(n){return yi.API_STYLE_REGEX.test(n)&&!hs(n)},a.j=function(n){return btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(+("0x"+t))))},a.k=ld,a.l=function(n){return decodeURIComponent(atob(n).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},a.m=function(n,e){return _c(Object.assign(n,{type:"json"}),e)},a.n=yc,a.o=ts,a.p=function(n,e){return _c(Object.assign(n,{method:"POST"}),e)},a.q=Fr,a.r=De,a.s=function(n){try{const e=self[n];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}},a.t=be,a.u=function(){return function n(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,n)}()},a.v=function(n){return!!n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(n)},a.w=zt,a.x=class{constructor(n){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(n&&n.maxTextureMemoryMB?n.maxTextureMemoryMB:256)*1024,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures()})}calculateTextureMemory(n){return n.image?Math.ceil(n.image.width*n.image.height*4*(n.patternPositions.size>0?1.33:1)):0}evictTexture(n){const e=this.textures.get(n);if(e){const t=this.calculateTextureMemory(n);e.destroy(),this.textures.delete(n),this.textureAccessTimes.delete(n),this.textureMemoryUsed-=t}}evictTexturesIfNeeded(n){for(;this.textureMemoryUsed+n>this.maxTextureMemory&&this.textures.size>0;){let e=null,t=1/0;for(const[r]of this.textures.entries()){const c=this.textureAccessTimes.get(r)||0;c<t&&(t=c,e=r)}if(!e)break;this.evictTexture(e)}}findCachedAtlas(n){const e=this.cache.get(n.hash);if(e){const t=e.deref();if(t&&t.contentDescriptor&&this.isMipmapCompatible(n,t.contentDescriptor))return t}for(const[,t]of this.cache.entries()){const r=t.deref();if(r&&r.contentDescriptor){const c=n.subsetOf(r.contentDescriptor),h=this.isMipmapCompatible(n,r.contentDescriptor);if(c&&h)return r}}}getTextureForAtlas(n,e,t){this.textureAccessTimes.set(n,performance.now());let r=this.textures.get(n);if(r)return r;if(n.image){const c=this.calculateTextureMemory(n);return this.evictTexturesIfNeeded(c),r=new tl(e,n.image,t,{useMipmap:!!n.patternPositions.size}),this.textures.set(n,r),this.textureMemoryUsed+=c,r}return null}clearExpiredTextures(){for(const[n]of this.textures.entries())if(!this.isAtlasCached(n)){const e=this.textures.get(n);if(e){const t=this.calculateTextureMemory(n);e.destroy(),this.textureMemoryUsed-=t}this.textures.delete(n),this.textureAccessTimes.delete(n)}}isAtlasCached(n){if(!n.contentDescriptor)return!1;const e=this.cache.get(n.contentDescriptor.hash);return!!e&&e.deref()===n}getOrCache(n){if(!("image"in n)){const c=this.cache.get(n.sourceAtlasHash);if(c){const h=c.deref();if(h)return h}return zt("ImageAtlasReference points to GC'd atlas - atlas may have been evicted"),null}if(!n.contentDescriptor)return n;const e=n.contentDescriptor,t=e.hash,r=this.cache.get(t);if(r){const c=r.deref();if(c&&c.contentDescriptor&&this.isMipmapCompatible(e,c.contentDescriptor))return c}return this.cache.set(t,new WeakRef(n)),this.finalizationRegistry.register(n,t,n),n}isMipmapCompatible(n,e){return!n.requiresMipMaps||e.requiresMipMaps}destroyTextures(){for(const n of this.textures.values())n&&n.destroy();this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}clear(){for(const n of this.textures.values())n&&n.destroy();this.cache.clear(),this.textures.clear(),this.textureAccessTimes.clear(),this.textureMemoryUsed=0}},a.y=qs,a.z=pw}),C(["require","./shared"],function(a,F){function H(Re){const $=Re?Re.url.toString():void 0;return $?performance.getEntriesByName($):[]}function ee(Re){if(typeof Re=="number"||typeof Re=="boolean"||typeof Re=="string"||Re==null)return JSON.stringify(Re);if(Array.isArray(Re)){let q="[";for(const oe of Re)q+=`${ee(oe)},`;return`${q}]`}let $="{";for(const q of Object.keys(Re).sort())$+=`${q}:${ee(Re[q])},`;return`${$}}`}function se(Re){let $="";for(const q of F.b5)$+=`/${ee(Re[q])}`;return $}function ue(Re,$){return function q(oe){return typeof oe=="string"&&oe===$||(Array.isArray(oe)?oe.some(q):!(!oe||typeof oe!="object")&&Object.values(oe).some(q))}(Re)}class Me{constructor($){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),$&&this.replace($)}replace($,q){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update($,[],q)}update($,q,oe){this._options=oe;for(const be of $)this._layerConfigs[be.id]=be,(this._layers[be.id]=F.de(be,this.scope,null,this._options)).compileFilter(oe),this.keyCache[be.id]&&delete this.keyCache[be.id];for(const be of q)delete this.keyCache[be],delete this._layerConfigs[be],delete this._layers[be];this.familiesBySource=Object.create(null);const ge=function(be,Te){const De=Object.create(null);for(let Le=0;Le<be.length;Le++){const rt=be[Le];let Ke=Te&&Te[rt.id];Ke||(rt.type==="symbol"?Ke=rt.id:(Ke=se(rt),rt.type==="line"&&rt.paint&&ue(rt.paint["line-width"],"line-progress")&&(Ke+=`/${ee(rt.paint["line-width"])}`))),Te&&(Te[rt.id]=Ke);let gt=De[Ke];gt||(gt=De[Ke]=[]),gt.push(rt)}const Ae=[];for(const Le in De)Ae.push(De[Le]);return Ae}(Object.values(this._layerConfigs),this.keyCache);for(const be of ge){const Te=be.map(gt=>this._layers[gt.id]),De=Te[0];if(De.visibility==="none")continue;const Ae=De.source||"";let Le=this.familiesBySource[Ae];Le||(Le=this.familiesBySource[Ae]=Object.create(null));const rt=De.sourceLayer||"_geojsonTileLayer";let Ke=Le[rt];Ke||(Ke=Le[rt]=[]),Ke.push(Te)}}}const Ve=1*F.fa;class ke{constructor($){const q={},oe=[];for(const De in $){const Ae=$[De],Le=q[De]={};for(const rt in Ae.glyphs){const Ke=Ae.glyphs[+rt];if(!Ke||Ke.bitmap.width===0||Ke.bitmap.height===0)continue;const gt=Ke.metrics.localGlyph?Ve:1,Lt={x:0,y:0,w:Ke.bitmap.width+2*gt,h:Ke.bitmap.height+2*gt};oe.push(Lt),Le[rt]=Lt}}const{w:ge,h:be}=F.J(oe),Te=new F.f9({width:ge||1,height:be||1});for(const De in $){const Ae=$[De];for(const Le in Ae.glyphs){const rt=Ae.glyphs[+Le];if(!rt||rt.bitmap.width===0||rt.bitmap.height===0)continue;const Ke=q[De][Le],gt=rt.metrics.localGlyph?Ve:1;F.f9.copy(rt.bitmap,Te,{x:0,y:0},{x:Ke.x+gt,y:Ke.y+gt},rt.bitmap)}}this.image=Te,this.positions=q}}function Ye(Re,$,q){Re[$]?q&&(Re[$].center=q):Re[$]={floorIds:new Set,center:q||[0,0],floors:{}}}function Se(Re,$,q,oe){for(const ge of $)Ye(Re,ge),Re[ge].floors[q]=oe,Re[ge].floorIds.add(q)}function ye(Re){return{id:Re.properties.id.toString(),center:[Re.properties.center_lon||0,Re.properties.center_lat||0]}}function Ie(Re,$){const q=Re.properties.id.toString(),oe=!!Re.properties.is_default&&Re.properties.is_default,ge=Re.properties.connected_floor_ids?new Set(Re.properties.connected_floor_ids.toString().split(";")):new Set,be=Re.properties.conflicted_floor_ids?new Set(Re.properties.conflicted_floor_ids.toString().split(";")):new Set,Te=Re.properties.structure_ids?new Set(Re.properties.structure_ids.toString().split(";")):new Set,De=Re.properties.name.toString(),Ae=Re.properties.z_index,Le=function(rt,Ke){const gt=rt.loadGeometry();if(!gt||gt.length===0)return;const Lt=gt.map(Bt=>Bt.map(zt=>F.fb(zt,Ke,rt.extent)));return Lt.length===0?void 0:{type:"Polygon",coordinates:[Lt[0]]}}(Re,$);return{id:q,isDefault:oe,connections:ge,conflicts:be,buildings:Te,name:De,zIndex:Ae,geometry:Le}}function qe(Re,$){return $.every(q=>Re.properties&&Re.properties[q]!=null)}function ot(Re){return qe(Re,["type","id","name"])&&Re.properties.type==="structure"}function xt(Re){return qe(Re,["type","id","name","z_index"])&&Re.properties.type==="floor"}F.f8(ke,"GlyphAtlas");class Rt{constructor($){this.tileID=new F.aR($.tileID.overscaledZ,$.tileID.wrap,$.tileID.canonical.z,$.tileID.canonical.x,$.tileID.canonical.y),this.tileZoom=$.tileZoom,this.uid=$.uid,this.zoom=$.zoom,this.lut=$.lut,this.canonical=$.tileID.canonical,this.pixelRatio=$.pixelRatio,this.tileSize=$.tileSize,this.source=$.source,this.scope=$.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=$.showCollisionBoxes,this.collectResourceTiming=!!$.request&&$.request.collectResourceTiming,this.promoteId=$.promoteId,this.renderSourceType=$.renderSourceType,this.tileTransform=F.fc($.tileID.canonical,$.projection),this.projection=$.projection,this.worldview=$.worldview,this.localizableLayerIds=$.localizableLayerIds,this.brightness=$.brightness,this.extraShadowCaster=!!$.extraShadowCaster,this.tessellationStep=$.tessellationStep,this.scaleFactor=$.scaleFactor,this.worldview=$.worldview,this.indoor=$.indoor}parse($,q,oe,ge,be,Te){this.status="parsing",this.data=$,this.collisionBoxArray=new F.fd;const De=new F.fe(Object.keys($.layers).sort()),Ae=new F.ff(this.tileID,this.promoteId);Ae.bucketLayerIDs=[];const Le={},rt=new F.fg(256,256),Ke={featureIndex:Ae,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:rt,availableImages:oe,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(Ke.activeFloors=function(zt,Kt,hi,_i){const Wi=Kt.indoorState.activeFloorsVisible;if(!Kt.sourceLayers)return Wi?Kt.indoorState.activeFloors:void 0;const zn=function(Ni,cn){if(!Ni)return F.w("No source layers defined in indoor specification"),cn;if(Ni.size===0)return cn;const jn=Ni.difference(cn);for(const Xi of jn)F.w(`Missing source layer required in indoor specification: ${Xi}`);return cn.intersection(cn)}(Kt.sourceLayers,new Set(Object.keys(zt.layers))),Cn=Kt.indoorState,bn=function(Ni,cn,jn,Xi,un){const wn={};for(const yi of cn){const Xn=Ni.layers[yi];if(Xn)for(let Tr=0;Tr<Xn.length;Tr++){const gr=Xn.feature(Tr);if(ot(gr)){const{id:us,center:hs}=ye(gr);Ye(wn,us,hs);continue}if(xt(gr)){const us=Ie(gr,un);Se(wn,us.buildings,us.id,us)}}else F.w(`indoor source layer not found: ${yi}`)}return{buildings:wn,activeFloors:F.d1.calculate(wn,Xi,jn)}}(zt,zn,Cn.activeFloors,Cn.selectedFloorId,_i);return hi.send("setIndoorData",bn),Wi?bn.activeFloors:void 0}($,this.indoor,be,this.canonical));const gt=[],Lt=q.familiesBySource[this.source];for(const zt in Lt){const Kt=$.layers[zt];if(!Kt)continue;let hi=!1,_i=!1,Wi=!1,zn=!1;for(const jn of Lt[zt])jn[0].type==="symbol"?hi=!0:jn[0].type==="fill-extrusion"?_i=!0:Wi=!0,jn[0].is3D()&&jn[0].type!=="model"&&(zn=!0);if(this.extraShadowCaster&&!zn||this.renderSourceType===F.b4.Symbol&&!hi||this.renderSourceType===F.b4.FillExtrusion&&!_i||this.renderSourceType===F.b4.Other&&!Wi)continue;Kt.version===1&&F.w(`Vector tile source "${this.source}" layer "${zt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Cn=De.encode(zt),bn=[],Ni=this.localizableLayerIds&&this.localizableLayerIds.has(zt);let cn=!1;for(let jn=0,Xi=0;jn<Kt.length;jn++){const un=Kt.feature(jn),wn=Ae.getId(un,zt),yi=un.properties?un.properties.worldview:null;if(Ni&&this.worldview&&typeof yi=="string")if(yi==="all")un.properties.$localized=!0;else{if(!yi.split(",").includes(this.worldview))continue;un.properties.$localized=!0,un.properties.worldview=this.worldview}!cn&&un.properties&&un.properties.hasOwnProperty(F.fh)&&(cn=!0),bn.push({feature:un,id:wn,index:Xi,sourceLayerIndex:Cn}),Xi++}cn&&!Ke.elevationFeatures&&$.layers.hasOwnProperty(F.fi)&&(Ke.elevationFeatures=F.fj.parseFrom($.layers[F.fi],this.canonical));for(const jn of Lt[zt]){const Xi=jn[0];if(this.extraShadowCaster&&(!Xi.is3D()||Xi.type==="model")||this.renderSourceType===F.b4.Symbol&&Xi.type!=="symbol"||this.renderSourceType===F.b4.FillExtrusion&&Xi.type!=="fill-extrusion"||this.renderSourceType===F.b4.Other&&(Xi.type==="symbol"||Xi.type==="fill-extrusion")||Xi.minzoom&&this.zoom<Math.floor(Xi.minzoom)||Xi.maxzoom&&this.zoom>=Xi.maxzoom||Xi.visibility==="none")continue;Tt(jn,this.zoom,Ke.brightness,oe,this.worldview,Ke.activeFloors);const un=Le[Xi.id]=Xi.createBucket({index:Ae.bucketLayerIDs.length,layers:jn,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Cn,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:ge,worldview:this.worldview,localizable:Ni,availableImages:oe,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO});Ae.bucketLayerIDs.push(jn.map(yi=>F.F(yi.id,yi.scope)));let wn=un.prepare?un.prepare():null;wn!=null?(wn=wn.then(()=>un.populate(bn,Ke,this.tileID.canonical,this.tileTransform)),gt.push(wn)):un.populate(bn,Ke,this.tileID.canonical,this.tileTransform)}}const Bt=()=>{rt.trim();const zt=!(!Ke.elevationFeatures||!Ke.elevationFeatures.some(Xi=>Xi.heightRange.min<0));let Kt,hi,_i,Wi,zn,Cn,bn;const Ni={type:"maybePrepare",renderSourceType:this.renderSourceType,zoom:this.zoom},cn=()=>{if(Kt)return this.status="done",Te(Kt);if(this.extraShadowCaster)this.status="done",Te(null,{buckets:Object.values(Le).filter(Xi=>!Xi.isEmpty()),featureIndex:Ae,collisionBoxArray:null,hasTunnelGeometry:zt,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:Ke.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(hi&&_i&&Wi&&bn){const un=new ke(hi),wn=new Map;for(const[Tr,gr]of _i.entries()){const{imagePosition:us}=F.fn(Tr,gr,F.fo);wn.set(Tr,us)}const yi={};for(const Tr in Le){const gr=Le[Tr];gr instanceof F.fp&&(Tt(gr.layers,this.zoom,Ke.brightness,oe,this.worldview,Ke.activeFloors),yi[Tr]=F.fq(gr,hi,un.positions,_i,wn,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,zn,this.worldview,oe))}const Xn={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(be,_i,zn,()=>{Xn.iconsPending=!1,jn(yi,un,Xn,void 0,bn)}),this.rasterizeIfNeeded(be,Wi,Cn,()=>{Xn.patternsPending=!1,jn(yi,un,Xn,void 0,bn)})}},jn=(Xi,un,wn,yi,Xn)=>{if(wn.iconsPending||wn.patternsPending)return;const Tr=_i.size>0||Wi.size>0,gr=Object.keys(Xi).length>0;if(!Tr&&!gr)return this.status="done",void Te(null,{buckets:Object.values(Le).filter(hs=>!hs.isEmpty()),featureIndex:Ae,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:zt,glyphAtlasImage:un.image,lineAtlas:rt,imageAtlas:null,brightness:Ke.brightness});const us=(hs,ko)=>{for(const qr in Le){const ds=Le[qr];if(qr in Xi)F.fv(ds,Xi[qr],this.showCollisionBoxes,oe,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,_i,ko);else if(ds.hasPattern&&(ds instanceof F.fw||ds instanceof F.fl||ds instanceof F.e0)){Tt(ds.layers,this.zoom,Ke.brightness,oe,this.worldview,Ke.activeFloors);const Fo=Object.fromEntries(ko.patternPositions);ds.addFeatures(Ke,this.tileID.canonical,Fo,oe,this.tileTransform,this.brightness)}}this.status="done",Te(null,{buckets:Object.values(Le).filter(qr=>!qr.isEmpty()),featureIndex:Ae,collisionBoxArray:this.collisionBoxArray,hasTunnelGeometry:zt,glyphAtlasImage:un.image,lineAtlas:rt,imageAtlas:hs,brightness:Ke.brightness})};if(Tr){const hs=new Map,ko=F.fr(_i,hs),qr=F.fr(Wi,hs),ds=new F.fs(ko,qr,Xn,this.lut,hs);be.send("checkAtlasCache",{descriptor:ds,scope:this.scope},(Fo,As)=>{let Oo,qs;if(Fo&&F.w(`[Worker] Error checking atlas cache: ${Fo.message}`),As)Oo=new F.ft(As.sourceHash),qs=As;else{const ts=new F.fu(_i,Wi,this.lut,Xn);Oo=ts,qs=ts}us(Oo,qs)})}else us(null,{iconPositions:new Map,patternPositions:new Map})};if(!this.extraShadowCaster){const Xi=F.fk(Ke.glyphDependencies,yi=>Object.keys(yi).map(Number));Object.keys(Xi).length?be.send("getGlyphs",{uid:this.uid,stacks:Xi},(yi,Xn)=>{Kt||(Kt=yi,hi=Xn,cn())},void 0,!1,Ni):hi={},bn=new Map;const un=Array.from(Ke.iconDependencies.keys()).map(yi=>F.I.parse(yi));un.length?be.send("getImages",{images:un,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(yi,Xn)=>{if(!Kt){Kt=yi,_i=new Map,zn=this.updateImageMapAndGetImageTaskQueue(_i,Xn.images,Ke.iconDependencies);for(const[Tr,gr]of Xn.versions.entries())bn.set(Tr,gr);cn()}},void 0,!1,Ni):(_i=new Map,zn=new Map);const wn=Array.from(Ke.patternDependencies.keys()).map(yi=>F.I.parse(yi));wn.length?be.send("getImages",{images:wn,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(yi,Xn)=>{if(!Kt){Kt=yi,Wi=new Map,Cn=this.updateImageMapAndGetImageTaskQueue(Wi,Xn.images,Ke.patternDependencies);for(const[Tr,gr]of Xn.versions.entries())bn.set(Tr,gr);cn()}},void 0,!1,Ni):(Wi=new Map,Cn=new Map)}if(Ke.elevationFeatures&&Ke.elevationFeatures.length>0){const Xi=[];for(const wn of Object.values(Le))if(wn instanceof F.fl){const yi=wn.getUnevaluatedPortalGraph();yi&&Xi.push(yi)}const un=F.fm.evaluate(Xi);for(const wn of Object.values(Le))if(wn instanceof F.fl){const yi=$.layers[De.decode(wn.sourceLayerIndex)];wn.setEvaluatedPortalGraph(un,yi,this.tileID.canonical,Ke.availableImages,Ke.brightness)}}cn()};gt.length>0?Promise.allSettled(gt).then(Bt).catch(Te):Bt()}updateParameters($){this.scaleFactor=$.scaleFactor,this.showCollisionBoxes=$.showCollisionBoxes,this.projection=$.projection,this.brightness=$.brightness,this.tileTransform=F.fc($.tileID.canonical,$.projection),this.extraShadowCaster=$.extraShadowCaster,this.lut=$.lut,this.worldview=$.worldview,this.indoor=$.indoor}rasterizeIfNeeded($,q,oe,ge){Array.from(q.values()).some(be=>be.usvg)?this.rasterize($,q,oe,ge):ge()}updateImageMapAndGetImageTaskQueue($,q,oe){const ge=new Map;for(const be of q.keys()){const Te=oe.get(be)||[];for(const De of Te){const Ae=De.toString(),Le=q.get(De.id.toString());Le.usvg?ge.has(Ae)||(ge.set(Ae,De),$.set(Ae,Object.assign({},Le))):$.set(Ae,Le)}}return ge}rasterize($,q,oe,ge){this.rasterizeTask=$.send("rasterizeImages",{scope:this.scope,tasks:oe},(be,Te)=>{if(!be)for(const[De,Ae]of Te.entries()){const Le=Object.assign(q.get(De),{data:Ae});q.set(De,Le)}ge()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function Tt(Re,$,q,oe,ge,be){const Te=new F.ae($,{brightness:q,worldview:ge,activeFloors:be});for(const De of Re)De.recalculate(Te,oe)}class li extends F.E{constructor({actor:$,layerIndex:q,availableImages:oe,availableModels:ge,isSpriteLoaded:be,tileProvider:Te,brightness:De,maxUniformBufferBindings:Ae,maxUniformBlockSizeDwords:Le,disableSymbolUBO:rt}){super(),this.actor=$,this.layerIndex=q,this.availableImages=oe,this.availableModels=ge,this.loadVectorData=F.aO,this.tileProvider=Te,this.loading={},this.loaded={},this.deduped=new F.aN($.scheduler),this.isSpriteLoaded=be,this.scheduler=$.scheduler,this.brightness=De,this.maxUniformBufferBindings=Ae,this.maxUniformBlockSizeDwords=Le,this.disableSymbolUBO=rt}loadTileData($,q){if(!this.tileProvider)return this.loadVectorData($,q);const oe=new AbortController,{z:ge,x:be,y:Te}=$.tileID.canonical;return this.tileProvider.loadTile({z:ge,x:be,y:Te},{request:$.request,signal:oe.signal}).then(De=>{if(oe.signal.aborted)return;if(De==null){const Le=new Error("Tile not found");return Le.status=404,q(Le)}if(De.data===null)return q(null,null);const Ae=new Map;De.expires&&Ae.set("expires",De.expires),De.cacheControl&&Ae.set("cache-control",De.cacheControl),q(null,{rawData:De.data,responseHeaders:Ae})}).catch(De=>{oe.signal.aborted||q(De instanceof Error?De:new Error(String(De)))}),()=>oe.abort()}loadTile($,q){const oe=$.uid,ge=$&&$.request,be=ge&&ge.collectResourceTiming,Te=this.loading[oe]=new Rt($);Te.maxUniformBufferBindings=this.maxUniformBufferBindings,Te.maxUniformBlockSizeDwords=this.maxUniformBlockSizeDwords,Te.disableSymbolUBO=this.disableSymbolUBO,Te.abort=this.loadTileData($,(De,Ae)=>{const Le=!this.loading[oe];if(delete this.loading[oe],Te.cancelRasterize(),Le||De||!Ae)return Te.status="done",Le||(this.loaded[oe]=Te),q(De);const rt=Ae.rawData,Ke={},gt=F.aP(Ae.responseHeaders);gt&&gt.expires&&(Ke.expires=gt.expires),gt&&gt.cacheControl&&(Ke.cacheControl=gt.cacheControl),Te.vectorTile=Ae.vectorTile||new F.fx(new F.a$(rt));const Lt=()=>{Te.parse(Te.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(Bt,zt)=>{if(Bt||!zt)return q(Bt);const Kt={};if(be){const hi=H(ge);hi.length>0&&(Kt.resourceTiming=JSON.parse(JSON.stringify(hi)))}q(null,Object.assign({rawTileData:rt.slice(0),responseHeaders:Ae.responseHeaders},zt,Ke,Kt))})};this.isSpriteLoaded?Lt():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Lt,{type:"parseTile",renderSourceType:$.renderSourceType,zoom:$.tileZoom}):Lt()}),this.loaded=this.loaded||{},this.loaded[oe]=Te})}reloadTile($,q){const oe=this.loaded,ge=$.uid;if(oe&&oe[ge]){const be=oe[ge];be.updateParameters($);const Te=(De,Ae)=>{const Le=be.reloadCallback;Le&&(delete be.reloadCallback,be.parse(be.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Le)),q(De,Ae)};be.status==="parsing"?be.reloadCallback=Te:be.status==="done"&&(be.vectorTile?be.parse(be.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Te):Te())}else q(null,void 0)}abortTile($,q){const oe=$.uid,ge=this.loading[oe];ge&&(ge.abort&&ge.abort(),delete this.loading[oe]),q()}removeTile($,q){const oe=this.loaded,ge=$.uid;oe&&oe[ge]&&delete oe[ge],q()}}class Xt{constructor($){this.loading={}}loadTile($,q){const oe=$.uid,{cancel:ge}=F.b1($.request,(be,Te,De)=>{const Ae=!this.loading[oe];if(delete this.loading[oe],Ae||be||!Te)return q(be);this.decodeTile(oe,Te,$.encoding).then(Le=>{const{expires:rt,cacheControl:Ke}=F.aP(De);q(null,Object.assign(Le,{expires:rt,cacheControl:Ke}))}).catch(Le=>q(Le))});this.loading[oe]={cancel:ge}}async decodeTile($,q,oe){const ge=await createImageBitmap(new Blob([new Uint8Array(q)],{type:"image/png"})),be=1-(ge.width-F.fy(ge.width))/2,Te=be<1,De=this.getImageData(ge,be);return ge.close(),{dem:new F.fz($,De,oe,Te),borderReady:Te}}reloadTile($,q){q(null,null)}abortTile($,q){const oe=$.uid,ge=this.loading[oe];ge&&(ge.cancel(),delete this.loading[oe]),q()}removeTile($,q){q()}getImageData($,q){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas($.width,$.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=$.width,this.offscreenCanvas.height=$.height,this.offscreenCanvasContext.drawImage($,0,0,$.width,$.height);const oe=this.offscreenCanvasContext.getImageData(-q,-q,$.width+2*q,$.height+2*q);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),oe}}F.a_.setPbf(F.a$);class Ji{constructor($){this._mrt=new F.a_($.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=$.uid,this.tileID=$.tileID,this.source=$.source}parse($,q){const oe=this._mrt;this.status="parsing",this._entireBuffer=$;try{oe.parseHeader($),this._isHeaderLoaded=!0;const ge=[];for(const be in oe.layers){const Te=oe.getLayer(be),De=Te.getDataRange(Te.getBandList()),Ae=oe.createDecodingTask(De),Le=$.slice(De.firstByte,De.lastByte+1),rt=F.a_.performDecoding(Le,Ae).then(Ke=>Ae.complete(null,Ke)).catch(Ke=>Ae.complete(Ke,null));ge.push(rt)}Promise.allSettled(ge).then(()=>q(null,oe)).catch(be=>q(be))}catch(ge){q(ge)}}}class An{constructor({actor:$}){this.actor=$,this.loading={},this.loaded={}}loadTile($,q){const oe=$.uid,ge=$.request,be=this.loading[oe]=new Ji($),{cancel:Te}=F.b1(ge,(De,Ae,Le)=>{const rt=!this.loading[oe];if(delete this.loading[oe],rt||De||!Ae)return be.status="done",rt||(this.loaded[oe]=be),q(De);be.parse(Ae,(Ke,gt)=>{if(Ke||!gt)return q(Ke);q(null,gt,Le)}),this.loaded[oe]=be});be.abort=Te}reloadTile($,q){q(null,void 0)}abortTile($,q){const oe=$.uid,ge=this.loading[oe];ge&&(ge.abort&&ge.abort(),delete this.loading[oe]),q()}removeTile($,q){const oe=$.uid;this.loaded[oe]&&delete this.loaded[oe],q()}decodeRasterArray($,q){F.a_.performDecoding($.buffer,$.task).then(oe=>q(null,oe)).catch(oe=>q(oe))}}const gi=F.fA.prototype.toGeoJSON;class Mr{constructor($){this._feature=$,this.extent=F.an,this.type=$.type,this.properties=$.tags,"id"in $&&!isNaN($.id)&&(this.id=parseInt($.id,10))}loadGeometry(){if(this._feature.type===1){const $=[];for(const q of this._feature.geometry)$.push([new F.P(q[0],q[1])]);return $}{const $=[];for(const q of this._feature.geometry){const oe=[];for(const ge of q)oe.push(new F.P(ge[0],ge[1]));$.push(oe)}return $}}toGeoJSON($,q,oe){return gi.call(this,$,q,oe)}}class Wn{constructor($,q){this.name=$,this.extent=F.an,this.length=q.length,this._jsonFeatures=q}feature($){return new Mr(this._jsonFeatures[$])}}class ji{constructor($){this.layers={},this.extent=F.an;for(const q of Object.keys($))this.layers[q]=new Wn(q,$[q])}}const ti=64/4096;class Pt{constructor(){this.features=new Map}clear(){this.features.clear()}load($=[],q){for(const oe of $){const ge=oe.id;if(ge==null)continue;let be=this.features.get(ge);be&&this.updateCache(be,q),oe.geometry?(be=Wt(oe),this.updateCache(be,q),this.features.set(ge,be)):this.features.delete(ge),this.updateCache(be,q)}}updateCache($,q){for(const{canonical:oe,uid:ge}of Object.values(q)){const{z:be,x:Te,y:De}=oe;$t($,Math.pow(2,be),Te,De)&&delete q[ge]}}getTile($,q,oe){const ge=Math.pow(2,$),be=[];for(const Te of this.features.values())$t(Te,ge,q,oe)&&be.push(rn(Te,ge,q,oe));return{features:be}}getFeatures(){return[...this.features.values()]}}function $t({minX:Re,minY:$,maxX:q,maxY:oe},ge,be,Te){return Re<(be+1+ti)/ge&&$<(Te+1+ti)/ge&&q>(be-ti)/ge&&oe>(Te-ti)/ge}function Wt(Re){const{id:$,geometry:q,properties:oe}=Re;if(!q)return;if(q.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:ge,coordinates:be}=q,Te={id:$,type:1,geometry:[],tags:oe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},De=Te.geometry;if(ge==="Point")Ut(be,De,Te);else if(ge==="MultiPoint")for(const Ae of be)Ut(Ae,De,Te);else if(ge==="LineString")Te.type=2,ii(be,De,Te);else if(ge==="MultiLineString")Te.type=2,mi(be,De,Te);else if(ge==="Polygon")Te.type=3,mi(be,De,Te,!0);else{if(ge!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Te.type=3;for(const Ae of be)mi(Ae,De,Te,!0)}return Te}function Ut([Re,$],q,oe){const ge=F.aH(Re);let be=F.aL($);be=be<0?0:be>1?1:be,q.push(ge,be),oe.minX=Math.min(oe.minX,ge),oe.minY=Math.min(oe.minY,be),oe.maxX=Math.max(oe.maxX,ge),oe.maxY=Math.max(oe.maxY,be)}function ii(Re,$,q,oe=!1,ge=!1){const be=[];for(const Te of Re)Ut(Te,be,q);$.push(be),oe&&function(Te,De){let Ae=0;for(let Le=0,rt=Te.length,Ke=rt-2;Le<rt;Ke=Le,Le+=2)Ae+=(Te[Le]-Te[Ke])*(Te[Le+1]+Te[Ke+1]);if(Ae>0===De)for(let Le=0,rt=Te.length;Le<rt/2;Le+=2){const Ke=Te[Le],gt=Te[Le+1];Te[Le]=Te[rt-2-Le],Te[Le+1]=Te[rt-1-Le],Te[rt-2-Le]=Ke,Te[rt-1-Le]=gt}}(be,ge)}function mi(Re,$,q,oe=!1){for(let ge=0;ge<Re.length;ge++)ii(Re[ge],$,q,oe,ge===0)}function rn(Re,$,q,oe){const{id:ge,type:be,geometry:Te,tags:De}=Re,Ae=[];if(be===1)(function(Le,rt,Ke,gt,Lt){for(let Bt=0;Bt<Le.length;Bt+=2){const zt=Math.round(F.an*(Le[Bt+0]*rt-Ke)),Kt=Math.round(F.an*(Le[Bt+1]*rt-gt));Lt.push([zt,Kt])}})(Te,$,q,oe,Ae);else if(be===2)for(const Le of Te)ln(Le,$,q,oe,Ae);else if(be===3)for(const Le of Te)sn(Le,$,q,oe,Ae);return{id:ge,type:be,geometry:Ae,tags:De}}function ln(Re,$,q,oe,ge){const Te=F.an+128;let De;for(let Ae=0;Ae<Re.length-2;Ae+=2){let Le=Math.round(F.an*(Re[Ae+0]*$-q)),rt=Math.round(F.an*(Re[Ae+1]*$-oe)),Ke=Math.round(F.an*(Re[Ae+2]*$-q)),gt=Math.round(F.an*(Re[Ae+3]*$-oe));const Lt=Ke-Le,Bt=gt-rt;Le<-128&&Ke<-128||(Le<-128?(rt+=Math.round(Bt*((-128-Le)/Lt)),Le=-128):Ke<-128&&(gt=rt+Math.round(Bt*((-128-Le)/Lt)),Ke=-128),rt<-128&&gt<-128||(rt<-128?(Le+=Math.round(Lt*((-128-rt)/Bt)),rt=-128):gt<-128&&(Ke=Le+Math.round(Lt*((-128-rt)/Bt)),gt=-128),Le>=Te&&Ke>=Te||(Le>=Te?(rt+=Math.round(Bt*((Te-Le)/Lt)),Le=Te):Ke>=Te&&(gt=rt+Math.round(Bt*((Te-Le)/Lt)),Ke=Te),rt>=Te&&gt>=Te||(rt>=Te?(Le+=Math.round(Lt*((Te-rt)/Bt)),rt=Te):gt>=Te&&(Ke=Le+Math.round(Lt*((Te-rt)/Bt)),gt=Te),De&&Le===De[De.length-1][0]&&rt===De[De.length-1][1]||(De=[[Le,rt]],ge.push(De)),De.push([Ke,gt])))))}}function sn(Re,$,q,oe,ge){const be=(q-ti)/$,Te=(oe-ti)/$,De=(q+1+ti)/$,Ae=(oe+1+ti)/$;function Le(gt,Lt){let Bt=0;return gt<be?Bt|=1:gt>De&&(Bt|=2),Lt<Te?Bt|=4:Lt>Ae&&(Bt|=8),Bt}let rt=[];for(let gt=1;gt<=8;gt*=2){let Lt=Re[Re.length-2],Bt=Re[Re.length-1],zt=!(Le(Lt,Bt)&gt);for(let Kt=0;Kt<Re.length;Kt+=2){const hi=Re[Kt],_i=Re[Kt+1],Wi=!(Le(hi,_i)&gt);Wi!==zt&&(8&gt?rt.push(Lt+(hi-Lt)*(Ae-Bt)/(_i-Bt),Ae):4&gt?rt.push(Lt+(hi-Lt)*(Te-Bt)/(_i-Bt),Te):2&gt?rt.push(De,Bt+(_i-Bt)*(De-Lt)/(hi-Lt)):1&gt&&rt.push(be,Bt+(_i-Bt)*(be-Lt)/(hi-Lt))),Wi&&rt.push(hi,_i),Lt=hi,Bt=_i,zt=Wi}if(!(Re=rt).length||gt===8)break;rt=[]}const Ke=[];for(let gt=0;gt<rt.length;gt+=2)Ke.push([Math.round(F.an*(rt[gt]*$-q)),Math.round(F.an*(rt[gt+1]*$-oe))]);Ke.length&&ge.push(Ke)}function Rr({name:Re,features:$},q){q.writeStringField(1,Re),q.writeVarintField(5,F.an);const oe=new Map,ge=new Map,be={keys:oe,values:ge,feature:null};for(const Te of $)be.feature=Te,q.writeMessage(2,lo,be);for(const Te of oe.keys())q.writeStringField(3,Te);for(const Te of ge.keys())q.writeMessage(4,mn,Te)}function lo(Re,$){const q=Re.feature;q.id!==void 0&&Number.isSafeInteger(+q.id)&&$.writeVarintField(1,+q.id),q.tags&&$.writeMessage(2,zi,Re),$.writeVarintField(3,q.type),$.writeMessage(4,oa,q)}function zi({keys:Re,values:$,feature:q},oe){for(const ge of Object.keys(q.tags)){let be=q.tags[ge];if(be===null)continue;let Te=Re.get(ge);Te===void 0&&(Te=Re.size,Re.set(ge,Te)),oe.writeVarint(Te);const De=typeof be;De!=="string"&&De!=="boolean"&&De!=="number"&&(be=JSON.stringify(be));let Ae=$.get(be);Ae===void 0&&(Ae=$.size,$.set(be,Ae)),oe.writeVarint(Ae)}}function pn(Re,$){return($<<3)+(7&Re)}function On(Re){return Re<<1^Re>>31}function oa(Re,$){const{geometry:q,type:oe}=Re;let ge=0,be=0;if(oe===1){$.writeVarint(pn(1,q.length));for(const Te of q){const De=Te[0]-ge,Ae=Te[1]-be;$.writeVarint(On(De)),$.writeVarint(On(Ae)),ge+=De,be+=Ae}}else for(const Te of q){if(Te.length===0)continue;$.writeVarint(pn(1,1));const De=Te.length-(oe===3?1:0);for(let Ae=0;Ae<De;Ae++){Ae===1&&$.writeVarint(pn(2,De-1));const Le=Te[Ae][0]-ge,rt=Te[Ae][1]-be;$.writeVarint(On(Le)),$.writeVarint(On(rt)),ge+=Le,be+=rt}oe===3&&$.writeVarint(pn(7,1))}}function mn(Re,$){const q=typeof Re;q==="string"?$.writeStringField(1,Re):q==="boolean"?$.writeBooleanField(7,Re):q==="number"&&(Re%1!=0?$.writeDoubleField(3,Re):Re<0?$.writeSVarintField(6,Re):$.writeVarintField(5,Re))}const Mo={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:Re=>Re},co=Math.fround||(cc=new Float32Array(1),Re=>(cc[0]=+Re,cc[0]));var cc;class Hs{constructor($){this.options=Object.assign(Object.create(Mo),$),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load($){const{log:q,minZoom:oe,maxZoom:ge}=this.options;q&&console.time("total time");const be=`prepare ${$.length} points`;q&&console.time(be),this.points=$;const Te=[];for(let Ae=0;Ae<$.length;Ae++){const Le=$[Ae];if(!Le.geometry)continue;const[rt,Ke]=Le.geometry.coordinates,gt=co(La(rt)),Lt=co(Zr(Ke));Te.push(gt,Lt,1/0,Ae,-1,1),this.options.reduce&&Te.push(0)}let De=this.trees[ge+1]=this._createTree(Te);q&&console.timeEnd(be);for(let Ae=ge;Ae>=oe;Ae--){const Le=+Date.now();De=this.trees[Ae]=this._createTree(this._cluster(De,Ae)),q&&console.log("z%d: %d clusters in %dms",Ae,De.numItems,+Date.now()-Le)}return q&&console.timeEnd("total time"),this}getClusters($,q){let oe=(($[0]+180)%360+360)%360-180;const ge=Math.max(-90,Math.min(90,$[1]));let be=$[2]===180?180:(($[2]+180)%360+360)%360-180;const Te=Math.max(-90,Math.min(90,$[3]));if($[2]-$[0]>=360)oe=-180,be=180;else if(oe>be){const Ke=this.getClusters([oe,ge,180,Te],q),gt=this.getClusters([-180,ge,be,Te],q);return Ke.concat(gt)}const De=this.trees[this._limitZoom(q)],Ae=De.range(La(oe),Zr(Te),La(be),Zr(ge)),Le=De.data,rt=[];for(const Ke of Ae){const gt=this.stride*Ke;rt.push(Le[gt+5]>1?Ln(Le,gt,this.clusterProps):this.points[Le[gt+3]])}return rt}getChildren($){const q=this._getOriginId($),oe=this._getOriginZoom($),ge="No cluster with the specified id.",be=this.trees[oe];if(!be)throw new Error(ge);const Te=be.data;if(q*this.stride>=Te.length)throw new Error(ge);const De=this.options.radius/(this.options.extent*Math.pow(2,oe-1)),Ae=be.within(Te[q*this.stride],Te[q*this.stride+1],De),Le=[];for(const rt of Ae){const Ke=rt*this.stride;Te[Ke+4]===$&&Le.push(Te[Ke+5]>1?Ln(Te,Ke,this.clusterProps):this.points[Te[Ke+3]])}if(Le.length===0)throw new Error(ge);return Le}getLeaves($,q,oe){const ge=[];return this._appendLeaves(ge,$,q=q||10,oe=oe||0,0),ge}getTile($,q,oe){const ge=this.trees[this._limitZoom($)],be=Math.pow(2,$),{extent:Te,radius:De}=this.options,Ae=De/Te,Le=(oe-Ae)/be,rt=(oe+1+Ae)/be,Ke={features:[]};return this._addTileFeatures(ge.range((q-Ae)/be,Le,(q+1+Ae)/be,rt),ge.data,q,oe,be,Ke),q===0&&this._addTileFeatures(ge.range(1-Ae/be,Le,1,rt),ge.data,be,oe,be,Ke),q===be-1&&this._addTileFeatures(ge.range(0,Le,Ae/be,rt),ge.data,-1,oe,be,Ke),Ke.features.length?Ke:null}getClusterExpansionZoom($){let q=this._getOriginZoom($)-1;for(;q<=this.options.maxZoom;){const oe=this.getChildren($);if(q++,oe.length!==1)break;$=oe[0].properties.cluster_id}return q}_appendLeaves($,q,oe,ge,be){const Te=this.getChildren(q);for(const De of Te){const Ae=De.properties;if(Ae&&Ae.cluster?be+Ae.point_count<=ge?be+=Ae.point_count:be=this._appendLeaves($,Ae.cluster_id,oe,ge,be):be<ge?be++:$.push(De),$.length===oe)break}return be}_createTree($){const q=new F.bI($.length/this.stride|0,this.options.nodeSize,Float32Array);for(let oe=0;oe<$.length;oe+=this.stride)q.add($[oe],$[oe+1]);return q.finish(),q.data=$,q}_addTileFeatures($,q,oe,ge,be,Te){for(const De of $){const Ae=De*this.stride,Le=q[Ae+5]>1;let rt,Ke,gt;if(Le)rt=id(q,Ae,this.clusterProps),Ke=q[Ae],gt=q[Ae+1];else{const zt=this.points[q[Ae+3]];rt=zt.properties;const[Kt,hi]=zt.geometry.coordinates;Ke=La(Kt),gt=Zr(hi)}const Lt={type:1,geometry:[[Math.round(this.options.extent*(Ke*be-oe)),Math.round(this.options.extent*(gt*be-ge))]],tags:rt};let Bt;Bt=Le||this.options.generateId?q[Ae+3]:this.points[q[Ae+3]].id,Bt!==void 0&&(Lt.id=Bt),Te.features.push(Lt)}}_limitZoom($){return Math.max(this.options.minZoom,Math.min(Math.floor(+$),this.options.maxZoom+1))}_cluster($,q){const{radius:oe,extent:ge,reduce:be,minPoints:Te}=this.options,De=oe/(ge*Math.pow(2,q)),Ae=$.data,Le=[],rt=this.stride;for(let Ke=0;Ke<Ae.length;Ke+=rt){if(Ae[Ke+2]<=q)continue;Ae[Ke+2]=q;const gt=Ae[Ke],Lt=Ae[Ke+1],Bt=$.within(Ae[Ke],Ae[Ke+1],De),zt=Ae[Ke+5];let Kt=zt;for(const hi of Bt){const _i=hi*rt;Ae[_i+2]>q&&(Kt+=Ae[_i+5])}if(Kt>zt&&Kt>=Te){let hi,_i=gt*zt,Wi=Lt*zt,zn=-1;const Cn=(Ke/rt<<5)+(q+1)+this.points.length;for(const bn of Bt){const Ni=bn*rt;if(Ae[Ni+2]<=q)continue;Ae[Ni+2]=q;const cn=Ae[Ni+5];_i+=Ae[Ni]*cn,Wi+=Ae[Ni+1]*cn,Ae[Ni+4]=Cn,be&&(hi||(hi=this._map(Ae,Ke,!0),zn=this.clusterProps.length,this.clusterProps.push(hi)),be(hi,this._map(Ae,Ni)))}Ae[Ke+4]=Cn,Le.push(_i/Kt,Wi/Kt,1/0,Cn,-1,Kt),be&&Le.push(zn)}else{for(let hi=0;hi<rt;hi++)Le.push(Ae[Ke+hi]);if(Kt>1)for(const hi of Bt){const _i=hi*rt;if(!(Ae[_i+2]<=q)){Ae[_i+2]=q;for(let Wi=0;Wi<rt;Wi++)Le.push(Ae[_i+Wi])}}}}return Le}_getOriginId($){return $-this.points.length>>5}_getOriginZoom($){return($-this.points.length)%32}_map($,q,oe){if($[q+5]>1){const Te=this.clusterProps[$[q+6]];return oe?Object.assign({},Te):Te}const ge=this.points[$[q+3]].properties,be=this.options.map(ge);return oe&&be===ge?Object.assign({},be):be}}function Ln(Re,$,q){return{type:"Feature",id:Re[$+3],properties:id(Re,$,q),geometry:{type:"Point",coordinates:[(oe=Re[$],360*(oe-.5)),nd(Re[$+1])]}};var oe}function id(Re,$,q){const oe=Re[$+5],ge=oe>=1e4?`${Math.round(oe/1e3)}k`:oe>=1e3?Math.round(oe/100)/10+"k":oe,be=Re[$+6],Te=be===-1?{}:Object.assign({},q[be]);return Object.assign(Te,{cluster:!0,cluster_id:Re[$+3],point_count:oe,point_count_abbreviated:ge})}function La(Re){return Re/360+.5}function Zr(Re){const $=Math.sin(Re*Math.PI/180),q=.5-.25*Math.log((1+$)/(1-$))/Math.PI;return q<0?0:q>1?1:q}function nd(Re){const $=(180-360*Re)*Math.PI/180;return 360*Math.atan(Math.exp($))/Math.PI-90}function za(Re,$,q,oe){let ge=oe;const be=$+(q-$>>1);let Te,De=q-$;const Ae=Re[$],Le=Re[$+1],rt=Re[q],Ke=Re[q+1];for(let gt=$+3;gt<q;gt+=3){const Lt=Ro(Re[gt],Re[gt+1],Ae,Le,rt,Ke);if(Lt>ge)Te=gt,ge=Lt;else if(Lt===ge){const Bt=Math.abs(gt-be);Bt<De&&(Te=gt,De=Bt)}}ge>oe&&(Te-$>3&&za(Re,$,Te,oe),Re[Te+2]=ge,q-Te>3&&za(Re,Te,q,oe))}function Ro(Re,$,q,oe,ge,be){let Te=ge-q,De=be-oe;if(Te!==0||De!==0){const Ae=((Re-q)*Te+($-oe)*De)/(Te*Te+De*De);Ae>1?(q=ge,oe=be):Ae>0&&(q+=Te*Ae,oe+=De*Ae)}return Te=Re-q,De=$-oe,Te*Te+De*De}function vr(Re,$,q,oe){const ge={id:Re??null,type:$,geometry:q,tags:oe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if($==="Point"||$==="MultiPoint"||$==="LineString")Es(ge,q);else if($==="Polygon")Es(ge,q[0]);else if($==="MultiLineString")for(const be of q)Es(ge,be);else if($==="MultiPolygon")for(const be of q)Es(ge,be[0]);return ge}function Es(Re,$){for(let q=0;q<$.length;q+=3)Re.minX=Math.min(Re.minX,$[q]),Re.minY=Math.min(Re.minY,$[q+1]),Re.maxX=Math.max(Re.maxX,$[q]),Re.maxY=Math.max(Re.maxY,$[q+1])}function aa(Re,$,q,oe){if(!$.geometry)return;const ge=$.geometry.coordinates;if(ge&&ge.length===0)return;const be=$.geometry.type,Te=Math.pow(q.tolerance/((1<<q.maxZoom)*q.extent),2);let De=[],Ae=$.id;if(q.promoteId?Ae=$.properties[q.promoteId]:q.generateId&&(Ae=oe||0),be==="Point")uc(ge,De);else if(be==="MultiPoint")for(const Le of ge)uc(Le,De);else if(be==="LineString")hc(ge,De,Te,!1);else if(be==="MultiLineString"){if(q.lineMetrics){for(const Le of ge)De=[],hc(Le,De,Te,!1),Re.push(vr(Ae,"LineString",De,$.properties));return}Nr(ge,De,Te,!1)}else if(be==="Polygon")Nr(ge,De,Te,!0);else{if(be!=="MultiPolygon"){if(be==="GeometryCollection"){for(const Le of $.geometry.geometries)aa(Re,{id:Ae,geometry:Le,properties:$.properties},q,oe);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const Le of ge){const rt=[];Nr(Le,rt,Te,!0),De.push(rt)}}Re.push(vr(Ae,be,De,$.properties))}function uc(Re,$){$.push(dc(Re[0]),fc(Re[1]),0)}function hc(Re,$,q,oe){let ge,be,Te=0;for(let Ae=0;Ae<Re.length;Ae++){const Le=dc(Re[Ae][0]),rt=fc(Re[Ae][1]);$.push(Le,rt,0),Ae>0&&(Te+=oe?(ge*rt-Le*be)/2:Math.sqrt(Math.pow(Le-ge,2)+Math.pow(rt-be,2))),ge=Le,be=rt}const De=$.length-3;$[2]=1,za($,0,De,q),$[De+2]=1,$.size=Math.abs(Te),$.start=0,$.end=$.size}function Nr(Re,$,q,oe){for(let ge=0;ge<Re.length;ge++){const be=[];hc(Re[ge],be,q,oe),$.push(be)}}function dc(Re){return Re/360+.5}function fc(Re){const $=Math.sin(Re*Math.PI/180),q=.5-.25*Math.log((1+$)/(1-$))/Math.PI;return q<0?0:q>1?1:q}function br(Re,$,q,oe,ge,be,Te,De){if(oe/=$,be>=(q/=$)&&Te<oe)return Re;if(Te<q||be>=oe)return null;const Ae=[];for(const Le of Re){const rt=Le.geometry;let Ke=Le.type;const gt=ge===0?Le.minX:Le.minY,Lt=ge===0?Le.maxX:Le.maxY;if(gt>=q&&Lt<oe){Ae.push(Le);continue}if(Lt<q||gt>=oe)continue;let Bt=[];if(Ke==="Point"||Ke==="MultiPoint")Eu(rt,Bt,q,oe,ge);else if(Ke==="LineString")Dr(rt,Bt,q,oe,ge,!1,De.lineMetrics);else if(Ke==="MultiLineString")ka(rt,Bt,q,oe,ge,!1);else if(Ke==="Polygon")ka(rt,Bt,q,oe,ge,!0);else if(Ke==="MultiPolygon")for(const zt of rt){const Kt=[];ka(zt,Kt,q,oe,ge,!0),Kt.length&&Bt.push(Kt)}if(Bt.length){if(De.lineMetrics&&Ke==="LineString"){for(const zt of Bt)Ae.push(vr(Le.id,Ke,zt,Le.tags));continue}Ke!=="LineString"&&Ke!=="MultiLineString"||(Bt.length===1?(Ke="LineString",Bt=Bt[0]):Ke="MultiLineString"),Ke!=="Point"&&Ke!=="MultiPoint"||(Ke=Bt.length===3?"Point":"MultiPoint"),Ae.push(vr(Le.id,Ke,Bt,Le.tags))}}return Ae.length?Ae:null}function Eu(Re,$,q,oe,ge){for(let be=0;be<Re.length;be+=3){const Te=Re[be+ge];Te>=q&&Te<=oe&&Is($,Re[be],Re[be+1],Re[be+2])}}function Dr(Re,$,q,oe,ge,be,Te){let De=Do(Re);const Ae=ge===0?Lo:fl;let Le,rt,Ke=Re.start;for(let Kt=0;Kt<Re.length-3;Kt+=3){const hi=Re[Kt],_i=Re[Kt+1],Wi=Re[Kt+2],zn=Re[Kt+3],Cn=Re[Kt+4],bn=ge===0?hi:_i,Ni=ge===0?zn:Cn;let cn=!1;Te&&(Le=Math.sqrt(Math.pow(hi-zn,2)+Math.pow(_i-Cn,2))),bn<q?Ni>q&&(rt=Ae(De,hi,_i,zn,Cn,q),Te&&(De.start=Ke+Le*rt)):bn>oe?Ni<oe&&(rt=Ae(De,hi,_i,zn,Cn,oe),Te&&(De.start=Ke+Le*rt)):Is(De,hi,_i,Wi),Ni<q&&bn>=q&&(rt=Ae(De,hi,_i,zn,Cn,q),cn=!0),Ni>oe&&bn<=oe&&(rt=Ae(De,hi,_i,zn,Cn,oe),cn=!0),!be&&cn&&(Te&&(De.end=Ke+Le*rt),$.push(De),De=Do(Re)),Te&&(Ke+=Le)}let gt=Re.length-3;const Lt=Re[gt],Bt=Re[gt+1],zt=ge===0?Lt:Bt;zt>=q&&zt<=oe&&Is(De,Lt,Bt,Re[gt+2]),gt=De.length-3,be&&gt>=3&&(De[gt]!==De[0]||De[gt+1]!==De[1])&&Is(De,De[0],De[1],De[2]),De.length&&$.push(De)}function Do(Re){const $=[];return $.size=Re.size,$.start=Re.start,$.end=Re.end,$}function ka(Re,$,q,oe,ge,be){for(const Te of Re)Dr(Te,$,q,oe,ge,be,!1)}function Is(Re,$,q,oe){Re.push($,q,oe)}function Lo(Re,$,q,oe,ge,be){const Te=(be-$)/(oe-$);return Is(Re,be,q+(ge-q)*Te,1),Te}function fl(Re,$,q,oe,ge,be){const Te=(be-q)/(ge-q);return Is(Re,$+(oe-$)*Te,be,1),Te}function pl(Re,$){const q=[];for(let oe=0;oe<Re.length;oe++){const ge=Re[oe],be=ge.type;let Te;if(be==="Point"||be==="MultiPoint"||be==="LineString")Te=ml(ge.geometry,$);else if(be==="MultiLineString"||be==="Polygon"){Te=[];for(const De of ge.geometry)Te.push(ml(De,$))}else if(be==="MultiPolygon"){Te=[];for(const De of ge.geometry){const Ae=[];for(const Le of De)Ae.push(ml(Le,$));Te.push(Ae)}}q.push(vr(ge.id,be,Te,ge.tags))}return q}function ml(Re,$){const q=[];q.size=Re.size,Re.start!==void 0&&(q.start=Re.start,q.end=Re.end);for(let oe=0;oe<Re.length;oe+=3)q.push(Re[oe]+$,Re[oe+1],Re[oe+2]);return q}function uo(Re,$){if(Re.transformed)return Re;const q=1<<Re.z,oe=Re.x,ge=Re.y;for(const be of Re.features){const Te=be.geometry,De=be.type;if(be.geometry=[],De===1)for(let Ae=0;Ae<Te.length;Ae+=2)be.geometry.push(_l(Te[Ae],Te[Ae+1],$,q,oe,ge));else for(let Ae=0;Ae<Te.length;Ae++){const Le=[];for(let rt=0;rt<Te[Ae].length;rt+=2)Le.push(_l(Te[Ae][rt],Te[Ae][rt+1],$,q,oe,ge));be.geometry.push(Le)}}return Re.transformed=!0,Re}function _l(Re,$,q,oe,ge,be){return[Math.round(q*(Re*oe-ge)),Math.round(q*($*oe-be))]}function Iu(Re,$,q,oe,ge){const be=$===ge.maxZoom?0:ge.tolerance/((1<<$)*ge.extent),Te={features:[],numPoints:0,numSimplified:0,numFeatures:Re.length,source:null,x:q,y:oe,z:$,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const De of Re)Ap(Te,De,be,ge);return Te}function Ap(Re,$,q,oe){const ge=$.geometry,be=$.type,Te=[];if(Re.minX=Math.min(Re.minX,$.minX),Re.minY=Math.min(Re.minY,$.minY),Re.maxX=Math.max(Re.maxX,$.maxX),Re.maxY=Math.max(Re.maxY,$.maxY),be==="Point"||be==="MultiPoint")for(let De=0;De<ge.length;De+=3)Te.push(ge[De],ge[De+1]),Re.numPoints++,Re.numSimplified++;else if(be==="LineString")Fa(Te,ge,Re,q,!1,!1);else if(be==="MultiLineString"||be==="Polygon")for(let De=0;De<ge.length;De++)Fa(Te,ge[De],Re,q,be==="Polygon",De===0);else if(be==="MultiPolygon")for(let De=0;De<ge.length;De++){const Ae=ge[De];for(let Le=0;Le<Ae.length;Le++)Fa(Te,Ae[Le],Re,q,!0,Le===0)}if(Te.length){let De=$.tags||null;if(be==="LineString"&&oe.lineMetrics){De={};for(const Le in $.tags)De[Le]=$.tags[Le];De.mapbox_clip_start=ge.start/ge.size,De.mapbox_clip_end=ge.end/ge.size}const Ae={geometry:Te,type:be==="Polygon"||be==="MultiPolygon"?3:be==="LineString"||be==="MultiLineString"?2:1,tags:De};$.id!==null&&(Ae.id=$.id),Re.features.push(Ae)}}function Fa(Re,$,q,oe,ge,be){const Te=oe*oe;if(oe>0&&$.size<(ge?Te:oe))return void(q.numPoints+=$.length/3);const De=[];for(let Ae=0;Ae<$.length;Ae+=3)(oe===0||$[Ae+2]>Te)&&(q.numSimplified++,De.push($[Ae],$[Ae+1])),q.numPoints++;ge&&function(Ae,Le){let rt=0;for(let Ke=0,gt=Ae.length,Lt=gt-2;Ke<gt;Lt=Ke,Ke+=2)rt+=(Ae[Ke]-Ae[Lt])*(Ae[Ke+1]+Ae[Lt+1]);if(rt>0===Le)for(let Ke=0,gt=Ae.length;Ke<gt/2;Ke+=2){const Lt=Ae[Ke],Bt=Ae[Ke+1];Ae[Ke]=Ae[gt-2-Ke],Ae[Ke+1]=Ae[gt-1-Ke],Ae[gt-2-Ke]=Lt,Ae[gt-1-Ke]=Bt}}(De,be),Re.push(De)}const rd={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class Au{constructor($,q){const oe=(q=this.options=function(be,Te){for(const De in Te)be[De]=Te[De];return be}(Object.create(rd),q)).debug;if(oe&&console.time("preprocess data"),q.maxZoom<0||q.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(q.promoteId&&q.generateId)throw new Error("promoteId and generateId cannot be used together.");let ge=function(be,Te){const De=[];if(be.type==="FeatureCollection")for(let Ae=0;Ae<be.features.length;Ae++)aa(De,be.features[Ae],Te,Ae);else aa(De,be.type==="Feature"?be:{geometry:be},Te);return De}($,q);this.tiles={},this.tileCoords=[],oe&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",q.indexMaxZoom,q.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),ge=function(be,Te){const De=Te.buffer/Te.extent;let Ae=be;const Le=br(be,1,-1-De,De,0,-1,2,Te),rt=br(be,1,1-De,2+De,0,-1,2,Te);return(Le||rt)&&(Ae=br(be,1,-De,1+De,0,-1,2,Te)||[],Le&&(Ae=pl(Le,1).concat(Ae)),rt&&(Ae=Ae.concat(pl(rt,-1)))),Ae}(ge,q),ge.length&&this.splitTile(ge,0,0,0),oe&&(ge.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile($,q,oe,ge,be,Te,De){const Ae=[$,q,oe,ge],Le=this.options,rt=Le.debug;for(;Ae.length;){ge=Ae.pop(),oe=Ae.pop(),q=Ae.pop(),$=Ae.pop();const Ke=1<<q,gt=it(q,oe,ge);let Lt=this.tiles[gt];if(!Lt&&(rt>1&&console.time("creation"),Lt=this.tiles[gt]=Iu($,q,oe,ge,Le),this.tileCoords.push({z:q,x:oe,y:ge}),rt)){rt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",q,oe,ge,Lt.numFeatures,Lt.numPoints,Lt.numSimplified),console.timeEnd("creation"));const cn=`z${q}`;this.stats[cn]=(this.stats[cn]||0)+1,this.total++}if(Lt.source=$,be==null){if(q===Le.indexMaxZoom||Lt.numPoints<=Le.indexMaxPoints)continue}else{if(q===Le.maxZoom||q===be)continue;if(be!=null){const cn=be-q;if(oe!==Te>>cn||ge!==De>>cn)continue}}if(Lt.source=null,$.length===0)continue;rt>1&&console.time("clipping");const Bt=.5*Le.buffer/Le.extent,zt=.5-Bt,Kt=.5+Bt,hi=1+Bt;let _i=null,Wi=null,zn=null,Cn=null,bn=br($,Ke,oe-Bt,oe+Kt,0,Lt.minX,Lt.maxX,Le),Ni=br($,Ke,oe+zt,oe+hi,0,Lt.minX,Lt.maxX,Le);$=null,bn&&(_i=br(bn,Ke,ge-Bt,ge+Kt,1,Lt.minY,Lt.maxY,Le),Wi=br(bn,Ke,ge+zt,ge+hi,1,Lt.minY,Lt.maxY,Le),bn=null),Ni&&(zn=br(Ni,Ke,ge-Bt,ge+Kt,1,Lt.minY,Lt.maxY,Le),Cn=br(Ni,Ke,ge+zt,ge+hi,1,Lt.minY,Lt.maxY,Le),Ni=null),rt>1&&console.timeEnd("clipping"),Ae.push(_i||[],q+1,2*oe,2*ge),Ae.push(Wi||[],q+1,2*oe,2*ge+1),Ae.push(zn||[],q+1,2*oe+1,2*ge),Ae.push(Cn||[],q+1,2*oe+1,2*ge+1)}}getTile($,q,oe){$=+$,q=+q,oe=+oe;const ge=this.options,{extent:be,debug:Te}=ge;if($<0||$>24)return null;const De=1<<$,Ae=it($,q=q+De&De-1,oe);if(this.tiles[Ae])return uo(this.tiles[Ae],be);Te>1&&console.log("drilling down to z%d-%d-%d",$,q,oe);let Le,rt=$,Ke=q,gt=oe;for(;!Le&&rt>0;)rt--,Ke>>=1,gt>>=1,Le=this.tiles[it(rt,Ke,gt)];return Le&&Le.source?(Te>1&&(console.log("found parent tile z%d-%d-%d",rt,Ke,gt),console.time("drilling down")),this.splitTile(Le.source,rt,Ke,gt,$,q,oe),Te>1&&console.timeEnd("drilling down"),this.tiles[Ae]?uo(this.tiles[Ae],be):null):null}}function it(Re,$,q){return 32*((1<<Re)*q+$)+Re}function zo(Re,$){const q=Re.tileID.canonical;if(!this._geoJSONIndex)return void $(null,null);const oe=this._geoJSONIndex.getTile(q.z,q.x,q.y);if(!oe)return void $(null,null);const ge=Le=>Le.tags&&"3d_elevation_id"in Le.tags&&"source"in Le.tags&&Le.tags.source==="elevation",be=oe.features.filter(Le=>ge(Le));let Te={_geojsonTileLayer:oe.features};be.length>0&&(Te={_geojsonTileLayer:oe.features.filter(Le=>!ge(Le)),hd_road_elevation:be});const De=new ji(Te),Ae=function(Le){const rt=new F.a$;for(const Ke of Object.keys(Le))rt.writeMessage(3,Rr,{name:Ke,features:Le[Ke]});return rt.finish()}(Te).buffer;$(null,{vectorTile:De,rawData:Ae})}class vn extends li{constructor($){super($),this.loadVectorData=zo,this._dynamicIndex=new Pt}loadData($,q){const oe=$&&$.request,ge=oe&&oe.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON($,(be,Te)=>{if(be||!Te)return q(be);if(typeof Te!="object")return q(new Error(`Input data given to '${$.source}' is not a valid GeoJSON object.`));{try{if($.filter){const Ae=F.X($.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Ae.result==="error")throw new Error(Ae.value.map(Le=>`${Le.key}: ${Le.message}`).join(", "));Te.features=Te.features.filter(Le=>Ae.value.evaluate({zoom:0},Le))}$.dynamic?(Te.type==="Feature"&&(Te={type:"FeatureCollection",features:[Te]}),$.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Te.features,this.loaded),$.cluster&&(Te.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=$.cluster?new Hs(function({superclusterOptions:Ae,clusterProperties:Le}){if(!Le||!Ae)return Ae;const rt={},Ke={},gt={accumulated:null,zoom:0},Lt={properties:null},Bt=Object.keys(Le);for(const zt of Bt){const[Kt,hi]=Le[zt],_i=F.X(hi),Wi=F.X(typeof Kt=="string"?[Kt,["accumulated"],["get",zt]]:Kt);rt[zt]=_i.value,Ke[zt]=Wi.value}return Ae.map=zt=>{Lt.properties=zt;const Kt={};for(const hi of Bt)Kt[hi]=rt[hi].evaluate(gt,Lt);return Kt},Ae.reduce=(zt,Kt)=>{Lt.properties=Kt;for(const hi of Bt)gt.accumulated=zt[hi],zt[hi]=Ke[hi].evaluate(gt,Lt)},Ae}($)).load(Te.features):$.dynamic?this._dynamicIndex:function(Ae,Le){return new Au(Ae,Le)}(Te,$.geojsonVtOptions)}catch(Ae){return q(Ae)}const De={};if(ge){const Ae=H(oe);Ae&&(De.resourceTiming={},De.resourceTiming[$.source]=JSON.parse(JSON.stringify(Ae)))}q(null,De)}})}reloadTile($,q){const oe=this.loaded;return oe&&oe[$.uid]?$.partial?q(null,void 0):super.reloadTile($,q):this.loadTile($,q)}loadGeoJSON($,q){if($.request)F.m($.request,q);else{if(typeof $.data!="string")return q(new Error(`Input data given to '${$.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return q(null,JSON.parse($.data))}catch{return q(new Error(`Input data given to '${$.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom($,q){try{q(null,this._geoJSONIndex.getClusterExpansionZoom($.clusterId))}catch(oe){q(oe)}}getClusterChildren($,q){try{q(null,this._geoJSONIndex.getChildren($.clusterId))}catch(oe){q(oe)}}getClusterLeaves($,q){try{q(null,this._geoJSONIndex.getLeaves($.clusterId,$.limit,$.offset))}catch(oe){q(oe)}}}class wr{constructor($,q,oe){this.tileID=new F.aR($.tileID.overscaledZ,$.tileID.wrap,$.tileID.canonical.z,$.tileID.canonical.x,$.tileID.canonical.y),this.tileZoom=$.tileZoom,this.uid=$.uid,this.zoom=$.zoom,this.canonical=$.tileID.canonical,this.pixelRatio=$.pixelRatio,this.tileSize=$.tileSize,this.source=$.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=$.projection,this.brightness=q,this.worldview=oe}parse($,q,oe,ge){this.status="parsing";const be=new F.aR(oe.tileID.overscaledZ,oe.tileID.wrap,oe.tileID.canonical.z,oe.tileID.canonical.x,oe.tileID.canonical.y),Te=[],De=q.familiesBySource[oe.source],Ae=new F.ff(be,oe.promoteId);Ae.bucketLayerIDs=[],Ae.is3DTile=!0,F.fB($).then(Le=>{const rt=Le.json.extensionsUsed&&Le.json.extensionsUsed.includes("MAPBOX_mesh_features")||Le.json.asset.extras&&Le.json.asset.extras.MAPBOX_mesh_features,Ke=Le.json.extensionsUsed&&Le.json.extensionsUsed.includes("EXT_meshopt_compression"),gt=new F.ae(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Lt in De)for(const Bt of De[Lt]){const zt=Bt[0];Ae.bucketLayerIDs.push(Bt.map(_i=>F.F(_i.id,_i.scope))),zt.recalculate(gt,[]);const Kt=F.fC(Le,1/F.cS(oe.tileID.canonical)),hi=new F.fD(Bt,Kt,be,rt,Ke,this.brightness,Ae,this.worldview);rt||(hi.needsUpload=!0),Te.push(hi),hi.evaluate(zt)}this.status="done",ge(null,{buckets:Te,featureIndex:Ae,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Le=>ge(new Error(Le.message)))}}class Ei{constructor({actor:$,layerIndex:q,availableImages:oe,availableModels:ge,brightness:be,worldview:Te}){this.actor=$,this.layerIndex=q,this.availableImages=oe,this.availableModels=ge,this.brightness=be,this.loading={},this.loaded={},this.worldview=Te}loadTile($,q){const oe=$.uid,ge=this.loading[oe]=new wr($,this.brightness,this.worldview);F.b1($.request,(be,Te)=>{const De=!this.loading[oe];return delete this.loading[oe],De||be?(ge.status="done",De||(this.loaded[oe]=ge),q(be)):Te&&Te.byteLength!==0?void ge.parse(Te,this.layerIndex,$,(Ae,Le)=>{ge.status="done",this.loaded=this.loaded||{},this.loaded[oe]=ge,Ae||!Le?q(Ae):q(null,Le)}):(ge.status="done",this.loaded[oe]=ge,q())})}reloadTile($,q){const oe=this.loaded,ge=$.uid;if(oe&&oe[ge]){const be=oe[ge];be.projection=$.projection,be.brightness=$.brightness;const Te=(De,Ae)=>{be.reloadCallback&&(delete be.reloadCallback,this.loadTile($,q)),q(De,Ae)};be.status==="parsing"?be.reloadCallback=Te:be.status==="done"&&this.loadTile($,q)}}abortTile($,q){const oe=$.uid;this.loading[oe]&&delete this.loading[oe],q()}removeTile($,q){const oe=this.loaded,ge=$.uid;oe&&oe[ge]&&delete oe[ge],q()}}const _r=new Map,Zs=new Map;class Cu{constructor($){this.self=$,this.actor=new F.A($,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new F.z,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=F.c0({name:"mercator"}),this.workerSourceTypes={vector:li,geojson:vn,"raster-dem":Xt,"raster-array":An,"batched-model":Ei},this.workerSources={},this.self.registerWorkerSource=(q,oe)=>{if(this.workerSourceTypes[q])throw new Error(`Worker source with name "${q}" already registered.`);this.workerSourceTypes[q]=oe},this.self.registerRTLTextPlugin=q=>{if(F.fF.isParsed())throw new Error("RTL text plugin already registered.");F.fF.setState({pluginStatus:F.fG.parsed,pluginURL:F.fF.getPluginURL()}),F.fF.applyArabicShaping=q.applyArabicShaping,F.fF.processBidirectionalText=q.processBidirectionalText,F.fF.processStyledBidirectionalText=q.processStyledBidirectionalText;for(const oe of this.rtlPluginParsingListeners)oe(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches($,q,oe){delete this.layerIndexes[$],delete this.availableImages[$],delete this.availableModels[$],delete this.workerSources[$],oe()}checkIfReady($,q,oe){oe()}setReferrer($,q){this.referrer=q}spriteLoaded($,q){this.isSpriteLoaded[$]||(this.isSpriteLoaded[$]={});const{scope:oe,isLoaded:ge}=q;if(this.isSpriteLoaded[$][oe]=ge,this.workerSources[$]&&this.workerSources[$][oe])for(const be in this.workerSources[$][oe]){const Te=this.workerSources[$][oe][be];for(const De in Te){const Ae=Te[De];Ae instanceof li&&(Ae.isSpriteLoaded=ge,Ae.fire(new F.C("isSpriteLoaded")))}}}setImages($,q,oe){this.availableImages[$]||(this.availableImages[$]={});const{scope:ge,images:be}=q;if(this.availableImages[$][ge]=be,this.workerSources[$]&&this.workerSources[$][ge]){for(const Te in this.workerSources[$][ge]){const De=this.workerSources[$][ge][Te];for(const Ae in De)De[Ae].availableImages=be}oe()}else oe()}setModels($,{scope:q,models:oe},ge){if(this.availableModels[$]||(this.availableModels[$]={}),this.availableModels[$][q]=oe,this.workerSources[$]&&this.workerSources[$][q]){for(const be in this.workerSources[$][q]){const Te=this.workerSources[$][q][be];for(const De in Te)Te[De].availableModels=oe}ge()}else ge()}setProjection($,q){this.projections[$]=F.c0(q)}setBrightness($,q,oe){this.brightness=q,oe()}setContextParams($,q,oe){this.maxUniformBufferBindings=q.maxBindingPoints,this.maxUniformBlockSizeDwords=q.maxUniformBlockSizeDwords,this.disableSymbolUBO=q.disableSymbolUBO,oe()}setWorldview($,q,oe){this.worldview=q,oe()}setLayers($,q,oe){this.getLayerIndex($,q.scope).replace(q.layers,q.options),oe()}updateLayers($,q,oe){this.getLayerIndex($,q.scope).update(q.layers,q.removedIds,q.options),oe()}loadTile($,q,oe){q.projection=this.projections[$]||this.defaultProjection,this.getWorkerSource($,q).loadTile(q,oe)}decodeRasterArray($,q,oe){this.getWorkerSource($,q).decodeRasterArray(q,oe)}reloadTile($,q,oe){q.projection=this.projections[$]||this.defaultProjection,this.getWorkerSource($,q).reloadTile(q,oe)}abortTile($,q,oe){this.getWorkerSource($,q).abortTile(q,oe)}removeTile($,q,oe){this.getWorkerSource($,q).removeTile(q,oe)}removeSource($,q,oe){if(!(this.workerSources[$]&&this.workerSources[$][q.scope]&&this.workerSources[$][q.scope][q.type]&&this.workerSources[$][q.scope][q.type][q.source]))return;const ge=this.workerSources[$][q.scope][q.type][q.source];delete this.workerSources[$][q.scope][q.type][q.source],ge.removeSource!==void 0?ge.removeSource(q,oe):oe()}loadTileProvider($,q,oe){(async function(ge,be){const Te=Zs.get(ge);if(Te)return Te;const De=_r.get(ge);if(De!==void 0)return De;const Ae=import(be).then(Le=>{const rt=Le.default;if(typeof rt!="function")throw new Error(`TileProvider "${ge}" module must default-export a class`);if(typeof rt.prototype.loadTile!="function")throw new Error(`TileProvider "${ge}" class must have a loadTile method`);return Zs.set(ge,rt),rt}).finally(()=>{_r.delete(ge)});return _r.set(ge,Ae),Ae})(q.name,q.url).then(ge=>{const be=new ge(q.options);return this.getWorkerSource($,{type:q.type,source:q.source,scope:q.scope},be),be.load&&q.request?be.load({request:q.request}):null}).then(ge=>oe(null,ge)).catch(ge=>oe(ge instanceof Error?ge:new Error(typeof ge=="string"?ge:"Unknown error")))}loadWorkerSource($,q,oe){try{this.self.importScripts(q.url),oe()}catch(ge){oe(ge)}}syncRTLPluginState($,q,oe){if(F.fF.isParsed())oe(null,!0);else if(F.fF.isParsing())this.rtlPluginParsingListeners.push(oe);else try{F.fF.setState(q);const ge=F.fF.getPluginURL();!F.fF.isLoaded()||F.fF.isParsed()||F.fF.isParsing()||ge==null||(F.fF.setState({pluginStatus:F.fG.parsing,pluginURL:F.fF.getPluginURL()}),this.self.importScripts(ge),F.fF.isParsed()?oe(null,!0):this.rtlPluginParsingListeners.push(oe))}catch(ge){oe(ge)}}setConfig($,q){Object.assign(F.g,q)}getAvailableImages($,q){this.availableImages[$]||(this.availableImages[$]={});let oe=this.availableImages[$][q];return oe||(oe=[]),oe}getAvailableModels($,q){this.availableModels[$]||(this.availableModels[$]={});let oe=this.availableModels[$][q];return oe||(oe={}),oe}getLayerIndex($,q){this.layerIndexes[$]||(this.layerIndexes[$]={});let oe=this.layerIndexes[$][q];return oe||(oe=this.layerIndexes[$][q]=new Me,oe.scope=q),oe}getWorkerSource($,q,oe){const{type:ge,source:be,scope:Te}=q,De=this.workerSources;if(De[$]||(De[$]={}),De[$][Te]||(De[$][Te]={}),De[$][Te][ge]||(De[$][Te][ge]={}),this.isSpriteLoaded[$]||(this.isSpriteLoaded[$]={}),!De[$][Te][ge][be]){const Ae={send:(rt,Ke,gt,Lt,Bt,zt)=>this.actor.send(rt,Ke,gt,$,Bt,zt),scheduler:this.actor.scheduler},Le=this.workerSourceTypes[ge];if(!Le)throw new Error(`Unknown worker source type "${ge}".`);De[$][Te][ge][be]=new Le({actor:Ae,layerIndex:this.getLayerIndex($,Te),availableImages:this.getAvailableImages($,Te),availableModels:this.getAvailableModels($,Te),isSpriteLoaded:this.isSpriteLoaded[$][Te],tileProvider:oe,brightness:this.brightness,worldview:this.worldview,maxUniformBufferBindings:this.maxUniformBufferBindings,maxUniformBlockSizeDwords:this.maxUniformBlockSizeDwords,disableSymbolUBO:this.disableSymbolUBO})}return De[$][Te][ge][be]}rasterizeImagesWorker($,q,oe){const ge=new Map;for(const[be,{image:Te,imageVariant:De}]of q.tasks.entries()){const Ae=this.imageRasterizer.rasterize(De,Te,q.scope,$);ge.set(be,Ae)}oe(void 0,ge)}removeRasterizedImages($,q,oe){this.imageRasterizer.removeImagesFromCacheByIds(q.imageIds,q.scope,$),oe()}enforceCacheSizeLimit($,q){F.fH(q)}getWorkerPerformanceMetrics($,q,oe){oe(void 0,void 0)}}return F.fE(self)&&(self.worker=new Cu(self)),Cu}),C(["./shared"],function(a){var F="3.22.0";const H={create:"create",load:"load",fullLoad:"fullLoad"},ee={mark(u){performance.mark(u)},measure(u,i,o){performance.measure(u,i,o)}};function se(u){const i=u.name.split("?")[0];return a.a(i)&&i.includes("mapbox-gl.js")?"javascript":a.a(i)&&i.includes("mapbox-gl.css")?"css":a.b(i)?"fontRange":a.c(i)?"sprite":a.i(i)?"style":a.d(i)?"tilejson":"other"}var ue,Me={},Ve=function(){if(ue)return Me;function u(d){return!i(d)}function i(d){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var y,v,w=new Blob([""],{type:"text/javascript"}),E=URL.createObjectURL(w);try{v=new Worker(E),y=!0}catch{y=!1}return v&&v.terminate(),URL.revokeObjectURL(E),y}()?function(){var y=document.createElement("canvas");y.width=y.height=1;var v=y.getContext("2d");if(!v)return!1;var w=v.getImageData(0,0,1,1);return w&&w.width===y.width}()?(o[m=d&&d.failIfMajorPerformanceCaveat]===void 0&&(o[m]=function(y){var v,w=function(E){var P=document.createElement("canvas"),R=Object.create(u.webGLContextAttributes);return R.failIfMajorPerformanceCaveat=E,P.getContext("webgl2",R)}(y);if(!w)return!1;try{v=w.createShader(w.VERTEX_SHADER)}catch{return!1}return!(!v||w.isContextLost())&&(w.shaderSource(v,"void main() {}"),w.compileShader(v),w.getShaderParameter(v,w.COMPILE_STATUS)===!0)}(m)),o[m]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var m}ue=1,Me.supported=u,Me.notSupportedReason=i;var o={};return u.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},Me}();function ke(u,i,o){const d=document.createElement(u);return i!=null&&(d.className=i),o&&o.appendChild(d),d}function Ye(u,i,o){const d=document.createElementNS("http://www.w3.org/2000/svg",u);for(const m of Object.keys(i))d.setAttributeNS(null,m,String(i[m]));return o&&o.appendChild(d),d}const Se=typeof document<"u"?document.documentElement&&document.documentElement.style:null,ye=Se&&Se.userSelect!==void 0?"userSelect":"WebkitUserSelect";let Ie;function qe(){Se&&ye&&(Ie=Se[ye],Se[ye]="none")}function ot(){Se&&ye&&(Se[ye]=Ie)}function xt(u){u.preventDefault(),u.stopPropagation(),window.removeEventListener("click",xt,!0)}function Rt(){window.addEventListener("click",xt,!0),window.setTimeout(()=>{window.removeEventListener("click",xt,!0)},0)}function Tt(u,i){const o=u.getBoundingClientRect();return Ji(u,o,i)}function li(u,i){const o=u.getBoundingClientRect(),d=[];for(let m=0;m<i.length;m++)d.push(Ji(u,o,i[m]));return d}function Xt(u){return/firefox/i.test(navigator.userAgent)&&/macintosh/i.test(navigator.userAgent)&&u.button===2&&u.ctrlKey?0:u.button}function Ji(u,i,o){const d=u.offsetWidth===i.width?1:u.offsetWidth/i.width;return new a.P((o.clientX-i.left)*d,(o.clientY-i.top)*d)}const An="01",gi="NO_ACCESS_TOKEN";class Mr{constructor(i,o,d){this._transformRequestFn=i,this._customAccessToken=o,this._silenceAuthErrors=!!d,this._createSkuToken()}_createSkuToken(){const i=function(){let o="";for(let d=0;d<10;d++)o+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",An,o].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=i.token,this._skuTokenExpiresAt=i.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(i,o){return this._transformRequestFn&&this._transformRequestFn(i,o)||{url:i}}normalizeStyleURL(i,o){if(!a.e(i))return i;const d=ji(i);return d.params.push(`sdk=js-${F}`),d.path=`/styles/v1${d.path}`,this._makeAPIURL(d,this._customAccessToken||o)}normalizeGlyphsURL(i,o){if(!a.e(i))return i;const d=ji(i);return d.path=`/fonts/v1${d.path}`,this._makeAPIURL(d,this._customAccessToken||o)}normalizeModelURL(i,o){if(!a.e(i))return i;const d=ji(i);return d.path=`/models/v1${d.path}`,this._makeAPIURL(d,this._customAccessToken||o)}normalizeSourceURL(i,o,d,m){if(!a.e(i))return i;const y=ji(i);return y.path=`/v4/${y.authority}.json`,y.params.push("secure"),d&&y.params.push(`language=${d}`),m&&y.params.push(`worldview=${m}`),this._makeAPIURL(y,this._customAccessToken||o)}normalizeIconsetURL(i,o){const d=ji(i);return a.e(i)?(d.path=`/styles/v1${d.path}/iconset.pbf`,this._makeAPIURL(d,this._customAccessToken||o)):ti(d)}normalizeSpriteURL(i,o,d,m){const y=ji(i);return a.e(i)?(y.path=`/styles/v1${y.path}/sprite${o}${d}`,this._makeAPIURL(y,this._customAccessToken||m)):(y.path+=`${o}${d}`,ti(y))}normalizeTileURL(i,o,d){if(this._isSkuTokenExpired()&&this._createSkuToken(),i&&!a.e(i))return i;const m=ji(i);m.path=m.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${o||d&&m.authority!=="raster"&&d===512?"@2x":""}${a.k.supported?".webp":"$1"}`),m.authority==="raster"?m.path=`/${a.g.RASTER_URL_PREFIX}${m.path}`:m.authority==="rasterarrays"?m.path=`/${a.g.RASTERARRAYS_URL_PREFIX}${m.path}`:m.authority==="3dtiles"?m.path=`/${a.g.TILES3D_URL_PREFIX}${m.path}`:(m.path=m.path.replace(/^.+\/v4\//,"/"),m.path=`/${a.g.TILE_URL_VERSION}${m.path}`);const y=this._customAccessToken||function(v){for(const w of v){const E=w.match(/^access_token=(.*)$/);if(E)return E[1]}return null}(m.params)||a.g.ACCESS_TOKEN;return a.g.REQUIRE_ACCESS_TOKEN&&y&&this._skuToken&&m.params.push(`sku=${this._skuToken}`),this._makeAPIURL(m,y)}canonicalizeTileURL(i,o){const d=ji(i);if(!d.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!d.path.match(/\.[\w]+$/))return i;let m="mapbox://";d.path.match(/^\/raster\/v1\//)?m+=`raster/${d.path.replace(`/${a.g.RASTER_URL_PREFIX}/`,"")}`:d.path.match(/^\/rasterarrays\/v1\//)?m+=`rasterarrays/${d.path.replace(`/${a.g.RASTERARRAYS_URL_PREFIX}/`,"")}`:m+=`tiles/${d.path.replace(`/${a.g.TILE_URL_VERSION}/`,"")}`;let y=d.params;return o&&(y=y.filter(v=>!v.match(/^access_token=/))),y.length&&(m+=`?${y.join("&")}`),m}canonicalizeTileset(i,o){const d=!!o&&a.e(o),m=[];for(const y of i.tiles||[])a.f(y)?m.push(this.canonicalizeTileURL(y,d)):m.push(y);return m}_makeAPIURL(i,o){const d="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",m=ji(a.g.API_URL);if(i.protocol=m.protocol,i.authority=m.authority,i.protocol==="http"){const y=i.params.indexOf("secure");y>=0&&i.params.splice(y,1)}if(m.path!=="/"&&(i.path=`${m.path}${i.path}`),!a.g.REQUIRE_ACCESS_TOKEN)return ti(i);if(o=o||a.g.ACCESS_TOKEN,!this._silenceAuthErrors){if(!o)throw new Error(`An API access token is required to use Mapbox GL. ${d}`);if(o[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${d}`)}return i.params=i.params.filter(y=>y.indexOf("access_token")===-1),i.params.push(`access_token=${o||""}`),ti(i)}}const Wn=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ji(u){const i=u.match(Wn);if(!i)throw new Error("Unable to parse URL object");return{protocol:i[1],authority:i[2],path:i[3]||"/",params:i[4]?i[4].split("&"):[]}}function ti(u){const i=u.params.length?`?${u.params.join("&")}`:"";return`${u.protocol}://${u.authority}${u.path}${i}`}const Pt="mapbox.eventData";function $t(u){if(!u)return null;const i=u.split(".");if(!i||i.length!==3)return null;try{return JSON.parse(a.l(i[1]))}catch{return null}}function Wt(u){return!(!a.g.EVENTS_URL||!u&&!a.g.ACCESS_TOKEN)}class Ut{constructor(i){this.type=i,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(i){const o=$t(a.g.ACCESS_TOKEN);let d="";return d=o&&o.u?a.j(o.u):a.g.ACCESS_TOKEN||"",i?`${Pt}.${i}:${d}`:`${Pt}:${d}`}fetchEventData(){const i=a.s("localStorage"),o=this.getStorageKey(),d=this.getStorageKey("uuid"),m=this.getStorageKey("uuidTimestamp");if(i)try{const y=localStorage.getItem(o);y&&(this.eventData=JSON.parse(y));const v=localStorage.getItem(d);v&&(this.anonId=v);const w=localStorage.getItem(m);w&&(this.anonIdTimestamp=Number(w));const E=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp<E)&&this.refreshUUID()}catch{a.w("Unable to read from LocalStorage")}}refreshUUID(){this.anonId=a.u(),this.anonIdTimestamp=Date.now()}saveEventData(){const i=a.s("localStorage"),o=this.getStorageKey(),d=this.getStorageKey("uuid"),m=this.getStorageKey("uuidTimestamp"),y=this.anonId,v=this.anonIdTimestamp;if(i&&y)try{localStorage.setItem(d,y),Object.keys(this.eventData).length>=1&&localStorage.setItem(o,JSON.stringify(this.eventData)),v&&localStorage.setItem(m,v.toString())}catch{a.w("Unable to write to LocalStorage")}}processRequests(i){}postEvent(i,o,d,m){if(!a.g.EVENTS_URL)return;const y=ji(a.g.EVENTS_URL);y.params.push(`access_token=${m||a.g.ACCESS_TOKEN||""}`);const v={event:this.type,created:new Date(i).toISOString()},w=o?Object.assign(v,o):v,E={url:ti(y),headers:{"Content-Type":"text/plain"},body:JSON.stringify([w])};this.pendingRequest=a.p(E,P=>{this.pendingRequest=null,d(P),this.saveEventData(),this.processRequests(m)})}queueRequest(i,o){this.queue.push(i),this.processRequests(o)}}class ii extends Ut{constructor(i){super("metrics"),i&&(this.data=i)}postMetricsEvent(i){if(!Wt(i))return;this.anonId||this.fetchEventData(),a.v(this.anonId)||this.refreshUUID();const o=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:o},i)}processRequests(i){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:o,payload:d}=this.queue.shift();this.postEvent(o,d,()=>{},i)}}const mi=new class extends Ut{constructor(u){super("appUserTurnstile"),this._customAccessToken=u}postTurnstileEvent(u,i){Wt(i)&&Array.isArray(u)&&u.some(o=>a.e(o)||a.f(o))&&this.queueRequest(Date.now(),i)}processRequests(u){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const i=$t(a.g.ACCESS_TOKEN),o=i?i.u:a.g.ACCESS_TOKEN;let d=o!==this.eventData.tokenU;a.v(this.anonId)||(this.refreshUUID(),d=!0);const m=this.queue.shift();if(this.eventData.lastSuccess){const y=new Date(this.eventData.lastSuccess),v=new Date(m),w=(m-this.eventData.lastSuccess)/864e5;d=d||w>=1||w<-1||y.getDate()!==v.getDate()}else d=!0;d?this.postEvent(m,{sdkIdentifier:"mapbox-gl-js",sdkVersion:F,skuId:An,"enabled.telemetry":!1,userId:this.anonId},y=>{y||(this.eventData.lastSuccess=m,this.eventData.tokenU=o)},u):this.processRequests()}},rn=mi.postTurnstileEvent.bind(mi),ln=new class extends Ut{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(u,i,o,d){this.skuToken=i,this.errorCb=d,a.g.EVENTS_URL&&(o||a.g.ACCESS_TOKEN?this.queueRequest({id:u,timestamp:Date.now()},o):this.errorCb(new Error(gi)))}processRequests(u){if(this.pendingRequest||this.queue.length===0)return;const{id:i,timestamp:o}=this.queue.shift();i&&this.success[i]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),a.v(this.anonId)||this.refreshUUID(),this.postEvent(o,{sdkIdentifier:"mapbox-gl-js",sdkVersion:F,skuId:An,skuToken:this.skuToken,userId:this.anonId},d=>{d?this.errorCb(d):i&&(this.success[i]=!0)},u))}remove(){this.errorCb=null}},sn=ln.postMapLoadEvent.bind(ln),Rr=new class extends Ut{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(u){let i=this.mapInstanceIdMap.get(u);return i||(i=a.u(),this.mapInstanceIdMap.set(u,i)),i}getEventId(u){const i=this.eventIdPerMapInstanceMap.get(u)||0;return this.eventIdPerMapInstanceMap.set(u,i+1),i}postStyleLoadEvent(u,i){const{map:o,style:d,importedStyles:m}=i;if(!Wt(u))return;const y=this.getMapInstanceId(o),v={mapInstanceId:y,eventId:this.getEventId(y),style:d};m.length&&(v.importedStyles=m),this.queueRequest({timestamp:Date.now(),payload:v},u)}processRequests(u){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:i,payload:o}=this.queue.shift();this.postEvent(i,o,()=>{},u)}},lo=Rr.postStyleLoadEvent.bind(Rr),zi=new ii({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),pn=zi.postMetricsEvent.bind(zi),On=new ii({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),oa=On.postMetricsEvent.bind(On),mn=new class extends Ut{constructor(){super("gljs.performance")}postPerformanceEvent(u,i){Wt(u)&&this.queueRequest({timestamp:Date.now(),performanceData:i},u)}processRequests(u){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:i,performanceData:o}=this.queue.shift(),d=function(m){const y=performance.getEntriesByType("resource"),v=performance.getEntriesByType("mark"),w=function(N){const j={};if(N){for(const U in N)if(U!=="other")for(const X of N[U]){const W=`${U}ResolveRangeMin`,ie=`${U}ResolveRangeMax`,ne=`${U}RequestCount`,K=`${U}RequestCachedCount`;j[W]=Math.min(j[W]||1/0,X.startTime),j[ie]=Math.max(j[ie]||-1/0,X.responseEnd);const xe=le=>{j[le]===void 0&&(j[le]=0),++j[le]};X.transferSize!==void 0&&X.transferSize===0&&xe(K),xe(ne)}}return j}(function(N,j){const U={};if(N)for(const X of N){const W=j(X);U[W]===void 0&&(U[W]=[]),U[W].push(X)}return U}(y,se)),E=window.devicePixelRatio,P=navigator.connection||navigator.mozConnection||navigator.webkitConnection,R=P?P.effectiveType:void 0,O={counters:[],metadata:[],attributes:[]},k=(N,j,U)=>{U!=null&&N.push({name:j,value:U.toString()})};for(const N in w)k(O.counters,N,w[N]);if(m.interactionRange[0]!==1/0&&m.interactionRange[1]!==-1/0&&(k(O.counters,"interactionRangeMin",m.interactionRange[0]),k(O.counters,"interactionRangeMax",m.interactionRange[1])),v)for(const N of Object.values(H)){const j=v.find(U=>U.name===N);j&&k(O.counters,N,j.startTime)}return k(O.counters,"visibilityHidden",m.visibilityHidden),k(O.attributes,"style",function(N){if(N)for(const j of N){const U=j.name.split("?")[0];if(a.i(U)){const X=U.split("/").slice(-2);if(X.length===2)return`mapbox://styles/${X[0]}/${X[1]}`}}}(y)),k(O.attributes,"terrainEnabled",m.terrainEnabled?"true":"false"),k(O.attributes,"fogEnabled",m.fogEnabled?"true":"false"),k(O.attributes,"projection",m.projection),k(O.attributes,"zoom",m.zoom),k(O.metadata,"devicePixelRatio",E),k(O.metadata,"connectionEffectiveType",R),k(O.metadata,"navigatorUserAgent",navigator.userAgent),k(O.metadata,"screenWidth",window.screen.width),k(O.metadata,"screenHeight",window.screen.height),k(O.metadata,"windowWidth",window.innerWidth),k(O.metadata,"windowHeight",window.innerHeight),k(O.metadata,"mapWidth",m.width/E),k(O.metadata,"mapHeight",m.height/E),k(O.metadata,"webglRenderer",m.renderer),k(O.metadata,"webglVendor",m.vendor),k(O.metadata,"sdkVersion",F),k(O.metadata,"sdkIdentifier","mapbox-gl-js"),O}(o);for(const m of d.metadata);for(const m of d.counters);for(const m of d.attributes);this.postEvent(i,d,()=>{},u)}},Mo=mn.postPerformanceEvent.bind(mn),co=new class extends Ut{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(u,i,o,d){if(!a.g.API_URL||!a.g.SESSION_PATH)return;const m=ji(a.g.API_URL+a.g.SESSION_PATH);m.params.push(`sku=${i||""}`),m.params.push(`access_token=${d||a.g.ACCESS_TOKEN||""}`);const y={url:ti(m),headers:{"Content-Type":"text/plain"}};this.pendingRequest=a.h(y,v=>{this.pendingRequest=null,o(v),this.saveEventData(),this.processRequests(d)})}getSessionAPI(u,i,o,d){this.skuToken=i,this.errorCb=d,a.g.EVENTS_URL&&a.g.SESSION_PATH&&a.g.API_URL&&(o||a.g.ACCESS_TOKEN?this.queueRequest({id:u,timestamp:Date.now()},o):this.errorCb(new Error(gi)))}processRequests(u){if(this.pendingRequest||this.queue.length===0)return;const{id:i,timestamp:o}=this.queue.shift();i&&this.success[i]||this.getSession(o,this.skuToken,d=>{d?this.errorCb(d):i&&(this.success[i]=!0)},u)}remove(){this.errorCb=null}},cc=co.getSessionAPI.bind(co),Hs=new Set;function Ln(u,i){i?Hs.add(u):Hs.delete(u)}class id{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(i,o){this._updatedSourceCaches[i]=o,this.setDirty()}discardSourceCacheUpdate(i){delete this._updatedSourceCaches[i]}updateLayer(i){const o=i.scope;this._updatedLayers[o]=this._updatedLayers[o]||new Set,this._updatedLayers[o].add(i.id),this.setDirty()}removeLayer(i){const o=i.scope;this._removedLayers[o]=this._removedLayers[o]||{},this._updatedLayers[o]=this._updatedLayers[o]||new Set,this._removedLayers[o][i.id]=i,this._updatedLayers[o].delete(i.id),this._updatedPaintProps.delete(i.fqid),this.setDirty()}getRemovedLayer(i){return this._removedLayers[i.scope]?this._removedLayers[i.scope][i.id]:null}discardLayerRemoval(i){this._removedLayers[i.scope]&&delete this._removedLayers[i.scope][i.id]}getLayerUpdatesByScope(){const i={};for(const o in this._updatedLayers)i[o]=i[o]||{},i[o].updatedIds=Array.from(this._updatedLayers[o].values());for(const o in this._removedLayers)i[o]=i[o]||{},i[o].removedIds=Object.keys(this._removedLayers[o]);return i}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(i){this._updatedPaintProps.add(i.fqid),this.setDirty()}getUpdatedImages(i){return this._updatedImages[i]?Array.from(this._updatedImages[i].values()):[]}updateImage(i,o){this._updatedImages[o]=this._updatedImages[o]||new Set,this._updatedImages[o].add(a.I.toString(i)),this.setDirty()}resetUpdatedImages(i){this._updatedImages[i]&&this._updatedImages[i].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function La(u){const{userImage:i}=u;return!!(i&&i.render&&i.render())&&(u.data.replace(new Uint8Array(i.data.buffer)),!0)}const Zr={workerUrl:"",workerClass:null,workerParams:void 0};function nd(u){return Zr.workerClass!=null?new Zr.workerClass:new self.Worker(Zr.workerUrl,Object.assign({name:u},Zr.workerParams))}const za="mapboxgl_preloaded_worker_pool";class Ro{constructor(i){this.active={},this.name=i}acquire(i,o=Ro.workerCount){if(!this.workers)for(this.workers=[];this.workers.length<o;){const d=nd(`${this.name||""}WorkerPool: ${i}-${this.workers.length}`);this.workers.push(d)}return this.active[i]=!0,this.workers.slice()}release(i){delete this.active[i],this.workers&&this.numActive()===0&&(this.workers.forEach(o=>{o.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[za]}numActive(){return Object.keys(this.active).length}}Ro.workerCount=2;class vr{constructor(i,o,d="Worker",m=Ro.workerCount){this.workerPool=i,this.actors=[],this.currentActor=0,this.id=a.r();const y=this.workerPool.acquire(this.id,m);for(let v=0;v<y.length;v++){const w=new vr.Actor(y[v],o,this.id);w.name=`${d} ${v}`,this.actors.push(w)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(i,o,d){a.t(this.actors,(m,y)=>{m.send(i,o,y)},d=d||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(i=>{i.remove()}),this.actors=[],this.workerPool.release(this.id)}}let Es,aa;function uc(){return Es||(Es=new Ro),Es}vr.Actor=a.A;class hc extends a.E{constructor(i){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new a.x,this.dirty=!0,this.spriteFormat=i,i!=="raster"&&a.y()&&(this.imageRasterizerDispatcher=new vr((aa||(aa=new Ro("ImageRasterizer")),aa),this,"Image Rasterizer Worker",1))}addScope(i){this.loaded.set(i,!1),this.imageProviders.set(i,new Map),this.images.set(i,new Map),this.updatedImages.set(i,new Set),this.callbackDispatchedThisFrame.set(i,new Set),this.imageVersions.set(i,new Map),this.patterns.set(i,new Map),this.atlasImage.set(i,new a.q({width:1,height:1}))}removeScope(i){this.loaded.delete(i),this.imageProviders.delete(i),this.images.delete(i),this.updatedImages.delete(i),this.callbackDispatchedThisFrame.delete(i),this.imageVersions.delete(i),this.patterns.delete(i),this.atlasImage.delete(i);const o=this.atlasTexture.get(i);o&&(o.destroy(),this.atlasTexture.delete(i))}addImageProvider(i,o){this.imageProviders.has(o)||this.imageProviders.set(o,new Map),this.imageProviders.get(o).set(i.id,i)}removeImageProvider(i,o){this.imageProviders.has(o)&&this.imageProviders.get(o).delete(i)}getPendingImageProviders(){const i=[];for(const o of this.imageProviders.values())for(const d of o.values())d.hasPendingRequests()&&i.push(d);return i}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new a.z),this._imageRasterizer}isLoaded(){for(const i of this.loaded.keys())if(!this.loaded.get(i))return!1;return!0}setLoaded(i,o){if(this.loaded.get(o)!==i&&(this.loaded.set(o,i),i)){for(const{ids:d,callback:m}of this.requestors)this._notify(d,o,m);this.requestors=[]}}hasImage(i,o){return!!this.getImage(i,o)}getImage(i,o){return this.images.get(o).get(i.toString())}addImage(i,o,d){if(this._validate(i,d)){this.images.get(o).set(i.toString(),d);const m=this.imageVersions.get(o),y=m.get(i.toString())||0;m.set(i.toString(),y+1)}}_validate(i,o){let d=!0;return this._validateStretch(o.stretchX,o.data&&o.data.width)||(this.fire(new a.B(new Error(`Image "${i.name}" has invalid "stretchX" value`))),d=!1),this._validateStretch(o.stretchY,o.data&&o.data.height)||(this.fire(new a.B(new Error(`Image "${i.name}" has invalid "stretchY" value`))),d=!1),this._validateContent(o.content,o)||(this.fire(new a.B(new Error(`Image "${i.name}" has invalid "content" value`))),d=!1),d}_validateStretch(i,o){if(!i)return!0;let d=0;for(const m of i){if(m[0]<d||m[1]<m[0]||o<m[1])return!1;d=m[1]}return!0}_validateContent(i,o){return i?i.length!==4||!o.usvg&&(i[0]<0||o.data.width<i[0]||i[1]<0||o.data.height<i[1]||i[2]<0||o.data.width<i[2]||i[3]<0||o.data.height<i[3])?!1:!(i[2]<i[0]||i[3]<i[1]):!0}updateImage(i,o,d){const m=this.images.get(o).get(i.toString());d.version=m.version+1,this.images.get(o).set(i.toString(),d),this.updatedImages.get(o).add(i);const y=this.imageVersions.get(o),v=y.get(i.toString())||0;y.set(i.toString(),v+1),this.removeFromImageRasterizerCache(i,o)}clearUpdatedImages(i){this.updatedImages.get(i).clear()}removeFromImageRasterizerCache(i,o){this.spriteFormat!=="raster"&&(a.y()?this.imageRasterizerDispatcher.getActor().send("removeRasterizedImages",{imageIds:[i],scope:o}):this.imageRasterizer.removeImagesFromCacheByIds([i],o))}removeImage(i,o){const d=this.images.get(o),m=d.get(i.toString());d.delete(i.toString());const y=this.imageVersions.get(o),v=y.get(i.toString())||0;y.set(i.toString(),v+1),this.patterns.get(o).delete(i.toString()),this.removeFromImageRasterizerCache(i,o),m.userImage&&m.userImage.onRemove&&m.userImage.onRemove()}listImages(i){return Array.from(this.images.get(i).keys()).map(o=>a.I.from(o))}getImageVersions(i){const o=this.imageVersions.get(i);if(o)return o}getImages(i,o,d){const m=[],y=[],v=this.imageProviders.get(o);for(const R of i){if(!R.iconsetId){m.push(R);continue}const O=v.get(R.iconsetId);O&&(this.getImage(R,o)?y.push(R):O.addPendingRequest(R))}if(m.length===0)return void this._notify(y,o,d);let w=!0;const E=!!this.loaded.get(o),P=this.images.get(o);if(!E)for(const R of m)P.has(R.toString())||(w=!1);E||w?this._notify(m,o,d):this.requestors.push({ids:m,scope:o,callback:d})}rasterizeImages(i,o){const d=new Map,{tasks:m,scope:y}=i;for(const[v,w]of m.entries()){const E=this.getImage(w.id,y);E&&d.set(v,{image:E,imageVariant:w})}this._rasterizeImages(y,d,o)}_rasterizeImages(i,o,d){if(a.y())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:o,scope:i},d);else{const m=new Map;for(const[y,{image:v,imageVariant:w}]of o.entries())m.set(y,this.imageRasterizer.rasterize(w,v,i,0));d(void 0,m)}}getUpdatedImages(i){return this.updatedImages.get(i)||new Set}_notify(i,o,d){const m=this.images.get(o),y=new Map;for(const v of i){if(!m.get(v.toString())){if(v.iconsetId)continue;this.fire(new a.C("styleimagemissing",{id:v.name}))}const w=m.get(v.toString());if(!w){a.w(`Image "${v.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const E={data:w.usvg?null:w.data.clone(),pixelRatio:w.pixelRatio,sdf:w.sdf,usvg:w.usvg,stretchX:w.stretchX,stretchY:w.stretchY,content:w.content,hasRenderCallback:!!(w.userImage&&w.userImage.render)};w.usvg&&Object.assign(E,{width:w.icon.usvg_tree.width,height:w.icon.usvg_tree.height}),y.set(a.I.toString(v),E)}d(null,{images:y,versions:this.getImageVersions(o)})}getPixelSize(i){const{width:o,height:d}=this.atlasImage.get(i);return{width:o,height:d}}getPattern(i,o,d){const m=i.toString(),y=this.patterns.get(o),v=y.get(m),w=this.getImage(i,o);if(!w)return null;if(v){if(v.position.version===w.version)return v.position;v.position.version=w.version}else{if(w.usvg&&!w.data){const E=this.getPatternInFlightId(m,o);if(this.patternsInFlight.has(E))return null;this.patternsInFlight.add(E);const P=new a.D(i).scaleSelf(a.o.devicePixelRatio),R=new Map([[P.toString(),{image:w,imageVariant:P}]]);return this._rasterizeImages(o,R,(O,k)=>this.storePatternImage(P,o,w,d,k)),null}this.storePattern(i,o,w)}return this._updatePatternAtlas(o,d),y.get(m).position}getPatternInFlightId(i,o){return a.F(i,o)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(i,o,d,m,y){const v=i.toString(),w=y?y.get(v):void 0;w&&(d.data=w,this.storePattern(i.id,o,d),this._updatePatternAtlas(o,m),this.patternsInFlight.delete(this.getPatternInFlightId(i.id.toString(),o)))}storePattern(i,o,d){const m={w:d.data.width+2*a.G,h:d.data.height+2*a.G,x:0,y:0},y=new a.H(m,d,a.G);this.patterns.get(o).set(i.toString(),{bin:m,position:y})}destroyAtlasTextures(){for(const i of this.atlasTexture.values())i&&i.destroy();this.atlasTexture.clear()}bind(i,o){const d=i.gl;let m=this.atlasTexture.get(o);m?this.dirty&&(m.update(this.atlasImage.get(o)),this.dirty=!1):(m=new a.T(i,this.atlasImage.get(o),d.RGBA8),this.atlasTexture.set(o,m)),m.bind(d.LINEAR,d.CLAMP_TO_EDGE)}_updatePatternAtlas(i,o){const d=this.patterns.get(i),m=Array.from(d.values()).map(({bin:P})=>P),{w:y,h:v}=a.J(m),w=this.atlasImage.get(i);w.resize({width:y||1,height:v||1});const E=this.images.get(i);for(const[P,{bin:R,position:O}]of d.entries()){let k=O.padding;const N=R.x+k,j=R.y+k,U=E.get(P).data,X=U.width,W=U.height;k=k>1?k-1:k,a.q.copy(U,w,{x:0,y:0},{x:N,y:j},{width:X,height:W},o),a.q.copy(U,w,{x:0,y:W-k},{x:N,y:j-k},{width:X,height:k},o),a.q.copy(U,w,{x:0,y:0},{x:N,y:j+W},{width:X,height:k},o),a.q.copy(U,w,{x:X-k,y:0},{x:N-k,y:j},{width:k,height:W},o),a.q.copy(U,w,{x:0,y:0},{x:N+X,y:j},{width:k,height:W},o),a.q.copy(U,w,{x:X-k,y:W-k},{x:N-k,y:j-k},{width:k,height:k},o),a.q.copy(U,w,{x:0,y:W-k},{x:N+X,y:j-k},{width:k,height:k},o),a.q.copy(U,w,{x:0,y:0},{x:N+X,y:j+W},{width:k,height:k},o),a.q.copy(U,w,{x:X-k,y:0},{x:N-k,y:j+W},{width:k,height:k},o)}this.dirty=!0}beginFrame(){for(const i of this.images.keys())this.callbackDispatchedThisFrame.set(i,new Set)}dispatchRenderCallbacks(i,o){const d=this.images.get(o);for(const m of i){if(this.callbackDispatchedThisFrame.get(o).has(m.toString()))continue;this.callbackDispatchedThisFrame.get(o).add(m.toString());const y=d.get(m.toString());La(y)&&this.updateImage(m,o,y)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Nr(u){const i=u.value,o=u.valueSpec,d=u.style,m=u.styleSpec,y=u.key,v=u.arrayElementValidator||vn;if(!Array.isArray(i))return[new a.V(y,i,`array expected, ${a.M(i)} found`)];if(o.length&&i.length!==o.length)return[new a.V(y,i,`array length ${o.length} expected, length ${i.length} found`)];if(o["min-length"]&&i.length<o["min-length"])return[new a.V(y,i,`array length at least ${o["min-length"]} expected, length ${i.length} found`)];let w={type:o.value,values:o.values,minimum:o.minimum,maximum:o.maximum,function:void 0};m.$version<7&&(w.function=o.function),a.K(o.value)&&(w=o.value);let E=[];for(let P=0;P<i.length;P++)E=E.concat(v({array:i,arrayIndex:P,value:i[P],valueSpec:w,style:d,styleSpec:m,key:`${y}[${P}]`},!0));return E}function dc(u){const i=u.key,o=u.value,d=u.valueSpec;if(!a.N(o))return[new a.V(i,o,`number expected, ${a.M(o)} found`)];if(o!=o)return[new a.V(i,o,"number expected, NaN found")];if("minimum"in d){let m=d.minimum;if(Array.isArray(d.minimum)&&(m=d.minimum[u.arrayIndex]),o<m)return[new a.V(i,o,`${o} is less than the minimum value ${m}`)]}if("maximum"in d){let m=d.maximum;if(Array.isArray(d.maximum)&&(m=d.maximum[u.arrayIndex]),o>m)return[new a.V(i,o,`${o} is greater than the maximum value ${m}`)]}return[]}function fc(u){const i=u.key,o=u.value;if(!a.K(o))return[new a.V(i,o,`object expected, ${a.M(o)} found`)];const d=u.valueSpec,m=a.L(o.type);let y,v,w,E={};const P=m!=="categorical"&&o.property===void 0,R=!P,O=function(U){const X=U.stops;return Array.isArray(X)&&Array.isArray(X[0])&&a.K(X[0][0])}(o),k=wr({key:u.key,value:u.value,valueSpec:u.styleSpec.function,style:u.style,styleSpec:u.styleSpec,objectElementValidators:{stops:function(U){if(m==="identity")return[new a.V(U.key,U.value,'identity function may not have a "stops" property')];let X=[];const W=U.value;return X=X.concat(Nr({key:U.key,value:W,valueSpec:U.valueSpec,style:U.style,styleSpec:U.styleSpec,arrayElementValidator:N})),Array.isArray(W)&&W.length===0&&X.push(new a.V(U.key,W,"array must have at least one stop")),X},default:function(U){return vn({key:U.key,value:U.value,valueSpec:d,style:U.style,styleSpec:U.styleSpec})}}});return m==="identity"&&P&&k.push(new a.V(u.key,u.value,'missing required property "property"')),m==="identity"||o.stops||k.push(new a.V(u.key,u.value,'missing required property "stops"')),m==="exponential"&&d.expression&&!a.O(d)&&k.push(new a.V(u.key,u.value,"exponential functions not supported")),u.styleSpec.$version>=8&&(R&&!a.Q(d)?k.push(new a.V(u.key,u.value,"property functions not supported")):P&&!a.S(d)&&k.push(new a.V(u.key,u.value,"zoom functions not supported"))),m!=="categorical"&&!O||o.property!==void 0||k.push(new a.V(u.key,u.value,'"property" property is required')),k;function N(U){let X=[];const W=U.value,ie=U.key;if(!Array.isArray(W))return[new a.V(ie,W,`array expected, ${a.M(W)} found`)];if(W.length!==2)return[new a.V(ie,W,`array length 2 expected, length ${W.length} found`)];if(O){if(!a.K(W[0]))return[new a.V(ie,W,`object expected, ${a.M(W[0])} found`)];const ne=W[0];if(ne.zoom===void 0)return[new a.V(ie,W,"object stop key must have zoom")];if(ne.value===void 0)return[new a.V(ie,W,"object stop key must have value")];const K=a.L(ne.zoom);if(typeof K!="number")return[new a.V(ie,ne.zoom,"stop zoom values must be numbers")];if(w&&w>K)return[new a.V(ie,ne.zoom,"stop zoom values must appear in ascending order")];K!==w&&(w=K,v=void 0,E={}),X=X.concat(wr({key:`${ie}[0]`,value:W[0],valueSpec:{zoom:{}},style:U.style,styleSpec:U.styleSpec,objectElementValidators:{zoom:dc,value:j}}))}else X=X.concat(j({key:`${ie}[0]`,value:W[0],style:U.style,styleSpec:U.styleSpec},W));return a.U(a.W(W[1]))?X.concat([new a.V(`${ie}[1]`,W[1],"expressions are not allowed in function stops.")]):X.concat(vn({key:`${ie}[1]`,value:W[1],valueSpec:d,style:U.style,styleSpec:U.styleSpec}))}function j(U,X){const W=a.M(U.value),ie=a.L(U.value),ne=U.value!==null?U.value:X;if(y){if(W!==y)return[new a.V(U.key,ne,`${W} stop domain type must match previous stop domain type ${y}`)]}else y=W;if(W!=="number"&&W!=="string"&&W!=="boolean"&&typeof ie!="number"&&typeof ie!="string"&&typeof ie!="boolean")return[new a.V(U.key,ne,"stop domain value must be a number, string, or boolean")];if(W!=="number"&&m!=="categorical"){let K=`number expected, ${W} found`;return a.Q(d)&&m===void 0&&(K+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new a.V(U.key,ne,K)]}return m!=="categorical"||W!=="number"||typeof ie=="number"&&isFinite(ie)&&Math.floor(ie)===ie?m!=="categorical"&&W==="number"&&typeof ie=="number"&&typeof v=="number"&&v!==void 0&&ie<v?[new a.V(U.key,ne,"stop domain values must appear in ascending order")]:(v=ie,m==="categorical"&&ie in E?[new a.V(U.key,ne,"stop domain values must be unique")]:(E[ie]=!0,[])):[new a.V(U.key,ne,`integer expected, found ${String(ie)}`)]}}function br(u){const i=(u.expressionContext==="property"?a.Y:a.X)(a.W(u.value),u.valueSpec);if(i.result==="error")return i.value.map(d=>new a.V(`${u.key}${d.key}`,u.value,d.message));const o=i.value.expression||i.value._styleExpression.expression;if(u.expressionContext==="property"&&u.propertyKey==="text-font"&&!o.outputDefined())return[new a.V(u.key,u.value,`Invalid data expression for "${u.propertyKey}". Output values must be contained as literals within the expression.`)];if(u.expressionContext==="property"&&u.propertyType==="layout"&&!a.$(o))return[new a.V(u.key,u.value,'"feature-state" data expressions are not supported with layout properties.')];if(u.expressionContext==="filter")return Eu(o,u);if(u.expressionContext==="appearance")return Dr(o,u);if(u.expressionContext&&u.expressionContext.indexOf("cluster")===0){if(!a.Z(o,["zoom","feature-state"]))return[new a.V(u.key,u.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(u.expressionContext==="cluster-initial"&&!a._(o))return[new a.V(u.key,u.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Eu(u,i){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const m of i.valueSpec.expression.parameters)o.delete(m);if(o.size===0)return[];const d=[];return u instanceof a.a0&&o.has(u.name)?[new a.V(i.key,i.value,`["${u.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(u.eachChild(m=>{d.push(...Eu(m,i))}),d)}function Dr(u,i){const o=new Set;if(i.valueSpec&&i.valueSpec.expression)for(const m of i.valueSpec.expression.parameters)o.add(m);if(o.size===0)return[];const d=[];return u instanceof a.a0&&!o.has(u.name)?[new a.V(i.key,i.value,`["${u.name}"] is not an allowed parameter`)]:(u.eachChild(m=>{d.push(...Dr(m,i))}),d)}function Do(u){const i=u.key,o=u.value,d=u.valueSpec,m=[];return Array.isArray(d.values)?d.values.indexOf(a.L(o))===-1&&m.push(new a.V(i,o,`expected one of [${d.values.join(", ")}], ${JSON.stringify(o)} found`)):Object.keys(d.values).indexOf(a.L(o))===-1&&m.push(new a.V(i,o,`expected one of [${Object.keys(d.values).join(", ")}], ${JSON.stringify(o)} found`)),m}function ka(u){return a.a4(a.W(u.value))?br(Object.assign({},u,{expressionContext:"filter",valueSpec:u.styleSpec[`filter_${u.layerType||"fill"}`]})):Is(u)}function Is(u){const i=u.value,o=u.key;if(!Array.isArray(i))return[new a.V(o,i,`array expected, ${a.M(i)} found`)];if(i.length<1)return[new a.V(o,i,"filter array must have at least 1 element")];const d=u.styleSpec;let m=Do({key:`${o}[0]`,value:i[0],valueSpec:d.filter_operator});const y=()=>{i.length>=2&&(a.a2(i[1])||m.push(new a.V(`${o}[1]`,i[1],`string expected, ${a.M(i[1])} found`)));for(let v=2;v<i.length;v++)a.L(i[1])==="$type"?m=m.concat(Do({key:`${o}[${v}]`,value:i[v],valueSpec:d.geometry_type})):a.a2(i[v])||a.N(i[v])||a.a1(i[v])||m.push(new a.V(`${o}[${v}]`,i[v],`string, number, or boolean expected, ${a.M(i[v])} found.`))};switch(a.L(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&a.L(i[1])==="$type"&&m.push(new a.V(o,i,`"$type" cannot be use with operator "${i[0]}"`)),i.length!==3&&m.push(new a.V(o,i,`filter array for operator "${i[0]}" must have 3 elements`)),y();break;case"==":case"!=":i.length!==3&&m.push(new a.V(o,i,`filter array for operator "${i[0]}" must have 3 elements`)),y();break;case"in":case"!in":y();break;case"any":case"all":case"none":for(let v=1;v<i.length;v++)m=m.concat(Is({key:`${o}[${v}]`,value:i[v],style:u.style,styleSpec:u.styleSpec}));break;case"has":case"!has":i.length!==2?m.push(new a.V(o,i,`filter array for "${i[0]}" operator must have 2 elements`)):a.a2(i[1])||m.push(new a.V(`${o}[1]`,i[1],`string expected, ${a.M(i[1])} found`))}return m}function Lo(u,i){const o=u.key,d=u.style,m=u.layer,y=u.styleSpec,v=u.value,w=u.objectKey,E=y[`${i}_${u.layerType}`];if(!E)return[];const P=w.match(/^(.*)-use-theme$/);if(P&&E[P[1]])return a.U(a.W(v))?[].concat(vn({key:o,value:v,valueSpec:{type:"string",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},style:d,styleSpec:y,expressionContext:"property",propertyType:i,propertyKey:w})):vn({key:o,value:v,valueSpec:{type:"string"},style:d,styleSpec:y});const R=w.match(/^(.*)-transition$/);if(i==="paint"&&R&&E[R[1]]&&E[R[1]].transition)return vn({key:o,value:v,valueSpec:y.transition,style:d,styleSpec:y});const O=u.valueSpec||E[w];if(!O)return[new a.a5(o,v,`unknown property "${w}"`)];let k;if(a.a2(v)&&a.Q(O)&&!O.tokens&&(k=/^{([^}]+)}$/.exec(v))){const j=`\`{ "type": "identity", "property": ${k?JSON.stringify(k[1]):'"_"'} }\``;return[new a.V(o,v,`"${w}" does not support interpolation syntax
Use an identity property function instead: ${j}.`)]}const N=[];if(u.layerType==="symbol")w!=="text-field"||!d||d.glyphs||d.imports||N.push(new a.V(o,v,'use of "text-field" requires a style "glyphs" property')),w==="text-font"&&a.a6(a.W(v))&&a.L(v.type)==="identity"&&N.push(new a.V(o,v,'"text-font" does not support identity functions'));else if(u.layerType==="model"&&i==="paint"&&m&&m.layout&&m.layout.hasOwnProperty("model-id")&&a.Q(O)&&(a.a7(O)||a.S(O))){const j=a.Y(a.W(v),O).value,U="expression"in j&&j.expression||"_styleExpression"in j&&j._styleExpression&&j._styleExpression.expression;U&&!a.Z(U,["measure-light"])&&(w==="model-emissive-strength"&&a._(U)&&a.$(U)||N.push(new a.V(o,v,`${w} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return N.concat(vn({key:u.key,value:v,valueSpec:O,style:d,styleSpec:y,expressionContext:"property",propertyType:i,propertyKey:w}))}function fl(u){return Lo(u,"paint")}function pl(u){return Lo(u,"layout")}function ml(u){let i=[];const o=u.value,d=u.key,m=u.style,y=u.styleSpec;if(!a.K(o))return[new a.V(d,o,"object expected")];o.type||o.ref||i.push(new a.V(d,o,'either "type" or "ref" is required'));let v=a.L(o.type);const w=a.L(o.ref);if(o.id){const E=a.L(o.id);for(let P=0;P<u.arrayIndex;P++){const R=m.layers[P];a.L(R.id)===E&&i.push(new a.V(d,o.id,`duplicate layer id "${E}", previously used at line ${R.id.__line__}`))}}if("ref"in o){let E;["type","source","source-layer","filter","layout"].forEach(P=>{P in o&&i.push(new a.V(d,o[P],`"${P}" is prohibited for ref layers`))}),m.layers.forEach(P=>{a.L(P.id)===w&&(E=P)}),E?E.ref?i.push(new a.V(d,o.ref,"ref cannot reference another ref layer")):v=a.L(E.type):typeof w=="string"&&i.push(new a.V(d,o.ref,`ref layer "${w}" not found`))}else if(v!=="background"&&v!=="sky"&&v!=="slot")if(o.source)if(a.a2(o.source)){const E=m.sources&&m.sources[o.source],P=E&&a.L(E.type);E?P==="vector"&&v==="raster"?i.push(new a.V(d,o.source,`layer "${o.id}" requires a raster source`)):P==="raster"&&v!=="raster"?i.push(new a.V(d,o.source,`layer "${o.id}" requires a vector source`)):P!=="vector"||o["source-layer"]?P==="raster-dem"&&v!=="hillshade"?i.push(new a.V(d,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):P!=="raster-array"||["raster","raster-particle"].includes(v)?v==="line"&&o.paint&&(o.paint["line-gradient"]||o.paint["line-trim-offset"])&&P==="geojson"&&!E.lineMetrics?i.push(new a.V(d,o,`layer "${o.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):v==="raster-particle"&&P!=="raster-array"&&i.push(new a.V(d,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):i.push(new a.V(d,o.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new a.V(d,o,`layer "${o.id}" must specify a "source-layer"`)):i.push(new a.V(d,o.source,`source "${o.source}" not found`))}else i.push(new a.V(`${d}.source`,o.source,'"source" must be a string'));else i.push(new a.V(d,o,'missing required property "source"'));return i=i.concat(wr({key:d,value:o,valueSpec:y.layer,style:u.style,styleSpec:u.styleSpec,objectElementValidators:{"*":()=>[],type:()=>vn({key:`${d}.type`,value:o.type,valueSpec:y.layer.type,style:u.style,styleSpec:u.styleSpec,object:o,objectKey:"type"}),filter:E=>ka(Object.assign({layerType:v},E)),layout:E=>wr({layer:o,key:E.key,value:E.value,valueSpec:{},style:E.style,styleSpec:E.styleSpec,objectElementValidators:{"*":P=>pl(Object.assign({layerType:v},P))}}),paint:E=>wr({layer:o,key:E.key,value:E.value,valueSpec:{},style:E.style,styleSpec:E.styleSpec,objectElementValidators:{"*":P=>fl(Object.assign({layerType:v,layer:o},P))}}),appearances(E){const P=Nr({key:E.key,value:E.value,valueSpec:E.valueSpec,style:E.style,styleSpec:E.styleSpec,arrayElementValidator:k=>function(N){const{key:j,layer:U,layerType:X}=N,W=a.L(N.value),ie=a.L(W.name),ne=a.L(W.condition),K=wr({key:j,value:W,valueSpec:N.styleSpec.appearance,style:N.style,styleSpec:N.styleSpec,objectElementValidators:{condition:xe=>function(le){const _e=[];return _e.push(...br({key:le.key,value:le.object.condition,valueSpec:a.a8.appearance.condition,expressionContext:"appearance"})),_e}(Object.assign({layer:U,layerType:X},xe)),properties:xe=>function(le){const _e=[],{styleSpec:re,layer:ae,layerType:fe}=le,Ce=re[`paint_${fe}`],ve=re[`layout_${fe}`],Ne=le.object[le.objectKey];for(const ze in Ne){const Je=ze in Ce?"paint":ze in ve?"layout":void 0;if(!Je){_e.push(new a.V(le.key,ze,`unknown property "${ze}" for layer type "${fe}"`));continue}const tt=Object.assign({},le,{key:`${le.key}.${ze}`,object:Ne,objectKey:ze,layer:ae,layerType:fe,value:Ne[ze],valueSpec:Je==="paint"?Ce[ze]:ve[ze]});_e.push(...Lo(tt,Je))}return _e}(Object.assign({layer:U,layerType:X},xe))}});return ie!=="hidden"&&ne===void 0&&K.push(new a.V(N.key,"name",'Appearance with name different than "hidden" must have a condition')),K}(Object.assign({layerType:v,layer:o},k))}),R=Array.isArray(E.value)?E.value:[],O=new Set;return R.forEach((k,N)=>{const j=a.L(k.name);if(j)if(O.has(j)){const U=a.L(o.id);P.push(new a.V(E.key,j,`Duplicated appearance name "${j}" for layer "${U}"`))}else O.add(j)}),P}}})),i}function uo({key:u,value:i}){return a.a2(i)?[]:[new a.V(u,i,`string expected, ${a.M(i)} found`)]}const _l={promoteId:function u({key:i,value:o}){if(a.a2(o))return uo({key:i,value:o});if(Array.isArray(o)){const m=[],y=a.W(o),v=a.X(y);return v.result==="error"?(v.value.forEach(w=>{m.push(new a.V(`${i}${w.key}`,null,`${w.message}`))}),m):(a.Z(v.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||m.push(new a.V(`${i}`,null,"promoteId expression should be only feature dependent")),m)}if(!a.K(o))return[new a.V(i,o,`string, expression or object expected, "${a.M(o)}" found`)];const d=[];for(const m in o)d.push(...u({key:`${i}.${m}`,value:o[m]}));return d}};function Iu(u){const i=u.value,o=u.key,d=u.styleSpec,m=u.style;if(!a.K(i))return[new a.V(o,i,`object expected, ${a.M(i)} found`)];if(!("type"in i))return[new a.V(o,i,'"type" is required')];const y=a.L(i.type);let v=[];switch(["vector","raster","raster-dem","raster-array"].includes(y)&&("url"in i||"tiles"in i||v.push(new a.a5(o,i,'Either "url" or "tiles" is required.'))),y){case"vector":case"raster":case"raster-dem":case"raster-array":return v=v.concat(wr({key:o,value:i,valueSpec:d[`source_${y.replace("-","_")}`],style:u.style,styleSpec:d,objectElementValidators:_l})),v;case"geojson":if(v=wr({key:o,value:i,valueSpec:d.source_geojson,style:m,styleSpec:d,objectElementValidators:_l}),"cluster"in i&&"clusterProperties"in i){if(!a.K(i.clusterProperties))return[new a.V(`${o}.clusterProperties`,i,`object expected, ${a.M(i)} found`)];for(const w in i.clusterProperties){const E=i.clusterProperties[w];if(!Array.isArray(E))return[new a.V(`${o}.clusterProperties.${w}`,E,"array expected")];const[P,R]=E,O=typeof P=="string"?[P,["accumulated"],["get",w]]:P;v.push(...br({key:`${o}.${w}.map`,value:R,expressionContext:"cluster-map"})),v.push(...br({key:`${o}.${w}.reduce`,value:O,expressionContext:"cluster-reduce"}))}}return v;case"video":return wr({key:o,value:i,valueSpec:d.source_video,style:m,styleSpec:d});case"image":return wr({key:o,value:i,valueSpec:d.source_image,style:m,styleSpec:d});case"canvas":return[new a.V(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Do({key:`${o}.type`,value:i.type,valueSpec:{values:Ap(d)}})}}function Ap(u){return u.source.reduce((i,o)=>{const d=u[o];return d.type.type==="enum"&&(i=i.concat(Object.keys(d.type.values||{}))),i},[])}function Fa(u){const i=u.value,o=u.styleSpec,d=o.light,m=u.style;if(i===void 0)return[];if(!a.K(i))return[new a.V("light",i,`object expected, ${a.M(i)} found`)];let y=[];for(const v in i){const w=v.match(/^(.*)-transition$/),E=v.match(/^(.*)-use-theme$/);y=y.concat(E&&d[E[1]]?vn({key:v,value:i[v],valueSpec:{type:"string"},style:m,styleSpec:o}):w&&d[w[1]]&&d[w[1]].transition?vn({key:v,value:i[v],valueSpec:o.transition,style:m,styleSpec:o}):d[v]?vn({key:v,value:i[v],valueSpec:d[v],style:m,styleSpec:o}):[new a.V(v,i[v],`unknown property "${v}"`)])}return y}function rd(u){const i=u.value;if(!i)return[];const o=u.key;if(!a.K(i))return[new a.V(o,i,`object expected, ${a.M(i)} found`)];let d=[];const m=u.styleSpec,y=m["light-3d"],v=u.style,w=u.style.lights;for(const R of["type","id"])if(!(R in i))return d=d.concat([new a.V(o,i,`missing property "${R}"`)]),d;if(!a.a2(i.type))return d=d.concat([new a.V(`${o}.type`,i.type,"string expected")]),d;if(w)for(let R=0;R<u.arrayIndex;R++){const O=a.L(i.type),k=w[R];a.L(k.type)===O&&d.push(new a.V(o,i.id,`duplicate light type "${i.type}", previously defined at line ${k.id.__line__}`))}const E=`properties_light_${i.type}`;if(!(E in m))return d=d.concat([new a.V(`${o}.type`,i,`Invalid light type ${i.type}`)]),d;const P=m[E];for(const R in i)if(R==="properties"){const O=i[R];if(!a.K(O))return d=d.concat([new a.V("properties",O,`object expected, ${a.M(O)} found`)]),d;for(const k in O){const N=k.match(/^(.*)-transition$/),j=k.match(/^(.*)-use-theme$/);d=d.concat(j&&P[j[1]]?vn({key:R,value:O[k],valueSpec:{type:"string"},style:v,styleSpec:m}):N&&P[N[1]]&&P[N[1]].transition?vn({key:R,value:i[R],valueSpec:m.transition,style:v,styleSpec:m}):P[k]?vn({key:k,value:O[k],valueSpec:P[k],style:v,styleSpec:m}):[new a.a5(u.key,O[k],`unknown property "${k}"`)])}}else d=d.concat(y[R]?vn({key:R,value:i[R],valueSpec:y[R],style:v,styleSpec:m}):[new a.a5(R,i[R],`unknown property "${R}"`)]);return d}function Au(u){const i=u.value,o=u.key,d=u.style,m=u.styleSpec,y=m.terrain;if(i==null)return[];if(!a.K(i))return[new a.V("terrain",i,`object expected, ${a.M(i)} found`)];let v=[];for(const w in i){const E=w.match(/^(.*)-transition$/),P=w.match(/^(.*)-use-theme$/);v=v.concat(P&&y[P[1]]?vn({key:w,value:i[w],valueSpec:{type:"string"},style:d,styleSpec:m}):E&&y[E[1]]&&y[E[1]].transition?vn({key:w,value:i[w],valueSpec:m.transition,style:d,styleSpec:m}):y[w]?vn({key:w,value:i[w],valueSpec:y[w],style:d,styleSpec:m}):[new a.a5(w,i[w],`unknown property "${w}"`)])}if(i.source)if(a.a2(i.source)){const w=d.sources&&d.sources[i.source],E=w&&a.L(w.type);w?E!=="raster-dem"&&v.push(new a.V(`${o}.source`,i.source,`terrain cannot be used with a source of type ${E}, it only be used with a "raster-dem" source type`)):v.push(new a.V(`${o}.source`,i.source,`source "${i.source}" not found`))}else v.push(new a.V(`${o}.source`,i.source,"source must be a string"));else v.push(new a.V(o,i,'terrain is missing required property "source"'));return v}function it(u){const i=u.value,o=u.style,d=u.styleSpec,m=d.fog;if(i===void 0)return[];if(!a.K(i))return[new a.V("fog",i,`object expected, ${a.M(i)} found`)];let y=[];for(const v in i){const w=v.match(/^(.*)-transition$/),E=v.match(/^(.*)-use-theme$/);y=y.concat(E&&m[E[1]]?vn({key:v,value:i[v],valueSpec:{type:"string"},style:o,styleSpec:d}):w&&m[w[1]]&&m[w[1]].transition?vn({key:v,value:i[v],valueSpec:d.transition,style:o,styleSpec:d}):m[v]?vn({key:v,value:i[v],valueSpec:m[v],style:o,styleSpec:d}):[new a.a5(v,i[v],`unknown property "${v}"`)])}return y}const zo={"*":()=>[],array:Nr,boolean:function(u){const i=u.value,o=u.key;return a.a1(i)?[]:[new a.V(o,i,`boolean expected, ${a.M(i)} found`)]},number:dc,color:function({key:u,value:i}){return a.a2(i)?a.a3.parseCSSColor(i)===null?[new a.V(u,i,`color expected, "${i}" found`)]:[]:[new a.V(u,i,`color expected, ${a.M(i)} found`)]},enum:Do,filter:ka,function:fc,layer:ml,object:wr,source:Iu,model:a.a9,light:Fa,"light-3d":rd,terrain:Au,fog:it,string:uo,formatted:function(u){return uo(u).length===0?[]:br(u)},resolvedImage:function(u){return uo(u).length===0?[]:br(u)},projection:function(u){const i=u.value,o=u.styleSpec,d=o.projection,m=u.style;if(a.K(i)){let y=[];for(const v in i)y=y.concat(vn({key:v,value:i[v],valueSpec:d[v],style:m,styleSpec:o}));return y}return a.a2(i)?[]:[new a.V("projection",i,`object or string expected, ${a.M(i)} found`)]},import:function(u){const i=u.key,{value:o,styleSpec:d}=u;if(!a.K(o))return[new a.V(i,o,"import must be an object")];const{data:m,...y}=o;Object.defineProperty(y,"__line__",{value:o.__line__,enumerable:!1});let v=wr(Object.assign({},u,{value:y,valueSpec:d.import}));return a.L(y.id)===""&&v.push(new a.V(`${u.key}.id`,y,"import id can't be an empty string")),m&&(v=v.concat(_r(m,d,{key:`${u.key}.data`}))),v},iconset:function(u){const i=u.value,o=u.key,d=u.styleSpec,m=u.style;if(!a.K(i))return[new a.V(o,i,"object expected")];if(!i.type)return[new a.V(o,i,'"type" is required')];const y=a.L(i.type);let v=[];if(v=v.concat(wr({key:o,value:i,valueSpec:d[`iconset_${y}`],style:m,styleSpec:d})),function(w,E){return!(w!=="source"||!E.source)}(y,i)){const w=m.sources&&m.sources[i.source],E=w&&a.L(w.type);w?E!=="raster-array"&&v.push(new a.V(o,i.source,`iconset cannot be used with a source of type ${String(E)}, it only be used with a "raster-array" source type`)):v.push(new a.V(o,i.source,`source "${i.source}" not found`))}return v}};function vn(u,i=!1){const o=u.value,d=u.valueSpec,m=u.styleSpec;if(d.expression){if(a.a6(a.L(o)))return fc(u);if(a.U(a.W(o)))return br(u)}if(d.type&&zo[d.type]){const y=zo[d.type](u);return i===!0&&y.length>0&&Array.isArray(u.value)?br(u):y}return wr(Object.assign({},u,{valueSpec:d.type?m[d.type]:d}))}function wr(u){const i=u.key,o=u.value,d=u.valueSpec||{},m=u.objectElementValidators||{},y=u.style,v=u.styleSpec;if(!a.K(o))return[new a.V(i,o,`object expected, ${a.M(o)} found`)];let w=[];for(const E in o){const P=E.split(".")[0];let R;m[P]?R=m[P]:d[P]?R=vn:m["*"]?R=m["*"]:d["*"]&&(R=vn),R?w=w.concat(R({key:(i&&`${i}.`)+E,value:o[E],valueSpec:d[P]||d["*"],style:y,styleSpec:v,object:o,objectKey:E},o)):w.push(new a.a5(i,o[E],`unknown property "${E}"`))}for(const E in d){if(m[E])continue;const P=d[E];P.required&&P.default===void 0&&o[E]===void 0&&w.push(new a.V(i,o,`missing required property "${E}"`))}return w}function Ei({key:u,value:i}){const o=uo({key:u,value:i});if(o.length)return o;const d=i;return d.indexOf("{fontstack}")===-1&&o.push(new a.V(u,i,'"glyphs" url must include a "{fontstack}" token')),d.indexOf("{range}")===-1&&o.push(new a.V(u,i,'"glyphs" url must include a "{range}" token')),o}function _r(u,i=a.a8,o={}){return wr({key:o.key||"",value:u,valueSpec:Object.assign(i.$root,{"*":{type:"*"}}),styleSpec:i,style:u,objectElementValidators:{glyphs:Ei}})}function Zs(u,i=a.a8){return Ke(_r(u,i))}const Cu=u=>Ke(Iu(u)),Re=u=>Ke(Fa(u)),$=u=>Ke(rd(u)),q=u=>Ke(Au(u)),oe=u=>Ke(it(u)),ge=u=>Ke(function(i){const o=i.value,d=i.style,m=i.styleSpec,y=m.snow;if(o===void 0)return[];if(!a.K(o))return[new a.V("snow",o,`object expected, ${a.M(o)} found`)];let v=[];for(const w in o){const E=w.match(/^(.*)-transition$/);v=v.concat(E&&y[E[1]]&&y[E[1]].transition?vn({key:w,value:o[w],valueSpec:m.transition,style:d,styleSpec:m}):y[w]?vn({key:w,value:o[w],valueSpec:y[w],style:d,styleSpec:m}):[new a.a5(w,o[w],`unknown property "${w}"`)])}return v}(u)),be=u=>Ke(function(i){const o=i.value,d=i.style,m=i.styleSpec,y=m.rain;if(o===void 0)return[];if(!a.K(o))return[new a.V("rain",o,`object expected, ${a.M(o)} found`)];let v=[];for(const w in o){const E=w.match(/^(.*)-transition$/);v=v.concat(E&&y[E[1]]&&y[E[1]].transition?vn({key:w,value:o[w],valueSpec:m.transition,style:d,styleSpec:m}):y[w]?vn({key:w,value:o[w],valueSpec:y[w],style:d,styleSpec:m}):[new a.a5(w,o[w],`unknown property "${w}"`)])}return v}(u)),Te=u=>Ke(ml(u)),De=u=>Ke(ka(u)),Ae=u=>Ke(fl(u)),Le=u=>Ke(pl(u)),rt=u=>Ke(a.a9(u));function Ke(u){return u.slice().sort((i,o)=>i.line&&o.line?i.line-o.line:0)}function gt(u,i){let o=!1;if(i&&i.length)for(const d of i)d instanceof a.a5?a.w(d.message):(u.fire(new a.B(new Error(d.message))),o=!0);return o}const Lt=a.a8.light;let Bt;class zt extends a.E{constructor(i,o="flat"){super(),this._transitionable=new a.aa(Bt||(Bt=new a.ab({anchor:new a.ac(Lt.anchor),position:new a.ad(Lt.position),color:new a.ac(Lt.color),intensity:new a.ac(Lt.intensity)}))),this.setLight(i,o),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(i,o,d={}){this._validate(Re,i,d)||(this._transitionable.setTransitionOrValue(i),this.id=o)}updateTransitions(i){this._transitioning=this._transitionable.transitioned(i,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(i){this.properties=this._transitioning.possiblyEvaluate(i)}_validate(i,o,d){return(!d||d.validate!==!1)&&gt(this,i.call(Zs,Object.assign({value:o,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}}const Kt=a.a8.terrain;let hi=class extends a.E{constructor(u,i,o,d,m){super(),this.scope=o,this._transitionable=new a.aa(new a.ab({source:new a.ac(Kt.source),exaggeration:new a.ac(Kt.exaggeration)}),o,d),this._transitionable.setTransitionOrValue(u,d),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i,this.worldview=m}get(){return this._transitionable.serialize()}set(u,i){this._transitionable.setTransitionOrValue(u,i)}updateTransitions(u){this._transitioning=this._transitionable.transitioned(u,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(u){this.properties=this._transitioning.possiblyEvaluate(u)}getExaggeration(u){return this._transitioning.possiblyEvaluate(new a.ae(u,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const u=this._transitionable._values.exaggeration;if(!u)return null;const i=u.value.expression;if(!i)return null;let o=-1,d=-1,m=1;for(const y of i.zoomStops)m=i.evaluate(new a.ae(y,{worldview:this.worldview})),m>.01?(o=y,d=-1):d=y;return m<.01&&o>0&&d>o?[o,d]:null}isZoomDependent(){const u=this._transitionable._values.exaggeration;return u!=null&&u.value!=null&&u.value.expression!=null&&u.value.expression instanceof a.af}};const _i=.05;function Wi(u,i,o,d){const m=a.aj(45,65,o),[y,v]=zn(u,d);let w=1-Math.min(1,Math.exp((i-y)/(v-y)*-6));return w*=w*w,w=Math.min(1,1.00747*w),w*m*u.alpha}function zn(u,i){const o=.5/Math.tan(.5*i);return[u.range[0]+o,u.range[1]+o]}function Cn(u,i,o,d,m){const y=a.ah([],[i,o,d],m.mercatorFogMatrix);return Wi(u,a.ai(y),m.pitch,m._fov)}function bn(u,i,o,d,m,y,v){const w=[[o,d,0],[m,d,0],[m,y,0],[o,y,0]];let E=Number.MAX_VALUE,P=-Number.MAX_VALUE;for(const R of w){const O=a.ah([],R,i),k=a.ai(O);E=Math.min(E,k),P=Math.max(P,k)}return[Wi(u,E,v.pitch,v._fov),Wi(u,P,v.pitch,v._fov)]}const Ni=a.a8.fog;class cn extends a.E{constructor(i,o,d,m){super();const y=new a.ab({range:new a.ac(Ni.range),color:new a.ac(Ni.color),"color-use-theme":new a.ac({type:"string","property-type":"data-constant",default:"default"}),"high-color":new a.ac(Ni["high-color"]),"high-color-use-theme":new a.ac({type:"string","property-type":"data-constant",default:"default"}),"space-color":new a.ac(Ni["space-color"]),"space-color-use-theme":new a.ac({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new a.ac(Ni["horizon-blend"]),"star-intensity":new a.ac(Ni["star-intensity"]),"vertical-range":new a.ac(Ni["vertical-range"])});this._transitionable=new a.aa(y,d,new Map(m)),this.set(i,m),this._transitioning=this._transitionable.untransitioned(),this._transform=o,this.properties=new a.ak(y),this.scope=d}get state(){const i=this._transform,o=i.projection.name==="globe",d=a.al(i.zoom),m=this.properties.get("range"),y=[.5,3];return{range:o?[a.am(y[0],m[0],d),a.am(y[1],m[1],d)]:m,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(i,o,d={}){if(this._validate(oe,i,d))return;const m=Object.assign({},i);for(const y of Object.keys(Ni))m[y]===void 0&&(m[y]=Ni[y].default);this._options=m,this._transitionable.setTransitionOrValue(this._options,o)}getOpacity(i){if(!this._transform.projection.supportsFog)return 0;const o=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:a.aj(45,65,i))*o.a}getOpacityAtLatLng(i,o){return this._transform.projection.supportsFog?function(d,m,y){const v=a.ag.fromLngLat(m),w=y.elevation?y.elevation.getAtPointOrZero(v):0;return Cn(d,v.x,v.y,w,y)}(this.state,i,o):0}getOpacityForTile(i){if(!this._transform.projection.supportsFog)return[1,1];const o=this._transform.calculateFogTileMatrix(i.toUnwrapped());return bn(this.state,o,0,0,a.an,a.an,this._transform)}getOpacityForBounds(i,o,d,m,y){return this._transform.projection.supportsFog?bn(this.state,i,o,d,m,y,this._transform):[1,1]}getFovAdjustedRange(i){return this._transform.projection.supportsFog?zn(this.state,i):[0,1]}isVisibleOnFrustum(i){if(!this._transform.projection.supportsFog)return!1;const o=[4,5,6,7];for(const d of o){const m=i.points[d];let y;if(m[2]>=0)y=m;else{const v=i.points[d-4];y=a.ao(v,m,v[2]/(v[2]-m[2]))}if(Cn(this.state,y[0],y[1],0,this._transform)>=_i)return!0}return!1}updateConfig(i){this._transitionable.setTransitionOrValue(this._options,new Map(i))}updateTransitions(i){this._transitioning=this._transitionable.transitioned(i,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(i){this.properties=this._transitioning.possiblyEvaluate(i)}_validate(i,o,d){return(!d||d.validate!==!1)&&gt(this,i.call(Zs,Object.assign({value:o,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}}let jn,Xi,un,wn=class extends a.E{constructor(u,i,o,d){super();const m=jn||(jn=new a.ab({density:new a.ac(a.a8.snow.density),intensity:new a.ac(a.a8.snow.intensity),color:new a.ac(a.a8.snow.color),opacity:new a.ac(a.a8.snow.opacity),vignette:new a.ac(a.a8.snow.vignette),"vignette-color":new a.ac(a.a8.snow["vignette-color"]),"center-thinning":new a.ac(a.a8.snow["center-thinning"]),direction:new a.ac(a.a8.snow.direction),"flake-size":new a.ac(a.a8.snow["flake-size"])}));this._transitionable=new a.aa(m,o,new Map(d)),this.set(u,d),this._transitioning=this._transitionable.untransitioned(),this.properties=new a.ak(m),this.scope=o}get state(){const u=this.properties.get("opacity"),i=this.properties.get("color"),o=this.properties.get("direction"),d=a.ap(o[0]),m=-Math.max(a.ap(o[1]),.01),y=[Math.cos(d)*Math.cos(m),Math.sin(d)*Math.cos(m),Math.sin(m)],v=this.properties.get("vignette"),w=this.properties.get("vignette-color");return w.a=v,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new a.aq(i.r,i.g,i.b,i.a*u),direction:y,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:w}}get(){return this._transitionable.serialize()}set(u,i,o={}){if(this._validate(ge,u,o))return;const d=Object.assign({},u),m=a.a8.snow;for(const y of Object.keys(m))d[y]===void 0&&(d[y]=m[y].default);this._options=d,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(u){this._transitionable.setTransitionOrValue(this._options,new Map(u))}updateTransitions(u){this._transitioning=this._transitionable.transitioned(u,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(u){this.properties=this._transitioning.possiblyEvaluate(u)}_validate(u,i,o){return(!o||o.validate!==!1)&&gt(this,u.call(Zs,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}},yi=class extends a.E{constructor(u,i,o,d){super();const m=Xi||(Xi=new a.ab({density:new a.ac(a.a8.rain.density),intensity:new a.ac(a.a8.rain.intensity),color:new a.ac(a.a8.rain.color),opacity:new a.ac(a.a8.rain.opacity),vignette:new a.ac(a.a8.rain.vignette),"vignette-color":new a.ac(a.a8.rain["vignette-color"]),"center-thinning":new a.ac(a.a8.rain["center-thinning"]),direction:new a.ac(a.a8.rain.direction),"droplet-size":new a.ac(a.a8.rain["droplet-size"]),"distortion-strength":new a.ac(a.a8.rain["distortion-strength"])}));this._transitionable=new a.aa(m,o,new Map(d)),this.set(u,d),this._transitioning=this._transitionable.untransitioned(),this.properties=new a.ak(m),this.scope=o}get state(){const u=this.properties.get("opacity"),i=this.properties.get("color"),o=this.properties.get("direction"),d=a.ap(o[0]),m=-Math.max(a.ap(o[1]),.01),y=[Math.cos(d)*Math.cos(m),Math.sin(d)*Math.cos(m),Math.sin(m)],v=this.properties.get("vignette-color");return v.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new a.aq(i.r,i.g,i.b,i.a*u),direction:y,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:v}}get(){return this._transitionable.serialize()}set(u,i,o={}){if(this._validate(be,u,o))return;const d=Object.assign({},u),m=a.a8.rain;for(const y of Object.keys(m))d[y]===void 0&&(d[y]=m[y].default);this._options=d,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(u){this._transitionable.setTransitionOrValue(this._options,new Map(u))}updateTransitions(u){this._transitioning=this._transitionable.transitioned(u,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(u){this.properties=this._transitioning.possiblyEvaluate(u)}_validate(u,i,o){return(!o||o.validate!==!1)&&gt(this,u.call(Zs,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:a.a8})))}};class Xn extends a.E{constructor(i,o,d,m){super(),this.scope=d,this._options=i,this.properties=new a.ak(o),this._transitionable=new a.aa(o,d,new Map(m)),this._transitionable.setTransitionOrValue(i.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(i){this._transitionable.setTransitionOrValue(this._options.properties,new Map(i))}updateTransitions(i){this._transitioning=this._transitionable.transitioned(i,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(i){this.properties=this._transitioning.possiblyEvaluate(i)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(i,o){this._options=i,this._transitionable.setTransitionOrValue(i.properties,o)}shadowsEnabled(){return!!this.properties&&this.properties.get("cast-shadows")===!0}}const Tr=()=>un||(un=new a.ab({color:new a.ac(a.a8.properties_light_ambient.color),"color-use-theme":new a.ac({type:"string",default:"default","property-type":"data-constant"}),intensity:new a.ac(a.a8.properties_light_ambient.intensity)}));let gr;const us=()=>gr||(gr=new a.ab({direction:new a.ar(a.a8.properties_light_directional.direction),color:new a.ac(a.a8.properties_light_directional.color),"color-use-theme":new a.ac({type:"string",default:"default","property-type":"data-constant"}),intensity:new a.ac(a.a8.properties_light_directional.intensity),"cast-shadows":new a.ac(a.a8.properties_light_directional["cast-shadows"]),"shadow-quality":new a.ac(a.a8.properties_light_directional["shadow-quality"]),"shadow-intensity":new a.ac(a.a8.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new a.ac(a.a8.properties_light_directional["shadow-draw-before-layer"])}));class hs{constructor(i,o,d){this.screenBounds=i,this.cameraPoint=d.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=o,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,d)}static createFromScreenPoints(i,o){let d,m;if(i instanceof a.P||typeof i[0]=="number"){const y=a.P.convert(i);d=[y],m=o.isPointAboveHorizon(y)}else{const y=a.P.convert(i[0]),v=a.P.convert(i[1]),w=y.add(v)._div(2);d=[y,v],m=a.as(y,v).every(E=>o.isPointAboveHorizon(E))&&o.isPointAboveHorizon(w)}return new hs(d,m,o)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(i){return a.as(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],i)}bufferedCameraGeometry(i){const o=this.screenBounds[0],d=this.screenBounds.length===1?this.screenBounds[0].add(new a.P(1,1)):this.screenBounds[1],m=a.as(o,d,0,!1);return this.cameraPoint.y>d.y&&(this.cameraPoint.x>o.x&&this.cameraPoint.x<d.x?m.splice(3,0,this.cameraPoint):this.cameraPoint.x>=d.x?m[2]=this.cameraPoint:this.cameraPoint.x<=o.x&&(m[3]=this.cameraPoint)),a.at(m,i)}bufferedCameraGeometryGlobe(i){const o=this.screenBounds[0],d=this.screenBounds.length===1?this.screenBounds[0].add(new a.P(1,1)):this.screenBounds[1],m=a.as(o,d,i),y=this.cameraPoint.clone(),v=+(y.x>o.x)+ +(y.x>d.x);switch(3*(+(y.y>o.y)+ +(y.y>d.y))+v){case 0:m[0]=y,m[4]=y.clone();break;case 1:m.splice(1,0,y);break;case 2:m[1]=y;break;case 3:m.splice(4,0,y);break;case 5:m.splice(2,0,y);break;case 6:m[3]=y;break;case 7:m.splice(3,0,y);break;case 8:m[2]=y}return m}containsTile(i,o,d,m=0){const y=Math.max(i.queryPadding,i.evaluateQueryRenderedFeaturePadding())/o._pixelsPerMercatorPixel+1,v=d?this._bufferedCameraMercator(y,o):this._bufferedScreenMercator(y,o);let w=i.tileID.wrap+(v.unwrapped?m:0);const E=v.polygon.map(X=>a.au(i.tileTransform,X,w));if(!a.av(E,0,0,a.an,a.an))return;w=i.tileID.wrap+(this.screenGeometryMercator.unwrapped?m:0);const P=this.screenGeometryMercator.polygon.map(X=>a.aw(i.tileTransform,X,w)),R=P.map(X=>new a.P(X[0],X[1])),O=o.getFreeCameraOptions().position||new a.ag(0,0,0),k=a.aw(i.tileTransform,O,w),N=P.map(X=>{const W=a.ax(X,X,k);return a.ay(W,W),new a.az(k,W)}),j=a.aA(i,1,o.zoom)*o._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:R,tilespaceRays:N,bufferedTilespaceGeometry:E,bufferedTilespaceBounds:(U=a.aB(E),U.min.x=a.aC(U.min.x,0,a.an),U.min.y=a.aC(U.min.y,0,a.an),U.max.x=a.aC(U.max.x,0,a.an),U.max.y=a.aC(U.max.y,0,a.an),U),tile:i,tileID:i.tileID,pixelToTileUnitsFactor:j};var U}_bufferedScreenMercator(i,o){const d=ds(i);if(this._screenRaycastCache[d])return this._screenRaycastCache[d];{let m;return m=o.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(i),o):{polygon:this.bufferedScreenGeometry(i).map(y=>o.pointCoordinate3D(y)),unwrapped:!0},this._screenRaycastCache[d]=m,m}}_bufferedCameraMercator(i,o){const d=ds(i);if(this._cameraRaycastCache[d])return this._cameraRaycastCache[d];{let m;return m=o.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(i),o):{polygon:this.bufferedCameraGeometry(i).map(y=>o.pointCoordinate3D(y)),unwrapped:!0},this._cameraRaycastCache[d]=m,m}}_projectAndResample(i,o){const d=function(y,v){const w=a.aD([],v.pixelMatrix,v.globeMatrix),E=[0,-a.aF,0,1],P=[0,a.aF,0,1],R=[0,0,0,1];a.aE(E,E,w),a.aE(P,P,w),a.aE(R,R,w);const O=new a.P(E[0]/E[3],E[1]/E[3]),k=new a.P(P[0]/P[3],P[1]/P[3]),N=a.aG(y,O)&&E[3]<R[3],j=a.aG(y,k)&&P[3]<R[3];if(!N&&!j)return null;const U=function(_e,re,ae){for(let fe=1;fe<_e.length;fe++){const Ce=qr(re.pointCoordinate3D(_e[fe-1]).x),ve=qr(re.pointCoordinate3D(_e[fe]).x);if(ae<0){if(Ce<ve)return{idx:fe,t:-Ce/(ve-1-Ce)}}else if(ve<Ce)return{idx:fe,t:(1-Ce)/(ve+1-Ce)}}return null}(y,v,N?-1:1);if(!U)return null;const{idx:X,t:W}=U;let ie=X>1?ko(y.slice(0,X),v):[],ne=X<y.length?ko(y.slice(X),v):[];ie=ie.map(_e=>new a.P(qr(_e.x),_e.y)),ne=ne.map(_e=>new a.P(qr(_e.x),_e.y));const K=[...ie];K.length===0&&K.push(ne[ne.length-1]);const xe=a.am(K[K.length-1].y,(ne.length===0?ie[0]:ne[0]).y,W);let le;return le=N?[new a.P(0,xe),new a.P(0,0),new a.P(1,0),new a.P(1,xe)]:[new a.P(1,xe),new a.P(1,1),new a.P(0,1),new a.P(0,xe)],K.push(...le),ne.length===0?K.push(ie[0]):K.push(...ne),{polygon:K.map(_e=>new a.ag(_e.x,_e.y)),unwrapped:!1}}(i,o);if(d)return d;const m=function(y,v){let w=!1,E=-1/0,P=0;for(let O=0;O<y.length-1;O++)y[O].x>E&&(E=y[O].x,P=O);for(let O=0;O<y.length-1;O++){const k=(P+O)%(y.length-1),N=y[k],j=y[k+1];Math.abs(N.x-j.x)>.5&&(N.x<j.x?(N.x+=1,k===0&&(y[y.length-1].x+=1)):(j.x+=1,k+1===y.length-1&&(y[0].x+=1)),w=!0)}const R=a.aH(v.center.lng);return w&&R<Math.abs(R-1)&&y.forEach(O=>{O.x-=1}),{polygon:y,unwrapped:w}}(ko(i,o).map(y=>new a.P(qr(y.x),y.y)),o);return{polygon:m.polygon.map(y=>new a.ag(y.x,y.y)),unwrapped:m.unwrapped}}}function ko(u,i){return a.aI(u,o=>{const d=i.pointCoordinate3D(o);o.x=d.x,o.y=d.y},1/256)}function qr(u){return u<0?1+u%1:u%1}function ds(u){return 100*u|0}function Fo(u,i,o){try{i=function(m){if(!m.variants)return m;if(!Array.isArray(m.variants))throw new Error("variants must be an array");for(const y of m.variants){if(y==null||typeof y!="object"||y.constructor!==Object)throw new Error("variant must be an object");if(!Array.isArray(y.capabilities))throw new Error("capabilities must be an array");if(y.capabilities.length===1&&y.capabilities[0]==="meshopt")return Object.assign(m,y)}return m}(i)}catch(m){return new Error("Failed to process TileJSON variants",{cause:m})}const d=a.aJ(Object.assign({},i,u),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);return u.url&&i.tiles&&u.tiles&&(d.tiles=i.tiles),d.tiles=o.canonicalizeTileset(d,u.url),d}function As(u,i,o,d,m){const y=function(w,E){if(w)return m(w);if(E){u.url&&E.tiles&&u.tiles&&delete u.tiles;const P=Fo(u,E,i);if(P instanceof Error)return m(P);m(null,P)}},v=function(w,E,P){if(!w)return null;if(!E&&!P)return w;P=P||w.worldview_default;const R=Object.values(w.language||{});if(R.length===0)return null;const O=Object.values(w.worldview||{});if(O.length===0)return null;const k=R.every(j=>j===E),N=O.every(j=>j===P);return k&&N?w:E in(w.language_options||{})||P in(w.worldview_options||{})?null:w.language_options&&w.worldview_options?w:null}(u.data,o,d);return v?a.o.frame(()=>y(null,v)):u.url?a.m(i.transformRequest(i.normalizeSourceURL(u.url,null,o,d),a.R.Source),y):a.o.frame(()=>{const{data:w,...E}=u;y(null,E)})}function Oo(u,i){const o=Math.pow(2,i.z),d=Math.floor(a.aH(u.getWest())*o),m=Math.floor(a.aL(u.getNorth())*o),y=Math.ceil(a.aH(u.getEast())*o),v=Math.ceil(a.aL(u.getSouth())*o);return i.x>=d&&i.x<y&&i.y>=m&&i.y<v}class qs{constructor(i,o,d){this.bounds=i?a.aK.convert(this.validateBounds(i)):null,this.minzoom=o||0,this.maxzoom=d||24}validateBounds(i){return Array.isArray(i)&&i.length===4?[Math.max(-180,i[0]),Math.max(-90,i[1]),Math.min(180,i[2]),Math.min(90,i[3])]:[-180,-90,180,90]}addExtraBounds(i){if(i){this.extraBounds||(this.extraBounds=[]);for(const o of i)this.extraBounds.push(a.aK.convert(this.validateBounds(o)))}}contains(i){if(i.z>this.maxzoom||i.z<this.minzoom||this.bounds&&!Oo(this.bounds,i))return!1;if(!this.extraBounds)return!0;for(const o of this.extraBounds)if(Oo(o,i))return!0;return!1}static fromTileJSON(i){if(!i.bounds&&!i.extra_bounds)return null;const o=new qs(i.bounds,i.minzoom,i.maxzoom);return o.addExtraBounds(i.extra_bounds),o}}class ts extends a.E{constructor(i,o,d,m){if(super(),this.id=i,this.dispatcher=d,this.type="vector",this.provider=o.provider,this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,Object.assign(this,a.aJ(o,["url","scheme","tileSize","promoteId"])),this._options=Object.assign({type:"vector"},o),this._collectResourceTiming=!!o.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(m),this._tileWorkers={},this._deduped=new a.aN}load(i){this._loaded=!1,this.fire(new a.C("dataloading",{dataType:"source"}));const o=Array.isArray(this.map._language)?this.map._language.join():this.map._language,d=this.map.getWorldview(),m=(v,w)=>{this._tileJSONRequest=null,this._loaded=!0,v?(o&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${o}`),d&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${d}`),this.fire(new a.B(v))):w&&(this._setTileJSON(w),rn(w.tiles,this.map._requestManager._customAccessToken),this.fire(new a.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))),i&&i(v)};this.provider=this._options.provider;const y=function(v){if("provider"in v&&!v.provider)return null;let w=v.provider;if(!w&&"url"in v&&v.url&&(w=a.aM(v.url)),!w)return null;const E=a.g.TILE_PROVIDER_URLS[w];if(!E)return null;let P;try{P=new URL(E,a.g.API_URL).href}catch{return a.w(`TileProvider "${w}" has an invalid URL: "${E}"`),null}return{name:w,url:P}}(this._options);if(this.provider&&!y)return this._loaded=!0,this.fire(new a.B(new Error(`TileProvider "${this.provider}" is not registered`))),void(i&&i());this._tileJSONRequest=y?this._loadWithProvider(y,m):As(this._options,this.map._requestManager,o,d,m)}_loadWithProvider(i,o){this.provider=i.name;const d=new AbortController,m=this._options.url&&!this._options.tiles?this.map._requestManager.transformRequest(this._options.url,a.R.Source):void 0,y=m?Object.assign({},this._options,{url:m.url}):this._options;return this.dispatcher.broadcast("loadTileProvider",{name:i.name,url:i.url,source:this.id,scope:this.scope,type:this.type,options:y,request:m},(v,w)=>{if(d.signal.aborted)return;if(v)return void o(v);const E=w?w.find(P=>P!=null):null;if(E){const P=Fo(this._options,E,this.map._requestManager);P instanceof Error?o(P):o(null,P)}else o(null,{tiles:this._options.tiles})}),{cancel:()=>{d.abort()}}}_setTileJSON(i){if(Object.assign(this,i),this.hasWorldviews=!!i.worldview_options,i.worldview_default&&(this.worldviewDefault=i.worldview_default),i.vector_layers){this.vectorLayers=i.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const o of i.vector_layers)this.vectorLayerIds.push(o.id),i.worldview&&i.worldview[o.source]&&this.localizableLayerIds.add(o.id)}this.tileBounds=qs.fromTileJSON(i)}loaded(){return this._loaded}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}onAdd(i){this.map=i,this.load()}reload(){this.cancelTileJSONRequest();const i=a.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(i))}setTiles(i){return this._options.tiles=i,this.reload(),this}setUrl(i){return this.url=i,this._options.url=i,this.reload(),this}onRemove(i){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(i,o){const d=i.tileID.canonical.url(this.tiles,this.scheme),m=this.map._requestManager.normalizeTileURL(d),y=this.map._requestManager.transformRequest(m,a.R.Tile),v=this.map.style?this.map.style.getLut(this.scope):null,w=v?{image:v.image.clone()}:null,E={request:y,data:void 0,uid:i.uid,tileID:i.tileID,tileZoom:i.tileZoom,zoom:i.tileID.overscaledZ,maxZoom:this.maxzoom,lut:w,tileSize:this.tileSize*i.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:a.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,renderSourceType:i.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:i.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&a.e(d)&&(E.localizableLayerIds=this.localizableLayerIds),E.request.collectResourceTiming=this._collectResourceTiming,i.actor&&i.state!=="expired")i.state==="loading"?i.reloadCallback=o:i.request=i.actor.send("reloadTile",E,P.bind(this));else if(i.actor=this._tileWorkers[m]=this._tileWorkers[m]||this.dispatcher.getActor(),this.dispatcher.ready||this.provider)i.request=i.actor.send("loadTile",E,P.bind(this),void 0,!0);else{const R=a.aO.call({deduped:this._deduped},E,(O,k)=>{if(O||!k)P.call(this,O);else{const N=a.aP(k.responseHeaders);E.data={rawData:k.rawData.slice(0),expires:N.expires,cacheControl:N.cacheControl},i.actor&&i.actor.send("loadTile",E,P.bind(this),void 0,!0)}},!0);i.request={cancel:R}}function P(R,O){return delete i.request,i.aborted?o(null):R?o(R):(O&&O.resourceTiming&&(i.resourceTiming=O.resourceTiming),this.map._refreshExpiredTiles&&O&&i.setExpiryData(O),i.loadVectorData(O,this.map.painter),a.aQ(this.dispatcher),o(null,O),void(i.reloadCallback&&(this.loadTile(i,i.reloadCallback),i.reloadCallback=null)))}}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(i,o){i.actor&&i.actor.send("removeTile",{uid:i.uid,type:this.type,source:this.id,scope:this.scope}),i.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Pu extends a.E{constructor(i,o,d,m){super(),this.id=i,this.dispatcher=d,this.setEventedParent(m),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},o),Object.assign(this,a.aJ(o,["url","scheme","tileSize"]))}load(i){this._loaded=!1,this.fire(new a.C("dataloading",{dataType:"source"}));const o=this.map.getWorldview();this._tileJSONRequest=As(this._options,this.map._requestManager,null,o,(d,m)=>{this._tileJSONRequest=null,this._loaded=!0,d?this.fire(new a.B(d)):m&&(Object.assign(this,m),m.raster_layers&&(this.rasterLayers=m.raster_layers,this.rasterLayerIds=this.rasterLayers.map(y=>y.id)),this.tileBounds=qs.fromTileJSON(m),rn(m.tiles),this.fire(new a.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))),i&&i(d)})}loaded(){return this._loaded}onAdd(i){this.map=i,this.load()}reload(){this.cancelTileJSONRequest();const i=a.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(i))}setTiles(i){return this._options.tiles=i,this.reload(),this}setUrl(i){return this.url=i,this._options.url=i,this.reload(),this}onRemove(i){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(i){return!this.tileBounds||this.tileBounds.contains(i.canonical)}loadTile(i,o){const d=a.o.devicePixelRatio>=2,m=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme),d,this.tileSize);i.request=a.n(this.map._requestManager.transformRequest(m,a.R.Tile),(y,v,w)=>{if(delete i.request,i.aborted)return i.state="unloaded",o(null);if(y)return i.state="errored",o(y);if(!v)return o(null);const E=a.aP(w);this.map._refreshExpiredTiles&&i.setExpiryData(E),i.setTexture(v,this.map.painter),i.state="loaded",a.aQ(this.dispatcher),o(null)})}abortTile(i,o){i.request&&(i.request.cancel(),delete i.request),o&&o()}unloadTile(i,o){i.texture&&i.texture instanceof a.T?(i.destroy(!1),i.texture&&i.texture instanceof a.T&&this.map.painter.saveTileTexture(i.texture)):i.destroy(),o&&o()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Cp([u,i],o,d,{scaled:m=!0}={}){const{tileSize:y,buffer:v}=d,{x:w,y:E,z:P}=o;if(!isFinite(w)||!isFinite(E)||!isFinite(P))throw new Error("Invalid MRT header");const R=2**P,O=R*a.aH(u),k=R*a.aL(i);return function([N,j],U,{scaled:X=!0}={}){if(!U)throw new Error("bandView is undefined");const{data:W,tileSize:ie,buffer:ne,offset:K,scale:xe,dimension:le}=U;if(N<-ne||N>ie+ne||j<-ne||j>ie+ne)throw new Error(`Point (${N}, ${j}) out of bounds for tileSize=${ie}, buffer=${ne}`);const _e=(j+ne)*(ie+2*ne)+(N+ne);if(new Uint32Array(W.buffer)[_e]===4294967295)return null;let re=[];re=X?[]:new U.data.constructor(le);for(let ae=0;ae<le;ae++)re[ae]=Math.round(1e12*(W[le*_e+ae]*xe+K))/1e12;return re}([Math.min(Math.max(-v,Math.floor((O-w)*y)),y-1+v),Math.min(Math.max(-v,Math.floor((k-E)*y)),y-1+v)],d,{scaled:m})}class gl extends Pu{constructor(i,o,d,m){super(i,o,d,m),this.type="raster-array",this.maxzoom=22,this.partial=!0,this._loadTilePending={},this._loadTileLoaded={},this._options=Object.assign({type:"raster-array"},o)}triggerRepaint(i){const o=this.map.painter._terrain,d=this.map.style.getSourceCache(this.id);o&&o.enabled&&d&&o._clearRenderCacheForTile(d.id,i.tileID),this.map.triggerRepaint()}loadTile(i,o){const d=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),m=this.map._requestManager.transformRequest(d,a.R.Tile),y={request:m,uid:i.uid,tileID:i.tileID,type:this.type,source:this.id,scope:this.scope,partial:this.partial};i.source=this.id,i.scope=this.scope,i.requestParams=m,i.actor||(i.actor=this.dispatcher.getActor());const v=(w,E,P)=>{if(delete i.request,i.aborted)return i.state="unloaded",o(null);if(w)return w.name==="AbortError"?void 0:(i.state="errored",o(w));if(this.map._refreshExpiredTiles&&E){const R=a.aP(P);i.setExpiryData(R)}if(this.partial&&i.state!=="expired")i.state="empty";else if(!this.partial){if(!E)return o(null);i.state="loaded",i._isHeaderLoaded=!0,i._mrt=E}o(null)};i.request=this.partial?i.fetchHeader(void 0,v.bind(this)):i.actor.send("loadTile",y,v.bind(this),void 0,!0)}abortTile(i){i.request&&(i.request.cancel(),delete i.request),i.actor&&i.actor.send("abortTile",{uid:i.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(i,o){const d=i.texturePerLayer;if(i.flushAllQueues(),d.size){i.destroy(!1);for(const m of d.values())this.map.painter.saveTileTexture(m)}else i.destroy()}prepareTile(i,o,d,m){i._isHeaderLoaded&&(i.state!=="empty"&&(i.state="reloading"),i.fetchBandForRender(o,d,m,(y,v)=>{y?(i.state="errored",this.fire(new a.B(y))):v&&(i._isHeaderLoaded=!0,i.setTexturePerLayer(d,v,this.map.painter),i.state="loaded"),this.triggerRepaint(i)}))}getInitialBand(i){if(!this.rasterLayers)return 0;const o=this.rasterLayers.find(({id:y})=>y===i),d=o&&o.fields,m=d&&d.bands&&d.bands;return m?m[0]:0}getTextureDescriptor(i,o,d){if(!i)return;const m=o.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!m)return;let y=null;o instanceof a.aS?y=o.paint.get("raster-array-band"):o instanceof a.aT&&(y=o.paint.get("raster-particle-array-band"));const v=y||this.getInitialBand(m);if(v==null)return;if(!i.textureDescriptorPerLayer.get(o.id))return void this.prepareTile(i,m,o.id,v);if(i.updateNeeded(o.id,v)&&!d)return;const w=i.textureDescriptorPerLayer.get(o.id);return Object.assign({},w,{texture:i.texturePerLayer.get(o.id)})}getImages(i,o){const d=new Map;for(const m of i)for(const y of o){const[v,w]=y.split("/"),E=m.getLayer(v);if(!E||!E.hasBand(w)||!E.hasDataForBand(w))continue;const{bytes:P,tileSize:R,buffer:O}=E.getBandView(w),k=R+2*O,N={data:new a.q({width:k,height:k},P),pixelRatio:2,sdf:!1,usvg:!1,version:0};d.set(y,N)}return d}queryRasterArrayValueByBandId(i,o,d){const m=o._mrt;return new Promise(y=>{const v={},w=new Set;for(const[E,P]of Object.entries(m.layers)){if(d.layerName&&E!==d.layerName)continue;const R={};v[E]=R;for(const{bands:O}of P.dataIndex)for(const k of O)d.bands&&!d.bands.includes(k)||(w.add(a.F(E,k)),o.fetchBand(E,null,k,N=>{a.o.frame(()=>{R[k]=N?null:Cp([i.lng,i.lat],m,P.getBandView(k)),w.delete(a.F(E,k)),w.size===0&&y(v)})},!1))}w.size===0&&y(v)})}_loadTileForQuery(i,o){if(this._loadTileLoaded[i.uid])return void o(null,i._mrt);if(this._loadTilePending[i.uid])return void this._loadTilePending[i.uid].push(o);this._loadTilePending[i.uid]=[o];const d=this.map._requestManager.normalizeTileURL(i.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),m=this.map._requestManager.transformRequest(d,a.R.Tile);i.actor.send("loadTile",{request:m,uid:i.uid,tileID:i.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(y,v,w)=>{if(y)return this._loadTilePending[i.uid].forEach(E=>E(y,null)),void delete this._loadTilePending[i.uid];if(!v)return this._loadTilePending[i.uid].forEach(E=>E(null,null)),void delete this._loadTilePending[i.uid];if(this.map._refreshExpiredTiles&&v){const E=a.aP(w);i.setExpiryData(E)}i._mrt=v,i._isHeaderLoaded=!0,i.state="loaded",this._loadTilePending[i.uid].forEach(E=>E(null,v)),this._loadTileLoaded[i.uid]=!0,delete this._loadTilePending[i.uid]},void 0,!0)}queryRasterArrayValueByAllBands(i,o,d){return new Promise((m,y)=>{this._loadTileForQuery(o,(v,w)=>{v?y(v):m(w?this.queryRasterArrayValueByBandId(i,o,d):null)})})}queryRasterArrayValue(i,o){const d=a.aU.convert(i),m=this.findLoadedParent(d);return m&&m._mrt?o.bands||!this.partial?this.queryRasterArrayValueByBandId(d,m,o):this.queryRasterArrayValueByAllBands(d,m,o):Promise.resolve(null)}findLoadedParent(i){const o=a.ag.fromLngLat(i,this.map.transform.tileSize),d=this.maxzoom+1,m=1<<d,y=Math.floor(o.x),v=Math.floor((o.x-y)*m),w=Math.floor(o.y*m),E=this.map.style.getSourceCache(this.id),P=new a.aR(d,y,d,v,w);return E.findLoadedParent(P,this.minzoom)}}const sd={vector:ts,raster:Pu,"raster-dem":class extends Pu{constructor(u,i,o,d){super(u,i,o,d),this.type="raster-dem",this.maxzoom=22,this._options=Object.assign({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(u,i){const o=this.map._requestManager.normalizeTileURL(u.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),d=this.map._requestManager.transformRequest(o,a.R.Tile),m={uid:u.uid,tileID:u.tileID,source:this.id,type:this.type,scope:this.scope,request:d,encoding:this.encoding};u.actor&&u.state!=="expired"||(u.actor=this.dispatcher.getActor(),u.request=u.actor.send("loadTile",m,(function(y,v){return delete u.request,u.aborted?(u.state="unloaded",i(null)):y?(u.state="errored",i(y)):(v&&(this.map._refreshExpiredTiles&&u.setExpiryData(v),v.borderReady||u.neighboringTiles||(u.neighboringTiles=this._getNeighboringTiles(u.tileID)),u.dem=v.dem,u.dem.onDeserialize(),u.needsHillshadePrepare=!0,u.needsDEMTextureUpload=!0,u.state="loaded"),void i(null))}).bind(this),void 0,!0))}abortTile(u,i){u.request&&(u.request.cancel(),delete u.request),u.actor&&u.actor.send("abortTile",{uid:u.uid,type:this.type,source:this.id,scope:this.scope}),i&&i()}_getNeighboringTiles(u){const i=u.canonical,o=Math.pow(2,i.z),d=(i.x-1+o)%o,m=i.x===0?u.wrap-1:u.wrap,y=(i.x+1+o)%o,v=i.x+1===o?u.wrap+1:u.wrap,w={};return w[new a.aR(u.overscaledZ,m,i.z,d,i.y).key]={backfilled:!1},w[new a.aR(u.overscaledZ,v,i.z,y,i.y).key]={backfilled:!1},i.y>0&&(w[new a.aR(u.overscaledZ,m,i.z,d,i.y-1).key]={backfilled:!1},w[new a.aR(u.overscaledZ,u.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},w[new a.aR(u.overscaledZ,v,i.z,y,i.y-1).key]={backfilled:!1}),i.y+1<o&&(w[new a.aR(u.overscaledZ,m,i.z,d,i.y+1).key]={backfilled:!1},w[new a.aR(u.overscaledZ,u.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},w[new a.aR(u.overscaledZ,v,i.z,y,i.y+1).key]={backfilled:!1}),w}},"raster-array":gl,geojson:class extends a.E{constructor(u,i,o,d){super(),this.id=u,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=o.getActor(),this.setEventedParent(d),this._data=i.data,this._options=Object.assign({},i),this._collectResourceTiming=i.collectResourceTiming,i.maxzoom!==void 0&&(this.maxzoom=i.maxzoom),i.minzoom!==void 0&&(this.minzoom=i.minzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const m=a.an/this.tileSize;this.workerOptions=Object.assign({source:this.id,scope:this.scope,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(i.buffer!==void 0?i.buffer:128)*m,tolerance:(i.tolerance!==void 0?i.tolerance:.375)*m,extent:a.an,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:i.clusterMaxZoom!==void 0?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:a.an,radius:(i.clusterRadius!==void 0?i.clusterRadius:50)*m,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter,dynamic:i.dynamic},i.workerOptions)}onAdd(u){this.map=u,this.setData(this._data)}setData(u){return this._data=u,this._updateWorkerData(),this}updateData(u){if(!this._options.dynamic)return this.fire(new a.B(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if(typeof u!="string"&&(u.type==="Feature"&&(u={type:"FeatureCollection",features:[u]}),u.type!=="FeatureCollection"))return this.fire(new a.B(new Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&typeof u!="string"&&typeof this._data!="string"&&this._data.type==="FeatureCollection"){const i=new Map;for(const o of this._data.features)i.set(o.id,o);for(const o of u.features)i.set(o.id,o);this._data.features=[...i.values()]}else this._data=u;return this._updateWorkerData(!0),this}getClusterExpansionZoom(u,i){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:u,source:this.id,scope:this.scope},i),this}getClusterChildren(u,i){return this.actor.send("geojson.getClusterChildren",{clusterId:u,source:this.id,scope:this.scope},i),this}getClusterLeaves(u,i,o,d){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:u,limit:i,offset:o},d),this}_updateWorkerData(u=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new a.C("dataloading",{dataType:"source"})),this._loaded=!1;const i=Object.assign({append:u},this.workerOptions);i.scope=this.scope;const o=this._data;typeof o=="string"?(i.request=this.map._requestManager.transformRequest(a.o.resolveURL(o),a.R.Source),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(o),this._pendingLoad=this.actor.send(`${this.type}.loadData`,i,(d,m)=>{if(this._loaded=!0,this._pendingLoad=null,d)this.fire(new a.B(d));else{const y={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&m&&m.resourceTiming&&m.resourceTiming[this.id]&&(y.resourceTiming=m.resourceTiming[this.id]),u&&(this._partialReload=!0),this.fire(new a.C("data",y)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(u),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const u=a.F(this.id,this.scope);this.map.style.clearSource(u),this._updateWorkerData()}loadTile(u,i){const o=u.actor?"reloadTile":"loadTile";u.actor=this.actor;const d=this.map.style?this.map.style.getLut(this.scope):null,m=d?{image:d.image.clone()}:null,y=this._partialReload,v={type:this.type,uid:u.uid,tileID:u.tileID,tileZoom:u.tileZoom,zoom:u.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:m,scope:this.scope,pixelRatio:a.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:u.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:y,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};u.request=this.actor.send(o,v,(w,E)=>y&&!E?(u.state="loaded",i(null)):(delete u.request,u.destroy(!1),u.aborted?i(null):w?i(w):(u.loadVectorData(E,this.map.painter,o==="reloadTile"),i(null))),void 0,o==="loadTile")}abortTile(u){u.request&&(u.request.cancel(),delete u.request),u.aborted=!0}unloadTile(u,i){this.actor.send("removeTile",{uid:u.uid,type:this.type,source:this.id,scope:this.scope}),u.destroy()}onRemove(u){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends a.aV{constructor(u,i,o,d){super(u,i,o,d),this.roundZoom=!0,this.type="video",this.options=i}load(){this._loaded=!1;const u=this.options;this.urls=[];for(const i of u.urls)this.urls.push(this.map._requestManager.transformRequest(i,a.R.Source).url);a.aW(this.urls,(i,o)=>{this._loaded=!0,i?this.fire(new a.B(i)):o&&(this.video=o,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(u){if(this.video){const i=this.video.seekable;u<i.start(0)||u>i.end(0)?this.fire(new a.B(new a.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=u}}getVideo(){return this.video}onAdd(u){this.map||(this.map=u,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const u=this.map.painter.context,i=u.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new a.T(u,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(u)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:a.aV,model:a.aY,"batched-model":class extends a.E{constructor(u,i,o,d){super(),this.type="batched-model",this.id=u,this.tileSize=512,this._options=i,this.tiles=this._options.tiles,this.maxzoom=i.maxzoom||19,this.minzoom=i.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=o,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(d)}onAdd(u){this.map=u,this.load()}reload(){this.cancelTileJSONRequest();const u=a.F(this.id,this.scope);this.load(()=>this.map.style.clearSource(u))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(u){this._loaded=!1,this.fire(new a.C("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview();this._tileJSONRequest=As(this._options,this.map._requestManager,i,o,(d,m)=>{this._tileJSONRequest=null,this._loaded=!0,d?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&o.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new a.B(d))):m&&(Object.assign(this,m),m.bounds&&(this.tileBounds=new qs(m.bounds,this.minzoom,this.maxzoom)),rn(m.tiles,this.map._requestManager._customAccessToken),this.fire(new a.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))),u&&u(d)})}hasTransition(){return!1}hasTile(u){return!this.tileBounds||this.tileBounds.contains(u.canonical)}loaded(){return this._loaded}loadTile(u,i){const o=this.map._requestManager.normalizeTileURL(u.tileID.canonical.url(this.tiles,this.scheme)),d={request:this.map._requestManager.transformRequest(o,a.R.Tile),data:void 0,uid:u.uid,tileID:u.tileID,tileZoom:u.tileZoom,zoom:u.tileID.overscaledZ,tileSize:this.tileSize*u.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,renderSourceType:u.renderSourceType,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:a.o.devicePixelRatio,promoteId:this.promoteId};if(u.actor&&u.state!=="expired")if(u.state==="loading")u.reloadCallback=i;else{if(u.buckets){const y=Object.values(u.buckets);for(const v of y)v.dirty=!0;return void(u.state="loaded")}u.request=u.actor.send("reloadTile",d,m.bind(this))}else u.actor=this.dispatcher.getActor(),u.request=u.actor.send("loadTile",d,m.bind(this),void 0,!0);function m(y,v){return u.aborted?i(null):y&&y.status!==404?i(y):(this.map._refreshExpiredTiles&&v&&u.setExpiryData(v),u.loadModelData(v,this.map.painter),u.state="loaded",void i(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends a.aV{constructor(u,i,o,d){super(u,i,o,d),i.coordinates?Array.isArray(i.coordinates)&&i.coordinates.length===4&&!i.coordinates.some(m=>!Array.isArray(m)||m.length!==2||m.some(y=>typeof y!="number"))||this.fire(new a.B(new a.V(`sources.${u}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.B(new a.V(`sources.${u}`,null,'missing required property "coordinates"'))),i.animate&&typeof i.animate!="boolean"&&this.fire(new a.B(new a.V(`sources.${u}`,null,'optional "animate" property must be a boolean value'))),i.canvas?typeof i.canvas=="string"||i.canvas instanceof HTMLCanvasElement||this.fire(new a.B(new a.V(`sources.${u}`,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 a.B(new a.V(`sources.${u}`,null,'missing required property "canvas"'))),this.options=i,this.animate=i.animate===void 0||i.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 a.B(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(u){this.map=u,this.load(),this.canvas&&this.animate&&this.play()}onRemove(u){this.pause()}prepare(){let u=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,u=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,u=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const i=this.map.painter.context;this.texture?!u&&!this._playing||this.texture instanceof a.aX||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.T(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const u of[this.canvas.width,this.canvas.height])if(isNaN(u)||u<=0)return!0;return!1}},custom:class extends a.E{constructor(u,i,o,d){super(),this.id=u,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=i,this.setEventedParent(d),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new a.B(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new a.B(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new qs(this._implementation.bounds,this.minzoom,this.maxzoom));const m=i;m.update=this._update.bind(this),m.clearTiles=this._clearTiles.bind(this),m.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,a.aJ(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return a.aJ(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new a.C("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(u){this.map=u,this._loaded=!1,this.fire(new a.C("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(u),this.load()}onRemove(u){this._implementation.onRemove&&this._implementation.onRemove(u)}hasTile(u){if(this._implementation.hasTile){const{x:i,y:o,z:d}=u.canonical;return this._implementation.hasTile({x:i,y:o,z:d})}return!this.tileBounds||this.tileBounds.contains(u.canonical)}loadTile(u,i){const{x:o,y:d,z:m}=u.tileID.canonical,y=new AbortController,v=Promise.resolve(this._implementation.loadTile({x:o,y:d,z:m},{signal:y.signal})).then((function(w){return delete u.request,u.aborted?(u.state="unloaded",i(null)):w===void 0?(u.state="errored",i(null)):w===null?(this.loadTileData(u,{width:this.tileSize,height:this.tileSize,data:null}),u.state="loaded",i(null)):function(E){return E instanceof ImageData||E instanceof HTMLCanvasElement||E instanceof ImageBitmap||E instanceof HTMLImageElement}(w)?(this.loadTileData(u,w),u.state="loaded",void i(null)):(u.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}).bind(this)).catch(w=>{w.name!=="AbortError"&&(u.state="errored",i(w))});v.cancel=()=>y.abort(),u.request=v}loadTileData(u,i){u.setTexture(i,this.map.painter)}unloadTile(u,i){if(u.texture&&u.texture instanceof a.T?(u.destroy(!1),u.texture&&u.texture instanceof a.T&&this.map.painter.saveTileTexture(u.texture)):u.destroy(),this._implementation.unloadTile){const{x:o,y:d,z:m}=u.tileID.canonical;this._implementation.unloadTile({x:o,y:d,z:m})}i&&i()}abortTile(u,i){u.request&&u.request.cancel&&(u.request.cancel(),delete u.request),i&&i()}hasTransition(){return!1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(u=>({x:u.canonical.x,y:u.canonical.y,z:u.canonical.z}))}_clearTiles(){const u=a.F(this.id,this.scope);this.map.style.clearSource(u)}_update(){this.fire(new a.C("data",{dataType:"source",sourceDataType:"content"}))}}},od=function(u,i,o,d){const m=new sd[i.type](u,i,o,d);if(m.id!==u)throw new Error(`Expected Source id to be ${u} instead of ${m.id}`);return a.aZ(["load","abort","unload","serialize","prepare"],m),m};function Pp(u,i,o=""){return`${o}:${i.id||""}:${i.layer.id}:${function(d){if("layerId"in d)return`layer:${d.layerId}`;{const{featuresetId:m,importId:y}=d;return`featureset:${m}${y?`:import:${y}`:""}`}}(u.target)}`}function Bo(u,i,o,d=""){if(u.uniqueFeatureID){const m=Pp(u,i,d);if(o.has(m))return!0;o.add(m)}return!1}function ty(u,i,o,d,m=!1,y=void 0){const v=i.sourceCache.transform,w=i.sourceCache.tilesIn(u,i.has3DLayers,m);w.sort(ld);const E=[];for(const P of w){const R=P.tile.queryRenderedFeatures(i,P,o,d,v,m,y);Object.keys(R).length&&E.push({wrappedTileID:P.tile.tileID.wrapped().key,queryResults:R})}for(const P in i.layers){const R=i.layers[P];if(R.styleLayer){const O=R.styleLayer.queryRenderedFeatures(u,i.sourceCache,d);Object.keys(O).length&&E.push({wrappedTileID:0,queryResults:O})}}return E.length===0?{}:function(P){const R={},O={};for(const k of P){const N=k.queryResults,j=k.wrappedTileID,U=O[j]=O[j]||{};for(const X in N){const W=N[X],ie=U[X]=U[X]||{},ne=R[X]=R[X]||[];for(const K of W)ie[K.featureIndex]||(ie[K.featureIndex]=!0,ne.push(K))}}return R}(E)}function ad(u,i,o,d,m,y){const v={},w=d.queryRenderedSymbols(u),E=[];for(const P of Object.keys(w).map(Number))E.push(m[P]);E.sort(ld);for(const P of E){const R=P.featureIndex.lookupSymbolFeatures(w[P.bucketInstanceId],P.bucketIndex,P.sourceLayerIndex,i,o,y);for(const O in R){const k=v[O]=v[O]||[],N=R[O];N.sort((j,U)=>{const X=P.featureSortOrder;if(X){const W=X.indexOf(j.featureIndex);return X.indexOf(U.featureIndex)-W}return U.featureIndex-j.featureIndex});for(const j of N)k.push(j)}}return v}function Mp(u,i){const o=u.getRenderableIds().map(y=>u.getTileByID(y)),d=[],m={};for(let y=0;y<o.length;y++){const v=o[y],w=v.tileID.canonical.key;m[w]||(m[w]=!0,v.querySourceFeatures(d,i))}return d}function ld(u,i){const o=u.tileID,d=i.tileID;return o.overscaledZ-d.overscaledZ||o.canonical.y-d.canonical.y||o.wrap-d.wrap||o.canonical.x-d.canonical.x}a.a_.setPbf(a.a$);class yl extends a.b0{constructor(i,o,d,m,y){super(i,o,d,m,y),this._workQueuePerLayer=new Map,this._fetchQueuePerLayer=new Map,this._taskQueue=new Map,this._isHeaderLoaded=!1,this.textureDescriptorPerLayer=new Map,this.texturePerLayer=new Map}getLayers(){return this._mrt?Object.values(this._mrt.layers):[]}getLayer(i){return this._mrt&&this._mrt.getLayer(i)}setTexturePerLayer(i,o,d){const m=d.context,y=m.gl;let v=this.texturePerLayer.get(i)||d.getTileTexture(o.width);v&&v instanceof a.T?v.update(o,{premultiply:!1}):v=new a.T(m,o,y.RGBA8,{premultiply:!1}),this.texturePerLayer.has(i)||this.texturePerLayer.set(i,v)}flushQueues(i){const o=this._workQueuePerLayer.get(i)||[],d=this._fetchQueuePerLayer.get(i)||[];for(;o.length;)o.pop()();for(;d.length;)d.pop()()}flushAllQueues(){for(const i of this._workQueuePerLayer.keys()){const o=this._workQueuePerLayer.get(i)||[];for(;o.length;)o.pop()()}for(const i of this._fetchQueuePerLayer.keys()){const o=this._fetchQueuePerLayer.get(i)||[];for(;o.length;)o.pop()()}}fetchHeader(i=16384,o){const d=this._mrt=new a.a_(30),m=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(i-1)}});return this.entireBuffer=null,this.request=a.b1(m,(y,v,w)=>{if(y)o(y);else try{const E=d.getHeaderLength(v);if(E>i)return void(this.request=this.fetchHeader(E,o));d.parseHeader(v),this._isHeaderLoaded=!0;let P=0;for(const R of Object.values(d.layers))P=Math.max(P,R.dataIndex[R.dataIndex.length-1].lastByte);v.byteLength>=P&&(this.entireBuffer=v),o(null,this.entireBuffer||v,w)}catch(E){o(E)}}),this.request}fetchBandForRender(i,o,d,m){this.fetchBand(i,o,d,y=>{if(y)return void m(y);this.updateTextureDescriptor(i,o,d);const v=this.textureDescriptorPerLayer.get(o);m(null,v?v.img:null)})}fetchBand(i,o,d,m,y=!0){const v=this._mrt;if(!this._isHeaderLoaded||!v)return void m(new Error("Tile header is not ready"));const w=this.actor;if(!w)return void m(new Error("Can't fetch tile band without an actor"));let E;const P=a.F(String(d),a.F(this.tileID.key,i));let R=this._taskQueue.get(P);R?R.add(m):(R=new Set,R.add(m),this._taskQueue.set(P,R));const O=(U,X)=>{E.complete(U,X),U?m(U):(R.forEach(W=>W(null,X)),this._taskQueue.delete(P))},k=(U,X)=>{if(U)return m(U);const W=w.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:X,task:E},O,void 0,!0);if(o!==null){const ie=this._workQueuePerLayer.get(o)||[];ie.push(()=>{W&&W.cancel(),E.cancel()}),this._workQueuePerLayer.has(o)||this._workQueuePerLayer.set(o,ie)}};let N;try{N=v.getLayer(i)}catch(U){if(this.state==="reloading")return;throw U}if(!N)return void m(new Error(`Unknown sourceLayer "${i}"`));if(N.hasDataForBand(d))return R.forEach(U=>U(null,null)),void this._taskQueue.delete(P);const j=N.getDataRange([d]);if(E=v.createDecodingTask(j),!E||E.tasks.length)if(o!==null&&this.flushQueues(o),this.entireBuffer)k(null,this.entireBuffer.slice(j.firstByte,j.lastByte+1));else{const U=Object.assign({},this.requestParams,{headers:{Range:`bytes=${j.firstByte}-${j.lastByte}`}}),X=a.b1(U,k);if(o!==null){const W=this._fetchQueuePerLayer.get(o)||[];W.push(()=>{X.cancel(),E.cancel()}),this._fetchQueuePerLayer.has(o)||this._fetchQueuePerLayer.set(o,W)}}}updateNeeded(i,o){return(!this.textureDescriptorPerLayer.get(i)||this.textureDescriptorPerLayer.get(i).band!==o||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(i,o,d){if(!this._mrt)return;const m=this._mrt.getLayer(i);if(!m||!m.hasBand(d)||!m.hasDataForBand(d))return;const{bytes:y,tileSize:v,buffer:w,offset:E,scale:P}=m.getBandView(d),R=v+2*w,O=new a.q({width:R,height:R},y),k=this.texturePerLayer.get(o);k&&k instanceof a.T&&k.update(O,{premultiply:!1}),this.textureDescriptorPerLayer.set(o,{layer:i,band:d,img:O,buffer:w,offset:E,tileSize:v,format:m.pixelFormat,mix:[P,256*P,65536*P,16777216*P]})}destroy(i=!1){if(super.destroy(i),delete this._mrt,!i)for(const o of this.texturePerLayer.values())o&&o instanceof a.T&&o.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}class pc{constructor(i,o){this.max=i,this.onRemove=o,this.reset()}reset(){for(const i in this.data)for(const o of this.data[i])o.timeout&&clearTimeout(o.timeout),this.onRemove(o.value);return this.data={},this.order=[],this}add(i,o,d){const m=i.wrapped().key;this.data[m]===void 0&&(this.data[m]=[]);const y={value:o,timeout:void 0};if(d!==void 0&&(y.timeout=setTimeout(()=>{this.remove(i,y)},d)),this.data[m].push(y),this.order.push(m),this.order.length>this.max){const v=this._getAndRemoveByKey(this.order[0]);v&&this.onRemove(v)}return this}has(i){return i.wrapped().key in this.data}getAndRemove(i){return this.has(i)?this._getAndRemoveByKey(i.wrapped().key):null}_getAndRemoveByKey(i){const o=this.data[i].shift();return o.timeout&&clearTimeout(o.timeout),this.data[i].length===0&&delete this.data[i],this.order.splice(this.order.indexOf(i),1),o.value}getByKey(i){const o=this.data[i];return o?o[0].value:null}get(i){return this.has(i)?this.data[i.wrapped().key][0].value:null}remove(i,o){if(!this.has(i))return this;const d=i.wrapped().key,m=o===void 0?0:this.data[d].indexOf(o),y=this.data[d][m];return this.data[d].splice(m,1),y.timeout&&clearTimeout(y.timeout),this.data[d].length===0&&delete this.data[d],this.onRemove(y.value),this.order.splice(this.order.indexOf(d),1),this}setMaxSize(i){for(this.max=i;this.order.length>this.max;){const o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}filter(i){const o=[];for(const d in this.data)for(const m of this.data[d])i(m.value)||o.push(m);for(const d of o)this.remove(d.value.tileID,d)}}class Rp{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(i,o,d){const m=String(o);if(this.stateChanges[i]=this.stateChanges[i]||{},this.stateChanges[i][m]=this.stateChanges[i][m]||{},Object.assign(this.stateChanges[i][m],d),this.deletedStates[i]===null){this.deletedStates[i]={};for(const y in this.state[i])y!==m&&(this.deletedStates[i][y]=null)}else if(this.deletedStates[i]&&this.deletedStates[i][m]===null){this.deletedStates[i][m]={};for(const y in this.state[i][m])d[y]||(this.deletedStates[i][m][y]=null)}else for(const y in d)this.deletedStates[i]&&this.deletedStates[i][m]&&this.deletedStates[i][m][y]===null&&delete this.deletedStates[i][m][y]}removeFeatureState(i,o,d){if(this.deletedStates[i]===null)return;const m=String(o);if(this.deletedStates[i]=this.deletedStates[i]||{},d&&o!==void 0)this.deletedStates[i][m]!==null&&(this.deletedStates[i][m]=this.deletedStates[i][m]||{},this.deletedStates[i][m][d]=null);else if(o!==void 0)if(this.stateChanges[i]&&this.stateChanges[i][m])for(d in this.deletedStates[i][m]={},this.stateChanges[i][m])this.deletedStates[i][m][d]=null;else this.deletedStates[i][m]=null;else this.deletedStates[i]=null}getState(i,o){const d=this.state[i]||{},m=this.stateChanges[i]||{},y=this.deletedStates[i];if(y===null)return{};if(o!==void 0){const w=String(o),E=Object.assign({},d[w],m[w]);if(y){const P=y[o];if(P===null)return{};for(const R in P)delete E[R]}return E}const v=Object.assign({},d,m);if(y)for(const w in y)delete v[w];return v}initializeTileState(i,o){i.refreshFeatureState(o)}coalesceChanges(i,o){const d={};for(const m in this.stateChanges){this.state[m]=this.state[m]||{};const y={};for(const v in this.stateChanges[m])this.state[m][v]||(this.state[m][v]={}),Object.assign(this.state[m][v],this.stateChanges[m][v]),y[v]=this.state[m][v];d[m]=y}for(const m in this.deletedStates){this.state[m]=this.state[m]||{};const y={};if(this.deletedStates[m]===null)for(const v in this.state[m])y[v]={},this.state[m][v]={};else for(const v in this.deletedStates[m]){if(this.deletedStates[m][v]===null)this.state[m][v]={};else if(this.state[m][v])for(const w of Object.keys(this.deletedStates[m][v]))delete this.state[m][v][w];y[v]=this.state[m][v]}d[m]=d[m]||{},Object.assign(d[m],y)}if(this.stateChanges={},this.deletedStates={},Object.keys(d).length!==0)for(const m in i)i[m].refreshFeatureState(o,d)}}class Ws extends a.E{constructor(i,o,d){super(),this.id=i,this._renderSourceType=d,this._maxzoomOverride=null,o.on("data",m=>{m.dataType==="source"&&m.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&m.dataType==="source"&&m.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),o.on("error",()=>{this._sourceErrored=!0}),this._source=o,this._tiles={},this._cache=new pc(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=o.minTileCacheSize,this._maxTileCacheSize=o.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Rp,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="raster-array"||this._source.type==="custom"&&"_dataType"in this._source&&this._source._dataType==="raster",this._supportsFading=this._source.type==="raster"||this._source.type==="raster-array"||this._source.type==="image"||this._source.type==="video"||this._source.type==="custom",this._isRasterElevatedOverTerrain=!1}onAdd(i){this.map=i,this._minTileCacheSize=this._minTileCacheSize===void 0&&i?i._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&i?i._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const i in this._tiles)if(!this._tiles[i].loaded())return!1;return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const i=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,i&&this.reload(),this.transform&&this.update(this.transform)}setMaxzoomOverride(i){this._maxzoomOverride=i}_loadTile(i,o){return i.renderSourceType=this._renderSourceType,i.isExtraShadowCaster=this._shadowCasterTiles[i.tileID.key],this._source.loadTile(i,o)}_unloadTile(i){if(this._source.unloadTile)return this._source.unloadTile(i)}_abortTile(i){if(this._source.abortTile)return this._source.abortTile(i)}serialize(){return this._source.serialize()}prepare(i){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const o in this._tiles){const d=this._tiles[o];d.upload(i,this.map?this.map.painter:void 0),d.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(i=>i.tileID).sort(Dp).map(i=>i.key)}getRenderableIds(i,o){const d=[];for(const m in this._tiles)this._isIdRenderable(+m,i,o)&&d.push(this._tiles[m]);return i?d.sort((m,y)=>{const v=m.tileID,w=y.tileID,E=new a.P(v.canonical.x,v.canonical.y)._rotate(this.transform.angle),P=new a.P(w.canonical.x,w.canonical.y)._rotate(this.transform.angle);return v.overscaledZ-w.overscaledZ||P.y-E.y||P.x-E.x}).map(m=>m.tileID.key):d.map(m=>m.tileID).sort(Dp).map(m=>m.key)}hasRenderableParent(i){const o=this.findLoadedParent(i,0);return!!o&&this._isIdRenderable(o.tileID.key)}_isIdRenderable(i,o,d){return this._tiles[i]&&this._tiles[i].hasData()&&!this._coveredTiles[i]&&(o||!this._tiles[i].holdingForFade())&&(d||!this._shadowCasterTiles[i])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const i in this._tiles)this._tiles[i].state!=="errored"&&this._reloadTile(+i,"reloading")}}_reloadTile(i,o){const d=this._tiles[i];d&&(d.state!=="loading"&&(d.state=o),this._loadTile(d,this._tileLoaded.bind(this,d,i,o)))}_tileLoaded(i,o,d,m,y){if(m){if(i.state="errored",a.b2(m)){if(this._source.fire(new a.C("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:i})),!(i.tileID.key in this._loadedParentTiles))return;if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const w=this.map.painter.terrain;this.update(this.transform,w.getScaledDemTileSize(),!0),w.resetTileLookupCache(this.id)}else this.update(this.transform)}else this._source.fire(new a.B(m,{tile:i}));return}i.timeAdded=a.o.now(),d==="expired"&&(i.refreshedUponExpiration=!0),this._setTileReloadTimer(o,i),this._source.type==="raster-dem"&&i.dem&&this._backfillDEM(i),this._state.initializeTileState(i,this.map?this.map.painter:null);let v=new Map;y&&y.responseHeaders&&(v=y.responseHeaders),this._source.fire(new a.C("data",{dataType:"source",tile:i,coord:i.tileID,sourceCacheId:this.id,responseHeaders:v}))}_hasTunnelGeometry(){for(const i in this._tiles){const o=this._tiles[i];if(o&&o.hasTunnelGeometry)return!0}return!1}_backfillDEM(i){const o=this.getRenderableIds();for(let m=0;m<o.length;m++){const y=o[m];if(i.neighboringTiles&&i.neighboringTiles[y]){const v=this.getTileByID(y);d(i,v),d(v,i)}}function d(m,y){if(!m.dem||m.dem.borderReady)return;m.needsHillshadePrepare=!0,m.needsDEMTextureUpload=!0;let v=y.tileID.canonical.x-m.tileID.canonical.x;const w=y.tileID.canonical.y-m.tileID.canonical.y,E=Math.pow(2,m.tileID.canonical.z),P=y.tileID.key;v===0&&w===0||Math.abs(w)>1||(Math.abs(v)>1&&(Math.abs(v+E)===1?v+=E:Math.abs(v-E)===1&&(v-=E)),y.dem&&m.dem&&(m.dem.backfillBorder(y.dem,v,w),m.neighboringTiles&&m.neighboringTiles[P]&&(m.neighboringTiles[P].backfilled=!0)))}}getTile(i){return this.getTileByID(i.key)}getTileByID(i){return this._tiles[i]}_retainLoadedChildren(i,o,d,m){for(const y in this._tiles){let v=this._tiles[y];if(m[y]||!v.hasData()||v.tileID.overscaledZ<=o||v.tileID.overscaledZ>d)continue;let w=v.tileID;for(;v&&v.tileID.overscaledZ>o+1;){const P=v.tileID.scaledTo(v.tileID.overscaledZ-1);v=this._tiles[P.key],v&&v.hasData()&&(w=P)}let E=w;for(;E.overscaledZ>o;)if(E=E.scaledTo(E.overscaledZ-1),i[E.key]){m[w.key]=w;break}}}findLoadedParent(i,o){if(i.key in this._loadedParentTiles){const d=this._loadedParentTiles[i.key];return d&&d.tileID.overscaledZ>=o?d:null}for(let d=i.overscaledZ-1;d>=o;d--){const m=i.scaledTo(d),y=this._getLoadedTile(m);if(y)return y}}_getLoadedTile(i){const o=this._tiles[i.key];return o&&o.hasData()?o:this._cache.getByKey(this._source.reparseOverscaled?i.wrapped().key:i.canonical.key)}updateCacheSize(i,o){o=o||this._source.tileSize;const d=Math.ceil(i.width/o)+1,m=Math.ceil(i.height/o)+1,y=Math.floor(d*m*5),v=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,y):y,w=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,v):v;this._cache.setMaxSize(w)}handleWrapJump(i){const o=Math.round((i-(this._prevLng===void 0?i:this._prevLng))/360);if(this._prevLng=i,o){const d={};for(const m in this._tiles){const y=this._tiles[m];y.tileID=y.tileID.unwrapTo(y.tileID.wrap+o),d[y.tileID.key]=y}this._tiles=d;for(const m in this._timers)clearTimeout(this._timers[m]),delete this._timers[m];for(const m in this._tiles)this._setTileReloadTimer(+m,this._tiles[m])}}update(i,o,d,m,y){if(this.transform=i,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!d)return;this.updateCacheSize(i,o),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const v=this._source.type==="batched-model";let w,E=this._source.maxzoom;this._maxzoomOverride!==null&&(E=Math.min(E,this._maxzoomOverride));const P=this.map&&this.map.painter?this.map.painter._terrain:null;if(P&&P.sourceCache===this&&P.attenuationRange()){const N=P.attenuationRange()[0],j=Math.floor(N)-Math.log2(P.getDemUpscale());E>j&&(E=j)}const R=this._maxzoomOverride===null&&this._source.reparseOverscaled;if(this.used||this.usedForTerrain){if(this._source.tileID)w=i.getVisibleUnwrappedCoordinates(this._source.tileID).map(N=>new a.aR(N.canonical.z,N.wrap,N.canonical.z,N.canonical.x,N.canonical.y));else if(this.tileCoverLift!==0){const N=i.clone();N.tileCoverLift=this.tileCoverLift,w=N.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:E,roundZoom:this._source.roundZoom&&!d,reparseOverscaled:R,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:v}),this._source.minzoom<=1&&i.projection.name==="globe"&&(w.push(new a.aR(1,0,1,0,0)),w.push(new a.aR(1,0,1,1,0)),w.push(new a.aR(1,0,1,0,1)),w.push(new a.aR(1,0,1,1,1)))}else if(w=i.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:E,roundZoom:this._source.roundZoom&&!d,reparseOverscaled:R,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:v}),this._source.hasTile){const N=this._source.hasTile.bind(this._source);w=w.filter(j=>N(j))}}else w=[];if(w.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!this._supportsFading){const N=i.coveringZoomLevel({tileSize:o||this._source.tileSize,roundZoom:this._source.roundZoom&&!d}),j=Math.min(N,E);if(v){const U=i.extendTileCover(w,j);for(const X of U)w.push(X)}else if(y){const U=this.transform.getFrustum(j),X=i.extendTileCoverToNearPlane(w,U,j);for(const W of X)w.push(W);if(j>=18&&this._hasTunnelGeometry()){const W=i.extendTileCoverForTunnels(w,U,j,20);for(const ie of W)w.push(ie)}}else if(this.castsShadows&&m){const U=i.extendTileCover(w,j,m,16);for(const X of U)this._shadowCasterTiles[X.key]=!0,w.push(X)}}const O=this._updateRetainedTiles(w);if(this._supportsFading&&w.length!==0){const N={},j={},U=a.o.now(),X=Object.keys(O);for(const ie of X){const ne=O[ie],K=this._tiles[ie];if(!K||K.fadeEndTime!==void 0&&K.fadeEndTime<=U)continue;const xe=this.findLoadedParent(ne,Math.max(ne.overscaledZ-Ws.maxOverzooming,this._source.minzoom));xe&&(this._addTile(xe.tileID),N[xe.tileID.key]=xe.tileID),j[ie]=ne}const W=w[w.length-1].overscaledZ;for(const ie in this._tiles){const ne=this._tiles[ie];if(O[ie]||!ne.hasData())continue;let K=ne.tileID;for(;K.overscaledZ>W;){K=K.scaledTo(K.overscaledZ-1);const xe=this._tiles[K.key];if(xe&&xe.hasData()&&j[K.key]){O[ie]=ne.tileID;break}}}for(const ie in N)O[ie]||(this._coveredTiles[ie]=!0,O[ie]=N[ie])}for(const N in O)this._tiles[N].clearFadeHold();const k=a.b3(this._tiles,O);for(const N of k){const j=this._tiles[N];j.hasSymbolBuckets&&!j.holdingForFade()?j.setHoldDuration(this.map._fadeDuration):j.hasSymbolBuckets&&!j.symbolFadeFinished()||this._removeTile(+N)}this._updateLoadedParentTileCache(),this._renderSourceType===a.b4.Symbol&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const i in this._tiles)this._tiles[i].holdingForFade()&&this._removeTile(+i)}_updateRetainedTiles(i){const o={};if(i.length===0)return o;const d={},m=i.reduce((P,R)=>Math.min(P,R.overscaledZ),1/0),y=i[0].overscaledZ,v=Math.max(y-Ws.maxOverzooming,this._source.minzoom),w=Math.max(y+Ws.maxUnderzooming,this._source.minzoom),E={};for(const P of i){const R=this._addTile(P);o[P.key]=P,R.hasData()||m<this._source.maxzoom&&(E[P.key]=P)}this._retainLoadedChildren(E,m,w,o);for(const P of i){let R=this._tiles[P.key];if(R.hasData())continue;if(P.canonical.z>=this._source.maxzoom){const k=P.children(this._source.maxzoom)[0],N=this.getTile(k);if(N&&N.hasData()){o[k.key]=k;continue}}else{const k=P.children(this._source.maxzoom);if(o[k[0].key]&&o[k[1].key]&&o[k[2].key]&&o[k[3].key])continue}let O=R.wasRequested();for(let k=P.overscaledZ-1;k>=v;--k){const N=P.scaledTo(k);if(d[N.key]||(d[N.key]=!0,R=this.getTile(N),!R&&O&&(R=this._addTile(N)),R&&(o[N.key]=N,O=R.wasRequested(),R.hasData())))break}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const i in this._tiles){const o=[];let d,m=this._tiles[i].tileID;for(;m.overscaledZ>0;){if(m.key in this._loadedParentTiles){d=this._loadedParentTiles[m.key];break}o.push(m.key);const y=m.scaledTo(m.overscaledZ-1);if(d=this._getLoadedTile(y),d)break;m=y}for(const y of o)this._loadedParentTiles[y]=d}}_addTile(i){let o=this._tiles[i.key];if(o)return o.isExtraShadowCaster!==!0||this._shadowCasterTiles[i.key]||this._reloadTile(i.key,"reloading"),o;o=this._cache.getAndRemove(i),o&&(this._setTileReloadTimer(i.key,o),o.tileID=i,this._state.initializeTileState(o,this.map?this.map.painter:null),this._cacheTimers[i.key]&&(clearTimeout(this._cacheTimers[i.key]),delete this._cacheTimers[i.key],this._setTileReloadTimer(i.key,o)));const d=!!o;if(!d){const m=this.map?this.map.painter:null,y=this._source.tileSize*i.overscaleFactor();o=this._source.type==="raster-array"?new yl(i,y,this.transform.tileZoom,m,this._isRaster):new a.b0(i,y,this.transform.tileZoom,m,this._isRaster,this._source.worldview),this._loadTile(o,this._tileLoaded.bind(this,o,i.key,o.state))}return o.uses++,this._tiles[i.key]=o,d||this._source.fire(new a.C("dataloading",{tile:o,coord:o.tileID,dataType:"source"})),o}_setTileReloadTimer(i,o){i in this._timers&&(clearTimeout(this._timers[i]),delete this._timers[i]);const d=o.getExpiryTimeout();d&&(this._timers[i]=setTimeout(()=>{this._reloadTile(i,"expired"),delete this._timers[i]},d))}_removeTile(i){const o=this._tiles[i];o&&(o.uses--,delete this._tiles[i],this._timers[i]&&(clearTimeout(this._timers[i]),delete this._timers[i]),o.uses>0||(o.hasData()&&o.state!=="reloading"||o.state==="empty"?this._cache.add(o.tileID,o,o.getExpiryTimeout()):(o.aborted=!0,this._abortTile(o),this._unloadTile(o))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const i in this._tiles)this._removeTile(+i);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(i,o,d){const m=[],y=this.transform;if(!y)return m;const v=y.projection.name==="globe",w=a.aH(y.center.lng);for(const E in this._tiles){const P=this._tiles[E];if(d&&P.clearQueryDebugViz(),P.holdingForFade())continue;let R;if(v){const O=P.tileID.canonical;if(O.z===0){const k=[Math.abs(a.aC(w,...mc(O,-1))-w),Math.abs(a.aC(w,...mc(O,1))-w)];R=[0,2*k.indexOf(Math.min(...k))-1]}else{const k=[Math.abs(a.aC(w,...mc(O,-1))-w),Math.abs(a.aC(w,...mc(O,0))-w),Math.abs(a.aC(w,...mc(O,1))-w)];R=[k.indexOf(Math.min(...k))-1]}}else R=[0];for(const O of R){const k=i.containsTile(P,y,o,O);k&&m.push(k)}}return m}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(i){return this._getRenderableCoordinates(i)}_getRenderableCoordinates(i,o){const d=this.getRenderableIds(i,o).map(y=>this._tiles[y].tileID),m=this.transform.projection.name==="globe";for(const y of d)y.projMatrix=this.transform.calculateProjMatrix(y.toUnwrapped()),y.expandedProjMatrix=m?this.transform.calculateProjMatrix(y.toUnwrapped(),!1,!0):y.projMatrix;return d}sortCoordinatesByDistance(i){const o=i.slice(),d=this.transform._camera.position,m=this.transform._camera.forward(),y={};for(const v of o){const w=1/(1<<v.canonical.z);y[v.key]=((v.canonical.x+.5)*w+v.wrap-d[0])*m[0]+((v.canonical.y+.5)*w-d[1])*m[1]-d[2]*m[2]}return o.sort((v,w)=>y[v.key]-y[w.key]),o}hasTransition(){if(this._source.hasTransition())return!0;if(this._supportsFading){const i=a.o.now();for(const o in this._tiles){const d=this._tiles[o];if(d.fadeEndTime!==void 0&&d.fadeEndTime>=i)return!0}}return!1}setFeatureState(i,o,d){this._state.updateState(i=i||"_geojsonTileLayer",o,d)}removeFeatureState(i,o,d){this._state.removeFeatureState(i=i||"_geojsonTileLayer",o,d)}getFeatureState(i,o){return this._state.getState(i=i||"_geojsonTileLayer",o)}setDependencies(i,o,d){const m=this._tiles[i];m&&m.setDependencies(o,d)}reloadTilesForDependencies(i,o){for(const d in this._tiles)this._tiles[d].hasDependency(i,o)&&this._reloadTile(+d,"reloading");this._cache.filter(d=>!d.hasDependency(i,o))}_preloadTiles(i,o){if(!this._sourceLoaded){const E=()=>{this._sourceLoaded&&(this._source.off("data",E),this._preloadTiles(i,o))};return void this._source.on("data",E)}const d=new Map,m=Array.isArray(i)?i:[i],y=this.map.painter.terrain,v=this.usedForTerrain&&y?y.getScaledDemTileSize():this._source.tileSize;for(const E of m){const P=E.coveringTiles({tileSize:v,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const R of P)d.set(R.key,R);this.usedForTerrain&&E.updateElevation(!1)}const w=Array.from(d.values());a.t(w,(E,P)=>{const R=new a.b0(E,this._source.tileSize*E.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(R,O=>{this._source.type==="raster-dem"&&R.dem&&this._backfillDEM(R),P(O,R)})},o)}}function Dp(u,i){const o=Math.abs(2*u.wrap)-+(u.wrap<0),d=Math.abs(2*i.wrap)-+(i.wrap<0);return u.overscaledZ-i.overscaledZ||d-o||i.canonical.y-u.canonical.y||i.canonical.x-u.canonical.x}function mc(u,i){const o=1<<u.z;return[u.x/o+i,(u.x+1)/o+i]}Ws.maxOverzooming=10,Ws.maxUnderzooming=3;class Mu{constructor(i){this.style=i,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];const i=!1,o=!1;for(const d in this.style._mergedLayers){const m=this.style._mergedLayers[d];if(m.type==="fill-extrusion"||m.type==="building")this.layers.push({layer:m,visible:i,visibilityChanged:o});else if(m.type==="model"){const y=this.style.getLayerSource(m);y&&y.type==="batched-model"&&this.layers.push({layer:m,visible:i,visibilityChanged:o})}}}onNewFrame(i){this.layersGotHidden=!1;for(const o of this.layers){const d=o.layer;let m=!1;d.type==="fill-extrusion"?m=!d.isHidden(i)&&d.paint.get("fill-extrusion-opacity")>0:d.type==="building"?m=!d.isHidden(i)&&d.paint.get("building-opacity")>0:d.type==="model"&&(m=!d.isHidden(i)&&d.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!m&&o.visible,o.visible=m}}updateZOffset(i,o){this.currentBuildingBuckets=[];for(const m of this.layers){const y=m.layer,v=this.style.getLayerSourceCache(y);let w=1;y.type==="fill-extrusion"?w=m.visible?y.paint.get("fill-extrusion-vertical-scale"):0:y.type==="building"&&(w=m.visible?y.paint.get("building-vertical-scale"):0);let E=v?v.getTile(o):null;if(!E&&v)for(const P in v._tiles){const R=v._tiles[P];if(o.canonical.isChildOf(R.tileID.canonical)){E=R;break}}this.currentBuildingBuckets.push({bucket:E?E.getBucket(y):null,tileID:E?E.tileID:o,verticalScale:w})}i.hasAnyZOffset=!1;let d=!1;for(let m=0;m<i.symbolInstances.length;m++){const y=i.symbolInstances.get(m),v=y.zOffset,w=this._getHeightAtTileOffset(o,y.tileAnchorX,y.tileAnchorY);y.zOffset=w!==Number.NEGATIVE_INFINITY?w:v,d||v===y.zOffset||(d=!0),i.hasAnyZOffset||y.zOffset===0||(i.hasAnyZOffset=!0)}d&&(i.zOffsetBuffersNeedUpload=!0,i.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(i,o,d,m){let y=o,v=d;if(i.canonical.z!==m.canonical.z){const w=m.canonical,E=1/(1<<i.canonical.z-w.z);y=(o+i.canonical.x*a.an)*E-w.x*a.an|0,v=(d+i.canonical.y*a.an)*E-w.y*a.an|0}return{tileX:y,tileY:v}}_getHeightAtTileOffset(i,o,d){let m,y;for(let v=0;v<this.layers.length;++v){const w=this.layers[v].layer;if(w.type!=="fill-extrusion"&&w.type!=="building")continue;const{bucket:E,tileID:P,verticalScale:R}=this.currentBuildingBuckets[v];if(!E)continue;const{tileX:O,tileY:k}=this._mapCoordToOverlappingTile(i,o,d,P),N=E.getHeightAtTileCoord(O,k);N&&N.height!==void 0&&(N.hidden?m=N.height:y=Math.max(N.height*R,y||0))}if(y!==void 0)return y;for(let v=0;v<this.layers.length;++v){const w=this.layers[v];if(w.layer.type!=="model"||!w.visible)continue;const{bucket:E,tileID:P}=this.currentBuildingBuckets[v];if(!E)continue;const{tileX:R,tileY:O}=this._mapCoordToOverlappingTile(i,o,d,P),k=E.getHeightAtTileCoord(R,O);if(k&&!k.hidden)return k.height===void 0&&m!==void 0?Math.min(k.maxHeight,m)*k.verticalScale:k.height?k.height*k.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}function Lp(u,i){const o={};for(const d in u)d!=="ref"&&(o[d]=u[d]);return a.b5.forEach(d=>{d in i&&(o[d]=i[d])}),o}function zp(u){u=u.slice();const i=Object.create(null);for(const o of u)i[o.id]=o;for(let o=0;o<u.length;o++){const d=u[o];if(d&&"ref"in d){const m=i[d.ref];m&&(u[o]=Lp(d,m))}}return u}const Ai={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setSnow:"setSnow",setRain:"setRain",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport",addIconset:"addIconset",removeIconset:"removeIconset"};function _c(u,i,o){o.push({command:Ai.addSource,args:[u,i[u]]})}function gc(u,i,o){i.push({command:Ai.removeSource,args:[u]}),o[u]=!0}function u1(u,i,o,d){gc(u,o,d),_c(u,i,o)}function cd(u,i,o){let d;for(d in u[o])if(u[o].hasOwnProperty(d)&&d!=="data"&&!a.b6(u[o][d],i[o][d]))return!1;for(d in i[o])if(i[o].hasOwnProperty(d)&&d!=="data"&&!a.b6(u[o][d],i[o][d]))return!1;return!0}function Oa(u,i,o,d,m,y){let v;for(v in i=i||{},u=u||{})u.hasOwnProperty(v)&&(a.b6(u[v],i[v])||o.push({command:y,args:[d,v,i[v],m]}));for(v in i)i.hasOwnProperty(v)&&!u.hasOwnProperty(v)&&(a.b6(u[v],i[v])||o.push({command:y,args:[d,v,i[v],m]}))}function yc(u){return u.id}function Ru(u,i){return u[i.id]=i,u}function ud(u,i,o){const d=i.createTileMatrix(u,u.worldSize,o.toUnwrapped());return a.aD(new Float32Array(16),u.projMatrix,d)}function iy(u,i,o){if(i.projection.name===o.projection.name)return u.projMatrix;const d=o.clone();return d.setProjection(i.projection),ud(d,i.getProjection(),u)}function xl(u,i,o){return i.name===o.projection.name?u.projMatrix:ud(o,i,u)}class ny{constructor(i,o){this.reset(i,o)}reset(i,o){this.points=i||[],this._distances=[0];for(let d=1;d<this.points.length;d++)this._distances[d]=this._distances[d-1]+this.points[d].dist(this.points[d-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(o||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(i){if(this.points.length===1)return this.points[0];i=a.aC(i,0,1);let o=1,d=this._distances[o];const m=i*this.paddedLength+this.padding;for(;d<m&&o<this._distances.length;)d=this._distances[++o];const y=o-1,v=this._distances[y],w=d-v,E=w>0?(m-v)/w:0;return this.points[y].mult(1-E).add(this.points[o].mult(E))}}class kp{constructor(i,o,d){const m=this.boxCells=[],y=this.circleCells=[];this.xCellCount=Math.ceil(i/d),this.yCellCount=Math.ceil(o/d);for(let v=0;v<this.xCellCount*this.yCellCount;v++)m.push([]),y.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=i,this.height=o,this.xScale=this.xCellCount/i,this.yScale=this.yCellCount/o,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(i,o,d,m,y){this._forEachCell(o,d,m,y,this._insertBoxCell,this.boxUid++),this.boxKeys.push(i),this.bboxes.push(o),this.bboxes.push(d),this.bboxes.push(m),this.bboxes.push(y)}insertCircle(i,o,d,m){this._forEachCell(o-m,d-m,o+m,d+m,this._insertCircleCell,this.circleUid++),this.circleKeys.push(i),this.circles.push(o),this.circles.push(d),this.circles.push(m)}_insertBoxCell(i,o,d,m,y,v){this.boxCells[y].push(v)}_insertCircleCell(i,o,d,m,y,v){this.circleCells[y].push(v)}_query(i,o,d,m,y,v){if(d<0||i>this.width||m<0||o>this.height)return!y&&[];const w=[];if(i<=0&&o<=0&&this.width<=d&&this.height<=m){if(y)return!0;for(let E=0;E<this.boxKeys.length;E++)w.push({key:this.boxKeys[E],x1:this.bboxes[4*E],y1:this.bboxes[4*E+1],x2:this.bboxes[4*E+2],y2:this.bboxes[4*E+3]});for(let E=0;E<this.circleKeys.length;E++){const P=this.circles[3*E],R=this.circles[3*E+1],O=this.circles[3*E+2];w.push({key:this.circleKeys[E],x1:P-O,y1:R-O,x2:P+O,y2:R+O})}return v?w.filter(v):w}return this._forEachCell(i,o,d,m,this._queryCell,w,{hitTest:y,seenUids:{box:{},circle:{}}},v),y?w.length>0:w}_queryCircle(i,o,d,m,y){const v=i-d,w=i+d,E=o-d,P=o+d;if(w<0||v>this.width||P<0||E>this.height)return!m&&[];const R=[];return this._forEachCell(v,E,w,P,this._queryCellCircle,R,{hitTest:m,circle:{x:i,y:o,radius:d},seenUids:{box:{},circle:{}}},y),m?R.length>0:R}query(i,o,d,m,y){return this._query(i,o,d,m,!1,y)}hitTest(i,o,d,m,y){return this._query(i,o,d,m,!0,y)}hitTestCircle(i,o,d,m){return this._queryCircle(i,o,d,!0,m)}_queryCell(i,o,d,m,y,v,w,E){const P=w.seenUids,R=this.boxCells[y];if(R!==null){const k=this.bboxes;for(const N of R)if(!P.box[N]){P.box[N]=!0;const j=4*N;if(i<=k[j+2]&&o<=k[j+3]&&d>=k[j+0]&&m>=k[j+1]&&(!E||E(this.boxKeys[N]))){if(w.hitTest)return v.push(!0),!0;v.push({key:this.boxKeys[N],x1:k[j],y1:k[j+1],x2:k[j+2],y2:k[j+3]})}}}const O=this.circleCells[y];if(O!==null){const k=this.circles;for(const N of O)if(!P.circle[N]){P.circle[N]=!0;const j=3*N;if(this._circleAndRectCollide(k[j],k[j+1],k[j+2],i,o,d,m)&&(!E||E(this.circleKeys[N]))){if(w.hitTest)return v.push(!0),!0;{const U=k[j],X=k[j+1],W=k[j+2];v.push({key:this.circleKeys[N],x1:U-W,y1:X-W,x2:U+W,y2:X+W})}}}}}_queryCellCircle(i,o,d,m,y,v,w,E){const P=w.circle,R=w.seenUids,O=this.boxCells[y];if(O!==null){const N=this.bboxes;for(const j of O)if(!R.box[j]){R.box[j]=!0;const U=4*j;if(this._circleAndRectCollide(P.x,P.y,P.radius,N[U+0],N[U+1],N[U+2],N[U+3])&&(!E||E(this.boxKeys[j])))return v.push(!0),!0}}const k=this.circleCells[y];if(k!==null){const N=this.circles;for(const j of k)if(!R.circle[j]){R.circle[j]=!0;const U=3*j;if(this._circlesCollide(N[U],N[U+1],N[U+2],P.x,P.y,P.radius)&&(!E||E(this.circleKeys[j])))return v.push(!0),!0}}}_forEachCell(i,o,d,m,y,v,w,E){const P=this._convertToXCellCoord(i),R=this._convertToYCellCoord(o),O=this._convertToXCellCoord(d),k=this._convertToYCellCoord(m);for(let N=P;N<=O;N++)for(let j=R;j<=k;j++)if(y.call(this,i,o,d,m,this.xCellCount*j+N,v,w,E))return}_convertToXCellCoord(i){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(i*this.xScale)))}_convertToYCellCoord(i){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(i*this.yScale)))}_circlesCollide(i,o,d,m,y,v){const w=m-i,E=y-o,P=d+v;return P*P>w*w+E*E}_circleAndRectCollide(i,o,d,m,y,v,w){const E=(v-m)/2,P=Math.abs(i-(m+E));if(P>E+d)return!1;const R=(w-y)/2,O=Math.abs(o-(y+R));if(O>R+d)return!1;if(P<=E||O<=R)return!0;const k=P-E,N=O-R;return k*k+N*N<=d*d}}const h1=Math.tan(85*Math.PI/180);function Ba(u,i,o,d,m,y,v){const w=a.bb();if(o)if(y.name==="globe"){const E=a.bc(m,i);a.aD(w,w,E)}else{const E=a.bd([],v);w[0]=E[0],w[1]=E[1],w[4]=E[2],w[5]=E[3],d||a.ba(w,w,m.angle)}else a.aD(w,m.labelPlaneMatrix,u);return w}function ho(u,i,o,d,m,y,v){const w=Ba(u,i,o,d,m,y,v);return y.name==="globe"&&o||(w[2]=w[6]=w[10]=w[14]=0),w}function xc(u,i,o,d,m,y,v){if(o){if(y.name==="globe"){const w=Ba(u,i,o,d,m,y,v);return a.b7(w,w),a.aD(w,u,w),w}{const w=a.b8(u),E=a.b9([]);return E[0]=v[0],E[1]=v[1],E[4]=v[2],E[5]=v[3],a.aD(w,w,E),d||a.ba(w,w,-m.angle),w}}return m.glCoordMatrix}function Xs(u,i,o,d){const m=[u,i,o,1];o?a.aE(m,m,d):Gt(m,m,d);const y=m[3];return m[0]/=y,m[1]/=y,m[2]/=y,m}function hd(u,i){return Math.min(.5+u/i*.5,1.5)}function Du(u,i){const o=u[0]/u[3],d=u[1]/u[3];return o>=-i[0]&&o<=i[0]&&d>=-i[1]&&d<=i[1]}function fs(u,i,o,d,m,y,v,w,E,P,R=1){const O=o.transform,k=d?u.textSizeData:u.iconSizeData,N=a.bj(k,o.transform.zoom,R),j=O.projection.name==="globe",U=[256/o.width*2+1,256/o.height*2+1],X=d?u.text.dynamicLayoutVertexArray:u.icon.dynamicLayoutVertexArray;X.clear();let W=null;j&&(W=d?u.text.globeExtVertexArray:u.icon.globeExtVertexArray);const ie=u.lineVertexArray,ne=d?u.text.placedSymbolArray:u.icon.placedSymbolArray,K=o.transform.width/o.transform.height;let xe,le=!1;for(let _e=0;_e<ne.length;_e++){const re=ne.get(_e),{numGlyphs:ae,writingMode:fe}=re;if(fe!==a.bk.vertical||le||xe===a.bk.horizontal||(le=!0),xe=fe,(re.hidden||fe===a.bk.vertical)&&!le){vc(ae,X);continue}le=!1;const Ce=new a.P(re.tileAnchorX,re.tileAnchorY),ve=u.elevationType==="road",Ne=!!O.elevation||ve;let{x:ze,y:Je,z:tt}=O.projection.projectTilePoint(Ce.x,Ce.y,P.canonical),Pe=null;if(Ne){const St=ve?u.getElevationFeatureForText(_e):null;Pe={getElevation:E,elevation:O.elevation,elevationFeature:St};const[Vt,Yt,Zt]=E(Ce,O.elevation,St);ze+=Vt,Je+=Yt,tt+=Zt}const we=[ze,Je,tt,1];if(a.aE(we,we,i),!Du(we,U)){vc(ae,X);continue}const Oe=we[3],Ue=hd(o.transform.getCameraToCenterDistance(O.projection),Oe),$e=a.bl(k,N,re),ft=v?$e/Ue:$e*Ue,lt=Xs(ze,Je,tt,m);if(lt[3]<=0){vc(ae,X);continue}let ct={};const et=a.ap(u.layers[0].layout.get("text-max-angle")),Et=Math.cos(et),Mt=v?null:Pe,vt=Op(re,ft,!1,w,i,m,y,u.glyphOffsetArray,ie,X,W,lt,Ce,ct,K,Mt,O.projection,P,v,Et);le=vt.useVertical,Mt&&vt.needsFlipping&&(ct={}),(vt.notEnoughRoom||le||vt.needsFlipping&&Op(re,ft,!0,w,i,m,y,u.glyphOffsetArray,ie,X,W,lt,Ce,ct,K,Mt,O.projection,P,v,Et).notEnoughRoom)&&vc(ae,X)}d?(u.text.dynamicLayoutVertexBuffer.updateData(X),W&&u.text.globeExtVertexBuffer&&u.text.globeExtVertexBuffer.updateData(W)):(u.icon.dynamicLayoutVertexBuffer.updateData(X),W&&u.icon.globeExtVertexBuffer&&u.icon.globeExtVertexBuffer.updateData(W))}function Fp(u,i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X){const{lineStartIndex:W,glyphStartIndex:ie,segment:ne}=w,K=ie+w.numGlyphs,xe=W+w.lineLength,le=i.getoffsetX(ie),_e=i.getoffsetX(K-1),re=fd(u*le,o,d,m,y,v,ne,W,xe,E,P,R,O,k,!0,N,j,U,X);if(!re)return null;const ae=fd(u*_e,o,d,m,y,v,ne,W,xe,E,P,R,O,k,!0,N,j,U,X);return ae?{first:re,last:ae}:null}function dd(u,i,o,d){return u===a.bk.horizontal&&Math.abs(d)>Math.abs(o)?{useVertical:!0}:u===a.bk.vertical?d>0?{needsFlipping:!0}:null:i!==0&&function(m,y){return m===0||Math.abs(y/m)>h1}(o,d)?i===1?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function Op(u,i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X,W,ie,ne){const K=i/24,xe=u.lineOffsetX*K,le=u.lineOffsetY*K,{lineStartIndex:_e,glyphStartIndex:re,numGlyphs:ae,segment:fe,writingMode:Ce,flipState:ve}=u,Ne=_e+u.lineLength,ze=Je=>{if(R){const[Oe,Ue,$e]=Je.up,ft=P.length;a.bm(R,ft+0,Oe,Ue,$e),a.bm(R,ft+1,Oe,Ue,$e),a.bm(R,ft+2,Oe,Ue,$e),a.bm(R,ft+3,Oe,Ue,$e)}const[tt,Pe,we]=Je.point;a.bn(P,tt,Pe,we,Je.angle)};if(ae>1){const Je=Fp(K,w,xe,le,o,O,k,u,E,y,N,U,!1,X,W,ie,ne);if(!Je)return{notEnoughRoom:!0};if(d&&!o){let[tt,Pe,we]=Je.first.point,[Oe,Ue,$e]=Je.last.point;[tt,Pe]=Xs(tt,Pe,we,v),[Oe,Ue]=Xs(Oe,Ue,$e,v);const ft=dd(Ce,ve,(Oe-tt)*j,Ue-Pe);if(u.flipState=ft&&ft.needsFlipping?1:2,ft)return ft}ze(Je.first);for(let tt=re+1;tt<re+ae-1;tt++){const Pe=fd(K*w.getoffsetX(tt),xe,le,o,O,k,fe,_e,Ne,E,y,N,U,!1,!1,X,W,ie,ne);if(!Pe)return P.length-=4*(tt-re),{notEnoughRoom:!0};ze(Pe)}ze(Je.last)}else{if(d&&!o){const tt=Xs(k.x,k.y,0,m),Pe=_e+fe+1,we=new a.P(E.getx(Pe),E.gety(Pe)),Oe=Xs(we.x,we.y,0,m),Ue=Oe[3]>0?Oe:Bp(k,we,tt,1,m,void 0,X,W.canonical),$e=dd(Ce,ve,(Ue[0]-tt[0])*j,Ue[1]-tt[1]);if(u.flipState=$e&&$e.needsFlipping?1:2,$e)return $e}const Je=fd(K*w.getoffsetX(re),xe,le,o,O,k,fe,_e,Ne,E,y,N,U,!1,!1,X,W,ie,ne);if(!Je)return{notEnoughRoom:!0};ze(Je)}return{}}function Ii(u,i,o,d,m){const{x:y,y:v,z:w}=d.projectTilePoint(u.x,u.y,i);if(!m)return Xs(y,v,w,o);const[E,P,R]=m.getElevation(u,m.elevation,m.elevationFeature);return Xs(y+E,v+P,w+R,o)}function Bp(u,i,o,d,m,y,v,w){const E=Ii(u.sub(i)._unit()._add(u),w,m,v,y);return a.ax(E,o,E),a.ay(E,E),a.bg(E,o,E,d)}function fd(u,i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X,W,ie){const ne=d?u-i:u+i;let K=ne>0?1:-1,xe=0;d&&(K*=-1,xe=Math.PI),K<0&&(xe+=Math.PI);let le=w+v+(K>0?0:1)|0,_e=m,re=m,ae=0,fe=0;const Ce=Math.abs(ne),ve=[],Ne=[];let ze=y,Je=ze,tt=a.be([]);const Pe=()=>Bp(Je,ze,re,Ce-ae+1,R,k,U,X.canonical);for(;ae+fe<=Ce;){if(le+=K,le<w||le>=E)return null;if(re=_e,Je=ze,ve.push(re),N&&Ne.push(Je),ze=new a.P(P.getx(le),P.gety(le)),_e=O[le],!_e){const Mt=Ii(ze,X.canonical,R,U,k);_e=Mt[3]>0?O[le]=Mt:Pe()}ae+=fe;const et=a.ax([],_e,re),Et=a.bf(re,_e);if(o&&Et>0&&fe>0&&a.bi(tt,et)/(fe*Et)<ie)return null;fe=Et,tt=et}j&&k&&(O[le]&&(_e=Pe(),fe=a.bf(re,_e),tt=a.ax([],_e,re)),O[le]=_e);const we=(Ce-ae)/fe,Oe=ze.sub(Je)._mult(we)._add(Je),Ue=a.bg([],re,tt,we);let $e=[0,0,1],ft=tt[0],lt=tt[1];if(W&&($e=U.upVector(X.canonical,Oe.x,Oe.y),$e[0]!==0||$e[1]!==0||$e[2]!==1)){const et=[$e[2],0,-$e[0]],Et=a.bh([],$e,et);a.ay(et,et),a.ay(Et,Et),ft=a.bi(tt,et),lt=a.bi(tt,Et)}if(o){const et=a.bh([],$e,tt);a.ay(et,et),a.bg(Ue,Ue,et,o*K)}const ct=xe+Math.atan2(lt,ft);return ve.push(Ue),N&&Ne.push(Oe),{point:Ue,angle:ct,path:ve,tilePath:Ne,up:$e}}function vc(u,i){const o=i.length,d=o+4*u;i.resize(d),i.float32.fill(-1/0,4*o,4*d)}function Gt(u,i,o){const d=i[0],m=i[1];return u[0]=o[0]*d+o[4]*m+o[12],u[1]=o[1]*d+o[5]*m+o[13],u[3]=o[3]*d+o[7]*m+o[15],u}const fo=100;class pd{constructor(i,o,d=new kp(i.width+200,i.height+200,25),m=new kp(i.width+200,i.height+200,25)){this.transform=i,this.grid=d,this.ignoredGrid=m,this.pitchfactor=Math.cos(i._pitch)*i.cameraToCenterDistance,this.screenRightBoundary=i.width+fo,this.screenBottomBoundary=i.height+fo,this.gridRightBoundary=i.width+200,this.gridBottomBoundary=i.height+200,this.fogState=o,this.clippedSymbols=new Map}clearClippedSymbolsForBucket(i){this.clippedSymbols.delete(i)}markSymbolAsClipped(i,o){let d=this.clippedSymbols.get(i);d||(d=new Set,this.clippedSymbols.set(i,d)),d.add(o)}placeCollisionBox(i,o,d,m,y,v,w,E,P,R,O){let k=d.projectedAnchorX,N=d.projectedAnchorY,j=d.projectedAnchorZ;const U=d.tileAnchorX,X=d.tileAnchorY,W=d.elevation,ie=d.tileID,ne=i.getProjection();if(W&&ie){const[Ne,ze,Je]=ne.upVector(ie.canonical,d.tileAnchorX,d.tileAnchorY),tt=ne.upVectorScale(ie.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;k+=Ne*W*tt,N+=ze*W*tt,j+=Je*W*tt}const K=i.projection.name==="globe",xe=i.projection.name==="globe"?a.al(this.transform.zoom):0;if(ie&&K&&xe<1&&!v){const Ne=1<<ie.canonical.z,ze=a.bo(U,X);a.bp(ze,ze,1/a.an),a.bq(ze,ze,a.bo(ie.canonical.x,ie.canonical.y)),a.bp(ze,ze,1/Ne),a.br(ze,ze,a.bo(m[0],m[1])),ze[0]=a.bs(ze[0],-.5,.5),a.bp(ze,ze,a.an);const Je=a.bt(ze[0],ze[1],a.an/(2*Math.PI),1);a.aE(Je,Je,y),k=a.am(k,Je[0],xe),N=a.am(N,Je[1],xe),j=a.am(j,Je[2],xe)}const le=this.projectAndGetPerspectiveRatio(R,k,N,j,d.tileID,ne.name==="globe"||!!W||this.transform.pitch>0,ne),_e=P*le.perspectiveRatio,re=(d.x1*o+w.x-d.padding)*_e+le.point.x,ae=(d.y1*o+w.y-d.padding)*_e+le.point.y,fe=(d.x2*o+w.x+d.padding)*_e+le.point.x,Ce=(d.y2*o+w.y+d.padding)*_e+le.point.y,ve=le.perspectiveRatio<=.55||le.occluded;return!this.isInsideGrid(re,ae,fe,Ce)||!E&&this.grid.hitTest(re,ae,fe,Ce,O)||ve?{box:[],offscreen:!1,occluded:le.occluded}:{box:[re,ae,fe,Ce],offscreen:this.isOffscreen(re,ae,fe,Ce),occluded:!1}}placeCollisionCircles(i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X){const W=[],ie=this.transform.elevation,ne=i.getProjection(),K=i.elevationType==="road",xe=!!ie||K,le=a.bu.getAtTileOffsetFunc(X,this.transform.center.lat,this.transform.worldSize,ne),_e=new a.P(d.tileAnchorX,d.tileAnchorY),re=new a.P(d.tileAnchorX,d.tileAnchorY);let{x:ae,y:fe,z:Ce}=ne.projectTilePoint(re.x,re.y,X.canonical),ve=null;if(xe){const Et=K?i.getElevationFeatureForText(m):null;ve={getElevation:le,elevation:ie,elevationFeature:Et};const[Mt,vt,St]=le(_e,ie,Et);ae+=Mt,fe+=vt,Ce+=St}const Ne=ne.name==="globe",ze=this.projectAndGetPerspectiveRatio(E,ae,fe,Ce,X,Ne||!!ie||this.transform.pitch>0,ne),{perspectiveRatio:Je}=ze,tt=(k?w/Je:w*Je)/a.by,Pe=Xs(ae,fe,Ce,P),we=d.lineOffsetX*tt,Oe=d.lineOffsetY*tt,Ue=a.ap(i.layers[0].layout.get("text-max-angle")),$e=Math.cos(Ue),ft=ze.signedDistanceFromCamera>0?Fp(tt,v,we,Oe,K&&d.flipState===1,Pe,re,d,y,P,{},xe&&!k?ve:null,k&&xe,ne,X,k,$e):null;let lt=!1,ct=!1,et=!0;if(ft&&!ze.occluded){const Et=.5*j*Je+U,Mt=new a.P(-100,-100),vt=new a.P(this.screenRightBoundary,this.screenBottomBoundary),St=new ny,{first:Vt,last:Yt}=ft,Zt=Vt.path.length;let si=[];for(let qt=Zt-1;qt>=1;qt--)si.push(Vt.path[qt]);for(let qt=1;qt<Yt.path.length;qt++)si.push(Yt.path[qt]);const Ft=2.5*Et;R&&(si=si.map(([qt,Ti,Vi],nn)=>(xe&&!Ne&&(Vi=le(nn<Zt-1?Vt.tilePath[Zt-1-nn]:Yt.tilePath[nn-Zt+2],ie,ve.elevationFeature)[2]),Xs(qt,Ti,Vi,R))),si.some(qt=>qt[3]<=0)&&(si=[]));let oi=[];if(si.length>0){let qt=1/0,Ti=-1/0,Vi=1/0,nn=-1/0;for(const Hi of si)qt=Math.min(qt,Hi[0]),Vi=Math.min(Vi,Hi[1]),Ti=Math.max(Ti,Hi[0]),nn=Math.max(nn,Hi[1]);Ti>=Mt.x&&qt<=vt.x&&nn>=Mt.y&&Vi<=vt.y&&(oi=[si.map(Hi=>new a.P(Hi[0],Hi[1]))],(qt<Mt.x||Ti>vt.x||Vi<Mt.y||nn>vt.y)&&(oi=a.bv(oi,Mt.x,Mt.y,vt.x,vt.y)))}for(const qt of oi){St.reset(qt,.25*Et);let Ti=0;Ti=St.length<=.5*Et?1:Math.ceil(St.paddedLength/Ft)+1;for(let Vi=0;Vi<Ti;Vi++){const nn=Vi/Math.max(Ti-1,1),Hi=St.lerp(nn),Ci=Hi.x+fo,ni=Hi.y+fo;W.push(Ci,ni,Et,0);const ri=Ci-Et,Zi=ni-Et,an=Ci+Et,Pi=ni+Et;if(et=et&&this.isOffscreen(ri,Zi,an,Pi),ct=ct||this.isInsideGrid(ri,Zi,an,Pi),!o&&this.grid.hitTestCircle(Ci,ni,Et,N)&&(lt=!0,!O))return{circles:[],offscreen:!1,collisionDetected:lt,occluded:!1}}}}return{circles:!O&&lt||!ct?[]:W,offscreen:et,collisionDetected:lt,occluded:ze.occluded}}queryRenderedSymbols(i){if(i.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const o=[];let d=1/0,m=1/0,y=-1/0,v=-1/0;for(const R of i){const O=new a.P(R.x+fo,R.y+fo);d=Math.min(d,O.x),m=Math.min(m,O.y),y=Math.max(y,O.x),v=Math.max(v,O.y),o.push(O)}const w=this.grid.query(d,m,y,v).concat(this.ignoredGrid.query(d,m,y,v)),E={},P={};for(const R of w){const O=R.key;if(E[O.bucketInstanceId]===void 0&&(E[O.bucketInstanceId]={}),E[O.bucketInstanceId][O.featureIndex])continue;const k=this.clippedSymbols.get(O.bucketInstanceId);if(k&&k.has(O.featureIndex))continue;const N=[new a.P(R.x1,R.y1),new a.P(R.x2,R.y1),new a.P(R.x2,R.y2),new a.P(R.x1,R.y2)];a.bw(o,N)&&(E[O.bucketInstanceId][O.featureIndex]=!0,P[O.bucketInstanceId]===void 0&&(P[O.bucketInstanceId]=[]),P[O.bucketInstanceId].push(O.featureIndex))}return P}insertCollisionBox(i,o,d,m,y){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:d,featureIndex:m,collisionGroupID:y},i[0],i[1],i[2],i[3])}insertCollisionCircles(i,o,d,m,y){const v=o?this.ignoredGrid:this.grid,w={bucketInstanceId:d,featureIndex:m,collisionGroupID:y};for(let E=0;E<i.length;E+=4)v.insertCircle(w,i[E],i[E+1],i[E+2])}projectAndGetPerspectiveRatio(i,o,d,m,y,v,w){const E=[o,d,m,1];let P=!1;m||this.transform.pitch>0?(a.aE(E,E,i),this.fogState&&y&&w.name!=="globe"&&(P=function(k,N,j,U,X,W){const ie=W.calculateFogTileMatrix(X),ne=[N,j,U];return a.ah(ne,ne,ie),Wi(k,a.ai(ne),W.pitch,W._fov)}(this.fogState,o,d,m,y.toUnwrapped(),this.transform)>.9)):Gt(E,E,i);const R=E[3];return{point:new a.P((E[0]/R+1)/2*this.transform.width+fo,(-E[1]/R+1)/2*this.transform.height+fo),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(w)/R*.5,1.5),signedDistanceFromCamera:R,occluded:v&&E[2]>R||P}}isOffscreen(i,o,d,m){return d<fo||i>=this.screenRightBoundary||m<fo||o>this.screenBottomBoundary}isInsideGrid(i,o,d,m){return d>=0&&i<this.gridRightBoundary&&m>=0&&o<this.gridBottomBoundary}getViewportMatrix(){const i=a.b9([]);return a.bx(i,i,[-100,-100,0]),i}}class Ys{constructor(i,o,d,m){this.opacity=i?Math.max(0,Math.min(1,i.opacity+(i.placed?o:-o))):m&&d?1:0,this.placed=d}isHidden(){return this.opacity===0&&!this.placed}}class vl{constructor(i,o,d,m,y,v=!1){this.text=new Ys(i?i.text:null,o,d,y),this.icon=new Ys(i?i.icon:null,o,m,y),this.clipped=v}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class la{constructor(i,o,d,m=!1){this.text=i,this.icon=o,this.skipFade=d,this.clipped=m}}class Dt{constructor(){this.invProjMatrix=a.bb(),this.viewportMatrix=a.bb(),this.circles=[]}}class ki{constructor(i,o,d,m,y){this.bucketInstanceId=i,this.featureIndex=o,this.sourceLayerIndex=d,this.bucketIndex=m,this.tileID=y}}class Fi{constructor(i){this.crossSourceCollisions=i,this.maxGroupID=0,this.collisionGroups={}}get(i){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[i]){const o=++this.maxGroupID;this.collisionGroups[i]={ID:o,predicate:d=>d.collisionGroupID===o}}return this.collisionGroups[i]}}function Wr(u,i,o,d,m){const{horizontalAlign:y,verticalAlign:v}=a.bF(u),w=-(y-.5)*i,E=-(v-.5)*o,P=a.bG(u,d);return new a.P(w+P[0]*m,E+P[1]*m)}function Na(u,i,o,d,m){const y=new a.P(u,i);return o&&y._rotate(d?m:-m),y}class Oi{constructor(i,o,d,m,y,v){this.transform=i.clone(),this.projection=i.projection.name,this.collisionIndex=new pd(this.transform,y),this.buildingIndex=v,this.frontCutoffStart=0,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new Fi(d),this.collisionCircleArrays={},this.prevPlacement=m,m&&(m.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(i,o,d,m,y=1){const v=d.getBucket(o),w=d.latestFeatureIndex;if(!v||!w||o.fqid!==v.layerIds[0])return;const E=v.layers[0].layout,P=v.layers[0].paint,R=d.collisionBoxArray,O=Math.pow(2,this.transform.zoom-d.tileID.overscaledZ),k=d.tileSize/a.an,N=d.tileID.toUnwrapped();this.transform.setProjection(v.projection);const j=(U=d.tileID,X=v.getProjection(),W=this.transform,X.name===this.projection?W.calculateProjMatrix(U.toUnwrapped()):ud(W,X,U));var U,X,W;const ie=E.get("text-pitch-alignment")==="map",ne=E.get("text-rotation-alignment")==="map";o.compileFilter(o.options);const K=o.dynamicFilter(),xe=o.dynamicFilterNeedsFeature(),le=o.dynamicFilterNeedsGeometry(),_e=this.transform.calculatePixelsToTileUnitsMatrix(d),re=ho(j,d.tileID.canonical,ie,ne,this.transform,v.getProjection(),_e);let ae=null;const fe=v.getProjection().createInversionMatrix(this.transform,d.tileID.canonical);if(ie){const Oe=xc(j,d.tileID.canonical,ie,ne,this.transform,v.getProjection(),_e);ae=a.aD([],this.transform.labelPlaneMatrix,Oe)}let Ce=null;K&&d.latestFeatureIndex&&(Ce={unwrappedTileID:N,dynamicFilter:K,dynamicFilterNeedsFeature:xe,needGeometry:le}),this.retainedQueryData[v.bucketInstanceId]=new ki(v.bucketInstanceId,w,v.sourceLayerIndex,v.index,d.tileID);const[ve,Ne]=v.layers[0].layout.get("text-size-scale-range"),ze=a.aC(y,ve,Ne),[Je,tt]=E.get("icon-size-scale-range"),Pe=a.aC(y,Je,tt),we={bucket:v,layout:E,paint:P,posMatrix:j,invMatrix:fe,mercatorCenter:[a.aH(this.transform.center.lng),a.aL(this.transform.center.lat)],textLabelPlaneMatrix:re,labelToScreenMatrix:ae,clippingData:Ce,scale:O,textPixelRatio:k,holdingForFade:d.holdingForFade(),collisionBoxArray:R,partiallyEvaluatedTextSize:a.bj(v.textSizeData,this.transform.zoom,ze),partiallyEvaluatedIconSize:a.bj(v.iconSizeData,this.transform.zoom,Pe),collisionGroup:this.collisionGroups.get(v.sourceID),latestFeatureIndex:d.latestFeatureIndex};if(m)for(const Oe of v.sortKeyRanges){const{sortKey:Ue,symbolInstanceStart:$e,symbolInstanceEnd:ft}=Oe;i.push({sortKey:Ue,symbolInstanceStart:$e,symbolInstanceEnd:ft,parameters:we})}else i.push({symbolInstanceStart:0,symbolInstanceEnd:v.symbolInstances.length,parameters:we})}attemptAnchorPlacement(i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X,W,ie,ne,K,xe){const{textOffset0:le,textOffset1:_e,crossTileID:re}=U,ae=[le,_e],fe=Wr(i,v,w,ae,E),Ce=this.collisionIndex.placeCollisionBox(W,E,o,d,m,y,Na(fe.x,fe.y,P,R,this.transform.angle),j,O,k,N.predicate);if(ne){const ve=W.getSymbolInstanceIconSize(xe,this.transform.zoom,U.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(W,ve,ne,d,m,y,Na(fe.x,fe.y,P,R,this.transform.angle),j,O,k,N.predicate).box.length===0)return}if(Ce.box.length>0){let ve;return this.prevPlacement&&this.prevPlacement.variableOffsets[re]&&this.prevPlacement.placements[re]&&this.prevPlacement.placements[re].text&&(ve=this.prevPlacement.variableOffsets[re].anchor),this.variableOffsets[re]={textOffset:ae,width:v,height:w,anchor:i,textScale:E,prevAnchor:ve},this.markUsedJustification(W,i,U,ie),W.allowVerticalPlacement&&(this.markUsedOrientation(W,ie,U),this.placedOrientations[re]=ie),{shift:fe,placedGlyphBoxes:Ce}}}placeLayerBucketPart(i,o,d,m,y=1){const{bucket:v,layout:w,paint:E,posMatrix:P,textLabelPlaneMatrix:R,labelToScreenMatrix:O,clippingData:k,textPixelRatio:N,mercatorCenter:j,invMatrix:U,holdingForFade:X,collisionBoxArray:W,partiallyEvaluatedTextSize:ie,partiallyEvaluatedIconSize:ne,collisionGroup:K,latestFeatureIndex:xe}=i.parameters,le=w.get("text-optional"),_e=w.get("icon-optional"),re=w.get("text-allow-overlap"),ae=w.get("icon-allow-overlap"),fe=w.get("text-rotation-alignment")==="map",Ce=w.get("icon-rotation-alignment")==="map",ve=w.get("text-pitch-alignment")==="map",Ne=E.get("symbol-z-offset"),ze=w.get("symbol-elevation-reference")==="sea",Je=w.get("symbol-placement"),[tt,Pe]=w.get("text-size-scale-range"),[we,Oe]=w.get("icon-size-scale-range"),Ue=a.aC(y,tt,Pe),$e=a.aC(y,we,Oe),ft=w.get("text-variable-anchor"),lt=fe&&Je!=="point",ct=Ce&&Je!=="point",et=ft&&v.hasTextData(),Et=v.hasIconTextFit()&&et&&v.hasIconData();this.transform.setProjection(v.projection);const Mt=et||lt,vt=ct||Et;let St=re&&(ae||!v.hasIconData()||_e),Vt=ae&&(re||!v.hasTextData()||le);const Yt=!Ne.isConstant();!v.collisionArrays&&W&&v.deserializeCollisionBoxes(W),d&&m&&v.updateCollisionDebugBuffers(this.transform.zoom,W,Ue,$e);const Zt=(Ft,oi,qt)=>{const{crossTileID:Ti,numVerticalGlyphVertices:Vi}=Ft;let nn=null;if(k&&k.dynamicFilterNeedsFeature||Yt){const Yi=this.retainedQueryData[v.bucketInstanceId],Ki=xe.loadFeature({featureIndex:Ft.featureIndex,bucketIndex:Yi.bucketIndex,sourceLayerIndex:Yi.sourceLayerIndex,layoutVertexArrayOffset:0}),Bi=Ki.properties?Ki.properties.worldview:null;if(v.localizable&&v.worldview&&typeof Bi=="string")if(Bi==="all")Ki.properties.$localized=!0;else{if(!Bi.split(",").includes(v.worldview))return;Ki.properties.$localized=!0,Ki.properties.worldview=v.worldview}nn=k&&k.needGeometry?a.bD(Ki,!0):Ki}if(k&&!(0,k.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:v.worldview},nn,this.retainedQueryData[v.bucketInstanceId].tileID.canonical,new a.P(Ft.tileAnchorX,Ft.tileAnchorY),this.transform.calculateDistanceTileData(k.unwrappedTileID)))return this.placements[Ti]=new la(!1,!1,!1,!0),void o.add(Ti);const Hi=Ne.evaluate(nn,{});if((Ft.zOffset||0)+(Hi||0)>0&&this.frontCutoffStart>0){const Yi=2*this.frontCutoffStart-1,Ki=[Ft.tileAnchorX,Ft.tileAnchorY,0,1],Bi=a.aE(a.bE(),Ki,P);if(Bi[1]/Bi[3]<Yi)return this.placements[Ti]=new la(!1,!1,!1,!0),void o.add(Ti)}if(o.has(Ti))return;if(X)return void(this.placements[Ti]=new la(!1,!1,!1));let Ci=!1,ni=!1,ri=!0,Zi=!1,an=!1,Pi=null,Jt={box:null,offscreen:null,occluded:null},en={box:null},Ui=null,kn=null,fi=null,Gi=0,Vn=0,Er=0;qt.textFeatureIndex?Gi=qt.textFeatureIndex:Ft.useRuntimeCollisionCircles&&(Gi=Ft.featureIndex),qt.verticalTextFeatureIndex&&(Vn=qt.verticalTextFeatureIndex);const Hn=v.elevationFeatures?v.elevationFeatures[Ft.elevationFeatureIndex]:void 0,ar=Yi=>{Yi.tileID=this.retainedQueryData[v.bucketInstanceId].tileID;const Ki=this.transform.elevation;Yi.elevation=ze?Hi:Hi+a.bu.getAtTileOffset(Yi.tileID,new a.P(Yi.tileAnchorX,Yi.tileAnchorY),Ki,Hn),Yi.elevation+=Ft.zOffset},_s=qt.textBox;if(_s){ar(_s);const Yi=Bi=>{let Mn=a.bk.horizontal;if(v.allowVerticalPlacement&&!Bi&&this.prevPlacement){const kr=this.prevPlacement.placedOrientations[Ti];kr&&(this.placedOrientations[Ti]=kr,Mn=kr,this.markUsedOrientation(v,Mn,Ft))}return Mn},Ki=(Bi,Mn)=>{if(v.allowVerticalPlacement&&Vi>0&&qt.verticalTextBox){for(const kr of v.writingModes)if(kr===a.bk.vertical?(Jt=Mn(),en=Jt):Jt=Bi(),Jt&&Jt.box&&Jt.box.length)break}else Jt=Bi()};if(ft){let Bi=ft;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Ti]){const _n=this.prevPlacement.variableOffsets[Ti];Bi.indexOf(_n.anchor)>0&&(Bi=Bi.filter(gs=>gs!==_n.anchor),Bi.unshift(_n.anchor))}const Mn=(_n,gs,Wa)=>{const Bl=v.getSymbolInstanceTextSize(ie,Ft,this.transform.zoom,oi),Nl=(_n.x2-_n.x1)*Bl+2*_n.padding,Uc=(_n.y2-_n.y1)*Bl+2*_n.padding,ga=Ft.hasIconTextFit&&!ae?gs:null;ga&&ar(ga);let Ho={box:[],offscreen:!1,occluded:!1};const jc=re?2*Bi.length:Bi.length;for(let ns=0;ns<jc;++ns){const Xa=this.attemptAnchorPlacement(Bi[ns%Bi.length],_n,j,U,Mt,Nl,Uc,Bl,fe,ve,N,P,K,ns>=Bi.length,Ft,oi,v,Wa,ga,ie,ne);if(Xa&&(Ho=Xa.placedGlyphBoxes,Ho&&Ho.box&&Ho.box.length)){Ci=!0,Pi=Xa.shift;break}}return Ho};Ki(()=>Mn(_s,qt.iconBox,a.bk.horizontal),()=>{const _n=qt.verticalTextBox;return _n&&ar(_n),v.allowVerticalPlacement&&!(Jt&&Jt.box&&Jt.box.length)&&Vi>0&&_n?Mn(_n,qt.verticalIconBox,a.bk.vertical):{box:null,offscreen:null,occluded:null}}),Jt&&(Ci=Jt.box,ri=Jt.offscreen,Zi=Jt.occluded);const kr=Yi(!(!Jt||!Jt.box));if(!Ci&&this.prevPlacement){const _n=this.prevPlacement.variableOffsets[Ti];_n&&(this.variableOffsets[Ti]=_n,this.markUsedJustification(v,_n.anchor,Ft,kr))}}else{const Bi=(Mn,kr)=>{const _n=v.getSymbolInstanceTextSize(ie,Ft,this.transform.zoom,oi),gs=this.collisionIndex.placeCollisionBox(v,_n,Mn,j,U,Mt,new a.P(0,0),re,N,P,K.predicate);return gs&&gs.box&&gs.box.length&&(this.markUsedOrientation(v,kr,Ft),this.placedOrientations[Ti]=kr),gs};Ki(()=>Bi(_s,a.bk.horizontal),()=>{const Mn=qt.verticalTextBox;return v.allowVerticalPlacement&&Vi>0&&Mn?(ar(Mn),Bi(Mn,a.bk.vertical)):{box:null,offscreen:null,occluded:null}}),Yi(!!(Jt&&Jt.box&&Jt.box.length))}}if(Ui=Jt,Ci=Ui&&Ui.box&&Ui.box.length>0,ri=Ui&&Ui.offscreen,Zi=Ui&&Ui.occluded,Ft.useRuntimeCollisionCircles){const Yi=Ft.centerJustifiedTextSymbolIndex>=0?Ft.centerJustifiedTextSymbolIndex:Ft.verticalPlacedTextSymbolIndex,Ki=v.text.placedSymbolArray.get(Yi),Bi=a.bl(v.textSizeData,ie,Ki),Mn=w.get("text-padding");kn=this.collisionIndex.placeCollisionCircles(v,re,Ki,Yi,v.lineVertexArray,v.glyphOffsetArray,Bi,P,R,O,d,ve,K.predicate,Ft.collisionCircleDiameter*Bi/a.by,Mn,this.retainedQueryData[v.bucketInstanceId].tileID),Ci=re||kn.circles.length>0&&!kn.collisionDetected,ri=ri&&kn.offscreen,Zi=kn.occluded}if(qt.iconFeatureIndex&&(Er=qt.iconFeatureIndex),qt.iconBox){const Yi=Ki=>{ar(Ki);const Bi=Ft.hasIconTextFit&&Pi?Na(Pi.x,Pi.y,fe,ve,this.transform.angle):new a.P(0,0),Mn=v.getSymbolInstanceIconSize(ne,this.transform.zoom,Ft.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(v,Mn,Ki,j,U,vt,Bi,ae,N,P,K.predicate)};en&&en.box&&en.box.length&&qt.verticalIconBox?(fi=Yi(qt.verticalIconBox),ni=fi.box.length>0):(fi=Yi(qt.iconBox),ni=fi.box.length>0),ri=ri&&fi.offscreen,an=fi.occluded}const Li=le||Ft.numHorizontalGlyphVertices===0&&Vi===0,Ls=_e||Ft.numIconVertices===0;if(Li||Ls?Ls?Li||(ni=ni&&Ci):Ci=ni&&Ci:ni=Ci=ni&&Ci,Ci&&Ui&&Ui.box&&this.collisionIndex.insertCollisionBox(Ui.box,w.get("text-ignore-placement"),v.bucketInstanceId,en&&en.box&&Vn?Vn:Gi,K.ID),ni&&fi&&this.collisionIndex.insertCollisionBox(fi.box,w.get("icon-ignore-placement"),v.bucketInstanceId,Er,K.ID),kn&&(Ci&&this.collisionIndex.insertCollisionCircles(kn.circles,w.get("text-ignore-placement"),v.bucketInstanceId,Gi,K.ID),d)){const Yi=v.bucketInstanceId;let Ki=this.collisionCircleArrays[Yi];Ki===void 0&&(Ki=this.collisionCircleArrays[Yi]=new Dt);for(let Bi=0;Bi<kn.circles.length;Bi+=4)Ki.circles.push(kn.circles[Bi+0]),Ki.circles.push(kn.circles[Bi+1]),Ki.circles.push(kn.circles[Bi+2]),Ki.circles.push(kn.collisionDetected?1:0)}const zs=v.projection.name!=="globe";St=St&&(zs||!Zi),Vt=Vt&&(zs||!an),this.placements[Ti]=new la(Ci||St,ni||Vt,ri||v.justReloaded),o.add(Ti)},si=this.retainedQueryData[v.bucketInstanceId].tileID;if(v.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(v,si),v.elevationType==="road"&&v.updateRoadElevation(si.canonical),v.updateZOffset(),v.sortFeaturesByY){const Ft=v.getSortedSymbolIndexes(this.transform.angle);for(let oi=Ft.length-1;oi>=0;--oi){const qt=Ft[oi];Zt(v.symbolInstances.get(qt),qt,v.collisionArrays[qt])}v.hasAnyZOffset&&a.w(`${v.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(v.hasAnyZOffset){const Ft=v.getSortedIndexesByZOffset();for(let oi=0;oi<Ft.length;++oi){const qt=Ft[oi];Zt(v.symbolInstances.get(qt),qt,v.collisionArrays[qt])}}else for(let Ft=i.symbolInstanceStart;Ft<i.symbolInstanceEnd;Ft++)Zt(v.symbolInstances.get(Ft),Ft,v.collisionArrays[Ft]);if(d&&v.bucketInstanceId in this.collisionCircleArrays){const Ft=this.collisionCircleArrays[v.bucketInstanceId];a.b7(Ft.invProjMatrix,P),Ft.viewportMatrix=this.collisionIndex.getViewportMatrix()}v.justReloaded=!1}markUsedJustification(i,o,d,m){const{leftJustifiedTextSymbolIndex:y,centerJustifiedTextSymbolIndex:v,rightJustifiedTextSymbolIndex:w,verticalPlacedTextSymbolIndex:E,crossTileID:P}=d,R=a.bH(o),O=m===a.bk.vertical?E:R==="left"?y:R==="center"?v:R==="right"?w:-1;y>=0&&(i.text.placedSymbolArray.get(y).crossTileID=O>=0&&y!==O?0:P),v>=0&&(i.text.placedSymbolArray.get(v).crossTileID=O>=0&&v!==O?0:P),w>=0&&(i.text.placedSymbolArray.get(w).crossTileID=O>=0&&w!==O?0:P),E>=0&&(i.text.placedSymbolArray.get(E).crossTileID=O>=0&&E!==O?0:P)}markUsedOrientation(i,o,d){const m=o===a.bk.horizontal||o===a.bk.horizontalOnly?o:0,y=o===a.bk.vertical?o:0,{leftJustifiedTextSymbolIndex:v,centerJustifiedTextSymbolIndex:w,rightJustifiedTextSymbolIndex:E,verticalPlacedTextSymbolIndex:P}=d,R=i.text.placedSymbolArray;v>=0&&(R.get(v).placedOrientation=m),w>=0&&(R.get(w).placedOrientation=m),E>=0&&(R.get(E).placedOrientation=m),P>=0&&(R.get(P).placedOrientation=y)}commit(i){this.commitTime=i,this.zoomAtLastRecencyCheck=this.transform.zoom;const o=this.prevPlacement;let d=!1;this.prevZoomAdjustment=o?o.zoomAdjustment(this.transform.zoom):0;const m=o?o.symbolFadeChange(i):1,y=o?o.opacities:{},v=o?o.variableOffsets:{},w=o?o.placedOrientations:{};for(const E in this.placements){const P=this.placements[E],R=y[E];R?(this.opacities[E]=new vl(R,m,P.text,P.icon,null,P.clipped),d=d||P.text!==R.text.placed||P.icon!==R.icon.placed):(this.opacities[E]=new vl(null,m,P.text,P.icon,P.skipFade,P.clipped),d=d||P.text||P.icon)}for(const E in y){const P=y[E];if(!this.opacities[E]){const R=new vl(P,m,!1,!1);R.isHidden()||(this.opacities[E]=R,d=d||P.text.placed||P.icon.placed)}}for(const E in v)this.variableOffsets[E]||!this.opacities[E]||this.opacities[E].isHidden()||(this.variableOffsets[E]=v[E]);for(const E in w)this.placedOrientations[E]||!this.opacities[E]||this.opacities[E].isHidden()||(this.placedOrientations[E]=w[E]);d?this.lastPlacementChangeTime=i:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=o?o.lastPlacementChangeTime:i)}updateLayerOpacities(i,o,d,m){m&&(this.lastReplacementSourceUpdateTime=m.updateTime);const y=new Set;for(const v of o){const w=v.getBucket(i);w&&v.latestFeatureIndex&&i.fqid===w.layerIds[0]&&(this.updateBucketOpacities(w,y,v,v.collisionBoxArray,d,m,v.tileID,i.scope),w.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(w,v.tileID),w.elevationType==="road"&&w.updateRoadElevation(v.tileID.canonical),w.updateZOffset())}}updateBucketOpacities(i,o,d,m,y,v,w,E){i.hasTextData()&&i.text.opacityVertexArray.clear(),i.hasIconData()&&i.icon.opacityVertexArray.clear(),i.hasIconCollisionBoxData()&&i.iconCollisionBox.collisionVertexArray.clear(),i.hasTextCollisionBoxData()&&i.textCollisionBox.collisionVertexArray.clear();const P=i.layers[0].layout,R=i.layers[0].paint,O=!!i.layers[0].dynamicFilter(),k=new vl(null,0,!1,!1,!0),N=P.get("text-allow-overlap"),j=P.get("icon-allow-overlap"),U=P.get("text-variable-anchor"),X=P.get("text-rotation-alignment")==="map",W=P.get("text-pitch-alignment")==="map",ie=R.get("symbol-z-offset"),ne=P.get("symbol-elevation-reference")==="sea",K=!ie.isConstant(),xe=new vl(null,0,N&&(j||!i.hasIconData()||P.get("icon-optional")),j&&(N||!i.hasTextData()||P.get("text-optional")),!0);!i.collisionArrays&&m&&(i.hasIconCollisionBoxData()||i.hasTextCollisionBoxData())&&i.deserializeCollisionBoxes(m);const le=(re,ae,fe)=>{for(let Ce=0;Ce<ae/4;Ce++)re.opacityVertexArray.emplaceBack(fe)};let _e=0;v&&i.updateReplacement(w,v),this.collisionIndex.clearClippedSymbolsForBucket(i.bucketInstanceId);for(let re=0;re<i.symbolInstances.length;re++){const ae=i.symbolInstances.get(re),{numHorizontalGlyphVertices:fe,numVerticalGlyphVertices:Ce,crossTileID:ve,numIconVertices:Ne,tileAnchorX:ze,tileAnchorY:Je}=ae;let tt=null;const Pe=this.retainedQueryData[i.bucketInstanceId];K&&ae&&Pe&&(tt=d.latestFeatureIndex.loadFeature({featureIndex:ae.featureIndex,bucketIndex:Pe.bucketIndex,sourceLayerIndex:Pe.sourceLayerIndex,layoutVertexArrayOffset:0}));const we=ie.evaluate(tt,{}),Oe=o.has(ve);let Ue=this.opacities[ve];Oe?Ue=k:Ue||(Ue=xe,this.opacities[ve]=Ue),o.add(ve);const $e=fe>0||Ce>0,ft=Ne>0,lt=this.placedOrientations[ve],ct=lt===a.bk.vertical,et=lt===a.bk.horizontal||lt===a.bk.horizontalOnly;!$e&&!ft||Ue.isHidden()||_e++;let Et=!1;if(($e||ft)&&v)for(const Mt of i.activeReplacements){if(a.bz(Mt,y,a.bA.Symbol,E)||Mt.min.x>ze||ze>Mt.max.x||Mt.min.y>Je||Je>Mt.max.y)continue;const vt=a.bB(ze,Je,w.canonical,Mt.footprintTileId.canonical);if(Et=a.bC(vt,Mt.footprint),Et)break}if(Et&&this.collisionIndex.markSymbolAsClipped(i.bucketInstanceId,ae.featureIndex),$e){const Mt=Et?ca:bc(Ue.text);le(i.text,fe,ct?ca:Mt),le(i.text,Ce,et?ca:Mt);const vt=Ue.text.isHidden(),{leftJustifiedTextSymbolIndex:St,centerJustifiedTextSymbolIndex:Vt,rightJustifiedTextSymbolIndex:Yt,verticalPlacedTextSymbolIndex:Zt}=ae,si=i.text.placedSymbolArray,Ft=vt||ct?1:0;St>=0&&(si.get(St).hidden=Ft),Vt>=0&&(si.get(Vt).hidden=Ft),Yt>=0&&(si.get(Yt).hidden=Ft),Zt>=0&&(si.get(Zt).hidden=vt||et?1:0);const oi=this.variableOffsets[ve];oi&&this.markUsedJustification(i,oi.anchor,ae,lt);const qt=this.placedOrientations[ve];qt&&(this.markUsedJustification(i,"left",ae,qt),this.markUsedOrientation(i,qt,ae))}if(ft){const Mt=Et?ca:bc(Ue.icon),{placedIconSymbolIndex:vt,verticalPlacedIconSymbolIndex:St}=ae,Vt=i.icon.placedSymbolArray,Yt=Ue.icon.isHidden()?1:0;vt>=0&&(le(i.icon,Ne,ct?ca:Mt),Vt.get(vt).hidden=Yt),St>=0&&(le(i.icon,ae.numVerticalIconVertices,et?ca:Mt),Vt.get(St).hidden=Yt)}if(i.hasIconCollisionBoxData()||i.hasTextCollisionBoxData()){const Mt=i.collisionArrays[re];if(Mt){let vt=new a.P(0,0),St=!0;if(Mt.textBox||Mt.verticalTextBox){if(U){const Yt=this.variableOffsets[ve];Yt?(vt=Wr(Yt.anchor,Yt.width,Yt.height,Yt.textOffset,Yt.textScale),X&&vt._rotate(W?this.transform.angle:-this.transform.angle)):St=!1}O&&(St=!Ue.clipped),Mt.textBox&&bl(i.textCollisionBox.collisionVertexArray,Ue.text.placed,!St||ct,we,ne,vt.x,vt.y),Mt.verticalTextBox&&bl(i.textCollisionBox.collisionVertexArray,Ue.text.placed,!St||et,we,ne,vt.x,vt.y)}const Vt=St&&!!(!et&&Mt.verticalIconBox);Mt.iconBox&&bl(i.iconCollisionBox.collisionVertexArray,Ue.icon.placed,Vt,we,ne,ae.hasIconTextFit?vt.x:0,ae.hasIconTextFit?vt.y:0),Mt.verticalIconBox&&bl(i.iconCollisionBox.collisionVertexArray,Ue.icon.placed,!Vt,we,ne,ae.hasIconTextFit?vt.x:0,ae.hasIconTextFit?vt.y:0)}}}if(i.fullyClipped=_e===0,i.sortFeatures(this.transform.angle),this.retainedQueryData[i.bucketInstanceId]&&(this.retainedQueryData[i.bucketInstanceId].featureSortOrder=i.featureSortOrder),i.hasTextData()&&i.text.opacityVertexBuffer&&i.text.opacityVertexBuffer.updateData(i.text.opacityVertexArray),i.hasIconData()&&i.icon.opacityVertexBuffer&&i.icon.opacityVertexBuffer.updateData(i.icon.opacityVertexArray),i.hasIconCollisionBoxData()&&i.iconCollisionBox.collisionVertexBuffer&&i.iconCollisionBox.collisionVertexBuffer.updateData(i.iconCollisionBox.collisionVertexArray),i.hasTextCollisionBoxData()&&i.textCollisionBox.collisionVertexBuffer&&i.textCollisionBox.collisionVertexBuffer.updateData(i.textCollisionBox.collisionVertexArray),i.bucketInstanceId in this.collisionCircleArrays){const re=this.collisionCircleArrays[i.bucketInstanceId];i.placementInvProjMatrix=re.invProjMatrix,i.placementViewportMatrix=re.viewportMatrix,i.collisionCircleArray=re.circles,delete this.collisionCircleArrays[i.bucketInstanceId]}}symbolFadeChange(i){return this.fadeDuration===0?1:(i-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(i){return Math.max(0,(this.transform.zoom-i)/1.5)}hasTransitions(i){return i-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(i,o){const d=this.zoomAtLastRecencyCheck===o?1-this.zoomAdjustment(o):1;return this.zoomAtLastRecencyCheck=o,this.commitTime+this.fadeDuration*d>i}isStale(){return this.stale}setStale(){this.stale=!0}}function bl(u,i,o,d,m,y,v){u.emplaceBack(i?1:0,o?1:0,y||0,v||0,d,m?1:0),u.emplaceBack(i?1:0,o?1:0,y||0,v||0,d,m?1:0),u.emplaceBack(i?1:0,o?1:0,y||0,v||0,d,m?1:0),u.emplaceBack(i?1:0,o?1:0,y||0,v||0,d,m?1:0)}const Lu=Math.pow(2,25),zu=Math.pow(2,24),Vr=Math.pow(2,17),Gn=Math.pow(2,16),d1=Math.pow(2,9),ku=Math.pow(2,8),Np=Math.pow(2,1);function bc(u){if(u.opacity===0&&!u.placed)return 0;if(u.opacity===1&&u.placed)return 4294967295;const i=u.placed?1:0,o=Math.floor(127*u.opacity);return o*Lu+i*zu+o*Vr+i*Gn+o*d1+i*ku+o*Np+i}const ca=0;class Vp{constructor(i){this._sortAcrossTiles=i.layout.get("symbol-z-order")!=="viewport-y"&&i.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(i,o,d,m,y,v){const w=this._bucketParts;for(;this._currentTileIndex<i.length;)if(o.getBucketParts(w,m,i[this._currentTileIndex],this._sortAcrossTiles,v),this._currentTileIndex++,y())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,w.sort((E,P)=>E.sortKey-P.sortKey));this._currentPartIndex<w.length;){const E=w[this._currentPartIndex];if(o.placeLayerBucketPart(E,this._seenCrossTileIDs,d,E.symbolInstanceStart===0,v),this._currentPartIndex++,y())return!0}return!1}}class Fu{startNewPlacement(i,o,d,m,y,v,w,E){return this.placement=new Oi(i,m,y,v,w,E),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=!1,this._showCollisionBoxes=d,this._fadeDuration=m,this._done=!1,this._inProgressLayer=null,this}requestFullPlacement(){this._forceFullPlacement=!0}isFullPlacementRequested(){return this._forceFullPlacement}setStale(){this.placement&&(this.placement.stale=!0)}isStale(){return!!this.placement&&this.placement.stale}isDone(){return this._done}continuePlacement(i,o,d,m,y){const v=a.o.now(),w=()=>{const E=a.o.now()-v;return!this.isFullPlacementRequested()&&this._fadeDuration!==0&&E>2};for(;this._currentPlacementIndex>=0;){const E=o[i[this._currentPlacementIndex]],P=this.placement.collisionIndex.transform.zoom;if(E.type==="symbol"&&E.visibility!=="none"&&(!E.minzoom||E.minzoom<=P)&&(!E.maxzoom||E.maxzoom>P)){const R=E,O=R.layout.get("symbol-z-elevate"),k=R.layout.get("symbol-sort-key").constantOr(1)!==void 0,N=R.layout.get("symbol-z-order"),j=N==="viewport-y"||N==="auto"&&!(N!=="viewport-y"&&k),U=R.layout.get("text-allow-overlap")||R.layout.get("icon-allow-overlap")||R.layout.get("text-ignore-placement")||R.layout.get("icon-ignore-placement"),X=j&&U,W=this._inProgressLayer=this._inProgressLayer||new Vp(R),ie=a.F(E.source,E.scope);if(W.continuePlacement(O||X?m[ie]:d[ie],this.placement,this._showCollisionBoxes,E,w,y))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._forceFullPlacement=!1,this._done=!0}commit(i){return this.placement.commit(i),this.placement}}const Lr=512/a.an/2;class Ks{constructor(i,o,d){this.tileID=i,this.bucketInstanceId=d,this.index=new a.bI(o.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const m=i.canonical.x*a.an,y=i.canonical.y*a.an;for(let v=0;v<o.length;v++){const{key:w,crossTileID:E,tileAnchorX:P,tileAnchorY:R}=o.get(v),O=Math.floor((m+P)*Lr),k=Math.floor((y+R)*Lr);this.index.add(O,k),this.keys.push(w),this.crossTileIDs.push(E)}this.index.finish()}findMatches(i,o,d){const m=this.tileID.canonical.z<o.canonical.z?1:Math.pow(2,this.tileID.canonical.z-o.canonical.z),y=Lr/Math.pow(2,o.canonical.z-this.tileID.canonical.z),v=o.canonical.x*a.an,w=o.canonical.y*a.an;for(let E=0;E<i.length;E++){const P=i.get(E);if(P.crossTileID)continue;const{key:R,tileAnchorX:O,tileAnchorY:k}=P,N=Math.floor((v+O)*y),j=Math.floor((w+k)*y),U=this.index.range(N-m,j-m,N+m,j+m).sort((X,W)=>X-W);for(const X of U){const W=this.crossTileIDs[X];if(this.keys[X]===R&&!d.has(W)){d.add(W),P.crossTileID=W;break}}}}}class is{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ry{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(i){const o=Math.round((i-this.lng)/360);if(o!==0)for(const d in this.indexes){const m=this.indexes[d],y={};for(const v in m){const w=m[v];w.tileID=w.tileID.unwrapTo(w.tileID.wrap+o),y[w.tileID.key]=w}this.indexes[d]=y}this.lng=i}addBucket(i,o,d){if(this.indexes[i.overscaledZ]&&this.indexes[i.overscaledZ][i.key]){if(this.indexes[i.overscaledZ][i.key].bucketInstanceId===o.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(i.overscaledZ,this.indexes[i.overscaledZ][i.key])}for(let y=0;y<o.symbolInstances.length;y++)o.symbolInstances.get(y).crossTileID=0;this.usedCrossTileIDs[i.overscaledZ]||(this.usedCrossTileIDs[i.overscaledZ]=new Set);const m=this.usedCrossTileIDs[i.overscaledZ];for(const y in this.indexes){const v=this.indexes[y];if(Number(y)>i.overscaledZ)for(const w in v){const E=v[w];E.tileID.isChildOf(i)&&E.findMatches(o.symbolInstances,i,m)}else{const w=v[i.scaledTo(Number(y)).key];w&&w.findMatches(o.symbolInstances,i,m)}}for(let y=0;y<o.symbolInstances.length;y++){const v=o.symbolInstances.get(y);v.crossTileID||(v.crossTileID=d.generate(),m.add(v.crossTileID))}return this.indexes[i.overscaledZ]===void 0&&(this.indexes[i.overscaledZ]={}),this.indexes[i.overscaledZ][i.key]=new Ks(i,o.symbolInstances,o.bucketInstanceId),!0}removeBucketCrossTileIDs(i,o){for(const d of o.crossTileIDs)this.usedCrossTileIDs[i].delete(d)}removeStaleBuckets(i){let o=!1;for(const d in this.indexes){const m=this.indexes[d];for(const y in m)i[m[y].bucketInstanceId]||(this.removeBucketCrossTileIDs(d,m[y]),delete m[y],o=!0)}return o}}class wc{constructor(){this.layerIndexes={},this.crossTileIDs=new is,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(i,o,d,m){let y=this.layerIndexes[i.fqid];y===void 0&&(y=this.layerIndexes[i.fqid]=new ry);let v=!1;const w={};m.name!=="globe"&&y.handleWrapJump(d);for(const E of o){const P=E.getBucket(i);P&&i.fqid===P.layerIds[0]&&(P.bucketInstanceId||(P.bucketInstanceId=++this.maxBucketInstanceId),y.addBucket(E.tileID,P,this.crossTileIDs)&&(v=!0),w[P.bucketInstanceId]=!0)}return y.removeStaleBuckets(w)&&(v=!0),v}pruneUnusedLayers(i){const o={};i.forEach(d=>{o[d]=!0});for(const d in this.layerIndexes)o[d]||delete this.layerIndexes[d]}}const Pn=771;class jt{constructor(i,o,d,m){this.blendFunction=i,this.blendColor=o.toNonPremultipliedRenderColor(null),this.mask=d,this.blendEquation=m}}jt.Replace=[1,0,1,0],jt.disabled=new jt(jt.Replace,a.aq.transparent,[!1,!1,!1,!1]),jt.unblended=new jt(jt.Replace,a.aq.transparent,[!0,!0,!0,!0]),jt.alphaBlended=new jt([1,Pn,1,Pn],a.aq.transparent,[!0,!0,!0,!0]),jt.alphaBlendedNonPremultiplied=new jt([770,Pn,770,Pn],a.aq.transparent,[!0,!0,!0,!0]),jt.multiply=new jt([774,0,774,0],a.aq.transparent,[!0,!0,!0,!0]),jt.multiplyAccumulateAlpha=new jt([774,0,1,Pn],a.aq.transparent,[!0,!0,!0,!0]),jt.additive=new jt([1,1,1,1],a.aq.transparent,[!0,!0,!0,!0]);class At{constructor(i,o,d){this.func=i,this.mask=o,this.range=d}}At.ReadOnly=!1,At.ReadWrite=!0,At.disabled=new At(519,At.ReadOnly,[0,1]);const Nn=7680;class Ht{constructor(i,o,d,m,y,v){this.test=i,this.ref=o,this.mask=d,this.fail=m,this.depthFail=y,this.pass=v}}Ht.disabled=new Ht({func:519,mask:0},0,0,Nn,Nn,Nn);const Cs=1029,wl=2305;class Nt{constructor(i,o,d){this.enable=i,this.mode=o,this.frontFace=d}}function Ou(u,i){const o=a.bO(u,3);a.bR(u,i),a.bW(u,3,o)}function md(u,i){const o=a.bL([]);return a.bM(o,o,-i),a.bN(o,o,-u),o}function _d(u,i){const o=[u[0],u[1],0],d=[i[0],i[1],0];if(a.ai(o)>=1e-15){const v=a.ay([],o);a.bJ(d,v,a.bi(d,v)),i[0]=d[0],i[1]=d[1]}const m=a.bh([],i,u);if(a.bK(m)<1e-15)return null;const y=Math.atan2(-m[1],m[0]);return md(Math.atan2(Math.sqrt(u[0]*u[0]+u[1]*u[1]),-u[2]),y)}Nt.disabled=new Nt(!1,Cs,wl),Nt.backCCW=new Nt(!0,Cs,wl),Nt.backCW=new Nt(!0,Cs,2304),Nt.frontCW=new Nt(!0,1028,2304),Nt.frontCCW=new Nt(!0,1028,wl);class Bu{constructor(i,o){this.position=i,this.orientation=o}get position(){return this._position}set position(i){if(i){const o=i instanceof a.ag?i:new a.ag(i[0],i[1],i[2]);this._renderWorldCopies&&(o.x=a.bs(o.x,0,1)),this._position=o}else this._position=null}lookAtPoint(i,o,d){if(this.orientation=null,!this.position)return;const m=this.position,y=d||(this._elevation?this._elevation.getAtPointOrZero(a.ag.fromLngLat(i)):0),v=a.ag.fromLngLat(i,y),w=[v.x-m.x,v.y-m.y,v.z-m.z];o||(o=[0,0,1]),o[2]=Math.abs(o[2]),this.orientation=_d(w,o)}setPitchBearing(i,o){this.orientation=md(a.ap(i),a.ap(-o))}}class Nu{constructor(i,o){this._transform=a.b9([]),this.orientation=o,this.position=i}get mercatorPosition(){const i=this.position;return new a.ag(i[0],i[1],i[2])}get position(){const i=a.bO(this._transform,3);return[i[0],i[1],i[2]]}set position(i){var o;i&&a.bW(this._transform,3,[(o=i)[0],o[1],o[2],1])}get orientation(){return this._orientation}set orientation(i){this._orientation=i||a.bL([]),i&&Ou(this._transform,this._orientation)}getPitchBearing(){const i=this.forward(),o=this.right();return{bearing:Math.atan2(-o[1],o[0]),pitch:Math.atan2(Math.sqrt(i[0]*i[0]+i[1]*i[1]),-i[2])}}setPitchBearing(i,o){this._orientation=md(i,o),Ou(this._transform,this._orientation)}forward(){const i=a.bO(this._transform,2);return[-i[0],-i[1],-i[2]]}up(){const i=a.bO(this._transform,1);return[-i[0],-i[1],-i[2]]}right(){const i=a.bO(this._transform,0);return[i[0],i[1],i[2]]}getCameraToWorld(i,o){const d=new Float64Array(16);return a.b7(d,this.getWorldToCamera(i,o)),d}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(i,o,d){const m=this.position;a.bJ(m,m,-i);const y=new Float64Array(16);return a.bP(y,[d,d,d]),a.bx(y,y,m),y[10]*=o,y}getWorldToCamera(i,o){const d=new Float64Array(16),m=new Float64Array(4),y=this.position;return a.bQ(m,this._orientation),a.bJ(y,y,-i),a.bR(d,m),a.bx(d,d,y),d[1]*=-1,d[5]*=-1,d[9]*=-1,d[13]*=-1,d[8]*=o,d[9]*=o,d[10]*=o,d[11]*=o,d}getCameraToClipPerspective(i,o,d,m){const y=new Float64Array(16);return a.bS(y,i,o,d,m),y}getCameraToClipOrthographic(i,o,d,m,y,v){const w=new Float64Array(16);return a.bT(w,i,o,d,m,y,v),w}getDistanceToElevation(i,o=!1){const d=i===0?0:a.bU(i,o?a.bV(this.position[1]):this.position[1]),m=this.forward();return(d-this.position[2])/m[2]}clone(){return new Nu([...this.position],[...this.orientation])}}const f1=(u,i)=>({u_matrix:u,u_ground_shadow_factor:i});class po{constructor(i=0,o=0,d=0,m=0){if(isNaN(i)||i<0||isNaN(o)||o<0||isNaN(d)||d<0||isNaN(m)||m<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=i,this.bottom=o,this.left=d,this.right=m}interpolate(i,o,d){return o.top!=null&&i.top!=null&&(this.top=a.am(i.top,o.top,d)),o.bottom!=null&&i.bottom!=null&&(this.bottom=a.am(i.bottom,o.bottom,d)),o.left!=null&&i.left!=null&&(this.left=a.am(i.left,o.left,d)),o.right!=null&&i.right!=null&&(this.right=a.am(i.right,o.right,d)),this}getCenter(i,o){const d=a.aC((this.left+i-this.right)/2,0,i),m=a.aC((this.top+o-this.bottom)/2,0,o);return new a.P(d,m)}equals(i){return this.top===i.top&&this.bottom===i.bottom&&this.left===i.left&&this.right===i.right}clone(){return new po(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Tl=15;class Vu{constructor(i,o,d,m,y,v,w){this.tileSize=512,this._renderWorldCopies=y===void 0||y,this._minZoom=i||0,this._maxZoom=o||22,this._minPitch=d??0,this._maxPitch=m??60,this.setProjection(v),this.setMaxBounds(w),this.width=0,this.height=0,this._center=new a.aU(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new po,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Nu,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,this._allowWorldUnderZoom=!1}clone(){const i=new Vu(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);return i._elevation=this._elevation,i._centerAltitude=this._centerAltitude,i._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,i.tileSize=this.tileSize,i.mercatorFromTransition=this.mercatorFromTransition,i.width=this.width,i.height=this.height,i.cameraElevationReference=this.cameraElevationReference,i._center=this._center,i._setZoom(this.zoom),i._seaLevelZoom=this._seaLevelZoom,i.angle=this.angle,i._fov=this._fov,i._pitch=this._pitch,i._nearZ=this._nearZ,i._farZ=this._farZ,i._nearClipOffset=this._nearClipOffset,i._averageElevation=this._averageElevation,i._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,i._unmodified=this._unmodified,i._edgeInsets=this._edgeInsets.clone(),i._camera=this._camera.clone(),i._calcMatrices(),i.freezeTileCoverage=this.freezeTileCoverage,i.frustumCorners=this.frustumCorners,i._allowWorldUnderZoom=this._allowWorldUnderZoom,i}get isOrthographic(){return this.projection.name!=="globe"&&this._orthographicProjectionAtLowPitch&&this.pitch<Tl}get elevation(){return this._elevation}set elevation(i){this._elevation!==i&&(this._elevation=i,this._updateCameraOnTerrain(),this._calcMatrices())}get nearClipOffset(){return this._nearClipOffset}set nearClipOffset(i){this._nearClipOffset=i,this._calcMatrices()}get depthOcclusionForSymbolsAndCircles(){return this.projection.name!=="globe"&&!this.isOrthographic}updateElevation(i,o=!1){const d=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||d)&&this._updateCameraOnTerrain(),(i||d)&&this._constrainCamera(o),this._calcMatrices()}getProjection(){return a.aJ(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};const o=this.projection?this.getProjection():void 0;this.projection=a.c0(this.projectionOptions);const d=this.getProjection(),m=!a.b6(o,d);return m&&this._calcMatrices(),this.mercatorFromTransition=!1,m}setOrthographicProjectionAtLowPitch(i){return this._orthographicProjectionAtLowPitch!==i&&(this._orthographicProjectionAtLowPitch=i,this._calcMatrices(),!0)}setMercatorFromTransition(){const i=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=a.c0({name:"mercator"});const o=i!==this.projection.name;return o&&this._calcMatrices(),o}get minZoom(){return this._minZoom}set minZoom(i){this._minZoom!==i&&(this._minZoom=i,this.zoom=Math.max(this.zoom,i))}get maxZoom(){return this._maxZoom}set maxZoom(i){this._maxZoom!==i&&(this._maxZoom=i,this.zoom=Math.min(this.zoom,i))}get minPitch(){return this._minPitch}set minPitch(i){this._minPitch!==i&&(this._minPitch=i,this.pitch=Math.max(this.pitch,i))}get maxPitch(){return this._maxPitch}set maxPitch(i){this._maxPitch!==i&&(this._maxPitch=i,this.pitch=Math.min(this.pitch,i))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(i){i===void 0?i=!0:i===null&&(i=!1),this._renderWorldCopies=i}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const i=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(i))}get cameraWorldSize(){const i=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(i))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return a.bU(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.P(this.width,this.height)}get bearing(){return a.bs(this.rotation,-180,180)}set bearing(i){this.rotation=i}get rotation(){return-this.angle/Math.PI*180}set rotation(i){const o=-i*Math.PI/180;this.angle!==o&&(this._unmodified=!1,this.angle=o,this._calcMatrices(),this.rotationMatrix=a.c1(),a.c2(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(i){const o=a.aC(i,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==o&&(this._unmodified=!1,this._pitch=o,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}set fov(i){i=Math.max(.01,Math.min(60,i)),this._fov!==i&&(this._unmodified=!1,this._fov=a.ap(i),this._calcMatrices())}get fovX(){return this._fov}get fovY(){const i=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/i)}get averageElevation(){return this._averageElevation}set averageElevation(i){this._averageElevation=i,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(i){const o=Math.min(Math.max(i,this.minZoom),this.maxZoom);this._zoom!==o&&(this._unmodified=!1,this._setZoom(o),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(i){this._zoom=i,this.scale=this.zoomScale(i),this.tileZoom=Math.floor(i),this.zoomFraction=i-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(i){this._tileCoverLift!==i&&(this._tileCoverLift=i)}_updateCameraOnTerrain(){const i=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,o=this.elevation&&i===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||i===Number.NEGATIVE_INFINITY&&(!o||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const d=this._elevation;o||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&d.exaggeration()&&this._centerAltitudeValidForExaggeration!==d.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*d.exaggeration(),this._centerAltitudeValidForExaggeration=d.exaggeration()):(this._centerAltitude=i||0,this._centerAltitudeValidForExaggeration=d.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){if(this._centerAltitudeValidForExaggeration===void 0)return;const i=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(i)}sampleAverageElevation(){if(!this._elevation)return 0;const i=this._elevation,o=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],d=this.horizonLineFromTop();let m=0,y=0;for(let v=0;v<o.length;v++){const w=new a.P(o[v][0]*this.width,d+o[v][1]*(this.height-d)),E=i.pointCoordinate(w);if(!E)continue;const P=1/Math.hypot(E[0]-this._camera.position[0],E[1]-this._camera.position[1]);m+=E[3]*P,y+=P}return y===0?NaN:m/y}get center(){return this._center}set center(i){i.lat===this._center.lat&&i.lng===this._center.lng||(this._unmodified=!1,this._center=i,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const i=this._seaLevelZoom,o=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),d=this.pixelsPerMeter/this.worldSize*o,m=this._mercatorZfromZoom(i),y=this._mercatorZfromZoom(this._maxZoom),v=Math.max(m-d,y);this._setZoom(this._zoomFromMercatorZ(v))}get padding(){return this._edgeInsets.toJSON()}set padding(i){this._edgeInsets.equals(i)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,i,1),this._calcMatrices())}equals(i){const o=this.elevation,d=i.elevation,m=o!=null!=(d!=null)||o&&d&&o.exaggeration()!==d.exaggeration();return this.width===i.width&&this.height===i.height&&this.center.lng===i.center.lng&&this.center.lat===i.center.lat&&this.zoom===i.zoom&&this.bearing===i.bearing&&this.pitch===i.pitch&&this.fov===i.fov&&this.projection.name===i.projection.name&&this._edgeInsets.equals(i.padding)&&!m}computeZoomRelativeTo(i){const o=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,i.toAltitude()));let d;d=i.z<this._camera.position[2]?[o.x,o.y,o.z]:[i.x,i.y,i.z];const m=a.ai(a.ax([],this._camera.position,d));return a.aC(this._zoomFromMercatorZ(m),this._minZoom,this._maxZoom)}setFreeCameraOptions(i){if(!this.height||!i.position&&!i.orientation)return;this._updateCameraState();let o=!1;if(i.orientation&&!a.c3(i.orientation,this._camera.orientation)&&(o=this._setCameraOrientation(i.orientation)),i.position){const d=[i.position.x,i.position.y,i.position.z];a.c4(d,this._camera.position)||(this._setCameraPosition(d),o=!0)}o&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const i=this._camera.position,o=new Bu;return o.position=new a.ag(i[0],i[1],i[2]),o.orientation=this._camera.orientation,o._elevation=this.elevation,o._renderWorldCopies=this.renderWorldCopies,o}_setCameraOrientation(i){if(!a.c5(i))return!1;a.c6(i,i);const o=a.c7([],[0,0,-1],i),d=a.c7([],[0,-1,0],i);if(d[2]<0)return!1;const m=_d(o,d);return!!m&&(this._camera.orientation=m,!0)}_setCameraPosition(i){const o=this.zoomScale(this.minZoom)*this.tileSize,d=this.zoomScale(this.maxZoom)*this.tileSize,m=this.cameraToCenterDistance;i[2]=a.aC(i[2],m/d,m/o),this._camera.position=i}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(i){return this._edgeInsets.equals(i)}interpolatePadding(i,o,d){this._unmodified=!1,this._edgeInsets.interpolate(i,o,d),this._constrain(),this._calcMatrices()}coveringZoomLevel(i){const o=(i.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/i.tileSize));return Math.max(0,o)}getVisibleUnwrappedCoordinates(i){const o=[new a.c8(0,i)];if(this.renderWorldCopies){const d=this.pointCoordinate(new a.P(0,0)),m=this.pointCoordinate(new a.P(this.width,0)),y=this.pointCoordinate(new a.P(this.width,this.height)),v=this.pointCoordinate(new a.P(0,this.height)),w=Math.floor(Math.min(d.x,m.x,y.x,v.x)),E=Math.floor(Math.max(d.x,m.x,y.x,v.x)),P=1;for(let R=w-P;R<=E+P;R++)R!==0&&o.push(new a.c8(R,i))}return o}isLODDisabled(i){return(!i||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(i,o,d,m){let y=[];const v=d!=null,w=!v;if(w&&this.zoom<o||v&&d[0]===0&&d[1]===0)return y;const E=new Set,P=(O,k,N,j,U)=>{const X=a.ck(k,O,N,j,U);E.has(X)||(y.push(new a.aR(O,k,N,j,U)),E.add(X))};for(let O=0;O<i.length;O++){const k=i[O];if(w&&k.canonical.z!==o||v&&m!==void 0&&m>k.canonical.z)continue;const N=k.canonical,j=k.overscaledZ,U=k.wrap,X=1<<N.z,W=N.x+1<X,ie=N.x>0,ne=N.y+1<X,K=N.y>0,xe=k.wrap-(ie?0:1),le=k.wrap+(W?0:1),_e=ie?N.x-1:X-1,re=W?N.x+1:0;if(v)d[0]<0?(P(j,le,N.z,re,N.y),d[1]<0&&ne&&(P(j,U,N.z,N.x,N.y+1),P(j,le,N.z,re,N.y+1)),d[1]>0&&K&&(P(j,U,N.z,N.x,N.y-1),P(j,le,N.z,re,N.y-1))):d[0]>0?(P(j,xe,N.z,_e,N.y),d[1]<0&&ne&&(P(j,U,N.z,N.x,N.y+1),P(j,xe,N.z,_e,N.y+1)),d[1]>0&&K&&(P(j,U,N.z,N.x,N.y-1),P(j,xe,N.z,_e,N.y-1))):d[1]<0&&ne?P(j,U,N.z,N.x,N.y+1):K&&P(j,U,N.z,N.x,N.y-1);else{const ae=k.visibleQuadrants;1&ae&&(P(j,xe,N.z,_e,N.y),K&&(P(j,U,N.z,N.x,N.y-1),P(j,xe,N.z,_e,N.y-1))),2&ae&&(P(j,le,N.z,re,N.y),K&&(P(j,U,N.z,N.x,N.y-1),P(j,le,N.z,re,N.y-1))),4&ae&&(P(j,xe,N.z,_e,N.y),ne&&(P(j,U,N.z,N.x,N.y+1),P(j,xe,N.z,_e,N.y+1))),8&ae&&(P(j,le,N.z,re,N.y),ne&&(P(j,U,N.z,N.x,N.y+1),P(j,le,N.z,re,N.y+1)))}}const R=[];for(const O of y)y.some(k=>O.isChildOf(k))||R.push(O);if(y=R.filter(O=>!i.some(k=>!!(O.overscaledZ<o&&k.isChildOf(O))||O.equals(k)||O.isChildOf(k))),w){const O=1<<o,k=this.projection.name==="globe"?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),N=[O*k.x,O*k.y],j=4,U=j*j;y=y.filter(X=>{const W=X.canonical.x+.5-N[0],ie=X.canonical.y+.5-N[1];return W*W+ie*ie<U})}return y}extendTileCoverToNearPlane(i,o,d){const m=[],y=new Set;for(const ie of i)y.add(ie.key);const v=(ie,ne,K,xe,le)=>{const _e=a.ck(ne,ie,K,xe,le);y.has(_e)||(m.push(new a.aR(ie,ne,K,xe,le)),y.add(_e))},w=i.reduce((ie,ne)=>Math.max(ie,ne.overscaledZ),d),E=1<<d,P=[new a.P(0,0),new a.P(a.an,0),new a.P(a.an,a.an),new a.P(0,a.an)],R=new a.P(0,0),O=new a.P(0,0),k=(ie,ne)=>{const K=Math.floor(ie[0]),xe=Math.floor(ie[1]),le=(ie[0]-K)*a.an,_e=(ie[1]-xe)*a.an,re=Math.floor(ne[0]),ae=Math.floor(ne[1]),fe=(ne[0]-re)*a.an,Ce=(ne[1]-ae)*a.an;for(let ve=-1;ve<=1;ve++){const Ne=K+ve;if(!(Ne<0||Ne>=E)){R.x=le-ve*a.an,O.x=fe-(Ne-re)*a.an;for(let ze=-1;ze<=1;ze++){const Je=xe+ze;R.y=_e-ze*a.an,O.y=Ce-(Je-ae)*a.an,a.cI(R,O,P)&&v(w,0,d,Ne,Je)}}}},N=o.points,j=N[a.c9],U=N[a.ca],X=this._projectToGround(j,N[a.cb]),W=this._projectToGround(U,N[a.cc]);return k(j,X),k(U,W),m}_projectToGround(i,o){return a.cd(a.ce(),i,o,i[2]/(i[2]-o[2]))}_projectToZ(i,o,d){const m=i[2]-o[2];return Math.abs(m)<1e-6?a.cf(i):a.cd(a.ce(),i,o,(i[2]-d)/m)}extendTileCoverForTunnels(i,o,d,m){if(d<18)return[];const y=o.points,v=y[a.cg],w=y[a.ch],E=y[a.ci],P=y[a.cj];if(E[2]>=0&&P[2]>=0||v[2]<=0||w[2]<=0)return[];const R=E[2]<0?this._projectToZ(v,E,0):E,O=P[2]<0?this._projectToZ(w,P,0):P,k=-m,N=E[2]<k?this._projectToZ(v,E,k):E,j=P[2]<k?this._projectToZ(w,P,k):P,U=this._findExtensionTilesInQuad(i,d,[j,N,O,R],[.5*(R[0]+O[0]),.5*(R[1]+O[1])]);return U.length>3&&(U.length=3),U}_findExtensionTilesInQuad(i,o,d,m){const y=[],v=new Set;for(const re of i)v.add(re.key);const w=i.reduce((re,ae)=>Math.max(re,ae.overscaledZ),o),E=1<<o,P=[new a.P(d[0][0],d[0][1]),new a.P(d[1][0],d[1][1]),new a.P(d[3][0],d[3][1]),new a.P(d[2][0],d[2][1]),new a.P(d[0][0],d[0][1])],R=d[0][0],O=d[1][0],k=d[2][0],N=d[3][0],j=d[0][1],U=d[1][1],X=d[2][1],W=d[3][1],ie=Math.max(0,Math.floor(Math.min(R,O,k,N))),ne=Math.min(E-1,Math.ceil(Math.max(R,O,k,N))-1),K=Math.max(0,Math.floor(Math.min(j,U,X,W))),xe=Math.min(E-1,Math.ceil(Math.max(j,U,X,W))-1);for(let re=K;re<=xe;re++)for(let ae=ie;ae<=ne;ae++){if(!a.av(P,ae,re,ae+1,re+1))continue;const fe=a.ck(0,w,o,ae,re);v.has(fe)||(y.push(new a.aR(w,0,o,ae,re)),v.add(fe))}const le=m[0],_e=m[1];return y.sort((re,ae)=>{const fe=re.canonical.x+.5-le,Ce=re.canonical.y+.5-_e,ve=ae.canonical.x+.5-le,Ne=ae.canonical.y+.5-_e;return fe*fe+Ce*Ce-(ve*ve+Ne*Ne)||re.canonical.x-ae.canonical.x||re.canonical.y-ae.canonical.y}),y}coveringTiles(i){let o=this.coveringZoomLevel(i);const d=o,m=this.elevation&&this.elevation.exaggeration(),y=m&&!i.isTerrainDEM,v=this.projection.name==="mercator";if(i.minzoom!==void 0&&o<i.minzoom)return[];i.maxzoom!==void 0&&o>i.maxzoom&&(o=i.maxzoom);const w=this.locationCoordinate(this.center),E=this.center.lat,P=1<<o,R=[P*w.x,P*w.y,0],O=this.projection.name==="globe",k=!O,N=a.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,o,k),j=O?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),U=P*a.bU(1,this.center.lat),X=this._camera.position[2]/a.bU(1,this.center.lat),W=[P*j.x,P*j.y,X*(k?1:U)],ie=O||m,ne=this.cameraToCenterDistance/i.tileSize*(i.roundZoom?1:.502),K=this.isLODDisabled(!0)?o:0;let xe;if(this._elevation&&i.isTerrainDEM)xe=1e4*this._elevation.exaggeration();else if(this._elevation){const we=this._elevation.getMinMaxForVisibleTiles();xe=we?we.max:this._centerAltitude}else xe=this._centerAltitude;const le=i.isTerrainDEM?-xe:this._elevation?this._elevation.getMinElevationBelowMSL():0,_e=this.projection.isReprojectedInTileSpace?a.cm(this):1,re=we=>{const Ue=new a.ag(we.x+25e-6,we.y,we.z),$e=new a.ag(we.x,we.y+25e-6,we.z),ft=we.toLngLat(),lt=Ue.toLngLat(),ct=$e.toLngLat(),et=this.locationCoordinate(ft),Et=this.locationCoordinate(lt),Mt=this.locationCoordinate(ct),vt=Math.hypot(Et.x-et.x,Et.y-et.y),St=Math.hypot(Mt.x-et.x,Mt.y-et.y);return Math.sqrt(vt*St)*_e/25e-6},ae=we=>{const Oe=xe,Ue=le;return{aabb:a.cp(this,P,0,0,0,we,Ue,Oe,this.projection),zoom:0,x:0,y:0,minZ:Ue,maxZ:Oe,wrap:we,fullyVisible:!1}},fe=[];let Ce=[];const ve=o,Ne=i.reparseOverscaled?d:o,ze=(X-this._centerAltitude)*U,Je=we=>{if(!this._elevation||!we.tileID||!v)return;const Oe=this._elevation.getMinMaxForTile(we.tileID),Ue=we.aabb;Oe?(Ue.min[2]=Oe.min,Ue.max[2]=Oe.max,Ue.center[2]=(Ue.min[2]+Ue.max[2])/2):(we.shouldSplit=Pe(we),we.shouldSplit||(Ue.min[2]=Ue.max[2]=Ue.center[2]=this._centerAltitude))},tt=(we,Oe)=>{if(.707*Oe<we)return 1;const Ue=Oe/we;return Ue/(1.4144271570014144+(Math.pow(1.1,Ue-1.4144271570014144+1)-1)/(1.1-1)-1)},Pe=we=>{if(we.zoom<K)return!0;if(we.zoom===ve)return!1;if(we.shouldSplit!=null)return we.shouldSplit;const Oe=we.aabb.distanceX(W),Ue=we.aabb.distanceY(W);let $e=ze,ft=1;if(O){$e=we.aabb.distanceZ(W);const St=Math.pow(2,we.zoom),Vt=a.bV((we.y+1)/St),Yt=a.bV(we.y/St),Zt=Math.min(Math.max(E,Vt),Yt),si=a.cM(Zt)/a.cM(E);if(ft=Zt===E?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,si/this._mercatorScaleRatio),this.zoom<=a.cJ&&we.zoom===ve-1&&si>=.9)return!0}else if(y&&($e=we.aabb.distanceZ(W)*U),this.projection.isReprojectedInTileSpace&&d<=5){const St=Math.pow(2,we.zoom),Vt=re(new a.ag((we.x+.5)/St,(we.y+.5)/St));ft=Vt>.85?1:Vt}if(!v&&!O){const St=Math.sqrt(Oe*Oe+Ue*Ue+$e*$e);let Vt=(1<<ve-we.zoom)*ne*ft;return Vt*=tt(Math.max($e,ze),St),St<Vt}let lt=Number.MAX_VALUE,ct=0;const et=we.aabb.getCorners(),Et=[];for(const St of et){a.ax(Et,St,W),O||(y?Et[2]*=U:Et[2]=ze);const Vt=a.bi(Et,this._camera.forward());Vt<lt&&(lt=Vt,ct=Math.abs(Et[2]))}let Mt=(1<<ve-we.zoom)*ne*ft;if(Mt*=tt(Math.max(ct,ze),lt),lt<Mt)return!0;const vt=we.aabb.closestPoint(R);return vt[0]===R[0]&&vt[1]===R[1]};if(this.renderWorldCopies)for(let we=1;we<=3;we++)fe.push(ae(-we)),fe.push(ae(we));for(fe.push(ae(0));fe.length>0;){const we=fe.pop(),Oe=we.x,Ue=we.y;let $e=we.fullyVisible;const ft=()=>this.projection.name==="globe"&&(we.y===0||we.y===(1<<we.zoom)-1);if(!$e){let lt=ie?we.aabb.intersects(N):we.aabb.intersectsFlat(N);if(lt===0&&ft()){const ct=new a.cn(we.zoom,Oe,Ue);lt=a.co(this,P,ct,!0).intersects(N)}if(lt===0)continue;$e=lt===2}if(we.zoom===ve||!Pe(we)){const lt=we.zoom===ve?Ne:we.zoom;if(i.minzoom&&i.minzoom>lt)continue;let ct=0;if(!$e){let vt=ie?we.aabb.intersectsPrecise(N):we.aabb.intersectsPreciseFlat(N);if(vt===0&&ft()){const St=new a.cn(we.zoom,Oe,Ue);vt=a.co(this,P,St,!0).intersectsPrecise(N)}if(vt===0)continue;if(i.calculateQuadrantVisibility)if(N.containsPoint(we.aabb.center))ct=15;else for(let St=0;St<4;St++)we.aabb.quadrant(St).intersects(N)!==0&&(ct|=1<<St)}const et=R[0]-(.5+Oe+(we.wrap<<we.zoom))*(1<<o-we.zoom),Et=R[1]-.5-Ue,Mt=we.tileID?we.tileID:new a.aR(lt,we.wrap,we.zoom,Oe,Ue);i.calculateQuadrantVisibility&&(Mt.visibleQuadrants=ct),Ce.push({tileID:Mt,distanceSq:et*et+Et*Et});continue}for(let lt=0;lt<4;lt++){const ct=(Oe<<1)+lt%2,et=(Ue<<1)+(lt>>1),Et={aabb:v?we.aabb.quadrant(lt):a.cp(this,P,we.zoom+1,ct,et,we.wrap,we.minZ,we.maxZ,this.projection),zoom:we.zoom+1,x:ct,y:et,wrap:we.wrap,fullyVisible:$e,tileID:void 0,shouldSplit:void 0,minZ:we.minZ,maxZ:we.maxZ};y&&!O&&(Et.tileID=new a.aR(we.zoom+1===ve?Ne:we.zoom+1,we.wrap,we.zoom+1,ct,et),Je(Et)),fe.push(Et)}}if(this.fogCullDistSq){const we=this.fogCullDistSq,Oe=this.horizonLineFromTop();Ce=Ce.filter(Ue=>{const $e=[0,0,0,1],ft=[a.an,a.an,0,1],lt=this.calculateFogTileMatrix(Ue.tileID.toUnwrapped());a.aE($e,$e,lt),a.aE(ft,ft,lt);const ct=a.cq([],$e,ft),et=a.cr([],$e,ft),Et=a.cK(ct,et);if(Et===0)return!0;let Mt=!1;const vt=this._elevation;if(vt&&Et>we&&Oe!==0){const St=this.calculateProjMatrix(Ue.tileID.toUnwrapped());let Vt;i.isTerrainDEM||(Vt=vt.getMinMaxForTile(Ue.tileID)),Vt||(Vt={min:le,max:xe});const Yt=a.cs(this.rotation),Zt=[Yt[0]*a.an,Yt[1]*a.an,Vt.max];a.ah(Zt,Zt,St),Mt=(1-Zt[1])*this.height*.5<Oe}return Et<we||Mt})}return Ce.sort((we,Oe)=>we.distanceSq-Oe.distanceSq).map(we=>we.tileID)}resize(i,o){this.width=i,this.height=o,this.pixelsToGLUnits=[2/i,-2/o],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(i){return Math.pow(2,i)}scaleZoom(i){return Math.log2(i)}project(i){const o=a.aC(i.lat,-a.ct,a.ct),d=this.projection.project(i.lng,o);return new a.P(d.x*this.worldSize,d.y*this.worldSize)}unproject(i){return this.projection.unproject(i.x/this.worldSize,i.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/a.bU(1,this.center.lat)/this.worldSize}setLocationAtPoint(i,o){let d,m;const y=this.centerPoint;if(this.projection.name==="globe"){const w=this.worldSize;d=(o.x-y.x)/w,m=(o.y-y.y)/w}else{const w=this.pointCoordinate(o),E=this.pointCoordinate(y);d=w.x-E.x,m=w.y-E.y}const v=this.locationCoordinate(i);this.setLocation(new a.ag(v.x-d,v.y-m))}setLocation(i){this.center=this.coordinateLocation(i),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(i,o){return this.projection.locationPoint(this,i,o)}locationPoint3D(i,o){return this.projection.locationPoint(this,i,o,!0)}pointLocation(i){return this.coordinateLocation(this.pointCoordinate(i))}pointLocation3D(i,o){return this.coordinateLocation(this.pointCoordinate3D(i,o))}locationCoordinate(i,o){const d=o?a.bU(o,i.lat):void 0,m=this.projection.project(i.lng,i.lat);return new a.ag(m.x,m.y,d)}coordinateLocation(i){return this.projection.unproject(i.x,i.y)}pointRayIntersection(i,o){const d=o??this._centerAltitude,m=[i.x,i.y,0,1],y=[i.x,i.y,1,1];a.aE(m,m,this.pixelMatrixInverse),a.aE(y,y,this.pixelMatrixInverse);const v=y[3];a.cu(m,m,1/m[3]),a.cu(y,y,1/v);const w=m[2],E=y[2];return{p0:m,p1:y,t:w===E?0:(d-w)/(E-w)}}screenPointToMercatorRay(i){const o=[i.x,i.y,0,1],d=[i.x,i.y,1,1];return a.aE(o,o,this.pixelMatrixInverse),a.aE(d,d,this.pixelMatrixInverse),a.cu(o,o,1/o[3]),a.cu(d,d,1/d[3]),o[2]=a.bU(o[2],this._center.lat)*this.worldSize,d[2]=a.bU(d[2],this._center.lat)*this.worldSize,a.cu(o,o,1/this.worldSize),a.cu(d,d,1/this.worldSize),new a.az([o[0],o[1],o[2]],a.ay([],a.ax([],d,o)))}rayIntersectionCoordinate(i){const{p0:o,p1:d,t:m}=i,y=a.bU(o[2],this._center.lat),v=a.bU(d[2],this._center.lat);return new a.ag(a.am(o[0],d[0],m)/this.worldSize,a.am(o[1],d[1],m)/this.worldSize,a.am(y,v,m))}pointCoordinate(i,o=this._centerAltitude){return this.projection.pointCoordinate(this,i.x,i.y,o)}pointCoordinate3D(i,o){if(!this.elevation)return this.pointCoordinate(i,o);let d=this.projection.pointCoordinate3D(this,i.x,i.y);if(d)return new a.ag(d[0],d[1],d[2]);let m=0,y=this.horizonLineFromTop();if(i.y>y)return this.pointCoordinate(i,o);const v=.02*y,w=i.clone();for(let E=0;E<10&&y-m>v;E++){w.y=a.am(m,y,.66);const P=this.projection.pointCoordinate3D(this,w.x,w.y);P?(y=w.y,d=P):m=w.y}return d?new a.ag(d[0],d[1],d[2]):this.pointCoordinate(i)}isPointAboveHorizon(i){return this.projection.isPointAboveHorizon(this,i)}isPointOnSurface(i){if(i.y<0||i.y>this.height||i.x<0||i.x>this.width)return!1;if(this.elevation||this.zoom>=a.cv)return!this.isPointAboveHorizon(i);const o=this.pointCoordinate(i);return o.y>=0&&o.y<=1}_coordinatePoint(i,o){const d=o&&this.elevation?this.elevation.getAtPointOrZero(i,this._centerAltitude):this._centerAltitude,m=[i.x*this.worldSize,i.y*this.worldSize,d+i.toAltitude(),1];return a.aE(m,m,this.pixelMatrix),m[3]>0?new a.P(m[0]/m[3],m[1]/m[3]):new a.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:i,left:o}=this._edgeInsets,d=this.height-this._edgeInsets.bottom,m=this.width-this._edgeInsets.right,y=this.pointLocation3D(new a.P(o,i)),v=this.pointLocation3D(new a.P(m,i)),w=this.pointLocation3D(new a.P(m,d)),E=this.pointLocation3D(new a.P(o,d));let P=Math.min(y.lng,v.lng,w.lng,E.lng),R=Math.max(y.lng,v.lng,w.lng,E.lng),O=Math.min(y.lat,v.lat,w.lat,E.lat),k=Math.max(y.lat,v.lat,w.lat,E.lat);const N=Math.pow(2,-this.zoom)/16*270,j=this.projection.name==="globe"?1:4,U=(X,W,ie,ne,K)=>{const xe=(X+ie)/2,le=(W+ne)/2,_e=new a.P(xe,le),{lng:re,lat:ae}=this.pointLocation3D(_e),fe=Math.max(0,P-re,O-ae,re-R,ae-k);P=Math.min(P,re),R=Math.max(R,re),O=Math.min(O,ae),k=Math.max(k,ae),(K<j||fe>N)&&(U(X,W,xe,le,K+1),U(xe,le,ie,ne,K+1))};if(U(o,i,m,i,1),U(m,i,m,d,1),U(m,d,o,d,1),U(o,d,o,i,1),this.projection.name==="globe"){const[X,W]=a.cw(this);X?(k=90,R=180,P=-180):W&&(O=-90,R=180,P=-180)}return new a.aK(new a.aU(P,O),new a.aU(R,k))}_getBoundsRectangular(i,o){const{top:d,left:m}=this._edgeInsets,y=this.height-this._edgeInsets.bottom,v=this.width-this._edgeInsets.right,w=new a.P(m,d),E=new a.P(v,d),P=new a.P(v,y),R=new a.P(m,y);let O=this.pointCoordinate(w,i),k=this.pointCoordinate(E,i);const N=this.pointCoordinate(P,o),j=this.pointCoordinate(R,o),U=(X,W)=>(W.y-X.y)/(W.x-X.x);return O.y>1&&k.y>=0?O=new a.ag((1-j.y)/U(j,O)+j.x,1):O.y<0&&k.y<=1&&(O=new a.ag(-j.y/U(j,O)+j.x,0)),k.y>1&&O.y>=0?k=new a.ag((1-N.y)/U(N,k)+N.x,1):k.y<0&&O.y<=1&&(k=new a.ag(-N.y/U(N,k)+N.x,0)),new a.aK().extend(this.coordinateLocation(O)).extend(this.coordinateLocation(k)).extend(this.coordinateLocation(j)).extend(this.coordinateLocation(N))}_getBoundsRectangularTerrain(){const i=this.elevation;if(!i.visibleDemTiles.length||i.isUsingMockSource())return this._getBoundsRectangular(0,0);const o=i.visibleDemTiles.reduce((d,m)=>{if(m.dem){const y=m.dem.tree;d.min=Math.min(d.min,y.minimums[0]),d.max=Math.max(d.max,y.maximums[0])}return d},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(o.min*i.exaggeration(),o.max*i.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(i=!0){const o=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,d=this.height/2-o*(1-this._horizonShift);return i?Math.max(0,d):d}getMaxBounds(){return this.maxBounds}setMaxBounds(i){this.maxBounds=i,this.minLat=-a.ct,this.maxLat=a.ct,this.minLng=-180,this.maxLng=180,i&&(this.minLat=i.getSouth(),this.maxLat=i.getNorth(),this.minLng=i.getWest(),this.maxLng=i.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=a.aH(this.minLng)*this.tileSize,this.worldMaxX=a.aH(this.maxLng)*this.tileSize,this.worldMinY=a.aL(this.maxLat)*this.tileSize,this.worldMaxY=a.aL(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(i,o){return this.projection.createTileMatrix(this,o,i)}calculateDistanceTileData(i){const o=i.key,d=this._distanceTileDataCache;if(d[o])return d[o];const m=i.canonical,y=1/this.height,v=this.cameraWorldSize,w=v/this.zoomScale(m.z),E=(m.x+Math.pow(2,m.z)*i.wrap)*w,P=m.y*w,R=this.point;R.x*=v/this.worldSize,R.y*=v/this.worldSize;const O=this.angle,k=Math.sin(-O),N=-Math.cos(-O);return d[o]={bearing:[k,N],center:[(R.x-E)*y,(R.y-P)*y],scale:w/a.an*y},d[o]}calculateFogTileMatrix(i){const o=i.key,d=this._fogTileMatrixCache;if(d[o])return d[o];const m=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,i);return a.aD(m,this.worldToFogMatrix,m),d[o]=new Float32Array(m),d[o]}calculateProjMatrix(i,o=!1,d=!1){const m=i.key;let y;if(y=d?this._expandedProjMatrixCache:o?this._alignedProjMatrixCache:this._projMatrixCache,y[m])return y[m];const v=this.calculatePosMatrix(i,this.worldSize);let w;return w=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:d?this.expandedFarZProjMatrix:o?this.alignedProjMatrix:this.projMatrix,a.aD(v,w,v),y[m]=new Float32Array(v),y[m]}calculatePixelsToTileUnitsMatrix(i){const o=i.tileID.key,d=this._pixelsToTileUnitsCache;if(d[o])return d[o];const m=a.cx(i,this);return d[o]=m,d[o]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){const i=1/this.worldSize,o=a.bP([],[i,i,i]);return a.aD(o,o,this.globeMatrix),o}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;const i=this._elevation;this._updateCameraState();const o=a.bU(1,this._center.lat)*this.worldSize,d=this._computeCameraPosition(o),m=this._camera.forward(),y=a.bU(1,this._center.lat);d[2]/=y,m[2]/=y,a.ay(m,m);const v=i.raycast(d,m,i.exaggeration());if(v){const w=a.bg([],d,m,v),E=new a.ag(w[0],w[1],a.bU(w[2],a.bV(w[1]))),P=(E.z+a.ai([E.x-d[0],E.y-d[1],E.z-d[2]*y]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(P),this._centerAltitude=E.toAltitude(),this._center=this.coordinateLocation(E),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(i=!1){if(!this._elevation)return;const o=this._elevation,d=a.bU(1,this._center.lat)*this.worldSize,m=this._computeCameraPosition(d),y=o.getAtPointOrZero(new a.ag(...m)),v=this.pixelsPerMeter/this.worldSize*y,w=this._minimumHeightOverTerrain(),E=m[2]-v;if(E<=w)if(E<0||i){const P=this.locationCoordinate(this._center,this._centerAltitude),R=[m[0],m[1],P.z-m[2]],O=a.ai(R);R[2]-=(w-E)/this._pixelsPerMercatorPixel;const k=a.ai(R);if(k===0)return;a.bJ(R,R,O/k*this._pixelsPerMercatorPixel),this._camera.position=[m[0],m[1],P.z*this._pixelsPerMercatorPixel-R[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const i=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||i){const k=this.center;return k.lat=a.aC(k.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!i)&&(k.lng=a.aC(k.lng,this.minLng,this.maxLng)),this.center=k,void(this._constraining=!1)}const o=this._unmodified,{x:d,y:m}=this.point;let y=0,v=d,w=m;const E=this.width/2,P=this.height/2,R=this.worldMinY*this.scale,O=this.worldMaxY*this.scale;if(m-P<R&&(w=R+P),m+P>O&&(w=O-P),O-R<this.height&&(y=Math.max(y,this.height/(O-R)),w=(O+R)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const k=this.worldMinX*this.scale,N=this.worldMaxX*this.scale,j=this.worldSize/2-(k+N)/2;v=(d+j+this.worldSize)%this.worldSize-j,v-E<k&&(v=k+E),v+E>N&&(v=N-E),N-k<this.width&&(y=Math.max(y,this.width/(N-k)),v=(N+k)/2)}v===d&&w===m||this._allowWorldUnderZoom||(this.center=this.unproject(new a.P(v,w))),y&&!this._allowWorldUnderZoom&&(this.zoom+=this.scaleZoom(y)),this._constrainCamera(),this._unmodified=o,this._constraining=!1}_minZoomForBounds(){let i=Math.max(0,this.scaleZoom(Math.max(0,this.height)/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(i=Math.max(i,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),i}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const i=this.centerOffset,o=this.projection.name==="globe",d=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=a.bU(1,this.center.lat)/a.bU(1,a.cN));const m=a.cy(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,m),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const y=this.projection.zAxisUnit==="meters"?d:1,v=this._camera.getWorldToCamera(this.worldSize,y);let w;const E=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(E[8]=2*-i.x/this.width,E[9]=2*i.y/this.height,this.isOrthographic){let ae=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),fe=ae*this.aspect,Ce=-fe,ve=-ae;fe-=i.x,Ce-=i.x,ae+=i.y,ve+=i.y,w=this._camera.getCameraToClipOrthographic(Ce,fe,ve,ae,this._nearZ+this._nearClipOffset,this._farZ),((Ne,ze,Je,tt)=>{for(let Pe=0;Pe<16;Pe++)Ne[Pe]=a.am(ze[Pe],Je[Pe],tt)})(w,w,E,a.cL(this.pitch>=Tl?1:this.pitch/Tl))}else w=E;const P=a.cz([],E,v);let R=a.cz([],w,v);if(this.projection.isReprojectedInTileSpace){const ae=this.locationCoordinate(this.center),fe=a.b9([]);a.bx(fe,fe,[ae.x*this.worldSize,ae.y*this.worldSize,0]),a.aD(fe,fe,a.cA(this)),a.bx(fe,fe,[-ae.x*this.worldSize,-ae.y*this.worldSize,0]),a.aD(R,R,fe),a.aD(P,P,fe),this.inverseAdjustmentMatrix=a.cB(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=a.cC([],R,[this.worldSize,this.worldSize,this.worldSize/y,1]),this.projMatrix=R,this.invProjMatrix=a.b7(new Float64Array(16),this.projMatrix),o){const ae=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);ae[8]=2*-i.x/this.width,ae[9]=2*i.y/this.height,this.expandedFarZProjMatrix=a.cz([],ae,v)}else this.expandedFarZProjMatrix=this.projMatrix;const O=a.b7([],w);this.frustumCorners=a.cD.fromInvProjectionMatrix(O,this.horizonLineFromTop(),this.height),this.cameraFrustum=a.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!o);const k=new Float32Array(16);a.b9(k),a.cC(k,k,[1,-1,1]),a.cE(k,k,this._pitch),a.ba(k,k,this.angle);const N=a.bS(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=a.b8(N);const j=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;N[8]=2*-i.x/this.width,N[9]=2*(i.y+j)/this.height,this.skyboxMatrix=a.aD(k,N,k);const U=this.point,X=U.x,W=U.y,ie=this.width%2/2,ne=this.height%2/2,K=Math.cos(this.angle),xe=Math.sin(this.angle),le=X-Math.round(X)+K*ie+xe*ne,_e=W-Math.round(W)+K*ne+xe*ie,re=new Float64Array(R);if(a.bx(re,re,[le>.5?le-1:le,_e>.5?_e-1:_e,0]),this.alignedProjMatrix=re,R=a.bb(),a.cC(R,R,[this.width/2,-this.height/2,1]),a.bx(R,R,[1,-1,0]),this.labelPlaneMatrix=R,R=a.bb(),a.cC(R,R,[1,-1,1]),a.bx(R,R,[-1,-1,0]),a.cC(R,R,[2/this.width,2/this.height,1]),this.glCoordMatrix=R,this.pixelMatrix=a.aD(new Float64Array(16),this.labelPlaneMatrix,P),this._calcFogMatrices(),this._distanceTileDataCache={},R=a.b7(new Float64Array(16),this.pixelMatrix),!R)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=R,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=a.cF(this);const ae=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=a.ah(ae,ae,v),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=R;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const i=this.cameraWorldSizeForFog,o=this.cameraPixelsPerMeter,d=this._camera.position,m=1/this.height/this._pixelsPerMercatorPixel,y=[i,i,o];a.bJ(y,y,m),a.bJ(d,d,-1),a.cG(d,d,y);const v=a.bb();a.bx(v,v,d),a.cC(v,v,y),this.mercatorFogMatrix=v,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(i,o,m)}_computeCameraPosition(i){const o=(i=i||this.pixelsPerMeter)/this.pixelsPerMeter,d=this._camera.forward(),m=this.point,y=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*o-i/this.worldSize*this._centerAltitude;return[m.x/this.worldSize-d[0]*y,m.y/this.worldSize-d[1]*y,i/this.worldSize*this._centerAltitude-d[2]*y]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(i){const o=this._maxCameraBoundsDistance()*Math.cos(this._pitch),d=this._camera.position[2],m=i[2];let y=1;this.projection.wrap&&(this.center=this.center.wrap()),m>0&&(y=Math.min((o-d)/m,1)),this._camera.position=a.bg([],this._camera.position,i,y),this._updateStateFromCamera()}_updateStateFromCamera(){const i=this._camera.position,o=this._camera.forward(),{pitch:d,bearing:m}=this._camera.getPitchBearing(),y=a.bU(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,v=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.ap(this._maxPitch)),w=Math.max((i[2]-y)/Math.cos(d),v),E=this._zoomFromMercatorZ(w);a.bg(i,i,o,w),this._pitch=a.aC(d,a.ap(this.minPitch),a.ap(this.maxPitch)),this.angle=a.bs(m,-Math.PI,Math.PI),this._setZoom(a.aC(E,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new a.ag(i[0],i[1],i[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(i){return Math.pow(2,i)*this.tileSize}_mercatorZfromZoom(i){return this.cameraToCenterDistance/this._worldSizeFromZoom(i)}_minimumHeightOverTerrain(){const i=Math.min(this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(i)}_zoomFromMercatorZ(i){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,i)*this.tileSize))}zoomFromMercatorZAdjusted(i){let o=0,d=a.cv,m=0,y=1/0;for(;d-o>1e-6&&d>o;){const v=o+.5*(d-o),w=this.tileSize*Math.pow(2,v),E=this.getCameraToCenterDistance(this.projection,v,w),P=this.scaleZoom(E/(Math.max(0,i)*this.tileSize)),R=Math.abs(v-P);R<y&&(y=R,m=v),v<P?o=v:d=v}return m}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(a.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(i,o){const d=Math.min(i.x,o.x),m=Math.max(i.x,o.x),y=Math.min(i.y,o.y),v=Math.max(i.y,o.y);if(y<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;const w=[new a.P(d,y),new a.P(m,v),new a.P(d,v),new a.P(m,y)],E=this.renderWorldCopies?-3:0,P=this.renderWorldCopies?4:1;for(const R of w){const O=this.pointRayIntersection(R);if(O.t<0)return!0;const k=this.rayIntersectionCoordinate(O);if(k.x<E||k.y<0||k.x>P||k.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.cH(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.P(0,0),new a.P(this.width,this.height))}zoomDeltaToMovement(i,o){const d=a.ai(a.ax([],this._camera.position,i)),m=this._zoomFromMercatorZ(d)+o;return d-this._mercatorZfromZoom(m)}getCameraPoint(){if(this.projection.name==="globe"){const i=function([o,d,m],y){const v=[o,d,m,1];a.aE(v,v,y);const w=v[3]=Math.max(v[3],1e-6);return v[0]/=w,v[1]/=w,v[2]/=w,v}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new a.P(i[0],i[1])}{const i=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.P(0,i))}}getCameraToCenterDistance(i,o=this.zoom,d=this.worldSize){const m=a.cy(i,o,this.width,this.height,1024),y=i.pixelSpaceConversion(this.center.lat,d,m);let v=.5/Math.tan(.5*this._fov)*this.height*y;return this.isOrthographic&&(v=a.am(1,v,a.cL(this.pitch>=Tl?1:this.pitch/Tl))),v}getWorldToCameraMatrix(){const i=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&a.aD(i,i,this.globeMatrix),i}getFrustum(i){return a.cl.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,i,this.projection.zAxisUnit==="meters")}}const ir=(u,i)=>{if(i>0&&u.terrain&&a.w("Cutoff is currently disabled on terrain"),i<=0||u.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const o=u.transform,d=o.pitch,m=o.isLODDisabled(!1)?60:30;if(d<m-15)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const y=o._farZ-o._nearZ,v=i*o.height*1.3,w=Math.pow(2,.85*Math.max(o._zoom-u.minCutoffZoom,0)),E=1.4*o.cameraToCenterDistance*w,P=a.aj(m-15,m,d),R=(1-(O=P))*(o._farZ+v)+O*E;var O;const k=Math.min(v,R-o._nearZ);return{shouldRenderCutoff:P>0,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(R-o._nearZ)/y,(R-k-o._nearZ)/y]}}},Va=2048;class gd{constructor(i,o){this.aabb=i,this.lastCascade=o}}class sy{add(i,o){const d=this.receivers[i.key];d!==void 0?(d.aabb.min[0]=Math.min(d.aabb.min[0],o.min[0]),d.aabb.min[1]=Math.min(d.aabb.min[1],o.min[1]),d.aabb.min[2]=Math.min(d.aabb.min[2],o.min[2]),d.aabb.max[0]=Math.max(d.aabb.max[0],o.max[0]),d.aabb.max[1]=Math.max(d.aabb.max[1],o.max[1]),d.aabb.max[2]=Math.max(d.aabb.max[2],o.max[2])):this.receivers[i.key]=new gd(o,null)}clear(){this.receivers={}}get(i){return this.receivers[i.key]}computeRequiredCascades(i,o,d){const m=a.cU.fromPoints(i.points);let y=0;for(const v in this.receivers){const w=this.receivers[v];if(!w||!m.intersectsAabb(w.aabb))continue;w.aabb.min=m.closestPoint(w.aabb.min),w.aabb.max=m.closestPoint(w.aabb.max);const E=w.aabb.getCorners();for(let P=0;P<d.length;P++){let R=!0;for(const O of E){const k=[O[0]*o,O[1]*o,O[2]];if(a.ah(k,k,d[P].matrix),k[0]<-1||k[0]>1||k[1]<-1||k[1]>1){R=!1;break}}if(w.lastCascade=P,y=Math.max(y,P),R)break}}return y+1}}class Uu{constructor(i){this.painter=i,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new sy,this._depthMode=new At(i.context.gl.LEQUAL,At.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}destroy(){for(const i of this._cascades)i.texture.destroy(),i.framebuffer.destroy();this._cascades=[]}updateShadowParameters(i,o){const d=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!o||!o.properties)return;const m=o.properties.get("shadow-intensity"),y=o.properties.get("shadow-draw-before-layer");if(!o.shadowsEnabled()||m<=0)return;let v=-1,w=0;for(const W of d.style.order){const ie=d.style._mergedLayers[W];ie.hasShadowPass()&&!ie.isHidden(i.zoom)&&(v=w),!y||y!==W&&y!==ie.slot||(this._drawShadowAfterLayer=w>0?w-1:0),w+=1}if(this._enabled=v>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=v);const E=d.context,P=Va,R=Va;if(this._cascades.length===0||Va!==this._cascades[0].texture.size[0]){this._cascades=[];for(let W=0;W<2;++W){const ie=E.gl,ne=E.createFramebuffer(P,R,0,"texture"),K=new a.T(E,{width:P,height:R,data:null},ie.DEPTH_COMPONENT16);ne.depthAttachment.set(K.texture),this._cascades.push({framebuffer:ne,texture:K,matrix:[],far:0,boundingSphereRadius:0,frustum:new a.cl,scale:0})}}this.shadowDirection=oy(o);let O=0;if(i.elevation){const W=i.elevation,ie=[1e4,-1e4];W.visibleDemTiles.filter(ne=>ne.dem).forEach(ne=>{const K=ne.dem.tree;ie[0]=Math.min(ie[0],K.minimums[0]),ie[1]=Math.max(ie[1],K.maximums[0])}),ie[0]!==1e4&&(O=(ie[1]-ie[0])*W.exaggeration())}const k=1.5*i.cameraToCenterDistance,N=3*k,j=new Float64Array(16);for(let W=0;W<this._cascades.length;++W){const ie=this._cascades[W];let ne=i.height/50,K=1;W===0?K=k:(ne=k,K=N);const[xe,le]=ju(i,this.shadowDirection,ne,K,Va,O);ie.scale=i.scale,ie.matrix=xe,ie.boundingSphereRadius=le,a.b7(j,ie.matrix),ie.frustum=a.cl.fromInvProjectionMatrix(j,1,0,!0),ie.far=K}const U=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[U].far,this._cascades[U].far],this._uniformValues.u_shadow_intensity=m,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=.00048828125,this._uniformValues.u_shadow_map_resolution=Va,this._uniformValues.u_shadowmap_0=11,this._uniformValues.u_shadowmap_1=12,this._groundShadowTiles=d.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const X=d.transform.elevation;for(const W of this._groundShadowTiles){let ie={min:0,max:0};if(X){const ne=X.getMinMaxForTile(W);ne&&(ie=ne)}this.addShadowReceiver(W.toUnwrapped(),ie.min,ie.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(i){this._enabled=i}drawShadowPass(i,o){if(!this.enabled)return;const d=this.painter,m=d.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(d.transform.getFrustum(0),d.transform.worldSize,this._cascades),m.viewport.set([0,0,Va,Va]);for(let y=0;y<this._numCascadesToRender;++y){d.currentShadowCascade=y,m.bindFramebuffer.set(this._cascades[y].framebuffer.framebuffer),m.clear({color:a.aq.white,depth:1});for(const v of i.order){const w=i._mergedLayers[v];if(!w.hasShadowPass()||w.isHidden(d.transform.zoom))continue;const E=i.getLayerSourceCache(w),P=E?o[E.id]:void 0;(w.type==="model"||P&&P.length)&&d.renderLayer(d,E,w,P)}}d.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;const i=this.painter,o=i.style,d=i.context,m=d.gl,y=o.directionalLight,v=o.ambientLight;if(!y||!v)return;const w=[],E=ir(i,i.longestCutoffRange);E.shouldRenderCutoff&&w.push("RENDER_CUTOFF"),w.push("RENDER_SHADOWS"),this.useNormalOffset&&w.push("NORMAL_OFFSET");const P=mo(o,y,v),R=new At(m.LEQUAL,At.ReadOnly,i.depthRangeFor3D),O=new Ht({func:m.EQUAL,mask:255},0,255,m.KEEP,m.KEEP,m.KEEP);for(const k of this._groundShadowTiles){const N=k.toUnwrapped(),j=i.isTileAffectedByFog(k),U=i.getOrCreateProgram("groundShadow",{defines:w,overrideFog:j});this.setupShadows(N,U),i.uploadCommonUniforms(d,U,N,null,E);const X=f1(i.transform.calculateProjMatrix(N),P);U.draw(i,m.TRIANGLES,R,O,jt.multiply,Nt.disabled,X,"ground_shadow",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments,null,i.transform.zoom,null,null)}}getShadowPassDepthMode(){return this._depthMode}getGroundShadowLayerIndex(){return this._drawShadowAfterLayer}calculateShadowPassMatrixFromTile(i){const o=this.painter.transform,d=o.calculatePosMatrix(i,o.worldSize);return a.aD(d,this._cascades[this.painter.currentShadowCascade].matrix,d),Float32Array.from(d)}calculateShadowPassMatrixFromMatrix(i){const o=a.b8(i);return a.aD(o,this._cascades[this.painter.currentShadowCascade].matrix,i),o}setupShadows(i,o,d){if(!this.enabled)return;const m=this.painter.transform,y=this.painter.context,v=y.gl,w=this._uniformValues,E=new Float64Array(16),P=m.calculatePosMatrix(i,m.worldSize);for(let R=0;R<this._cascades.length;R++)a.aD(E,this._cascades[R].matrix,P),w[R===0?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(E),y.activeTexture.set(v.TEXTURE0+11+R),this._cascades[R].texture.bindExtraParam(v.LINEAR,v.LINEAR,v.CLAMP_TO_EDGE,v.CLAMP_TO_EDGE,v.GREATER);if(this.useNormalOffset=!!d,this.useNormalOffset){const R=a.cS(i.canonical),O=2/m.tileSize*a.an/Va,k=O*this._cascades[0].boundingSphereRadius,N=O*this._cascades[this._cascades.length-1].boundingSphereRadius,j=(d==="vector-tile"?1:3)*function(U){const X=a.aC((U-22)/-22,0,1);return .125*(1-X)+4*X}(m.zoom);w.u_shadow_normal_offset=[R,k*j,N*j],w.u_shadow_bias=[1e-4,.0012,.012]}else w.u_shadow_bias=[36e-5,.0012,.012];o.setShadowUniformValues(y,w)}setupShadowsFromMatrix(i,o,d=!1){if(!this.enabled)return;const m=this.painter.context,y=m.gl,v=this._uniformValues,w=new Float64Array(16);for(let E=0;E<2;E++)a.aD(w,this._cascades[E].matrix,i),v[E===0?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(w),m.activeTexture.set(y.TEXTURE0+11+E),this._cascades[E].texture.bindExtraParam(y.LINEAR,y.LINEAR,y.CLAMP_TO_EDGE,y.CLAMP_TO_EDGE,y.GREATER);this.useNormalOffset=d,d?(v.u_shadow_normal_offset=[1,3,3],v.u_shadow_bias=[6e-5,.0012,.012]):v.u_shadow_bias=[36e-5,.0012,.012],o.setShadowUniformValues(m,v)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(i,o,d,m){if(m[2]>=0)return{};const y=function(E,P,R){const O=R/(1<<E.canonical.z);return new a.cU([E.canonical.x*O+E.wrap*R,E.canonical.y*O+E.wrap*R,0],[(E.canonical.x+1)*O+E.wrap*R,(E.canonical.y+1)*O+E.wrap*R,P])}(i,o,d).getCorners(),v=o/-m[2];m[0]<0?(a.cT(y[0],y[0],[m[0]*v,0,0]),a.cT(y[3],y[3],[m[0]*v,0,0])):m[0]>0&&(a.cT(y[1],y[1],[m[0]*v,0,0]),a.cT(y[2],y[2],[m[0]*v,0,0])),m[1]<0?(a.cT(y[0],y[0],[0,m[1]*v,0]),a.cT(y[1],y[1],[0,m[1]*v,0])):m[1]>0&&(a.cT(y[2],y[2],[0,m[1]*v,0]),a.cT(y[3],y[3],[0,m[1]*v,0]));const w={};return w.vertices=y,w.planes=[yd(y[1],y[0],y[4]),yd(y[2],y[1],y[5]),yd(y[3],y[2],y[6]),yd(y[0],y[3],y[7])],w}addShadowReceiver(i,o,d){this._receivers.add(i,a.cU.fromTileIdAndHeight(i,o,d))}getMaxCascadeForTile(i){const o=this._receivers.get(i);return o&&o.lastCascade?o.lastCascade:0}}function yd(u,i,o){const d=a.ax([],o,i),m=a.ax([],u,i),y=a.bh([],d,m),v=a.ai(y);return v===0?[0,0,1,0]:(a.bJ(y,y,1/v),[y[0],y[1],y[2],-a.bi(y,i)])}function oy(u){const i=u.properties.get("direction"),o=a.cP(i.x,i.y,i.z);o[2]=a.aC(o[2],0,75);const d=a.cR([o[0],o[1],o[2]]);return a.cQ(d.x,d.y,d.z)}function mo(u,i,o){const d=i.properties.get("color-use-theme")==="none",m=i.properties.get("color"),y=i.properties.get("intensity"),v=i.properties.get("direction"),w=[v.x,v.y,v.z],E=o.properties.get("color-use-theme")==="none",P=o.properties.get("color"),R=o.properties.get("intensity"),O=Math.max(a.bi([0,0,1],w),0),k=[0,0,0];a.bJ(k,P.toPremultipliedRenderColor(E?null:u.getLut(i.scope)).toArray01Linear().slice(0,3),R);const N=[0,0,0];return a.bJ(N,m.toPremultipliedRenderColor(d?null:u.getLut(o.scope)).toArray01Linear().slice(0,3),O*y),a.cW([k[0]>0?k[0]/(k[0]+N[0]):0,k[1]>0?k[1]/(k[1]+N[1]):0,k[2]>0?k[2]/(k[2]+N[2]):0])}function ju(u,i,o,d,m,y){const v=u.zoom,w=u.scale,E=u.worldSize,P=1/E,R=u.aspect,O=Math.sqrt(1+R*R)*Math.tan(.5*u.fovX),k=O*O,N=d-o,j=d+o;let U,X;k>N/j?(U=d,X=d*O):(U=.5*j*(1+k),X=.5*Math.sqrt(N*N+2*(d*d+o*o)*k+j*j*k*k));const W=u.projection.pixelsPerMeter(u.center.lat,E),ie=u._camera.getCameraToWorldMercator(),ne=[0,0,-U*P];a.ah(ne,ne,ie);let K=X*P;const xe=function($e){return $e[0]/=w,$e[1]/=w,$e[2]=a.bU($e[2],u._center.lat),$e},le=u._edgeInsets;if(!(le.left===0&&le.top===0&&le.right===0&&le.bottom===0||le.left===le.right&&le.top===le.bottom)){const $e=u._camera.getWorldToCamera(u.worldSize,u.projection.zAxisUnit==="meters"?W:1),ft=u._camera.getCameraToClipPerspective(u._fov,u.width/u.height,o,d);ft[8]=2*-u.centerOffset.x/u.width,ft[9]=2*u.centerOffset.y/u.height;const lt=new Float64Array(16);a.cz(lt,ft,$e);const ct=new Float64Array(16);a.b7(ct,lt);const et=a.cl.fromInvProjectionMatrix(ct,E,v,!0);for(const Et of et.points){const Mt=xe(Et);K=Math.max(K,a.bK(a.cV([],ne,Mt)))}}K*=m/(m-1);const _e=Math.acos(i[2]),re=Math.atan2(-i[0],-i[1]),ae=new Nu;ae.position=ne,ae.setPitchBearing(_e,re);const fe=ae.getWorldToCamera(E,W),Ce=K*E,ve=Math.min(u._mercatorZfromZoom(17)*E*-2,-2*Ce),Ne=ae.getCameraToClipOrthographic(-Ce,Ce,-Ce,Ce,ve,(Ce+y*W)/i[2]),ze=new Float64Array(16);a.aD(ze,Ne,fe);const Je=a.cQ(Math.floor(1e6*ne[0])/1e6*E,Math.floor(1e6*ne[1])/1e6*E,0),tt=.5*m,Pe=[0,0,0];a.ah(Pe,Je,ze),a.bJ(Pe,Pe,tt);const we=[Math.floor(Pe[0]),Math.floor(Pe[1]),Math.floor(Pe[2])],Oe=[0,0,0];a.ax(Oe,Pe,we),a.bJ(Oe,Oe,-1/tt);const Ue=new Float64Array(16);return a.b9(Ue),a.bx(Ue,Ue,Oe),a.aD(ze,Ue,ze),[ze,Ce]}class p1 extends a.E{constructor(i){super(),this.requestManager=i,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(i,o){return a.cX(this.requestManager.transformRequest(o,a.R.Model).url).then(d=>{const m=a.cY(d),y=new a.cZ(i,o,void 0,void 0,m);return y.computeBoundsAndApplyParent(),y}).catch(d=>{if(d&&d.status===404)return null;this.fire(new a.B(new Error(`Could not load model ${i} from ${o}: ${d.message}`)))})}load(i,o,d={forceReload:!1}){this.models[o]||(this.models[o]={});const m=Object.keys(i),y=[],v=[];for(const w of m){const E=i[w];this.hasURLBeenRequested(E)&&!d.forceReload||(this.modelByURL[E]={modelId:w,scope:o},y.push(this.loadModel(w,E)),v.push(w)),this.models[o][w]||(this.models[o][w]={model:null,numReferences:1})}this.numModelsLoading[o]=(this.numModelsLoading[o]||0)+v.length,Promise.allSettled(y).then(w=>{for(let E=0;E<w.length;E++){const{status:P}=w[E];if(P==="rejected")continue;const{value:R}=w[E];this.models[o][v[E]]||(this.models[o][v[E]]={model:null,numReferences:1}),this.models[o][v[E]].model=R}this.numModelsLoading[o]-=v.length,this.fire(new a.C("data",{dataType:"style"}))}).catch(w=>{this.fire(new a.B(new Error(`Could not load models: ${w.message}`)))})}isLoaded(){for(const i in this.numModelsLoading)if(this.numModelsLoading[i]>0)return!1;return!0}hasModel(i,o,d={exactIdMatch:!1}){return!!(d.exactIdMatch?this.getModel(i,o):this.getModelByURL(this.modelUris[o][i]))}getModel(i,o){return this.models[o]||(this.models[o]={}),this.models[o][i]?this.models[o][i].model:void 0}getModelByURL(i){if(!i)return null;const o=this.modelByURL[i];return o?this.models[o.scope][o.modelId].model:null}hasModelBeenAdded(i,o){return this.models[o]&&this.models[o][i]!==void 0}getModelURIs(i){return this.modelUris[i]||{}}addModel(i,o,d){this.models[d]||(this.models[d]={}),this.modelUris[d]||(this.modelUris[d]={});const m=this.requestManager.normalizeModelURL(o);if((this.hasModel(i,d,{exactIdMatch:!0})||this.hasModelBeenAdded(i,d))&&this.modelUris[d][i]===m)this.models[d][i].numReferences++;else if(this.hasURLBeenRequested(m)){const{scope:y,modelId:v}=this.modelByURL[m];this.models[y][v].numReferences++}else this.modelUris[d][i]=m,this.load({[i]:this.modelUris[d][i]},d)}addModelURLs(i,o){this.models[o]||(this.models[o]={}),this.modelUris[o]||(this.modelUris[o]={});const d=this.modelUris[o];for(const m in i)d[m]=this.requestManager.normalizeModelURL(i[m])}reloadModels(i){this.load(this.modelUris[i],i,{forceReload:!0})}addModelsFromBucket(i,o){this.models[o]||(this.models[o]={}),this.modelUris[o]||(this.modelUris[o]={});const d={};for(const m of i)this.hasModel(m,o,{exactIdMatch:!0})||this.hasURLBeenRequested(m)?this.models[o][m].numReferences++:this.modelUris[o][m]&&!this.hasURLBeenRequested(m)?d[m]=this.modelUris[o][m]:!this.hasURLBeenRequested(m)&&a.c_(m,!1)&&(this.modelUris[o][m]=this.requestManager.normalizeModelURL(m),d[m]=this.modelUris[o][m]);this.load(d,o)}hasURLBeenRequested(i){return this.modelByURL[i]!==void 0}removeModel(i,o,d=!1,m=!1){if(this.models[o]&&this.models[o][i]&&(this.models[o][i].numReferences--,this.models[o][i].numReferences===0||m)){const y=this.modelUris[o][i];d||delete this.modelUris[o][i],delete this.modelByURL[y];const v=this.models[o][i].model;if(!v)return;delete this.models[o][i],v.destroy()}}destroy(){for(const i of Object.keys(this.models))for(const o of Object.keys(this.models[i])){const d=this.models[i][o].model;delete this.models[i][o],d&&d.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(i){return this.models[i]||(this.models[i]={}),Object.keys(this.models[i])}upload(i,o){this.models[o]||(this.models[o]={});for(const d in this.models[o])this.models[o][d].model&&this.models[o][d].model.upload(i.context)}}const Up=a.a8.colorTheme,Tc=new a.ab({data:new a.ac(Up.data)});function ay(u){if(!u.metadata||!u.metadata.content_area)return;const i=a.o.devicePixelRatio,{left:o,top:d,width:m,height:y}=u.metadata.content_area,v=o*i,w=d*i;return[v,w,v+m*i,w+y*i]}function Gu(u){if(u)return u.map(([i,o])=>[i*a.o.devicePixelRatio,o*a.o.devicePixelRatio])}class jp{constructor(i,o,d){this.id=i,this.scope=o,this.sourceCache=d,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(i){this.missingRequests.has(i.name)||this.pendingRequests.has(i.name)||this.pendingRequests.add(i.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const i=new Map;if(!this.sourceCache.loaded())return i;const o=this.sourceCache.getVisibleCoordinates();if(o.length===0)return i;const d=this.sourceCache.getSource();if(!(d instanceof gl))return i;const m=o.map(v=>this.sourceCache.getTile(v)),y=d.getImages(m,Array.from(this.pendingRequests));for(const[v,w]of y)i.set(a.I.from({name:v,iconsetId:this.id}),w),this.pendingRequests.delete(v);for(const v of this.pendingRequests)this.missingRequests.add(v);return this.pendingRequests.clear(),i}}class Ua{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16}findClosestBuilding(i,o,d,m,y){if(d<this._indoorMinimumZoom)return this._previousClosestBuildingId=null,null;let v=null,w=Number.MAX_VALUE,E=Number.MAX_VALUE,P=!1;const R=this._previousClosestBuildingId?i[this._previousClosestBuildingId]:null;this._previousClosestBuildingId&&R&&this._isBuildingVisible(R,m,y)&&(P=!0,E=this._calculateDistance(o,R));for(const[O,k]of Object.entries(i)){if(!this._isBuildingVisible(k,m,y))continue;const N=this._calculateDistance(o,k);N<w&&(w=N,v=O)}return P&&v&&this._previousClosestBuildingId&&v!==this._previousClosestBuildingId?w>E*this._hysteresisRatio&&(v=this._previousClosestBuildingId):P&&!v&&(v=this._previousClosestBuildingId),this._previousClosestBuildingId=v,v}_calculateDistance(i,o){if(!o.center)return Number.MAX_VALUE;const d=i.lat-o.center[1],m=i.lng-o.center[0];return d*d+m*m}_isBuildingVisible(i,o,d){if(!d)return!1;for(const m of i.floorIds){const y=i.floors[m];if(!y.geometry)continue;const v=y.geometry;if(v.type==="Polygon"){const w=this._convertRingToPoints(v.coordinates[0]);if(a.bw(w,d))return!0}else if(v.type==="MultiPolygon"){const w=this._convertMultiPolygonToPoints(v.coordinates);if(a.d0(d,w))return!0}}return!1}_convertRingToPoints(i){return i.map(o=>new a.P(o[0],o[1]))}_convertMultiPolygonToPoints(i){return i.map(o=>o.length===0?[]:o[0].map(d=>new a.P(d[0],d[1])))}}class m1 extends a.E{constructor(i){super(),this._style=i,this._buildings={},this._activeFloors=new Set,this._closestBuildingId=null,this._indoorState={selectedFloorId:null,activeFloorsVisible:!0,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Ua,this._initialLoadDone=!1,a.aZ(["_updateUI"],this),this._style.on("style.load",()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",()=>{this._initialLoadDone=!0,this._indoorState&&this._indoorState.needsUpdate&&(this._indoorState.needsUpdate=!1,this._style.updateIndoorDependentLayers()),this._updateUI()}),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI))})}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(i){i===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=i,this._recalculateActiveFloors())}setActiveFloorsVisibility(i){this._updateActiveFloors(i),this._updateIndoorSelector()}setIndoorData(i){let o=!1;for(const[d,m]of Object.entries(i.buildings))if(this._buildings[d])for(const y of m.floorIds)this._buildings[d].floorIds.add(y),this._buildings[d].floors[y]?this._mergeFloors(this._buildings[d].floors[y],m.floors[y]):(this._buildings[d].floors[y]=m.floors[y],o=!0);else this._buildings[d]=m,o=!0;o&&this._recalculateActiveFloors()}getIndoorTileOptions(i,o){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(i,o),indoorState:this._indoorState}:null}getControlState(){const i=this._buildings,o=this._closestBuildingId,d=o&&i?i[o]:void 0;if(!d)return{selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let m=null;for(const v of d.floorIds)if(this._activeFloors&&this._activeFloors.has(v)){m=v;break}const y=Array.from(d.floorIds).map(v=>({id:v,name:d.floors[v].name,zIndex:d.floors[v].zIndex})).sort((v,w)=>w.zIndex-v.zIndex).filter((v,w,E)=>w===0||v.zIndex!==E[w-1].zIndex);return{selectedFloorId:m,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:y}}_updateUI(){this._initialLoadDone=!0;const i=this._style.map.transform,o=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,i.center,i.zoom,i.getBounds(),this._makeViewportPolygon());if(o!==this._closestBuildingId){const d=this._closestBuildingId;this._closestBuildingId=o,this._onBuildingTransition(d,o),this._updateIndoorSelector()}}_onBuildingTransition(i,o){if(!this._indoorState)return;!o&&i?(this._indoorState.activeFloors=new Set,this._indoorState.activeFloorsVisible=!1,this._style.updateIndoorDependentLayers()):!!o&&!i&&(this._recalculateActiveFloors(),this._updateActiveFloors(!0))}_updateIndoorSelector(){this.fire(new a.C("selector-update",this.getControlState()))}_updateActiveFloors(i){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:i,activeFloors:this._activeFloors},this._initialLoadDone?this._style.updateIndoorDependentLayers():this._indoorState.needsUpdate=!0}_recalculateActiveFloors(){if(!this._buildings)return;const i=a.d1.calculate(this._buildings,this._selectedFloorId,this._activeFloors);(function(o,d){if(o===d)return!0;if(!o||!d||o.size!==d.size)return!1;for(const m of o)if(!d.has(m))return!1;return!0})(i,this._activeFloors)||(this._activeFloors=i,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector())}_mergeFloors(i,o){o.geometry&&(i.geometry?(i.geometry.type==="Polygon"&&(i.geometry={type:"MultiPolygon",coordinates:[i.geometry.coordinates]}),o.geometry.type==="Polygon"?i.geometry.coordinates.push(o.geometry.coordinates):o.geometry.type==="MultiPolygon"&&i.geometry.coordinates.push(...o.geometry.coordinates)):i.geometry=o.geometry)}_makeViewportPolygon(){const i=this._style.map.transform,o=i.width,d=i.height;return[i.pointLocation(new a.P(0,0)),i.pointLocation(new a.P(o,0)),i.pointLocation(new a.P(o,d)),i.pointLocation(new a.P(0,d))].map(m=>new a.P(m.lng,m.lat))}}const Sl=(u,i)=>gt(u,i&&i.filter(o=>o.identifier!=="source.canvas")),_1=a.aJ(Ai,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),ly=a.aJ(Ai,["setCenter","setZoom","setBearing","setPitch"]),Gp=new Set(["background","sky","slot","custom"]),xd={version:8,layers:[],sources:{}},$p={duration:300,delay:0};class Js extends a.E{constructor(i,o={}){if(super(),this.map=i,this.scope=o.scope||"",this.globalId=null,this.fragments=[],this.importDepth=o.importDepth||0,this.importsCache=o.importsCache||new Map,this.resolvedImports=o.resolvedImports||new Set,this.transition=Object.assign({},$p),this._buildingIndex=new Mu(this),this.crossTileSymbolIndex=new wc,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._mergedFillExtrusionSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=o.styleChanges||new id,this._hasDataDrivenEmissive=!1,this.indoorManager=new m1(this),this.dispatcher=o.dispatcher?o.dispatcher:new vr(uc(),this),this.map.painter&&this.map.painter.context){const m=this.map.painter.context.maxUniformBufferBindings,y=Math.floor(this.map.painter.context.maxUniformBlockSize/4);this.dispatcher.broadcast("setContextParams",{maxBindingPoints:m,maxUniformBlockSizeDwords:y,disableSymbolUBO:this.map.painter.context.disableSymbolUBO})}o.imageManager?this.imageManager=o.imageManager:(this.imageManager=new hc(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=o.glyphManager?o.glyphManager:new a.d2(i._requestManager,o.localFontFamily?a.d3.all:o.localIdeographFontFamily?a.d3.ideographs:a.d3.none,o.localFontFamily||o.localIdeographFontFamily,o.useServerFontComposition),o.modelManager?this.modelManager=o.modelManager:(this.modelManager=new p1(i._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._fillExtrusionSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=o.configOptions?o.configOptions:new Map,this._configDependentLayers=o.configDependentLayers?o.configDependentLayers:new Set,this._indoorDependentLayers=o.indoorDependentLayers?o.indoorDependentLayers:new Set,this._config=o.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:o.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=o.initialConfig,this.dispatcher.broadcast("setReferrer",a.d4()),this.dispatcher.broadcast("setConfig",a.d5());const d=this;this._rtlTextPluginCallback=Js.registerForPluginStateChange(m=>{d.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:m.pluginStatus,pluginURL:m.pluginURL},(y,v)=>{if(a.d6(y),v&&v.every(w=>w))for(const w in d._sourceCaches){const E=d._sourceCaches[w],P=E.getSource().type;P!=="vector"&&P!=="geojson"||E.reload()}})}),this.on("data",m=>{if(m.dataType!=="source"||m.sourceDataType!=="metadata")return;const y=this.getOwnSource(m.sourceId);if(y&&y.vectorLayerIds)for(const v in this._layers){const w=this._layers[v];w.source===y.id&&this._validateLayer(w)}})}load(i){return i?(typeof i=="string"?this.loadURL(i):this.loadJSON(i),this):this}_getGlobalId(i){if(!i)return null;if(typeof i=="string"){if(a.e(i))return i;const o=a.d7(i);if(!o.startsWith("http"))try{return new URL(o,location.href).toString()}catch{return o}return o}return`json://${a.d8(JSON.stringify(i))}`}_diffStyle(i,o,d){this.globalId=this._getGlobalId(i);const m=(y,v)=>{try{v(null,this.setState(y,d))}catch(w){v(w,!1)}};if(typeof i=="string"){const y=this.map._requestManager.normalizeStyleURL(i),v=this.map._requestManager.transformRequest(y,a.R.Style);a.m(v,(w,E)=>{w?this.fire(new a.B(w)):E&&m(E,o)})}else typeof i=="object"&&m(i,o)}loadURL(i,o={}){this.fire(new a.C("dataloading",{dataType:"style"}));const d=typeof o.validate=="boolean"?o.validate:!a.e(i);this.globalId=this._getGlobalId(i),i=this.map._requestManager.normalizeStyleURL(i,o.accessToken),this.resolvedImports.add(i);const m=this.importsCache.get(i);if(m)return this._load(m,d);const y=this.map._requestManager.transformRequest(i,a.R.Style);this._request=a.m(y,(v,w)=>{if(this._request=null,v)this.fire(new a.B(v));else if(w)return this.importsCache.set(i,w),this._load(w,d)})}loadJSON(i,o={}){this.fire(new a.C("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(i),this._request=a.o.frame(()=>{this._request=null,this._load(i,o.validate!==!1)})}loadEmpty(){this.fire(new a.C("dataloading",{dataType:"style"})),this._load(xd,!1)}_loadImports(i,o,d){if(this.importDepth>=4)return a.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const m=[];for(const y of i){const v=this._createFragmentStyle(y),w=new Promise(R=>{v.once("style.import.load",R),v.once("error",R)}).then(()=>{this.mergeAll(),this.fire(new a.C("data",{dataType:"style"}))});if(m.push(w),this.resolvedImports.has(y.url)){v.loadEmpty();continue}const E=y.data||this.importsCache.get(y.url);E?(y.data?(v.fire(new a.C("dataloading",{dataType:"style"})),v.globalId=v._getGlobalId(E),queueMicrotask(()=>v._load(E,o))):v.loadJSON(E,{validate:o}),this._isInternalStyle(E)&&(v.globalId=null)):y.url?v.loadURL(y.url,{validate:o}):v.loadEmpty();const P={style:v,id:y.id,config:y.config};if(d){const R=this.fragments.findIndex(({id:O})=>O===d);this.fragments=this.fragments.slice(0,R).concat(P).concat(this.fragments.slice(R))}else this.fragments.push(P)}return Promise.allSettled(m)}getImportGlobalIds(i=this,o=new Set){for(const d of i.fragments)d.style.globalId&&o.add(d.style.globalId),this.getImportGlobalIds(d.style,o);return[...o.values()]}_createFragmentStyle(i){const o=this.scope?a.F(i.id,this.scope):i.id;let d;const m=this._initialConfig&&this._initialConfig[o];(i.config||m)&&(d=Object.assign({},i.config,m));const y=new Js(this.map,{scope:o,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:d,configOptions:this.options,colorThemeOverride:i["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return y.setEventedParent(this.map,{style:y}),y}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(i){return this.isRootStyle()&&(i.fragment||!!i.schema&&i.fragment!==!1)}_load(i,o){if(this._isInternalStyle(i)){const y=Object.assign({},xd,{imports:[{id:"basemap",data:i,url:""}]},i.center?{center:i.center}:{},i.bearing?{bearing:i.bearing}:{},i.pitch?{pitch:i.pitch}:{},i.zoom?{zoom:i.zoom}:{},i.light?{light:i.light}:{});return this._importedAsBasemap=!0,void this._load(y,o)}if(this.updateConfig(this._config,i.schema),o&&Sl(this,Zs(i)))return;this._loaded=!0;for(const y in i.sources)this.addSource(y,i.sources[y],{validate:!1,isInitialLoad:!0});this.stylesheet=a.d9(i);const d=()=>{if(i.iconsets)for(const E in i.iconsets)this.addIconset(E,i.iconsets[E]);i.sprite?this._loadIconset(i.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&i.glyphs&&this.glyphManager.setURL(i.glyphs);const y=zp(this.stylesheet.layers);if(this._order=y.map(E=>E.id),this.stylesheet.light&&a.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(this.stylesheet.lights.length===1&&this.stylesheet.lights[0].type==="flat"){const E=this.stylesheet.lights[0];this.light=new zt(E.properties,E.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new zt(this.stylesheet.light)),this._layers={};for(const E of y){const P=a.de(E,this.scope,this._styleColorTheme.lut,this.options);P.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(P.fqid),P.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(P.fqid),this._hasAppearances=this._hasAppearances||P.getAppearances().length!==0,P.setEventedParent(this,{layer:{id:P.id}}),this._layers[P.id]=P;const R=this.getOwnLayerSourceCache(P),O=!!this.directionalLight&&this.directionalLight.shadowsEnabled();R&&P.canCastShadows()&&O&&(R.castsShadows=!0)}if(this.glyphManager.url){const E=new Set;for(const P in this._layers){const R=this._layers[P];if(R.type==="symbol"&&R.layout){const O=R.layout.get("text-font");O&&O.value&&O.value.kind==="constant"&&E.add(O.value.value.join(","))}}for(const P of E)this.glyphManager.prefetchRange(P,0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const v=this.stylesheet.terrain;v&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(v,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new a.C("data",{dataType:"style"}));const w=this.isRootStyle();i.imports?this._loadImports(i.imports,o).then(()=>{this._reloadImports(),this.fire(new a.C(w?"style.load":"style.import.load"))}).catch(E=>{this.fire(new a.B(new Error("Failed to load imports",E))),this.fire(new a.C(w?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new a.C(w?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const m=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(m){const y=this._evaluateColorThemeData(m);this._loadColorTheme(y).then(()=>{d()}).catch(v=>{a.w(`Couldn't load color theme from the stylesheet: ${v}`),d()})}else this._styleColorTheme.lut=null,d()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(i=>i.style.hasAppearances())}mergeAll(){let i,o,d,m,y,v,w,E,P,R;const O={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(k=>{if(k.stylesheet){if(k.light!=null&&(i=k.light),k.stylesheet.lights)for(const N of k.stylesheet.lights)N.type==="ambient"&&k.ambientLight!=null&&(o=k.ambientLight),N.type==="directional"&&k.directionalLight!=null&&(d=k.directionalLight);m=this._prioritizeTerrain(m,k.terrain,k.stylesheet.terrain),k.stylesheet.fog&&k.fog!=null&&(y=k.fog),k.stylesheet.snow&&k.snow!=null&&(v=k.snow),k.stylesheet.rain&&k.rain!=null&&(w=k.rain),k.stylesheet.camera!=null&&(R=k.stylesheet.camera),k.stylesheet.projection!=null&&(E=k.stylesheet.projection),k.stylesheet.transition!=null&&(P=k.stylesheet.transition),O[k.scope]=k._styleColorTheme}}),this.light=i,this.ambientLight=o,this.directionalLight=d,this.fog=y,this.snow=v,this.rain=w,this._styleColorThemeForScope=O,m===null?delete this.terrain:this.terrain=m,this.camera=R||{"camera-projection":"perspective"},this.projection=E||{name:"mercator"},this.transition=Object.assign({},$p,P),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(i){const o=d=>{for(const m of d.fragments)o(m.style);i(d)};o(this)}_prioritizeTerrain(i,o,d){const m=i&&i.drapeRenderMode===0;return d===null?o&&o.drapeRenderMode===0?o:m?i:null:o!=null&&(!i||m||o&&o.drapeRenderMode===1)?o:i}mergeTerrain(){let i;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(o=>{i=this._prioritizeTerrain(i,o.terrain,o.stylesheet.terrain)}),i===null?delete this.terrain:this.terrain=i}mergeProjection(){let i;this.forEachFragmentStyle(o=>{o.stylesheet.projection!=null&&(i=o.stylesheet.projection)}),this.projection=i||{name:"mercator"}}mergeSources(){const i={},o={},d={},m={};this.forEachFragmentStyle(y=>{for(const v in y._sourceCaches){const w=a.F(v,y.scope);i[w]=y._sourceCaches[v]}for(const v in y._otherSourceCaches){const w=a.F(v,y.scope);o[w]=y._otherSourceCaches[v]}for(const v in y._symbolSourceCaches){const w=a.F(v,y.scope);d[w]=y._symbolSourceCaches[v]}for(const v in y._fillExtrusionSourceCaches){const w=a.F(v,y.scope);m[w]=y._fillExtrusionSourceCaches[v]}}),this._mergedSourceCaches=i,this._mergedOtherSourceCaches=o,this._mergedSymbolSourceCaches=d,this._mergedFillExtrusionSourceCaches=m}mergeIndoor(){this.forEachFragmentStyle(i=>{if(i.stylesheet&&i.stylesheet.indoor)for(const o of Object.values(i.stylesheet.indoor)){const d=o,m=a.F(d.sourceId,i.scope);this._mergedIndoor[m]=new Set(d.sourceLayers||[])}})}mergeLayers(){const i={},o=[],d={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(v=>{for(const w of v._order){const E=v._layers[w];if(E.type==="slot"){const P=a.da(w);if(i[P])continue;i[P]=[]}E.slot&&i[E.slot]?i[E.slot].push(E):o.push(E)}}),this._mergedOrder=[];let m=-1;const y=(v=[])=>{for(const w of v)if(w.type==="slot"){const E=a.da(w.id);i[E]&&y(i[E]),this._mergedSlots.push(E)}else{const E=a.F(w.id,w.scope);this._mergedOrder.push(E),d[E]=w,w.is3D(!!this.terrain)&&(this._has3DLayers=!0,m=this._mergedOrder.length-1),w.type==="circle"&&(this._hasCircleLayers=!0),w.type==="symbol"&&(this._hasSymbolLayers=!0),w.type==="clip"&&(this._clipLayerPresent=!0)}};if(y(o),this._has3DLayers){const v={};for(let w=0;w<this._mergedOrder.length;++w){const E=this._mergedOrder[w];v[E]=w===m?1:w<m?d[E].hasOcclusionOpacityProperties?2:0:4}this._mergedOrder.sort((w,E)=>v[w]-v[E])}this._mergedLayers=d,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength()}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}getCamera(){return this.stylesheet.camera}setCamera(i){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,i),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(i){return i.data?function(o,d,m){const y=Object.assign({},d);for(const w of Object.keys(Up))y[w]===void 0&&(y[w]=Up[w].default);const v=new a.aa(Tc,o,new Map(m));return v.setTransitionOrValue(y,m),v.untransitioned().possiblyEvaluate(new a.ae(0,{worldview:void 0}))}(this.scope,i,this.options).get("data"):null}_loadColorTheme(i){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const o=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((d,m)=>{const y="data:image/png;base64,";if(!i||i.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void d();let v=i;v.startsWith(y)||(v=y+v);const w=a.I.from("mapbox-reserved-lut"),E=new Image;E.src=v,E.onerror=()=>{this._styleColorTheme.lutLoading=!1,m(new Error("Failed to load image data"))},E.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==o)return void d();this._styleColorTheme.lutLoading=!1;const{width:P,height:R,data:O}=a.o.getImageData(E);if(R>32)return void m(new Error("The height of the image must be less than or equal to 32 pixels."));if(P!==R*R)return void m(new Error("The width of the image must be equal to the height squared."));this.getImage(w)&&this.removeImage(w),this.addImage(w,{data:new a.q({width:P,height:R},O),pixelRatio:1,sdf:!1,usvg:!1,version:0});const k=this.imageManager.getImage(w,this.scope);k?(this._styleColorTheme.lut={image:k.data,data:i},d()):m(new Error("Missing LUT image."))}})}getLut(i){const o=this._styleColorThemeForScope[i];return o?o.lut:null}setProjection(i){i?this.stylesheet.projection=i: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(i){this._spriteRequest=function(o,d,m){let y,v,w;const E=a.o.devicePixelRatio>1?"@2x":"";let P=a.m(d.transformRequest(d.normalizeSpriteURL(o,E,".json"),a.R.SpriteJSON),(k,N)=>{P=null,w||(w=k,y=N,O())}),R=a.n(d.transformRequest(d.normalizeSpriteURL(o,E,".png"),a.R.SpriteImage),(k,N)=>{R=null,w||(w=k,v=N,O())});function O(){if(w)m(w);else if(y&&v){const k=a.o.getImageData(v),N={};for(const j in y){const{width:U,height:X,x:W,y:ie,sdf:ne,pixelRatio:K,stretchX:xe,stretchY:le,content:_e}=y[j],re=new a.q({width:U,height:X});a.q.copy(k,re,{x:W,y:ie},{x:0,y:0},{width:U,height:X},null),N[j]={data:re,pixelRatio:K!==void 0?K:1,sdf:ne!==void 0&&ne,stretchX:xe,stretchY:le,content:_e,usvg:!1,version:0}}m(null,N)}}return{cancel(){P&&(P.cancel(),P=null),R&&(R.cancel(),R=null)}}}(i,this.map._requestManager,(o,d)=>{if(this._spriteRequest=null,o)this.fire(new a.B(o));else if(d){const m=new Map;for(const y in d)m.set(a.I.from(y),d[y]);this.addImages(m)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new a.C("data",{dataType:"style"}))})}addIconset(i,o){if(o.type==="sprite")return void this._loadSprite(o.url);const d=this.getOwnSourceCache(o.source);if(!d)return void this.fire(new a.B(new Error(`Source "${o.source}" as specified by iconset "${i}" does not exist and cannot be used as an iconset source`)));const m=d.getSource();if(m.type!=="raster-array")return void this.fire(new a.B(new Error(`Source "${o.source}" as specified by iconset "${i}" is not a "raster-array" source and cannot be used as an iconset source`)));m.partial=!1;const y=new jp(i,this.scope,d);this.imageManager.addImageProvider(y,this.scope)}removeIconset(i){this.imageManager.removeImageProvider(i,this.scope)}_loadIconset(i){if(!a.e(i)&&this.map._spriteFormat!=="icon_set"||this.map._spriteFormat==="raster")return void this._loadSprite(i);const o=this.map._spriteFormat==="auto";var d,m;this._spriteRequest=(m=(y,v)=>{if(this._spriteRequest=null,y)o?this._loadSprite(i):this.fire(new a.B(y));else if(v){const w=new Map;for(const E in v)w.set(a.I.from(E),v[E]);this.addImages(w)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new a.C("data",{dataType:"style"}))},a.b1((d=this.map._requestManager).transformRequest(d.normalizeIconsetURL(i),a.R.Iconset),(y,v)=>{if(y)return void m(y);const w={},E=a.c$(new a.a$(v));for(const P of E.icons){const R={version:1,pixelRatio:a.o.devicePixelRatio,content:ay(P),stretchX:P.metadata?Gu(P.metadata.stretch_x_areas):void 0,stretchY:P.metadata?Gu(P.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:P};w[P.name]=R}m(null,w)}))}_validateLayer(i){const o=this.getOwnSource(i.source);if(!o)return;const d=i.sourceLayer;d&&(o.type==="geojson"||o.vectorLayerIds&&o.vectorLayerIds.indexOf(d)===-1)&&this.fire(new a.B(new Error(`Source layer "${d}" does not exist on source "${o.id}" as specified by style layer "${i.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const i in this._sourceCaches)if(!this._sourceCaches[i].loaded())return!1;if(!this.imageManager.isLoaded()||this.imageManager.hasPatternsInFlight()||!this.modelManager.isLoaded()||this._styleColorTheme.lutLoading)return!1;for(const{style:i}of this.fragments)if(!i.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((i,o)=>{const d=this.fragments[o];return d&&d.style&&(i.data=d.style.serialize()),i})}_serializeSources(){const i={};for(const o in this._sourceCaches){const d=this._sourceCaches[o].getSource();i[d.id]||(i[d.id]=d.serialize())}return i}_serializeLayers(i){const o=[];for(const d of i){const m=this._layers[d];m&&m.type!=="custom"&&o.push(m.serialize())}return o}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition()||this.hasSnowTransition()||this.hasRainTransition())return!0;for(const i in this._sourceCaches)if(this._sourceCaches[i].hasTransition())return!0;for(const i in this._layers)if(this._layers[i].hasTransition())return!0;return!1}_updateDataDrivenEmissiveStrength(){for(const i in this._mergedLayers){const o=this._mergedLayers[i];if(o._transitionablePaint&&o._transitionablePaint._values){const d=o._transitionablePaint._values["line-emissive-strength"];if(d&&d.value&&d.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(i){return i?this.order:this._mergedOrder}isLayerDraped(i){return!!this.terrain&&i.isDraped(this.getLayerSourceCache(i))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(i){const o=this.getOwnLayer(i);if(o)return o;this.fire(new a.B(new Error(`The layer '${i}' does not exist in the map's style.`)))}_checkSource(i){const o=this.getOwnSource(i);if(o)return o;this.fire(new a.B(new Error(`The source '${i}' does not exist in the map's style.`)))}precompilePrograms(i,o){const d=this.map.painter;if(d)for(let m=i.minzoom||0;m<(i.maxzoom||25.5);m++){const y=i.getProgramIds();if(y)for(const v of y){const w=i.getDefaultProgramParams(v,o.zoom,this._styleColorTheme.lut);w&&(d.style=this,this.fog&&(d._fogVisible=!0,w.overrideFog=!0,d.getOrCreateProgram(v,w)),d._fogVisible=!1,w.overrideFog=!1,d.getOrCreateProgram(v,w),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(w.overrideRtt=!0,d.getOrCreateProgram(v,w)))}}}update(i){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(i),this.directionalLight&&this.directionalLight.recalculate(i);const o=this.calculateLightsBrightness();i.brightness=o||0,o!==this._brightness&&(this._brightness=o,this.dispatcher.broadcast("setBrightness",o)),i.worldview!==this._worldview&&(this._worldview=i.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const d=this._changes.isDirty();let m=!1;if(this._changes.isDirty()){const E=this._changes.getLayerUpdatesByScope();for(const P in E){const{updatedIds:R,removedIds:O}=E[P];(R||O)&&(this._updateWorkerLayers(P,R,O),m=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(i),this.light&&this.light.updateTransitions(i),this.ambientLight&&this.ambientLight.updateTransitions(i),this.directionalLight&&this.directionalLight.updateTransitions(i),this.fog&&this.fog.updateTransitions(i),this.snow&&this.snow.updateTransitions(i),this.rain&&this.rain.updateTransitions(i),this._changes.reset()}const y={};for(const E in this._mergedSourceCaches){const P=this._mergedSourceCaches[E];y[E]=P.used,P.used=!1,P.tileCoverLift=0}const v={};for(const E of this._mergedOrder){const P=this._mergedLayers[E];if((P.visibility!=="none"||P.hasTransition())&&P.recalculate(i,this._availableImages),!P.isHidden(i.zoom)){const R=this.getLayerSourceCache(P);R&&(R.used=!0,R.tileCoverLift=Math.max(R.tileCoverLift,P.tileCoverLift()))}if(P.type==="fill-extrusion"){const R=a.F(P.source,P.scope);if(R in this._mergedFillExtrusionSourceCaches){const O=P.layout&&P.layout.get("source-max-zoom");if(O!=null){const k=v[R];v[R]=k==null?O:Math.min(k,O)}}}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(P,i)}):this.precompilePrograms(P,i))}this._shouldPrecompile&&(this._precompileDone=!0);for(const E in this._mergedFillExtrusionSourceCaches)this._mergedFillExtrusionSourceCaches[E].setMaxzoomOverride(v[E]!=null?v[E]:null);this.terrain&&m&&this.mergeLayers();const w=this.imageManager.getPendingImageProviders();for(const E of w)E.sourceCache.used=!0;for(const E in y){const P=this._mergedSourceCaches[E];y[E]!==P.used&&P.getSource().fire(new a.C("data",{sourceDataType:"visibility",dataType:"source",sourceId:P.getSource().id}))}this.light&&this.light.recalculate(i),this.terrain&&this.terrain.recalculate(i),this.fog&&this.fog.recalculate(i),this.snow&&this.snow.recalculate(i),this.rain&&this.rain.recalculate(i),this.z=i.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),d&&this.fire(new a.C("data",{dataType:"style"}))}updateImageProviders(){const i=this.imageManager.getPendingImageProviders();for(const o of i){const d=o.resolvePendingRequests(),m=this.getFragmentStyle(o.scope);m&&m.addImages(d)}}_updateTilesForChangedImages(){const i={};for(const o in this._mergedSourceCaches){const d=this._mergedSourceCaches[o].getSource().scope;i[d]=i[d]||this._changes.getUpdatedImages(d),i[d].length!==0&&this._mergedSourceCaches[o].reloadTilesForDependencies(["icons","patterns"],i[d])}for(const o in i)this._changes.resetUpdatedImages(o)}_updateWorkerLayers(i,o,d){const m=this.getFragmentStyle(i);m&&this.dispatcher.broadcast("updateLayers",{layers:o?m._serializeLayers(o):[],scope:i,removedIds:d||[],options:m.options})}setState(i,o){if(this._checkLoaded(),Sl(this,Zs(i)))return!1;(i=a.d9(i)).layers=zp(i.layers);const d=function(v,w){if(!v)return[{command:Ai.setStyle,args:[w]}];let E=[];try{if(!a.b6(v.version,w.version))return[{command:Ai.setStyle,args:[w]}];if(a.b6(v.center,w.center)||E.push({command:Ai.setCenter,args:[w.center]}),a.b6(v.zoom,w.zoom)||E.push({command:Ai.setZoom,args:[w.zoom]}),a.b6(v.bearing,w.bearing)||E.push({command:Ai.setBearing,args:[w.bearing]}),a.b6(v.pitch,w.pitch)||E.push({command:Ai.setPitch,args:[w.pitch]}),a.b6(v.sprite,w.sprite)||E.push({command:Ai.setSprite,args:[w.sprite]}),a.b6(v.glyphs,w.glyphs)||E.push({command:Ai.setGlyphs,args:[w.glyphs]}),a.b6(v.imports,w.imports)||function(N=[],j=[],U){j=j||[];const X=(N=N||[]).map(yc),W=j.map(yc),ie=N.reduce(Ru,{}),ne=j.reduce(Ru,{}),K=X.slice();let xe,le,_e,re;for(xe=0,le=0;xe<X.length;xe++)_e=X[xe],ne.hasOwnProperty(_e)?le++:(U.push({command:Ai.removeImport,args:[_e]}),K.splice(K.indexOf(_e,le),1));for(xe=0,le=0;xe<W.length;xe++)_e=W[W.length-1-xe],K[K.length-1-xe]!==_e&&(ie.hasOwnProperty(_e)?(U.push({command:Ai.removeImport,args:[_e]}),K.splice(K.lastIndexOf(_e,K.length-le),1)):le++,re=K[K.length-xe],U.push({command:Ai.addImport,args:[ne[_e],re]}),K.splice(K.length-xe,0,_e));for(const ae of j){const fe=ie[ae.id];fe&&(delete fe.data,a.b6(fe,ae)||U.push({command:Ai.updateImport,args:[ae.id,ae]}))}}(v.imports,w.imports,E),a.b6(v.transition,w.transition)||E.push({command:Ai.setTransition,args:[w.transition]}),a.b6(v.light,w.light)||E.push({command:Ai.setLight,args:[w.light]}),a.b6(v.fog,w.fog)||E.push({command:Ai.setFog,args:[w.fog]}),a.b6(v.snow,w.snow)||E.push({command:Ai.setSnow,args:[w.snow]}),a.b6(v.rain,w.rain)||E.push({command:Ai.setRain,args:[w.rain]}),a.b6(v.projection,w.projection)||E.push({command:Ai.setProjection,args:[w.projection]}),a.b6(v.lights,w.lights)||E.push({command:Ai.setLights,args:[w.lights]}),a.b6(v.camera,w.camera)||E.push({command:Ai.setCamera,args:[w.camera]}),a.b6(v.iconsets,w.iconsets)||function(N,j,U){let X;for(X in j=j||{},N=N||{})N.hasOwnProperty(X)&&(j.hasOwnProperty(X)||U.push({command:Ai.removeIconset,args:[X]}));for(X in j){if(!j.hasOwnProperty(X))continue;const W=j[X];N.hasOwnProperty(X)?a.b6(N[X],W)||(U.push({command:Ai.removeIconset,args:[X]}),U.push({command:Ai.addIconset,args:[X,W]})):U.push({command:Ai.addIconset,args:[X,W]})}}(v.iconsets,w.iconsets,E),!a.b6(v["color-theme"],w["color-theme"]))return[{command:Ai.setStyle,args:[w]}];const P={},R=[];(function(N,j,U,X){let W;for(W in j=j||{},N=N||{})N.hasOwnProperty(W)&&(j.hasOwnProperty(W)||gc(W,U,X));for(W in j){if(!j.hasOwnProperty(W))continue;const ie=j[W];N.hasOwnProperty(W)?a.b6(N[W],ie)||(N[W].type==="geojson"&&ie.type==="geojson"&&cd(N,j,W)?U.push({command:Ai.setGeoJSONSourceData,args:[W,ie.data]}):u1(W,j,U,X)):_c(W,j,U)}})(v.sources,w.sources,R,P);const O=[];v.layers&&v.layers.forEach(N=>{N.source&&P[N.source]?E.push({command:Ai.removeLayer,args:[N.id]}):O.push(N)});let k=v.terrain;k&&P[k.source]&&(E.push({command:Ai.setTerrain,args:[void 0]}),k=void 0),E=E.concat(R),a.b6(k,w.terrain)||E.push({command:Ai.setTerrain,args:[w.terrain]}),function(N,j,U){j=j||[];const X=(N=N||[]).map(yc),W=j.map(yc),ie=N.reduce(Ru,{}),ne=j.reduce(Ru,{}),K=X.slice(),xe=Object.create(null);let le,_e,re,ae,fe,Ce,ve;for(le=0,_e=0;le<X.length;le++)re=X[le],ne.hasOwnProperty(re)?_e++:(U.push({command:Ai.removeLayer,args:[re]}),K.splice(K.indexOf(re,_e),1));for(le=0,_e=0;le<W.length;le++)re=W[W.length-1-le],K[K.length-1-le]!==re&&(ie.hasOwnProperty(re)?(U.push({command:Ai.removeLayer,args:[re]}),K.splice(K.lastIndexOf(re,K.length-_e),1)):_e++,Ce=K[K.length-le],U.push({command:Ai.addLayer,args:[ne[re],Ce]}),K.splice(K.length-le,0,re),xe[re]=!0);for(le=0;le<W.length;le++)if(re=W[le],ae=ie[re],fe=ne[re],!xe[re]&&!a.b6(ae,fe))if(a.b6(ae.source,fe.source)&&a.b6(ae["source-layer"],fe["source-layer"])&&a.b6(ae.type,fe.type)){for(ve in Oa(ae.layout,fe.layout,U,re,null,Ai.setLayoutProperty),Oa(ae.paint,fe.paint,U,re,null,Ai.setPaintProperty),a.b6(ae.slot,fe.slot)||U.push({command:Ai.setSlot,args:[re,fe.slot]}),a.b6(ae.filter,fe.filter)||U.push({command:Ai.setFilter,args:[re,fe.filter]}),a.b6(ae.minzoom,fe.minzoom)&&a.b6(ae.maxzoom,fe.maxzoom)||U.push({command:Ai.setLayerZoomRange,args:[re,fe.minzoom,fe.maxzoom]}),ae)ae.hasOwnProperty(ve)&&ve!=="layout"&&ve!=="paint"&&ve!=="filter"&&ve!=="metadata"&&ve!=="minzoom"&&ve!=="maxzoom"&&ve!=="slot"&&(ve.indexOf("paint.")===0?Oa(ae[ve],fe[ve],U,re,ve.slice(6),Ai.setPaintProperty):a.b6(ae[ve],fe[ve])||U.push({command:Ai.setLayerProperty,args:[re,ve,fe[ve]]}));for(ve in fe)fe.hasOwnProperty(ve)&&!ae.hasOwnProperty(ve)&&ve!=="layout"&&ve!=="paint"&&ve!=="filter"&&ve!=="metadata"&&ve!=="minzoom"&&ve!=="maxzoom"&&ve!=="slot"&&(ve.indexOf("paint.")===0?Oa(ae[ve],fe[ve],U,re,ve.slice(6),Ai.setPaintProperty):a.b6(ae[ve],fe[ve])||U.push({command:Ai.setLayerProperty,args:[re,ve,fe[ve]]}))}else U.push({command:Ai.removeLayer,args:[re]}),Ce=K[K.lastIndexOf(re)+1],U.push({command:Ai.addLayer,args:[fe,Ce]})}(O,w.layers,E)}catch(P){console.warn("Unable to compute style diff:",P),E=[{command:Ai.setStyle,args:[w]}]}return E}(this.serialize(),i).filter(v=>!(v.command in ly));if(d.length===0)return!1;const m=d.filter(v=>!(v.command in _1));if(m.length>0)throw new Error(`Unimplemented: ${m.map(v=>v.command).join(", ")}.`);const y=[];return d.forEach(v=>{y.push(this[v.command](...v.args))}),o&&Promise.all(y).then(o).catch(o),this.stylesheet=i,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(i){if(i.size===0)return this;for(const[o,d]of i.entries()){if(this.getImage(o))return this.fire(new a.B(new Error(`An image with the name "${o.name}" already exists.`)));this.imageManager.addImage(o,this.scope,d),this._changes.updateImage(o,this.scope)}return this._updateWorkerImages(),this.fire(new a.C("data",{dataType:"style"})),this}addImage(i,o){return this.getImage(i)?this.fire(new a.B(new Error(`An image with the name "${i.name}" already exists.`))):(this.imageManager.addImage(i,this.scope,o),this._changes.updateImage(i,this.scope),this._updateWorkerImages(),this.fire(new a.C("data",{dataType:"style"})),this)}updateImage(i,o,d=!1){this.imageManager.updateImage(i,this.scope,o),d&&(this._changes.updateImage(i,this.scope),this._updateWorkerImages(),this.fire(new a.C("data",{dataType:"style"})))}getImage(i){return this.imageManager.getImage(i,this.scope)}removeImage(i){return this.getImage(i)?(this.imageManager.removeImage(i,this.scope),this._changes.updateImage(i,this.scope),this._updateWorkerImages(),this.fire(new a.C("data",{dataType:"style"})),this):this.fire(new a.B(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(i){return this.modelManager.addModelURLs(i,this.getActualScope()),this._updateWorkerModels(),this.fire(new a.C("data",{dataType:"style"})),this}addModel(i,o,d={}){return this._checkLoaded(),this._validate(rt,`models.${i}`,o,null,d)||(this.modelManager.addModel(i,o,this.getActualScope()),this.fire(new a.C("data",{dataType:"style"}))),this}hasModel(i){return this.modelManager.hasModel(i,this.getActualScope())}removeModel(i){return this.hasModel(i)?(this.modelManager.removeModel(i,this.getActualScope(),!1,!0),this.fire(new a.C("data",{dataType:"style"})),this):this.fire(new a.B(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(i,o,d={}){if(this._checkLoaded(),this.getOwnSource(i)!==void 0)throw new Error(`There is already a source with ID "${i}".`);if(!o.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(o).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(o.type)>=0&&this._validate(Cu,`sources.${i}`,o,null,d))return;this.map&&this.map._collectResourceTiming&&(o.collectResourceTiming=!0);const m=od(i,o,this.dispatcher,this);m.scope=this.scope,m.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(m.id),source:m.serialize(),sourceId:m.id}));const y=v=>{const w=(v===a.b4.Symbol?"symbol:":v===a.b4.FillExtrusion?"fill-extrusion:":"other:")+m.id,E=a.F(w,this.scope),P=this._sourceCaches[w]=new Ws(E,m,v);v===a.b4.Symbol?this._symbolSourceCaches[m.id]=P:v===a.b4.FillExtrusion?this._fillExtrusionSourceCaches[m.id]=P:this._otherSourceCaches[m.id]=P,P.onAdd(this.map)};y(a.b4.Other),o.type!=="vector"&&o.type!=="geojson"||(y(a.b4.Symbol),o.type==="vector"&&y(a.b4.FillExtrusion)),m.onAdd&&m.onAdd(this.map),d.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(i){this._checkLoaded();const o=this.getOwnSource(i);if(!o)throw new Error("There is no source with this ID");for(const m in this._layers)if(this._layers[m].source===i)return this.fire(new a.B(new Error(`Source "${i}" cannot be removed while layer "${m}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===i)return this.fire(new a.B(new Error(`Source "${i}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const m=Object.entries(this.stylesheet.iconsets).find(([y,v])=>v.type==="source"&&v.source===i);if(m)return this.fire(new a.B(new Error(`Source "${i}" cannot be removed while iconset "${m[0]}" is using it.`)))}const d=this.getOwnSourceCaches(i);for(const m of d){const y=a.da(m.id);delete this._sourceCaches[y],this._changes.discardSourceCacheUpdate(m.id),m.fire(new a.C("data",{sourceDataType:"metadata",dataType:"source",sourceId:m.getSource().id})),m.setEventedParent(null),m.clearTiles()}return delete this._otherSourceCaches[i],delete this._symbolSourceCaches[i],delete this._fillExtrusionSourceCaches[i],this.mergeSources(),o.setEventedParent(null),o.onRemove&&o.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(i,o){this._checkLoaded(),this.getOwnSource(i).setData(o),this._changes.setDirty()}getOwnSource(i){const o=this.getOwnSourceCache(i);return o&&o.getSource()}getOwnSources(){const i=[];for(const o in this._otherSourceCaches){const d=this.getOwnSourceCache(o);d&&i.push(d.getSource())}return i}areTilesLoaded(){const i=this._mergedSourceCaches;for(const o in i){const d=i[o]._tiles;for(const m in d){const y=d[m];if(y.state!=="loaded"&&y.state!=="errored")return!1}}return!0}setLights(i){if(this._checkLoaded(),!i)return delete this.ambientLight,void delete this.directionalLight;const o=this._getTransitionParameters();for(const y of i){if(this._validate($,"lights",y))return;switch(y.type){case"ambient":if(this.ambientLight){const v=this.ambientLight;v.set(y),v.updateTransitions(o)}else this.ambientLight=new Xn(y,Tr(),this.scope,this.options);break;case"directional":if(this.directionalLight){const v=this.directionalLight;v.set(y),v.updateTransitions(o)}else this.directionalLight=new Xn(y,us(),this.scope,this.options)}}const d=Object.assign(o,{worldview:this.map.getWorldview()}),m=new a.ae(this.z||0,d);this.ambientLight&&this.ambientLight.recalculate(m),this.directionalLight&&this.directionalLight.recalculate(m),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const i=this.directionalLight,o=this.ambientLight;if(!i||!o)return;const d=k=>.2126*(k[0]<=.03928?k[0]/12.92:Math.pow((k[0]+.055)/1.055,2.4))+.7152*(k[1]<=.03928?k[1]/12.92:Math.pow((k[1]+.055)/1.055,2.4))+.0722*(k[2]<=.03928?k[2]/12.92:Math.pow((k[2]+.055)/1.055,2.4)),m=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),y=i.properties.get("intensity"),v=i.properties.get("direction"),w=1-a.cP(v.x,v.y,v.z)[2]/90,E=d(m)*y*w,P=o.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),R=o.properties.get("intensity"),O=d(P)*R;return Number(((E+O)/2).toFixed(6))}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const i=[];return this.directionalLight&&i.push(this.directionalLight.get()),this.ambientLight&&i.push(this.ambientLight.get()),i}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(i){if(i==null||i===""&&this.isRootStyle())return this;if(a.db(i)){const o=a.dc(i),d=this.fragments.find(({id:y})=>y===o);if(!d)return;const m=a.da(i);return d.style.getFragmentStyle(m)}{const o=this.fragments.find(({id:d})=>d===i);return o?o.style:void 0}}setFeaturesetSelectors(i){if(!i)return;const o=(d,m="")=>`${d}::${m}`;this._featuresetSelectors={};for(const d in i){const m={},y=this._featuresetSelectors[d]=[];for(const v of i[d].selectors){if(v.featureNamespace){const E=this.getOwnLayer(v.layer);if(!E){a.w(`Layer is undefined for selector: ${v.layer}`);continue}const P=o(E.source,E.sourceLayer);if(P in m&&m[P]!==v.featureNamespace){a.w(`"featureNamespace ${v.featureNamespace} of featureset ${d}'s selector is not associated to the same source, skip this selector`);continue}m[P]=v.featureNamespace}let w;if(v.properties)for(const E in v.properties){const P=a.X(v.properties[E]);P.result==="success"&&(w=w||{},w[E]=P.value)}y.push({layerId:v.layer,namespace:v.featureNamespace,properties:w,uniqueFeatureID:v._uniqueFeatureID})}}}getFeaturesetDescriptors(i){const o=this.getFragmentStyle(i);if(!o||!o.stylesheet.featuresets)return[];const d=[];for(const m in o.stylesheet.featuresets)d.push({featuresetId:m,importId:o.scope?o.scope:void 0});return d}getFeaturesetLayers(i,o){const d=this.getFragmentStyle(o),m=d.stylesheet.featuresets;if(!m||!m[i])return this.fire(new a.B(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried.`))),[];const y=[];for(const v of m[i].selectors){const w=d.getOwnLayer(v.layer);w&&y.push(w)}return y}getConfigProperty(i,o){const d=this.getFragmentStyle(i);if(!d)return null;const m=a.F(o,d.scope),y=d.options.get(m),v=y?y.value||y.default:null;return v?v.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(i,o){const d=a.F(i,o);return this._mergedIndoor[d]}setIndoorData(i,o){this.indoorManager.setIndoorData(o)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(i,o,d){const m=this.getFragmentStyle(i);if(!m)return;const y=m.stylesheet.schema;if(!y||!y[o])return;const v=a.X(d);if(v.result!=="success")return void Sl(this,v.value);const w=v.value.expression,E=a.F(o,m.scope),P=m.options.get(E);if(!P)return;let R;const{minValue:O,maxValue:k,stepValue:N,type:j,values:U}=y[o],X=a.X(y[o].default);X.result==="success"&&(R=X.value.expression),R?(this.options.set(E,Object.assign({},P,{value:w,default:R,minValue:O,maxValue:k,stepValue:N,type:j,values:U})),this.updateConfigDependencies(o)):this.fire(new a.B(new Error(`No schema defined for the config option "${o}" in the "${i}" fragment.`)))}getConfig(i){const o=this.getFragmentStyle(i);if(!o)return null;const d=o.stylesheet.schema;if(!d)return null;const m={};for(const y in d){const v=a.F(y,o.scope),w=o.options.get(v),E=w?w.value||w.default:null;m[y]=E?E.serialize():null}return m}setConfig(i,o){const d=this.getFragmentStyle(i);d&&(d.updateConfig(o,d.stylesheet.schema),this.updateConfigDependencies())}getSchema(i){const o=this.getFragmentStyle(i);return o?o.stylesheet.schema:null}setSchema(i,o){const d=this.getFragmentStyle(i);d&&(d.stylesheet.schema=o,d.updateConfig(d._config,o),this.updateConfigDependencies())}updateConfig(i,o){if(this._config=i,i||o)if(o)for(const d in o){let m,y;const v=a.X(o[d].default);if(v.result==="success"&&(m=v.value.expression),i&&i[d]!==void 0){const k=a.X(i[d]);k.result==="success"&&(y=k.value.expression)}const{minValue:w,maxValue:E,stepValue:P,type:R,values:O}=o[d];if(m){const k=a.F(d,this.scope);this.options.set(k,{default:m,value:y,minValue:w,maxValue:E,stepValue:P,type:R,values:O})}else this.fire(new a.B(new Error(`No schema defined for config option "${d}".`)))}else this.fire(new a.B(new Error("Attempting to set config for a style without schema.")))}_updateLayers(i,o=()=>!0){for(const d of i){const m=this.getLayer(d);m&&o(m)&&(m.possiblyEvaluateVisibility(),this._updateLayer(m),this._changes.setDirty())}}updateConfigDependencies(i){this._updateLayers(this._configDependentLayers,o=>!i||o.expressionDependencies.configDependencies.has(i)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(o=>{const d=o._styleColorTheme.colorThemeOverride?o._styleColorTheme.colorThemeOverride:o._styleColorTheme.colorTheme;if(d){const m=o._evaluateColorThemeData(d);(!o._styleColorTheme.lut&&m!==""||o._styleColorTheme.lut&&m!==o._styleColorTheme.lut.data)&&o.setColorTheme(d)}}),this._changes.setDirty()}addLayer(i,o,d={}){this._checkLoaded();const m=i.id;if(this._layers[m])return void this.fire(new a.B(new Error(`Layer with id "${m}" already exists on this map`)));let y;if(i.type==="custom"){if(Sl(this,a.dd(i)))return;y=a.de(i,this.scope,this._styleColorTheme.lut,this.options)}else{if(typeof i.source=="object"&&(this.addSource(m,i.source),i=a.d9(i),i=Object.assign(i,{source:m})),this._validate(Te,`layers.${m}`,i,{arrayIndex:-1},d))return;y=a.de(i,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(y),y.setEventedParent(this,{layer:{id:m}})}const v=a.F(y.source,y.scope);y.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(v),y.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(v);let w=this._order.length;if(o){const O=this._order.indexOf(o);if(O===-1)return void this.fire(new a.B(new Error(`Layer with id "${o}" does not exist on this map.`)));y.slot&&y.slot!==this._layers[o].slot?a.w(`Layer with id "${o}" has a different slot. Layers can only be rearranged within the same slot.`):w=O}this._order.splice(w,0,m),this._handleLayerOrderChange(),this._layers[m]=y;const E=this.getOwnLayerSourceCache(y),P=!!this.directionalLight&&this.directionalLight.shadowsEnabled();E&&y.canCastShadows()&&P&&(E.castsShadows=!0);const R=this._changes.getRemovedLayer(y);if(R&&y.source&&E&&y.type!=="custom"){this._changes.discardLayerRemoval(y);const O=a.F(y.source,y.scope);R.type!==y.type?this._changes.updateSourceCache(O,"clear"):(this._changes.updateSourceCache(O,"reload"),E.pause())}this._updateLayer(y),y.onAdd&&y.onAdd(this.map),y.scope=this.scope,this.mergeLayers()}moveLayer(i,o){this._checkLoaded();const d=this._checkLayer(i);if(!d||i===o)return;const m=this._order.indexOf(i);this._order.splice(m,1);let y=this._order.length;if(o){const v=this._order.indexOf(o);if(v===-1)return void this.fire(new a.B(new Error(`Layer with id "${o}" does not exist on this map.`)));d.slot&&d.slot!==this._layers[o].slot?a.w(`Layer with id "${o}" has a different slot. Layers can only be rearranged within the same slot.`):y=v}this._order.splice(y,0,i),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers()}removeLayer(i){this._checkLoaded();const o=this._checkLayer(i);if(!o)return;o.setEventedParent(null);const d=this._order.indexOf(i);this._order.splice(d,1),delete this._layers[i],this._changes.setDirty(),this._handleLayerOrderChange(),this._configDependentLayers.delete(o.fqid),this._indoorDependentLayers.delete(o.fqid),this._changes.removeLayer(o);const m=this.getOwnLayerSourceCache(o);if(m&&m.castsShadows){let y=!1;for(const v in this._layers)if(this._layers[v].source===o.source&&this._layers[v].canCastShadows()){y=!0;break}m.castsShadows=y}o.onRemove&&o.onRemove(this.map),this.mergeLayers()}getOwnLayer(i){return this._layers[i]}hasLayer(i){return i in this._mergedLayers}hasLayerType(i){for(const o in this._layers)if(this._layers[o].type===i)return!0;return!1}setLayerZoomRange(i,o,d){this._checkLoaded();const m=this._checkLayer(i);m&&(m.minzoom===o&&m.maxzoom===d||(o!=null&&(m.minzoom=o),d!=null&&(m.maxzoom=d),this._updateLayer(m)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(i,o){this._checkLoaded();const d=this._checkLayer(i);d&&d.slot!==o&&(d.slot=o,this._updateLayer(d))}setFilter(i,o,d={}){this._checkLoaded();const m=this._checkLayer(i);if(m&&!a.b6(m.filter,o))return o==null?(m.filter=void 0,void this._updateLayer(m)):void(this._validate(De,`layers.${m.id}.filter`,o,{layerType:m.type},d)||(m.filter=a.d9(o),this._updateLayer(m)))}getFilter(i){const o=this._checkLayer(i);if(o)return a.d9(o.filter)}setLayoutProperty(i,o,d,m={}){this._checkLoaded();const y=this._checkLayer(i);if(y&&!a.b6(y.getLayoutProperty(o),d)){if(d!=null&&(!m||m.validate!==!1)&&Sl(y,Le.call(Zs,{key:`layers.${i}.layout.${o}`,layerType:y.type,objectKey:o,value:d,styleSpec:a.a8,style:{glyphs:!0,sprite:!0}})))return;y.setLayoutProperty(o,d),y.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(y.fqid),y.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(y.fqid),this._updateLayer(y)}}setLayerProperty(i,o,d,m={}){this._checkLoaded();const y=this._checkLayer(i);y&&(o==="appearances"?(y.setAppearances(d),this._updateLayer(y)):y.isPaintProperty(o)?this.setPaintProperty(i,o,d,m):this.setLayoutProperty(i,o,d,m))}getLayoutProperty(i,o){const d=this._checkLayer(i);if(d)return d.getLayoutProperty(o)}setPaintProperty(i,o,d,m={}){this._checkLoaded();const y=this._checkLayer(i);if(!y||a.b6(y.getPaintProperty(o),d)||d!=null&&(!m||m.validate!==!1)&&Sl(y,Ae.call(Zs,{key:`layers.${i}.paint.${o}`,layerType:y.type,objectKey:o,value:d,styleSpec:a.a8})))return;const v=y.setPaintProperty(o,d);y.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(y.fqid),y.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(y.fqid),v&&this._updateLayer(y),this._changes.updatePaintProperties(y)}getPaintProperty(i,o){const d=this._checkLayer(i);if(d)return d.getPaintProperty(o)}setFeatureState(i,o){if(this._checkLoaded(),"target"in i){if("featuresetId"in i.target){const{featuresetId:E,importId:P}=i.target,R=this.getFragmentStyle(P),O=R.getFeaturesetLayers(E);for(const{source:k,sourceLayer:N}of O)R.setFeatureState({id:i.id,source:k,sourceLayer:N},o)}else if("layerId"in i.target){const{layerId:E}=i.target,P=this.getLayer(E);this.setFeatureState({id:i.id,source:P.source,sourceLayer:P.sourceLayer},o)}return}const d=i.source,m=i.sourceLayer,y=this._checkSource(d);if(!y)return;const v=y.type;if(v==="geojson"&&m)return void this.fire(new a.B(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(v==="vector"&&!m)return void this.fire(new a.B(new Error("The sourceLayer parameter must be provided for vector source types.")));i.id===void 0&&this.fire(new a.B(new Error("The feature id parameter must be provided.")));const w=this.getOwnSourceCaches(d);for(const E of w)E.setFeatureState(m,i.id,o)}removeFeatureState(i,o){if(this._checkLoaded(),"target"in i){if("featuresetId"in i.target){const{featuresetId:E,importId:P}=i.target,R=this.getFragmentStyle(P),O=R.getFeaturesetLayers(E);for(const{source:k,sourceLayer:N}of O)R.removeFeatureState({id:i.id,source:k,sourceLayer:N},o)}else if("layerId"in i.target){const{layerId:E}=i.target,P=this.getLayer(E);this.removeFeatureState({id:i.id,source:P.source,sourceLayer:P.sourceLayer},o)}return}const d=i.source,m=this._checkSource(d);if(!m)return;const y=m.type,v=y==="vector"?i.sourceLayer:void 0;if(y==="vector"&&!v)return void this.fire(new a.B(new Error("The sourceLayer parameter must be provided for vector source types.")));if(o&&typeof i.id!="string"&&typeof i.id!="number")return void this.fire(new a.B(new Error("A feature id is required to remove its specific state property.")));const w=this.getOwnSourceCaches(d);for(const E of w)E.removeFeatureState(v,i.id,o)}getFeatureState(i){if(this._checkLoaded(),"target"in i){let y;if("featuresetId"in i.target){const{featuresetId:v,importId:w}=i.target,E=this.getFragmentStyle(w),P=E.getFeaturesetLayers(v);for(const{source:R,sourceLayer:O}of P){const k=E.getFeatureState({id:i.id,source:R,sourceLayer:O});if(k&&!y)y=k;else if(!a.b6(y,k))return void this.fire(new a.B(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in i.target){const{layerId:v}=i.target,w=this.getLayer(v);y=this.getFeatureState({id:i.id,source:w.source,sourceLayer:w.sourceLayer})}return y}const o=i.source,d=i.sourceLayer,m=this._checkSource(o);if(m){if(m.type!=="vector"||d)return i.id===void 0&&this.fire(new a.B(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(o)[0].getFeatureState(d,i.id);this.fire(new a.B(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(i){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,i),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}setWorldview(i){i!==this._worldview&&(this._worldview=i,this.dispatcher.broadcast("setWorldview",this._worldview),this.reloadSources())}serialize(){this._checkLoaded();const i=this.getTerrain(),o=i&&this.terrain&&this.terrain.scope===this.scope?i:this.stylesheet.terrain;return a.df({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:o,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],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)},d=>d!==void 0)}_updateFilteredLayers(i){for(const o of Object.values(this._mergedLayers))i(o)&&this._updateLayer(o)}_updateLayer(i){this._changes.updateLayer(i);const o=this.getLayerSourceCache(i),d=a.F(i.source,i.scope),m=this._changes.getUpdatedSourceCaches();i.source&&!m[d]&&o&&o.getSource().type!=="raster"&&(this._changes.updateSourceCache(d,"reload"),o.pause()),i.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(i){const o=w=>this._mergedLayers[w].is3D(!!this.terrain),d=this.order,m={},y=[];for(let w=d.length-1;w>=0;w--){const E=d[w];if(o(E)){m[E]=w;for(const P of i){const R=P[E];if(R)for(const O of R)y.push(O)}}}y.sort((w,E)=>E.intersectionZ-w.intersectionZ);const v=[];for(let w=d.length-1;w>=0;w--){const E=d[w];if(o(E))for(let P=y.length-1;P>=0;P--){const R=y[P].feature;if(R.layer&&m[R.layer.id]<w)break;v.push(R),y.pop()}else for(const P of i){const R=P[E];if(R)for(const O of R)v.push(O.feature)}}return v}queryRasterValue(i,o,d){const m=this.getOwnSource(i);return m?m.type!=="raster-array"?(this.fire(new a.B(new Error('queryRasterValue support only "raster-array" sources.'))),Promise.resolve(null)):m.queryRasterArrayValue(o,d):(this.fire(new a.B(new Error(`Source with id "${i}" does not exist in the style.`))),Promise.resolve(null))}queryRenderedFeatures(i,o,d){let m;o&&!Array.isArray(o)&&o.filter&&(this._validate(De,"queryRenderedFeatures.filter",o.filter,null,o),m=a.dg(o.filter));const y={},v=R=>{if(Gp.has(R.type))return;const O=this.getOwnLayerSourceCache(R),k=y[O.id]=y[O.id]||{sourceCache:O,layers:{},has3DLayers:!1};R.is3D(!!this.terrain)&&(k.has3DLayers=!0),k.layers[R.fqid]=k.layers[R.fqid]||{styleLayer:R,targets:[]},k.layers[R.fqid].targets.push({filter:m})};if(o&&o.layers){if(!Array.isArray(o.layers))return this.fire(new a.B(new Error("parameters.layers must be an Array."))),[];for(const R of o.layers){const O=this._layers[R];if(!O)return this.fire(new a.B(new Error(`The layer '${R}' does not exist in the map's style and cannot be queried for features.`))),[];v(O)}}else for(const R in this._layers)v(this._layers[R]);const w=this._queryRenderedFeatures(i,y,d),E=this._flattenAndSortRenderedFeatures(w),P=[];for(const R of E)a.dh(R.layer.id)===this.scope&&P.push(R);return P}queryRenderedFeatureset(i,o,d){let m;o&&!Array.isArray(o)&&o.filter&&(this._validate(De,"queryRenderedFeatures.filter",o.filter,null,o),m=a.dg(o.filter));const y="mock",v=[];if(o&&o.target)v.push(Object.assign({},o,{targetId:y,filter:m}));else{const R=this.getFeaturesetDescriptors();for(const O of R)v.push({targetId:y,filter:m,target:O});for(const{style:O}of this.fragments){const k=O.getFeaturesetDescriptors();for(const N of k)v.push({targetId:y,filter:m,target:N})}}const w=this.queryRenderedTargets(i,v,d),E=[],P=new Set;for(const R of w)for(const O of R.variants[y])Bo(O,R,P)||E.push(new a.di(R,O));return E}queryRenderedTargets(i,o,d){const m={},y=(w,E,P,R)=>{const O=m[E.id]=m[E.id]||{sourceCache:E,layers:{},has3DLayers:!1};if(O.layers[w.fqid]=O.layers[w.fqid]||{styleLayer:w,targets:[]},w.is3D(!!this.terrain)&&(O.has3DLayers=!0),!R)return P.uniqueFeatureID=!1,void O.layers[w.fqid].targets.push(P);O.layers[w.fqid].targets.push(Object.assign({},P,{namespace:R.namespace,properties:R.properties,uniqueFeatureID:R.uniqueFeatureID}))};for(const w of o)if("featuresetId"in w.target){const{featuresetId:E,importId:P}=w.target,R=this.getFragmentStyle(P);if(!R||!R._featuresetSelectors)continue;const O=R._featuresetSelectors[E];if(!O){this.fire(new a.B(new Error(`The featureset '${E}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const k of O){const N=R.getOwnLayer(k.layerId);N&&!Gp.has(N.type)&&y(N,R.getOwnLayerSourceCache(N),w,k)}}else if("layerId"in w.target){const{layerId:E}=w.target,P=this.getLayer(E);if(!P||Gp.has(P.type))continue;y(P,this.getLayerSourceCache(P),w)}const v=this._queryRenderedFeatures(i,m,d);return this._flattenAndSortRenderedFeatures(v)}_queryRenderedFeatures(i,o,d){const m=[],y=!!this.map._showQueryGeometry,v=hs.createFromScreenPoints(i,d);for(const w in o){const E=ty(v,o[w],this._availableImages,d,y,this.getActualScope());Object.keys(E).length&&m.push(E)}if(this.placement)for(const w in o){if(o[w].sourceCache._renderSourceType!==a.b4.Symbol)continue;const E=ad(v.screenGeometry,o[w],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(E).length&&m.push(E)}return m}querySourceFeatures(i,o){const d=o&&o.filter;d&&this._validate(De,"querySourceFeatures.filter",d,null,o);let m=[];const y=this.getOwnSourceCaches(i);for(const v of y)m=m.concat(Mp(v,o));return m}addSourceType(i,o,d){return Js.getSourceType(i)?d(new Error(`A source type called "${i}" already exists.`)):(Js.setSourceType(i,o),o.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:i,url:o.workerSourceURL},d):d(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(i,o,d={}){this._checkLoaded();const m=this.light.getLight();let y=!1;for(const w in i)if(!a.b6(i[w],m[w])){y=!0;break}if(!y)return;const v=this._getTransitionParameters();this.light.setLight(i,o,d),this.light.updateTransitions(v)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){this.disableElevatedTerrain===void 0&&(this.disableElevatedTerrain=a.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&a.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(i,o=1){if(this._checkLoaded(),!i)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),o===0&&delete this.terrain,i===null?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let d=i;const m=!("source"in i)||i.source==null;if(o===1){if(this.disableElevatedTerrain)return;if("source"in d&&typeof d.source=="object"){const w="terrain-dem-src";this.addSource(w,d.source),d=a.d9(d),d=Object.assign(d,{source:w})}const y=Object.assign({},d),v={};if(this.terrain&&m){y.source=this.terrain.get().source;const w=this.terrain?this.getFragmentStyle(this.terrain.scope):null;w&&(v.style=w.serialize())}if(this._validate(q,"terrain",y,v))return}if(!this.terrain||this.terrain.scope!==this.scope&&!m||this.terrain&&o!==this.terrain.drapeRenderMode){if(!d)return;this._createTerrain(d,o),this.fire(new a.C("data",{dataType:"style"}))}else{const y=this.terrain,v=y.get();for(const w of Object.keys(a.a8.terrain))!d.hasOwnProperty(w)&&a.a8.terrain[w].default&&(d[w]=a.a8.terrain[w].default);for(const w in i)if(!a.b6(i[w],v[w])){y.set(i,this.options),this.stylesheet.terrain=i;const E=this._getTransitionParameters({duration:0});y.updateTransitions(E),this.fire(new a.C("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(i){const o=this.fog=new cn(i,this.map.transform,this.scope,this.options);this.stylesheet.fog=o.get();const d=this._getTransitionParameters({duration:0});o.updateTransitions(d)}_createSnow(i){const o=this.snow=new wn(i,this.map.transform,this.scope,this.options);this.stylesheet.snow=o.get();const d=this._getTransitionParameters({duration:0});o.updateTransitions(d)}_createRain(i){const o=this.rain=new yi(i,this.map.transform,this.scope,this.options);this.stylesheet.rain=o.get();const d=this._getTransitionParameters({duration:0});o.updateTransitions(d)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const i of this.map._markers)i._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(i){if(this._checkLoaded(),!i)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const o=this.fog;if(!a.b6(o.get(),i)){o.set(i,this.options),this.stylesheet.fog=o.get();const d=this._getTransitionParameters({duration:0});o.updateTransitions(d)}}else this._createFog(i);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(i){if(this._checkLoaded(),!i)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const o=this.snow;if(!a.b6(o.get(),i)){o.set(i,this.options),this.stylesheet.snow=o.get();const d=this._getTransitionParameters({duration:0});o.updateTransitions(d)}}else this._createSnow(i);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(i){if(this._checkLoaded(),!i)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const o=this.rain;if(!a.b6(o.get(),i)){o.set(i,this.options),this.stylesheet.rain=o.get();const d=this._getTransitionParameters({duration:0});o.updateTransitions(d)}}else this._createRain(i);this._markersNeedUpdate=!0}_reloadColorTheme(){const i=()=>{for(const m in this._layers)this._layers[m].lut=this._styleColorTheme.lut;for(const m in this._sourceCaches)this._sourceCaches[m].clearTiles()},o=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!o)return this._styleColorTheme.lut=null,void i();const d=this._evaluateColorThemeData(o);this._loadColorTheme(d).then(()=>{this.fire(new a.C("colorthemeset")),i()}).catch(m=>{a.w(`Couldn't set color theme: ${m}`)})}setColorTheme(i){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&a.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=i,this._reloadColorTheme()}setImportColorTheme(i,o){const d=this.getFragmentStyle(i);d&&(d._styleColorTheme.colorThemeOverride=o,d._reloadColorTheme())}_getTransitionParameters(i){return{now:a.o.now(),transition:Object.assign(this.transition,i)}}updateDrapeFirstLayers(){if(!this.terrain)return;const i=[],o=[];for(const d of this._mergedOrder)this.isLayerDraped(this._mergedLayers[d])?i.push(d):o.push(d);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...i),this._drapedFirstOrder.push(...o)}_createTerrain(i,o){const d=this.terrain=new hi(i,o,this.scope,this.options,this.map.getWorldview());o===1&&(this.stylesheet.terrain=i),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const m=this._getTransitionParameters({duration:0});d.updateTransitions(m)}_force3DLayerUpdate(){for(const i in this._layers){const o=this._layers[i];o.type==="fill-extrusion"&&this._updateLayer(o)}}_forceSymbolLayerUpdate(){for(const i in this._layers){const o=this._layers[i];o.type==="symbol"&&this._updateLayer(o)}}_validate(i,o,d,m,y={}){if(y&&y.validate===!1)return!1;const v=Object.assign({},this.serialize());return Sl(this,i.call(Zs,Object.assign({key:o,style:v,value:d,styleSpec:a.a8},m)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.dj.off("pluginStateChange",this._rtlTextPluginCallback);for(const i in this._mergedLayers)this._mergedLayers[i].setEventedParent(null);for(const i in this._mergedSourceCaches)this._mergedSourceCaches[i].clearTiles(),this._mergedSourceCaches[i].setEventedParent(null);this.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),this.dispatcher.remove())}clearSource(i){const o=this.getSourceCaches(i);for(const d of o)d.clearTiles()}clearSources(){for(const i in this._mergedSourceCaches)this._mergedSourceCaches[i].clearTiles()}clearLayers(){for(const i in this._mergedLayers){const o=this._mergedLayers[i];o._clear&&o._clear()}}reloadSource(i){const o=this.getSourceCaches(i);for(const d of o)d.resume(),d.reload()}reloadSources(){for(const i of this.getSources())i.reload&&i.reload()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(i=>{i.modelManager.reloadModels(i.scope)})}updateSources(i){let o;this.directionalLight&&(o=oy(this.directionalLight));const d=new Set,m=new Set,y=new Set;for(const v in this._mergedLayers){const w=this._mergedLayers[v];w.type==="building"?d.add(w.source):w.type==="raster"&&w.paint&&w.paint.get("raster-elevation-reference")==="ground"&&y.add(w.source),w.hasElevation()&&!m.has(w.source)&&m.add(w.source)}for(const v in this._mergedSourceCaches){const w=this._mergedSourceCaches[v],E=m.has(w._source.id);w._isRasterElevatedOverTerrain=y.has(w._source.id),d.has(w._source.id)&&(w._source.reparseOverscaled=!1),w.update(i,void 0,void 0,o,E)}}_generateCollisionBoxes(){for(const i in this._sourceCaches){const o=this._sourceCaches[i];o.resume(),o.reload()}}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new a.C("neworder"))}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Fu),this.pauseablePlacement.requestFullPlacement()}_setLabelPlacementStale(){this.placement&&this.placement.setStale()}_updatePlacement(i,o,d,m,y){this.pauseablePlacement||(this.pauseablePlacement=new Fu);let v=!1,w=!1;const E={},P={};for(const U of this._mergedOrder){const X=this._mergedLayers[U];if(X.type!=="symbol")continue;const W=a.F(X.source,X.scope);let ie=E[W];if(!ie){const K=this.getLayerSourceCache(X);if(!K)continue;const xe=K.getRenderableIds(!0).map(le=>K.getTileByID(le));P[W]=xe.slice(),ie=E[W]=xe.sort((le,_e)=>_e.tileID.overscaledZ-le.tileID.overscaledZ||(le.tileID.isLessThan(_e.tileID)?-1:1))}const ne=this.crossTileSymbolIndex.addLayer(X,ie,i.center.lng,i.projection);v=v||ne}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const R=!!(this.placement&&!i.equals(this.placement.transform)),O=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!y||this.placement.lastReplacementSourceUpdateTime!==y.updateTime)),k=R||O||v,N=(k||this.pauseablePlacement.isStale())&&d===0,j=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.o.now(),i.zoom)&&d!==0;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||N||j)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(i,this._mergedOrder,o,d,m,this.placement,this.fog&&i.projection.supportsFog?this.fog.state:null,this._buildingIndex),this.map.painter)){const U=this.map.painter.maxFrontCutoffRawStart;if(U>0){const X=180*i.pitch/Math.PI;if(X>=15){const W=Math.min(1,Math.max(0,(X-15)/5)),ie=W*W*(3-2*W);this.pauseablePlacement.placement.frontCutoffStart=-.5*(1-ie)+U*ie}}}if(this.pauseablePlacement.isDone()?k&&d!==0&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,E,P,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.o.now()),w=!0),v&&this.pauseablePlacement.setStale()),w||v){this._buildingIndex.onNewFrame(i.zoom);for(let U=0;U<this._mergedOrder.length;U++){const X=this._mergedLayers[this._mergedOrder[U]];if(X.type!=="symbol"||X.visibility==="none")continue;const W=this.isLayerClipped(X);this.placement.updateLayerOpacities(X,E[a.F(X.source,X.scope)],U,W?y:null)}}return!this.pauseablePlacement.isDone()||this.placement.isStale()||this.placement.hasTransitions(a.o.now())}_releaseSymbolFadeTiles(){for(const i in this._sourceCaches)this._sourceCaches[i].releaseSymbolFadeTiles()}addImport(i,o){this._checkLoaded();const d=this.stylesheet.imports=this.stylesheet.imports||[];if(d.findIndex(({id:y})=>y===i.id)!==-1)return void this.fire(new a.B(new Error(`Import with id '${i.id}' already exists in the map's style.`)));if(!o)return d.push(i),this._loadImports([i],!0);const m=d.findIndex(({id:y})=>y===o);return m===-1&&this.fire(new a.B(new Error(`Import with id "${o}" does not exist on this map.`))),this.stylesheet.imports=d.slice(0,m).concat(i).concat(d.slice(m)),this._loadImports([i],!0,o)}updateImport(i,o){this._checkLoaded();const d=this.stylesheet.imports||[],m=this.getImportIndex(i);return m===-1?this:typeof o=="string"?(this.setImportUrl(i,o),this):(o.url&&o.url!==d[m].url&&this.setImportUrl(i,o.url),a.b6(o.config,d[m].config)||this.setImportConfig(i,o.config,o.data.schema),a.b6(o.data,d[m].data)||this.setImportData(i,o.data),this)}moveImport(i,o){this._checkLoaded();let d=this.stylesheet.imports||[];const m=this.getImportIndex(i);if(m===-1)return this;const y=this.getImportIndex(o);if(y===-1)return this;const v=d[m],w=this.fragments[m];return d=d.filter(({id:E})=>E!==i),this.fragments=this.fragments.filter(({id:E})=>E!==i),this.stylesheet.imports=d.slice(0,y).concat(v).concat(d.slice(y)),this.fragments=this.fragments.slice(0,y).concat(w).concat(this.fragments.slice(y)),this.mergeLayers(),this}setImportUrl(i,o){this._checkLoaded();const d=this.stylesheet.imports||[],m=this.getImportIndex(i);if(m===-1)return this;d[m].url=o;const y=this.fragments[m];return y.style=this._createFragmentStyle(d[m]),y.style.on("style.import.load",()=>this.mergeAll()),y.style.loadURL(o),this}setImportData(i,o){this._checkLoaded();const d=this.getImportIndex(i),m=this.stylesheet.imports||[];return d===-1?this:o?(this.fragments[d].style.setState(o),this._reloadImports(),this):(delete m[d].data,this.setImportUrl(i,m[d].url))}setImportConfig(i,o,d){this._checkLoaded();const m=this.getImportIndex(i),y=this.stylesheet.imports||[];if(m===-1)return this;o?y[m].config=o:delete y[m].config;const v=this.fragments[m];d&&v.style.stylesheet&&(v.style.stylesheet.schema=d);const w=v.style.stylesheet&&v.style.stylesheet.schema;return v.config=o,v.style.updateConfig(o,w),this.updateConfigDependencies(),this}removeImport(i){this._checkLoaded();const o=this.stylesheet.imports||[],d=this.getImportIndex(i);d!==-1&&(o.splice(d,1),this.fragments[d].style._remove(),this.fragments.splice(d,1),this._reloadImports())}getImportIndex(i){const o=(this.stylesheet.imports||[]).findIndex(d=>d.id===i);return o===-1&&this.fire(new a.B(new Error(`Import '${i}' does not exist in the map's style and cannot be updated.`))),o}getLayer(i){return this._mergedLayers[i]}getSources(){const i=[];for(const o in this._mergedOtherSourceCaches){const d=this._mergedOtherSourceCaches[o];d&&i.push(d.getSource())}return i}getSource(i,o){const d=this.getSourceCache(i,o);return d&&d.getSource()}getLayerSource(i){const o=this.getLayerSourceCache(i);return o&&o.getSource()}getSourceCache(i,o){const d=a.F(i,o);return this._mergedOtherSourceCaches[d]}getLayerSourceCache(i){const o=a.F(i.source,i.scope);return i.type==="symbol"?this._mergedSymbolSourceCaches[o]:i.type==="fill-extrusion"&&this._mergedFillExtrusionSourceCaches[o]||this._mergedOtherSourceCaches[o]}getSourceCaches(i){if(i==null)return Object.values(this._mergedSourceCaches);const o=[];return this._mergedOtherSourceCaches[i]&&o.push(this._mergedOtherSourceCaches[i]),this._mergedSymbolSourceCaches[i]&&o.push(this._mergedSymbolSourceCaches[i]),this._mergedFillExtrusionSourceCaches[i]&&o.push(this._mergedFillExtrusionSourceCaches[i]),o}updateSourceCaches(){const i=this._changes.getUpdatedSourceCaches();for(const o in i){const d=i[o];d==="reload"?this.reloadSource(o):d==="clear"&&this.clearSource(o)}}updateLayers(i){const o=this._changes.getUpdatedPaintProperties();for(const d of o){const m=this.getLayer(d);m&&m.updateTransitions(i)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(i){this.stylesheet.glyphs=i,this.glyphManager.setURL(i)}getImages(i,o,d){this.imageManager.getImages(o.images,o.scope,d),this._updateTilesForChangedImages();const m=v=>{if(v){const w=o.images.map(E=>a.I.toString(E));v.setDependencies(o.tileID.key,o.type,w)}},y=a.F(o.source,o.scope);m(this._mergedOtherSourceCaches[y]),m(this._mergedSymbolSourceCaches[y]),o.images.some(v=>v.iconsetId)&&this.fire(new a.C("data",{dataType:"style"}))}rasterizeImages(i,o,d){this.imageManager.rasterizeImages(o,d)}checkAtlasCache(i,o,d){const m=this.imageManager.imageAtlasCache.findCachedAtlas(o.descriptor);d(null,m&&m.contentDescriptor?{iconPositions:m.iconPositions,patternPositions:m.patternPositions,sourceHash:m.contentDescriptor.hash}:null)}getGlyphs(i,o,d){this.glyphManager.getGlyphs(o.stacks,d)}getOwnSourceCache(i){return this._otherSourceCaches[i]}getOwnLayerSourceCache(i){return i.type==="symbol"?this._symbolSourceCaches[i.source]:i.type==="fill-extrusion"&&this._fillExtrusionSourceCaches[i.source]||this._otherSourceCaches[i.source]}getOwnSourceCaches(i){const o=[];return this._otherSourceCaches[i]&&o.push(this._otherSourceCaches[i]),this._symbolSourceCaches[i]&&o.push(this._symbolSourceCaches[i]),this._fillExtrusionSourceCaches[i]&&o.push(this._fillExtrusionSourceCaches[i]),o}_isSourceCacheLoaded(i){const o=this.getOwnSourceCaches(i);return o.length===0?(this.fire(new a.B(new Error(`There is no source with ID '${i}'`))),!1):o.every(d=>d.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(i,o){if(!this._clipLayerPresent&&i.type!=="fill-extrusion"&&i.type!=="building")return!1;const d=i.type==="fill-extrusion"&&(i.sourceLayer==="building"||i.sourceLayer==="procedural_buildings"),m=i.type==="building";if(i.is3D(!!this.terrain)){if(d||m||o&&o.type==="batched-model"||i.type==="model")return!0}else if(i.type==="symbol")return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(i=>{i.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Js.getSourceType=function(u){return sd[u]},Js.setSourceType=function(u,i){sd[u]=i},Js.registerForPluginStateChange=a.dk;var Hp=`
#define EPSILON 0.0000001
#define PI 3.141592653589793
#ifdef RENDER_CUTOFF
float 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);}
#endif`,Zp=`
#ifdef DUAL_SOURCE_BLENDING
layout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;
#elif defined(FLOAT_RENDER_TARGET)
layout(location=0) out highp vec4 glFragColor;
#else
layout(location=0) out vec4 glFragColor;
#endif
#ifdef USE_MRT1
layout(location=1) out vec4 out_Target1;
#endif
highp float unpack_depth(highp vec4 rgba_depth)
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}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;}
#ifdef INDICATOR_CUTOUT
uniform vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;
#endif
const float DITHER_THRESHOLDS[16]=float[16](
1.0/17.0, 9.0/17.0, 3.0/17.0,11.0/17.0,13.0/17.0, 5.0/17.0,15.0/17.0, 7.0/17.0,4.0/17.0,12.0/17.0, 2.0/17.0,10.0/17.0,16.0/17.0, 8.0/17.0,14.0/17.0, 6.0/17.0
);vec4 applyCutout(vec4 color,float height) {
#ifdef INDICATOR_CUTOUT
float verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));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);
#else
return color;
#endif
}float cutoutGroundRoofOpacity(vec4 groundRoof) {
#ifdef INDICATOR_CUTOUT
float fadeStartX=u_indicator_cutout_params.w;float holeRadius=u_indicator_cutout_params.y;float holeMinOpacity=mix(u_indicator_cutout_params.x,1.0,smoothstep(u_indicator_cutout_params.z,u_indicator_cutout_centers.z,groundRoof.y));float distX=abs(u_indicator_cutout_centers.x-groundRoof.x);float roofOpacity=mix(holeMinOpacity,1.0,smoothstep(fadeStartX,holeRadius,u_indicator_cutout_centers.y-groundRoof.w));float groundOpacity=min(smoothstep(fadeStartX,holeRadius,distX)+holeMinOpacity,1.0);return max(roofOpacity,groundOpacity);
#else
return 1.0;
#endif
}
#ifdef DEBUG_WIREFRAME
#define HANDLE_WIREFRAME_DEBUG \\
glFragColor=vec4(0.7,0.0,0.0,0.7); \\
gl_FragDepth=gl_FragCoord.z-0.0001;
#else
#define HANDLE_WIREFRAME_DEBUG
#endif
#ifdef RENDER_CUTOFF
uniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;
#endif
vec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}`,ja=`
#define EXTENT 8192.0
#define RAD_TO_DEG 180.0/PI
#define DEG_TO_RAD PI/180.0
#define GLOBE_RADIUS EXTENT/PI/2.0
float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}
#ifdef PROJECTION_GLOBE_VIEW
vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
#ifndef PROJECTED_POS_ON_VIEWPORT
float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
#else
return vec3(0.0);
#endif
}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
#endif
vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec4 decode_color(const vec2 encodedColor) {return vec4(
unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const vec2 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 (units_to_pixels*pos+offset)/pattern_size;}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) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}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);}
#ifdef RENDER_CUTOFF
uniform vec4 u_cutoff_params;out float v_cutoff_opacity;
#endif
const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(ivec2 posWithComposedSkirt)
{float skirt=float(float(posWithComposedSkirt.x) >=skirtOffset);vec2 pos=vec2(posWithComposedSkirt)-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}
#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer
#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib
#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib
#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib
#define DECLARE_MATERIAL_TABLE_INFO
#endif`,$u="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;}",qp=`
#define ELEVATION_SCALE 7.0
#define ELEVATION_OFFSET 450.0
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}
#else
vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
#endif
#ifdef TERRAIN
uniform 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;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) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;
#else
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=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);
#endif
}float prevElevation(vec2 apos) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;
#else
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=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);
#endif
}
#ifdef TERRAIN_VERTEX_MORPHING
float elevation(vec2 apos) {
#ifdef ZERO_EXAGGERATION
return 0.0;
#endif
float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
#else
float elevation(vec2 apos) {
#ifdef ZERO_EXAGGERATION
return 0.0;
#endif
return currentElevation(apos);}
#endif
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);}
#else
float elevation(vec2 pos) { return 0.0; }
#endif
#ifdef DEPTH_OCCLUSION
uniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;
#ifdef DEPTH_D24
float unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}
#else
highp float unpack_depth_rgba(vec4 rgba_depth)
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}
#endif
bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;
#ifdef CLIP_ZERO_TO_ONE
coord.z=-1.0+2.0*coord.z; 
#endif
#ifdef DEPTH_D24
float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);
#else
float depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));
#endif
return coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;
#ifdef DEPTH_D24
highp vec4 depth=vec4(
texture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r
);depth=unpack_depth4(depth);
#else
highp vec4 depth=vec4(
unpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))
);
#endif
return depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;
#ifdef CLIP_ZERO_TO_ONE
coord.z=-1.0+2.0*coord.z; 
#endif
int NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {
#ifdef DEPTH_D24
highp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);
#else
highp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));
#endif
res+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;
#ifdef CLIP_ZERO_TO_ONE
coord.z=-1.0+2.0*coord.z; 
#endif
highp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}
#else
bool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }
#endif`,Wp=`#ifdef FOG
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;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);}
#endif`,Sc=`#ifdef FOG
uniform 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;
#ifdef FLIP_Y
uv.y=1.0-uv.y;
#endif
highp vec3 ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float 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) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
#endif`,Ec=`#ifdef RASTER_ARRAY
uniform highp 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)
);}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)
);}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);}
#endif`,Xp=`#ifdef RASTER_ARRAY
uniform 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 vec2 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=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}
#endif
uniform 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;}`,vd=`#ifdef RENDER_SHADOWS
uniform 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) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,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];}
#endif`,Ps=`#ifdef RENDER_SHADOWS
precision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform 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;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {
#ifdef CLIP_ZERO_TO_ONE
highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);
#else
highp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias);
#endif
return texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;
#ifdef SHADOWS_SINGLE_CASCADE
vec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);
#else
light_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);
#endif
}highp float calculate_shadow_bias(float NDotL) {
#ifdef NORMAL_OFFSET
return 0.5*u_shadow_bias.x;
#else
return 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));
#endif
}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_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {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)*shadow_opacity;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));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)
{highp vec2 biasUV=vec2(
pos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}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);}
#endif`;const Hu=/#include\s+"([^"]+)"/g,_t=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,cy=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,uy=new Set(["ifdef","ifndef","elif","if","defined"]),El=new Set;ua(Hp,El),ua(ja,El),ua(Zp,El);const _o={"_prelude_fog.vertex.glsl":Wp,"_prelude_terrain.vertex.glsl":qp,"_prelude_shadow.vertex.glsl":vd,"_prelude_material_table.vertex.glsl":`#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer
#define MATERIAL_TABLE_DEBUG 0
uniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;
#if MATERIAL_TABLE_DEBUG
vec4 colorDebug;
#endif
};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { 
if (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; 
}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { 
iRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;
#if MATERIAL_TABLE_DEBUG
const vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;
#endif
uint offset=0u;
#if MATERIAL_TABLE_DEBUG
bool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}
#endif
offset++;
#if MATERIAL_TABLE_DEBUG
uint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}
#endif
offset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);
#if MATERIAL_TABLE_DEBUG
if(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}
#endif
uint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);
#if MATERIAL_TABLE_DEBUG
if(keepFinding)
{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}
#endif
offset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;
#if MATERIAL_TABLE_DEBUG
if(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}
#endif
info.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)
{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}
#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)
#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)
#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)
#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));
#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;
#endif`,"_prelude_fog.fragment.glsl":Sc,"_prelude_shadow.fragment.glsl":Ps,"_prelude_lighting.glsl":`
#ifdef LIGHTING_3D_MODE
uniform 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);}
#endif`,"_prelude_raster_array.glsl":Ec,"_prelude_raster_particle.glsl":Xp},Ic={};xi("",qp),xi(Sc,Wp),xi(Ps,vd),xi(Ec,""),xi(Xp,"");const Ga=xi(Zp,ja),Zu=Hp,Ac=[`
#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)
#extension GL_EXT_blend_func_extended : require
#endif`,"precision mediump float;",Zu,Ga.fragmentSource].join(`
`),g1=["precision highp float;",Zu,Ga.vertexSource].join(`
`);var hy={background:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;
#ifdef LIGHTING_3D_MODE
in vec4 v_color;
#endif
void main() {vec4 out_color;
#ifdef FEATURE_CUTOUT
vec2 uv=gl_FragCoord.xy*u_inv_viewport_size.xy;
#ifdef FLIP_Y
uv.y=1.0-uv.y;
#endif
float factorTex=min(texture(u_cutout_factor_image,uv).r,1.0);float cutoutFactor=(1.0-u_feature_cutout_params.x)*factorTex;out_color=u_color*(1.0-cutoutFactor);
#else
#ifdef LIGHTING_3D_MODE
out_color=v_color;
#else
out_color=u_color;
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
#endif
glFragColor=out_color*u_opacity;
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_lighting.glsl"
in ivec2 a_pos;uniform mat4 u_matrix;uniform mediump float u_emissive_strength;
#ifdef LIGHTING_3D_MODE
uniform mediump vec4 u_color;out vec4 v_color;
#endif
void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
#ifndef FEATURE_CUTOUT
#ifdef LIGHTING_3D_MODE
v_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);
#endif
#ifdef FOG
v_fog_pos=fog_position(vec2(a_pos));
#endif
#endif
}`),backgroundPattern:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform 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 highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
glFragColor=out_color*u_opacity;
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in ivec2 a_pos;out highp vec2 v_pos;void main() {vec2 pos=vec2(a_pos);gl_Position=u_matrix*vec4(pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,pos);
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),building:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_shadow.fragment.glsl"
#include "_prelude_lighting.glsl"
const float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;
#ifdef RENDER_FRONT_CUTOFF
in float v_front_cutoff_opacity;
#endif
#ifdef INDICATOR_CUTOUT
#ifdef FEATURE_CUTOUT
in vec4 v_ground_roof;
#endif
#endif
#ifdef BUILDING_FAUX_FACADE
in lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;
#endif
#ifdef RENDER_SHADOWS
in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
#endif
#ifdef FLOOD_LIGHT
in highp float v_flood_radius;in float v_has_flood_light;
#endif
uniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}
#ifdef BUILDING_FAUX_FACADE
highp float hash12(in highp vec2 p) {highp vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}highp vec2 get_uv_mask_id(in highp vec2 q,out highp float mask,out highp vec2 id) {highp vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;highp vec2 uv=modf(p/v_faux_facade_floor,id);highp vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;highp vec4 edge=d/v_faux_facade_floor.xyxy;highp vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}highp float ray_unit_box(in highp vec3 ray_o,in highp vec3 ray_d,in highp vec3 bmin,in highp vec3 bmax) {highp vec3 planes=mix(bmin,bmax,step(0.0,ray_d));highp vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in highp vec3 v,in highp vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;highp vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;
#if 0
if (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;
#else
if (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;
#endif
return out_color;}
#endif
vec3 apply_lighting_linear(in vec3 color,in vec3 normal,in 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 color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;
#ifdef BUILDING_FAUX_FACADE
if (v_faux_facade > 0.0) {highp mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);highp vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;highp vec3 view_tangent=transpose(tbn)*v;highp vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);highp vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;highp vec3 bmin=vec3(0.0,0.0,-window_depth);highp vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);highp vec3 ray_o=vec3(uv,0.0);highp vec3 ray_d=normalize(view_tangent);highp float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);highp vec3 hit=ray_o+t_min*ray_d;highp vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;highp vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}
#endif
vec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;
#ifdef RENDER_SHADOWS
#ifdef RENDER_CUTOFF
shadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}
#else
shadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);
#endif
#else
shadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));
#endif
color.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);
#ifdef FLOOD_LIGHT
float flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);
#endif
color.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));
#endif
color*=u_opacity;
#ifdef INDICATOR_CUTOUT
#ifdef FEATURE_CUTOUT
{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}
#else
color=applyCutout(color,v_pos.z);
#endif
#endif
#ifdef RENDER_FRONT_CUTOFF
if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}
#endif
#ifdef FEATURE_CUTOUT
color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);
#endif
glFragColor=color;
#ifdef DEBUG_SHOW_NORMALS
color.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
in vec3 a_pos_3f;in ivec4 a_normal_3;in ivec4 a_centroid_3;
#ifdef FLOOD_LIGHT
in int a_flood_light_wall_radius_1i16;
#endif
#ifdef BUILDING_FAUX_FACADE
in uvec4 a_faux_facade_data;in uvec2 a_faux_facade_vertical_range;
#endif
uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;
#ifdef RENDER_FRONT_CUTOFF
uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;
#endif
#ifdef INDICATOR_CUTOUT
#ifdef FEATURE_CUTOUT
out vec4 v_ground_roof;
#endif
#endif
out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;
#ifdef BUILDING_FAUX_FACADE
out lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;
#endif
#ifdef RENDER_SHADOWS
uniform 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;
#endif
#ifdef FLOOD_LIGHT
out highp float v_flood_radius;out float v_has_flood_light;
#endif
const float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
#ifdef BUILDING_FAUX_FACADE
mat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}
#endif
#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive
#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 faux_facade_color_emissive
void main() {
#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive
#pragma mapbox: initialize-attribute-custom highp uvec2 faux_facade_color_emissive
#ifdef FLOOD_LIGHT
v_flood_radius=(float(a_flood_light_wall_radius_1i16)/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);
#endif
vec4 color_emissive=decode_color(vec2(part_color_emissive));v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=vec3(a_normal_3)/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;vec2 centroid_xy=vec2(a_centroid_3.xy >> 2);vec2 spanBits=vec2(a_centroid_3.xy & 3);
#ifdef BUILDING_FAUX_FACADE
vec4 faux_facade_data=vec4(a_faux_facade_data);v_faux_facade=faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(faux_facade_data.y/TWO_POW_8);float window_y_perc=faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(vec2(a_faux_facade_vertical_range)/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(vec2(faux_facade_color_emissive));v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);depth_offset=min(1000.0,float(a_centroid_3.z))*0.0000002;}
#endif
v_pos=a_pos_3f;
#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
float halfSpanX=spanBits.x*10.0/u_tile_to_meter;float halfSpanY=spanBits.y*10.0/u_tile_to_meter;vec2 screenUpInTile=vec2(u_matrix[0][1],u_matrix[1][1]);vec2 spanOffset=vec2(halfSpanX,halfSpanY)*sign(screenUpInTile);vec2 cutoff_highestCorner=centroid_xy+spanOffset;vec2 cutoff_lowestCorner=centroid_xy-spanOffset;
#endif
#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
vec4 ground=u_matrix*vec4(centroid_xy,0.0,1.0);
#endif
#ifdef RENDER_CUTOFF
v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;
#endif
#ifdef RENDER_SHADOWS
vec3 shadow_pos=v_pos;
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();
#endif
v_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);
#endif
#ifdef FOG
v_fog_pos=fog_position(v_pos);
#endif
#ifdef RENDER_FRONT_CUTOFF
v_front_cutoff_opacity=1.0;{hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;hidden=max(hidden,float(ndc_y < threshold-range_ndc));float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}
#endif
gl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;
#ifdef INDICATOR_CUTOUT
#ifdef FEATURE_CUTOUT
vec4 ic_ground=u_matrix*vec4(v_pos.xy,0.0,1.0);vec4 ic_roof=u_matrix*vec4(v_pos.xy,v_pos.z,1.0);v_ground_roof=vec4(ic_ground.xy/ic_ground.w,ic_roof.xy/ic_roof.w);
#endif
#endif
}`),buildingBloom:xi(`in vec4 v_color_emissive;
#pragma mapbox: define-attribute highp vec4 bloom_attenuation
#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation
float saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;
#ifdef HAS_ATTRIBUTE_a_bloom_attenuation
float distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);
#endif
#ifdef RENDER_CUTOFF
opacity*=v_cutoff_opacity;
#endif
glFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}`,`in vec3 a_pos_3f;
#pragma mapbox: define-attribute-vertex-shader-only highp uvec2 part_color_emissive
#pragma mapbox: define-attribute highp vec4 bloom_attenuation
out vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {
#pragma mapbox: initialize-attribute-custom highp uvec2 part_color_emissive
#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation
#ifdef HAS_ATTRIBUTE_a_part_color_emissive
vec4 color_emissive=decode_color(vec2(part_color_emissive));float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);
#else
v_color_emissive=vec4(1.0);
#endif
gl_Position=u_matrix*vec4(a_pos_3f,1.0);
#ifdef RENDER_CUTOFF
v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
#endif
}`),buildingDepth:xi("void main() {}","in vec3 a_pos_3f;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),circle:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
in vec3 v_data;in float v_visibility;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump float radius
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp vec4 stroke_color
#pragma mapbox: define mediump float stroke_width
#pragma mapbox: define lowp float stroke_opacity
uniform float u_emissive_strength;void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump float radius
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp vec4 stroke_color
#pragma mapbox: initialize mediump float stroke_width
#pragma mapbox: initialize lowp float stroke_opacity
vec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? 
smoothstep(0.0,-antialiased_blur,1.0-extrude_length) : 
smoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#endif
#ifdef FOG
out_color=fog_apply_premultiplied(out_color,v_fog_pos);
#endif
glFragColor=out_color*(v_visibility*opacity_t);
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
#define NUM_VISIBILITY_RINGS 2
#define INV_SQRT2 0.70710678
#define ELEVATION_BIAS 0.0001
#define NUM_SAMPLES_PER_RING 16
uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in ivec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
#endif
#ifdef ELEVATED_ROADS
in float a_circle_z_offset;
#endif
out vec3 v_data;out float v_visibility;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump float radius
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp vec4 stroke_color
#pragma mapbox: define mediump float stroke_width
#pragma mapbox: define lowp float stroke_opacity
vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1.0,-1.0),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1.0,-1.0),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1.0,1.0),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1.0,1.0),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
#if defined(TERRAIN)
return elevation(pos)+ELEVATION_BIAS;
#else
return 0.0;
#endif
}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
#ifdef PITCH_WITH_MAP
#ifdef PROJECTION_GLOBE_VIEW
return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
#else
return u_matrix*( world_center+vec4(sample_offset,0,0) );
#endif
#else
return projected_center+vec4(sample_offset,0,0);
#endif
}float get_sample_step() {
#ifdef PITCH_WITH_MAP
return 2.0*PI/float(NUM_SAMPLES_PER_RING);
#else
return PI/float(NUM_SAMPLES_PER_RING);
#endif
}void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump float radius
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp vec4 stroke_color
#pragma mapbox: initialize mediump float stroke_width
#pragma mapbox: initialize lowp float stroke_opacity
vec2 pos2=vec2(a_pos);vec2 extrude=vec2(mod(pos2,2.0)*2.0-1.0);vec2 circle_center=floor(pos2*0.5);float height=circle_elevation(circle_center);vec4 world_center;mat3 surface_vectors;
#ifdef PROJECTION_GLOBE_VIEW
surface_vectors=globe_mercator_surface_vectors(vec3(a_pos_normal_3)/16384.0,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)*height;vec3 globe_pos=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*height;vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);
#else 
surface_vectors=mat3(1.0);world_center=vec4(circle_center,height,1);
#endif
#ifdef ELEVATED_ROADS
world_center.z+=a_circle_z_offset+ELEVATION_BIAS;
#endif
vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
#ifdef PITCH_WITH_MAP
#ifdef SCALE_WITH_MAP
view_scale=1.0;
#else
view_scale=projected_center.w/u_camera_to_center_distance;
#endif
#else
#ifdef SCALE_WITH_MAP
view_scale=u_camera_to_center_distance;
#else
view_scale=projected_center.w;
#endif
#endif
gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
#ifdef TERRAIN
float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;
#ifdef PITCH_WITH_MAP
float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;
#else
occlusion_world_center=world_center;occlusion_projected_center=projected_center;
#endif
for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
#else
visibility=1.0;
#endif
#ifdef PROJECTION_GLOBE_VIEW
visibility=1.0;
#endif
v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
#ifdef FOG
v_fog_pos=fog_position(world_center.xyz);
#endif
}`),clippingMask:xi("void main() {glFragColor=vec4(1.0);}","in ivec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:xi(`#include "_prelude_fog.fragment.glsl"
uniform highp float u_intensity;in vec2 v_extrude;
#pragma mapbox: define highp float weight
#define GAUSS_COEF 0.3989422804014327
void main() {
#pragma mapbox: initialize highp float weight
float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);
#ifdef FOG
if (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl"
#include "_prelude_fog.vertex.glsl"
uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in ivec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
#endif
out vec2 v_extrude;
#pragma mapbox: define highp float weight
#pragma mapbox: define mediump float radius
const highp float ZERO=1.0/255.0/16.0;
#define GAUSS_COEF 0.3989422804014327
void main() {
#pragma mapbox: initialize highp float weight
#pragma mapbox: initialize mediump float radius
vec2 unscaled_extrude=vec2(mod(vec2(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(vec2(a_pos)*0.5);vec3 pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 pos_normal_3=vec3(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=vec3(a_pos_3)+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#else
pos=vec3(tilePos+extrude,elevation(tilePos));
#endif
gl_Position=u_matrix*vec4(pos,1);
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),heatmapTexture:xi(`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;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(0.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),collisionBox:xi("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"
in ivec4 a_pos;in ivec2 a_anchor_pos;in ivec2 a_extrude;in uvec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;
#endif
out float v_placed;out float v_notUsed;void main() {vec2 anchor_pos=vec2(a_anchor_pos);float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(anchor_pos));vec3 proj_pos=vec3(a_pos)+elevationVector(anchor_pos)*(feature_elevation+terrain_elevation);
#ifdef PROJECTION_GLOBE_VIEW
#ifndef PROJECTED_POS_ON_VIEWPORT
vec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);
#endif
#endif
vec4 projectedPoint=u_matrix*vec4(proj_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(vec2(a_extrude)*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=float(a_placed.x);v_notUsed=float(a_placed.y);}`),collisionCircle:xi("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 ivec2 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;int vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(
mix(-1.0,1.0,float(vertexIdx >=2)),mix(-1.0,1.0,float(vertexIdx >=1 && vertexIdx <=2)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=float(a_flags.x);gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:xi("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"
in ivec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
in ivec4 a_pos_3;
#endif
out vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {vec2 pos=vec2(a_pos);float h=elevation(pos);v_uv=pos/8192.0;
#ifdef PROJECTION_GLOBE_VIEW
gl_Position=u_matrix*vec4(vec3(a_pos_3)+elevationVector(pos)*h,1);
#else
gl_Position=u_matrix*vec4(pos*u_overlay_scale,h,1);
#endif
}`),elevatedStructuresDepth:xi("void main() {}","in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:xi(`#ifdef DEPTH_RECONSTRUCTION
in float v_height;
#endif
void main() {
#ifdef DEPTH_RECONSTRUCTION
if (v_height >=0.0)
discard;
#else
#ifdef FEATURE_CUTOUT
apply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord,get_cutout_factors(gl_FragCoord).x);
#endif
#endif
glFragColor=vec4(1.0,0.0,0.0,1.0);}`,`in ivec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;
#ifdef DEPTH_RECONSTRUCTION
out float v_height;
#endif
void main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);
#ifdef DEPTH_RECONSTRUCTION
if (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;
#endif
gl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}`),elevatedStructures:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
in vec3 v_normal;in float v_height;
#ifdef RENDER_SHADOWS
in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;
#endif
vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)
{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;
#pragma mapbox: define highp vec4 structure_color
void main() {
#pragma mapbox: initialize highp vec4 structure_color
vec3 color=structure_color.xyz;vec2 cutout_factors=vec2(0.0);
#ifdef FEATURE_CUTOUT
cutout_factors=get_cutout_factors(gl_FragCoord);
#endif
#ifdef LIGHTING_3D_MODE
vec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);color.rgb=apply_lighting(color.rgb,transformed_normal,light);
#else
color=apply_lighting(color,transformed_normal);
#endif
color=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}
#endif
#ifdef FOG
color=fog_apply(color,v_fog_pos);
#endif
vec4 out_color=vec4(color,1.0);
#ifdef INDICATOR_CUTOUT
out_color=applyCutout(out_color,v_height);
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
#endif
glFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
in ivec2 a_pos;in float a_height;in ivec4 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;
#ifdef RENDER_SHADOWS
uniform 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;out float v_depth;
#endif
#pragma mapbox: define highp vec4 structure_color
void main() {
#pragma mapbox: initialize highp vec4 structure_color
v_normal=vec3(a_pos_normal_3)/16384.0;v_height=a_height;vec3 pos=vec3(vec2(a_pos),a_height);gl_Position=u_matrix*vec4(pos,1);
#ifdef RENDER_SHADOWS
vec3 shd_pos0=pos;vec3 shd_pos1=pos;
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_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);v_depth=gl_Position.w;
#endif
#ifdef FOG
v_fog_pos=fog_position(vec2(a_pos));
#endif
}`),fill:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float opacity
uniform float u_emissive_strength;
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
#ifdef ELEVATED_ROADS
in highp float v_road_z_offset;
#endif
#ifdef INDICATOR_CUTOUT
in highp float v_z_offset;
#endif
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float opacity
vec2 cutout_factors=vec2(0.0);
#ifdef FEATURE_CUTOUT
cutout_factors=get_cutout_factors(gl_FragCoord);
#endif
vec4 out_color=color;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
out_color*=opacity;
#ifdef INDICATOR_CUTOUT
if (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
#endif
glFragColor=out_color;
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
in ivec2 a_pos;
#ifdef ELEVATED_ROADS
in float a_road_z_offset;out highp float v_road_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform 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;out highp float v_depth;
#endif
#ifdef INDICATOR_CUTOUT
out highp float v_z_offset;
#endif
uniform mat4 u_matrix;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp float z_offset
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp float z_offset
#ifdef ELEVATED_ROADS
z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
#endif
float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);
#ifdef RENDER_SHADOWS
vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_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);v_depth=gl_Position.w;
#endif
#ifdef FOG
v_fog_pos=fog_position(vec2(a_pos));
#endif
#ifdef INDICATOR_CUTOUT
v_z_offset=z_offset;
#endif
}`),fillOutline:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
in highp vec2 v_pos;uniform float u_emissive_strength;
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
#pragma mapbox: define highp vec4 outline_color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 outline_color
#pragma mapbox: initialize lowp float opacity
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;vec2 cutout_factors=vec2(0.0);
#ifdef FEATURE_CUTOUT
cutout_factors=get_cutout_factors(gl_FragCoord);
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
#endif
glFragColor=out_color*(alpha*opacity);
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
in ivec2 a_pos;
#ifdef ELEVATED_ROADS
in float a_road_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform 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;out highp float v_depth;
#endif
uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;
#pragma mapbox: define highp vec4 outline_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp float z_offset
void main() {
#pragma mapbox: initialize highp vec4 outline_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp float z_offset
#ifdef ELEVATED_ROADS
z_offset+=a_road_z_offset;
#endif
float hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);
#ifdef FLIP_Y
v_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;
#else
v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
#endif
#ifdef RENDER_SHADOWS
vec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_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);v_depth=gl_Position.w;
#endif
#ifdef FOG
v_fog_pos=fog_position(vec2(a_pos));
#endif
}`),fillOutlinePattern:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
uniform vec2 u_texsize;uniform sampler2D u_image;
#ifdef FILL_PATTERN_TRANSITION
uniform float u_pattern_transition;
#endif
uniform float u_emissive_strength;
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
in highp vec2 v_pos;in highp vec2 v_pos_world;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp uvec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: define mediump uvec4 pattern_b
#endif
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump uvec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: initialize mediump uvec4 pattern_b
#endif
vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp 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);
#ifdef APPLY_LUT_ON_GPU
out_color=applyLUT(u_lutTexture,out_color);
#endif
#ifdef FILL_PATTERN_TRANSITION
vec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
#endif
vec2 cutout_factors=vec2(0.0);
#ifdef FEATURE_CUTOUT
cutout_factors=get_cutout_factors(gl_FragCoord);
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
glFragColor=out_color*(alpha*opacity);
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;
#ifdef ELEVATED_ROADS
in float a_road_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform 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;out highp float v_depth;
#endif
out highp vec2 v_pos;out highp vec2 v_pos_world;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp uvec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: define mediump uvec4 pattern_b
#endif
#pragma mapbox: define lowp float pixel_ratio
#pragma mapbox: define highp float z_offset
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump uvec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: initialize mediump uvec4 pattern_b
#endif
#pragma mapbox: initialize lowp float pixel_ratio
#pragma mapbox: initialize highp float z_offset
vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);
#ifdef ELEVATED_ROADS
z_offset+=a_road_z_offset;
#endif
float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);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,pos);
#ifdef FLIP_Y
v_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;
#else
v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
#endif
#ifdef RENDER_SHADOWS
vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_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);v_depth=gl_Position.w;
#endif
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),fillPattern:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
uniform vec2 u_texsize;uniform sampler2D u_image;
#ifdef FILL_PATTERN_TRANSITION
uniform float u_pattern_transition;
#endif
in highp vec2 v_pos;uniform float u_emissive_strength;
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
#ifdef ELEVATED_ROADS
in highp float v_road_z_offset;
#endif
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp uvec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: define mediump uvec4 pattern_b
#endif
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump uvec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: initialize mediump uvec4 pattern_b
#endif
vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
#ifdef APPLY_LUT_ON_GPU
out_color=applyLUT(u_lutTexture,out_color);
#endif
#ifdef FILL_PATTERN_TRANSITION
vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
#endif
vec2 cutout_factors=vec2(0.0);
#ifdef FEATURE_CUTOUT
cutout_factors=get_cutout_factors(gl_FragCoord);
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);
#ifdef ELEVATED_ROADS
out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
#else
out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
glFragColor=out_color*opacity;
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in ivec2 a_pos;
#ifdef ELEVATED_ROADS
in float a_road_z_offset;out highp float v_road_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform 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;out highp float v_depth;
#endif
out highp vec2 v_pos;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp uvec4 pattern
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: define mediump uvec4 pattern_b
#endif
#pragma mapbox: define lowp float pixel_ratio
#pragma mapbox: define highp float z_offset
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump uvec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
#pragma mapbox: initialize highp float z_offset
#ifdef FILL_PATTERN_TRANSITION
#pragma mapbox: initialize mediump uvec4 pattern_b
#endif
vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;
#ifdef ELEVATED_ROADS
z_offset+=a_road_z_offset;v_road_z_offset=z_offset;
#endif
float hidden=float(opacity==0.0);vec2 pos=vec2(a_pos);gl_Position=mix(u_matrix*vec4(pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);
#ifdef RENDER_SHADOWS
vec3 shd_pos0=vec3(pos,z_offset);vec3 shd_pos1=vec3(pos,z_offset);
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_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);v_depth=gl_Position.w;
#endif
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),lineBlendComposite:xi(`uniform sampler2D u_image;uniform float u_opacity;uniform int u_blend_mode;in vec2 v_pos;
#define ADDITIVE 1
void main() {vec4 color=texture(u_image,v_pos);if (u_blend_mode==ADDITIVE) {if (color.a <=0.0) {discard;}float density=color.a;vec3 avgColor=color.rgb/max(density,0.001);float t=density/(1.0+density);glFragColor=vec4(avgColor*t*u_opacity,t*u_opacity);} else {vec3 multiplyFactor=color.rgb*u_opacity+(1.0-u_opacity);glFragColor=vec4(multiplyFactor,1.0);}
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(0.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,"in ivec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=vec2(a_pos)*0.5+0.5;}"),fillExtrusion:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_shadow.fragment.glsl"
#include "_prelude_lighting.glsl"
in vec4 v_color;in vec4 v_flat;
#ifdef RENDER_SHADOWS
in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;
#endif
uniform lowp float u_opacity;
#ifdef RENDER_FRONT_CUTOFF
in float v_front_cutoff_opacity;
#endif
#ifdef INDICATOR_CUTOUT
#ifdef FEATURE_CUTOUT
in vec4 v_ground_roof;
#endif
#endif
#ifdef FAUX_AO
uniform lowp vec2 u_ao;in vec2 v_ao;
#endif
#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
in vec4 v_roof_color;
#endif
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
in highp vec3 v_normal;
#endif
uniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;
#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
in float v_flood_radius;in float v_has_floodlight;
#endif
in float v_height;
#pragma mapbox: define highp float emissive_strength
void main() {
#pragma mapbox: initialize highp float emissive_strength
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
vec3 normal=normalize(v_normal);
#endif
float z;vec4 color=v_color;
#ifdef ZERO_ROOF_RADIUS
z=float(normal.z > 0.00001);
#ifdef LIGHTING_3D_MODE
normal=mix(normal,vec3(0.0,0.0,1.0),z);
#else
color=mix(v_color,v_roof_color,z);
#endif
#endif
float h=max(0.0,v_height);float ao_shade=1.0;
#ifdef FAUX_AO
float 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;
#ifdef ZERO_ROOF_RADIUS
concave*=(1.0-z);
#endif
float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);
#ifdef LIGHTING_3D_MODE
#ifdef FLOOD_LIGHT
color.rgb*=mix(ao_shade,1.0,v_has_floodlight);
#else
color.rgb*=ao_shade;
#endif
#else
color.rgb*=ao_shade;
#endif
#endif
#ifdef LIGHTING_3D_MODE
float flood_radiance=0.0;
#ifdef FLOOD_LIGHT
flood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;
#endif
#ifdef RENDER_SHADOWS
#ifdef FLOOD_LIGHT
float 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);
#else
float shadowed_lighting_factor;
#ifdef RENDER_CUTOFF
shadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}
#else
shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);
#endif
color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);
#endif
#else
color.rgb=apply_lighting(color.rgb,normal);
#ifdef FLOOD_LIGHT
color.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);
#endif
#endif
color.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));
#endif
#ifdef INDICATOR_CUTOUT
#ifdef FEATURE_CUTOUT
{float ditherOpacity=cutoutGroundRoofOpacity(v_ground_roof);if (ditherOpacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (ditherOpacity < DITHER_THRESHOLDS[index]) {discard;}}}
#else
color=applyCutout(color,h);
#endif
#endif
#ifdef RENDER_FRONT_CUTOFF
if (v_front_cutoff_opacity < 1.0) {int index=(int(gl_FragCoord.x) % 4)*4+(int(gl_FragCoord.y) % 4);if (v_front_cutoff_opacity < DITHER_THRESHOLDS[index]) {discard;}}
#endif
#ifdef FEATURE_CUTOUT
color=apply_feature_cutout(color,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);
#endif
glFragColor=color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_material_table.vertex.glsl"
uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in ivec4 a_pos_normal_ed;
#if defined(HAS_CENTROID) || defined(TERRAIN)
in uvec2 a_centroid_pos;
#endif
#ifdef RENDER_WALL_MODE
in ivec4 a_join_normal_inside;
#endif
#ifdef PROJECTION_GLOBE_VIEW
in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
#endif
#ifdef TERRAIN
uniform int u_height_type;uniform int u_base_type;
#endif
uniform highp float u_vertical_scale;
#ifdef RENDER_FRONT_CUTOFF
uniform vec3 u_front_cutoff_params;out float v_front_cutoff_opacity;
#endif
out vec4 v_color;out vec4 v_flat;
#ifdef RENDER_SHADOWS
uniform 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;
#endif
#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
out vec4 v_roof_color;
#endif
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
out highp vec3 v_normal;
#endif
#ifdef FAUX_AO
uniform lowp vec2 u_ao;out vec2 v_ao;
#endif
#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)
out float v_flood_radius;out float v_has_floodlight;
#endif
out float v_height;
#ifdef INDICATOR_CUTOUT
#ifdef FEATURE_CUTOUT
out vec4 v_ground_roof;
#endif
#endif
vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define highp vec4 color
#pragma mapbox: define highp float flood_light_wall_radius
#pragma mapbox: define highp float line_width
#pragma mapbox: define highp float emissive_strength
void main() {DECLARE_MATERIAL_TABLE_INFO
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize highp float flood_light_wall_radius
#pragma mapbox: initialize highp float line_width
#pragma mapbox: initialize highp float emissive_strength
base*=u_vertical_scale;height*=u_vertical_scale;vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)
v_normal=normal;
#endif
base=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny_start.y==0.0 && top_up_ny_start.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny_start.x;vec2 centroid_pos=vec2(0.0);
#if defined(HAS_CENTROID) || defined(TERRAIN)
centroid_pos=vec2(a_centroid_pos);
#endif
float ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;
#ifdef TERRAIN
bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && (int(centroid_pos.y) & 7)==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;
#else
h=t > 0.0 ? height : base;
#endif
pos=vec3(pos_nx.xy,h);
#ifdef PROJECTION_GLOBE_VIEW
float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#endif
float cutoff=1.0;vec3 scaled_pos=pos;
#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
vec2 centroid_decoded=pos.xy;bool isBorderCentroid=false;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {int iy=int(centroid_pos.y);int spanYbits=iy & 7;if (spanYbits==7) {isBorderCentroid=true;int borderID=(iy >> 3) & 3;float coordAlongBorder=float(iy >> 5)*4.0;if (borderID==0) centroid_decoded=vec2(0.0,coordAlongBorder);else if (borderID==1) centroid_decoded=vec2(EXTENT,coordAlongBorder);else if (borderID==2) centroid_decoded=vec2(coordAlongBorder,0.0);else centroid_decoded=vec2(coordAlongBorder,EXTENT);} else {centroid_decoded=floor(centroid_pos/8.0);}}
#endif
#if defined(RENDER_CUTOFF) || defined(RENDER_FRONT_CUTOFF)
vec4 ground=u_matrix*vec4(centroid_decoded,ele,1.0);
#endif
#ifdef RENDER_CUTOFF
#ifdef CLIP_ZERO_TO_ONE
cutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);
#else
cutoff=cutoff_opacity(u_cutoff_params,ground.z);
#endif
if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_random/8.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;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);
#endif
float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));
#ifdef RENDER_FRONT_CUTOFF
v_front_cutoff_opacity=1.0;if (centroid_pos.x > 0.0 && centroid_pos.y > 0.0) {hidden=max(hidden,float(ground.w <=0.0));float ndc_y=ground.y/max(ground.w,0.001);float threshold=u_front_cutoff_params.x*2.0-1.0;float range_ndc=u_front_cutoff_params.y*2.0;if (!isBorderCentroid) {hidden=max(hidden,float(ndc_y < threshold-range_ndc));}float t=clamp((ndc_y-(threshold-range_ndc))/max(range_ndc,0.001),0.0,1.0);v_front_cutoff_opacity=mix(u_front_cutoff_params.z,1.0,t);}
#endif
#ifdef RENDER_WALL_MODE
vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=join_normal_inside.z*wall_offset*0.5;
#endif
gl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;
#ifdef RENDER_SHADOWS
vec3 shd_pos0=pos;vec3 shd_pos1=pos;
#ifdef NORMAL_OFFSET
vec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();
#endif
v_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);
#endif
float NdotL=0.0;float colorvalue=0.0;
#ifndef LIGHTING_3D_MODE
colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
#endif
#ifdef FAUX_AO
float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
#ifdef TERRAIN
top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
#endif
v_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);
#ifdef PROJECTION_GLOBE_VIEW
top_height+=u_height_lift;
#endif
gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
#endif
#ifdef LIGHTING_3D_MODE
#ifdef FLOOD_LIGHT
float is_wall=1.0-float(t > 0.0 && top_up_ny_start.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;
#endif
v_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);
#else
v_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;
#endif
#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)
float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=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;
#endif
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
#ifdef INDICATOR_CUTOUT
#ifdef FEATURE_CUTOUT
vec4 pos_ground=u_matrix*vec4(pos.xy,ele,1.0);vec4 pos_roof=u_matrix*vec4(pos.xy,ele+height,1.0);v_ground_roof=vec4(pos_ground.xy/pos_ground.w,pos_roof.xy/pos_roof.w);
#endif
#endif
}`),fillExtrusionDepth:xi("void main() {}",`#include "_prelude_terrain.vertex.glsl"
#include "_prelude_material_table.vertex.glsl"
uniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;
#ifdef TERRAIN
uniform int u_height_type;uniform int u_base_type;
#endif
in ivec4 a_pos_normal_ed;
#if defined(HAS_CENTROID) || defined(TERRAIN)
in uvec2 a_centroid_pos;
#endif
#ifdef RENDER_WALL_MODE
in ivec4 a_join_normal_inside;
#endif
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define highp float line_width
#pragma mapbox: define highp vec4 color
void main() {DECLARE_MATERIAL_TABLE_INFO
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize highp float line_width
#pragma mapbox: initialize highp vec4 color
base*=u_vertical_scale;height*=u_vertical_scale;vec3 top_up_ny=vec3(a_pos_normal_ed.xyz & 1);vec3 pos_nx=vec3(a_pos_normal_ed.xyz >> 1);base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
#if defined(HAS_CENTROID) || defined(TERRAIN)
centroid_pos=vec2(a_centroid_pos);
#endif
vec3 pos;
#ifdef TERRAIN
bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);float c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);
#else
pos=vec3(pos_nx.xy,t > 0.0 ? height : base);
#endif
#ifdef RENDER_WALL_MODE
vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);pos.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;pos.xy-=join_normal_inside.z*wall_offset*0.5;
#endif
float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);}`),fillExtrusionPattern:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform vec2 u_texsize;uniform sampler2D u_image;
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
uniform float u_pattern_transition;
#endif
#ifdef FAUX_AO
uniform lowp vec2 u_ao;in vec3 v_ao;
#endif
#ifdef LIGHTING_3D_MODE
in vec3 v_normal;
#endif
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
in highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define mediump uvec4 pattern
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
#pragma mapbox: define mediump uvec4 pattern_b
#endif
#pragma mapbox: define highp float pixel_ratio
void main() {
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize mediump uvec4 pattern
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
#pragma mapbox: initialize mediump uvec4 pattern_b
#endif
#pragma mapbox: initialize highp float pixel_ratio
vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);
#ifdef APPLY_LUT_ON_GPU
out_color=applyLUT(u_lutTexture,out_color);
#endif
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;
#else
out_color=out_color*v_lighting;
#endif
#ifdef FAUX_AO
float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
#ifdef INDICATOR_CUTOUT
out_color=applyCutout(out_color,height);
#endif
glFragColor=out_color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_material_table.vertex.glsl"
uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in ivec4 a_pos_normal_ed;
#if defined(HAS_CENTROID) || defined(TERRAIN)
in uvec2 a_centroid_pos;
#endif
#ifdef RENDER_WALL_MODE
in ivec4 a_join_normal_inside;
#endif
#ifdef PROJECTION_GLOBE_VIEW
in ivec4 a_pos_3;in ivec4 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
#endif
#ifdef TERRAIN
uniform int u_height_type;uniform int u_base_type;
#endif
out highp vec2 v_pos;out vec4 v_lighting;
#ifdef FAUX_AO
uniform lowp vec2 u_ao;out vec3 v_ao;
#endif
#ifdef LIGHTING_3D_MODE
out vec3 v_normal;
#endif
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump uvec4 pattern
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
#pragma mapbox: define mediump uvec4 pattern_b
#endif
#pragma mapbox: define highp float pixel_ratio
#pragma mapbox: define highp float line_width
void main() {DECLARE_MATERIAL_TABLE_INFO
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump uvec4 pattern
#ifdef FILL_EXTRUSION_PATTERN_TRANSITION
#pragma mapbox: initialize mediump uvec4 pattern_b
#endif
#pragma mapbox: initialize highp float pixel_ratio
#pragma mapbox: initialize highp float line_width
vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec4 top_up_ny_start=vec4(a_pos_normal_ed & 1);vec4 pos_nx=vec4(a_pos_normal_ed >> 1);float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny_start.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny_start.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=float(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_start.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
#if defined(HAS_CENTROID) || defined(TERRAIN)
centroid_pos=vec2(a_centroid_pos);
#endif
float ele=0.0;float h=z;vec3 p;float c_ele;
#ifdef TERRAIN
bool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);bool is_elevation_encoded=centroid_pos.y==0.0 || (centroid_pos.y > 0.0 && int(centroid_pos.y)-(int(centroid_pos.y)/8)*8==7);c_ele=is_flat_height || is_flat_base ? (is_elevation_encoded ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);
#else
p=vec3(pos_nx.xy,z);
#endif
#ifdef PROJECTION_GLOBE_VIEW
float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(vec3(a_pos_normal_3)/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=vec3(a_pos_3)+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#endif
#ifdef RENDER_WALL_MODE
vec3 join_normal_inside=vec3(a_join_normal_inside);vec2 wall_offset=u_width_scale*line_width*(join_normal_inside.xy/EXTENT);p.xy+=(1.0-join_normal_inside.z)*wall_offset*0.5;p.xy-=join_normal_inside.z*wall_offset*0.5;
#endif
float hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
? pos_nx.xy
: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;
#ifdef LIGHTING_3D_MODE
NdotL=calculate_NdotL(normal);
#else
NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);
#endif
if (normal.y !=0.0) {float r=0.84;
#ifndef LIGHTING_3D_MODE
r=mix(0.7,0.98,1.0-u_lightintensity);
#endif
NdotL*=(
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
#ifdef FAUX_AO
float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
#ifdef TERRAIN
top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
#endif
v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny_start.y)*u_ao[0]);
#ifdef PROJECTION_GLOBE_VIEW
top_height+=u_height_lift;
#endif
gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
#endif
#ifdef LIGHTING_3D_MODE
v_normal=normal;
#else
v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
#endif
#ifdef FOG
v_fog_pos=fog_position(p);
#endif
}`),groundShadow:xi(`#include "_prelude_shadow.fragment.glsl"
precision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;
#ifdef FOG
in float v_fog_opacity;
#endif
void main() {float light=shadowed_light_factor_plane_bias(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);
#ifdef RENDER_CUTOFF
shadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));
#endif
#ifdef FOG
shadow=mix(shadow,vec3(1.0),v_fog_opacity);
#endif
#ifdef INDICATOR_CUTOUT
shadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0),0.0).r);
#endif
#ifdef FEATURE_CUTOUT
shadow=mix(shadow,vec3(1.0),get_cutout_factors(gl_FragCoord).y);
#endif
glFragColor=vec4(shadow,1.0);}`,`#include "_prelude_fog.vertex.glsl"
uniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in ivec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;
#ifdef FOG
out float v_fog_opacity;
#endif
void 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);
#ifdef FOG
v_fog_pos=fog_position(vec2(a_pos));v_fog_opacity=fog(v_fog_pos);
#endif
}`),fillExtrusionGroundEffect:xi(`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;
#ifdef SDF_SUBPASS
in 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);}
#ifdef FOG
in highp float v_fog;
#endif
#endif
void main() {
#ifdef CLEAR_SUBPASS
vec4 color=vec4(1.0);
#ifdef CLEAR_FROM_TEXTURE
color=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));
#endif
glFragColor=color;
#else
#ifdef SDF_SUBPASS
highp 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;
#ifdef FOG
fog=v_fog;
#endif
#ifdef RENDER_CUTOFF
fog*=v_cutoff_opacity;
#endif
glFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));
#else
#ifdef USE_MRT1
out_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);
#else
vec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);
#ifdef OVERDRAW_INSPECTOR
color=vec4(1.0);
#endif
glFragColor=color;
#endif
#endif
HANDLE_WIREFRAME_DEBUG;
#endif
}`,`#include "_prelude_fog.vertex.glsl"
in highp ivec4 a_pos_end;in highp int a_angular_offset_factor;in highp uint a_hidden_by_landmark;
#ifdef SDF_SUBPASS
out highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;
#ifdef FOG
out highp float v_fog;
#endif
#endif
uniform 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 float u_dynamic_offset;uniform highp vec2 u_ao;
#pragma mapbox: define highp float flood_light_ground_radius
const float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {
#pragma mapbox: initialize highp float flood_light_ground_radius
vec4 pos_end=vec4(a_pos_end);vec2 p=pos_end.xy;vec2 q=floor(pos_end.zw*0.5);vec2 start_bottom=pos_end.zw-q*2.0;float 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=float(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(u_dynamic_offset,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;
#ifdef SDF_SUBPASS
v_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);
#ifdef FOG
v_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);
#endif
#endif
float hidden_by_landmark=0.0;
#ifdef HAS_CENTROID
hidden_by_landmark=float(a_hidden_by_landmark);
#endif
float 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));
#ifdef RENDER_CUTOFF
v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
#endif
}`),hillshadePrepare:xi(`precision highp float;uniform highp 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(
(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)
)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(
deriv.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 ivec2 a_pos;in uvec2 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=(vec2(a_texture_pos)/8192.0)*scale+epsilon;}"),hillshade:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform 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;
#ifdef LIGHTING_3D_MODE
glFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);
#endif
#ifdef FOG
glFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));
#endif
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
uniform mat4 u_matrix;in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=vec2(a_texture_pos)/8192.0;
#ifdef FOG
v_fog_pos=fog_position(vec2(a_pos));
#endif
}`),line:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
uniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;uniform bool u_emissive_in_shadows;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;
#ifdef ELEVATED_ROADS
in highp float v_road_z_offset;
#endif
#ifdef VARIABLE_LINE_WIDTH
in float stub_side;
#endif
#ifdef RENDER_LINE_DASH
uniform sampler2D u_dash_image;in vec2 v_tex;
#endif
#ifdef RENDER_LINE_GRADIENT
uniform sampler2D u_gradient_image;
#endif
#ifdef INDICATOR_CUTOUT
in highp float v_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define mediump uvec4 dash
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define mediump float side_z_offset
#pragma mapbox: define lowp float border_width
#pragma mapbox: define lowp vec4 border_color
#pragma mapbox: define lowp float emissive_strength
float linearstep(float edge0,float edge1,float x) {return  clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize mediump uvec4 dash
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float side_z_offset
#pragma mapbox: initialize lowp float border_width
#pragma mapbox: initialize lowp vec4 border_color
#pragma mapbox: initialize lowp float emissive_strength
float dist=length(v_normal)*v_width2_dilute.x;
#ifdef VARIABLE_LINE_WIDTH
blur=mix(blur,0.0,stub_side);
#endif
float diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0);
#ifdef VARIABLE_LINE_WIDTH
alpha=mix(alpha,1.0,stub_side);
#endif
alpha=side_z_offset > 0.0 ? 1.0-alpha : alpha;
#ifdef RENDER_LINE_DASH
float sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/(float(dash.z)+float(dash.w)/65535.0);float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);
#endif
highp vec4 out_color;
#ifdef RENDER_LINE_GRADIENT
out_color=texture(u_gradient_image,v_uv.xy);
#else
out_color=color;
#endif
float trim_alpha=1.0;
#ifdef RENDER_LINE_TRIM_OFFSET
highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0;
#ifdef RENDER_LINE_GRADIENT
gradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);
#endif
highp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;}
#endif
if (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}
#ifdef RENDER_LINE_BORDER
#ifndef VARIABLE_LINE_WIDTH
float edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2_dilute.y-edgeBlur),v_width2_dilute.x-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}out_color*=v_width2_dilute.w;}
#endif
#endif
vec2 cutout_factors=vec2(0.0);
#ifdef FEATURE_CUTOUT
cutout_factors=get_cutout_factors(gl_FragCoord);
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light;
#ifdef ELEVATED_ROADS
out_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
#else
out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
out_color*=(alpha*diluted_opacity);
#ifdef LINE_BLEND_MULTIPLY
glFragColor=vec4(out_color.rgb+(1.0-out_color.a),1.0);HANDLE_WIREFRAME_DEBUG;return;
#endif
#ifdef INDICATOR_CUTOUT
out_color=applyCutout(out_color,v_z_offset);
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
#endif
glFragColor=out_color;
#ifdef DUAL_SOURCE_BLENDING
glFragColorSrc1=vec4(vec3(0.0),emissive_strength);
#else
#ifdef USE_MRT1
out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
#define EXTRUDE_SCALE 0.015873016
in ivec2 a_pos_normal;in uvec4 a_data;
#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)
in vec3 a_z_offset_width;
#endif
#ifdef ELEVATION_GROUND_SCALE
in float a_elevation_ground_scale;
#endif
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)
in highp vec3 a_packed;
#endif
#ifdef RENDER_LINE_DASH
in float a_linesofar;
#endif
uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;uniform float u_width_scale;uniform highp float u_floor_width_scale;
#ifdef RENDER_LINE_CURVE
uniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;
#endif
#ifdef ELEVATED
uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {
#ifdef ELEVATION_REFERENCE_SEA
return 0.0;
#else
return elevation(apos);
#endif
}
#endif
out vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out highp vec3 v_uv;
#ifdef ELEVATED_ROADS
out highp float v_road_z_offset;
#endif
#ifdef VARIABLE_LINE_WIDTH
out float stub_side;
#endif
#ifdef RENDER_LINE_DASH
uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;
#endif
#ifdef RENDER_LINE_GRADIENT
uniform float u_image_height;
#endif
#ifdef INDICATOR_CUTOUT
out highp float v_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform 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;out highp float v_depth;
#endif
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define mediump uvec4 dash
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define lowp float offset
#pragma mapbox: define mediump float width
#pragma mapbox: define mediump float side_z_offset
#pragma mapbox: define lowp float border_width
#pragma mapbox: define lowp vec4 border_color
#pragma mapbox: define lowp float emissive_strength
#ifdef RENDER_LINE_CURVE
vec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2=t*t;float t3=t2*t;return 0.5*(
2.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3
);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(
(-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2
);}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;}
#endif
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize mediump uvec4 dash
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize mediump float side_z_offset
#pragma mapbox: initialize lowp float border_width
#pragma mapbox: initialize lowp vec4 border_color
#pragma mapbox: initialize lowp float emissive_strength
float a_z_offset;
#if defined(ELEVATED) || defined(ELEVATED_ROADS)
a_z_offset=a_z_offset_width.x;
#endif
highp float line_progress=0.0;
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)
line_progress=a_packed[2];
#endif
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);mediump vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0;
#ifdef RENDER_LINE_CURVE
CurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z;
#endif
gapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;
#ifdef VARIABLE_LINE_WIDTH
float left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=(u_width_scale*(left ? left_width : right_width))/2.0;if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=left_f;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale*0.5 : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING;
#else
halfwidth=(u_width_scale*width)/2.0;
#endif
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);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;
#ifdef ELEVATED_ROADS
v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0);
#else
#ifdef ELEVATED
vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;
#ifdef ELEVATION_GROUND_SCALE
scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);
#endif
#ifdef CROSS_SLOPE_VERTICAL
float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);
#else
#ifdef CROSS_SLOPE_HORIZONTAL
float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;
#else
float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;
#endif
#endif
gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);
#else
gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0);
#endif
#endif
#ifndef ELEVATED
#ifndef VARIABLE_LINE_WIDTH
#ifndef RENDER_TO_TEXTURE
float base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (width >=1.0 && base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else
{
#ifdef RENDER_LINE_BORDER
float border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel);
#endif
}}
#endif
#endif
#ifdef ELEVATED_ROADS
gl_Position=gl_Position+projected_extrude;
#else
gl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);
#endif
#endif
#ifdef ELEVATED_ROADS
#ifdef RENDER_SHADOWS
vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;
#ifdef NORMAL_OFFSET
vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
#endif
v_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);v_depth=gl_Position.w;
#endif
#endif
#ifndef RENDER_TO_TEXTURE
float epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));
#else
v_gamma_scale=1.0;
#endif
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
highp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];
#ifdef RENDER_LINE_GRADIENT
highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);
#else
v_uv=vec3(a_uv_x,0.0,line_progress);
#endif
#endif
#ifdef RENDER_LINE_DASH
vec4 dashf=vec4(dash);float totalLength=dashf.z+dashf.w/65535.0;float scale=totalLength==0.0 ? 0.0 : u_tile_units_to_pixels/totalLength;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*dashf.y+dashf.x+0.5)/u_texsize.y);
#endif
v_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
#ifdef INDICATOR_CUTOUT
v_z_offset=a_z_offset;
#endif
}`),linePattern:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
uniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
#ifdef LINE_PATTERN_TRANSITION
uniform float u_pattern_transition;
#endif
in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;
#ifdef RENDER_LINE_TRIM_OFFSET
in highp vec3 v_uv;
#endif
#ifdef ELEVATED_ROADS
in highp float v_road_z_offset;
#endif
#ifdef LINE_JOIN_NONE
in vec2 v_pattern_data;
#endif
#ifdef INDICATOR_CUTOUT
in highp float v_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
#pragma mapbox: define mediump uvec4 pattern
#ifdef LINE_PATTERN_TRANSITION
#pragma mapbox: define mediump uvec4 pattern_b
#endif
#pragma mapbox: define mediump float pixel_ratio
#pragma mapbox: define mediump float blur
#pragma mapbox: define mediump float opacity
#pragma mapbox: define lowp float emissive_strength
void main() {
#pragma mapbox: initialize mediump uvec4 pattern
#ifdef LINE_PATTERN_TRANSITION
#pragma mapbox: initialize mediump uvec4 pattern_b
#endif
#pragma mapbox: initialize mediump float pixel_ratio
#pragma mapbox: initialize mediump float blur
#pragma mapbox: initialize mediump float opacity
#pragma mapbox: initialize lowp float emissive_strength
vec2 pattern_tl=vec2(pattern.xy);vec2 pattern_br=vec2(pattern.zw);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp 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);
#ifdef APPLY_LUT_ON_GPU
color=applyLUT(u_lutTexture,color);
#endif
#ifdef LINE_PATTERN_TRANSITION
vec2 pattern_b_tl=vec2(pattern_b.xy);vec2 pattern_b_br=vec2(pattern_b.zw);highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;
#endif
#ifdef RENDER_LINE_TRIM_OFFSET
highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}
#endif
#ifdef LINE_JOIN_NONE
highp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp 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);}
#endif
#ifdef LIGHTING_3D_MODE
color=apply_lighting_with_emission_ground(color,emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);
#ifdef ELEVATED_ROADS
color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
#else
color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#endif
#endif
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#endif
color*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}
#ifdef INDICATOR_CUTOUT
color=applyCutout(color,v_z_offset);
#endif
glFragColor=color;
#ifdef DUAL_SOURCE_BLENDING
glFragColorSrc1=vec4(vec3(0.0),emissive_strength);
#else
#ifdef USE_MRT1
out_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
#define scale 0.015873016
in ivec2 a_pos_normal;in uvec4 a_data;
#if defined(ELEVATED) || defined(ELEVATED_ROADS)
in vec3 a_z_offset_width;
#endif
#ifdef ELEVATION_GROUND_SCALE
in float a_elevation_ground_scale;
#endif
#ifdef RENDER_LINE_TRIM_OFFSET
in highp vec3 a_packed;
#endif
in highp float a_linesofar;
#ifdef LINE_JOIN_NONE
in highp vec3 a_pattern_data;out vec2 v_pattern_data;
#endif
#ifdef INDICATOR_CUTOUT
out highp float v_z_offset;
#endif
uniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;
#ifdef ELEVATED
uniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {
#ifdef ELEVATION_REFERENCE_SEA
return 0.0;
#else
return elevation(apos);
#endif
}
#endif
out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;
#ifdef RENDER_LINE_TRIM_OFFSET
out highp vec3 v_uv;
#endif
#ifdef ELEVATED_ROADS
out highp float v_road_z_offset;
#endif
#ifdef RENDER_SHADOWS
uniform 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;out highp float v_depth;
#endif
#pragma mapbox: define mediump float blur
#pragma mapbox: define mediump float opacity
#pragma mapbox: define mediump float offset
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define mediump float width
#pragma mapbox: define mediump float floorwidth
#pragma mapbox: define mediump uvec4 pattern
#ifdef LINE_PATTERN_TRANSITION
#pragma mapbox: define mediump uvec4 pattern_b
#endif
#pragma mapbox: define mediump float pixel_ratio
#pragma mapbox: define lowp float emissive_strength
void main() {
#pragma mapbox: initialize mediump float blur
#pragma mapbox: initialize mediump float opacity
#pragma mapbox: initialize mediump float offset
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize mediump float floorwidth
#pragma mapbox: initialize mediump uvec4 pattern
#ifdef LINE_PATTERN_TRANSITION
#pragma mapbox: initialize mediump uvec4 pattern_b
#endif
#pragma mapbox: initialize mediump float pixel_ratio
#pragma mapbox: initialize lowp float emissive_strength
float a_z_offset;
#if defined(ELEVATED) || defined(ELEVATED_ROADS)
a_z_offset=a_z_offset_width.x;
#endif
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(a_data.xy)-128.0;float a_direction=float(a_data.z & 3u)-1.0;vec2 pos_normal=vec2(a_pos_normal);vec2 pos=floor(pos_normal*0.5);vec2 normal=pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;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);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;
#ifdef ELEVATED_ROADS
v_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;
#else
#ifdef ELEVATED
vec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;
#ifdef ELEVATION_GROUND_SCALE
scaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);
#endif
#ifdef CROSS_SLOPE_VERTICAL
float top=pos_normal.y-2.0*floor(pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);
#else
#ifdef CROSS_SLOPE_HORIZONTAL
float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;
#else
float ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;
#endif
#endif
gl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);
#else
gl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);
#endif
#endif
#ifdef ELEVATED_ROADS
#ifdef RENDER_SHADOWS
vec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;
#ifdef NORMAL_OFFSET
vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
#endif
v_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);v_depth=gl_Position.w;
#endif
#endif
#ifndef RENDER_TO_TEXTURE
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));
#else
v_gamma_scale=1.0;
#endif
#ifdef RENDER_LINE_TRIM_OFFSET
highp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);
#endif
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);
#ifdef LINE_JOIN_NONE
v_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/(float(pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=float(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);
#endif
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
#ifdef INDICATOR_CUTOUT
v_z_offset=a_z_offset;
#endif
}`),raster:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
#include "_prelude_raster_array.glsl"
uniform 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;
#ifdef PROJECTION_GLOBE_VIEW
in float v_split_fade;
#endif
uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;
#ifndef RASTER_ARRAY
uniform highp sampler2D u_image0;uniform sampler2D u_image1;
#endif
#ifdef RASTER_COLOR
uniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;
#endif
void main() {vec4 color0,color1,color;vec2 value;
#ifdef RASTER_COLOR
#ifdef RASTER_ARRAY
#ifdef RASTER_ARRAY_LINEAR
value=mix(
raTexture2D_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
);
#else
value=mix(
raTexture2D_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
);
#endif
if (value.y > 0.0) value.x/=value.y;
#else
color=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);
#endif
color=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;
#else
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);
#endif
color.a*=u_opacity;
#ifdef GLOBE_POLES
color.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);
#endif
vec3 rgb=color.rgb;rgb=vec3(
dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;
#endif
#ifdef FOG
highp 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));
#endif
glFragColor=vec4(out_color*color.a,color.a);
#ifdef PROJECTION_GLOBE_VIEW
glFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));
#endif
#ifdef RENDER_CUTOFF
glFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);
#endif
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
#ifdef USE_MRT1
out_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
uniform 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;
#ifdef ELEVATED
uniform lowp float u_zbias_factor;
#endif
#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8
#ifdef GLOBE_POLES
in vec3 a_globe_pos;in vec2 a_uv;
#else
in ivec2 a_pos;in uvec2 a_texture_pos;
#endif
out vec2 v_pos0;out vec2 v_pos1;out float v_depth;
#ifdef PROJECTION_GLOBE_VIEW
out float v_split_fade;
#endif
void main() {vec2 uv;
#ifdef GLOBE_POLES
vec3 globe_pos=a_globe_pos;uv=a_uv;float ele=u_raster_elevation;
#ifdef ELEVATION_REFERENCE_GROUND
ele+=elevation(uv*EXTENT);
#endif
globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos,1.0);
#ifdef FOG
v_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);
#endif
#else
vec4 world_pos;
#ifdef PROJECTION_GLOBE_VIEW
vec2 texture_pos=vec2(a_texture_pos);uv=texture_pos/8192.0;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 mercatorX=mercatorXfromLng(latLng[1]);  
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);}float ele=u_raster_elevation;
#ifdef ELEVATION_REFERENCE_GROUND
ele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;
#endif
vec4 merc_world_pos=vec4(0.0);   
v_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,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)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
#ifdef FOG
v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
#endif
#else
float ele=0.0;vec2 decodedPos=vec2(a_pos);
#ifdef ELEVATION_REFERENCE_GROUND
vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;
#else
uv=vec2(a_texture_pos)/8192.0;
#endif
world_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);
#ifdef FOG
v_fog_pos=fog_position(decodedPos);
#endif
#endif
float w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;
#endif
v_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;
#ifdef ELEVATED
float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias);
#endif
#ifdef RENDER_CUTOFF
v_depth=gl_Position.z;
#endif
}`),rasterParticle:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform 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;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).rgb;
#endif
#ifdef FOG
highp 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));
#endif
glFragColor=vec4(out_color*color.a,color.a);
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
uniform 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;
#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8
in ivec2 a_pos;in uvec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;
#ifdef PROJECTION_GLOBE_VIEW
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 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;
#ifdef FOG
v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
#endif
#else
uv=vec2(a_texture_pos)/8192.0;gl_Position=u_matrix*vec4(vec2(a_pos)*w,u_raster_elevation*w,w);
#ifdef FOG
v_fog_pos=fog_position(vec2(a_pos));
#endif
#endif
v_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),rasterParticleDraw:xi("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"
in int 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(
mod(float(a_index),u_particle_texture_side_len),float(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-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}`),rasterParticleTexture:xi("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 ivec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*vec2(a_pos)+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:xi(`#include "_prelude_raster_particle.glsl"
uniform 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;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return  clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}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 vec2 persist_rate=pow(
linearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)
);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}`,"in ivec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*vec2(a_pos+ivec2(1));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:xi(`#include "_prelude_lighting.glsl"
#include "_prelude_shadow.fragment.glsl"
#define SDF_PX 8.0
#define SDF 1.0
#define ICON 0.0
uniform 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_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;
#ifdef ICON_TRANSITION
uniform float u_icon_transition;
#endif
#ifdef COLOR_ADJUSTMENT
uniform mat4 u_color_adj_mat;
#endif
#ifdef INDICATOR_CUTOUT
in highp float v_z_offset;
#else
#ifdef RENDER_SHADOWS
in highp float v_z_offset;
#endif
#endif
in vec2 v_tex_a;
#ifdef ICON_TRANSITION
in vec2 v_tex_b;
#endif
in float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;
#ifdef RENDER_TEXT_AND_SYMBOL
in float is_sdf;in vec2 v_tex_a_icon;
#endif
#ifdef RENDER_SHADOWS
uniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;
#endif
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
#ifdef USE_PAINT_PROPERTIES_UBO
in lowp float v_opacity;
#ifdef RENDER_SDF
in lowp vec4 v_fill_np_color;in lowp vec4 v_halo_np_color;in lowp float v_halo_width;in lowp float v_halo_blur;
#endif
#ifdef LIGHTING_3D_MODE
in lowp float v_emissive_strength;
#endif
#else
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
#pragma mapbox: define lowp float emissive_strength
#endif
void main() {
#ifdef USE_PAINT_PROPERTIES_UBO
lowp float opacity=v_opacity;lowp vec4 fill_color=vec4(0.0);lowp vec4 halo_color=vec4(0.0);lowp float halo_width=0.0;lowp float halo_blur=0.0;
#ifdef RENDER_SDF
fill_color=vec4(v_fill_np_color.rgb*v_fill_np_color.a,v_fill_np_color.a);halo_color=vec4(v_halo_np_color.rgb*v_halo_np_color.a,v_halo_np_color.a);halo_width=v_halo_width;halo_blur=v_halo_blur;
#endif
lowp float emissive_strength=0.0;
#ifdef LIGHTING_3D_MODE
emissive_strength=v_emissive_strength;
#endif
#else
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
#pragma mapbox: initialize lowp float emissive_strength
#endif
vec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];
#ifdef RENDER_TEXT_AND_SYMBOL
if (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
return;}
#endif
vec2 cutout_factors=vec2(0.0);
#ifdef FEATURE_CUTOUT
cutout_factors=get_cutout_factors(gl_FragCoord);
#endif
#ifdef RENDER_SDF
float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_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) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;
#else
#ifdef ICON_TRANSITION
vec4 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);
#else
out_color=texture(u_texture,v_tex_a);
#endif
#ifdef APPLY_LUT_ON_GPU
out_color=applyLUT(u_lutTexture,out_color);
#endif
#ifdef COLOR_ADJUSTMENT
out_color=u_color_adj_mat*out_color;
#endif
#endif
out_color*=opacity*fade_opacity;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting_with_emission_ground(out_color,emissive_strength);
#ifdef RENDER_SHADOWS
float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=mix(light,1.0,cutout_factors.y);
#ifdef TERRAIN
out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);
#else
out_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);
#endif
#endif
#endif
#ifdef INDICATOR_CUTOUT
out_color=applyCutout(out_color,v_z_offset);
#endif
#ifdef FEATURE_CUTOUT
out_color=apply_feature_cutout(out_color,gl_FragCoord,cutout_factors.x);
#endif
glFragColor=out_color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_terrain.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
#define USING_APPEARANCE 1.0
in ivec4 a_pos_offset;in uvec4 a_tex_size;in ivec4 a_pixeloffset;in vec4 a_projected_pos;in uint a_fade_opacity;
#ifdef Z_OFFSET
in float a_auto_z_offset;
#endif
#ifdef PROJECTION_GLOBE_VIEW
in ivec4 a_globe_anchor;in vec3 a_globe_normal;
#endif
#ifdef ICON_TRANSITION
in uvec2 a_texb;
#endif
#ifdef OCCLUSION_QUERIES
in float a_occlusion_query_opacity;
#endif
#ifdef ELEVATED_ROADS
in vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;
#endif
#ifdef INDICATOR_CUTOUT
out highp float v_z_offset;
#else
#ifdef RENDER_SHADOWS
out highp float v_z_offset;
#endif
#endif
uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;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;
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
#endif
out vec2 v_tex_a;
#ifdef ICON_TRANSITION
out vec2 v_tex_b;
#endif
out float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;
#ifdef RENDER_TEXT_AND_SYMBOL
out float is_sdf;out vec2 v_tex_a_icon;
#endif
#ifdef RENDER_SHADOWS
uniform 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;out highp float v_depth;
#endif
#ifdef USE_PAINT_PROPERTIES_UBO
#ifndef MAX_UBO_SIZE_VEC4
#define MAX_UBO_SIZE_VEC4 1024u
#endif
#define SPP_HEADER_SIZE_VEC4 3u
#define DWORDS_PER_VEC4 4u
struct SymbolPaintProperties {vec4 fill_np_color;vec4 halo_np_color;float opacity;float halo_width;float halo_blur;float emissive_strength;float occlusion_opacity;float z_offset;vec2 translate;};struct PropertyType {bool isDataDriven;bool isZoomDependent;uint offsetDwords;};struct SymbolPropertyHeader {uint dataDrivenBlockSizeVec4;PropertyType fill_np_color;PropertyType halo_np_color;PropertyType opacity;PropertyType halo_width;PropertyType halo_blur;PropertyType emissive_strength;PropertyType occlusion_opacity;PropertyType z_offset;PropertyType translate;};uniform float u_zoom;uniform lowp vec4 u_spp_fill_np_color;uniform lowp vec4 u_spp_halo_np_color;uniform lowp float u_spp_opacity;uniform lowp float u_spp_halo_width;uniform lowp float u_spp_halo_blur;uniform lowp float u_spp_emissive_strength;uniform lowp float u_spp_occlusion_opacity;uniform lowp float u_spp_z_offset;uniform lowp vec2 u_spp_translate_rotation;in float a_feature_index;layout(std140) uniform SymbolPaintPropertiesHeaderUniform {uvec4 header[SPP_HEADER_SIZE_VEC4];} u_spp_header;layout(std140) uniform SymbolPaintPropertiesUniform {vec4 properties[MAX_UBO_SIZE_VEC4];} u_spp_properties;layout(std140) uniform SymbolPaintPropertiesIndexUniform {uvec4 block_indices[MAX_UBO_SIZE_VEC4];} u_spp_index;out lowp float v_opacity;
#ifdef RENDER_SDF
out lowp vec4 v_fill_np_color;out lowp vec4 v_halo_np_color;out lowp float v_halo_width;out lowp float v_halo_blur;
#endif
#ifdef LIGHTING_3D_MODE
out lowp float v_emissive_strength;
#endif
PropertyType getPropertyType(uint propertyIndex,uint dataDrivenMask,uint zoomDependentMask,uint offsetDwords) {PropertyType type;type.isDataDriven=(dataDrivenMask & (1u << propertyIndex)) !=0u;type.isZoomDependent=(zoomDependentMask & (1u << propertyIndex)) !=0u;type.offsetDwords=offsetDwords;return type;}SymbolPropertyHeader readSymbolPropertiesHeader() {SymbolPropertyHeader header;uint dataDrivenMask=u_spp_header.header[0][0];uint zoomDependentMask=u_spp_header.header[0][1];header.dataDrivenBlockSizeVec4=u_spp_header.header[0][2];header.fill_np_color       =getPropertyType(0u,dataDrivenMask,zoomDependentMask,u_spp_header.header[0][3]);header.halo_np_color       =getPropertyType(1u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][0]);header.opacity             =getPropertyType(2u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][1]);header.halo_width          =getPropertyType(3u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][2]);header.halo_blur           =getPropertyType(4u,dataDrivenMask,zoomDependentMask,u_spp_header.header[1][3]);header.emissive_strength   =getPropertyType(5u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][0]);header.occlusion_opacity   =getPropertyType(6u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][1]);header.z_offset            =getPropertyType(7u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][2]);header.translate           =getPropertyType(8u,dataDrivenMask,zoomDependentMask,u_spp_header.header[2][3]);return header;}uint uvec4At(uvec4 v,uint index) {return (index==0u) ? v.x :
(index==1u) ? v.y :
(index==2u) ? v.z : v.w;}float vec4At(vec4 v,uint index) {return (index==0u) ? v.x :
(index==1u) ? v.y :
(index==2u) ? v.z : v.w;}vec4 readVec4(uint baseOffsetVec4,uint propertyOffsetDwords) {return u_spp_properties.properties[baseOffsetVec4+propertyOffsetDwords/DWORDS_PER_VEC4];}float readFloat(vec4 slot,uint propertyOffsetDwords) {return slot[propertyOffsetDwords % DWORDS_PER_VEC4];}uint readUint(uvec4 slot,uint offset) {return slot[offset % DWORDS_PER_VEC4];}vec2 readVec2(vec4 slot,uint propertyOffsetDwords) {float x=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4);float y=vec4At(slot,propertyOffsetDwords % DWORDS_PER_VEC4+1u);return vec2(x,y);}uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {uint featureIndex=uint(a_feature_index);uvec4 slot=u_spp_index.block_indices[featureIndex/DWORDS_PER_VEC4];uint blockIndex=uvec4At(slot,featureIndex % DWORDS_PER_VEC4);return blockIndex*dataDrivenBlockSizeVec4;}vec4 readColorProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 color=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {color=unpack_mix_color(color,u_zoom);} else {vec2 packedColor=readVec2(color,propertyType.offsetDwords);color=decode_color(packedColor);}return color;}vec2 readVec2Property(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);if (propertyType.isZoomDependent) {vec2 minVal=slot.xy;vec2 maxVal=slot.zw;return mix(minVal,maxVal,u_zoom);}return readVec2(slot,propertyType.offsetDwords);}float readFloatProperty(PropertyType propertyType,uint dataDrivenBlockSizeVec4) {uint blockOffsetVec4=getDataDrivenBlockOffsetVec4(dataDrivenBlockSizeVec4);vec4 slot=readVec4(blockOffsetVec4,propertyType.offsetDwords);float value;if (propertyType.isZoomDependent) {vec2 packedValues=readVec2(slot,propertyType.offsetDwords);value=unpack_mix_vec2(packedValues,u_zoom);} else {value=readFloat(slot,propertyType.offsetDwords);}return value;}SymbolPaintProperties readSymbolPaintProperties() {SymbolPropertyHeader header=readSymbolPropertiesHeader();uint sizeVec4=header.dataDrivenBlockSizeVec4;SymbolPaintProperties props;props.fill_np_color       =header.fill_np_color.isDataDriven     ? readColorProperty(header.fill_np_color,sizeVec4)     : u_spp_fill_np_color;props.halo_np_color       =header.halo_np_color.isDataDriven     ? readColorProperty(header.halo_np_color,sizeVec4)     : u_spp_halo_np_color;props.opacity             =header.opacity.isDataDriven           ? readFloatProperty(header.opacity,sizeVec4)           : u_spp_opacity;props.halo_width          =header.halo_width.isDataDriven        ? readFloatProperty(header.halo_width,sizeVec4)        : u_spp_halo_width;props.halo_blur           =header.halo_blur.isDataDriven         ? readFloatProperty(header.halo_blur,sizeVec4)         : u_spp_halo_blur;props.emissive_strength   =header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength,sizeVec4) : u_spp_emissive_strength;props.occlusion_opacity   =header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity,sizeVec4) : u_spp_occlusion_opacity;props.z_offset            =header.z_offset.isDataDriven          ? readFloatProperty(header.z_offset,sizeVec4)          : u_spp_z_offset;props.translate           =header.translate.isDataDriven          ? readVec2Property(header.translate,sizeVec4)           : vec2(0.0);return props;}
#else
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
#pragma mapbox: define lowp float emissive_strength
#pragma mapbox: define lowp float occlusion_opacity
#pragma mapbox: define lowp float z_offset
#endif
vec2 unpack_opacity(uint packedOpacity) {return vec2(float(packedOpacity/2u)/127.0,float(packedOpacity & 1u));}void main() {
#ifdef USE_PAINT_PROPERTIES_UBO
SymbolPaintProperties paint_properties=readSymbolPaintProperties();lowp float opacity=paint_properties.opacity;v_opacity=opacity;
#ifdef RENDER_SDF
v_fill_np_color=paint_properties.fill_np_color;v_halo_np_color=paint_properties.halo_np_color;v_halo_width=paint_properties.halo_width;v_halo_blur=paint_properties.halo_blur;
#endif
#ifdef LIGHTING_3D_MODE
v_emissive_strength=paint_properties.emissive_strength;
#endif
lowp float occlusion_opacity=paint_properties.occlusion_opacity;lowp float z_offset=paint_properties.z_offset;
#else
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
#pragma mapbox: initialize lowp float emissive_strength
#pragma mapbox: initialize lowp float occlusion_opacity
#pragma mapbox: initialize lowp float z_offset
#endif
vec2 a_pos=vec2(a_pos_offset.xy);vec2 a_offset=vec2(a_pos_offset.zw);vec2 a_tex=vec2(a_tex_size.xy);vec2 a_size=vec2(a_tex_size.zw);float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=vec2(a_pixeloffset.xy);vec2 a_min_font_scale=vec2(a_pixeloffset.zw)/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,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=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);
#ifdef Z_OFFSET
e+=a_auto_z_offset;
#endif
vec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;
#ifdef PROJECTION_GLOBE_VIEW
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=vec3(a_globe_anchor)+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
#else
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
#endif
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a;
#ifdef PROJECTION_GLOBE_VIEW
vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(vec3(a_globe_anchor)+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;
#else
offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;
#endif
vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
#ifdef PROJECTION_GLOBE_VIEW
#ifdef PROJECTED_POS_ON_VIEWPORT
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);
#else
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);    
#endif
#else
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
#endif
highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);
#ifdef TERRAIN
#ifdef PITCH_WITH_MAP_TERRAIN
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
#endif
#endif
#ifdef Z_OFFSET
z+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;
#else
z+=u_pitch_with_map ? z_offset : 0.0;
#endif
float occlusion_fade=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 out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));
#ifdef DEPTH_OCCLUSION
float depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;
#endif
#ifdef OCCLUSION_QUERIES
float occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;
#endif
#ifdef Z_TEST_OCCLUSION
out_fade_opacity*=occlusion_opacity;
#endif
float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;
#else
#ifdef ELEVATED_ROADS
vec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;
#else
pos=vec3(projected_pos.xy/projected_pos.w+offset,z);
#endif
#endif
gl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);
#ifdef USE_PAINT_PROPERTIES_UBO
{vec2 tr=paint_properties.translate;vec2 rotated_tr=vec2(
u_spp_translate_rotation.x*tr.x-u_spp_translate_rotation.y*tr.y,u_spp_translate_rotation.y*tr.x+u_spp_translate_rotation.x*tr.y
);gl_Position.xy+=(u_coord_matrix*vec4(rotated_tr,0.0,0.0)).xy;}
#endif
float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;
#ifdef RENDER_TEXT_AND_SYMBOL
is_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;
#endif
#ifdef ICON_TRANSITION
v_tex_b=vec2(a_texb)/u_texsize;
#endif
#ifdef RENDER_SHADOWS
vec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;
#ifdef NORMAL_OFFSET
vec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();
#endif
v_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);v_depth=gl_Position.w;
#endif
#ifdef INDICATOR_CUTOUT
v_z_offset=e;
#else
#ifdef RENDER_SHADOWS
v_z_offset=e;
#endif
#endif
}`),terrainRaster:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_shadow.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform sampler2D u_image0;
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
uniform sampler2D u_image1;uniform float u_emissive_texture_available;
#endif
in vec2 v_pos0;
#ifdef FOG
in float v_fog_opacity;
#endif
#ifdef RENDER_SHADOWS
in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;
#endif
uniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;
#ifdef LIGHTING_3D_MODE
const vec3 normal=vec3(0.0,0.0,1.0);
#ifdef RENDER_SHADOWS
float cutoffOpacity=1.0;
#ifdef RENDER_CUTOFF
cutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);
#endif
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;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;
#else
float 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));
#endif
#else
float lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0;
#endif
#endif
#else
color=image_color;
#endif
#ifdef FOG
#ifdef ZERO_EXAGGERATION
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#else
color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
#endif
#endif
glFragColor=color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
uniform mat4 u_matrix;uniform float u_skirt_height;in ivec2 a_pos;out vec2 v_pos0;
#ifdef FOG
out float v_fog_opacity;
#endif
#ifdef RENDER_SHADOWS
uniform 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;
#endif
void 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);
#ifdef FOG
#ifdef ZERO_EXAGGERATION
v_fog_pos=fog_position(decodedPos);
#else
v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
#endif
#endif
#ifdef RENDER_SHADOWS
vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);
#endif
}`),terrainDepth:xi("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",`#include "_prelude_terrain.vertex.glsl"
uniform mat4 u_matrix;in ivec2 a_pos;out float v_depth;void main() {float elevation=elevation(vec2(a_pos));gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}`),skybox:xi(`#include "_prelude_fog.fragment.glsl"
in lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb;
#ifdef FOG
sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
#endif
sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
}`,$u),skyboxGradient:xi(`#include "_prelude_fog.fragment.glsl"
in 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));
#ifdef FOG
color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
#endif
color*=u_opacity;glFragColor=color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
}`,$u),skyboxCapture:xi(`
in 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;
#define BETA_R                  vec3(5.5e-6,13.0e-6,22.4e-6)
#define BETA_M                  vec3(21e-6,21e-6,21e-6)
#define MIE_G                   0.76
#define DENSITY_HEIGHT_SCALE_R  8000.0
#define DENSITY_HEIGHT_SCALE_M  1200.0
#define PLANET_RADIUS           6360e3
#define ATMOSPHERE_RADIUS       6420e3
#define SAMPLE_STEPS            10
#define DENSITY_STEPS           4
float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;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:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform sampler2D u_image0;
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
uniform sampler2D u_image1;uniform float u_emissive_texture_available;
#endif
uniform float u_far_z_cutoff;in vec2 v_pos0;
#ifndef FOG
uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;
#endif
void main() {vec4 color;
#ifdef CUSTOM_ANTIALIASING
highp vec2 uv=gl_FragCoord.xy/u_viewport;
#ifdef FLIP_Y
uv.y=1.0-uv.y;
#endif
highp vec3 ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);
#ifdef LIGHTING_3D_MODE
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias);
#else
raster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);
#endif
#else
color=vec4(raster.rgb*antialias,raster.a*antialias);
#endif
#else
color=texture(u_image0,v_pos0);
#ifdef LIGHTING_3D_MODE
#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS
float emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0;
#else
color=apply_lighting_ground(color);
#endif
#endif
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#endif
color*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_terrain.vertex.glsl"
uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;
#ifdef GLOBE_POLES
in vec3 a_globe_pos;in vec2 a_uv;
#else
in ivec2 a_pos;
#endif
out vec2 v_pos0;void main() {
#ifdef GLOBE_POLES
vec3 globe_pos=a_globe_pos;vec2 uv=a_uv;
#else
float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
#endif
v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;
#ifdef GLOBE_POLES
vec3 up_vector=globe_derived_up_vector;
#else
vec3 up_vector=elevationVector(tile_pos);
#endif
float height=elevation(tile_pos);globe_pos+=up_vector*height;
#ifndef GLOBE_POLES
globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;
#endif
#ifdef GLOBE_POLES
vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);
#else
vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
#endif
gl_Position=u_proj_matrix*interpolated_pos;
#ifdef FOG
v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
#endif
}`),globeAtmosphere:xi(`#include "_prelude_fog.fragment.glsl"
uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_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;
#ifdef PROJECTION_GLOBE_VIEW
globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {
#ifdef ALPHA_PASS
glFragColor=vec4(0,0,0,0);return;
#else
#ifdef NATIVE
glFragColor=vec4(1,1,1,1);
#else
glFragColor=vec4(0,0,0,1);
#endif
return;
#endif
}
#endif
highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?
0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;
#ifdef PROJECTION_GLOBE_VIEW
highp 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 ?
PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);
#else
horizon_angle=horizon_angle_mercator;
#endif
horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;
#ifdef ALPHA_PASS
float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);
#else
vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;glFragColor=vec4(c*t,t);
#endif
}`,`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(
mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(
mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`),model:xi(`#include "_prelude_fog.fragment.glsl"
#include "_prelude_shadow.fragment.glsl"
#include "_prelude_lighting.glsl"
uniform float u_opacity;
#ifdef DITHERED_DISCARD
uniform float u_dithered_discard_threshold;
#endif
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;
#ifdef RENDER_SHADOWS
in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;
#endif
#ifdef OCCLUSION_TEXTURE_TRANSFORM
uniform vec4 u_occlusionTextureTransform;
#endif
#pragma mapbox: define-attribute highp vec3 normal_3f
#pragma mapbox: define-attribute highp vec3 color_3f
#pragma mapbox: define-attribute highp vec4 color_4f
#pragma mapbox: define-attribute highp vec2 uv_2f
#pragma mapbox: initialize-attribute highp vec3 normal_3f
#pragma mapbox: initialize-attribute highp vec3 color_3f
#pragma mapbox: initialize-attribute highp vec4 color_4f
#pragma mapbox: initialize-attribute highp vec2 uv_2f
#ifdef HAS_ATTRIBUTE_a_pbr
in lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;
#endif
#ifdef HAS_TEXTURE_u_baseColorTexture
uniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;
#endif
#ifdef HAS_TEXTURE_u_metallicRoughnessTexture
uniform sampler2D u_metallicRoughnessTexture;
#endif
#ifdef HAS_TEXTURE_u_occlusionTexture
uniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;
#endif
#ifdef HAS_TEXTURE_u_normalTexture
uniform sampler2D u_normalTexture;
#endif
#ifdef HAS_TEXTURE_u_emissionTexture
uniform sampler2D u_emissionTexture;
#endif
#ifdef APPLY_LUT_ON_GPU
uniform highp sampler3D u_lutTexture;
#endif
#ifdef TERRAIN_FRAGMENT_OCCLUSION
in highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;
#ifdef DEPTH_D24
highp float unpack_depth(highp float depth) {return  depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}
#else
highp float unpack_depth_rgba(highp vec4 rgba_depth)
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}
#endif
bool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;
#ifdef FLIP_Y
coord.y=1.0-coord.y;
#endif
#ifdef DEPTH_D24
highp float depth=unpack_depth(texture(u_depthTexture,coord).r);
#else
highp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));
#endif
return v_depth > depth+0.0005;}
#endif
#define saturate(_x) clamp(_x,0.,1.)
vec3 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)
{
#ifdef LIGHTING_3D_MODE
vec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;
#ifdef RENDER_SHADOWS
lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);
#else
lighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));
#endif
return apply_lighting(albedo,transformed_normal,lighting_factor);
#else
vec3 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;
#endif
}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;
#ifdef HAS_ATTRIBUTE_a_color_3f
albedo*=vec4(color_3f,1.0);
#endif
#ifdef HAS_ATTRIBUTE_a_pbr
#else
#ifdef HAS_ATTRIBUTE_a_color_4f
albedo*=color_4f;
#endif
#endif
#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)
vec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}
#ifdef UNPREMULT_TEXTURE_IN_SHADER
if(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;
#endif
if(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}
#endif
vec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);
#ifdef APPLY_LUT_ON_GPU
color=applyLUT(u_lutTexture,color);
#endif
return color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {
#ifdef HAS_TEXTURE_u_normalTexture
highp 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;
#ifdef FLIP_Y
T=-T;B=-B;
#endif
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;
#else
return mat3(1.0);
#endif
}highp vec3 getNormal(){highp vec3 n;
#ifdef HAS_ATTRIBUTE_a_normal_3f
n=normalize(normal_3f);
#else
highp 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));
#ifdef FLIP_Y
n=normalize(cross(fdx,fdy));
#else
n=normalize(cross(fdx,fdy))*-1.0;
#endif
#endif
#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
vec3 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);
#endif
return 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;
#ifdef HAS_ATTRIBUTE_a_pbr
mat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;
#endif
#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) 
vec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;
#endif
const 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)
{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)
{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)
{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)
{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)
{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)
{
#ifdef LIGHTING_3D_MODE
return mat.diffuseColor;
#else
return mat.diffuseColor/PI;
#endif
}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)
{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)
{vec3 env_light=vec3(0.65,0.65,0.65);
#ifdef LIGHTING_3D_MODE
float ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;
#endif
vec3 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)
{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;
#ifdef RENDER_SHADOWS
lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);
#else
lighting_factor=NdotL;
#endif
vec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;
#if !defined(LIGHTING_3D_MODE)
const 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);
#endif
color*=intensityFactor;return color;}void main() {
#ifdef TERRAIN_FRAGMENT_OCCLUSION
if (isOccluded()) {discard;}
#endif
vec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;
#ifdef LIGHTING_3D_MODE
lightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;
#endif
vec4 finalColor;
#ifdef DIFFUSE_SHADED
vec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);
#ifdef HAS_TEXTURE_u_occlusionTexture
float ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;
#endif
finalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;
#else
Material mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;
#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
#ifdef OCCLUSION_TEXTURE_TRANSFORM
vec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;
#else
vec2 uv=uv_2f;
#endif
ao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;
#endif
vec4 emissive=u_emissiveFactor;
#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)
emissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);
#endif
#ifdef APPLY_LUT_ON_GPU
float emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;
#endif
color+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;
#ifdef HAS_ATTRIBUTE_a_pbr
float 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);vec3 color_mix=v_color_mix.rgb;
#ifdef APPLY_LUT_ON_GPU
color_mix=applyLUT(u_lutTexture,color_mix);
#endif
color=mix(color,color_mix,min(1.0,resEmission));
#ifdef HAS_ATTRIBUTE_a_color_4f
float 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);
#endif
#endif
vec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);
#endif
#ifdef DITHERED_DISCARD
if (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}}
#endif
#ifdef FOG
finalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));
#endif
#ifdef RENDER_CUTOFF
finalColor*=v_cutoff_opacity;
#endif
#ifdef INDICATOR_CUTOUT
finalColor=applyCutout(finalColor,v_position_height.w);
#endif
#ifdef FEATURE_CUTOUT
finalColor=apply_feature_cutout(finalColor,gl_FragCoord,get_cutout_factors(gl_FragCoord).x);
#endif
glFragColor=finalColor;
#ifdef OVERDRAW_INSPECTOR
glFragColor=vec4(1.0);
#endif
HANDLE_WIREFRAME_DEBUG;}`,`#include "_prelude_fog.vertex.glsl"
#include "_prelude_shadow.vertex.glsl"
in vec3 a_pos_3f;
#pragma mapbox: define-attribute highp vec3 normal_3f
#pragma mapbox: define-attribute highp vec2 uv_2f
#pragma mapbox: define-attribute highp vec3 color_3f
#pragma mapbox: define-attribute highp vec4 color_4f
#pragma mapbox: define-attribute-vertex-shader-only highp uvec4 pbr
#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength
uniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;
#ifdef INSTANCED_ARRAYS
in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;
#else
uniform highp mat4 u_normal_matrix;
#endif
#ifdef RENDER_SHADOWS
uniform 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;out float v_depth_shadows;
#endif
out vec4 v_position_height;out lowp vec4 v_color_mix;
#ifdef TERRAIN_FRAGMENT_OCCLUSION
out highp float v_depth;
#endif
#ifdef HAS_ATTRIBUTE_a_pbr
out lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;
#endif
vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {
#pragma mapbox: initialize-attribute highp vec3 normal_3f
#pragma mapbox: initialize-attribute highp vec2 uv_2f
#pragma mapbox: initialize-attribute highp vec3 color_3f
#pragma mapbox: initialize-attribute highp vec4 color_4f
#pragma mapbox: initialize-attribute-custom highp uvec4 pbr
#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength
highp mat4 normal_matrix;
#ifdef INSTANCED_ARRAYS
normal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);
#else
normal_matrix=u_normal_matrix;
#endif
vec3 local_pos;mat3 rs;
#ifdef MODEL_POSITION_ON_GPU
vec3 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 hidden=float(pos_a.x > EXTENT);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=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;
#else
local_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);
#endif
v_position_height.w=a_pos_3f.z;
#ifdef HAS_ATTRIBUTE_a_pbr
vec4 albedo_c=decode_color(vec2(pbr.xy));vec2 e_r_m=unpack_float(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(float(pbr.w))/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;
#endif
#ifdef FOG
v_fog_pos=fog_position(local_pos);
#endif
#ifdef RENDER_CUTOFF
v_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);
#endif
#ifdef TERRAIN_FRAGMENT_OCCLUSION
v_depth=gl_Position.z/gl_Position.w;
#ifdef CLIP_ZERO_TO_ONE
v_depth=-1.0+2.0*v_depth; 
#endif
#endif
#ifdef HAS_ATTRIBUTE_a_normal_3f
#ifdef MODEL_POSITION_ON_GPU
float 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);
#else
normal_3f=vec3(normal_matrix*vec4(normal_3f,0));
#endif
#endif
#ifdef HAS_ATTRIBUTE_a_pbr
#ifdef HAS_ATTRIBUTE_a_color_4f
v_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);
#endif
#endif
#ifdef RENDER_SHADOWS
vec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);
#ifdef NORMAL_OFFSET
#ifdef HAS_ATTRIBUTE_a_normal_3f
#ifdef MODEL_POSITION_ON_GPU
vec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();
#else
vec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();
#endif
#endif
#endif
v_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;
#endif
}`),modelDepth:xi("void main() {}",`in vec3 a_pos_3f;uniform mat4 u_matrix;
#ifdef MODEL_POSITION_ON_GPU
#ifdef INSTANCED_ARRAYS
in vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;
#else
uniform highp mat4 u_instance;
#endif
uniform highp mat4 u_node_matrix;
#endif
void main() {
#ifdef MODEL_POSITION_ON_GPU
highp mat4 instance;
#ifdef INSTANCED_ARRAYS
instance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);
#else
instance=u_instance;
#endif
vec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);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=mix(u_matrix*pos,AWAY,hidden);
#else
gl_Position=u_matrix*vec4(a_pos_3f,1);
#endif
}`),stars:xi(`in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)
{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;}`,`
in vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_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_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);}`),snowParticle:xi("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}",`
in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; 
uniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; 
uniform float u_horizontalOscillationRate; 
uniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+
localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}`),rainParticle:xi("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}",`
in highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; 
uniform float u_velocity; 
uniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; 
pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+
localY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}`),vignette:xi("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:xi("uniform vec4 u_color;void main() {glFragColor=u_color;}",`#include "_prelude_terrain.vertex.glsl"
in highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;
#ifdef TERRAIN
float e=elevation(world_pos.xy);world_pos.z+=e;
#endif
vec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}`)};function ua(u,i){const o=u.split(`
`);for(let d of o){if(d=d.trimStart(),d[0]!=="#"||!d.includes("if")||d.startsWith("#endif"))continue;const m=d.match(cy);if(m)for(const y of m)uy.has(y)||i.add(y)}}function dy(u){return new Set(["uint","int","uvec2","ivec2","uvec3","ivec3","uvec4","ivec4"]).has(u)}function xi(u,i){const o=new Set,d=[],m=[];u=u.replace(Hu,(v,w)=>(m.push(w),"")),i=i.replace(Hu,(v,w)=>(d.push(w),""));let y=new Set(El);ua(u,y),ua(i,y);for(const v of[...d,...m])Ic[v]||(Ic[v]=new Set,ua(_o[v],Ic[v])),y=new Set([...y,...Ic[v]]);return{fragmentSource:u=u.replace(_t,(v,w,E,P,R)=>(o.add(R),w==="define"?`
#ifndef HAS_UNIFORM_u_${R}
${dy(P)?"flat ":""}in ${E} ${P} ${R};
#else
uniform ${E} ${P} u_${R};
#endif
`:w==="initialize"?`
#ifdef HAS_UNIFORM_u_${R}
    ${E} ${P} ${R} = u_${R};
#endif
`:w==="define-attribute"?`
#ifdef HAS_ATTRIBUTE_a_${R}
    in ${E} ${P} ${R};
#endif
`:w==="initialize-attribute"?"":void 0)),vertexSource:i=i.replace(_t,(v,w,E,P,R)=>{const O=`MATERIAL_ATTRIBUTE_OFFSET_${R}`,k=P==="float"?"vec2":P,N=`GET_ATTRIBUTE_${k}(a_${R}, materialInfo, ${O})`,j=R.match(/color/)?"color":k;return w==="define-attribute-vertex-shader-only"?`
#ifdef HAS_ATTRIBUTE_a_${R}
in ${E} ${P} a_${R};
#endif
`:o.has(R)?w==="define"?`
#ifndef HAS_UNIFORM_u_${R}
uniform lowp float u_${R}_t;
    #if !defined(${O})
        in ${E} ${k} a_${R};
    #endif
${dy(P)?"flat ":""}out ${E} ${P} ${R};
#else
uniform ${E} ${P} u_${R};
#endif
`:w==="initialize"?j==="vec4"||j==="uvec4"?`
#ifndef HAS_UNIFORM_u_${R}
    ${R} = a_${R};
#else
    ${E} ${P} ${R} = u_${R};
#endif
`:`
#if !defined(HAS_UNIFORM_u_${R})
    #ifdef ${O}
        ${R} = unpack_mix_${j}(${N}, u_${R}_t);
    #else
        ${R} = unpack_mix_${j}(a_${R}, u_${R}_t);
    #endif
#else
    ${E} ${P} ${R} = u_${R};
#endif
`:w==="define-attribute"?`
#ifdef HAS_ATTRIBUTE_a_${R}
    in ${E} ${P} a_${R};
    out ${E} ${P} ${R};
#endif
`:w==="initialize-attribute"?`
#ifdef HAS_ATTRIBUTE_a_${R}
    ${R} = a_${R};
#endif
`:void 0:w==="define"?`
#ifndef HAS_UNIFORM_u_${R}
uniform lowp float u_${R}_t;
    #if !defined(${O})
        in ${E} ${k} a_${R};
    #endif
#else
uniform ${E} ${P} u_${R};
#endif
`:w==="define-instanced"?j==="mat4"?`
#ifdef INSTANCED_ARRAYS
in vec4 a_${R}0;
in vec4 a_${R}1;
in vec4 a_${R}2;
in vec4 a_${R}3;
#else
uniform ${E} ${P} u_${R};
#endif
`:`
#ifdef INSTANCED_ARRAYS
in ${E} ${k} a_${R};
#else
uniform ${E} ${P} u_${R};
#endif
`:w==="initialize-attribute-custom"?`
#ifdef HAS_ATTRIBUTE_a_${R}
    ${E} ${P} ${R} = a_${R};
#endif
`:j==="vec4"||j==="uvec4"?`
#ifndef HAS_UNIFORM_u_${R}
    #ifdef ${O}
        ${E} ${P} ${R} = ${N};
    #else
        ${E} ${P} ${R} = a_${R};
    #endif
#else
    ${E} ${P} ${R} = u_${R};
#endif
`:`
#ifndef HAS_UNIFORM_u_${R}
    #ifdef ${O}
        ${E} ${P} ${R} = unpack_mix_${j}(${N}, u_${R}_t);
    #else
        ${E} ${P} ${R} = unpack_mix_${j}(a_${R}, u_${R}_t);
    #endif
#else
    ${E} ${P} ${R} = u_${R};
#endif
`}),usedDefines:y,vertexIncludes:d,fragmentIncludes:m}}class fy{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(i,o,d,m,y,v,w,E){this.context=i;let P=this.boundPaintVertexBuffers.length!==m.length;for(let O=0;!P&&O<m.length;O++)this.boundPaintVertexBuffers[O]!==m[O]&&(P=!0);let R=this.boundDynamicVertexBuffers.length!==w.length;for(let O=0;!R&&O<w.length;O++)this.boundDynamicVertexBuffers[O]!==w[O]&&(R=!0);if(!this.vao||this.boundProgram!==o||this.boundLayoutVertexBuffer!==d||P||R||this.boundIndexBuffer!==y||this.boundVertexOffset!==v)this.freshBind(o,d,m,y,v,w,E);else{i.bindVertexArrayOES.set(this.vao);for(const O of w)O&&(O.bind(),E&&O.instanceCount&&O.setVertexAttribDivisor(i.gl,o,E));y&&y.dynamicDraw&&y.bind()}}freshBind(i,o,d,m,y,v,w){const E=this.context,P=E.gl;this.vao&&this.destroy(),this.vao=E.gl.createVertexArray(),E.bindVertexArrayOES.set(this.vao),this.boundProgram=i,this.boundLayoutVertexBuffer=o,this.boundPaintVertexBuffers=d,this.boundIndexBuffer=m,this.boundVertexOffset=y,this.boundDynamicVertexBuffers=v,o.enableAttributes(P,i),o.bind(),o.setVertexAttribPointers(P,i,y);for(const R of d)R.enableAttributes(P,i),R.bind(),R.setVertexAttribPointers(P,i,y);for(const R of v)R&&(R.enableAttributes(P,i),R.bind(),R.setVertexAttribPointers(P,i,y),w&&R.instanceCount&&R.setVertexAttribDivisor(P,i,w));m&&m.bind()}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function Yp(u,i){const o=Math.pow(2,i.canonical.z),d=i.canonical.y;return[new a.ag(0,d/o).toLngLat().lat,new a.ag(0,(d+1)/o).toLngLat().lat]}function y1(u,i,o,d,m,y,v){const w=u.context,E=w.gl,P=o.hillshadeFBO;if(!P)return;u.prepareDrawTile();const R=u.isTileAffectedByFog(i),O=[];u.terrain&&u.terrain.renderingToTexture&&u.emissiveMode==="mrt-fallback"&&O.push("USE_MRT1");const k=u.getOrCreateProgram("hillshade",{overrideFog:R,defines:O});w.activeTexture.set(E.TEXTURE0),E.bindTexture(E.TEXTURE_2D,P.colorAttachment0.get());const N=((W,ie,ne,K)=>{const xe=ne.paint.get("hillshade-shadow-color"),le=ne.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",_e=ne.paint.get("hillshade-highlight-color"),re=ne.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",ae=ne.paint.get("hillshade-accent-color"),fe=ne.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Ce=ne.paint.get("hillshade-emissive-strength");let ve=a.ap(ne.paint.get("hillshade-illumination-direction"));if(ne.paint.get("hillshade-illumination-anchor")==="viewport")ve-=W.transform.angle;else if(W.style&&W.style.enable3dLights()&&W.style.directionalLight){const ze=W.style.directionalLight.properties.get("direction"),Je=a.cP(ze.x,ze.y,ze.z);ve=a.ap(Je[1])}const Ne=!W.options.moving;return{u_matrix:K||W.transform.calculateProjMatrix(ie.tileID.toUnwrapped(),Ne),u_image:0,u_latrange:Yp(0,ie.tileID),u_light:[ne.paint.get("hillshade-exaggeration"),ve],u_shadow:xe.toPremultipliedRenderColor(le?null:ne.lut),u_highlight:_e.toPremultipliedRenderColor(re?null:ne.lut),u_emissive_strength:Ce,u_accent:ae.toPremultipliedRenderColor(fe?null:ne.lut)}})(u,o,d,u.terrain?i.projMatrix:null);u.uploadCommonUniforms(w,k,i.toUnwrapped());const{tileBoundsBuffer:j,tileBoundsIndexBuffer:U,tileBoundsSegments:X}=u.getTileBoundsBuffers(o);k.draw(u,E.TRIANGLES,m,y,v,Nt.disabled,N,d.id,j,U,X)}function py(u,i,o){if(!i.needsDEMTextureUpload)return;const d=u.context,m=d.gl;d.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||u.getTileTexture(o.stride);const y=o.getPixels();i.demTexture?i.demTexture.update(y,{premultiply:!1}):i.demTexture=new a.T(d,y,m.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1}function x1(u,i,o){const d=u.context,m=d.gl;if(!i.dem)return;const y=i.dem;if(d.activeTexture.set(m.TEXTURE1),py(u,i,y),!i.demTexture)return;i.demTexture.bind(m.NEAREST,m.CLAMP_TO_EDGE);const v=y.dim;d.activeTexture.set(m.TEXTURE0);let w=i.hillshadeFBO;if(!w){const k=new a.T(d,{width:v,height:v,data:null},m.RGBA8);k.bind(m.LINEAR,m.CLAMP_TO_EDGE),w=i.hillshadeFBO=d.createFramebuffer(v,v,1,"renderbuffer"),w.colorAttachment0.set(k.texture)}d.bindFramebuffer.set(w.framebuffer),d.viewport.set([0,0,v,v]);const{tileBoundsBuffer:E,tileBoundsIndexBuffer:P,tileBoundsSegments:R}=u.getMercatorTileBoundsBuffers(),O=[];u.linearFloatFilteringSupported()&&O.push("TERRAIN_DEM_FLOAT_FORMAT"),u.terrain&&u.terrain.renderingToTexture&&u.emissiveMode==="mrt-fallback"&&O.push("USE_MRT1"),u.getOrCreateProgram("hillshadePrepare",{defines:O}).draw(u,m.TRIANGLES,At.disabled,Ht.disabled,jt.unblended,Nt.disabled,((k,N)=>{const j=N.stride,U=a.bb();return a.bT(U,0,a.an,-a.an,0,0,1),a.bx(U,U,[0,-a.an,0]),{u_matrix:U,u_image:1,u_dimension:[j,j],u_zoom:k.overscaledZ}})(i.tileID,y),o.id,E,P,R),i.needsHillshadePrepare=!1}class hn{constructor(i){this.gl=i.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(i){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class my extends hn{getDefault(){return a.aq.transparent.toNonPremultipliedRenderColor(null)}set(i){const o=this.current;(i.r!==o.r||i.g!==o.g||i.b!==o.b||i.a!==o.a||this.dirty)&&(this.gl.clearColor(i.r,i.g,i.b,i.a),this.current=i,this.dirty=!1)}}class v1 extends hn{getDefault(){return 1}set(i){(i!==this.current||this.dirty)&&(this.gl.clearDepth(i),this.current=i,this.dirty=!1)}}class bd extends hn{getDefault(){return 0}set(i){(i!==this.current||this.dirty)&&(this.gl.clearStencil(i),this.current=i,this.dirty=!1)}}class b1 extends hn{getDefault(){return[!0,!0,!0,!0]}set(i){const o=this.current;(i[0]!==o[0]||i[1]!==o[1]||i[2]!==o[2]||i[3]!==o[3]||this.dirty)&&(this.gl.colorMask(i[0],i[1],i[2],i[3]),this.current=i,this.dirty=!1)}}class _y extends hn{getDefault(){return!0}set(i){(i!==this.current||this.dirty)&&(this.gl.depthMask(i),this.current=i,this.dirty=!1)}}class Kp extends hn{getDefault(){return 255}set(i){(i!==this.current||this.dirty)&&(this.gl.stencilMask(i),this.current=i,this.dirty=!1)}}class wd extends hn{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(i){const o=this.current;(i.func!==o.func||i.ref!==o.ref||i.mask!==o.mask||this.dirty)&&(this.gl.stencilFunc(i.func,i.ref,i.mask),this.current=i,this.dirty=!1)}}class Jp extends hn{getDefault(){const i=this.gl;return[i.KEEP,i.KEEP,i.KEEP]}set(i){const o=this.current;(i[0]!==o[0]||i[1]!==o[1]||i[2]!==o[2]||this.dirty)&&(this.gl.stencilOp(i[0],i[1],i[2]),this.current=i,this.dirty=!1)}}class Il extends hn{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;i?o.enable(o.STENCIL_TEST):o.disable(o.STENCIL_TEST),this.current=i,this.dirty=!1}}class Al extends hn{getDefault(){return[0,1]}set(i){const o=this.current;(i[0]!==o[0]||i[1]!==o[1]||this.dirty)&&(this.gl.depthRange(i[0],i[1]),this.current=i,this.dirty=!1)}}class Cc extends hn{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;i?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),this.current=i,this.dirty=!1}}class No extends hn{getDefault(){return this.gl.LESS}set(i){(i!==this.current||this.dirty)&&(this.gl.depthFunc(i),this.current=i,this.dirty=!1)}}class gy extends hn{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;i?o.enable(o.BLEND):o.disable(o.BLEND),this.current=i,this.dirty=!1}}class Qp extends hn{getDefault(){const i=this.gl;return[i.ONE,i.ZERO,i.ONE,i.ZERO]}set(i){const o=this.current;(i[0]!==o[0]||i[1]!==o[1]||i[2]!==o[2]||i[3]!==o[3]||this.dirty)&&(this.gl.blendFuncSeparate(i[0],i[1],i[2],i[3]),this.current=i,this.dirty=!1)}}class yy extends hn{getDefault(){return a.aq.transparent.toNonPremultipliedRenderColor(null)}set(i){const o=this.current;(i.r!==o.r||i.g!==o.g||i.b!==o.b||i.a!==o.a||this.dirty)&&(this.gl.blendColor(i.r,i.g,i.b,i.a),this.current=i,this.dirty=!1)}}class Pc extends hn{getDefault(){return this.gl.FUNC_ADD}set(i){(i!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(i,i),this.current=i,this.dirty=!1)}}class Td extends hn{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;i?o.enable(o.CULL_FACE):o.disable(o.CULL_FACE),this.current=i,this.dirty=!1}}class Sd extends hn{getDefault(){return this.gl.BACK}set(i){(i!==this.current||this.dirty)&&(this.gl.cullFace(i),this.current=i,this.dirty=!1)}}class em extends hn{getDefault(){return this.gl.CCW}set(i){(i!==this.current||this.dirty)&&(this.gl.frontFace(i),this.current=i,this.dirty=!1)}}let Ed=class extends hn{getDefault(){return null}set(u){(u!==this.current||this.dirty)&&(this.gl.useProgram(u),this.current=u,this.dirty=!1)}};class qu extends hn{getDefault(){return this.gl.TEXTURE0}set(i){(i!==this.current||this.dirty)&&(this.gl.activeTexture(i),this.current=i,this.dirty=!1)}}class xy extends hn{getDefault(){const i=this.gl;return[0,0,i.drawingBufferWidth,i.drawingBufferHeight]}set(i){const o=this.current;(i[0]!==o[0]||i[1]!==o[1]||i[2]!==o[2]||i[3]!==o[3]||this.dirty)&&(this.gl.viewport(i[0],i[1],i[2],i[3]),this.current=i,this.dirty=!1)}}class vy extends hn{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;o.bindFramebuffer(o.FRAMEBUFFER,i),this.current=i,this.dirty=!1}}class by extends hn{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;o.bindRenderbuffer(o.RENDERBUFFER,i),this.current=i,this.dirty=!1}}class Mc extends hn{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;o.bindTexture(o.TEXTURE_2D,i),this.current=i,this.dirty=!1}}class wy extends hn{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;o.bindBuffer(o.ARRAY_BUFFER,i),this.current=i,this.dirty=!1}}class w1 extends hn{getDefault(){return null}set(i){const o=this.gl;o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,i),this.current=i,this.dirty=!1}}class T1 extends hn{getDefault(){return null}set(i){this.gl&&(i!==this.current||this.dirty)&&(this.gl.bindVertexArray(i),this.current=i,this.dirty=!1)}}class S1 extends hn{getDefault(){return 4}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_ALIGNMENT,i),this.current=i,this.dirty=!1}}class tm extends hn{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i),this.current=i,this.dirty=!1}}class im extends hn{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,i),this.current=i,this.dirty=!1}}class Wu extends hn{constructor(i,o){super(i),this.context=i,this.parent=o}getDefault(){return null}}class Rc extends Wu{constructor(i,o,d=0){super(i,o),this.attachmentPoint=i.gl.COLOR_ATTACHMENT0+d}setDirty(){this.dirty=!0}set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,this.attachmentPoint,o.TEXTURE_2D,i,0),this.current=i,this.dirty=!1}}class nm extends Wu{attachment(){return this.gl.DEPTH_ATTACHMENT}set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferRenderbuffer(o.FRAMEBUFFER,this.attachment(),o.RENDERBUFFER,i),this.current=i,this.dirty=!1}}class Ty extends Wu{attachment(){return this.gl.DEPTH_ATTACHMENT}set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,this.attachment(),o.TEXTURE_2D,i,0),this.current=i,this.dirty=!1}}class E1 extends nm{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Xu=(u,i,o,d)=>({u_matrix:u,u_image0:0,u_image1:1,u_skirt_height:i,u_ground_shadow_factor:o,u_emissive_texture_available:d}),Dc=(u,i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X)=>({u_proj_matrix:Float32Array.from(u),u_globe_matrix:i,u_normalize_matrix:Float32Array.from(d),u_merc_matrix:o,u_zoom_transition:m,u_merc_center:y,u_image0:0,u_image1:1,u_frustum_tl:v,u_frustum_tr:w,u_frustum_br:E,u_frustum_bl:P,u_globe_pos:R,u_globe_radius:O,u_viewport:k,u_grid_matrix:X?Float32Array.from(X):new Float32Array(9),u_skirt_height:N,u_far_z_cutoff:j,u_emissive_texture_available:U});function rm(u,i){return u!=null&&i!=null&&!(!u.hasData()||!i.hasData())&&u.demTexture!=null&&i.demTexture!=null&&u.tileID.key!==i.tileID.key}const zr=new class{constructor(){this.operations={}}newMorphing(u,i,o,d,m){if(u in this.operations){const y=this.operations[u];y.to.tileID.key!==o.tileID.key&&(y.queued=o)}else this.operations[u]={startTime:d,phase:0,duration:m,from:i,to:o,queued:null}}getMorphValuesForProxy(u){if(!(u in this.operations))return null;const i=this.operations[u];return{from:i.from,to:i.to,phase:i.phase}}update(u){for(const i in this.operations){const o=this.operations[i];for(o.phase=(u-o.startTime)/o.duration;o.phase>=1||!this._validOp(o);)if(!this._nextOp(o,u)){delete this.operations[i];break}}}_nextOp(u,i){return!!u.queued&&(u.from=u.to,u.to=u.queued,u.queued=null,u.phase=0,u.startTime=i,!0)}_validOp(u){return u.from.hasData()&&u.to.hasData()}},Id={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Yu(u,i,o){if(i===0)return 0;const d=i<1&&o===514?.25/i:1;return 6*Math.pow(1.5,22-u)*Math.max(i,1)*d}function Ad(u,i){const o=1<<u.z;return!i&&(u.x===0||u.x===o-1)||u.y===0||u.y===o-1}function Ku(u,i){if(!u.style||!u.style.enable3dLights())return;const o=u.context,d=o.gl;o.activeTexture.set(d.TEXTURE1),i?i.bind(d.LINEAR,d.CLAMP_TO_EDGE):u.emptyTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE)}const Ju=u=>({u_matrix:u});function Qu(u,i,o,d,m){if(m>0){const y=a.o.now(),v=(y-u.timeAdded)/m,w=i?(y-i.timeAdded)/m:-1,E=o.getSource(),P=d.coveringZoomLevel({tileSize:E.tileSize,roundZoom:E.roundZoom}),R=!i||Math.abs(i.tileID.overscaledZ-P)>Math.abs(u.tileID.overscaledZ-P),O=R&&u.refreshedUponExpiration?1:a.aC(R?v:1-w,0,1);return i?{opacity:1,mix:1-O,isFading:v<1}:{opacity:O,mix:0,isFading:v<1}}return{opacity:1,mix:0,isFading:!1}}class Cd extends Ws{constructor(i){const o={type:"raster-dem",maxzoom:Math.ceil(i.transform.maxZoom)},d=od("mock-dem",o,i.style.dispatcher,i.style);super("mock-dem",d,null),d.setEventedParent(this),this._sourceLoaded=!0}_loadTile(i,o){i.state="loaded",o(null)}}class sm extends Ws{constructor(i){const o=od("proxy",{type:"geojson",maxzoom:Math.ceil(i.transform.maxZoom)},i.style.dispatcher,i.style);super("proxy",o,null),o.setEventedParent(this),this.map=this.getSource().map=i,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(i,o,d){if(i.freezeTileCoverage)return;this.transform=i;const m=i.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((y,v)=>{if(y[v.key]="",!this._tiles[v.key]){const w=new a.b0(v,this._source.tileSize*v.overscaleFactor(),i.tileZoom,void 0,void 0,this._source.worldview);w.state="loaded",this._tiles[v.key]=w}return y},{});for(const y in this._tiles)y in m||(this.freeFBO(y),this._tiles[y].unloadVectorData(),delete this._tiles[y])}freeFBO(i){const o=this.proxyCachedFBO[i];if(o!==void 0){const d=Object.values(o);this.renderCachePool.push(...d),delete this.proxyCachedFBO[i]}}deallocRenderCache(){this.renderCache.forEach(i=>i.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Pd extends a.aR{constructor(i,o,d){super(i.overscaledZ,i.wrap,i.canonical.z,i.canonical.x,i.canonical.y),this.proxyTileKey=o,this.projMatrix=d}}class eh extends a.bu{constructor(i,o){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=i,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[d,m,y]=function(){const E=new a.dB,P=new a.dC,R=131;E.reserve(17161),P.reserve(33800);const O=a.an/128,k=a.an+O/2,N=k+O;for(let U=-O;U<N;U+=O)for(let X=-O;X<N;X+=O){const W=X<0||X>k||U<0||U>k?24575:0,ie=a.aC(Math.round(X),0,a.an),ne=a.aC(Math.round(U),0,a.an);E.emplaceBack(ie+W,ne)}const j=(U,X)=>{const W=X*R+U;P.emplaceBack(W+1,W,W+R),P.emplaceBack(W+R,W+R+1,W+1)};for(let U=1;U<129;U++)for(let X=1;X<129;X++)j(X,U);return[0,129].forEach(U=>{for(let X=0;X<130;X++)j(X,U),j(U,X)}),[E,P,32768]}(),v=i.context;this.gridBuffer=v.createVertexBuffer(d,a.dx.members),this.gridIndexBuffer=v.createIndexBuffer(m),this.gridSegments=a.dy.simpleSegment(0,0,d.length,m.length),this.gridNoSkirtSegments=a.dy.simpleSegment(0,0,d.length,y),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new sm(o.map),this.orthoMatrix=a.bb(),a.bT(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,a.an,0,a.an,0,1);const w=v.gl;this._overlapStencilMode=new Ht({func:w.GEQUAL,mask:255},0,255,w.KEEP,w.KEEP,w.REPLACE),this._previousZoom=i.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=o,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Cd(o.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1}set style(i){i.on("data",this._onStyleDataEvent.bind(this)),this._style=i,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(i,o,d){if(i&&i.terrain){this._style!==i&&(this.style=i,this._evaluationZoom=void 0);const m=i.terrain.properties,y=i.terrain.drapeRenderMode===0,v=i.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=a.o.now();const w=i.terrain&&i.terrain.scope,E=m.get("source"),P=y?this._mockSourceCache:i.getSourceCache(E,w);if(!P)return void a.w(`Couldn't find terrain source "${E}".`);if(this.sourceCache=P,this._attenuationRange=i.terrain.getAttenuationRange(),this._exaggeration=v?this.calculateExaggeration(o):m.get("exaggeration"),!o.projection.requiresDraping&&v&&this._exaggeration===0)return void this._disable();this.enabled=!0;const R=()=>{this.sourceCache.used&&a.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const O=this.getScaledDemTileSize();this.sourceCache.update(o,O,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,R(),this._initializing=!0),R(),o.updateElevation(!0,d),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(o),this._emptyDEMTextureDirty=!0,this._previousZoom=o.zoom}else this._disable()}calculateExaggeration(i){if(this._attenuationRange&&i.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(i.zoom);const o=this._previousCameraAltitude,d=i.getFreeCameraOptions().position.z/i.pixelsPerMeter*i.worldSize;this._previousCameraAltitude=d;const m=o!=null?d-o:Number.MAX_VALUE;if(Math.abs(m)<2)return this._exaggeration;const y=i.zoom,v=this._style.terrain;if(!this._previousUpdateTimestamp)return v.getExaggeration(y);let w=y-this._previousZoom;const E=this._previousUpdateTimestamp;let P=y;this._evaluationZoom!=null&&(P=this._evaluationZoom,Math.abs(y-P)>.5&&(w=.5*(y-P+w)),w*m<0&&(P+=w)),this._evaluationZoom=P;const R=v.getExaggeration(P),O=R===v.getExaggeration(Math.max(0,P-.1));if(O&&Math.abs(R-this._exaggeration)<.01)return R;let k=Math.min(.1,.00375*(this._updateTimestamp-E));return(O||R<.1||Math.abs(w)<1e-4)&&(k=Math.min(.2,4*k)),a.am(this._exaggeration,R,k)}resetTileLookupCache(i){this._findCoveringTileCache[i]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(i){i.dataType==="source"&&i.coord?this._clearRenderCacheForTile(i.sourceCacheId,i.coord):i.dataType==="style"&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._emptyDEMTextureDirty=!0,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const i in this._style._mergedSourceCaches)this._style._mergedSourceCaches[i].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach(i=>i.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const i=2*this.proxySourceCache.getSource().tileSize;return[i,i]}set useVertexMorphing(i){this._useVertexMorphing=i}updateTileBinding(i){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const o=this.proxySourceCache,d=this.painter.transform;this._initializing&&(this._initializing=d._centerAltitude===0&&this.getAtPointOrZero(a.ag.fromLngLat(d.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const m=this.proxyCoords=o.getIds().map(E=>{const P=o.getTileByID(E).tileID;return P.projMatrix=d.calculateProjMatrix(P.toUnwrapped()),P});(function(E,P){const R=P.transform.pointCoordinate(P.transform.getCameraPoint()),O=new a.P(R.x,R.y);E.sort((k,N)=>{if(N.overscaledZ-k.overscaledZ)return N.overscaledZ-k.overscaledZ;const j=new a.P(k.canonical.x+(1<<k.canonical.z)*k.wrap,k.canonical.y),U=new a.P(N.canonical.x+(1<<N.canonical.z)*N.wrap,N.canonical.y),X=O.mult(1<<k.canonical.z);return X.x-=.5,X.y-=.5,X.distSqr(j)-X.distSqr(U)})})(m,this.painter);const y=this.proxyToSource||{};this.proxyToSource={},m.forEach(E=>{this.proxyToSource[E.key]={}}),this.terrainTileForTile={};const v=this._style._mergedSourceCaches;for(const E in v){const P=v[E];if(!P.used||(P!==this.sourceCache&&this.resetTileLookupCache(P.id),this._setupProxiedCoordsForOrtho(P,i[E],y),P.usedForTerrain))continue;const R=i[E];(P.getSource().reparseOverscaled||P._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(R)}this.proxiedCoords[o.id]=m.map(E=>new Pd(E,E.key,this.orthoMatrix)),this._assignTerrainTiles(m),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(y),this.renderingToTexture=!1;const w={};this._visibleDemTiles=[];for(const E of this.proxyCoords){const P=this.terrainTileForTile[E.key];if(!P)continue;const R=P.tileID.key;R in w||(this._visibleDemTiles.push(P),w[R]=R)}}_assignTerrainTiles(i){this._initializing||i.forEach(o=>{if(this.terrainTileForTile[o.key])return;const d=this._findTileCoveringTileID(o,this.sourceCache);d&&(this.terrainTileForTile[o.key]=d)})}_prepareDEMTextures(){const i=this.painter.context,o=i.gl;for(const d in this.terrainTileForTile){const m=this.terrainTileForTile[d],y=m.dem;!y||m.demTexture&&!m.needsDEMTextureUpload||(i.activeTexture.set(o.TEXTURE1),py(this.painter,m,y))}}_prepareDemTileUniforms(i,o,d,m){if(!o||o.demTexture==null)return!1;const y=i.tileID.canonical,v=Math.pow(2,o.tileID.canonical.z-y.z),w=m||"";return d[`u_dem_tl${w}`]=[y.x*v%1,y.y*v%1],d[`u_dem_scale${w}`]=v,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let i=0;const o=this._visibleDemTiles.reduce((d,m)=>{if(!m.dem)return d;const y=m.dem.tree.minimums[0];return y>0&&i++,d+y},0);return i?o/i:0}_updateEmptyDEMTexture(){const i=this.painter.context,o=i.gl;i.activeTexture.set(o.TEXTURE2);const d=this._getLoadedAreaMinimum(),m=new a.dz({width:1,height:1},new Float32Array([d]));this._emptyDEMTextureDirty=!1;let y=this._emptyDEMTexture;return y?y.update(m,{premultiply:!1}):y=this._emptyDEMTexture=new a.T(i,m,o.R32F,{premultiply:!1}),y}setupElevationDraw(i,o,d){const m=this.painter.context,y=m.gl,v={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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};v.u_exaggeration=this.exaggeration();let w=null,E=null,P=1;if(d&&d.morphing&&this._useVertexMorphing){const N=d.morphing.srcDemTile,j=d.morphing.dstDemTile;P=d.morphing.phase,N&&j&&(this._prepareDemTileUniforms(i,N,v,"_prev")&&(E=N),this._prepareDemTileUniforms(i,j,v)&&(w=j))}const R=N=>N&&N.demTexture&&this.painter.linearFloatFilteringSupported()?y.LINEAR:y.NEAREST;let O=null;var k;if(this.enabled?E&&w?(O=w.demTexture,m.activeTexture.set(y.TEXTURE4),E.demTexture.bind(R(E),y.CLAMP_TO_EDGE),v.u_dem_lerp=P):(w=this.terrainTileForTile[i.tileID.key],O=this._prepareDemTileUniforms(i,w,v)?w.demTexture:this.emptyDEMTexture):O=this.emptyDEMTexture,m.activeTexture.set(y.TEXTURE2),O&&(v.u_dem_size=(k=O).size[0]===1?1:k.size[0]-2,O.bind(R(w),y.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(d&&d.useDepthForOcclusion,o,v),d&&d.useMeterToDem&&w){const N=(1<<w.tileID.canonical.z)*a.bU(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;v.u_meter_to_dem=N}if(d&&d.labelPlaneMatrixInv&&(v.u_label_plane_matrix_inv=d.labelPlaneMatrixInv),o.setTerrainUniformValues(m,v),this.painter.transform.projection.name==="globe"){const N=this.globeUniformValues(this.painter.transform,i.tileID.canonical,d&&d.useDenormalizedUpVectorScale);o.setGlobeUniformValues(m,N)}}globeUniformValues(i,o,d){const m=i.projection;return{u_tile_tl_up:m.upVector(o,0,0),u_tile_tr_up:m.upVector(o,a.an,0),u_tile_br_up:m.upVector(o,a.an,a.an),u_tile_bl_up:m.upVector(o,0,a.an),u_tile_up_scale:d?a.dA(1):m.upVectorScale(o,i.center.lat,i.worldSize).metersToTile}}renderToBackBuffer(i){const o=this.painter,d=this.painter.context;i.length!==0&&(d.bindFramebuffer.set(null),d.viewport.set([0,0,o.width,o.height]),o.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(m,y,v,w,E){if(m.transform.projection.name==="globe")(function(P,R,O,k,N){const j=P.context,U=j.gl;let X,W;const ie=P.transform,ne=a.dp(P,j,ie),K=(Ne,ze)=>{if(W===ze)return;const Je=[Id[ze],"PROJECTION_GLOBE_VIEW"];ne&&Je.push("CUSTOM_ANTIALIASING");const tt=P.isTileAffectedByFog(Ne);X=P.getOrCreateProgram("globeRaster",{defines:Je,overrideFog:tt}),W=ze},xe=P.colorModeForRenderPass(),le=new At(U.LEQUAL,At.ReadWrite,P.depthRangeFor3D);zr.update(N);const _e=a.dq(ie),re=[a.aH(ie.center.lng),a.aL(ie.center.lat)],ae=P.globeSharedBuffers,fe=[ie.width*a.o.devicePixelRatio,ie.height*a.o.devicePixelRatio],Ce=Float32Array.from(ie.globeMatrix),ve={useDenormalizedUpVectorScale:!0};{const Ne=P.transform,ze=Yu(Ne.zoom,R.exaggeration(),R.sourceCache._source.tileSize);W=-1;const Je=U.TRIANGLES;for(const tt of k){const Pe=O.getTile(tt),we=Ht.disabled,Oe=R.prevTerrainTileForTile[tt.key],Ue=R.terrainTileForTile[tt.key];rm(Oe,Ue)&&zr.newMorphing(tt.key,Oe,Ue,N,250),Ku(P,Pe.emissiveTexture),j.activeTexture.set(U.TEXTURE0),Pe.texture&&Pe.texture.bind(U.LINEAR,U.CLAMP_TO_EDGE);const $e=zr.getMorphValuesForProxy(tt.key),ft=$e?1:0;$e&&Object.assign(ve,{morphing:{srcDemTile:$e.from,dstDemTile:$e.to,phase:a.dn($e.phase)}});const lt=a.dr(tt.canonical),ct=a.ds(lt.getCenter().lat),et=a.dt(tt.canonical,lt,ct,Ne.worldSize/Ne._pixelsPerMercatorPixel),Et=a.du(a.dv(tt.canonical)),Mt=P.emissiveMode==="mrt-fallback"?1:0,vt=Dc(Ne.expandedFarZProjMatrix,Ce,_e,Et,a.al(Ne.zoom),re,Ne.frustumCorners.TL,Ne.frustumCorners.TR,Ne.frustumCorners.BR,Ne.frustumCorners.BL,Ne.globeCenterInViewSpace,Ne.globeRadius,fe,ze,Ne._farZ,Mt,et);if(K(tt,ft),X&&(R.setupElevationDraw(Pe,X,ve),P.uploadCommonUniforms(j,X,tt.toUnwrapped()),ae)){const[St,Vt,Yt]=ae.getGridBuffers(ct,ze!==0);X.draw(P,Je,le,we,xe,Nt.backCCW,vt,"globe_raster",St,Vt,Yt)}}}if(ae&&(P.renderDefaultNorthPole||P.renderDefaultSouthPole)){const Ne=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];ne&&Ne.push("CUSTOM_ANTIALIASING"),X=P.getOrCreateProgram("globeRaster",{defines:Ne});for(const ze of k){const{x:Je,y:tt,z:Pe}=ze.canonical,we=tt===0,Oe=tt===(1<<Pe)-1,[Ue,$e,ft,lt]=ae.getPoleBuffers(Pe,!1);if(lt&&(we||Oe)){const ct=O.getTile(ze);Ku(P,ct.emissiveTexture),j.activeTexture.set(U.TEXTURE0),ct.texture&&ct.texture.bind(U.LINEAR,U.CLAMP_TO_EDGE);let et=a.dw(Pe,Je,ie);const Et=a.du(a.dv(ze.canonical)),Mt=P.emissiveMode==="mrt-fallback"?1:0,vt=(St,Vt)=>St.draw(P,U.TRIANGLES,le,Ht.disabled,xe,Nt.disabled,Dc(ie.expandedFarZProjMatrix,et,et,Et,0,re,ie.frustumCorners.TL,ie.frustumCorners.TR,ie.frustumCorners.BR,ie.frustumCorners.BL,ie.globeCenterInViewSpace,ie.globeRadius,fe,0,ie._farZ,Mt),"globe_pole_raster",Vt,ft,lt);R.setupElevationDraw(ct,X,ve),P.uploadCommonUniforms(j,X,ze.toUnwrapped()),we&&P.renderDefaultNorthPole&&vt(X,Ue),Oe&&P.renderDefaultSouthPole&&(et=a.cC(a.bb(),et,[1,-1,1]),vt(X,$e))}}}})(m,y,v,w,E);else{const P=m.context,R=P.gl;let O,k;const N=m.shadowRenderer,j=ir(m,m.longestCutoffRange),U=xe=>{if(k===xe)return;const le=[];le.push(Id[xe]),j.shouldRenderCutoff&&le.push("RENDER_CUTOFF"),N&&(le.push("RENDER_SHADOWS"),N.useNormalOffset&&le.push("NORMAL_OFFSET")),O=m.getOrCreateProgram("terrainRaster",{defines:le}),k=xe},X=m.colorModeForRenderPass(),W=new At(R.LEQUAL,At.ReadWrite,m.depthRangeFor3D);zr.update(E);const ie=m.transform,ne=Yu(ie.zoom,y.exaggeration(),y.sourceCache._source.tileSize);let K=[0,0,0];if(N){const xe=m.style.directionalLight,le=m.style.ambientLight;xe&&le&&(K=mo(m.style,xe,le))}{k=-1;const xe=R.TRIANGLES,[le,_e]=[y.gridIndexBuffer,y.gridSegments];for(const re of w){const ae=v.getTile(re),fe=Ht.disabled,Ce=y.prevTerrainTileForTile[re.key],ve=y.terrainTileForTile[re.key];rm(Ce,ve)&&zr.newMorphing(re.key,Ce,ve,E,250),Ku(m,ae.emissiveTexture),P.activeTexture.set(R.TEXTURE0),ae.texture&&ae.texture.bind(R.LINEAR,R.CLAMP_TO_EDGE);const Ne=zr.getMorphValuesForProxy(re.key),ze=Ne?1:0;let Je;Ne&&(Je={morphing:{srcDemTile:Ne.from,dstDemTile:Ne.to,phase:a.dn(Ne.phase)}});const tt=m.emissiveMode==="mrt-fallback"?1:0,Pe=Xu(re.projMatrix,Ad(re.canonical,ie.renderWorldCopies)?ne/10:ne,K,tt);if(U(ze),!O)continue;y.setupElevationDraw(ae,O,Je);const we=re.toUnwrapped();N&&N.setupShadows(we,O),m.uploadCommonUniforms(P,O,we,null,j),O.draw(m,xe,W,fe,X,Nt.backCCW,Pe,"terrain_raster",y.gridBuffer,le,_e)}}}}(o,this,this.proxySourceCache,i,this._updateTimestamp),this.renderingToTexture=!0,o.gpuTimingDeferredRenderEnd(),i.splice(0,i.length))}renderBatch(i){if(this._drapedRenderBatches.length===0)return i+1;this.renderingToTexture=!0;const o=this.painter,d=this.painter.context,m=this.proxySourceCache,y=this.proxiedCoords[m.id],v=this._drapedRenderBatches.shift(),w=o.style.order,E=[];this._updateFBOs(o.emissiveMode==="mrt-fallback");let P=0;for(const R of y){const O=m.getTileByID(R.proxyTileKey),k=m.proxyCachedFBO[R.key]?m.proxyCachedFBO[R.key][i]:void 0,N=k!==void 0?m.renderCache[k]:this.pool[P++],j=k!==void 0;if(O.texture=N.tex,O.emissiveTexture=N.emissiveTex,j&&!N.dirty){E.push(O.tileID);continue}d.bindFramebuffer.set(N.fb.framebuffer);const U=d.gl;let X;U.drawBuffers(o.emissiveMode==="mrt-fallback"?[U.COLOR_ATTACHMENT0,U.COLOR_ATTACHMENT1]:[U.COLOR_ATTACHMENT0]),this.renderedToTile=!1,N.dirty&&(d.clear({color:a.aq.transparent,stencil:0}),N.dirty=!1);for(let W=v.start;W<=v.end;++W){const ie=o.style._mergedLayers[w[W]];if(ie.isHidden(o.transform.zoom))continue;const ne=o.style.getLayerSourceCache(ie),K=ne?this.proxyToSource[R.key][ne.id]:[R];if(!K)continue;const xe=K;d.viewport.set([0,0,N.fb.width,N.fb.height]),X!==(ne?ne.id:null)&&(this._setupStencil(N,K,ie,ne),X=ne?ne.id:null),o.renderLayer(o,ne,ie,xe)}if(U.drawBuffers([U.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const W of this._pendingGroundEffectLayers){const ie=o.style._mergedLayers[w[W]];if(ie.isHidden(o.transform.zoom))continue;const ne=o.style.getLayerSourceCache(ie),K=ne?this.proxyToSource[R.key][ne.id]:[R];if(!K)continue;const xe=K;d.viewport.set([0,0,N.fb.width,N.fb.height]),X!==(ne?ne.id:null)&&(this._setupStencil(N,K,ie,ne),X=ne?ne.id:null),o.renderLayer(o,ne,ie,xe)}this.renderedToTile?(N.dirty=!0,E.push(O.tileID)):j||--P,P===5&&(P=0,this.renderToBackBuffer(E))}return this.renderToBackBuffer(E),this.renderingToTexture=!1,d.bindFramebuffer.set(null),d.viewport.set([0,0,o.width,o.height]),v.end+1}postRender(){}isLayerOrderingCorrect(i){const o=i.order.length;let d=-1,m=o;for(let y=0;y<o;++y)this._style.isLayerDraped(i._mergedLayers[i.order[y]])?d=Math.max(d,y):m=Math.min(m,y);return m>d}getMinElevationBelowMSL(){let i=0;return this._visibleDemTiles.filter(o=>o.dem).forEach(o=>{i=Math.min(i,o.dem.tree.minimums[0])}),i===0?i:(i-30)*this._exaggeration}raycast(i,o,d){if(!this._visibleDemTiles)return null;const m=this._visibleDemTiles.filter(y=>y.dem).map(y=>{const v=y.tileID,w=1<<v.overscaledZ,{x:E,y:P}=v.canonical,R=E/w,O=(E+1)/w,k=P/w,N=(P+1)/w;return{minx:R,miny:k,maxx:O,maxy:N,t:y.dem.tree.raycastRoot(R,k,O,N,i,o,d),tile:y}});m.sort((y,v)=>(y.t!==null?y.t:Number.MAX_VALUE)-(v.t!==null?v.t:Number.MAX_VALUE));for(const y of m){if(y.t==null)return null;const v=y.tile.dem.tree.raycast(y.minx,y.miny,y.maxx,y.maxy,i,o,d);if(v!=null)return v}return null}_createFBO(){const i=this.painter.context,o=i.gl,d=this.drapeBufferSize;i.activeTexture.set(o.TEXTURE0);const m=new a.T(i,{width:d[0],height:d[1],data:null},o.RGBA8);m.bind(o.LINEAR,o.CLAMP_TO_EDGE);const y=i.createFramebuffer(d[0],d[1],1,null);let v;return y.colorAttachment0.set(m.texture),this._emissiveTexture&&(v=new a.T(i,{width:d[0],height:d[1],data:null},o.R8),v.bind(o.LINEAR,o.CLAMP_TO_EDGE),y.createColorAttachment(i,1),y.colorAttachment1.set(v.texture)),y.depthAttachment=new E1(i,y.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=i.createRenderbuffer(i.gl.DEPTH_STENCIL,d[0],d[1]),this._stencilRef=0,y.depthAttachment.set(this._sharedDepthStencil),i.clear({stencil:0})):y.depthAttachment.set(this._sharedDepthStencil),i.extTextureFilterAnisotropic&&o.texParameterf(o.TEXTURE_2D,i.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,i.extTextureFilterAnisotropicMax),{fb:y,tex:m,emissiveTex:v,dirty:!1}}_updateFBOs(i){if(this._emissiveTexture!==i){for(const o of this.pool)this._updateFBO(o,i);for(const o of this.proxySourceCache.renderCache)this._updateFBO(o,i);this._emissiveTexture=i}}_updateFBO(i,o){const d=i.fb,m=this.painter.context,y=m.gl,v=this.drapeBufferSize;if(o){const w=new a.T(m,{width:v[0],height:v[1],data:null},y.R8);w.bind(y.LINEAR,y.CLAMP_TO_EDGE),i.emissiveTex=w,d.createColorAttachment(m,1),d.colorAttachment1.set(w.texture)}else i.emissiveTex=void 0,d.removeColorAttachment(m,1);i.dirty=!0}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._debugParams.disableRenderCache||this._style.hasLightTransitions())return!0;for(const i in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[i].hasTransition())return!0;return this._style.order.some(i=>{const o=this._style._mergedLayers[i],d=o.isHidden(this.painter.transform.zoom);return o.type==="hillshade"||o.type==="custom"?!d&&o.shouldRedrape():!d&&o.hasTransition()})}_clearLineLayersFromRenderCache(){let i=!1;for(const d of this._style.getSources())if(d instanceof ts){i=!0;break}if(!i)return;const o={};for(let d=0;d<this._style.order.length;++d){const m=this._style._mergedLayers[this._style.order[d]],y=this._style.getLayerSourceCache(m);if(!y||o[y.id]||m.isHidden(this.painter.transform.zoom)||m.type!=="line")continue;const v=m.widthExpression(),w=m.emissiveStrengthExpression();if(v instanceof a.af||w instanceof a.af){o[y.id]=!0;for(const E of this.proxyCoords){const P=this.proxyToSource[E.key][y.id];if(P)for(const R of P)this._clearRenderCacheForTile(y.id,R)}}}}_clearRasterLayersFromRenderCache(){let i=!1;for(const d in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[d]._source instanceof Pu){i=!0;break}if(!i)return;const o={};for(let d=0;d<this._style.order.length;++d){const m=this._style._mergedLayers[this._style.order[d]],y=this._style.getLayerSourceCache(m);if(!y||o[y.id]||m.isHidden(this.painter.transform.zoom)||m.type!=="raster")continue;const v=m.paint.get("raster-fade-duration");for(const w of this.proxyCoords){const E=this.proxyToSource[w.key][y.id];if(E)for(const P of E){const R=Qu(y.getTile(P),y.findLoadedParent(P,0),y,this.painter.transform,v);(R.opacity!==1||R.mix!==0)&&this._clearRenderCacheForTile(y.id,P)}}}}_setupDrapedRenderBatches(){this._style.updateDrapeFirstLayers();const i=this._style.order,o=i.length;if(o===0)return;const d=[];this._pendingGroundEffectLayers=[];let m,y=0,v=this._style._mergedLayers[i[y]];for(;!this._style.isLayerDraped(v)&&v.isHidden(this.painter.transform.zoom)&&++y<o;)v=this._style._mergedLayers[i[y]];for(;y<o;++y){const w=this._style._mergedLayers[i[y]];w.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(w)?m===void 0&&(m=y):(w.type==="fill-extrusion"&&this._pendingGroundEffectLayers.push(y),m!==void 0&&(d.push({start:m,end:y-1}),m=void 0)))}if(m!==void 0&&d.push({start:m,end:y-1}),d.length!==0){const w=d[d.length-1];this._pendingGroundEffectLayers.every(E=>E>w.end)||a.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=d}_setupRenderCache(i){const o=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,o.renderCache.length>o.renderCachePool.length){const v=Object.values(o.proxyCachedFBO);o.proxyCachedFBO={};for(let w=0;w<v.length;++w){const E=Object.values(v[w]);o.renderCachePool.push(...E)}}return}this._clearRasterLayersFromRenderCache();const d=this.proxyCoords,m=this._tilesDirty;for(let v=d.length-1;v>=0;v--){const w=d[v];if(o.getTileByID(w.key),o.proxyCachedFBO[w.key]!==void 0){const E=i[w.key],P=this.proxyToSource[w.key];let R=0;for(const O in P){const k=P[O],N=E[O];if(!N||N.length!==k.length||k.some((j,U)=>j!==N[U]||m[O]&&m[O].hasOwnProperty(j.key))){R=-1;break}++R}for(const O in o.proxyCachedFBO[w.key])o.renderCache[o.proxyCachedFBO[w.key][O]].dirty=R<0||R!==Object.values(E).length}}const y=[...this._drapedRenderBatches];y.sort((v,w)=>w.end-w.start-(v.end-v.start));for(const v of y)for(const w of d){if(o.proxyCachedFBO[w.key])continue;let E=o.renderCachePool.pop();E===void 0&&o.renderCache.length<50&&(E=o.renderCache.length,o.renderCache.push(this._createFBO())),E!==void 0&&(o.proxyCachedFBO[w.key]={},o.proxyCachedFBO[w.key][v.start]=E,o.renderCache[E].dirty=!0)}this._tilesDirty={}}_setupStencil(i,o,d,m){if(!m||!this._sourceTilesOverlap[m.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const y=this.painter.context,v=y.gl;if(o.length<=1)return void(this._overlapStencilType=!1);let w;if(d.isTileClipped())w=o.length,this._overlapStencilMode.test={func:v.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(o[0].overscaledZ>o[o.length-1].overscaledZ))return void(this._overlapStencilType=!1);w=1,this._overlapStencilMode.test={func:v.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+w>255&&(y.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=w,this._overlapStencilMode.ref=this._stencilRef,d.isTileClipped()&&this._renderTileClippingMasks(o,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(i){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[i.key]),this._overlapStencilMode):Ht.disabled}_renderTileClippingMasks(i,o){const d=this.painter,m=this.painter.context,y=m.gl;d._tileClippingMaskIDs={},m.setColorMode(jt.disabled),m.setDepthMode(At.disabled);const v=d.getOrCreateProgram("clippingMask");for(const w of i){const E=d._tileClippingMaskIDs[w.key]=--o;v.draw(d,y.TRIANGLES,At.disabled,new Ht({func:y.ALWAYS,mask:0},E,255,y.KEEP,y.KEEP,y.REPLACE),jt.disabled,Nt.disabled,Ju(w.projMatrix),"$clipping",d.tileExtentBuffer,d.quadTriangleIndexBuffer,d.tileExtentSegments)}}pointCoordinate(i){const o=this.painter.transform;if(i.x<0||i.x>o.width||i.y<0||i.y>o.height)return null;const d=[i.x,i.y,1,1];a.aE(d,d,o.pixelMatrixInverse),a.cu(d,d,1/d[3]),d[0]/=o.worldSize,d[1]/=o.worldSize;const m=o._camera.position,y=a.bU(1,o.center.lat),v=[m[0],m[1],m[2]/y,0],w=a.cV([],d.slice(0,3),v);a.ay(w,w);const E=this.raycast(v,w,this._exaggeration);return E!==null&&E?(a.bg(v,v,w,E),v[3]=v[2],v[2]*=y,v):null}_setupProxiedCoordsForOrtho(i,o,d){if(i.getSource()instanceof a.aV)return this._setupProxiedCoordsForImageSource(i,o,d);this._findCoveringTileCache[i.id]=this._findCoveringTileCache[i.id]||{};const m=this.proxiedCoords[i.id]=[],y=this.proxyCoords;for(let E=0;E<y.length;E++){const P=y[E],R=this._findTileCoveringTileID(P,i);if(R){const O=this._createProxiedId(P,R,d[P.key]&&d[P.key][i.id]);m.push(O),this.proxyToSource[P.key][i.id]=[O]}}let v=!1;const w=new Set;for(let E=0;E<o.length;E++){const P=i.getTile(o[E]);if(!P||!P.hasData())continue;const R=this._findTileCoveringTileID(P.tileID,this.proxySourceCache);if(R&&R.tileID.canonical.z!==P.tileID.canonical.z){const O=this.proxyToSource[R.tileID.key][i.id],k=this._createProxiedId(R.tileID,P,d[R.tileID.key]&&d[R.tileID.key][i.id]);O?O.splice(O.length-1,0,k):this.proxyToSource[R.tileID.key][i.id]=[k];const N=this.proxyToSource[R.tileID.key][i.id];w.has(N)||w.add(N),m.push(k),v=!0}}if(this._sourceTilesOverlap[i.id]=v,v&&this._debugParams.sortTilesHiZFirst)for(const E of w)E.sort((P,R)=>R.overscaledZ-P.overscaledZ)}_setupProxiedCoordsForImageSource(i,o,d){if(!i.getSource().loaded())return;const m=this.proxiedCoords[i.id]=[],y=this.proxyCoords,v=i.getSource(),w=v.tileID;if(!w)return;const E=new a.P(w.x,w.y)._div(1<<w.z),P=v.coordinates.map(a.ag.fromLngLat).reduce((O,k)=>(O.min.x=Math.min(O.min.x,k.x-E.x),O.min.y=Math.min(O.min.y,k.y-E.y),O.max.x=Math.max(O.max.x,k.x-E.x),O.max.y=Math.max(O.max.y,k.y-E.y),O),{min:new a.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),R=(O,k)=>{const N=O.wrap+O.canonical.x/(1<<O.canonical.z),j=O.canonical.y/(1<<O.canonical.z),U=a.an/(1<<O.canonical.z),X=k.wrap+k.canonical.x/(1<<k.canonical.z),W=k.canonical.y/(1<<k.canonical.z);return N+U<X+P.min.x||N>X+P.max.x||j+U<W+P.min.y||j>W+P.max.y};for(let O=0;O<y.length;O++){const k=y[O];for(let N=0;N<o.length;N++){const j=i.getTile(o[N]);if(!j||!j.hasData()||R(k,j.tileID))continue;const U=this._createProxiedId(k,j,d[k.key]&&d[k.key][i.id]),X=this.proxyToSource[k.key][i.id];X?X.push(U):this.proxyToSource[k.key][i.id]=[U],m.push(U)}}}_createProxiedId(i,o,d){let m=this.orthoMatrix;if(d){const y=d.find(v=>v.key===o.tileID.key);if(y)return y}if(o.tileID.key!==i.key){const y=i.canonical.z-o.tileID.canonical.z;let v,w,E;m=a.bb();const P=o.tileID.wrap-i.wrap<<i.overscaledZ;y>0?(v=a.an>>y,w=v*((o.tileID.canonical.x<<y)-i.canonical.x+P),E=v*((o.tileID.canonical.y<<y)-i.canonical.y)):(v=a.an<<-y,w=a.an*(o.tileID.canonical.x-(i.canonical.x+P<<-y)),E=a.an*(o.tileID.canonical.y-(i.canonical.y<<-y))),a.bT(m,0,v,0,v,0,1),a.bx(m,m,[w,E,0])}return new Pd(o.tileID,i.key,m)}_findTileCoveringTileID(i,o){let d=o.getTile(i);if(d&&d.hasData())return d;const m=this._findCoveringTileCache[o.id],y=m[i.key];if(d=y?o.getTileByID(y):null,d&&d.hasData()||y===null)return d;let v=d?d.tileID:i,w=v.overscaledZ;const E=o.getSource().minzoom,P=[];if(!y){const O=o.getSource().maxzoom;if(i.canonical.z>=O){const k=i.canonical.z-O;o.getSource().reparseOverscaled?(w=Math.max(i.canonical.z+2,o.transform.tileZoom),v=new a.aR(w,i.wrap,O,i.canonical.x>>k,i.canonical.y>>k)):k!==0&&(w=O,v=new a.aR(w,i.wrap,O,i.canonical.x>>k,i.canonical.y>>k))}v.key!==i.key&&(P.push(v.key),d=o.getTile(v))}const R=O=>{P.forEach(k=>{m[k]=O}),P.length=0};for(w-=1;w>=E&&(!d||!d.hasData());w--){d&&R(d.tileID.key);const O=v.calculateScaledKey(w);if(d=o.getTileByID(O),d&&d.hasData())break;const k=m[O];if(k===null)break;k===void 0?P.push(O):d=o.getTileByID(k)}return R(d?d.tileID.key:null),d&&d.hasData()?d:null}findDEMTileFor(i){return this.enabled?this._findTileCoveringTileID(i,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(i,o){let d=this._tilesDirty[i];d||(d=this._tilesDirty[i]={}),d[o.key]=!0}}function om(u,i,o){const d=function(w,E,P){const R=a.bi(E,w),O=a.bi(P,[.2126,.7152,.0722]),k=(j,U,X)=>(1-X)*j+X*U,N=k(1-.3*Math.min(O,1),1,Math.min(R+1,1));return k(.92,1,Math.asin(a.aC(E[2],-1,1))/Math.PI+.5)*N}(u,[0,0,1],i),m=[0,0,0];a.bJ(m,o.slice(0,3),d);const y=[0,0,0];a.bJ(y,i.slice(0,3),u[2]);const v=[0,0,0];return a.cT(v,m,y),a.cW(v)}const Sy=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Ey=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class Cl{static cacheKey(i,o,d,m){const y=[o];m&&y.push(m.cacheKey);for(const v of d)(typeof v=="string"&&v.includes(" ")||i.usedDefines.has(v))&&y.push(v);return y.join("/")}constructor(i,o,d,m,y,v){const w=i.gl;this.program=w.createProgram(),this.configuration=m,this.name=o,this.fixedDefines=[...v];const E=`#version 300 es
${(m?m.defines():[]).concat(v.map(U=>`#define ${U}`)).join(`
`)}`,P=[E,Ac];for(const U of d.fragmentIncludes)P.push(_o[U]);P.push(d.fragmentSource);const R=P.join(`
`),O=[E,g1];for(const U of d.vertexIncludes)O.push(_o[U]);this.forceManualRenderingForInstanceIDShaders=i.forceManualRenderingForInstanceIDShaders&&d.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&O.push("uniform int u_instanceID;"),O.push(d.vertexSource);let k=O.join(`
`);this.forceManualRenderingForInstanceIDShaders&&(k=k.replaceAll("gl_InstanceID","u_instanceID"));const N=w.createShader(w.FRAGMENT_SHADER);if(w.isContextLost())return void(this.failedToCreate=!0);w.shaderSource(N,R),w.compileShader(N),w.attachShader(this.program,N);const j=w.createShader(w.VERTEX_SHADER);w.isContextLost()?this.failedToCreate=!0:(w.shaderSource(j,k),w.compileShader(j),w.attachShader(this.program,j),this.attributes={},w.linkProgram(this.program),w.deleteShader(j),w.deleteShader(N),this.fixedUniforms=y(i),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=m?m.getUniforms(i):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(U=>({u_instanceID:new a.bX(U)}))(i)),(v.includes("TERRAIN")||v.includes("ELEVATED")||o.includes("symbol")||o.includes("circle"))&&(this.terrainUniforms=(U=>({u_dem:new a.bX(U),u_dem_prev:new a.bX(U),u_dem_tl:new a.b_(U),u_dem_scale:new a.bZ(U),u_dem_tl_prev:new a.b_(U),u_dem_scale_prev:new a.bZ(U),u_dem_size:new a.bZ(U),u_dem_lerp:new a.bZ(U),u_exaggeration:new a.bZ(U),u_depth:new a.bX(U),u_depth_size_inv:new a.b_(U),u_depth_range_unpack:new a.b_(U),u_occluder_half_size:new a.bZ(U),u_occlusion_depth_offset:new a.bZ(U),u_meter_to_dem:new a.bZ(U),u_label_plane_matrix_inv:new a.b$(U)}))(i)),v.includes("GLOBE")&&(this.globeUniforms=(U=>({u_tile_tl_up:new a.bY(U),u_tile_tr_up:new a.bY(U),u_tile_br_up:new a.bY(U),u_tile_bl_up:new a.bY(U),u_tile_up_scale:new a.bZ(U)}))(i)),v.includes("FOG")&&(this.fogUniforms=(U=>({u_fog_matrix:new a.b$(U),u_fog_range:new a.b_(U),u_fog_color:new a.cO(U),u_fog_horizon_blend:new a.bZ(U),u_fog_vertical_limit:new a.b_(U),u_fog_temporal_offset:new a.bZ(U),u_frustum_tl:new a.bY(U),u_frustum_tr:new a.bY(U),u_frustum_br:new a.bY(U),u_frustum_bl:new a.bY(U),u_globe_pos:new a.bY(U),u_globe_radius:new a.bZ(U),u_globe_transition:new a.bZ(U),u_is_globe:new a.bX(U),u_viewport:new a.b_(U)}))(i)),v.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(U=>({u_cutoff_params:new a.cO(U)}))(i)),v.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(U=>({u_lighting_ambient_color:new a.bY(U),u_lighting_directional_dir:new a.bY(U),u_lighting_directional_color:new a.bY(U),u_ground_radiance:new a.bY(U)}))(i)),v.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(U=>({u_light_matrix_0:new a.b$(U),u_light_matrix_1:new a.b$(U),u_fade_range:new a.b_(U),u_shadow_normal_offset:new a.bY(U),u_shadow_intensity:new a.bZ(U),u_shadow_texel_size:new a.bZ(U),u_shadow_map_resolution:new a.bZ(U),u_shadow_direction:new a.bY(U),u_shadow_bias:new a.bY(U),u_shadowmap_0:new a.bX(U),u_shadowmap_1:new a.bX(U)}))(i)))}getAttributeLocation(i,o){let d=this.attributes[o];return d===void 0&&(d=this.attributes[o]=i.getAttribLocation(this.program,o)),d}setTerrainUniformValues(i,o){if(!this.terrainUniforms)return;const d=this.terrainUniforms;if(!this.failedToCreate){i.program.set(this.program);for(const m in o)d[m]&&d[m].set(this.program,m,o[m])}}setGlobeUniformValues(i,o){if(!this.globeUniforms)return;const d=this.globeUniforms;if(!this.failedToCreate){i.program.set(this.program);for(const m in o)d[m]&&d[m].set(this.program,m,o[m])}}setFogUniformValues(i,o){if(!this.fogUniforms)return;const d=this.fogUniforms;if(!this.failedToCreate){i.program.set(this.program);for(const m in o)d[m].set(this.program,m,o[m])}}setCutoffUniformValues(i,o){if(!this.cutoffUniforms)return;const d=this.cutoffUniforms;if(!this.failedToCreate){i.program.set(this.program);for(const m in o)d[m].set(this.program,m,o[m])}}setLightsUniformValues(i,o){if(!this.lightsUniforms)return;const d=this.lightsUniforms;if(!this.failedToCreate){i.program.set(this.program);for(const m in o)d[m].set(this.program,m,o[m])}}setShadowUniformValues(i,o){if(this.failedToCreate||!this.shadowUniforms)return;const d=this.shadowUniforms;i.program.set(this.program);for(const m in o)d[m].set(this.program,m,o[m])}_drawDebugWireframe(i,o,d,m,y,v,w,E,P,R){const O=i.options.wireframe;if(O.terrain===!1&&O.layers2D===!1&&O.layers3D===!1)return;const k=i.context;if(!(!(!O.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!O.layers2D||i._terrain&&i._terrain.renderingToTexture||!Sy.includes(this.name))||!(!O.layers3D||!Ey.includes(this.name))))return;const N=k.gl,j=i.wireframeDebugCache.getLinesFromTrianglesBuffer(i.frameCounter,y,k);if(!j)return;const U=[...this.fixedDefines,"DEBUG_WIREFRAME"],X=i.getOrCreateProgram(this.name,{config:this.configuration,defines:U});k.program.set(X.program);const W=(K,xe,le)=>{if(xe[K]&&le[K])for(const _e in xe[K])le[K][_e]&&le[K][_e].set(le.program,_e,xe[K][_e].current)};P&&P.setUniforms(X.program,k,X.binderUniforms,w,{zoom:E}),W("fixedUniforms",this,X),W("terrainUniforms",this,X),W("globeUniforms",this,X),W("fogUniforms",this,X),W("lightsUniforms",this,X),W("shadowUniforms",this,X),j.bind(),k.setColorMode(new jt([N.ONE,N.ONE_MINUS_SRC_ALPHA,N.ZERO,N.ONE],a.aq.transparent,[!0,!0,!0,!1])),k.setDepthMode(new At(o.func===N.LESS?N.LEQUAL:o.func,At.ReadOnly,o.range)),k.setStencilMode(Ht.disabled);const ie=3*v.primitiveLength*2,ne=3*v.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const K=R||1;for(let xe=0;xe<K;++xe)X.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",xe),N.drawElements(N.LINES,ie,N.UNSIGNED_SHORT,ne)}else R&&R>1?N.drawElementsInstanced(N.LINES,ie,N.UNSIGNED_SHORT,ne,R):N.drawElements(N.LINES,ie,N.UNSIGNED_SHORT,ne);y.bind(),k.program.set(this.program),k.setDepthMode(o),k.setStencilMode(d),k.setColorMode(m)}checkUniforms(i,o,d){if(this.fixedDefines.includes(o)){for(const m of Object.keys(d))if(!d[m].initialized)throw new Error(`Program '${this.name}', from draw '${i}': uniform ${m} not set but required by ${o} being defined`)}}draw(i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X){const W=i.context,ie=W.gl;if(this.failedToCreate)return;W.program.set(this.program),W.setDepthMode(d),W.setStencilMode(m),W.setColorMode(y),W.setCullFace(v);for(const[re,ae]of this.fixedUniformsEntries)ae.set(this.program,re,w[re]);j&&j.setUniforms(this.program,W,this.binderUniforms,k,{zoom:N});const ne={[ie.POINTS]:1,[ie.LINES]:2,[ie.TRIANGLES]:3,[ie.LINE_STRIP]:1}[o];this.checkUniforms(E,"RENDER_SHADOWS",this.shadowUniforms);const K=U||[],xe=j?j.getPaintVertexBuffers():[],le=o===ie.TRIANGLES&&R,_e=X&&X>0?1:void 0;for(const re of O.get()){const ae=re.vaos||(re.vaos={});if((ae[E]||(ae[E]=new fy)).bind(W,this,P,xe,R,re.vertexOffset,K,_e),this.forceManualRenderingForInstanceIDShaders){const fe=X||1;for(let Ce=0;Ce<fe;++Ce)this.instancingUniforms.u_instanceID.set(this.program,"u_instanceID",Ce),R?ie.drawElements(o,re.primitiveLength*ne,ie.UNSIGNED_SHORT,re.primitiveOffset*ne*2):ie.drawArrays(o,re.vertexOffset,re.vertexLength)}else X&&X>1?ie.drawElementsInstanced(o,re.primitiveLength*ne,ie.UNSIGNED_SHORT,re.primitiveOffset*ne*2,X):R?ie.drawElements(o,re.primitiveLength*ne,ie.UNSIGNED_SHORT,re.primitiveOffset*ne*2):ie.drawArrays(o,re.vertexOffset,re.vertexLength);le&&this._drawDebugWireframe(i,d,m,y,R,re,k,N,j,X)}}}function Iy(u,i,o=0){const d=Math.pow(2,i.tileID.overscaledZ),m=i.tileSize*Math.pow(2,u.transform.tileZoom)/d,y=m*(i.tileID.canonical.x+i.tileID.wrap*d),v=m*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/a.aA(i,1,u.transform.tileZoom),u_pixel_coord_upper:[y>>16,v>>16],u_pixel_coord_lower:[65535&y,65535&v],u_pattern_transition:o}}const Md={terrain:0,flat:1},I1=a.bb(),Ay=(u,i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X,W,ie=[0,0,1])=>{const ne=i.style.light,K=ne.properties.get("position"),xe=[K.x,K.y,K.z],le=a.dE();ne.properties.get("anchor")==="viewport"&&(a.dF(le,-i.transform.angle),a.dG(xe,xe,le));const _e=ne.properties.get("color").toPremultipliedRenderColor(null),re=i.transform,ae={u_matrix:u,u_lightpos:xe,u_lightintensity:ne.properties.get("intensity"),u_lightcolor:[_e.r,_e.g,_e.b],u_vertical_gradient:+o,u_opacity:d,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:I1,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:Md[P],u_base_type:Md[R],u_ao:m,u_edge_radius:y,u_width_scale:v,u_flood_light_color:j,u_vertical_scale:U,u_flood_light_intensity:X,u_ground_shadow_factor:W,u_front_cutoff_params:ie};return re.projection.name==="globe"&&(ae.u_tile_id=[w.canonical.x,w.canonical.y,1<<w.canonical.z],ae.u_zoom_transition=O,ae.u_inv_rot_matrix=N,ae.u_merc_center=k,ae.u_up_dir=re.projection.upVector(new a.cn(0,0,0),k[0]*a.an,k[1]*a.an),ae.u_height_lift=E),ae},A1=(u,i,o,d,m,y)=>({u_matrix:u,u_edge_radius:i,u_width_scale:o,u_vertical_scale:d,u_height_type:Md[m],u_base_type:Md[y]}),C1=(u,i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X,W)=>{const ie=Ay(u,i,o,d,m,y,v,w,P,R,O,k,N,j,U,X,1,[0,0,0]),ne={u_height_factor:-Math.pow(2,w.overscaledZ)/E.tileSize/8};return Object.assign(ie,Iy(i,E,W),ne)},Rd=(u,i,o)=>({u_matrix:u,u_emissive_strength:i,u_ground_shadow_factor:o}),Dd=(u,i,o,d,m,y=0)=>Object.assign(Rd(u,i,m),Iy(o,d,y)),Cy=(u,i,o,d)=>({u_matrix:u,u_world:o,u_emissive_strength:i,u_ground_shadow_factor:d}),Lc=(u,i,o,d,m,y,v=0)=>Object.assign(Dd(u,i,o,d,y,v),{u_world:m}),Py=(u,i)=>({u_matrix:u,u_depth_bias:i}),My=(u,i)=>({u_matrix:u,u_ground_shadow_factor:i}),th=(u,i,o,d,m)=>({u_matrix:u,u_camera_pos:[i[0],i[1],i[2]],u_depth_bias:o,u_height_scale:d,u_reset_depth:m}),Ld=(u,i,o)=>({u_image:u,u_opacity:i,u_blend_mode:o}),$a=(u,i,o,d,m,y,v,w,E,P=[0,0,1])=>({u_matrix:u,u_normal_matrix:i,u_opacity:o,u_faux_facade_ao_intensity:d,u_camera_pos:m,u_tile_to_meter:y,u_facade_emissive_chance:v,u_flood_light_color:w,u_flood_light_intensity:E,u_front_cutoff_params:P}),zd=u=>({u_matrix:u}),kd=u=>({u_matrix:u}),Ry=(u,i,o,d,m,y,v,w)=>{const E=a.an/y.tileSize;return{u_matrix:u,u_inv_rot_matrix:i,u_camera_to_center_distance:o.getCameraToCenterDistance(w),u_extrude_scale:[o.pixelsToGLUnits[0]/E,o.pixelsToGLUnits[1]/E],u_zoom_transition:d,u_tile_id:v,u_merc_center:m}},Ha=(u,i,o,d)=>({u_matrix:u,u_inv_matrix:i,u_camera_to_center_distance:o.getCameraToCenterDistance(d),u_viewport_size:[o.width,o.height]}),ih=(u,i,o=1)=>({u_matrix:u,u_color:i,u_overlay:0,u_overlay_scale:o}),Fd=a.bb(),Dy=(u,i,o,d,m,y,v)=>{const w=u.transform,E=w.projection.name==="globe",P=E?a.dH(w.zoom,i.canonical)*w._pixelsPerMercatorPixel:a.aA(o,1,y),R={u_matrix:i.projMatrix,u_extrude_scale:P,u_intensity:v,u_inv_rot_matrix:Fd,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(E){R.u_inv_rot_matrix=d,R.u_merc_center=m,R.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],R.u_zoom_transition=a.al(w.zoom);const O=m[0]*a.an,k=m[1]*a.an;R.u_up_dir=w.projection.upVector(new a.cn(0,0,0),O,k)}return R};function am(u,[i,o,d,m],[y,v]){if(y===v)return[0,0,0,0];const w=255*(u-1)/(u*(v-y));return[i*w,o*w,d*w,m*w]}function Od(u,i,[o,d]){return o===d?0:.5/u+(i-o)*(u-1)/(u*(d-o))}function lm(u){const i=u.terrain?u.terrain.exaggeration():1;var o;return(u.transform.pitch<15?.07*(1-(o=a.aC((14-u.transform.zoom)/5,0,1)))+.7*o:.07)*i}const Ly=(u,i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X,W,ie,ne,K,xe)=>({u_matrix:i,u_normalize_matrix:o,u_globe_matrix:d,u_merc_matrix:m,u_grid_matrix:y,u_tl_parent:v,u_scale_parent:R,u_fade_t:O.mix,u_opacity:O.opacity*k.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:k.paint.get("raster-brightness-min"),u_brightness_high:k.paint.get("raster-brightness-max"),u_saturation_factor:a.dJ(k.paint.get("raster-saturation")),u_contrast_factor:a.dI(k.paint.get("raster-contrast")),u_spin_weights:zy(k.paint.get("raster-hue-rotate")),u_perspective_transform:N,u_raster_elevation:j,u_zoom_transition:w,u_merc_center:E,u_cutoff_params:P,u_colorization_mix:am(a.dK,X,ie),u_colorization_offset:Od(a.dK,W,ie),u_color_ramp:U,u_texture_offset:[K/(ne+2*K),ne/(ne+2*K)],u_texture_res:[ne+2*K,ne+2*K],u_emissive_strength:xe,u_zbias_factor:lm(u)});function zy(u){u*=Math.PI/180;const i=Math.sin(u),o=Math.cos(u);return[(2*o+1)/3,(-Math.sqrt(3)*i-o+1)/3,(Math.sqrt(3)*i-o+1)/3]}const Vo=.05,P1=(u,i,o,d,m,y,v,w,E,P,R,O)=>({u_matrix:u,u_normalize_matrix:i,u_globe_matrix:o,u_merc_matrix:d,u_grid_matrix:m,u_tl_parent:y,u_scale_parent:P,u_fade_t:R.mix,u_opacity:R.opacity,u_image0:0,u_image1:1,u_raster_elevation:O,u_zoom_transition:v,u_merc_center:w,u_cutoff_params:E}),M1=(u,i,o,d,m,y,v,w,E,P)=>({u_particle_texture:u,u_particle_texture_side_len:i,u_tile_offset:o,u_velocity:d,u_color_ramp:y,u_velocity_res:m,u_max_speed:v,u_uv_offset:w,u_data_scale:[255*E[0],255*E[1]],u_data_offset:P,u_particle_pos_scale:1.1,u_particle_pos_offset:[Vo,Vo]}),ky=(u,i,o,d,m,y,v,w,E,P)=>({u_particle_texture:u,u_particle_texture_side_len:i,u_velocity:o,u_velocity_res:d,u_max_speed:m,u_speed_factor:y,u_reset_rate:v,u_rand_seed:Math.random(),u_uv_offset:w,u_data_scale:[255*E[0],255*E[1]],u_data_offset:P,u_particle_pos_scale:1.1,u_particle_pos_offset:[Vo,Vo]}),Fy=a.bb(),Bd=(u,i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X,W,ie,ne,K,xe,le,_e)=>{const re=m.transform,ae={u_is_size_zoom_constant:+(u==="constant"||u==="source"),u_is_size_feature_constant:+(u==="constant"||u==="camera"),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:re.getCameraToCenterDistance(ie),u_rotate_symbol:+o,u_aspect_ratio:re.width/re.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:y,u_label_plane_matrix:v,u_coord_matrix:w,u_is_text:+P,u_elevation_from_sea:E?1:0,u_pitch_with_map:+d,u_texsize:R,u_texsize_icon:O,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Fy,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Fy,u_up_vector:[0,-1,0],u_color_adj_mat:xe,u_icon_transition:le||0,u_gamma_scale:d?m.transform.getCameraToCenterDistance(ie)*Math.cos(m.terrain?0:m.transform._pitch):1,u_device_pixel_ratio:a.o.devicePixelRatio,u_is_halo:1,u_scale_factor:_e||1,u_ground_shadow_factor:ne,u_inv_matrix:a.b7(a.bb(),v),u_normal_scale:K,u_lutTexture:10,u_zoom:re.zoom-Math.floor(re.zoom),u_spp_fill_np_color:[0,0,0,1],u_spp_halo_np_color:[0,0,0,0],u_spp_opacity:1,u_spp_halo_width:0,u_spp_halo_blur:0,u_spp_emissive_strength:0,u_spp_occlusion_opacity:1,u_spp_z_offset:0,u_spp_translate_rotation:[1,0]};return ie.name==="globe"&&(ae.u_tile_id=[N.canonical.x,N.canonical.y,1<<N.canonical.z],ae.u_zoom_transition=j,ae.u_inv_rot_matrix=X,ae.u_merc_center=U,ae.u_camera_forward=re._camera.forward(),ae.u_ecef_origin=a.dL(re.globeMatrix,N.toUnwrapped()),ae.u_tile_matrix=Float32Array.from(re.globeMatrix),ae.u_up_vector=W),ae},nh=(u,i,o,d)=>({u_matrix:u,u_emissive_strength:i,u_opacity:o,u_color:d}),Za=(u,i,o,d,m,y,v,w,E)=>Object.assign(function(P,R,O,k,N,j){const{width:U,height:X}=k.imageManager.getPixelSize(R),W=Math.pow(2,j.tileID.overscaledZ),ie=j.tileSize*Math.pow(2,k.transform.tileZoom)/W,ne=ie*(j.tileID.canonical.x+j.tileID.wrap*W),K=ie*j.tileID.canonical.y;return{u_image:0,u_pattern_tl:O.tl,u_pattern_br:O.br,u_texsize:[U,X],u_pattern_size:O.displaySize,u_pattern_units_to_pixels:N?[k.transform.width,-1*k.transform.height]:[1/a.aA(j,1,k.transform.tileZoom),1/a.aA(j,1,k.transform.tileZoom)],u_pixel_coord_upper:[ne>>16,K>>16],u_pixel_coord_lower:[65535&ne,65535&K]}}(0,y,v,d,w,E),{u_matrix:u,u_emissive_strength:i,u_opacity:o}),zc=new Float32Array(a.b9([])),Pl=(u,i,o,d,m,y,v,w,E,P,R,O,k,N=[0,0,0],j,U,X)=>{const W=m.style.light,ie=W.properties.get("position"),ne=[-ie.x,-ie.y,ie.z],K=a.dE();W.properties.get("anchor")==="viewport"&&(a.dF(K,-m.transform.angle),a.dG(ne,ne,K));const xe=R.alphaMode==="MASK",le=W.properties.get("color").toNonPremultipliedRenderColor(null),_e=k.paint.get("model-ambient-occlusion-intensity"),re=k.paint.get("model-color").constantOr(a.aq.white).toNonPremultipliedRenderColor(null);return re.a=k.paint.get("model-color-mix-intensity").constantOr(0),X&&(re.r=X[0],re.g=X[1],re.b=X[2],re.a=X[3]),U&&(re.r=U.color.r,re.g=U.color.g,re.b=U.color.b,re.a=U.colorMix,O=U.emissionStrength,y*=U.opacity),{u_matrix:u,u_lighting_matrix:i,u_normal_matrix:o,u_node_matrix:d||zc,u_lightpos:ne,u_lightintensity:W.properties.get("intensity"),u_lightcolor:[le.r,le.g,le.b],u_camera_pos:N,u_opacity:y,u_baseTextureIsAlpha:0,u_alphaMask:+xe,u_alphaCutoff:R.alphaCutoff,u_baseColorFactor:v.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:w.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:E,u_roughnessFactor:P,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:re.toArray01(),u_aoIntensity:_e,u_emissive_strength:O,u_occlusionTextureTransform:j||[0,0,0,0]}},cm=(u,i=zc,o=zc)=>({u_matrix:u,u_instance:i,u_node_matrix:o}),Nd={fillExtrusion:u=>({u_matrix:new a.b$(u),u_lightpos:new a.bY(u),u_lightintensity:new a.bZ(u),u_lightcolor:new a.bY(u),u_vertical_gradient:new a.bZ(u),u_opacity:new a.bZ(u),u_edge_radius:new a.bZ(u),u_width_scale:new a.bZ(u),u_ao:new a.b_(u),u_height_type:new a.bX(u),u_base_type:new a.bX(u),u_tile_id:new a.bY(u),u_zoom_transition:new a.bZ(u),u_inv_rot_matrix:new a.b$(u),u_merc_center:new a.b_(u),u_up_dir:new a.bY(u),u_height_lift:new a.bZ(u),u_flood_light_color:new a.bY(u),u_vertical_scale:new a.bZ(u),u_flood_light_intensity:new a.bZ(u),u_ground_shadow_factor:new a.bY(u),u_front_cutoff_params:new a.bY(u)}),fillExtrusionDepth:u=>({u_matrix:new a.b$(u),u_edge_radius:new a.bZ(u),u_width_scale:new a.bZ(u),u_vertical_scale:new a.bZ(u),u_height_type:new a.bX(u),u_base_type:new a.bX(u)}),fillExtrusionPattern:u=>({u_matrix:new a.b$(u),u_lightpos:new a.bY(u),u_lightintensity:new a.bZ(u),u_lightcolor:new a.bY(u),u_vertical_gradient:new a.bZ(u),u_height_factor:new a.bZ(u),u_edge_radius:new a.bZ(u),u_width_scale:new a.bZ(u),u_ao:new a.b_(u),u_height_type:new a.bX(u),u_base_type:new a.bX(u),u_tile_id:new a.bY(u),u_zoom_transition:new a.bZ(u),u_inv_rot_matrix:new a.b$(u),u_merc_center:new a.b_(u),u_up_dir:new a.bY(u),u_height_lift:new a.bZ(u),u_image:new a.bX(u),u_texsize:new a.b_(u),u_pixel_coord_upper:new a.b_(u),u_pixel_coord_lower:new a.b_(u),u_tile_units_to_pixels:new a.bZ(u),u_opacity:new a.bZ(u),u_pattern_transition:new a.bZ(u)}),fillExtrusionGroundEffect:u=>({u_matrix:new a.b$(u),u_opacity:new a.bZ(u),u_ao_pass:new a.bZ(u),u_meter_to_tile:new a.bZ(u),u_ao:new a.b_(u),u_flood_light_intensity:new a.bZ(u),u_flood_light_color:new a.bY(u),u_attenuation:new a.bZ(u),u_edge_radius:new a.bZ(u),u_fb:new a.bX(u),u_fb_size:new a.bZ(u),u_dynamic_offset:new a.bZ(u)}),fill:u=>({u_matrix:new a.b$(u),u_emissive_strength:new a.bZ(u),u_ground_shadow_factor:new a.bY(u)}),fillPattern:u=>({u_matrix:new a.b$(u),u_emissive_strength:new a.bZ(u),u_image:new a.bX(u),u_texsize:new a.b_(u),u_pixel_coord_upper:new a.b_(u),u_pixel_coord_lower:new a.b_(u),u_tile_units_to_pixels:new a.bZ(u),u_ground_shadow_factor:new a.bY(u),u_pattern_transition:new a.bZ(u)}),fillOutline:u=>({u_matrix:new a.b$(u),u_emissive_strength:new a.bZ(u),u_world:new a.b_(u),u_ground_shadow_factor:new a.bY(u)}),fillOutlinePattern:u=>({u_matrix:new a.b$(u),u_emissive_strength:new a.bZ(u),u_world:new a.b_(u),u_image:new a.bX(u),u_texsize:new a.b_(u),u_pixel_coord_upper:new a.b_(u),u_pixel_coord_lower:new a.b_(u),u_tile_units_to_pixels:new a.bZ(u),u_ground_shadow_factor:new a.bY(u),u_pattern_transition:new a.bZ(u)}),lineBlendComposite:u=>({u_image:new a.bX(u),u_opacity:new a.bZ(u),u_blend_mode:new a.bX(u)}),building:u=>({u_matrix:new a.b$(u),u_normal_matrix:new a.b$(u),u_opacity:new a.bZ(u),u_faux_facade_ao_intensity:new a.bZ(u),u_camera_pos:new a.bY(u),u_tile_to_meter:new a.bZ(u),u_facade_emissive_chance:new a.bZ(u),u_flood_light_color:new a.bY(u),u_flood_light_intensity:new a.bZ(u),u_front_cutoff_params:new a.bY(u)}),buildingBloom:u=>({u_matrix:new a.b$(u)}),buildingDepth:u=>({u_matrix:new a.b$(u)}),elevatedStructuresDepth:u=>({u_matrix:new a.b$(u),u_depth_bias:new a.bZ(u)}),elevatedStructures:u=>({u_matrix:new a.b$(u),u_ground_shadow_factor:new a.bY(u)}),elevatedStructuresDepthReconstruct:u=>({u_matrix:new a.b$(u),u_camera_pos:new a.bY(u),u_depth_bias:new a.bZ(u),u_height_scale:new a.bZ(u),u_reset_depth:new a.bZ(u)}),circle:a.dO,collisionBox:u=>({u_matrix:new a.b$(u),u_inv_rot_matrix:new a.b$(u),u_camera_to_center_distance:new a.bZ(u),u_extrude_scale:new a.b_(u),u_zoom_transition:new a.bZ(u),u_merc_center:new a.b_(u),u_tile_id:new a.bY(u)}),collisionCircle:u=>({u_matrix:new a.b$(u),u_inv_matrix:new a.b$(u),u_camera_to_center_distance:new a.bZ(u),u_viewport_size:new a.b_(u)}),debug:u=>({u_color:new a.dl(u),u_matrix:new a.b$(u),u_overlay:new a.bX(u),u_overlay_scale:new a.bZ(u)}),clippingMask:u=>({u_matrix:new a.b$(u)}),heatmap:u=>({u_extrude_scale:new a.bZ(u),u_intensity:new a.bZ(u),u_matrix:new a.b$(u),u_inv_rot_matrix:new a.b$(u),u_merc_center:new a.b_(u),u_tile_id:new a.bY(u),u_zoom_transition:new a.bZ(u),u_up_dir:new a.bY(u)}),heatmapTexture:u=>({u_image:new a.bX(u),u_color_ramp:new a.bX(u),u_opacity:new a.bZ(u)}),hillshade:u=>({u_matrix:new a.b$(u),u_image:new a.bX(u),u_latrange:new a.b_(u),u_light:new a.b_(u),u_shadow:new a.dl(u),u_highlight:new a.dl(u),u_emissive_strength:new a.bZ(u),u_accent:new a.dl(u)}),hillshadePrepare:u=>({u_matrix:new a.b$(u),u_image:new a.bX(u),u_dimension:new a.b_(u),u_zoom:new a.bZ(u)}),line:a.dN,linePattern:a.dM,raster:u=>({u_matrix:new a.b$(u),u_normalize_matrix:new a.b$(u),u_globe_matrix:new a.b$(u),u_merc_matrix:new a.b$(u),u_grid_matrix:new a.dm(u),u_tl_parent:new a.b_(u),u_scale_parent:new a.bZ(u),u_fade_t:new a.bZ(u),u_opacity:new a.bZ(u),u_image0:new a.bX(u),u_image1:new a.bX(u),u_brightness_low:new a.bZ(u),u_brightness_high:new a.bZ(u),u_saturation_factor:new a.bZ(u),u_contrast_factor:new a.bZ(u),u_spin_weights:new a.bY(u),u_perspective_transform:new a.b_(u),u_raster_elevation:new a.bZ(u),u_zoom_transition:new a.bZ(u),u_merc_center:new a.b_(u),u_cutoff_params:new a.cO(u),u_colorization_mix:new a.cO(u),u_colorization_offset:new a.bZ(u),u_color_ramp:new a.bX(u),u_texture_offset:new a.b_(u),u_texture_res:new a.b_(u),u_emissive_strength:new a.bZ(u),u_zbias_factor:new a.bZ(u)}),rasterParticle:u=>({u_matrix:new a.b$(u),u_normalize_matrix:new a.b$(u),u_globe_matrix:new a.b$(u),u_merc_matrix:new a.b$(u),u_grid_matrix:new a.dm(u),u_tl_parent:new a.b_(u),u_scale_parent:new a.bZ(u),u_fade_t:new a.bZ(u),u_opacity:new a.bZ(u),u_image0:new a.bX(u),u_image1:new a.bX(u),u_raster_elevation:new a.bZ(u),u_zoom_transition:new a.bZ(u),u_merc_center:new a.b_(u),u_cutoff_params:new a.cO(u)}),rasterParticleTexture:u=>({u_texture:new a.bX(u),u_opacity:new a.bZ(u)}),rasterParticleDraw:u=>({u_particle_texture:new a.bX(u),u_particle_texture_side_len:new a.bZ(u),u_tile_offset:new a.b_(u),u_velocity:new a.bX(u),u_color_ramp:new a.bX(u),u_velocity_res:new a.b_(u),u_max_speed:new a.bZ(u),u_uv_offset:new a.b_(u),u_data_scale:new a.b_(u),u_data_offset:new a.bZ(u),u_particle_pos_scale:new a.bZ(u),u_particle_pos_offset:new a.b_(u)}),rasterParticleUpdate:u=>({u_particle_texture:new a.bX(u),u_particle_texture_side_len:new a.bZ(u),u_velocity:new a.bX(u),u_velocity_res:new a.b_(u),u_max_speed:new a.bZ(u),u_speed_factor:new a.bZ(u),u_reset_rate:new a.bZ(u),u_rand_seed:new a.bZ(u),u_uv_offset:new a.b_(u),u_data_scale:new a.b_(u),u_data_offset:new a.bZ(u),u_particle_pos_scale:new a.bZ(u),u_particle_pos_offset:new a.b_(u)}),symbol:u=>({u_is_size_zoom_constant:new a.bX(u),u_is_size_feature_constant:new a.bX(u),u_size_t:new a.bZ(u),u_size:new a.bZ(u),u_camera_to_center_distance:new a.bZ(u),u_rotate_symbol:new a.bX(u),u_aspect_ratio:new a.bZ(u),u_fade_change:new a.bZ(u),u_matrix:new a.b$(u),u_label_plane_matrix:new a.b$(u),u_coord_matrix:new a.b$(u),u_is_text:new a.bX(u),u_elevation_from_sea:new a.bX(u),u_pitch_with_map:new a.bX(u),u_texsize:new a.b_(u),u_texsize_icon:new a.b_(u),u_texture:new a.bX(u),u_texture_icon:new a.bX(u),u_gamma_scale:new a.bZ(u),u_device_pixel_ratio:new a.bZ(u),u_tile_id:new a.bY(u),u_zoom_transition:new a.bZ(u),u_inv_rot_matrix:new a.b$(u),u_merc_center:new a.b_(u),u_camera_forward:new a.bY(u),u_tile_matrix:new a.b$(u),u_up_vector:new a.bY(u),u_ecef_origin:new a.bY(u),u_is_halo:new a.bX(u),u_icon_transition:new a.bZ(u),u_color_adj_mat:new a.b$(u),u_scale_factor:new a.bZ(u),u_ground_shadow_factor:new a.bY(u),u_inv_matrix:new a.b$(u),u_normal_scale:new a.bZ(u),u_lutTexture:new a.bX(u),u_zoom:new a.bZ(u),u_spp_fill_np_color:new a.cO(u),u_spp_halo_np_color:new a.cO(u),u_spp_opacity:new a.bZ(u),u_spp_halo_width:new a.bZ(u),u_spp_halo_blur:new a.bZ(u),u_spp_emissive_strength:new a.bZ(u),u_spp_occlusion_opacity:new a.bZ(u),u_spp_z_offset:new a.bZ(u),u_spp_translate_rotation:new a.b_(u)}),background:u=>({u_matrix:new a.b$(u),u_emissive_strength:new a.bZ(u),u_opacity:new a.bZ(u),u_color:new a.dl(u)}),backgroundPattern:u=>({u_matrix:new a.b$(u),u_emissive_strength:new a.bZ(u),u_opacity:new a.bZ(u),u_image:new a.bX(u),u_pattern_tl:new a.b_(u),u_pattern_br:new a.b_(u),u_texsize:new a.b_(u),u_pattern_size:new a.b_(u),u_pixel_coord_upper:new a.b_(u),u_pixel_coord_lower:new a.b_(u),u_pattern_units_to_pixels:new a.b_(u)}),terrainRaster:u=>({u_matrix:new a.b$(u),u_image0:new a.bX(u),u_image1:new a.bX(u),u_skirt_height:new a.bZ(u),u_ground_shadow_factor:new a.bY(u),u_emissive_texture_available:new a.bZ(u)}),skybox:u=>({u_matrix:new a.b$(u),u_sun_direction:new a.bY(u),u_cubemap:new a.bX(u),u_opacity:new a.bZ(u),u_temporal_offset:new a.bZ(u)}),skyboxGradient:u=>({u_matrix:new a.b$(u),u_color_ramp:new a.bX(u),u_center_direction:new a.bY(u),u_radius:new a.bZ(u),u_opacity:new a.bZ(u),u_temporal_offset:new a.bZ(u)}),skyboxCapture:u=>({u_matrix_3f:new a.dm(u),u_sun_direction:new a.bY(u),u_sun_intensity:new a.bZ(u),u_color_tint_r:new a.cO(u),u_color_tint_m:new a.cO(u),u_luminance:new a.bZ(u)}),globeRaster:u=>({u_proj_matrix:new a.b$(u),u_globe_matrix:new a.b$(u),u_normalize_matrix:new a.b$(u),u_merc_matrix:new a.b$(u),u_zoom_transition:new a.bZ(u),u_merc_center:new a.b_(u),u_image0:new a.bX(u),u_image1:new a.bX(u),u_grid_matrix:new a.dm(u),u_skirt_height:new a.bZ(u),u_far_z_cutoff:new a.bZ(u),u_frustum_tl:new a.bY(u),u_frustum_tr:new a.bY(u),u_frustum_br:new a.bY(u),u_frustum_bl:new a.bY(u),u_globe_pos:new a.bY(u),u_globe_radius:new a.bZ(u),u_viewport:new a.b_(u),u_emissive_texture_available:new a.bZ(u)}),globeAtmosphere:u=>({u_frustum_tl:new a.bY(u),u_frustum_tr:new a.bY(u),u_frustum_br:new a.bY(u),u_frustum_bl:new a.bY(u),u_horizon:new a.bZ(u),u_transition:new a.bZ(u),u_fadeout_range:new a.bZ(u),u_atmosphere_fog_color:new a.cO(u),u_high_color:new a.cO(u),u_space_color:new a.cO(u),u_temporal_offset:new a.bZ(u),u_horizon_angle:new a.bZ(u)}),model:u=>({u_matrix:new a.b$(u),u_lighting_matrix:new a.b$(u),u_normal_matrix:new a.b$(u),u_node_matrix:new a.b$(u),u_lightpos:new a.bY(u),u_lightintensity:new a.bZ(u),u_lightcolor:new a.bY(u),u_camera_pos:new a.bY(u),u_opacity:new a.bZ(u),u_baseColorFactor:new a.cO(u),u_emissiveFactor:new a.cO(u),u_metallicFactor:new a.bZ(u),u_roughnessFactor:new a.bZ(u),u_baseTextureIsAlpha:new a.bX(u),u_alphaMask:new a.bX(u),u_alphaCutoff:new a.bZ(u),u_baseColorTexture:new a.bX(u),u_metallicRoughnessTexture:new a.bX(u),u_normalTexture:new a.bX(u),u_occlusionTexture:new a.bX(u),u_emissionTexture:new a.bX(u),u_lutTexture:new a.bX(u),u_color_mix:new a.cO(u),u_aoIntensity:new a.bZ(u),u_emissive_strength:new a.bZ(u),u_occlusionTextureTransform:new a.cO(u)}),modelDepth:u=>({u_matrix:new a.b$(u),u_instance:new a.b$(u),u_node_matrix:new a.b$(u)}),groundShadow:u=>({u_matrix:new a.b$(u),u_ground_shadow_factor:new a.bY(u)}),stars:u=>({u_matrix:new a.b$(u),u_up:new a.bY(u),u_right:new a.bY(u),u_intensity_multiplier:new a.bZ(u)}),snowParticle:u=>({u_modelview:new a.b$(u),u_projection:new a.b$(u),u_time:new a.bZ(u),u_cam_pos:new a.bY(u),u_velocityConeAperture:new a.bZ(u),u_velocity:new a.bZ(u),u_horizontalOscillationRadius:new a.bZ(u),u_horizontalOscillationRate:new a.bZ(u),u_boxSize:new a.bZ(u),u_billboardSize:new a.bZ(u),u_simpleShapeParameters:new a.b_(u),u_screenSize:new a.b_(u),u_thinningCenterPos:new a.b_(u),u_thinningShape:new a.bY(u),u_thinningAffectedRatio:new a.bZ(u),u_thinningParticleOffset:new a.bZ(u),u_particleColor:new a.cO(u),u_direction:new a.bY(u)}),rainParticle:u=>({u_modelview:new a.b$(u),u_projection:new a.b$(u),u_time:new a.bZ(u),u_cam_pos:new a.bY(u),u_texScreen:new a.bX(u),u_velocityConeAperture:new a.bZ(u),u_velocity:new a.bZ(u),u_boxSize:new a.bZ(u),u_rainDropletSize:new a.b_(u),u_distortionStrength:new a.bZ(u),u_rainDirection:new a.bY(u),u_color:new a.cO(u),u_screenSize:new a.b_(u),u_thinningCenterPos:new a.b_(u),u_thinningShape:new a.bY(u),u_thinningAffectedRatio:new a.bZ(u),u_thinningParticleOffset:new a.bZ(u),u_shapeDirectionalPower:new a.bZ(u),u_shapeNormalPower:new a.bZ(u),u_mode:new a.bZ(u)}),vignette:u=>({u_vignetteShape:new a.bY(u),u_vignetteColor:new a.cO(u)}),occlusion:u=>({u_matrix:new a.b$(u),u_anchorPos:new a.bY(u),u_screenSizePx:new a.b_(u),u_occluderSizePx:new a.b_(u),u_color:new a.cO(u)})};class go{constructor(i,o,d,m){this.id=go.uniqueIdxCounter,go.uniqueIdxCounter++,this.context=i;const y=i.gl;this.buffer=y.createBuffer(),this.dynamicDraw=!!d,this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),y.bufferData(y.ELEMENT_ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?y.DYNAMIC_DRAW:y.STATIC_DRAW),this.dynamicDraw||m||o.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){this.id=go.uniqueIdxCounter,go.uniqueIdxCounter++;const o=this.context.gl;this.context.unbindVAO(),this.bind(),o.bufferSubData(o.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}go.uniqueIdxCounter=0;const um={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Oy{constructor(i,o,d,m,y,v){this.length=o.length,this.attributes=d,this.itemSize=o.bytesPerElement,this.dynamicDraw=m,this.instanceCount=v,this.context=i;const w=i.gl;this.buffer=w.createBuffer(),i.bindVertexBuffer.set(this.buffer),w.bufferData(w.ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?w.DYNAMIC_DRAW:w.STATIC_DRAW),this.dynamicDraw||y||o.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){const o=this.context.gl;this.bind(),o.bufferSubData(o.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,o){for(const d of this.attributes){const m=o.getAttributeLocation(i,d.name);m!==-1&&i.enableVertexAttribArray(m)}}setVertexAttribPointers(i,o,d){for(const m of this.attributes){const y=o.getAttributeLocation(i,m.name);if(y!==-1){const v=m.offset+this.itemSize*(d||0);m.type==="Float32"?i.vertexAttribPointer(y,m.components,i.FLOAT,!1,this.itemSize,v):i.vertexAttribIPointer(y,m.components,i[um[m.type]],this.itemSize,v)}}}setVertexAttribDivisor(i,o,d){for(let m=0;m<this.attributes.length;m++){const y=o.getAttributeLocation(i,this.attributes[m].name);y!==-1&&this.instanceCount&&this.instanceCount>0&&i.vertexAttribDivisor(y,d)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class rh{constructor(i,o,d,m,y){this.context=i,this.width=o,this.height=d;const v=this.framebuffer=i.gl.createFramebuffer();m>0&&(this.colorAttachment0=new Rc(i,v,0)),m>1&&(this.colorAttachment1=new Rc(i,v,1)),y&&(this.depthAttachmentType=y,this.depthAttachment=y==="renderbuffer"?new nm(i,v):new Ty(i,v))}static createWithTexture(i,o,d,m,y){const v=i.gl;if(i.activeTexture.set(v.TEXTURE1),i.viewport.set([0,0,d,m]),o&&o.width===d&&o.height===m)return v.bindTexture(v.TEXTURE_2D,o.colorAttachment0.get()),i.bindFramebuffer.set(o.framebuffer),o;o&&o.destroy();const w=new a.T(i,{width:d,height:m,data:null},i.extRenderToTextureHalfFloat?i.gl.RGBA16F:i.gl.RGBA8);w.bind(v.LINEAR,v.CLAMP_TO_EDGE);const E=i.createFramebuffer(d,m,1,null);if(E.colorAttachment0.set(w.texture),y){const P=i.createRenderbuffer(v.DEPTH24_STENCIL8,d,m);i.bindFramebuffer.set(E.framebuffer),v.framebufferRenderbuffer(v.FRAMEBUFFER,v.DEPTH_STENCIL_ATTACHMENT,v.RENDERBUFFER,P),E._stencilRbo=P}return E}createColorAttachment(i,o){o===0?this.colorAttachment0=new Rc(i,this.framebuffer,0):o===1&&(this.colorAttachment1=new Rc(i,this.framebuffer,1))}removeColorAttachment(i,o){const d=this.context.gl;let m;o===0?(m=this.colorAttachment0.get(),this.colorAttachment0=void 0):o===1&&(m=this.colorAttachment1.get(),this.colorAttachment1=void 0),m&&d.deleteTexture(m)}destroy(){const i=this.context.gl;if(this.colorAttachment0){const o=this.colorAttachment0.get();o&&i.deleteTexture(o)}if(this.colorAttachment1){const o=this.colorAttachment1.get();o&&i.deleteTexture(o)}if(this.depthAttachment&&this.depthAttachmentType)if(this.depthAttachmentType==="renderbuffer"){const o=this.depthAttachment.get();o&&i.deleteRenderbuffer(o)}else{const o=this.depthAttachment.get();o&&i.deleteTexture(o)}this._stencilRbo&&(i.deleteRenderbuffer(this._stencilRbo),this._stencilRbo=null),i.deleteFramebuffer(this.framebuffer)}}class kc{constructor(i,o){this.gl=i,this.clearColor=new my(this),this.clearDepth=new v1(this),this.clearStencil=new bd(this),this.colorMask=new b1(this),this.depthMask=new _y(this),this.stencilMask=new Kp(this),this.stencilFunc=new wd(this),this.stencilOp=new Jp(this),this.stencilTest=new Il(this),this.depthRange=new Al(this),this.depthTest=new Cc(this),this.depthFunc=new No(this),this.blend=new gy(this),this.blendFunc=new Qp(this),this.blendColor=new yy(this),this.blendEquation=new Pc(this),this.cullFace=new Td(this),this.cullFaceSide=new Sd(this),this.frontFace=new em(this),this.program=new Ed(this),this.activeTexture=new qu(this),this.viewport=new xy(this),this.bindFramebuffer=new vy(this),this.bindRenderbuffer=new by(this),this.bindTexture=new Mc(this),this.bindVertexBuffer=new wy(this),this.bindElementBuffer=new w1(this),this.bindVertexArrayOES=new T1(this),this.pixelStoreUnpack=new S1(this),this.pixelStoreUnpackPremultiplyAlpha=new tm(this),this.pixelStoreUnpackFlipY=new im(this),this.options=o?Object.assign({},o):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=i.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=i.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=i.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=i.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.forceManualRenderingForInstanceIDShaders=o&&!!o.forceManualRenderingForInstanceIDShaders||this.renderer&&this.renderer.indexOf("PowerVR")!==-1,this.disableSymbolUBO=o&&!!o.forceDisableSymbolUBO,this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=i.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=i.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=i.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=i.getParameter(i.MAX_TEXTURE_SIZE),this.maxUniformBlockSize=Math.min(i.getParameter(i.MAX_UNIFORM_BLOCK_SIZE),32768),this.maxUniformBufferBindings=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS),this.extBlendFuncExtended=i.getExtension("WEBGL_blend_func_extended")}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(i,o,d){return new go(this,i,o,d)}createVertexBuffer(i,o,d,m,y){return new Oy(this,i,o,d,m,y)}createRenderbuffer(i,o,d){const m=this.gl,y=m.createRenderbuffer();return this.bindRenderbuffer.set(y),m.renderbufferStorage(m.RENDERBUFFER,i,o,d),this.bindRenderbuffer.set(null),y}createFramebuffer(i,o,d,m){return new rh(this,i,o,d,m)}clear({color:i,depth:o,stencil:d,colorMask:m}){const y=this.gl;let v=0;i&&(v|=y.COLOR_BUFFER_BIT,this.clearColor.set(i.toNonPremultipliedRenderColor(null)),this.colorMask.set(m||[!0,!0,!0,!0])),o!==void 0&&(v|=y.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(o),this.depthMask.set(!0)),d!==void 0&&(v|=y.STENCIL_BUFFER_BIT,this.clearStencil.set(d),this.stencilMask.set(255)),y.clear(v)}setCullFace(i){i.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(i.mode),this.frontFace.set(i.frontFace))}setDepthMode(i){i.func!==this.gl.ALWAYS||i.mask?(this.depthTest.set(!0),this.depthFunc.set(i.func),this.depthMask.set(i.mask),this.depthRange.set(i.range)):this.depthTest.set(!1)}setStencilMode(i){i.test.func!==this.gl.ALWAYS||i.mask?(this.stencilTest.set(!0),this.stencilMask.set(i.mask),this.stencilOp.set([i.fail,i.depthFail,i.pass]),this.stencilFunc.set({func:i.test.func,ref:i.ref,mask:i.test.mask})):this.stencilTest.set(!1)}setColorMode(i){a.b6(i.blendFunction,jt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(i.blendFunction),this.blendColor.set(i.blendColor),i.blendEquation?this.blendEquation.set(i.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(i.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let Ml;function wt(u,i,o,d,m,y,v){const w=u.context,E=w.gl,P=u.transform,R=[a.aH(P.center.lng),a.aL(P.center.lat)],O=o.layout.get("symbol-placement"),k=o.layout.get("text-variable-anchor"),N=o.layout.get("icon-rotation-alignment")==="map",j=o.layout.get("text-rotation-alignment")==="map",U=O!=="point",X=[];let W=0,ie=0;for(let re=0;re<d.length;re++){const ae=d[re],fe=i.getTile(ae),Ce=fe.getBucket(o);if(!Ce)continue;const ve=Ce.getProjection().createInversionMatrix(P,ae.canonical),Ne=[],ze=iy(ae,Ce,P),Je=!v&&N&&U,tt=v&&j&&U,Pe=k&&Ce.hasTextData(),we=Ce.hasIconTextFit()&&Pe&&Ce.hasIconData(),Oe=Je||tt||v&&Pe||we,Ue=Ce.projection.name==="globe",$e=Ue?a.al(P.zoom):0;Ue&&(Ne.push("PROJECTION_GLOBE_VIEW"),Oe&&Ne.push("PROJECTED_POS_ON_VIEWPORT"));const ft=u.getOrCreateProgram("collisionBox",{defines:Ne});let lt=ze;m[0]===0&&m[1]===0||(lt=u.translatePosMatrix(ze,fe,m,y));const ct=v?Ce.textCollisionBox:Ce.iconCollisionBox,et=Ce.collisionCircleArray;if(et.length>0){const Mt=a.bb(),vt=lt;a.cz(Mt,Ce.placementInvProjMatrix,P.glCoordMatrix),a.cz(Mt,Mt,Ce.placementViewportMatrix),X.push({circleArray:et,circleOffset:ie,transform:vt,invTransform:Mt,projection:Ce.getProjection()}),W+=et.length/4,ie=W}if(!ct)continue;u.terrain&&u.terrain.setupElevationDraw(fe,ft);const Et=Ue?[ae.canonical.x,ae.canonical.y,1<<ae.canonical.z]:[0,0,0];ft.draw(u,E.LINES,At.disabled,Ht.disabled,u.colorModeForRenderPass(),Nt.disabled,Ry(lt,ve,P,$e,R,fe,Et,Ce.getProjection()),o.id,ct.layoutVertexBuffer,ct.indexBuffer,ct.segments,null,P.zoom,null,[ct.collisionVertexBuffer,ct.collisionVertexBufferExt])}if(!v||!X.length)return;const ne=u.getOrCreateProgram("collisionCircle"),K=new a.dP;K.resize(4*W),K._trim();let xe=0;for(const re of X)for(let ae=0;ae<re.circleArray.length/4;ae++){const fe=4*ae,Ce=re.circleArray[fe+0],ve=re.circleArray[fe+1],Ne=re.circleArray[fe+2],ze=re.circleArray[fe+3];K.emplace(xe++,Ce,ve,Ne,ze,0),K.emplace(xe++,Ce,ve,Ne,ze,1),K.emplace(xe++,Ce,ve,Ne,ze,2),K.emplace(xe++,Ce,ve,Ne,ze,3)}(!Ml||Ml.length<2*W)&&(Ml=function(re){const ae=2*re,fe=new a.dC;fe.resize(ae),fe._trim();for(let Ce=0;Ce<ae;Ce++){const ve=6*Ce;fe.uint16[ve+0]=4*Ce+0,fe.uint16[ve+1]=4*Ce+1,fe.uint16[ve+2]=4*Ce+2,fe.uint16[ve+3]=4*Ce+2,fe.uint16[ve+4]=4*Ce+3,fe.uint16[ve+5]=4*Ce+0}return fe}(W));const le=w.createIndexBuffer(Ml,!0),_e=w.createVertexBuffer(K,a.dQ.members,!0);for(const re of X){const ae=Ha(re.transform,re.invTransform,P,re.projection);ne.draw(u,E.TRIANGLES,At.disabled,Ht.disabled,u.colorModeForRenderPass(),Nt.disabled,ae,o.id,_e,le,a.dy.simpleSegment(0,2*re.circleOffset,re.circleArray.length,re.circleArray.length/2),null,P.zoom)}_e.destroy(),le.destroy()}const sh=a.bb();function ha(u){const i=u._camera.getWorldToCamera(u.worldSize,1),o=a.aD([],i,u.globeMatrix);a.b7(o,o);const d=[0,0,0],m=[0,1,0,0];return a.aE(m,m,o),d[0]=m[0],d[1]=m[1],d[2]=m[2],a.ay(d,d),d}function qa({width:u,height:i,anchor:o,textOffset:d,textScale:m},y){const{horizontalAlign:v,verticalAlign:w}=a.bF(o),E=-(v-.5)*u,P=-(w-.5)*i,R=a.bG(o,d);return new a.P((E/m+R[0])*y,(P/m+R[1])*y)}function By(u,i,o,d,m,y,v,w,E,P){const R=u.text.placedSymbolArray,O=u.text.dynamicLayoutVertexArray,k=u.icon.dynamicLayoutVertexArray,N={},j=u.getProjection(),U=xl(v,j,m),X=m.elevation,W=j.upVectorScale(v.canonical,m.center.lat,m.worldSize).metersToTile;O.clear();for(let ie=0;ie<R.length;ie++){const ne=R.get(ie),{tileAnchorX:K,tileAnchorY:xe,numGlyphs:le}=ne,_e=ne.hidden||!ne.crossTileID||u.allowVerticalPlacement&&!ne.placedOrientation?null:d[ne.crossTileID];if(_e){let re=0,ae=0,fe=0;const Ce=u.elevationType==="road";if(X||Ce){const Ue=Ce?u.getElevationFeatureForText(ie):null,$e=a.bu.getAtTileOffset(v,new a.P(K,xe),X,Ue),[ft,lt,ct]=j.upVector(v.canonical,K,xe);re=$e*ft*W,ae=$e*lt*W,fe=$e*ct*W}let[ve,Ne,ze,Je]=Xs(ne.projectedAnchorX+re,ne.projectedAnchorY+ae,ne.projectedAnchorZ+fe,o?U:y);const tt=hd(m.getCameraToCenterDistance(j),Je);let Pe=a.bl(u.textSizeData,E,ne)*tt/a.by;o&&(Pe*=u.tilePixelRatio/w);const we=qa(_e,Pe);o?({x:ve,y:Ne,z:ze}=j.projectTilePoint(K+we.x,xe+we.y,v.canonical),[ve,Ne,ze]=Xs(ve+re,Ne+ae,ze+fe,y)):(i&&we._rotate(-m.angle),ve+=we.x,Ne+=we.y,ze=0);const Oe=u.allowVerticalPlacement&&ne.placedOrientation===a.bk.vertical?Math.PI/2:0;for(let Ue=0;Ue<le;Ue++)a.bn(O,ve,Ne,ze,Oe);P&&ne.associatedIconIndex>=0&&(N[ne.associatedIconIndex]={x:ve,y:Ne,z:ze,angle:Oe})}else vc(le,O)}if(P){k.clear();const ie=u.icon.placedSymbolArray;for(let ne=0;ne<ie.length;ne++){const K=ie.get(ne),{numGlyphs:xe}=K,le=N[ne];if(K.hidden||!le)vc(xe,k);else{const{x:_e,y:re,z:ae,angle:fe}=le;for(let Ce=0;Ce<xe;Ce++)a.bn(k,_e,re,ae,fe)}}u.icon.dynamicLayoutVertexBuffer.updateData(k)}u.text.dynamicLayoutVertexBuffer.updateData(O)}function Vd(u,i,o,d,m,y,v={}){const w=o.paint.get("icon-translate"),E=o.paint.get("text-translate"),P=o.paint.get("icon-translate-anchor"),R=o.paint.get("text-translate-anchor"),O=o.layout.get("icon-rotation-alignment"),k=o.layout.get("text-rotation-alignment"),N=o.layout.get("icon-pitch-alignment"),j=o.layout.get("text-pitch-alignment"),U=o.layout.get("icon-keep-upright"),X=o.layout.get("text-keep-upright"),W=o.paint.get("icon-color-saturation"),ie=o.paint.get("icon-color-contrast"),ne=o.paint.get("icon-color-brightness-min"),K=o.paint.get("icon-color-brightness-max"),xe=o.layout.get("symbol-elevation-reference")==="sea",le=o.layout.get("icon-image-use-theme")==="none",_e=u.context,re=_e.gl,ae=u.transform,fe=O==="map",Ce=k==="map",ve=N==="map",Ne=j==="map",ze=o.layout.get("symbol-sort-key").constantOr(1)!==void 0;let Je=!1;const tt=u.depthModeForSublayer(0,At.ReadOnly),Pe=new At(u.context.gl.LEQUAL,At.ReadOnly,u.depthRangeFor3D),we=[a.aH(ae.center.lng),a.aL(ae.center.lat)],Oe=o.layout.get("text-variable-anchor"),Ue=ae.projection.name==="globe",$e=[],ft=[0,-1,0];for(const lt of d){const ct=i.getTile(lt),et=ct.getBucket(o);if(!et||et.projection.name==="mercator"&&Ue||et.fullyClipped)continue;const Et=et.projection.name==="globe",Mt=Et?a.al(ae.zoom):0,vt=xl(lt,et.getProjection(),ae),St=ae.calculatePixelsToTileUnitsMatrix(ct),Vt=Oe&&et.hasTextData(),Yt=et.hasIconTextFit()&&Vt&&et.hasIconData(),Zt=et.getProjection().createInversionMatrix(ae,lt.canonical),si=(1<<ct.tileID.canonical.z)*a.an/u.transform.worldSize,Ft=Pi=>{let Jt=[0,0,0];if(Pi){const en=u.style.directionalLight,Ui=u.style.ambientLight;en&&Ui&&(Jt=mo(u.style,en,Ui))}return Jt},oi=Pi=>{if(u.context.disableSymbolUBO)return;Pi.push("USE_PAINT_PROPERTIES_UBO");const Jt=Math.floor(u.context.maxUniformBlockSize/4),en=Math.floor(Jt/4);Pi.push(`MAX_UBO_SIZE_VEC4 ${en}u`)},qt=Pi=>{ae.depthOcclusionForSymbolsAndCircles&&(o.hasOcclusionOpacityProperties||u.terrain)&&(Pi.push("DEPTH_D24"),Pi.push("DEPTH_OCCLUSION"))},Ti=Pi=>{o.lut&&!le&&(o.lut.texture||(o.lut.texture=new a.dR(u.context,o.lut.image,[o.lut.image.height,o.lut.image.height,o.lut.image.height],_e.gl.RGBA8)),_e.activeTexture.set(_e.gl.TEXTURE0+10),o.lut.texture&&o.lut.texture.bind(_e.gl.LINEAR,_e.gl.CLAMP_TO_EDGE),Pi.push("APPLY_LUT_ON_GPU"))},Vi=()=>{const Pi=fe&&o.layout.get("symbol-placement")!=="point",Jt=[];qt(Jt),Ti(Jt);const en=Pi||Yt,Ui=et.elevationType==="road",kn=u.shadowRenderer,fi=Ui&&ve&&!!kn&&kn.enabled,Gi=Ft(fi),Vn=Ui&&ve&&!u.terrain?Pe:tt,Er=o.paint.get("icon-image-cross-fade");u.terrainRenderModeElevated()&&ve&&Jt.push("PITCH_WITH_MAP_TERRAIN"),Et&&(Jt.push("PROJECTION_GLOBE_VIEW"),en&&Jt.push("PROJECTED_POS_ON_VIEWPORT")),Er>0&&et.hasAnySecondaryIcon&&Jt.push("ICON_TRANSITION"),!et.icon.zOffsetVertexBuffer||Ui&&u.terrain||Jt.push("Z_OFFSET"),W===0&&ie===0&&ne===0&&K===1||Jt.push("COLOR_ADJUSTMENT"),et.sdfIcons&&Jt.push("RENDER_SDF"),fi&&Jt.push("RENDER_SHADOWS","NORMAL_OFFSET"),Ui&&ve&&!u.terrain&&et.icon.orientationVertexBuffer&&Jt.push("ELEVATED_ROADS"),oi(Jt);const Hn=_e.disableSymbolUBO?et.icon.programConfigurations.get(o.id):null,ar=u.getOrCreateProgram("symbol",{config:Hn,defines:Jt}),_s=ct.imageAtlasTexture?ct.imageAtlasTexture.size:[0,0],Li=et.iconSizeData,Ls=a.bj(Li,ae.zoom),zs=ve||!ae.isOrthographic,Yi=Ba(vt,ct.tileID.canonical,ve,fe,ae,et.getProjection(),St),Ki=xc(vt,ct.tileID.canonical,ve,fe,ae,et.getProjection(),St),Bi=et.icon.uboBinder&&et.icon.uboBinder.cachedHeader&&256&et.icon.uboBinder.cachedHeader.dataDrivenMask?[0,0]:w,Mn=u.translatePosMatrix(Ki,ct,Bi,P,!0),kr=u.translatePosMatrix(vt,ct,Bi,P),_n=en?sh:Yi,gs=fe&&!ve&&!Pi;let Wa=ft;!Ue&&!ae.mercatorFromTransition||fe||(Wa=ha(ae));const Bl=Et?Wa:ft,Nl=o.getColorAdjustmentMatrix(W,ie,ne,K),Uc=Bd(Li.kind,Ls,gs,ve,u,kr,_n,Mn,xe,!1,_s,[0,0],0,lt,Mt,we,Zt,Bl,et.getProjection(),Gi,si,Nl,Er,null),ga=ct.imageAtlasTexture?ct.imageAtlasTexture:null,Ho=o.layout.get("icon-size").constantOr(0)!==1||et.iconsNeedLinear,jc=et.sdfIcons||u.options.rotating||u.options.zooming||Ho||zs?re.LINEAR:re.NEAREST,ns=et.sdfIcons&&o.paint.get("icon-halo-width").constantOr(1)!==0,Xa=u.terrain&&ve&&Pi?a.b7(a.bb(),Yi):sh;if(Pi&&et.icon){const Ya=a.bu.getAtTileOffsetFunc(lt,ae.center.lat,ae.worldSize,et.getProjection()),Ka=ho(vt,ct.tileID.canonical,ve,fe,ae,et.getProjection(),St),uf=o.layout.get("icon-size-scale-range"),Gc=a.aC(u.scaleFactor,uf[0],uf[1]);fs(et,vt,u,!1,Ka,Ki,ve,U,Ya,lt,Gc)}return{program:ar,buffers:et.icon,uniformValues:Uc,atlasTexture:ga,atlasTextureIcon:null,atlasInterpolation:jc,atlasInterpolationIcon:null,isSDF:et.sdfIcons,hasHalo:ns,depthMode:Vn,tile:ct,renderWithShadows:fi,labelPlaneMatrixInv:Xa}},nn=()=>{const Pi=Ce&&o.layout.get("symbol-placement")!=="point",Jt=[],en=Pi||Oe||Yt,Ui=et.elevationType==="road",kn=u.shadowRenderer,fi=Ui&&Ne&&!!kn&&kn.enabled,Gi=Ft(fi),Vn=Ui&&Ne&&!u.terrain?Pe:tt;u.terrainRenderModeElevated()&&Ne&&Jt.push("PITCH_WITH_MAP_TERRAIN"),Et&&(Jt.push("PROJECTION_GLOBE_VIEW"),en&&Jt.push("PROJECTED_POS_ON_VIEWPORT")),!et.text.zOffsetVertexBuffer||Ui&&u.terrain||Jt.push("Z_OFFSET"),et.iconsInText&&Jt.push("RENDER_TEXT_AND_SYMBOL"),Jt.push("RENDER_SDF"),fi&&Jt.push("RENDER_SHADOWS","NORMAL_OFFSET"),Ui&&Ne&&!u.terrain&&et.text.orientationVertexBuffer&&Jt.push("ELEVATED_ROADS"),qt(Jt),oi(Jt);const Er=_e.disableSymbolUBO?et.text.programConfigurations.get(o.id):null,Hn=u.getOrCreateProgram("symbol",{config:Er,defines:Jt});let ar,_s=[0,0],Li=null;const Ls=et.textSizeData;et.iconsInText&&(_s=ct.imageAtlasTexture?ct.imageAtlasTexture.size:[0,0],Li=ct.imageAtlasTexture?ct.imageAtlasTexture:null,ar=Ne||!ae.isOrthographic||u.options.rotating||u.options.zooming||Ls.kind==="composite"||Ls.kind==="camera"?re.LINEAR:re.NEAREST);const zs=ct.glyphAtlasTexture?ct.glyphAtlasTexture.size:[0,0],Yi=o.layout.get("text-size-scale-range"),Ki=a.aC(u.scaleFactor,Yi[0],Yi[1]),Bi=a.bj(Ls,ae.zoom,Ki),Mn=Ba(vt,ct.tileID.canonical,Ne,Ce,ae,et.getProjection(),St),kr=xc(vt,ct.tileID.canonical,Ne,Ce,ae,et.getProjection(),St),_n=et.text.uboBinder&&et.text.uboBinder.cachedHeader&&256&et.text.uboBinder.cachedHeader.dataDrivenMask?[0,0]:E,gs=u.translatePosMatrix(kr,ct,_n,R,!0),Wa=u.translatePosMatrix(vt,ct,_n,R),Bl=en?sh:Mn,Nl=Ce&&!Ne&&!Pi;let Uc=ft;!Ue&&!ae.mercatorFromTransition||Ce||(Uc=ha(ae));const ga=Bd(Ls.kind,Bi,Nl,Ne,u,Wa,Bl,gs,xe,!0,zs,_s,0,lt,Mt,we,Zt,Et?Uc:ft,et.getProjection(),Gi,si,null,null,Ki),Ho=ct.glyphAtlasTexture?ct.glyphAtlasTexture:null,jc=re.LINEAR,ns=o.paint.get("text-halo-width").constantOr(1)!==0,Xa=u.terrain&&Ne&&Pi?a.b7(a.bb(),Mn):sh;if(Pi&&et.text){const Ya=a.bu.getAtTileOffsetFunc(lt,ae.center.lat,ae.worldSize,et.getProjection()),Ka=ho(vt,ct.tileID.canonical,Ne,Ce,ae,et.getProjection(),St);fs(et,vt,u,!0,Ka,kr,Ne,X,Ya,lt,Ki)}return{program:Hn,buffers:et.text,uniformValues:ga,atlasTexture:Ho,atlasTextureIcon:Li,atlasInterpolation:jc,atlasInterpolationIcon:ar,isSDF:!0,hasHalo:ns,depthMode:Vn,tile:ct,renderWithShadows:fi,labelPlaneMatrixInv:Xa}},Hi=et.icon.segments.get().length,Ci=et.text.segments.get().length,ni=Hi&&!v.onlyText?Vi():null,ri=Ci&&!v.onlyIcons?nn():null,Zi=o.paint.get("icon-opacity").constantOr(1),an=o.paint.get("text-opacity").constantOr(1);if(ze&&et.canOverlap){Je=!0;const Pi=Zi&&!v.onlyText?et.icon.segments.get():[],Jt=an&&!v.onlyIcons?et.text.segments.get():[];for(const en of Pi)$e.push({segments:new a.dy([en]),sortKey:en.sortKey,state:ni});for(const en of Jt)$e.push({segments:new a.dy([en]),sortKey:en.sortKey,state:ri})}else v.onlyText||$e.push({segments:Zi?et.icon.segments:new a.dy([]),sortKey:0,state:ni}),v.onlyIcons||$e.push({segments:an?et.text.segments:new a.dy([]),sortKey:0,state:ri})}Je&&$e.sort((lt,ct)=>lt.sortKey-ct.sortKey);for(const lt of $e){const ct=lt.state;if(ct)if(u.terrain?u.terrain.setupElevationDraw(ct.tile,ct.program,{useDepthForOcclusion:ae.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:ct.labelPlaneMatrixInv}):u.setupDepthForOcclusion(ae.depthOcclusionForSymbolsAndCircles,ct.program),_e.activeTexture.set(re.TEXTURE0),ct.atlasTexture&&ct.atlasTexture.bind(ct.atlasInterpolation,re.CLAMP_TO_EDGE,!0),ct.atlasTextureIcon&&(_e.activeTexture.set(re.TEXTURE1),ct.atlasTextureIcon&&ct.atlasTextureIcon.bind(ct.atlasInterpolationIcon,re.CLAMP_TO_EDGE,!0)),ct.renderWithShadows&&u.shadowRenderer.setupShadows(ct.tile.tileID.toUnwrapped(),ct.program,"vector-tile"),u.uploadCommonLightUniforms(u.context,ct.program),ct.hasHalo){const et=ct.uniformValues;et.u_is_halo=1,Ud(ct.buffers,lt.segments,o,u,ct.program,ct.depthMode,m,y,et,2),et.u_is_halo=0}else{if(ct.isSDF){const et=ct.uniformValues;ct.hasHalo&&(et.u_is_halo=1,Ud(ct.buffers,lt.segments,o,u,ct.program,ct.depthMode,m,y,et,1)),et.u_is_halo=0}Ud(ct.buffers,lt.segments,o,u,ct.program,ct.depthMode,m,y,ct.uniformValues,1)}}}function Ud(u,i,o,d,m,y,v,w,E,P){const R=d.context,O=R.gl,k=[u.dynamicLayoutVertexBuffer,u.opacityVertexBuffer,u.iconTransitioningVertexBuffer,u.globeExtVertexBuffer,u.zOffsetVertexBuffer,u.orientationVertexBuffer];u.featureIdBuffer&&k.push(u.featureIdBuffer);const N=u.uboBinder?null:u.programConfigurations.get(o.id);if(u.uboBinder){u.uboBinder.layer=o;const X=d.transform.zoom,W=d.style.getBrightness?d.style.getBrightness():null,ie=u.uboBinder.getConstantUniformValues(X,W);E.u_spp_fill_np_color=ie.fill_np_color,E.u_spp_halo_np_color=ie.halo_np_color,E.u_spp_opacity=ie.opacity,E.u_spp_halo_width=ie.halo_width,E.u_spp_halo_blur=ie.halo_blur,E.u_spp_emissive_strength=ie.emissive_strength,E.u_spp_occlusion_opacity=ie.occlusion_opacity,E.u_spp_z_offset=ie.z_offset;const ne=o.paint.get(u.uboBinder.isText?"text-translate-anchor":"icon-translate-anchor"),K=u.uboBinder.cachedHeader&&256&u.uboBinder.cachedHeader.dataDrivenMask&&ne==="map"?d.transform.angle:0;E.u_spp_translate_rotation=[Math.cos(K),Math.sin(K)]}const{batchIndices:j,batchSegments:U}=u.getBatchGrouping(i);for(const X of j){const W=U.get(X);u.uboBinder&&u.uboBinder.bind(R,m.program,X),m.draw(d,O.TRIANGLES,y,v,w,Nt.disabled,E,o.id,u.layoutVertexBuffer,u.indexBuffer,W,o.paint,d.transform.zoom,N,k,P)}}function jd(u,i,o,d,m,y){const v=o.paint.get("line-width"),w=o.paint.get("line-emissive-strength").isConstant(),E=o.paint.get("line-emissive-strength").constantOr(0),P=o.paint.get("line-occlusion-opacity"),R=o.layout.get("line-elevation-reference"),O=o.layout.get("line-width-unit")==="meters",k=R==="sea",N=!(!u.terrain||!u.terrain.enabled),j=u.context,U=j.gl;if(o.hasElevatedBuckets&&u.transform.projection.name==="globe")return;const X=o.layout.get("line-cross-slope"),W=X!==void 0,ie=X<1,ne=m||u.colorModeForDrapableLayerRenderPass(w?E:null),K=u.terrain&&u.terrain.renderingToTexture||y,xe=K?1:a.o.devicePixelRatio,le=o.paint.get("line-dasharray"),_e=le.constantOr(1),re=o.layout.get("line-cap"),ae=le.constantOr(null),fe=re.constantOr(null),Ce=o.paint.get("line-pattern"),ve=Ce.constantOr(1),Ne=o.paint.get("line-pattern-cross-fade"),ze=Ce.constantOr(null),Je=o.paint.get("line-opacity").constantOr(1);let tt=!ve&&Je!==1||u.depthOcclusion&&P>0&&P<1;const Pe=o.paint.get("line-gradient"),we=ve?"linePattern":"line",Oe=a.dU(o);let Ue;if(K&&u.terrain&&u.terrain.clipOrMaskOverlapStencilType()&&(tt=!1),P!==0&&u.depthOcclusion){const et=o.paint._values["line-opacity"];et&&et.value&&et.value.kind==="constant"?Ue=et.value:a.w(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`)}v.value.kind!=="constant"&&v.value.isLineProgressConstant===!1&&Oe.push("VARIABLE_LINE_WIDTH"),K&&(u.emissiveMode!=="dual-source-blending"||w?u.emissiveMode==="mrt-fallback"&&Oe.push("USE_MRT1"):Oe.push("DUAL_SOURCE_BLENDING"));const $e={},ft=(et,Et,Mt,vt,St,Vt)=>{for(const Yt of et){const Zt=i.getTile(Yt);if(ve&&!Zt.patternsLoaded())continue;const si=Zt.getBucket(o);if(!si||si.elevationType!=="none"&&!St||si.elevationType==="none"&&St)continue;u.prepareDrawTile();const Ft=[...Et],oi=u.shadowRenderer,qt=si.elevationType==="road"&&!!oi&&oi.enabled;let Ti=[0,0,0];if(qt){const fi=u.style.directionalLight,Gi=u.style.ambientLight;fi&&Gi&&(Ti=mo(u.style,fi,Gi)),Ft.push("RENDER_SHADOWS","NORMAL_OFFSET")}const Vi=si.programConfigurations.get(o.id);let nn=!1;if(ze&&Zt.imageAtlas){const fi=a.dV.from(ze),Gi=fi.getPrimary().scaleSelf(xe).toString(),Vn=Zt.imageAtlas.patternPositions.get(Gi),Er=fi.getSecondary(),Hn=Er?Zt.imageAtlas.patternPositions.get(Er.scaleSelf(xe).toString()):null;nn=!!Vn&&!!Hn,Vn&&Vi.setConstantPatternPositions(Vn,Hn)}Ne>0&&(nn||Vi.getPatternTransitionVertexBuffer("line-pattern"))&&Ft.push("LINE_PATTERN_TRANSITION"),si.elevationGroundScaleVertexBuffer&&Ft.push("ELEVATION_GROUND_SCALE");const Hi=u.isTileAffectedByFog(Yt),Ci=u.getOrCreateProgram(we,{config:Vi,defines:Ft,overrideFog:Hi});if(!ve&&ae&&fe&&Zt.lineAtlas){const fi=Zt.lineAtlas.getDash(ae,fe);fi&&Vi.setConstantPatternPositions(fi)}qt&&oi.setupShadows(Zt.tileID.toUnwrapped(),Ci,"vector-tile");let[ni,ri]=o.paint.get("line-trim-offset");(fe==="round"||fe==="square")&&ni!==ri&&(ni===0&&(ni-=1),ri===1&&(ri+=1));const Zi=K?Yt.projMatrix:null,an=O?1/si.tileToMeter/a.aA(Zt,1,u.transform.zoom):1,Pi=O?1/si.tileToMeter/a.aA(Zt,1,Math.floor(u.transform.zoom)):1,Jt=_e?o.paint._values["line-floorwidth"]:null;let en;if(Jt&&Jt.value.kind==="constant"){const fi=si.zoom;fi in $e||($e[fi]=Math.max(.01,o.widthExpression().evaluate({zoom:fi}))),en=Jt.value.value;const Gi=Math.floor(u.transform.zoom);Jt.value.value=$e[fi]*Math.pow(2,Gi-Zt.tileID.overscaledZ)}const Ui=ve?a.dW(u,Zt,o,Zi,xe,an,Pi,[ni,ri],Ti,Ne):a.dX(u,Zt,o,Zi,si.lineClipsArray.length,xe,an,Pi,[ni,ri],Ti);if(Pe){const fi=si.gradients[o.id];let Gi=fi.texture;if(o.gradientVersion!==fi.version){let Vn=256;if(o.stepInterpolant){const Er=i.getSource().maxzoom,Hn=Yt.canonical.z===Er?Math.ceil(1<<u.transform.maxZoom-Yt.canonical.z):1;Vn=a.aC(a.dY(si.maxLineLength/a.an*1024*Hn),256,j.maxTextureSize)}fi.gradient=a.dZ({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:Vn,image:fi.gradient||void 0,clips:si.lineClipsArray}),fi.texture?fi.texture.update(fi.gradient):fi.texture=new a.T(j,fi.gradient,U.RGBA8),fi.version=o.gradientVersion,Gi=fi.texture}j.activeTexture.set(U.TEXTURE1),Gi.bind(o.stepInterpolant?U.NEAREST:U.LINEAR,U.CLAMP_TO_EDGE)}_e&&(j.activeTexture.set(U.TEXTURE0),Zt.lineAtlasTexture&&Zt.lineAtlasTexture.bind(U.LINEAR,U.REPEAT),Vi.updatePaintBuffers()),ve&&(j.activeTexture.set(U.TEXTURE0),Zt.imageAtlasTexture&&Zt.imageAtlasTexture.bind(U.LINEAR,U.CLAMP_TO_EDGE),Vi.updatePaintBuffers()),St&&u.terrain.setupElevationDraw(Zt,Ci),u.uploadCommonUniforms(j,Ci,Yt.toUnwrapped());const kn=fi=>{Ue!=null&&(Ue.value=Je*P),Ci.draw(u,U.TRIANGLES,Mt,fi,ne,Nt.disabled,Ui,o.id,si.layoutVertexBuffer,si.indexBuffer,si.segments,o.paint,u.transform.zoom,Vi,[si.layoutVertexBuffer2,si.patternVertexBuffer,si.zOffsetVertexBuffer,si.elevationGroundScaleVertexBuffer]),Ue!=null&&(Ue.value=Je)};if(tt&&!St){const fi=u.stencilModeForClipping(Yt).ref;fi===0&&K&&j.clear({stencil:0});const Gi={func:U.EQUAL,mask:255};Ui.u_alpha_discard_threshold=.8,kn(new Ht(Gi,fi,255,U.KEEP,U.KEEP,U.INVERT)),Ui.u_alpha_discard_threshold=0,kn(new Ht(Gi,fi,255,U.KEEP,U.KEEP,U.KEEP))}else Ui.u_alpha_discard_threshold=tt&&St&&Vt?.8:0,kn(St?vt:u.stencilModeForClipping(Yt));en!==void 0&&(Jt.value.value=en)}};let lt=u.depthModeForSublayer(0,At.ReadOnly);const ct=new At(u.depthOcclusion?U.GREATER:U.LEQUAL,At.ReadOnly,u.depthRangeFor3D);if(o.hasNonElevatedBuckets){const et=!K&&u.terrain;P!==0&&et?a.w(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has line-z-offset enabled.`):et?a.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${o.id}.`):ft(d,Oe,lt,Ht.disabled,!1,!0)}if(o.hasElevatedBuckets){R==="hd-road-markup"?N||(lt=ct,Oe.push("ELEVATED_ROADS")):(Oe.push("ELEVATED"),lt=ct,W&&Oe.push(ie?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),k&&Oe.push("ELEVATION_REFERENCE_SEA"));const et=tt?u.stencilModeFor3D():Ht.disabled;u.forceTerrainMode=!0,ft(d,Oe,lt,et,!0,!0),tt&&ft(d,Oe,lt,et,!0,!1),u.forceTerrainMode=!1}tt&&(u.resetStencilClippingMasks(),K&&j.clear({stencil:0})),P===0||u.depthOcclusion||K||u.layersWithOcclusionOpacity.push(u.currentLayer)}const da={additive:{clearColor:new a.aq(0,0,0,0),colorMode:jt.additive,compositeUniformValue:1},multiply:{clearColor:new a.aq(1,1,1,1),colorMode:jt.multiply,compositeUniformValue:0}};function hm(u,i){const o=1<<u.canonical.z,d=(i.x*o-u.canonical.x-u.wrap*o)*a.an,m=(i.y*o-u.canonical.y)*a.an,y=a.d_(i.z,i.y);return a.cQ(d,m,y)}function oh(u,i,o,d,m){if(!o.layout||o.layout.get("fill-elevation-reference")==="none"||o.paint.get("fill-opacity").constantOr(1)===0)return;const y=u.context.gl,v=new At(u.context.gl.LEQUAL,At.ReadWrite,u.depthRangeFor3D),w=new At(u.context.gl.GREATER,At.ReadWrite,u.depthRangeFor3D),E=function(N){let j=.01;return N.isOrthographic&&(j=a.am(1e-4,j,a.cL(N.pitch>=Tl?1:N.pitch/Tl))),2*j}(u.transform),P=u.transform.getFreeCameraOptions().position,R="elevatedStructuresDepthReconstruct",O=u.getOrCreateProgram(R,{defines:["DEPTH_RECONSTRUCTION"]}),k=u.getOrCreateProgram(R);for(const N of d){const j=i.getTile(N),U=j.getBucket(o);if(!U)continue;const X=U.elevatedStructures;if(!X)continue;const W=U.elevationBufferData.heightRange,ie=hm(N.toUnwrapped(),P),ne=u.translatePosMatrix(N.projMatrix,j,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));let K,xe,le,_e;if(m==="initialize"){if(!W||W.min>=1||X.depthSegments.segments[0].primitiveLength===0)continue;K=th(ne,ie,E,1,0),xe=v,le=X.depthSegments,_e=O}else if(m==="reset"){if(!W||W.min>=0||X.maskSegments.segments[0].primitiveLength===0)continue;K=th(ne,ie,0,0,1),xe=w,le=X.maskSegments,_e=O}else if(m==="geometry"){if(X.depthSegments.segments[0].primitiveLength===0)continue;K=th(ne,ie,E,1,0),xe=v,le=X.depthSegments,_e=k}_e.draw(u,y.TRIANGLES,xe,Ht.disabled,jt.disabled,Nt.disabled,K,o.id,X.vertexBuffer,X.indexBuffer,le,o.paint,u.transform.zoom)}}function ah(u,i,o,d){const{painter:m,sourceCache:y,layer:v,coords:w,colorMode:E,elevationType:P,terrainEnabled:R,pass:O}=u,k=m.context.gl,N=v.paint.get("fill-pattern"),j=v.paint.get("fill-pattern-cross-fade"),U=N.constantOr(null);let X=P;P!=="road"||i&&!R||(X="none");const W=X==="road",ie=u.painter.shadowRenderer,ne=W&&!!ie&&ie.enabled,K=new At(m.context.gl.LEQUAL,At.ReadOnly,m.depthRangeFor3D);let xe=[0,0,0];if(ne){const ae=m.style.directionalLight,fe=m.style.ambientLight;ae&&fe&&(xe=mo(m.style,ae,fe))}const le=N&&N.constantOr(1),_e=m.terrain&&m.terrain.renderingToTexture,re=(ae,fe)=>{let Ce,ve,Ne,ze,Je;fe?(Ce=le&&!v.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",Ne=k.LINES):(Ce=le?"fillPattern":"fill",Ne=k.TRIANGLES);for(const tt of w){const Pe=y.getTile(tt);if(le&&!Pe.patternsLoaded())continue;const we=Pe.getBucket(v);if(!we)continue;const Oe=i?we.elevationBufferData:we.bufferData;if(Oe.isEmpty())continue;m.prepareDrawTile();const Ue=Oe.programConfigurations.get(v.id),$e=m.isTileAffectedByFog(tt),ft=[],lt=[];W&&(ft.push("ELEVATED_ROADS"),lt.push(Oe.elevatedLayoutVertexBuffer)),ne&&ft.push("RENDER_SHADOWS","NORMAL_OFFSET"),_e&&o&&ft.push("USE_MRT1"),le&&(m.context.activeTexture.set(k.TEXTURE0),Pe.imageAtlasTexture&&Pe.imageAtlasTexture.bind(k.LINEAR,k.CLAMP_TO_EDGE),Ue.updatePaintBuffers());let ct=!1;if(U&&Pe.imageAtlas){const St=Pe.imageAtlas,Vt=a.dV.from(U),Yt=Vt.getPrimary().scaleSelf(a.o.devicePixelRatio).toString(),Zt=Vt.getSecondary(),si=St.patternPositions.get(Yt),Ft=Zt?St.patternPositions.get(Zt.scaleSelf(a.o.devicePixelRatio).toString()):null;ct=!!si&&!!Ft,si&&Ue.setConstantPatternPositions(si,Ft)}j>0&&(ct||Ue.getPatternTransitionVertexBuffer("fill-pattern"))&&ft.push("FILL_PATTERN_TRANSITION");const et=m.getOrCreateProgram(Ce,{config:Ue,overrideFog:$e,defines:ft}),Et=m.translatePosMatrix(tt.projMatrix,Pe,v.paint.get("fill-translate"),v.paint.get("fill-translate-anchor"));ne&&ie.setupShadows(Pe.tileID.toUnwrapped(),et,"vector-tile");const Mt=v.paint.get("fill-emissive-strength");if(fe){ze=Oe.lineIndexBuffer,Je=Oe.lineSegments;const St=m.terrain&&m.terrain.renderingToTexture?m.terrain.drapeBufferSize:[k.drawingBufferWidth,k.drawingBufferHeight];ve=Ce==="fillOutlinePattern"&&le?Lc(Et,Mt,m,Pe,St,xe,j):Cy(Et,Mt,St,xe)}else ze=Oe.indexBuffer,Je=Oe.triangleSegments,ve=le?Dd(Et,Mt,m,Pe,xe,j):Rd(Et,Mt,xe);m.uploadCommonUniforms(m.context,et,tt.toUnwrapped());let vt=ae;(P==="road"&&!R||P==="offset")&&(vt=K),et.draw(m,Ne,vt,d||m.stencilModeForClipping(tt),E,Nt.disabled,ve,v.id,Oe.layoutVertexBuffer,ze,Je,v.paint,m.transform.zoom,Ue,lt)}};m.renderPass===O&&re(m.depthModeForSublayer(1,m.renderPass==="opaque"?At.ReadWrite:At.ReadOnly),!1),X==="none"&&m.renderPass==="translucent"&&v.paint.get("fill-antialias")&&re(m.depthModeForSublayer(v.getPaintProperty("fill-outline-color")?2:0,At.ReadOnly),!0)}function Rl(u,i,o,d,m,y,v,w){o.resetLayerRenderingStats(u);const E=u.context,P=E.gl,R=u.transform,O=o.paint.get("fill-extrusion-pattern"),k=o.paint.get("fill-extrusion-pattern-cross-fade"),N=O.constantOr(null),j=O.constantOr(1),U=o.paint.get("fill-extrusion-opacity"),X=u.style.enable3dLights(),W=o.paint.get(X&&!j?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),ie=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),W],ne=o.layout.get("fill-extrusion-edge-radius"),K=ne>0&&!o.paint.get("fill-extrusion-rounded-roof"),xe=K?0:ne,le=R.projection.name==="globe"?a.e1():0,_e=R.projection.name==="globe",re=_e?a.al(R.zoom):0,ae=[a.aH(R.center.lng),a.aL(R.center.lat)],fe=o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Ce=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(fe?null:o.lut).toArray01().slice(0,3),ve=o.paint.get("fill-extrusion-flood-light-intensity"),Ne=o.paint.get("fill-extrusion-vertical-scale"),ze=o.paint.get("fill-extrusion-line-width").constantOr(1)!==0,Je=o.paint.get("fill-extrusion-height-alignment"),tt=o.paint.get("fill-extrusion-base-alignment"),Pe=ir(u,o.paint.get("fill-extrusion-cutoff-fade-range")),we=o.paint.get("fill-extrusion-front-cutoff"),Oe=Gd(R.pitch,we,!!u.terrain),Ue=Oe[2]<1;Ue&&(u.maxFrontCutoffRawStart=Math.max(u.maxFrontCutoffRawStart,we[0]));const $e=[];let ft;_e&&$e.push("PROJECTION_GLOBE_VIEW"),ie[0]>0&&$e.push("FAUX_AO"),K&&$e.push("ZERO_ROOF_RADIUS"),w&&$e.push("HAS_CENTROID"),ve>0&&$e.push("FLOOD_LIGHT"),Pe.shouldRenderCutoff&&$e.push("RENDER_CUTOFF"),Ue&&$e.push("RENDER_FRONT_CUTOFF"),ze&&$e.push("RENDER_WALL_MODE");const lt=u.renderPass==="shadow",ct=u.shadowRenderer,et=lt&&!!ct,Et=lt?Nt.disabled:Nt.backCCW;u.shadowRenderer&&(u.shadowRenderer.useNormalOffset=!0);let Mt=[0,0,0];if(ct){const Vt=u.style.directionalLight,Yt=u.style.ambientLight;Vt&&Yt&&(Mt=mo(u.style,Vt,Yt)),lt||($e.push("RENDER_SHADOWS"),ct.useNormalOffset&&$e.push("NORMAL_OFFSET")),ft=$e.concat(["SHADOWS_SINGLE_CASCADE"])}const vt=et?"fillExtrusionDepth":j?"fillExtrusionPattern":"fillExtrusion",St=o.getLayerRenderingStats();for(const Vt of d){const Yt=i.getTile(Vt),Zt=Yt.getBucket(o);if(!Zt||Zt.projection.name!==R.projection.name)continue;let si=!1;ct&&(si=ct.getMaxCascadeForTile(Vt.toUnwrapped())===0);const Ft=u.isTileAffectedByFog(Vt),oi=Zt.programConfigurations.get(o.id);let qt=!1;if(N&&Yt.imageAtlas){const ri=Yt.imageAtlas,Zi=a.dV.from(N),an=Zi.getPrimary().scaleSelf(a.o.devicePixelRatio).toString(),Pi=Zi.getSecondary(),Jt=ri.patternPositions.get(an),en=Pi?ri.patternPositions.get(Pi.scaleSelf(a.o.devicePixelRatio).toString()):null;qt=!!Jt&&!!en,Jt&&oi.setConstantPatternPositions(Jt,en)}k>0&&(qt||oi.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&$e.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Ti=u.getOrCreateProgram(vt,{config:oi,defines:si?ft:$e,overrideFog:Ft});if(u.terrain&&u.terrain.setupElevationDraw(Yt,Ti,{useMeterToDem:!0}),!Zt.centroidVertexBuffer){const ri=Ti.getAttributeLocation(P,"a_centroid_pos");ri!==-1&&P.vertexAttribI4ui(ri,0,0,0,0)}!lt&&ct&&ct.setupShadows(Yt.tileID.toUnwrapped(),Ti,"vector-tile"),j&&(u.context.activeTexture.set(P.TEXTURE0),Yt.imageAtlasTexture&&Yt.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),oi.updatePaintBuffers());const Vi=o.paint.get("fill-extrusion-vertical-gradient"),nn=1/Zt.tileToMeter;let Hi;if(lt&&ct){if($d(Yt.tileID,Zt.maxHeight,u))continue;const ri=ct.calculateShadowPassMatrixFromTile(Yt.tileID.toUnwrapped());Hi=A1(ri,xe,nn,Ne,Je,tt)}else{const ri=u.translatePosMatrix(Vt.expandedProjMatrix,Yt,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),Zi=R.projection.createInversionMatrix(R,Vt.canonical);Hi=j?C1(ri,u,Vi,U,ie,xe,nn,Vt,Yt,le,Je,tt,re,ae,Zi,Ce,Ne,k):Ay(ri,u,Vi,U,ie,xe,nn,Vt,le,Je,tt,re,ae,Zi,Ce,Ne,ve,Mt,Oe)}u.uploadCommonUniforms(E,Ti,Vt.toUnwrapped(),null,Pe);let Ci=Zt.segments;if(R.projection.name==="mercator"&&!lt&&(Ci=Zt.getVisibleSegments(Yt.tileID,u.terrain,u.transform.getFrustum(0)),!Ci.get().length))continue;if(St)if(lt)for(const ri of Ci.get())St.numRenderedVerticesInShadowPass+=ri.primitiveLength;else for(const ri of Ci.get())St.numRenderedVerticesInTransparentPass+=ri.primitiveLength;const ni=[];(u.terrain||w)&&ni.push(Zt.centroidVertexBuffer),_e&&ni.push(Zt.layoutVertexExtBuffer),ze&&ni.push(Zt.wallVertexBuffer),Ti.draw(u,E.gl.TRIANGLES,m,y,v,Et,Hi,o.id,Zt.layoutVertexBuffer,Zt.indexBuffer,Ci,o.paint,u.transform.zoom,oi,ni)}u.shadowRenderer&&(u.shadowRenderer.useNormalOffset=!1)}class dm{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function Gd(u,i,o){if(!(i[2]<1)||o)return[0,0,1];const d=180*u/Math.PI;if(d<15)return[-.5,i[1],i[2]];const m=Math.min(1,Math.max(0,(d-15)/5)),y=m*m*(3-2*m);return[-.5*(1-y)+i[0]*y,i[1],i[2]]}function Uo(u,i,o,d,m,y,v,w,E,P,R,O,k,N,j,U,X,W,ie,ne,K){const xe=i.context,le=xe.gl,_e=i.transform,re=i.transform.zoom,ae=[],fe=u.translate,Ce=u.translateAnchor,ve=u.edgeRadius,Ne=ir(i,u.cutoffFadeRange);R==="clear"?(ae.push("CLEAR_SUBPASS"),ne&&(ae.push("CLEAR_FROM_TEXTURE"),xe.activeTexture.set(le.TEXTURE0),ne.bind(le.LINEAR,le.CLAMP_TO_EDGE))):R==="sdf"?ae.push("SDF_SUBPASS"):R==="emissive"&&(ae.push("USE_MRT1"),xe.activeTexture.set(le.TEXTURE0),ne.bind(le.LINEAR,le.CLAMP_TO_EDGE)),W&&ae.push("HAS_CENTROID"),Ne.shouldRenderCutoff&&ae.push("RENDER_CUTOFF");const ze=(Je,tt,Pe,we,Oe)=>{let Ue=ae;tt.groundRadiusBuffer!=null&&(Ue=ae.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const $e=tt.programConfigurations.get(d.id),ft=i.isTileAffectedByFog(Je),lt=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:$e,defines:Ue,overrideFog:ft}),ct=((Et,Mt,vt,St,Vt,Yt,Zt,si,Ft,oi,qt)=>({u_matrix:Mt,u_opacity:vt,u_ao_pass:St?1:0,u_meter_to_tile:Vt,u_ao:Yt,u_flood_light_intensity:Zt,u_flood_light_color:si,u_attenuation:Ft,u_edge_radius:oi,u_fb:0,u_fb_size:qt,u_dynamic_offset:1}))(0,we,O,P,Oe,[k,N*Oe],j,U,X,re>=17?0:ve*Oe,ne?ne.size[0]:0),et=[];W&&et.push(tt.hiddenByLandmarkVertexBuffer),tt.groundRadiusBuffer!=null&&et.push(tt.groundRadiusBuffer),i.uploadCommonUniforms(xe,lt,Je.toUnwrapped(),null,Ne),lt.draw(i,xe.gl.TRIANGLES,y,v,w,E,ct,d.id,tt.vertexBuffer,tt.indexBuffer,Pe,d.paint,re,$e,et)};for(const Je of m){const tt=o.getTile(Je),Pe=tt.getBucket(d);if(!Pe||Pe.projection.name!==_e.projection.name||!Pe.groundEffect||Pe.groundEffect&&!Pe.groundEffect.hasData())continue;const we=Pe.groundEffect,Oe=1/Pe.tileToMeter;{const Ue=i.translatePosMatrix(Je.projMatrix,tt,fe,Ce),$e=we.getDefaultSegment();ze(Je,we,$e,Ue,Oe)}if(ie)for(let Ue=0;Ue<4;Ue++){const $e=a.d$[Ue](Je),ft=o.getTile($e);if(!ft)continue;const lt=ft.getBucket(d);if(!lt||lt.projection.name!==_e.projection.name||!lt.groundEffect||lt.groundEffect&&!lt.groundEffect.hasData())continue;const ct=lt.groundEffect;let et,Et;Ue===0?(et=[-a.an,0,0],Et=1):Ue===1?(et=[a.an,0,0],Et=0):Ue===2?(et=[0,-a.an,0],Et=3):(et=[0,a.an,0],Et=2);const Mt=ct.regionSegments[Et];if(!Mt)continue;const vt=new Float32Array(16);a.bx(vt,Je.projMatrix,et),ze(Je,ct,Mt,i.translatePosMatrix(vt,tt,fe,Ce),Oe)}}}function Ny(u,i,o,d,m,y,v){d.centroidVertexArray.length===0&&d.createCentroidsBuffer();const w=y?y.findDEMTileFor(o):null;if(!(w&&w.dem||v))return;y&&w&&w.dem&&d.selfDEMTileTimestamp!==w.dem._timestamp&&(d.borderDoneWithNeighborZ=[-1,-1,-1,-1],d.selfDEMTileTimestamp=w.dem._timestamp);const E=(W,ie)=>{(W.flags|ie.flags)&a.e3?(W.flags|=a.e3,ie.flags|=a.e3):(W.flags&=~a.e3,ie.flags&=~a.e3)},P=W=>new a.P(Math.ceil((W+a.e4)*a.e5),0),R=(W,ie,ne)=>{const K=Math.ceil((W+a.e4)*a.e5),xe=Math.floor(Math.max(0,Math.min(a.an-1,ne))/4);return new a.P(K,xe<<5|(3&ie)<<3|7)},O=W=>{const ie=i.getSource().minzoom,ne=xe=>{const le=i.getTileByID(xe);if(le&&le.hasData())return le.getBucket(m)},K=[0,-1,1];for(const xe of K){if(W.overscaledZ+xe<ie)continue;const le=ne(W.calculateScaledKey(W.overscaledZ+xe));if(le)return le}},k=[0,0,0],N=(W,ie)=>(k[0]=Math.min(W.min.y,ie.min.y),k[1]=Math.max(W.max.y,ie.max.y),k[2]=a.an-ie.min.x>W.max.x?ie.min.x-a.an:W.max.x,k),j=(W,ie)=>(k[0]=Math.min(W.min.x,ie.min.x),k[1]=Math.max(W.max.x,ie.max.x),k[2]=a.an-ie.min.y>W.max.y?ie.min.y-a.an:W.max.y,k),U=[(W,ie)=>N(W,ie),(W,ie)=>N(ie,W),(W,ie)=>j(W,ie),(W,ie)=>j(ie,W)],X=(W,ie,ne,K,xe,le,_e)=>{if(!y)return 0;const re=[[le?ne:W,le?W:ne,0],[le?ne:ie,le?ie:ne,0]],ae=_e<0?a.an+_e:_e,fe=[le?ae:(W+ie)/2,le?(W+ie)/2:ae,0];return ne===0&&_e<0||ne!==0&&_e>0?y.getForTilePoints(xe,[fe],!0,K):re.push(fe),y.getForTilePoints(o,re,!0,w),Math.max(re[0][2],re[1][2],fe[2])/y.exaggeration()};for(let W=0;W<4;W++){const ie=d.borderFeatureIndices[W];if(ie.length===0)continue;const ne=a.d$[W](o),K=O(ne);if(!(K&&K instanceof a.e0))continue;const xe=y?y.findDEMTileFor(ne):null;if(!(xe&&xe.dem||v)||(y&&xe&&xe.dem&&d.borderDEMTileTimestamp[W]!==xe.dem._timestamp&&(d.borderDoneWithNeighborZ[W]=-1,d.borderDEMTileTimestamp[W]=xe.dem._timestamp),d.borderDoneWithNeighborZ[W]===K.canonical.z))continue;K.centroidVertexArray.length===0&&K.createCentroidsBuffer();const le=(W<2?1:5)-W,_e=K.borderDoneWithNeighborZ[le]!==d.canonical.z,re=K.borderFeatureIndices[le];let ae=0;if(d.canonical.z!==K.canonical.z){for(const Ne of ie)d.showCentroid(d.featuresOnBorder[Ne]);if(_e)for(const Ne of re)K.showCentroid(K.featuresOnBorder[Ne]);d.borderDoneWithNeighborZ[W]=K.canonical.z,K.borderDoneWithNeighborZ[le]=d.canonical.z;continue}const fe=new Map,Ce=new Set,ve=new Set;for(let Ne=0;Ne<re.length;Ne++){const ze=K.featuresOnBorder[re[Ne]];ze.buildingId!==void 0&&fe.set(ze.buildingId,Ne)}for(const Ne of ie){const ze=d.featuresOnBorder[Ne],Je=d.centroidData[ze.centroidDataIndex];if(ze.buildingId===void 0)continue;const tt=fe.get(ze.buildingId);if(tt===void 0)continue;const Pe=K.featuresOnBorder[re[tt]],we=K.centroidData[Pe.centroidDataIndex];Ce.add(Ne),ve.add(tt),v&&E(Je,we);const Oe=Je.groupCentroidPos.x!==0||Je.groupCentroidPos.y!==0?Je.groupCentroidPos:ze.centroid(),Ue=we.groupCentroidPos.x!==0||we.groupCentroidPos.y!==0?we.groupCentroidPos:Pe.centroid(),$e=W<2?Math.round((Oe.y+Ue.y)/2):Math.round((Oe.x+Ue.x)/2),ft=ze.intersectsCount()>1||Pe.intersectsCount()>1;{let lt=0;if(xe&&xe.dem&&!ft){const ct=U[W](Je,we),et=W%2?a.an-1:0;lt=X(ct[0],Math.min(a.an-1,ct[1]),et,xe,ne,W<2,ct[2])}Je.centroidXY=R(lt,W,$e),we.centroidXY=R(lt,le,$e)}if(d.writeCentroidToBuffer(Je),K.writeCentroidToBuffer(we),ze.buildingId!==void 0){for(const lt of d.centroidData)lt.buildingId===ze.buildingId&&lt!==Je&&(lt.centroidXY=Je.centroidXY,d.writeCentroidToBuffer(lt));for(const lt of K.centroidData)lt.buildingId===ze.buildingId&&lt!==we&&(lt.centroidXY=we.centroidXY,K.writeCentroidToBuffer(lt))}}for(const Ne of ie){if(Ce.has(Ne))continue;const ze=d.featuresOnBorder[Ne],Je=d.centroidData[ze.centroidDataIndex],tt=ze.borders[W];let Pe;for(;ae<re.length;){if(ve.has(ae)){ae++;continue}Pe=K.featuresOnBorder[re[ae]];const we=Pe.borders[le];if(we[1]>tt[0]+3||we[0]>tt[0]-3)break;K.showCentroid(Pe),ae++}if(Pe&&ae<re.length){let we=ae,Oe=0;for(;;)if(ve.has(ae)){if(++ae===re.length)break;Pe=K.featuresOnBorder[re[ae]]}else{if(Pe.borders[le][0]>tt[1]-3||(Oe++,++ae===re.length))break;Pe=K.featuresOnBorder[re[ae]]}for(;we<re.length&&ve.has(we);)we++;if(we>=re.length){d.showCentroid(ze);continue}Pe=K.featuresOnBorder[re[we]];let Ue=!1;if(Oe>=1){const lt=Pe.borders[le];Math.abs(tt[0]-lt[0])<3&&Math.abs(tt[1]-lt[1])<3&&(Oe=1,Ue=!0,ae=we+1)}else if(Oe===0){d.showCentroid(ze);continue}const $e=K.centroidData[Pe.centroidDataIndex];v&&Ue&&E(Je,$e);const ft=ze.intersectsCount()>1||Pe.intersectsCount()>1;if(Oe>1)ae=we,Je.centroidXY=$e.centroidXY=new a.P(0,0);else if(xe&&xe.dem&&!ft){const lt=U[W](Je,$e),ct=W%2?a.an-1:0,et=X(lt[0],Math.min(a.an-1,lt[1]),ct,xe,ne,W<2,lt[2]);Je.centroidXY=$e.centroidXY=P(et)}else ft?Je.centroidXY=$e.centroidXY=new a.P(0,0):(Je.centroidXY=d.encodeBorderCentroid(ze),$e.centroidXY=K.encodeBorderCentroid(Pe));d.writeCentroidToBuffer(Je),K.writeCentroidToBuffer($e)}else d.showCentroid(ze)}d.borderDoneWithNeighborZ[W]=K.canonical.z,K.borderDoneWithNeighborZ[le]=d.canonical.z}(d.needsCentroidUpdate||!d.centroidVertexBuffer&&d.centroidVertexArray.length!==0)&&d.uploadCentroid(u)}const Vy=[1,0,0],Uy=[0,1,0],fm=[0,0,1];function $d(u,i,o){const d=o.transform,m=o.shadowRenderer;if(!m)return!0;const y=u.toUnwrapped(),v=d.tileSize*m._cascades[o.currentShadowCascade].scale;let w=i;if(d.elevation){const j=d.elevation.getMinMaxForTile(u);j&&(w+=j.max)}const E=d.scaleZoom(v);w/=a.e2(d.center.lat,E);const P=[...m.shadowDirection];P[2]=-P[2];const R=m.computeSimplifiedTileShadowVolume(y,w,v,P);if(!R)return!1;const O=[Vy,Uy,fm,P,[P[0],0,P[2]],[0,P[1],P[2]]],k=a.cl.fromInvProjectionMatrix(d.invProjMatrix,d.worldSize,E,d.projection.name!=="globe"),N=m.getCurrentCascadeFrustum();return k.intersectsPrecise(R.vertices,R.planes,O)===0||N.intersectsPrecise(R.vertices,R.planes,O)===0}function lh(u){const{painter:i,source:o,layer:d,coords:m}=u;let y=u.defines;const v=i.context,w=i.renderPass==="shadow",E=i.renderPass==="light-beam",P=i.shadowRenderer,R=a.e2(i.transform.center.lat,i.transform.zoom),O=ir(i,d.paint.get("building-cutoff-fade-range"));O.shouldRenderCutoff&&(y=y.concat("RENDER_CUTOFF"));const k=d.paint.get("building-front-cutoff"),N=k[2]<1&&!i.terrain,j=Gd(i.transform.pitch,k,!!i.terrain);N&&(y=y.concat("RENDER_FRONT_CUTOFF"),i.maxFrontCutoffRawStart=Math.max(i.maxFrontCutoffRawStart,k[0])),u.floodLightIntensity>0&&(y=y.concat("FLOOD_LIGHT"));for(const U of m){const X=o.getTile(U),W=X.getBucket(d);if(!W)continue;P&&P.getMaxCascadeForTile(U.toUnwrapped())===0&&(y=y.concat("SHADOWS_SINGLE_CASCADE"));const ie=W.programConfigurations.get(d.id);let ne,K,xe,le=i.translatePosMatrix(U.expandedProjMatrix,X,[0,0],"map");if(le=a.cC(a.bb(),le,[1,1,u.verticalScale]),w&&P){if($d(X.tileID,W.maxHeight*R,i))continue;let re=P.calculateShadowPassMatrixFromTile(X.tileID.toUnwrapped());re=a.cC(a.bb(),re,[1,1,u.verticalScale]),xe=kd(re),ne=K=i.getOrCreateProgram("buildingDepth",{config:ie,defines:y,overrideFog:!1})}else if(E)ne=K=i.getOrCreateProgram("buildingBloom",{config:ie,defines:y,overrideFog:!1}),xe=zd(le);else{const re=i.transform.calculatePosMatrix(U.toUnwrapped(),i.transform.worldSize);a.cC(re,re,[1,1,u.verticalScale]);const ae=a.bb();a.cC(ae,re,[1,-1,1/R]),a.b7(ae,ae),a.e6(ae,ae);const fe=i.transform.getFreeCameraOptions().position,Ce=1<<U.canonical.z;if(xe=$a(le,ae,u.opacity,u.facadeAOIntensity,[((fe.x-U.wrap)*Ce-U.canonical.x)*a.an,(fe.y*Ce-U.canonical.y)*a.an,fe.z*Ce*a.an],W.tileToMeter,u.facadeEmissiveChance,u.floodLightColor,u.floodLightIntensity,j),K=i.getOrCreateProgram("building",{config:ie,defines:y,overrideFog:!1}),u.depthOnly===!0)ne=K;else{const ve=y.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);ne=i.getOrCreateProgram("building",{config:ie,defines:ve,overrideFog:!1})}P&&(P.setupShadowsFromMatrix(re,K,!0),ne!==K&&P.setupShadowsFromMatrix(re,ne,!0))}const _e=(re,ae)=>{if(E){const fe=re.entranceBloom;ae.draw(i,v.gl.TRIANGLES,u.depthMode,Ht.disabled,u.blendMode,Nt.disabled,xe,d.id,fe.layoutVertexBuffer,fe.indexBuffer,fe.segmentsBucket,d.paint,i.transform.zoom,ie,[fe.layoutAttenuationBuffer,fe.layoutColorBuffer])}else{const fe=re.segmentsBucket;let Ce=[re.layoutNormalBuffer,re.layoutCentroidBuffer,re.layoutColorBuffer,re.layoutFloodLightDataBuffer];re.layoutFacadePaintBuffer&&(Ce=Ce.concat([re.layoutFacadeDataBuffer,re.layoutFacadeVerticalRangeBuffer,re.layoutFacadePaintBuffer])),ae.draw(i,v.gl.TRIANGLES,u.depthMode,Ht.disabled,u.blendMode,w?Nt.disabled:Nt.backCW,xe,d.id,re.layoutVertexBuffer,re.indexBuffer,fe,d.paint,i.transform.zoom,ie,Ce)}};i.uploadCommonUniforms(v,K,U.toUnwrapped(),null,O),W.buildingWithoutFacade&&_e(W.buildingWithoutFacade,K),W.buildingWithFacade&&(ne!==K&&i.uploadCommonUniforms(v,ne,U.toUnwrapped(),null,O),_e(W.buildingWithFacade,ne))}}function pm(u,i,o,d,m,y,v,w,E,P,R,O,k,N){const j=u.context.gl,U=u.depthModeForSublayer(1,At.ReadOnly,j.LEQUAL,!0),X=.1*(1-(W=R))+3*W;var W;const ie=u._showOverdrawInspector,ne=O,K=new dm;ie||Uo(K,u,i,o,d,U,new Ht({func:j.ALWAYS,mask:255},255,255,j.KEEP,j.KEEP,j.REPLACE),new jt([j.ONE,j.ONE,j.ONE,j.ONE],a.aq.transparent,[!1,!1,!1,!0],j.MIN),Nt.disabled,m,"sdf",y,v,w,E,P,X,ne,!1,void 0);{const xe=ie?Ht.disabled:new Ht({func:j.EQUAL,mask:255},255,255,j.KEEP,j.DECR,j.DECR),le=ie?u.colorModeForRenderPass():new jt([j.ONE_MINUS_DST_ALPHA,j.DST_ALPHA,j.ONE,j.ONE],a.aq.transparent,[!0,!0,!0,!0]);Uo(K,u,i,o,d,U,xe,le,Nt.disabled,m,"color",y,v,w,E,P,X,ne,!1,void 0)}}function mm(u){return[u[0]*a.e7,u[1]*a.e7,u[2]*a.e7,0]}function Hd(u,i,o,d,m,y,v,w,E){const P=d.getSource(),R=o.globeSharedBuffers;if(!R)return;let O,k,N;if(i&&(O=d.getTile(i)),P instanceof a.aV?(k=P.texture,N=a.dw(0,0,o.transform)):O&&i&&(k=O.texture,N=a.dw(i.canonical.z,i.canonical.x,o.transform)),!k||!N)return;u||(N=a.cC(a.bb(),N,[1,-1,1]));const j=o.context,U=j.gl,X=m.paint.get("raster-resampling")==="nearest"?U.NEAREST:U.LINEAR,W=o.colorModeForDrapableLayerRenderPass(y),ie=v.defines;ie.push("GLOBE_POLES");const ne=new At(U.LEQUAL,At.ReadWrite,o.depthRangeFor3D),K=Float32Array.from(o.transform.expandedFarZProjMatrix),xe=Float32Array.from(a.du(a.dv(new a.cn(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),j.activeTexture.set(U.TEXTURE0),k.bind(X,U.CLAMP_TO_EDGE),j.activeTexture.set(U.TEXTURE1),k.bind(X,U.CLAMP_TO_EDGE),"useMipmap"in k&&j.extTextureFilterAnisotropic&&o.transform.pitch>20&&U.texParameterf(U.TEXTURE_2D,j.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,j.extTextureFilterAnisotropicMax);const[le,_e,re,ae]=i?R.getPoleBuffers(i.canonical.z,!1):R.getPoleBuffers(0,!0),fe=m.paint.get("raster-elevation");let Ce;u?(Ce=le,o.renderDefaultNorthPole=fe!==0):(Ce=_e,o.renderDefaultSouthPole=fe!==0);const ve=mm(v.mix),Ne=((Je,tt,Pe,we,Oe,Ue,$e,ft,lt,ct,et,Et,Mt,vt)=>Ly(Je,tt,Pe,we,new Float32Array(16),new Float32Array(9),[0,0],Oe,[0,0],[0,0,0,0],1,{opacity:1,mix:0},$e,[0,0],lt,2,et,Et,Mt,1,0,vt))(o,K,xe,N,a.al(o.transform.zoom),0,m,0,fe,0,ve,v.offset,v.range,y),ze=o.getOrCreateProgram("raster",{defines:ie});o.uploadCommonUniforms(j,ze,null),ze.draw(o,U.TRIANGLES,ne,E,W,w,Ne,m.id,Ce,re,ae)}function _m(u){if(u.isOrthographic)return[0,0,0,0];const i=u._nearZ,o=u.projection.farthestPixelDistance(u),d=o-i,m=.2*u.height,y=i+m;return[i,o,(y-m-i)/d,(y-i)/d]}function jy(u,i,o,d){if(u)return i instanceof gl&&u instanceof yl?i.getTextureDescriptor(u,o,!0):{texture:u.texture,mix:mm(d.mix),offset:d.offset,buffer:0,tileSize:1}}var gm=a.e8([{name:"a_index",type:"Int16",components:1}]);class Gy{constructor(i,o,d,m){const y={width:d[0],height:d[1],data:null},v=i.gl;this.targetColorTexture=new a.T(i,y,v.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new a.T(i,y,v.RGBA8,{useMipmap:!1}),this.context=i,this.updateParticleTexture(o,m),this.lastInvalidatedAt=0}updateParticleTexture(i,o){if(this.particleTextureDimension===o.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const d=this.context.gl,m=o.width*o.height;this.particleTexture0=new a.T(this.context,o,d.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new a.T(this.context,o,d.RGBA8,{premultiply:!1,useMipmap:!1});const y=new a.e9;y.reserve(m);for(let v=0;v<m;v++)y.emplaceBack(v);this.particleIndexBuffer=this.context.createVertexBuffer(y,gm.members,!0),this.particleSegment=a.dy.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=o.width}update(i){return!(this.lastInvalidatedAt<i&&(this.lastInvalidatedAt=a.o.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}function ym(u,i,o){if(!u)return null;const d=i.getTextureDescriptor(u,o,!0);if(!d)return null;let{texture:m,mix:y,offset:v,tileSize:w,buffer:E,format:P}=d;if(!m||!P)return null;let R=!1;return P==="uint32"&&(R=!0,y[3]=0,y=am(a.ea,y,[0,o.paint.get("raster-particle-max-speed")]),v=Od(a.ea,v,[0,o.paint.get("raster-particle-max-speed")])),{texture:m,textureOffset:[E/(w+2*E),w/(w+2*E)],tileSize:w,scalarData:R,scale:y,offset:v,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[P]]}}function xm(u){const i=u._nearZ,o=u.projection.farthestPixelDistance(u),d=o-i,m=.2*u.height,y=i+m;return[i,o,(y-m-i)/d,(y-i)/d]}const vm=new a.aq(1,0,0,1),R1=new a.aq(0,1,0,1),D1=new a.aq(0,0,1,1),L1=new a.aq(1,0,1,1),bm=new a.aq(0,1,1,1);function $y(u,i,o,d,m,y){for(let v=0;v<o.length;v++)if(m){const P=new a.aq(d.r*.8,d.g*.8,d.b*.8,1);Dl(u,i,o[v],d,-1,-1,y),Dl(u,i,o[v],d,-1,1,y),Dl(u,i,o[v],d,1,1,y),Dl(u,i,o[v],d,1,-1,y),Dl(u,i,o[v],P,0,0,y)}else Dl(u,i,o[v],d,0,0,y)}function Dl(u,i,o,d,m,y,v){const w=u.context,E=u.transform,P=w.gl,R=E.projection.name==="globe",O=R?["PROJECTION_GLOBE_VIEW"]:[];let k=a.b8(o.projMatrix);if(R&&a.al(E.zoom)>0){const ve=a.ec(o.canonical,E),Ne=a.ed(ve);k=a.aD(new Float32Array(16),E.globeMatrix,Ne),a.aD(k,E.projMatrix,k)}const N=a.bb();N[12]+=2*m/(a.o.devicePixelRatio*E.width),N[13]+=2*y/(a.o.devicePixelRatio*E.height),a.aD(k,N,k);const j=u.getOrCreateProgram("debug",{defines:O}),U=i.getTileByID(o.key);u.terrain&&u.terrain.setupElevationDraw(U,j);const X=At.disabled,W=Ht.disabled,ie=u.colorModeForRenderPass(),ne="$debug";w.activeTexture.set(P.TEXTURE0),u.emptyTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),R?U._makeGlobeTileDebugBuffers(u.context,E):U._makeDebugTileBoundsBuffers(u.context,E.projection);const K=U._tileDebugBuffer||u.debugBuffer,xe=U._tileDebugIndexBuffer||u.debugIndexBuffer,le=U._tileDebugSegments||u.debugSegments;if(j.draw(u,P.LINE_STRIP,X,W,ie,Nt.disabled,ih(k,d.toPremultipliedRenderColor(null)),ne,K,xe,le,null,null,null,[U._globeTileDebugBorderBuffer]),v){const ve=U.latestRawTileData,Ne=Math.floor((ve&&ve.byteLength||0)/1024);let ze=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(ze+=` => ${o.overscaledZ}`),ze+=` ${U.state}`,ze+=` ${Ne}kb`,function(Je,tt){Je.initDebugOverlayCanvas();const Pe=Je.debugOverlayCanvas,we=Je.context.gl,Oe=Je.debugOverlayCanvas.getContext("2d");Oe.clearRect(0,0,Pe.width,Pe.height),Oe.shadowColor="white",Oe.shadowBlur=2,Oe.lineWidth=1.5,Oe.strokeStyle="white",Oe.textBaseline="top",Oe.font="bold 36px Open Sans, sans-serif",Oe.fillText(tt,5,5),Oe.strokeText(tt,5,5),Je.debugOverlayTexture.update(Pe),Je.debugOverlayTexture.bind(we.LINEAR,we.CLAMP_TO_EDGE)}(u,ze)}const _e=i.getTile(o).tileSize,re=512/Math.min(_e,512)*(o.overscaledZ/E.zoom)*.5,ae=U._tileDebugTextBuffer||u.debugBuffer,fe=U._tileDebugTextIndexBuffer||u.quadTriangleIndexBuffer,Ce=U._tileDebugTextSegments||u.debugSegments;j.draw(u,P.TRIANGLES,X,W,jt.alphaBlended,Nt.disabled,ih(k,a.aq.transparent.toPremultipliedRenderColor(null),re),ne,ae,fe,Ce,null,null,null,[U._globeTileDebugTextBuffer])}function Hy(u,i,o,d){Zd(u,0,i+o/2,u.transform.width,o,d)}function wm(u,i,o,d){Zd(u,i-o/2,0,o,u.transform.height,d)}function Zd(u,i,o,d,m,y){const v=u.context,w=v.gl;w.enable(w.SCISSOR_TEST),w.scissor(i*a.o.devicePixelRatio,o*a.o.devicePixelRatio,d*a.o.devicePixelRatio,m*a.o.devicePixelRatio),v.clear({color:y}),w.disable(w.SCISSOR_TEST)}const z1=a.e8([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:ps}=z1;function jo(u,i,o,d){u.emplaceBack(i,o,d)}class Ur{constructor(i){this.vertexArray=new a.ee,this.indices=new a.dC,jo(this.vertexArray,-1,-1,1),jo(this.vertexArray,1,-1,1),jo(this.vertexArray,-1,1,1),jo(this.vertexArray,1,1,1),jo(this.vertexArray,-1,-1,-1),jo(this.vertexArray,1,-1,-1),jo(this.vertexArray,-1,1,-1),jo(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=i.createVertexBuffer(this.vertexArray,ps),this.indexBuffer=i.createIndexBuffer(this.indices),this.segment=a.dy.simpleSegment(0,0,36,12)}}function Ms(u,i,o,d,m,y){const v=u.context.gl,w=i.paint.get("sky-atmosphere-color"),E=i.paint.get("sky-atmosphere-halo-color"),P=i.paint.get("sky-atmosphere-sun-intensity"),R=((O,k,N,j,U)=>({u_matrix_3f:O,u_sun_direction:k,u_sun_intensity:N,u_color_tint_r:[j.r,j.g,j.b,j.a],u_color_tint_m:[U.r,U.g,U.b,U.a],u_luminance:5e-5}))(a.eg(a.dE(),d),m,P,w.toPremultipliedRenderColor(null),E.toPremultipliedRenderColor(null));v.framebufferTexture2D(v.FRAMEBUFFER,v.COLOR_ATTACHMENT0,v.TEXTURE_CUBE_MAP_POSITIVE_X+y,i.skyboxTexture,0),o.draw(u,v.TRIANGLES,At.disabled,Ht.disabled,jt.unblended,Nt.frontCW,R,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Zy=a.e8([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Tm{constructor(i){const o=new a.eh;o.emplaceBack(-1,1,1,0,0),o.emplaceBack(1,1,1,1,0),o.emplaceBack(1,-1,1,1,1),o.emplaceBack(-1,-1,1,0,1);const d=new a.dC;d.emplaceBack(0,1,2),d.emplaceBack(2,3,0),this.vertexBuffer=i.createVertexBuffer(o,Zy.members),this.indexBuffer=i.createIndexBuffer(d),this.segments=a.dy.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Sm=a.e8([{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_opacity",components:1}]);class Em{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class qy{constructor(i){this.colorModeAlphaBlendedWriteRGB=new jt([1,Pn,1,Pn],a.aq.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new jt([1,0,1,0],a.aq.transparent,[!1,!1,!1,!0]),this.params=new Em,this.updateNeeded=!0}update(i){const o=i.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Tm(o);const d=this.params.sizeRange,m=this.params.intensityRange,y=function(R){const O=a.em(30),k=[];for(let N=0;N<R;++N){const j=2*Math.PI*O(),U=Math.acos(1-2*O())-.5*Math.PI;k.push(a.cQ(Math.cos(U)*Math.cos(j),Math.cos(U)*Math.sin(j),Math.sin(U)))}return k}(this.params.starsCount),v=a.em(300),w=new a.ei,E=new a.dC;let P=0;for(let R=0;R<y.length;++R){const O=a.bJ([],y[R],200),k=Math.max(0,1+.01*d*(1*v()-.5)),N=Math.max(0,1+.01*m*(1*v()-.5));w.emplaceBack(O[0],O[1],O[2],-1,-1,k,N),w.emplaceBack(O[0],O[1],O[2],1,-1,k,N),w.emplaceBack(O[0],O[1],O[2],1,1,k,N),w.emplaceBack(O[0],O[1],O[2],-1,1,k,N),E.emplaceBack(P+0,P+1,P+2),E.emplaceBack(P+0,P+2,P+3),P+=4}this.starsVx=o.createVertexBuffer(w,Sm.members),this.starsIdx=o.createIndexBuffer(E),this.starsSegments=a.dy.simpleSegment(0,0,w.length,E.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy()}drawAtmosphereGlow(i,o){const d=i.context,m=d.gl,y=i.transform,v=new At(m.LEQUAL,At.ReadOnly,[0,1]),w=a.al(y.zoom),E=i.style.getLut(o.scope),P=o.properties.get("color-use-theme")==="none",R=o.properties.get("color").toNonPremultipliedRenderColor(P?null:E),O=o.properties.get("high-color-use-theme")==="none",k=o.properties.get("high-color").toNonPremultipliedRenderColor(O?null:E),N=o.properties.get("space-color-use-theme")==="none",j=o.properties.get("space-color").toNonPremultipliedRenderColor(N?null:E),U=5e-4,X=a.ej(o.properties.get("horizon-blend"),0,1,U,.25),W=a.dp(i,d,y)&&X===U?y.worldSize/(2*Math.PI*1.025)-1:y.globeRadius,ie=i.frameCounter/1e3%1,ne=a.ai(y.globeCenterInViewSpace),K=Math.sqrt(Math.pow(ne,2)-Math.pow(W,2)),xe=Math.acos(K/ne),le=_e=>{const re=y.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];_e&&re.push("ALPHA_PASS");const ae=i.getOrCreateProgram("globeAtmosphere",{defines:re}),fe=((ve,Ne,ze,Je,tt,Pe,we,Oe,Ue,$e,ft,lt)=>({u_frustum_tl:ve,u_frustum_tr:Ne,u_frustum_br:ze,u_frustum_bl:Je,u_horizon:tt,u_transition:Pe,u_fadeout_range:we,u_atmosphere_fog_color:Oe.toArray01(),u_high_color:Ue.toArray01(),u_space_color:$e.toArray01(),u_temporal_offset:ft,u_horizon_angle:lt}))(y.frustumCorners.TL,y.frustumCorners.TR,y.frustumCorners.BR,y.frustumCorners.BL,y.frustumCorners.horizon,w,X,R,k,j,ie,xe);i.uploadCommonUniforms(d,ae);const Ce=this.atmosphereBuffer;Ce&&ae.draw(i,m.TRIANGLES,v,Ht.disabled,_e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Nt.backCW,fe,_e?"atmosphere_glow_alpha":"atmosphere_glow",Ce.vertexBuffer,Ce.indexBuffer,Ce.segments)};le(!1),le(!0)}drawStars(i,o){const d=a.aC(o.properties.get("star-intensity"),0,1);if(d===0)return;const m=i.context,y=m.gl,v=i.transform,w=i.getOrCreateProgram("stars"),E=a.bL([]);a.bN(E,E,-v._pitch),a.bM(E,E,-v.angle),a.bN(E,E,a.ap(v._center.lat)),a.ek(E,E,-a.ap(v._center.lng));const P=a.bR(new Float32Array(16),E),R=a.aD([],v.starsProjMatrix,P),O=a.eg([],P),k=a.el([],O),N=[0,1,0];a.dG(N,N,k),a.bJ(N,N,this.params.sizeMultiplier);const j=[1,0,0];a.dG(j,j,k),a.bJ(j,j,this.params.sizeMultiplier);const U=(X=N,W=j,ie=d,{u_matrix:Float32Array.from(R),u_up:X,u_right:W,u_intensity_multiplier:ie});var X,W,ie;i.uploadCommonUniforms(m,w),this.starsVx&&this.starsIdx&&w.draw(i,y.TRIANGLES,At.disabled,Ht.disabled,this.colorModeAlphaBlendedWriteRGB,Nt.disabled,U,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class fa{constructor(){this.visibleTiles=[]}updateBorders(i,o){const d=[],m=[],y=i._getRenderableCoordinates(!1,!0);for(const E of y){const P=i.getTile(E);if(!P.hasData())continue;const R=P.getBucket(o);R&&(R.isEmpty()||(d.push(E.key),m.push({bucket:R,tileID:E.canonical})))}let v=d.length!==this.visibleTiles.length;if(!v){d.sort();for(let E=0;E<d.length;E++)if(d[E]!==this.visibleTiles[E]){v=!0;break}}if(!v)return;const w=new Set;this.visibleTiles=d,m.sort((E,P)=>E.tileID.z-P.tileID.z||E.tileID.x-P.tileID.x||E.tileID.y-P.tileID.y);for(const E of m){const P=new Array,R=new Array,O=E.bucket;for(const k of O.featuresOnBorder)w.has(k.featureId)?R.push(k.footprintIndex):(w.add(k.featureId),P.push(k.footprintIndex));O.updateFootprintHiddenFlags(P,a.en,!1),O.updateFootprintHiddenFlags(R,a.en,!0)}}}function Wy(u,i){const o=[...u],d=i.cameraWorldSizeForFog/i.worldSize,m=a.b9([]);return a.cC(m,m,[d,d,1]),a.aD(o,m,o),a.aD(o,i.worldToFogMatrix,o),o}function Mi(u,i,o,d,m){const y=o.material,v=d.context,{baseColorTexture:w,metallicRoughnessTexture:E}=y.pbrMetallicRoughness,{normalTexture:P,occlusionTexture:R,emissionTexture:O}=y;function k(j,U,X){if(j&&(u.push(U),v.activeTexture.set(v.gl.TEXTURE0+X),j.gfxTexture)){const{minFilter:W,magFilter:ie,wrapS:ne,wrapT:K}=j.sampler;j.gfxTexture.bindExtraParam(W,ie,ne,K)}}k(w,"HAS_TEXTURE_u_baseColorTexture",5),k(E,"HAS_TEXTURE_u_metallicRoughnessTexture",6),k(P,"HAS_TEXTURE_u_normalTexture",7),k(R,"HAS_TEXTURE_u_occlusionTexture",8),k(O,"HAS_TEXTURE_u_emissionTexture",9),m&&(m.texture||(m.texture=new a.dR(d.context,m.image,[m.image.height,m.image.height,m.image.height],v.gl.RGBA8)),v.activeTexture.set(v.gl.TEXTURE0+10),m.texture&&m.texture.bind(v.gl.LINEAR,v.gl.CLAMP_TO_EDGE),u.push("APPLY_LUT_ON_GPU")),o.texcoordBuffer&&(u.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(o.texcoordBuffer)),o.colorBuffer&&(u.push(o.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(o.colorBuffer)),o.normalBuffer&&(u.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(o.normalBuffer)),o.pbrBuffer&&(u.push("HAS_ATTRIBUTE_a_pbr"),u.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(o.pbrBuffer)),y.alphaMode!=="OPAQUE"&&y.alphaMode!=="MASK"||u.push("UNPREMULT_TEXTURE_IN_SHADER"),y.defined||u.push("DIFFUSE_SHADED");const N=d.shadowRenderer;N&&(u.push("RENDER_SHADOWS"),N.useNormalOffset&&u.push("NORMAL_OFFSET"))}function Fc(u,i,o,d,m,y){const v=u.modelOpacity,w=i.context,E=new At(i.context.gl.LEQUAL,u.isLightMesh?At.ReadOnly:At.ReadWrite,i.depthRangeFor3D),P=i.transform,R=u.mesh,O=R.material,k=O.pbrMetallicRoughness,N=i.style.fog;let j;j=i.transform.projection.zAxisUnit==="pixels"?[...u.nodeModelMatrix]:a.aD([],d.zScaleMatrix,u.nodeModelMatrix),a.aD(j,d.negCameraPosMatrix,j);const U=a.b7([],j);a.e6(U,U);const X=o.paint.get("model-color-use-theme").constantOr("default")==="none",W=o.paint.get("model-emissive-strength").constantOr(0),ie=Pl(new Float32Array(u.worldViewProjection),new Float32Array(j),new Float32Array(U),null,i,v,k.baseColorFactor,O.emissiveFactor,k.metallicFactor,k.roughnessFactor,O,W,o,void 0,void 0,u.materialOverride,u.modelColor),ne={defines:[]},K=[],xe=i.shadowRenderer;xe&&(xe.useNormalOffset=!1),Mi(ne.defines,K,R,i,X?null:o.lut);let le=null;if(N){const ae=Wy(u.nodeModelMatrix,i.transform);if(le=new Float32Array(ae),P.projection.name!=="globe"){const fe=R.aabb.min,Ce=R.aabb.max,[ve,Ne]=N.getOpacityForBounds(ae,fe[0],fe[1],Ce[0],Ce[1]);ne.overrideFog=ve>=_i||Ne>=_i}}const _e=ir(i,o.paint.get("model-cutoff-fade-range"));_e.shouldRenderCutoff&&ne.defines.push("RENDER_CUTOFF");const re=i.getOrCreateProgram("model",ne);i.uploadCommonUniforms(w,re,null,le,_e),i.renderPass!=="shadow"&&xe&&xe.setupShadowsFromMatrix(u.nodeModelMatrix,re),re.draw(i,w.gl.TRIANGLES,E,m,y,R.material.doubleSided?Nt.disabled:Nt.backCCW,ie,o.id,R.vertexBuffer,R.indexBuffer,R.segments,o.paint,i.transform.zoom,void 0,K)}function qd(u,i){return u.style._importedAsBasemap?"basemap":i.scope}function Wd(u,i,o,d,m,y,v,w,E,P){const R=u.transform,O=!!i.isGeometryBloom&&i.isGeometryBloom;if(O&&u.renderPass==="shadow")return;const k=R.projection.name==="globe"?a.ev(o,R):[...o];a.aD(k,k,i.globalMatrix);const N=a.aD([],d,k);if(i.meshes)for(const j of i.meshes){const U=w.get(j.material.name);if(U&&U.opacity<=0)continue;if(j.material.alphaMode!=="BLEND"){v.push({mesh:j,depth:0,modelIndex:m,worldViewProjection:N,nodeModelMatrix:k,isLightMesh:O,materialOverride:U,modelOpacity:E,modelColor:P,node:i,modelMatrix:o});continue}const X=a.ah([],j.centroid,N);!R.isOrthographic&&X[2]<=0||y.push({mesh:j,depth:X[2],modelIndex:m,worldViewProjection:N,nodeModelMatrix:k,isLightMesh:O,materialOverride:U,modelOpacity:E,modelColor:P,node:i,modelMatrix:o})}if(i.children)for(const j of i.children)Wd(u,j,o,d,m,y,v,w,E,P)}function Oc(u,i,o,d){const m=o.shadowRenderer;if(!m)return;const y=m.getShadowPassDepthMode(),v=m.calculateShadowPassMatrixFromMatrix(i),w=cm(v);o.getOrCreateProgram("modelDepth").draw(o,o.context.gl.TRIANGLES,y,Ht.disabled,jt.disabled,Nt.disabled,w,d.id,u.vertexBuffer,u.indexBuffer,u.segments,d.paint,o.transform.zoom,void 0,void 0)}function Im(u,i,o,d){const m=function(R,O){if(O.footprintDebugMesh)return O.footprintDebugMesh;if(!O.footprint)return null;const k=R.context,N=O.footprint.vertices,j=O.footprint.indices,U=new a.dB;U.reserve(N.length);for(const fe of N)U.emplaceBack(fe.x,fe.y);const X=new a.dC;X.reserve(j.length);for(let fe=0;fe<j.length;fe+=3)X.emplaceBack(j[fe],j[fe+1],j[fe+2]);const W=k.createVertexBuffer(U,a.dx.members),ie=k.createIndexBuffer(X),ne=a.dy.simpleSegment(0,0,N.length,j.length),K=O.id||O.name||"footprint";let xe;const le=parseInt(K,10);xe=isNaN(le)?function(fe){let Ce=0;for(let ve=0;ve<fe.length;ve++)Ce=(Ce<<5)-Ce+fe.charCodeAt(ve)|0;return Ce}(K):le;const _e=a.eb(xe),re=a.eb(xe+1),ae=a.eb(xe+2);return O.footprintDebugMesh={vertexBuffer:W,indexBuffer:ie,segments:ne,color:new a.aq(_e,re,ae,.5)},O.footprintDebugMesh}(u,o);if(!m)return;const y=u.context,v=y.gl,w=u.getOrCreateProgram("debug"),E=m.color,P=At.disabled;y.activeTexture.set(v.TEXTURE0),u.emptyTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),w.draw(u,v.TRIANGLES,P,Ht.disabled,jt.alphaBlended,Nt.disabled,ih(d,E.toPremultipliedRenderColor(null)),"$debug",m.vertexBuffer,m.indexBuffer,m.segments)}function Am(u,i,o,d,m,y){for(const v of m){const w=Object.assign({},d);w.part=v;const E={type:"Unknown",id:i,properties:w},P={orientation:u.paint.get("model-rotation").evaluate(E,o)};y.set(v,P)}}function Ll(u,i,o,d,m,y){for(const v of m){const w=Object.assign({},d);w.part=v;const E={type:"Unknown",id:i,properties:w},P={color:u.paint.get("model-color").evaluate(E,o),colorMix:u.paint.get("model-color-mix-intensity").evaluate(E,o),opacity:u.paint.get("model-opacity").evaluate(E,o),emissionStrength:u.paint.get("model-emissive-strength").evaluate(E,o)};y.set(v,P)}}function pa(u,i,o,d,m){let y=!1;for(const w of d)w.modelOpacity!==1&&(Fc(w,u,i,m[w.modelIndex],Ht.disabled,jt.disabled),y=!0);for(const w of d)Fc(w,u,i,m[w.modelIndex],w.modelOpacity!==1?u.stencilModeFor3D():Ht.disabled,u.colorModeForRenderPass());y&&u.resetStencilClippingMasks();const v=jt.additive;for(const w of o)Fc(w,u,i,m[w.modelIndex],Ht.disabled,w.isLightMesh?v:u.colorModeForRenderPass())}function dt(u,i,o){const d=i.updateZoomBasedPaintProperties(),m=function(y,v,w){let E,P,R,O=y.terrain?y.terrain.exaggeration():0;if(y.terrain&&O>0){const k=y.terrain,N=k.findDEMTileFor(w);N&&N.dem?E=a.ex.create(k,w,N):O=0}if(O===0&&(v.terrainElevationMin=0,v.terrainElevationMax=0),O===v.validForExaggeration&&(O===0||E&&E._demTile&&E._demTile.tileID===v.validForDEMTile.id&&E._dem._timestamp===v.validForDEMTile.timestamp))return!1;for(const k in v.instancesPerModel){const N=v.instancesPerModel[k];for(let j=0;j<N.instancedDataArray.length;++j){const U=(E?O*E.getElevationAt(0|N.instancedDataArray.float32[16*j],0|N.instancedDataArray.float32[16*j+1],!0,!0):0)+N.instancesEvaluatedElevation[j];N.instancedDataArray.float32[16*j+6]=U,P=P?Math.min(v.terrainElevationMin,U):U,R=R?Math.max(v.terrainElevationMax,U):U}}return v.terrainElevationMin=P||0,v.terrainElevationMax=R||0,v.validForExaggeration=O,v.validForDEMTile=E&&E._demTile?{id:E._demTile.tileID,timestamp:E._dem._timestamp}:{id:void 0,timestamp:0},!0}(u,i,o);(d||m)&&(i.uploaded=!1,i.upload(u.context))}const at={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new a.cU([0,0,0],[a.an,a.an,0])};function Bc(u,i){const o=1<<u.canonical.z,d=i.getFreeCameraOptions().position,m=i.elevation,y=u.canonical.x/o,v=(u.canonical.x+1)/o,w=u.canonical.y/o,E=(u.canonical.y+1)/o;let P=i._centerAltitude;if(m){const N=m.getMinMaxForTile(u);N&&N.max>P&&(P=N.max)}const R=a.aC(d.x,y,v)-d.x,O=a.aC(d.y,w,E)-d.y,k=a.bU(P,i.center.lat)-d.z;return i._zoomFromMercatorZ(Math.sqrt(R*R+O*O+k*k))}function on(u,i,o,d,m,y,v){const w=u.context,E=u.renderPass==="shadow",P=u.shadowRenderer,R=E&&P?P.getShadowPassDepthMode():new At(w.gl.LEQUAL,At.ReadWrite,u.depthRangeFor3D),O=u.isTileAffectedByFog(y),k=u.transform.projection.name==="globe";if(o.meshes)for(const N of o.meshes){const j=k?[]:["MODEL_POSITION_ON_GPU"],U=[];let X,W,ie;const ne=!k&&d.instancedDataArray.length>20;ne&&j.push("INSTANCED_ARRAYS");const K=ir(u,i.paint.get("model-cutoff-fade-range"));if(K.shouldRenderCutoff&&j.push("RENDER_CUTOFF"),E&&P)X=u.getOrCreateProgram("modelDepth",{defines:j}),W=cm(v.shadowTileMatrix,v.shadowTileMatrix,Float32Array.from(o.globalMatrix)),ie=jt.disabled;else{Mi(j,U,N,u,i.paint.get("model-color-use-theme").constantOr("default")==="none"?null:i.lut),X=u.getOrCreateProgram("model",{defines:j,overrideFog:O});const le=N.material,_e=le.pbrMetallicRoughness,re=i.paint.get("model-opacity").constantOr(1),ae=i.paint.get("model-emissive-strength").constantOr(0);W=Pl(y.expandedProjMatrix,Float32Array.from(o.globalMatrix),new Float32Array(16),null,u,re,_e.baseColorFactor,le.emissiveFactor,_e.metallicFactor,_e.roughnessFactor,le,ae,i,m),P&&(v.shadowUniformsInitialized?X.setShadowUniformValues(w,P.getShadowUniformValues()):(P.setupShadows(y.toUnwrapped(),X,"model-tile"),v.shadowUniformsInitialized=!0)),ie=K.shouldRenderCutoff||re<1||le.alphaMode!=="OPAQUE"?jt.alphaBlended:jt.unblended}u.uploadCommonUniforms(w,X,y.toUnwrapped(),null,K);const xe=N.material.doubleSided?Nt.disabled:Nt.backCCW;if(ne)U.push(d.instancedDataBuffer),X.draw(u,w.gl.TRIANGLES,R,Ht.disabled,ie,xe,W,i.id,N.vertexBuffer,N.indexBuffer,N.segments,i.paint,u.transform.zoom,void 0,U,d.instancedDataArray.length);else{const le=E?"u_instance":"u_normal_matrix";for(let _e=0;_e<d.instancedDataArray.length;++_e)W[le]=new Float32Array(d.instancedDataArray.arrayBuffer,64*_e,16),X.draw(u,w.gl.TRIANGLES,R,Ht.disabled,ie,xe,W,i.id,N.vertexBuffer,N.indexBuffer,N.segments,i.paint,u.transform.zoom,void 0,U)}}if(o.children)for(const N of o.children)on(u,i,N,d,m,y,v)}const Ee=[1,-1,1];function Xy(u,i,o,d){if(!o.modelManager)return!0;const m=o.modelManager;if(!o.shadowRenderer)return!0;const y=o.shadowRenderer,v=i.aabb;let w=!0,E=u.maxHeight;if(E===0){let R=0;for(const O in u.instancesPerModel){const k=m.getModel(O,d);k?R=Math.max(R,Math.max(Math.max(k.aabb.max[0],k.aabb.max[1]),k.aabb.max[2])):w=!1}E=u.maxScale*R*1.41+u.maxVerticalOffset,w&&(u.maxHeight=E)}v.max[2]=E,v.min[2]+=u.terrainElevationMin,v.max[2]+=u.terrainElevationMax,a.ah(v.min,v.min,i.tileMatrix),a.ah(v.max,v.max,i.tileMatrix);const P=v.intersects(y.getCurrentCascadeFrustum());return o.currentShadowCascade===0&&(u.isInsideFirstShadowMapFrustum=P===2),P===0}function Xd(u,i){const o=u.uniformValues.u_cutoff_params[0],d=u.uniformValues.u_cutoff_params[1],m=u.uniformValues.u_cutoff_params[2],y=u.uniformValues.u_cutoff_params[3];return d===o||y===m?1:a.aC(((i-o)/(d-o)-m)/(y-m),0,1)}function Cm(u,i,o,d){if(i.pitch<20)return 1;const m=i.getWorldToCameraMatrix();a.aD(m,m,u);const y=a.bt(o.min[0],o.min[1],o.min[2],1);let v=a.aE(a.bE(),y,m),w=v,E=v;y[1]=o.max[1],v=a.aE(a.bE(),y,m),w=v[1]<w[1]?v:w,E=v[1]>E[1]?v:E,y[0]=o.max[0],v=a.aE(a.bE(),y,m),w=v[1]<w[1]?v:w,E=v[1]>E[1]?v:E,y[1]=o.min[1],v=a.aE(a.bE(),y,m),w=v[1]<w[1]?v:w,E=v[1]>E[1]?v:E;const P=a.aC(d[0],0,1),R=100*i.pixelsPerMeter*a.aC(d[1],0,1),O=a.aC(d[2],0,1),k=a.ey(a.bE(),w,E,P),N=Math.tan(.5*i.fovX),j=-k[2]*N;if(R===0)return k[1]<-Math.abs(j)?O:1;const U=(-Math.abs(j)-k[1])/R,X=(ie,ne,K)=>(1-K)*ie+K*ne,W=a.aC(X(1,O,U),O,1);return X(1,W,a.aC((i.pitch-20)/20,0,1))}class Yd{}class Yy{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(i,o,d){{const O=this._storage.get(o.id);if(O)return O.lastUsedFrameIdx=i,O.buf}const m=d.gl,y=m.getBufferParameter(m.ELEMENT_ARRAY_BUFFER,m.BUFFER_SIZE),v=new ArrayBuffer(y),w=new Int16Array(v);m.getBufferSubData(m.ELEMENT_ARRAY_BUFFER,0,new Int16Array(v));const E=new a.eA;for(let O=0;O<y/2;O+=3){const k=w[O],N=w[O+1],j=w[O+2];E.emplaceBack(k,N),E.emplaceBack(N,j),E.emplaceBack(j,k)}const P=d.bindVertexArrayOES.current,R=new Yd;return R.buf=new go(d,E),R.lastUsedFrameIdx=i,this._storage.set(o.id,R),d.bindVertexArrayOES.set(P),R.buf}update(i){for(const[o,d]of this._storage)i-d.lastUsedFrameIdx>30&&(d.buf.destroy(),this._storage.delete(o))}destroy(){for(const[i,o]of this._storage)o.buf.destroy(),this._storage.delete(i)}}class Ky{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const Nc=a.e8([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class Jy{constructor(i){this.revealStart=11,this.revealRange=2}}const k1=a.e8([{type:"Float32",name:"a_pos_2f",components:2}]);class Qy{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(i,o){const d=i.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const v=new a.eB,w=new a.dC;v.emplaceBack(-1,-1),v.emplaceBack(1,-1),v.emplaceBack(1,1),v.emplaceBack(-1,1),w.emplaceBack(0,1,2),w.emplaceBack(0,2,3),this.vignetteVx=i.context.createVertexBuffer(v,k1.members),this.vignetteIdx=i.context.createIndexBuffer(w)}const m=a.dy.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){i.uploadCommonUniforms(i.context,d);const v={u_vignetteShape:(y={vignetteShape:[o.start,o.range,Math.pow(10,o.fadePower)],vignetteColor:[o.color.r,o.color.g,o.color.b,o.color.a*o.strength]}).vignetteShape,u_vignetteColor:y.vignetteColor};d.draw(i,i.context.gl.TRIANGLES,At.disabled,Ht.disabled,jt.alphaBlended,Nt.disabled,v,"vignette",this.vignetteVx,this.vignetteIdx,m)}var y}}class Kd{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(i,o){const d=i.getFreeCameraOptions().position,m=d.toAltitude(),y=d.toLngLat(),v=a.ap(y.lng),w=a.ap(y.lat),E=i.pixelsPerMeter/o,P=v*a.eD,R=a.eD*Math.log(Math.tan(Math.PI/4+w/2));if(this._offsetXPrev===void 0)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const O=-this._offsetYPrev+R,k=-this._elevationPrev+m;this._accumulatedOffsetX+=(-this._offsetXPrev+P)*E,this._accumulatedOffsetY+=O*E,this._accumulatedElevation+=k*E,this._offsetXPrev=P,this._offsetYPrev=R,this._elevationPrev=m}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function Jd(u,i){return[-(u[0]-Math.floor(u[0]/i)*i),-(u[1]-Math.floor(u[1]/i)*i),-(u[2]-Math.floor(u[2]/i)*i)]}function Pm(u){const i=a.em(1323123451230),o=[];for(let d=0;d<u;++d){const m=2*i()-1,y=2*i()-1,v=2*i()-1;o.push(a.cQ(m,y,v))}return o}function ma(u,i,o,d,m){const y=a.aC((m-o)/(d-o),0,1);return(1-y)*u+y*i}class ch{constructor(i){this._movement=new Kd,this._accumulatedTimeFromStart=0,this._prevTime=Date.now()/1e3,this._vignette=new Qy,this._ppmScaleFactor=i}destroy(){this.particlesVx&&this.particlesVx.destroy(),this.particlesIdx&&this.particlesIdx.destroy(),this._vignette&&this._vignette.destroy()}updateOnRender(i,o){const d=i.transform;this._movement.update(d,this._ppmScaleFactor);const m=d.starsProjMatrix,y=a.bL([]);a.bN(y,y,a.ap(90)-d._pitch),a.bM(y,y,-d.angle);const v=a.bR(new Float32Array(16),y),w=a.eC(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1),E=a.e6([],w),P=a.aD([],E,v),R=Date.now()/1e3;return this._accumulatedTimeFromStart+=(R-this._prevTime)*o,this._prevTime=R,{projectionMatrix:m,modelviewMatrix:P}}}class uh extends ch{constructor(i){super(4.25),this._params={overrideStyleParameters:!1,intensity:.5,timeFactor:1,velocityConeAperture:0,velocity:300,boxSize:2500,dropletSizeX:1,dropletSizeYScale:10,distortionStrength:70,screenThinning:{intensity:.57,start:.46,range:1.17,fadePower:.17,affectedRatio:1,particleOffset:-.2},color:{r:.66,g:.68,b:.74,a:.7},direction:{x:-50,y:-35},shapeDirPower:2,shapeNormalPower:1},this._revealParams=new Jy("Precipitation > Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3}update(i){const o=i.context;if(!this.particlesVx){const d=Pm(this.particlesCount),m=new a.eE,y=new a.dC;let v=0;const w=a.em(1323123451230);for(let E=0;E<d.length;++E){const P=d[E],R=[2*w()-1,w(),w(),w()];m.emplaceBack(P[0],P[1],P[2],-1,-1,...R),m.emplaceBack(P[0],P[1],P[2],1,-1,...R),m.emplaceBack(P[0],P[1],P[2],1,1,...R),m.emplaceBack(P[0],P[1],P[2],-1,1,...R),y.emplaceBack(v+0,v+1,v+2),y.emplaceBack(v+0,v+2,v+3),v+=4}this.particlesVx=o.createVertexBuffer(m,Nc.members),this.particlesIdx=o.createIndexBuffer(y)}}draw(i){if(!this._params.overrideStyleParameters&&!i.style.rain)return;const o=this._params.overrideStyleParameters?this._revealParams:{revealStart:0,revealRange:.01},d=i.transform.zoom;if(o.revealStart>d)return;const m=ma(0,1,o.revealStart,o.revealStart+o.revealRange,d);if(!this.particlesVx||!this.particlesIdx)return;const y=structuredClone(this._params);let v=[-y.direction.x,y.direction.y,-100];a.ay(v,v);const w=structuredClone(this._vignetteParams);w.strength*=m,y.overrideStyleParameters||(y.intensity=i.style.rain.state.density,y.timeFactor=i.style.rain.state.intensity,y.color=structuredClone(i.style.rain.state.color),v=structuredClone(i.style.rain.state.direction),y.screenThinning.intensity=i.style.rain.state.centerThinning,y.dropletSizeX=i.style.rain.state.dropletSize[0],y.dropletSizeYScale=i.style.rain.state.dropletSize[1]/i.style.rain.state.dropletSize[0],y.distortionStrength=100*i.style.rain.state.distortionStrength,w.strength=1,w.color=structuredClone(i.style.rain.state.vignetteColor));const E=this.updateOnRender(i,y.timeFactor),P=i.context,R=P.gl,O=i.transform;this.screenTexture&&this.screenTexture.size[0]===i.width&&this.screenTexture.size[1]===i.height||(this.screenTexture=new a.T(P,{width:i.width,height:i.height,data:null},R.RGBA8)),y.distortionStrength>0&&(P.activeTexture.set(R.TEXTURE0),this.screenTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE),R.copyTexSubImage2D(R.TEXTURE_2D,0,0,0,0,0,i.width,i.height));const k=i.getOrCreateProgram("rainParticle");i.uploadCommonUniforms(P,k),P.activeTexture.set(R.TEXTURE0),this.screenTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE);const N=[y.color.r,y.color.g,y.color.b,y.color.a],j=(U,X)=>{const W=Jd(this._movement.getPosition(),U),ie=y.dropletSizeX,ne=y.dropletSizeX*y.dropletSizeYScale,K=i.width/2,xe=i.height/2,le=ma(0,y.screenThinning.start,0,1,y.screenThinning.intensity),_e=ma(.001,y.screenThinning.range,0,1,y.screenThinning.intensity),re=ma(0,y.screenThinning.particleOffset,0,1,y.screenThinning.intensity),ae=(fe={modelview:E.modelviewMatrix,projection:E.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:W,velocityConeAperture:y.velocityConeAperture,velocity:y.velocity,boxSize:U,rainDropletSize:[ie,ne],distortionStrength:y.distortionStrength,rainDirection:v,color:N,screenSize:[O.width,O.height],thinningCenterPos:[K,xe],thinningShape:[le,_e,Math.pow(10,y.screenThinning.fadePower)],thinningAffectedRatio:y.screenThinning.affectedRatio,thinningParticleOffset:re,shapeDirectionalPower:y.shapeDirPower,shapeNormalPower:y.shapeNormalPower,mode:X?0:1},{u_modelview:Float32Array.from(fe.modelview),u_projection:Float32Array.from(fe.projection),u_time:fe.time,u_cam_pos:fe.camPos,u_texScreen:0,u_velocityConeAperture:fe.velocityConeAperture,u_velocity:fe.velocity,u_boxSize:fe.boxSize,u_rainDropletSize:fe.rainDropletSize,u_distortionStrength:fe.distortionStrength,u_rainDirection:fe.rainDirection,u_color:fe.color,u_screenSize:fe.screenSize,u_thinningCenterPos:fe.thinningCenterPos,u_thinningShape:fe.thinningShape,u_thinningAffectedRatio:fe.thinningAffectedRatio,u_thinningParticleOffset:fe.thinningParticleOffset,u_shapeDirectionalPower:fe.shapeDirectionalPower,u_shapeNormalPower:fe.shapeNormalPower,u_mode:fe.mode});var fe;const Ce=Math.round(y.intensity*this.particlesCount),ve=a.dy.simpleSegment(0,0,4*Ce,2*Ce);k.draw(i,R.TRIANGLES,At.disabled,Ht.disabled,jt.alphaBlended,Nt.disabled,ae,"rain_particles",this.particlesVx,this.particlesIdx,ve)};y.distortionStrength>0&&j(y.boxSize,!0),j(y.boxSize,!1),this._vignette.draw(i,w)}}const zl=a.e8([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]);class ex extends ch{constructor(i){super(2.25),this._params={overrideStyleParameters:!1,intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._revealParams=new Jy("Precipitation > Snow"),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(i){const o=i.context;if(!this.particlesVx){const d=Pm(this.particlesCount),m=new a.eF,y=new a.dC;let v=0;const w=a.em(1323123451230);for(let E=0;E<d.length;++E){const P=d[E],R=w(),O=w(),k=w(),N=[E/d.length,R,O,k],j=[w(),w()];m.emplaceBack(P[0],P[1],P[2],-1,-1,...N,...j),m.emplaceBack(P[0],P[1],P[2],1,-1,...N,...j),m.emplaceBack(P[0],P[1],P[2],1,1,...N,...j),m.emplaceBack(P[0],P[1],P[2],-1,1,...N,...j),y.emplaceBack(v+0,v+1,v+2),y.emplaceBack(v+0,v+2,v+3),v+=4}this.particlesVx=o.createVertexBuffer(m,zl.members),this.particlesIdx=o.createIndexBuffer(y)}}draw(i){if(!this._params.overrideStyleParameters&&!i.style.snow)return;const o=structuredClone(this._params);let d=[-o.direction.x,o.direction.y,-100];a.ay(d,d);const m=structuredClone(this._vignetteParams),y=o.overrideStyleParameters?this._revealParams:{revealStart:0,revealRange:.01},v=i.transform.zoom;if(y.revealStart>v)return;const w=ma(0,1,y.revealStart,y.revealStart+y.revealRange,v);m.strength*=w,o.overrideStyleParameters||(o.intensity=i.style.snow.state.density,o.timeFactor=i.style.snow.state.intensity,o.color=structuredClone(i.style.snow.state.color),d=structuredClone(i.style.snow.state.direction),o.screenThinning.intensity=i.style.snow.state.centerThinning,o.billboardSize=2.79*i.style.snow.state.flakeSize,m.strength=1,m.color=structuredClone(i.style.snow.state.vignetteColor));const E=this.updateOnRender(i,o.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const P=i.context,R=P.gl,O=i.transform,k=i.getOrCreateProgram("snowParticle");i.uploadCommonUniforms(P,k),((N,j,U)=>{const X=Jd(this._movement.getPosition(),N),W=O.width/2,ie=O.height/2,ne=ma(0,U.screenThinning.start,0,1,U.screenThinning.intensity),K=ma(.001,U.screenThinning.range,0,1,U.screenThinning.intensity),xe=ma(0,U.screenThinning.particleOffset,0,1,U.screenThinning.intensity),le=(_e={modelview:E.modelviewMatrix,projection:E.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:X,velocityConeAperture:U.velocityConeAperture,velocity:U.velocity,horizontalOscillationRadius:U.horizontalOscillationRadius,horizontalOscillationRate:U.horizontalOscillationRate,boxSize:N,billboardSize:1*U.billboardSize,simpleShapeParameters:[U.shapeFadeStart,U.shapeFadePower],screenSize:[O.width,O.height],thinningCenterPos:[W,ie],thinningShape:[ne,K,Math.pow(10,U.screenThinning.fadePower)],thinningAffectedRatio:U.screenThinning.affectedRatio,thinningParticleOffset:xe,color:[U.color.r,U.color.g,U.color.b,U.color.a],direction:d},{u_modelview:Float32Array.from(_e.modelview),u_projection:Float32Array.from(_e.projection),u_time:_e.time,u_cam_pos:_e.camPos,u_velocityConeAperture:_e.velocityConeAperture,u_velocity:_e.velocity,u_horizontalOscillationRadius:_e.horizontalOscillationRadius,u_horizontalOscillationRate:_e.horizontalOscillationRate,u_boxSize:_e.boxSize,u_billboardSize:_e.billboardSize,u_simpleShapeParameters:_e.simpleShapeParameters,u_screenSize:_e.screenSize,u_thinningCenterPos:_e.thinningCenterPos,u_thinningShape:_e.thinningShape,u_thinningAffectedRatio:_e.thinningAffectedRatio,u_thinningParticleOffset:_e.thinningParticleOffset,u_particleColor:_e.color,u_direction:_e.direction});var _e;const re=Math.round(U.intensity*this.particlesCount),ae=a.dy.simpleSegment(0,0,4*re,2*re);this.particlesVx&&this.particlesIdx&&k.draw(i,R.TRIANGLES,At.disabled,Ht.disabled,jt.alphaBlended,Nt.disabled,le,"snow_particles",this.particlesVx,this.particlesIdx,ae)})(o.boxSize,0,o),this._vignette.draw(i,m)}}const tx={symbol:function(u,i,o,d,m){if(u.renderPass!=="translucent")return;const y=Ht.disabled,v=u.colorModeForRenderPass(),w=o.layout.get("text-variable-anchor"),E=o.layout.get("text-size-scale-range"),P=a.aC(u.scaleFactor,E[0],E[1]);w&&function(k,N,j,U,X,W,ie,ne){const K=N.transform,xe=X==="map",le=W==="map";for(const _e of k){const re=U.getTile(_e),ae=re.getBucket(j);if(!ae||!ae.text||!ae.text.segments.get().length)continue;const fe=a.bj(ae.textSizeData,K.zoom,ne),Ce=xl(_e,ae.getProjection(),K),ve=K.calculatePixelsToTileUnitsMatrix(re),Ne=Ba(Ce,re.tileID.canonical,le,xe,K,ae.getProjection(),ve),ze=ae.hasIconTextFit()&&ae.hasIconData();fe&&By(ae,xe,le,ie,K,Ne,_e,Math.pow(2,K.zoom-re.tileID.overscaledZ),fe,ze)}}(d,u,o,i,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),m,P);const R=o.paint.get("icon-opacity").constantOr(1)!==0,O=o.paint.get("text-opacity").constantOr(1)!==0;o.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(R||O)?Vd(u,i,o,d,y,v):(R&&Vd(u,i,o,d,y,v,{onlyIcons:!0}),O&&Vd(u,i,o,d,y,v,{onlyText:!0})),i.map.showCollisionBoxes&&(wt(u,i,o,d,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),wt(u,i,o,d,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(u,i,o,d){if(u.renderPass!=="translucent")return;const m=o.paint.get("circle-opacity"),y=o.paint.get("circle-stroke-width"),v=o.paint.get("circle-stroke-opacity"),w=o.layout.get("circle-sort-key").constantOr(1)!==void 0,E=o.paint.get("circle-emissive-strength");if(m.constantOr(1)===0&&(y.constantOr(1)===0||v.constantOr(1)===0))return;const P=u.context,R=P.gl,O=u.transform,k=!(!u.terrain||!u.terrain.enabled),N=o.layout.get("circle-elevation-reference"),j=u.depthModeForSublayer(0,At.ReadOnly),U=new At(u.context.gl.LEQUAL,At.ReadOnly,u.depthRangeFor3D),X=N==="none"||k?j:U,W=Ht.disabled,ie=u.colorModeForDrapableLayerRenderPass(E),ne=O.projection.name==="globe",K=[a.aH(O.center.lng),a.aL(O.center.lat)],xe=[];for(let _e=0;_e<d.length;_e++){const re=d[_e],ae=i.getTile(re),fe=ae.getBucket(o);if(!fe||fe.projection.name!==O.projection.name)continue;const Ce=fe.programConfigurations.get(o.id),ve=fe.layoutVertexBuffer,Ne=fe.globeExtVertexBuffer,ze=fe.indexBuffer,Je=a.dS(o),tt=[Ne],Pe=u.isTileAffectedByFog(re);ne&&Je.push("PROJECTION_GLOBE_VIEW"),Je.push("DEPTH_D24"),u.terrain&&O.depthOcclusionForSymbolsAndCircles&&Je.push("DEPTH_OCCLUSION"),fe.hasElevation&&!u.terrain&&(Je.push("ELEVATED_ROADS"),tt.push(fe.elevatedLayoutVertexBuffer));const we=u.getOrCreateProgram("circle",{config:Ce,defines:Je,overrideFog:Pe}),Oe=O.projection.createInversionMatrix(O,re.canonical),Ue={programConfiguration:Ce,program:we,layoutVertexBuffer:ve,dynamicBuffers:tt,indexBuffer:ze,uniformValues:a.dT(u,re,ae,Oe,K,o),tile:ae};if(w){const $e=fe.segments.get();for(const ft of $e)xe.push({segments:new a.dy([ft]),sortKey:ft.sortKey,state:Ue})}else xe.push({segments:fe.segments,sortKey:0,state:Ue})}w&&xe.sort((_e,re)=>_e.sortKey-re.sortKey);const le={useDepthForOcclusion:O.depthOcclusionForSymbolsAndCircles};for(const _e of xe){const{programConfiguration:re,program:ae,layoutVertexBuffer:fe,dynamicBuffers:Ce,indexBuffer:ve,uniformValues:Ne,tile:ze}=_e.state,Je=_e.segments;u.terrain&&u.terrain.setupElevationDraw(ze,ae,le),u.uploadCommonUniforms(P,ae,ze.tileID.toUnwrapped()),ae.draw(u,R.TRIANGLES,X,W,ie,Nt.disabled,Ne,o.id,fe,ve,Je,o.paint,O.zoom,re,Ce)}},heatmap:function(u,i,o,d){if(o.paint.get("heatmap-opacity")!==0)if(u.renderPass==="offscreen"){const m=u.context,y=m.gl,v=Ht.disabled,w=new jt([y.ONE,y.ONE,y.ONE,y.ONE],a.aq.transparent,[!0,!0,!0,!0]),E=u.transform.projection.name==="globe"?.5:.25;o.heatmapFbo=rh.createWithTexture(m,o.heatmapFbo,u.width*E,u.height*E),m.clear({color:a.aq.transparent});const P=u.transform,R=P.projection.name==="globe",O=R?["PROJECTION_GLOBE_VIEW"]:[],k=R?Nt.frontCCW:Nt.disabled,N=[a.aH(P.center.lng),a.aL(P.center.lat)];for(let j=0;j<d.length;j++){const U=d[j];if(i.hasRenderableParent(U))continue;const X=i.getTile(U),W=X.getBucket(o);if(!W||W.projection.name!==P.projection.name)continue;const ie=u.isTileAffectedByFog(U),ne=W.programConfigurations.get(o.id),K=u.getOrCreateProgram("heatmap",{config:ne,defines:O,overrideFog:ie}),{zoom:xe}=u.transform;u.terrain&&u.terrain.setupElevationDraw(X,K),u.uploadCommonUniforms(m,K,U.toUnwrapped());const le=P.projection.createInversionMatrix(P,U.canonical);K.draw(u,y.TRIANGLES,At.disabled,v,w,k,Dy(u,U,X,le,N,xe,o.paint.get("heatmap-intensity")),o.id,W.layoutVertexBuffer,W.indexBuffer,W.segments,o.paint,u.transform.zoom,ne,R?[W.globeExtVertexBuffer]:null)}m.viewport.set([0,0,u.width,u.height])}else u.renderPass==="translucent"&&(u.context.setColorMode(u.colorModeForRenderPass()),function(m,y){const v=m.context,w=v.gl,E=y.heatmapFbo;if(!E)return;v.activeTexture.set(w.TEXTURE0),w.bindTexture(w.TEXTURE_2D,E.colorAttachment0.get()),v.activeTexture.set(w.TEXTURE1);let P=y.colorRampTexture;P||(P=y.colorRampTexture=new a.T(v,y.colorRamp,w.RGBA8)),P.bind(w.LINEAR,w.CLAMP_TO_EDGE),m.getOrCreateProgram("heatmapTexture").draw(m,w.TRIANGLES,At.disabled,Ht.disabled,m.colorModeForRenderPass(),Nt.disabled,((R,O)=>({u_image:0,u_color_ramp:1,u_opacity:O.paint.get("heatmap-opacity")}))(0,y),y.id,m.viewportBuffer,m.quadTriangleIndexBuffer,m.viewportSegments,y.paint,m.transform.zoom)}(u,o))},line:function(u,i,o,d){const m=o.paint.get("line-opacity"),y=o.paint.get("line-width");if(m.constantOr(1)===0||y.constantOr(1)===0)return;const v=o.paint.get("line-blend-mode");if(v!=="default"&&u.transform.projection.name!=="globe")return u.terrain&&u.terrain.renderingToTexture?void function(w,E,P,R,O){if(w.renderPass!=="translucent")return;const k=w.context,N=k.gl,j=w.terrain;if(!j)return;const U=k.bindFramebuffer.current,X=w.emissiveMode==="mrt-fallback";P.lineBlendDrapeFbo=rh.createWithTexture(k,P.lineBlendDrapeFbo,j.drapeBufferSize[0],j.drapeBufferSize[1],!0),P.lineBlendDrapeStencil=P.lineBlendDrapeFbo._stencilRbo,X&&N.drawBuffers([N.COLOR_ATTACHMENT0]),k.clear({color:da[O].clearColor,depth:1,stencil:0});const W=w.currentStencilSource,ie=w._tileClippingMaskIDs,ne=w.nextStencilID;w.currentStencilSource=void 0,w._tileClippingMaskIDs={},w.nextStencilID=1;const K=w._terrain;w._terrain=null,w._renderTileClippingMasks(P,E,R),jd(w,E,P,R,da[O].colorMode,!0),w._terrain=K,w.currentStencilSource=W,w._tileClippingMaskIDs=ie,w.nextStencilID=ne,k.bindFramebuffer.set(U),X&&N.drawBuffers([N.COLOR_ATTACHMENT0,N.COLOR_ATTACHMENT1]);const xe=j.drapeBufferSize;k.viewport.set([0,0,xe[0],xe[1]]);const le=P.lineBlendDrapeFbo;if(!le)return;k.activeTexture.set(N.TEXTURE0),N.bindTexture(N.TEXTURE_2D,le.colorAttachment0.get());const _e=O==="additive"?1:P.paint.get("line-opacity").constantOr(1),re=P.paint.get("line-emissive-strength").constantOr(0),ae=O==="additive"?w.colorModeForDrapableLayerRenderPass(re):da[O].colorMode;w.getOrCreateProgram("lineBlendComposite").draw(w,N.TRIANGLES,At.disabled,Ht.disabled,ae,Nt.disabled,Ld(0,_e,da[O].compositeUniformValue),P.id,w.viewportBuffer,w.quadTriangleIndexBuffer,w.viewportSegments,P.paint,w.transform.zoom)}(u,i,o,d,v):u.renderPass==="offscreen"?void function(w,E,P,R,O){const k=w.context,N=Math.ceil(w.width),j=Math.ceil(w.height);P.lineBlendFbo=rh.createWithTexture(k,P.lineBlendFbo,N,j,!0),P.lineBlendStencil=P.lineBlendFbo._stencilRbo,k.clear({color:da[O].clearColor,depth:1,stencil:0});const U=w.currentStencilSource,X=w._tileClippingMaskIDs,W=w.nextStencilID;w.currentStencilSource=void 0,w._tileClippingMaskIDs={},w.nextStencilID=1,w._renderTileClippingMasks(P,E,R);const ie=w.renderPass;w.renderPass="translucent",jd(w,E,P,R,da[O].colorMode),w.renderPass=ie,w.currentStencilSource=U,w._tileClippingMaskIDs=X,w.nextStencilID=W,k.viewport.set([0,0,w.width,w.height])}(u,i,o,d,v):u.renderPass==="translucent"?void function(w,E,P){const R=w.context,O=R.gl,k=E.lineBlendFbo;if(!k)return;R.activeTexture.set(O.TEXTURE0),O.bindTexture(O.TEXTURE_2D,k.colorAttachment0.get());const N=P==="additive"?1:E.paint.get("line-opacity").constantOr(1),j=P==="additive"?w.colorModeForDrapableLayerRenderPass(E.paint.get("line-emissive-strength").constantOr(0)):da[P].colorMode;w.getOrCreateProgram("lineBlendComposite").draw(w,O.TRIANGLES,At.disabled,Ht.disabled,j,Nt.disabled,Ld(0,N,da[P].compositeUniformValue),E.id,w.viewportBuffer,w.quadTriangleIndexBuffer,w.viewportSegments,E.paint,w.transform.zoom)}(u,o,v):void 0;u.renderPass==="translucent"&&jd(u,i,o,d)},fill:function(u,i,o,d){const m=o.paint.get("fill-color"),y=o.paint.get("fill-opacity");if(y.constantOr(1)===0)return;const v=o.paint.get("fill-emissive-strength"),w=u.colorModeForDrapableLayerRenderPass(v),E=o.paint.get("fill-pattern"),P=u.opaquePassEnabledForLayer()&&!E.constantOr(1)&&m.constantOr(a.aq.transparent).a===1&&y.constantOr(0)===1?"opaque":"translucent";let R="none";o.layout.get("fill-elevation-reference")!=="none"?R="road":o.paint.get("fill-z-offset").constantOr(1)!==0&&(R="offset");const O=!(!u.terrain||!u.terrain.enabled),k={painter:u,sourceCache:i,layer:o,coords:d,colorMode:w,elevationType:R,terrainEnabled:O,pass:P};if(u.renderPass==="shadow")return void(u.shadowRenderer&&R==="road"&&!O&&function(j){const{painter:U,sourceCache:X,layer:W,coords:ie}=j,ne=U.context.gl,K=j.painter.shadowRenderer;for(const xe of ie){const le=X.getTile(xe),_e=le.getBucket(W);if(!_e)continue;const re=_e.elevatedStructures;if(!re||!re.shadowCasterSegments||re.shadowCasterSegments.segments[0].primitiveLength===0)continue;U.prepareDrawTile();const ae=_e.bufferData.programConfigurations.get(W.id),fe=U.isTileAffectedByFog(xe),Ce=U.getOrCreateProgram("elevatedStructuresDepth",{config:ae,overrideFog:fe}),ve=K.calculateShadowPassMatrixFromTile(le.tileID.toUnwrapped());U.uploadCommonUniforms(U.context,Ce,xe.toUnwrapped());const Ne=Py(ve,0);Ce.draw(U,ne.TRIANGLES,K.getShadowPassDepthMode(),Ht.disabled,jt.disabled,Nt.disabled,Ne,W.id,re.vertexBuffer,re.indexBuffer,re.shadowCasterSegments,W.paint,U.transform.zoom,ae)}}(k));const N=u.emissiveMode==="mrt-fallback";if(R!=="offset"){if(ah(k,!1,N),R==="road"){const j=!O&&u.renderPass==="translucent";j&&oh(u,i,o,d,"geometry"),ah(k,!0,N,Ht.disabled),j&&function(U){const{painter:X,sourceCache:W,layer:ie,coords:ne,colorMode:K}=U,xe=X.context.gl,le=U.painter.shadowRenderer,_e=!!le&&le.enabled,re=new At(X.context.gl.LEQUAL,At.ReadOnly,X.depthRangeFor3D);let ae=[0,0,0];if(_e){const Ce=X.style.directionalLight,ve=X.style.ambientLight;Ce&&ve&&(ae=mo(X.style,Ce,ve))}const fe=Ce=>{for(const ve of ne){const Ne=W.getTile(ve),ze=Ne.getBucket(ie);if(!ze)continue;const Je=ze.elevatedStructures;if(!Je)continue;let tt,Pe;if(Ce?(tt=Je.renderableBridgeSegments,Pe=Je.bridgeProgramConfigurations.get(ie.id)):(tt=Je.renderableTunnelSegments,Pe=Je.tunnelProgramConfigurations.get(ie.id)),!tt||tt.segments[0].primitiveLength===0)continue;Pe.updatePaintBuffers(),X.prepareDrawTile();const we=X.isTileAffectedByFog(ve),Oe=[];_e&&Oe.push("RENDER_SHADOWS","NORMAL_OFFSET");const Ue=X.getOrCreateProgram("elevatedStructures",{config:Pe,overrideFog:we,defines:Oe}),$e=X.translatePosMatrix(ve.projMatrix,Ne,ie.paint.get("fill-translate"),ie.paint.get("fill-translate-anchor"));_e&&le.setupShadows(Ne.tileID.toUnwrapped(),Ue,"vector-tile");const ft=My($e,ae);X.uploadCommonUniforms(X.context,Ue,ve.toUnwrapped()),Ue.draw(X,xe.TRIANGLES,re,Ht.disabled,K,Nt.backCCW,ft,ie.id,Je.vertexBuffer,Je.indexBuffer,tt,ie.paint,X.transform.zoom,Pe,[Je.vertexBufferNormal])}};fe(!0),fe(!1)}(k)}}else ah(k,!1,N,u.stencilModeFor3D())},"fill-extrusion":function(u,i,o,d){const m=o.paint.get("fill-extrusion-opacity"),y=u.context,v=y.gl,w=u.terrain,E=w&&w.renderingToTexture;if(m===0)return;const P=u.emissiveMode==="mrt-fallback",R=u.conflationActive&&u.style.isLayerClipped(o,i.getSource()),O=u.style.order.indexOf(o.fqid);if(R&&function(k,N,j,U,X){for(const W of U){const ie=N.getTile(W).getBucket(j);ie&&(ie.updateReplacement(W,k.replacementSource,X),ie.uploadCentroid(k.context))}}(u,i,o,d,O),w||R)for(const k of d){const N=i.getTile(k).getBucket(o);N&&Ny(u.context,i,k,N,o,w,R)}if(u.renderPass==="shadow"&&u.shadowRenderer){if(w&&m<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof a.af)return;const k=u.shadowRenderer.getShadowPassDepthMode();Rl(u,i,o,d,k,Ht.disabled,jt.disabled,R)}else if(u.renderPass==="translucent"){const k=!o.paint.get("fill-extrusion-pattern").constantOr(1),N=o.paint.get("fill-extrusion-color").constantOr(a.aq.white);if(!E&&N.a!==0){const j=new At(u.context.gl.LEQUAL,At.ReadWrite,u.depthRangeFor3D);m===1&&k?Rl(u,i,o,d,j,Ht.disabled,jt.unblended,R):(Rl(u,i,o,d,j,Ht.disabled,jt.disabled,R),Rl(u,i,o,d,j,u.stencilModeFor3D(),u.colorModeForRenderPass(),R),u.resetStencilClippingMasks())}if(u.style.enable3dLights()&&k&&(!w&&u.transform.projection.name!=="globe"||E)){const j=o.paint.get("fill-extrusion-opacity"),U=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),X=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),W=o.paint.get("fill-extrusion-flood-light-intensity"),ie=o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",ne=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(ie?null:o.lut).toArray01().slice(0,3),K=U>0&&X>0,xe=W>0,le=(ae,fe,Ce)=>(1-Ce)*ae+Ce*fe,_e=new dm;_e.translate=o.paint.get("fill-extrusion-translate"),_e.translateAnchor=o.paint.get("fill-extrusion-translate-anchor"),_e.edgeRadius=o.layout.get("fill-extrusion-edge-radius"),_e.cutoffFadeRange=o.paint.get("fill-extrusion-cutoff-fade-range");const re=ae=>{const fe=u.depthModeForSublayer(1,At.ReadOnly,v.LEQUAL,!0),Ce=o.paint.get(ae?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),ve=le(.1,3,Ce),Ne=u._showOverdrawInspector;if(!Ne){const ze=new Ht({func:v.ALWAYS,mask:255},255,255,v.KEEP,v.KEEP,v.REPLACE),Je=new jt([v.ONE,v.ONE,v.ONE,v.ONE],a.aq.transparent,[!1,!1,!1,!0],v.MIN);Uo(_e,u,i,o,d,fe,ze,Je,Nt.disabled,ae,"sdf",j,U,X,W,ne,ve,R,!1)}{const ze=Ne?Ht.disabled:new Ht({func:v.EQUAL,mask:255},255,255,v.KEEP,v.DECR,v.DECR),Je=Ne?u.colorModeForRenderPass():new jt([v.ONE_MINUS_DST_ALPHA,v.DST_ALPHA,v.ONE,v.ONE],a.aq.transparent,[!0,!0,!0,!0]);Uo(_e,u,i,o,d,fe,ze,Je,Nt.disabled,ae,"color",j,U,X,W,ne,ve,R,!1)}};if(E){const ae=()=>{const Ce=w.drapeBufferSize[0],ve=w.drapeBufferSize[1];let Ne=w.framebufferCopyTexture;return Ne&&(!Ne||Ne.size[0]===Ce&&Ne.size[1]===ve)||(Ne&&Ne.destroy(),Ne=w.framebufferCopyTexture=new a.T(y,new a.q({width:Ce,height:ve}),v.RGBA8)),Ne.bind(v.LINEAR,v.CLAMP_TO_EDGE),v.copyTexSubImage2D(v.TEXTURE_2D,0,0,0,0,0,Ce,ve),Ne},fe=(Ce,ve,Ne)=>{const ze=u.depthModeForSublayer(1,At.ReadOnly,v.LEQUAL,!1),Je=o.paint.get(Ce?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),tt=le(.1,3,Je);{const Pe=new jt([v.ONE,v.ONE,v.ONE,v.ONE],a.aq.transparent,[!1,!1,!1,!0]);Uo(_e,u,i,o,d,ze,Ht.disabled,Pe,Nt.disabled,Ce,"clear",j,U,X,W,ne,tt,R,ve)}{const Pe=new Ht({func:v.ALWAYS,mask:255},255,255,v.KEEP,v.KEEP,v.REPLACE),we=new jt([v.ONE,v.ONE,v.ONE,v.ONE],a.aq.transparent,[!1,!1,!1,!0],v.MIN);Uo(_e,u,i,o,d,ze,Pe,we,Nt.disabled,Ce,"sdf",j,U,X,W,ne,tt,R,ve)}P&&!Ce&&(Ne=ae());{const Pe=Ce?v.ZERO:v.ONE_MINUS_DST_ALPHA,we=new Ht({func:v.EQUAL,mask:255},255,255,v.KEEP,v.DECR,v.DECR),Oe=new jt([Pe,v.DST_ALPHA,v.ONE_MINUS_DST_ALPHA,v.ZERO],a.aq.transparent,[!0,!0,!0,!0]);Uo(_e,u,i,o,d,ze,we,Oe,Nt.disabled,Ce,"color",j,U,X,W,ne,tt,R,ve)}if(!P||Ce){const Pe=new jt([v.ONE,v.ONE,v.ONE,Ce?v.ZERO:v.ONE],a.aq.transparent,[!1,!1,!1,!0],Ce?v.FUNC_ADD:v.MAX);Uo(_e,u,i,o,d,ze,Ht.disabled,Pe,Nt.disabled,Ce,"clear",j,U,X,W,ne,tt,R,ve,Ne)}else{v.drawBuffers([v.NONE,v.COLOR_ATTACHMENT1]);const Pe=new Ht({func:v.EQUAL,mask:255},254,255,v.KEEP,v.DECR,v.DECR),we=new jt([v.ONE,v.ONE,v.ONE,v.ONE],a.aq.transparent,[!0,!1,!1,!1],v.MAX);Uo(_e,u,i,o,d,ze,Pe,we,Nt.disabled,Ce,"emissive",j,U,X,W,ne,tt,R,ve,Ne),v.drawBuffers([v.COLOR_ATTACHMENT0])}};if(K||xe){let Ce;u.prepareDrawTile(),P&&!K||(Ce=ae()),K&&fe(!0,!1,Ce),xe&&fe(!1,!0,Ce)}}else K&&re(!0),xe&&re(!1),(K||xe)&&u.resetStencilClippingMasks()}}},building:function(u,i,o,d){u.currentLayer<u.firstLightBeamLayer&&(u.firstLightBeamLayer=u.currentLayer);const m=o.paint.get("building-ambient-occlusion-ground-intensity"),y=o.paint.get("building-ambient-occlusion-ground-radius"),v=o.paint.get("building-ambient-occlusion-ground-attenuation"),w=o.paint.get("building-opacity");if(w<=0)return;let E=m>0&&y>0,P=!0;const R=o.paint.get("building-vertical-scale");if(R<=0)return;u.shadowRenderer||(P=!1);const O=u.conflationActive&&u.style.isLayerClipped(o,i.getSource()),k=u.style.order.indexOf(o.fqid);if(function(N,j,U,X,W,ie){for(const ne of ie){const K=j.getTile(ne).getBucket(U);K&&(W&&K.updateReplacement(ne,N.replacementSource,X),K.uploadUpdatedIndexBuffer(N.context))}}(u,i,o,k,O,d),function(N,j,U,X){for(const W of X){const ie=j.getTile(W).getBucket(U);ie&&ie.needsEvaluation()&&ie.uploadUpdatedColorBuffer(N.context)}}(u,i,o,d),o.resetLayerRenderingStats(u),u.shadowRenderer&&(u.shadowRenderer.useNormalOffset=!0),u.renderPass==="shadow"&&u.shadowRenderer){const N=[],j=u.shadowRenderer.getShadowPassDepthMode();lh({painter:u,source:i,layer:o,coords:d,defines:N,blendMode:jt.disabled,depthMode:j,opacity:w,verticalScale:R,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(u.renderPass==="translucent"){let N=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];P&&(N=N.concat("RENDER_SHADOWS")),u.shadowRenderer&&u.shadowRenderer.useNormalOffset&&(N=N.concat("NORMAL_OFFSET"));const j=o.paint.get("building-facade-emissive-chance"),U=o.paint.get("building-ambient-occlusion-intensity"),X=o.paint.get("building-flood-light-intensity"),W=o.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",ie=o.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(W?null:o.lut).toArray01().slice(0,3),ne=o.paint.get("building-flood-light-ground-attenuation"),K=X>0,xe=new At(u.context.gl.LEQUAL,At.ReadWrite,u.depthRangeFor3D);w<1&&lh({painter:u,source:i,layer:o,coords:d,defines:N,blendMode:jt.disabled,depthMode:xe,opacity:w,verticalScale:R,facadeEmissiveChance:j,facadeAOIntensity:U,floodLightIntensity:X,floodLightColor:ie,depthOnly:!0});const le=u.colorModeForRenderPass();lh({painter:u,source:i,layer:o,coords:d,defines:N,blendMode:le,depthMode:xe,opacity:w,verticalScale:R,facadeEmissiveChance:j,facadeAOIntensity:U,floodLightIntensity:X,floodLightColor:ie});const _e=o.paint.get("building-front-cutoff");Gd(u.transform.pitch,_e,!!u.terrain),E&&pm(u,i,o,d,!0,w,m,y,X,ie,v,O),K&&pm(u,i,o,d,!1,w,m,y,X,ie,ne,O)}else if(u.renderPass==="light-beam"){const N=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],j=new At(u.context.gl.LEQUAL,At.ReadOnly,u.depthRangeFor3D);lh({painter:u,source:i,layer:o,coords:d,defines:N,blendMode:jt.alphaBlended,depthMode:j,opacity:w,verticalScale:R,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}u.shadowRenderer&&(u.shadowRenderer.useNormalOffset=!1),u.resetStencilClippingMasks()},hillshade:function(u,i,o,d){if(u.renderPass!=="offscreen"&&u.renderPass!=="translucent"||u.style.disableElevatedTerrain)return;const m=u.context,y=u.terrain&&u.terrain.renderingToTexture,[v,w]=u.renderPass!=="translucent"||y?[{},d]:u.stencilConfigForOverlap(d);for(const E of w){const P=i.getTile(E);if(P.needsHillshadePrepare&&u.renderPass==="offscreen")x1(u,P,o);else if(u.renderPass==="translucent"){const R=u.depthModeForSublayer(0,At.ReadOnly),O=o.paint.get("hillshade-emissive-strength"),k=u.colorModeForDrapableLayerRenderPass(O),N=y&&u.terrain?u.terrain.stencilModeForRTTOverlap(E):v[E.overscaledZ];y1(u,E,P,o,R,N,k)}}m.viewport.set([0,0,u.width,u.height]),u.resetStencilClippingMasks()},raster:function(u,i,o,d,m,y){if(u.renderPass!=="translucent")return;const v=o.paint.get("raster-opacity");if(v===0)return;const w=u.transform.projection.name==="globe",E=o.paint.get("raster-elevation")!==0,P=E&&w,R=u.terrain&&u.terrain.exaggeration()>0&&E&&o.paint.get("raster-elevation-reference")==="ground",O=!w&&R;if(u.renderElevatedRasterBackface&&!P)return;const k=u.context,N=k.gl,j=i.getSource(),U=function(ae,fe,Ce,ve,Ne){const ze=fe.paint.get("raster-color"),Je=ae.type==="raster-array",tt=[],Pe=fe.paint.get("raster-resampling"),we=fe.paint.get("raster-color-mix");let Oe=fe.paint.get("raster-color-range");const Ue=[we[0],we[1],we[2],0],$e=we[3];let ft=Pe==="nearest"?ve.NEAREST:ve.LINEAR;if(Je&&(tt.push("RASTER_ARRAY"),ze||tt.push("RASTER_COLOR"),Pe==="linear"&&tt.push("RASTER_ARRAY_LINEAR"),ft=ve.NEAREST,!Oe&&ae.rasterLayers)){const lt=ae.rasterLayers.find(({id:ct})=>ct===fe.sourceLayer);lt&&lt.fields&&lt.fields.range&&(Oe=lt.fields.range)}if(Oe=Oe||[0,1],ze){tt.push("RASTER_COLOR"),Ce.activeTexture.set(ve.TEXTURE2),fe.updateColorRamp(Oe);let lt=fe.colorRampTexture;lt||(lt=fe.colorRampTexture=new a.T(Ce,fe.colorRamp,ve.RGBA8)),lt.bind(ft,ve.CLAMP_TO_EDGE)}return Ne&&tt.push("USE_MRT1"),{mix:Ue,range:Oe,offset:$e,defines:tt,resampling:ft}}(j,o,k,N,u.terrain&&u.terrain.renderingToTexture&&u.emissiveMode==="mrt-fallback");if(j instanceof a.aV&&!d.length&&!w)return;const X=o.paint.get("raster-emissive-strength"),W=u.colorModeForDrapableLayerRenderPass(X),ie=u.terrain&&u.terrain.renderingToTexture,ne=!u.options.moving,K=o.paint.get("raster-resampling")==="nearest"?N.NEAREST:N.LINEAR;if(j instanceof a.aV&&!d.length&&(j.onNorthPole||j.onSouthPole)){const ae=E?u.stencilModeFor3D():Ht.disabled;return void Hd(!!j.onNorthPole,null,u,i,o,X,U,Nt.disabled,ae)}if(!d.length)return;const[xe,le]=j instanceof a.aV||ie?[{},d]:u.stencilConfigForOverlap(d),_e=le[le.length-1].overscaledZ;P&&U.defines.push("PROJECTION_GLOBE_VIEW"),E&&U.defines.push("RENDER_CUTOFF","ELEVATED"),R&&U.defines.push("ELEVATION_REFERENCE_GROUND");const re=(ae,fe,Ce)=>{for(const ve of ae){const Ne=ve.toUnwrapped(),ze=i.getTile(ve);if(ie&&(!ze||!ze.hasData()))continue;k.activeTexture.set(N.TEXTURE0);const Je=jy(ze,j,o,U);if(!Je||!Je.texture)continue;const{texture:tt,mix:Pe,offset:we,tileSize:Oe,buffer:Ue}=Je;let $e,ft;ie?($e=At.disabled,ft=ve.projMatrix):E?($e=new At(N.LEQUAL,At.ReadWrite,u.depthRangeFor3D),ft=w?Float32Array.from(u.transform.expandedFarZProjMatrix):u.transform.calculateProjMatrix(Ne,ne)):($e=u.depthModeForSublayer(ve.overscaledZ-_e,v===1?At.ReadWrite:At.ReadOnly,N.LESS),ft=u.transform.calculateProjMatrix(Ne,ne));const lt=u.terrain&&ie?u.terrain.stencilModeForRTTOverlap(ve):xe[ve.overscaledZ],ct=y?0:o.paint.get("raster-fade-duration");ze.registerFadeDuration(ct);const et=i.findLoadedParent(ve,0),Et=Qu(ze,et,i,u.transform,ct);let Mt,vt;!Et.isFading&&ze.refreshedUponExpiration&&(ze.refreshedUponExpiration=!1),u.terrain&&u.terrain.prepareDrawTile(),k.activeTexture.set(N.TEXTURE0),tt.bind(K,N.CLAMP_TO_EDGE),k.activeTexture.set(N.TEXTURE1),et?(et.texture&&et.texture.bind(K,N.CLAMP_TO_EDGE),Mt=Math.pow(2,et.tileID.overscaledZ-ze.tileID.overscaledZ),vt=[ze.tileID.canonical.x*Mt%1,ze.tileID.canonical.y*Mt%1]):tt.bind(K,N.CLAMP_TO_EDGE),"useMipmap"in tt&&k.extTextureFilterAnisotropic&&u.transform.pitch>20&&N.texParameterf(N.TEXTURE_2D,k.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,k.extTextureFilterAnisotropicMax);const St=u.transform;let Vt;const Yt=E?_m(St):[0,0,0,0];let Zt,si,Ft,oi,qt,Ti=0;if(P&&j instanceof a.aV&&j.coordinates.length>3)Zt=Float32Array.from(a.du(a.dv(new a.cn(0,0,0)))),si=Float32Array.from(St.globeMatrix),Ft=Float32Array.from(a.dq(St)),oi=[a.aH(St.center.lng),a.aL(St.center.lat)],Vt=j.elevatedGlobePerspectiveTransform,qt=j.elevatedGlobeGridMatrix||new Float32Array(9);else if(P){const Ci=a.dr(ve.canonical);Ti=a.ds(Ci.getCenter().lat),Zt=Float32Array.from(a.du(a.dv(ve.canonical))),si=Float32Array.from(St.globeMatrix),Ft=Float32Array.from(a.dq(St)),oi=[a.aH(St.center.lng),a.aL(St.center.lat)],Vt=[0,0],qt=Float32Array.from(a.dt(ve.canonical,Ci,Ti,St.worldSize/St._pixelsPerMercatorPixel))}else Vt=j instanceof a.aV?j.perspectiveTransform:[0,0],Zt=new Float32Array(16),si=new Float32Array(9),Ft=new Float32Array(16),oi=[0,0],qt=new Float32Array(9);const Vi=Ly(u,ft,Zt,si,Ft,qt,vt||[0,0],a.al(u.transform.zoom),oi,Yt,Mt||1,Et,o,Vt,E?o.paint.get("raster-elevation"):0,2,Pe,we,U.range,Oe,Ue,X),nn=u.isTileAffectedByFog(ve),Hi=u.getOrCreateProgram("raster",{defines:U.defines,overrideFog:nn});if(u.uploadCommonUniforms(k,Hi,Ne),j instanceof a.aV){const Ci=j.elevatedGlobeVertexBuffer,ni=j.elevatedGlobeIndexBuffer;if(ie||!w)j.boundsBuffer&&j.boundsSegments&&Hi.draw(u,N.TRIANGLES,$e,Ht.disabled,W,Nt.disabled,Vi,o.id,j.boundsBuffer,u.quadTriangleIndexBuffer,j.boundsSegments);else if(Ci&&ni){const ri=St.zoom<=a.cJ?j.elevatedGlobeSegments:j.getSegmentsForLongitude(St.center.lng);ri&&Hi.draw(u,N.TRIANGLES,$e,Ht.disabled,W,fe,Vi,o.id,Ci,ni,ri)}}else if(P){$e=new At(N.LEQUAL,At.ReadOnly,u.depthRangeFor3D);const Ci=u.globeSharedBuffers;if(Ci){R&&(u.terrain.setupElevationDraw(ze,Hi),u.uploadCommonUniforms(k,Hi,ze.tileID.toUnwrapped()));const[ni,ri,Zi]=Ci.getGridBuffers(Ti,!1),an=Hi.getAttributeLocation(N,"a_texture_pos");an!==-1&&N.vertexAttribI4ui(an,0,0,0,0),Hi.draw(u,N.TRIANGLES,$e,Ce||lt,u.colorModeForRenderPass(),fe,Vi,o.id,ni,ri,Zi)}}else if(O)$e=new At(N.LEQUAL,At.ReadWrite,u.depthRangeFor3D),u.terrain.setupElevationDraw(ze,Hi),u.uploadCommonUniforms(k,Hi,ze.tileID.toUnwrapped()),St.pitch>20&&Hi.draw(u,N.TRIANGLES,$e,Ht.disabled,jt.disabled,Nt.frontCCW,Vi,o.id,u.terrain.gridBuffer,u.terrain.gridIndexBuffer,u.terrain.gridSegments),Hi.draw(u,N.TRIANGLES,$e,lt,W,Nt.backCCW,Vi,o.id,u.terrain.gridBuffer,u.terrain.gridIndexBuffer,u.terrain.gridSegments);else{const{tileBoundsBuffer:Ci,tileBoundsIndexBuffer:ni,tileBoundsSegments:ri}=u.getTileBoundsBuffers(ze);Hi.draw(u,N.TRIANGLES,$e,lt,W,Nt.disabled,Vi,o.id,Ci,ni,ri)}}if(!(j instanceof a.aV)&&P)for(const ve of ae){const Ne=ve.canonical.y===(1<<ve.canonical.z)-1;ve.canonical.y===0&&Hd(!0,ve,u,i,o,X,U,fe,Ce||Ht.disabled),Ne&&Hd(!1,ve,u,i,o,X,U,fe===Nt.frontCW?Nt.backCW:Nt.frontCW,Ce||Ht.disabled)}};P?re(le,u.renderElevatedRasterBackface?Nt.backCW:Nt.frontCW,u.stencilModeFor3D()):re(le,Nt.disabled,void 0),u.resetStencilClippingMasks()},"raster-particle":function(u,i,o,d,m,y){u.renderPass==="offscreen"&&function(v,w,E,P){if(!P.length)return;const R=v.context,O=R.gl,k=w.getSource();if(!(k instanceof gl))return;const N=Math.ceil(Math.sqrt(E.paint.get("raster-particle-count")));let j=E.particlePositionRGBAImage;if(!j||j.width!==N){const ne=function(K){const xe=K*K,le=new Uint8Array(4*xe),_e=.9090909090909091;for(let re=0;re<xe;re++){const ae=_e*(a.eb(2*re+0)+Vo),fe=_e*(a.eb(2*re+1)+Vo),Ce=255*ae%1,ve=255*fe%1,Ne=Ce,ze=fe-ve/255,Je=ve;le[4*re+0]=255*(ae-Ce/255),le[4*re+1]=255*Ne,le[4*re+2]=255*ze,le[4*re+3]=255*Je}return le}(N);j=E.particlePositionRGBAImage=new a.q({width:N,height:N},ne)}let U=E.particleFramebuffer;U?U.width!==N&&(U.destroy(),U=E.particleFramebuffer=R.createFramebuffer(N,N,1,null)):U=E.particleFramebuffer=R.createFramebuffer(N,N,1,null);const X=[];for(const ne of P){const K=w.getTile(ne);if(!(K instanceof yl))continue;const xe=ym(K,k,E);if(!xe)continue;const le=[K.tileSize,K.tileSize];let _e=E.tileFramebuffer;_e||(_e=E.tileFramebuffer=R.createFramebuffer(le[0],le[1],1,null));let re=K.rasterParticleState;re||(re=K.rasterParticleState=new Gy(R,ne,le,j));const ae=re.update(E.lastInvalidatedAt);re.particleTextureDimension!==N&&re.updateParticleTexture(ne,j);const fe=re.targetColorTexture;re.targetColorTexture=re.backgroundColorTexture,re.backgroundColorTexture=fe;const Ce=re.particleTexture0;re.particleTexture0=re.particleTexture1,re.particleTexture1=Ce,X.push([ne,xe,re,ae])}if(X.length===0)return;const W=a.o.now(),ie=E.previousDrawTimestamp?.001*(W-E.previousDrawTimestamp):.0167;if(E.previousDrawTimestamp=W,E.hasColorMap()){R.activeTexture.set(O.TEXTURE0+2);let ne=E.colorRampTexture;ne||(ne=E.colorRampTexture=new a.T(R,E.colorRamp,O.RGBA8)),ne.bind(O.LINEAR,O.CLAMP_TO_EDGE)}R.bindFramebuffer.set(E.tileFramebuffer.framebuffer),function(ne,K,xe){const le=ne.context,_e=le.gl,re=K.tileFramebuffer;le.activeTexture.set(_e.TEXTURE0);const ae={u_texture:0,u_opacity:1.05*(Ce=K.paint.get("raster-particle-fade-opacity-factor"))/(Ce+.05)},fe=ne.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var Ce;for(const ve of xe){const[,,Ne,ze]=ve;re.colorAttachment0.set(Ne.targetColorTexture.texture),le.viewport.set([0,0,re.width,re.height]),le.clear({color:a.aq.transparent}),ze&&(Ne.backgroundColorTexture.bind(_e.NEAREST,_e.CLAMP_TO_EDGE),fe.draw(ne,_e.TRIANGLES,At.disabled,Ht.disabled,jt.alphaBlended,Nt.disabled,ae,K.id,ne.viewportBuffer,ne.quadTriangleIndexBuffer,ne.viewportSegments))}}(v,E,X),function(ne,K,xe,le){const _e=ne.context,re=_e.gl,ae=xe.tileFramebuffer,fe=ne.transform.projection.name==="globe",Ce=xe.paint.get("raster-particle-max-speed");for(const ve of le){const[Ne,ze,Je]=ve;_e.activeTexture.set(re.TEXTURE0+0),ze.texture.bind(re.LINEAR,re.CLAMP_TO_EDGE),ae.colorAttachment0.set(Je.targetColorTexture.texture);const tt=ne.getOrCreateProgram("rasterParticleDraw",{defines:ze.defines,overrideFog:!1});_e.activeTexture.set(re.TEXTURE0+1);const Pe=ze.scalarData?[]:[0,1,2,3].map(Ue=>a.d$[Ue](Ne));Pe.push(Ne);const we=Ne.canonical.x,Oe=Ne.canonical.y;for(const Ue of Pe){const $e=K.getTile(fe?Ue.wrapped():Ue);if(!$e)continue;const ft=$e.rasterParticleState;if(!ft)continue;const lt=Ue.canonical.x+(1<<Ue.canonical.z)*(Ue.wrap-Ne.wrap),ct=Ue.canonical.y;ft.particleTexture0.bind(re.NEAREST,re.CLAMP_TO_EDGE);const et=M1(1,ft.particleTexture0.size[0],[lt-we,ct-Oe],0,ze.texture.size,2,Ce,ze.textureOffset,ze.scale,ze.offset);tt.draw(ne,re.POINTS,At.disabled,Ht.disabled,jt.alphaBlended,Nt.disabled,et,xe.id,ft.particleIndexBuffer,void 0,ft.particleSegment)}}}(v,w,E,X),R.bindFramebuffer.set(E.particleFramebuffer.framebuffer),function(ne,K,xe,le){const _e=ne.context,re=_e.gl,ae=K.paint.get("raster-particle-max-speed"),fe=le*K.paint.get("raster-particle-speed-factor")*.15,Ce=function(Ne){return Math.pow(Ne,6)}(.01+1*K.paint.get("raster-particle-reset-rate-factor")),ve=K.particleFramebuffer;_e.viewport.set([0,0,ve.width,ve.height]);for(const Ne of xe){const[,ze,Je]=Ne;_e.activeTexture.set(re.TEXTURE0+0),ze.texture.bind(re.LINEAR,re.CLAMP_TO_EDGE),_e.activeTexture.set(re.TEXTURE0+1);const tt=Je.particleTexture0;tt.bind(re.NEAREST,re.CLAMP_TO_EDGE);const Pe=ky(1,tt.size[0],0,ze.texture.size,ae,fe,Ce,ze.textureOffset,ze.scale,ze.offset);ve.colorAttachment0.set(Je.particleTexture1.texture),_e.clear({color:a.aq.transparent}),ne.getOrCreateProgram("rasterParticleUpdate",{defines:ze.defines}).draw(ne,re.TRIANGLES,At.disabled,Ht.disabled,jt.unblended,Nt.disabled,Pe,K.id,ne.viewportBuffer,ne.quadTriangleIndexBuffer,ne.viewportSegments)}}(v,E,X,ie)}(u,i,o,d),u.renderPass==="translucent"&&(function(v,w,E,P){const R=v.context,O=R.gl,k=w.getSource().tileSize,N=5*(1-a.aj(a.cv,a.cv+1,v.transform.zoom))*k+E.paint.get("raster-particle-elevation"),j=!v.options.moving,U=v.transform.projection.name==="globe";if(!P.length)return;const[X,W]=v.stencilConfigForOverlap(P),ie=[];U&&ie.push("PROJECTION_GLOBE_VIEW");const ne=v.stencilModeFor3D();for(const K of W){const xe=K.toUnwrapped(),le=w.getTile(K);if(!le.rasterParticleState)continue;const _e=le.rasterParticleState,re=100;le.registerFadeDuration(re);const ae=w.findLoadedParent(K,0),fe=Qu(le,ae,w,v.transform,re);let Ce,ve;v.terrain&&v.terrain.prepareDrawTile(),R.activeTexture.set(O.TEXTURE0),_e.targetColorTexture.bind(O.LINEAR,O.CLAMP_TO_EDGE),R.activeTexture.set(O.TEXTURE1),ae&&ae.rasterParticleState?(ae.rasterParticleState.targetColorTexture.bind(O.LINEAR,O.CLAMP_TO_EDGE),Ce=Math.pow(2,ae.tileID.overscaledZ-le.tileID.overscaledZ),ve=[le.tileID.canonical.x*Ce%1,le.tileID.canonical.y*Ce%1]):_e.targetColorTexture.bind(O.LINEAR,O.CLAMP_TO_EDGE);const Ne=U?Float32Array.from(v.transform.expandedFarZProjMatrix):v.transform.calculateProjMatrix(xe,j),ze=v.transform,Je=xm(ze),tt=a.dr(K.canonical),Pe=a.ds(tt.getCenter().lat);let we,Oe,Ue,$e,ft;U?(we=Float32Array.from(a.du(a.dv(K.canonical))),Oe=Float32Array.from(ze.globeMatrix),Ue=Float32Array.from(a.dq(ze)),$e=[a.aH(ze.center.lng),a.aL(ze.center.lat)],ft=Float32Array.from(a.dt(K.canonical,tt,Pe,ze.worldSize/ze._pixelsPerMercatorPixel))):(we=new Float32Array(16),Oe=new Float32Array(9),Ue=new Float32Array(16),$e=[0,0],ft=new Float32Array(9));const lt=P1(Ne,we,Oe,Ue,ft,ve||[0,0],a.al(v.transform.zoom),$e,Je,Ce||1,fe,N),ct=v.isTileAffectedByFog(K),et=v.getOrCreateProgram("rasterParticle",{defines:ie,overrideFog:ct});if(v.uploadCommonUniforms(R,et,xe),U){const Et=new At(O.LEQUAL,At.ReadOnly,v.depthRangeFor3D),Mt=0,vt=v.globeSharedBuffers;if(vt){const[St,Vt,Yt]=vt.getGridBuffers(Pe,Mt!==0);et.draw(v,O.TRIANGLES,Et,ne,jt.alphaBlended,v.renderElevatedRasterBackface?Nt.frontCCW:Nt.backCCW,lt,E.id,St,Vt,Yt)}}else{const Et=v.depthModeForSublayer(0,At.ReadOnly),Mt=X[K.overscaledZ],{tileBoundsBuffer:vt,tileBoundsIndexBuffer:St,tileBoundsSegments:Vt}=v.getTileBoundsBuffers(le);et.draw(v,O.TRIANGLES,Et,Mt,jt.alphaBlended,Nt.disabled,lt,E.id,vt,St,Vt)}}v.resetStencilClippingMasks()}(u,i,o,d),u.style.map.triggerRepaint())},background:function(u,i,o,d){const m=o.paint.get("background-color"),y=o.paint.get("background-color-use-theme").constantOr("default")==="none",v=o.paint.get("background-opacity"),w=o.paint.get("background-emissive-strength"),E=o.paint.get("background-pitch-alignment")==="viewport";if(v===0)return;const P=u.context,R=P.gl,O=u.transform,k=O.tileSize,N=o.paint.get("background-pattern");let j;if(N!==void 0&&(N===null||(j=u.imageManager.getPattern(a.I.from(N.toString()),o.scope,u.style.getLut(o.scope)),!j)))return;const U=!N&&m.a===1&&v===1&&u.opaquePassEnabledForLayer()?"opaque":"translucent";if(u.renderPass!==U)return;const X=Ht.disabled,W=u.depthModeForSublayer(0,U==="opaque"?At.ReadWrite:At.ReadOnly),ie=u.colorModeForDrapableLayerRenderPass(w),ne=N?"backgroundPattern":"background";let K,xe=d;xe||(K=u.getBackgroundTiles(),xe=Object.values(K).map(_e=>_e.tileID)),N&&(P.activeTexture.set(R.TEXTURE0),u.imageManager.bind(u.context,o.scope));const le=[];if(u.terrain&&u.terrain.renderingToTexture&&u.emissiveMode==="mrt-fallback"&&le.push("USE_MRT1"),E){const _e=u.getOrCreateProgram(ne,{overrideFog:!1,overrideRtt:!0,defines:le}),re=new Float32Array(a.b9([])),ae=new a.aR(0,0,0,0,0),fe=N?Za(re,w,v,u,0,o.scope,j,E,{tileID:ae,tileSize:k}):nh(re,w,v,m.toPremultipliedRenderColor(y?null:o.lut));return void _e.draw(u,R.TRIANGLES,W,X,ie,Nt.disabled,fe,o.id,u.viewportBuffer,u.quadTriangleIndexBuffer,u.viewportSegments)}for(const _e of xe){const re=u.isTileAffectedByFog(_e),ae=u.getOrCreateProgram(ne,{overrideFog:re,defines:le}),fe=_e.toUnwrapped(),Ce=d?_e.projMatrix:u.transform.calculateProjMatrix(fe);u.prepareDrawTile();const ve=i?i.getTile(_e):K?K[_e.key]:new a.b0(_e,k,O.zoom,u),Ne=N?Za(Ce,w,v,u,0,o.scope,j,E,{tileID:_e,tileSize:k}):nh(Ce,w,v,m.toPremultipliedRenderColor(y?null:o.lut));u.uploadCommonUniforms(P,ae,fe);const{tileBoundsBuffer:ze,tileBoundsIndexBuffer:Je,tileBoundsSegments:tt}=u.getTileBoundsBuffers(ve);ae.draw(u,R.TRIANGLES,W,X,ie,Nt.disabled,Ne,o.id,ze,Je,tt)}},sky:function(u,i,o){const d=u._atmosphere?a.al(u.transform.zoom):1,m=o.paint.get("sky-opacity")*d;if(m===0)return;const y=u.context,v=o.paint.get("sky-type"),w=new At(y.gl.LEQUAL,At.ReadOnly,[0,1]),E=u.frameCounter/1e3%1;v==="atmosphere"?u.renderPass==="offscreen"?o.needsSkyboxCapture(u)&&(function(P,R){const O=P.context,k=O.gl;let N=R.skyboxFbo;if(!N){N=R.skyboxFbo=O.createFramebuffer(32,32,1,null),R.skyboxGeometry=new Ur(O),R.skyboxTexture=O.gl.createTexture(),k.bindTexture(k.TEXTURE_CUBE_MAP,R.skyboxTexture),k.texParameteri(k.TEXTURE_CUBE_MAP,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE),k.texParameteri(k.TEXTURE_CUBE_MAP,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE),k.texParameteri(k.TEXTURE_CUBE_MAP,k.TEXTURE_MIN_FILTER,k.LINEAR),k.texParameteri(k.TEXTURE_CUBE_MAP,k.TEXTURE_MAG_FILTER,k.LINEAR);for(let W=0;W<6;++W)k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,k.RGBA,32,32,0,k.RGBA,k.UNSIGNED_BYTE,null)}O.bindFramebuffer.set(N.framebuffer),O.viewport.set([0,0,32,32]);const j=R.getCenter(P,!0),U=P.getOrCreateProgram("skyboxCapture"),X=new Float64Array(16);a.b9(X),a.ef(X,X,.5*-Math.PI),Ms(P,R,U,X,j,0),a.b9(X),a.ef(X,X,.5*Math.PI),Ms(P,R,U,X,j,1),a.b9(X),a.cE(X,X,.5*-Math.PI),Ms(P,R,U,X,j,2),a.b9(X),a.cE(X,X,.5*Math.PI),Ms(P,R,U,X,j,3),a.b9(X),Ms(P,R,U,X,j,4),a.b9(X),a.ef(X,X,Math.PI),Ms(P,R,U,X,j,5),O.viewport.set([0,0,P.width,P.height])}(u,o),o.markSkyboxValid(u)):u.renderPass==="sky"&&function(P,R,O,k,N){const j=P.context,U=j.gl,X=P.transform,W=P.getOrCreateProgram("skybox");j.activeTexture.set(U.TEXTURE0),U.bindTexture(U.TEXTURE_CUBE_MAP,R.skyboxTexture);const ie=((ne,K,xe,le,_e)=>({u_matrix:ne,u_sun_direction:K,u_cubemap:0,u_opacity:le,u_temporal_offset:_e}))(X.skyboxMatrix,R.getCenter(P,!1),0,k,N);P.uploadCommonUniforms(j,W),W.draw(P,U.TRIANGLES,O,Ht.disabled,P.colorModeForRenderPass(),Nt.backCW,ie,"skybox",R.skyboxGeometry.vertexBuffer,R.skyboxGeometry.indexBuffer,R.skyboxGeometry.segment)}(u,o,w,m,E):v==="gradient"&&u.renderPass==="sky"&&function(P,R,O,k,N){const j=P.context,U=j.gl,X=P.transform,W=P.getOrCreateProgram("skyboxGradient");R.skyboxGeometry||(R.skyboxGeometry=new Ur(j)),j.activeTexture.set(U.TEXTURE0);let ie=R.colorRampTexture;ie||(ie=R.colorRampTexture=new a.T(j,R.colorRamp,U.RGBA8)),ie.bind(U.LINEAR,U.CLAMP_TO_EDGE);const ne=((K,xe,le,_e,re)=>({u_matrix:K,u_color_ramp:0,u_center_direction:xe,u_radius:a.ap(le),u_opacity:_e,u_temporal_offset:re}))(X.skyboxMatrix,R.getCenter(P,!1),R.paint.get("sky-gradient-radius"),k,N);P.uploadCommonUniforms(j,W),W.draw(P,U.TRIANGLES,O,Ht.disabled,P.colorModeForRenderPass(),Nt.backCW,ne,"skyboxGradient",R.skyboxGeometry.vertexBuffer,R.skyboxGeometry.indexBuffer,R.skyboxGeometry.segment)}(u,o,w,m,E)},custom:function(u,i,o,d){const m=u.context,y=o.implementation;if(!u.transform.projection.unsupportedLayers||!u.transform.projection.unsupportedLayers.includes("custom")||u.terrain&&(u.terrain.renderingToTexture||u.renderPass==="offscreen")&&o.isDraped(i)){if(u.renderPass==="offscreen"){const v=y.prerender;if(v){if(u.setCustomLayerDefaults(),m.setColorMode(u.colorModeForRenderPass()),u.transform.projection.name==="globe"){const w=u.transform.pointMerc;v.call(y,m.gl,u.transform.customLayerMatrix(),u.transform.getProjection(),u.transform.globeToMercatorMatrix(),a.al(u.transform.zoom),[w.x,w.y],u.transform.pixelsPerMeterRatio)}else v.call(y,m.gl,u.transform.customLayerMatrix());m.setDirty(),u.setBaseState()}}else if(u.renderPass==="translucent"){if(u.terrain&&u.terrain.renderingToTexture){const w=y.renderToTile;if(w){const E=d[0].canonical,P={x:E.x+d[0].wrap*(y.wrapTileId?0:1<<E.z),y:E.y,z:E.z};m.setDepthMode(At.disabled),m.setStencilMode(Ht.disabled),m.setColorMode(u.colorModeForRenderPass()),u.setCustomLayerDefaults(),w.call(y,m.gl,P),m.setDirty(),u.setBaseState()}return}u.setCustomLayerDefaults(),m.setColorMode(u.colorModeForRenderPass()),m.setStencilMode(Ht.disabled);const v=y.renderingMode==="3d"?new At(u.context.gl.LEQUAL,At.ReadWrite,u.depthRangeFor3D):u.depthModeForSublayer(0,At.ReadOnly);if(m.setDepthMode(v),u.transform.projection.name==="globe"){const w=u.transform.pointMerc;y.render(m.gl,u.transform.customLayerMatrix(),u.transform.getProjection(),u.transform.globeToMercatorMatrix(),a.al(u.transform.zoom),[w.x,w.y],u.transform.pixelsPerMeterRatio)}else y.render(m.gl,u.transform.customLayerMatrix());m.setDirty(),u.setBaseState(),m.bindFramebuffer.set(null)}}else a.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")},model:function(u,i,o,d){if(u.renderPass==="opaque")return;const m=o.paint.get("model-opacity").constantOr(1),y=o.paint.get("model-elevation-reference"),v=y==="ground",w=y==="ground";if(m===0)return;const E=o.paint.get("model-cast-shadows");if(u.renderPass==="shadow"&&(!E||u.terrain&&m<.65&&o._transitionablePaint._values["model-opacity"].value.expression instanceof a.af))return;const P=u.shadowRenderer,R=o.paint.get("model-receive-shadows");P&&(P.useNormalOffset=!0,R||(P.enabled=!1));const O=()=>{P&&(P.useNormalOffset=!0,R||(P.enabled=!0))},k=i.getSource();if(u.renderPass==="light-beam"&&k.type!=="batched-model")return;if(k.type==="vector"||k.type==="geojson")return function(K,xe,le,_e,re){const ae=K.transform,fe=ae.projection.name==="globe",Ce=ae.getFreeCameraOptions().position;if(!K.modelManager)return;const ve=K.modelManager;le.modelManager=ve;const Ne=K.shadowRenderer;if(!le._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const ze=le._unevaluatedLayout._values["model-id"],Je=Object.assign({},le.layout.get("model-id").parameters),tt=K.style.order.indexOf(le.fqid),Pe=le.paint.get("model-opacity").constantOr(1);for(const we of _e){const Oe=xe.getTile(we).getBucket(le);if(!Oe||Oe.projection.name!==ae.projection.name)continue;const Ue=Oe.getModelUris();if(Ue&&!Oe.modelsRequested&&(ve.addModelsFromBucket(Ue,re),Oe.modelsRequested=!0),fe)Je.zoom=we.overscaledZ;else{const vt=Bc(we,ae);Je.zoom=vt}const $e=ze.possiblyEvaluate(Je);if(dt(K,Oe,we),at.shadowUniformsInitialized=!1,at.useSingleShadowCascade=!!Ne&&Ne.getMaxCascadeForTile(we.toUnwrapped())===0,K.renderPass==="shadow"&&Ne){if(K.currentShadowCascade===1&&Oe.isInsideFirstShadowMapFrustum)continue;const vt=ae.calculatePosMatrix(we.toUnwrapped(),ae.worldSize);if(at.tileMatrix.set(vt),at.shadowTileMatrix=Float32Array.from(Ne.calculateShadowPassMatrixFromMatrix(vt)),at.aabb.min=[0,0,0],at.aabb.max[0]=at.aabb.max[1]=a.an,at.aabb.max[2]=0,Xy(Oe,at,K,le.scope))continue}const ft=1<<we.canonical.z,lt=[((Ce.x-we.wrap)*ft-we.canonical.x)*a.an,(Ce.y*ft-we.canonical.y)*a.an,Ce.z*ft*a.an];K.conflationActive&&Object.keys(Oe.instancesPerModel).length>0&&K.style.isLayerClipped(le,xe.getSource())&&Oe.updateReplacement(we,K.replacementSource,tt,le.scope)&&(Oe.uploaded=!1,Oe.upload(K.context));let ct=0;const et=new Array,Et=new Array,Mt=new Array;for(let vt in Oe.instancesPerModel){const St=Oe.instancesPerModel[vt];St.features.length>0&&!fe&&(vt=$e.evaluate(St.features[0].feature,{}));const Vt=ve.getModel(vt,re);if(Vt||ve.hasURLBeenRequested(vt)||Oe.modelUris.includes(vt)||(Oe.modelUris.push(vt),Oe.modelsRequested=!1),Vt&&Vt.uploaded)if(fe){const Yt=a.bJ([],[Ce.x,Ce.y,Ce.z],K.transform.worldSize);a.eo(Yt,Yt);for(let Zt=0;Zt<St.instancedDataArray.length;++Zt){const si=[0,0,0],Ft=[1,1,1],oi=a.ep(),qt=St.tileCoordinatesForInstance(Zt),Ti=St.transformForInstance(Zt);a.eq(Ft,Ti),a.er(oi,Ti),a.es(si,oi);const Vi=St.translationForInstance(Zt),nn=new a.aU(0,0);a.et(Oe.canonical,nn,qt.x,qt.y);const Hi=a.bb();a.eu(Hi,Vt,K.transform,nn,si,Ft,Vi,!0,!1,!1);const Ci=St.colorForInstance(Zt),ni=a.b9([]),ri=a.e2(nn.lat,K.transform.zoom),Zi=a.bP([],[1,1,1/ri]);a.bx(ni,ni,Yt),Mt.push({zScaleMatrix:Zi,negCameraPosMatrix:ni});for(const an of Vt.nodes)Wd(K,an,Hi,K.transform.expandedFarZProjMatrix,ct,et,Et,Vt.materialOverrides,Pe,Ci);++ct}}else for(const Yt of Vt.nodes)on(K,le,Yt,St,lt,we,at)}if(fe)if(K.renderPass==="shadow"){for(const vt of Et)Oc(vt.mesh,vt.nodeModelMatrix,K,le);for(const vt of et)Oc(vt.mesh,vt.nodeModelMatrix,K,le)}else pa(K,le,et,Et,Mt)}}(u,i,o,d,qd(u,o)),void O();if(!k.loaded())return;if(k.type==="batched-model")return function(K,xe,le,_e){le.resetLayerRenderingStats(K);const re=K.context,ae=K.transform,fe=K.style.fog,Ce=K.shadowRenderer;if(ae.projection.name!=="mercator")return void a.w(`Drawing 3D landmark models for ${ae.projection.name} projection is not yet implemented`);const ve=K.transform.getFreeCameraOptions().position,Ne=a.bJ([],[ve.x,ve.y,ve.z],K.transform.worldSize),ze=a.eo([],Ne),Je=a.b9([]),tt=a.e2(ae.center.lat,ae.zoom),Pe=a.bP([],[1,1,1/tt]);a.bx(Je,Je,ze);const we=le.paint.get("model-opacity").constantOr(1),Oe=new At(re.gl.LEQUAL,At.ReadWrite,K.depthRangeFor3D),Ue=new At(re.gl.LEQUAL,At.ReadOnly,K.depthRangeFor3D),$e=new a.cU([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),ft=K.renderPass==="shadow",lt=ft&&Ce?Ce.getCurrentCascadeFrustum():ae.getFrustum(ae.scaleZoom(ae.worldSize)),ct=le.paint.get("model-front-cutoff"),et=ct[2]<1,Et=ir(K,le.paint.get("model-cutoff-fade-range")),Mt=le.getLayerRenderingStats();(function(vt,St,Vt,Yt){const Zt=vt.terrain?vt.terrain.exaggeration():0,si=vt.transform.zoom;for(const Ft of Yt){const oi=St.getTile(Ft).getBucket(Vt);oi&&(oi.setFilter(Vt.filter),vt.conflationActive&&oi.updateReplacement(Ft,vt.replacementSource),oi.evaluateTransform(vt,Vt),vt.terrain&&Zt>0&&oi.elevationUpdate(vt.terrain,Zt,Ft,Vt.source),oi.needsReEvaluation(vt,si,Vt)&&oi.evaluate(Vt))}})(K,xe,le,_e),function(){const vt=new Map;let St,Vt,Yt;et?(St=_e.length-1,Vt=-1,Yt=-1):(St=0,Vt=_e.length,Yt=1);const Zt=new Float64Array(16),si=a.ce(),Ft=new a.P(0,0);for(let oi=St;oi!==Vt;oi+=Yt){const qt=_e[oi],Ti=xe.getTile(qt).getBucket(le);if(!Ti||!Ti.uploaded)continue;let Vi=!1;Ce&&(Vi=Ce.getMaxCascadeForTile(qt.toUnwrapped())===0);const nn=ae.calculatePosMatrix(qt.toUnwrapped(),ae.worldSize),Hi=Ti.modelTraits;!ft&&et&&(a.b7(Zt,nn),a.ah(si,Ne,Zt),Ft.x=si[0],Ft.y=si[1]);const Ci=[];Ti.setFilter(le.filter);for(const ni of Ti.getNodesInfo()){if(ni.hiddenByReplacement||!ni.node.meshes)continue;const ri=ni.node;let Zi=0;K.terrain&&ri.elevation&&(Zi=ri.elevation*K.terrain.exaggeration());const an=(()=>{const ar=ni.aabb;return $e.min=[...ar.min],$e.max=[...ar.max],$e.min[2]+=Zi,$e.max[2]+=Zi,a.ah($e.min,$e.min,nn),a.ah($e.max,$e.max,nn),$e})(),Pi=ni.evaluatedScale;if(Pi[0]<=1&&Pi[1]<=1&&Pi[2]<=1&&an.intersects(lt)===0)continue;if(!ft&&et){const ar=.16666666666666666;ni.cameraCollisionOpacity=Ne[0]>an.min[0]&&Ne[0]<an.max[0]&&Ne[1]>an.min[1]&&Ne[1]<an.max[1]&&Ne[2]*tt<an.max[2]&&ri.footprint&&a.bC(Ft,ri.footprint)?Math.max(ni.cameraCollisionOpacity-ar,0):Math.min(1,ni.cameraCollisionOpacity+ar)}const Jt=[...nn],en=1/a.cS(qt.canonical),Ui=ri.anchor?ri.anchor[0]:0,kn=ri.anchor?ri.anchor[1]:0;a.bx(Jt,Jt,[Ui*(Pi[0]-1)+ni.evaluatedTranslation[0]*en,kn*(Pi[1]-1)+ni.evaluatedTranslation[1]*en,Zi+ni.evaluatedTranslation[2]]),a.c4(Pi,a.ew)||a.cC(Jt,Jt,Pi);const fi=a.aD([],Jt,ri.globalMatrix),Gi=a.aD([],ae.expandedFarZProjMatrix,fi),Vn=a.aD([],ae.expandedFarZProjMatrix,Jt),Er=a.aE([],[Ui,kn,Zi,1],Gi)[2];ri.hidden=!1;let Hn=we;ft||(et&&(Hn*=ni.cameraCollisionOpacity,Hn*=Cm(Jt,ae,ni.aabb,ct)),Hn*=Xd(Et,Er)),Hn!==0?Ci.push({nodeInfo:ni,depth:Er,opacity:Hn,wvpForNode:Gi,wvpForTile:Vn,nodeModelMatrix:fi,tileModelMatrix:Jt}):ri.hidden=!0}ft||Ci.sort((ni,ri)=>!et||ni.opacity===1&&ri.opacity===1?ni.depth<ri.depth?-1:1:ni.opacity===1?-1:ri.opacity===1?1:ni.depth>ri.depth?-1:1);for(const ni of Ci){const ri=ni.nodeInfo,Zi=ri.node;if(K._debugParams.show3DModelFootprints&&Zi.footprint){const fi=Zi.id||Zi.name||"footprint";vt.has(fi)||vt.set(fi,{node:Zi,mvp:ni.wvpForTile})}let an=a.aD([],Pe,ni.tileModelMatrix);a.aD(an,Je,an);const Pi=a.b7([],an);a.e6(Pi,Pi),a.cC(Pi,Pi,Ee),an=a.aD(an,an,Zi.globalMatrix);const Jt=K.renderPass==="light-beam",en=le.paint.get("model-color-use-theme").constantOr("default")==="none",Ui=Hi&a.ez.HasMapboxMeshFeatures,kn=Ui?0:ri.evaluatedRMEA[0][2];for(let fi=0;fi<Zi.meshes.length;++fi){const Gi=Zi.meshes[fi],Vn=fi===Zi.lightMeshIndex;let Er=ni.wvpForNode;if(Vn){if(!Jt&&!K.terrain&&K.shadowRenderer){K.currentLayer<K.firstLightBeamLayer&&(K.firstLightBeamLayer=K.currentLayer);continue}Er=ni.wvpForTile}else if(Jt)continue;const Hn={defines:[]},ar=[];if(!ft&&Ce&&(Ce.useNormalOffset=!!Gi.normalBuffer),Mi(Hn.defines,ar,Gi,K,en?null:le.lut),Ui||Hn.defines.push("DIFFUSE_SHADED"),Vi&&Hn.defines.push("SHADOWS_SINGLE_CASCADE"),Mt&&(ft?Mt.numRenderedVerticesInShadowPass+=Gi.vertexArray.length:Mt.numRenderedVerticesInTransparentPass+=Gi.vertexArray.length),ft){Oc(Gi,ni.nodeModelMatrix,K,le);continue}let _s=null;if(fe){const Bi=Wy(ni.nodeModelMatrix,K.transform);if(_s=new Float32Array(Bi),ae.projection.name!=="globe"){const Mn=Gi.aabb.min,kr=Gi.aabb.max,[_n,gs]=fe.getOpacityForBounds(Bi,Mn[0],Mn[1],kr[0],kr[1]);Hn.overrideFog=_n>=_i||gs>=_i}}const Li=Gi.material;let Ls;Li.occlusionTexture&&Li.occlusionTexture.offsetScale&&(Ls=Li.occlusionTexture.offsetScale,Hn.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const zs=K.getOrCreateProgram("model",Hn);!ft&&Ce&&Ce.setupShadowsFromMatrix(ni.tileModelMatrix,zs,Ce.useNormalOffset),K.uploadCommonUniforms(re,zs,null,_s);const Yi=Li.pbrMetallicRoughness;Yi.metallicFactor=.9,Yi.roughnessFactor=.5;const Ki=Pl(new Float32Array(Er),new Float32Array(an),new Float32Array(Pi),new Float32Array(Zi.globalMatrix),K,ni.opacity,Yi.baseColorFactor,Li.emissiveFactor,Yi.metallicFactor,Yi.roughnessFactor,Li,kn,le,[0,0,0],Ls);!Vn&&(ri.hasTranslucentParts||ni.opacity<1)&&zs.draw(K,re.gl.TRIANGLES,Oe,Ht.disabled,jt.disabled,Nt.backCCW,Ki,le.id,Gi.vertexBuffer,Gi.indexBuffer,Gi.segments,le.paint,K.transform.zoom,void 0,ar),zs.draw(K,re.gl.TRIANGLES,Vn?Ue:Oe,Ht.disabled,Vn||ni.opacity<1||ri.hasTranslucentParts?jt.alphaBlended:jt.unblended,Nt.backCCW,Ki,le.id,Gi.vertexBuffer,Gi.indexBuffer,Gi.segments,le.paint,K.transform.zoom,void 0,ar)}}}if(K._debugParams.show3DModelFootprints&&vt.size>0){const oi=Array.from(vt.keys()).sort();for(const qt of oi){const{node:Ti,mvp:Vi}=vt.get(qt);Im(K,0,Ti,Vi)}}}()}(u,i,o,d),void O();if(k.type!=="model")return;const N=k.getModels(),j=[],U=u.transform.getFreeCameraOptions().position,X=a.bJ([],[U.x,U.y,U.z],u.transform.worldSize);a.eo(X,X);const W=[],ie=[];let ne=0;for(const K of N){const xe=i.getFeatureState("",K.id),le={type:"Unknown",id:K.id,properties:K.featureProperties},_e=o.paint.get("model-rotation").evaluate(le,xe),re=o.paint.get("model-scale").evaluate(le,xe),ae=o.paint.get("model-translation").evaluate(le,xe),fe=o.paint.get("model-opacity").evaluate(le,xe);Am(o,K.id,xe,K.featureProperties,K.nodeOverrideNames,K.nodeOverrides),Ll(o,K.id,xe,K.featureProperties,K.materialOverrideNames,K.materialOverrides),K.nodeOverrides.size>0&&K.computeBoundsAndApplyParent(),K.computeModelMatrix(u,_e,re,ae,w,v,!1);const Ce=a.b9([]),ve=a.e2(K.position.lat,u.transform.zoom),Ne=a.bP([],[1,1,1/ve]);a.bx(Ce,Ce,X),j.push({zScaleMatrix:Ne,negCameraPosMatrix:Ce});for(const ze of K.nodes)Wd(u,ze,K.matrix,u.transform.expandedFarZProjMatrix,ne,W,ie,K.materialOverrides,fe);ne++}if(W.sort((K,xe)=>xe.depth-K.depth),u.renderPass!=="shadow"){if(u._debugParams.show3DModelFootprints){const K=u.transform.projMatrix,xe=new Map,le=(re,ae)=>{if(re.footprint){const fe=re.id||re.name||"footprint";if(!xe.has(fe)){const Ce=a.aD([],K,ae);xe.set(fe,{node:re,mvp:Ce})}}};for(const re of ie)le(re.node,re.modelMatrix);for(const re of W)le(re.node,re.modelMatrix);const _e=Array.from(xe.keys()).sort();for(const re of _e){const{node:ae,mvp:fe}=xe.get(re);Im(u,0,ae,fe)}}pa(u,o,W,ie,j),O()}else{for(const K of ie)Oc(K.mesh,K.nodeModelMatrix,u,o);for(const K of W)Oc(K.mesh,K.nodeModelMatrix,u,o);O()}}},Mm={line:function(u,i,o){if(u.hasElevatedBuckets=!1,u.hasNonElevatedBuckets=!1,u._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||u._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(i){const d=i.getVisibleCoordinates();for(const m of d){const y=i.getTile(m).getBucket(u);if(y&&(y.elevationType!=="none"?u.hasElevatedBuckets=!0:u.hasNonElevatedBuckets=!0,u.hasElevatedBuckets&&u.hasNonElevatedBuckets))break}}}else u.hasNonElevatedBuckets=!0},model:function(u,i,o){const d=i.getSource();if(!d.loaded())return;if(d.type==="vector"||d.type==="geojson")return void(o.modelManager&&o.modelManager.upload(o,qd(o,u)));if(d.type==="batched-model"||d.type!=="model")return;const m=d.getModels();for(const y of m)y.upload(o.context)},raster:function(u,i,o){const d=i.getSource();if(!(d instanceof gl&&d.loaded()))return;const m=u.sourceLayer||d.rasterLayerIds&&d.rasterLayerIds[0];if(!m)return;const y=u.paint.get("raster-array-band")||d.getInitialBand(m);if(y==null)return;const v=i.getIds().map(w=>i.getTileByID(w));for(const w of v)w.updateNeeded(u.id,y)&&d.prepareTile(w,m,u.id,y)},"raster-particle":function(u,i,o){const d=i.getSource();if(!(d instanceof gl&&d.loaded()))return;const m=u.sourceLayer||d.rasterLayerIds&&d.rasterLayerIds[0];if(!m)return;const y=u.paint.get("raster-particle-array-band")||d.getInitialBand(m);if(y==null)return;const v=i.getIds().map(w=>i.getTileByID(w));for(const w of v)w.updateNeeded(u.id,y)&&d.prepareTile(w,m,u.id,y)}},Rm={fill:oh},Dm={fill:function(u,i,o,d){if(!o.layout||o.layout.get("fill-elevation-reference")==="none"||o.paint.get("fill-opacity").constantOr(1)===0)return;const m=u.context.gl,y=new At(m.LEQUAL,At.ReadOnly,u.depthRangeFor3D),v=new Ht({func:m.ALWAYS,mask:255},255,255,m.KEEP,m.KEEP,m.REPLACE),w=u.transform.getFreeCameraOptions().position,E=u.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const P of d){const R=i.getTile(P),O=R.getBucket(o);if(!O)continue;const k=O.elevatedStructures;if(!k||k.depthSegments.segments[0].primitiveLength===0)continue;const N=hm(P.toUnwrapped(),w),j=u.translatePosMatrix(P.projMatrix,R,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor")),U=th(j,N,0,1,0);E.draw(u,m.TRIANGLES,y,v,jt.disabled,Nt.disabled,U,o.id,k.vertexBuffer,k.indexBuffer,k.depthSegments,o.paint,u.transform.zoom)}}};class F1{constructor(i,o,d,m,y){this.context=new kc(i,o),this.transform=d,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._timeStamp=a.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,show3DModelFootprints:!1,enabledLayers:{}};const v=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const E of v)this._debugParams.enabledLayers[E]=!0;for(const E of v);this.occlusionParams=new Ky,this.setup(),this.numSublayers=Ws.maxUnderzooming+Ws.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new a.eG,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new Uu(this),this._wireframeDebugCache=new Yy,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const w=new a.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new a.T(this.context,w,i.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=m,this.maxFrontCutoffRawStart=0,this.worldview=y,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(i,o){const d=!!i&&!!i.terrain&&this.transform.projection.supportsTerrain;if(!(d||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new eh(this,i));const m=this._terrain;this.transform.elevation=d?m:null,m.update(i,this.transform,o),this.transform.elevation&&!m.enabled&&(this.transform.elevation=null)}_updateFog(i){const o=i.fog;if(!o||this.transform.projection.name==="globe"||o.getOpacity(this.transform.pitch)<1||o.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[d,m]=o.getFovAdjustedRange(this.transform._fov);if(d>m)return void(this.transform.fogCullDistSq=null);const y=d+.78*(m-d);this.transform.fogCullDistSq=y*y}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(i){i&&!this._terrain&&(this._terrain=new eh(this,this.style)),this._forceTerrainMode=i}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(i,o){if(this.width=i*a.o.devicePixelRatio,this.height=o*a.o.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const d of this.style.order)this.style._mergedLayers[d].resize()}setup(){const i=this.context,o=new a.dB;o.emplaceBack(0,0),o.emplaceBack(a.an,0),o.emplaceBack(0,a.an),o.emplaceBack(a.an,a.an),this.tileExtentBuffer=i.createVertexBuffer(o,a.dx.members),this.tileExtentSegments=a.dy.simpleSegment(0,0,4,2);const d=new a.dB;d.emplaceBack(0,0),d.emplaceBack(a.an,0),d.emplaceBack(0,a.an),d.emplaceBack(a.an,a.an),this.debugBuffer=i.createVertexBuffer(d,a.dx.members),this.debugSegments=a.dy.simpleSegment(0,0,4,5);const m=new a.dB;m.emplaceBack(-1,-1),m.emplaceBack(1,-1),m.emplaceBack(-1,1),m.emplaceBack(1,1),this.viewportBuffer=i.createVertexBuffer(m,a.dx.members),this.viewportSegments=a.dy.simpleSegment(0,0,4,2);const y=new a.eH;y.emplaceBack(0,0,0,0),y.emplaceBack(a.an,0,a.an,0),y.emplaceBack(0,a.an,0,a.an),y.emplaceBack(a.an,a.an,a.an,a.an),this.mercatorBoundsBuffer=i.createVertexBuffer(y,a.eI.members),this.mercatorBoundsSegments=a.dy.simpleSegment(0,0,4,2);const v=new a.dC;v.emplaceBack(0,1,2),v.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=i.createIndexBuffer(v);const w=new a.eJ;for(const P of[0,1,3,2,0])w.emplaceBack(P);this.debugIndexBuffer=i.createIndexBuffer(w),this.emptyTexture=new a.T(i,new a.q({width:1,height:1},Uint8Array.of(0,0,0,0)),i.gl.RGBA8),this.identityMat=a.bb();const E=this.context.gl;this.stencilClearMode=new Ht({func:E.ALWAYS,mask:0},0,255,E.ZERO,E.ZERO,E.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(i){return i._makeTileBoundsBuffers(this.context,this.transform.projection),i._tileBoundsBuffer?{tileBoundsBuffer:i._tileBoundsBuffer,tileBoundsIndexBuffer:i._tileBoundsIndexBuffer,tileBoundsSegments:i._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const i=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,i.TRIANGLES,At.disabled,this.stencilClearMode,jt.disabled,Nt.disabled,Ju(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(i,o,d){if(!o||this.currentStencilSource===o.id||!i.isTileClipped()||!d||d.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let w=!1;for(const E of d)if(this._tileClippingMaskIDs[E.key]===void 0){w=!0;break}if(!w)return}this.currentStencilSource=o.id;const m=this.context,y=m.gl;this.nextStencilID+d.length>256&&this.clearStencil(),m.setColorMode(jt.disabled),m.setDepthMode(At.disabled);const v=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const w of d){const E=o.getTile(w),P=this._tileClippingMaskIDs[w.key]=this.nextStencilID++,{tileBoundsBuffer:R,tileBoundsIndexBuffer:O,tileBoundsSegments:k}=this.getTileBoundsBuffers(E);v.draw(this,y.TRIANGLES,At.disabled,new Ht({func:y.ALWAYS,mask:0},P,255,y.KEEP,y.KEEP,y.REPLACE),jt.disabled,Nt.disabled,Ju(w.projMatrix),"$clipping",R,O,k)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const i=this.nextStencilID++,o=this.context.gl;return new Ht({func:o.NOTEQUAL,mask:255},i,255,o.KEEP,o.KEEP,o.REPLACE)}stencilModeForClipping(i){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(i);const o=this.context.gl;return new Ht({func:o.EQUAL,mask:255},this._tileClippingMaskIDs[i.key],0,o.KEEP,o.KEEP,o.REPLACE)}stencilConfigForOverlap(i){const o=this.context.gl,d=i.sort((v,w)=>w.overscaledZ-v.overscaledZ),m=d[d.length-1].overscaledZ,y=d[0].overscaledZ-m+1;if(y>1){this.currentStencilSource=void 0,this.nextStencilID+y>256&&this.clearStencil();const v={};for(let w=0;w<y;w++)v[w+m]=new Ht({func:o.GEQUAL,mask:255},w+this.nextStencilID,255,o.KEEP,o.KEEP,o.REPLACE);return this.nextStencilID+=y,[v,d]}return[{[m]:Ht.disabled},d]}colorModeForRenderPass(){const i=this.context.gl;return this._showOverdrawInspector?new jt([i.CONSTANT_COLOR,i.ONE,i.CONSTANT_COLOR,i.ONE],new a.aq(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?jt.unblended:jt.alphaBlended}colorModeForDrapableLayerRenderPass(i){const o=this.context.gl;return this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture&&this.renderPass==="translucent"?i!=null&&this.emissiveMode!=="mrt-fallback"||this.emissiveMode==="constant"?new jt([o.ONE,o.ONE_MINUS_SRC_ALPHA,o.CONSTANT_ALPHA,o.ONE_MINUS_SRC_ALPHA],new a.aq(0,0,0,i??0),[!0,!0,!0,!0]):this.emissiveMode==="dual-source-blending"?new jt([o.ONE,o.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,o.ONE_MINUS_SRC_ALPHA],a.aq.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(i,o,d,m=!1){if(this.depthOcclusion)return new At(this.context.gl.GREATER,At.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!m)return At.disabled;const y=1-((1+this.currentLayer)*this.numSublayers+i)*this.depthEpsilon;return new At(d||this.context.gl.LEQUAL,o,[y,y])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){const i=this.context.gl,o=Math.ceil(this.width),d=Math.ceil(this.height),m=this.context.bindFramebuffer.get(),y=i.getParameter(i.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===o&&this.depthFBO.height===d||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),o!==0&&d!==0&&(this.depthFBO=new rh(this.context,o,d,0,"texture"),this.depthTexture=new a.T(this.context,{width:o,height:d,data:null},i.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(m),i.bindTexture(i.TEXTURE_2D,y),this.depthFBO&&(i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),i.blitFramebuffer(0,0,o,d,0,0,o,d,i.DEPTH_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,this.context.bindFramebuffer.current))}updateAverageFPS(){this._fpsHistory.push(this._dt===0?0:1e3/this._dt),this._fpsHistory.length>this._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((i,o)=>i+o/this._fpsHistory.length,0))}render(i,o){const d=a.o.now();this._dt=d-this._timeStamp,this._timeStamp=d,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=i.map.repaint,this.style=i,this.options=o;const m=this.style._mergedLayers,y=!(!this.terrain||!this.terrain.enabled),v=()=>this.style._getOrder(y).filter(Pe=>{const we=m[Pe];return!(we.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[we.type]});let w=v(),E=!1,P=!1,R=null,O=0,k=!1;for(const Pe of w){const we=m[Pe];we.visibility!=="none"&&(we.type==="circle"?E=!0:we.type==="building"?(R=we,++O):we.type==="symbol"&&(we.hasOcclusionOpacityProperties?P=!0:E=!0))}this.updateEmissiveMode();let N=w.map(Pe=>m[Pe]);const j=this.style._mergedSourceCaches;this.imageManager=i.imageManager,this.modelManager=i.modelManager,this.symbolFadeChange=i.placement.symbolFadeChange(a.o.now()),this.imageManager.beginFrame();for(const Pe in j){const we=j[Pe];we.used&&(we.prepare(this.context),we.getSource().usedInConflation&&++O)}let U=!1;for(const Pe of N)Pe.isHidden(this.transform.zoom)||(Pe.type==="clip"&&(U=!0),this.prepareLayer(Pe));const X={},W={},ie={},ne={},K={};for(const Pe in j){const we=j[Pe];X[Pe]=we.getVisibleCoordinates(),W[Pe]=X[Pe].slice().reverse(),ie[Pe]=we.getVisibleCoordinates(!0).reverse(),ne[Pe]=we.getShadowCasterCoordinates(),K[Pe]=we.sortCoordinatesByDistance(X[Pe])}const xe=Pe=>{const we=this.style.getLayerSourceCache(Pe);return we&&we.used?we.getSource():null};if(O||U||this._clippingActiveLastFrame){const Pe=[],we=[];let Oe=0;for(const Ue of N)this.isSourceForClippingOrConflation(Ue,xe(Ue))&&(Pe.push(Ue),we.push(Oe)),Oe++;if(Pe&&(U||Pe.length>1)||this._clippingActiveLastFrame){U=!1;const Ue=[];for(let $e=0;$e<Pe.length;$e++){const ft=Pe[$e],lt=we[$e],ct=this.style.getLayerSourceCache(ft);if(!ct||!ct.used||!ct.getSource().usedInConflation&&ft.type!=="clip"&&ft.type!=="building")continue;let et=a.eK,Et=a.bA.None;const Mt=[];let vt=!0;if(ft.type==="building")et=a.eM;else if(ft.type==="clip")if(et=lt,ft.isHidden(this.transform.zoom))vt=!1;else{if(!ft.layout){vt=!1;continue}for(const St of ft.layout.get("clip-layer-types"))Et|=St==="model"?a.bA.Model:St==="symbol"?a.bA.Symbol:a.bA.FillExtrusion;for(const St of ft.layout.get("clip-layer-scope"))Mt.push(a.F(St,ft.scope));U=!0}vt&&Ue.push({layer:ft.fqid,cache:ct,order:et,clipMask:Et,clipScope:Mt})}this.replacementSource.setSources(Ue),k=!0}}this._clippingActiveLastFrame=U,k||this.replacementSource.clear(),this.conflationActive=k,this.minCutoffZoom=0,this.longestCutoffRange=0,this.maxFrontCutoffRawStart=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let Pe=0;Pe<N.length;Pe++){const we=N[Pe];if(we.visibility==="none")continue;const Oe=we.cutoffRange();if(this.longestCutoffRange=Math.max(Oe,this.longestCutoffRange),Oe>0){const Ue=xe(we);Ue&&(this.minCutoffZoom=Math.max(Ue.minzoom,this.minCutoffZoom)),we.minzoom&&(this.minCutoffZoom=Math.max(we.minzoom,this.minCutoffZoom))}we.is3D(y)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Pe),this._lastOcclusionLayer=Pe)}const le=this.style&&this.style.fog;le?(this._fogVisible=le.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=le.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(ie),this.opaquePassCutoff=0,w=v(),N=w.map(Pe=>m[Pe]));const _e=this._shadowRenderer;if(_e){_e.updateShadowParameters(this.transform,this.style.directionalLight);for(const Pe in j)for(const we of X[Pe]){let Oe={min:0,max:0};this.terrain&&(Oe=this.terrain.getMinMaxForTile(we)||Oe),_e.addShadowReceiver(we.toUnwrapped(),Oe.min,Oe.max)}}this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new a.eL(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new qy(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const re=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),ae=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(re&&!this._snow&&(this._snow=new ex(this)),!re&&this._snow&&(this._snow.destroy(),delete this._snow),ae&&!this._rain&&(this._rain=new uh(this)),!ae&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),R){this.buildingTileBorderManager||(this.buildingTileBorderManager=new fa);const Pe=this.style.getLayerSourceCache(R);this.buildingTileBorderManager.updateBorders(Pe,R)}if(!Hs.has(this.context.gl))return;this.renderPass="offscreen";for(const Pe of N){const we=i.getLayerSourceCache(Pe);if(!Pe.hasOffscreenPass()||Pe.isHidden(this.transform.zoom))continue;const Oe=we?W[we.id]:void 0;(Pe.type==="custom"||Pe.type==="raster"||Pe.type==="raster-particle"||Pe.isSky()||Oe&&Oe.length)&&this.renderLayer(this,we,Pe,Oe)}this.depthRangeFor3D=[0,1-(N.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,ne)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const fe=this.transform.projection.name==="globe"||this.transform.isHorizonVisible(),Ce=(()=>{if(o.showOverdrawInspector)return a.aq.black;const Pe=this.style.fog;if(Pe&&this.transform.projection.supportsFog){const we=this.style.getLut(Pe.scope);if(!fe){const Oe=Pe.properties.get("color-use-theme")==="none",Ue=Pe.properties.get("color").toNonPremultipliedRenderColor(Oe?null:we).toArray01();return new a.aq(...Ue)}if(fe){const Oe=Pe.properties.get("space-color-use-theme")==="none",Ue=Pe.properties.get("space-color").toNonPremultipliedRenderColor(Oe?null:we).toArray01();return new a.aq(...Ue)}}return a.aq.transparent})();if(this.context.clear({color:Ce,depth:1}),this.clearStencil(),this._showOverdrawInspector=o.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&fe&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=w.length-1;this.currentLayer>=0;this.currentLayer--){const Pe=N[this.currentLayer],we=i.getLayerSourceCache(Pe);if(Pe.isSky())continue;const Oe=we?(Pe.is3D(y)?K:W)[we.id]:void 0;this._renderTileClippingMasks(Pe,we,Oe),this.renderLayer(this,we,Pe,Oe)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&fe&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||a.al(this.transform.zoom)>0)&&(this.transform.projection.name==="globe"||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<w.length;this.currentLayer++){const Pe=N[this.currentLayer],we=i.getLayerSourceCache(Pe);Pe.isSky()&&this.renderLayer(this,we,Pe,we?W[we.id]:void 0)}function ve(Pe,we){let Oe;return we&&(Oe=(Pe.type==="symbol"?ie:Pe.is3D(y)?K:W)[we.id]),Oe}if(this.renderPass="translucent",this.transform.projection.name==="globe"){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<w.length;){const Pe=N[this.currentLayer];if(Pe.type==="raster"||Pe.type==="raster-particle"){const we=i.getLayerSourceCache(Pe);this.renderLayer(this,we,Pe,ve(Pe,we))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;const Ne=_e?_e.getGroundShadowLayerIndex():-1;let ze=!1,Je=-1;for(let Pe=0;Pe<w.length;++Pe){const we=N[Pe];we.isHidden(this.transform.zoom)||we.is3D(y)&&(Je=Pe)}P&&Je===-1&&(E=!0);let tt=!1;for(;this.currentLayer<w.length;){const Pe=N[this.currentLayer],we=i.getLayerSourceCache(Pe);if(Pe.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(Pe)){if(Pe.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer)}else{if(!tt&&Pe.is3D(y)&&!y){const Oe=this.currentLayer,Ue=$e=>{for(this.currentLayer=0;this.currentLayer<N.length;this.currentLayer++){const ft=N[this.currentLayer];if(Rm[ft.type]){const lt=this.style.getLayerSourceCache(ft);Rm[ft.type](this,lt,ft,ve(ft,lt),$e)}}};Ue("initialize"),Ue("reset"),this.currentLayer=Oe,tt=!0}if(E&&!ze&&this.terrain&&!this.transform.isOrthographic&&(ze=!0,this.blitDepth()),P&&Je!==-1&&this.currentLayer===Je+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(Pe,we,we?X[we.id]:void 0),this.renderLayer(this,we,Pe,ve(Pe,we)),!this.terrain&&_e&&this.currentLayer===Ne){{this.clearStencil(),this.resetStencilClippingMasks();const Oe=this.currentLayer;for(this.currentLayer=0;this.currentLayer<N.length;this.currentLayer++){const Ue=N[this.currentLayer];if(Dm[Ue.type]){const $e=this.style.getLayerSourceCache(Ue);Dm[Ue.type](this,$e,Ue,ve(Ue,$e))}}this.currentLayer=Oe}if(_e.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer){const Oe=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=Oe;this.currentLayer++){const Ue=N[this.currentLayer];if(!Ue.hasLightBeamPass())continue;const $e=i.getLayerSourceCache(Ue);this.renderLayer(this,$e,Ue,$e?W[$e.id]:void 0)}this.currentLayer=Oe,this.renderPass="translucent"}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const Oe=this.currentLayer;this.depthOcclusion=!0;for(const Ue of this.layersWithOcclusionOpacity){this.currentLayer=Ue;const $e=N[this.currentLayer],ft=i.getLayerSourceCache($e),lt=ft?W[ft.id]:void 0;this.terrain||this._renderTileClippingMasks($e,ft,ft?X[ft.id]:void 0),this.renderLayer(this,ft,$e,lt)}this.depthOcclusion=!1,this.currentLayer=Oe,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let Pe=null;N.forEach(we=>{const Oe=i.getLayerSourceCache(we);Oe&&!we.isHidden(this.transform.zoom)&&Oe.getVisibleCoordinates().length&&(!Pe||Pe.getSource().maxzoom<Oe.getSource().maxzoom)&&(Pe=Oe)}),Pe&&this.options.showTileBoundaries&&$y(this,Pe,Pe.getVisibleCoordinates(),a.aq.red,!1,this.options.showParseStatus)}this.terrain&&this._debugParams.showTerrainProxyTiles&&$y(this,this.terrain.proxySourceCache,this.terrain.proxyCoords,new a.aq(1,.8,.1,1),!0,this.options.showParseStatus),this.options.showPadding&&function(Pe){const we=Pe.transform.padding;Hy(Pe,Pe.transform.height-(we.top||0),3,vm),Hy(Pe,we.bottom||0,3,R1),wm(Pe,we.left||0,3,D1),wm(Pe,Pe.transform.width-(we.right||0),3,L1);const Oe=Pe.transform.centerPoint;(function(Ue,$e,ft,lt){Zd(Ue,$e-1,ft-10,2,20,lt),Zd(Ue,$e-10,ft-1,20,2,lt)})(Pe,Oe.x,Pe.transform.height-Oe.y,bm)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),k||(this.conflationActive=!1)}prepareLayer(i){this.gpuTimingStart(i);const{unsupportedLayers:o}=this.transform.projection,d=!o||!o.includes(i.type);if(Mm[i.type]&&(d||this.terrain&&i.type==="custom")){const m=this.style.getLayerSourceCache(i);Mm[i.type](i,m,this)}this.gpuTimingEnd()}renderLayer(i,o,d,m){d.isHidden(this.transform.zoom)||(d.type==="background"||d.type==="sky"||d.type==="custom"||d.type==="model"||d.type==="raster"||d.type==="raster-particle"||m&&m.length)&&(this.id=d.id,this.gpuTimingStart(d),i.transform.projection.unsupportedLayers&&i.transform.projection.unsupportedLayers.includes(d.type)&&(!i.terrain||d.type!=="custom")||d.type==="clip"||tx[d.type](i,o,d,m,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(i){if(!this.options.gpuTiming)return;const o=this.context.extTimerQuery,d=this.context.gl;let m=this.gpuTimers[i.id];m||(m=this.gpuTimers[i.id]={calls:0,cpuTime:0,query:d.createQuery()}),m.calls++,d.beginQuery(o.TIME_ELAPSED_EXT,m.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const i=this.context.extTimerQuery,o=this.context.gl,d=o.createQuery();this.deferredRenderGpuTimeQueries.push(d),o.beginQuery(i.TIME_ELAPSED_EXT,d)}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}collectGpuTimers(){const i=this.gpuTimers;return this.gpuTimers={},i}collectDeferredRenderGpuQueries(){const i=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],i}queryGpuTimers(i){const o={};for(const d in i){const m=i[d],y=this.context.extTimerQuery,v=y.getQueryParameter(m.query,this.context.gl.QUERY_RESULT)/1e6;y.deleteQueryEXT(m.query),o[d]=v}return o}queryGpuTimeDeferredRender(i){if(!this.options.gpuTimingDeferredRender)return 0;const o=this.context.gl;let d=0;for(const m of i)d+=o.getQueryParameter(m,o.QUERY_RESULT)/1e6,o.deleteQuery(m);return d}translatePosMatrix(i,o,d,m,y){if(!d[0]&&!d[1])return i;const v=y?m==="map"?this.transform.angle:0:m==="viewport"?-this.transform.angle:0;if(v){const P=Math.sin(v),R=Math.cos(v);d=[d[0]*R-d[1]*P,d[0]*P+d[1]*R]}const w=[y?d[0]:a.aA(o,d[0],this.transform.zoom),y?d[1]:a.aA(o,d[1],this.transform.zoom),0],E=new Float32Array(16);return a.bx(E,i,w),E}saveTileTexture(i){if(i.context!==this.context)return;const o=i.size[0],d=this._tileTextures[o];d?d.push(i):this._tileTextures[o]=[i]}getTileTexture(i){const o=this._tileTextures[i];return o&&o.length>0?o.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return this.context.extTextureFloatLinear!=null}currentGlobalDefines(i,o,d){const m=d===void 0?this.terrain&&this.terrain.renderingToTexture:d,y=[];return this.style&&this.style.enable3dLights()&&(i==="globeRaster"||i==="terrainRaster"?(y.push("LIGHTING_3D_MODE"),y.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):m||y.push("LIGHTING_3D_MODE")),this.terrainRenderModeElevated()&&(y.push("TERRAIN"),this.linearFloatFilteringSupported()&&y.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&y.push("GLOBE"),!this._fogVisible||m||o!==void 0&&!o||y.push("FOG"),m&&y.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&y.push("OVERDRAW_INSPECTOR"),y}getOrCreateProgram(i,o){this.cache=this.cache||{};const d=o&&o.defines||[],m=o&&o.config,y=this.currentGlobalDefines(i,o&&o.overrideFog,o&&o.overrideRtt).concat(d),v=Cl.cacheKey(hy[i],i,y,m);return this.cache[v]||(this.cache[v]=new Cl(this.context,i,hy[i],m,Nd[i],y)),this.cache[v]}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 i=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(i.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}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(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(i,o){if(this.style.enable3dLights()){const d=this.style.directionalLight,m=this.style.ambientLight;if(d&&m){const y=((v,w,E)=>{const P=v.properties.get("direction"),R=v.properties.get("color-use-theme")==="none",O=v.properties.get("color").toNonPremultipliedRenderColor(R?null:E.getLut(v.scope)).toArray01(),k=v.properties.get("intensity"),N=w.properties.get("color-use-theme")==="none",j=w.properties.get("color").toNonPremultipliedRenderColor(N?null:E.getLut(w.scope)).toArray01(),U=w.properties.get("intensity"),X=[P.x,P.y,P.z],W=a.dD(j,U),ie=a.dD(O,k);return{u_lighting_ambient_color:W,u_lighting_directional_dir:X,u_lighting_directional_color:ie,u_ground_radiance:om(X,ie,W)}})(d,m,this.style);o.setLightsUniformValues(i,y)}}}uploadCommonUniforms(i,o,d,m,y){if(this.uploadCommonLightUniforms(i,o),this.terrain&&this.terrain.renderingToTexture)return;const v=this.style.fog;if(v){const w=v.getOpacity(this.transform.pitch),E=((P,R,O,k,N,j,U,X,W,ie,ne,K)=>{const xe=P.transform,le=R.properties.get("color-use-theme")==="none",_e=R.properties.get("color").toNonPremultipliedRenderColor(le?null:P.style.getLut(R.scope)).toArray01();_e[3]=k;const re=P.frameCounter/1e3%1,[ae,fe]=R.properties.get("vertical-range");return{u_fog_matrix:O?xe.calculateFogTileMatrix(O):K||P.identityMat,u_fog_range:R.getFovAdjustedRange(xe._fov),u_fog_color:_e,u_fog_horizon_blend:R.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(ae,fe),fe],u_fog_temporal_offset:re,u_frustum_tl:N,u_frustum_tr:j,u_frustum_br:U,u_frustum_bl:X,u_globe_pos:W,u_globe_radius:ie,u_viewport:ne,u_globe_transition:a.al(xe.zoom),u_is_globe:+(xe.projection.name==="globe")}})(this,v,d,w,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*a.o.devicePixelRatio,this.transform.height*a.o.devicePixelRatio],m);o.setFogUniformValues(i,E)}y&&o.setCutoffUniformValues(i,y.uniformValues)}setTileLoadedFlag(i){this.tileLoaded=i}saveCanvasCopy(){const i=this.canvasCopy();i&&(this.frameCopies.push(i),this.tileLoaded=!1)}canvasCopy(){const i=this.context.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.copyTexImage2D(i.TEXTURE_2D,0,i.RGBA,0,0,i.drawingBufferWidth,i.drawingBufferHeight,0),o}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const i=this.style&&this.style.fog;return!!i&&i.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const i=this._backgroundTiles,o=this._backgroundTiles={},d=this.transform.coveringTiles({tileSize:512});for(const m of d)o[m.key]=i[m.key]||new a.b0(m,512,this.transform.tileZoom,this,void 0,this.worldview);return o}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(i,o){return!(!i.is3D(!(!this.terrain||!this.terrain.enabled))||i.type!=="clip"&&i.type!=="building"&&(i.minzoom&&i.minzoom>this.transform.zoom||(this.style._clipLayerPresent||i.sourceLayer!=="building"&&i.sourceLayer!=="procedural_buildings")&&(!o||o.type!=="batched-model")))}isTileAffectedByFog(i){if(!this.style||!this.style.fog)return!1;if(this.transform.projection.name==="globe")return!0;let o=this._cachedTileFogOpacities[i.key];return o||(this._cachedTileFogOpacities[i.key]=o=this.style.fog.getOpacityForTile(i)),o[0]>=_i||o[1]>=_i}setupDepthForOcclusion(i,o,d){const m=this.context,y=m.gl,v=!!d;var w;d||(d={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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),m.activeTexture.set(y.TEXTURE3),i&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(y.NEAREST,y.CLAMP_TO_EDGE),d.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],d.u_depth_range_unpack=[2/((w=this.depthRangeFor3D)[1]-w[0]),-1-2*w[0]/(w[1]-w[0])],d.u_occluder_half_size=.5*this.occlusionParams.occluderSize,d.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(y.NEAREST,y.CLAMP_TO_EDGE),m.activeTexture.set(y.TEXTURE0),v||o.setTerrainUniformValues(m,d)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const i=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=i?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function Lm(u,i){let o=!1,d=null;const m=()=>{d=null,o&&(u(),d=setTimeout(m,i),o=!1)};return()=>(o=!0,d||m(),d)}class O1{constructor(i){this._hashName=i&&encodeURIComponent(i),a.aZ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Lm(this._updateHashUnthrottled.bind(this),300)}addTo(i){return this._map=i,window.addEventListener("hashchange",this._onHashChange,!1),i.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 i=this._map;if(!i)return"";const o=jr(i);if(this._hashName){const d=this._hashName;let m=!1;const y=location.hash.slice(1).split("&").map(v=>{const w=v.split("=")[0];return w===d?(m=!0,`${w}=${o}`):v}).filter(v=>v);return m||y.push(`${d}=${o}`),`#${y.join("&")}`}return`#${o}`}_getCurrentHash(){const i=location.hash.replace("#","");if(this._hashName){let o;return i.split("&").map(d=>d.split("=")).forEach(d=>{d[0]===this._hashName&&(o=d)}),(o&&o[1]||"").split("/")}return i.split("/")}_onHashChange(){const i=this._map;if(!i)return!1;const o=this._getCurrentHash();if(o.length>=3&&!o.some(d=>isNaN(Number(d)))){const d=i.dragRotate.isEnabled()&&i.touchZoomRotate.isEnabled()?+(o[3]||0):i.getBearing();return i.jumpTo({center:[+o[2],+o[1]],zoom:+o[0],bearing:d,pitch:+(o[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function jr(u,i){const o=u.getCenter(),d=Math.round(100*u.getZoom())/100,m=Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10),y=Math.pow(10,m),v=Math.round(o.lng*y)/y,w=Math.round(o.lat*y)/y,E=u.getBearing(),P=u.getPitch();let R=i?`/${v}/${w}/${d}`:`${d}/${w}/${v}`;return(E||P)&&(R+="/"+Math.round(10*E)/10),P&&(R+=`/${Math.round(P)}`),R}const Qd={linearity:.3,easing:a.eN(0,0,.3,1)},hh=Object.assign({deceleration:2500,maxSpeed:1400},Qd),B1=Object.assign({deceleration:20,maxSpeed:1400},Qd),Qi=Object.assign({deceleration:1e3,maxSpeed:360},Qd),pi=Object.assign({deceleration:1e3,maxSpeed:90},Qd);class ix{constructor(i){this._map=i,this.clear()}clear(){this._inertiaBuffer=[]}record(i){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.o.now(),settings:i})}_drainInertiaBuffer(){const i=this._inertiaBuffer,o=a.o.now();for(;i.length>0&&o-i[0].time>160;)i.shift()}_onMoveEnd(i){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const o={zoom:0,bearing:0,pitch:0,pan:new a.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:y}of this._inertiaBuffer)o.zoom+=y.zoomDelta||0,o.bearing+=y.bearingDelta||0,o.pitch+=y.pitchDelta||0,y.panDelta&&o.pan._add(y.panDelta),y.around&&(o.around=y.around),y.pinchAround&&(o.pinchAround=y.pinchAround);const d=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,m={};if(o.pan.mag()){const y=Go(o.pan.mag(),d,Object.assign({},hh,i||{}));m.offset=o.pan.mult(y.amount/o.pan.mag()),m.center=this._map.transform.center,ms(m,y)}if(o.zoom){const y=Go(o.zoom,d,B1);m.zoom=this._map.transform.zoom+y.amount,ms(m,y)}if(o.bearing){const y=Go(o.bearing,d,Qi);m.bearing=this._map.transform.bearing+a.aC(y.amount,-179,179),ms(m,y)}if(o.pitch){const y=Go(o.pitch,d,pi);m.pitch=this._map.transform.pitch+y.amount,ms(m,y)}if(m.zoom||m.bearing){const y=o.pinchAround===void 0?o.around:o.pinchAround;m.around=y?this._map.unproject(y):this._map.getCenter()}return this.clear(),m.noMoveStart=!0,m}}function ms(u,i){(!u.duration||u.duration<i.duration)&&(u.duration=i.duration,u.easing=i.easing)}function Go(u,i,o){const{maxSpeed:d,linearity:m,deceleration:y}=o,v=a.aC(u*m/(i/1e3),-d,d),w=Math.abs(v)/(y*m);return{easing:o.easing,duration:1e3*w,amount:v*(w/2)}}class Sr extends a.C{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,o,d,m={}){const y=Tt(o.getCanvasContainer(),d),v=o.unproject(y);super(i,Object.assign({point:y,lngLat:v,originalEvent:d},m)),this._defaultPrevented=!1,this.target=o}}class Rs extends a.C{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,o,d){const m=i==="touchend"?d.changedTouches:d.touches,y=li(o.getCanvasContainer(),m),v=y.map(E=>o.unproject(E)),w=y.reduce((E,P,R,O)=>E.add(P.div(O.length)),new a.P(0,0));super(i,{points:y,point:w,lngLats:v,lngLat:o.unproject(w),originalEvent:d}),this._defaultPrevented=!1}}class zm extends a.C{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,o){super("wheel",{originalEvent:o}),this._defaultPrevented=!1}}class km{constructor(i,o){this._map=i,this._clickTolerance=o.clickTolerance}reset(){this._mousedownPos=void 0}wheel(i){return this._firePreventable(new zm(this._map,i))}mousedown(i,o){return this._mousedownPos=o,this._firePreventable(new Sr(i.type,this._map,i))}mouseup(i){this._map.fire(new Sr(i.type,this._map,i))}preclick(i){const o=new MouseEvent("preclick",i);this._map.fire(new Sr(o.type,this._map,o))}click(i,o){this._mousedownPos&&this._mousedownPos.dist(o)>=this._clickTolerance||(this.preclick(i),this._map.fire(new Sr(i.type,this._map,i)))}dblclick(i){return this._firePreventable(new Sr(i.type,this._map,i))}mouseover(i){this._map.fire(new Sr(i.type,this._map,i))}mouseout(i){this._map.fire(new Sr(i.type,this._map,i))}touchstart(i){return this._firePreventable(new Rs(i.type,this._map,i))}touchmove(i){this._map.fire(new Rs(i.type,this._map,i))}touchend(i){this._map.fire(new Rs(i.type,this._map,i))}touchcancel(i){this._map.fire(new Rs(i.type,this._map,i))}_firePreventable(i){if(this._map.fire(i),i.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Fm{constructor(i){this._map=i}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(i){this._map.fire(new Sr(i.type,this._map,i))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Sr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(i){this._delayContextMenu?this._contextMenuEvent=i:this._map.fire(new Sr(i.type,this._map,i)),this._map.listens("contextmenu")&&i.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Om{constructor(i,o){this._map=i,this._el=i.getCanvasContainer(),this._container=i.getContainer(),this._clickTolerance=o.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(i,o){this.isEnabled()&&i.shiftKey&&i.button===0&&(qe(),this._startPos=this._lastPos=o,this._active=!0)}mousemoveWindow(i,o){if(!this._active)return;const d=o,m=this._startPos,y=this._lastPos;if(!m||!y||y.equals(d)||!this._box&&d.dist(m)<this._clickTolerance)return;this._lastPos=d,this._box||(this._box=ke("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",i));const v=Math.min(m.x,d.x),w=Math.max(m.x,d.x),E=Math.min(m.y,d.y),P=Math.max(m.y,d.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${v}px,${E}px)`,this._box.style.width=w-v+"px",this._box.style.height=P-E+"px")})}mouseupWindow(i,o){if(!this._active)return;const d=this._startPos,m=o;if(d&&i.button===0){if(this.reset(),Rt(),d.x!==m.x||d.y!==m.y)return this._map.fire(new a.C("boxzoomend",{originalEvent:i})),{cameraAnimation:y=>y.fitScreenCoordinates(d,m,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",i)}}keydown(i){this._active&&i.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",i))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),ot(),delete this._startPos,delete this._lastPos}_fireEvent(i,o){return this._map.fire(new a.C(i,{originalEvent:o}))}}function dh(u,i){const o={};for(let d=0;d<u.length;d++)o[u[d].identifier]=i[d];return o}class Qs{constructor(i){this.reset(),this.numTouches=i.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(i,o,d){(this.centroid||d.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=i.timeStamp),d.length===this.numTouches&&(this.centroid=function(m){const y=new a.P(0,0);for(const v of m)y._add(v);return y.div(m.length)}(o),this.touches=dh(d,o)))}touchmove(i,o,d){if(this.aborted||!this.centroid)return;const m=dh(d,o);for(const y in this.touches){const v=m[y];(!v||v.dist(this.touches[y])>30)&&(this.aborted=!0)}}touchend(i,o,d){if((!this.centroid||i.timeStamp-this.startTime>500)&&(this.aborted=!0),d.length===0){const m=!this.aborted&&this.centroid;if(this.reset(),m)return m}}}class $o{constructor(i){this.singleTap=new Qs(i),this.numTaps=i.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(i,o,d){this.singleTap.touchstart(i,o,d)}touchmove(i,o,d){this.singleTap.touchmove(i,o,d)}touchend(i,o,d){const m=this.singleTap.touchend(i,o,d);if(m){const y=i.timeStamp-this.lastTime<500,v=!this.lastTap||this.lastTap.dist(m)<30;if(y&&v||this.reset(),this.count++,this.lastTime=i.timeStamp,this.lastTap=m,this.count===this.numTaps)return this.reset(),m}}}class Vc{constructor(){this._zoomIn=new $o({numTouches:1,numTaps:2}),this._zoomOut=new $o({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(i,o,d){this._zoomIn.touchstart(i,o,d),this._zoomOut.touchstart(i,o,d)}touchmove(i,o,d){this._zoomIn.touchmove(i,o,d),this._zoomOut.touchmove(i,o,d)}touchend(i,o,d){const m=this._zoomIn.touchend(i,o,d),y=this._zoomOut.touchend(i,o,d);return m?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:v=>v.easeTo({duration:300,zoom:v.getZoom()+1,around:v.unproject(m)},{originalEvent:i})}):y?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:v=>v.easeTo({duration:300,zoom:v.getZoom()-1,around:v.unproject(y)},{originalEvent:i})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const ef=0,Bm=2,Nm={[ef]:1,[Bm]:2},_a={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class fh{constructor(i){this.reset(),this._clickTolerance=i.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(i,o){return!1}_move(i,o){return{}}mousedown(i,o){if(this._lastPoint)return;const d=Xt(i);this._correctButton(i,d)&&(this._lastPoint=o,this._eventButton=d)}mousemoveWindow(i,o){const d=this._lastPoint;if(d){if(i.preventDefault(),this._eventButton!=null&&function(m,y){const v=Nm[y];return m.buttons===void 0||(m.buttons&v)!==v}(i,this._eventButton))this.reset();else if(this._moved||!(o.dist(d)<this._clickTolerance))return this._moved=!0,this._lastPoint=o,this._move(d,o)}}mouseupWindow(i){this._lastPoint&&Xt(i)===this._eventButton&&(this._moved&&Rt(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class eo extends fh{mousedown(i,o){super.mousedown(i,o),this._lastPoint&&(this._active=!0)}_correctButton(i,o){return o===0&&!i.ctrlKey}_move(i,o){return{around:o,panDelta:o.sub(i)}}}class tf extends fh{constructor(i){super(i),this._pitchRotateKey=i.pitchRotateKey?_a[i.pitchRotateKey]:void 0}_correctButton(i,o){return this._pitchRotateKey?o===0&&i[this._pitchRotateKey]:o===0&&i.ctrlKey||o===2}_move(i,o){const d=.8*(o.x-i.x);if(d)return this._active=!0,{bearingDelta:d}}contextmenu(i){this._pitchRotateKey||i.preventDefault()}}class ph extends fh{constructor(i){super(i),this._pitchRotateKey=i.pitchRotateKey?_a[i.pitchRotateKey]:void 0}_correctButton(i,o){return this._pitchRotateKey?o===0&&i[this._pitchRotateKey]:o===0&&i.ctrlKey||o===2}_move(i,o){const d=-.5*(o.y-i.y);if(d)return this._active=!0,{pitchDelta:d}}contextmenu(i){this._pitchRotateKey||i.preventDefault()}}class Vm{constructor(i,o){this._map=i,this._el=i.getCanvasContainer(),this._minTouches=1,this._clickTolerance=o.clickTolerance||1,this.reset(),a.aZ(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new a.P(0,0)}touchstart(i,o,d){return this._calculateTransform(i,o,d)}touchmove(i,o,d){if(this._active&&!(d.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(d.length===1&&!a.eO())return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return i.cancelable&&i.preventDefault(),this._calculateTransform(i,o,d)}}touchend(i,o,d){this._calculateTransform(i,o,d),this._active&&d.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(i,o,d){d.length>0&&(this._active=!0);const m=dh(d,o),y=new a.P(0,0),v=new a.P(0,0);let w=0;for(const P in m){const R=m[P],O=this._touches[P];O&&(y._add(R),v._add(R.sub(O)),w++,m[P]=R)}if(this._touches=m,w<this._minTouches||!v.mag())return;const E=v.div(w);return this._sum._add(E),this._sum.mag()<this._clickTolerance?void 0:{around:y.div(w),panDelta:E}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=ke("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class mh{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(i){}_move(i,o,d){return{}}touchstart(i,o,d){this._firstTwoTouches||d.length<2||(this._firstTwoTouches=[d[0].identifier,d[1].identifier],this._start([o[0],o[1]]))}touchmove(i,o,d){const m=this._firstTwoTouches;if(!m)return;i.preventDefault();const[y,v]=m,w=Tn(d,o,y),E=Tn(d,o,v);if(!w||!E)return;const P=this._aroundCenter?null:w.add(E).div(2);return this._move([w,E],P,i)}touchend(i,o,d){if(!this._firstTwoTouches)return;const[m,y]=this._firstTwoTouches,v=Tn(d,o,m),w=Tn(d,o,y);v&&w||(this._active&&Rt(),this.reset())}touchcancel(){this.reset()}enable(i){this._enabled=!0,this._aroundCenter=!!i&&i.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Tn(u,i,o){for(let d=0;d<u.length;d++)if(u[d].identifier===o)return i[d]}function nf(u,i){return Math.log2(u/i)}class Um extends mh{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(i){this._startDistance=this._distance=i[0].dist(i[1])}_move(i,o){const d=this._distance;if(this._distance=i[0].dist(i[1]),this._active||!(Math.abs(nf(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:nf(this._distance,d),pinchAround:o}}}function rf(u,i){return 180*u.angleWith(i)/Math.PI}class kl extends mh{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(i){this._startVector=this._vector=i[0].sub(i[1]),this._minDiameter=i[0].dist(i[1])}_move(i,o){const d=this._vector;if(this._vector=i[0].sub(i[1]),d&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:rf(this._vector,d),pinchAround:o}}_isBelowThreshold(i){this._minDiameter=Math.min(this._minDiameter,i.mag());const o=25/(Math.PI*this._minDiameter)*360,d=this._startVector;if(!d)return!1;const m=rf(i,d);return Math.abs(m)<o}}function _h(u){return Math.abs(u.y)>Math.abs(u.x)}class jm extends mh{constructor(i){super(),this._map=i}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(i){this._lastPoints=i,_h(i[0].sub(i[1]))&&(this._valid=!1)}_move(i,o,d){const m=this._lastPoints;if(!m)return;const y=i[0].sub(m[0]),v=i[1].sub(m[1]);return this._map._cooperativeGestures&&!a.eO()&&d.touches.length<3||(this._valid=this.gestureBeginsVertically(y,v,d.timeStamp),!this._valid)?void 0:(this._lastPoints=i,this._active=!0,{pitchDelta:(y.y+v.y)/2*-.5})}gestureBeginsVertically(i,o,d){if(this._valid!==void 0)return this._valid;const m=i.mag()>=2,y=o.mag()>=2;if(!m&&!y)return;if(!m||!y)return this._firstMove==null&&(this._firstMove=d),d-this._firstMove<100&&void 0;const v=i.y>0==o.y>0;return _h(i)&&_h(o)&&v}}const Gm={panStep:100,bearingStep:15,pitchStep:10};class Fl{constructor(){const i=Gm;this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(i){if(i.altKey||i.ctrlKey||i.metaKey)return;let o=0,d=0,m=0,y=0,v=0;switch(i.keyCode){case 61:case 107:case 171:case 187:o=1;break;case 189:case 109:case 173:o=-1;break;case 37:i.shiftKey?d=-1:(i.preventDefault(),y=-1);break;case 39:i.shiftKey?d=1:(i.preventDefault(),y=1);break;case 38:i.shiftKey?m=1:(i.preventDefault(),v=-1);break;case 40:i.shiftKey?m=-1:(i.preventDefault(),v=1);break;default:return}return this._rotationDisabled&&(d=0,m=0),{cameraAnimation:w=>{const E=w.getZoom();w.easeTo({duration:300,easeId:"keyboardHandler",easing:$m,zoom:o?Math.round(E)+o*(i.shiftKey?2:1):E,bearing:w.getBearing()+d*this._bearingStep,pitch:w.getPitch()+m*this._pitchStep,offset:[-y*this._panStep,-v*this._panStep],center:w.getCenter()},{originalEvent:i})}}}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 $m(u){return u*(2-u)}const Ol=4.000244140625,Hm=1/450;class sf{constructor(i,o){this._map=i,this._el=i.getCanvasContainer(),this._handler=o,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Hm,a.aZ(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(i){this._defaultZoomRate=i}setWheelZoomRate(i){this._wheelZoomRate=i}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(i){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!i&&i.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(i){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(i.ctrlKey||i.metaKey||this.isZooming()||a.eO()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let o=i.deltaMode===WheelEvent.DOM_DELTA_LINE?40*i.deltaY:i.deltaY;const d=a.o.now(),m=d-(this._lastWheelEventTime||0);this._lastWheelEventTime=d,o!==0&&o%Ol===0?this._type="wheel":o!==0&&Math.abs(o)<4?this._type="trackpad":m>400?(this._type=null,this._lastValue=o,this._timeout=window.setTimeout(this._onTimeout,40,i)):this._type||(this._type=Math.abs(m*o)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,o+=this._lastValue)),i.shiftKey&&o&&(o/=4),this._type&&(this._lastWheelEvent=i,this._delta-=o,this._active||this._start(i)),i.preventDefault()}_onTimeout(i){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(i)}_start(i){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 o=Tt(this._el,i);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:o,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const i=this._map.transform;this._type==="wheel"&&i.projection.wrap&&(i._center.lng>=180||i._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const o=()=>i._terrainEnabled()&&this._aroundCoord?i.computeZoomRelativeTo(this._aroundCoord):i.zoom;if(this._delta!==0){const P=this._type==="wheel"&&Math.abs(this._delta)>Ol?this._wheelZoomRate:this._defaultZoomRate;let R=2/(1+Math.exp(-Math.abs(this._delta*P)));this._delta<0&&R!==0&&(R=1/R);const O=o(),k=Math.pow(2,O),N=typeof this._targetZoom=="number"?i.zoomScale(this._targetZoom):k;this._targetZoom=Math.min(i.maxZoom,Math.max(i.minZoom,i.scaleZoom(N*R))),this._type==="wheel"&&(this._startZoom=O,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const d=typeof this._targetZoom=="number"?this._targetZoom:o(),m=this._startZoom,y=this._easing;let v,w=!1;if(this._type==="wheel"&&m&&y){const P=Math.min((a.o.now()-this._lastWheelEventTime)/200,1),R=y(P);v=a.am(m,d,R),P<1?this._frameId||(this._frameId=!0):w=!0}else v=d,w=!0;this._active=!0,w&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let E=v-o();return E*this._lastDelta<0&&(E=0),{noInertia:!0,needsRenderFrame:!w,zoomDelta:E,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(i){let o=a.eP;if(this._prevEase){const d=this._prevEase,m=(a.o.now()-d.start)/d.duration,y=d.easing(m+.01)-d.easing(m),v=.27/Math.sqrt(y*y+1e-4)*.01,w=Math.sqrt(.0729-v*v);o=a.eN(v,w,.25,1)}return this._prevEase={start:a.o.now(),duration:i,easing:o},o}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=ke("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=`${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=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class of{constructor(i,o){this._clickZoom=i,this._tapZoom=o}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 af{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(i,o){return i.preventDefault(),{cameraAnimation:d=>{d.easeTo({duration:300,zoom:d.getZoom()+(i.shiftKey?-1:1),around:d.unproject(o)},{originalEvent:i})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class nx{constructor(){this._tap=new $o({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(i,o,d){this._swipePoint||(this._tapTime&&i.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?d.length>0&&(this._swipePoint=o[0],this._swipeTouch=d[0].identifier):this._tap.touchstart(i,o,d))}touchmove(i,o,d){if(this._tapTime){if(this._swipePoint){if(d[0].identifier!==this._swipeTouch)return;const m=o[0],y=m.y-this._swipePoint.y;return this._swipePoint=m,i.preventDefault(),this._active=!0,{zoomDelta:y/128}}}else this._tap.touchmove(i,o,d)}touchend(i,o,d){this._tapTime?this._swipePoint&&d.length===0&&this.reset():this._tap.touchend(i,o,d)&&(this._tapTime=i.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zm{constructor(i,o,d){this._el=i,this._mousePan=o,this._touchPan=d}enable(i){this._inertiaOptions=i||{},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 rx{constructor(i,o,d){this._pitchWithRotate=i.pitchWithRotate,this._mouseRotate=o,this._mousePitch=d}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 sx{constructor(i,o,d,m){this._el=i,this._touchZoom=o,this._touchRotate=d,this._tapDragZoom=m,this._rotationDisabled=!1,this._enabled=!0}enable(i){this._touchZoom.enable(i),this._rotationDisabled||this._touchRotate.enable(i),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 gh=u=>u.zoom||u.drag||u.pitch||u.rotate;class ox extends a.C{}class ax{constructor(){this.constants=[1,1,.01],this.radius=0}setup(i,o){const d=a.ax([],o,i);this.radius=a.ai(d[2]<0?a.eR([],d,this.constants):[d[0],d[1],0])}projectRay(i){a.eR(i,i,this.constants),a.ay(i,i),a.eS(i,i,this.constants);const o=a.bJ([],i,this.radius);if(o[2]>0){const d=a.bJ([],[0,0,1],a.bi(o,[0,0,1])),m=a.bJ([],a.ay([],[o[0],o[1],0]),this.radius),y=a.cT([],o,a.bJ([],a.ax([],a.cT([],m,d),o),2));o[0]=y[0],o[1]=y[1]}return o}}function yh(u){return u.panDelta&&u.panDelta.mag()||u.zoomDelta||u.bearingDelta||u.pitchDelta}class lx{constructor(i,o){this._map=i,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ix(i),this._bearingSnap=o.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new ax,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(o),a.aZ(["handleEvent","handleWindowEvent"],this);const d=this._el;this._listeners=[[d,"touchstart",{passive:!0}],[d,"touchmove",{passive:!1}],[d,"touchend",void 0],[d,"touchcancel",void 0],[d,"mousedown",void 0],[d,"mousemove",void 0],[d,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[d,"mouseover",void 0],[d,"mouseout",void 0],[d,"dblclick",void 0],[d,"click",void 0],[d,"keydown",{capture:!1}],[d,"keyup",void 0],[d,"wheel",{passive:!1}],[d,"contextmenu",void 0],[window,"blur",void 0]];for(const[m,y,v]of this._listeners){const w=m===document?this.handleWindowEvent:this.handleEvent;m.addEventListener(y,w,v)}}destroy(){for(const[i,o,d]of this._listeners){const m=i===document?this.handleWindowEvent:this.handleEvent;i.removeEventListener(o,m,d)}}_addDefaultHandlers(i){const o=this._map,d=o.getCanvasContainer();this._add("mapEvent",new km(o,i));const m=o.boxZoom=new Om(o,i);this._add("boxZoom",m);const y=new Vc,v=new af;o.doubleClickZoom=new of(v,y),this._add("tapZoom",y),this._add("clickZoom",v);const w=new nx;this._add("tapDragZoom",w);const E=o.touchPitch=new jm(o);this._add("touchPitch",E);const P=new tf(i),R=new ph(i);o.dragRotate=new rx(i,P,R),this._add("mouseRotate",P,["mousePitch"]),this._add("mousePitch",R,["mouseRotate"]);const O=new eo(i),k=new Vm(o,i);o.dragPan=new Zm(d,O,k),this._add("mousePan",O),this._add("touchPan",k,["touchZoom","touchRotate"]);const N=new kl,j=new Um;o.touchZoomRotate=new sx(d,j,N,w),this._add("touchRotate",N,["touchPan","touchZoom"]),this._add("touchZoom",j,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Fm(o));const U=o.scrollZoom=new sf(o,this);this._add("scrollZoom",U,["mousePan"]);const X=o.keyboard=new Fl;this._add("keyboard",X);for(const W of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])i.interactive&&i[W]&&o[W].enable(i[W])}_add(i,o,d){this._handlers.push({handlerName:i,handler:o,allowed:d}),this._handlersById[i]=o}stop(i){if(!this._updatingCamera){for(const{handler:o}of this._handlers)o.reset();this._inertia.clear(),this._fireEvents({},{},i),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:i}of this._handlers)if(i.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!gh(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(i,o,d){for(const m in i)if(m!==d&&(!o||o.indexOf(m)<0))return!0;return!1}handleWindowEvent(i){this.handleEvent(i,`${i.type}Window`)}_getMapTouches(i){const o=[];for(const d of i)this._el.contains(d.target)&&o.push(d);return o}handleEvent(i,o){this._updatingCamera=!0;const d=i.type==="renderFrame",m=d?void 0:i,y={needsRenderFrame:!1},v={},w={},E=i.touches?this._getMapTouches(i.touches):void 0,P=E?li(this._el,E):d?void 0:Tt(this._el,i);for(const{handlerName:k,handler:N,allowed:j}of this._handlers){if(!N.isEnabled())continue;let U;this._blockedByActive(w,j,k)?N.reset():N[o||i.type]&&(U=N[o||i.type](i,P,E),this.mergeHandlerResult(y,v,U,k,m),U&&U.needsRenderFrame&&this._triggerRenderFrame()),(U||N.isActive())&&(w[k]=N)}const R={};for(const k in this._previousActiveHandlers)w[k]||(R[k]=m);this._previousActiveHandlers=w,(Object.keys(R).length||yh(y))&&(this._changes.push([y,v,R]),this._triggerRenderFrame()),(Object.keys(w).length||yh(y))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:O}=y;O&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],O(this._map))}mergeHandlerResult(i,o,d,m,y){if(!d)return;Object.assign(i,d);const v={handlerName:m,originalEvent:d.originalEvent||y};d.zoomDelta!==void 0&&(o.zoom=v),d.panDelta!==void 0&&(o.drag=v),d.pitchDelta!==void 0&&(o.pitch=v),d.bearingDelta!==void 0&&(o.rotate=v)}_applyChanges(){const i={},o={},d={};for(const[m,y,v]of this._changes)m.panDelta&&(i.panDelta=(i.panDelta||new a.P(0,0))._add(m.panDelta)),m.zoomDelta&&(i.zoomDelta=(i.zoomDelta||0)+m.zoomDelta),m.bearingDelta&&(i.bearingDelta=(i.bearingDelta||0)+m.bearingDelta),m.pitchDelta&&(i.pitchDelta=(i.pitchDelta||0)+m.pitchDelta),m.around!==void 0&&(i.around=m.around),m.aroundCoord!==void 0&&(i.aroundCoord=m.aroundCoord),m.pinchAround!==void 0&&(i.pinchAround=m.pinchAround),m.noInertia&&(i.noInertia=m.noInertia),Object.assign(o,y),Object.assign(d,v);this._updateMapTransform(i,o,d),this._changes=[]}_updateMapTransform(i,o,d){const m=this._map,y=m.transform,v=ie=>[ie.x,ie.y,ie.z];if((()=>{const ie=this._eventsInProgress.drag;return ie&&!this._handlersById[ie.handlerName].isActive()})()&&!yh(i)){const ie=y.zoom;y.cameraElevationReference="sea",this._originalZoom!=null&&y._orthographicProjectionAtLowPitch&&y.projection.name!=="globe"&&y.pitch===0?(y.cameraElevationReference="ground",y.zoom=this._originalZoom):(y.recenterOnTerrain(),y.cameraElevationReference="ground"),ie!==y.zoom&&this._map._update(!0)}if(y._isCameraConstrained&&m._stop(!0),!yh(i))return void this._fireEvents(o,d,!0);let{panDelta:w,zoomDelta:E,bearingDelta:P,pitchDelta:R,around:O,aroundCoord:k,pinchAround:N}=i;y._isCameraConstrained&&(E>0&&(E=0),y._isCameraConstrained=!1),N!==void 0&&(O=N),(E||(ie=>o[ie]&&!this._eventsInProgress[ie])("drag"))&&O&&(this._dragOrigin=v(y.pointCoordinate3D(O)),this._originalZoom=y.zoom,this._trackingEllipsoid.setup(y._camera.position,this._dragOrigin)),y.cameraElevationReference="sea",m._stop(!0),O=O||m.transform.centerPoint,P&&(y.bearing+=P),R&&(y.pitch+=R),y._updateCameraState();const j=[0,0,0];if(w)if(y.projection.name==="mercator"){const ie=this._trackingEllipsoid.projectRay(y.screenPointToMercatorRay(O).dir),ne=this._trackingEllipsoid.projectRay(y.screenPointToMercatorRay(O.sub(w)).dir);j[0]=ne[0]-ie[0],j[1]=ne[1]-ie[1]}else{const ie=y.pointCoordinate(O);if(y.projection.name==="globe"){w=w.rotate(-y.angle);const ne=y._pixelsPerMercatorPixel/y.worldSize;j[0]=-w.x*a.eQ(a.bV(ie.y))*ne,j[1]=-w.y*a.eQ(y.center.lat)*ne}else{const ne=y.pointCoordinate(O.sub(w));ie&&ne&&(j[0]=ne.x-ie.x,j[1]=ne.y-ie.y)}}const U=y.zoom,X=[0,0,0];if(E){const ie=v(k||y.pointCoordinate3D(O)),ne={dir:a.ay([],a.ax([],ie,y._camera.position))};if(ne.dir[2]<0){const K=y.zoomDeltaToMovement(ie,E);a.bJ(X,ne.dir,K)}}const W=a.cT(j,j,X);y._translateCameraConstrained(W),E&&Math.abs(y.zoom-U)>1e-4&&y.recenterOnTerrain(),y.cameraElevationReference="ground",this._map._update(),i.noInertia||this._inertia.record(i),this._fireEvents(o,d,!0)}_fireEvents(i,o,d){const m=gh(this._eventsInProgress),y=gh(i),v={};for(const R in i){const{originalEvent:O}=i[R];this._eventsInProgress[R]||(v[`${R}start`]=O),this._eventsInProgress[R]=i[R]}!m&&y&&this._fireEvent("movestart",y.originalEvent);for(const R in v)this._fireEvent(R,v[R]);y&&this._fireEvent("move",y.originalEvent);for(const R in i){const{originalEvent:O}=i[R];this._fireEvent(R,O)}const w={};let E;for(const R in this._eventsInProgress){const{handlerName:O,originalEvent:k}=this._eventsInProgress[R];this._handlersById[O].isActive()||(delete this._eventsInProgress[R],E=o[O]||k,w[`${R}end`]=E)}for(const R in w)this._fireEvent(R,w[R]);const P=gh(this._eventsInProgress);if(d&&(m||y)&&!P){this._updatingCamera=!0;const R=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),O=k=>k!==0&&-this._bearingSnap<k&&k<this._bearingSnap;R?(O(R.bearing||this._map.getBearing())&&(R.bearing=0),this._map.easeTo(R,{originalEvent:E})):(this._map.fire(new a.C("moveend",{originalEvent:E})),O(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(i,o){this._map.fire(new a.C(i,o?{originalEvent:o}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(i=>{this._frameId=void 0,this.handleEvent(new ox("renderFrame",{timeStamp:i})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const qm="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class cx extends a.E{constructor(i,o){super(),this._moving=!1,this._zooming=!1,this.transform=i,this._bearingSnap=o.bearingSnap,this._respectPrefersReducedMotion=o.respectPrefersReducedMotion!==!1,a.aZ(["_renderFrameCallback"],this)}getCenter(){return new a.aU(this.transform.center.lng,this.transform.center.lat)}setCenter(i,o){return this.jumpTo({center:i},o)}panBy(i,o,d){return i=a.P.convert(i).mult(-1),this.panTo(this.transform.center,Object.assign({offset:i},o),d)}panTo(i,o,d){return this.easeTo(Object.assign({center:i},o),d)}getZoom(){return this.transform.zoom}setZoom(i,o){return this.jumpTo({zoom:i},o),this}zoomTo(i,o,d){return this.easeTo(Object.assign({zoom:i},o),d)}zoomIn(i,o){return this.zoomTo(this.getZoom()+1,i,o),this}zoomOut(i,o){return this.zoomTo(this.getZoom()-1,i,o),this}getBearing(){return this.transform.bearing}setBearing(i,o){return this.jumpTo({bearing:i},o),this}getPadding(){return this.transform.padding}setPadding(i,o){return this.jumpTo({padding:i},o),this}rotateTo(i,o,d){return this.easeTo(Object.assign({bearing:i},o),d)}resetNorth(i,o){return this.rotateTo(0,Object.assign({duration:1e3},i),o),this}resetNorthPitch(i,o){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},i),o),this}snapToNorth(i,o){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(i,o):this}getPitch(){return this.transform.pitch}setPitch(i,o){return this.jumpTo({pitch:i},o),this}cameraForBounds(i,o){i=a.aK.convert(i);const d=o&&o.bearing||0,m=o&&o.pitch||0,y=i.getNorthWest(),v=i.getSouthEast();return this._cameraForBounds(this.transform,y,v,d,m,o)}_extendPadding(i){const o={top:0,right:0,bottom:0,left:0};return i==null?Object.assign({},o,this.transform.padding):typeof i=="number"?{top:i,bottom:i,right:i,left:i}:Object.assign({},o,i)}_extendCameraOptions(i){return(i=Object.assign({offset:[0,0],maxZoom:this.transform.maxZoom},i)).padding=this._extendPadding(i.padding),i}_minimumAABBFrustumDistance(i,o){const d=o.max[0]-o.min[0],m=o.max[1]-o.min[1];return d/m>i.aspect?d/(2*Math.tan(.5*i.fovX)*i.aspect):m/(2*Math.tan(.5*i.fovY)*i.aspect)}_cameraForBoundsOnGlobe(i,o,d,m,y,v){const w=i.clone(),E=this._extendCameraOptions(v);w.bearing=m,w.pitch=y;const P=a.aU.convert(o),R=a.aU.convert(d),O=.5*(P.lat+R.lat),k=.5*(P.lng+R.lng),N=a.eT(O,k),j=a.ay([],N),U=a.ay([],a.bh([],j,[0,1,0])),X=a.bh([],U,j),W=[U[0],U[1],U[2],0,X[0],X[1],X[2],0,j[0],j[1],j[2],0,0,0,0,1],ie=[N,a.eT(P.lat,P.lng),a.eT(R.lat,P.lng),a.eT(R.lat,R.lng),a.eT(P.lat,R.lng),a.eT(O,P.lng),a.eT(O,R.lng),a.eT(P.lat,k),a.eT(R.lat,k)];let ne=a.cU.fromPoints(ie.map(Ue=>[a.bi(U,Ue),a.bi(X,Ue),a.bi(j,Ue)]));const K=a.ah([],ne.center,W);a.eU(K)===0&&a.eV(K,0,0,1),a.ay(K,K),a.bJ(K,K,a.aF),w.center=a.eW(K);const xe=w.getWorldToCameraMatrix(),le=a.b7(new Float64Array(16),xe);ne=a.cU.applyTransform(ne,a.aD([],xe,W));const _e=this._extendAABB(ne,w,E,m);if(!_e)return void a.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ne=_e,a.ah(K,K,xe);const re=.5*(ne.max[2]-ne.min[2]),ae=this._minimumAABBFrustumDistance(w,ne),fe=a.bJ([],[0,0,1],re),Ce=a.cT(fe,K,fe),ve=ae+(w.pitch===0?0:a.bf(K,Ce)),Ne=w.globeCenterInViewSpace,ze=a.ax([],K,[Ne[0],Ne[1],Ne[2]]);a.ay(ze,ze),a.bJ(ze,ze,ve);const Je=a.cT([],K,ze);a.ah(Je,Je,le);const tt=a.eD/a.aF,Pe=a.ai(Je),we=a.bU(Math.max(Pe*tt-a.eD,Number.EPSILON),0),Oe=Math.min(w.zoomFromMercatorZAdjusted(we),E.maxZoom);return Oe>.5*(a.cJ+a.cv)?(w.setProjection({name:"mercator"}),w.zoom=Oe,this._cameraForBounds(w,o,d,m,y,v)):{center:w.center,zoom:Oe,bearing:m,pitch:y}}_extendAABB(i,o,d,m){const y=.5*((d.padding.left||0)+(d.padding.right||0)),v=.5*((d.padding.top||0)+(d.padding.bottom||0)),w=v,E=y,P=y,R=v,O=o.width-(E+P),k=o.height-(w+R),N=a.ax([],i.max,i.min),j=Math.min(O/N[0],k/N[1]),U=Math.min(o.scaleZoom(o.scale*j),d.maxZoom);if(isNaN(U))return null;const X=o.scale/o.zoomScale(U),W=new a.cU([i.min[0]-E*X,i.min[1]-R*X,i.min[2]],[i.max[0]+P*X,i.max[1]+w*X,i.max[2]]),ie=(typeof d.offset.x=="number"&&typeof d.offset.y=="number"?new a.P(d.offset.x,d.offset.y):a.P.convert(d.offset)).rotate(-a.ap(m));return W.center[0]-=ie.x*X,W.center[1]+=ie.y*X,W}queryTerrainElevation(i,o){const d=this.transform.elevation;return d?(o=Object.assign({},{exaggerated:!0},o),d.getAtPoint(a.ag.fromLngLat(i),null,o.exaggerated)):null}_cameraForBounds(i,o,d,m,y,v){if(i.projection.name==="globe")return this._cameraForBoundsOnGlobe(i,o,d,m,y,v);const w=i.clone(),E=this._extendCameraOptions(v);w.bearing=m,w.pitch=y;const P=a.aU.convert(o),R=a.aU.convert(d),O=new a.aU(P.lng,R.lat),k=new a.aU(R.lng,P.lat),N=w.project(P),j=w.project(R),U=this.queryTerrainElevation(P),X=this.queryTerrainElevation(R),W=this.queryTerrainElevation(O),ie=this.queryTerrainElevation(k),ne=[[N.x,N.y,Math.min(U||0,X||0,W||0,ie||0)],[j.x,j.y,Math.max(U||0,X||0,W||0,ie||0)]];let K=a.cU.fromPoints(ne);const xe=w.getWorldToCameraMatrix(),le=a.b7(new Float64Array(16),xe);K=a.cU.applyTransform(K,xe);const _e=this._extendAABB(K,w,E,m);if(!_e)return void a.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");K=_e;const re=.5*a.ax([],K.max,K.min)[2],ae=this._minimumAABBFrustumDistance(w,K),fe=[0,0,1,0];a.aE(fe,fe,xe),a.eX(fe,fe);const Ce=a.bJ([],fe,ae+re),ve=a.cT([],K.center,Ce);a.ah(K.center,K.center,le),a.ah(ve,ve,le);const Ne=w.unproject(new a.P(K.center[0],K.center[1])),ze=a.eY(w.projection,Ne),Je=Math.pow(2,ze),tt=Math.min(w._zoomFromMercatorZ(ve[2]*w.pixelsPerMeter*Je/w.worldSize),E.maxZoom);return w.mercatorFromTransition&&tt<.5*(a.cJ+a.cv)?(w.setProjection({name:"globe"}),w.zoom=tt,this._cameraForBounds(w,o,d,m,y,v)):{center:Ne,zoom:tt,bearing:m,pitch:y}}fitBounds(i,o,d){const m=this.cameraForBounds(i,o);return this._fitInternal(m,o,d)}fitScreenCoordinates(i,o,d,m,y){const v=a.P.convert(i),w=a.P.convert(o),E=new a.P(Math.min(v.x,w.x),Math.min(v.y,w.y)),P=new a.P(Math.max(v.x,w.x),Math.max(v.y,w.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(v,w))return this;const R=this.transform.pointLocation3D(E),O=this.transform.pointLocation3D(P),k=this.transform.pointLocation3D(new a.P(E.x,P.y)),N=this.transform.pointLocation3D(new a.P(P.x,E.y)),j=[Math.min(R.lng,O.lng,k.lng,N.lng),Math.min(R.lat,O.lat,k.lat,N.lat)],U=[Math.max(R.lng,O.lng,k.lng,N.lng),Math.max(R.lat,O.lat,k.lat,N.lat)],X=m&&m.pitch?m.pitch:this.getPitch(),W=this._cameraForBounds(this.transform,j,U,d,X,m);return this._fitInternal(W,m,y)}_fitInternal(i,o,d){return i?(o=Object.assign(i,o)).linear?this.easeTo(o,d):this.flyTo(o,d):this}jumpTo(i,o){this.stop();const d=i.preloadOnly?this.transform.clone():this.transform;let m=!1,y=!1,v=!1;"zoom"in i&&d.zoom!==+i.zoom&&(m=!0,d.zoom=+i.zoom),i.center!==void 0&&(d.center=a.aU.convert(i.center)),"bearing"in i&&d.bearing!==+i.bearing&&(y=!0,d.bearing=+i.bearing),"pitch"in i&&d.pitch!==+i.pitch&&(v=!0,d.pitch=+i.pitch);const w=typeof i.padding=="number"?this._extendPadding(i.padding):i.padding;if(i.padding!=null&&!d.isPaddingEqual(w))if(i.retainPadding===!1){const E=d.clone();E.padding=w,d.setLocationAtPoint(d.center,E.centerPoint)}else d.padding=w;return i.preloadOnly?(this._preloadTiles(d),this):(this.fire(new a.C("movestart",o)).fire(new a.C("move",o)),m&&this.fire(new a.C("zoomstart",o)).fire(new a.C("zoom",o)).fire(new a.C("zoomend",o)),y&&this.fire(new a.C("rotatestart",o)).fire(new a.C("rotate",o)).fire(new a.C("rotateend",o)),v&&this.fire(new a.C("pitchstart",o)).fire(new a.C("pitch",o)).fire(new a.C("pitchend",o)),this.fire(new a.C("moveend",o)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||a.w(qm),this.transform.getFreeCameraOptions()}setFreeCameraOptions(i,o){const d=this.transform;if(!d.projection.supportsFreeCamera)return a.w(qm),this;this.stop();const m=d.zoom,y=d.pitch,v=d.bearing;d.setFreeCameraOptions(i);const w=m!==d.zoom,E=y!==d.pitch,P=v!==d.bearing;return this.fire(new a.C("movestart",o)).fire(new a.C("move",o)),w&&this.fire(new a.C("zoomstart",o)).fire(new a.C("zoom",o)).fire(new a.C("zoomend",o)),P&&this.fire(new a.C("rotatestart",o)).fire(new a.C("rotate",o)).fire(new a.C("rotateend",o)),E&&this.fire(new a.C("pitchstart",o)).fire(new a.C("pitch",o)).fire(new a.C("pitchend",o)),this.fire(new a.C("moveend",o)),this}easeTo(i,o){this._stop(!1,i.easeId),((i=Object.assign({offset:[0,0],duration:500,easing:a.eP},i)).animate===!1||this._prefersReducedMotion(i))&&(i.duration=0);const d=this.transform,m=this.getZoom(),y=this.getBearing(),v=this.getPitch(),w=this.getPadding(),E="zoom"in i?+i.zoom:m,P="bearing"in i?this._normalizeBearing(i.bearing,y):y,R="pitch"in i?+i.pitch:v,O=this._extendPadding(i.padding),k=a.P.convert(i.offset);let N,j,U;if(d.projection.name==="globe"){const fe=a.ag.fromLngLat(d.center),Ce=k.rotate(-d.angle);fe.x+=Ce.x/d.worldSize,fe.y+=Ce.y/d.worldSize;const ve=fe.toLngLat(),Ne=a.aU.convert(i.center||ve);this._normalizeCenter(Ne),N=d.centerPoint.add(Ce),j=new a.P(fe.x,fe.y).mult(d.worldSize),U=new a.P(a.aH(Ne.lng),a.aL(Ne.lat)).mult(d.worldSize).sub(j)}else{N=d.centerPoint.add(k);const fe=d.pointLocation(N),Ce=a.aU.convert(i.center||fe);this._normalizeCenter(Ce),j=d.project(fe),U=d.project(Ce).sub(j)}const X=d.zoomScale(E-m);let W,ie;i.around&&(W=a.aU.convert(i.around),ie=d.locationPoint(W));const ne=this._zooming||E!==m,K=this._rotating||y!==P,xe=this._pitching||R!==v,le=!d.isPaddingEqual(O),_e=i.retainPadding===!1?d.clone():d,re=fe=>Ce=>{if(ne&&(fe.zoom=a.am(m,E,Ce)),K&&(fe.bearing=a.am(y,P,Ce)),xe&&(fe.pitch=a.am(v,R,Ce)),le&&(_e.interpolatePadding(w,O,Ce),N=_e.centerPoint.add(k)),W)fe.setLocationAtPoint(W,ie);else{const ve=fe.zoomScale(fe.zoom-m),Ne=E>m?Math.min(2,X):Math.max(.5,X),ze=Math.pow(Ne,1-Ce),Je=fe.unproject(j.add(U.mult(Ce*ze)).mult(ve));fe.setLocationAtPoint(fe.renderWorldCopies?Je.wrap():Je,N)}return i.preloadOnly||this._fireMoveEvents(o),fe};if(i.preloadOnly){const fe=this._emulate(re,i.duration,d);return this._preloadTiles(fe),this}const ae={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ne,this._rotating=K,this._pitching=xe,this._padding=le,this._easeId=i.easeId,this._prepareEase(o,i.noMoveStart,ae),this._ease(re(d),fe=>{d.cameraElevationReference==="sea"&&d.recenterOnTerrain(),this._afterEase(o,fe)},i),this}_prepareEase(i,o,d={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),o||d.moving||this.fire(new a.C("movestart",i)),this._zooming&&!d.zooming&&this.fire(new a.C("zoomstart",i)),this._rotating&&!d.rotating&&this.fire(new a.C("rotatestart",i)),this._pitching&&!d.pitching&&this.fire(new a.C("pitchstart",i))}_fireMoveEvents(i){this.fire(new a.C("move",i)),this._zooming&&this.fire(new a.C("zoom",i)),this._rotating&&this.fire(new a.C("rotate",i)),this._pitching&&this.fire(new a.C("pitch",i))}_afterEase(i,o){if(this._easeId&&o&&this._easeId===o)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const d=this._zooming,m=this._rotating,y=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,d&&this.fire(new a.C("zoomend",i)),m&&this.fire(new a.C("rotateend",i)),y&&this.fire(new a.C("pitchend",i)),this.fire(new a.C("moveend",i))}flyTo(i,o){if(this._prefersReducedMotion(i)){const Ue=a.aJ(i,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Ue,o)}this.stop(),i=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:a.eP},i);const d=this.transform,m=this.getZoom(),y=this.getBearing(),v=this.getPitch(),w=this.getPadding(),E="zoom"in i?a.aC(+i.zoom,d.minZoom,d.maxZoom):m,P="bearing"in i?this._normalizeBearing(i.bearing,y):y,R="pitch"in i?+i.pitch:v,O=this._extendPadding(i.padding),k=d.zoomScale(E-m),N=a.P.convert(i.offset);let j=d.centerPoint.add(N);const U=d.pointLocation(j),X=a.aU.convert(i.center||U);this._normalizeCenter(X);const W=d.project(U),ie=d.project(X).sub(W);let ne=i.curve;const K=Math.max(d.width,d.height),xe=K/k,le=ie.mag();if("minZoom"in i){const Ue=a.aC(Math.min(i.minZoom,m,E),d.minZoom,d.maxZoom),$e=K/d.zoomScale(Ue-m);ne=Math.sqrt($e/le*2)}const _e=ne*ne;function re(Ue){const $e=(xe*xe-K*K+(Ue?-1:1)*_e*_e*le*le)/(2*(Ue?xe:K)*_e*le);return Math.log(Math.sqrt($e*$e+1)-$e)}function ae(Ue){return(Math.exp(Ue)-Math.exp(-Ue))/2}function fe(Ue){return(Math.exp(Ue)+Math.exp(-Ue))/2}const Ce=re(0);let ve=function(Ue){return fe(Ce)/fe(Ce+ne*Ue)},Ne=function(Ue){return K*((fe(Ce)*(ae($e=Ce+ne*Ue)/fe($e))-ae(Ce))/_e)/le;var $e},ze=(re(1)-Ce)/ne;if(Math.abs(le)<1e-6||!isFinite(ze)){if(Math.abs(K-xe)<1e-6)return this.easeTo(i,o);const Ue=xe<K?-1:1;ze=Math.abs(Math.log(xe/K))/ne,Ne=function(){return 0},ve=function($e){return Math.exp(Ue*ne*$e)}}i.duration="duration"in i?+i.duration:1e3*ze/("screenSpeed"in i?+i.screenSpeed/ne:+i.speed),i.maxDuration&&i.duration>i.maxDuration&&(i.duration=0);const Je=y!==P,tt=R!==v,Pe=!d.isPaddingEqual(O),we=i.retainPadding===!1?d.clone():d,Oe=Ue=>$e=>{const ft=$e*ze,lt=1/ve(ft);Ue.zoom=$e===1?E:m+Ue.scaleZoom(lt),Je&&(Ue.bearing=a.am(y,P,$e)),tt&&(Ue.pitch=a.am(v,R,$e)),Pe&&(we.interpolatePadding(w,O,$e),j=we.centerPoint.add(N));const ct=$e===1?X:Ue.unproject(W.add(ie.mult(Ne(ft))).mult(lt));return Ue.setLocationAtPoint(Ue.renderWorldCopies?ct.wrap():ct,j),Ue._updateCameraOnTerrain(),i.preloadOnly||this._fireMoveEvents(o),Ue};if(i.preloadOnly){const Ue=this._emulate(Oe,i.duration,d);return this._preloadTiles(Ue),this}return this._zooming=!0,this._rotating=Je,this._pitching=tt,this._padding=Pe,this._prepareEase(o,!1),this._ease(Oe(d),()=>this._afterEase(o),i),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(i){}_cancelRenderFrame(i){}_stop(i,o){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const d=this._onEaseEnd;this._onEaseEnd=void 0,d.call(this,o)}if(!i){const d=this.handlers;d&&d.stop(!1)}return this}_ease(i,o,d){d.animate===!1||d.duration===0?(i(1),o()):(this._easeStart=a.o.now(),this._easeOptions=d,this._onEaseFrame=i,this._onEaseEnd=o,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const i=Math.min((a.o.now()-this._easeStart)/this._easeOptions.duration,1),o=this._onEaseFrame;o&&o(this._easeOptions.easing(i)),i<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(i,o){i=a.bs(i,-180,180);const d=Math.abs(i-o);return Math.abs(i-360-o)<d&&(i-=360),Math.abs(i+360-o)<d&&(i+=360),i}_normalizeCenter(i){const o=this.transform;if(o.maxBounds||o.projection.name!=="globe"&&!o.renderWorldCopies)return;const d=i.lng-o.center.lng;i.lng+=d>180?-360:d<-180?360:0}_prefersReducedMotion(i){return this._respectPrefersReducedMotion&&a.o.prefersReducedMotion&&!(i&&i.essential)}_emulate(i,o,d){const m=Math.ceil(15*o/1e3),y=[],v=i(d.clone());for(let w=0;w<=m;w++){const E=v(w/m);y.push(E.clone())}return y}_preloadTiles(i,o){}}class Wm{constructor(i={}){this.options=i,a.aZ(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(i){const o=this.options&&this.options.compact,d=i._getUIString("AttributionControl.ToggleAttribution");this._map=i,this._container=ke("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=ke("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",d);const m=ke("span","mapboxgl-ctrl-icon",this._compactButton);return m.setAttribute("aria-hidden","true"),m.setAttribute("title",d),this._innerContainer=ke("div","mapboxgl-ctrl-attrib-inner",this._container),o&&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),o===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_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 i=this._editLink;i||(i=this._editLink=this._container.querySelector(".mapbox-improve-map"));const o=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.g.ACCESS_TOKEN}];if(i){const d=o.reduce((m,y,v)=>(y.value&&(m+=`${y.key}=${y.value}${v<o.length-1?"&":""}`),m),"?");i.href=`${a.g.FEEDBACK_URL}/${d}#${jr(this._map,!0)}`,i.rel="noopener nofollow"}}_updateData(i){!i||(i.dataType!=="source"||i.sourceDataType!=="metadata"&&i.sourceDataType!=="visibility")&&i.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let i=[];if(this._map.style.stylesheet){const m=this._map.style.stylesheet;this.styleOwner=m.owner,this.styleId=m.id}const o=this._map.style._mergedSourceCaches;for(const m in o){const y=o[m];if(y.used){const v=y.getSource();v.attribution&&i.indexOf(v.attribution)<0&&i.push(v.attribution)}}i.sort((m,y)=>m.length-y.length),i=i.filter((m,y)=>{for(let v=y+1;v<i.length;v++)if(i[v].indexOf(m)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?i=[...this.options.customAttribution,...i]:i.unshift(this.options.customAttribution));const d=i.map(m=>function(y){const v=new DOMParser().parseFromString(y,"text/html");return Array.from(v.body.querySelectorAll("*")).reverse().forEach(w=>{const E=w.textContent||"";if(w.tagName!=="A")return void w.replaceWith(...w.childNodes);const P=w.getAttribute("href");if(!P||!/^(https?:|mailto:)/i.test(P))return void w.replaceWith(v.createTextNode(E));const R=v.createElement("a");R.href=P,R.textContent=E,R.rel="noopener nofollow";const O=w.getAttribute("class");O&&(R.className=O),w.replaceWith(R)}),v.body.innerHTML}(m)).join(" | ");d!==this._attribHTML&&(this._attribHTML=d,i.length?(this._innerContainer.innerHTML=d,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 Xm{constructor(){a.aZ(["_updateLogo","_updateCompact"],this)}onAdd(i){this._map=i,this._container=ke("div","mapboxgl-ctrl");const o=ke("a","mapboxgl-ctrl-logo");return o.target="_blank",o.rel="noopener nofollow",o.href="https://www.mapbox.com/",o.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),o.setAttribute("rel","noopener nofollow"),this._container.appendChild(o),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(i){i&&i.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const i=this._map.style._sourceCaches;if(Object.entries(i).length===0)return!0;for(const o in i){const d=i[o].getSource();if(d.hasOwnProperty("mapbox_logo")&&!d.mapbox_logo)return!1}return!0}_updateCompact(){const i=this._container.children;if(i.length){const o=i[0];this._map.getCanvasContainer().offsetWidth<250?o.classList.add("mapboxgl-compact"):o.classList.remove("mapboxgl-compact")}}}class ux{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(i){const o=++this._id;return this._queue.push({callback:i,id:o,cancelled:!1}),o}remove(i){const o=this._currentlyRunning,d=o?this._queue.concat(o):this._queue;for(const m of d)if(m.id===i)return void(m.cancelled=!0)}run(i=0){const o=this._currentlyRunning=this._queue;this._queue=[];for(const d of o)if(!d.cancelled&&(d.callback(i),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class N1{constructor(i){this.jumpTo(i)}getValue(i){if(i<=this._startTime)return this._start;if(i>=this._endTime)return this._end;const o=a.dn((i-this._startTime)/(this._endTime-this._startTime));return this._start*(1-o)+this._end*o}isEasing(i){return i>=this._startTime&&i<=this._endTime}jumpTo(i){this._startTime=-1/0,this._endTime=-1/0,this._start=i,this._end=i}easeTo(i,o,d){this._start=this.getValue(o),this._end=i,this._startTime=o,this._endTime=o+d}}const V1={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class $i extends a.C{constructor(i,o,d,m){const{point:y,lngLat:v,originalEvent:w,target:E}=i;super(i.type,{point:y,lngLat:v,originalEvent:w,target:E}),this.preventDefault=()=>{i.preventDefault()},this.id=o,this.interaction=d,this.feature=m}}class lf{constructor(i){this.map=i,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(i,o){if(this.typeById.has(i))throw new Error(`Interaction id "${i}" already exists.`);const d=o.filter;let m=o.type;d&&this.filters.set(i,a.dg(d)),m==="mouseover"&&(m="mouseenter"),m==="mouseout"&&(m="mouseleave");const y=this.interactionsByType.get(m)||new Map;m==="mouseenter"||m==="mouseleave"?(this.delegatedInteractions.size===0&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(i,o)):y.size===0&&this.map.on(m,this.handleType),y.size===0&&this.interactionsByType.set(m,y),y.set(i,o),this.typeById.set(i,m)}get(i){const o=this.typeById.get(i);if(!o)return;const d=this.interactionsByType.get(o);return d?d.get(i):void 0}remove(i){const o=this.typeById.get(i);if(!o)return;this.typeById.delete(i),this.filters.delete(i);const d=this.interactionsByType.get(o);d&&(d.delete(i),o==="mouseenter"||o==="mouseleave"?(this.delegatedInteractions.delete(i),this.delegatedInteractions.size===0&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):d.size===0&&this.map.off(o,this.handleType))}queryTargets(i,o){const d=[];for(const[m,y]of o)y.target&&d.push({targetId:m,target:y.target,filter:this.filters.get(m)});return this.map.style.queryRenderedTargets(i,d,this.map.transform)}handleMove(i){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const o=this.queryTargets(i.point,Array.from(this.delegatedInteractions).reverse());o.length&&(i.type="mouseenter",this.handleType(i,o));const d=new Map;for(const[m,{feature:y}]of this.prevHoveredFeatures)this.hoveredFeatures.has(m)||d.set(y.id,y);d.size&&(i.type="mouseleave",this.handleType(i,Array.from(d.values())))}handleOut(i){const o=Array.from(this.hoveredFeatures.values()).map(({feature:d})=>d);o.length&&(i.type="mouseleave",this.handleType(i,o)),this.hoveredFeatures.clear()}handleType(i,o){const d=i.type==="mouseenter";if(d&&!this.interactionsByType.has(i.type))return void a.w("mouseenter interaction required for mouseleave to work.");const m=Array.from(this.interactionsByType.get(i.type)).reverse(),y=!!o;o=o||this.queryTargets(i.point,m);let v=!1;const w=new Set;for(const E of o){for(const[P,R]of m){if(!R.target)continue;const O=E.variants?E.variants[P]:null;if(O){for(const k of O){if(Bo(k,E,w,P))continue;const N=new a.di(E,k),j=Pp(k,E,P);y&&N.id!==void 0&&(N.state=this.map.getFeatureState(N));const U=d?this.prevHoveredFeatures.get(j):null,X=new $i(i,P,R,N),W=U?U.stop:R.handler(X);if(d&&this.hoveredFeatures.set(j,{feature:E,stop:W}),W!==!1){v=!0;break}}if(v)break}}if(v)break}if(!v)for(const[E,P]of m){const{handler:R,target:O}=P;if(!O&&R(new $i(i,E,P,null))!==!1)break}}}function U1(u,i){if(Array.isArray(u)&&Array.isArray(i)){const o=new Set(u),d=new Set(i);return o.size===d.size&&u.every(m=>d.has(m))}return a.b6(u,i)}const j1={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,useServerFontComposition:!0,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1},G1={showCompass:!0,showZoom:!0,visualizePitch:!1};class xh{constructor(i,o,d=!1){this._clickTolerance=10,this.element=o,this.mouseRotate=new tf({clickTolerance:i.dragRotate._mouseRotate._clickTolerance}),this.map=i,d&&(this.mousePitch=new ph({clickTolerance:i.dragRotate._mousePitch._clickTolerance})),a.aZ(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),o.addEventListener("mousedown",this.mousedown),o.addEventListener("touchstart",this.touchstart,{passive:!1}),o.addEventListener("touchmove",this.touchmove),o.addEventListener("touchend",this.touchend),o.addEventListener("touchcancel",this.reset)}down(i,o){this.mouseRotate.mousedown(i,o),this.mousePitch&&this.mousePitch.mousedown(i,o),qe()}move(i,o){const d=this.map,m=this.mouseRotate.mousemoveWindow(i,o),y=m&&m.bearingDelta;if(y&&d.setBearing(d.getBearing()+y),this.mousePitch){const v=this.mousePitch.mousemoveWindow(i,o),w=v&&v.pitchDelta;w&&d.setPitch(d.getPitch()+w)}}off(){const i=this.element;i.removeEventListener("mousedown",this.mousedown),i.removeEventListener("touchstart",this.touchstart),i.removeEventListener("touchmove",this.touchmove),i.removeEventListener("touchend",this.touchend),i.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){ot(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(i){this.down(Object.assign({},i,{button:i.button,type:i.type,ctrlKey:!0,preventDefault:()=>i.preventDefault()}),Tt(this.element,i)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(i){this.move(i,Tt(this.element,i))}mouseup(i){this.mouseRotate.mouseupWindow(i),this.mousePitch&&this.mousePitch.mouseupWindow(i),this.offTemp()}touchstart(i){i.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=li(this.element,i.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>i.preventDefault()},this._startPos))}touchmove(i){i.targetTouches.length!==1?this.reset():(this._lastPos=li(this.element,i.targetTouches)[0],this.move({buttons:1,preventDefault:()=>i.preventDefault()},this._lastPos))}touchend(i){i.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}function Ym(u,i,o){if(u=new a.aU(u.lng,u.lat),i){const d=new a.aU(u.lng-360,u.lat),m=new a.aU(u.lng+360,u.lat),y=360*Math.ceil(Math.abs(u.lng-o.center.lng)/360),v=o.locationPoint3D(u).distSqr(i),w=i.x<0||i.y<0||i.x>o.width||i.y>o.height;o.locationPoint3D(d).distSqr(i)<v&&(w||Math.abs(d.lng-o.center.lng)<y)?u=d:o.locationPoint3D(m).distSqr(i)<v&&(w||Math.abs(m.lng-o.center.lng)<y)&&(u=m)}for(;Math.abs(u.lng-o.center.lng)>180;){const d=o.locationPoint3D(u);if(d.x>=0&&d.y>=0&&d.x<=o.width&&d.y<=o.height)break;u.lng>o.center.lng?u.lng-=360:u.lng+=360}return u}const vh={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%)"},Ds={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class to extends a.E{constructor(i,o){super(),(i instanceof HTMLElement||o)&&(i=Object.assign({element:i},o)),a.aZ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:d="center",color:m="#3FB1CE",scale:y=1,draggable:v=!1,clickTolerance:w=0,rotation:E=Ds.rotation,rotationAlignment:P=Ds.rotationAlignment,pitchAlignment:R=Ds.pitchAlignment,occludedOpacity:O=Ds.occludedOpacity,altitude:k=Ds.altitude}=i||{};this._anchor=d,this._color=m,this._scale=y,this._draggable=v,this._clickTolerance=w,this._rotation=E,this._rotationAlignment=P,this._pitchAlignment=R,this._occludedOpacity=O,this._altitude=k,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),i&&i.element?(this._element=i.element,this._offset=a.P.convert(i&&i.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=a.P.convert(i&&i.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",U=>{U.preventDefault()}),this._element.addEventListener("mousedown",U=>{U.preventDefault()});const N=this._element.classList;for(const U in vh)N.remove(`mapboxgl-marker-anchor-${U}`);N.add(`mapboxgl-marker-anchor-${this._anchor}`);const j=i&&i.className?i.className.trim().split(/\s+/):[];N.add(...j),this._popup=null}_createDefaultMarker(){const i=ke("div"),o=Ye("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},i);if(this._altitude===0){const d=Ye("radialGradient",{id:"shadowGradient"},Ye("defs",{},o));Ye("stop",{offset:"10%","stop-opacity":.4},d),Ye("stop",{offset:"100%","stop-opacity":.05},d),Ye("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},o)}return Ye("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"},o),Ye("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"},o),Ye("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},o),i}addTo(i){return i===this._map||(this.remove(),this._map=i,i.getCanvasContainer().appendChild(this._element),i.on("move",this._updateMoving),i.on("moveend",this._update),i.on("remove",this._clearFadeTimer),i._addMarker(this),this.setDraggable(this._draggable),this._update(),i.on("click",this._onMapClick)),this}remove(){const i=this._map;return i&&(i.off("click",this._onMapClick),i.off("move",this._updateMoving),i.off("moveend",this._update),i.off("mousedown",this._addDragHandler),i.off("touchstart",this._addDragHandler),i.off("mouseup",this._onUp),i.off("touchend",this._onUp),i.off("mousemove",this._onMove),i.off("touchmove",this._onMove),i.off("remove",this._clearFadeTimer),i._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(i){return this._lngLat=a.aU.convert(i),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(i){return i===this._altitude||(this._defaultMarker&&(this._altitude===0&&i!==0||this._altitude!==0&&i===0)&&(this._element=this._createDefaultMarker()),this._altitude=i||Ds.altitude,this._update()),this}getAltitude(){return this._altitude}getElement(){return this._element}setPopup(i){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")),i){if(!("offset"in i.options)){const m=Math.sqrt(Math.pow(13.5,2)/2);i.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[m,-1*(38.1-13.5+m)],"bottom-right":[-m,-1*(38.1-13.5+m)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=i,i._marker=this,i._altitude=this._altitude,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(i){const o=i.code,d=i.charCode||i.keyCode;o!=="Space"&&o!=="Enter"&&d!==32&&d!==13||this.togglePopup()}_onMapClick(i){const o=i.originalEvent.target,d=this._element;this._popup&&(o===d||d.contains(o))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const i=this._popup;return i?(i.isOpen()?(i.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(i.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const i=this._map,o=this._pos;if(!i||!o)return!1;const d=i.unproject(o,this._altitude),m=i.getFreeCameraOptions();if(!m.position)return!1;const y=m.position.toLngLat();return y.distanceTo(d)<.9*y.distanceTo(this._lngLat)}_evaluateOpacity(){const i=this._map;if(!i)return;const o=this._pos;if(!o||o.x<0||o.x>i.transform.width||o.y<0||o.y>i.transform.height)return void this._clearFadeTimer();const d=i.unproject(o,this._altitude);let m;i._showingGlobe()&&a.e$(i.transform,this._lngLat)?m=0:(m=1-i._queryFogOpacity(d),i.transform._terrainEnabled()&&i.getTerrain()&&this._behindTerrain()&&(m*=this._occludedOpacity)),this._element.style.opacity=`${m}`,this._element.style.pointerEvents=m>0?"auto":"none",this._popup&&this._popup._setOpacity(m),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const i=this._pos;if(!i||!this._map)return;const o=this._offset.mult(this._scale);this._element.style.transform=`
            translate(${i.x}px,${i.y}px)
            ${vh[this._anchor]}
            ${this._calculateXYTransform()} ${this._calculateZTransform()}
            translate(${o.x}px,${o.y}px)
        `}_calculateXYTransform(){const i=this._pos,o=this._map,d=this.getPitchAlignment();if(!o||!i||d!=="map")return"";if(!o._showingGlobe()){const E=o.getPitch();return E?`rotateX(${E}deg)`:""}const m=a.cH(a.f0(o.transform,this._lngLat)),y=i.sub(a.f1(o.transform)),v=Math.abs(y.x)+Math.abs(y.y);if(v===0)return"";const w=m/v;return`rotateX(${-y.y*w}deg) rotateY(${y.x*w}deg)`}_calculateZTransform(){const i=this._pos,o=this._map;if(!o||!i)return"";let d=0;const m=this.getRotationAlignment();if(m==="map")if(o._showingGlobe()){const y=o.project(new a.aU(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),v=o.project(new a.aU(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(y);d=a.cH(Math.atan2(v.y,v.x))-90}else d=-o.getBearing();else if(m==="horizon"){const y=a.aj(4,6,o.getZoom()),v=a.f1(o.transform);v.y+=y*o.transform.height;const w=i.sub(v),E=a.cH(Math.atan2(w.y,w.x));d=(E>90?E-270:E+90)*(1-y)}return d+=this._rotation,d?`rotateZ(${d}deg)`:""}_update(i){cancelAnimationFrame(this._updateFrameId);const o=this._map;o&&(o.transform.renderWorldCopies&&(this._lngLat=Ym(this._lngLat,this._pos,o.transform)),this._pos=o.project(this._lngLat,this._altitude),i===!0?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),o._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(o._showingGlobe()||o.getTerrain()||o.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(i){return this._offset=a.P.convert(i),this._update(),this}addClassName(i){return this._element.classList.add(i),this}removeClassName(i){return this._element.classList.remove(i),this}toggleClassName(i){return this._element.classList.toggle(i)}_onMove(i){const o=this._map;if(!o)return;const d=this._pointerdownPos,m=this._positionDelta;if(d&&m){if(!this._isDragging){const y=this._clickTolerance||o._clickTolerance;if(i.point.dist(d)<y)return;this._isDragging=!0}this._pos=i.point.sub(m),this._lngLat=o.unproject(this._pos,this._altitude),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new a.C("dragstart"))),this.fire(new a.C("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const i=this._map;i&&(i.off("mousemove",this._onMove),i.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new a.C("dragend")),this._state="inactive"}_addDragHandler(i){const o=this._map,d=this._pos;o&&d&&this._element.contains(i.originalEvent.target)&&(i.preventDefault(),this._positionDelta=i.point.sub(d),this._pointerdownPos=i.point,this._state="pending",o.on("mousemove",this._onMove),o.on("touchmove",this._onMove),o.once("mouseup",this._onUp),o.once("touchend",this._onUp))}setDraggable(i){this._draggable=!!i;const o=this._map;return o&&(i?(o.on("mousedown",this._addDragHandler),o.on("touchstart",this._addDragHandler)):(o.off("mousedown",this._addDragHandler),o.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(i){return this._rotation=i||Ds.rotation,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(i){return this._rotationAlignment=i||Ds.rotationAlignment,this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(i){return this._pitchAlignment=i||Ds.pitchAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(i){return this._occludedOpacity=i||Ds.occludedOpacity,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const bh={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1,showButton:!0,followUserLocation:!0},$n={maxWidth:100,unit:"metric"},io={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},wh={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",altitude:0},$1=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function cf(u=new a.P(0,0),i="bottom"){if(typeof u=="number"){const o=Math.round(Math.sqrt(.5*Math.pow(u,2)));switch(i){case"top":return new a.P(0,u);case"top-left":return new a.P(o,o);case"top-right":return new a.P(-o,o);case"bottom":return new a.P(0,-u);case"bottom-left":return new a.P(o,-o);case"bottom-right":return new a.P(-o,-o);case"left":return new a.P(u,0);case"right":return new a.P(-u,0)}return new a.P(0,0)}return u instanceof a.P||Array.isArray(u)?a.P.convert(u):a.P.convert(u[i]||[0,0])}return{version:F,supported:Ve.supported,setRTLTextPlugin:a.f3,getRTLTextPluginStatus:a.f2,addTileProvider:function(u,i){if(!u||!i)throw new Error("TileProvider name and URL are required");a.g.TILE_PROVIDER_URLS[u]=a.o.resolveURL(i)},Map:class extends cx{constructor(u){ee.mark(H.create);const i=u;if((u=Object.assign({},j1,u)).minZoom!=null&&u.maxZoom!=null&&u.minZoom>u.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(u.minPitch!=null&&u.maxPitch!=null&&u.minPitch>u.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(u.minPitch!=null&&u.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(u.maxPitch!=null&&u.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");u.antialias&&a.eZ(window)&&(u.antialias=!1,a.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Vu(u.minZoom,u.maxZoom,u.minPitch,u.maxPitch,u.renderWorldCopies,null,null),u),this._repaint=!!u.repaint,this._interactive=u.interactive,this._minTileCacheSize=u.minTileCacheSize,this._maxTileCacheSize=u.maxTileCacheSize,this._failIfMajorPerformanceCaveat=u.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=u.preserveDrawingBuffer,this._antialias=u.antialias,this._trackResize=u.trackResize,this._bearingSnap=u.bearingSnap,this._refreshExpiredTiles=u.refreshExpiredTiles,this._fadeDuration=u.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=u.crossSourceCollisions,this._collectResourceTiming=u.collectResourceTiming,this._language=this._parseLanguage(u.language),this._worldview=u.worldview,this._renderTaskQueue=new ux,this._domRenderTaskQueue=new ux,this._controls=[],this._markers=[],this._popups=[],this._mapId=a.r(),this._locale=Object.assign({},V1,u.locale),this._clickTolerance=u.clickTolerance,this._cooperativeGestures=u.cooperativeGestures,this._performanceMetricsCollection=u.performanceMetricsCollection,this._tessellationStep=u.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=u.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new N1(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=u.scaleFactor,this._requestManager=new Mr(u.transformRequest,u.accessToken,u.testMode);const o=$t(u.accessToken||a.g.ACCESS_TOKEN);if(o&&"atlas"in o&&typeof o.atlas=="number"&&(this._tokenExpiration=o.atlas),this._silenceAuthErrors=!!u.testMode,this._contextCreateOptions=u.contextCreateOptions?Object.assign({},u.contextCreateOptions):{},typeof u.container=="string"){const d=document.getElementById(u.container);if(!d)throw new Error(`Container '${u.container.toString()}' not found.`);this._container=d}else{if(!(u.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=u.container}if(this._container.childNodes.length>0&&a.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."),u.maxBounds&&this.setMaxBounds(u.maxBounds),this._spriteFormat="auto",a.aZ(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)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 lx(this,u),this._localFontFamily=u.localFontFamily,this._localIdeographFontFamily=u.localIdeographFontFamily,this._useServerFontComposition=u.useServerFontComposition,(u.style||!u.testMode)&&this.setStyle(u.style||a.g.DEFAULT_STYLE,{config:u.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily,useServerFontComposition:this._useServerFontComposition}),u.projection&&this.setProjection(u.projection),u.hash&&(this._hash=new O1(typeof u.hash=="string"&&u.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){i.center==null&&i.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:u.center,zoom:u.zoom,bearing:u.bearing,pitch:u.pitch});const d=u.bounds;d&&(this.resize(),this.fitBounds(d,Object.assign({},u.fitBoundsOptions,{duration:0})))}this.resize(),u.attributionControl&&this.addControl(new Wm({customAttribution:u.customAttribution})),this._logoControl=new Xm,this.addControl(this._logoControl,u.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent()}),this.on("data",d=>{this._update(d.dataType==="style"),this.fire(new a.C(`${d.dataType}data`,d))}),this.on("dataloading",d=>{this.fire(new a.C(`${d.dataType}dataloading`,d))}),this._interactions=new lf(this)}_getMapId(){return this._mapId}addControl(u,i){if(i===void 0&&(i=u.getDefaultPosition?u.getDefaultPosition():"top-right"),!u||!u.onAdd)return this.fire(new a.B(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=u.onAdd(this);this._controls.push(u);const d=this._controlPositions[i];return i.indexOf("bottom")!==-1?d.insertBefore(o,d.firstChild):d.appendChild(o),this}removeControl(u){if(!u||!u.onRemove)return this.fire(new a.B(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(u);return i>-1&&this._controls.splice(i,1),u.onRemove(this),this}hasControl(u){return this._controls.indexOf(u)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(u){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 i=!this._moving;return i&&this.fire(new a.C("movestart",u)).fire(new a.C("move",u)),this.fire(new a.C("resize",u)),i&&this.fire(new a.C("moveend",u)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(u){return this.transform.setMaxBounds(a.aK.convert(u)),this._update()}setMinZoom(u){if((u=u??-2)>=-2&&u<=this.transform.maxZoom)return this.transform.minZoom=u,this._update(),this.getZoom()<u?this.setZoom(u):this.fire(new a.C("zoomstart")).fire(new a.C("zoom")).fire(new a.C("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(u){if((u=u??22)>=this.transform.minZoom)return this.transform.maxZoom=u,this._update(),this.getZoom()>u?this.setZoom(u):this.fire(new a.C("zoomstart")).fire(new a.C("zoom")).fire(new a.C("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(u){if((u=u??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(u>=0&&u<=this.transform.maxPitch)return this.transform.minPitch=u,this._update(),this.getPitch()<u?this.setPitch(u):this.fire(new a.C("pitchstart")).fire(new a.C("pitch")).fire(new a.C("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(u){if((u=u??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(u>=this.transform.minPitch)return this.transform.maxPitch=u,this._update(),this.getPitch()>u?this.setPitch(u):this.fire(new a.C("pitchstart")).fire(new a.C("pitch")).fire(new a.C("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(u){return this._scaleFactor=u,this.painter.scaleFactor=u,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(i=>i.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(u){return this.transform.renderWorldCopies=u,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(u){return u==="auto"?navigator.language:Array.isArray(u)?u.length===0?void 0:u.map(i=>i==="auto"?navigator.language:i):u}setLanguage(u){const i=this._parseLanguage(u);if(!this.style||i===this._language)return this;this._language=i,this.style.reloadSources();for(const o of this._controls)o._setLanguage&&o._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(u){return this.style&&u!==this._worldview?(this._worldview=u,this._styleDirty=!0,this.style.setWorldview(u),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(u){return this._lazyInitEmptyStyle(),u?typeof u=="string"&&(u={name:u}):u=null,this._useExplicitProjection=!!u,this._prioritizeAndUpdateProjection(u,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const u=this.transform,i=u.projection.name;let o;i==="globe"&&u.zoom>=a.cv?(u.setMercatorFromTransition(),o=!0):i==="mercator"&&u.zoom<a.cv&&(u.setProjection({name:"globe"}),o=!0),o&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate(),this._update(!0))}_prioritizeAndUpdateProjection(u,i){return this._updateProjection(u||i||{name:"mercator"})}_updateProjection(u){let i;const o=this.transform.mercatorFromTransition;i=u.name==="globe"&&this.transform.zoom>=a.cv?this.transform.setMercatorFromTransition():this.transform.setProjection(u),this.style.applyProjectionUpdate();const d=this.transform.getProjection().name==="mercator"&&o!==this.transform.mercatorFromTransition;return(i||d)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(u,i){return this.transform.locationPoint3D(a.aU.convert(u),i)}unproject(u,i){return this.transform.pointLocation3D(a.P.convert(u),i)}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(u,i,o){const d=m=>{let y=[];if(Array.isArray(i)){const v=i.filter(w=>this.getLayer(w));y=v.length?this.queryRenderedFeatures(m,{layers:v}):[]}else y=this.queryRenderedFeatures(m,{target:i});return y};if(u==="mouseenter"||u==="mouseover"){let m=!1;return{listener:o,targets:i,delegates:{mousemove:v=>{const w=d(v.point);w.length?m||(m=!0,o.call(this,new Sr(u,this,v.originalEvent,{features:w}))):m=!1},mouseout:()=>{m=!1}}}}if(u==="mouseleave"||u==="mouseout"){let m=!1;return{listener:o,targets:i,delegates:{mousemove:w=>{d(w.point).length?m=!0:m&&(m=!1,o.call(this,new Sr(u,this,w.originalEvent)))},mouseout:w=>{m&&(m=!1,o.call(this,new Sr(u,this,w.originalEvent)))}}}}{const m=y=>{const v=d(y.point);v.length&&(y.features=v,o.call(this,y),delete y.features)};return{listener:o,targets:i,delegates:{[u]:m}}}}on(u,i,o){if(typeof i=="function"||o===void 0)return super.on(u,i);if(typeof i=="string"&&(i=[i]),!this._areTargetsValid(i))return this;const d=this._createDelegatedListener(u,i,o);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[u]=this._delegatedListeners[u]||[],this._delegatedListeners[u].push(d);for(const m in d.delegates)this.on(m,d.delegates[m]);return this}once(u,i,o){if(typeof i=="function"||o===void 0)return super.once(u,i);if(typeof i=="string"&&(i=[i]),!this._areTargetsValid(i))return this;const d=this._createDelegatedListener(u,i,o);for(const m in d.delegates)this.once(m,d.delegates[m]);return this}off(u,i,o){if(typeof i=="function"||o===void 0)return super.off(u,i);if(typeof i=="string"&&(i=[i]),!this._areTargetsValid(i))return this;const d=this._delegatedListeners?this._delegatedListeners[u]:void 0;return d&&(m=>{for(let y=0;y<m.length;y++){const v=m[y];if(v.listener===o&&U1(v.targets,i)){for(const w in v.delegates)this.off(w,v.delegates[w]);return m.splice(y,1),this}}})(d),this}queryRenderedFeatures(u,i){if(!this.style)return[];if(u===void 0||u instanceof a.P||Array.isArray(u)||i!==void 0||(i=u,u=void 0),u=u||[[0,0],[this.transform.width,this.transform.height]],!i){const y=this.style.queryRenderedFeatures(u,void 0,this.transform),v=this.style.queryRenderedFeatureset(u,void 0,this.transform);return y.concat(v)}let o=!0;if(i.target&&(o=this._isTargetValid(i.target),o&&!i.layers))return this.style.queryRenderedFeatureset(u,i,this.transform);let d=!0;if(i.layers&&Array.isArray(i.layers)){for(const y of i.layers)if(!this._isValidId(y)){d=!1;break}if(d&&!i.target)return this.style.queryRenderedFeatures(u,i,this.transform)}let m=[];return d&&(m=m.concat(this.style.queryRenderedFeatures(u,i,this.transform))),o&&(m=m.concat(this.style.queryRenderedFeatureset(u,i,this.transform))),m}querySourceFeatures(u,i){return!u||typeof u=="string"&&!this._isValidId(u)?[]:this.style.querySourceFeatures(u,i)}queryRasterValue(u,i,o){return this._isValidId(u)?this.style.queryRasterValue(u,i,o):Promise.resolve(null)}isPointOnSurface(u){const{name:i}=this.transform.projection;return i!=="globe"&&i!=="mercator"&&a.w(`${i} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(a.P.convert(u))}addInteraction(u,i){return this._interactions.add(u,i),this}removeInteraction(u){return this._interactions.remove(u),this}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(u){return this._cooperativeGestures=u,this}setStyle(u,i){return i=Object.assign({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily,useServerFontComposition:this._useServerFontComposition},i),this.style&&u&&i.diff!==!1&&i.localFontFamily===this._localFontFamily&&i.localIdeographFontFamily===this._localIdeographFontFamily&&!i.config?(this.style._diffStyle(u,(o,d)=>{if(o){const m=typeof o=="string"?o:o instanceof Error?o.message:o.error;a.w(`Unable to perform style diff: ${m}. Rebuilding the style from scratch.`),this._updateStyle(u,i)}else d&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(u,i))}_getUIString(u){const i=this._locale[u];if(i==null)throw new Error(`Missing UI string '${u}'`);return i}_updateStyle(u,i){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),u){const o=Object.assign({},i);i&&i.config&&(o.initialConfig=i.config,delete o.config),this.style=new Js(this,o).load(u),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Js(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():(a.w("There is no style added to the map."),!1)}_isValidId(u){return u==null?(this.fire(new a.B(new Error("IDs can't be empty."))),!1):!a.db(u)||(this.fire(new a.B(new Error(`IDs can't contain special symbols: "${u}".`))),!1)}_isTargetValid(u){return"featuresetId"in u?this._isValidId("importId"in u?u.importId:u.featuresetId):"layerId"in u&&this._isValidId(u.layerId)}_areTargetsValid(u){if(Array.isArray(u)){for(const i of u)if(!this._isValidId(i))return!1;return!0}return this._isTargetValid(u)}addSource(u,i){return this._isValidId(u)?(this._lazyInitEmptyStyle(),this.style.addSource(u,i),this._update(!0)):this}isSourceLoaded(u){return!!this._isValidId(u)&&!!this.style&&this.style._isSourceCacheLoaded(u)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(u,i,o){this._lazyInitEmptyStyle(),this.style.addSourceType(u,i,o)}removeSource(u){return this._isValidId(u)?(this.style.removeSource(u),this._updateTerrain(),this._update(!0)):this}getSource(u){return this._isValidId(u)?this.style.getOwnSource(u):null}addImage(u,i,{pixelRatio:o=1,sdf:d=!1,stretchX:m,stretchY:y,content:v}={}){this._lazyInitEmptyStyle();const w=a.I.from(u);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:E,height:P,data:R}=a.o.getImageData(i);this.style.addImage(w,{data:new a.q({width:E,height:P},R),pixelRatio:o,stretchX:m,stretchY:y,content:v,sdf:d,version:0,usvg:!1})}else if(i.width===void 0||i.height===void 0)this.fire(new a.B(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:E,height:P}=i,R=i;this.style.addImage(w,{data:new a.q({width:E,height:P},new Uint8Array(R.data)),pixelRatio:o,stretchX:m,stretchY:y,content:v,sdf:d,usvg:!1,version:0,userImage:R}),R.onAdd&&R.onAdd(this,u)}}updateImage(u,i){this._lazyInitEmptyStyle();const o=a.I.from(u),d=this.style.getImage(o);if(!d)return void this.fire(new a.B(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const m=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?a.o.getImageData(i):i,{width:y,height:v,data:w}=m;if(y===void 0||v===void 0)return void this.fire(new a.B(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(y!==(d.usvg?d.icon.usvg_tree.width:d.data.width)||v!==(d.usvg?d.icon.usvg_tree.height:d.data.height))return void this.fire(new a.B(new Error(`The width and height of the updated image (${y}, ${v})
                must be that same as the previous version of the image
                (${d.data.width}, ${d.data.height})`)));const E=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let P=!1;d.usvg?(d.data=new a.q({width:y,height:v},new Uint8Array(w)),d.usvg=!1,d.icon=void 0,P=!0):d.data.replace(w,E),this.style.updateImage(o,d,P)}hasImage(u){return u?!!this.style&&!!this.style.getImage(a.I.from(u)):(this.fire(new a.B(new Error("Missing required image id"))),!1)}removeImage(u){this.style.removeImage(a.I.from(u))}loadImage(u,i){a.n(this._requestManager.transformRequest(u,a.R.Image),(o,d)=>{i(o,d)})}listImages(){return this.style.listImages().map(u=>u.name)}addModel(u,i){this._lazyInitEmptyStyle(),this.style.addModel(u,i)}hasModel(u){return u?this.style.hasModel(u):(this.fire(new a.B(new Error("Missing required model id"))),!1)}removeModel(u){this.style.removeModel(u)}listModels(){return this.style.listModels()}addLayer(u,i){return this._isValidId(u.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(u,i),this._update(!0)):this}getSlot(u){const i=this.getLayer(u);return i&&i.slot||null}setSlot(u,i){return this.style.setSlot(u,i),this.style.mergeLayers(),this._update(!0)}addImport(u,i){return this.style.addImport(u,i).catch(o=>this.fire(new a.B(new Error("Failed to add import",o)))),this}updateImport(u,i){return typeof i!="string"&&i.id!==u?(this.removeImport(u),this.addImport(i)):(this.style.updateImport(u,i),this._update(!0))}removeImport(u){return this.style.removeImport(u),this}moveImport(u,i){return this.style.moveImport(u,i),this._update(!0)}moveLayer(u,i){return this._isValidId(u)?(this.style.moveLayer(u,i),this._update(!0)):this}removeLayer(u){return this._isValidId(u)?(this.style.removeLayer(u),this._update(!0)):this}getLayer(u){if(!this._isValidId(u))return null;const i=this.style.getOwnLayer(u);return i?i.type==="custom"?i.implementation:i.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(u,i,o){return this._isValidId(u)?(this.style.setLayerZoomRange(u,i,o),this._update(!0)):this}setFilter(u,i,o={}){return this._isValidId(u)?(this.style.setFilter(u,i,o),this._update(!0)):this}getFilter(u){return this._isValidId(u)?this.style.getFilter(u):null}setPaintProperty(u,i,o,d={}){return this._isValidId(u)?(this.style.setPaintProperty(u,i,o,d),this._update(!0)):this}getPaintProperty(u,i){return this._isValidId(u)?this.style.getPaintProperty(u,i):null}setLayoutProperty(u,i,o,d={}){return this._isValidId(u)?(this.style.setLayoutProperty(u,i,o,d),this._update(!0)):this}getLayoutProperty(u,i){return this._isValidId(u)?this.style.getLayoutProperty(u,i):null}setLayerProperty(u,i,o,d={}){return this._isValidId(u)?(i==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(u,i,o,d),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(u){return this.style.setGlyphsUrl(u),this._update(!0)}getSchema(u){return this.style.getSchema(u)}setSchema(u,i){return this.style.setSchema(u,i),this._update(!0)}getConfig(u){return this.style.getConfig(u)}setConfig(u,i){return this.style.setConfig(u,i),this._update(!0)}getConfigProperty(u,i){return this.style.getConfigProperty(u,i)}setConfigProperty(u,i,o){return this.style.setConfigProperty(u,i,o),this._update(!0)}getFeaturesetDescriptors(u){return this.style.getFeaturesetDescriptors(u)}setLights(u){if(this._lazyInitEmptyStyle(),u&&u.length===1&&u[0].type==="flat"){const i=u[0];i.properties?this.style.setFlatLight(i.properties,i.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(u),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const u=this.style.getLights()||[];return u.length===0&&u.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),u}setLight(u,i={}){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:u}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(u){return this._lazyInitEmptyStyle(),!u&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(u),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(u){return this._lazyInitEmptyStyle(),this.style.setFog(u),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(u){return this._lazyInitEmptyStyle(),this.style.setSnow(u),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(u){return this._lazyInitEmptyStyle(),this.style.setRain(u),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(u){return this._lazyInitEmptyStyle(),this.style.setColorTheme(u),this._update(!0)}setImportColorTheme(u,i){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(u,i),this._update(!0)}setCamera(u){return this.style.setCamera(u),this._triggerCameraUpdate(u)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(u){const i=this.transform.nearClipOffset!==u;return this.transform.nearClipOffset=u,this._update(i)}_triggerCameraUpdate(u){return this._update(this.transform.setOrthographicProjectionAtLowPitch(u["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(u){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.aU.convert(u),this.transform):0}setFeatureState(u,i){return u.source&&!this._isValidId(u.source)?this:(this.style.setFeatureState(u,i),this._update())}removeFeatureState(u,i){return u.source&&!this._isValidId(u.source)?this:(this.style.removeFeatureState(u,i),this._update())}getFeatureState(u){return u.source&&!this._isValidId(u.source)?null:this.style.getFeatureState(u)}_selectIndoorFloor(u){this.style.indoorManager.selectFloor(u)}_setIndoorActiveFloorsVisibility(u){this.style.indoorManager.setActiveFloorsVisibility(u)}getIndoorTileOptions(u,i){return this.style.isIndoorEnabled()?this.style.indoorManager.getIndoorTileOptions(u,i):null}_updateContainerDimensions(){if(!this._container)return;const u=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let o,d,m,y=this._container;for(;y&&(!d||!m);){const v=window.getComputedStyle(y).transform;v&&v!=="none"&&(o=v.match(/matrix.*\((.+)\)/)[1].split(", "),o[0]&&o[0]!=="0"&&o[0]!=="1"&&(d=o[0]),o[3]&&o[3]!=="0"&&o[3]!=="1"&&(m=o[3])),y=y.parentElement}this._containerWidth=d?Math.abs(u/d):u,this._containerHeight=m?Math.abs(i/m):i}_detectMissingCSS(){window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&a.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 u=this._container;u.classList.add("mapboxgl-map"),(this._missingCSSCanary=ke("div","mapboxgl-canary",u)).style.visibility="hidden",this._detectMissingCSS();const i=this._canvasContainer=ke("div","mapboxgl-canvas-container",u);this._canvas=ke("canvas","mapboxgl-canvas",i),this._interactive&&(i.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 o=this._controlContainer=ke("div","mapboxgl-control-container",u),d=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(m=>{d[m]=ke("div",`mapboxgl-ctrl-${m}`,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(u,i){const o=a.o.devicePixelRatio||1;this._canvas.width=o*Math.ceil(u),this._canvas.height=o*Math.ceil(i),this._canvas.style.width=`${u}px`,this._canvas.style.height=`${i}px`}_addMarker(u){this._markers.push(u)}_removeMarker(u){const i=this._markers.indexOf(u);i!==-1&&this._markers.splice(i,1)}_addPopup(u){this._popups.push(u)}_removePopup(u){const i=this._popups.indexOf(u);i!==-1&&this._popups.splice(i,1)}_setupPainter(){const u=Object.assign({},Ve.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",u);i?(Ln(i,!0),this.painter=new F1(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",o=>{if(o.dataType==="source"){const d=this.transform.elevation?this.transform.elevation._source():null;d&&o.sourceCacheId===d.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0)}}),a.k.testSupport(i)):this.fire(new a.B(new Error("Failed to initialize WebGL")))}_contextLost(u){u.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.C("webglcontextlost",{originalEvent:u}))}_contextRestored(u){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new a.C("webglcontextrestored",{originalEvent:u}))}_onMapScroll(u){if(u.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(u){return this.style?(this._styleDirty=this._styleDirty||u,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(u){return this._update(),this._renderTaskQueue.add(u)}_cancelRenderFrame(u){this._renderTaskQueue.remove(u)}_requestDomTask(u){!this.loaded()||this.loaded()&&!this.isMoving()?u():this._domRenderTaskQueue.add(u)}_render(u){let i;this.fire(new a.C("renderstart")),++this._frameId;const o=this.painter.context.extTimerQuery,d=a.o.now(),m=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(i=m.createQuery(),m.beginQuery(o.TIME_ELAPSED_EXT,i)),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(u),this._domRenderTaskQueue.run(u),this._removed)return;this._updateProjectionTransition();const y=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const E=this.transform.zoom,P=this.transform.pitch,R=a.o.now(),O=new a.ae(E,{now:R,fadeDuration:y,pitch:P,transition:this.style.transition,worldview:this._worldview});this.style.update(O)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let v=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),v=this._updateAverageElevation(d),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):v=this._updateAverageElevation(d),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,y,this._crossSourceCollisions,this.painter.replacementSource)),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:y,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 a.C("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,ee.mark(H.load),this.fire(new a.C("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const E=a.o.now()-d;m.endQuery(o.TIME_ELAPSED_EXT),setTimeout(()=>{const P=m.getQueryParameter(i,m.QUERY_RESULT)/1e6;m.deleteQuery(i),this.fire(new a.C("gpu-timing-frame",{cpuTime:E,gpuTime:P}))},50)}if(this.listens("gpu-timing-layer")){const E=this.painter.collectGpuTimers();setTimeout(()=>{const P=this.painter.queryGpuTimers(E);this.fire(new a.C("gpu-timing-layer",{layerTimes:P}))},50)}if(this.listens("gpu-timing-deferred-render")){const E=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const P=this.painter.queryGpuTimeDeferredRender(E);this.fire(new a.C("gpu-timing-deferred-render",{gpuTime:P}))},50)}const w=this._sourcesDirty||this._styleDirty||this._placementDirty||v;if(w||this._repaint)this.triggerRepaint();else{const E=this.idle();if(E&&(v=this._updateAverageElevation(d,!0)),v)this.triggerRepaint();else if(this._triggerFrame(!1),E&&(this.fire(new a.C("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const P=this._calculateSpeedIndex();this.fire(new a.C("speedindexcompleted",{speedIndex:P})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||w||(this._fullyLoaded=!0,ee.mark(H.fullLoad),this._performanceMetricsCollection&&Mo(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(u){for(const i of this._markers)u&&!this.getRenderWorldCopies()&&(i._lngLat=i._lngLat.wrap()),i._update();for(const i of this._popups)!u||this.getRenderWorldCopies()||i._trackPointer||(i._lngLat=i._lngLat.wrap()),i._update()}_updateAverageElevation(u,i=!1){const o=m=>(this.transform.averageElevation=m,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&o(0);const d=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(d||(i||u-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(u)){const m=this.transform.averageElevation;let y=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(y)?y=0:this._averageElevationLastSampledAt=u;const v=Math.abs(m-y);if(v>1){if(this._isInitialLoad||d)return this._averageElevation.jumpTo(y),o(y);this._averageElevation.easeTo(y,u,300)}else if(v>1e-4)return this._averageElevation.jumpTo(y),o(y)}return!!this._averageElevation.isEasing(u)&&o(this._averageElevation.getValue(u))}_isTokenExpired(){return this._tokenExpiration!=null&&Date.now()>this._tokenExpiration}_revokeAuth(){const u=this.painter.context.gl;Ln(u,!1),this._logoControl instanceof Xm&&this._logoControl._updateLogo(),u&&u.clear(u.DEPTH_BUFFER_BIT|u.COLOR_BUFFER_BIT|u.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.B(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/")))}_authenticate(){cc(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,u=>{u&&(u.message!==gi&&u.status!==401||this._revokeAuth())}),this._isTokenExpired()&&this._revokeAuth(),sn(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&lo(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&pn(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){oa(this._requestManager._customAccessToken)}_updateTerrain(){const u=this._isDragging();this.painter.updateTerrain(this.style,u)}_calculateSpeedIndex(){const u=this.painter.canvasCopy(),i=this.painter.getCanvasCopiesAndTimestamps();i.timeStamps.push(performance.now());const o=this.painter.context.gl,d=o.createFramebuffer();function m(y){o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,y,0);const v=new Uint8Array(o.drawingBufferWidth*o.drawingBufferHeight*4);return o.readPixels(0,0,o.drawingBufferWidth,o.drawingBufferHeight,o.RGBA,o.UNSIGNED_BYTE,v),v}return o.bindFramebuffer(o.FRAMEBUFFER,d),this._canvasPixelComparison(m(u),i.canvasCopies.map(m),i.timeStamps)}_canvasPixelComparison(u,i,o){let d=o[1]-o[0];const m=u.length/4;for(let y=0;y<i.length;y++){const v=i[y];let w=0;for(let E=0;E<v.length;E+=4)v[E]===u[E]&&v[E+1]===u[E+1]&&v[E+2]===u[E+2]&&v[E+3]===u[E+3]&&(w+=1);d+=(o[y+2]-o[y+1])*(1-w/m)}return d}remove(){this._hash&&this._hash.remove();for(const i of this._controls)i.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);const u=this.painter.context.gl.getExtension("WEBGL_lose_context");u&&u.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),Hs.delete(this.painter.context.gl),co.remove(),ln.remove(),this._removed=!0,this.fire(new a.C("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(u){this._renderNextFrame=this._renderNextFrame||u,this.style&&!this._frame&&(this._frame=a.o.frame(i=>{const o=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,o&&this._render(i)}))}_preloadTiles(u){const i=this.style?this.style.getSourceCaches():[];return a.t(i,(o,d)=>o._preloadTiles(u,d),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(u){this._trackResize&&this.resize({originalEvent:u})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(u){this._showTileBoundaries!==u&&(this._showTileBoundaries=u,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(u){this._showParseStatus!==u&&(this._showParseStatus=u,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(u){this._showTerrainWireframe!==u&&(this._showTerrainWireframe=u,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(u){this._showLayers2DWireframe!==u&&(this._showLayers2DWireframe=u,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(u){this._showLayers3DWireframe!==u&&(this._showLayers3DWireframe=u,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(u){this._speedIndexTiming!==u&&(this._speedIndexTiming=u,this._update())}get showPadding(){return!!this._showPadding}set showPadding(u){this._showPadding!==u&&(this._showPadding=u,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(u){this._showCollisionBoxes!==u&&(this._showCollisionBoxes=u,this.style&&u?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(u){this._showOverdrawInspector!==u&&(this._showOverdrawInspector=u,this._update())}get repaint(){return!!this._repaint}set repaint(u){this._repaint!==u&&(this._repaint=u,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(u){this._vertices=u,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(u){this._showTileAABBs!==u&&(this._showTileAABBs=u,u&&this._update())}_setCacheLimits(u,i){a.e_(u,i)}get version(){return F}},NavigationControl:class{constructor(u={}){this.options=Object.assign({},G1,u),this._container=ke("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",i=>i.preventDefault()),this.options.showZoom&&(a.aZ(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",i=>{this._map&&this._map.zoomIn({},{originalEvent:i})}),ke("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",i=>{this._map&&this._map.zoomOut({},{originalEvent:i})}),ke("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(a.aZ(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",i=>{const o=this._map;o&&(this.options.visualizePitch?o.resetNorthPitch({},{originalEvent:i}):o.resetNorth({},{originalEvent:i}))}),this._compassIcon=ke("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const u=this._map;if(!u)return;const i=u.getZoom(),o=i===u.getMaxZoom(),d=i===u.getMinZoom();this._zoomInButton.disabled=o,this._zoomOutButton.disabled=d,this._zoomInButton.setAttribute("aria-disabled",o.toString()),this._zoomOutButton.setAttribute("aria-disabled",d.toString())}_rotateCompassArrow(){const u=this._map;if(!u)return;const i=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(u.transform.pitch*(Math.PI/180)),.5)}) rotateX(${u.transform.pitch}deg) rotateZ(${u.transform.angle*(180/Math.PI)}deg)`:`rotate(${u.transform.angle*(180/Math.PI)}deg)`;u._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=i)})}onAdd(u){return this._map=u,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),u.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&u.on("pitch",this._rotateCompassArrow),u.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new xh(u,this._compass,this.options.visualizePitch)),this._container}onRemove(){const u=this._map;u&&(this._container.remove(),this.options.showZoom&&u.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&u.off("pitch",this._rotateCompassArrow),u.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(u,i){const o=ke("button",u,this._container);return o.type="button",o.addEventListener("click",i),o}_setButtonTitle(u,i){if(!this._map)return;const o=this._map._getUIString(`NavigationControl.${i}`);u.setAttribute("aria-label",o),u.firstElementChild&&u.firstElementChild.setAttribute("title",o)}},GeolocateControl:class extends a.E{constructor(u={}){super();const i=navigator.geolocation;this.options=Object.assign({geolocation:i},bh,u),a.aZ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Lm(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(u){return this._map=u,this._container=ke("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(u){const i=(o=!!this.options.geolocation)=>{this._supportsGeolocation=o,u(o)};this._supportsGeolocation!==void 0?u(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(o=>i(o.state!=="denied")).catch(()=>i()):i()}_isOutOfMapMaxBounds(u){const i=this._map.getMaxBounds(),o=u.coords;return!!i&&(o.longitude<i.getWest()||o.longitude>i.getEast()||o.latitude<i.getSouth()||o.latitude>i.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(u){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(u))return this._setErrorState(),this.fire(new a.C("outofmaxbounds",u)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=u,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this.options.followUserLocation?(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active")):(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"));break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(u),this.options.followUserLocation&&(!this.options.trackUserLocation||this._watchState==="ACTIVE_LOCK")&&this._updateCamera(u),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new a.C("geolocate",Object.assign({coords:u.coords,timestamp:u.timestamp},u.toJSON?{toJSON:u.toJSON.bind(u)}:{}))),this._finish()}}_updateCamera(u){const i=new a.aU(u.coords.longitude,u.coords.latitude),o=u.coords.accuracy,d=this._map.getBearing(),m=Object.assign({bearing:d},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(o),m,{geolocateSource:!0})}_updateMarker(u){if(u){const i=new a.aU(u.coords.longitude,u.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=u.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const u=this._map.transform,i=a.bU(1,u._center.lat)*u.worldSize,o=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(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(u){if(this._map){if(this._clearRequestTimeout(),this.options.trackUserLocation)if(u.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",i),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",i),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(u.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new a.C("error",{code:u.code,message:u.message,PERMISSION_DENIED:u.PERMISSION_DENIED,POSITION_UNAVAILABLE:u.POSITION_UNAVAILABLE,TIMEOUT:u.TIMEOUT})),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_startRequestTimeout(){this._clearRequestTimeout();const u=this.options.positionOptions.timeout;u&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"})},u))}_clearRequestTimeout(){this._requestTimeoutId!==void 0&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0)}_setupUI(u){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",i=>i.preventDefault()),this._geolocateButton=ke("button","mapboxgl-ctrl-geolocate",this._container),ke("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",u===!1){a.w("Geolocation support is not available so the GeolocateControl will be disabled.");const i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",i),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",i)}else{const i=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",i),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",i)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=ke("div","mapboxgl-user-location"),this._dotElement.appendChild(ke("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(ke("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new to({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=ke("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new to({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.showButton||(this._container.style.display="none"),this.options.trackUserLocation&&this._map.on("movestart",i=>{i.geolocateSource||this._watchState!=="ACTIVE_LOCK"||i.originalEvent&&i.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new a.C("trackuserlocationend")))})}}_onDeviceOrientation(u){this._userLocationDotMarker&&(u.webkitCompassHeading?this._heading=u.webkitCompassHeading:u.absolute===!0&&(this._heading=-1*u.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return a.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 a.C("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 a.C("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 a.C("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let u;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(u={maximumAge:6e5,timeout:0},this._noTimeout=!0):(u=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,u),this._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}setFollowUserLocation(u){return this.options.followUserLocation=u??bh.followUserLocation,this.options.trackUserLocation&&this._watchState!=="OFF"&&(this.options.followUserLocation?this._watchState!=="BACKGROUND"&&this._watchState!=="BACKGROUND_ERROR"||(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new a.C("trackuserlocationstart"))):this._watchState!=="ACTIVE_LOCK"&&this._watchState!=="ACTIVE_ERROR"||(this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this.fire(new a.C("trackuserlocationend")))),this}_addDeviceOrientationListener(){const u=()=>{const i="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(i,this._onDeviceOrientation)};typeof DeviceOrientationEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(i=>{i==="granted"&&u()}).catch(console.error):u()}_clearWatch(){this._clearRequestTimeout(),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:Wm,ScaleControl:class{constructor(u={}){this.options=Object.assign({},$n,u),a.aZ(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const u=this.options.maxWidth||100,i=this._map,o=i._containerHeight/2,d=i._containerWidth/2-u/2,m=i.unproject([d,o]),y=i.unproject([d+u,o]),v=m.distanceTo(y);if(this.options.unit==="imperial"){const w=3.2808*v;w>5280?this._setScale(u,w/5280,"mile"):this._setScale(u,w,"foot")}else this.options.unit==="nautical"?this._setScale(u,v/1852,"nautical-mile"):v>=1e3?this._setScale(u,v/1e3,"kilometer"):this._setScale(u,v,"meter")}_setScale(u,i,o){this._map._requestDomTask(()=>{const d=function(y){const v=Math.pow(10,`${Math.floor(y)}`.length-1);let w=y/v;return w=w>=10?10:w>=5?5:w>=3?3:w>=2?2:w>=1?1:function(E){const P=Math.pow(10,Math.ceil(-Math.log(E)/Math.LN10));return Math.round(E*P)/P}(w),v*w}(i),m=d/i;this._container.innerHTML=o!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:o}).format(d):`${d}&nbsp;${io[o]}`,this._container.style.width=u*m+"px"})}onAdd(u){return this._map=u,this._language=u.getLanguage(),this._container=ke("div","mapboxgl-ctrl mapboxgl-ctrl-scale",u.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(u){this._language=u,this._update()}setUnit(u){this.options.unit=u,this._update()}},FullscreenControl:class{constructor(u={}){this._fullscreen=!1,u&&u.container&&(u.container instanceof HTMLElement?this._container=u.container:a.w("Full screen control 'container' must be a DOM element.")),a.aZ(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(u){return this._map=u,this._container||(this._container=this._map.getContainer()),this._controlContainer=ke("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.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 u=this._fullscreenButton=ke("button","mapboxgl-ctrl-fullscreen",this._controlContainer);ke("span","mapboxgl-ctrl-icon",u).setAttribute("aria-hidden","true"),u.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const u=this._getTitle();this._fullscreenButton.setAttribute("aria-label",u),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",u)}_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()}},IndoorControl:class{constructor(){a.aZ(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null}onAdd(u){return this._map=u,this._container=ke("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection()}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const u=this._map.style.indoorManager;u.off("selector-update",this._onIndoorUpdate),u.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(u.getControlState())}}_createButton(u,i){const o=ke("button",u,this._container);return o.type="button",o.addEventListener("click",i),o}_setButtonTitle(u,i){u.setAttribute("aria-label",i),u.textContent=i}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.style&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"top-right"}_onIndoorUpdate(u){if(!u||!u.floors||u.floors.length===0)return this._model=u,void(this._container.style.display="none");const i=this._model;this._model=u,this._container.style.display="inline-block";const o=!i||i.floors.length!==u.floors.length||i.floors.some((d,m)=>d.id!==u.floors[m].id);if(o&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),u.selectedFloorId){if(u.selectedFloorId!==this._lastSelectedFloorId||o){const d=u.floors.findIndex(m=>m.id===u.selectedFloorId);if(d!==-1){const m=u.floors.length;let y,v;m<=5?(y=0,v=m-1):this._visibleFloorStart===0?(y=0,v=3):this._visibleFloorStart>=m-3?(y=m-3-1,v=m-1):(y=this._visibleFloorStart,v=this._visibleFloorStart+3-1),d<y?this._visibleFloorStart=d:d>v&&(this._visibleFloorStart=d-2)}}this._lastSelectedFloorId=u.selectedFloorId}this._render()}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const u=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);ke("span","mapboxgl-ctrl-icon",u).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||u.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(u);const i=this._model.floors,o=i.length;if(o<=5)return void i.forEach(v=>this._createFloorButton(v));const d=this._visibleFloorStart===0,m=this._visibleFloorStart>=o-3;if(d)this._createFloorButton(i[0]);else{const v=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);ke("span","mapboxgl-ctrl-icon",v).setAttribute("aria-hidden","true"),this._container.appendChild(v)}let y=[];if(y=d?i.slice(1,4):m?i.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):i.slice(this._visibleFloorStart,this._visibleFloorStart+3),y.forEach(v=>this._createFloorButton(v)),m)this._createFloorButton(i[o-1]);else{const v=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);ke("span","mapboxgl-ctrl-icon",v).setAttribute("aria-hidden","true"),this._container.appendChild(v)}}_createFloorButton(u){const i=this._createButton("mapboxgl-ctrl-level-button",()=>{const y=u.id;this._model&&this._model.selectedFloorId===y&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(y))}),o=(u.name||"").trim(),d=u.zIndex.toString(),m=o?Array.from(o).slice(0,3).join(""):d;this._setButtonTitle(i,m),this._model&&this._model.activeFloorsVisible&&u.id===this._model.selectedFloorId&&i.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(i)}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1)}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,this._visibleFloorStart===1&&(this._visibleFloorStart=0);const u=this._model&&this._model.floors||[];if(u.length>3){const i=u.length-3;this._visibleFloorStart===i-1&&(this._visibleFloorStart=i-2)}this._render()}}_scrollDown(){if(this._model&&this._model.floors){const u=this._model.floors.length-3;this._visibleFloorStart<u&&(this._visibleFloorStart++,this._visibleFloorStart===1&&(this._visibleFloorStart=2),this._visibleFloorStart===u-1&&(this._visibleFloorStart=u),this._visibleFloorStart>u&&(this._visibleFloorStart=u),this._render())}}},Popup:class extends a.E{constructor(u){super(),this.options=Object.assign(Object.create(wh),u),this._altitude=this.options.altitude,a.aZ(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(u&&u.className?u.className.trim().split(/\s+/):[])}addTo(u){return this._map&&this.remove(),this._map=u,this.options.closeOnClick&&u.on("preclick",this._onClose),this.options.closeOnMove&&u.on("move",this._onClose),u.on("remove",this.remove),this._update(),u._addPopup(this),this._focusFirstElement(),this._trackPointer?(u.on("mousemove",this._onMouseEvent),u.on("mouseup",this._onMouseEvent),u._canvasContainer.classList.add("mapboxgl-track-pointer")):u.on("move",this._update),this.fire(new a.C("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const u=this._map;return u&&(u.off("move",this._update),u.off("move",this._onClose),u.off("preclick",this._onClose),u.off("click",this._onClose),u.off("remove",this.remove),u.off("mousemove",this._onMouseEvent),u.off("mouseup",this._onMouseEvent),u.off("drag",this._onMouseEvent),u._canvasContainer&&u._canvasContainer.classList.remove("mapboxgl-track-pointer"),u._removePopup(this),this._map=void 0),this.fire(new a.C("close")),this}getLngLat(){return this._lngLat}setLngLat(u){this._lngLat=a.aU.convert(u),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(u){return this._altitude=u,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const u=this._map;return u&&(u.off("move",this._update),u.on("mousemove",this._onMouseEvent),u.on("drag",this._onMouseEvent),u._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(u){return this.setDOMContent(document.createTextNode(u))}setHTML(u){const i=document.createDocumentFragment(),o=document.createElement("body");let d;for(o.innerHTML=u;d=o.firstChild,d;)i.appendChild(d);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(u){return this.options.maxWidth=u,this._update(),this}setDOMContent(u){let i=this._content;if(i)for(;i.hasChildNodes();)i.firstChild&&i.removeChild(i.firstChild);else i=this._content=ke("div","mapboxgl-popup-content",this._container||void 0);if(i.appendChild(u),this.options.closeButton){const o=this._closeButton=ke("button","mapboxgl-popup-close-button",i);o.type="button",o.setAttribute("aria-label","Close popup"),o.innerHTML='<span aria-hidden="true">&#215;</span>',o.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(u){return this._classList.add(u),this._updateClassList(),this}removeClassName(u){return this._classList.delete(u),this._updateClassList(),this}setOffset(u){return this.options.offset=u,this._update(),this}toggleClassName(u){let i;return this._classList.delete(u)?i=!1:(this._classList.add(u),i=!0),this._updateClassList(),i}_onMouseEvent(u){this._update(u.point)}_getAnchor(u){if(this.options.anchor)return this.options.anchor;const i=this._map,o=this._container,d=this._pos;if(!i||!o||!d)return"bottom";const m=o.offsetWidth,y=o.offsetHeight,v=d.x<m/2,w=d.x>i.transform.width-m/2;if(d.y+u<y)return v?"top-left":w?"top-right":"top";if(d.y>i.transform.height-y){if(v)return"bottom-left";if(w)return"bottom-right"}return v?"left":w?"right":"bottom"}_updateClassList(){const u=this._container;if(!u)return;const i=[...this._classList];i.push("mapboxgl-popup"),this._anchor&&i.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&i.push("mapboxgl-popup-track-pointer"),u.className=i.join(" ")}_update(u){const i=this._map,o=this._content;if(!i||!this._lngLat&&!this._trackPointer||!o)return;let d=this._container;if(d||(d=this._container=ke("div","mapboxgl-popup",i.getContainer()),this._tip=ke("div","mapboxgl-popup-tip",d),d.appendChild(o)),this.options.maxWidth&&d.style.maxWidth!==this.options.maxWidth&&(d.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ym(this._lngLat,this._pos,i.transform)),!this._trackPointer||u){const m=this._pos=this._trackPointer&&u instanceof a.P?u:i.project(this._lngLat,this._altitude),y=cf(this.options.offset),v=this._anchor=this._getAnchor(y.y),w=cf(this.options.offset,v),E=m.add(w).round();i._requestDomTask(()=>{this._container&&v&&(this._container.style.transform=`${vh[v]} translate(${E.x}px,${E.y}px)`)})}if(!this._marker&&i._showingGlobe()){const m=a.e$(i.transform,this._lngLat)?0:1;this._setOpacity(m)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const u=this._container.querySelector($1);u&&u.focus()}_onClose(){this.remove()}_setOpacity(u){this._container&&(this._container.style.opacity=`${u}`),this._content&&(this._content.style.pointerEvents=u?"auto":"none")}},Marker:to,Style:Js,LngLat:a.aU,LngLatBounds:a.aK,Point:a.P,MercatorCoordinate:a.ag,FreeCameraOptions:Bu,Evented:a.E,config:a.g,prewarm:function(){uc().acquire(za)},clearPrewarmedResources:function(){const u=Es;u&&(u.isPreloaded()&&u.numActive()===1?(u.release(za),Es=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return a.g.ACCESS_TOKEN},set accessToken(u){a.g.ACCESS_TOKEN=u},get baseApiUrl(){return a.g.API_URL},set baseApiUrl(u){a.g.API_URL=u},get workerCount(){return Ro.workerCount},set workerCount(u){Ro.workerCount=u},get maxParallelImageRequests(){return a.g.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(u){a.g.MAX_PARALLEL_IMAGE_REQUESTS=u},clearStorage(u){a.f7(u)},get workerUrl(){return Zr.workerUrl},set workerUrl(u){Zr.workerUrl=u},get workerClass(){return Zr.workerClass},set workerClass(u){Zr.workerClass=u},get workerParams(){return Zr.workerParams},set workerParams(u){Zr.workerParams=u},get dracoUrl(){return a.f6()},set dracoUrl(u){a.g.DRACO_URL=a.o.resolveURL(u)},get meshoptUrl(){return a.f5()},set meshoptUrl(u){const i=a.o.resolveURL(u);a.g.MESHOPT_URL=i,a.g.MESHOPT_SIMD_URL=i},get buildingGenUrl(){return a.f4()},set buildingGenUrl(u){a.g.BUILDING_GEN_URL=a.o.resolveURL(u)},setNow:a.o.setNow,restoreNow:a.o.restoreNow}});var L=T;return L})})(_F);var GG=_F.exports;const ap=DS(GG),PS="pk.eyJ1IjoiZHlsZWVlIiwiYSI6ImNtbzRwMWcxOTB2NWwyb3NseGMweDhyMGMifQ.z5Aadnqm-kG3mMaC_ybuMg",yF="mapbox://styles/mapbox/dark-v11";function c1({onMapReady:s,center:l,zoom:p=13}){const x=Ge.useRef(null),T=Ge.useRef(null);return Ge.useEffect(()=>{if(!x.current||T.current)return;ap.accessToken=PS;const C=new ap.Map({container:x.current,style:yF,center:l||[3.3792,6.5244],zoom:p,attributionControl:!1,logoPosition:"bottom-left"});return T.current=C,C.on("load",()=>s==null?void 0:s(C)),()=>{C.remove(),T.current=null}},[]),Ge.useEffect(()=>{!l||!T.current||T.current.easeTo({center:l,duration:800})},[l==null?void 0:l[0],l==null?void 0:l[1]]),J.jsx("div",{ref:x,className:"absolute inset-0 w-full h-full",style:{zIndex:0}})}function $G(){const s=t1(),{requestOtp:l,verifyOtp:p,loading:x,error:T,clearError:C,token:L,user:a}=sc(),[F,H]=Ge.useState("welcome"),[ee,se]=Ge.useState("phone"),[ue,Me]=Ge.useState(""),[Ve,ke]=Ge.useState(""),[Ye,Se]=Ge.useState("vendor"),[ye,Ie]=Ge.useState(""),[qe,ot]=Ge.useState(""),[xt,Rt]=Ge.useState(""),[Tt,li]=Ge.useState(""),[Xt,Ji]=Ge.useState(!1),[An,gi]=Ge.useState(0),[Mr,Wn]=Ge.useState(Date.now()),ji=Tt||T||"";Ge.useEffect(()=>{L&&a&&["welcome","method","role","email","phone"].includes(F)&&s("/",{replace:!0})},[L,a,F,s]),Ge.useEffect(()=>{if(An<=Date.now())return;const ln=setInterval(()=>Wn(Date.now()),500);return()=>clearInterval(ln)},[An]);const ti=async ln=>{if(!Xt){li(""),C(),Ji(!0);try{const sn=await l(ln,Ye,ee);Rt(sn),gi(Date.now()+3e4),H("otp")}catch(sn){li(sn instanceof Error?sn.message:"Failed to send OTP")}finally{Ji(!1)}}},Pt=async()=>{const ln=ee==="email"?ue:Ve;ln&&(An>Date.now()||(ot(""),await ti(ln)))},$t=async ln=>{const sn=ln??qe;if(!(sn.length<6||x)){li(""),C();try{await p(ee==="email"?ue:Ve,sn,Ye,ye||void 0,ee),H("complete")}catch(Rr){li(Rr instanceof Error?Rr.message:"Invalid or expired code"),ot("")}}};Ge.useEffect(()=>{F==="otp"&&qe.length===6&&!x&&$t(qe)},[qe,F]);const Wt=()=>{s("/",{replace:!0})},ii=[{id:"welcome",title:"Welcome"},{id:"method",title:"Method"},{id:"role",title:"Role"},{id:ee,title:ee==="email"?"Email":"Phone"},{id:"otp",title:"Verify"},{id:"complete",title:"Done"}],mi=ii.findIndex(ln=>ln.id===F),rn=Math.max(0,Math.ceil((An-Mr)/1e3));return J.jsxs("div",{className:"relative h-full w-full overflow-hidden",children:[J.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none",children:J.jsx(c1,{center:[3.3792,6.5244],zoom:12})}),J.jsx("div",{className:"absolute inset-0 z-10 bg-black/50"}),J.jsx("div",{className:"absolute top-8 left-0 right-0 z-20 px-6",children:J.jsx("div",{className:"max-w-sm mx-auto",children:J.jsx("div",{className:"flex items-center justify-between gap-2",role:"progressbar","aria-valuemin":0,"aria-valuemax":ii.length,"aria-valuenow":mi+1,children:ii.map((ln,sn)=>J.jsx("div",{className:`flex-1 h-1 rounded-full transition-all ${sn<=mi?"bg-accent-primary":"bg-white/20"}`},ln.id))})})}),J.jsx("div",{className:"absolute inset-0 z-20 flex flex-col items-center justify-center px-6",children:J.jsx(bi.div,{initial:{opacity:0,y:24,scale:.97},animate:{opacity:1,y:0,scale:1},transition:{duration:.4,ease:"easeOut"},className:"w-full max-w-sm glass rounded-3xl p-8 space-y-6",style:{boxShadow:"0 8px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(99,102,241,0.15)"},children:J.jsxs(oc,{mode:"wait",children:[F==="welcome"&&J.jsx(HG,{onNext:()=>H("method")},"welcome"),F==="method"&&J.jsx(ZG,{onSelect:se,onNext:()=>H("role")},"method"),F==="role"&&J.jsx(YG,{role:Ye,onChange:Se,onNext:()=>H(ee),referralCode:ye,onReferralChange:Ie},"role"),F==="email"&&J.jsx(qG,{value:ue,onChange:ln=>{Me(ln.target.value),li("")},onNext:()=>ti(ue),onBack:()=>H("role"),error:ji,sending:Xt},"email"),F==="phone"&&J.jsx(WG,{value:Ve,onChange:ln=>{ke(ln.target.value),li("")},onNext:()=>ti(Ve),onBack:()=>H("role"),error:ji,sending:Xt},"phone"),F==="otp"&&J.jsx(XG,{contact:ee==="email"?ue:Ve,method:ee,devCode:xt,otp:qe,onChange:ot,onVerify:()=>$t(),onBack:()=>{H(ee),ot(""),li(""),C()},onResend:Pt,resendSecondsLeft:rn,sending:Xt,loading:x,error:ji},"otp"),F==="complete"&&J.jsx(KG,{onContinue:Wt},"complete")]})})})]})}function HG({onNext:s}){return J.jsxs(bi.div,{initial:{opacity:0,x:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},className:"space-y-6 text-center",children:[J.jsxs("div",{className:"space-y-4",children:[J.jsx(bi.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.2,type:"spring"},className:"inline-flex items-center justify-center w-20 h-20 rounded-3xl bg-accent-primary/20 border border-accent-primary/30",children:J.jsx("span",{className:"text-4xl",children:"🚚"})}),J.jsxs("div",{children:[J.jsx("h1",{className:"text-3xl font-bold text-white",children:"Delivra"}),J.jsx("p",{className:"text-text-secondary mt-2 text-sm",children:"Real-time delivery platform"})]})]}),J.jsxs("div",{className:"space-y-3 text-left",children:[J.jsx(hT,{icon:"⚡",text:"Instant delivery tracking"}),J.jsx(hT,{icon:"📍",text:"Real-time location updates"}),J.jsx(hT,{icon:"📱",text:"Easy rider & vendor tools"})]}),J.jsx(bi.button,{whileTap:{scale:.97},onClick:s,className:"w-full py-3.5 bg-accent-primary rounded-xl text-white font-semibold text-sm glow-primary",children:"Get Started →"})]})}function ZG({onSelect:s,onNext:l}){return J.jsxs(bi.div,{initial:{opacity:0,x:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},className:"space-y-6",children:[J.jsxs("div",{className:"text-center",children:[J.jsx("h2",{className:"text-xl font-bold text-white",children:"How would you like to sign up?"}),J.jsx("p",{className:"text-text-secondary mt-2 text-sm",children:"Choose your preferred verification method"})]}),J.jsxs("div",{className:"space-y-3",children:[J.jsx(oD,{icon:"📧",title:"Email",description:"Get a code via email",onClick:()=>{s("email"),l()}}),J.jsx(oD,{icon:"📱",title:"Phone",description:"Get a code via SMS",onClick:()=>{s("phone"),l()}})]})]})}function oD({icon:s,title:l,description:p,onClick:x}){return J.jsx(bi.button,{whileTap:{scale:.98},onClick:x,className:"w-full p-4 glass-light rounded-2xl text-left hover:bg-white/5 transition-all border border-white/10",children:J.jsxs("div",{className:"flex items-center gap-4",children:[J.jsx("span",{className:"text-2xl",children:s}),J.jsxs("div",{children:[J.jsx("h3",{className:"font-semibold text-white",children:l}),J.jsx("p",{className:"text-text-secondary text-xs",children:p})]})]})})}function uE(){return J.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[J.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),J.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8z"})]})}function qG({value:s,onChange:l,onNext:p,onBack:x,error:T,sending:C}){const[L,a]=Ge.useState(!1);Ge.useEffect(()=>{a(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s))},[s]);const F=L&&!C;return J.jsxs(bi.div,{initial:{opacity:0,x:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},className:"space-y-4",children:[J.jsxs("div",{className:"text-center",children:[J.jsx("h2",{className:"text-xl font-bold text-white",children:"Enter your email"}),J.jsx("p",{className:"text-text-secondary mt-2 text-sm",children:"We'll send you a verification code"})]}),J.jsxs("div",{className:"space-y-3",children:[J.jsx("label",{className:"sr-only",htmlFor:"onboarding-email",children:"Email address"}),J.jsx("input",{id:"onboarding-email",type:"email",autoComplete:"email",inputMode:"email",autoFocus:!0,placeholder:"you@example.com",value:s,onChange:l,onKeyDown:H=>H.key==="Enter"&&F&&p(),"aria-invalid":!!s&&!L,className:"w-full px-4 py-3.5 glass-light rounded-xl text-white placeholder:text-text-secondary/50 outline-none text-sm border border-transparent focus:border-accent-primary/50 transition-all"}),s&&J.jsx("div",{className:"flex items-center gap-2 text-xs",children:L?J.jsx("span",{className:"text-green-400",children:"✓ Looks good"}):J.jsx("span",{className:"text-red-400",children:"Enter a valid email"})}),T&&J.jsx("p",{className:"text-red-400 text-xs text-center",role:"alert",children:T})]}),J.jsxs("div",{className:"flex gap-3",children:[J.jsx("button",{type:"button",onClick:x,className:"flex-1 py-3 glass-light rounded-xl text-text-secondary text-sm",children:"← Back"}),J.jsx(bi.button,{whileTap:{scale:.97},onClick:p,disabled:!F,className:"flex-1 py-3 bg-accent-primary rounded-xl text-white font-semibold text-sm disabled:opacity-40 glow-primary flex items-center justify-center gap-2",children:C?J.jsxs(J.Fragment,{children:[J.jsx(uE,{})," Sending…"]}):"Continue"})]})]})}function WG({value:s,onChange:l,onNext:p,onBack:x,error:T,sending:C}){const[L,a]=Ge.useState(!1);Ge.useEffect(()=>{const H=s.replace(/\D/g,"");a(H.length>=10)},[s]);const F=L&&!C;return J.jsxs(bi.div,{initial:{opacity:0,x:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},className:"space-y-4",children:[J.jsxs("div",{className:"text-center",children:[J.jsx("h2",{className:"text-xl font-bold text-white",children:"Enter your phone"}),J.jsx("p",{className:"text-text-secondary mt-2 text-sm",children:"We'll send you an SMS verification code"})]}),J.jsxs("div",{className:"space-y-3",children:[J.jsx("label",{className:"sr-only",htmlFor:"onboarding-phone",children:"Phone number"}),J.jsx("input",{id:"onboarding-phone",type:"tel",autoComplete:"tel",inputMode:"tel",autoFocus:!0,placeholder:"+234 800 000 0000",value:s,onChange:l,onKeyDown:H=>H.key==="Enter"&&F&&p(),"aria-invalid":!!s&&!L,className:"w-full px-4 py-3.5 glass-light rounded-xl text-white placeholder:text-text-secondary/50 outline-none text-sm border border-transparent focus:border-accent-primary/50 transition-all"}),J.jsxs("p",{className:"text-[11px] text-text-secondary/60",children:["Nigerian number? Type it as ",J.jsx("span",{className:"font-mono",children:"0801…"})," — we'll add ",J.jsx("span",{className:"font-mono",children:"+234"})," for you."]}),s&&J.jsx("div",{className:"flex items-center gap-2 text-xs",children:L?J.jsx("span",{className:"text-green-400",children:"✓ Looks good"}):J.jsx("span",{className:"text-red-400",children:"Enter at least 10 digits"})}),T&&J.jsx("p",{className:"text-red-400 text-xs text-center",role:"alert",children:T})]}),J.jsxs("div",{className:"flex gap-3",children:[J.jsx("button",{type:"button",onClick:x,className:"flex-1 py-3 glass-light rounded-xl text-text-secondary text-sm",children:"← Back"}),J.jsx(bi.button,{whileTap:{scale:.97},onClick:p,disabled:!F,className:"flex-1 py-3 bg-accent-primary rounded-xl text-white font-semibold text-sm disabled:opacity-40 glow-primary flex items-center justify-center gap-2",children:C?J.jsxs(J.Fragment,{children:[J.jsx(uE,{})," Sending…"]}):"Continue"})]})]})}function XG({contact:s,method:l,devCode:p,otp:x,onChange:T,onVerify:C,onBack:L,onResend:a,resendSecondsLeft:F,sending:H,loading:ee,error:se}){return J.jsxs(bi.div,{initial:{opacity:0,x:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},className:"space-y-4",children:[J.jsxs("div",{className:"text-center",children:[J.jsxs("h2",{className:"text-xl font-bold text-white",children:["Verify your ",l]}),J.jsxs("p",{className:"text-text-secondary mt-2 text-sm",children:["Code sent to ",J.jsx("span",{className:"text-white font-medium",children:s})]})]}),p&&J.jsxs("div",{className:"text-center bg-accent-primary/10 border border-accent-primary/20 rounded-xl py-3 px-4",children:[J.jsx("p",{className:"text-[10px] text-text-secondary mb-1",children:"Your Code"}),J.jsx("p",{className:"text-accent-primary font-bold font-mono tracking-[0.3em] text-xl",children:p})]}),J.jsx(jG,{value:x,onChange:T}),se&&J.jsx("p",{className:"text-red-400 text-xs text-center",role:"alert",children:se}),J.jsx(bi.button,{whileTap:{scale:.97},onClick:C,disabled:x.length<6||ee,className:"w-full py-3 bg-accent-primary rounded-xl text-white font-semibold text-sm disabled:opacity-40 glow-primary flex items-center justify-center gap-2",children:ee?J.jsxs(J.Fragment,{children:[J.jsx(uE,{})," Verifying…"]}):"Verify"}),J.jsxs("div",{className:"flex items-center justify-between text-xs",children:[J.jsxs("button",{type:"button",onClick:L,className:"text-text-secondary hover:text-white transition",children:["← Change ",l]}),J.jsx("button",{type:"button",onClick:a,disabled:F>0||H,className:"text-text-secondary hover:text-white disabled:opacity-50 disabled:cursor-not-allowed transition",children:H?"Sending…":F>0?`Resend in ${F}s`:"Resend code"})]})]})}function YG({role:s,onChange:l,onNext:p,referralCode:x,onReferralChange:T}){return J.jsxs(bi.div,{initial:{opacity:0,x:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},className:"space-y-4",children:[J.jsxs("div",{className:"text-center",children:[J.jsx("h2",{className:"text-xl font-bold text-white",children:"Choose your role"}),J.jsx("p",{className:"text-text-secondary mt-2 text-sm",children:"How will you use Delivra?"})]}),J.jsx("div",{className:"flex gap-2",children:["vendor","rider"].map(C=>J.jsx("button",{onClick:()=>l(C),className:`flex-1 py-3 rounded-xl text-sm font-medium transition-all capitalize ${s===C?"bg-accent-primary text-white glow-primary":"glass-light text-text-secondary"}`,children:C},C))}),s==="rider"&&J.jsx("input",{placeholder:"Referral code (optional)",value:x,onChange:C=>T(C.target.value),className:"w-full px-4 py-3 glass-light rounded-xl text-white placeholder:text-text-secondary/50 outline-none text-sm border border-transparent focus:border-accent-primary/50 transition-all"}),J.jsx(bi.button,{whileTap:{scale:.97},onClick:p,className:"w-full py-3 bg-accent-primary rounded-xl text-white font-semibold text-sm glow-primary",children:"Continue →"})]})}function KG({onContinue:s}){return J.jsxs(bi.div,{initial:{opacity:0,x:-16},animate:{opacity:1,x:0},exit:{opacity:0,x:16},className:"space-y-6 text-center",children:[J.jsx(bi.div,{initial:{scale:0},animate:{scale:1},transition:{delay:.2,type:"spring"},className:"inline-flex items-center justify-center w-20 h-20 rounded-full bg-green-500/20 border border-green-500/30",children:J.jsx("span",{className:"text-4xl",children:"✓"})}),J.jsxs("div",{children:[J.jsx("h2",{className:"text-2xl font-bold text-white",children:"Welcome to Delivra!"}),J.jsx("p",{className:"text-text-secondary mt-2 text-sm",children:"Your account is ready to go"})]}),J.jsxs("div",{className:"space-y-2 text-left",children:[J.jsx(dT,{icon:"📦",text:"Create your first delivery"}),J.jsx(dT,{icon:"📍",text:"Track in real-time"}),J.jsx(dT,{icon:"⚡",text:"Get instant notifications"})]}),J.jsx(bi.button,{whileTap:{scale:.97},onClick:s,className:"w-full py-3.5 bg-accent-primary rounded-xl text-white font-semibold text-sm glow-primary",children:"Start Using Delivra →"})]})}function hT({icon:s,text:l}){return J.jsxs(bi.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:.1},className:"flex items-center gap-3 p-3 glass-light rounded-xl",children:[J.jsx("span",{className:"text-lg",children:s}),J.jsx("span",{className:"text-sm text-text-secondary",children:l})]})}function dT({icon:s,text:l}){return J.jsxs(bi.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{delay:.1},className:"flex items-center gap-3",children:[J.jsx("span",{className:"text-lg",children:s}),J.jsx("span",{className:"text-sm text-text-secondary",children:l})]})}const MS=Sp(s=>({drawerOpen:!1,cameraFollow:!0,toggleDrawer:()=>s(l=>({drawerOpen:!l.drawerOpen})),setCameraFollow:l=>s({cameraFollow:l})})),JG=[{path:"/vendor",label:"Home",icon:"⬡"},{path:"/history",label:"History",icon:"◷"},{path:"/ratings",label:"Ratings",icon:"★"}],QG=[{path:"/rider",label:"Home",icon:"⬡"},{path:"/history",label:"History",icon:"◷"},{path:"/ratings",label:"Ratings",icon:"★"}];function Jg(){const s=t1(),l=e1(),p=sc(C=>C.user),x=MS(C=>C.toggleDrawer),T=(p==null?void 0:p.role)==="rider"?QG:JG;return J.jsxs("nav",{className:"fixed bottom-4 left-4 right-4 rounded-2xl px-2 py-3 flex items-center justify-around z-50",style:{background:"rgba(11, 15, 26, 0.45)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255,255,255,0.07)"},children:[J.jsx("button",{onClick:x,className:"w-10 h-10 flex items-center justify-center text-text-secondary hover:text-text-primary transition-colors",children:"☰"}),T.map(C=>J.jsxs("button",{onClick:()=>{l.pathname===C.path?window.dispatchEvent(new CustomEvent("snapToLocation")):s(C.path)},className:`flex flex-col items-center gap-1 px-3 py-1 rounded-xl transition-all ${l.pathname===C.path?"text-accent-primary":"text-text-secondary hover:text-text-primary"}`,children:[J.jsx("span",{className:"text-lg",children:C.icon}),J.jsx("span",{className:"text-[10px]",children:C.label})]},C.path))]})}const e$=[{path:"/",label:"Dashboard",icon:"⬡"},{path:"/settings",label:"Settings",icon:"⚙"}];function Qg(){const s=MS(L=>L.drawerOpen),l=MS(L=>L.toggleDrawer),p=sc(L=>L.logout),x=sc(L=>L.user),T=t1(),C=L=>{T(L),l()};return J.jsx(oc,{children:s&&J.jsxs(J.Fragment,{children:[J.jsx(bi.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-40",onClick:l}),J.jsxs(bi.aside,{initial:{x:-280},animate:{x:0},exit:{x:-280},transition:{type:"spring",damping:25,stiffness:200},className:"fixed left-0 top-0 bottom-0 w-[280px] glass z-50 flex flex-col p-6",children:[J.jsxs("div",{className:"mb-8",children:[J.jsx("h2",{className:"text-xl font-bold text-accent-primary",children:"Delivara"}),x&&J.jsxs("p",{className:"text-xs text-text-secondary mt-1 capitalize",children:[x.role," · ",x.phone]})]}),J.jsxs("div",{className:"flex-1 flex flex-col gap-1",children:[e$.map(L=>J.jsxs("button",{onClick:()=>C(L.path),className:"flex items-center gap-3 px-4 py-3 rounded-xl text-text-secondary hover:text-text-primary hover:bg-white/5 transition-all text-left",children:[J.jsx("span",{children:L.icon}),J.jsx("span",{className:"text-sm",children:L.label})]},L.path)),J.jsx("div",{className:"my-2 border-t border-white/5"}),J.jsxs("div",{className:"px-4 py-3 text-text-secondary/40 flex items-center gap-3",children:[J.jsx("span",{children:"💳"}),J.jsx("span",{className:"text-sm",children:"Payments"}),J.jsx("span",{className:"text-[10px] ml-auto bg-white/10 px-2 py-0.5 rounded-full",children:"Soon"})]}),J.jsxs("div",{className:"px-4 py-3 text-text-secondary/40 flex items-center gap-3",children:[J.jsx("span",{children:"🏪"}),J.jsx("span",{className:"text-sm",children:"Become a Vendor"}),J.jsx("span",{className:"text-[10px] ml-auto bg-white/10 px-2 py-0.5 rounded-full",children:"Soon"})]}),J.jsxs("div",{className:"px-4 py-3 text-text-secondary/40 flex items-center gap-3",children:[J.jsx("span",{children:"🏍️"}),J.jsx("span",{className:"text-sm",children:"Become a Rider"}),J.jsx("span",{className:"text-[10px] ml-auto bg-white/10 px-2 py-0.5 rounded-full",children:"Soon"})]})]}),J.jsx("button",{onClick:()=>{p(),T("/login"),l()},className:"px-4 py-3 rounded-xl text-red-400 hover:bg-red-400/10 transition-all text-left text-sm",children:"Logout"})]})]})})}let jv=null,Gv=1e3,fT=!1;const Vg=Sp((s,l)=>({connected:!1,socket:null,handlers:new Map,connect:()=>{const p=localStorage.getItem("delivara_token");if(!p)return;const x=l().socket;if(x&&x.readyState===WebSocket.OPEN)return;fT=!1;const T="wss://api.delivra.ng/ws",C=new WebSocket(`${T}?token=${p}`);C.onopen=()=>{s({connected:!0,socket:C}),Gv=1e3,C.send(JSON.stringify({type:"RECONNECT",data:{}}))},C.onmessage=L=>{try{const a=JSON.parse(L.data),F=l().handlers.get(a.type);F&&F.forEach(H=>H(a.data||{}))}catch{}},C.onclose=()=>{s({connected:!1,socket:null}),!fT&&(jv=setTimeout(()=>{Gv=Math.min(Gv*2,3e4),l().connect()},Gv))},C.onerror=()=>C.close(),s({socket:C})},disconnect:()=>{fT=!0,jv&&(clearTimeout(jv),jv=null);const{socket:p}=l();p&&p.close(),s({connected:!1,socket:null})},send:(p,x={})=>{const{socket:T}=l();(T==null?void 0:T.readyState)===WebSocket.OPEN&&T.send(JSON.stringify({type:p,data:x}))},on:(p,x)=>{const{handlers:T}=l();return T.has(p)||T.set(p,new Set),T.get(p).add(x),()=>{var C;(C=T.get(p))==null||C.delete(x)}}})),t$=3500;let aD=0;function pT(){return window.isSecureContext||location.hostname==="localhost"||location.hostname==="127.0.0.1"}const mg=Sp((s,l)=>({watching:!1,watchId:null,currentLat:null,currentLng:null,jobId:null,permissionDenied:!1,httpsRequired:!pT(),requestPermission:async()=>{if(!pT())return s({httpsRequired:!0}),!1;if(!navigator.geolocation)return s({permissionDenied:!0}),!1;try{const p=await new Promise((x,T)=>navigator.geolocation.getCurrentPosition(x,T,{enableHighAccuracy:!0,timeout:1e4}));return s({permissionDenied:!1,httpsRequired:!1,currentLat:p.coords.latitude,currentLng:p.coords.longitude}),!0}catch(p){return s({permissionDenied:p.code===GeolocationPositionError.PERMISSION_DENIED}),!1}},upgradeJobId:p=>{s({jobId:p})},startWatching:p=>{if(l().stopWatching(),!pT()||!navigator.geolocation)return;const x=navigator.geolocation.watchPosition(T=>{const C=T.coords.latitude,L=T.coords.longitude;s({currentLat:C,currentLng:L,permissionDenied:!1});const a=Date.now();if(a-aD>=t$){aD=a;const F=mg.getState().jobId;F&&F!=="idle"&&Vg.getState().send("LOCATION_UPDATE",{lat:C,lng:L,job_id:F})}},T=>{s({permissionDenied:T.code===GeolocationPositionError.PERMISSION_DENIED})},{enableHighAccuracy:!0,maximumAge:2e3});s({watching:!0,watchId:x,jobId:p})},stopWatching:()=>{const{watchId:p}=l();p!==null&&navigator.geolocation&&navigator.geolocation.clearWatch(p),s({watching:!1,watchId:null,jobId:null})}})),ey=Sp(s=>({message:null,type:"info",show:(l,p="info")=>{s({message:l,type:p}),setTimeout(()=>s({message:null}),3e3)},hide:()=>s({message:null})})),i$={success:"border-green-500/30",error:"border-red-500/30",info:"border-accent-primary/30"};function hE(){const{message:s,type:l}=ey();return J.jsx(oc,{children:s&&J.jsx(bi.div,{initial:{y:-60,opacity:0},animate:{y:0,opacity:1},exit:{y:-60,opacity:0},className:`fixed top-4 left-4 right-4 glass rounded-xl px-4 py-3 z-[100] ${i$[l]}`,children:J.jsx("p",{className:"text-sm text-text-primary text-center",children:s})})})}let lD=!1,mT=!1;const _T=[];function n$(s){return new Promise(l=>{if(lD){l();return}if(_T.push(l),mT)return;mT=!0;const p="initMap_"+Math.floor(Math.random()*1e6);window[p]=()=>{lD=!0,_T.forEach(T=>T()),_T.length=0,delete window[p]};const x=document.createElement("script");x.src=`https://maps.googleapis.com/maps/api/js?key=${s}&libraries=places&callback=${p}`,x.async=!0,x.defer=!0,x.onerror=()=>{mT=!1,console.error("[Places] Failed to load Google Maps script")},document.head.appendChild(x)})}function cD({placeholder:s,value:l,onChange:p,className:x=""}){const[T,C]=Ge.useState(l),[L,a]=Ge.useState([]),[F,H]=Ge.useState(!1),[ee,se]=Ge.useState(!1),[ue,Me]=Ge.useState(""),Ve=Ge.useRef(null),ke=Ge.useRef(null),Ye=Ge.useRef(null);Ge.useEffect(()=>{C(l)},[l]),Ge.useEffect(()=>{n$("AIzaSyAyorij0v5Y3GzxDomXVmQ3ad4bNX536sg").then(()=>{try{Ye.current=new google.maps.Geocoder,se(!0)}catch(qe){console.error("[Places] Init failed:",qe),Me("init_failed")}})},[]),Ge.useEffect(()=>{const Ie=qe=>{Ve.current&&!Ve.current.contains(qe.target)&&H(!1)};return document.addEventListener("mousedown",Ie),document.addEventListener("touchstart",Ie,{passive:!0}),()=>{document.removeEventListener("mousedown",Ie),document.removeEventListener("touchstart",Ie)}},[]);const Se=Ge.useCallback(Ie=>{if(!Ie||Ie.length<2){a([]),H(!1);return}!ee||typeof google>"u"||(ke.current&&clearTimeout(ke.current),ke.current=setTimeout(async()=>{try{const{suggestions:qe}=await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions({input:Ie});qe&&qe.length>0?(a(qe.slice(0,5).map(ot=>{var Rt,Tt,li,Xt,Ji,An;const xt=ot.placePrediction;return{place_id:xt.placeId,description:((Rt=xt.text)==null?void 0:Rt.text)||"",main_text:((li=(Tt=xt.structuredFormat)==null?void 0:Tt.mainText)==null?void 0:li.text)||((Xt=xt.text)==null?void 0:Xt.text)||"",secondary_text:((An=(Ji=xt.structuredFormat)==null?void 0:Ji.secondaryText)==null?void 0:An.text)||""}})),H(!0)):(a([]),H(!1))}catch(qe){console.error("[Places] Autocomplete search failed:",qe),a([]),H(!1)}},300))},[ee]),ye=Ge.useCallback(Ie=>{C(Ie.description),a([]),H(!1),Ye.current&&Ye.current.geocode({placeId:Ie.place_id},(qe,ot)=>{if(ot==="OK"&&(qe!=null&&qe[0])){const xt=qe[0].geometry.location;p(Ie.description,xt.lat(),xt.lng())}})},[p]);return J.jsxs("div",{ref:Ve,className:"relative",children:[J.jsx("input",{type:"text",placeholder:ue==="no_key"?"Enter address manually (no API key)":s,value:T,onChange:Ie=>{C(Ie.target.value),ee&&Se(Ie.target.value)},onFocus:()=>L.length>0&&H(!0),autoComplete:"off",className:x}),F&&L.length>0&&J.jsxs("div",{className:"absolute left-0 right-0 top-full mt-1 rounded-2xl overflow-hidden z-[9999]",style:{background:"rgba(8,12,22,0.99)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(99,102,241,0.3)",boxShadow:"0 16px 48px rgba(0,0,0,0.8)"},children:[L.map(Ie=>J.jsxs("button",{onMouseDown:qe=>{qe.preventDefault(),ye(Ie)},onTouchEnd:qe=>{qe.preventDefault(),ye(Ie)},className:"w-full text-left px-4 py-3 flex items-start gap-3 border-b border-white/5 last:border-0 active:bg-white/10 transition-colors",children:[J.jsx("span",{className:"text-accent-primary flex-shrink-0 mt-0.5",children:"📍"}),J.jsxs("div",{className:"min-w-0",children:[J.jsx("p",{className:"text-sm text-white font-medium truncate",children:Ie.main_text}),Ie.secondary_text&&J.jsx("p",{className:"text-xs text-text-secondary truncate mt-0.5",children:Ie.secondary_text})]})]},Ie.place_id)),J.jsx("div",{className:"px-4 py-2 flex justify-end opacity-40",children:J.jsx("img",{src:"https://developers.google.com/static/maps/documentation/images/google_on_white.png",alt:"Powered by Google",className:"h-3.5 invert"})})]})]})}function r$({open:s,onClose:l}){const p=Vg(Ut=>Ut.send),{currentLat:x,currentLng:T}=mg(),C=ey(),L=Ge.useRef(null),a=Ge.useRef(null),F=Ge.useRef(null),H=Ge.useRef(null),[ee,se]=Ge.useState(""),[ue,Me]=Ge.useState(""),[Ve,ke]=Ge.useState(""),[Ye,Se]=Ge.useState(""),[ye,Ie]=Ge.useState(""),[qe,ot]=Ge.useState(""),[xt,Rt]=Ge.useState(""),[Tt,li]=Ge.useState(!1),Xt=Ge.useRef(0),Ji=Ge.useRef(0),An=Ge.useRef(!1);Ge.useEffect(()=>{var ii;if(!s){(ii=F.current)==null||ii.remove(),F.current=null,H.current=null;return}const Ut=setTimeout(()=>{if(!a.current||F.current||!PS)return;ap.accessToken=PS;const mi=x&&T?[T,x]:[3.3792,6.5244],rn=new ap.Map({container:a.current,style:yF,center:mi,zoom:14,attributionControl:!1,interactive:!0}),ln=document.createElement("div");ln.style.cssText=`
        width:32px;height:32px;border-radius:50% 50% 50% 0;
        background:#6366f1;border:3px solid #fff;
        transform:rotate(-45deg);cursor:grab;
        box-shadow:0 4px 12px rgba(99,102,241,0.5);
      `;const sn=new ap.Marker({element:ln,draggable:!0}).setLngLat(mi).addTo(rn);H.current=sn;const Rr=(zi,pn,On)=>{const oa=`${zi.toFixed(5)}, ${pn.toFixed(5)}`;if(typeof window.google>"u"||!window.google.maps){On(oa);return}new window.google.maps.Geocoder().geocode({location:{lat:zi,lng:pn}},(Mo,co)=>{co==="OK"&&(Mo!=null&&Mo[0])?On(Mo[0].formatted_address):On(oa)})},lo=zi=>{Ie(zi.lat.toFixed(6)),ot(zi.lng.toFixed(6)),Rr(zi.lat,zi.lng,Se)};lo(sn.getLngLat()),sn.on("dragend",()=>lo(sn.getLngLat())),rn.on("click",zi=>{sn.setLngLat(zi.lngLat),lo(zi.lngLat)}),F.current=rn},350);return()=>clearTimeout(Ut)},[s]);const gi=(Ut,ii,mi)=>{Se(Ut),Ie(ii.toFixed(6)),ot(mi.toFixed(6)),H.current&&F.current&&(H.current.setLngLat([mi,ii]),F.current.easeTo({center:[mi,ii],zoom:15,duration:600}))},Mr=()=>{const Ut=(ii,mi)=>{Me(ii.toFixed(6)),ke(mi.toFixed(6));const rn=`${ii.toFixed(5)}, ${mi.toFixed(5)}`;if(typeof window.google>"u"||!window.google.maps){se(rn);return}new window.google.maps.Geocoder().geocode({location:{lat:ii,lng:mi}},(sn,Rr)=>{Rr==="OK"&&(sn!=null&&sn[0])?se(sn[0].formatted_address):se(rn)})};if(x&&T){Ut(x,T);return}if(!navigator.geolocation){C.show("Geolocation not supported","error");return}li(!0),navigator.geolocation.getCurrentPosition(ii=>{Ut(ii.coords.latitude,ii.coords.longitude),li(!1)},()=>{C.show("Could not get location","error"),li(!1)},{enableHighAccuracy:!0,timeout:8e3})},Wn=()=>{se(""),Me(""),ke(""),Se(""),Ie(""),ot(""),Rt("")},ji=()=>{const Ut=parseFloat(ue),ii=parseFloat(Ve),mi=parseFloat(ye),rn=parseFloat(qe);if(!ee||!Ye){C.show("Set pickup and dropoff locations","error");return}if(isNaN(Ut)||isNaN(ii)||isNaN(mi)||isNaN(rn)){C.show("Enter valid coordinates","error");return}p("CREATE_JOB",{pickup_address:ee,pickup_lat:Ut,pickup_lng:ii,dropoff_address:Ye,dropoff_lat:mi,dropoff_lng:rn,package_description:xt||void 0}),Wn(),l(),C.show("Job created — broadcasting to riders","success")},ti=Ut=>{Xt.current=Ut.touches[0].clientY,Ji.current=0,An.current=!0,L.current&&(L.current.style.transition="none")},Pt=Ut=>{if(!An.current)return;const ii=Ut.touches[0].clientY-Xt.current;ii<0||(Ji.current=ii,L.current&&(L.current.style.transform=`translateY(${ii}px)`))},$t=()=>{An.current=!1,L.current&&(L.current.style.transition=""),Ji.current>100?l():L.current&&(L.current.style.transform=""),Ji.current=0},Wt="w-full px-4 py-3 glass-light rounded-xl text-sm text-text-primary placeholder:text-text-secondary/40 outline-none";return J.jsx(oc,{children:s&&J.jsxs(J.Fragment,{children:[J.jsx(bi.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 z-30",onClick:l}),J.jsx(bi.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{delay:.15},className:"fixed bottom-[82vh] left-4 right-4 z-50",children:J.jsx(bi.button,{whileTap:{scale:.97},onClick:ji,className:"w-full py-4 bg-accent-primary rounded-2xl text-white font-bold text-base glow-primary",style:{boxShadow:"0 8px 32px rgba(99,102,241,0.5)"},children:"Create Delivery →"})}),J.jsxs(bi.div,{ref:L,initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:28,stiffness:220},className:"fixed bottom-0 left-0 right-0 glass rounded-t-3xl z-40 flex flex-col",style:{height:"82vh"},children:[J.jsx("div",{className:"flex-shrink-0 pt-4 pb-2 flex justify-center cursor-grab active:cursor-grabbing select-none",onTouchStart:ti,onTouchMove:Pt,onTouchEnd:$t,children:J.jsx("div",{className:"w-10 h-1 bg-white/25 rounded-full"})}),J.jsxs("div",{className:"flex-shrink-0 px-6 pb-3 flex items-center justify-between",children:[J.jsx("h3",{className:"text-lg font-bold",children:"New Delivery"}),J.jsx("button",{onClick:l,className:"w-8 h-8 rounded-full glass-light flex items-center justify-center text-text-secondary text-sm",children:"✕"})]}),J.jsxs("div",{className:"flex-1 overflow-y-auto px-6 pb-6 space-y-5",children:[J.jsxs("div",{className:"space-y-2",children:[J.jsxs("div",{className:"flex items-center justify-between",children:[J.jsx("label",{className:"text-xs font-semibold text-text-secondary/70 uppercase tracking-wide",children:"📍 Pickup"}),J.jsxs(bi.button,{whileTap:{scale:.94},onClick:Mr,disabled:Tt,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full glass-light text-accent-primary text-xs font-medium relative overflow-hidden",children:[!Tt&&J.jsx(bi.span,{className:"absolute inset-0 rounded-full bg-accent-primary/10",animate:{scale:[1,1.3,1],opacity:[.6,0,.6]},transition:{repeat:1/0,duration:2}}),Tt?J.jsxs("svg",{className:"animate-spin h-3 w-3",viewBox:"0 0 24 24",fill:"none",children:[J.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),J.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8z"})]}):J.jsx("span",{className:"text-[10px]",children:"◎"}),"My Location"]})]}),J.jsx(cD,{placeholder:"Search pickup address…",value:ee,onChange:(Ut,ii,mi)=>{se(Ut),Me(ii.toFixed(6)),ke(mi.toFixed(6))},className:Wt}),J.jsx("input",{type:"hidden",value:ue,readOnly:!0}),J.jsx("input",{type:"hidden",value:Ve,readOnly:!0})]}),J.jsxs("div",{className:"space-y-2",children:[J.jsx("label",{className:"text-xs font-semibold text-text-secondary/70 uppercase tracking-wide block",children:"📌 Dropoff"}),J.jsx(cD,{placeholder:"Search dropoff address…",value:Ye,onChange:gi,className:Wt}),J.jsx("input",{type:"hidden",value:ye,readOnly:!0}),J.jsx("input",{type:"hidden",value:qe,readOnly:!0}),J.jsxs("div",{className:"relative rounded-2xl overflow-hidden border border-white/10",style:{height:180},children:[J.jsx("div",{ref:a,className:"absolute inset-0"}),J.jsx("div",{className:"absolute top-2 left-0 right-0 flex justify-center pointer-events-none",children:J.jsx("span",{className:"glass text-[10px] text-text-secondary px-3 py-1 rounded-full",children:"Drag pin or tap to adjust"})})]})]}),J.jsxs("div",{children:[J.jsx("label",{className:"text-xs font-semibold text-text-secondary/70 uppercase tracking-wide block mb-2",children:"📋 Package (optional)"}),J.jsx("input",{placeholder:"What's in the package?",value:xt,onChange:Ut=>Rt(Ut.target.value),className:Wt})]}),J.jsx("div",{className:"h-2"})]})]})]})})}const s$={CREATED:"bg-gray-500",BROADCASTING:"bg-yellow-500",ASSIGNED:"bg-blue-500",PICKED_UP:"bg-indigo-500",IN_TRANSIT:"bg-accent-secondary",DELIVERED:"bg-green-500",COMPLETED:"bg-green-600"},o$={CREATED:"Created",BROADCASTING:"Broadcasting",ASSIGNED:"Assigned",PICKED_UP:"Picked Up",IN_TRANSIT:"In Transit",DELIVERED:"Delivered",COMPLETED:"Completed"};function xp({status:s}){const l=s$[s]??"bg-gray-500",p=o$[s]??s.replace(/_/g," "),x=s==="IN_TRANSIT"||s==="BROADCASTING";return J.jsxs(bi.div,{layout:!0,className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-xs font-medium text-white ${l}`,children:[x&&J.jsx(bi.span,{className:"w-2 h-2 rounded-full bg-white",animate:{opacity:[1,.3,1]},transition:{repeat:1/0,duration:1.5}}),p]})}function a$({job:s,onClick:l}){return J.jsxs("button",{onClick:l,className:"w-full glass rounded-xl p-4 text-left hover:border-accent-primary/30 transition-all",children:[J.jsxs("div",{className:"flex items-center justify-between mb-3",children:[J.jsx(xp,{status:s.status}),J.jsx("span",{className:"text-[10px] text-text-secondary font-mono",children:s.tracking_slug})]}),J.jsxs("div",{className:"space-y-1.5",children:[J.jsxs("div",{className:"flex items-start gap-2",children:[J.jsx("span",{className:"text-accent-primary text-sm mt-0.5",children:"●"}),J.jsx("span",{className:"text-sm text-text-secondary truncate",children:s.pickup_address})]}),J.jsxs("div",{className:"flex items-start gap-2",children:[J.jsx("span",{className:"text-accent-secondary text-sm mt-0.5",children:"●"}),J.jsx("span",{className:"text-sm text-text-secondary truncate",children:s.dropoff_address})]})]}),s.package_description&&J.jsx("p",{className:"text-xs text-text-secondary/60 mt-2 truncate",children:s.package_description})]})}function uD(s,l,p){return s+(l-s)*p}function l$(s,l,p){return{lat:uD(s.lat,l.lat,p),lng:uD(s.lng,l.lng,p)}}function xF({map:s,lat:l,lng:p,follow:x=!1}){const T=Ge.useRef(null),C=Ge.useRef(null),L=Ge.useRef({lat:l,lng:p}),a=Ge.useRef(0),F=Ge.useRef(!0);return Ge.useEffect(()=>{if(!s)return;const H=document.createElement("div");H.style.position="relative",H.style.width="24px",H.style.height="24px";const ee=document.createElement("div");ee.style.cssText=`
      position:absolute;inset:-8px;border-radius:50%;
      border:2px solid rgba(34,211,238,0.5);
      animation:rider-pulse 2s ease-out infinite;
    `,C.current=ee;const se=document.createElement("div");if(se.style.cssText=`
      width:24px;height:24px;border-radius:50%;
      background:#22D3EE;border:3px solid #05070D;
      box-shadow:0 0 16px rgba(34,211,238,0.7);
      position:relative;z-index:1;
    `,H.appendChild(ee),H.appendChild(se),!document.getElementById("rider-pulse-style")){const ue=document.createElement("style");ue.id="rider-pulse-style",ue.textContent=`
        @keyframes rider-pulse {
          0%   { transform: scale(0.8); opacity: 0.8; }
          70%  { transform: scale(1.8); opacity: 0; }
          100% { transform: scale(0.8); opacity: 0; }
        }
      `,document.head.appendChild(ue)}return T.current=new ap.Marker({element:H,anchor:"center"}).setLngLat([p,l]).addTo(s),()=>{var ue;(ue=T.current)==null||ue.remove(),cancelAnimationFrame(a.current)}},[s]),Ge.useEffect(()=>{if(!T.current||!s)return;const H=L.current,ee={lat:l,lng:p};if(F.current){T.current.setLngLat([p,l]),F.current=!1,x&&s.flyTo({center:[p,l],zoom:15,duration:800}),L.current=ee;return}const se=3500,ue=performance.now();cancelAnimationFrame(a.current);const Me=Ve=>{var Se;const ke=Math.min((Ve-ue)/se,1),Ye=l$(H,ee,ke);(Se=T.current)==null||Se.setLngLat([Ye.lng,Ye.lat]),x&&ke<1&&s.easeTo({center:[Ye.lng,Ye.lat],duration:100,easing:ye=>ye}),ke<1?a.current=requestAnimationFrame(Me):x&&s.easeTo({center:[ee.lng,ee.lat],duration:300})};a.current=requestAnimationFrame(Me),L.current=ee},[l,p,x,s]),null}const Qo=Sp(s=>({jobs:[],activeJob:null,incomingRequest:null,riderLocation:null,loading:!1,error:null,setActiveJob:l=>s({activeJob:l}),setIncomingRequest:l=>s({incomingRequest:l}),setRiderLocation:l=>s({riderLocation:l}),updateJobStatus:(l,p)=>{s(x=>{var T;return{jobs:x.jobs.map(C=>C.id===l?{...C,status:p}:C),activeJob:((T=x.activeJob)==null?void 0:T.id)===l?{...x.activeJob,status:p}:x.activeJob}})},fetchJobs:async()=>{s({loading:!0,error:null});try{const l=await ul("/api/jobs");s({jobs:l,loading:!1})}catch(l){s({loading:!1,error:l instanceof Error?l.message:"Failed to load jobs"})}},addJob:l=>s(p=>({jobs:[l,...p.jobs]}))}));function c$(){const[s,l]=Ge.useState(null),[p,x]=Ge.useState(!1),[T,C]=Ge.useState(!0),{connect:L,disconnect:a,on:F}=Vg(),{jobs:H,activeJob:ee,riderLocation:se,setActiveJob:ue,setRiderLocation:Me,updateJobStatus:Ve,addJob:ke,fetchJobs:Ye}=Qo();Ge.useEffect(()=>(L(),Ye(),()=>a()),[]),Ge.useEffect(()=>{const ye=[F("JOB_CREATED",Ie=>{const qe={...Ie,id:Ie.job_id??Ie.id};ke(qe)}),F("JOB_ACCEPTED",Ie=>{const qe=Ie;Ve(qe.job_id,qe.status);const{jobs:ot}=Qo.getState(),xt=ot.find(Rt=>Rt.id===qe.job_id);xt&&ue(xt)}),F("LOCATION_UPDATE",Ie=>{const qe=Ie,{activeJob:ot}=Qo.getState();(!ot||qe.job_id===ot.id)&&Me({lat:qe.lat,lng:qe.lng})}),F("JOB_STATUS",Ie=>{const qe=Ie;Ve(qe.job_id,qe.status);const{activeJob:ot}=Qo.getState();ot&&qe.job_id===ot.id&&ue({...ot,status:qe.status})}),F("JOB_COMPLETED",Ie=>{const qe=Ie;Ve(qe.job_id,"COMPLETED");const{activeJob:ot}=Qo.getState();ot&&qe.job_id===ot.id&&(ue(null),Me(null))}),F("STATE_SNAPSHOT",Ie=>{const qe=Ie;if(qe.jobs){const ot=qe.jobs.find(xt=>xt.status!=="COMPLETED");ot&&ue(ot)}})];return()=>ye.forEach(Ie=>Ie())},[]),Ge.useEffect(()=>{if(!s)return;const ye=()=>{navigator.geolocation&&navigator.geolocation.getCurrentPosition(Ie=>{s.flyTo({center:[Ie.coords.longitude,Ie.coords.latitude],zoom:15,essential:!0})},Ie=>console.warn("Could not get location:",Ie),{enableHighAccuracy:!0,timeout:5e3})};return ye(),window.addEventListener("snapToLocation",ye),()=>window.removeEventListener("snapToLocation",ye)},[s]);const Se=H.filter(ye=>ye.status!=="COMPLETED");return J.jsxs("div",{className:"relative h-full w-full",children:[J.jsx(c1,{onMapReady:l}),se&&s&&J.jsx(xF,{map:s,lat:se.lat,lng:se.lng,follow:T}),ee&&J.jsx("div",{className:"absolute top-4 left-4 right-4 z-10",children:J.jsxs("div",{className:"glass rounded-xl p-4",children:[J.jsxs("div",{className:"flex items-center justify-between mb-2",children:[J.jsx("span",{className:"text-sm font-medium",children:"Active Delivery"}),J.jsxs("div",{className:"flex items-center gap-2",children:[J.jsx(xp,{status:ee.status}),se&&J.jsx("button",{onClick:()=>C(ye=>!ye),className:`text-xs px-2 py-1 rounded-lg transition-all ${T?"bg-cyan-500/20 text-cyan-400 border border-cyan-500/30":"glass-light text-text-secondary"}`,children:T?"🎯 Following":"📍 Follow"})]})]}),J.jsx("p",{className:"text-xs text-text-secondary truncate",children:ee.dropoff_address}),J.jsxs("p",{className:"text-[10px] text-text-secondary/60 mt-1 font-mono select-all",children:[location.origin,"/track/",ee.tracking_slug]})]})}),J.jsx(oc,{children:!ee&&Se.length>0&&J.jsx(bi.div,{initial:{y:100},animate:{y:0},exit:{y:100},className:"absolute top-20 left-4 right-4 z-10 space-y-2 max-h-[40vh] overflow-y-auto",children:Se.map(ye=>J.jsx(a$,{job:ye,onClick:()=>ue(ye)},ye.id))})}),se&&!ee&&J.jsx("div",{className:"absolute top-4 left-4 right-4 z-10",children:J.jsxs("div",{className:"glass rounded-xl px-4 py-3 flex items-center gap-2",children:[J.jsx(bi.span,{className:"w-2 h-2 rounded-full bg-cyan-400",animate:{opacity:[1,.3,1]},transition:{repeat:1/0,duration:1.5}}),J.jsx("span",{className:"text-xs text-text-secondary",children:"Rider location streaming"})]})}),J.jsx(bi.button,{whileTap:{scale:.9},onClick:()=>x(!0),className:"fixed bottom-24 right-4 w-14 h-14 bg-accent-primary rounded-full flex items-center justify-center text-2xl text-white glow-primary z-20",children:"+"}),J.jsx(r$,{open:p,onClose:()=>x(!1)}),J.jsx(Jg,{}),J.jsx(Qg,{}),J.jsx(hE,{})]})}function u$({jobId:s,onUploaded:l}){const p=Ge.useRef(null),[x,T]=Ge.useState(!1),[C,L]=Ge.useState(null),a=ey(),F=async H=>{var se;const ee=(se=H.target.files)==null?void 0:se[0];if(ee){L(URL.createObjectURL(ee)),T(!0);try{const ue=new FormData;ue.append("proof",ee);const Me=s.replace("jobs:",""),Ve=await ul(`/api/jobs/${Me}/proof`,{method:"POST",body:ue});l(Ve.photo_url),a.show("Proof uploaded","success")}catch{a.show("Upload failed","error")}finally{T(!1)}}};return J.jsxs("div",{className:"space-y-3",children:[C?J.jsxs("div",{className:"relative rounded-xl overflow-hidden",children:[J.jsx("img",{src:C,alt:"Delivery proof",className:"w-full h-40 object-cover"}),x&&J.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:J.jsx(bi.div,{className:"w-8 h-8 border-2 border-accent-secondary border-t-transparent rounded-full",animate:{rotate:360},transition:{repeat:1/0,duration:1,ease:"linear"}})})]}):J.jsxs(bi.button,{whileTap:{scale:.95},onClick:()=>{var H;return(H=p.current)==null?void 0:H.click()},className:"w-full py-8 glass rounded-xl border-dashed border-2 border-accent-primary/30 text-text-secondary hover:text-text-primary transition-all",children:[J.jsx("div",{className:"text-2xl mb-1",children:"📷"}),J.jsx("div",{className:"text-sm",children:"Take delivery photo"})]}),J.jsx("input",{ref:p,type:"file",accept:"image/*",capture:"environment",onChange:F,className:"hidden"})]})}function RS({value:s=0,onChange:l,readonly:p=!1}){const[x,T]=Ge.useState(0);return J.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(C=>J.jsx(bi.button,{whileTap:p?{}:{scale:.85},onMouseEnter:()=>!p&&T(C),onMouseLeave:()=>T(0),onClick:()=>l==null?void 0:l(C),disabled:p,className:"text-2xl transition-colors",style:{color:C<=(x||s)?"#F59E0B":"#374151"},children:"★"},C))})}function h$(){const[,s]=Ge.useState(null),[l,p]=Ge.useState(!1),[x,T]=Ge.useState(!1),[C,L]=Ge.useState(0),[a,F]=Ge.useState(!1),{connect:H,disconnect:ee,send:se,on:ue}=Vg(),{activeJob:Me,incomingRequest:Ve,setActiveJob:ke,setIncomingRequest:Ye,updateJobStatus:Se}=Qo(),{startWatching:ye,stopWatching:Ie,upgradeJobId:qe,currentLat:ot,currentLng:xt,permissionDenied:Rt,httpsRequired:Tt,requestPermission:li}=mg(),Xt=ey();Ge.useEffect(()=>{li()},[]),Ge.useEffect(()=>{const $t=localStorage.getItem("rider_online")==="true";p($t)},[]),Ge.useEffect(()=>{const{connected:$t}=Vg.getState();if($t&&l){const{currentLat:Wt,currentLng:Ut}=mg.getState();se("RIDER_ONLINE",{lat:Wt??6.5244,lng:Ut??3.3792}),ye("idle")}},[l]),Ge.useEffect(()=>(H(),()=>ee()),[]),Ge.useEffect(()=>{const $t=[ue("JOB_REQUEST",Wt=>{const Ut={...Wt,id:Wt.job_id??Wt.id};Ye(Ut),Xt.show("📦 New delivery request!")}),ue("JOB_ASSIGNED",Wt=>{const Ut=Wt;ke(Ut),ye(Ut.id),Ye(null),Xt.show("Job accepted!","success")}),ue("JOB_TAKEN",Wt=>{const Ut=Wt,{incomingRequest:ii}=Qo.getState();ii&&ii.id===Ut.job_id&&(Ye(null),Xt.show("This job was taken by another rider","error"))}),ue("JOB_ASSIGN_FAILED",()=>{Ye(null),Xt.show("Job already taken","error")}),ue("JOB_STATUS",Wt=>{const Ut=Wt;Se(Ut.job_id,Ut.status);const{activeJob:ii}=Qo.getState();ii&&Ut.job_id===ii.id&&ke({...ii,status:Ut.status})}),ue("JOB_COMPLETED",Wt=>{const Ut=Wt;Se(Ut.job_id,"COMPLETED");const{activeJob:ii}=Qo.getState();ii&&Ut.job_id===ii.id&&ke({...ii,status:"COMPLETED"})}),ue("STATE_SNAPSHOT",Wt=>{const Ut=Wt;if(Ut.jobs){const ii=Ut.jobs.find(mi=>mi.rider_id&&mi.status!=="COMPLETED");ii&&(ke(ii),ye(ii.id))}})];return()=>$t.forEach(Wt=>Wt())},[]);const Ji=async()=>{if(!await li()){Xt.show("Location permission required to go online","error");return}p(!0),localStorage.setItem("rider_online","true"),ye("idle");const{currentLat:Wt,currentLng:Ut}=mg.getState();se("RIDER_ONLINE",{lat:Wt??6.5244,lng:Ut??3.3792}),Xt.show("You are now online","success")},An=()=>{p(!1),localStorage.setItem("rider_online","false"),Ie(),se("RIDER_OFFLINE",{})},gi=()=>{Xt.show("Accepting job...","info");const{incomingRequest:$t}=Qo.getState();if(!$t){Xt.show("Error: No request data found","error");return}se("ACCEPT_JOB",{job_id:$t.id}),qe($t.id),ke({...$t,status:"ASSIGNED"}),Ye(null)},Mr=()=>{Ye(null)},Wn=()=>{const{activeJob:$t}=Qo.getState();if(!$t)return;const Ut={ASSIGNED:"PICKED_UP",PICKED_UP:"IN_TRANSIT",IN_TRANSIT:"DELIVERED",DELIVERED:"COMPLETED"}[$t.status];if(Ut){if(Ut==="DELIVERED"&&!x){Xt.show("Upload photo proof first","error");return}se("JOB_STATUS",{job_id:$t.id,status:Ut}),Ut==="COMPLETED"&&(Ie(),T(!1),F(!1))}},ji=async()=>{const{activeJob:$t}=Qo.getState();if(!(!$t||C===0||a))try{const Wt=$t.id.replace("jobs:","");await ul(`/api/jobs/${Wt}/rate`,{method:"POST",body:JSON.stringify({score:C})}),Xt.show("Rating submitted","success"),F(!0),L(0),ke(null)}catch{Xt.show("Failed to submit rating","error")}},ti={ASSIGNED:"Mark Picked Up",PICKED_UP:"Start Transit",IN_TRANSIT:"Mark Delivered",DELIVERED:"Complete Delivery"},Pt={ASSIGNED:"📍",PICKED_UP:"🚚",IN_TRANSIT:"⚡",DELIVERED:"✅"};return J.jsxs("div",{className:"relative h-full w-full",children:[J.jsx(c1,{onMapReady:s,center:ot!=null&&xt!=null?[xt,ot]:void 0}),J.jsxs("div",{className:"absolute top-4 left-4 right-4 z-10 flex items-center justify-between",children:[J.jsx(bi.button,{whileTap:{scale:.95},onClick:l?An:Ji,className:`px-5 py-2.5 rounded-xl font-medium text-sm transition-all ${l?"bg-green-500/20 text-green-400 border border-green-500/30":"glass text-text-secondary"}`,children:l?"● Online":"Go Online"}),Me&&J.jsx(xp,{status:Me.status})]}),J.jsx(oc,{children:(Rt||Tt)&&J.jsx(bi.div,{initial:{y:-40,opacity:0},animate:{y:0,opacity:1},exit:{y:-40,opacity:0},className:"absolute top-20 left-4 right-4 z-20 glass rounded-xl px-4 py-3 border border-yellow-500/30",children:Tt?J.jsxs("p",{className:"text-xs text-yellow-400 text-center",children:["🔒 Location requires HTTPS. Access via ",J.jsx("strong",{children:"https://"})," or use localhost."]}):J.jsx("p",{className:"text-xs text-yellow-400 text-center",children:"📍 Location access denied. Enable it in browser settings to go online."})})}),J.jsx(oc,{children:Ve&&J.jsxs(J.Fragment,{children:[J.jsx(bi.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:Mr,className:"fixed inset-0 bg-black/60 z-30 cursor-pointer"}),J.jsxs(bi.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:28,stiffness:220},className:"fixed bottom-0 left-0 right-0 z-40 glass rounded-t-3xl flex flex-col",style:{maxHeight:"85vh",boxShadow:"0 -8px 40px rgba(0,0,0,0.5)"},children:[J.jsxs("div",{className:"absolute -top-14 left-0 flex gap-2.5 px-5 z-50",children:[J.jsx(bi.button,{whileTap:{scale:.96},onClick:Mr,className:"px-5 py-2 glass rounded-full text-text-secondary text-xs font-medium border border-white/10 shadow-2xl",children:"Decline"}),J.jsx(bi.button,{whileTap:{scale:.96},onClick:gi,className:"px-7 py-2 bg-accent-primary rounded-full text-white text-xs font-bold glow-primary shadow-2xl shadow-accent-primary/30",children:"Accept Job →"})]}),J.jsx("div",{className:"flex justify-center pt-4 pb-1 flex-shrink-0",children:J.jsx(bi.div,{className:"w-10 h-1 bg-accent-primary/60 rounded-full",animate:{opacity:[.4,1,.4]},transition:{repeat:1/0,duration:1.5}})}),J.jsxs("div",{className:"overflow-y-auto flex-1 px-6 pt-2 pb-10",children:[J.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[J.jsx("div",{className:"w-10 h-10 rounded-2xl bg-accent-primary/20 border border-accent-primary/30 flex items-center justify-center text-lg",children:"📦"}),J.jsxs("div",{children:[J.jsx("h3",{className:"font-bold text-base",children:"New Delivery Request"}),J.jsx("p",{className:"text-xs text-text-secondary",children:"Tap Accept to claim this job"})]})]}),J.jsxs("div",{className:"glass-light rounded-2xl p-4 mb-4 space-y-3",children:[J.jsxs("div",{className:"flex items-start gap-3",children:[J.jsx("div",{className:"mt-0.5 w-6 h-6 rounded-full bg-accent-primary/20 border border-accent-primary/40 flex items-center justify-center flex-shrink-0",children:J.jsx("div",{className:"w-2 h-2 rounded-full bg-accent-primary"})}),J.jsxs("div",{children:[J.jsx("p",{className:"text-[10px] text-text-secondary/60 uppercase tracking-wide font-medium",children:"Pickup"}),J.jsx("p",{className:"text-sm font-medium mt-0.5",children:Ve.pickup_address}),J.jsxs("p",{className:"text-[11px] text-text-secondary/60 font-mono mt-0.5",children:[Ve.pickup_lat,","," ",Ve.pickup_lng]})]})]}),J.jsxs("div",{className:"flex items-center gap-3",children:[J.jsx("div",{className:"w-6 flex justify-center",children:J.jsx("div",{className:"w-px h-5 bg-white/10"})}),J.jsx("div",{className:"h-px flex-1 border-t border-dashed border-white/10"})]}),J.jsxs("div",{className:"flex items-start gap-3",children:[J.jsx("div",{className:"mt-0.5 w-6 h-6 rounded-full bg-cyan-500/20 border border-cyan-500/40 flex items-center justify-center flex-shrink-0",children:J.jsx("div",{className:"w-2 h-2 rounded-full bg-cyan-400"})}),J.jsxs("div",{children:[J.jsx("p",{className:"text-[10px] text-text-secondary/60 uppercase tracking-wide font-medium",children:"Dropoff"}),J.jsx("p",{className:"text-sm font-medium mt-0.5",children:Ve.dropoff_address}),J.jsxs("p",{className:"text-[11px] text-text-secondary/60 font-mono mt-0.5",children:[Ve.dropoff_lat,","," ",Ve.dropoff_lng]})]})]})]}),Ve.package_description&&J.jsxs("div",{className:"glass-light rounded-xl px-4 py-3 mb-4 flex items-center gap-2",children:[J.jsx("span",{className:"text-sm",children:"📋"}),J.jsx("p",{className:"text-sm text-text-secondary",children:Ve.package_description})]}),J.jsxs("div",{className:"glass-light rounded-xl px-4 py-3 mb-4 flex items-center justify-between",children:[J.jsx("span",{className:"text-xs text-text-secondary/60",children:"Job ID"}),J.jsx("span",{className:"text-xs font-mono text-text-secondary",children:Ve.tracking_slug})]})]})]})]})}),Me&&!Ve&&J.jsxs("div",{className:"absolute bottom-28 left-4 right-4 z-10 space-y-3",children:[J.jsxs("div",{className:"glass rounded-2xl p-4",children:[J.jsxs("div",{className:"flex items-center justify-between mb-3",children:[J.jsxs("div",{className:"flex items-center gap-2",children:[J.jsx("span",{className:"text-base",children:Pt[Me.status]||"🚚"}),J.jsx(xp,{status:Me.status})]}),J.jsx("span",{className:"text-[10px] font-mono text-text-secondary/50",children:Me.tracking_slug})]}),J.jsx("p",{className:"text-xs text-text-secondary mb-0.5",children:"Delivering to"}),J.jsx("p",{className:"text-sm font-medium",children:Me.dropoff_address})]}),Me.status==="IN_TRANSIT"&&!x&&J.jsx(u$,{jobId:Me.id,onUploaded:()=>T(!0)}),Me.status==="COMPLETED"&&!a&&J.jsxs("div",{className:"glass rounded-2xl p-4 space-y-3",children:[J.jsx("p",{className:"text-sm font-medium",children:"Rate this vendor"}),J.jsx(RS,{value:C,onChange:L}),J.jsx(bi.button,{whileTap:{scale:.95},onClick:ji,disabled:C===0,className:"w-full py-2.5 bg-accent-primary rounded-xl text-white text-sm font-medium disabled:opacity-40",children:"Submit Rating"})]}),ti[Me.status]&&J.jsx(bi.button,{whileTap:{scale:.97},onClick:Wn,className:"w-full py-3.5 bg-accent-primary rounded-2xl text-white font-bold glow-primary",children:ti[Me.status]})]}),J.jsx(Jg,{}),J.jsx(Qg,{}),J.jsx(hE,{})]})}function d$(){const{slug:s}=T5(),[l,p]=Ge.useState(null),[x,T]=Ge.useState(null),[C,L]=Ge.useState(null),[a,F]=Ge.useState(null),[H,ee]=Ge.useState(""),se=Ge.useRef(null);if(Ge.useEffect(()=>{s&&ul(`/api/track/${s}`).then(Me=>T(Me)).catch(()=>ee("Delivery not found"))},[s]),Ge.useEffect(()=>{if(!x||x.status==="COMPLETED")return;const Me="wss://api.delivra.ng/ws",Ve=new WebSocket(Me);return se.current=Ve,Ve.onopen=()=>{Ve.send(JSON.stringify({type:"TRACK_SUBSCRIBE",data:{tracking_slug:s,job_id:x.id}}))},Ve.onmessage=ke=>{var Ye;try{const Se=JSON.parse(ke.data);Se.type==="LOCATION_UPDATE"&&(L(Se.data.lat),F(Se.data.lng)),(Se.type==="JOB_STATUS"||Se.type==="JOB_COMPLETED")&&T(ye=>ye&&{...ye,status:Se.data.status}),Se.type==="STATE_SNAPSHOT"&&((Ye=Se.data)!=null&&Ye.status)&&T(ye=>ye&&{...ye,status:Se.data.status})}catch{}},Ve.onclose=()=>{se.current=null},()=>{Ve.close(),se.current=null}},[x==null?void 0:x.id]),H)return J.jsx("div",{className:"h-full flex items-center justify-center bg-bg-primary",children:J.jsx("p",{className:"text-text-secondary",children:H})});if(!x)return J.jsx("div",{className:"h-full flex items-center justify-center bg-bg-primary",children:J.jsx("div",{className:"w-8 h-8 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"})});const ue=C!=null&&a!=null?[a,C]:[x.dropoff_lng,x.dropoff_lat];return J.jsxs("div",{className:"relative h-full w-full",children:[J.jsx(c1,{onMapReady:p,center:ue}),C!=null&&a!=null&&l&&J.jsx(xF,{map:l,lat:C,lng:a}),J.jsx("div",{className:"absolute top-4 left-4 right-4 z-10",children:J.jsxs("div",{className:"glass rounded-xl p-4",children:[J.jsxs("div",{className:"flex items-center justify-between mb-2",children:[J.jsx("span",{className:"text-sm font-semibold",children:"Live Tracking"}),J.jsx(xp,{status:x.status})]}),J.jsx("p",{className:"text-xs text-text-secondary",children:x.pickup_address}),J.jsxs("p",{className:"text-xs text-text-secondary mt-1",children:["→ ",x.dropoff_address]})]})}),x.status==="COMPLETED"&&J.jsx("div",{className:"absolute bottom-8 left-4 right-4 z-10",children:J.jsx("div",{className:"glass rounded-xl p-4 text-center",children:J.jsx("p",{className:"text-sm font-medium text-green-400",children:"✓ Delivery Complete"})})})]})}function f$(){const[s,l]=Ge.useState([]),[p,x]=Ge.useState(!0),[T,C]=Ge.useState(""),L=()=>{x(!0),C(""),ul("/api/jobs").then(ee=>l(Array.isArray(ee)?ee:[])).catch(ee=>C(ee instanceof Error?ee.message:"Failed to load history")).finally(()=>x(!1))};Ge.useEffect(()=>{L()},[]);const a=s.filter(ee=>ee.status==="COMPLETED"),F=s.filter(ee=>ee.status!=="COMPLETED"),H=({job:ee,i:se,dim:ue})=>J.jsxs(bi.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:se*.04},className:`glass rounded-xl p-4 ${ue?"opacity-60":""}`,children:[J.jsxs("div",{className:"flex items-center justify-between mb-2",children:[J.jsx("span",{className:"text-[10px] font-mono text-text-secondary/50",children:ee.tracking_slug}),J.jsx(xp,{status:ee.status})]}),J.jsxs("div",{className:"flex items-start gap-2 mb-1",children:[J.jsx("span",{className:"text-accent-primary text-xs mt-0.5 flex-shrink-0",children:"●"}),J.jsx("p",{className:"text-sm truncate",children:ee.pickup_address})]}),J.jsxs("div",{className:"flex items-start gap-2",children:[J.jsx("span",{className:"text-cyan-400 text-xs mt-0.5 flex-shrink-0",children:"●"}),J.jsx("p",{className:"text-xs text-text-secondary truncate",children:ee.dropoff_address})]})]},ee.id);return J.jsxs("div",{className:"h-full bg-bg-primary overflow-y-auto pb-24",children:[J.jsxs("div",{className:"px-4 pt-12 pb-4 flex items-center justify-between",children:[J.jsx("h1",{className:"text-xl font-bold",children:"Delivery History"}),T&&J.jsx("button",{onClick:L,className:"text-xs text-accent-primary",children:"Retry"})]}),p?J.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[J.jsx("div",{className:"w-8 h-8 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),J.jsx("p",{className:"text-xs text-text-secondary",children:"Loading deliveries..."})]}):T?J.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3 px-6",children:[J.jsx("span",{className:"text-3xl",children:"⚠️"}),J.jsx("p",{className:"text-sm text-red-400 text-center",children:T}),J.jsx(bi.button,{whileTap:{scale:.97},onClick:L,className:"mt-2 px-6 py-2.5 bg-accent-primary/20 border border-accent-primary/30 rounded-xl text-accent-primary text-sm",children:"Try again"})]}):J.jsxs("div",{className:"px-4 space-y-6",children:[F.length>0&&J.jsxs("div",{children:[J.jsxs("h2",{className:"text-xs font-semibold text-text-secondary/60 uppercase tracking-wide mb-3",children:["Active · ",F.length]}),J.jsx("div",{className:"space-y-2",children:F.map((ee,se)=>J.jsx(H,{job:ee,i:se},ee.id))})]}),a.length>0&&J.jsxs("div",{children:[J.jsxs("h2",{className:"text-xs font-semibold text-text-secondary/60 uppercase tracking-wide mb-3",children:["Completed · ",a.length]}),J.jsx("div",{className:"space-y-2",children:a.map((ee,se)=>J.jsx(H,{job:ee,i:se,dim:!0},ee.id))})]}),s.length===0&&J.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-2",children:[J.jsx("span",{className:"text-4xl",children:"📭"}),J.jsx("p",{className:"text-text-secondary text-sm mt-2",children:"No deliveries yet"})]})]}),J.jsx(Jg,{}),J.jsx(Qg,{})]})}function p$(){const s=sc(F=>F.user),[l,p]=Ge.useState([]),[x,T]=Ge.useState(!0),[C,L]=Ge.useState("");Ge.useEffect(()=>{s&&(s.role==="rider"?ul("/api/riders/me").then(F=>p(F.ratings||[])).catch(()=>L("Failed to load ratings")).finally(()=>T(!1)):T(!1))},[s]);const a=l.length>0?l.reduce((F,H)=>F+H.score,0)/l.length:0;return J.jsxs("div",{className:"h-full bg-bg-primary overflow-y-auto pb-24",children:[J.jsx("div",{className:"px-4 pt-12 pb-4",children:J.jsx("h1",{className:"text-xl font-bold",children:"Ratings"})}),x?J.jsx("div",{className:"flex justify-center py-12",children:J.jsx("div",{className:"w-8 h-8 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"})}):C?J.jsx("p",{className:"text-center text-red-400 text-sm py-12",children:C}):J.jsxs("div",{className:"px-4 space-y-4",children:[J.jsxs(bi.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"glass rounded-xl p-6 text-center",children:[J.jsx("p",{className:"text-4xl font-bold",children:a.toFixed(1)}),J.jsx("div",{className:"flex justify-center mt-2",children:J.jsx(RS,{value:Math.round(a),readonly:!0})}),J.jsxs("p",{className:"text-xs text-text-secondary mt-2",children:[l.length," ",l.length===1?"rating":"ratings"]})]}),l.length>0&&J.jsx("div",{className:"space-y-2",children:l.map((F,H)=>{var ee;return J.jsxs(bi.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:H*.05},className:"glass rounded-xl p-4",children:[J.jsxs("div",{className:"flex items-center justify-between mb-1",children:[J.jsx(RS,{value:F.score,readonly:!0}),J.jsx("span",{className:"text-xs text-text-secondary/60 font-mono",children:((ee=F.job_id)==null?void 0:ee.replace("jobs:",""))||""})]}),F.review&&J.jsx("p",{className:"text-xs text-text-secondary mt-1",children:F.review})]},F.id)})}),l.length===0&&J.jsx("p",{className:"text-center text-text-secondary text-sm py-8",children:"No ratings yet"})]}),J.jsx(Jg,{}),J.jsx(Qg,{})]})}function m$(){const{user:s,logout:l,loadUser:p}=sc(),x=ey(),[T,C]=Ge.useState(""),[L,a]=Ge.useState(""),[F,H]=Ge.useState(!1);Ge.useEffect(()=>{s&&(C(s.name||""),a(s.business_name||""))},[s]);const ee=async()=>{H(!0);try{const se={name:T};(s==null?void 0:s.role)==="vendor"&&(se.business_name=L),await ul("/api/me",{method:"PATCH",body:JSON.stringify(se)}),await p(),x.show("Profile updated","success")}catch{x.show("Update failed","error")}finally{H(!1)}};return J.jsxs("div",{className:"h-full bg-bg-primary overflow-y-auto pb-24",children:[J.jsx("div",{className:"px-4 pt-12 pb-4",children:J.jsx("h1",{className:"text-xl font-bold",children:"Settings"})}),J.jsxs("div",{className:"px-4 space-y-4",children:[J.jsxs("div",{className:"glass rounded-xl p-4 space-y-3",children:[J.jsx("h2",{className:"text-sm font-medium text-text-secondary",children:"Profile"}),J.jsxs("div",{children:[J.jsx("label",{className:"text-xs text-text-secondary/60",children:"Name"}),J.jsx("input",{value:T,onChange:se=>C(se.target.value),className:"w-full px-4 py-3 glass-light rounded-xl text-sm text-text-primary placeholder:text-text-secondary/50 outline-none mt-1"})]}),(s==null?void 0:s.role)==="vendor"&&J.jsxs("div",{children:[J.jsx("label",{className:"text-xs text-text-secondary/60",children:"Business Name"}),J.jsx("input",{value:L,onChange:se=>a(se.target.value),className:"w-full px-4 py-3 glass-light rounded-xl text-sm text-text-primary placeholder:text-text-secondary/50 outline-none mt-1"})]}),J.jsxs("div",{children:[J.jsx("label",{className:"text-xs text-text-secondary/60",children:"Phone"}),J.jsx("p",{className:"px-4 py-3 text-sm text-text-secondary",children:(s==null?void 0:s.phone)||"—"})]}),J.jsxs("div",{children:[J.jsx("label",{className:"text-xs text-text-secondary/60",children:"Role"}),J.jsx("p",{className:"px-4 py-3 text-sm text-text-secondary capitalize",children:(s==null?void 0:s.role)||"—"})]}),J.jsx(bi.button,{whileTap:{scale:.97},onClick:ee,disabled:F,className:"w-full py-3 bg-accent-primary rounded-xl text-white font-medium disabled:opacity-40 glow-primary",children:F?"Saving...":"Save Changes"})]}),J.jsxs("div",{className:"glass rounded-xl p-4",children:[J.jsx("h2",{className:"text-sm font-medium text-text-secondary mb-3",children:"Account"}),J.jsx(bi.button,{whileTap:{scale:.97},onClick:l,className:"w-full py-3 glass-light rounded-xl text-red-400 text-sm font-medium",children:"Log Out"})]})]}),J.jsx(Jg,{}),J.jsx(Qg,{}),J.jsx(hE,{})]})}function _$(){const s=navigator.userAgent;return/iphone|ipad|ipod/i.test(s)?"ios":/android/i.test(s)?"android":window.matchMedia("(display-mode: standalone)").matches?null:"desktop"}function gT(){return window.matchMedia("(display-mode: standalone)").matches||navigator.standalone===!0}function g$(){const[s,l]=Ge.useState(null),[p,x]=Ge.useState(!1),[T,C]=Ge.useState(!1),[L,a]=Ge.useState(!1);Ge.useEffect(()=>{if(gT()||sessionStorage.getItem("install_dismissed"))return;const se=Me=>{Me.preventDefault(),l(Me),setTimeout(()=>x(!0),3e3)};window.addEventListener("beforeinstallprompt",se);const ue=navigator.userAgent;return/iphone|ipad|ipod/i.test(ue)&&!gT()&&setTimeout(()=>x(!0),3e3),()=>window.removeEventListener("beforeinstallprompt",se)},[]);const F=()=>{x(!1),a(!0),sessionStorage.setItem("install_dismissed","1")},H=async()=>{if(_$()==="ios"){C(!0);return}if(!s)return;const ue=s;ue.prompt();const{outcome:Me}=await ue.userChoice;Me==="accepted"&&x(!1),l(null)};if(gT()||L)return null;const ee=s!==null||/iphone|ipad|ipod/i.test(navigator.userAgent);return J.jsxs(J.Fragment,{children:[J.jsx(oc,{children:p&&ee&&J.jsxs(bi.div,{initial:{opacity:0,y:16,scale:.9},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.9},transition:{type:"spring",damping:20,stiffness:300},className:"fixed bottom-24 left-4 z-[60] flex items-center",children:[J.jsxs(bi.button,{whileTap:{scale:.96},onClick:H,className:"flex items-center gap-2.5 pl-3 pr-4 py-2.5 rounded-2xl text-white text-sm font-semibold shadow-2xl",style:{background:"linear-gradient(135deg, #6366f1, #4f46e5)",boxShadow:"0 8px 24px rgba(99,102,241,0.45)"},children:[J.jsx("span",{className:"text-base",children:"📲"}),J.jsx("span",{children:"Install App"})]}),J.jsx(bi.button,{whileTap:{scale:.9},onClick:F,className:"ml-2 w-7 h-7 rounded-full flex items-center justify-center text-white/60 hover:text-white transition-colors",style:{background:"rgba(99,102,241,0.2)",border:"1px solid rgba(99,102,241,0.3)"},children:J.jsx("span",{className:"text-xs",children:"✕"})})]})}),J.jsx(oc,{children:T&&J.jsxs(J.Fragment,{children:[J.jsx(bi.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/60 z-[70]",onClick:()=>C(!1)}),J.jsxs(bi.div,{initial:{y:"100%"},animate:{y:0},exit:{y:"100%"},transition:{type:"spring",damping:28,stiffness:220},className:"fixed bottom-0 left-0 right-0 z-[80] rounded-t-3xl p-6 pb-10",style:{background:"rgba(11,15,26,0.98)",backdropFilter:"blur(24px)",border:"1px solid rgba(99,102,241,0.2)"},children:[J.jsx("div",{className:"w-10 h-1 bg-white/20 rounded-full mx-auto mb-6"}),J.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[J.jsx("div",{className:"w-12 h-12 rounded-2xl bg-accent-primary/20 border border-accent-primary/30 flex items-center justify-center text-2xl",children:"🚚"}),J.jsxs("div",{children:[J.jsx("h3",{className:"font-bold text-white",children:"Install Delivara"}),J.jsx("p",{className:"text-xs text-text-secondary",children:"Add to your home screen"})]})]}),J.jsx("div",{className:"space-y-4",children:[{step:"1",icon:"⬆️",text:"Tap the Share button at the bottom of Safari"},{step:"2",icon:"📋",text:'Scroll down and tap "Add to Home Screen"'},{step:"3",icon:"✅",text:'Tap "Add" in the top right corner'}].map(({step:se,icon:ue,text:Me})=>J.jsxs("div",{className:"flex items-start gap-4",children:[J.jsx("div",{className:"w-7 h-7 rounded-full bg-accent-primary/20 border border-accent-primary/30 flex items-center justify-center flex-shrink-0",children:J.jsx("span",{className:"text-xs font-bold text-accent-primary",children:se})}),J.jsxs("div",{className:"flex items-center gap-2 pt-0.5",children:[J.jsx("span",{children:ue}),J.jsx("p",{className:"text-sm text-text-secondary",children:Me})]})]},se))}),J.jsx(bi.button,{whileTap:{scale:.97},onClick:()=>{C(!1),F()},className:"w-full mt-6 py-3 bg-accent-primary rounded-2xl text-white font-semibold text-sm",children:"Got it"})]})]})})]})}function Of({children:s}){return sc(p=>p.token)?J.jsx(J.Fragment,{children:s}):J.jsx(ug,{to:"/login",replace:!0})}function hD({role:s,children:l}){const p=sc(x=>x.user);return!p||p.role!==s?J.jsx(ug,{to:"/",replace:!0}):J.jsx(J.Fragment,{children:l})}function y$(){const s=sc(l=>l.user);return J.jsxs(J.Fragment,{children:[J.jsxs(N5,{children:[J.jsx(sl,{path:"/login",element:J.jsx($G,{})}),J.jsx(sl,{path:"/track/:slug",element:J.jsx(d$,{})}),J.jsx(sl,{path:"/",element:J.jsx(Of,{children:(s==null?void 0:s.role)==="rider"?J.jsx(ug,{to:"/rider",replace:!0}):J.jsx(ug,{to:"/vendor",replace:!0})})}),J.jsx(sl,{path:"/vendor",element:J.jsx(Of,{children:J.jsx(hD,{role:"vendor",children:J.jsx(c$,{})})})}),J.jsx(sl,{path:"/rider",element:J.jsx(Of,{children:J.jsx(hD,{role:"rider",children:J.jsx(h$,{})})})}),J.jsx(sl,{path:"/history",element:J.jsx(Of,{children:J.jsx(f$,{})})}),J.jsx(sl,{path:"/ratings",element:J.jsx(Of,{children:J.jsx(p$,{})})}),J.jsx(sl,{path:"/settings",element:J.jsx(Of,{children:J.jsx(m$,{})})}),J.jsx(sl,{path:"*",element:J.jsx(ug,{to:"/login",replace:!0})})]}),J.jsx(g$,{})]})}"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{});yT.createRoot(document.getElementById("root")).render(J.jsx(OS.StrictMode,{children:J.jsx(j5,{children:J.jsx(y$,{})})}));
